Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-08 08:15:41

0001 #ifndef CalibCalorimetry_EcalLaserAnalyzer_MELaserPrim_h
0002 #define CalibCalorimetry_EcalLaserAnalyzer_MELaserPrim_h
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 #include "ME.h"
0017 
0018 class MELaserPrim {
0019 public:
0020   // Julie's ntuple variables
0021   enum { iAPD, iAPDoPN, iAPDoPNA, iAPDoPNB, iAPDoAPD, iAPDoAPDA, iAPDoAPDB, iTime, iSizeArray_apdpn };
0022   enum { iMean, iRMS, iM3, iNevt, iMin, iMax, iSize_apdpn };
0023   enum { iShapeCor, iSizeExtra_apdpn };
0024   enum { iAlpha, iBeta, iWidth, iChi2, iSize_ab };
0025   enum { iPeak, iSigma, iFit, iAmpl, iTrise, iFwhm, iFw20, iFw80, iSlide, iSize_mtq };
0026 
0027   enum { iGain0, iGain1, iGain2, iGain3, iSize_gain };
0028 
0029   // channel views & logic ids
0030   enum {
0031     iECAL,
0032     iECAL_LMR,
0033     iEB_crystal_number,
0034     iEB_LM_LMM,
0035     iEB_LM_PN,
0036     iEE_crystal_number,
0037     iEE_LM_LMM,
0038     iEE_LM_PN,
0039     iSize_cv
0040   };
0041   static TString channelViewName(int);
0042   static int logicId(int channelView, int id1, int id2 = 0);
0043   static bool getViewIds(int logicId, int &channelView, int &id1, int &id2);
0044 
0045   // constructor
0046   MELaserPrim(ME::Header header, ME::Settings settings, const char *inpath, const char *outfile);
0047 
0048   // destructor
0049   virtual ~MELaserPrim();
0050 
0051   // functions
0052   bool init_ok;
0053   void init();
0054   void bookHistograms();
0055   void fillHistograms();
0056   void writeHistograms();
0057   void print(std::ostream &o);
0058 
0059   // name of tables
0060   static TString lmfLaserName(int table, int type, int color = ME::iBlue);
0061 
0062   // fill histograms from a user application (e.g. DB )
0063   bool setInt(const char *, int ix, int iy, int ival);
0064   bool setVal(const char *, int ix, int iy, float val);
0065 
0066   // fill tree variables from a user application (e.g. DB )
0067   bool setInt(const char *tname, const char *vname, int ival);
0068   bool setVal(const char *tname, const char *vname, float val);
0069 
0070   bool fill(const char *tname);
0071 
0072   // access
0073   Int_t getInt(const char *, int ix, int iy);
0074   Float_t getVal(const char *, int ix, int iy);
0075 
0076   static const TString separator;
0077 
0078 private:
0079   // monitoring region (dcc+side), wavelength, run number and timestamp
0080   int _reg;
0081   bool _isBarrel;
0082   int _lmr;
0083   int _dcc;
0084   int _side;
0085   int _run;
0086   int _lb;
0087   int _events;
0088 
0089   int _type;
0090   int _color;
0091   int _power;
0092   int _filter;
0093   int _delay;
0094 
0095   // GHM
0096   ME::TimeStamp _ts;
0097   ME::TimeStamp _ts_beg;
0098   ME::TimeStamp _ts_end;
0099 
0100   int _mgpagain;
0101   int _memgain;
0102 
0103   // useful
0104   int _ecal_region;
0105   int _sm;
0106   //  std::map< int, std::pair<int, int> > _pn;  // association module -> pair of PN diodes
0107 
0108   TString _sectorStr;
0109   TString _regionStr;
0110   TString _primStr;
0111   TString _pnPrimStr;
0112   TString _pulseStr;
0113   TString _tpPrimStr;
0114   TString _tpPnPrimStr;
0115 
0116   // root files
0117   TFile *apdpn_file;
0118   TFile *ab_file;
0119   TFile *pn_file;
0120   TFile *mtq_file;
0121   TFile *tpapd_file;
0122   TFile *out_file;
0123 
0124   // root trees
0125   TTree *apdpn_tree;
0126   TTree *ab_tree;
0127   TTree *pn_tree;
0128   TTree *mtq_tree;
0129   TTree *tpapd_tree;
0130   TTree *tppn_tree;
0131 
0132   // paths to laser monitoring trees
0133   TString _inpath;
0134 
0135   // root file in output
0136   TString _outfile;
0137 
0138   // index limits (depends on dcc)
0139   int nx;
0140   int ixmin;
0141   int ixmax;
0142   int ny;
0143   int iymin;
0144   int iymax;
0145 
0146   // 2D-histograms
0147   std::map<TString, TH2 *> i_h;  // integer quantities
0148   std::map<TString, TH2 *> f_h;  // floating point quantities
0149 
0150   // trees
0151   std::map<TString, TTree *> t_t;       // map of trees
0152   std::map<TString, int> i_t;           // integer values
0153   std::map<TString, float> f_t;         // float values
0154   std::map<TString, const char *> c_t;  // string values
0155 
0156   // leaves for the APDPN ntuple
0157   Int_t apdpn_dccID;
0158   Int_t apdpn_towerID;
0159   Int_t apdpn_channelID;
0160   Int_t apdpn_moduleID;
0161   //  Double_t        apdpn_gainID;
0162   Int_t apdpn_side;
0163   Int_t apdpn_ieta;
0164   Int_t apdpn_iphi;
0165   Int_t apdpn_flag;
0166   Double_t apdpn_ShapeCor;
0167   Double_t apdpn_apdpn[iSizeArray_apdpn][iSize_apdpn];
0168 
0169   // leaves for the AB ntuple
0170   Int_t ab_dccID;
0171   Int_t ab_towerID;
0172   Int_t ab_channelID;
0173   Int_t ab_ieta;
0174   Int_t ab_iphi;
0175   Int_t ab_flag;
0176   Double_t ab_ab[iSize_ab];
0177 
0178   // leaves for the PN ntuple
0179   Int_t pn_side;
0180   Int_t pn_pnID;
0181   Int_t pn_moduleID;
0182   Double_t pn_PN[iSize_apdpn];
0183   Double_t pn_PNoPN[iSize_apdpn];
0184   Double_t pn_PNoPNA[iSize_apdpn];
0185   Double_t pn_PNoPNB[iSize_apdpn];
0186 
0187   // leaves for the MTQ ntuple
0188   Int_t mtq_side;
0189   Int_t mtq_color;
0190   Double_t mtq_mtq[iSize_mtq];
0191 
0192   // leaves for the TPAPD ntuple
0193   Int_t tpapd_iphi;
0194   Int_t tpapd_ieta;
0195   Int_t tpapd_dccID;
0196   Int_t tpapd_side;
0197   Int_t tpapd_towerID;
0198   Int_t tpapd_channelID;
0199   Int_t tpapd_moduleID;
0200   Int_t tpapd_flag;
0201   Int_t tpapd_gain;
0202   Double_t tpapd_APD[iSize_apdpn];
0203 
0204   // leaves for the TPPN ntuple
0205   Int_t tppn_side;
0206   Int_t tppn_pnID;
0207   Int_t tppn_moduleID;
0208   Int_t tppn_gain;
0209   Double_t tppn_PN[iSize_apdpn];
0210 
0211   // List of branches for APDPN
0212   TBranch *b_apdpn_dccID;      //!
0213   TBranch *b_apdpn_towerID;    //!
0214   TBranch *b_apdpn_channelID;  //!
0215   TBranch *b_apdpn_moduleID;   //!
0216   //  TBranch        *b_apdpn_gainID;   //!
0217   TBranch *b_apdpn_side;                     //!
0218   TBranch *b_apdpn_ieta;                     //!
0219   TBranch *b_apdpn_iphi;                     //!
0220   TBranch *b_apdpn_flag;                     //!
0221   TBranch *b_apdpn_ShapeCor;                 //!
0222   TBranch *b_apdpn_apdpn[iSizeArray_apdpn];  //!
0223 
0224   // List of branches for AB
0225   TBranch *b_ab_dccID;         //!
0226   TBranch *b_ab_towerID;       //!
0227   TBranch *b_ab_channelID;     //!
0228   TBranch *b_ab_ieta;          //!
0229   TBranch *b_ab_iphi;          //!
0230   TBranch *b_ab_flag;          //!
0231   TBranch *b_ab_ab[iSize_ab];  //!
0232 
0233   // List of branches for PN
0234   TBranch *b_pn_side;      //!
0235   TBranch *b_pn_pnID;      //!
0236   TBranch *b_pn_moduleID;  //!
0237   TBranch *b_pn_PN;        //!
0238   TBranch *b_pn_PNoPN;     //!
0239   TBranch *b_pn_PNoPNA;    //!
0240   TBranch *b_pn_PNoPNB;    //!
0241 
0242   // List of branches for MTQ
0243   TBranch *b_mtq_side;            //!
0244   TBranch *b_mtq_color;           //!
0245   TBranch *b_mtq_mtq[iSize_mtq];  //!
0246 
0247   // List of branches for TPAPD
0248   TBranch *b_tpapd_iphi;       //!
0249   TBranch *b_tpapd_ieta;       //!
0250   TBranch *b_tpapd_dccID;      //!
0251   TBranch *b_tpapd_side;       //!
0252   TBranch *b_tpapd_towerID;    //!
0253   TBranch *b_tpapd_channelID;  //!
0254   TBranch *b_tpapd_moduleID;   //!
0255   TBranch *b_tpapd_flag;       //!
0256   TBranch *b_tpapd_gain;       //!
0257   TBranch *b_tpapd_APD;        //!
0258 
0259   // List of branches for TPPN
0260   TBranch *b_tppn_side;      //!
0261   TBranch *b_tppn_pnID;      //!
0262   TBranch *b_tppn_moduleID;  //!
0263   TBranch *b_tppn_gain;      //!
0264   TBranch *b_tppn_PN;        //!
0265 
0266   static const TString apdpn_arrayName[iSizeArray_apdpn];
0267   static const TString apdpn_varName[iSize_apdpn];
0268   static const TString apdpn_varUnit[iSizeArray_apdpn][iSize_apdpn];
0269   static const TString apdpn_extraVarName[iSizeExtra_apdpn];
0270   static const TString apdpn_extraVarUnit[iSizeExtra_apdpn];
0271   static const TString ab_varName[iSize_ab];
0272   static const TString mtq_varName[iSize_mtq];
0273   static const TString mtq_varUnit[iSize_mtq];
0274 
0275   void setHistoStyle(TH1 *);
0276   void refresh();
0277   void addBranchI(const char *t_name, const char *v_name);
0278   void addBranchF(const char *t_name, const char *v_name);
0279   void addBranchC(const char *t_name, const char *v_name);
0280   void bookHistoI(const char *t_name, const char *v_name);
0281   void bookHistoF(const char *t_name, const char *v_name);
0282 
0283   //  ClassDef( MELaserPrim, 0 ) // reads/writes Laser primitives
0284 };
0285 
0286 #endif