ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/mstein/triggerStudy/triggerStudy.C
(Generate patch)

Comparing UserCode/mstein/triggerStudy/triggerStudy.C (file contents):
Revision 1.4 by mstein, Thu Dec 6 10:36:16 2012 UTC vs.
Revision 1.5 by mstein, Thu Dec 6 12:27:27 2012 UTC

# Line 71 | Line 71 | void plotHistograms(eventInfo& evt, map<
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;
# Line 90 | Line 90 | const Double_t lowPU = 0.;
90   const Double_t upPU  = 64.;
91  
92  
93
93   //================================================================================= triggerStudy
94   //main function which will be called
95   //here, it is possible to run over multiple files and to estimate trigger efficiencies for different samples
96 < void triggerStudy(TString inputFileName = "TTJets_mu_tree.root"){
96 > void triggerStudy(){
97 >  
98 >  //--------------------------------------------------- define the muon TriggerFilters to be checked
99    triggerFilterToCheckMu.push_back("hltL1sMu16Eta2p1");
100    triggerFilterToCheckMu.push_back("hltL2fL1sMu16Eta2p1L1f0L2Filtered16Q");
101    triggerFilterToCheckMu.push_back("hltL3crIsoL1sMu16Eta2p1L1f0L2f16QL3f20L3crIsoFiltered10");
# Line 102 | Line 103 | void triggerStudy(TString inputFileName
103    triggerFilterToCheckMu.push_back("hltIsoMu202p1TriCentralPFJet303020MuCleaned");
104    triggerFilterToCheckMu.push_back("hltDiMuonGlb22Trk8DzFiltered0p2");  
105    triggerFilterToCheckMu.push_back("hltL3crIsoL1sMu14Eta2p1L1f0L2f16QL3f20L3crIsoRhoFiltered0p15");  
106 <
106 <  
106 >  //--------------------------------------------------- define the electron TriggerFilters to be checked
107   //   triggerFilterToCheckEl.push_back("hltL1sL1SingleEG20orL1SingleEG22");  
108   //   triggerFilterToCheckEl.push_back("hltEle25CaloIdVTTrkIdTCaloIsoTTrkIsoTTrackIsoFilter");  
109   //   triggerFilterToCheckEl.push_back("hltEle25CaloIdVTCaloIsoTTrkIdTTrkIsoTTriCentralPFJet30EleCleaned");  
110   //   triggerFilterToCheckEl.push_back("hltEle25CaloIdVTCaloIsoTTrkIdTTrkIsoTTriCentralPFNoPUJet30EleCleaned");  
111   //   triggerFilterToCheckEl.push_back("hltEle25CaloIdVTCaloIsoTTrkIdTTrkIsoTTriCentralPFNoPUJet303020EleCleaned");  
112    
113 <  TH1::SetDefaultSumw2();
114 <  
115 <  //Loop(inputFileName, outputFileName);
116 <  
117 <  inputFileName = "TTJets_mu_tree.root";
118 <  inputFileName = "TTJets_el_tree.root";
119 <  inputFileName = "DYJets_mu_tree.root";
120 <  inputFileName = "DYJets_el_tree.root";
121 <  
122 <  inputFileName = "TTJets_SUMMER12_TrigStudy-mu_noTail_Tree.root";
123 <  //inputFileName = "TTJets_SUMMER12_TrigStudy-el_noTail_Tree.root";
124 <  inputFileName = "DYJets_M-50_TrigStudy-mu_noTail_Tree.root";
125 <  //inputFileName = "DYJets_M-50_TrigStudy-el_noTail_Tree.root";  
126 <  
127 <  TString dir ="";
128 <  dir ="/scratch/hh/current/cms/user/mstein/output/";
129 <  Loop(dir + inputFileName, "out_"+inputFileName);
130 <  
113 >  //--------------------------------------------------- define the sample(s) to loop over and the output file
114 >  //these are small test files of ONE single file af a sample
115 > //   Loop("/scratch/hh/current/cms/user/mstein/output/TTJets_mu_tree.root", "out_TTJets_mu_tree.root");
116 > //   Loop("/scratch/hh/current/cms/user/mstein/output/TTJets_el_tree.root", "out_TTJets_el_tree.root");
117 > //  Loop("/scratch/hh/current/cms/user/mstein/output/DYJets_mu_tree.root", "out_DYJets_mu_tree.root");
118 > //   Loop("/scratch/hh/current/cms/user/mstein/output/DYJets_el_tree.root", "out_DYJets_el_tree.root");
119 > //   Loop("/scratch/hh/current/cms/user/mstein/output/SingleMu_mu_tree.root", "out_SingleMu_mu_tree.root");
120 > //   Loop("/scratch/hh/current/cms/user/mstein/output/SingleElectron_el_tree.root", "out_SingleElectron_el_tree.root");
121 >  //these are the whole samples
122 > //   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");
123 > //   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");
124 >   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");
125 > //   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");
126 > //   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");
127 > //   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");
128  
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");
136
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  
129    
144  
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");
130   }
131  
132  
# Line 165 | Line 146 | void plotHistograms(eventInfo& evt, map<
146  
147  
148   //================================================================================= investigateTriggerFilterMu
149 < // eff = 2*NTT / (2*NTT + NTP)
150 < void investigateTriggerFilterMu(eventInfo& evt, map<TString, plotMaker> &plot, TString filterName){
151 <  //create vector which stores, if a muon is matched to the trigger filter with the name "filterName"
149 > //check, if the positive lepton can be matched to the trigger filter
150 > //if yes, take this lepton as Tag
151 > //then probe the other lepton
152 > void investigateTriggerFilterMu(eventInfo& evt, map<TString, plotMaker> &plot, TString filterName, TString label){
153 >  //--------------------------------------------------- do some consistency check - just to be sure
154 >  if(evt.muonP4->size() != 2){
155 >    cout<<"WARNING: The size of the muon vector is NOT two!"<<endl;
156 >    cout<<"evt.muonP4->size()          = " << evt.muonP4->size() << endl;
157 >    return;
158 >  }  
159 >  if(evt.muonP4->size() != evt.triggerFilterMu.size()){
160 >    cout<<"WARNING: The size of the muon vector and Matching-info vector is different!"<<endl;
161 >    cout<<"evt.muonP4->size()         = " << evt.muonP4->size() << endl;
162 >    cout<<"evt.triggerFilterMu.size() = " << evt.triggerFilterMu.size() << endl;
163 >    return;
164 >  }
165 >  if(evt.muonP4->size() != evt.muonCharge->size()){
166 >    cout<<"WARNING: The size of the muon vector and muon-charge vector is different!"<<endl;
167 >    cout<<"evt.muonP4->size()     = " << evt.muonP4->size() << endl;
168 >    cout<<"evt.muonCharge->size() = " << evt.muonCharge->size() << endl;
169 >    return;
170 >  }
171 > //   if(evt.electronP4->size() != evt.triggerFilterEl.size()){
172 > //     cout<<"WARNING: The size of the electron vector and Matching-info vector is different!"
173 > //     cout<<"evt.electronP4->size()      = " << evt.electronP4->size() << endl;
174 > //     cout<<"evt.triggerFilterEl->size() = " << evt.triggerFilterEl->size() << endl;
175 > //     return;
176 > //   }
177 > //   if(evt.electronP4->size() != evt.electronP4.size()){
178 > //     cout<<"WARNING: The size of the electron vector and muon-charge vector is different!"
179 > //     cout<<"evt.electronP4->size() = " << evt.electronP4->size() << endl;
180 > //     cout<<"evt.electronP4->size() = " << evt.electronP4->size() << endl;
181 > //     return;
182 > //   }
183 >  //--------------------------------------------------- check which lepton has positive and which negative charge
184 >  Int_t index_pos = 0;
185 >  Int_t index_neg = 1;  
186 >  if(evt.muonCharge->at(0)==-1){
187 >    index_pos = 0;
188 >    index_pos = 1;
189 >  }
190 >  //--------------------------------------------------- check which lepton has been matched to the trigger filter
191    vector<bool> matched;
172  vector<int> probeIndex;
192    for(Int_t i=0,N=evt.muonP4->size(); i<N; ++i){
193      matched.push_back(false);
194      for(Int_t j=0,M=evt.triggerFilterMu.at(i).size(); j<M; ++j){
# Line 178 | Line 197 | void investigateTriggerFilterMu(eventInf
197          break;
198        }
199      }
181    if(!matched.at(i)) probeIndex.push_back(i);
200    }
201 +  //--------------------------------------------------- do the plotting according to the outcome, which lepton could be matched
202    
203 <  if(probeIndex.size()>2){
204 <    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
203 >  //if the positive lepton IS NOT matched => no Tag found => return
204 >  if(!matched.at(index_pos)) return;
205    
206 <  //Fill the Tag histograms
207 <  //here, we have TWO Tag leptons -> use BOTH for the efficiency
208 <  if(probeIndex.size()==0){
209 <    for(Int_t i=0,N=evt.muonP4->size(); i<N; ++i){
210 <      plot[filterName].addh1d("pt_tag", "pt_tag", "p_{T}(tag) [GeV/c]", "events", binPt, lowPt, upPt, evt.muonP4->at(i).Pt(), evt.Weight);
211 <      plot[filterName].addh1d("eta_tag", "eta_tag", "#eta(tag)", "events", binEta, lowEta, upEta, evt.muonP4->at(i).eta(), evt.Weight);
212 <    }
213 <    //the factor of '2' is due to the fact, that there are two matched tag leptons
214 <    plot[filterName].addh1d("PUVertices_tag", "PUVertices_tag", "number of primary vertices (tag)", "events", binPU, lowPU, upPU, evt.PUInter, 2*evt.Weight);
215 <  }
216 <
217 <  //Fill the Probe histograms
218 <  //here, we have ONE Tag lepton -> the probe is NOT matched to the trigger filter  
219 <  if(probeIndex.size()==1){
220 <    plot[filterName].addh1d("pt_probe", "pt_probe", "p_{T}(probe) [GeV/c]", "events", binPt, lowPt, upPt, evt.muonP4->at(probeIndex.back()).pt(), evt.Weight);    
221 <    plot[filterName].addh1d("eta_probe", "eta_probe", "#eta(probe)", "events", binEta, lowEta, upEta, evt.muonP4->at(probeIndex.back()).eta(), evt.Weight);
222 <    plot[filterName].addh1d("PUVertices_probe", "PUVertices_probe", "number of primary vertices (probe)", "events", binPU, lowPU, upPU, evt.PUInter, evt.Weight);
206 >  //if the positive lepton IS matched => plot Tag and Probe, and passed and failed
207 >  //plot the Tag
208 >  plot[filterName].addh1d(filterName+"_pt_tag", filterName+"_pt_tag", "p_{T}(tag) [GeV/c]", "events", binPt, lowPt, upPt, evt.muonP4->at(index_pos).Pt(), evt.Weight);
209 >  plot[filterName].addh1d(filterName+"_eta_tag", filterName+"_eta_tag", "#eta(tag)", "events", binEta, lowEta, upEta, evt.muonP4->at(index_pos).eta(), evt.Weight);
210 >  //plot the Probe
211 >  plot[filterName].addh1d(filterName+"_pt_probe", filterName+"_pt_probe", "p_{T}(probe) [GeV/c]", "events", binPt, lowPt, upPt, evt.muonP4->at(index_neg).pt(), evt.Weight);    
212 >  plot[filterName].addh1d(filterName+"_eta_probe", filterName+"_eta_probe", "#eta(probe)", "events", binEta, lowEta, upEta, evt.muonP4->at(index_neg).eta(), evt.Weight);
213 >  //plot the passed
214 >  if(matched.at(index_neg)){
215 >    plot[filterName].addh1d(filterName+"_pt_passed", filterName+"_pt_passed", "p_{T}(passed) [GeV/c]", "events", binPt, lowPt, upPt, evt.muonP4->at(index_neg).pt(), evt.Weight);    
216 >    plot[filterName].addh1d(filterName+"_eta_passed", filterName+"_eta_passed", "#eta(passed)", "events", binEta, lowEta, upEta, evt.muonP4->at(index_neg).eta(), evt.Weight);
217 >    plot[filterName].addh1d(filterName+"_PUVertices_passed", filterName+"_PUVertices_passed", "number of primary vertices (passed)", "events", binPU, lowPU, upPU, evt.PUInter, evt.Weight);
218 >  }
219 >  else{//plot the failed
220 >    plot[filterName].addh1d(filterName+"_pt_failed", filterName+"_pt_failed", "p_{T}(failed) [GeV/c]", "events", binPt, lowPt, upPt, evt.muonP4->at(index_neg).pt(), evt.Weight);    
221 >    plot[filterName].addh1d(filterName+"_eta_failed", filterName+"_eta_failed", "#eta(failed)", "events", binEta, lowEta, upEta, evt.muonP4->at(index_neg).eta(), evt.Weight);
222 >    plot[filterName].addh1d(filterName+"_PUVertices_failed", filterName+"_PUVertices_failed", "number of primary vertices (failed)", "events", binPU, lowPU, upPU, evt.PUInter, evt.Weight);
223    }
224   }
225  
226  
227   //================================================================================= makeEfficiencyPlots
228 < //eff = tag/(tag+probe)
228 > //eff = passed/(passed+failed)
229   void makeEfficiencyPlots(map<TString, plotMaker> &plot){
230    cout<<"----------> Create efficiency histograms"<<endl;
231  
# Line 218 | Line 234 | void makeEfficiencyPlots(map<TString, pl
234      allTriggerFiltersToCheck.push_back(triggerFilterToCheckEl.at(i));
235    }
236    vector<string> histNames;
237 <  histNames.push_back("pt_tag");
238 <  histNames.push_back("eta_tag");
239 <  histNames.push_back("PUVertices_tag");
237 >  histNames.push_back("_pt_passed");
238 >  histNames.push_back("_eta_passed");
239 >  histNames.push_back("_PUVertices_passed");
240    
241    for(Int_t i=0,N=allTriggerFiltersToCheck.size(); i<N; ++i){
242      TString triggerFilter = allTriggerFiltersToCheck.at(i);
243      for(Int_t j=0,M=histNames.size(); j<M; ++j){
244 <      TString tagName   = histNames.at(j);
245 <      TString probeName = histNames.at(j);
246 <      TString effName   = histNames.at(j);
247 <      probeName.ReplaceAll("tag", "probe");
248 <      effName.ReplaceAll("tag", "eff");
249 <      if(plot[triggerFilter].isNewh1d(tagName)) continue;
250 <      if(plot[triggerFilter].isNewh1d(probeName)) continue;
251 <
252 <      TH1D *h_tag   = (TH1D*)(plot[triggerFilter].h1d[tagName])->Clone();
253 <      TH1D *h_probe = (TH1D*)(plot[triggerFilter].h1d[probeName])->Clone();
254 <      TH1D *den = (TH1D*)(h_tag)->Clone();
255 <      den->Add((TH1D*)(h_probe)->Clone());
244 >      TString passedName = triggerFilter;
245 >      TString failedName = triggerFilter;
246 >      TString effName    = triggerFilter;
247 >      passedName += histNames.at(j);
248 >      failedName += histNames.at(j);
249 >      effName += histNames.at(j);
250 >      failedName.ReplaceAll("passed", "failed");
251 >      effName.ReplaceAll("passed", "eff");
252 >
253 >      if(plot[triggerFilter].isNewh1d(passedName)) continue;
254 >      if(plot[triggerFilter].isNewh1d(failedName)) continue;
255 >
256 >      TH1D *h_passed = (TH1D*)(plot[triggerFilter].h1d[passedName])->Clone();
257 >      TH1D *h_failed = (TH1D*)(plot[triggerFilter].h1d[failedName])->Clone();
258 >      TH1D *den = (TH1D*)(h_passed)->Clone();
259 >      den->Add((TH1D*)(h_failed)->Clone());
260  
261 <      TH1D *eff = (TH1D*)(h_tag)->Clone();
261 >      TH1D *eff = (TH1D*)(h_passed)->Clone();
262        eff->Divide(den);
263 <      setEfficiencyErrors(eff, h_tag, h_probe);
263 >      setEfficiencyErrors(eff, h_passed, h_failed);
264        
265        eff->SetName(effName);
266        eff->SetTitle(effName);
267        
268        TString xTitle_eff = eff->GetXaxis()->GetTitle();
269 <      xTitle_eff.ReplaceAll("(tag)","");
269 >      xTitle_eff.ReplaceAll("(passed)","");
270        eff->GetXaxis()->SetTitle(xTitle_eff);
271        eff->GetYaxis()->SetTitle("efficiency");
272        //eff->SetAxisRange(0.,1.,"Y");
# Line 257 | Line 277 | void makeEfficiencyPlots(map<TString, pl
277  
278  
279   //================================================================================= setEfficiencyErrors
280 < // f(eff) = t/(t+p)
281 < // df/dt = 1/(t+p) - t/(t+p)^2
282 < // df/dp = - t/(t+p)^2
283 < // eff_sig = sqrt(t_sig^2*(df/dt)^2 + p_sig^2*(df/dp)^2)
284 < void setEfficiencyErrors(TH1D* &eff, TH1D* &h_tag, TH1D* &h_probe){
285 <  if(h_tag->GetNbinsX() !=  h_probe->GetNbinsX()){
286 <    cout<<"WARNING: the number of bins of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl;
287 <    cout<<"Number of bins (Tag | Probe): " << h_tag->GetNbinsX() << " | " << h_probe->GetNbinsX() << endl;
288 <  }
289 <  if(h_tag->GetXaxis()->GetXmax() !=  h_probe->GetXaxis()->GetXmax()){
290 <    cout<<"WARNING: the upper x-range of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl;
291 <    cout<<"Number of bins (Tag | Probe): " << h_tag->GetXaxis()->GetXmax() << " | " << h_probe->GetXaxis()->GetXmax() << endl;
292 <  }
293 <  if(h_tag->GetXaxis()->GetXmin() !=  h_probe->GetXaxis()->GetXmin()){
294 <    cout<<"WARNING: the lower x-range of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl;
295 <    cout<<"Number of bins (Tag | Probe): " << h_tag->GetXaxis()->GetXmin() << " | " << h_probe->GetXaxis()->GetXmin() << endl;
280 > //p = passed; f = failed
281 > // f(eff) = p/(p+f)
282 > // df/dt = 1/(p+f) - p/(p+f)^2
283 > // df/dp = - p/(p+f)^2
284 > // eff_sig = sqrt(p_sig^2*(df/dp)^2 + f_sig^2*(df/df)^2)
285 > void setEfficiencyErrors(TH1D* &eff, TH1D* &h_passed, TH1D* &h_failed){
286 >  if(h_passed->GetNbinsX() !=  h_failed->GetNbinsX()){
287 >    cout<<"WARNING: the number of bins of the passed and failed histograms differ! The efficiency calculation might be depricated!"<<endl;
288 >    cout<<"Number of bins (passed | failed): " << h_passed->GetNbinsX() << " | " << h_failed->GetNbinsX() << endl;
289 >  }
290 >  if(h_passed->GetXaxis()->GetXmax() !=  h_failed->GetXaxis()->GetXmax()){
291 >    cout<<"WARNING: the upper x-range of the passed and failed histograms differ! The efficiency calculation might be depricated!"<<endl;
292 >    cout<<"Number of bins (passed | failed): " << h_passed->GetXaxis()->GetXmax() << " | " << h_failed->GetXaxis()->GetXmax() << endl;
293 >  }
294 >  if(h_passed->GetXaxis()->GetXmin() !=  h_failed->GetXaxis()->GetXmin()){
295 >    cout<<"WARNING: the lower x-range of the passed and failed histograms differ! The efficiency calculation might be depricated!"<<endl;
296 >    cout<<"Number of bins (passed | failed): " << h_passed->GetXaxis()->GetXmin() << " | " << h_failed->GetXaxis()->GetXmin() << endl;
297    }
298    //loop over single bins of histograms an set the efficiency error
299 <  for(Int_t i=1,N=h_tag->GetNbinsX(); i<=N; ++i){
300 <    Double_t t = h_tag  ->GetBinContent(i);
301 <    Double_t p = h_probe->GetBinContent(i);
302 <    Double_t t_sig = h_tag  ->GetBinError(i);
303 <    Double_t p_sig = h_probe->GetBinError(i);
299 >  for(Int_t i=1,N=h_passed->GetNbinsX(); i<=N; ++i){
300 >    Double_t p = h_passed  ->GetBinContent(i);
301 >    Double_t f = h_failed->GetBinContent(i);
302 >    Double_t p_sig = h_passed  ->GetBinError(i);
303 >    Double_t f_sig = h_failed->GetBinError(i);
304      
305      if(eff->GetBinContent(i)==0.) continue;
306      
307 <    Double_t dedt = 1/(t+p)-t/((t+p)*(t+p));
308 <    Double_t dedp = -t/((t+p)*(t+p));
307 >    Double_t dedt = 1/(p+f)-p/((p+f)*(p+f));
308 >    Double_t dedp = -p/((p+f)*(p+f));
309      
310 <    Double_t eff_sig = sqrt(t_sig*t_sig*dedt*dedt + p_sig*p_sig*dedp*dedp);
310 >    Double_t eff_sig = sqrt(p_sig*p_sig*dedt*dedt + f_sig*f_sig*dedp*dedp);
311      eff->SetBinError(i, eff_sig);
312    }
313   }
# Line 317 | Line 338 | void Loop(TString inputFileName, TString
338    cout<<"-------------------------------------------------------------------------------"<<endl;
339    cout<<endl;
340    cout<<"Looping over events..."<<endl;
341 < //   nEvents=50000;
341 >  nEvents=50000;
342    for (int iEvent=0; iEvent<nEvents; ++iEvent){
343      tools::progress(iEvent);
344      inputTree->GetEntry(iEvent);
# Line 539 | Line 560 | void printElectronInfo(eventInfo& evt, o
560  
561  
562  
563 +
564 +
565 +
566 +
567 +
568 + //Thats another version of implementing the T&P method
569 + //This version uses ALL Objects within an event to extract the trigger efficiency.
570 + //However, this method leads to a more complex treatment of the counting and the error propagation.
571 + //The advantage is higher statistict. But the statistis is anayhow large enough...
572 + // //================================================================================= investigateTriggerFilterMu
573 + // // eff = 2*NTT / (2*NTT + NTP)
574 + // void investigateTriggerFilterMu(eventInfo& evt, map<TString, plotMaker> &plot, TString filterName){
575 + //   //create vector which stores, if a muon is matched to the trigger filter with the name "filterName"
576 + //   vector<bool> matched;
577 + //   vector<int> probeIndex;
578 + //   for(Int_t i=0,N=evt.muonP4->size(); i<N; ++i){
579 + //     matched.push_back(false);
580 + //     for(Int_t j=0,M=evt.triggerFilterMu.at(i).size(); j<M; ++j){
581 + //       if(filterName == evt.triggerFilterMu.at(i).at(j)){
582 + //      matched.back() = true;
583 + //      break;
584 + //       }
585 + //     }
586 + //     if(!matched.at(i)) probeIndex.push_back(i);
587 + //   }
588 + //  
589 + //   if(probeIndex.size()>2){
590 + //     cout<<"WARNING: Something is awkward with the number of Probe leptons: " << probeIndex.size() << endl;
591 + //     cout<<"The number of probe leptons is expected to be 1 or 2, because here a T&P method is applied!" << endl;
592 + //   }
593 + //   else if(probeIndex.size()==2) return; //make only plots if at least one Tag exists in an event
594 + //  
595 + //   //Fill the Tag histograms
596 + //   //here, we have TWO Tag leptons -> use BOTH for the efficiency
597 + //   if(probeIndex.size()==0){
598 + //     for(Int_t i=0,N=evt.muonP4->size(); i<N; ++i){
599 + //       plot[filterName].addh1d("pt_tag", "pt_tag", "p_{T}(tag) [GeV/c]", "events", binPt, lowPt, upPt, evt.muonP4->at(i).Pt(), evt.Weight);
600 + //       plot[filterName].addh1d("eta_tag", "eta_tag", "#eta(tag)", "events", binEta, lowEta, upEta, evt.muonP4->at(i).eta(), evt.Weight);
601 + //     }
602 + //     //the factor of '2' is due to the fact, that there are two matched tag leptons
603 + //     plot[filterName].addh1d("PUVertices_tag", "PUVertices_tag", "number of primary vertices (tag)", "events", binPU, lowPU, upPU, evt.PUInter, 2*evt.Weight);
604 + //   }
605 + //
606 + //   //Fill the Probe histograms
607 + //   //here, we have ONE Tag lepton -> the probe is NOT matched to the trigger filter  
608 + //   if(probeIndex.size()==1){
609 + //     plot[filterName].addh1d("pt_probe", "pt_probe", "p_{T}(probe) [GeV/c]", "events", binPt, lowPt, upPt, evt.muonP4->at(probeIndex.back()).pt(), evt.Weight);    
610 + //     plot[filterName].addh1d("eta_probe", "eta_probe", "#eta(probe)", "events", binEta, lowEta, upEta, evt.muonP4->at(probeIndex.back()).eta(), evt.Weight);
611 + //     plot[filterName].addh1d("PUVertices_probe", "PUVertices_probe", "number of primary vertices (probe)", "events", binPU, lowPU, upPU, evt.PUInter, evt.Weight);
612 + //   }
613 + // }
614 + //
615 + //
616 + // //================================================================================= makeEfficiencyPlots
617 + // //eff = tag/(tag+probe)
618 + // void makeEfficiencyPlots(map<TString, plotMaker> &plot){
619 + //   cout<<"----------> Create efficiency histograms"<<endl;
620 + //
621 + //   vector<string> allTriggerFiltersToCheck = triggerFilterToCheckMu;
622 + //   for(Int_t i=0,N=triggerFilterToCheckEl.size(); i<N; ++i){
623 + //     allTriggerFiltersToCheck.push_back(triggerFilterToCheckEl.at(i));
624 + //   }
625 + //   vector<string> histNames;
626 + //   histNames.push_back("pt_tag");
627 + //   histNames.push_back("eta_tag");
628 + //   histNames.push_back("PUVertices_tag");
629 + //  
630 + //   for(Int_t i=0,N=allTriggerFiltersToCheck.size(); i<N; ++i){
631 + //     TString triggerFilter = allTriggerFiltersToCheck.at(i);
632 + //     for(Int_t j=0,M=histNames.size(); j<M; ++j){
633 + //       TString tagName   = histNames.at(j);
634 + //       TString probeName = histNames.at(j);
635 + //       TString effName   = histNames.at(j);
636 + //       probeName.ReplaceAll("tag", "probe");
637 + //       effName.ReplaceAll("tag", "eff");
638 + //       if(plot[triggerFilter].isNewh1d(tagName)) continue;
639 + //       if(plot[triggerFilter].isNewh1d(probeName)) continue;
640 + //
641 + //       TH1D *h_tag   = (TH1D*)(plot[triggerFilter].h1d[tagName])->Clone();
642 + //       TH1D *h_probe = (TH1D*)(plot[triggerFilter].h1d[probeName])->Clone();
643 + //       TH1D *den = (TH1D*)(h_tag)->Clone();
644 + //       den->Add((TH1D*)(h_probe)->Clone());
645 + //
646 + //       TH1D *eff = (TH1D*)(h_tag)->Clone();
647 + //       eff->Divide(den);
648 + //       setEfficiencyErrors(eff, h_tag, h_probe);
649 + //      
650 + //       eff->SetName(effName);
651 + //       eff->SetTitle(effName);
652 + //      
653 + //       TString xTitle_eff = eff->GetXaxis()->GetTitle();
654 + //       xTitle_eff.ReplaceAll("(tag)","");
655 + //       eff->GetXaxis()->SetTitle(xTitle_eff);
656 + //       eff->GetYaxis()->SetTitle("efficiency");
657 + //       //eff->SetAxisRange(0.,1.,"Y");
658 + //       plot[triggerFilter].addh1d(eff);
659 + //     }
660 + //   }
661 + // }
662 + //
663 + //
664 + // //================================================================================= setEfficiencyErrors
665 + // // f(eff) = t/(t+p)
666 + // // df/dt = 1/(t+p) - t/(t+p)^2
667 + // // df/dp = - t/(t+p)^2
668 + // // eff_sig = sqrt(t_sig^2*(df/dt)^2 + p_sig^2*(df/dp)^2)
669 + // void setEfficiencyErrors(TH1D* &eff, TH1D* &h_tag, TH1D* &h_probe){
670 + //   if(h_tag->GetNbinsX() !=  h_probe->GetNbinsX()){
671 + //     cout<<"WARNING: the number of bins of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl;
672 + //     cout<<"Number of bins (Tag | Probe): " << h_tag->GetNbinsX() << " | " << h_probe->GetNbinsX() << endl;
673 + //   }
674 + //   if(h_tag->GetXaxis()->GetXmax() !=  h_probe->GetXaxis()->GetXmax()){
675 + //     cout<<"WARNING: the upper x-range of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl;
676 + //     cout<<"Number of bins (Tag | Probe): " << h_tag->GetXaxis()->GetXmax() << " | " << h_probe->GetXaxis()->GetXmax() << endl;
677 + //   }
678 + //   if(h_tag->GetXaxis()->GetXmin() !=  h_probe->GetXaxis()->GetXmin()){
679 + //     cout<<"WARNING: the lower x-range of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl;
680 + //     cout<<"Number of bins (Tag | Probe): " << h_tag->GetXaxis()->GetXmin() << " | " << h_probe->GetXaxis()->GetXmin() << endl;
681 + //   }
682 + //   //loop over single bins of histograms an set the efficiency error
683 + //   for(Int_t i=1,N=h_tag->GetNbinsX(); i<=N; ++i){
684 + //     Double_t t = h_tag  ->GetBinContent(i);
685 + //     Double_t p = h_probe->GetBinContent(i);
686 + //     Double_t t_sig = h_tag  ->GetBinError(i);
687 + //     Double_t p_sig = h_probe->GetBinError(i);
688 + //    
689 + //     if(eff->GetBinContent(i)==0.) continue;
690 + //    
691 + //     Double_t dedt = 1/(t+p)-t/((t+p)*(t+p));
692 + //     Double_t dedp = -t/((t+p)*(t+p));
693 + //    
694 + //     Double_t eff_sig = sqrt(t_sig*t_sig*dedt*dedt + p_sig*p_sig*dedp*dedp);
695 + //     eff->SetBinError(i, eff_sig);
696 + //   }
697 + // }
698 +
699 +
700 +
701  
702  
703  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines