Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:46:59

0001 #ifndef MusEcal_hh
0002 #define MusEcal_hh
0003 
0004 #include <map>
0005 
0006 //

0007 // MusEcal : Monitoring and Useful Survey of CMS Ecal

0008 //                  Clever Analysis of Laser

0009 //

0010 // Authors  : Gautier Hamel de Monchenault and Julie Malcles, Saclay 

0011 //

0012 #include <TROOT.h>
0013 #include <TH1.h>
0014 #include <TH2.h>
0015 #include <TTree.h>
0016 #include <TFile.h>
0017 
0018 #include "../../interface/ME.h"
0019 
0020 class MERunManager;
0021 class MERun;
0022 class MEChannel;
0023 
0024 // #include "MEIntervals.hh"

0025 // #include "MECorrector2Var.hh"

0026 
0027 class MusEcal
0028 {
0029 
0030 public:
0031 
0032   typedef std::map< ME::Time, MERun* >              RunMap;
0033   typedef std::map< ME::Time, float >               FloatTimeMap;
0034   typedef std::map< ME::Time, bool >                BoolTimeMap;
0035   typedef std::pair< float, bool >              Var;
0036   typedef std::map< ME::Time, Var >                 VarTimeMap;
0037   typedef std::vector<Var>                      VarVec;
0038   typedef std::map< ME::Time, VarVec* >             VarVecTimeMap;
0039   typedef RunMap::iterator             RunIterator;
0040   typedef RunMap::const_iterator  RunConstIterator;
0041 
0042   enum HistCateg  { iH_APD=0, iH_PN, iH_MTQ, iSizeHC };
0043   enum HistType   { iHIST=0, iVS_CHANNEL, iMAP, iSizeHT }; 
0044 
0045   // MusEcal: Laser variables

0046   enum { iNLS, iCorNLS, iAPDoPNA, iAPDoPNB, iAPDoPN, iAPD, iAPDTime, 
0047      iPNA, iPNB, iPNBoPNA, iAlphaBeta, iAlphaBeta_used, iShapeCor, 
0048      iMTQTrise, iMTQAmpl, iMTQFwhm, iMTQFw20, iMTQFw80, iMTQTime,
0049      iSizeLV };  
0050 
0051   // MusEcal: TP variables

0052   enum { iTPAPD_0, iTPAPD_1, iTPAPD_2, iTPPNA_0, iTPPNA_1, iTPPNB_0, iTPPNB_1, iSizeTPV };  
0053 
0054   // Zoom

0055   enum { iOneHundredPercent, iFiftyPercent, iThirtyPercent, iTenPercent,
0056      iFivePercent, iThreePercent, iPercent, 
0057      iFivePerMil, iThreePerMil, iPerMil, iZero };
0058 
0059   static TString historyVarTitle[iSizeLV];
0060   static TString historyVarName[iSizeLV];
0061   static int iGVar[iSizeLV];
0062   static int historyVarZoom[ME::iSizeC][iSizeLV];
0063   static int historyVarColor[iSizeLV];
0064   static TString historyTPVarName[iSizeTPV];
0065   static TString historyTPVarTitle[iSizeTPV];
0066   static int iGTPVar[iSizeTPV];
0067   static int historyTPVarColor[iSizeTPV];
0068   static int historyTPVarZoom[iSizeTPV];
0069   static TString zoomName[ iZero ];
0070   static double zoomRange[ iZero ];
0071   static TString mgrName( int lmr, int type, int color );
0072   static int firstRun;
0073   static int lastRun;
0074 
0075   // contructors/destructor

0076   MusEcal( int type=ME::iLaser, int color=ME::iBlue );
0077   virtual  ~MusEcal();
0078 
0079   // access to run manager for given laser monitoring region

0080   MERunManager* runMgr( int lmr ) { return runMgr(  lmr, _type, _color ); }
0081   MERunManager* runMgr()          { return runMgr( _lmr, _type, _color ); }
0082 
0083   // access to run manager for current laser monitoring region

0084   MERunManager* curMgr()          { return runMgr( _lmr ); }
0085 
0086   // set type (Laser, TestPulse, Pedestal) and color if applicable

0087   virtual void setType( int type, int color=ME::iBlue );
0088 
0089   // set laser monitoring region

0090   virtual void setLMRegion( int lmr );
0091 
0092   // set current time

0093   virtual void setTime( ME::Time );
0094   
0095   // set granularity and channel

0096   virtual void setChannel( MEChannel* );
0097   virtual void setChannel( int ig, int ieta, int iphi, bool useEtaPhi=true );
0098 
0099   // channel navigation

0100   void oneLevelUp();
0101 
0102   // set default time

0103   void setDefaultTime();
0104 
0105   // set run & sequence in run

0106   void setRunAndSequence( unsigned int run, int seq=1 );
0107 
0108   // next sequence

0109   bool nextSequence();
0110 
0111   // set laser monitoring variable

0112   void setVar( int var=MusEcal::iAPD ) { _var = var; _zoom = 0; }
0113   
0114   // dump vector for current channel and variable (ascii)

0115   void dumpVector( int ivar );
0116 
0117   // histograms

0118   void histConfig();
0119   void bookHistograms();
0120   void bookEBAPDHistograms();
0121   void bookEBPNHistograms();
0122   void bookEEAPDHistograms();
0123   void bookEEPNHistograms();
0124   void fillHistograms();
0125   void fillEBGlobalHistograms();
0126   void fillEBLocalHistograms();
0127   void fillEEGlobalHistograms();
0128   void fillEELocalHistograms();
0129   void writeGlobalHistograms();
0130 
0131   // verbosity

0132   static bool verbose;
0133 
0134 protected:
0135 
0136   virtual void refresh();
0137 
0138   // map of run managers

0139   std::map< TString, MERunManager* > _runMgr;
0140 
0141   // access to run managers

0142   MERunManager* runMgr( int lmr, int type, int color );
0143 
0144   // current monitoring region

0145   int _lmr;
0146   bool isBarrel();
0147 
0148   // current run type (Laser, Test Pulse, Pedestal)

0149   int _type; 
0150 
0151   // current color

0152   int _color;
0153 
0154   // current channel or group of channels

0155   MEChannel* _leaf; 
0156 
0157   // current level of detector  

0158   int _ig;         
0159 
0160   // reference time

0161   ME::Time _time;
0162 
0163   // current laser monitoring variable

0164   int _var;
0165   
0166   // current zoom

0167   int _zoom;
0168 
0169   // debug

0170   bool _debug;
0171 
0172   // GUI

0173   bool _isGUI;
0174 
0175   //

0176   // Histograms

0177   //

0178   bool _histoBooked;
0179   bool _ebHistoBooked;
0180   bool _eeHistoBooked;
0181 
0182   TFile* _febgeom;
0183   TH2 *_eb_h, *_eb_loc_h;
0184   std::map< TString, TH1* > _eb_m;
0185   std::map< TString, TH1* > _eb_loc_m;
0186 
0187   TFile* _feegeom;
0188   TH2* _ee_h; 
0189   TH2* _ee_loc_h[10];
0190   std::map< TString, TH1* > _ee_m;
0191   std::map< TString, TH1* > _ee_loc_m;
0192 
0193   // histogam limits

0194   std::map< TString,  int  > _eb_nbin;
0195   std::map< TString, float > _eb_min;
0196   std::map< TString, float > _eb_max;
0197   std::map< TString,  int  > _ee_nbin;
0198   std::map< TString, float > _ee_min;
0199   std::map< TString, float > _ee_max;
0200   int   hist_nbin( TString& );
0201   float hist_min(  TString& );
0202   float hist_max(  TString& );
0203 
0204   TTree* _seq_t;    // sequence rootuple

0205   Int_t _seq_run;   // run number

0206   Int_t _seq_lb;    // lumi block of first LMR

0207   Int_t _seq_tbeg;  // time at beginning of sequence

0208   Int_t _seq_tlmr[92]; // array of times, -1 LMR not present

0209 
0210   TBranch        *b_seq_run;   //!

0211   TBranch        *b_seq_lb;   //!

0212   TBranch        *b_seq_tbeg;   //!

0213   TBranch        *b_seq_tlmr[92];   //!

0214 
0215 //   // validity intervals

0216 //   void setMtqVar( int mtqVar0, int mtqVar1, int mtqLevel );

0217 //   void setPnVar(  int  pnVar0, int  pnVar1, int  pnLevel );

0218 
0219 //   MEIntervals* mtqIntervals( int type );

0220 //   MEKeyInterval* topMtqInterval( int type ) { return mtqIntervals(type)->topInterval(); }

0221 
0222 //   MEIntervals* pnIntervals( int type );

0223 //   MEKeyInterval* topPnInterval( int type ) { return pnIntervals(type)->topInterval(); }

0224 //   std::map< MEKeyInterval*, int >& choices( int type ) { return _choices[type]; }

0225  
0226 //   // create corrections

0227 //   virtual void createCorrectors();

0228   
0229 //   // apply corrections

0230 //   void applyCorrections( MELeaf* leaf, int type, int var0, int var1, 

0231 //           std::vector< MERunKey>& keys, std::vector< MERunKey>& altkeys,

0232 //           std::vector< double >& val, std::vector< double >& cor_val, std::vector< double >& glued_val, std::vector< double >& cor_and_glued_val,

0233 //           std::vector< bool   >&  ok, std::vector< bool   >& cor_ok , std::vector< bool   >& glued_ok,  std::vector< bool   >& cor_and_glued_ok  );

0234 
0235 //   void rabouteVector( MEKeyInterval*, int level, const std::vector< MERunKey >& keys, std::vector< double >& val, std::vector< bool >& ok, 

0236 //            MERunKey curKey=0, unsigned nbuf=2, unsigned nave=10 );

0237 //   void rabouteVector( MEKeyInterval*, int level, MEVarMap& val, MEBoolMap& ok, 

0238 //            MERunKey curKey=0, unsigned nbuf=2, unsigned nave=10 );

0239   
0240 //   void dumpHistory();

0241 
0242 //   // current variable

0243 //   int _var;

0244   
0245 //   // current zoom

0246 //   int _zoom;

0247 
0248 //   // current channel of group of channels

0249 //   bool _newVar;

0250 //   bool _newSelection;

0251 //   bool _newRange;

0252 //   bool _newReference;

0253 //   bool _iSelect;

0254 
0255 //   // validity intervals the Side level, based on MATACQ variables

0256 //   bool _mtqTwoVar;

0257 //   int  _mtqLevel;

0258 //   int  _mtqVar0;

0259 //   int  _mtqVar1;

0260 
0261 //   // validity intervals at the Module level, based on the PNA and PNB signal variations

0262 //   bool _pnTwoVar;

0263 //   int  _pnLevel;

0264 //   int  _pnVar0;

0265 //   int  _pnVar1;

0266 
0267 //   // variable to correct against

0268 //   int _corVar0;

0269 //   int _corVar1;

0270 //   int _corZoom0;

0271 //   int _corZoom1;

0272 //   unsigned _corFitDegree;

0273 //   double _corX0;

0274 //   double _corY0;

0275 //   std::vector< double > _corBeta;

0276  
0277 //   // intervals, as a function of the Leaf (at the Side or Module level)

0278 //   std::map< MELeaf*, MEIntervals* > _intervals[MusEcalHist::iSizeT];

0279 
0280 //   // choice of variables in PN intervals

0281 //   std::map< MEKeyInterval*, int > _choices[MusEcalHist::iSizeT];

0282 
0283   
0284 //   // range range and normalisation

0285 //   bool _normalize;

0286 
0287 //   // reference key

0288 //   MERunKey _refKey[MusEcalHist::iSizeT];

0289 
0290 
0291   
0292 //   virtual void buildMtqIntervals( int type );

0293 //   virtual void buildPnIntervals( int type );

0294 
0295 public:
0296 
0297   // declare to ROOT dictionary

0298   ClassDef(MusEcal,0) // MusEcal -- Monitoring utility for survey of Ecal

0299 };
0300 
0301 #endif
0302