00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef PLEXPLANEID_H
00013 #define PLEXPLANEID_H
00014
00015 #include <iosfwd>
00016
00017 #include "Conventions/Detector.h"
00018 #include "Conventions/PlaneView.h"
00019 #include "Conventions/PlaneCoverage.h"
00020
00021 class PlexPlaneId;
00022 std::ostream& operator<<(std::ostream& os, const PlexPlaneId& p);
00023
00024 class PlexPlaneId {
00025
00026 public:
00027
00028 PlexPlaneId();
00029 PlexPlaneId(Detector::Detector_t detector,
00030 UInt_t plane, Bool_t isSteel=kFALSE,
00031 PlaneView::PlaneView_t view=PlaneView::kUnknown,
00032 PlaneCoverage::PlaneCoverage_t cover=PlaneCoverage::kUnknown);
00033
00034 virtual ~PlexPlaneId() { ; }
00035
00036
00037 explicit PlexPlaneId(const UInt_t encoded);
00038 inline UInt_t GetEncoded() const;
00039
00040 const char *AsString(Option_t *option="") const;
00041
00042 Detector::Detector_t GetDetector() const;
00043 UShort_t GetPlane() const;
00044 PlaneCoverage::PlaneCoverage_t GetPlaneCoverage() const;
00045 PlaneView::PlaneView_t GetPlaneView() const;
00046
00047 Bool_t IsSteel() const;
00048 Bool_t IsVetoShield() const;
00049
00050 Int_t GetVetoSection() const;
00051 Int_t GetSuperModule() const;
00052 Bool_t IsNearSpect() const;
00053
00054 virtual Bool_t IsValid() const;
00055 Bool_t IsNull() const;
00056
00057 UShort_t NumberOfStrips() const;
00058
00059 enum EPlaneType {
00060 kScintOrSteel,
00061 kScint,
00062 kSteel
00063 };
00064
00065
00066
00067 PlexPlaneId GetNext(EPlaneType ptype=PlexPlaneId::kScintOrSteel,
00068 PlaneView::PlaneView_t view=PlaneView::kUnknown,
00069 PlaneCoverage::PlaneCoverage_t cover=PlaneCoverage::kUnknown) const;
00070 PlexPlaneId GetPrevious(EPlaneType ptype=PlexPlaneId::kScintOrSteel,
00071 PlaneView::PlaneView_t view=PlaneView::kUnknown,
00072 PlaneCoverage::PlaneCoverage_t cover=PlaneCoverage::kUnknown) const;
00073
00074
00075 PlexPlaneId GetAdjoin(Int_t dir,
00076 EPlaneType ptype=PlexPlaneId::kScintOrSteel,
00077 PlaneView::PlaneView_t view=PlaneView::kUnknown,
00078 PlaneCoverage::PlaneCoverage_t cover=PlaneCoverage::kUnknown) const;
00079 PlexPlaneId GetAdjoinScint(Int_t dir,
00080 PlaneView::PlaneView_t view=PlaneView::kUnknown,
00081 PlaneCoverage::PlaneCoverage_t cover=PlaneCoverage::kUnknown) const;
00082 PlexPlaneId GetAdjoinSteel(Int_t dir,
00083 PlaneView::PlaneView_t view=PlaneView::kUnknown,
00084 PlaneCoverage::PlaneCoverage_t cover=PlaneCoverage::kUnknown) const;
00085
00086 UShort_t GetNumStrips() const;
00087 UShort_t GetNumScintMdls() const;
00088
00089 void Print(Option_t *option="") const;
00090
00091 void SetDetector(Detector::Detector_t detector);
00092 void SetPlane(UInt_t plane,
00093 PlaneView::PlaneView_t view=PlaneView::kUnknown,
00094 PlaneCoverage::PlaneCoverage_t cover=PlaneCoverage::kUnknown);
00095
00096 void SetPlaneCoverage(PlaneCoverage::PlaneCoverage_t coverage);
00097 void SetPlaneView(PlaneView::PlaneView_t view);
00098
00099 void SetIsSteel(Bool_t isSteel);
00100
00101 friend Bool_t operator< (const PlexPlaneId &lhs, const PlexPlaneId &rhs);
00102 friend Bool_t operator<=(const PlexPlaneId &lhs, const PlexPlaneId &rhs);
00103 friend Bool_t operator==(const PlexPlaneId &lhs, const PlexPlaneId &rhs);
00104 friend Bool_t operator!=(const PlexPlaneId &lhs, const PlexPlaneId &rhs);
00105 friend Bool_t operator> (const PlexPlaneId &lhs, const PlexPlaneId &rhs);
00106 friend Bool_t operator>=(const PlexPlaneId &lhs, const PlexPlaneId &rhs);
00107
00108 protected:
00109
00110 UInt_t fEncoded;
00111
00112 private:
00113
00114 PlaneView::PlaneView_t
00115 DefaultPlaneView(Detector::Detector_t detector, UInt_t plane);
00116
00117 PlaneCoverage::PlaneCoverage_t
00118 DefaultPlaneCoverage(Detector::Detector_t detector, UInt_t plane);
00119
00120 public:
00121
00122 inline static UInt_t LastPlaneFarSM0() { return 248; }
00123 inline static UInt_t LastPlaneFarSM1() { return 485; }
00124 inline static UInt_t LastPlaneNearCalor() { return 120; }
00125 inline static UInt_t LastPlaneNearSpect() { return 281; }
00126
00127
00128
00129 static Bool_t fgCalDetCosmicsAView;
00130
00131 ClassDef(PlexPlaneId,4)
00132 };
00133
00134 #ifndef __CINT__
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 const UInt_t defaultPlexPlaneId = 0xffffffff;
00163 const UInt_t defaultPlexStripEndId = defaultPlexPlaneId;
00164 const UInt_t defaultPlexScintMdlId = defaultPlexPlaneId;
00165
00166 const UInt_t maskPlexIdDetector = 0x70000000;
00167 const UInt_t shftPlexIdDetector = 28;
00168 const UInt_t maskPlexIdPlane = 0x0FFC0000;
00169 const UInt_t shftPlexIdPlane = 18;
00170 const UInt_t maskPlexIdIsSteel = 0x00020000;
00171 const UInt_t maskPlexIdView = 0x0001C000;
00172 const UInt_t shftPlexIdView = 14;
00173 const UInt_t bitsPlexIdView = 3;
00174 const UInt_t maskPlexIdCoverage = 0x00003000;
00175 const UInt_t shftPlexIdCoverage = 12;
00176 const UInt_t bitsPlexIdCoverage = 2;
00177 const UInt_t maskPlexIdStrip = 0x00000FF0;
00178 const UInt_t shftPlexIdStrip = 4;
00179 const UInt_t bitsPlexIdStrip = 8;
00180 const UInt_t maskPlexIdScintMdl = maskPlexIdStrip;
00181 const UInt_t shftPlexIdScintMdl = shftPlexIdStrip;
00182 const UInt_t maskPlexIdSubPart = 0x0000000C;
00183 const UInt_t shftPlexIdSubPart = 2;
00184 const UInt_t maskPlexIdEnd = 0x00000003;
00185 const UInt_t shftPlexIdEnd = 0;
00186
00187 const UInt_t zeroPlexIdStripInfo =
00188 ~(maskPlexIdStrip|maskPlexIdSubPart|maskPlexIdEnd);
00189
00190
00191
00192 const UInt_t maskPlexIdIsVetoShield = (512 << shftPlexIdPlane);
00193
00194 const UInt_t shftPlexIdVetoSection = 6;
00195 const UInt_t maskPlexIdIsFar =
00196 (Detector::kFar << shftPlexIdDetector);
00197 const UInt_t setPlexIdVSView = (1 << bitsPlexIdView);
00198 const UInt_t setPlexIdVSCoverage = (1 << bitsPlexIdCoverage);
00199 const UInt_t setPlexIdVSCoverage2 = (setPlexIdVSCoverage << 1);
00200 const UInt_t maskPlexIdVSCoverage2 = 0x80000000;
00201
00202 const UInt_t maskPlexIdIsNear =
00203 (Detector::kNear << shftPlexIdDetector);
00204
00205
00206
00207
00208
00209
00210
00211
00212 inline Bool_t operator< (const PlexPlaneId &lhs, const PlexPlaneId &rhs)
00213 { return (lhs.fEncoded&zeroPlexIdStripInfo) < (rhs.fEncoded&zeroPlexIdStripInfo); }
00214
00215 inline Bool_t operator<=(const PlexPlaneId &lhs, const PlexPlaneId &rhs)
00216 { return (lhs.fEncoded&zeroPlexIdStripInfo) <= (rhs.fEncoded&zeroPlexIdStripInfo); }
00217
00218 inline Bool_t operator==(const PlexPlaneId &lhs, const PlexPlaneId &rhs)
00219 { return (lhs.fEncoded&zeroPlexIdStripInfo) == (rhs.fEncoded&zeroPlexIdStripInfo); }
00220
00221 inline Bool_t operator!=(const PlexPlaneId &lhs, const PlexPlaneId &rhs)
00222 { return (lhs.fEncoded&zeroPlexIdStripInfo) != (rhs.fEncoded&zeroPlexIdStripInfo); }
00223
00224 inline Bool_t operator> (const PlexPlaneId &lhs, const PlexPlaneId &rhs)
00225 { return (lhs.fEncoded&zeroPlexIdStripInfo) > (rhs.fEncoded&zeroPlexIdStripInfo); }
00226
00227 inline Bool_t operator>=(const PlexPlaneId &lhs, const PlexPlaneId &rhs)
00228 { return (lhs.fEncoded&zeroPlexIdStripInfo) >= (rhs.fEncoded&zeroPlexIdStripInfo); }
00229
00230 inline PlexPlaneId::PlexPlaneId() : fEncoded(defaultPlexPlaneId) { ; }
00231 inline PlexPlaneId::PlexPlaneId(const UInt_t encoded) : fEncoded(encoded) { ; }
00232
00233 inline UInt_t PlexPlaneId::GetEncoded() const
00234 { return fEncoded & zeroPlexIdStripInfo; }
00235
00236 inline Detector::Detector_t PlexPlaneId::GetDetector() const
00237 {
00238 Int_t bitField = ( fEncoded & maskPlexIdDetector ) >> shftPlexIdDetector;
00239 return (Detector::Detector_t) bitField;
00240 }
00241
00242 inline UShort_t PlexPlaneId::GetPlane() const
00243 {
00244 return ( fEncoded & maskPlexIdPlane ) >> shftPlexIdPlane;
00245 }
00246
00247 inline Bool_t PlexPlaneId::IsSteel() const
00248 {
00249
00250 return ( fEncoded & maskPlexIdIsSteel );
00251 }
00252
00253 inline Bool_t PlexPlaneId::IsNull() const
00254 {
00255
00256 return ( fEncoded & maskPlexIdPlane ) == maskPlexIdPlane;
00257 }
00258
00259 inline Bool_t PlexPlaneId::IsVetoShield() const
00260 {
00261 if ( IsNull() ) return false;
00262 switch (GetDetector()) {
00263 case Detector::kFar:
00264 return ( fEncoded & maskPlexIdIsVetoShield );
00265 case Detector::kCalDet:
00266 return ( GetPlane() > 60 );
00267 default:
00268 return false;
00269 }
00270 }
00271
00272 inline Int_t PlexPlaneId::GetVetoSection() const
00273 {
00274
00275 if ( ! IsVetoShield() ) return 0;
00276 if ( Detector::kCalDet == GetDetector() ) return 1;
00277 UShort_t plane = GetPlane();
00278 return ( ( ( plane >> shftPlexIdVetoSection ) & 0x03 ) + 1 );
00279 }
00280
00281 inline Int_t PlexPlaneId::GetSuperModule() const
00282 {
00283
00284 if ( ! ( fEncoded & maskPlexIdIsFar ) ) return 0;
00285 UShort_t plane = GetPlane();
00286 if ( plane <= LastPlaneFarSM0() ) return 0;
00287 else if ( plane <= LastPlaneFarSM1() ) return 1;
00288 else return -1;
00289 }
00290
00291 inline Bool_t PlexPlaneId::IsNearSpect() const
00292 {
00293
00294 if ( ! ( fEncoded & maskPlexIdIsNear ) ) return false;
00295 UShort_t plane = GetPlane();
00296 return ( plane > LastPlaneNearCalor() );
00297 }
00298
00299 inline PlaneCoverage::PlaneCoverage_t PlexPlaneId::GetPlaneCoverage() const
00300 {
00301 Int_t bitField = ( fEncoded & maskPlexIdCoverage ) >> shftPlexIdCoverage;
00302 if (GetDetector()==Detector::kFar && IsVetoShield()) {
00303 if ( fEncoded & maskPlexIdVSCoverage2 ) bitField |= setPlexIdVSCoverage2;
00304 else bitField |= setPlexIdVSCoverage;
00305 }
00306 return (PlaneCoverage::PlaneCoverage_t) bitField;
00307 }
00308
00309 inline PlaneView::PlaneView_t PlexPlaneId::GetPlaneView() const
00310 {
00311 Int_t bitField = ( fEncoded & maskPlexIdView ) >> shftPlexIdView;
00312 if (GetDetector()==Detector::kFar && IsVetoShield())
00313 bitField |= setPlexIdVSView;
00314 return (PlaneView::PlaneView_t) bitField;
00315 }
00316
00317 inline void PlexPlaneId::SetDetector(Detector::Detector_t detector)
00318 {
00319 fEncoded = ( fEncoded & ~maskPlexIdDetector ) |
00320 ( ( detector << shftPlexIdDetector ) & maskPlexIdDetector );
00321 }
00322
00323 inline void PlexPlaneId::SetIsSteel(Bool_t isSteel)
00324 {
00325 if (isSteel) fEncoded |= maskPlexIdIsSteel;
00326 else fEncoded &= ~maskPlexIdIsSteel;
00327 }
00328
00329 inline void PlexPlaneId::SetPlaneCoverage(PlaneCoverage::PlaneCoverage_t coverage)
00330 {
00331 fEncoded = ( fEncoded & ~(maskPlexIdCoverage|maskPlexIdVSCoverage2) ) |
00332 ( ( coverage << shftPlexIdCoverage ) & maskPlexIdCoverage );
00333
00334 if ( coverage >= PlaneCoverage::kVScS ) fEncoded |= maskPlexIdVSCoverage2;
00335 }
00336
00337 inline void PlexPlaneId::SetPlaneView(PlaneView::PlaneView_t view)
00338 {
00339 fEncoded = ( fEncoded & ~maskPlexIdView ) |
00340 ( ( view << shftPlexIdView ) & maskPlexIdView );
00341 }
00342
00343 inline PlexPlaneId
00344 PlexPlaneId::GetAdjoin(Int_t dir, EPlaneType ptype,
00345 PlaneView::PlaneView_t view,
00346 PlaneCoverage::PlaneCoverage_t cover) const
00347 {
00348 return (dir<0) ? GetPrevious(ptype,view,cover) : GetNext(ptype,view,cover);
00349 }
00350
00351 inline PlexPlaneId
00352 PlexPlaneId::GetAdjoinScint(Int_t dir,
00353 PlaneView::PlaneView_t view,
00354 PlaneCoverage::PlaneCoverage_t cover) const
00355 { return GetAdjoin(dir,PlexPlaneId::kScint,view,cover); }
00356
00357 inline PlexPlaneId
00358 PlexPlaneId::GetAdjoinSteel(Int_t dir,
00359 PlaneView::PlaneView_t view,
00360 PlaneCoverage::PlaneCoverage_t cover) const
00361 { return GetAdjoin(dir,PlexPlaneId::kSteel,view,cover); }
00362
00363 #endif
00364 #endif // PLEXPLANEID_H