Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

PlexScintMdlId.cxx

Go to the documentation of this file.
00001 
00002 // $Id: PlexScintMdlId.cxx,v 1.13 2005/08/26 18:47:04 rhatcher Exp $
00003 //
00004 // PlexScintMdlId
00005 //
00006 // PlexScintMdlId encapsulates scint module encoding
00007 //
00008 // Author:  R. Hatcher 2002.06.26
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 // This (private) code deals with describing the configuration
00031 // of strips in modules on various plane types.   In particular
00032 // for the near detector there are 4 plane types {full,partial}x{U,V}
00033 // are are quite distinct.  We need this for describing the module
00034 // type (or "shape") and how many strips there are in a module --
00035 // these help us in AsString() and StripToScintMdl().
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;            //[fNumMdls]
00065   UChar_t*                        fStripsPerMdl;       //[fNumMdls]
00066   UChar_t*                        fFirstStripInMdl;    //[fNumMdls]
00067   UChar_t*                        fLastStripInMdl;     //[fNumMdls]
00068   UChar_t*                        fStripToMdl;         //[fNumStrips]
00069   UChar_t*                        fStripToStripInMdl;  //[fNumStrips]
00070   UChar_t*                        fStripToMapperStrip; //[fNumStrips]
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   // if no modules just return
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   // copy types to owned array, translate type to strip count
00090   // calculate total # of strips, last strip in each module
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   // calculate mapping from strip to module
00104   for (UChar_t istrip=0; istrip<fNumStrips; ++istrip) {
00105     // find the right module
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     // upper/lower case tells us about mapper convention
00114     // upper case ordering is same, but starts with 1
00115     // lower case ordering is reversed and ends with 1
00116     fStripToMapperStrip[istrip] = 
00117       ( (isupper(fMdlType[mdl]) ) ? stripinmdl+1 : nstrips-stripinmdl );
00118   }
00119 }
00120 
00121 ModulesInPlnInfo::~ModulesInPlnInfo() { 
00122   // delete any and all owned arrays
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   // module types are characterized by a single char
00178   // though actual shapes may also depend on plane view
00179   // (esp. in the case of the near detector).  For the
00180   // far detector case distinguishes between those installed
00181   // one way or rotated 180deg in the z plane.
00182 
00183   UChar_t mdltypeUpper = toupper(mdltype);
00184 
00185   switch (mdltypeUpper) {
00186     // far detector types
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     // near detector partial types
00194   case 'G': return 28;
00195   case 'H': return 20;
00196   case 'I': return 20;
00197     // near detector full types
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     // caldet types
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 // this is the description of the module type in each kind of plane
00215 // case convention tells us which way this is installed relative to
00216 // what the mapper calls strip 1: lower case means mapper strip "1" 
00217 // is actually at the larger 'tpos' position.
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' };  // this is unchecked
00225 const UChar_t caldetV[] = { 'X' };  // this is unchecked
00226 const UChar_t caldetB[] = { 'X' };  // this is unchecked
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 // some shorthand notations
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 // This structure serves as a mini-database of the configurations
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   // veto shield (only those truly expressed in placement)
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   // veto shield (speculative until installed)
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   // veto shield all possible alternatives (some redundant w/ above)
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 // a utility function for picking the right entry based on
00348 // detector, coverage, and view
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       // this one matches
00362       return oneModulesInPlnInfo;
00363   }
00364   // no matches
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    // Normal ctor from PlaneId + extras
00391 
00392    // ensure that it isn't tagged as "steel" even if plnid was
00393    SetIsSteel(kFALSE);
00394 
00395    // because the "PlexPlaneId" passed in could actually be
00396    // a PlexStripEndId we might have subpart & end bits set
00397    // which we need to reset to the default that PlexPlaneId
00398    // would set them to
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    // Normal ctor from all components
00417 
00418    SetModule(module);
00419 }
00420 
00421 //==========================================================================
00422 // Implementation details 
00423 //==========================================================================
00424 
00425 //inline 
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 //inline 
00433 Bool_t operator==(const PlexScintMdlId &lhs, const PlexScintMdlId &rhs)
00434 { return lhs.fEncoded == rhs.fEncoded; }
00435 
00436 //inline 
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 //inline 
00447 UShort_t PlexScintMdlId::GetModule() const
00448 {
00449    return ( fEncoded & maskPlexIdScintMdl ) >> shftPlexIdScintMdl;
00450 }
00451 
00452 //inline 
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    // Return unpacked StripEndId as a string
00463    // User should copy result because it points to a 
00464    // statically allocated string.
00465    // Internally uses a circular list of buffers to avoid problems
00466    // using AsString multiple times in a cout-like situation.
00467 
00468    const int nbuffers = 8;   // use a circular list of strings
00469    static char newstring[nbuffers][27]; // = "|123456789|1234 VX|123|SE|";
00470       //                                      12345678901234567890123456
00471    static int  ibuffer = nbuffers;
00472    ibuffer = (ibuffer+1)%nbuffers;  // each time move to next buffer
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       // only the part the defines the "shape"
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       // compact rendering identifying whole module (including plane)
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    // compactified plane,module
00522    // packed tightly, not simple bit shifts
00523 
00524    // this isn't quite as tight as it could possibly be for the
00525    // near detector as it doesn't worry about partial vs. full planes
00526    // and has gaps for empty spectrometer planes 
00527 
00528    Int_t plane = GetPlane();
00529    Int_t mdl   = GetModule();
00530    Detector::Detector_t det = GetDetector();
00531 
00532    Int_t nMdls = 8;  // need some default
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    // recover true id object from hashed down version
00557    // needs detector info that was lost in compactification
00558 
00559    Int_t nMdls = 8;  // need some default
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    // Print the (decoded) value
00580 
00581    printf("%s\n",AsString(option));
00582 }
00583 
00584 //_____________________________________________________________________________
00585 PlexScintMdlId PlexScintMdlId::StripToScintMdl(const PlexPlaneId& plnid, 
00586                                                Int_t strip)
00587 {
00588    // given a plane and a strip figure out which module it is in
00589 
00590    ModulesInPlnInfo* plninfo = getModulesInPlnInfo(plnid,"StripToScintMdl");
00591    if (plninfo) return PlexScintMdlId(plnid,plninfo->StripToMdl(strip));
00592 
00593    // should this return a completely bogus scint module id
00594    // or just one with a bogus mdl # set within it?
00595    return PlexScintMdlId();
00596 }
00597 
00598 //_____________________________________________________________________________
00599 Short_t PlexScintMdlId::GetStripInMdl(const PlexPlaneId& plnid, UInt_t strip)
00600 {
00601    // given a plane and a strip figure out which strip in module it is 
00602 
00603    ModulesInPlnInfo* plninfo = getModulesInPlnInfo(plnid,"GetStripInMdl");
00604    if (plninfo) return plninfo->StripToStripInMdl(strip);
00605 
00606    // bogus return if nonsensical
00607    return -1;
00608 }
00609 
00610 //_____________________________________________________________________________
00611 Short_t PlexScintMdlId::GetMapperStripInMdl(const PlexPlaneId& plnid,
00612                                              UInt_t strip){
00613    // Return an strip # within a module using construction based notation
00614    // starts w/ 1 .. flip flops w/ increasing 'tpos' depending on
00615    // installation orientation
00616  
00617    ModulesInPlnInfo* plninfo = getModulesInPlnInfo(plnid,"GetMapperStripInMdl");   if (plninfo) return plninfo->StripToMapperStrip(strip);
00618  
00619    // bogus return if nonsensical
00620    return -1;
00621 }
00622 
00623 //_____________________________________________________________________________
00624 UShort_t PlexScintMdlId::GetNumStripsInPln(const PlexPlaneId& plnid)
00625 {
00626    // use pseudo-database to determine # of strips in plane
00627 
00628    ModulesInPlnInfo* plninfo = getModulesInPlnInfo(plnid,"GetNumStripsInPln");
00629    if (plninfo) return plninfo->GetNumStripsInPln();
00630 
00631    // bogus return if nonsensical
00632    return 0;
00633 }
00634 
00635 //_____________________________________________________________________________
00636 UShort_t PlexScintMdlId::GetNumScintMdlsInPln(const PlexPlaneId& plnid)
00637 {
00638    // use pseudo-database to determine # of strips in plane
00639 
00640    ModulesInPlnInfo* plninfo = getModulesInPlnInfo(plnid,"GetNumStripsInPln");
00641    if (plninfo) return plninfo->GetNumScintMdlsInPln();
00642 
00643    // bogus return if nonsensical
00644    return 0;
00645 }
00646 
00647 //_____________________________________________________________________________

Generated on Mon Feb 15 11:07:23 2010 for loon by  doxygen 1.3.9.1