CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTMonPhotonClient.cc
Go to the documentation of this file.
5 
11 
12 using namespace edm;
13 
15 {
16 
17  LogDebug("HLTMonPhotonClient") << "constructor...." ;
18 
19  logFile_.open("HLTMonPhotonClient.log");
20 
21  dbe = NULL;
22  if (iConfig.getUntrackedParameter < bool > ("DQMStore", false)) {
23  dbe = Service < DQMStore > ().operator->();
24  dbe->setVerbose(0);
25  }
26 
27  outputFile_ =
28  iConfig.getUntrackedParameter <std::string>("outputFile", "");
29  if (outputFile_.size() != 0) {
30  LogInfo("HLTMonPhotonClient") << "Photon Trigger Monitoring histograms will be saved to "
31  << outputFile_ ;
32  }
33  else {
34  outputFile_ = "PhotonDQM.root";
35  }
36 
37  bool disable =
38  iConfig.getUntrackedParameter < bool > ("disableROOToutput", false);
39  if (disable) {
40  outputFile_ = "";
41  }
42 
43  sourcetag_=iConfig.getParameter<edm::InputTag>("SourceTag");
44 
45  theHLTCollectionLabels = iConfig.getParameter<std::vector<edm::InputTag> >("theHLTCollectionLabels");
46 
47  dirname_="HLT/HLTMonPhoton/"+iConfig.getParameter<std::string>("@module_label");
48  sourcedirname_="HLT/HLTMonPhoton/"+sourcetag_.label();
49 
50  if (dbe != NULL) {
51  dbe->setCurrentFolder(dirname_);
52  }
53 
54 }
55 
56 
58 {
59 
60  // do anything here that needs to be done at desctruction time
61  // (e.g. close files, deallocate resources etc.)
62 
63 }
64 
65 
66 //
67 // member functions
68 //
69 
70 // ------------ method called to for each event ------------
71 void
73 {
74  TH1F* refhisto = eventCounter->getTH1F();
75  if(refhisto->GetBinContent(1) != 0){
76  // relFilterEff->setBinContent(6,refhisto->GetBinContent(5)/refhisto->GetBinContent(2));
77  // cumFilterEff->setBinContent(5,refhisto->GetBinContent(5)/refhisto->GetBinContent(1));
78  cumFilterEff->setBinContent(4,refhisto->GetBinContent(4)/refhisto->GetBinContent(1));
79  cumFilterEff->setBinContent(3,refhisto->GetBinContent(3)/refhisto->GetBinContent(1));
80  cumFilterEff->setBinContent(2,refhisto->GetBinContent(2)/refhisto->GetBinContent(1));
81  }else{
82  relFilterEff->setBinContent(6,0);
83  cumFilterEff->setBinContent(5,0);
84  cumFilterEff->setBinContent(4,0);
85  cumFilterEff->setBinContent(3,0);
86  cumFilterEff->setBinContent(2,0);
87  }
88  for(int i = 0; i<4; i++){
89  if(refhisto->GetBinContent(4-i) != 0){
90  relFilterEff->setBinContent(5-i,refhisto->GetBinContent(5-i)/refhisto->GetBinContent(4-i));
91  }else{
92  relFilterEff->setBinContent(5-i,0);
93  }
94  }
95  if(refhisto->GetBinContent(1) != 0){
96  relFilterEff->setBinContent(1,refhisto->GetBinContent(1)/refhisto->GetBinContent(1));
97  cumFilterEff->setBinContent(2,refhisto->GetBinContent(2)/refhisto->GetBinContent(1));
98  cumFilterEff->setBinContent(1,refhisto->GetBinContent(1)/refhisto->GetBinContent(1));
99  }else{
100  relFilterEff->setBinContent(1,0);
101  cumFilterEff->setBinContent(2,0);
102  cumFilterEff->setBinContent(1,0);
103  }
104 
105  TH1F* num;
106  TH1F* denom;
107 
108  for(int i=0; i<3; i++){
109  denom = pixelhistosEt[0]->getTH1F();
110  num = pixelhistosEt[i+1]->getTH1F();
111  for(int j=1; j <= pixelhistosEtOut[i]->getNbinsX();j++ ){
112  if(denom->GetBinContent(j)!=0){
113  pixelhistosEtOut[i]->setBinContent(j,num->GetBinContent(j)/denom->GetBinContent(j));
114  }
115  else{
116  pixelhistosEtOut[i]->setBinContent(j,0.);
117  }
118  }
119  denom = pixelhistosEta[0]->getTH1F();
120  num = pixelhistosEta[i+1]->getTH1F();
121  for(int j=1; j <= pixelhistosEtaOut[i]->getNbinsX();j++ ){
122  if(denom->GetBinContent(j)!=0)
123  pixelhistosEtaOut[i]->setBinContent(j,num->GetBinContent(j)/denom->GetBinContent(j));
124  else
125  pixelhistosEtaOut[i]->setBinContent(j,0.);
126  }
127  denom = pixelhistosPhi[0]->getTH1F();
128  num = pixelhistosPhi[i+1]->getTH1F();
129  for(int j=1; j <= pixelhistosPhiOut[i]->getNbinsX();j++ ){
130  if(denom->GetBinContent(j)!=0)
131  pixelhistosPhiOut[i]->setBinContent(j,num->GetBinContent(j)/denom->GetBinContent(j));
132  else
133  pixelhistosPhiOut[i]->setBinContent(j,0.);
134  }
135  }
136 
137  denom = pixelhistosEt[0]->getTH1F();
138  num = pixelhistosEt[3]->getTH1F();
139  for(int j=1; j <= pixelhistosEtOut[3]->getNbinsX();j++ ){
140  if(denom->GetBinContent(j)!=0){
141  pixelhistosEtOut[3]->setBinContent(j,num->GetBinContent(j)/denom->GetBinContent(j));
142  }
143  else{
144  pixelhistosEtOut[3]->setBinContent(j,0.);
145  }
146  }
147 
148  denom = pixelhistosEta[0]->getTH1F();
149  num = pixelhistosEta[3]->getTH1F();
150  for(int j=1; j <= pixelhistosEtaOut[3]->getNbinsX();j++ ){
151  if(denom->GetBinContent(j)!=0){
152  pixelhistosEtaOut[3]->setBinContent(j,num->GetBinContent(j)/denom->GetBinContent(j));
153  }
154  else{
155  pixelhistosEtaOut[3]->setBinContent(j,0.);
156  }
157  }
158 
159  denom = pixelhistosPhi[0]->getTH1F();
160  num = pixelhistosPhi[3]->getTH1F();
161  for(int j=1; j <= pixelhistosPhiOut[3]->getNbinsX();j++ ){
162  if(denom->GetBinContent(j)!=0){
163  pixelhistosPhiOut[3]->setBinContent(j,num->GetBinContent(j)/denom->GetBinContent(j));
164  }
165  else{
166  pixelhistosPhiOut[3]->setBinContent(j,0.);
167  }
168  }
169 
170 }
171 
172 
173 // ------------ method called once each job just before starting event loop ------------
174 void
176 {
177 
178  DQMStore *dbe = 0;
179  dbe = Service < DQMStore > ().operator->();
180 
181  if (dbe) {
182  dbe->setCurrentFolder(dirname_);
183  dbe->rmdir(dirname_);
184  }
185 
186  if (dbe) {
187  dbe->setCurrentFolder(dirname_);
188 
189  std::string tmpname = "";
190 
191  for(int i = 0; i<4; i++){
192  LogInfo("HLTMonPhotonClient") << "loop iteration: "<<i ;
193  tmpname = sourcedirname_ + "/" + theHLTCollectionLabels[i].label() + " Eta Dist";
194  pixelhistosEta[i]=dbe->get(tmpname);
195  tmpname = sourcedirname_ + "/" + theHLTCollectionLabels[i].label() + " Et Dist";
196  pixelhistosEt[i]=dbe->get(tmpname);
197  tmpname = sourcedirname_ + "/" + theHLTCollectionLabels[i].label() + " Phi Dist";
198  pixelhistosPhi[i]=dbe->get(tmpname);
199  }
200 
201  TH1F* refhist;
202  int nBins;
203  double xMin;
204  double xMax;
205 
206  refhist = pixelhistosEt[0]->getTH1F();
207  nBins = refhist->GetNbinsX();
208  xMin = refhist->GetXaxis()->GetXmin();
209  xMax = refhist->GetXaxis()->GetXmax();
210  pixelhistosEtOut[0] =dbe->book1D("EcalIsol Eff vs Et","EcalIsol Eff vs Et",nBins,xMin,xMax);
211  pixelhistosEtOut[1] =dbe->book1D("HcalIsol Eff vs Et","HcalIsol Eff vs Et",nBins,xMin,xMax);
212  pixelhistosEtOut[2] =dbe->book1D("Track Isol Eff vs Et","Track Isol Eff vs Et",nBins,xMin,xMax);
213  pixelhistosEtOut[3] =dbe->book1D("Total Eff vs Et","Total Eff vs Et",nBins,xMin,xMax);
214 
215  refhist = pixelhistosEta[0]->getTH1F();
216  nBins = refhist->GetNbinsX();
217  xMin = refhist->GetXaxis()->GetXmin();
218  xMax = refhist->GetXaxis()->GetXmax();
219  pixelhistosEtaOut[0] =dbe->book1D("EcalIsol Eff vs Eta","EcalIsol Eff vs Eta",nBins,xMin,xMax);
220  pixelhistosEtaOut[1] =dbe->book1D("HcalIsol Eff vs Eta","HcalIsol Eff vs Eta",nBins,xMin,xMax);
221  pixelhistosEtaOut[2] =dbe->book1D("Track Isol Eff vs Eta","Track Isol Eff vs Eta",nBins,xMin,xMax);
222  pixelhistosEtaOut[3] =dbe->book1D("Total Eff vs Eta","Total Eff vs Eta",nBins,xMin,xMax);
223 
224  refhist = pixelhistosPhi[0]->getTH1F();
225  nBins = refhist->GetNbinsX();
226  xMin = refhist->GetXaxis()->GetXmin();
227  xMax = refhist->GetXaxis()->GetXmax();
228  pixelhistosPhiOut[0] =dbe->book1D("EcalIsol Eff vs Phi","EcalIsol Eff vs Phi",nBins,xMin,xMax);
229  pixelhistosPhiOut[1] =dbe->book1D("HcalIsol Eff vs Phi","HcalIsol Eff vs Phi",nBins,xMin,xMax);
230  pixelhistosPhiOut[2] =dbe->book1D("Track Isol Eff vs Phi","Track Isol Eff vs Phi",nBins,xMin,xMax);
231  pixelhistosPhiOut[3] =dbe->book1D("Total Eff vs Phi","Total Eff vs Phi",nBins,xMin,xMax);
232 
233  tmpname = sourcedirname_ + "/Evts Passing Filters";
234  eventCounter = dbe->get(tmpname);
235 
236  relFilterEff = dbe->book1D("Relative Filter Effs","Relative Filter Effs",5,0,5);
237  relFilterEff->setBinLabel(1,"HLTIsoEtFilterEff");
238  relFilterEff->setBinLabel(2,"HLTIsoEcalIsolEff");
239  relFilterEff->setBinLabel(3,"HLTIsoHcalIsolEff");
240  relFilterEff->setBinLabel(4,"HLTIsoTrackIsolEff");
241  // relFilterEff->setBinLabel(5,"FIXME");
242  // relFilterEff->setBinLabel(6,"FIXME");
243 
244  cumFilterEff = dbe->book1D("Cumulative Filter Effs","Cumulative Filter Effs",5,0,5);
245  cumFilterEff->setBinLabel(1,"HLTIsoEtFilterEff");
246  cumFilterEff->setBinLabel(2,"HLTIsoEcalIsolEff");
247  cumFilterEff->setBinLabel(3,"HLTIsoHcalIsolEff");
248  cumFilterEff->setBinLabel(4,"HLTIsoTrackIsolEff");
249  // cumFilterEff->setBinLabel(5,"TrackIsolEff");
250 
251  } // end "if(dbe)"
252 }
253 
254 // ------------ method called once each job just after ending the event loop ------------
255 void
257 
258 // std::cout << "HLTMonPhotonClient: end job...." << std::endl;
259 
260  if (outputFile_.size() != 0 && dbe)
261  dbe->save(outputFile_);
262 
263  return;
264 }
265 
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2535
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
#define NULL
Definition: scimark2.h:8
DEFINE_FWK_MODULE(HiMixingModule)
int iEvent
Definition: GenABIO.cc:243
int j
Definition: DBlmapReader.cc:9
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1473
TH1F * getTH1F(void) const
long long int num
Definition: procUtils.cc:71
HLTMonPhotonClient(const edm::ParameterSet &)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
virtual void analyze(const edm::Event &, const edm::EventSetup &)