CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTTauDQMSummaryPlotter.cc
Go to the documentation of this file.
2 
4  //Initialize Plotter
5  name_ = "HLTTauDQMSummaryPlotter";
6 
7  //Process PSet
8  try {
11  type_ = ps.getUntrackedParameter<std::string>("ConfigType");
12  dqmBaseFolder_ = dqmBaseFolder;
13  validity_ = true;
14  } catch ( cms::Exception &e ) {
15  edm::LogInfo("HLTTauDQMSummaryPlotter::HLTTauDQMSummaryPlotter") << e.what() << std::endl;
16  validity_ = false;
17  return;
18  }
19 
20  if (store_) {
21  //Path Summary
22  if ( type_ == "Path" ) {
23  bookTriggerBitEfficiencyHistos(triggerTag(),"MatchedTriggerBits");
24  }
25 
26  //Lite Path Summary
27  if ( type_ == "LitePath" ) {
28  bookEfficiencyHisto(triggerTag(),"PathEfficiency","MatchedPathTriggerBits");
29  bookEfficiencyHisto(triggerTag(),"TrigTauEtEff","EfficiencyHelpers/TrigTauEtEffNum");
30  bookEfficiencyHisto(triggerTag(),"TrigTauEtaEff","EfficiencyHelpers/TrigTauEtaEffNum");
31  bookEfficiencyHisto(triggerTag(),"TrigTauPhiEff","EfficiencyHelpers/TrigTauPhiEffNum");
32  }
33 
34  //L1 Summary
35  if ( type_ == "L1" ) {
36  bookEfficiencyHisto(triggerTag(),"L1TauEtEff","EfficiencyHelpers/L1TauEtEffNum");
37  bookEfficiencyHisto(triggerTag(),"L1TauEtaEff","EfficiencyHelpers/L1TauEtaEffNum");
38  bookEfficiencyHisto(triggerTag(),"L1TauPhiEff","EfficiencyHelpers/L1TauPhiEffNum");
39 
40  bookEfficiencyHisto(triggerTag(),"L1JetEtEff","EfficiencyHelpers/L1JetEtEffNum");
41  bookEfficiencyHisto(triggerTag(),"L1JetEtaEff","EfficiencyHelpers/L1JetEtaEffNum");
42  bookEfficiencyHisto(triggerTag(),"L1JetPhiEff","EfficiencyHelpers/L1JetPhiEffNum");
43 
44  bookEfficiencyHisto(triggerTag(),"L1SingleTauEff","L1LeadTauEt");
45  bookEfficiencyHisto(triggerTag(),"L1DoubleTauEff","L1SecondTauEt");
46  }
47 
48  //L2 Summary
49  if ( type_ == "Calo" ) {
50  bookEfficiencyHisto(triggerTag(),"L2RecoTauEtEff","EfficiencyHelpers/L2RecoTauEtEffNum");
51  bookEfficiencyHisto(triggerTag(),"L2RecoTauEtaEff","EfficiencyHelpers/L2RecoTauEtaEffNum");
52  bookEfficiencyHisto(triggerTag(),"L2RecoTauPhiEff","EfficiencyHelpers/L2RecoTauPhiEffNum");
53 
54  bookEfficiencyHisto(triggerTag(),"L2IsoTauEtEff","EfficiencyHelpers/L2IsoTauEtEffNum");
55  bookEfficiencyHisto(triggerTag(),"L2IsoTauEtaEff","EfficiencyHelpers/L2IsoTauEtaEffNum");
56  bookEfficiencyHisto(triggerTag(),"L2IsoTauPhiEff","EfficiencyHelpers/L2IsoTauPhiEffNum");
57  }
58 
59  //L25/3 Summary
60  if ( type_ == "Track" ) {
61  bookEfficiencyHisto(triggerTag(),"L25TauEtEff","L25TauEtEffNum");
62  bookEfficiencyHisto(triggerTag(),"L25TauEtaEff","L25TauEtaEffNum");
63  bookEfficiencyHisto(triggerTag(),"L25TauPhiEff","L25TauPhiEffNum");
64  bookEfficiencyHisto(triggerTag(),"L3TauEtEff","L3TauEtEffNum");
65  bookEfficiencyHisto(triggerTag(),"L3TauEtaEff","L3TauEtaEffNum");
66  bookEfficiencyHisto(triggerTag(),"L3TauPhiEff","L3TauPhiEffNum");
67  }
68  }
69 }
70 
72 }
73 
75  if (store_) {
76  //Path Summary
77  if ( type_ == "Path" ) {
78  plotTriggerBitEfficiencyHistos(triggerTag(),"MatchedTriggerBits");
79  }
80 
81  //Lite Path Summary
82  if ( type_ == "LitePath" ) {
83  plotEfficiencyHisto(triggerTag(),"PathEfficiency","MatchedPathTriggerBits","RefEvents");
84  plotEfficiencyHisto(triggerTag(),"TrigTauEtEff","EfficiencyHelpers/TrigTauEtEffNum","EfficiencyHelpers/TrigTauEtEffDenom");
85  plotEfficiencyHisto(triggerTag(),"TrigTauEtaEff","EfficiencyHelpers/TrigTauEtaEffNum","EfficiencyHelpers/TrigTauEtaEffDenom");
86  plotEfficiencyHisto(triggerTag(),"TrigTauPhiEff","EfficiencyHelpers/TrigTauPhiEffNum","EfficiencyHelpers/TrigTauPhiEffDenom");
87  }
88 
89  //L1 Summary
90  if ( type_ == "L1" ) {
91  plotEfficiencyHisto(triggerTag(),"L1TauEtEff","EfficiencyHelpers/L1TauEtEffNum","EfficiencyHelpers/L1TauEtEffDenom");
92  plotEfficiencyHisto(triggerTag(),"L1TauEtaEff","EfficiencyHelpers/L1TauEtaEffNum","EfficiencyHelpers/L1TauEtaEffDenom");
93  plotEfficiencyHisto(triggerTag(),"L1TauPhiEff","EfficiencyHelpers/L1TauPhiEffNum","EfficiencyHelpers/L1TauPhiEffDenom");
94 
95  plotEfficiencyHisto(triggerTag(),"L1JetEtEff","EfficiencyHelpers/L1JetEtEffNum","EfficiencyHelpers/L1JetEtEffDenom");
96  plotEfficiencyHisto(triggerTag(),"L1JetEtaEff","EfficiencyHelpers/L1JetEtaEffNum","EfficiencyHelpers/L1JetEtaEffDenom");
97  plotEfficiencyHisto(triggerTag(),"L1JetPhiEff","EfficiencyHelpers/L1JetPhiEffNum","EfficiencyHelpers/L1JetPhiEffDenom");
98 
99  plotEfficiencyHisto(triggerTag(),"L1ElectronEtEff","EfficiencyHelpers/L1ElectronEtEffNum","EfficiencyHelpers/L1ElectronEtEffDenom");
100  plotEfficiencyHisto(triggerTag(),"L1ElectronEtaEff","EfficiencyHelpers/L1ElectronEtaEffNum","EfficiencyHelpers/L1ElectronEtaEffDenom");
101  plotEfficiencyHisto(triggerTag(),"L1ElectronPhiEff","EfficiencyHelpers/L1ElectronPhiEffNum","EfficiencyHelpers/L1ElectronPhiEffDenom");
102 
103  plotEfficiencyHisto(triggerTag(),"L1MuonEtEff","EfficiencyHelpers/L1MuonEtEffNum","EfficiencyHelpers/L1MuonEtEffDenom");
104  plotEfficiencyHisto(triggerTag(),"L1MuonEtaEff","EfficiencyHelpers/L1MuonEtaEffNum","EfficiencyHelpers/L1MuonEtaEffDenom");
105  plotEfficiencyHisto(triggerTag(),"L1MuonPhiEff","EfficiencyHelpers/L1MuonPhiEffNum","EfficiencyHelpers/L1MuonPhiEffDenom");
106 
107  plotIntegratedEffHisto(triggerTag(),"L1SingleTauEff","L1LeadTauEt","InputEvents",1);
108  plotIntegratedEffHisto(triggerTag(),"L1DoubleTauEff","L1SecondTauEt","InputEvents",2);
109  }
110 
111  //L2 Summary
112  if ( type_ == "Calo" ) {
113  plotEfficiencyHisto(triggerTag(),"L2RecoTauEtEff","EfficiencyHelpers/L2RecoTauEtEffNum","EfficiencyHelpers/L2RecoTauEtEffDenom");
114  plotEfficiencyHisto(triggerTag(),"L2RecoTauEtaEff","EfficiencyHelpers/L2RecoTauEtaEffNum","EfficiencyHelpers/L2RecoTauEtaEffDenom");
115  plotEfficiencyHisto(triggerTag(),"L2RecoTauPhiEff","EfficiencyHelpers/L2RecoTauPhiEffNum","EfficiencyHelpers/L2RecoTauPhiEffDenom");
116 
117  plotEfficiencyHisto(triggerTag(),"L2IsoTauEtEff","EfficiencyHelpers/L2IsoTauEtEffNum","EfficiencyHelpers/L2IsoTauEtEffDenom");
118  plotEfficiencyHisto(triggerTag(),"L2IsoTauEtaEff","EfficiencyHelpers/L2IsoTauEtaEffNum","EfficiencyHelpers/L2IsoTauEtaEffDenom");
119  plotEfficiencyHisto(triggerTag(),"L2IsoTauPhiEff","EfficiencyHelpers/L2IsoTauPhiEffNum","EfficiencyHelpers/L2IsoTauPhiEffDenom");
120  }
121 
122  //L25/3 Summary
123  if ( type_ == "Track" ) {
124  plotEfficiencyHisto(triggerTag(),"L25TauEtEff","L25TauEtEffNum","L25TauEtEffDenom");
125  plotEfficiencyHisto(triggerTag(),"L25TauEtaEff","L25TauEtaEffNum","L25TauEtaEffDenom");
126  plotEfficiencyHisto(triggerTag(),"L25TauPhiEff","L25TauPhiEffNum","L25TauPhiEffDenom");
127  plotEfficiencyHisto(triggerTag(),"L3TauEtEff","L3TauEtEffNum","L3TauEtEffDenom");
128  plotEfficiencyHisto(triggerTag(),"L3TauEtaEff","L3TauEtaEffNum","L3TauEtaEffDenom");
129  plotEfficiencyHisto(triggerTag(),"L3TauPhiEff","L3TauPhiEffNum","L3TauPhiEffDenom");
130  }
131  }
132 }
133 
135  if ( store_->dirExists(folder) ) {
136  store_->setCurrentFolder(folder);
137 
138  MonitorElement * effnum = store_->get(folder+"/"+hist1);
139 
140  if ( effnum ) {
141  MonitorElement *tmp = store_->bookProfile(name,name,effnum->getTH1F()->GetNbinsX(),effnum->getTH1F()->GetXaxis()->GetXmin(),effnum->getTH1F()->GetXaxis()->GetXmax(),105,0,1.05);
142 
143  tmp->setTitle(name);
144  }
145  }
146 }
147 
149  if ( store_->dirExists(folder) ) {
150  store_->setCurrentFolder(folder);
151 
152  MonitorElement * effnum = store_->get(folder+"/"+hist1);
153  MonitorElement * effdenom = store_->get(folder+"/"+hist2);
154  MonitorElement * eff = store_->get(folder+"/"+name);
155 
156  if ( effnum && effdenom && eff ) {
157  for ( int i = 1; i <= effnum->getTH1F()->GetNbinsX(); ++i ) {
158  double efficiency = calcEfficiency(effnum->getTH1F()->GetBinContent(i),effdenom->getTH1F()->GetBinContent(i)).first;
159  double err = calcEfficiency(effnum->getTH1F()->GetBinContent(i),effdenom->getTH1F()->GetBinContent(i)).second;
160  eff->getTProfile()->SetBinContent(i,efficiency);
161  eff->getTProfile()->SetBinEntries(i,1);
162  eff->getTProfile()->SetBinError(i,sqrt(efficiency*efficiency+err*err));
163  }
164  }
165  }
166 }
167 
169  if ( store_->dirExists(folder) ) {
170  store_->setCurrentFolder(folder);
171 
172  MonitorElement * refH = store_->get(folder+"/"+refHisto);
173  MonitorElement * evC = store_->get(folder+"/"+evCount);
174  MonitorElement * eff = store_->get(folder+"/"+name);
175 
176  if ( refH && evC && eff ) {
177  TH1F *histo = refH->getTH1F();
178  float nGenerated = evC->getTH1F()->GetBinContent(bin);
179  // Assuming that the histogram is incremented with weight=1 for each event
180  // this function integrates the histogram contents above every bin and stores it
181  // in that bin. The result is plot of integral rate versus threshold plot.
182  int nbins = histo->GetNbinsX();
183  double integral = histo->GetBinContent(nbins+1); // Initialize to overflow
184  if (nGenerated<=0.0) nGenerated=1.0;
185  for ( int i = nbins; i >= 1; i-- ) {
186  double thisBin = histo->GetBinContent(i);
187  integral += thisBin;
188  double integralEff;
189  double integralError;
190  integralEff = (integral / nGenerated);
191  eff->getTProfile()->SetBinContent(i, integralEff);
192  eff->getTProfile()->SetBinEntries(i, 1);
193  // error
194  integralError = (sqrt(integral) / nGenerated);
195 
196  eff->getTProfile()->SetBinError(i, sqrt(integralEff*integralEff+integralError*integralError));
197  }
198  }
199  }
200 }
201 
203  if ( store_->dirExists(folder) ) {
204  store_->setCurrentFolder(folder);
205 
206  MonitorElement * eff = store_->get(folder+"/"+histo);
207 
208  if ( eff ) {
209  store_->bookProfile("EfficiencyRefInput","Efficiency with Matching",eff->getNbinsX()-1,0,eff->getNbinsX()-1,100,0,1);
210  store_->bookProfile("EfficiencyRefL1","Efficiency with Matching Ref to L1",eff->getNbinsX()-2,0,eff->getNbinsX()-2,100,0,1);
211  store_->bookProfile("EfficiencyRefPrevious","Efficiency with Matching Ref to Previous",eff->getNbinsX()-1,0,eff->getNbinsX()-1,100,0,1);
212  }
213  }
214 }
215 
217  if ( store_->dirExists(folder) ) {
218  store_->setCurrentFolder(folder);
219  MonitorElement * eff = store_->get(folder+"/"+histo);
220  MonitorElement * effRefTruth = store_->get(folder+"/EfficiencyRefInput");
221  MonitorElement * effRefL1 = store_->get(folder+"/EfficiencyRefL1");
222  MonitorElement * effRefPrevious = store_->get(folder+"/EfficiencyRefPrevious");
223 
224  if ( eff && effRefTruth && effRefL1 && effRefPrevious ) {
225  //Calculate efficiencies with ref to matched objects
226  for ( int i = 2; i <= eff->getNbinsX(); ++i ) {
228  double err = calcEfficiency(eff->getBinContent(i),eff->getBinContent(1)).second;
229 
230  effRefTruth->getTProfile()->SetBinContent(i-1,efficiency);
231  effRefTruth->getTProfile()->SetBinEntries(i-1,1);
232  effRefTruth->getTProfile()->SetBinError(i-1,sqrt(efficiency*efficiency+err*err));
233  effRefTruth->setBinLabel(i-1,eff->getTH1F()->GetXaxis()->GetBinLabel(i));
234 
235  }
236  //Calculate efficiencies with ref to L1
237  for ( int i = 3; i <= eff->getNbinsX(); ++i ) {
239  double err = calcEfficiency(eff->getBinContent(i),eff->getBinContent(2)).second;
240 
241  effRefL1->getTProfile()->SetBinContent(i-2,efficiency);
242  effRefL1->getTProfile()->SetBinEntries(i-2,1);
243  effRefL1->getTProfile()->SetBinError(i-2,sqrt(efficiency*efficiency+err*err));
244  effRefL1->setBinLabel(i-2,eff->getTH1F()->GetXaxis()->GetBinLabel(i));
245  }
246  //Calculate efficiencies with ref to previous
247  for ( int i = 2; i <= eff->getNbinsX(); ++i ) {
248  double efficiency = calcEfficiency(eff->getBinContent(i),eff->getBinContent(i-1)).first;
249  double err = calcEfficiency(eff->getBinContent(i),eff->getBinContent(i-1)).second;
250 
251  effRefPrevious->getTProfile()->SetBinContent(i-1,efficiency);
252  effRefPrevious->getTProfile()->SetBinEntries(i-1,1);
253  effRefPrevious->getTProfile()->SetBinError(i-1,sqrt(efficiency*efficiency+err*err));
254  effRefPrevious->setBinLabel(i-1,eff->getTH1F()->GetXaxis()->GetBinLabel(i));
255  }
256  }
257  }
258 }
259 
260 std::pair<double,double> HLTTauDQMSummaryPlotter::calcEfficiency( float num, float denom ) {
261  if ( denom != 0.0 ) {
262  return std::pair<double,double>(num/denom,sqrt(num/denom*(1.0-num/denom)/denom));
263  }
264  return std::pair<double,double>(0.0,0.0);
265 }
virtual char const * what() const
Definition: Exception.cc:141
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void plotTriggerBitEfficiencyHistos(std::string folder, std::string histo)
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)
U second(std::pair< T, U > const &p)
void bookTriggerBitEfficiencyHistos(std::string folder, std::string histo)
T sqrt(T t)
Definition: SSEVec.h:48
std::string triggerTagAlias_
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:1036
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
bool first
Definition: L1TdeRCT.cc:94
Integral< F, X >::type integral(const F &f)
Definition: Integral.h:69
void plotEfficiencyHisto(std::string folder, std::string name, std::string hist1, std::string hist2)
void setTitle(const std::string &title)
set (ie. change) histogram/profile title
bool dirExists(const std::string &path) const
true if directory exists
Definition: DQMStore.cc:498
std::string triggerTag()
void bookEfficiencyHisto(std::string folder, std::string name, std::string hist1)
TH1F * getTH1F(void) const
long long int num
Definition: procUtils.cc:71
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
double getBinContent(int binx) const
get content of bin (1-D)
TProfile * getTProfile(void) const
int getNbinsX(void) const
get # of bins in X-axis
std::pair< double, double > calcEfficiency(float num, float denom)
HLTTauDQMSummaryPlotter(const edm::ParameterSet &, std::string)
std::string triggerTag_
void plotIntegratedEffHisto(std::string folder, std::string name, std::string refHisto, std::string evCount, int bin)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
std::string dqmBaseFolder_