CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/CalibCalorimetry/EcalLaserAnalyzer/interface/ME.h

Go to the documentation of this file.
00001 #ifndef ME_hh
00002 #define ME_hh
00003 
00004 #include <vector>
00005 #include <map>
00006 #include <string>
00007 #include <TString.h>
00008 
00009 class MEChannel;
00010 
00011 class ME
00012 {
00013 public:
00014 
00015   // ECAL regions
00016   enum EcalRegion { iEEM=0, iEBM, iEBP, iEEP, iSizeE };
00017 
00018   enum EcalUnit   { iEcalRegion=0, iSector, iLMRegion, iLMModule, 
00019                     iSuperCrystal, iCrystal, iSizeG };
00020 
00021   enum EcalElec   { iElectronicChannel=iSizeG, 
00022                     iHVChannel, iLVChannel, iSizeU };
00023 
00024   // ECAL region from Laser Monitoring Region
00025   static int ecalRegion( int ilmr );
00026   static bool isBarrel( int ilmr );
00027   
00028   // Laser Monitoring Region from dcc and side
00029   static int lmr( int idcc, int iside );
00030 
00031   // ECAL Region, Sector, dcc and side from Laser Monitoring Region
00032   static void regionAndSector( int ilmr, int& ireg, int& isect, int& idcc, int& iside );
00033 
00034   // dcc and side from the laser monitoring region
00035   static std::pair<int, int> dccAndSide( int ilmr );
00036 
00037   // get trees of channels
00038   static MEChannel* regTree( int ireg );
00039   static MEChannel* lmrTree( int ilmr );
00040   static bool useElectronicNumbering;
00041 
00042   typedef int DCCid;
00043   typedef int LMRid;
00044   typedef int LMMid;
00045   typedef int PNid;
00046   enum PN { iPNA=0, iPNB };
00047   static std::pair<ME::DCCid,ME::PNid> pn( ME::LMRid ilmr, 
00048                                            ME::LMMid ilmmod, 
00049                                            ME::PN    ipn );
00050   static std::pair<ME::DCCid,ME::DCCid>  memFromLmr( ME::LMRid ilmr );
00051   static std::vector<ME::LMMid>        lmmodFromLmr( ME::LMRid ilmr );
00052   static std::vector<ME::DCCid>          memFromDcc( ME::DCCid idcc ); 
00053   static std::vector<ME::LMMid>        lmmodFromDcc( ME::DCCid idcc );
00054   static std::vector< int>             apdRefChannels( ME::LMMid ilmmod , ME::LMRid ilmr);
00055 
00056   // ECAL Region names
00057   static TString region[4];
00058 
00059   // unit names
00060   static TString granularity[iSizeG];
00061 
00062   // Super-Module name from Laser Monitoring Region
00063   static TString smNameFromDcc( int idcc );
00064   static TString smName( int ilmr );
00065 
00066   // Super-Module name from ECAL Region and Super-Module
00067   static TString smName( int ireg, int ism );
00068   
00069   enum RunType    { iLaser=0, iTestPulse, iSizeT };  
00070   enum Color      { iBlue=0, iGreen, iRed, iIRed, iLED1, iLED2, iSizeC };   
00071   enum Gain       { iVfeGain12=1, iVfeGain6, iVfeGain1, iSizeVfeGain };  
00072   enum PNGain     { iPnGain1=0, iPnGain16, iSizePnGain };  
00073 
00074   typedef unsigned long      Time;
00075   typedef unsigned long long TimeStamp;
00076   static const TimeStamp kLowMask;
00077 
00078   typedef struct 
00079   {
00080     std::string rundir; int dcc; int side;  int run; int lb; int events;
00081     TimeStamp ts_beg; TimeStamp ts_end;
00082   } Header;
00083   
00084   typedef struct
00085   {
00086     int type; int wavelength; int power; int filter; int delay; 
00087     int mgpagain; int memgain; 
00088   } Settings;
00089 
00090   // Database tables
00091   enum { iLmfLaserRun,
00092          iLmfLaserConfig,  
00093          iLmfLaserPulse,  
00094          iLmfLaserPrim,   
00095          iLmfLaserPnPrim,
00096          iLmfTestPulseRun,
00097          iLmfTestPulseConfig,  
00098          iLmfTestPulsePrim,   
00099          iLmfTestPulsePnPrim,
00100          iSizeLmf   }; 
00101 
00102   // Laser primitive variables (table LmfLaserPrim)
00103   enum { iAPD_FLAG, iAPD_MEAN, iAPD_RMS, iAPD_M3, 
00104          iAPD_OVER_PNA_MEAN, iAPD_OVER_PNA_RMS, iAPD_OVER_PNA_M3,
00105          iAPD_OVER_PNB_MEAN, iAPD_OVER_PNB_RMS, iAPD_OVER_PNB_M3,
00106          iAPD_OVER_PN_MEAN, iAPD_OVER_PN_RMS, iAPD_OVER_PN_M3,
00107          iAPD_SHAPE_COR, iAPD_ALPHA, iAPD_BETA,
00108          iAPD_TIME_MEAN, iAPD_TIME_RMS, iAPD_TIME_M3, iAPD_TIME_NEVT,
00109          iSizeAPD };
00110   static TString APDPrimVar[ iSizeAPD ];
00111 
00112   // PN primitive variables (table LmfLaserPnPrim)
00113   enum { iPN_FLAG, iPN_MEAN, iPN_RMS, iPN_M3, 
00114          iPNA_OVER_PNB_MEAN, iPNA_OVER_PNB_RMS, iPNA_OVER_PNB_M3,
00115          iSizePN };
00116   static TString PNPrimVar[ iSizePN ];
00117   
00118   // MATAQ Primitive variables (table iLmfLaserPulse)
00119   enum { iMTQ_FIT_METHOD, 
00120          iMTQ_AMPL, iMTQ_TIME, iMTQ_RISE, 
00121          iMTQ_FWHM, iMTQ_FW20, iMTQ_FW80, iMTQ_SLIDING,   
00122          iSizeMTQ };
00123   static TString MTQPrimVar[ iSizeMTQ ];
00124   
00125   // TP-APD Primitive variables (table iLmfTestPulsePrim)
00126   enum { iTPAPD_FLAG, iTPAPD_MEAN, iTPAPD_RMS, iTPAPD_M3, iTPAPD_NEVT,
00127          iSizeTPAPD };
00128   static TString TPAPDPrimVar[ iSizeTPAPD ];
00129 
00130   // TP-PN Primitive variables (table iLmfTestPulsePnPrim)
00131   enum { iTPPN_GAIN, iTPPN_MEAN, iTPPN_RMS, iTPPN_M3, 
00132          iSizeTPPN };
00133   static TString TPPNPrimVar[ iSizeTPPN ];
00134 
00135   // Time functions
00136   enum TUnit { iDay, iHour, iMinute, iSecond, iSizeTU };
00137   static std::vector< Time > timeDiff( Time t1, Time t2, 
00138                                        short int& sign );
00139   static float timeDiff( Time t1, Time t0, int tunit=iHour );
00140   static Time  time( float dt, Time t0, int tunit=iHour );
00141   static Time  time_low( TimeStamp t );
00142   static Time  time_high( TimeStamp t );
00143 
00144   static TString type[iSizeT];
00145   static TString color[iSizeC];
00146 
00147   // get file names
00148   static TString path();               // MusEcal main working directory
00149   static TString primPath(  int lmr );   // where the primitives are
00150   static TString lmdataPath(  int lmr ); // where the LM data are
00151   static TString rootFileName( ME::Header header, ME::Settings settings );
00152   static TString runListName( int lmr, int type, int color );
00153 
00154   virtual ~ME() {}
00155 
00156   static std::vector<MEChannel*> _trees;
00157   //GHM  ClassDef(ME,0) // ME -- MusEcal name space
00158 };
00159 
00160 #endif