Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:14

0001 #ifndef MELaserPrim_hh
0002 #define MELaserPrim_hh
0003 
0004 #include <iostream>
0005 #include <fstream>
0006 #include <vector>
0007 #include <map>
0008 
0009 #include <TROOT.h>
0010 #include <TChain.h>
0011 #include <TH2I.h>
0012 #include <TH2F.h>
0013 #include <TFile.h>
0014 #include <TString.h>
0015 
0016 class MELaserPrim 
0017 {
0018 
0019 public:
0020 
0021   // enums
0022   enum apdpn_array_num    { iAPD, iAPDoPN, iAPDoPNA, iAPDoPNB, iSizeArray_apdpn }; 
0023   enum apdpn_var_num      { iMean, iRMS, iWbin, iSumPk, iNevt, iSize_apdpn }; 
0024   enum apdpn_extraVar_num { iShapeCor, iSizeExtra_apdpn };
0025   enum ab_var_num         { iAlpha, iBeta, iWidth, iChi2, iSize_ab };
0026   enum mtq_var_num        { iPeak, iSigma, iFit, iAmpl, iTrise, iFwhm, iFw20, iFw80, iSize_mtq };
0027   enum laser_color_num    { iBlue, iGreen, iRed, iIRed, iLed1, iLed2, iSizeColor };  
0028   enum vfe_gain_num       { iVfeGain12=1, iVfeGain6, iVfeGain1, iSizeVfeGain };  
0029   enum pn_gain_num        { iPnGain1, iPnGain16, iSizePnGain };  
0030   enum lmf_laser_num      { iLmfLaserRun,
0031                             iLmfLaserConfig,  
0032                 iLmfLaserPulse,  
0033                 iLmfLaserPrim,   
0034                 iLmfLaserPnPrim,
0035                             iSizeLmfLaser   }; 
0036 
0037   // constructor
0038   MELaserPrim( int dcc, int side, int color, int run, int ts, const char* inpath, const char* outpath ); 
0039 
0040   // destructor
0041   virtual ~MELaserPrim();
0042 
0043   // functions
0044   void init();
0045   void bookHistograms();
0046   void fillHistograms();
0047   void writeHistograms();
0048   void print(std::ostream& o );
0049 
0050   // name of tables
0051   static TString lmfLaserName( int table, int color=iBlue );
0052 
0053   // fill histograms from a user application (e.g. DB )
0054   bool setInt( const char*, int ix, int iy,   int ival );
0055   bool setVal( const char*, int ix, int iy, float  val );
0056 
0057   // fill tree variables from a user application (e.g. DB )
0058   bool setInt( const char* tname, const char* vname, int ival );
0059   bool setVal( const char* tname, const char* vname, float  val );
0060 
0061   bool fill( const char* tname );
0062 
0063   // access
0064   Int_t    getInt( const char*, int ix, int iy );
0065   Float_t  getVal( const char*, int ix, int iy );
0066 
0067 private:
0068 
0069   // monitoring region (dcc+side), wavelength, run number and timestamp
0070   int   _dcc;
0071   int  _side;
0072   int _color;
0073   int   _run;
0074   int    _ts;
0075 
0076   // useful 
0077   int  _ecal_region;
0078   int    _sm;
0079   std::map< int, std::pair<int, int> > _pn;  // association module -> pair of PN diodes
0080 
0081   TString _detStr;
0082   TString _sectorStr;
0083   TString _regionStr;
0084   TString _primStr;
0085   TString _pnPrimStr;
0086   TString _pulseStr;
0087 
0088   // root files
0089   TFile* apdpn_file;
0090   TFile*    ab_file;
0091   TFile*    pn_file;
0092   TFile*   mtq_file;
0093   TFile*   out_file;
0094 
0095   // root trees
0096   TTree* apdpn_tree;
0097   TTree*    ab_tree;
0098   TTree*    pn_tree;
0099   TTree*   mtq_tree;
0100   
0101   // paths to root trees
0102   TString  _inpath;
0103   TString _outpath;
0104 
0105   // index limits (depends on dcc)
0106   int nx;
0107   int ixmin;
0108   int ixmax;
0109   int ny;
0110   int iymin;
0111   int iymax;
0112 
0113   // 2D-histograms
0114   std::map< TString, TH2* > i_h;    // integer quantities
0115   std::map< TString, TH2* > f_h;    // floating point quantities
0116 
0117   // trees
0118   std::map< TString, TTree* >  t_t;  // map of trees
0119   std::map< TString, int >     i_t;  // integer values
0120   std::map< TString, float >   f_t;  // float values
0121   std::map< TString, const char* > c_t;  // string values
0122   
0123   // leaves for the APDPN ntuple
0124   Int_t           apdpn_dccID;
0125   Int_t           apdpn_towerID;
0126   Int_t           apdpn_channelID;
0127   Int_t           apdpn_moduleID;
0128   Double_t        apdpn_gainID;
0129   Int_t           apdpn_ieta;
0130   Int_t           apdpn_iphi;
0131   Int_t           apdpn_flag;
0132   Double_t        apdpn_ShapeCor;
0133   Double_t        apdpn_apdpn[iSizeArray_apdpn][iSize_apdpn];
0134 
0135   // leaves for the AB ntuple
0136   Int_t           ab_dccID;
0137   Int_t           ab_towerID;
0138   Int_t           ab_channelID;
0139   Int_t           ab_ieta;
0140   Int_t           ab_iphi;
0141   Int_t           ab_flag;
0142   Double_t        ab_ab[iSize_ab];
0143 
0144   // leaves for the PN ntuple
0145   Int_t           pn_pnID;
0146   Int_t           pn_moduleID;
0147   Double_t        pn_PN[iSize_apdpn];
0148   Double_t        pn_PNoPN[iSize_apdpn];
0149   Double_t        pn_PNoPNA[iSize_apdpn];
0150   Double_t        pn_PNoPNB[iSize_apdpn];
0151 
0152   // leaves for the MTQ ntuple
0153   Int_t           mtq_event;
0154   Int_t           mtq_laser_color;
0155   Int_t           mtq_status;
0156   Double_t        mtq_mtq[iSize_mtq];
0157 
0158   // List of branches for APDPN
0159   TBranch        *b_apdpn_dccID;   //!
0160   TBranch        *b_apdpn_towerID;   //!
0161   TBranch        *b_apdpn_channelID;   //!
0162   TBranch        *b_apdpn_moduleID;   //!
0163   TBranch        *b_apdpn_gainID;   //!
0164   TBranch        *b_apdpn_ieta;   //!
0165   TBranch        *b_apdpn_iphi;   //!
0166   TBranch        *b_apdpn_flag;   //!
0167   TBranch        *b_apdpn_ShapeCor;   //!
0168   TBranch        *b_apdpn_apdpn[iSizeArray_apdpn];   //!
0169 
0170   // List of branches for AB
0171   TBranch        *b_ab_dccID;   //!
0172   TBranch        *b_ab_towerID;   //!
0173   TBranch        *b_ab_channelID;   //!
0174   TBranch        *b_ab_ieta;   //!
0175   TBranch        *b_ab_iphi;   //!
0176   TBranch        *b_ab_flag;   //!
0177   TBranch        *b_ab_ab[iSize_ab];   //!
0178 
0179   // List of branches for PN
0180   TBranch        *b_pn_pnID;   //!
0181   TBranch        *b_pn_moduleID;   //!
0182   TBranch        *b_pn_PN;   //!
0183   TBranch        *b_pn_PNoPN;   //!
0184   TBranch        *b_pn_PNoPNA;   //!
0185   TBranch        *b_pn_PNoPNB;   //!
0186 
0187   // List of branches for MTQ
0188   TBranch        *b_mtq_event;   //!
0189   TBranch        *b_mtq_laser_color;   //!
0190   TBranch        *b_mtq_status;   //!  
0191   TBranch        *b_mtq_mtq[iSize_mtq]; //!
0192 
0193   static TString apdpn_arrayName[iSizeArray_apdpn];
0194   static TString apdpn_varName[iSize_apdpn];
0195   static TString apdpn_varUnit[iSizeArray_apdpn][iSize_apdpn];
0196   static TString apdpn_extraVarName[iSizeExtra_apdpn];
0197   static TString apdpn_extraVarUnit[iSizeExtra_apdpn];
0198   static TString ab_varName[iSize_ab];
0199   static TString mtq_varName[iSize_mtq];
0200   static TString mtq_varUnit[iSize_mtq];
0201   static TString separator;
0202 
0203   void setHistoStyle( TH1* );
0204   void refresh();
0205   void addBranchI( const char* t_name, const char* v_name );
0206   void addBranchF( const char* t_name, const char* v_name );
0207   void addBranchC( const char* t_name, const char* v_name );
0208   void bookHistoI( const char* t_name, const char* v_name );
0209   void bookHistoF( const char* t_name, const char* v_name );
0210 
0211 };
0212 
0213 #endif