00001 #ifndef HcalPedestalAnalysis_H
00002 #define HcalPedestalAnalysis_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 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00013 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00014
00015 #include "CondFormats/HcalObjects/interface/AllObjects.h"
00016
00017 #include "TH1F.h"
00018 #include "TF1.h"
00019
00020 #include <memory>
00021
00022 #include <fstream>
00023 #include <vector>
00024 #include <string>
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class HcalDbService;
00035 class TFile;
00036
00037 class HcalPedestalAnalysis{
00038
00039 public:
00040
00042 HcalPedestalAnalysis(const edm::ParameterSet& ps);
00044 ~HcalPedestalAnalysis();
00045
00046 void setup(const std::string& m_outputFileROOT);
00047
00048 void SampleAnalysis();
00049
00050 int done(const HcalPedestals* fInputPedestals,
00051 const HcalPedestalWidths* fInputWidths,
00052 HcalPedestals* fOutputPedestals,
00053 HcalPedestalWidths* fOutputWidths);
00054
00055 void processEvent(const HBHEDigiCollection& hbhe,
00056 const HODigiCollection& ho,
00057 const HFDigiCollection& hf,
00058 const HcalDbService& cond);
00059
00060
00061
00062
00063
00064 static int HcalPedVal(int nstat[4], const HcalPedestals* fRefPedestals,
00065 const HcalPedestalWidths* fRefPedestalWidths,
00066 HcalPedestals* fRawPedestals,
00067 HcalPedestalWidths* fRawPedestalWidths,
00068 HcalPedestals* fValPedestals,
00069 HcalPedestalWidths* fValPedestalWidths);
00070
00071 protected:
00072
00073
00074 private:
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 typedef std::pair<TH1F*,std::pair<std::map<int, std::vector<double> >,std::vector<TH1F*> > > PEDBUNCH;
00090
00091 void per2CapsHists(int flag, int id, const HcalDetId detid, const HcalQIESample& qie1, const HcalQIESample& qie2, std::map<HcalDetId, std::map<int,PEDBUNCH> > &toolT,const HcalDbService& cond);
00092
00093 void GetPedConst(std::map<HcalDetId,std::map<int, PEDBUNCH > > &toolT, TH1F* PedMeans, TH1F* PedWidths);
00094
00095 void Trendings(std::map<HcalDetId,std::map<int, PEDBUNCH > > &toolT, TH1F* Chi2, TH1F* CapidAverage, TH1F* CapidChi2);
00096
00097 void AllChanHists(const HcalDetId detid, const HcalQIESample& qie0, const HcalQIESample& qie1, const HcalQIESample& qie2, const HcalQIESample& qie3, const HcalQIESample& qie4, const HcalQIESample& qie5, std::map<HcalDetId, std::map<int,PEDBUNCH> > &toolT);
00098
00099 TFile* m_file;
00100
00101 std::string m_outputFileROOT;
00102 std::string m_outputFileMean;
00103 std::string m_outputFileWidth;
00104 std::ofstream m_logFile;
00105 int m_startTS;
00106 int m_endTS;
00107 int m_nevtsample;
00108 int m_pedsinADC;
00109 int m_hiSaveflag;
00110 int m_pedValflag;
00111 int m_AllPedsOK;
00112
00113 const HcalQIEShape* m_shape;
00114 const HcalQIECoder* m_coder;
00115 struct{
00116 std::map<HcalDetId,std::map<int, PEDBUNCH > > PEDTRENDS;
00117 TH1F* ALLPEDS;
00118 TH1F* PEDRMS;
00119 TH1F* PEDMEAN;
00120 TH1F* CHI2;
00121 TH1F* CAPID_AVERAGE;
00122 TH1F* CAPID_CHI2;
00123 } hbHists, hfHists, hoHists;
00124 std::map<HcalDetId,std::map<int, PEDBUNCH > >::iterator _meot;
00125 const HcalPedestals* fRefPedestals;
00126 const HcalPedestalWidths* fRefPedestalWidths;
00127 HcalPedestals* fRawPedestals;
00128 HcalPedestalWidths* fRawPedestalWidths;
00129 HcalPedestals* fValPedestals;
00130 HcalPedestalWidths* fValPedestalWidths;
00131 int evt;
00132 int sample;
00133 int evt_curr;
00134 float m_stat[4];
00135 std::vector<bool> state;
00136
00137
00138 static const int fitflag=0;
00139 };
00140
00141 #endif