Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:05

0001 #ifndef HcalLedAnalysis_H
0002 #define HcalLedAnalysis_H
0003 
0004 #include "FWCore/Framework/interface/Frameworkfwd.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 
0007 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
0008 
0009 #include "TH1F.h"
0010 #include "TF1.h"
0011 #include "TProfile.h"
0012 
0013 #include <memory>
0014 //#include <iostream>
0015 #include <fstream>
0016 #include <vector>
0017 #include <string>
0018 
0019 class HcalPedestal;
0020 class HcalDbService;
0021 class HcalQIEShape;
0022 class HcalQIECoder;
0023 class TFile;
0024 
0025 class HcalLedAnalysis {
0026 public:
0027   /// Constructor
0028   HcalLedAnalysis(const edm::ParameterSet& ps);
0029   /// Destructor
0030   ~HcalLedAnalysis();
0031   void LedSetup(const std::string& m_outputFileROOT);
0032   //void doPeds(const HcalPedestals* fInputPedestals);
0033   void LedSampleAnalysis();
0034   void LedDone();
0035   void processLedEvent(const HBHEDigiCollection& hbhe,
0036                        const HODigiCollection& ho,
0037                        const HFDigiCollection& hf,
0038                        const HcalCalibDigiCollection& calib,
0039                        const HcalDbService& cond);
0040 
0041 protected:
0042 private:
0043   //###
0044   //#  LEDBUNCH is used in map<HcalDetId,map<int, LEDBUNCH > > LEDTRENDS;
0045   //#  For each HcalDetId (channel) a map<int, LEDBUNCH> is associated;
0046   //#  int was originally cap-id and now is just dummy;
0047   //#  LEDBUNCH is a pair - first element is the main
0048   //#  histo with the ADC values and second one is another pair;
0049   //#  this pair contains map<int, std::vector<double> > as a first element;
0050   //#  vector contains some useful variables;
0051   //#  the second element is a vector of histos (pointers);
0052   //#  for the "trend" analysis the main histo (with ADC values) is reset every
0053   //#  m_nevtsample events and info is put in the other part of the LEDBUNCH;
0054   //#  so at the end we have the trends for the variables in concern
0055   //#  which are written in THE vector<TH1F*>;
0056   //###
0057   typedef std::pair<TH1F*, std::pair<std::map<int, std::vector<double> >, std::vector<TH1F*> > > LEDBUNCH;
0058   typedef struct {
0059     TProfile* avePulse;
0060     TH1F* thisPulse;
0061     TH1F* integPulse;
0062   } CALIBBUNCH;
0063   TFile* m_file;
0064   void LedHBHEHists(const HcalDetId& detid,
0065                     const HBHEDataFrame& ledDigi,
0066                     std::map<HcalDetId, std::map<int, LEDBUNCH> >& toolT,
0067                     const HcalDbService& cond);
0068   void LedHOHists(const HcalDetId& detid,
0069                   const HODataFrame& ledDigi,
0070                   std::map<HcalDetId, std::map<int, LEDBUNCH> >& toolT,
0071                   const HcalDbService& cond);
0072   void LedHFHists(const HcalDetId& detid,
0073                   const HFDataFrame& ledDigi,
0074                   std::map<HcalDetId, std::map<int, LEDBUNCH> >& toolT,
0075                   const HcalDbService& cond);
0076   void SetupLEDHists(int id, const HcalDetId detid, std::map<HcalDetId, std::map<int, LEDBUNCH> >& toolT);
0077   void GetLedConst(std::map<HcalDetId, std::map<int, LEDBUNCH> >& toolT);
0078   void LedTrendings(std::map<HcalDetId, std::map<int, LEDBUNCH> >& toolT);
0079   void ProcessCalibEvent(int fiberChan, HcalCalibDetId calibId, const HcalCalibDataFrame& digi);
0080   float BinsizeCorr(float time);
0081 
0082   std::string m_outputFileROOT;
0083   std::string m_outputFileText;
0084   std::string m_outputFileX;
0085   std::ofstream m_outFile;
0086   std::ofstream m_outputFileXML;
0087 
0088   int m_startTS;
0089   int m_endTS;
0090   int m_nevtsample;
0091   int m_hiSaveflag;
0092   bool m_usecalib;
0093   // analysis flag:
0094   //  m_fitflag = 0  - take mean TS value of averaged pulse shape
0095   //              1  - take peak from landau fit to averaged pulse shape
0096   //              2  - take average of mean TS values per event
0097   //                     (preferred for laser & HF LED)
0098   //              3  - take average of peaks from landau fits per event
0099   //                     (preferred for LED)
0100   //              4  - 0+1+2+3 REMOVED in 1_6
0101   int m_fitflag;
0102 
0103   const HcalQIEShape* m_shape;
0104   const HcalQIECoder* m_coder;
0105   const HcalPedestal* m_ped;
0106   struct {
0107     std::map<HcalDetId, std::map<int, LEDBUNCH> > LEDTRENDS;
0108     TH1F* ALLLEDS;
0109     TH1F* LEDRMS;
0110     TH1F* LEDMEAN;
0111     TH1F* CHI2;
0112   } hbHists, hfHists, hoHists;
0113   std::map<HcalDetId, std::map<int, LEDBUNCH> >::iterator _meol;
0114   std::map<HcalDetId, std::map<int, float> > m_AllPedVals;
0115   std::map<HcalDetId, std::map<int, float> >::iterator _meee;
0116 
0117   std::map<HcalCalibDetId, CALIBBUNCH> calibHists;
0118   std::map<HcalCalibDetId, CALIBBUNCH>::iterator _meca;
0119 
0120   //const HcalPedestal* pedCan;
0121   int evt;
0122   int sample;
0123   int evt_curr;
0124   std::vector<bool> state;
0125 };
0126 
0127 #endif