CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/CalibCalorimetry/HcalAlgos/interface/HcalLedAnalysis.h

Go to the documentation of this file.
00001 #ifndef HcalLedAnalysis_H
00002 #define HcalLedAnalysis_H
00003 
00004 
00005 #include "FWCore/Framework/interface/Frameworkfwd.h"
00006 #include "FWCore/Framework/interface/EDAnalyzer.h"
00007 #include "FWCore/Framework/interface/Event.h"
00008 #include "FWCore/Framework/interface/MakerMacros.h"
00009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00010 #include "FWCore/ServiceRegistry/interface/Service.h"
00011 #include "FWCore/Framework/interface/ESHandle.h"
00012 
00013 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00014 
00015 
00016 #include "TH1F.h"
00017 #include "TF1.h"
00018 #include "TProfile.h"
00019 
00020 #include <memory>
00021 //#include <iostream>
00022 #include <fstream>
00023 #include <vector>
00024 #include <string>
00025 
00026 class HcalPedestal;
00027 class HcalDbService;
00028 class HcalQIEShape;
00029 class HcalQIECoder;
00030 class TFile;
00031 
00032 class HcalLedAnalysis{
00033   
00034 public:
00035   
00037   HcalLedAnalysis(const edm::ParameterSet& ps);  
00039   ~HcalLedAnalysis();
00040   void LedSetup(const std::string& m_outputFileROOT);
00041   //void doPeds(const HcalPedestals* fInputPedestals);
00042   void LedSampleAnalysis();
00043   void LedDone();
00044   void processLedEvent(const HBHEDigiCollection& hbhe,
00045                     const HODigiCollection& ho,
00046                     const HFDigiCollection& hf,
00047                     const HcalCalibDigiCollection calib,
00048                     const HcalDbService& cond);
00049 
00050 protected:
00051   
00052   
00053 private:
00054   //###
00055   //#  LEDBUNCH is used in map<HcalDetId,map<int, LEDBUNCH > > LEDTRENDS;
00056   //#  For each HcalDetId (channel) a map<int, LEDBUNCH> is associated;
00057   //#  int was originally cap-id and now is just dummy;
00058   //#  LEDBUNCH is a pair - first element is the main 
00059   //#  histo with the ADC values and second one is another pair;
00060   //#  this pair contains map<int, std::vector<double> > as a first element;
00061   //#  vector contains some useful variables;
00062   //#  the second element is a vector of histos (pointers);
00063   //#  for the "trend" analysis the main histo (with ADC values) is reset every 
00064   //#  m_nevtsample events and info is put in the other part of the LEDBUNCH;
00065   //#  so at the end we have the trends for the variables in concern
00066   //#  which are written in THE vector<TH1F*>; 
00067   //###  
00068   typedef std::pair<TH1F*,std::pair<std::map<int, std::vector<double> >,std::vector<TH1F*> > > LEDBUNCH;
00069   typedef struct{
00070     TProfile* avePulse;
00071     TH1F* thisPulse;
00072     TH1F* integPulse;
00073   } CALIBBUNCH;
00074   TFile* m_file;
00075   void LedHBHEHists(const HcalDetId& detid, const HBHEDataFrame& ledDigi, std::map<HcalDetId, std::map<int,LEDBUNCH> > &toolT, const HcalDbService& cond);
00076   void LedHOHists(const HcalDetId& detid, const HODataFrame& ledDigi, std::map<HcalDetId, std::map<int,LEDBUNCH> > &toolT, const HcalDbService& cond);
00077   void LedHFHists(const HcalDetId& detid, const HFDataFrame& ledDigi, std::map<HcalDetId, std::map<int,LEDBUNCH> > &toolT, const HcalDbService& cond);
00078   void SetupLEDHists(int id, const HcalDetId detid, std::map<HcalDetId, std::map<int,LEDBUNCH> > &toolT);
00079   void GetLedConst(std::map<HcalDetId,std::map<int, LEDBUNCH > > &toolT);
00080   void LedTrendings(std::map<HcalDetId,std::map<int, LEDBUNCH > > &toolT);
00081   void ProcessCalibEvent(int fiberChan,HcalCalibDetId calibId, const HcalCalibDataFrame digi);
00082   float BinsizeCorr(float time);
00083   
00084   std::string m_outputFileROOT;
00085   std::string m_outputFileText;
00086   std::string m_outputFileX;
00087   std::ofstream m_outFile;
00088   std::ofstream m_logFile;
00089   std::ofstream m_outputFileXML;
00090   char output[100];
00091  
00092   int m_startTS;
00093   int m_endTS;
00094   int m_nevtsample;
00095   int m_hiSaveflag;
00096   bool m_usecalib;
00097 // analysis flag:
00098 //  m_fitflag = 0  - take mean TS value of averaged pulse shape
00099 //              1  - take peak from landau fit to averaged pulse shape
00100 //              2  - take average of mean TS values per event
00101 //                     (preferred for laser & HF LED)
00102 //              3  - take average of peaks from landau fits per event
00103 //                     (preferred for LED)
00104 //              4  - 0+1+2+3 REMOVED in 1_6
00105   int m_fitflag;
00106   
00107   const HcalQIEShape* m_shape;
00108   const HcalQIECoder* m_coder;
00109   const HcalPedestal* m_ped;
00110   struct{
00111     std::map<HcalDetId,std::map<int, LEDBUNCH > > LEDTRENDS;
00112     TH1F* ALLLEDS;
00113     TH1F* LEDRMS;
00114     TH1F* LEDMEAN;
00115     TH1F* CHI2;
00116   } hbHists, hfHists, hoHists;
00117   std::map<HcalDetId,std::map<int, LEDBUNCH > >::iterator _meol;
00118   std::map<HcalDetId,std::map<int,float> > m_AllPedVals;
00119   std::map<HcalDetId,std::map<int,float> >::iterator _meee;
00120 
00121   std::map<HcalCalibDetId,CALIBBUNCH> calibHists;
00122   std::map<HcalCalibDetId,CALIBBUNCH>::iterator _meca;
00123 
00124   //const HcalPedestal* pedCan;
00125   int evt;
00126   int sample;
00127   int evt_curr;
00128   std::vector<bool> state;
00129 
00130 };
00131 
00132 #endif