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.1 by mstein, Thu Nov 22 15:32:47 2012 UTC vs.
Revision 1.3 by mstein, Wed Dec 5 13:10:34 2012 UTC

# Line 1 | Line 1
1 < #ifndef triggerStudy_cxx
2 < #define  triggerStudy_cxx
3 < #include "triggerStudy.h"
4 < #include "triggerStudy.cfg"
5 < #include "histo.h"
6 <
7 < //using namespace tools;
1 > #include <iostream>
2 > #include <fstream>
3 > #include <map>
4 > #include <vector>
5 >
6 > #include <Math/LorentzVector.h>
7 >
8 > #include "TString.h"
9 > #include "TH1.h"
10 > #include "TH1D.h"
11 > #include "TTree.h"
12 > #include "TFile.h"
13 >
14 > #include "plotMaker.h"
15 > #include "tools.h"
16 > //--------------------------------------------------- declare some special types
17 > #ifdef __MAKECINT__
18 > #pragma link C++ class pair<string,bool>+;
19 > #pragma link C++ class pair<string,string>+;
20 > #pragma link C++ class map<string,bool>+;
21 > #pragma link C++ class map<string,string>+;
22 > #pragma link C++ class ROOT::Math::PtEtaPhiM4D<float>+;
23 > #pragma link C++ class ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<float> >+;
24 > #pragma link C++ class vector<ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<float> > >+;
25 > #endif
26  
27 + typedef ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<float> > LorentzM;
28  
29 < //================================================================================= mainProgram
30 < void triggerStudy::mainProgram(){
31 <  tools::enterFcn("mainProgram",1);
32 <  Loop();
33 <  tools::exitFcn("mainProgram",1);
29 > //--------------------------------------------------- Structure to store the whole event information in order to pass it to functions
30 > struct eventInfo{
31 >  vector<string> *DESYtriggerElMatchedTriggerFilter;
32 >  vector<string> *DESYtriggerMuMatchedTriggerFilter;  
33 >  map<string, string> *DESYtriggerNameMap;
34 >  vector<int> *electronCharge;
35 >  vector<LorentzM> *electronP4;
36 >  int Event;
37 >  double HT;
38 >  vector<LorentzM> *jetP4;
39 >  double MET;
40 >  vector<int> *muonCharge;
41 >  vector<LorentzM> *muonP4;
42 >  map<string, int> *prescaled;
43 >  int Run;
44 >  int PUInter;
45 >  double PUWeight;
46 >  map<string, bool> *triggered;
47 >  vector<vector<TString> > triggerFilterEl;
48 >  vector<vector<TString> > triggerFilterMu;
49 >  double Weight;
50 > };
51 >
52 > //--------------------------------------------------- functions
53 > // void init(TString inputFileName);
54 > void handleTriggerMatchingInfo(eventInfo& evt);
55 > void initBranches(TTree *tree, eventInfo &event);
56 > void investigateTriggerFilterMu(eventInfo& evt, map<TString, plotMaker> &plot, TString filterName);
57 > void Loop(TString inputFileName, TString outputFileName);
58 > void makeEfficiencyPlots(map<TString, plotMaker> &plot);
59 > void plotHistograms(eventInfo& evt, map<TString, plotMaker> &plot);
60 > void printElectronInfo(eventInfo& evt, ostream& os=cout);
61 > void printEventInfo(eventInfo& evt, ostream& os=cout);
62 > void printMuonInfo(eventInfo& evt, ostream& os=cout);
63 > void setEfficiencyErrors(TH1D* &eff, TH1D* &h_tag, TH1D* &h_probe);
64 >
65 > //--------------------------------------------------- global Variables
66 > vector<string> triggerFilterToCheckMu;
67 > vector<string> triggerFilterToCheckEl;
68 > //----------------------------------------
69 > const Int_t    binPt = 25;
70 > const Double_t lowPt = 0.;
71 > const Double_t upPt  = 250.;
72 > //----------------------------------------
73 > const Int_t    binEta = 50;
74 > const Double_t lowEta = -2.5;
75 > const Double_t upEta  = 2.5;
76 > //----------------------------------------
77 > const Int_t    binPU = 64;
78 > const Double_t lowPU = 0.;
79 > const Double_t upPU  = 64.;
80 >
81 >
82 >
83 > //================================================================================= triggerStudy
84 > //main function which will be called
85 > //here, it is possible to run over multiple files and to estimate trigger efficiencies for different samples
86 > void triggerStudy(TString inputFileName = "TTJets_mu_tree.root"){
87 >  triggerFilterToCheckMu.push_back("hltL1sMu16Eta2p1");
88 >  triggerFilterToCheckMu.push_back("hltL2fL1sMu16Eta2p1L1f0L2Filtered16Q");
89 >  triggerFilterToCheckMu.push_back("hltL3crIsoL1sMu16Eta2p1L1f0L2f16QL3f20L3crIsoFiltered10");
90 >  triggerFilterToCheckMu.push_back("hltIsoMu202p1TriCentralPFJet30MuCleaned");
91 >  triggerFilterToCheckMu.push_back("hltIsoMu202p1TriCentralPFJet303020MuCleaned");
92 >  triggerFilterToCheckMu.push_back("hltDiMuonGlb22Trk8DzFiltered0p2");  
93 >  triggerFilterToCheckMu.push_back("hltL3crIsoL1sMu14Eta2p1L1f0L2f16QL3f20L3crIsoRhoFiltered0p15");  
94 >
95 >  
96 > //   triggerFilterToCheckEl.push_back("hltL1sL1SingleEG20orL1SingleEG22");  
97 > //   triggerFilterToCheckEl.push_back("hltEle25CaloIdVTTrkIdTCaloIsoTTrkIsoTTrackIsoFilter");  
98 > //   triggerFilterToCheckEl.push_back("hltEle25CaloIdVTCaloIsoTTrkIdTTrkIsoTTriCentralPFJet30EleCleaned");  
99 > //   triggerFilterToCheckEl.push_back("hltEle25CaloIdVTCaloIsoTTrkIdTTrkIsoTTriCentralPFNoPUJet30EleCleaned");  
100 > //   triggerFilterToCheckEl.push_back("hltEle25CaloIdVTCaloIsoTTrkIdTTrkIsoTTriCentralPFNoPUJet303020EleCleaned");  
101 >  
102 >  TH1::SetDefaultSumw2();
103 >  
104 >  //Loop(inputFileName, outputFileName);
105 >  
106 >  inputFileName = "TTJets_mu_tree.root";
107 >  inputFileName = "TTJets_el_tree.root";
108 >  inputFileName = "DYJets_mu_tree.root";
109 >  inputFileName = "DYJets_el_tree.root";
110 >  
111 >  inputFileName = "TTJets_SUMMER12_TrigStudy-mu_noTail_Tree.root";
112 >  //inputFileName = "TTJets_SUMMER12_TrigStudy-el_noTail_Tree.root";
113 >  inputFileName = "DYJets_M-50_TrigStudy-mu_noTail_Tree.root";
114 >  //inputFileName = "DYJets_M-50_TrigStudy-el_noTail_Tree.root";  
115 >  
116 >  TString dir ="";
117 >  dir ="/scratch/hh/current/cms/user/mstein/output/";
118 >  
119 >  Loop(dir + inputFileName, "out_"+inputFileName);
120 >
121 >  
122 >  
123 >  //Loop("/scratch/hh/current/cms/user/mstein/output/TTJets_SUMMER12_TrigStudy-mu_noTail_Tree.root", "out_TTJets_SUMMER12_TrigStudy-mu_noTail_Tree.root");
124 >    
125 >  //   init(inputFileName);  
126 >  //   Loop("SusyCAF_Tree_n722_3403013856_out_tree.root", "TTJets.root");
127 >  //Loop("TTJets_SUMMER12_TrigStudy-mu_noTail_Tree.root", "TTJets.root");
128 >  //Loop(inputFileName, "Run2012C.root");
129   }
130  
131  
132 < //================================================================================= Loop
133 < void triggerStudy::Loop(){
134 <  tools::enterFcn("Loop",1,1);
135 <  timer.Start("Loop");
136 <  vector<UInt_t> loopEvents;
132 > //================================================================================= plotHistograms
133 > void plotHistograms(eventInfo& evt, map<TString, plotMaker> &plot){
134 >  plot["event"].addh1d("muMultiplicity", "muMultiplicity", "muon multiplicity", "events", 5, -0.5, 4.5, evt.muonP4->size(), evt.Weight);
135 >  plot["event"].addh1d("elMultiplicity", "elMultiplicity", "electron multiplicity", "events", 5, -0.5, 4.5, evt.electronP4->size(), evt.Weight);
136 >  plot["event"].addh1d("jetMultiplicity", "jetMultiplicity", "jet multiplicity", "events", 10, -0.5, 9.5, evt.jetP4->size(), evt.Weight);
137  
138 <  for(Long64_t jentry=startEvent; jentry<nentries + startEvent; ++jentry){
139 <    tools::progress(jentry);
26 <    inputTree->GetEntry(jentry);
27 <    //initVariables(jentry);
28 <  
29 <    //makeHistograms("_before");
30 <    //makeHistograms("_after");
138 >  for(Int_t i=0,N=triggerFilterToCheckMu.size(); i<N; ++i){
139 >    investigateTriggerFilterMu(evt, plot, triggerFilterToCheckMu.at(i));
140    }
141 <  timer.Stop("Loop");
142 <  tools::exitFcn("Loop",1,1);
141 > //   for(Int_t i=0,N=triggerFilterToCheckEl.size(); i<N; ++i){
142 > //     investigateTriggerFilterEl(evt, plot, triggerFilterToCheckEl.at(i));
143 > //   }
144   }
145  
146  
147 + //================================================================================= investigateTriggerFilterMu
148 + // eff = 2*NTT / (2*NTT + NTP)
149 + void investigateTriggerFilterMu(eventInfo& evt, map<TString, plotMaker> &plot, TString filterName){
150 +  //create vector which stores, if a muon is matched to the trigger filter with the name "filterName"
151 +  vector<bool> matched;
152 +  vector<int> probeIndex;
153 +  for(Int_t i=0,N=evt.muonP4->size(); i<N; ++i){
154 +    matched.push_back(false);
155 +    for(Int_t j=0,M=evt.triggerFilterMu.at(i).size(); j<M; ++j){
156 +      if(filterName == evt.triggerFilterMu.at(i).at(j)){
157 +        matched.back() = true;
158 +        break;
159 +      }
160 +    }
161 +    if(!matched.at(i)) probeIndex.push_back(i);
162 +  }
163 +  
164 +  if(probeIndex.size()>2){
165 +    cout<<"WARNING: Something is awkward with the number of Probe leptons: " << probeIndex.size() << endl;
166 +    cout<<"The number of probe leptons is expected to be 1 or 2, because here a T&P method is applied!" << endl;
167 +  }
168 +  else if(probeIndex.size()==2) return; //make only plots if at least one Tag exists in an event
169 +  
170 +  //Fill the Tag histograms
171 +  //here, we have TWO Tag leptons -> use BOTH for the efficiency
172 +  if(probeIndex.size()==0){
173 +    for(Int_t i=0,N=evt.muonP4->size(); i<N; ++i){
174 +      plot[filterName].addh1d("pt_tag", "pt_tag", "p_{T}(tag) [GeV/c]", "events", binPt, lowPt, upPt, evt.muonP4->at(i).Pt(), evt.Weight);
175 +      plot[filterName].addh1d("eta_tag", "eta_tag", "#eta(tag)", "events", binEta, lowEta, upEta, evt.muonP4->at(i).eta(), evt.Weight);
176 +    }
177 +    //the factor of '2' is due to the fact, that there are two matched tag leptons
178 +    plot[filterName].addh1d("PUVertices_tag", "PUVertices_tag", "number of primary vertices (tag)", "events", binPU, lowPU, upPU, evt.PUInter, 2*evt.Weight);
179 +  }
180  
181 +  //Fill the Probe histograms
182 +  //here, we have ONE Tag lepton -> the probe is NOT matched to the trigger filter  
183 +  if(probeIndex.size()==1){
184 +    plot[filterName].addh1d("pt_probe", "pt_probe", "p_{T}(probe) [GeV/c]", "events", binPt, lowPt, upPt, evt.muonP4->at(probeIndex.back()).pt(), evt.Weight);    
185 +    plot[filterName].addh1d("eta_probe", "eta_probe", "#eta(probe)", "events", binEta, lowEta, upEta, evt.muonP4->at(probeIndex.back()).eta(), evt.Weight);
186 +    plot[filterName].addh1d("PUVertices_probe", "PUVertices_probe", "number of primary vertices (probe)", "events", binPU, lowPU, upPU, evt.PUInter, evt.Weight);
187 +  }
188 + }
189  
190  
191 < //================================================================================= initVariables
192 < void triggerStudy::initVariables(){
193 <  tools::enterFcn("initVariables",2);
191 > //================================================================================= makeEfficiencyPlots
192 > //eff = tag/(tag+probe)
193 > void makeEfficiencyPlots(map<TString, plotMaker> &plot){
194 >  cout<<"----------> Create efficiency histograms"<<endl;
195 >
196 >  vector<string> allTriggerFiltersToCheck = triggerFilterToCheckMu;
197 >  for(Int_t i=0,N=triggerFilterToCheckEl.size(); i<N; ++i){
198 >    allTriggerFiltersToCheck.push_back(triggerFilterToCheckEl.at(i));
199 >  }
200 >  vector<string> histNames;
201 >  histNames.push_back("pt_tag");
202 >  histNames.push_back("eta_tag");
203 >  histNames.push_back("PUVertices_tag");
204 >  
205 >  for(Int_t i=0,N=allTriggerFiltersToCheck.size(); i<N; ++i){
206 >    TString triggerFilter = allTriggerFiltersToCheck.at(i);
207 >    for(Int_t j=0,M=histNames.size(); j<M; ++j){
208 >      TString tagName   = histNames.at(j);
209 >      TString probeName = histNames.at(j);
210 >      TString effName   = histNames.at(j);
211 >      probeName.ReplaceAll("tag", "probe");
212 >      effName.ReplaceAll("tag", "eff");
213 >      if(plot[triggerFilter].isNewh1d(tagName)) continue;
214 >      if(plot[triggerFilter].isNewh1d(probeName)) continue;
215 >
216 >      TH1D *h_tag   = (TH1D*)(plot[triggerFilter].h1d[tagName])->Clone();
217 >      TH1D *h_probe = (TH1D*)(plot[triggerFilter].h1d[probeName])->Clone();
218 >      TH1D *den = (TH1D*)(h_tag)->Clone();
219 >      den->Add((TH1D*)(h_probe)->Clone());
220 >
221 >      TH1D *eff = (TH1D*)(h_tag)->Clone();
222 >      eff->Divide(den);
223 >      setEfficiencyErrors(eff, h_tag, h_probe);
224 >      
225 >      eff->SetName(effName);
226 >      eff->SetTitle(effName);
227 >      
228 >      TString xTitle_eff = eff->GetXaxis()->GetTitle();
229 >      xTitle_eff.ReplaceAll("(tag)","");
230 >      eff->GetXaxis()->SetTitle(xTitle_eff);
231 >      eff->GetYaxis()->SetTitle("efficiency");
232 >      //eff->SetAxisRange(0.,1.,"Y");
233 >      plot[triggerFilter].addh1d(eff);
234 >    }
235 >  }
236 > }
237 >
238 >
239 > //================================================================================= setEfficiencyErrors
240 > // f(eff) = t/(t+p)
241 > // df/dt = 1/(t+p) - t/(t+p)^2
242 > // df/dp = - t/(t+p)^2
243 > // eff_sig = sqrt(t_sig^2*(df/dt)^2 + p_sig^2*(df/dp)^2)
244 > void setEfficiencyErrors(TH1D* &eff, TH1D* &h_tag, TH1D* &h_probe){
245 >  if(h_tag->GetNbinsX() !=  h_probe->GetNbinsX()){
246 >    cout<<"WARNING: the number of bins of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl;
247 >    cout<<"Number of bins (Tag | Probe): " << h_tag->GetNbinsX() << " | " << h_probe->GetNbinsX() << endl;
248 >  }
249 >  if(h_tag->GetXaxis()->GetXmax() !=  h_probe->GetXaxis()->GetXmax()){
250 >    cout<<"WARNING: the upper x-range of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl;
251 >    cout<<"Number of bins (Tag | Probe): " << h_tag->GetXaxis()->GetXmax() << " | " << h_probe->GetXaxis()->GetXmax() << endl;
252 >  }
253 >  if(h_tag->GetXaxis()->GetXmin() !=  h_probe->GetXaxis()->GetXmin()){
254 >    cout<<"WARNING: the lower x-range of the tag and probe histograms differ! The efficiency calculation might be depricated!"<<endl;
255 >    cout<<"Number of bins (Tag | Probe): " << h_tag->GetXaxis()->GetXmin() << " | " << h_probe->GetXaxis()->GetXmin() << endl;
256 >  }
257 >  //loop over single bins of histograms an set the efficiency error
258 >  for(Int_t i=1,N=h_tag->GetNbinsX(); i<=N; ++i){
259 >    Double_t t = h_tag  ->GetBinContent(i);
260 >    Double_t p = h_probe->GetBinContent(i);
261 >    Double_t t_sig = h_tag  ->GetBinError(i);
262 >    Double_t p_sig = h_probe->GetBinError(i);
263 >    
264 >    if(eff->GetBinContent(i)==0.) continue;
265 >    
266 >    Double_t dedt = 1/(t+p)-t/((t+p)*(t+p));
267 >    Double_t dedp = -t/((t+p)*(t+p));
268 >    
269 >    Double_t eff_sig = sqrt(t_sig*t_sig*dedt*dedt + p_sig*p_sig*dedp*dedp);
270 >    eff->SetBinError(i, eff_sig);
271 >  }
272 > }
273 >
274  
275 <  //cout<<"dataset = " << dataset << endl;
276 < //   Candidates             .clear();
277 <
278 <  tools::exitFcn("initVariables",2);
275 > //================================================================================= Loop
276 > void Loop(TString inputFileName, TString outputFileName){
277 >  //timer.Start("Loop");
278 >  TString treeName = "trigStudyTree";
279 >  map<TString, plotMaker> myPlots;      
280 >  
281 >  //--------------------------------------------------- open file and read in leafs
282 >  TFile* inputFile = new TFile(inputFileName,"READ");
283 >  if (!inputFile->IsOpen()) std::cout<<"Could not open file "<<inputFileName<<std::endl;
284 >  TTree* inputTree= (TTree*)inputFile->Get(treeName);
285 >  
286 >  eventInfo event;
287 >  initBranches(inputTree, event);
288 >  //--------------------------------------------------- Event Loop
289 >  int nEvents=inputTree->GetEntries();
290 >  cout<<endl;
291 >  cout<<"///////////////////////////////////////////////////////////////////////////////"<<endl;
292 >  cout<<"////////////////////////////// Starting Event Loop ////////////////////////////"<<endl;
293 >  cout<<"///////////////////////////////////////////////////////////////////////////////"<<endl;
294 >  cout<<"Investigate File: " << inputFileName << endl;
295 >  cout<<"Read out TTree:   " << treeName << endl;
296 >  cout<<"Number of events: " << nEvents << endl;
297 >  cout<<"-------------------------------------------------------------------------------"<<endl;
298 >  cout<<endl;
299 >  cout<<"Looping over events..."<<endl;
300 > //   nEvents=50000;
301 >  for (int iEvent=0; iEvent<nEvents; ++iEvent){
302 >    tools::progress(iEvent);
303 >    inputTree->GetEntry(iEvent);
304 >    handleTriggerMatchingInfo(event);
305 > //     printEventInfo(event);
306 > //      printMuonInfo(event);
307 >     //printElectronInfo(event);
308 >    plotHistograms(event, myPlots);
309 >    //tools::progressReset();
310 >  }
311 >  
312 >  makeEfficiencyPlots(myPlots);
313 >  //--------------------------------------------------- Save all histograms in the appropriate folders
314 >  TString option="RECREATE";
315 >  for(typename map<TString, plotMaker>::iterator it = myPlots.begin(); it != myPlots.end(); ++it){
316 >    it->second.savePlots(outputFileName, option, it->first);
317 >    option="UPDATE";
318 >  }
319 >  //timer.Stop("Loop");
320   }
321  
322  
323 + //================================================================================= handleTriggerMatchingInfo
324 + // converting the trigger Info to a more practical format:  vector<string> --> vector<vector<string> >
325 + void handleTriggerMatchingInfo(eventInfo& evt){
326 +  evt.triggerFilterEl.clear();
327 +  evt.triggerFilterMu.clear();
328 +  //make simple check
329 +  
330 +  if(evt.electronP4->size() != evt.DESYtriggerElMatchedTriggerFilter->size()){
331 +    cout<<"WARNING: Size of electron vector does not correspond to size of matching info vector!"<<endl;
332 +    cout<<"evt.electronP4->size()                        = " << evt.electronP4->size() << endl;
333 +    cout<<"evt.DESYtriggerElMatchedTriggerFilter->size() = " << evt.DESYtriggerElMatchedTriggerFilter->size() << endl;
334 +    
335 +    tools::printVector("evt.electronP4", *(evt.electronP4));
336 +    tools::printVector("evt.DESYtriggerElMatchedTriggerFilter", *(evt.DESYtriggerElMatchedTriggerFilter));
337  
338 +    return;
339 +  }
340 +  if(evt.muonP4->size() != evt.DESYtriggerMuMatchedTriggerFilter->size()){
341 +    cout<<"WARNING: Size of muon vector does not correspond to size of matching info vector!"<<endl;
342 +    cout<<"evt.muonP4->size()                            = " << evt.muonP4->size() << endl;
343 +    cout<<"evt.DESYtriggerMuMatchedTriggerFilter->size() = " << evt.DESYtriggerMuMatchedTriggerFilter->size() << endl;
344 +    return;
345 +  }
346 +  
347 +  for(Int_t i=0,N=evt.electronP4->size(); i<N; ++i){
348 +    evt.triggerFilterEl.push_back(tools::splitToWords(evt.DESYtriggerElMatchedTriggerFilter->at(i), ";"));
349 +    //cout<<"evt.DESYtriggerElMatchedTriggerFilter->at("<<i<<") = " << evt.DESYtriggerElMatchedTriggerFilter->at(i) << endl;
350 +    //tools::printVector<TString>("triggerFilterEl", evt.triggerFilterEl.at(i));
351 +  }
352 + //     printMuonInfo(evt);
353 + //     printElectronInfo(evt);
354 +    
355 +    //tools::printVector("evt.triggerFilterMu", evt.triggerFilterMu);
356 + //     tools::printVector("evt.DESYtriggerMuMatchedTriggerFilter", *(evt.DESYtriggerMuMatchedTriggerFilter));
357 + //     tools::printVector("evt.muonP4", *(evt.muonP4));
358 +    
359 +  for(Int_t i=0,N=evt.muonP4->size(); i<N; ++i){
360 +    evt.triggerFilterMu.push_back(tools::splitToWords(evt.DESYtriggerMuMatchedTriggerFilter->at(i), ";"));
361 +    //cout<<"evt.DESYtriggerMuMatchedTriggerFilter->at("<<i<<") = " << evt.DESYtriggerMuMatchedTriggerFilter->at(i) << endl;
362 +    //tools::printVector<TString>("triggerFilterMu", evt.triggerFilterMu.at(i));
363 +  }  
364 +  //cout<<"size: muonP4 | filterinfo = "
365 +  //<<evt.muonP4->size() << " | "
366 +  //<<evt.DESYtriggerMuMatchedTriggerFilter->size()
367 +  //<<endl;
368 + }
369  
370  
371 + //================================================================================= initBranches
372 + void initBranches(TTree *tree, eventInfo& evt){
373 +  //--------------------------------------------------- initialize event info
374 +  evt.DESYtriggerElMatchedTriggerFilter = 0;
375 +  evt.DESYtriggerMuMatchedTriggerFilter = 0;
376 +  evt.DESYtriggerNameMap                = 0;
377 +  evt.electronCharge                    = 0;
378 +  evt.electronP4                        = 0;
379 +  evt.Event                             = 0;
380 +  evt.HT                                = 0.;
381 +  evt.jetP4                             = 0;
382 +  evt.MET                               = 0.;
383 +  evt.muonCharge                        = 0;
384 +  evt.muonP4                            = 0;
385 +  evt.prescaled                         = 0;
386 +  evt.Run                               = 0;
387 +  evt.PUInter                           = 0.;
388 +  evt.PUWeight                          = 0.;
389 +  evt.triggered                         = 0;
390 +  evt.Weight                            = 0.;
391 +  //--------------------------------------------------- assign branches to event structure
392 +  tree->SetBranchAddress("DESYtriggerElMatchedTriggerFilter", &(evt.DESYtriggerElMatchedTriggerFilter));
393 +  tree->SetBranchAddress("DESYtriggerMuMatchedTriggerFilter",&(evt.DESYtriggerMuMatchedTriggerFilter));
394 +  tree->SetBranchAddress("DESYtriggerNameMap",&(evt.DESYtriggerNameMap));
395 +  tree->SetBranchAddress("electronCharge",&(evt.electronCharge));
396 +  tree->SetBranchAddress("electronP4",&(evt.electronP4));
397 +  tree->SetBranchAddress("Event",&(evt.Event));
398 +  tree->SetBranchAddress("HT",&(evt.HT));
399 +  tree->SetBranchAddress("jetP4",&(evt.jetP4));
400 +  tree->SetBranchAddress("MET",&(evt.MET));
401 +  tree->SetBranchAddress("muonCharge",&(evt.muonCharge));
402 +  tree->SetBranchAddress("muonP4",&(evt.muonP4));
403 +  tree->SetBranchAddress("prescaled",&(evt.prescaled));
404 +  tree->SetBranchAddress("Run",&(evt.Run));
405 +  tree->SetBranchAddress("PUInter",&(evt.PUInter));
406 +  tree->SetBranchAddress("PUWeight",&(evt.PUWeight));
407 +  tree->SetBranchAddress("triggered",&(evt.triggered));
408 +  tree->SetBranchAddress("Weight",&(evt.Weight));
409 + }
410  
411  
412 + //================================================================================= printEventInfo
413 + void printEventInfo(eventInfo& evt, ostream& os){
414 +  os<<endl;
415 +  os<<"///////////////////////////////////////////////////////"<<endl;
416 +  os<<"///////////////////// Event Info //////////////////////"<<endl;
417 +  os<<"///////////////////////////////////////////////////////"<<endl;
418 +  os<<endl;
419 +  os<<"-----------------------------------------"<<endl;
420 +  os<<"Run      = "<<evt.Run<<endl;
421 +  os<<"Event    = "<<evt.Event<<endl;
422 +  os<<"Weight   = "<<evt.Weight<<endl;
423 +  os<<"PUWeight = "<<evt.PUWeight<<endl;
424 +  os<<"PUInter  = "<<evt.PUInter<<endl;
425 +  os<<"-----------------------------------------"<<endl;
426 +  os<<"HT               = "<<evt.HT<<endl;
427 +  os<<"MET              = "<<evt.MET<<endl;
428 +  os<<"-----------------------------------------"<<endl;
429 +  os<<"No. of Muons     = "<<evt.muonP4->size()<<endl;
430 +  os<<"No. of Electrons = "<<evt.electronP4->size()<<endl;
431 +  os<<"No. of Jets      = "<<evt.jetP4->size()<<endl;
432 +  os<<"-----------------------------------------"<<endl;
433 +  os<<"muonCharge.size()     = "<<evt.muonCharge->size()<<endl;
434 +  os<<"electronCharge.size() = "<<evt.electronCharge->size()<<endl;
435 +  os<<"-----------------------------------------"<<endl;
436 +  os<<"MuMatchedTriggerFilter.size() = "<<evt.DESYtriggerMuMatchedTriggerFilter->size()<<endl;
437 +  os<<"ElMatchedTriggerFilter.size() = "<<evt.DESYtriggerElMatchedTriggerFilter->size()<<endl;
438 +  os<<"-----------------------------------------"<<endl;
439 +  os<<"triggered.size()      = "<<evt.triggered->size()<<endl;
440 +  os<<"prescaled.size()      = "<<evt.prescaled->size()<<endl;
441 +  os<<"DESYTriggerMap.size() = "<<evt.DESYtriggerNameMap->size()<<endl;
442 +  os<<"-----------------------------------------"<<endl;
443 +  os<<endl;
444 +  
445 +  //tools::printVector<string>("jetP4", *(evt.jetP4));  
446 +  //tools::printVector<string>("DESYtriggerMuMatchedTriggerFilter", *(evt.DESYtriggerMuMatchedTriggerFilter));
447 +  //tools::printVector<string>("DESYtriggerElMatchedTriggerFilter", *(evt.DESYtriggerElMatchedTriggerFilter));
448 +  //tools::printVector<string>("DESYtriggerNameMap", *(evt.DESYtriggerNameMap));
449 +  //tools::printVector<string>("prescaled", *(evt.prescaled));
450 +  //tools::printVector<string>("triggered", *(evt.triggered));
451 + }
452  
453  
454 + //================================================================================= printMuonInfo
455 + void printMuonInfo(eventInfo& evt, ostream& os){
456 +  os<<endl;
457 +  os<<"///////////////////////////////////////////////////////"<<endl;
458 +  os<<"////////////////////// Muon Info //////////////////////"<<endl;
459 +  os<<"///////////////////////////////////////////////////////"<<endl;
460 +  os<<endl;
461 +  tools::printVector<LorentzM>("muonP4", *(evt.muonP4), os);
462 +  tools::printVector<int>("muonCharge", *(evt.muonCharge), os);
463 +  //------------------------ print invariant mass from all possible muon pairs
464 +  if(evt.muonP4->size()>=2){
465 +    os<<"-------------> Invariant masses of all possible muon pairs:"<<endl;
466 +    for(Int_t i=0,N=evt.muonP4->size(); i<N-1; ++i){
467 +      for(Int_t j=i+1; j<N; ++j){
468 +        Double_t minv = (evt.muonP4->at(i) + evt.muonP4->at(j)).mass();
469 +        os<<"Minv("<<i<<" + " <<j<<") = "<<minv<<endl;
470 +      }
471 +    }
472 +    os<<endl;
473 +  }
474 +  //------------------------ print matching info
475 +  for(Int_t i=0,N=evt.muonP4->size(); i<N; ++i){
476 +    os<<"----------------------------------------------------------------------------> Matches for muon "<<i<<":"<<
477 +    endl;
478 +    tools::printVector<TString>("matched TriggerFilter", evt.triggerFilterMu.at(i), os);
479 +  }
480 +  os<<endl;
481 + }
482  
483  
484 + //================================================================================= printElectronInfo
485 + void printElectronInfo(eventInfo& evt, ostream& os){
486 +  os<<endl;
487 +  os<<"///////////////////////////////////////////////////////"<<endl;
488 +  os<<"///////////////////// Electron Info ///////////////////"<<endl;
489 +  os<<"///////////////////////////////////////////////////////"<<endl;
490 +  os<<endl;
491 +  tools::printVector<LorentzM>("electronP4", *(evt.electronP4), os);
492 +  tools::printVector<int>("electronCharge", *(evt.electronCharge), os);
493 +  //------------------------ print invariant mass from all possible electron pairs
494 +  if(evt.electronP4->size()>=2){
495 +    os<<"-------------> Invariant masses of all possible electron pairs:"<<endl;
496 +    for(Int_t i=0,N=evt.electronP4->size(); i<N-1; ++i){
497 +      for(Int_t j=i+1; j<N; ++j){
498 +        Double_t minv = (evt.electronP4->at(i) + evt.electronP4->at(j)).mass();
499 +        os<<"Minv("<<i<<" + " <<j<<") = "<<minv<<endl;
500 +      }
501 +    }
502 +    os<<endl;
503 +  }
504 +  //------------------------ print matching info
505 +  for(Int_t i=0,N=evt.electronP4->size(); i<N; ++i){
506 +    os<<"----------------------------------------------------------------------------> Matches for electron "<<i<<":"<<
507 +    endl;
508 +    tools::printVector<TString>("matched TriggerFilter", evt.triggerFilterEl.at(i), os);
509 +  }
510 +  os<<endl;
511 + }
512  
61 #endif
513  
514  
515  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines