ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/AachenCompatibility.C
(Generate patch)

Comparing UserCode/cbrown/Development/Plotting/Modules/AachenCompatibility.C (file contents):
Revision 1.2 by buchmann, Wed Jul 4 18:38:59 2012 UTC vs.
Revision 1.3 by buchmann, Mon Jul 9 12:38:25 2012 UTC

# Line 1 | Line 1
1 < TTree* SkimTreeAndAachifyIt(TCut eventselection, string treename, int isample, string jzbexpression, samplecollection &scollection) {
1 > TTree* SkimTreeAndAachifyIt(TCut eventselection, string treename, string jzbexpression, TFile *sfile) {
2    TTree* newTree = new TTree(treename.c_str(),treename.c_str());
3    float AachenWeight,AachenchargeProduct,Aachenpt1,Aachenpt2;
4    
# Line 8 | Line 8 | TTree* SkimTreeAndAachifyIt(TCut eventse
8    newTree->Branch("pt2",&Aachenpt2,"pt2/F");
9    float ETHweight,ETHpt1,ETHpt2;
10    int ETHid1,ETHid2,ETHch1,ETHch2;
11 <  scollection.collection[isample].events->SetBranchAddress("id1",&ETHid1);
12 <  scollection.collection[isample].events->SetBranchAddress("id2",&ETHid2);
13 <  scollection.collection[isample].events->SetBranchAddress("weight",&ETHweight);
14 <  scollection.collection[isample].events->SetBranchAddress("pt1",&ETHpt1);
15 <  scollection.collection[isample].events->SetBranchAddress("pt2",&ETHpt2);
16 <  scollection.collection[isample].events->SetBranchAddress("ch1",&ETHch1);
17 <  scollection.collection[isample].events->SetBranchAddress("ch2",&ETHch2);
11 >  
12 >  TTree *origtree = (TTree*)sfile->Get("events");
13 >  
14 >  if(!origtree) {
15 >    write_error(__FUNCTION__,"Problem while aachifying - there is no tree called \"events\" in this file! Aborting!");
16 >    assert(origtree);
17 >  }
18 >  
19 >  origtree->SetBranchAddress("id1",&ETHid1);
20 >  origtree->SetBranchAddress("id2",&ETHid2);
21 >  origtree->SetBranchAddress("weight",&ETHweight);
22 >  origtree->SetBranchAddress("pt1",&ETHpt1);
23 >  origtree->SetBranchAddress("pt2",&ETHpt2);
24 >  origtree->SetBranchAddress("ch1",&ETHch1);
25 >  origtree->SetBranchAddress("ch2",&ETHch2);
26    
27    
28    float Aacheneta1,Aacheneta2,Aachenid1,Aachenid2,Aachenjzb,Aachenht,Aachenmet;
# Line 29 | Line 37 | TTree* SkimTreeAndAachifyIt(TCut eventse
37    float ETHeta1,ETHeta2,ETHiso1,ETHiso2,ETHht;
38    float ETHjzb[30];
39    float ETHmet[30];
40 <  scollection.collection[isample].events->SetBranchAddress("eta1",&ETHeta1);
41 <  scollection.collection[isample].events->SetBranchAddress("eta2",&ETHeta2);
42 <  scollection.collection[isample].events->SetBranchAddress("iso1",&ETHiso1);
43 <  scollection.collection[isample].events->SetBranchAddress("iso2",&ETHiso2);
44 <  scollection.collection[isample].events->SetBranchAddress("pfHT",&ETHht);
45 <  scollection.collection[isample].events->SetBranchAddress("met",&ETHmet);
40 >  origtree->SetBranchAddress("eta1",&ETHeta1);
41 >  origtree->SetBranchAddress("eta2",&ETHeta2);
42 >  origtree->SetBranchAddress("iso1",&ETHiso1);
43 >  origtree->SetBranchAddress("iso2",&ETHiso2);
44 >  origtree->SetBranchAddress("pfHT",&ETHht);
45 >  origtree->SetBranchAddress("met",&ETHmet);
46    
47    
48    
# Line 52 | Line 60 | TTree* SkimTreeAndAachifyIt(TCut eventse
60    float ETHeta;
61    int ETHnjets,ETHnBJets,ETHnVertices;
62    float ETHjetPt[30];
63 <  scollection.collection[isample].events->SetBranchAddress("eta",&ETHeta);
64 <  scollection.collection[isample].events->SetBranchAddress("pfJetGoodNum",&ETHnjets);
65 <  scollection.collection[isample].events->SetBranchAddress("pfJetGoodNumBtag",&ETHnBJets);
66 <  scollection.collection[isample].events->SetBranchAddress("numVtx",&ETHnVertices);
67 <  scollection.collection[isample].events->SetBranchAddress("pfJetGoodPt",&ETHjetPt);
63 >  origtree->SetBranchAddress("eta",&ETHeta);
64 >  origtree->SetBranchAddress("pfJetGoodNum40",&ETHnjets);
65 >  origtree->SetBranchAddress("pfJetGoodNumBtag",&ETHnBJets);
66 >  origtree->SetBranchAddress("numVtx",&ETHnVertices);
67 >  origtree->SetBranchAddress("pfJetGoodPt",&ETHjetPt);
68    
69    
70    
# Line 72 | Line 80 | TTree* SkimTreeAndAachifyIt(TCut eventse
80    float ETHBJetPt[30];
81    int ETHlumi,ETHrunNum,ETHgenId1,ETHgenId2;
82    ULong64_t ETHevent;
83 <  scollection.collection[isample].events->SetBranchAddress("runNum",&ETHrunNum);
84 <  scollection.collection[isample].events->SetBranchAddress("lumi",&ETHlumi);
85 <  scollection.collection[isample].events->SetBranchAddress("eventNum",&ETHevent);
86 <  scollection.collection[isample].events->SetBranchAddress("genId1",&ETHgenId1);
87 <  scollection.collection[isample].events->SetBranchAddress("genId2",&ETHgenId2);
83 >  origtree->SetBranchAddress("runNum",&ETHrunNum);
84 >  origtree->SetBranchAddress("lumi",&ETHlumi);
85 >  origtree->SetBranchAddress("eventNum",&ETHevent);
86 >  origtree->SetBranchAddress("genId1",&ETHgenId1);
87 >  origtree->SetBranchAddress("genId2",&ETHgenId2);
88    
89  
90    float ETHmll;
91 <  scollection.collection[isample].events->SetBranchAddress("mll",&ETHmll);
91 >  origtree->SetBranchAddress("mll",&ETHmll);
92    
93    float Aachenmll;
94    newTree->Branch("inv",&Aachenmll,"inv/F");
95  
96 <  TTreeFormula *JZBExpression = new TTreeFormula("jzbexpression",jzbexpression.c_str(),scollection.collection[isample].events);
97 <  TTreeFormula *select = new TTreeFormula("select", eventselection&&"(passed_triggers||!is_data)", scollection.collection[isample].events);
98 <  for (Int_t entry = 0 ; entry < scollection.collection[isample].events->GetEntries() ; entry++) {
99 <   scollection.collection[isample].events->LoadTree(entry);
96 >  TTreeFormula *JZBExpression = new TTreeFormula("jzbexpression",jzbexpression.c_str(),origtree);
97 >  TTreeFormula *select = new TTreeFormula("select", eventselection&&"(passed_triggers||!is_data)", origtree);
98 >  for (Int_t entry = 0 ; entry < origtree->GetEntries() ; entry++) {
99 >   origtree->LoadTree(entry);
100     if (select->EvalInstance()) {
101 <     scollection.collection[isample].events->GetEntry(entry);
101 >     origtree->GetEntry(entry);
102       AachenWeight=ETHweight;
103       AachenchargeProduct=ETHch1*ETHch2;
104       if(ETHid1==ETHid2) {
# Line 162 | Line 170 | TTree* SkimTreeAndAachifyIt(TCut eventse
170    return newTree;
171   }
172  
173 < void CastETHtoAachenNtuple(string jzbexpression) {
174 <  bool do_simulation=true;
173 > void CastETHtoAachenNtuple(string jzbexpression, string filename) {
174 >  
175 >  TFile *sfile = new TFile(filename.c_str(),"READ");
176 >  if(!sfile) {
177 >    write_error(__FUNCTION__,"The file you want to Aachify is invalid!");
178 >    dout << "Error while trying to Aachify " << filename << endl;
179 >    return;
180 >  }
181 >  
182 >  dout << "Going to process file " << filename << " with JZB expression " << jzbexpression << endl;
183    
184    stringstream jzbcut;
185    jzbcut << "abs(" << jzbexpression << ")>100";
186 <  TCut basecut(("pfJetGoodNum>=3&&"+jzbcut.str()).c_str());
186 >  TCut basecut(("pfJetGoodNum40>=3&&"+jzbcut.str()).c_str());
187    
188 <  TTree *eetree;
189 <  TTree *mmtree;
190 <  TTree *emtree;
191 <  if(do_simulation) {
176 <    eetree = SkimTreeAndAachifyIt(basecut&&"id1==id2&&id1==0","EEDileptonTree",  1,jzbexpression,signalsamples);
177 <    mmtree = SkimTreeAndAachifyIt(basecut&&"id1==id2&&id1==1"  ,"MuMuDileptonTree",1,jzbexpression,signalsamples);
178 <    emtree = SkimTreeAndAachifyIt(basecut&&"id1!=id2"          ,"EMuDileptonTree", 1,jzbexpression,signalsamples);
179 <  } else {
180 <    eetree = SkimTreeAndAachifyIt(basecut&&"id1==id2&&id1==0","EEDileptonTree",  0,jzbexpression,allsamples);
181 <    mmtree = SkimTreeAndAachifyIt(basecut&&"id1==id2&&id1==1"  ,"MuMuDileptonTree",0,jzbexpression,allsamples);
182 <    emtree = SkimTreeAndAachifyIt(basecut&&"id1!=id2"          ,"EMuDileptonTree", 0,jzbexpression,allsamples);
183 <  }
184 <
188 >  TTree *eetree = SkimTreeAndAachifyIt(basecut&&"id1==id2&&id1==0","EEDileptonTree",  jzbexpression,sfile);
189 >  TTree *mmtree = SkimTreeAndAachifyIt(basecut&&"id1==id2&&id1==1"  ,"MuMuDileptonTree",jzbexpression,sfile);
190 >  TTree *emtree = SkimTreeAndAachifyIt(basecut&&"id1!=id2"          ,"EMuDileptonTree", jzbexpression,sfile);
191 >    
192    TFile *f = new TFile("Aachen_Sample.root","RECREATE");
193    f->mkdir("ETH2AachenNtuples");
194    f->cd("ETH2AachenNtuples");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines