00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #include "Plex/PlexScintMdlId.h"
00013
00014 #include <iostream>
00015 #include <iomanip>
00016 #include <string>
00017
00018 #ifndef CASSERT
00019 #include <cassert>
00020 #define CASSERT
00021 #endif
00022
00023 #include "MessageService/MsgService.h"
00024 CVSID("$Id: PlexScintMdlId.cxx,v 1.13 2005/08/26 18:47:04 rhatcher Exp $");
00025
00026 ClassImp(PlexScintMdlId)
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 class ModulesInPlnInfo {
00039 public:
00040 ModulesInPlnInfo(Detector::Detector_t detector,
00041 PlaneCoverage::PlaneCoverage_t coverage,
00042 PlaneView::PlaneView_t view,
00043 UChar_t nmdl, const UChar_t* mdltype);
00044 ~ModulesInPlnInfo();
00045
00046 UChar_t GetNumStripsInPln() { return fNumStrips; }
00047 UChar_t GetNumScintMdlsInPln() { return fNumMdls; }
00048 UChar_t MdlType(UChar_t mdl);
00049 UChar_t StripToMdl(UChar_t strip);
00050 UChar_t StripToStripInMdl(UChar_t strip);
00051 UChar_t StripToMapperStrip(UChar_t strip);
00052
00053 void BoundsErrorMsg(UChar_t asked, UChar_t last, const char* what="?");
00054
00055 static UChar_t NumStripsInType(UChar_t mdltype);
00056
00057 Detector::Detector_t fDetector;
00058 PlaneCoverage::PlaneCoverage_t fCoverage;
00059 PlaneView::PlaneView_t fView;
00060
00061 UChar_t fNumMdls;
00062 UChar_t fNumStrips;
00063
00064 UChar_t* fMdlType;
00065 UChar_t* fStripsPerMdl;
00066 UChar_t* fFirstStripInMdl;
00067 UChar_t* fLastStripInMdl;
00068 UChar_t* fStripToMdl;
00069 UChar_t* fStripToStripInMdl;
00070 UChar_t* fStripToMapperStrip;
00071 };
00072
00073 ModulesInPlnInfo::ModulesInPlnInfo(Detector::Detector_t detector,
00074 PlaneCoverage::PlaneCoverage_t coverage,
00075 PlaneView::PlaneView_t view,
00076 UChar_t nmdl, const UChar_t* mdltype)
00077 : fDetector(detector), fCoverage(coverage), fView(view),
00078 fNumMdls(nmdl), fNumStrips(0), fMdlType(0),
00079 fStripsPerMdl(0), fFirstStripInMdl(0), fLastStripInMdl(0),
00080 fStripToMdl(0), fStripToStripInMdl(0), fStripToMapperStrip(0)
00081 {
00082
00083 if (fNumMdls==0) return;
00084
00085 fMdlType = new UChar_t [fNumMdls];
00086 fStripsPerMdl = new UChar_t [fNumMdls];
00087 fFirstStripInMdl = new UChar_t [fNumMdls];
00088 fLastStripInMdl = new UChar_t [fNumMdls];
00089
00090
00091 for (UChar_t imdl=0; imdl<fNumMdls; ++imdl) {
00092 UChar_t nstripsInMdl = NumStripsInType(mdltype[imdl]);
00093 fNumStrips += nstripsInMdl;
00094 fMdlType[imdl] = mdltype[imdl];
00095 fStripsPerMdl[imdl] = nstripsInMdl;
00096 fFirstStripInMdl[imdl] = fNumStrips-nstripsInMdl;
00097 fLastStripInMdl[imdl] = fNumStrips-1;
00098 }
00099
00100 fStripToMdl = new UChar_t [fNumStrips];
00101 fStripToStripInMdl = new UChar_t [fNumStrips];
00102 fStripToMapperStrip = new UChar_t [fNumStrips];
00103
00104 for (UChar_t istrip=0; istrip<fNumStrips; ++istrip) {
00105
00106 UChar_t mdl = 0;
00107 while (istrip > fLastStripInMdl[mdl]) ++mdl;
00108
00109 fStripToMdl[istrip] = mdl;
00110 UChar_t stripinmdl = istrip - fFirstStripInMdl[mdl];
00111 UChar_t nstrips = fStripsPerMdl[mdl];
00112 fStripToStripInMdl[istrip] = stripinmdl;
00113
00114
00115
00116 fStripToMapperStrip[istrip] =
00117 ( (isupper(fMdlType[mdl]) ) ? stripinmdl+1 : nstrips-stripinmdl );
00118 }
00119 }
00120
00121 ModulesInPlnInfo::~ModulesInPlnInfo() {
00122
00123 if (fMdlType) delete [] fMdlType;
00124 if (fStripsPerMdl) delete [] fStripsPerMdl;
00125 if (fFirstStripInMdl) delete [] fFirstStripInMdl;
00126 if (fLastStripInMdl) delete [] fLastStripInMdl;
00127 if (fStripToMdl) delete [] fStripToMdl;
00128 if (fStripToStripInMdl) delete [] fStripToStripInMdl;
00129 if (fStripToMapperStrip) delete [] fStripToMapperStrip;
00130 }
00131
00132 UChar_t ModulesInPlnInfo::MdlType(UChar_t mdl)
00133 {
00134 if (mdl<fNumMdls) return fMdlType[mdl];
00135 static int nmsg = 10;
00136 if (--nmsg >= 0) BoundsErrorMsg(mdl,fNumMdls-1,"module");
00137 return '?';
00138 }
00139
00140 UChar_t ModulesInPlnInfo::StripToMdl(UChar_t strip)
00141 {
00142 if (strip<fNumStrips) return fStripToMdl[strip];
00143 static int nmsg = 10;
00144 if (--nmsg >= 0) BoundsErrorMsg(strip,fNumStrips-1,"strip");
00145 return 0xff;
00146 }
00147
00148 UChar_t ModulesInPlnInfo::StripToStripInMdl(UChar_t strip)
00149 {
00150 if (strip<fNumStrips) return fStripToStripInMdl[strip];
00151 static int nmsg = 10;
00152 if (--nmsg >= 0) BoundsErrorMsg(strip,fNumStrips-1,"strip");
00153 return 0xff;
00154 }
00155
00156 UChar_t ModulesInPlnInfo::StripToMapperStrip(UChar_t strip)
00157 {
00158 if (strip<fNumStrips) return fStripToMapperStrip[strip];
00159 static int nmsg = 10;
00160 if (--nmsg >= 0) BoundsErrorMsg(strip,fNumStrips-1,"strip");
00161 return 0xff;
00162 }
00163
00164 void ModulesInPlnInfo::BoundsErrorMsg(UChar_t asked, UChar_t last, const char* what)
00165 {
00166 MSG("Plex",Msg::kWarning)
00167 << what << " " << (int)asked << " in {"
00168 << " " << Detector::AsString(fDetector)
00169 << " " << PlaneCoverage::AsString(fCoverage)
00170 << " " << PlaneView::AsString(fView)
00171 << "} is beyond last " << what << ": "
00172 << (int)last << endl;
00173 }
00174
00175 UChar_t ModulesInPlnInfo::NumStripsInType(UChar_t mdltype)
00176 {
00177
00178
00179
00180
00181
00182
00183 UChar_t mdltypeUpper = toupper(mdltype);
00184
00185 switch (mdltypeUpper) {
00186
00187 case 'A': return 28;
00188 case 'B': return 28;
00189 case 'C': return 20;
00190 case 'D': return 20;
00191 case 'E': return 20;
00192 case 'F': return 20;
00193
00194 case 'G': return 28;
00195 case 'H': return 20;
00196 case 'I': return 20;
00197
00198 case 'J': return 28;
00199 case 'K': return 20;
00200 case 'L': return 16;
00201 case 'M': return 16;
00202 case 'N': return 16;
00203
00204 case 'X': return 24;
00205 default:
00206 MSG("Plex",Msg::kWarning)
00207 << " no module type '" << mdltype
00208 << "' (0x" << hex << setw(2) << (int)mdltype << dec
00209 << ") defined" << endl;
00210 }
00211 return 0;
00212 }
00213
00214
00215
00216
00217
00218 const UChar_t farU[] = { 'a','b','e','f','F','E','B','A' };
00219 const UChar_t farV[] = { 'a','b','c','d','D','C','B','A' };
00220 const UChar_t nearfullU[] = { 'n','m','l','K','J'};
00221 const UChar_t nearfullV[] = { 'j','k','L','M','N'};
00222 const UChar_t nearpartU[] = { 'i','H','G'};
00223 const UChar_t nearpartV[] = { 'g','h','I'};
00224 const UChar_t caldetU[] = { 'X' };
00225 const UChar_t caldetV[] = { 'X' };
00226 const UChar_t caldetB[] = { 'X' };
00227
00228 const UChar_t veto_c[] = { 'c' };
00229 const UChar_t veto_C[] = { 'C' };
00230 const UChar_t veto_e[] = { 'e' };
00231 const UChar_t veto_E[] = { 'E' };
00232
00233
00234
00235 const Detector::Detector_t isfar = Detector::kFar;
00236 const Detector::Detector_t isnear = Detector::kNear;
00237 const Detector::Detector_t iscaldet = Detector::kCalDet;
00238 const PlaneCoverage::PlaneCoverage_t iscomplete = PlaneCoverage::kComplete;
00239 const PlaneCoverage::PlaneCoverage_t isnearfull = PlaneCoverage::kNearFull;
00240 const PlaneCoverage::PlaneCoverage_t isnearpart = PlaneCoverage::kNearPartial;
00241 const PlaneView::PlaneView_t isU = PlaneView::kU;
00242 const PlaneView::PlaneView_t isV = PlaneView::kV;
00243 const PlaneView::PlaneView_t isB = PlaneView::kB;
00244
00245 const PlaneCoverage::PlaneCoverage_t isVScN = PlaneCoverage::kVScN;
00246 const PlaneCoverage::PlaneCoverage_t isVSCN = PlaneCoverage::kVSCN;
00247 const PlaneCoverage::PlaneCoverage_t isVSeS = PlaneCoverage::kVSeS;
00248 const PlaneCoverage::PlaneCoverage_t isVSES = PlaneCoverage::kVSES;
00249 const PlaneCoverage::PlaneCoverage_t isVScS = PlaneCoverage::kVScS;
00250 const PlaneCoverage::PlaneCoverage_t isVSCS = PlaneCoverage::kVSCS;
00251 const PlaneCoverage::PlaneCoverage_t isVSeN = PlaneCoverage::kVSeN;
00252 const PlaneCoverage::PlaneCoverage_t isVSEN = PlaneCoverage::kVSEN;
00253
00254 const PlaneView::PlaneView_t isTopFlat = PlaneView::kVSTopFlat;
00255 const PlaneView::PlaneView_t isTopEastSlant = PlaneView::kVSTopEastSlant;
00256 const PlaneView::PlaneView_t isTopWestSlant = PlaneView::kVSTopWestSlant;
00257 const PlaneView::PlaneView_t isWallOnEdge = PlaneView::kVSWallOnEdge;
00258 const PlaneView::PlaneView_t isWallEastSlant = PlaneView::kVSWallEastSlant;
00259 const PlaneView::PlaneView_t isWallWestSlant = PlaneView::kVSWallWestSlant;
00260
00261
00262
00263
00264 static ModulesInPlnInfo gModulesInPlnInfoList[] = {
00265 ModulesInPlnInfo(isfar,iscomplete,isU,sizeof(farU),farU),
00266 ModulesInPlnInfo(isfar,iscomplete,isV,sizeof(farV),farV),
00267 ModulesInPlnInfo(isnear,isnearfull,isU,sizeof(nearfullU),nearfullU),
00268 ModulesInPlnInfo(isnear,isnearfull,isV,sizeof(nearfullV),nearfullV),
00269 ModulesInPlnInfo(isnear,isnearpart,isU,sizeof(nearpartU),nearpartU),
00270 ModulesInPlnInfo(isnear,isnearpart,isV,sizeof(nearpartV),nearpartV),
00271 ModulesInPlnInfo(iscaldet,iscomplete,isU,sizeof(caldetU),caldetU),
00272 ModulesInPlnInfo(iscaldet,iscomplete,isV,sizeof(caldetV),caldetV),
00273 ModulesInPlnInfo(iscaldet,iscomplete,isB,sizeof(caldetB),caldetB),
00274
00275 ModulesInPlnInfo(isfar,isVScN,isTopFlat ,1,veto_c),
00276 ModulesInPlnInfo(isfar,isVSCN,isTopFlat ,1,veto_C),
00277 ModulesInPlnInfo(isfar,isVSeS,isTopFlat ,1,veto_e),
00278 ModulesInPlnInfo(isfar,isVSES,isTopFlat ,1,veto_E),
00279 ModulesInPlnInfo(isfar,isVSCN,isTopEastSlant ,1,veto_C),
00280 ModulesInPlnInfo(isfar,isVSeS,isTopWestSlant ,1,veto_e),
00281
00282 ModulesInPlnInfo(isfar,isVSeS,isWallOnEdge ,1,veto_e),
00283 ModulesInPlnInfo(isfar,isVSES,isWallOnEdge ,1,veto_E),
00284 ModulesInPlnInfo(isfar,isVSeS,isWallEastSlant,1,veto_e),
00285 ModulesInPlnInfo(isfar,isVSeS,isWallWestSlant,1,veto_e),
00286 ModulesInPlnInfo(isfar,isVSCN,isWallOnEdge ,1,veto_C),
00287
00288 ModulesInPlnInfo(isfar,isVScN,isTopFlat ,1,veto_c),
00289 ModulesInPlnInfo(isfar,isVSCN,isTopFlat ,1,veto_C),
00290 ModulesInPlnInfo(isfar,isVSeS,isTopFlat ,1,veto_e),
00291 ModulesInPlnInfo(isfar,isVSES,isTopFlat ,1,veto_E),
00292 ModulesInPlnInfo(isfar,isVScS,isTopFlat ,1,veto_c),
00293 ModulesInPlnInfo(isfar,isVSCS,isTopFlat ,1,veto_C),
00294 ModulesInPlnInfo(isfar,isVSeN,isTopFlat ,1,veto_e),
00295 ModulesInPlnInfo(isfar,isVSEN,isTopFlat ,1,veto_E),
00296
00297 ModulesInPlnInfo(isfar,isVScN,isTopEastSlant ,1,veto_c),
00298 ModulesInPlnInfo(isfar,isVSCN,isTopEastSlant ,1,veto_C),
00299 ModulesInPlnInfo(isfar,isVSeS,isTopEastSlant ,1,veto_e),
00300 ModulesInPlnInfo(isfar,isVSES,isTopEastSlant ,1,veto_E),
00301 ModulesInPlnInfo(isfar,isVScS,isTopEastSlant ,1,veto_c),
00302 ModulesInPlnInfo(isfar,isVSCS,isTopEastSlant ,1,veto_C),
00303 ModulesInPlnInfo(isfar,isVSeN,isTopEastSlant ,1,veto_e),
00304 ModulesInPlnInfo(isfar,isVSEN,isTopEastSlant ,1,veto_E),
00305
00306 ModulesInPlnInfo(isfar,isVScN,isTopWestSlant ,1,veto_c),
00307 ModulesInPlnInfo(isfar,isVSCN,isTopWestSlant ,1,veto_C),
00308 ModulesInPlnInfo(isfar,isVSeS,isTopWestSlant ,1,veto_e),
00309 ModulesInPlnInfo(isfar,isVSES,isTopWestSlant ,1,veto_E),
00310 ModulesInPlnInfo(isfar,isVScS,isTopWestSlant ,1,veto_c),
00311 ModulesInPlnInfo(isfar,isVSCS,isTopWestSlant ,1,veto_C),
00312 ModulesInPlnInfo(isfar,isVSeN,isTopWestSlant ,1,veto_e),
00313 ModulesInPlnInfo(isfar,isVSEN,isTopWestSlant ,1,veto_E),
00314
00315 ModulesInPlnInfo(isfar,isVScN,isWallOnEdge ,1,veto_c),
00316 ModulesInPlnInfo(isfar,isVSCN,isWallOnEdge ,1,veto_C),
00317 ModulesInPlnInfo(isfar,isVSeS,isWallOnEdge ,1,veto_e),
00318 ModulesInPlnInfo(isfar,isVSES,isWallOnEdge ,1,veto_E),
00319 ModulesInPlnInfo(isfar,isVScS,isWallOnEdge ,1,veto_c),
00320 ModulesInPlnInfo(isfar,isVSCS,isWallOnEdge ,1,veto_C),
00321 ModulesInPlnInfo(isfar,isVSeN,isWallOnEdge ,1,veto_e),
00322 ModulesInPlnInfo(isfar,isVSEN,isWallOnEdge ,1,veto_E),
00323
00324 ModulesInPlnInfo(isfar,isVScN,isWallEastSlant ,1,veto_c),
00325 ModulesInPlnInfo(isfar,isVSCN,isWallEastSlant ,1,veto_C),
00326 ModulesInPlnInfo(isfar,isVSeS,isWallEastSlant ,1,veto_e),
00327 ModulesInPlnInfo(isfar,isVSES,isWallEastSlant ,1,veto_E),
00328 ModulesInPlnInfo(isfar,isVScS,isWallEastSlant ,1,veto_c),
00329 ModulesInPlnInfo(isfar,isVSCS,isWallEastSlant ,1,veto_C),
00330 ModulesInPlnInfo(isfar,isVSeN,isWallEastSlant ,1,veto_e),
00331 ModulesInPlnInfo(isfar,isVSEN,isWallEastSlant ,1,veto_E),
00332
00333 ModulesInPlnInfo(isfar,isVScN,isWallWestSlant ,1,veto_c),
00334 ModulesInPlnInfo(isfar,isVSCN,isWallWestSlant ,1,veto_C),
00335 ModulesInPlnInfo(isfar,isVSeS,isWallWestSlant ,1,veto_e),
00336 ModulesInPlnInfo(isfar,isVSES,isWallWestSlant ,1,veto_E),
00337 ModulesInPlnInfo(isfar,isVScS,isWallWestSlant ,1,veto_c),
00338 ModulesInPlnInfo(isfar,isVSCS,isWallWestSlant ,1,veto_C),
00339 ModulesInPlnInfo(isfar,isVSeN,isWallWestSlant ,1,veto_e),
00340 ModulesInPlnInfo(isfar,isVSEN,isWallWestSlant ,1,veto_E)
00341
00342 };
00343
00344 static int gNumModulesInPlnInfoList =
00345 sizeof(gModulesInPlnInfoList)/sizeof(ModulesInPlnInfo);
00346
00347
00348
00349 ModulesInPlnInfo* getModulesInPlnInfo(const PlexPlaneId& plnid,
00350 const char* whence = "")
00351 {
00352 Detector::Detector_t detector = plnid.GetDetector();
00353 PlaneCoverage::PlaneCoverage_t coverage = plnid.GetPlaneCoverage();
00354 PlaneView::PlaneView_t view = plnid.GetPlaneView();
00355
00356 for (int indx=0; indx<gNumModulesInPlnInfoList; ++indx) {
00357 ModulesInPlnInfo *oneModulesInPlnInfo = gModulesInPlnInfoList+indx;
00358 if (oneModulesInPlnInfo->fDetector == detector &&
00359 oneModulesInPlnInfo->fCoverage == coverage &&
00360 oneModulesInPlnInfo->fView == view )
00361
00362 return oneModulesInPlnInfo;
00363 }
00364
00365 if (!whence) whence = "unknown callee";
00366 MSG("Plex",Msg::kError)
00367 << "no match for pln="
00368 << plnid.GetPlane() << " {"
00369 << " " << Detector::AsString(detector)
00370 << " " << PlaneCoverage::AsString(coverage)
00371 << " " << PlaneView::AsString(view)
00372 << "} used by " << whence
00373 << endl;
00374 return 0;
00375
00376 }
00377
00378
00379 std::ostream& operator<<(std::ostream& os, const PlexScintMdlId& p)
00380 {
00381 os << p.AsString();
00382
00383 return os;
00384 }
00385
00386
00387 PlexScintMdlId::PlexScintMdlId(PlexPlaneId plnid, Int_t module)
00388 : PlexPlaneId(plnid)
00389 {
00390
00391
00392
00393 SetIsSteel(kFALSE);
00394
00395
00396
00397
00398
00399
00400 const UInt_t maskLower =
00401 defaultPlexScintMdlId & (maskPlexIdSubPart|maskPlexIdEnd);
00402 fEncoded |= maskLower;
00403
00404 SetModule(module);
00405
00406 }
00407
00408
00409 PlexScintMdlId::PlexScintMdlId(Detector::Detector_t detector,
00410 Int_t plane, Int_t module,
00411 PlaneView::PlaneView_t view,
00412 PlaneCoverage::PlaneCoverage_t coverage)
00413
00414 : PlexPlaneId(detector,plane,kFALSE,view,coverage)
00415 {
00416
00417
00418 SetModule(module);
00419 }
00420
00421
00422
00423
00424
00425
00426 Bool_t operator< (const PlexScintMdlId &lhs, const PlexScintMdlId &rhs)
00427 { return lhs.fEncoded < rhs.fEncoded; }
00428
00429 Bool_t operator<=(const PlexScintMdlId &lhs, const PlexScintMdlId &rhs)
00430 { return lhs.fEncoded <= rhs.fEncoded; }
00431
00432
00433 Bool_t operator==(const PlexScintMdlId &lhs, const PlexScintMdlId &rhs)
00434 { return lhs.fEncoded == rhs.fEncoded; }
00435
00436
00437 Bool_t operator!=(const PlexScintMdlId &lhs, const PlexScintMdlId &rhs)
00438 { return lhs.fEncoded != rhs.fEncoded; }
00439
00440 Bool_t operator> (const PlexScintMdlId &lhs, const PlexScintMdlId &rhs)
00441 { return lhs.fEncoded > rhs.fEncoded; }
00442
00443 Bool_t operator>=(const PlexScintMdlId &lhs, const PlexScintMdlId &rhs)
00444 { return lhs.fEncoded >= rhs.fEncoded; }
00445
00446
00447 UShort_t PlexScintMdlId::GetModule() const
00448 {
00449 return ( fEncoded & maskPlexIdScintMdl ) >> shftPlexIdScintMdl;
00450 }
00451
00452
00453 void PlexScintMdlId::SetModule(UInt_t module)
00454 {
00455 fEncoded = ( fEncoded & ~maskPlexIdScintMdl ) |
00456 ( ( module << shftPlexIdScintMdl ) & maskPlexIdScintMdl );
00457 }
00458
00459
00460 const char * PlexScintMdlId::AsString(Option_t *option) const
00461 {
00462
00463
00464
00465
00466
00467
00468 const int nbuffers = 8;
00469 static char newstring[nbuffers][27];
00470
00471 static int ibuffer = nbuffers;
00472 ibuffer = (ibuffer+1)%nbuffers;
00473
00474 int mdl = GetModule();
00475
00476 Detector::Detector_t det = GetDetector();
00477 PlaneCoverage::PlaneCoverage_t cover = GetPlaneCoverage();
00478 PlaneView::PlaneView_t view = GetPlaneView();
00479
00480 ModulesInPlnInfo* plninfo = getModulesInPlnInfo(*this,"AsString");
00481 UChar_t mdltype = ((plninfo) ? plninfo->MdlType(mdl) : '?');
00482
00483 switch (option[0]) {
00484 case 's':
00485
00486 sprintf(newstring[ibuffer],"%c%c-%c%c(%1d)",
00487 Detector::AsString(det)[0],
00488 PlaneCoverage::AsString(cover)[0],
00489 mdltype,
00490 PlaneView::AsString(view)[0],
00491 mdl);
00492 break;
00493 default:
00494
00495 sprintf(newstring[ibuffer],"%c%4.4d-%1.1d-%c%c%c",
00496 Detector::AsString(det)[0],
00497 GetPlane(),
00498 mdl,
00499 PlaneCoverage::AsString(cover)[0],
00500 PlaneView::AsString(view)[0],
00501 mdltype);
00502
00503 break;
00504 }
00505
00506 return newstring[ibuffer];
00507 }
00508
00509
00510 UChar_t PlexScintMdlId::GetModuleType() const
00511 {
00512 ModulesInPlnInfo* plninfo = getModulesInPlnInfo(*this,"GetModuleType");
00513 int mdl = GetModule();
00514 UChar_t mdltype = ((plninfo) ? plninfo->MdlType(mdl) : '?');
00515 return mdltype;
00516 }
00517
00518
00519 Int_t PlexScintMdlId::BuildPlnMdlKey() const
00520 {
00521
00522
00523
00524
00525
00526
00527
00528 Int_t plane = GetPlane();
00529 Int_t mdl = GetModule();
00530 Detector::Detector_t det = GetDetector();
00531
00532 Int_t nMdls = 8;
00533 switch (det) {
00534 case Detector::kNear: nMdls = 8; break;
00535 case Detector::kFar: nMdls = 8; break;
00536 case Detector::kCalDet: nMdls = 8; break;
00537 default:
00538 MSG("Plex",Msg::kWarning)
00539 << "PlexScintMdlId " << *this << " is not Near/Far/CalDet" << endl;
00540 }
00541
00542 if (mdl>=nMdls)
00543 MSG("Plex",Msg::kWarning)
00544 << "PlexScintMdlId " << *this
00545 << " exceeds expected nMdls " << nMdls << endl;
00546
00547 Int_t hvalue = plane*nMdls + mdl;
00548
00549 return hvalue;
00550 }
00551
00552
00553 PlexScintMdlId PlexScintMdlId::UnbuildPlnMdlKey(Detector::Detector_t det,
00554 Int_t key)
00555 {
00556
00557
00558
00559 Int_t nMdls = 8;
00560 switch (det) {
00561 case Detector::kNear: nMdls = 8; break;
00562 case Detector::kFar: nMdls = 8; break;
00563 case Detector::kCalDet: nMdls = 8; break;
00564 default:
00565 MSG("Plex",Msg::kWarning)
00566 << "PlexScintMdlId " << Detector::AsString(det)
00567 << "(" << (int)det << ")"
00568 << " is not Near/Far/CalDet" << endl;
00569 }
00570 Int_t plane = key / nMdls;
00571 Int_t mdl = key - (plane*nMdls);
00572 PlexPlaneId plnid(det,plane);
00573 return PlexScintMdlId(plnid,mdl);
00574 }
00575
00576
00577 void PlexScintMdlId::Print(Option_t *option) const
00578 {
00579
00580
00581 printf("%s\n",AsString(option));
00582 }
00583
00584
00585 PlexScintMdlId PlexScintMdlId::StripToScintMdl(const PlexPlaneId& plnid,
00586 Int_t strip)
00587 {
00588
00589
00590 ModulesInPlnInfo* plninfo = getModulesInPlnInfo(plnid,"StripToScintMdl");
00591 if (plninfo) return PlexScintMdlId(plnid,plninfo->StripToMdl(strip));
00592
00593
00594
00595 return PlexScintMdlId();
00596 }
00597
00598
00599 Short_t PlexScintMdlId::GetStripInMdl(const PlexPlaneId& plnid, UInt_t strip)
00600 {
00601
00602
00603 ModulesInPlnInfo* plninfo = getModulesInPlnInfo(plnid,"GetStripInMdl");
00604 if (plninfo) return plninfo->StripToStripInMdl(strip);
00605
00606
00607 return -1;
00608 }
00609
00610
00611 Short_t PlexScintMdlId::GetMapperStripInMdl(const PlexPlaneId& plnid,
00612 UInt_t strip){
00613
00614
00615
00616
00617 ModulesInPlnInfo* plninfo = getModulesInPlnInfo(plnid,"GetMapperStripInMdl"); if (plninfo) return plninfo->StripToMapperStrip(strip);
00618
00619
00620 return -1;
00621 }
00622
00623
00624 UShort_t PlexScintMdlId::GetNumStripsInPln(const PlexPlaneId& plnid)
00625 {
00626
00627
00628 ModulesInPlnInfo* plninfo = getModulesInPlnInfo(plnid,"GetNumStripsInPln");
00629 if (plninfo) return plninfo->GetNumStripsInPln();
00630
00631
00632 return 0;
00633 }
00634
00635
00636 UShort_t PlexScintMdlId::GetNumScintMdlsInPln(const PlexPlaneId& plnid)
00637 {
00638
00639
00640 ModulesInPlnInfo* plninfo = getModulesInPlnInfo(plnid,"GetNumStripsInPln");
00641 if (plninfo) return plninfo->GetNumScintMdlsInPln();
00642
00643
00644 return 0;
00645 }
00646
00647