Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:47

0001 #ifndef CalibCalorimetry_EcalLaserAnalyzer_ME_h
0002 #define CalibCalorimetry_EcalLaserAnalyzer_ME_h
0003 
0004 #include <vector>
0005 #include <map>
0006 #include <string>
0007 #include "TString.h"
0008 
0009 class MEChannel;
0010 
0011 class ME {
0012 public:
0013   // ECAL regions
0014   enum EcalRegion { iEEM = 0, iEBM, iEBP, iEEP, iSizeE };
0015 
0016   enum EcalUnit { iEcalRegion = 0, iSector, iLMRegion, iLMModule, iSuperCrystal, iCrystal, iSizeG };
0017 
0018   enum EcalElec { iElectronicChannel = iSizeG, iHVChannel, iLVChannel, iSizeU };
0019 
0020   // ECAL region from Laser Monitoring Region
0021   static int ecalRegion(int ilmr);
0022   static bool isBarrel(int ilmr);
0023 
0024   // Laser Monitoring Region from dcc and side
0025   static int lmr(int idcc, int iside);
0026 
0027   // ECAL Region, Sector, dcc and side from Laser Monitoring Region
0028   static void regionAndSector(int ilmr, int& ireg, int& isect, int& idcc, int& iside);
0029 
0030   // dcc and side from the laser monitoring region
0031   static std::pair<int, int> dccAndSide(int ilmr);
0032 
0033   // get trees of channels
0034   static MEChannel* regTree(int ireg);
0035   static MEChannel* lmrTree(int ilmr);
0036   static const bool useElectronicNumbering;
0037 
0038   typedef int DCCid;
0039   typedef int LMRid;
0040   typedef int LMMid;
0041   typedef int PNid;
0042   enum PN { iPNA = 0, iPNB };
0043   static std::pair<ME::DCCid, ME::PNid> pn(ME::LMRid ilmr, ME::LMMid ilmmod, ME::PN ipn);
0044   static std::pair<ME::DCCid, ME::DCCid> memFromLmr(ME::LMRid ilmr);
0045   static std::vector<ME::LMMid> lmmodFromLmr(ME::LMRid ilmr);
0046   static std::vector<ME::DCCid> memFromDcc(ME::DCCid idcc);
0047   static std::vector<ME::LMMid> lmmodFromDcc(ME::DCCid idcc);
0048   static std::vector<int> apdRefChannels(ME::LMMid ilmmod, ME::LMRid ilmr);
0049 
0050   // ECAL Region names
0051   static const TString region[iSizeE];
0052 
0053   // unit names
0054   static const TString granularity[iSizeG];
0055 
0056   // Super-Module name from Laser Monitoring Region
0057   static TString smNameFromDcc(int idcc);
0058   static TString smName(int ilmr);
0059 
0060   // Super-Module name from ECAL Region and Super-Module
0061   static TString smName(int ireg, int ism);
0062 
0063   enum RunType { iLaser = 0, iTestPulse, iSizeT };
0064   enum Color { iBlue = 0, iGreen, iRed, iIRed, iLED1, iLED2, iSizeC };
0065   enum Gain { iVfeGain12 = 1, iVfeGain6, iVfeGain1, iSizeVfeGain };
0066   enum PNGain { iPnGain1 = 0, iPnGain16, iSizePnGain };
0067 
0068   typedef unsigned long Time;
0069   typedef unsigned long long TimeStamp;
0070   static const TimeStamp kLowMask;
0071 
0072   typedef struct {
0073     std::string rundir;
0074     int dcc;
0075     int side;
0076     int run;
0077     int lb;
0078     int events;
0079     TimeStamp ts_beg;
0080     TimeStamp ts_end;
0081   } Header;
0082 
0083   typedef struct {
0084     int type;
0085     int wavelength;
0086     int power;
0087     int filter;
0088     int delay;
0089     int mgpagain;
0090     int memgain;
0091   } Settings;
0092 
0093   // Database tables
0094   enum {
0095     iLmfLaserRun,
0096     iLmfLaserConfig,
0097     iLmfLaserPulse,
0098     iLmfLaserPrim,
0099     iLmfLaserPnPrim,
0100     iLmfTestPulseRun,
0101     iLmfTestPulseConfig,
0102     iLmfTestPulsePrim,
0103     iLmfTestPulsePnPrim,
0104     iSizeLmf
0105   };
0106 
0107   // Laser primitive variables (table LmfLaserPrim)
0108   enum {
0109     iAPD_FLAG,
0110     iAPD_MEAN,
0111     iAPD_RMS,
0112     iAPD_M3,
0113     iAPD_OVER_PNA_MEAN,
0114     iAPD_OVER_PNA_RMS,
0115     iAPD_OVER_PNA_M3,
0116     iAPD_OVER_PNB_MEAN,
0117     iAPD_OVER_PNB_RMS,
0118     iAPD_OVER_PNB_M3,
0119     iAPD_OVER_PN_MEAN,
0120     iAPD_OVER_PN_RMS,
0121     iAPD_OVER_PN_M3,
0122     iAPD_SHAPE_COR,
0123     iAPD_ALPHA,
0124     iAPD_BETA,
0125     iAPD_TIME_MEAN,
0126     iAPD_TIME_RMS,
0127     iAPD_TIME_M3,
0128     iAPD_TIME_NEVT,
0129     iSizeAPD
0130   };
0131   static const TString APDPrimVar[iSizeAPD];
0132 
0133   // PN primitive variables (table LmfLaserPnPrim)
0134   enum { iPN_FLAG, iPN_MEAN, iPN_RMS, iPN_M3, iPNA_OVER_PNB_MEAN, iPNA_OVER_PNB_RMS, iPNA_OVER_PNB_M3, iSizePN };
0135   static const TString PNPrimVar[iSizePN];
0136 
0137   // MATAQ Primitive variables (table iLmfLaserPulse)
0138   enum { iMTQ_FIT_METHOD, iMTQ_AMPL, iMTQ_TIME, iMTQ_RISE, iMTQ_FWHM, iMTQ_FW20, iMTQ_FW80, iMTQ_SLIDING, iSizeMTQ };
0139   static const TString MTQPrimVar[iSizeMTQ];
0140 
0141   // TP-APD Primitive variables (table iLmfTestPulsePrim)
0142   enum { iTPAPD_FLAG, iTPAPD_MEAN, iTPAPD_RMS, iTPAPD_M3, iTPAPD_NEVT, iSizeTPAPD };
0143   static const TString TPAPDPrimVar[iSizeTPAPD];
0144 
0145   // TP-PN Primitive variables (table iLmfTestPulsePnPrim)
0146   enum { iTPPN_GAIN, iTPPN_MEAN, iTPPN_RMS, iTPPN_M3, iSizeTPPN };
0147   static const TString TPPNPrimVar[iSizeTPPN];
0148 
0149   // Time functions
0150   enum TUnit { iDay, iHour, iMinute, iSecond, iSizeTU };
0151   static std::vector<Time> timeDiff(Time t1, Time t2, short int& sign);
0152   static float timeDiff(Time t1, Time t0, int tunit = iHour);
0153   static Time time(float dt, Time t0, int tunit = iHour);
0154   static Time time_low(TimeStamp t);
0155   static Time time_high(TimeStamp t);
0156 
0157   static const TString type[iSizeT];
0158   static const TString color[iSizeC];
0159 
0160   // get file names
0161   static TString path();               // MusEcal main working directory
0162   static TString primPath(int lmr);    // where the primitives are
0163   static TString lmdataPath(int lmr);  // where the LM data are
0164   static TString rootFileName(ME::Header header, ME::Settings settings);
0165   static TString runListName(int lmr, int type, int color);
0166 
0167   virtual ~ME() {}
0168 
0169   static std::vector<MEChannel*> _trees;
0170   //GHM  ClassDef(ME,0) // ME -- MusEcal name space
0171 };
0172 
0173 #endif