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.4 by buchmann, Wed Jan 9 09:27:49 2013 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 7 | Line 7 | TTree* SkimTreeAndAachifyIt(TCut eventse
7    newTree->Branch("pt1",&Aachenpt1,"pt1/F");
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);
10 >  float ETHid1,ETHid2,ETHch1,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("tri_id2",&ETHid1);
20 >  origtree->SetBranchAddress("tri_id3",&ETHid2);
21 >  origtree->SetBranchAddress("weight",&ETHweight);
22 >  origtree->SetBranchAddress("tri_pt2",&ETHpt1);
23 >  origtree->SetBranchAddress("tri_pt3",&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("tri_eta2",&ETHeta1);
41 >  origtree->SetBranchAddress("tri_eta3",&ETHeta2);
42 >  origtree->SetBranchAddress("tri_iso2",&ETHiso1);
43 >  origtree->SetBranchAddress("tri_iso3",&ETHiso2);
44 >  origtree->SetBranchAddress("pfTightHT",&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("tri_submll",&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, 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 135 | Line 143 | TTree* SkimTreeAndAachifyIt(TCut eventse
143       }
144       Aachenht=ETHht;
145       Aachenmet=ETHmet[2];
146 <     Aachenjzb=JZBExpression->EvalInstance();
147 <     if(Aachenjzb<0 && ETHid1!=ETHid2) AachenWeight=-1 * AachenWeight;
146 > //     Aachenjzb=JZBExpression->EvalInstance();
147 > //     if(Aachenjzb<0 && ETHid1!=ETHid2) AachenWeight=-1 * AachenWeight;
148       Aachenmll=ETHmll;
149      
150       AachenpZeta=ETHeta;
# 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) {
192 <    eetree = SkimTreeAndAachifyIt(basecut&&"id1==id2&&id1==0","EEDileptonTree",  1,jzbexpression,signalsamples);
193 <    mmtree = SkimTreeAndAachifyIt(basecut&&"id1==id2&&id1==1"  ,"MuMuDileptonTree",1,jzbexpression,signalsamples);
194 <    emtree = SkimTreeAndAachifyIt(basecut&&"id1!=id2"          ,"EMuDileptonTree", 1,jzbexpression,signalsamples);
195 <  } else {
196 <    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 >  TCut BasicCut("leptonNum>2&&tri_pt1>30&&tri_pt2>20&&tri_pt3>20");
189 >  TCut Selection("abs(tri_mlll-91)>30 && tri_mT>40 && met[4] > 30 && abs(tri_mll-91)<10 && tri_submll > 10");
190 >  TCut basecut(BasicCut&&Selection);
191 >  
192 >  
193 >  TTree *eetree = SkimTreeAndAachifyIt(basecut&&"tri_id2==tri_id3&&tri_id2==0","EEDileptonTree",  jzbexpression,sfile);
194 >  TTree *mmtree = SkimTreeAndAachifyIt(basecut&&"tri_id2==tri_id3&&tri_id2==1"  ,"MuMuDileptonTree",jzbexpression,sfile);
195 >  TTree *emtree = SkimTreeAndAachifyIt(basecut&&"tri_id2!=tri_id3"          ,"EMuDileptonTree", jzbexpression,sfile);
196 >    
197    TFile *f = new TFile("Aachen_Sample.root","RECREATE");
198    f->mkdir("ETH2AachenNtuples");
199    f->cd("ETH2AachenNtuples");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines