1 |
buchmann |
1.3 |
TTree* SkimTreeAndAachifyIt(TCut eventselection, string treename, string jzbexpression, TFile *sfile) {
|
2 |
buchmann |
1.2 |
TTree* newTree = new TTree(treename.c_str(),treename.c_str());
|
3 |
buchmann |
1.1 |
float AachenWeight,AachenchargeProduct,Aachenpt1,Aachenpt2;
|
4 |
|
|
|
5 |
|
|
newTree->Branch("weight",&AachenWeight,"weight/F");
|
6 |
|
|
newTree->Branch("chargeProduct",&AachenchargeProduct,"chargeProduct/F");
|
7 |
|
|
newTree->Branch("pt1",&Aachenpt1,"pt1/F");
|
8 |
|
|
newTree->Branch("pt2",&Aachenpt2,"pt2/F");
|
9 |
buchmann |
1.2 |
float ETHweight,ETHpt1,ETHpt2;
|
10 |
buchmann |
1.5 |
int ETHid1,ETHid2,ETHch1,ETHch2;
|
11 |
buchmann |
1.3 |
|
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 |
buchmann |
1.5 |
origtree->SetBranchAddress("id1",Ðid1);
|
20 |
|
|
origtree->SetBranchAddress("id2",Ðid2);
|
21 |
buchmann |
1.3 |
origtree->SetBranchAddress("weight",Ðweight);
|
22 |
buchmann |
1.5 |
origtree->SetBranchAddress("pt1",Ðpt1);
|
23 |
|
|
origtree->SetBranchAddress("pt2",Ðpt2);
|
24 |
buchmann |
1.3 |
origtree->SetBranchAddress("ch1",Ðch1);
|
25 |
|
|
origtree->SetBranchAddress("ch2",Ðch2);
|
26 |
buchmann |
1.1 |
|
27 |
|
|
|
28 |
|
|
float Aacheneta1,Aacheneta2,Aachenid1,Aachenid2,Aachenjzb,Aachenht,Aachenmet;
|
29 |
|
|
newTree->Branch("eta1",&Aacheneta1,"eta1/F");
|
30 |
|
|
newTree->Branch("eta2",&Aacheneta2,"eta2/F");
|
31 |
|
|
newTree->Branch("id1",&Aachenid1,"id1/F");
|
32 |
|
|
newTree->Branch("id2",&Aachenid2,"id2/F");
|
33 |
|
|
newTree->Branch("jzb",&Aachenjzb,"jzb/F");
|
34 |
|
|
newTree->Branch("ht",&Aachenht,"ht/F");
|
35 |
|
|
newTree->Branch("met",&Aachenmet,"met/F");
|
36 |
|
|
|
37 |
|
|
float ETHeta1,ETHeta2,ETHiso1,ETHiso2,ETHht;
|
38 |
|
|
float ETHjzb[30];
|
39 |
|
|
float ETHmet[30];
|
40 |
buchmann |
1.5 |
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 |
buchmann |
1.3 |
origtree->SetBranchAddress("met",Ðmet);
|
46 |
buchmann |
1.1 |
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
float AachenpZeta,AachenpZetaVis,AachennJets,AachennBJets,AachennVertices,Aachenjet1pt,Aachenjet2pt,Aachenjet3pt,Aachenjet4pt;
|
50 |
|
|
newTree->Branch("pZeta",&AachenpZeta,"pZeta/F");
|
51 |
|
|
newTree->Branch("pZetaVis",&AachenpZetaVis,"pZetaVis/F");
|
52 |
|
|
newTree->Branch("nJets",&AachennJets,"nJets/F");
|
53 |
|
|
newTree->Branch("nBJets",&AachennBJets,"nBJets/F");
|
54 |
|
|
newTree->Branch("nVertices",&AachennVertices,"nVertices/F");
|
55 |
|
|
newTree->Branch("jet1pt",&Aachenjet1pt,"jet1pt/F");
|
56 |
|
|
newTree->Branch("jet2pt",&Aachenjet2pt,"jet2pt/F");
|
57 |
|
|
newTree->Branch("jet3pt",&Aachenjet3pt,"jet3pt/F");
|
58 |
|
|
newTree->Branch("jet4pt",&Aachenjet4pt,"jet4pt/F");
|
59 |
|
|
|
60 |
buchmann |
1.2 |
float ETHeta;
|
61 |
|
|
int ETHnjets,ETHnBJets,ETHnVertices;
|
62 |
buchmann |
1.1 |
float ETHjetPt[30];
|
63 |
buchmann |
1.3 |
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 |
buchmann |
1.1 |
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
float Aachenbjet1pt;
|
72 |
|
|
int AachenrunNr,AachenlumiSec,AachenpdgId1,AachenpdgId2,AacheneventNr;
|
73 |
|
|
newTree->Branch("bjet1pt",&Aachenbjet1pt,"bjet1pt/F");
|
74 |
|
|
newTree->Branch("runNr",&AachenrunNr,"runNr/I");
|
75 |
|
|
newTree->Branch("lumiSec",&AachenlumiSec,"lumiSec/I");
|
76 |
|
|
newTree->Branch("eventNr",&AacheneventNr,"eventNr/I");
|
77 |
|
|
newTree->Branch("pdgId1",&AachenpdgId1,"pdgId1/I");
|
78 |
|
|
newTree->Branch("pdgId2",&AachenpdgId2,"pdgId2/I");
|
79 |
|
|
|
80 |
buchmann |
1.2 |
float ETHBJetPt[30];
|
81 |
|
|
int ETHlumi,ETHrunNum,ETHgenId1,ETHgenId2;
|
82 |
|
|
ULong64_t ETHevent;
|
83 |
buchmann |
1.3 |
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 |
buchmann |
1.1 |
|
89 |
|
|
|
90 |
|
|
float ETHmll;
|
91 |
buchmann |
1.5 |
origtree->SetBranchAddress("mll",Ðmll);
|
92 |
buchmann |
1.2 |
|
93 |
|
|
float Aachenmll;
|
94 |
|
|
newTree->Branch("inv",&Aachenmll,"inv/F");
|
95 |
|
|
|
96 |
buchmann |
1.3 |
TTreeFormula *JZBExpression = new TTreeFormula("jzbexpression",jzbexpression.c_str(),origtree);
|
97 |
buchmann |
1.5 |
TTreeFormula *select = new TTreeFormula("select", eventselection&&"(passed_triggers||!is_data)", origtree);
|
98 |
buchmann |
1.3 |
for (Int_t entry = 0 ; entry < origtree->GetEntries() ; entry++) {
|
99 |
|
|
origtree->LoadTree(entry);
|
100 |
buchmann |
1.2 |
if (select->EvalInstance()) {
|
101 |
buchmann |
1.3 |
origtree->GetEntry(entry);
|
102 |
buchmann |
1.2 |
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 |
buchmann |
1.1 |
|
114 |
buchmann |
1.2 |
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 |
buchmann |
1.1 |
|
130 |
buchmann |
1.2 |
|
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 |
buchmann |
1.5 |
Aachenjzb=JZBExpression->EvalInstance();
|
147 |
|
|
if(Aachenjzb<0 && ETHid1!=ETHid2) AachenWeight=-1 * AachenWeight;
|
148 |
buchmann |
1.2 |
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 |
buchmann |
1.1 |
newTree->Fill();
|
166 |
|
|
}
|
167 |
|
|
}
|
168 |
|
|
|
169 |
buchmann |
1.2 |
dout << " Reduced tree (" << newTree->GetName() << ") contains " << newTree->GetEntries() << " entries " << endl;
|
170 |
buchmann |
1.1 |
return newTree;
|
171 |
|
|
}
|
172 |
|
|
|
173 |
buchmann |
1.3 |
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 |
buchmann |
1.1 |
|
184 |
buchmann |
1.2 |
stringstream jzbcut;
|
185 |
|
|
jzbcut << "abs(" << jzbexpression << ")>100";
|
186 |
buchmann |
1.5 |
TCut basecut(("pfJetGoodNum40>=3&&"+jzbcut.str()).c_str());
|
187 |
buchmann |
1.2 |
|
188 |
buchmann |
1.5 |
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 |
buchmann |
1.3 |
|
192 |
buchmann |
1.2 |
TFile *f = new TFile("Aachen_Sample.root","RECREATE");
|
193 |
|
|
f->mkdir("ETH2AachenNtuples");
|
194 |
|
|
f->cd("ETH2AachenNtuples");
|
195 |
|
|
eetree->Write();
|
196 |
|
|
mmtree->Write();
|
197 |
|
|
emtree->Write();
|
198 |
buchmann |
1.1 |
f->Close();
|
199 |
|
|
}
|