CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/CalibCalorimetry/EcalLaserAnalyzer/plugins/EcalLaserAnalyzer.h

Go to the documentation of this file.
00001 // $Id: EcalLaserAnalyzer.h
00002 
00003 #include <memory>
00004 
00005 #include <vector>
00006 #include <map>
00007 
00008 #include <FWCore/Framework/interface/EDAnalyzer.h>
00009 
00010 class TFile;
00011 class TTree;
00012 class TProfile;
00013 class TPNCor;
00014 class TPN;
00015 class TAPD;
00016 class TMom;
00017 class TShapeAnalysis;
00018 class TAPDPulse;
00019 class TPNPulse;
00020 class TMem;
00021 
00022 // Define geometrical constants 
00023 // NOT the same for "EB" and "EE"
00024 //
00025 //     "EB"       "EE"
00026 //
00027 //      0          0
00028 //   1     2    1     2
00029 //   3     4
00030 //   5     6
00031 //   7     8 
00032 //
00033 // 
00034 
00035 // "EB" geometry
00036 #define NCRYSEB    1700  // Number of crystals per EB supermodule
00037 #define NMODEB     9     // Number of EB submodules
00038 #define NPNPERMOD  2     // Number of PN per module
00039 
00040 // "EE" geometry 
00041 #define NCRYSEE    830   // Number of crystals per EE supermodule
00042 #define NMODEE     22     // Number of EE submodules
00043 
00044 #define NSIDES     2     // Number of sides
00045 #define NREFCHAN   2     // Ref number for APDB
00046 
00047 class EcalLaserAnalyzer: public edm::EDAnalyzer{  
00048 
00049  public:
00050   
00051   explicit EcalLaserAnalyzer(const edm::ParameterSet& iConfig);  
00052   ~EcalLaserAnalyzer();
00053   
00054   
00055   virtual void analyze( const edm::Event & e, const  edm::EventSetup& c);
00056   virtual void beginJob();
00057   virtual void endJob();
00058   
00059   void setGeomEB(int etaG, int phiG, int module, int tower, int strip, int xtal, 
00060                  int apdRefTT, int channel, int lmr);
00061   void setGeomEE(int etaG, int phiG,int iX, int iY, int iZ, int module, int tower, 
00062                  int ch , int apdRefTT, int channel, int lmr);
00063 
00064   enum VarCol   { iBlue, iRed, nColor }; 
00065   
00066  private:
00067   
00068   int iEvent;
00069 
00070 
00071   // Framework parameters
00072   
00073   unsigned int  _nsamples;
00074   unsigned int  _presample;
00075   unsigned int  _firstsample;
00076   unsigned int  _lastsample;
00077   unsigned int  _nsamplesPN;
00078   unsigned int  _presamplePN;
00079   unsigned int  _firstsamplePN;
00080   unsigned int  _lastsamplePN;
00081   unsigned int  _timingcutlow;
00082   unsigned int  _timingcuthigh;
00083   unsigned int  _timingquallow;
00084   unsigned int  _timingqualhigh;
00085   double        _ratiomincutlow;
00086   double        _ratiomincuthigh;
00087   double        _ratiomaxcutlow;
00088   double        _presamplecut;
00089   unsigned int  _niter ;
00090   bool          _fitab ;
00091   double        _alpha;
00092   double        _beta;
00093   unsigned int  _nevtmax;
00094   double        _noise;
00095   double        _chi2cut;
00096   std::string   _ecalPart;
00097   bool          _docorpn;
00098   int           _fedid;
00099   bool          _saveallevents;
00100   double        _qualpercent;
00101   int           _debug;
00102 
00103   TAPDPulse *APDPulse;
00104   TPNPulse *PNPulse;
00105   TMem *Mem;
00106   TMom *Delta01;
00107   TMom *Delta12;
00108   
00109   bool doesABTreeExist;
00110   
00111   std::string  resdir_;
00112   std::string  pncorfile_;
00113   std::string  digiCollection_;
00114   std::string  digiPNCollection_;
00115   std::string  digiProducer_;
00116   std::string  eventHeaderCollection_;
00117   std::string  eventHeaderProducer_;
00118 
00119   // Output file names
00120 
00121   std::string  alphafile;
00122   std::string  alphainitfile;
00123   std::string  ADCfile;
00124   std::string  APDfile;
00125   std::string  resfile;
00126 
00127   
00128   TShapeAnalysis * shapana;
00129   unsigned int nevtAB[NCRYSEB];
00130 
00131   //  Define geometrical constants
00132 
00133   unsigned int nCrys;
00134   unsigned int nPNPerMod;
00135   unsigned int nRefChan;
00136   unsigned int nRefTrees;
00137   unsigned int nMod;
00138   unsigned int nSides;
00139 
00140   // Identify run type
00141 
00142   int runType;
00143   int runNum;
00144 
00145   // Identify channel
00146 
00147   int towerID;
00148   int channelID;
00149   int fedID;
00150   int dccID;
00151   int side;
00152   int lightside;
00153   int iZ;
00154 
00155   // Count Laser Events
00156   int laserEvents;
00157 
00158   // PN linearity corrections
00159 
00160   TPNCor *pnCorrector;
00161 
00162   // Temporary root files and trees
00163 
00164   TFile *ADCFile; 
00165   TTree *ADCtrees[NCRYSEB];
00166 
00167   TFile *APDFile; 
00168   TTree *APDtrees[NCRYSEB];
00169   TTree *RefAPDtrees[NREFCHAN][NMODEE];
00170 
00171   TFile *resFile; 
00172   TTree *restrees[nColor];
00173   TTree *respntrees[nColor];
00174 
00175   std::vector<int> colors;
00176   std::map<unsigned int, unsigned int> channelMapEE;
00177    std::vector<int> modules;
00178   std::map <int, unsigned int> apdRefMap[2];
00179 
00180   
00181   // Declaration of leaves types for temporary trees
00182   
00183   int             phi, eta;
00184   int             event ;
00185   int             color ;
00186   double          adc[10];
00187   int             adcG[10];
00188   double          pn0,pn1;
00189   double          pn[50];
00190   int             pnG[50];
00191   double          apdAmpl;
00192   double          apdAmplA;
00193   double          apdAmplB;
00194   double          apdTime;
00195   double          pnAmpl;
00196 
00197   int             eventref;
00198   int             colorref;
00199 
00200   double *adcNoPed;
00201   double *pnNoPed;
00202 
00203   // declare TPN stuff
00204   TPN  *PNFirstAnal[NMODEE][NPNPERMOD][nColor];
00205   TPN  *PNAnal[NMODEE][NPNPERMOD][nColor];
00206 
00207   // declare TAPD stuff
00208   TAPD *APDFirstAnal[NCRYSEB][nColor];
00209   TAPD *APDAnal[NCRYSEB][nColor];
00210 
00211   int IsThereDataADC[NCRYSEB][nColor];
00212 
00213   // Declaration of leaves types for results tree
00214 
00215   int         pnID, moduleID, flag, flagAB;
00216   int         channelIteratorEE;
00217 
00218   double      APD[6], Time[6], PN[6], APDoPN[6], APDoPNA[6], APDoPNB[6],
00219     APDoAPDA[6], APDoAPDB[6], PNoPN[6], PNoPNA[6], PNoPNB[6]; 
00220 
00221   // [0]=mean, [1]=rms, [2]=L3, [3]=nevt, [4]=min, [5]=max 
00222   // flag is 1 if fit if there is data, 0 if there is no data
00223 
00224   int iEta[NCRYSEB],iPhi[NCRYSEB];
00225   unsigned int iModule[NCRYSEB];
00226   int iTowerID[NCRYSEB],iChannelID[NCRYSEB], idccID[NCRYSEB], iside[NCRYSEB];
00227   unsigned int firstChanMod[NMODEE];
00228   unsigned int isFirstChanModFilled[NMODEE];
00229 
00230   // Quality Checks variables and flags
00231   
00232   int nEvtBadGain[NCRYSEB];
00233   int nEvtBadTiming[NCRYSEB];
00234   int nEvtTot[NCRYSEB];
00235 
00236   bool          wasGainOK[NCRYSEB];
00237   bool          wasTimingOK[NCRYSEB];
00238   bool          wasABCalcOK[NCRYSEB];
00239 
00240   bool          isGainOK;
00241   bool          isTimingOK;
00242 
00243 };
00244 
00245