1 |
< |
TTree* SkimTreeAndAachifyIt(int isample) { |
2 |
< |
TTree* newTree = new TTree("newTree","FullTree"); |
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 |
|
|
5 |
|
newTree->Branch("weight",&AachenWeight,"weight/F"); |
6 |
– |
// initFloatBranch( "weight" ); |
6 |
|
newTree->Branch("chargeProduct",&AachenchargeProduct,"chargeProduct/F"); |
8 |
– |
// initFloatBranch( "chargeProduct" ); |
7 |
|
newTree->Branch("pt1",&Aachenpt1,"pt1/F"); |
10 |
– |
// initFloatBranch( "pt1" ); |
8 |
|
newTree->Branch("pt2",&Aachenpt2,"pt2/F"); |
9 |
< |
// initFloatBranch( "pt2" ); |
10 |
< |
float ETHid1,ETHid2,ETHweight,ETHpt1,ETHpt2; |
11 |
< |
allsamples.collection[isample].events->SetBranchAddress("id1",Ðid1); |
12 |
< |
allsamples.collection[isample].events->SetBranchAddress("id2",Ðid2); |
13 |
< |
allsamples.collection[isample].events->SetBranchAddress("weight",Ðweight); |
14 |
< |
allsamples.collection[isample].events->SetBranchAddress("pt1",Ðpt1); |
15 |
< |
allsamples.collection[isample].events->SetBranchAddress("pt2",Ðpt2); |
9 |
> |
float ETHweight,ETHpt1,ETHpt2; |
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",Ðid1); |
20 |
> |
origtree->SetBranchAddress("tri_id3",Ðid2); |
21 |
> |
origtree->SetBranchAddress("weight",Ðweight); |
22 |
> |
origtree->SetBranchAddress("tri_pt2",Ðpt1); |
23 |
> |
origtree->SetBranchAddress("tri_pt3",Ðpt2); |
24 |
> |
origtree->SetBranchAddress("ch1",Ðch1); |
25 |
> |
origtree->SetBranchAddress("ch2",Ðch2); |
26 |
|
|
27 |
|
|
28 |
|
float Aacheneta1,Aacheneta2,Aachenid1,Aachenid2,Aachenjzb,Aachenht,Aachenmet; |
29 |
|
newTree->Branch("eta1",&Aacheneta1,"eta1/F"); |
23 |
– |
// initFloatBranch( "eta1" ); |
30 |
|
newTree->Branch("eta2",&Aacheneta2,"eta2/F"); |
25 |
– |
// initFloatBranch( "eta2" ); |
31 |
|
newTree->Branch("id1",&Aachenid1,"id1/F"); |
27 |
– |
// initFloatBranch( "id1" ); // isolation |
32 |
|
newTree->Branch("id2",&Aachenid2,"id2/F"); |
29 |
– |
// initFloatBranch( "id2" ); // isolation |
33 |
|
newTree->Branch("jzb",&Aachenjzb,"jzb/F"); |
31 |
– |
// initFloatBranch( "jzb" ); |
34 |
|
newTree->Branch("ht",&Aachenht,"ht/F"); |
33 |
– |
// initFloatBranch( "ht" ); |
35 |
|
newTree->Branch("met",&Aachenmet,"met/F"); |
35 |
– |
// initFloatBranch( "met" ); |
36 |
|
|
37 |
|
float ETHeta1,ETHeta2,ETHiso1,ETHiso2,ETHht; |
38 |
|
float ETHjzb[30]; |
39 |
|
float ETHmet[30]; |
40 |
< |
allsamples.collection[isample].events->SetBranchAddress("eta1",Ðeta1); |
41 |
< |
allsamples.collection[isample].events->SetBranchAddress("eta2",Ðeta2); |
42 |
< |
allsamples.collection[isample].events->SetBranchAddress("iso1",Ðiso1); |
43 |
< |
allsamples.collection[isample].events->SetBranchAddress("iso2",Ðiso2); |
44 |
< |
allsamples.collection[isample].events->SetBranchAddress("pfHT",Ðht); |
45 |
< |
allsamples.collection[isample].events->SetBranchAddress("met",Ðmet); |
40 |
> |
origtree->SetBranchAddress("tri_eta2",Ðeta1); |
41 |
> |
origtree->SetBranchAddress("tri_eta3",Ðeta2); |
42 |
> |
origtree->SetBranchAddress("tri_iso2",Ðiso1); |
43 |
> |
origtree->SetBranchAddress("tri_iso3",Ðiso2); |
44 |
> |
origtree->SetBranchAddress("pfTightHT",Ðht); |
45 |
> |
origtree->SetBranchAddress("met",Ðmet); |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
float AachenpZeta,AachenpZetaVis,AachennJets,AachennBJets,AachennVertices,Aachenjet1pt,Aachenjet2pt,Aachenjet3pt,Aachenjet4pt; |
50 |
|
newTree->Branch("pZeta",&AachenpZeta,"pZeta/F"); |
51 |
– |
// initFloatBranch( "pZeta" ); |
51 |
|
newTree->Branch("pZetaVis",&AachenpZetaVis,"pZetaVis/F"); |
53 |
– |
// initFloatBranch( "pZetaVis" ); |
52 |
|
newTree->Branch("nJets",&AachennJets,"nJets/F"); |
55 |
– |
// initIntBranch( "nJets" ); |
53 |
|
newTree->Branch("nBJets",&AachennBJets,"nBJets/F"); |
57 |
– |
// initIntBranch( "nBJets" ); |
54 |
|
newTree->Branch("nVertices",&AachennVertices,"nVertices/F"); |
59 |
– |
// initIntBranch( "nVertices" ); |
55 |
|
newTree->Branch("jet1pt",&Aachenjet1pt,"jet1pt/F"); |
61 |
– |
// initFloatBranch( "jet1pt" ); |
56 |
|
newTree->Branch("jet2pt",&Aachenjet2pt,"jet2pt/F"); |
63 |
– |
// initFloatBranch( "jet2pt" ); |
57 |
|
newTree->Branch("jet3pt",&Aachenjet3pt,"jet3pt/F"); |
65 |
– |
// initFloatBranch( "jet3pt" ); |
58 |
|
newTree->Branch("jet4pt",&Aachenjet4pt,"jet4pt/F"); |
67 |
– |
// initFloatBranch( "jet4pt" ); |
59 |
|
|
60 |
< |
float ETHeta,ETHnjets,ETHnBJets,ETHnVertices; |
60 |
> |
float ETHeta; |
61 |
> |
int ETHnjets,ETHnBJets,ETHnVertices; |
62 |
|
float ETHjetPt[30]; |
63 |
< |
allsamples.collection[isample].events->SetBranchAddress("eta",Ðeta); |
64 |
< |
allsamples.collection[isample].events->SetBranchAddress("pfJetGoodNum",Ðnjets); |
65 |
< |
allsamples.collection[isample].events->SetBranchAddress("pfJetGoodNumBtag",ÐnBJets); |
66 |
< |
allsamples.collection[isample].events->SetBranchAddress("numVtx",ÐnVertices); |
67 |
< |
allsamples.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 |
|
|
71 |
|
float Aachenbjet1pt; |
72 |
|
int AachenrunNr,AachenlumiSec,AachenpdgId1,AachenpdgId2,AacheneventNr; |
73 |
|
newTree->Branch("bjet1pt",&Aachenbjet1pt,"bjet1pt/F"); |
82 |
– |
// initFloatBranch( "bjet1pt" ); |
74 |
|
newTree->Branch("runNr",&AachenrunNr,"runNr/I"); |
84 |
– |
// initIntBranch( "runNr" ); |
75 |
|
newTree->Branch("lumiSec",&AachenlumiSec,"lumiSec/I"); |
86 |
– |
// initIntBranch( "lumiSec" ); |
76 |
|
newTree->Branch("eventNr",&AacheneventNr,"eventNr/I"); |
88 |
– |
// initIntBranch( "eventNr" ); |
77 |
|
newTree->Branch("pdgId1",&AachenpdgId1,"pdgId1/I"); |
90 |
– |
// initIntBranch( "pdgId1" ); |
78 |
|
newTree->Branch("pdgId2",&AachenpdgId2,"pdgId2/I"); |
92 |
– |
// initIntBranch( "pdgId2" ); |
79 |
|
|
80 |
< |
float ETHBJetPt; |
81 |
< |
int ETHrunNum,ETHlumi,ETHevent,ETHgenId1,ETHgenId2; |
82 |
< |
allsamples.collection[isample].events->SetBranchAddress("runNum",ÐrunNum); |
83 |
< |
allsamples.collection[isample].events->SetBranchAddress("lumi",Ðlumi); |
84 |
< |
allsamples.collection[isample].events->SetBranchAddress("eventNum",Ðevent); |
85 |
< |
allsamples.collection[isample].events->SetBranchAddress("genId1",ÐgenId1); |
86 |
< |
allsamples.collection[isample].events->SetBranchAddress("genId2",ÐgenId2); |
80 |
> |
float ETHBJetPt[30]; |
81 |
> |
int ETHlumi,ETHrunNum,ETHgenId1,ETHgenId2; |
82 |
> |
ULong64_t ETHevent; |
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 |
< |
allsamples.collection[isample].events->SetBranchAddress("mll",Ðmll); |
105 |
< |
|
106 |
< |
/* |
107 |
< |
e ist pt1, mu ist pt2 |
108 |
< |
pt1 ist subleading lepton, pt2 leading |
109 |
< |
fuege mll zu |
110 |
< |
correctedJZB |
111 |
< |
*/ |
112 |
< |
|
113 |
< |
|
114 |
< |
|
91 |
> |
origtree->SetBranchAddress("tri_submll",Ðmll); |
92 |
|
|
93 |
< |
// int id1,id2; |
94 |
< |
|
95 |
< |
TTreeFormula *select = new TTreeFormula("select", "pfJetGoodNum>4", allsamples.collection[isample].events); |
96 |
< |
for (Int_t entry = 0 ; entry < allsamples.collection[isample].events->GetEntries() ; entry++) { |
97 |
< |
allsamples.collection[isample].events->LoadTree(entry); |
93 |
> |
float Aachenmll; |
94 |
> |
newTree->Branch("inv",&Aachenmll,"inv/F"); |
95 |
> |
|
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 |
< |
allsamples.collection[isample].events->GetEntry(entry); |
102 |
< |
cout << ETHrunNum << endl; |
101 |
> |
origtree->GetEntry(entry); |
102 |
> |
AachenWeight=ETHweight; |
103 |
> |
AachenchargeProduct=ETHch1*ETHch2; |
104 |
> |
if(ETHid1==ETHid2) { |
105 |
> |
//ee or mm event: pt1 is the subleading, pt2 the leading one (Aachen convention) |
106 |
> |
Aachenpt1=ETHpt2; |
107 |
> |
Aachenpt2=ETHpt1; |
108 |
> |
Aacheneta1=ETHeta2; |
109 |
> |
Aacheneta2=ETHeta1; |
110 |
> |
|
111 |
> |
Aachenid1=ETHiso2; |
112 |
> |
Aachenid2=ETHeta1; |
113 |
> |
|
114 |
> |
AachenpdgId1=ETHgenId2; |
115 |
> |
AachenpdgId2=ETHgenId1; |
116 |
> |
} else { |
117 |
> |
//emu event |
118 |
> |
if(ETHid1==0) { |
119 |
> |
Aachenpt1=ETHpt1; //electron |
120 |
> |
Aacheneta1=ETHeta1; |
121 |
> |
Aachenid1=ETHiso1; |
122 |
> |
|
123 |
> |
Aachenpt2=ETHpt2;//muon |
124 |
> |
Aacheneta2=ETHeta2; |
125 |
> |
Aachenid2=ETHiso2; |
126 |
> |
|
127 |
> |
AachenpdgId1=ETHgenId1; |
128 |
> |
AachenpdgId2=ETHgenId2; |
129 |
> |
|
130 |
> |
|
131 |
> |
} else { |
132 |
> |
Aachenpt1=ETHpt2; //electron |
133 |
> |
Aacheneta1=ETHeta2; |
134 |
> |
Aachenid1=ETHiso2; |
135 |
> |
|
136 |
> |
Aachenpt2=ETHpt1;//muon |
137 |
> |
Aacheneta2=ETHeta1; |
138 |
> |
Aachenid2=ETHiso1; |
139 |
> |
|
140 |
> |
AachenpdgId1=ETHgenId1; |
141 |
> |
AachenpdgId2=ETHgenId2; |
142 |
> |
} |
143 |
> |
} |
144 |
> |
Aachenht=ETHht; |
145 |
> |
Aachenmet=ETHmet[2]; |
146 |
> |
// Aachenjzb=JZBExpression->EvalInstance(); |
147 |
> |
// if(Aachenjzb<0 && ETHid1!=ETHid2) AachenWeight=-1 * AachenWeight; |
148 |
> |
Aachenmll=ETHmll; |
149 |
> |
|
150 |
> |
AachenpZeta=ETHeta; |
151 |
> |
AachenpZetaVis=0.0; |
152 |
> |
AachennJets=ETHnjets; |
153 |
> |
AachennBJets=ETHnBJets; |
154 |
> |
AachennVertices=ETHnVertices; |
155 |
> |
Aachenjet1pt=ETHjetPt[0]; |
156 |
> |
Aachenjet2pt=ETHjetPt[1]; |
157 |
> |
Aachenjet3pt=ETHjetPt[2]; |
158 |
> |
Aachenjet4pt=ETHjetPt[3]; |
159 |
> |
|
160 |
> |
Aachenbjet1pt=ETHBJetPt[0]; |
161 |
> |
AachenrunNr=ETHrunNum; |
162 |
> |
AachenlumiSec=ETHlumi; |
163 |
> |
AacheneventNr=ETHevent; |
164 |
> |
|
165 |
|
newTree->Fill(); |
166 |
|
} |
167 |
|
} |
168 |
|
|
169 |
< |
if(EdgeFitter::MarcoDebug) cout << " Reduced tree contains " << newTree->GetEntries() << " entries " << endl; |
169 |
> |
dout << " Reduced tree (" << newTree->GetName() << ") contains " << newTree->GetEntries() << " entries " << endl; |
170 |
|
return newTree; |
171 |
|
} |
172 |
|
|
173 |
< |
void CastETHtoAachenNtuple() { |
174 |
< |
TTree *completetree; |
175 |
< |
write_warning(__FUNCTION__,"Need to make this function ready for scans as well (use signal from scan samples)"); |
176 |
< |
TList *treelist = new TList; |
177 |
< |
int is_data=1; |
178 |
< |
for(int isample=0;isample<(int)allsamples.collection.size();isample++) { |
179 |
< |
if(!allsamples.collection[isample].is_active) continue; |
139 |
< |
if(is_data==1&&allsamples.collection[isample].is_data==false) continue;//kick all samples that aren't data if we're looking for data. |
140 |
< |
if(is_data==1&&allsamples.collection[isample].is_data==false) continue;//kick all samples that aren't data if we're looking for data. |
141 |
< |
if(is_data!=1&&allsamples.collection[isample].is_data==true) continue;//kick all data samples when looking for MC |
142 |
< |
if(is_data!=2&&allsamples.collection[isample].is_signal==true) continue;//remove signal sample if we don't want it. |
143 |
< |
if(EdgeFitter::MarcoDebug) cout << "Considering : " << allsamples.collection[isample].samplename << endl; |
144 |
< |
treelist->Add(SkimTreeAndAachifyIt(isample)); |
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 |
|
} |
146 |
– |
completetree = TTree::MergeTrees(treelist); |
147 |
– |
if(EdgeFitter::MarcoDebug) cout << "Complete tree now contains " << completetree->GetEntries() << " entries " << endl; |
181 |
|
|
182 |
< |
TFile *f = new TFile("AachenTree.root","RECREATE"); |
150 |
< |
completetree->Write(); |
151 |
< |
f->Close(); |
182 |
> |
dout << "Going to process file " << filename << " with JZB expression " << jzbexpression << endl; |
183 |
|
|
184 |
+ |
stringstream jzbcut; |
185 |
+ |
jzbcut << "abs(" << jzbexpression << ")>100"; |
186 |
+ |
// TCut basecut(("pfJetGoodNum40>=3&&"+jzbcut.str()).c_str()); |
187 |
+ |
|
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"); |
200 |
+ |
eetree->Write(); |
201 |
+ |
mmtree->Write(); |
202 |
+ |
emtree->Write(); |
203 |
+ |
f->Close(); |
204 |
|
} |