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 |
|
|
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",Ðid1); |
12 |
< |
scollection.collection[isample].events->SetBranchAddress("id2",Ðid2); |
13 |
< |
scollection.collection[isample].events->SetBranchAddress("weight",Ðweight); |
14 |
< |
scollection.collection[isample].events->SetBranchAddress("pt1",Ðpt1); |
15 |
< |
scollection.collection[isample].events->SetBranchAddress("pt2",Ðpt2); |
16 |
< |
scollection.collection[isample].events->SetBranchAddress("ch1",Ðch1); |
17 |
< |
scollection.collection[isample].events->SetBranchAddress("ch2",Ðch2); |
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",Ðid1); |
20 |
> |
origtree->SetBranchAddress("id2",Ðid2); |
21 |
> |
origtree->SetBranchAddress("weight",Ðweight); |
22 |
> |
origtree->SetBranchAddress("pt1",Ðpt1); |
23 |
> |
origtree->SetBranchAddress("pt2",Ðpt2); |
24 |
> |
origtree->SetBranchAddress("ch1",Ðch1); |
25 |
> |
origtree->SetBranchAddress("ch2",Ðch2); |
26 |
|
|
27 |
|
|
28 |
|
float Aacheneta1,Aacheneta2,Aachenid1,Aachenid2,Aachenjzb,Aachenht,Aachenmet; |
37 |
|
float ETHeta1,ETHeta2,ETHiso1,ETHiso2,ETHht; |
38 |
|
float ETHjzb[30]; |
39 |
|
float ETHmet[30]; |
40 |
< |
scollection.collection[isample].events->SetBranchAddress("eta1",Ðeta1); |
41 |
< |
scollection.collection[isample].events->SetBranchAddress("eta2",Ðeta2); |
42 |
< |
scollection.collection[isample].events->SetBranchAddress("iso1",Ðiso1); |
43 |
< |
scollection.collection[isample].events->SetBranchAddress("iso2",Ðiso2); |
44 |
< |
scollection.collection[isample].events->SetBranchAddress("pfHT",Ðht); |
45 |
< |
scollection.collection[isample].events->SetBranchAddress("met",Ðmet); |
40 |
> |
origtree->SetBranchAddress("eta1",Ðeta1); |
41 |
> |
origtree->SetBranchAddress("eta2",Ðeta2); |
42 |
> |
origtree->SetBranchAddress("iso1",Ðiso1); |
43 |
> |
origtree->SetBranchAddress("iso2",Ðiso2); |
44 |
> |
origtree->SetBranchAddress("pfHT",Ðht); |
45 |
> |
origtree->SetBranchAddress("met",Ðmet); |
46 |
|
|
47 |
|
|
48 |
|
|
60 |
|
float ETHeta; |
61 |
|
int ETHnjets,ETHnBJets,ETHnVertices; |
62 |
|
float ETHjetPt[30]; |
63 |
< |
scollection.collection[isample].events->SetBranchAddress("eta",Ðeta); |
64 |
< |
scollection.collection[isample].events->SetBranchAddress("pfJetGoodNum",Ðnjets); |
65 |
< |
scollection.collection[isample].events->SetBranchAddress("pfJetGoodNumBtag",ÐnBJets); |
66 |
< |
scollection.collection[isample].events->SetBranchAddress("numVtx",ÐnVertices); |
67 |
< |
scollection.collection[isample].events->SetBranchAddress("pfJetGoodPt",ÐjetPt); |
63 |
> |
origtree->SetBranchAddress("eta",Ðeta); |
64 |
> |
origtree->SetBranchAddress("pfJetGoodNum40",Ðnjets); |
65 |
> |
origtree->SetBranchAddress("pfJetGoodNumBtag",ÐnBJets); |
66 |
> |
origtree->SetBranchAddress("numVtx",ÐnVertices); |
67 |
> |
origtree->SetBranchAddress("pfJetGoodPt",ÐjetPt); |
68 |
|
|
69 |
|
|
70 |
|
|
80 |
|
float ETHBJetPt[30]; |
81 |
|
int ETHlumi,ETHrunNum,ETHgenId1,ETHgenId2; |
82 |
|
ULong64_t ETHevent; |
83 |
< |
scollection.collection[isample].events->SetBranchAddress("runNum",ÐrunNum); |
84 |
< |
scollection.collection[isample].events->SetBranchAddress("lumi",Ðlumi); |
85 |
< |
scollection.collection[isample].events->SetBranchAddress("eventNum",Ðevent); |
86 |
< |
scollection.collection[isample].events->SetBranchAddress("genId1",ÐgenId1); |
87 |
< |
scollection.collection[isample].events->SetBranchAddress("genId2",ÐgenId2); |
83 |
> |
origtree->SetBranchAddress("runNum",ÐrunNum); |
84 |
> |
origtree->SetBranchAddress("lumi",Ðlumi); |
85 |
> |
origtree->SetBranchAddress("eventNum",Ðevent); |
86 |
> |
origtree->SetBranchAddress("genId1",ÐgenId1); |
87 |
> |
origtree->SetBranchAddress("genId2",ÐgenId2); |
88 |
|
|
89 |
|
|
90 |
|
float ETHmll; |
91 |
< |
scollection.collection[isample].events->SetBranchAddress("mll",Ðmll); |
91 |
> |
origtree->SetBranchAddress("mll",Ðmll); |
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) { |
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"); |