64 |
|
// void init(TString inputFileName); |
65 |
|
void handleTriggerMatchingInfo(eventInfo& evt); |
66 |
|
void initBranches(TTree *tree, eventInfo &event); |
67 |
< |
void investigateTriggerFilterMu(eventInfo& evt, map<TString, plotMaker> &plot, TString filterName); |
67 |
> |
void investigateTriggerFilterLep(eventInfo& evt, map<TString, plotMaker> &plot, TString filterName, TString label); |
68 |
|
void Loop(TString inputFileName, TString outputFileName); |
69 |
|
void makeEfficiencyPlots(map<TString, plotMaker> &plot); |
70 |
|
void plotHistograms(eventInfo& evt, map<TString, plotMaker> &plot); |
71 |
|
void printElectronInfo(eventInfo& evt, ostream& os=cout); |
72 |
|
void printEventInfo(eventInfo& evt, ostream& os=cout); |
73 |
|
void printMuonInfo(eventInfo& evt, ostream& os=cout); |
74 |
< |
void setEfficiencyErrors(TH1D* &eff, TH1D* &h_tag, TH1D* &h_probe); |
74 |
> |
void setEfficiencyErrors(TH1D* &eff, TH1D* &h_passed, TH1D* &h_failed); |
75 |
|
|
76 |
|
//--------------------------------------------------- global Variables |
77 |
|
vector<string> triggerFilterToCheckMu; |
88 |
|
const Int_t binPU = 64; |
89 |
|
const Double_t lowPU = 0.; |
90 |
|
const Double_t upPU = 64.; |
91 |
< |
|
91 |
> |
//---------------------------------------- |
92 |
> |
const Int_t binMinv = 40; |
93 |
> |
const Double_t lowMinv = 50.; |
94 |
> |
const Double_t upMinv = 130.; |
95 |
|
|
96 |
|
|
97 |
|
//================================================================================= triggerStudy |
98 |
|
//main function which will be called |
99 |
|
//here, it is possible to run over multiple files and to estimate trigger efficiencies for different samples |
100 |
< |
void triggerStudy(TString inputFileName = "TTJets_mu_tree.root"){ |
100 |
> |
void triggerStudy(){ |
101 |
> |
|
102 |
> |
//--------------------------------------------------- define the muon TriggerFilters to be checked |
103 |
|
triggerFilterToCheckMu.push_back("hltL1sMu16Eta2p1"); |
104 |
|
triggerFilterToCheckMu.push_back("hltL2fL1sMu16Eta2p1L1f0L2Filtered16Q"); |
105 |
|
triggerFilterToCheckMu.push_back("hltL3crIsoL1sMu16Eta2p1L1f0L2f16QL3f20L3crIsoFiltered10"); |
107 |
|
triggerFilterToCheckMu.push_back("hltIsoMu202p1TriCentralPFJet303020MuCleaned"); |
108 |
|
triggerFilterToCheckMu.push_back("hltDiMuonGlb22Trk8DzFiltered0p2"); |
109 |
|
triggerFilterToCheckMu.push_back("hltL3crIsoL1sMu14Eta2p1L1f0L2f16QL3f20L3crIsoRhoFiltered0p15"); |
110 |
< |
|
106 |
< |
|
110 |
> |
//--------------------------------------------------- define the electron TriggerFilters to be checked |
111 |
|
// triggerFilterToCheckEl.push_back("hltL1sL1SingleEG20orL1SingleEG22"); |
112 |
|
// triggerFilterToCheckEl.push_back("hltEle25CaloIdVTTrkIdTCaloIsoTTrkIsoTTrackIsoFilter"); |
113 |
|
// triggerFilterToCheckEl.push_back("hltEle25CaloIdVTCaloIsoTTrkIdTTrkIsoTTriCentralPFJet30EleCleaned"); |
114 |
|
// triggerFilterToCheckEl.push_back("hltEle25CaloIdVTCaloIsoTTrkIdTTrkIsoTTriCentralPFNoPUJet30EleCleaned"); |
115 |
|
// triggerFilterToCheckEl.push_back("hltEle25CaloIdVTCaloIsoTTrkIdTTrkIsoTTriCentralPFNoPUJet303020EleCleaned"); |
116 |
|
|
117 |
< |
TH1::SetDefaultSumw2(); |
118 |
< |
|
119 |
< |
//Loop(inputFileName, outputFileName); |
120 |
< |
|
121 |
< |
inputFileName = "TTJets_mu_tree.root"; |
122 |
< |
inputFileName = "TTJets_el_tree.root"; |
123 |
< |
inputFileName = "DYJets_mu_tree.root"; |
124 |
< |
inputFileName = "DYJets_el_tree.root"; |
125 |
< |
|
126 |
< |
inputFileName = "TTJets_SUMMER12_TrigStudy-mu_noTail_Tree.root"; |
127 |
< |
//inputFileName = "TTJets_SUMMER12_TrigStudy-el_noTail_Tree.root"; |
128 |
< |
inputFileName = "DYJets_M-50_TrigStudy-mu_noTail_Tree.root"; |
129 |
< |
//inputFileName = "DYJets_M-50_TrigStudy-el_noTail_Tree.root"; |
130 |
< |
|
131 |
< |
TString dir =""; |
128 |
< |
dir ="/scratch/hh/current/cms/user/mstein/output/"; |
129 |
< |
Loop(dir + inputFileName, "out_"+inputFileName); |
130 |
< |
|
131 |
< |
|
132 |
< |
Loop("/scratch/hh/current/cms/user/mstein/output/TTJets_mu_tree.root", "out_TTJets_mu_tree.root"); |
133 |
< |
Loop("/scratch/hh/current/cms/user/mstein/output/TTJets_el_tree.root", "out_TTJets_el_tree.root"); |
134 |
< |
Loop("/scratch/hh/current/cms/user/mstein/output/DYJets_mu_tree.root", "out_DYJets_mu_tree.root"); |
135 |
< |
Loop("/scratch/hh/current/cms/user/mstein/output/DYJets_el_tree.root", "out_DYJets_el_tree.root"); |
117 |
> |
//--------------------------------------------------- define the sample(s) to loop over and the output file |
118 |
> |
//these are small test files of ONE single file af a sample |
119 |
> |
// Loop("/scratch/hh/current/cms/user/mstein/output/TTJets_mu_tree.root", "out_TTJets_mu_tree.root"); |
120 |
> |
// Loop("/scratch/hh/current/cms/user/mstein/output/TTJets_el_tree.root", "out_TTJets_el_tree.root"); |
121 |
> |
// Loop("/scratch/hh/current/cms/user/mstein/output/DYJets_mu_tree.root", "out_DYJets_mu_tree.root"); |
122 |
> |
// Loop("/scratch/hh/current/cms/user/mstein/output/DYJets_el_tree.root", "out_DYJets_el_tree.root"); |
123 |
> |
// Loop("/scratch/hh/current/cms/user/mstein/output/SingleMu_mu_tree.root", "out_SingleMu_mu_tree.root"); |
124 |
> |
// Loop("/scratch/hh/current/cms/user/mstein/output/SingleElectron_el_tree.root", "out_SingleElectron_el_tree.root"); |
125 |
> |
//these are the whole samples |
126 |
> |
// Loop("/scratch/hh/current/cms/user/mstein/output/TTJets/SUMMER12/TTJets_SUMMER12_TrigStudy-mu_noTail_Tree.root", "out_TTJets_SUMMER12_TrigStudy-mu_noTail_Tree.root"); |
127 |
> |
// Loop("/scratch/hh/current/cms/user/mstein/output/TTJets/SUMMER12/TTJets_SUMMER12_TrigStudy-el_noTail_Tree.root", "out_TTJets_SUMMER12_TrigStudy-el_noTail_Tree.root"); |
128 |
> |
Loop("/scratch/hh/current/cms/user/mstein/output/DYJets/M-50/DYJets_M-50_TrigStudy-mu_noTail_Tree.root", "out_DYJets_M-50_TrigStudy-mu_noTail_Tree.root"); |
129 |
> |
// Loop("/scratch/hh/current/cms/user/mstein/output/DYJets/M-50/DYJets_M-50_TrigStudy-el_noTail_Tree.root", "out_DYJets_M-50_TrigStudy-el_noTail_Tree.root"); |
130 |
> |
// Loop("/scratch/hh/current/cms/user/mstein/output/SingleElectron/Run2012B-13Jul2012-v1/SingleElectron_Run2012B-13Jul2012-v1_TrigStudy-el_noTail_Tree.root", "out_SingleElectron_Run2012B-13Jul2012-v1_TrigStudy-el_noTail_Tree.root"); |
131 |
> |
// Loop("/scratch/hh/current/cms/user/mstein/output/SingleMu/Run2012B-13Jul2012-v1/SingleMu_Run2012B-13Jul2012-v1_TrigStudy-mu_noTail_Tree.root", "out_SingleMu_Run2012B-13Jul2012-v1_TrigStudy-mu_noTail_Tree.root"); |
132 |
|
|
137 |
– |
Loop("/scratch/hh/current/cms/user/mstein/output/TTJets/SUMMER12/TTJets_SUMMER12_TrigStudy-mu_noTail_Tree.root", "out_TTJets_SUMMER12_TrigStudy-mu_noTail_Tree.root"); |
138 |
– |
Loop("/scratch/hh/current/cms/user/mstein/output/TTJets/SUMMER12/TTJets_SUMMER12_TrigStudy-el_noTail_Tree.root", "out_TTJets_SUMMER12_TrigStudy-el_noTail_Tree.root"); |
139 |
– |
Loop("/scratch/hh/current/cms/user/mstein/output/DYJets/M-10to50/TTJets_SUMMER12_TrigStudy-mu_noTail_Tree.root", "out_TTJets_SUMMER12_TrigStudy-mu_noTail_Tree.root"); |
140 |
– |
Loop("/scratch/hh/current/cms/user/mstein/output/DYJets/M-50/TTJets_SUMMER12_TrigStudy-mu_noTail_Tree.root", "out_TTJets_SUMMER12_TrigStudy-mu_noTail_Tree.root"); |
141 |
– |
|
142 |
– |
|
143 |
– |
|
133 |
|
|
145 |
– |
// init(inputFileName); |
146 |
– |
// Loop("SusyCAF_Tree_n722_3403013856_out_tree.root", "TTJets.root"); |
147 |
– |
//Loop("TTJets_SUMMER12_TrigStudy-mu_noTail_Tree.root", "TTJets.root"); |
148 |
– |
//Loop(inputFileName, "Run2012C.root"); |
134 |
|
} |
135 |
|
|
136 |
|
|
139 |
|
plot["event"].addh1d("muMultiplicity", "muMultiplicity", "muon multiplicity", "events", 5, -0.5, 4.5, evt.muonP4->size(), evt.Weight); |
140 |
|
plot["event"].addh1d("elMultiplicity", "elMultiplicity", "electron multiplicity", "events", 5, -0.5, 4.5, evt.electronP4->size(), evt.Weight); |
141 |
|
plot["event"].addh1d("jetMultiplicity", "jetMultiplicity", "jet multiplicity", "events", 10, -0.5, 9.5, evt.jetP4->size(), evt.Weight); |
142 |
+ |
if(evt.electronP4->size()==2){ |
143 |
+ |
Double_t minv = (evt.electronP4->at(0) + evt.electronP4->at(1)).mass(); |
144 |
+ |
plot["event"].addh1d("Minv", "Minv", "M_{inv} [GeV/c^{2}]", "events", binMinv, lowMinv, upMinv, minv, evt.Weight); |
145 |
+ |
} |
146 |
|
|
147 |
+ |
|
148 |
|
for(Int_t i=0,N=triggerFilterToCheckMu.size(); i<N; ++i){ |
149 |
< |
investigateTriggerFilterMu(evt, plot, triggerFilterToCheckMu.at(i)); |
149 |
> |
investigateTriggerFilterLep(evt, plot, triggerFilterToCheckMu.at(i), "muon"); |
150 |
> |
} |
151 |
> |
for(Int_t i=0,N=triggerFilterToCheckEl.size(); i<N; ++i){ |
152 |
> |
investigateTriggerFilterLep(evt, plot, triggerFilterToCheckEl.at(i), "electron"); |
153 |
|
} |
161 |
– |
// for(Int_t i=0,N=triggerFilterToCheckEl.size(); i<N; ++i){ |
162 |
– |
// investigateTriggerFilterEl(evt, plot, triggerFilterToCheckEl.at(i)); |
163 |
– |
// } |
154 |
|
} |
155 |
|
|
156 |
|
|
157 |
|
//================================================================================= investigateTriggerFilterMu |
158 |
< |
// eff = 2*NTT / (2*NTT + NTP) |
159 |
< |
void investigateTriggerFilterMu(eventInfo& evt, map<TString, plotMaker> &plot, TString filterName){ |
160 |
< |
//create vector which stores, if a muon is matched to the trigger filter with the name "filterName" |
158 |
> |
//check, if the positive lepton can be matched to the trigger filter |
159 |
> |
//if yes, take this lepton as Tag |
160 |
> |
//then probe the other lepton |
161 |
> |
void investigateTriggerFilterLep(eventInfo& evt, map<TString, plotMaker> &plot, TString filterName, TString label){ |
162 |
> |
vector<LorentzM>* lepP4; |
163 |
> |
vector<int>* lepCharge; |
164 |
> |
vector<vector<TString> > triggerFilterLep; |
165 |
> |
//--------------------------------------------------- chose input variables according to label |
166 |
> |
if(label = "muon"){ |
167 |
> |
lepP4 = (evt.muonP4); |
168 |
> |
lepCharge = (evt.muonCharge); |
169 |
> |
triggerFilterLep = (evt.triggerFilterMu); |
170 |
> |
} |
171 |
> |
else if(label = "electron"){ |
172 |
> |
lepP4 = (evt.electronP4); |
173 |
> |
lepCharge = (evt.electronCharge); |
174 |
> |
triggerFilterLep = (evt.triggerFilterEl); |
175 |
> |
} |
176 |
> |
else{ |
177 |
> |
cout<<"WARNING: Label for 'investigateTriggerFilter' is neither 'muon' nor 'electron'!"<<endl; |
178 |
> |
cout<<"label = " << label << endl; |
179 |
> |
return; |
180 |
> |
} |
181 |
> |
//--------------------------------------------------- do some consistency check - just to be sure |
182 |
> |
if(lepP4->size() != 2){ |
183 |
> |
cout<<"WARNING: The size of the " << label << "vector is NOT two!"<<endl; |
184 |
> |
cout<<"lepP4->size() = " << lepP4->size() << endl; |
185 |
> |
return; |
186 |
> |
} |
187 |
> |
if(lepP4->size() != triggerFilterLep.size()){ |
188 |
> |
cout<<"WARNING: The size of the "<< label << " vector and Matching-info vector is different!"<<endl; |
189 |
> |
cout<<"lepP4->size() = " << lepP4->size() << endl; |
190 |
> |
cout<<"triggerFilterLep.size() = " << triggerFilterLep.size() << endl; |
191 |
> |
return; |
192 |
> |
} |
193 |
> |
if(lepP4->size() != lepCharge->size()){ |
194 |
> |
cout<<"WARNING: The size of the "<< label << "muon vector and muon-charge vector is different!"<<endl; |
195 |
> |
cout<<"lepP4->size() = " << lepP4->size() << endl; |
196 |
> |
cout<<"lepCharge->size() = " << lepCharge->size() << endl; |
197 |
> |
return; |
198 |
> |
} |
199 |
> |
// if(evt.electronP4->size() != evt.triggerFilterEl.size()){ |
200 |
> |
// cout<<"WARNING: The size of the electron vector and Matching-info vector is different!" |
201 |
> |
// cout<<"evt.electronP4->size() = " << evt.electronP4->size() << endl; |
202 |
> |
// cout<<"evt.triggerFilterEl->size() = " << evt.triggerFilterEl->size() << endl; |
203 |
> |
// return; |
204 |
> |
// } |
205 |
> |
// if(evt.electronP4->size() != evt.electronP4.size()){ |
206 |
> |
// cout<<"WARNING: The size of the electron vector and muon-charge vector is different!" |
207 |
> |
// cout<<"evt.electronP4->size() = " << evt.electronP4->size() << endl; |
208 |
> |
// cout<<"evt.electronP4->size() = " << evt.electronP4->size() << endl; |
209 |
> |
// return; |
210 |
> |
// } |
211 |
> |
//--------------------------------------------------- check which lepton has positive and which negative charge |
212 |
> |
Int_t index_pos = 0; |
213 |
> |
Int_t index_neg = 1; |
214 |
> |
if(lepCharge->at(0)==-1){ |
215 |
> |
index_pos = 0; |
216 |
> |
index_pos = 1; |
217 |
> |
} |
218 |
> |
//--------------------------------------------------- check which lepton has been matched to the trigger filter |
219 |
|
vector<bool> matched; |
220 |
< |
vector<int> probeIndex; |
173 |
< |
for(Int_t i=0,N=evt.muonP4->size(); i<N; ++i){ |
220 |
> |
for(Int_t i=0,N=lepP4->size(); i<N; ++i){ |
221 |
|
matched.push_back(false); |
222 |
< |
for(Int_t j=0,M=evt.triggerFilterMu.at(i).size(); j<M; ++j){ |
223 |
< |
if(filterName == evt.triggerFilterMu.at(i).at(j)){ |
222 |
> |
for(Int_t j=0,M=triggerFilterLep.at(i).size(); j<M; ++j){ |
223 |
> |
if(filterName == triggerFilterLep.at(i).at(j)){ |
224 |
|
matched.back() = true; |
225 |
|
break; |
226 |
|
} |
227 |
|
} |
181 |
– |
if(!matched.at(i)) probeIndex.push_back(i); |
228 |
|
} |
229 |
+ |
//--------------------------------------------------- do the plotting according to the outcome, which lepton could be matched |
230 |
|
|
231 |
< |
if(probeIndex.size()>2){ |
232 |
< |
cout<<"WARNING: Something is awkward with the number of Probe leptons: " << probeIndex.size() << endl; |
186 |
< |
cout<<"The number of probe leptons is expected to be 1 or 2, because here a T&P method is applied!" << endl; |
187 |
< |
} |
188 |
< |
else if(probeIndex.size()==2) return; //make only plots if at least one Tag exists in an event |
231 |
> |
//if the positive lepton IS NOT matched => no Tag found => return |
232 |
> |
if(!matched.at(index_pos)) return; |
233 |
|
|
234 |
< |
//Fill the Tag histograms |
235 |
< |
//here, we have TWO Tag leptons -> use BOTH for the efficiency |
236 |
< |
if(probeIndex.size()==0){ |
237 |
< |
for(Int_t i=0,N=evt.muonP4->size(); i<N; ++i){ |
238 |
< |
plot[filterName].addh1d("pt_tag", "pt_tag", "p_{T}(tag) [GeV/c]", "events", binPt, lowPt, upPt, evt.muonP4->at(i).Pt(), evt.Weight); |
239 |
< |
plot[filterName].addh1d("eta_tag", "eta_tag", "#eta(tag)", "events", binEta, lowEta, upEta, evt.muonP4->at(i).eta(), evt.Weight); |
240 |
< |
} |
241 |
< |
//the factor of '2' is due to the fact, that there are two matched tag leptons |
242 |
< |
plot[filterName].addh1d("PUVertices_tag", "PUVertices_tag", "number of primary vertices (tag)", "events", binPU, lowPU, upPU, evt.PUInter, 2*evt.Weight); |
243 |
< |
} |
244 |
< |
|
245 |
< |
//Fill the Probe histograms |
246 |
< |
//here, we have ONE Tag lepton -> the probe is NOT matched to the trigger filter |
247 |
< |
if(probeIndex.size()==1){ |
248 |
< |
plot[filterName].addh1d("pt_probe", "pt_probe", "p_{T}(probe) [GeV/c]", "events", binPt, lowPt, upPt, evt.muonP4->at(probeIndex.back()).pt(), evt.Weight); |
249 |
< |
plot[filterName].addh1d("eta_probe", "eta_probe", "#eta(probe)", "events", binEta, lowEta, upEta, evt.muonP4->at(probeIndex.back()).eta(), evt.Weight); |
250 |
< |
plot[filterName].addh1d("PUVertices_probe", "PUVertices_probe", "number of primary vertices (probe)", "events", binPU, lowPU, upPU, evt.PUInter, evt.Weight); |
234 |
> |
//if the positive lepton IS matched => plot Tag and Probe, and passed and failed |
235 |
> |
//plot the Tag |
236 |
> |
plot[filterName].addh1d(filterName+"_pt_tag", filterName+"_pt_tag", "p_{T}(tag) [GeV/c]", "events", binPt, lowPt, upPt, lepP4->at(index_pos).Pt(), evt.Weight); |
237 |
> |
plot[filterName].addh1d(filterName+"_eta_tag", filterName+"_eta_tag", "#eta(tag)", "events", binEta, lowEta, upEta, lepP4->at(index_pos).eta(), evt.Weight); |
238 |
> |
//plot the Probe |
239 |
> |
plot[filterName].addh1d(filterName+"_pt_probe", filterName+"_pt_probe", "p_{T}(probe) [GeV/c]", "events", binPt, lowPt, upPt, lepP4->at(index_neg).pt(), evt.Weight); |
240 |
> |
plot[filterName].addh1d(filterName+"_eta_probe", filterName+"_eta_probe", "#eta(probe)", "events", binEta, lowEta, upEta, lepP4->at(index_neg).eta(), evt.Weight); |
241 |
> |
//plot the passed |
242 |
> |
if(matched.at(index_neg)){ |
243 |
> |
Double_t minv = (lepP4->at(index_pos) + lepP4->at(index_neg)).mass(); |
244 |
> |
plot[filterName].addh1d(filterName+"_pt_passed", filterName+"_pt_passed", "p_{T}(passed) [GeV/c]", "events", binPt, lowPt, upPt, lepP4->at(index_neg).pt(), evt.Weight); |
245 |
> |
plot[filterName].addh1d(filterName+"_eta_passed", filterName+"_eta_passed", "#eta(passed)", "events", binEta, lowEta, upEta, lepP4->at(index_neg).eta(), evt.Weight); |
246 |
> |
plot[filterName].addh1d(filterName+"_PUVertices_passed", filterName+"_PUVertices_passed", "number of primary vertices (passed)", "events", binPU, lowPU, upPU, evt.PUInter, evt.Weight); |
247 |
> |
plot[filterName].addh1d(filterName+"_Minv_passed", filterName+"_Minv_passed", "M_{inv} [GeV/c^{2}]", "events", binMinv, lowMinv, upMinv, minv, evt.Weight); |
248 |
> |
} |
249 |
> |
else{//plot the failed |
250 |
> |
Double_t minv = (lepP4->at(index_pos) + lepP4->at(index_neg)).mass(); |
251 |
> |
plot[filterName].addh1d(filterName+"_pt_failed", filterName+"_pt_failed", "p_{T}(failed) [GeV/c]", "events", binPt, lowPt, upPt, lepP4->at(index_neg).pt(), evt.Weight); |
252 |
> |
plot[filterName].addh1d(filterName+"_eta_failed", filterName+"_eta_failed", "#eta(failed)", "events", binEta, lowEta, upEta, lepP4->at(index_neg).eta(), evt.Weight); |
253 |
> |
plot[filterName].addh1d(filterName+"_PUVertices_failed", filterName+"_PUVertices_failed", "number of primary vertices (failed)", "events", binPU, lowPU, upPU, evt.PUInter, evt.Weight); |
254 |
> |
plot[filterName].addh1d(filterName+"_Minv_failed", filterName+"_Minv_failed", "M_{inv} [GeV/c^{2}]", "events", binMinv, lowMinv, upMinv, minv, evt.Weight); |
255 |
|
} |
256 |
|
} |
257 |
|
|
258 |
|
|
259 |
|
//================================================================================= makeEfficiencyPlots |
260 |
< |
//eff = tag/(tag+probe) |
260 |
> |
//eff = passed/(passed+failed) |
261 |
|
void makeEfficiencyPlots(map<TString, plotMaker> &plot){ |
262 |
|
cout<<"----------> Create efficiency histograms"<<endl; |
263 |
|
|
266 |
|
allTriggerFiltersToCheck.push_back(triggerFilterToCheckEl.at(i)); |
267 |
|
} |
268 |
|
vector<string> histNames; |
269 |
< |
histNames.push_back("pt_tag"); |
270 |
< |
histNames.push_back("eta_tag"); |
271 |
< |
histNames.push_back("PUVertices_tag"); |
269 |
> |
histNames.push_back("_pt_passed"); |
270 |
> |
histNames.push_back("_eta_passed"); |
271 |
> |
histNames.push_back("_PUVertices_passed"); |
272 |
|
|
273 |
|
for(Int_t i=0,N=allTriggerFiltersToCheck.size(); i<N; ++i){ |
274 |
|
TString triggerFilter = allTriggerFiltersToCheck.at(i); |
275 |
|
for(Int_t j=0,M=histNames.size(); j<M; ++j){ |
276 |
< |
TString tagName = histNames.at(j); |
277 |
< |
TString probeName = histNames.at(j); |
278 |
< |
TString effName = histNames.at(j); |
279 |
< |
probeName.ReplaceAll("tag", "probe"); |
280 |
< |
effName.ReplaceAll("tag", "eff"); |
281 |
< |
if(plot[triggerFilter].isNewh1d(tagName)) continue; |
282 |
< |
if(plot[triggerFilter].isNewh1d(probeName)) continue; |
283 |
< |
|
284 |
< |
TH1D *h_tag = (TH1D*)(plot[triggerFilter].h1d[tagName])->Clone(); |
285 |
< |
TH1D *h_probe = (TH1D*)(plot[triggerFilter].h1d[probeName])->Clone(); |
286 |
< |
TH1D *den = (TH1D*)(h_tag)->Clone(); |
287 |
< |
den->Add((TH1D*)(h_probe)->Clone()); |
276 |
> |
TString passedName = triggerFilter; |
277 |
> |
TString failedName = triggerFilter; |
278 |
> |
TString effName = triggerFilter; |
279 |
> |
passedName += histNames.at(j); |
280 |
> |
failedName += histNames.at(j); |
281 |
> |
effName += histNames.at(j); |
282 |
> |
failedName.ReplaceAll("passed", "failed"); |
283 |
> |
effName.ReplaceAll("passed", "eff"); |
284 |
> |
|
285 |
> |
if(plot[triggerFilter].isNewh1d(passedName)) continue; |
286 |
> |
if(plot[triggerFilter].isNewh1d(failedName)) continue; |
287 |
> |
|
288 |
> |
TH1D *h_passed = (TH1D*)(plot[triggerFilter].h1d[passedName])->Clone(); |
289 |
> |
TH1D *h_failed = (TH1D*)(plot[triggerFilter].h1d[failedName])->Clone(); |
290 |
> |
TH1D *den = (TH1D*)(h_passed)->Clone(); |
291 |
> |
den->Add((TH1D*)(h_failed)->Clone()); |
292 |
|
|
293 |
< |
TH1D *eff = (TH1D*)(h_tag)->Clone(); |
293 |
> |
TH1D *eff = (TH1D*)(h_passed)->Clone(); |
294 |
|
eff->Divide(den); |
295 |
< |
setEfficiencyErrors(eff, h_tag, h_probe); |
295 |
> |
setEfficiencyErrors(eff, h_passed, h_failed); |
296 |
|
|
297 |
|
eff->SetName(effName); |
298 |
|
eff->SetTitle(effName); |
299 |
|
|
300 |
|
TString xTitle_eff = eff->GetXaxis()->GetTitle(); |
301 |
< |
xTitle_eff.ReplaceAll("(tag)",""); |
301 |
> |
xTitle_eff.ReplaceAll("(passed)",""); |
302 |
|
eff->GetXaxis()->SetTitle(xTitle_eff); |
303 |
|
eff->GetYaxis()->SetTitle("efficiency"); |
304 |
|
//eff->SetAxisRange(0.,1.,"Y"); |
309 |
|
|
310 |
|
|
311 |
|
//================================================================================= setEfficiencyErrors |
312 |
< |
// f(eff) = t/(t+p) |
313 |
< |
// df/dt = 1/(t+p) - t/(t+p)^2 |
314 |
< |
// df/dp = - t/(t+p)^2 |
315 |
< |
// eff_sig = sqrt(t_sig^2*(df/dt)^2 + p_sig^2*(df/dp)^2) |
316 |
< |
void setEfficiencyErrors(TH1D* &eff, TH1D* &h_tag, TH1D* &h_probe){ |
317 |
< |
if(h_tag->GetNbinsX() != h_probe->GetNbinsX()){ |
318 |
< |
cout<<"WARNING: the number of bins of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl; |
319 |
< |
cout<<"Number of bins (Tag | Probe): " << h_tag->GetNbinsX() << " | " << h_probe->GetNbinsX() << endl; |
320 |
< |
} |
321 |
< |
if(h_tag->GetXaxis()->GetXmax() != h_probe->GetXaxis()->GetXmax()){ |
322 |
< |
cout<<"WARNING: the upper x-range of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl; |
323 |
< |
cout<<"Number of bins (Tag | Probe): " << h_tag->GetXaxis()->GetXmax() << " | " << h_probe->GetXaxis()->GetXmax() << endl; |
324 |
< |
} |
325 |
< |
if(h_tag->GetXaxis()->GetXmin() != h_probe->GetXaxis()->GetXmin()){ |
326 |
< |
cout<<"WARNING: the lower x-range of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl; |
327 |
< |
cout<<"Number of bins (Tag | Probe): " << h_tag->GetXaxis()->GetXmin() << " | " << h_probe->GetXaxis()->GetXmin() << endl; |
312 |
> |
//p = passed; f = failed |
313 |
> |
// f(eff) = p/(p+f) |
314 |
> |
// df/dt = 1/(p+f) - p/(p+f)^2 |
315 |
> |
// df/dp = - p/(p+f)^2 |
316 |
> |
// eff_sig = sqrt(p_sig^2*(df/dp)^2 + f_sig^2*(df/df)^2) |
317 |
> |
void setEfficiencyErrors(TH1D* &eff, TH1D* &h_passed, TH1D* &h_failed){ |
318 |
> |
if(h_passed->GetNbinsX() != h_failed->GetNbinsX()){ |
319 |
> |
cout<<"WARNING: the number of bins of the passed and failed histograms differ! The efficiency calculation might be depricated!"<<endl; |
320 |
> |
cout<<"Number of bins (passed | failed): " << h_passed->GetNbinsX() << " | " << h_failed->GetNbinsX() << endl; |
321 |
> |
} |
322 |
> |
if(h_passed->GetXaxis()->GetXmax() != h_failed->GetXaxis()->GetXmax()){ |
323 |
> |
cout<<"WARNING: the upper x-range of the passed and failed histograms differ! The efficiency calculation might be depricated!"<<endl; |
324 |
> |
cout<<"Number of bins (passed | failed): " << h_passed->GetXaxis()->GetXmax() << " | " << h_failed->GetXaxis()->GetXmax() << endl; |
325 |
> |
} |
326 |
> |
if(h_passed->GetXaxis()->GetXmin() != h_failed->GetXaxis()->GetXmin()){ |
327 |
> |
cout<<"WARNING: the lower x-range of the passed and failed histograms differ! The efficiency calculation might be depricated!"<<endl; |
328 |
> |
cout<<"Number of bins (passed | failed): " << h_passed->GetXaxis()->GetXmin() << " | " << h_failed->GetXaxis()->GetXmin() << endl; |
329 |
|
} |
330 |
|
//loop over single bins of histograms an set the efficiency error |
331 |
< |
for(Int_t i=1,N=h_tag->GetNbinsX(); i<=N; ++i){ |
332 |
< |
Double_t t = h_tag ->GetBinContent(i); |
333 |
< |
Double_t p = h_probe->GetBinContent(i); |
334 |
< |
Double_t t_sig = h_tag ->GetBinError(i); |
335 |
< |
Double_t p_sig = h_probe->GetBinError(i); |
331 |
> |
for(Int_t i=1,N=h_passed->GetNbinsX(); i<=N; ++i){ |
332 |
> |
Double_t p = h_passed ->GetBinContent(i); |
333 |
> |
Double_t f = h_failed->GetBinContent(i); |
334 |
> |
Double_t p_sig = h_passed ->GetBinError(i); |
335 |
> |
Double_t f_sig = h_failed->GetBinError(i); |
336 |
|
|
337 |
|
if(eff->GetBinContent(i)==0.) continue; |
338 |
|
|
339 |
< |
Double_t dedt = 1/(t+p)-t/((t+p)*(t+p)); |
340 |
< |
Double_t dedp = -t/((t+p)*(t+p)); |
339 |
> |
Double_t dedt = 1/(p+f)-p/((p+f)*(p+f)); |
340 |
> |
Double_t dedp = -p/((p+f)*(p+f)); |
341 |
|
|
342 |
< |
Double_t eff_sig = sqrt(t_sig*t_sig*dedt*dedt + p_sig*p_sig*dedp*dedp); |
342 |
> |
Double_t eff_sig = sqrt(p_sig*p_sig*dedt*dedt + f_sig*f_sig*dedp*dedp); |
343 |
|
eff->SetBinError(i, eff_sig); |
344 |
|
} |
345 |
|
} |
370 |
|
cout<<"-------------------------------------------------------------------------------"<<endl; |
371 |
|
cout<<endl; |
372 |
|
cout<<"Looping over events..."<<endl; |
373 |
< |
// nEvents=50000; |
373 |
> |
nEvents=50000; |
374 |
|
for (int iEvent=0; iEvent<nEvents; ++iEvent){ |
375 |
|
tools::progress(iEvent); |
376 |
|
inputTree->GetEntry(iEvent); |
592 |
|
|
593 |
|
|
594 |
|
|
595 |
+ |
|
596 |
+ |
|
597 |
+ |
|
598 |
+ |
|
599 |
+ |
|
600 |
+ |
//Thats another version of implementing the T&P method |
601 |
+ |
//This version uses ALL Objects within an event to extract the trigger efficiency. |
602 |
+ |
//However, this method leads to a more complex treatment of the counting and the error propagation. |
603 |
+ |
//The advantage is higher statistict. But the statistis is anayhow large enough... |
604 |
+ |
// //================================================================================= investigateTriggerFilterMu |
605 |
+ |
// // eff = 2*NTT / (2*NTT + NTP) |
606 |
+ |
// void investigateTriggerFilterMu(eventInfo& evt, map<TString, plotMaker> &plot, TString filterName){ |
607 |
+ |
// //create vector which stores, if a muon is matched to the trigger filter with the name "filterName" |
608 |
+ |
// vector<bool> matched; |
609 |
+ |
// vector<int> probeIndex; |
610 |
+ |
// for(Int_t i=0,N=evt.muonP4->size(); i<N; ++i){ |
611 |
+ |
// matched.push_back(false); |
612 |
+ |
// for(Int_t j=0,M=evt.triggerFilterMu.at(i).size(); j<M; ++j){ |
613 |
+ |
// if(filterName == evt.triggerFilterMu.at(i).at(j)){ |
614 |
+ |
// matched.back() = true; |
615 |
+ |
// break; |
616 |
+ |
// } |
617 |
+ |
// } |
618 |
+ |
// if(!matched.at(i)) probeIndex.push_back(i); |
619 |
+ |
// } |
620 |
+ |
// |
621 |
+ |
// if(probeIndex.size()>2){ |
622 |
+ |
// cout<<"WARNING: Something is awkward with the number of Probe leptons: " << probeIndex.size() << endl; |
623 |
+ |
// cout<<"The number of probe leptons is expected to be 1 or 2, because here a T&P method is applied!" << endl; |
624 |
+ |
// } |
625 |
+ |
// else if(probeIndex.size()==2) return; //make only plots if at least one Tag exists in an event |
626 |
+ |
// |
627 |
+ |
// //Fill the Tag histograms |
628 |
+ |
// //here, we have TWO Tag leptons -> use BOTH for the efficiency |
629 |
+ |
// if(probeIndex.size()==0){ |
630 |
+ |
// for(Int_t i=0,N=evt.muonP4->size(); i<N; ++i){ |
631 |
+ |
// plot[filterName].addh1d("pt_tag", "pt_tag", "p_{T}(tag) [GeV/c]", "events", binPt, lowPt, upPt, evt.muonP4->at(i).Pt(), evt.Weight); |
632 |
+ |
// plot[filterName].addh1d("eta_tag", "eta_tag", "#eta(tag)", "events", binEta, lowEta, upEta, evt.muonP4->at(i).eta(), evt.Weight); |
633 |
+ |
// } |
634 |
+ |
// //the factor of '2' is due to the fact, that there are two matched tag leptons |
635 |
+ |
// plot[filterName].addh1d("PUVertices_tag", "PUVertices_tag", "number of primary vertices (tag)", "events", binPU, lowPU, upPU, evt.PUInter, 2*evt.Weight); |
636 |
+ |
// } |
637 |
+ |
// |
638 |
+ |
// //Fill the Probe histograms |
639 |
+ |
// //here, we have ONE Tag lepton -> the probe is NOT matched to the trigger filter |
640 |
+ |
// if(probeIndex.size()==1){ |
641 |
+ |
// plot[filterName].addh1d("pt_probe", "pt_probe", "p_{T}(probe) [GeV/c]", "events", binPt, lowPt, upPt, evt.muonP4->at(probeIndex.back()).pt(), evt.Weight); |
642 |
+ |
// plot[filterName].addh1d("eta_probe", "eta_probe", "#eta(probe)", "events", binEta, lowEta, upEta, evt.muonP4->at(probeIndex.back()).eta(), evt.Weight); |
643 |
+ |
// plot[filterName].addh1d("PUVertices_probe", "PUVertices_probe", "number of primary vertices (probe)", "events", binPU, lowPU, upPU, evt.PUInter, evt.Weight); |
644 |
+ |
// } |
645 |
+ |
// } |
646 |
+ |
// |
647 |
+ |
// |
648 |
+ |
// //================================================================================= makeEfficiencyPlots |
649 |
+ |
// //eff = tag/(tag+probe) |
650 |
+ |
// void makeEfficiencyPlots(map<TString, plotMaker> &plot){ |
651 |
+ |
// cout<<"----------> Create efficiency histograms"<<endl; |
652 |
+ |
// |
653 |
+ |
// vector<string> allTriggerFiltersToCheck = triggerFilterToCheckMu; |
654 |
+ |
// for(Int_t i=0,N=triggerFilterToCheckEl.size(); i<N; ++i){ |
655 |
+ |
// allTriggerFiltersToCheck.push_back(triggerFilterToCheckEl.at(i)); |
656 |
+ |
// } |
657 |
+ |
// vector<string> histNames; |
658 |
+ |
// histNames.push_back("pt_tag"); |
659 |
+ |
// histNames.push_back("eta_tag"); |
660 |
+ |
// histNames.push_back("PUVertices_tag"); |
661 |
+ |
// |
662 |
+ |
// for(Int_t i=0,N=allTriggerFiltersToCheck.size(); i<N; ++i){ |
663 |
+ |
// TString triggerFilter = allTriggerFiltersToCheck.at(i); |
664 |
+ |
// for(Int_t j=0,M=histNames.size(); j<M; ++j){ |
665 |
+ |
// TString tagName = histNames.at(j); |
666 |
+ |
// TString probeName = histNames.at(j); |
667 |
+ |
// TString effName = histNames.at(j); |
668 |
+ |
// probeName.ReplaceAll("tag", "probe"); |
669 |
+ |
// effName.ReplaceAll("tag", "eff"); |
670 |
+ |
// if(plot[triggerFilter].isNewh1d(tagName)) continue; |
671 |
+ |
// if(plot[triggerFilter].isNewh1d(probeName)) continue; |
672 |
+ |
// |
673 |
+ |
// TH1D *h_tag = (TH1D*)(plot[triggerFilter].h1d[tagName])->Clone(); |
674 |
+ |
// TH1D *h_probe = (TH1D*)(plot[triggerFilter].h1d[probeName])->Clone(); |
675 |
+ |
// TH1D *den = (TH1D*)(h_tag)->Clone(); |
676 |
+ |
// den->Add((TH1D*)(h_probe)->Clone()); |
677 |
+ |
// |
678 |
+ |
// TH1D *eff = (TH1D*)(h_tag)->Clone(); |
679 |
+ |
// eff->Divide(den); |
680 |
+ |
// setEfficiencyErrors(eff, h_tag, h_probe); |
681 |
+ |
// |
682 |
+ |
// eff->SetName(effName); |
683 |
+ |
// eff->SetTitle(effName); |
684 |
+ |
// |
685 |
+ |
// TString xTitle_eff = eff->GetXaxis()->GetTitle(); |
686 |
+ |
// xTitle_eff.ReplaceAll("(tag)",""); |
687 |
+ |
// eff->GetXaxis()->SetTitle(xTitle_eff); |
688 |
+ |
// eff->GetYaxis()->SetTitle("efficiency"); |
689 |
+ |
// //eff->SetAxisRange(0.,1.,"Y"); |
690 |
+ |
// plot[triggerFilter].addh1d(eff); |
691 |
+ |
// } |
692 |
+ |
// } |
693 |
+ |
// } |
694 |
+ |
// |
695 |
+ |
// |
696 |
+ |
// //================================================================================= setEfficiencyErrors |
697 |
+ |
// // f(eff) = t/(t+p) |
698 |
+ |
// // df/dt = 1/(t+p) - t/(t+p)^2 |
699 |
+ |
// // df/dp = - t/(t+p)^2 |
700 |
+ |
// // eff_sig = sqrt(t_sig^2*(df/dt)^2 + p_sig^2*(df/dp)^2) |
701 |
+ |
// void setEfficiencyErrors(TH1D* &eff, TH1D* &h_tag, TH1D* &h_probe){ |
702 |
+ |
// if(h_tag->GetNbinsX() != h_probe->GetNbinsX()){ |
703 |
+ |
// cout<<"WARNING: the number of bins of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl; |
704 |
+ |
// cout<<"Number of bins (Tag | Probe): " << h_tag->GetNbinsX() << " | " << h_probe->GetNbinsX() << endl; |
705 |
+ |
// } |
706 |
+ |
// if(h_tag->GetXaxis()->GetXmax() != h_probe->GetXaxis()->GetXmax()){ |
707 |
+ |
// cout<<"WARNING: the upper x-range of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl; |
708 |
+ |
// cout<<"Number of bins (Tag | Probe): " << h_tag->GetXaxis()->GetXmax() << " | " << h_probe->GetXaxis()->GetXmax() << endl; |
709 |
+ |
// } |
710 |
+ |
// if(h_tag->GetXaxis()->GetXmin() != h_probe->GetXaxis()->GetXmin()){ |
711 |
+ |
// cout<<"WARNING: the lower x-range of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl; |
712 |
+ |
// cout<<"Number of bins (Tag | Probe): " << h_tag->GetXaxis()->GetXmin() << " | " << h_probe->GetXaxis()->GetXmin() << endl; |
713 |
+ |
// } |
714 |
+ |
// //loop over single bins of histograms an set the efficiency error |
715 |
+ |
// for(Int_t i=1,N=h_tag->GetNbinsX(); i<=N; ++i){ |
716 |
+ |
// Double_t t = h_tag ->GetBinContent(i); |
717 |
+ |
// Double_t p = h_probe->GetBinContent(i); |
718 |
+ |
// Double_t t_sig = h_tag ->GetBinError(i); |
719 |
+ |
// Double_t p_sig = h_probe->GetBinError(i); |
720 |
+ |
// |
721 |
+ |
// if(eff->GetBinContent(i)==0.) continue; |
722 |
+ |
// |
723 |
+ |
// Double_t dedt = 1/(t+p)-t/((t+p)*(t+p)); |
724 |
+ |
// Double_t dedp = -t/((t+p)*(t+p)); |
725 |
+ |
// |
726 |
+ |
// Double_t eff_sig = sqrt(t_sig*t_sig*dedt*dedt + p_sig*p_sig*dedp*dedp); |
727 |
+ |
// eff->SetBinError(i, eff_sig); |
728 |
+ |
// } |
729 |
+ |
// } |
730 |
+ |
|
731 |
+ |
|
732 |
+ |
|
733 |
|
|
734 |
|
|
735 |
|
|