1 |
|
---|
2 | /** \class TreeWriter
|
---|
3 | *
|
---|
4 | * Fills ROOT tree branches.
|
---|
5 | *
|
---|
6 | * $Date: 2013-12-21 14:00:11 +0000 (Sat, 21 Dec 2013) $
|
---|
7 | * $Revision: 1345 $
|
---|
8 | *
|
---|
9 | *
|
---|
10 | * \author P. Demin - UCL, Louvain-la-Neuve
|
---|
11 | *
|
---|
12 | */
|
---|
13 |
|
---|
14 | #include "modules/TreeWriter.h"
|
---|
15 |
|
---|
16 | #include "classes/DelphesClasses.h"
|
---|
17 | #include "classes/DelphesFactory.h"
|
---|
18 | #include "classes/DelphesFormula.h"
|
---|
19 |
|
---|
20 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
21 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
22 | #include "ExRootAnalysis/ExRootClassifier.h"
|
---|
23 | #include "ExRootAnalysis/ExRootTreeBranch.h"
|
---|
24 |
|
---|
25 | #include "TROOT.h"
|
---|
26 | #include "TMath.h"
|
---|
27 | #include "TString.h"
|
---|
28 | #include "TFormula.h"
|
---|
29 | #include "TRandom3.h"
|
---|
30 | #include "TObjArray.h"
|
---|
31 | #include "TDatabasePDG.h"
|
---|
32 | #include "TLorentzVector.h"
|
---|
33 |
|
---|
34 | #include <algorithm>
|
---|
35 | #include <stdexcept>
|
---|
36 | #include <iostream>
|
---|
37 | #include <sstream>
|
---|
38 |
|
---|
39 | using namespace std;
|
---|
40 |
|
---|
41 | //------------------------------------------------------------------------------
|
---|
42 |
|
---|
43 | TreeWriter::TreeWriter()
|
---|
44 | {
|
---|
45 | }
|
---|
46 |
|
---|
47 | //------------------------------------------------------------------------------
|
---|
48 |
|
---|
49 | TreeWriter::~TreeWriter()
|
---|
50 | {
|
---|
51 | }
|
---|
52 |
|
---|
53 | //------------------------------------------------------------------------------
|
---|
54 |
|
---|
55 | void TreeWriter::Init()
|
---|
56 | {
|
---|
57 | fClassMap[GenParticle::Class()] = &TreeWriter::ProcessParticles;
|
---|
58 | fClassMap[Vertex::Class()] = &TreeWriter::ProcessVertices;
|
---|
59 | fClassMap[Track::Class()] = &TreeWriter::ProcessTracks;
|
---|
60 | fClassMap[Tower::Class()] = &TreeWriter::ProcessTowers;
|
---|
61 | fClassMap[Photon::Class()] = &TreeWriter::ProcessPhotons;
|
---|
62 | fClassMap[Electron::Class()] = &TreeWriter::ProcessElectrons;
|
---|
63 | fClassMap[Muon::Class()] = &TreeWriter::ProcessMuons;
|
---|
64 | fClassMap[Jet::Class()] = &TreeWriter::ProcessJets;
|
---|
65 | fClassMap[MissingET::Class()] = &TreeWriter::ProcessMissingET;
|
---|
66 | fClassMap[ScalarHT::Class()] = &TreeWriter::ProcessScalarHT;
|
---|
67 | fClassMap[Rho::Class()] = &TreeWriter::ProcessRho;
|
---|
68 | fClassMap[Weight::Class()] = &TreeWriter::ProcessWeight;
|
---|
69 |
|
---|
70 | TBranchMap::iterator itBranchMap;
|
---|
71 | map< TClass *, TProcessMethod >::iterator itClassMap;
|
---|
72 |
|
---|
73 | // read branch configuration and
|
---|
74 | // import array with output from filter/classifier/jetfinder modules
|
---|
75 |
|
---|
76 | ExRootConfParam param = GetParam("Branch");
|
---|
77 | Long_t i, size;
|
---|
78 | TString branchName, branchClassName, branchInputArray;
|
---|
79 | TClass *branchClass;
|
---|
80 | TObjArray *array;
|
---|
81 | ExRootTreeBranch *branch;
|
---|
82 |
|
---|
83 | size = param.GetSize();
|
---|
84 | for(i = 0; i < size/3; ++i)
|
---|
85 | {
|
---|
86 | branchInputArray = param[i*3].GetString();
|
---|
87 | branchName = param[i*3 + 1].GetString();
|
---|
88 | branchClassName = param[i*3 + 2].GetString();
|
---|
89 |
|
---|
90 | branchClass = gROOT->GetClass(branchClassName);
|
---|
91 |
|
---|
92 | if(!branchClass)
|
---|
93 | {
|
---|
94 | cout << "** ERROR: cannot find class '" << branchClassName << "'" << endl;
|
---|
95 | continue;
|
---|
96 | }
|
---|
97 |
|
---|
98 | itClassMap = fClassMap.find(branchClass);
|
---|
99 | if(itClassMap == fClassMap.end())
|
---|
100 | {
|
---|
101 | cout << "** ERROR: cannot create branch for class '" << branchClassName << "'" << endl;
|
---|
102 | continue;
|
---|
103 | }
|
---|
104 |
|
---|
105 | array = ImportArray(branchInputArray);
|
---|
106 | branch = NewBranch(branchName, branchClass);
|
---|
107 |
|
---|
108 | fBranchMap.insert(make_pair(branch, make_pair(itClassMap->second, array)));
|
---|
109 | }
|
---|
110 |
|
---|
111 | }
|
---|
112 |
|
---|
113 | //------------------------------------------------------------------------------
|
---|
114 |
|
---|
115 | void TreeWriter::Finish()
|
---|
116 | {
|
---|
117 | }
|
---|
118 |
|
---|
119 | //------------------------------------------------------------------------------
|
---|
120 |
|
---|
121 | void TreeWriter::FillParticles(Candidate *candidate, TRefArray *array)
|
---|
122 | {
|
---|
123 | TIter it1(candidate->GetCandidates());
|
---|
124 | it1.Reset();
|
---|
125 | array->Clear();
|
---|
126 | while((candidate = static_cast<Candidate*>(it1.Next())))
|
---|
127 | {
|
---|
128 | TIter it2(candidate->GetCandidates());
|
---|
129 |
|
---|
130 | // particle
|
---|
131 | if(candidate->GetCandidates()->GetEntriesFast() == 0)
|
---|
132 | {
|
---|
133 | array->Add(candidate);
|
---|
134 | continue;
|
---|
135 | }
|
---|
136 |
|
---|
137 | // track
|
---|
138 | candidate = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
|
---|
139 | if(candidate->GetCandidates()->GetEntriesFast() == 0)
|
---|
140 | {
|
---|
141 | array->Add(candidate);
|
---|
142 | continue;
|
---|
143 | }
|
---|
144 |
|
---|
145 | // tower
|
---|
146 | it2.Reset();
|
---|
147 | while((candidate = static_cast<Candidate*>(it2.Next())))
|
---|
148 | {
|
---|
149 | array->Add(candidate->GetCandidates()->At(0));
|
---|
150 | }
|
---|
151 | }
|
---|
152 | }
|
---|
153 |
|
---|
154 | //------------------------------------------------------------------------------
|
---|
155 |
|
---|
156 | void TreeWriter::ProcessParticles(ExRootTreeBranch *branch, TObjArray *array)
|
---|
157 | {
|
---|
158 | TIter iterator(array);
|
---|
159 | Candidate *candidate = 0;
|
---|
160 | GenParticle *entry = 0;
|
---|
161 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
162 |
|
---|
163 | const Double_t c_light = 2.99792458E8;
|
---|
164 |
|
---|
165 | // loop over all particles
|
---|
166 | iterator.Reset();
|
---|
167 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
168 | {
|
---|
169 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
170 | const TLorentzVector &position = candidate->Position;
|
---|
171 |
|
---|
172 | entry = static_cast<GenParticle*>(branch->NewEntry());
|
---|
173 |
|
---|
174 | entry->SetBit(kIsReferenced);
|
---|
175 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
176 |
|
---|
177 | pt = momentum.Pt();
|
---|
178 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
179 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
180 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
181 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
182 |
|
---|
183 | entry->PID = candidate->PID;
|
---|
184 |
|
---|
185 | entry->Status = candidate->Status;
|
---|
186 | entry->IsPU = candidate->IsPU;
|
---|
187 |
|
---|
188 | entry->M1 = candidate->M1;
|
---|
189 | entry->M2 = candidate->M2;
|
---|
190 |
|
---|
191 | entry->D1 = candidate->D1;
|
---|
192 | entry->D2 = candidate->D2;
|
---|
193 |
|
---|
194 | entry->Charge = candidate->Charge;
|
---|
195 | entry->Mass = candidate->Mass;
|
---|
196 |
|
---|
197 | entry->E = momentum.E();
|
---|
198 | entry->Px = momentum.Px();
|
---|
199 | entry->Py = momentum.Py();
|
---|
200 | entry->Pz = momentum.Pz();
|
---|
201 |
|
---|
202 | entry->Eta = eta;
|
---|
203 | entry->Phi = momentum.Phi();
|
---|
204 | entry->PT = pt;
|
---|
205 |
|
---|
206 | entry->Rapidity = rapidity;
|
---|
207 |
|
---|
208 | entry->X = position.X();
|
---|
209 | entry->Y = position.Y();
|
---|
210 | entry->Z = position.Z();
|
---|
211 | entry->T = position.T()*1.0E-3/c_light;
|
---|
212 | }
|
---|
213 | }
|
---|
214 |
|
---|
215 | //------------------------------------------------------------------------------
|
---|
216 |
|
---|
217 | void TreeWriter::ProcessVertices(ExRootTreeBranch *branch, TObjArray *array)
|
---|
218 | {
|
---|
219 | TIter iterator(array);
|
---|
220 | Candidate *candidate = 0;
|
---|
221 | Vertex *entry = 0;
|
---|
222 |
|
---|
223 | const Double_t c_light = 2.99792458E8;
|
---|
224 |
|
---|
225 | // loop over all vertices
|
---|
226 | iterator.Reset();
|
---|
227 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
228 | {
|
---|
229 | const TLorentzVector &position = candidate->Position;
|
---|
230 |
|
---|
231 | entry = static_cast<Vertex*>(branch->NewEntry());
|
---|
232 |
|
---|
233 | entry->X = position.X();
|
---|
234 | entry->Y = position.Y();
|
---|
235 | entry->Z = position.Z();
|
---|
236 | entry->T = position.T()*1.0E-3/c_light;
|
---|
237 | }
|
---|
238 | }
|
---|
239 |
|
---|
240 | //------------------------------------------------------------------------------
|
---|
241 |
|
---|
242 | void TreeWriter::ProcessTracks(ExRootTreeBranch *branch, TObjArray *array)
|
---|
243 | {
|
---|
244 | TIter iterator(array);
|
---|
245 | Candidate *candidate = 0;
|
---|
246 | Candidate *particle = 0;
|
---|
247 | Track *entry = 0;
|
---|
248 | Double_t pt, signz, cosTheta, eta, rapidity;
|
---|
249 | const Double_t c_light = 2.99792458E8;
|
---|
250 |
|
---|
251 | // loop over all tracks
|
---|
252 | iterator.Reset();
|
---|
253 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
254 | {
|
---|
255 | const TLorentzVector &position = candidate->Position;
|
---|
256 |
|
---|
257 | cosTheta = TMath::Abs(position.CosTheta());
|
---|
258 | signz = (position.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
259 | eta = (cosTheta == 1.0 ? signz*999.9 : position.Eta());
|
---|
260 | rapidity = (cosTheta == 1.0 ? signz*999.9 : position.Rapidity());
|
---|
261 |
|
---|
262 | entry = static_cast<Track*>(branch->NewEntry());
|
---|
263 |
|
---|
264 | entry->SetBit(kIsReferenced);
|
---|
265 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
266 |
|
---|
267 | entry->PID = candidate->PID;
|
---|
268 |
|
---|
269 | entry->Charge = candidate->Charge;
|
---|
270 |
|
---|
271 | entry->EtaOuter = eta;
|
---|
272 | entry->PhiOuter = position.Phi();
|
---|
273 |
|
---|
274 | entry->XOuter = position.X();
|
---|
275 | entry->YOuter = position.Y();
|
---|
276 | entry->ZOuter = position.Z();
|
---|
277 | entry->TOuter = position.T()*1.0E-3/c_light;
|
---|
278 |
|
---|
279 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
280 |
|
---|
281 | pt = momentum.Pt();
|
---|
282 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
283 | signz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
284 | eta = (cosTheta == 1.0 ? signz*999.9 : momentum.Eta());
|
---|
285 | rapidity = (cosTheta == 1.0 ? signz*999.9 : momentum.Rapidity());
|
---|
286 |
|
---|
287 | entry->Eta = eta;
|
---|
288 | entry->Phi = momentum.Phi();
|
---|
289 | entry->PT = pt;
|
---|
290 |
|
---|
291 | particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
|
---|
292 | const TLorentzVector &initialPosition = particle->Position;
|
---|
293 |
|
---|
294 | entry->X = initialPosition.X();
|
---|
295 | entry->Y = initialPosition.Y();
|
---|
296 | entry->Z = initialPosition.Z();
|
---|
297 | entry->T = initialPosition.T()*1.0E-3/c_light;
|
---|
298 |
|
---|
299 | entry->Particle = particle;
|
---|
300 | }
|
---|
301 | }
|
---|
302 |
|
---|
303 | //------------------------------------------------------------------------------
|
---|
304 |
|
---|
305 | void TreeWriter::ProcessTowers(ExRootTreeBranch *branch, TObjArray *array)
|
---|
306 | {
|
---|
307 | TIter iterator(array);
|
---|
308 | Candidate *candidate = 0;
|
---|
309 | Tower *entry = 0;
|
---|
310 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
311 | const Double_t c_light = 2.99792458E8;
|
---|
312 |
|
---|
313 | // loop over all towers
|
---|
314 | iterator.Reset();
|
---|
315 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
316 | {
|
---|
317 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
318 | const TLorentzVector &position = candidate->Position;
|
---|
319 |
|
---|
320 | pt = momentum.Pt();
|
---|
321 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
322 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
323 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
324 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
325 |
|
---|
326 | entry = static_cast<Tower*>(branch->NewEntry());
|
---|
327 |
|
---|
328 | entry->SetBit(kIsReferenced);
|
---|
329 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
330 |
|
---|
331 | entry->Eta = eta;
|
---|
332 | entry->Phi = momentum.Phi();
|
---|
333 | entry->ET = pt;
|
---|
334 | entry->E = momentum.E();
|
---|
335 | entry->Eem = candidate->Eem;
|
---|
336 | entry->Ehad = candidate->Ehad;
|
---|
337 | entry->Edges[0] = candidate->Edges[0];
|
---|
338 | entry->Edges[1] = candidate->Edges[1];
|
---|
339 | entry->Edges[2] = candidate->Edges[2];
|
---|
340 | entry->Edges[3] = candidate->Edges[3];
|
---|
341 |
|
---|
342 | entry->T = position.T()*1.0E-3/c_light;
|
---|
343 |
|
---|
344 | FillParticles(candidate, &entry->Particles);
|
---|
345 | }
|
---|
346 | }
|
---|
347 |
|
---|
348 | //------------------------------------------------------------------------------
|
---|
349 |
|
---|
350 | void TreeWriter::ProcessPhotons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
351 | {
|
---|
352 | TIter iterator(array);
|
---|
353 | Candidate *candidate = 0;
|
---|
354 | Photon *entry = 0;
|
---|
355 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
356 | const Double_t c_light = 2.99792458E8;
|
---|
357 |
|
---|
358 | array->Sort();
|
---|
359 |
|
---|
360 | // loop over all photons
|
---|
361 | iterator.Reset();
|
---|
362 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
363 | {
|
---|
364 | TIter it1(candidate->GetCandidates());
|
---|
365 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
366 | const TLorentzVector &position = candidate->Position;
|
---|
367 |
|
---|
368 |
|
---|
369 | pt = momentum.Pt();
|
---|
370 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
371 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
372 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
373 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
374 |
|
---|
375 | entry = static_cast<Photon*>(branch->NewEntry());
|
---|
376 |
|
---|
377 | entry->Eta = eta;
|
---|
378 | entry->Phi = momentum.Phi();
|
---|
379 | entry->PT = pt;
|
---|
380 | entry->E = momentum.E();
|
---|
381 |
|
---|
382 | entry->T = position.T()*1.0E-3/c_light;
|
---|
383 |
|
---|
384 | entry->EhadOverEem = candidate->Eem > 0.0 ? candidate->Ehad/candidate->Eem : 999.9;
|
---|
385 |
|
---|
386 | FillParticles(candidate, &entry->Particles);
|
---|
387 | }
|
---|
388 | }
|
---|
389 |
|
---|
390 | //------------------------------------------------------------------------------
|
---|
391 |
|
---|
392 | void TreeWriter::ProcessElectrons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
393 | {
|
---|
394 | TIter iterator(array);
|
---|
395 | Candidate *candidate = 0;
|
---|
396 | Electron *entry = 0;
|
---|
397 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
398 | const Double_t c_light = 2.99792458E8;
|
---|
399 |
|
---|
400 | array->Sort();
|
---|
401 |
|
---|
402 | // loop over all electrons
|
---|
403 | iterator.Reset();
|
---|
404 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
405 | {
|
---|
406 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
407 | const TLorentzVector &position = candidate->Position;
|
---|
408 |
|
---|
409 | pt = momentum.Pt();
|
---|
410 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
411 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
412 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
413 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
414 |
|
---|
415 | entry = static_cast<Electron*>(branch->NewEntry());
|
---|
416 |
|
---|
417 | entry->Eta = eta;
|
---|
418 | entry->Phi = momentum.Phi();
|
---|
419 | entry->PT = pt;
|
---|
420 |
|
---|
421 | entry->T = position.T()*1.0E-3/c_light;
|
---|
422 |
|
---|
423 | entry->Charge = candidate->Charge;
|
---|
424 |
|
---|
425 | entry->EhadOverEem = 0.0;
|
---|
426 |
|
---|
427 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
428 | }
|
---|
429 | }
|
---|
430 |
|
---|
431 | //------------------------------------------------------------------------------
|
---|
432 |
|
---|
433 | void TreeWriter::ProcessMuons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
434 | {
|
---|
435 | TIter iterator(array);
|
---|
436 | Candidate *candidate = 0;
|
---|
437 | Muon *entry = 0;
|
---|
438 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
439 |
|
---|
440 | const Double_t c_light = 2.99792458E8;
|
---|
441 |
|
---|
442 | array->Sort();
|
---|
443 |
|
---|
444 | // loop over all muons
|
---|
445 | iterator.Reset();
|
---|
446 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
447 | {
|
---|
448 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
449 | const TLorentzVector &position = candidate->Position;
|
---|
450 |
|
---|
451 |
|
---|
452 | pt = momentum.Pt();
|
---|
453 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
454 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
455 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
456 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
457 |
|
---|
458 | entry = static_cast<Muon*>(branch->NewEntry());
|
---|
459 |
|
---|
460 | entry->SetBit(kIsReferenced);
|
---|
461 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
462 |
|
---|
463 | entry->Eta = eta;
|
---|
464 | entry->Phi = momentum.Phi();
|
---|
465 | entry->PT = pt;
|
---|
466 |
|
---|
467 | entry->T = position.T()*1.0E-3/c_light;
|
---|
468 |
|
---|
469 | // cout<<entry->PT<<","<<entry->T<<endl;
|
---|
470 |
|
---|
471 | entry->Charge = candidate->Charge;
|
---|
472 |
|
---|
473 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
474 | }
|
---|
475 | }
|
---|
476 |
|
---|
477 | //------------------------------------------------------------------------------
|
---|
478 |
|
---|
479 | void TreeWriter::ProcessJets(ExRootTreeBranch *branch, TObjArray *array)
|
---|
480 | {
|
---|
481 | TIter iterator(array);
|
---|
482 | Candidate *candidate = 0, *constituent = 0;
|
---|
483 | Jet *entry = 0;
|
---|
484 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
485 | Double_t ecalEnergy, hcalEnergy;
|
---|
486 | const Double_t c_light = 2.99792458E8;
|
---|
487 |
|
---|
488 | array->Sort();
|
---|
489 |
|
---|
490 | // loop over all jets
|
---|
491 | iterator.Reset();
|
---|
492 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
493 | {
|
---|
494 | TIter itConstituents(candidate->GetCandidates());
|
---|
495 |
|
---|
496 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
497 | const TLorentzVector &position = candidate->Position;
|
---|
498 |
|
---|
499 | pt = momentum.Pt();
|
---|
500 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
501 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
502 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
503 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
504 |
|
---|
505 | entry = static_cast<Jet*>(branch->NewEntry());
|
---|
506 |
|
---|
507 | entry->Eta = eta;
|
---|
508 | entry->Phi = momentum.Phi();
|
---|
509 | entry->PT = pt;
|
---|
510 |
|
---|
511 | entry->T = position.T()*1.0E-3/c_light;
|
---|
512 |
|
---|
513 | entry->Mass = momentum.M();
|
---|
514 |
|
---|
515 | entry->DeltaEta = candidate->DeltaEta;
|
---|
516 | entry->DeltaPhi = candidate->DeltaPhi;
|
---|
517 |
|
---|
518 | entry->BTag = candidate->BTag;
|
---|
519 | entry->TauTag = candidate->TauTag;
|
---|
520 |
|
---|
521 | entry->Charge = candidate->Charge;
|
---|
522 |
|
---|
523 | itConstituents.Reset();
|
---|
524 | entry->Constituents.Clear();
|
---|
525 | ecalEnergy = 0.0;
|
---|
526 | hcalEnergy = 0.0;
|
---|
527 | while((constituent = static_cast<Candidate*>(itConstituents.Next())))
|
---|
528 | {
|
---|
529 | entry->Constituents.Add(constituent);
|
---|
530 | ecalEnergy += constituent->Eem;
|
---|
531 | hcalEnergy += constituent->Ehad;
|
---|
532 | }
|
---|
533 |
|
---|
534 | entry->EhadOverEem = ecalEnergy > 0.0 ? hcalEnergy/ecalEnergy : 999.9;
|
---|
535 |
|
---|
536 | FillParticles(candidate, &entry->Particles);
|
---|
537 | }
|
---|
538 | }
|
---|
539 |
|
---|
540 | //------------------------------------------------------------------------------
|
---|
541 |
|
---|
542 | void TreeWriter::ProcessMissingET(ExRootTreeBranch *branch, TObjArray *array)
|
---|
543 | {
|
---|
544 | Candidate *candidate = 0;
|
---|
545 | MissingET *entry = 0;
|
---|
546 |
|
---|
547 | // get the first entry
|
---|
548 | if((candidate = static_cast<Candidate*>(array->At(0))))
|
---|
549 | {
|
---|
550 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
551 |
|
---|
552 | entry = static_cast<MissingET*>(branch->NewEntry());
|
---|
553 |
|
---|
554 | entry->Eta = (-momentum).Eta();
|
---|
555 | entry->Phi = (-momentum).Phi();
|
---|
556 | entry->MET = momentum.Pt();
|
---|
557 | }
|
---|
558 | }
|
---|
559 |
|
---|
560 | //------------------------------------------------------------------------------
|
---|
561 |
|
---|
562 | void TreeWriter::ProcessScalarHT(ExRootTreeBranch *branch, TObjArray *array)
|
---|
563 | {
|
---|
564 | Candidate *candidate = 0;
|
---|
565 | ScalarHT *entry = 0;
|
---|
566 |
|
---|
567 | // get the first entry
|
---|
568 | if((candidate = static_cast<Candidate*>(array->At(0))))
|
---|
569 | {
|
---|
570 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
571 |
|
---|
572 | entry = static_cast<ScalarHT*>(branch->NewEntry());
|
---|
573 |
|
---|
574 | entry->HT = momentum.Pt();
|
---|
575 | }
|
---|
576 | }
|
---|
577 |
|
---|
578 | //------------------------------------------------------------------------------
|
---|
579 |
|
---|
580 | void TreeWriter::ProcessRho(ExRootTreeBranch *branch, TObjArray *array)
|
---|
581 | {
|
---|
582 | TIter iterator(array);
|
---|
583 | Candidate *candidate = 0;
|
---|
584 | Rho *entry = 0;
|
---|
585 |
|
---|
586 | // loop over all rho
|
---|
587 | iterator.Reset();
|
---|
588 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
589 | {
|
---|
590 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
591 |
|
---|
592 | entry = static_cast<Rho*>(branch->NewEntry());
|
---|
593 |
|
---|
594 | entry->Rho = momentum.E();
|
---|
595 | entry->Edges[0] = candidate->Edges[0];
|
---|
596 | entry->Edges[1] = candidate->Edges[1];
|
---|
597 | }
|
---|
598 | }
|
---|
599 |
|
---|
600 | //------------------------------------------------------------------------------
|
---|
601 |
|
---|
602 | void TreeWriter::ProcessWeight(ExRootTreeBranch *branch, TObjArray *array)
|
---|
603 | {
|
---|
604 | Candidate *candidate = 0;
|
---|
605 | Weight *entry = 0;
|
---|
606 |
|
---|
607 | // get the first entry
|
---|
608 | if((candidate = static_cast<Candidate*>(array->At(0))))
|
---|
609 | {
|
---|
610 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
611 |
|
---|
612 | entry = static_cast<Weight*>(branch->NewEntry());
|
---|
613 |
|
---|
614 | entry->Weight = momentum.E();
|
---|
615 | }
|
---|
616 | }
|
---|
617 |
|
---|
618 | //------------------------------------------------------------------------------
|
---|
619 |
|
---|
620 | void TreeWriter::Process()
|
---|
621 | {
|
---|
622 | TBranchMap::iterator itBranchMap;
|
---|
623 | ExRootTreeBranch *branch;
|
---|
624 | TProcessMethod method;
|
---|
625 | TObjArray *array;
|
---|
626 |
|
---|
627 | for(itBranchMap = fBranchMap.begin(); itBranchMap != fBranchMap.end(); ++itBranchMap)
|
---|
628 | {
|
---|
629 | branch = itBranchMap->first;
|
---|
630 | method = itBranchMap->second.first;
|
---|
631 | array = itBranchMap->second.second;
|
---|
632 |
|
---|
633 | (this->*method)(branch, array);
|
---|
634 | }
|
---|
635 | }
|
---|
636 |
|
---|
637 | //------------------------------------------------------------------------------
|
---|