Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-18 02:24:39

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