Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef CalibCalorimetry_EcalLaserAnalyzer_EcalLaserAnalyzer_h
0002 #define CalibCalorimetry_EcalLaserAnalyzer_EcalLaserAnalyzer_h
0003 // $Id: EcalLaserAnalyzer.h
0004 
0005 #include <memory>
0006 
0007 #include <vector>
0008 #include <map>
0009 
0010 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0011 
0012 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
0013 #include "DataFormats/EcalRawData/interface/EcalRawDataCollections.h"
0014 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
0015 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
0016 
0017 class TFile;
0018 class TTree;
0019 class TProfile;
0020 class TPNCor;
0021 class TPN;
0022 class TAPD;
0023 class TMom;
0024 class TShapeAnalysis;
0025 class TAPDPulse;
0026 class TPNPulse;
0027 class TMem;
0028 
0029 // Define geometrical constants
0030 // NOT the same for "EB" and "EE"
0031 //
0032 //     "EB"       "EE"
0033 //
0034 //      0          0
0035 //   1     2    1     2
0036 //   3     4
0037 //   5     6
0038 //   7     8
0039 //
0040 //
0041 
0042 // "EB" geometry
0043 #define NCRYSEB 1700  // Number of crystals per EB supermodule
0044 #define NMODEB 9      // Number of EB submodules
0045 #define NPNPERMOD 2   // Number of PN per module
0046 
0047 // "EE" geometry
0048 #define NCRYSEE 830  // Number of crystals per EE supermodule
0049 #define NMODEE 22    // Number of EE submodules
0050 
0051 #define NSIDES 2    // Number of sides
0052 #define NREFCHAN 2  // Ref number for APDB
0053 
0054 class EcalLaserAnalyzer : public edm::one::EDAnalyzer<> {
0055 public:
0056   explicit EcalLaserAnalyzer(const edm::ParameterSet &iConfig);
0057   ~EcalLaserAnalyzer() override;
0058 
0059   void analyze(const edm::Event &e, const edm::EventSetup &c) override;
0060   void beginJob() override;
0061   void endJob() override;
0062 
0063   void setGeomEB(int etaG, int phiG, int module, int tower, int strip, int xtal, int apdRefTT, int channel, int lmr);
0064   void setGeomEE(
0065       int etaG, int phiG, int iX, int iY, int iZ, int module, int tower, int ch, int apdRefTT, int channel, int lmr);
0066 
0067   enum VarCol { iBlue, iRed, nColor };
0068 
0069 private:
0070   int iEvent;
0071 
0072   const std::string eventHeaderCollection_;
0073   const std::string eventHeaderProducer_;
0074   const std::string digiCollection_;
0075   const std::string digiProducer_;
0076   const std::string digiPNCollection_;
0077 
0078   const edm::EDGetTokenT<EcalRawDataCollection> rawDataToken_;
0079   edm::EDGetTokenT<EBDigiCollection> ebDigiToken_;
0080   edm::EDGetTokenT<EEDigiCollection> eeDigiToken_;
0081   const edm::EDGetTokenT<EcalPnDiodeDigiCollection> pnDiodeDigiToken_;
0082   const edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> mappingToken_;
0083 
0084   // Framework parameters
0085 
0086   const unsigned int _nsamples;
0087   unsigned int _presample;
0088   const unsigned int _firstsample;
0089   const unsigned int _lastsample;
0090   const unsigned int _nsamplesPN;
0091   const unsigned int _presamplePN;
0092   const unsigned int _firstsamplePN;
0093   const unsigned int _lastsamplePN;
0094   const unsigned int _timingcutlow;
0095   const unsigned int _timingcuthigh;
0096   const unsigned int _timingquallow;
0097   const unsigned int _timingqualhigh;
0098   const double _ratiomincutlow;
0099   const double _ratiomincuthigh;
0100   const double _ratiomaxcutlow;
0101   const double _presamplecut;
0102   const unsigned int _niter;
0103   bool _fitab;
0104   const double _alpha;
0105   const double _beta;
0106   const unsigned int _nevtmax;
0107   const double _noise;
0108   const double _chi2cut;
0109   const std::string _ecalPart;
0110   const bool _docorpn;
0111   const int _fedid;
0112   const bool _saveallevents;
0113   const double _qualpercent;
0114   const int _debug;
0115 
0116   TAPDPulse *APDPulse;
0117   TPNPulse *PNPulse;
0118   TMem *Mem;
0119   TMom *Delta01;
0120   TMom *Delta12;
0121 
0122   bool doesABTreeExist;
0123 
0124   const std::string resdir_;
0125   const std::string pncorfile_;
0126 
0127   // Output file names
0128 
0129   std::string alphafile;
0130   std::string alphainitfile;
0131   std::string ADCfile;
0132   std::string APDfile;
0133   std::string resfile;
0134 
0135   TShapeAnalysis *shapana;
0136   unsigned int nevtAB[NCRYSEB];
0137 
0138   //  Define geometrical constants
0139 
0140   unsigned int nCrys;
0141   unsigned int nPNPerMod;
0142   unsigned int nRefChan;
0143   unsigned int nRefTrees;
0144   unsigned int nMod;
0145   unsigned int nSides;
0146 
0147   // Identify run type
0148 
0149   int runType;
0150   int runNum;
0151 
0152   // Identify channel
0153 
0154   int towerID;
0155   int channelID;
0156   int fedID;
0157   int dccID;
0158   int side;
0159   int lightside;
0160   int iZ;
0161 
0162   // Count Laser Events
0163   int laserEvents;
0164 
0165   // PN linearity corrections
0166 
0167   TPNCor *pnCorrector;
0168 
0169   // Temporary root files and trees
0170 
0171   TFile *ADCFile;
0172   TTree *ADCtrees[NCRYSEB];
0173 
0174   TFile *APDFile;
0175   TTree *APDtrees[NCRYSEB];
0176   TTree *RefAPDtrees[NREFCHAN][NMODEE];
0177 
0178   TFile *resFile;
0179   TTree *restrees[nColor];
0180   TTree *respntrees[nColor];
0181 
0182   std::vector<int> colors;
0183   std::map<unsigned int, unsigned int> channelMapEE;
0184   std::vector<int> modules;
0185   std::map<int, unsigned int> apdRefMap[2];
0186 
0187   // Declaration of leaves types for temporary trees
0188 
0189   int phi, eta;
0190   int event;
0191   int color;
0192   double adc[10];
0193   int adcG[10];
0194   double pn0, pn1;
0195   double pn[50];
0196   int pnG[50];
0197   double apdAmpl;
0198   double apdAmplA;
0199   double apdAmplB;
0200   double apdTime;
0201   double pnAmpl;
0202 
0203   int eventref;
0204   int colorref;
0205 
0206   double *adcNoPed;
0207   double *pnNoPed;
0208 
0209   // declare TPN stuff
0210   TPN *PNFirstAnal[NMODEE][NPNPERMOD][nColor];
0211   TPN *PNAnal[NMODEE][NPNPERMOD][nColor];
0212 
0213   // declare TAPD stuff
0214   TAPD *APDFirstAnal[NCRYSEB][nColor];
0215   TAPD *APDAnal[NCRYSEB][nColor];
0216 
0217   int IsThereDataADC[NCRYSEB][nColor];
0218 
0219   // Declaration of leaves types for results tree
0220 
0221   int pnID, moduleID, flag, flagAB;
0222   int channelIteratorEE;
0223 
0224   double APD[6], Time[6], PN[6], APDoPN[6], APDoPNA[6], APDoPNB[6], APDoAPDA[6], APDoAPDB[6], PNoPN[6], PNoPNA[6],
0225       PNoPNB[6];
0226 
0227   // [0]=mean, [1]=rms, [2]=L3, [3]=nevt, [4]=min, [5]=max
0228   // flag is 1 if fit if there is data, 0 if there is no data
0229 
0230   int iEta[NCRYSEB], iPhi[NCRYSEB];
0231   unsigned int iModule[NCRYSEB];
0232   int iTowerID[NCRYSEB], iChannelID[NCRYSEB], idccID[NCRYSEB], iside[NCRYSEB];
0233   unsigned int firstChanMod[NMODEE];
0234   unsigned int isFirstChanModFilled[NMODEE];
0235 
0236   // Quality Checks variables and flags
0237 
0238   int nEvtBadGain[NCRYSEB];
0239   int nEvtBadTiming[NCRYSEB];
0240   int nEvtTot[NCRYSEB];
0241 
0242   bool wasGainOK[NCRYSEB];
0243   bool wasTimingOK[NCRYSEB];
0244   bool wasABCalcOK[NCRYSEB];
0245 
0246   bool isGainOK;
0247   bool isTimingOK;
0248 };
0249 #endif