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.2 by mstein, Tue Nov 27 12:50:57 2012 UTC vs.
Revision 1.4 by mstein, Thu Dec 6 10:36:16 2012 UTC

# Line 1 | Line 1
1 + /////////////////////////////////////////////////////////
2 + //                  Trigger Study
3 + /////////////////////////////////////////////////////////
4 + //to run, execute: root run.C
5 + //
6 + //In this file, the implementation of the T&P method and
7 + //the evaluation of the trigger efficiency is performed.
8 + //some documentation can be found here:
9 + //https://twiki.cern.ch/twiki/bin/viewauth/CMSsandbox/MatthiasSteinTriggerStudy
10 +
11 +
12   #include <iostream>
13   #include <fstream>
14   #include <map>
# Line 6 | Line 17
17   #include <Math/LorentzVector.h>
18  
19   #include "TString.h"
20 + #include "TH1.h"
21 + #include "TH1D.h"
22   #include "TTree.h"
23   #include "TFile.h"
24  
# Line 27 | Line 40 | typedef ROOT::Math::LorentzVector<ROOT::
40   //--------------------------------------------------- Structure to store the whole event information in order to pass it to functions
41   struct eventInfo{
42    vector<string> *DESYtriggerElMatchedTriggerFilter;
43 <  vector<string> *DESYtriggerMuMatchedTriggerFilter;
43 >  vector<string> *DESYtriggerMuMatchedTriggerFilter;  
44    map<string, string> *DESYtriggerNameMap;
45    vector<int> *electronCharge;
46    vector<LorentzM> *electronP4;
# Line 39 | Line 52 | struct eventInfo{
52    vector<LorentzM> *muonP4;
53    map<string, int> *prescaled;
54    int Run;
55 +  int PUInter;
56    double PUWeight;
57    map<string, bool> *triggered;
58 +  vector<vector<TString> > triggerFilterEl;
59 +  vector<vector<TString> > triggerFilterMu;
60    double Weight;
61   };
62  
47
63   //--------------------------------------------------- functions
64   // void init(TString inputFileName);
65 + void handleTriggerMatchingInfo(eventInfo& evt);
66   void initBranches(TTree *tree, eventInfo &event);
67 < void initVariables();
67 > void investigateTriggerFilterMu(eventInfo& evt, map<TString, plotMaker> &plot, TString filterName);
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);
75 +
76 + //--------------------------------------------------- global Variables
77 + vector<string> triggerFilterToCheckMu;
78 + vector<string> triggerFilterToCheckEl;
79 + //----------------------------------------
80 + const Int_t    binPt = 25;
81 + const Double_t lowPt = 0.;
82 + const Double_t upPt  = 250.;
83 + //----------------------------------------
84 + const Int_t    binEta = 50;
85 + const Double_t lowEta = -2.5;
86 + const Double_t upEta  = 2.5;
87 + //----------------------------------------
88 + const Int_t    binPU = 64;
89 + const Double_t lowPU = 0.;
90 + const Double_t upPU  = 64.;
91 +
92  
93  
94   //================================================================================= triggerStudy
95   //main function which will be called
96   //here, it is possible to run over multiple files and to estimate trigger efficiencies for different samples
97 < void triggerStudy(TString inputFileName = "SusyCAF_Tree_9_1_UMa_out_tree.root"){  
98 <  //   init(inputFileName);
99 <  //Loop(inputFileName, "TTJets.root");
100 <  //   Loop("SusyCAF_Tree_n722_3403013856_out_tree.root", "TTJets.root");
101 <   Loop("TTJets_SUMMER12_TrigStudy-mu_noTail_Tree.root", "TTJets.root");
97 > void triggerStudy(TString inputFileName = "TTJets_mu_tree.root"){
98 >  triggerFilterToCheckMu.push_back("hltL1sMu16Eta2p1");
99 >  triggerFilterToCheckMu.push_back("hltL2fL1sMu16Eta2p1L1f0L2Filtered16Q");
100 >  triggerFilterToCheckMu.push_back("hltL3crIsoL1sMu16Eta2p1L1f0L2f16QL3f20L3crIsoFiltered10");
101 >  triggerFilterToCheckMu.push_back("hltIsoMu202p1TriCentralPFJet30MuCleaned");
102 >  triggerFilterToCheckMu.push_back("hltIsoMu202p1TriCentralPFJet303020MuCleaned");
103 >  triggerFilterToCheckMu.push_back("hltDiMuonGlb22Trk8DzFiltered0p2");  
104 >  triggerFilterToCheckMu.push_back("hltL3crIsoL1sMu14Eta2p1L1f0L2f16QL3f20L3crIsoRhoFiltered0p15");  
105 >
106 >  
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 +  
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");
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 +  
143 +  
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");
149   }
150  
# Line 74 | Line 154 | void plotHistograms(eventInfo& evt, map<
154    plot["event"].addh1d("muMultiplicity", "muMultiplicity", "muon multiplicity", "events", 5, -0.5, 4.5, evt.muonP4->size(), evt.Weight);
155    plot["event"].addh1d("elMultiplicity", "elMultiplicity", "electron multiplicity", "events", 5, -0.5, 4.5, evt.electronP4->size(), evt.Weight);
156    plot["event"].addh1d("jetMultiplicity", "jetMultiplicity", "jet multiplicity", "events", 10, -0.5, 9.5, evt.jetP4->size(), evt.Weight);
157 <    
158 <  
157 >
158 >  for(Int_t i=0,N=triggerFilterToCheckMu.size(); i<N; ++i){
159 >    investigateTriggerFilterMu(evt, plot, triggerFilterToCheckMu.at(i));
160 >  }
161 > //   for(Int_t i=0,N=triggerFilterToCheckEl.size(); i<N; ++i){
162 > //     investigateTriggerFilterEl(evt, plot, triggerFilterToCheckEl.at(i));
163 > //   }
164 > }
165 >
166 >
167 > //================================================================================= investigateTriggerFilterMu
168 > // eff = 2*NTT / (2*NTT + NTP)
169 > void investigateTriggerFilterMu(eventInfo& evt, map<TString, plotMaker> &plot, TString filterName){
170 >  //create vector which stores, if a muon is matched to the trigger filter with the name "filterName"
171 >  vector<bool> matched;
172 >  vector<int> probeIndex;
173 >  for(Int_t i=0,N=evt.muonP4->size(); i<N; ++i){
174 >    matched.push_back(false);
175 >    for(Int_t j=0,M=evt.triggerFilterMu.at(i).size(); j<M; ++j){
176 >      if(filterName == evt.triggerFilterMu.at(i).at(j)){
177 >        matched.back() = true;
178 >        break;
179 >      }
180 >    }
181 >    if(!matched.at(i)) probeIndex.push_back(i);
182 >  }
183    
184 +  if(probeIndex.size()>2){
185 +    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
189    
190 <    //     for(Int_t i=0,N=muonP4->size(); i<N; ++i){
191 < //       //cout<<"muonP4["<<i<<"] = " << (*muonP4)[i]<< endl;
192 < // //       myPlot.addh1d("MuPt", "MuPt", "p_T(#mu)  [GeV]", "events", 100, 0., 300., muonP4->at(i).pt(), Weight);
193 < //       //myPlot.h1d ("MuPt", "MuPt", "p_T(#mu)  [GeV]", "events", 100, 0., 300., muonP4->at(i).pt(), Weight);
194 < //      
195 < //       //cout<<"myPlot.h1d.size() = " << myPlot.h1d.size() << endl;
196 < //      
197 < //     }
190 >  //Fill the Tag histograms
191 >  //here, we have TWO Tag leptons -> use BOTH for the efficiency
192 >  if(probeIndex.size()==0){
193 >    for(Int_t i=0,N=evt.muonP4->size(); i<N; ++i){
194 >      plot[filterName].addh1d("pt_tag", "pt_tag", "p_{T}(tag) [GeV/c]", "events", binPt, lowPt, upPt, evt.muonP4->at(i).Pt(), evt.Weight);
195 >      plot[filterName].addh1d("eta_tag", "eta_tag", "#eta(tag)", "events", binEta, lowEta, upEta, evt.muonP4->at(i).eta(), evt.Weight);
196 >    }
197 >    //the factor of '2' is due to the fact, that there are two matched tag leptons
198 >    plot[filterName].addh1d("PUVertices_tag", "PUVertices_tag", "number of primary vertices (tag)", "events", binPU, lowPU, upPU, evt.PUInter, 2*evt.Weight);
199 >  }
200 >
201 >  //Fill the Probe histograms
202 >  //here, we have ONE Tag lepton -> the probe is NOT matched to the trigger filter  
203 >  if(probeIndex.size()==1){
204 >    plot[filterName].addh1d("pt_probe", "pt_probe", "p_{T}(probe) [GeV/c]", "events", binPt, lowPt, upPt, evt.muonP4->at(probeIndex.back()).pt(), evt.Weight);    
205 >    plot[filterName].addh1d("eta_probe", "eta_probe", "#eta(probe)", "events", binEta, lowEta, upEta, evt.muonP4->at(probeIndex.back()).eta(), evt.Weight);
206 >    plot[filterName].addh1d("PUVertices_probe", "PUVertices_probe", "number of primary vertices (probe)", "events", binPU, lowPU, upPU, evt.PUInter, evt.Weight);
207 >  }
208 > }
209 >
210 >
211 > //================================================================================= makeEfficiencyPlots
212 > //eff = tag/(tag+probe)
213 > void makeEfficiencyPlots(map<TString, plotMaker> &plot){
214 >  cout<<"----------> Create efficiency histograms"<<endl;
215 >
216 >  vector<string> allTriggerFiltersToCheck = triggerFilterToCheckMu;
217 >  for(Int_t i=0,N=triggerFilterToCheckEl.size(); i<N; ++i){
218 >    allTriggerFiltersToCheck.push_back(triggerFilterToCheckEl.at(i));
219 >  }
220 >  vector<string> histNames;
221 >  histNames.push_back("pt_tag");
222 >  histNames.push_back("eta_tag");
223 >  histNames.push_back("PUVertices_tag");
224 >  
225 >  for(Int_t i=0,N=allTriggerFiltersToCheck.size(); i<N; ++i){
226 >    TString triggerFilter = allTriggerFiltersToCheck.at(i);
227 >    for(Int_t j=0,M=histNames.size(); j<M; ++j){
228 >      TString tagName   = histNames.at(j);
229 >      TString probeName = histNames.at(j);
230 >      TString effName   = histNames.at(j);
231 >      probeName.ReplaceAll("tag", "probe");
232 >      effName.ReplaceAll("tag", "eff");
233 >      if(plot[triggerFilter].isNewh1d(tagName)) continue;
234 >      if(plot[triggerFilter].isNewh1d(probeName)) continue;
235 >
236 >      TH1D *h_tag   = (TH1D*)(plot[triggerFilter].h1d[tagName])->Clone();
237 >      TH1D *h_probe = (TH1D*)(plot[triggerFilter].h1d[probeName])->Clone();
238 >      TH1D *den = (TH1D*)(h_tag)->Clone();
239 >      den->Add((TH1D*)(h_probe)->Clone());
240 >
241 >      TH1D *eff = (TH1D*)(h_tag)->Clone();
242 >      eff->Divide(den);
243 >      setEfficiencyErrors(eff, h_tag, h_probe);
244 >      
245 >      eff->SetName(effName);
246 >      eff->SetTitle(effName);
247 >      
248 >      TString xTitle_eff = eff->GetXaxis()->GetTitle();
249 >      xTitle_eff.ReplaceAll("(tag)","");
250 >      eff->GetXaxis()->SetTitle(xTitle_eff);
251 >      eff->GetYaxis()->SetTitle("efficiency");
252 >      //eff->SetAxisRange(0.,1.,"Y");
253 >      plot[triggerFilter].addh1d(eff);
254 >    }
255 >  }
256 > }
257 >
258 >
259 > //================================================================================= setEfficiencyErrors
260 > // f(eff) = t/(t+p)
261 > // df/dt = 1/(t+p) - t/(t+p)^2
262 > // df/dp = - t/(t+p)^2
263 > // eff_sig = sqrt(t_sig^2*(df/dt)^2 + p_sig^2*(df/dp)^2)
264 > void setEfficiencyErrors(TH1D* &eff, TH1D* &h_tag, TH1D* &h_probe){
265 >  if(h_tag->GetNbinsX() !=  h_probe->GetNbinsX()){
266 >    cout<<"WARNING: the number of bins of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl;
267 >    cout<<"Number of bins (Tag | Probe): " << h_tag->GetNbinsX() << " | " << h_probe->GetNbinsX() << endl;
268 >  }
269 >  if(h_tag->GetXaxis()->GetXmax() !=  h_probe->GetXaxis()->GetXmax()){
270 >    cout<<"WARNING: the upper x-range of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl;
271 >    cout<<"Number of bins (Tag | Probe): " << h_tag->GetXaxis()->GetXmax() << " | " << h_probe->GetXaxis()->GetXmax() << endl;
272 >  }
273 >  if(h_tag->GetXaxis()->GetXmin() !=  h_probe->GetXaxis()->GetXmin()){
274 >    cout<<"WARNING: the lower x-range of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl;
275 >    cout<<"Number of bins (Tag | Probe): " << h_tag->GetXaxis()->GetXmin() << " | " << h_probe->GetXaxis()->GetXmin() << endl;
276 >  }
277 >  //loop over single bins of histograms an set the efficiency error
278 >  for(Int_t i=1,N=h_tag->GetNbinsX(); i<=N; ++i){
279 >    Double_t t = h_tag  ->GetBinContent(i);
280 >    Double_t p = h_probe->GetBinContent(i);
281 >    Double_t t_sig = h_tag  ->GetBinError(i);
282 >    Double_t p_sig = h_probe->GetBinError(i);
283 >    
284 >    if(eff->GetBinContent(i)==0.) continue;
285 >    
286 >    Double_t dedt = 1/(t+p)-t/((t+p)*(t+p));
287 >    Double_t dedp = -t/((t+p)*(t+p));
288      
289 +    Double_t eff_sig = sqrt(t_sig*t_sig*dedt*dedt + p_sig*p_sig*dedp*dedp);
290 +    eff->SetBinError(i, eff_sig);
291 +  }
292   }
293  
294  
# Line 94 | Line 296 | void plotHistograms(eventInfo& evt, map<
296   void Loop(TString inputFileName, TString outputFileName){
297    //timer.Start("Loop");
298    TString treeName = "trigStudyTree";
299 <  map<TString, plotMaker> myPlots;
98 <  plotMaker myPlot;
299 >  map<TString, plotMaker> myPlots;      
300    
301    //--------------------------------------------------- open file and read in leafs
302    TFile* inputFile = new TFile(inputFileName,"READ");
303    if (!inputFile->IsOpen()) std::cout<<"Could not open file "<<inputFileName<<std::endl;
304    TTree* inputTree= (TTree*)inputFile->Get(treeName);
305 <  inputTree->SetBranchStatus("*",0);
105 <
305 >  
306    eventInfo event;
307    initBranches(inputTree, event);
308    //--------------------------------------------------- Event Loop
# Line 117 | Line 317 | void Loop(TString inputFileName, TString
317    cout<<"-------------------------------------------------------------------------------"<<endl;
318    cout<<endl;
319    cout<<"Looping over events..."<<endl;
320 + //   nEvents=50000;
321    for (int iEvent=0; iEvent<nEvents; ++iEvent){
322      tools::progress(iEvent);
323      inputTree->GetEntry(iEvent);
324 +    handleTriggerMatchingInfo(event);
325   //     printEventInfo(event);
326 < //     printMuonInfo(event);
327 < //     printElectronInfo(event);
326 > //      printMuonInfo(event);
327 >     //printElectronInfo(event);
328      plotHistograms(event, myPlots);
329      //tools::progressReset();
330    }
331    
332 < //   for (int iEvent=0; iEvent<3000; ++iEvent){
131 < //     tools::progress(iEvent);
132 < //     inputTree->GetEntry(iEvent);
133 < //     //printEventInfo(event);
134 < //     //printMuonInfo(event);
135 < //     //printElectronInfo(event);
136 < //     //plotHistograms(event, myPlots);
137 < //     //tools::progressReset();
138 < //   }
139 <  
332 >  makeEfficiencyPlots(myPlots);
333    //--------------------------------------------------- Save all histograms in the appropriate folders
334    TString option="RECREATE";
335    for(typename map<TString, plotMaker>::iterator it = myPlots.begin(); it != myPlots.end(); ++it){
# Line 147 | Line 340 | void Loop(TString inputFileName, TString
340   }
341  
342  
343 + //================================================================================= handleTriggerMatchingInfo
344 + // converting the trigger Info to a more practical format:  vector<string> --> vector<vector<string> >
345 + void handleTriggerMatchingInfo(eventInfo& evt){
346 +  evt.triggerFilterEl.clear();
347 +  evt.triggerFilterMu.clear();
348 +  //make simple check
349 +  
350 +  if(evt.electronP4->size() != evt.DESYtriggerElMatchedTriggerFilter->size()){
351 +    cout<<"WARNING: Size of electron vector does not correspond to size of matching info vector!"<<endl;
352 +    cout<<"evt.electronP4->size()                        = " << evt.electronP4->size() << endl;
353 +    cout<<"evt.DESYtriggerElMatchedTriggerFilter->size() = " << evt.DESYtriggerElMatchedTriggerFilter->size() << endl;
354 +    
355 +    tools::printVector("evt.electronP4", *(evt.electronP4));
356 +    tools::printVector("evt.DESYtriggerElMatchedTriggerFilter", *(evt.DESYtriggerElMatchedTriggerFilter));
357 +
358 +    return;
359 +  }
360 +  if(evt.muonP4->size() != evt.DESYtriggerMuMatchedTriggerFilter->size()){
361 +    cout<<"WARNING: Size of muon vector does not correspond to size of matching info vector!"<<endl;
362 +    cout<<"evt.muonP4->size()                            = " << evt.muonP4->size() << endl;
363 +    cout<<"evt.DESYtriggerMuMatchedTriggerFilter->size() = " << evt.DESYtriggerMuMatchedTriggerFilter->size() << endl;
364 +    return;
365 +  }
366 +  
367 +  for(Int_t i=0,N=evt.electronP4->size(); i<N; ++i){
368 +    evt.triggerFilterEl.push_back(tools::splitToWords(evt.DESYtriggerElMatchedTriggerFilter->at(i), ";"));
369 +    //cout<<"evt.DESYtriggerElMatchedTriggerFilter->at("<<i<<") = " << evt.DESYtriggerElMatchedTriggerFilter->at(i) << endl;
370 +    //tools::printVector<TString>("triggerFilterEl", evt.triggerFilterEl.at(i));
371 +  }
372 + //     printMuonInfo(evt);
373 + //     printElectronInfo(evt);
374 +    
375 +    //tools::printVector("evt.triggerFilterMu", evt.triggerFilterMu);
376 + //     tools::printVector("evt.DESYtriggerMuMatchedTriggerFilter", *(evt.DESYtriggerMuMatchedTriggerFilter));
377 + //     tools::printVector("evt.muonP4", *(evt.muonP4));
378 +    
379 +  for(Int_t i=0,N=evt.muonP4->size(); i<N; ++i){
380 +    evt.triggerFilterMu.push_back(tools::splitToWords(evt.DESYtriggerMuMatchedTriggerFilter->at(i), ";"));
381 +    //cout<<"evt.DESYtriggerMuMatchedTriggerFilter->at("<<i<<") = " << evt.DESYtriggerMuMatchedTriggerFilter->at(i) << endl;
382 +    //tools::printVector<TString>("triggerFilterMu", evt.triggerFilterMu.at(i));
383 +  }  
384 +  //cout<<"size: muonP4 | filterinfo = "
385 +  //<<evt.muonP4->size() << " | "
386 +  //<<evt.DESYtriggerMuMatchedTriggerFilter->size()
387 +  //<<endl;
388 + }
389 +
390 +
391   //================================================================================= initBranches
392   void initBranches(TTree *tree, eventInfo& evt){
393    //--------------------------------------------------- initialize event info
# Line 163 | Line 404 | void initBranches(TTree *tree, eventInfo
404    evt.muonP4                            = 0;
405    evt.prescaled                         = 0;
406    evt.Run                               = 0;
407 +  evt.PUInter                           = 0.;
408    evt.PUWeight                          = 0.;
409    evt.triggered                         = 0;
410    evt.Weight                            = 0.;
169  
170    
171 //   tree->SetBranchStatus("DESYtriggerElMatchedTriggerFilter", 1);
172 //   tree->SetBranchStatus("DESYtriggerMuMatchedTriggerFilter", 1);
173 //   tree->SetBranchStatus("DESYtriggerNameMap*", 1);
174 //   tree->SetBranchStatus("electronCharge", 1);
175 //   tree->SetBranchStatus("electronP4", 1);
176 //   tree->SetBranchStatus("Event", 1);
177 //   tree->SetBranchStatus("HT", 1);
178 //   tree->SetBranchStatus("jetP4", 1);
179 //   tree->SetBranchStatus("MET", 1);
180 //   tree->SetBranchStatus("muonCharge", 1);
181 //   tree->SetBranchStatus("muonP4", 1);
182 //   tree->SetBranchStatus("prescaled", 1);
183 //   tree->SetBranchStatus("Run", 1);
184 //   tree->SetBranchStatus("PUWeight", 1);
185 //   tree->SetBranchStatus("triggered", 1);
186 //   tree->SetBranchStatus("Weight", 1);
187
188  tree->SetBranchStatus("DESYtriggerElMatchedTriggerFilter*", 1);
189 tree->SetBranchStatus("DESYtriggerMuMatchedTriggerFilter*", 1);
190 tree->SetBranchStatus("DESYtriggerNameMap*", 1);
191 tree->SetBranchStatus("electronCharge*", 1);
192 tree->SetBranchStatus("electronP4*", 1);
193 tree->SetBranchStatus("Event*", 1);
194 tree->SetBranchStatus("HT*", 1);
195 tree->SetBranchStatus("jetP4*", 1);
196 tree->SetBranchStatus("MET*", 1);
197 tree->SetBranchStatus("muonCharge*", 1);
198 tree->SetBranchStatus("muonP4*", 1);
199 tree->SetBranchStatus("prescaled*", 1);
200 tree->SetBranchStatus("Run*", 1);
201 tree->SetBranchStatus("PUWeight*", 1);
202 tree->SetBranchStatus("triggered*", 1);
203 tree->SetBranchStatus("Weight*", 1);
204
205
411    //--------------------------------------------------- assign branches to event structure
412    tree->SetBranchAddress("DESYtriggerElMatchedTriggerFilter", &(evt.DESYtriggerElMatchedTriggerFilter));
413    tree->SetBranchAddress("DESYtriggerMuMatchedTriggerFilter",&(evt.DESYtriggerMuMatchedTriggerFilter));
# Line 217 | Line 422 | tree->SetBranchStatus("Weight*", 1);
422    tree->SetBranchAddress("muonP4",&(evt.muonP4));
423    tree->SetBranchAddress("prescaled",&(evt.prescaled));
424    tree->SetBranchAddress("Run",&(evt.Run));
425 +  tree->SetBranchAddress("PUInter",&(evt.PUInter));
426    tree->SetBranchAddress("PUWeight",&(evt.PUWeight));
427    tree->SetBranchAddress("triggered",&(evt.triggered));
428    tree->SetBranchAddress("Weight",&(evt.Weight));
223  
224  
225
226  
227
228  
229  
230 //   tree->SetBranchStatus("DESY*", 1);
231 //   tree->SetBranchStatus("muonP4", 1);
232 //   tree->SetBranchStatus("jetP4", 1);
233 //   tree->SetBranchStatus("electronP4", 1);
234 //   tree->SetBranchStatus("Weight", 1);
235      
429   }
430  
431  
# Line 248 | Line 441 | void printEventInfo(eventInfo& evt, ostr
441    os<<"Event    = "<<evt.Event<<endl;
442    os<<"Weight   = "<<evt.Weight<<endl;
443    os<<"PUWeight = "<<evt.PUWeight<<endl;
444 +  os<<"PUInter  = "<<evt.PUInter<<endl;
445    os<<"-----------------------------------------"<<endl;
446    os<<"HT               = "<<evt.HT<<endl;
447    os<<"MET              = "<<evt.MET<<endl;
# Line 298 | Line 492 | void printMuonInfo(eventInfo& evt, ostre
492      os<<endl;
493    }
494    //------------------------ print matching info
495 <  vector<string> matchInfo = *(evt.DESYtriggerMuMatchedTriggerFilter);
302 <  for(Int_t i=0,N=matchInfo.size(); i<N; ++i){
303 <    vector<TString> singleMatchInfo = tools::splitToWords(matchInfo[i], ";");
495 >  for(Int_t i=0,N=evt.muonP4->size(); i<N; ++i){
496      os<<"----------------------------------------------------------------------------> Matches for muon "<<i<<":"<<
497 <    endl;
498 <    tools::printVector<TString>("matched TriggerFilter", singleMatchInfo, os);
497 >    endl;
498 >    tools::printVector<TString>("matched TriggerFilter", evt.triggerFilterMu.at(i), os);
499    }
500    os<<endl;
501   }
# Line 330 | Line 522 | void printElectronInfo(eventInfo& evt, o
522      os<<endl;
523    }
524    //------------------------ print matching info
525 <  vector<string> matchInfo = *(evt.DESYtriggerElMatchedTriggerFilter);
334 <  for(Int_t i=0,N=matchInfo.size(); i<N; ++i){
335 <    vector<TString> singleMatchInfo = tools::splitToWords(matchInfo[i], ";");
525 >  for(Int_t i=0,N=evt.electronP4->size(); i<N; ++i){
526      os<<"----------------------------------------------------------------------------> Matches for electron "<<i<<":"<<
527 <    endl;
528 <    tools::printVector<TString>("matched TriggerFilter", singleMatchInfo, os);
527 >    endl;
528 >    tools::printVector<TString>("matched TriggerFilter", evt.triggerFilterEl.at(i), os);
529    }
530    os<<endl;
531   }
532  
533  
534  
345 //================================================================================= initVariables
346 void initVariables(){
347  //cout<<"dataset = " << dataset << endl;
348  //Candidates             .clear();
349 }
350
351
352
353
354
535  
536  
537  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines