1 | /*
|
---|
2 | * Delphes: a framework for fast simulation of a generic collider experiment
|
---|
3 | * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
|
---|
4 | *
|
---|
5 | * This program is free software: you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
8 | * (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
17 | */
|
---|
18 |
|
---|
19 |
|
---|
20 | /** \class TreeWriter
|
---|
21 | *
|
---|
22 | * Fills ROOT tree branches.
|
---|
23 | *
|
---|
24 | * \author P. Demin - UCL, Louvain-la-Neuve
|
---|
25 | *
|
---|
26 | */
|
---|
27 |
|
---|
28 | #include "modules/TreeWriter.h"
|
---|
29 |
|
---|
30 | #include "classes/DelphesClasses.h"
|
---|
31 | #include "classes/DelphesFactory.h"
|
---|
32 | #include "classes/DelphesFormula.h"
|
---|
33 |
|
---|
34 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
35 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
36 | #include "ExRootAnalysis/ExRootClassifier.h"
|
---|
37 | #include "ExRootAnalysis/ExRootTreeBranch.h"
|
---|
38 |
|
---|
39 | #include "TROOT.h"
|
---|
40 | #include "TMath.h"
|
---|
41 | #include "TString.h"
|
---|
42 | #include "TFormula.h"
|
---|
43 | #include "TRandom3.h"
|
---|
44 | #include "TObjArray.h"
|
---|
45 | #include "TDatabasePDG.h"
|
---|
46 | #include "TLorentzVector.h"
|
---|
47 |
|
---|
48 | #include <algorithm>
|
---|
49 | #include <stdexcept>
|
---|
50 | #include <iostream>
|
---|
51 | #include <sstream>
|
---|
52 |
|
---|
53 | using namespace std;
|
---|
54 |
|
---|
55 | //------------------------------------------------------------------------------
|
---|
56 |
|
---|
57 | TreeWriter::TreeWriter()
|
---|
58 | {
|
---|
59 | }
|
---|
60 |
|
---|
61 | //------------------------------------------------------------------------------
|
---|
62 |
|
---|
63 | TreeWriter::~TreeWriter()
|
---|
64 | {
|
---|
65 | }
|
---|
66 |
|
---|
67 | //------------------------------------------------------------------------------
|
---|
68 |
|
---|
69 | void TreeWriter::Init()
|
---|
70 | {
|
---|
71 | fClassMap[GenParticle::Class()] = &TreeWriter::ProcessParticles;
|
---|
72 | fClassMap[Vertex::Class()] = &TreeWriter::ProcessVertices;
|
---|
73 | fClassMap[Track::Class()] = &TreeWriter::ProcessTracks;
|
---|
74 | fClassMap[Tower::Class()] = &TreeWriter::ProcessTowers;
|
---|
75 | fClassMap[Photon::Class()] = &TreeWriter::ProcessPhotons;
|
---|
76 | fClassMap[Electron::Class()] = &TreeWriter::ProcessElectrons;
|
---|
77 | fClassMap[Muon::Class()] = &TreeWriter::ProcessMuons;
|
---|
78 | fClassMap[Jet::Class()] = &TreeWriter::ProcessJets;
|
---|
79 | fClassMap[MissingET::Class()] = &TreeWriter::ProcessMissingET;
|
---|
80 | fClassMap[ScalarHT::Class()] = &TreeWriter::ProcessScalarHT;
|
---|
81 | fClassMap[Rho::Class()] = &TreeWriter::ProcessRho;
|
---|
82 | fClassMap[Weight::Class()] = &TreeWriter::ProcessWeight;
|
---|
83 | fClassMap[HectorHit::Class()] = &TreeWriter::ProcessHectorHit;
|
---|
84 |
|
---|
85 | TBranchMap::iterator itBranchMap;
|
---|
86 | map< TClass *, TProcessMethod >::iterator itClassMap;
|
---|
87 |
|
---|
88 | // read branch configuration and
|
---|
89 | // import array with output from filter/classifier/jetfinder modules
|
---|
90 |
|
---|
91 | ExRootConfParam param = GetParam("Branch");
|
---|
92 | Long_t i, size;
|
---|
93 | TString branchName, branchClassName, branchInputArray;
|
---|
94 | TClass *branchClass;
|
---|
95 | TObjArray *array;
|
---|
96 | ExRootTreeBranch *branch;
|
---|
97 |
|
---|
98 | size = param.GetSize();
|
---|
99 | for(i = 0; i < size/3; ++i)
|
---|
100 | {
|
---|
101 | branchInputArray = param[i*3].GetString();
|
---|
102 | branchName = param[i*3 + 1].GetString();
|
---|
103 | branchClassName = param[i*3 + 2].GetString();
|
---|
104 |
|
---|
105 | branchClass = gROOT->GetClass(branchClassName);
|
---|
106 |
|
---|
107 | if(!branchClass)
|
---|
108 | {
|
---|
109 | cout << "** ERROR: cannot find class '" << branchClassName << "'" << endl;
|
---|
110 | continue;
|
---|
111 | }
|
---|
112 |
|
---|
113 | itClassMap = fClassMap.find(branchClass);
|
---|
114 | if(itClassMap == fClassMap.end())
|
---|
115 | {
|
---|
116 | cout << "** ERROR: cannot create branch for class '" << branchClassName << "'" << endl;
|
---|
117 | continue;
|
---|
118 | }
|
---|
119 |
|
---|
120 | array = ImportArray(branchInputArray);
|
---|
121 | branch = NewBranch(branchName, branchClass);
|
---|
122 |
|
---|
123 | fBranchMap.insert(make_pair(branch, make_pair(itClassMap->second, array)));
|
---|
124 | }
|
---|
125 |
|
---|
126 | }
|
---|
127 |
|
---|
128 | //------------------------------------------------------------------------------
|
---|
129 |
|
---|
130 | void TreeWriter::Finish()
|
---|
131 | {
|
---|
132 | }
|
---|
133 |
|
---|
134 | //------------------------------------------------------------------------------
|
---|
135 |
|
---|
136 | void TreeWriter::FillParticles(Candidate *candidate, TRefArray *array)
|
---|
137 | {
|
---|
138 | TIter it1(candidate->GetCandidates());
|
---|
139 | it1.Reset();
|
---|
140 | array->Clear();
|
---|
141 | while((candidate = static_cast<Candidate*>(it1.Next())))
|
---|
142 | {
|
---|
143 | TIter it2(candidate->GetCandidates());
|
---|
144 |
|
---|
145 | // particle
|
---|
146 | if(candidate->GetCandidates()->GetEntriesFast() == 0)
|
---|
147 | {
|
---|
148 | array->Add(candidate);
|
---|
149 | continue;
|
---|
150 | }
|
---|
151 |
|
---|
152 | // track
|
---|
153 | candidate = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
|
---|
154 | if(candidate->GetCandidates()->GetEntriesFast() == 0)
|
---|
155 | {
|
---|
156 | array->Add(candidate);
|
---|
157 | continue;
|
---|
158 | }
|
---|
159 |
|
---|
160 | // tower
|
---|
161 | it2.Reset();
|
---|
162 | while((candidate = static_cast<Candidate*>(it2.Next())))
|
---|
163 | {
|
---|
164 | array->Add(candidate->GetCandidates()->At(0));
|
---|
165 | }
|
---|
166 | }
|
---|
167 | }
|
---|
168 |
|
---|
169 | //------------------------------------------------------------------------------
|
---|
170 |
|
---|
171 | void TreeWriter::ProcessParticles(ExRootTreeBranch *branch, TObjArray *array)
|
---|
172 | {
|
---|
173 | TIter iterator(array);
|
---|
174 | Candidate *candidate = 0;
|
---|
175 | GenParticle *entry = 0;
|
---|
176 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
177 |
|
---|
178 | const Double_t c_light = 2.99792458E8;
|
---|
179 |
|
---|
180 | // loop over all particles
|
---|
181 | iterator.Reset();
|
---|
182 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
183 | {
|
---|
184 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
185 | const TLorentzVector &position = candidate->Position;
|
---|
186 |
|
---|
187 | entry = static_cast<GenParticle*>(branch->NewEntry());
|
---|
188 |
|
---|
189 | entry->SetBit(kIsReferenced);
|
---|
190 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
191 |
|
---|
192 | pt = momentum.Pt();
|
---|
193 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
194 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
195 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
196 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
197 |
|
---|
198 | entry->PID = candidate->PID;
|
---|
199 |
|
---|
200 | entry->Status = candidate->Status;
|
---|
201 | entry->IsPU = candidate->IsPU;
|
---|
202 |
|
---|
203 | entry->M1 = candidate->M1;
|
---|
204 | entry->M2 = candidate->M2;
|
---|
205 |
|
---|
206 | entry->D1 = candidate->D1;
|
---|
207 | entry->D2 = candidate->D2;
|
---|
208 |
|
---|
209 | entry->Charge = candidate->Charge;
|
---|
210 | entry->Mass = candidate->Mass;
|
---|
211 |
|
---|
212 | entry->E = momentum.E();
|
---|
213 | entry->Px = momentum.Px();
|
---|
214 | entry->Py = momentum.Py();
|
---|
215 | entry->Pz = momentum.Pz();
|
---|
216 |
|
---|
217 | entry->D0 = candidate->D0;
|
---|
218 | entry->DZ = candidate->DZ;
|
---|
219 | entry->P = candidate->P;
|
---|
220 | entry->PT = candidate->PT;
|
---|
221 | entry->CtgTheta = candidate->CtgTheta;
|
---|
222 | entry->Phi = candidate->Phi;
|
---|
223 |
|
---|
224 | entry->Eta = eta;
|
---|
225 | entry->Phi = momentum.Phi();
|
---|
226 | entry->PT = pt;
|
---|
227 |
|
---|
228 | entry->Rapidity = rapidity;
|
---|
229 |
|
---|
230 | entry->X = position.X();
|
---|
231 | entry->Y = position.Y();
|
---|
232 | entry->Z = position.Z();
|
---|
233 | entry->T = position.T()*1.0E-3/c_light;
|
---|
234 | }
|
---|
235 | }
|
---|
236 |
|
---|
237 | //------------------------------------------------------------------------------
|
---|
238 |
|
---|
239 | void TreeWriter::ProcessVertices(ExRootTreeBranch *branch, TObjArray *array)
|
---|
240 | {
|
---|
241 | TIter iterator(array);
|
---|
242 | Candidate *candidate = 0;
|
---|
243 | Vertex *entry = 0;
|
---|
244 |
|
---|
245 | const Double_t c_light = 2.99792458E8;
|
---|
246 |
|
---|
247 | Double_t x, y, z, t, xError, yError, zError, sigma, sumPT2, btvSumPT2, genDeltaZ, genSumPT2;
|
---|
248 | UInt_t index, ndf;
|
---|
249 |
|
---|
250 | array->Sort();
|
---|
251 |
|
---|
252 | // loop over all vertices
|
---|
253 | iterator.Reset();
|
---|
254 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
255 | {
|
---|
256 |
|
---|
257 | index = candidate->ClusterIndex;
|
---|
258 | ndf = candidate->ClusterNDF;
|
---|
259 | sigma = candidate->ClusterSigma;
|
---|
260 | sumPT2 = candidate->SumPT2;
|
---|
261 | btvSumPT2 = candidate->BTVSumPT2;
|
---|
262 | genDeltaZ = candidate->GenDeltaZ;
|
---|
263 | genSumPT2 = candidate->GenSumPT2;
|
---|
264 |
|
---|
265 | x = candidate->Position.X();
|
---|
266 | y = candidate->Position.Y();
|
---|
267 | z = candidate->Position.Z();
|
---|
268 | t = candidate->Position.T()*1.0E-3/c_light;
|
---|
269 |
|
---|
270 | xError = candidate->PositionError.X ();
|
---|
271 | yError = candidate->PositionError.Y ();
|
---|
272 | zError = candidate->PositionError.Z ();
|
---|
273 |
|
---|
274 | entry = static_cast<Vertex*>(branch->NewEntry());
|
---|
275 |
|
---|
276 | entry->Index = index;
|
---|
277 | entry->NDF = ndf;
|
---|
278 | entry->Sigma = sigma;
|
---|
279 | entry->SumPT2 = sumPT2;
|
---|
280 | entry->BTVSumPT2 = btvSumPT2;
|
---|
281 | entry->GenDeltaZ = genDeltaZ;
|
---|
282 | entry->GenSumPT2 = genSumPT2;
|
---|
283 |
|
---|
284 | entry->X = x;
|
---|
285 | entry->Y = y;
|
---|
286 | entry->Z = z;
|
---|
287 | entry->T = t;
|
---|
288 |
|
---|
289 | entry->ErrorX = xError;
|
---|
290 | entry->ErrorY = yError;
|
---|
291 | entry->ErrorZ = zError;
|
---|
292 | }
|
---|
293 | }
|
---|
294 |
|
---|
295 |
|
---|
296 | //------------------------------------------------------------------------------
|
---|
297 |
|
---|
298 | void TreeWriter::ProcessTracks(ExRootTreeBranch *branch, TObjArray *array)
|
---|
299 | {
|
---|
300 | TIter iterator(array);
|
---|
301 | Candidate *candidate = 0;
|
---|
302 | Candidate *particle = 0;
|
---|
303 | Track *entry = 0;
|
---|
304 | Double_t pt, signz, cosTheta, eta, rapidity;
|
---|
305 | const Double_t c_light = 2.99792458E8;
|
---|
306 |
|
---|
307 | // loop over all tracks
|
---|
308 | iterator.Reset();
|
---|
309 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
310 | {
|
---|
311 | const TLorentzVector &position = candidate->Position;
|
---|
312 |
|
---|
313 | cosTheta = TMath::Abs(position.CosTheta());
|
---|
314 | signz = (position.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
315 | eta = (cosTheta == 1.0 ? signz*999.9 : position.Eta());
|
---|
316 | rapidity = (cosTheta == 1.0 ? signz*999.9 : position.Rapidity());
|
---|
317 |
|
---|
318 | entry = static_cast<Track*>(branch->NewEntry());
|
---|
319 |
|
---|
320 | entry->SetBit(kIsReferenced);
|
---|
321 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
322 |
|
---|
323 | entry->PID = candidate->PID;
|
---|
324 |
|
---|
325 | entry->Charge = candidate->Charge;
|
---|
326 |
|
---|
327 | entry->EtaOuter = eta;
|
---|
328 | entry->PhiOuter = position.Phi();
|
---|
329 |
|
---|
330 | entry->XOuter = position.X();
|
---|
331 | entry->YOuter = position.Y();
|
---|
332 | entry->ZOuter = position.Z();
|
---|
333 | entry->TOuter = position.T()*1.0E-3/c_light;
|
---|
334 |
|
---|
335 | entry->L = candidate->L;
|
---|
336 |
|
---|
337 | entry->D0 = candidate->D0;
|
---|
338 | entry->ErrorD0 = candidate->ErrorD0;
|
---|
339 | entry->DZ = candidate->DZ;
|
---|
340 | entry->ErrorDZ = candidate->ErrorDZ;
|
---|
341 | entry->P = candidate->P;
|
---|
342 | entry->ErrorP = candidate->ErrorP;
|
---|
343 | entry->PT = candidate->PT;
|
---|
344 | entry->ErrorPT = candidate->ErrorPT;
|
---|
345 | entry->CtgTheta = candidate->CtgTheta;
|
---|
346 | entry->ErrorCtgTheta = candidate->ErrorCtgTheta;
|
---|
347 | entry->Phi = candidate->Phi;
|
---|
348 | entry->ErrorPhi = candidate->ErrorPhi;
|
---|
349 |
|
---|
350 | entry->Xd = candidate->Xd;
|
---|
351 | entry->Yd = candidate->Yd;
|
---|
352 | entry->Zd = candidate->Zd;
|
---|
353 |
|
---|
354 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
355 |
|
---|
356 | pt = momentum.Pt();
|
---|
357 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
358 | signz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
359 | eta = (cosTheta == 1.0 ? signz*999.9 : momentum.Eta());
|
---|
360 | rapidity = (cosTheta == 1.0 ? signz*999.9 : momentum.Rapidity());
|
---|
361 |
|
---|
362 | entry->Eta = eta;
|
---|
363 |
|
---|
364 | particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
|
---|
365 | const TLorentzVector &initialPosition = particle->Position;
|
---|
366 |
|
---|
367 | entry->X = initialPosition.X();
|
---|
368 | entry->Y = initialPosition.Y();
|
---|
369 | entry->Z = initialPosition.Z();
|
---|
370 | entry->T = initialPosition.T()*1.0E-3/c_light;
|
---|
371 |
|
---|
372 | entry->Particle = particle;
|
---|
373 |
|
---|
374 | entry->VertexIndex = candidate->ClusterIndex;
|
---|
375 |
|
---|
376 | }
|
---|
377 | }
|
---|
378 |
|
---|
379 | //------------------------------------------------------------------------------
|
---|
380 |
|
---|
381 | void TreeWriter::ProcessTowers(ExRootTreeBranch *branch, TObjArray *array)
|
---|
382 | {
|
---|
383 | TIter iterator(array);
|
---|
384 | Candidate *candidate = 0;
|
---|
385 | Tower *entry = 0;
|
---|
386 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
387 | const Double_t c_light = 2.99792458E8;
|
---|
388 |
|
---|
389 | // loop over all towers
|
---|
390 | iterator.Reset();
|
---|
391 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
392 | {
|
---|
393 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
394 | const TLorentzVector &position = candidate->Position;
|
---|
395 |
|
---|
396 | pt = momentum.Pt();
|
---|
397 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
398 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
399 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
400 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
401 |
|
---|
402 | entry = static_cast<Tower*>(branch->NewEntry());
|
---|
403 |
|
---|
404 | entry->SetBit(kIsReferenced);
|
---|
405 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
406 |
|
---|
407 | entry->Eta = eta;
|
---|
408 | entry->Phi = momentum.Phi();
|
---|
409 | entry->ET = pt;
|
---|
410 | entry->E = momentum.E();
|
---|
411 | entry->Eem = candidate->Eem;
|
---|
412 | entry->Ehad = candidate->Ehad;
|
---|
413 | entry->Edges[0] = candidate->Edges[0];
|
---|
414 | entry->Edges[1] = candidate->Edges[1];
|
---|
415 | entry->Edges[2] = candidate->Edges[2];
|
---|
416 | entry->Edges[3] = candidate->Edges[3];
|
---|
417 |
|
---|
418 | entry->T = position.T()*1.0E-3/c_light;
|
---|
419 | entry->NTimeHits = candidate->NTimeHits;
|
---|
420 |
|
---|
421 | FillParticles(candidate, &entry->Particles);
|
---|
422 | }
|
---|
423 | }
|
---|
424 |
|
---|
425 | //------------------------------------------------------------------------------
|
---|
426 |
|
---|
427 | void TreeWriter::ProcessPhotons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
428 | {
|
---|
429 | TIter iterator(array);
|
---|
430 | Candidate *candidate = 0;
|
---|
431 | Photon *entry = 0;
|
---|
432 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
433 | const Double_t c_light = 2.99792458E8;
|
---|
434 |
|
---|
435 | array->Sort();
|
---|
436 |
|
---|
437 | // loop over all photons
|
---|
438 | iterator.Reset();
|
---|
439 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
440 | {
|
---|
441 | TIter it1(candidate->GetCandidates());
|
---|
442 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
443 | const TLorentzVector &position = candidate->Position;
|
---|
444 |
|
---|
445 |
|
---|
446 | pt = momentum.Pt();
|
---|
447 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
448 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
449 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
450 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
451 |
|
---|
452 | entry = static_cast<Photon*>(branch->NewEntry());
|
---|
453 |
|
---|
454 | entry->Eta = eta;
|
---|
455 | entry->Phi = momentum.Phi();
|
---|
456 | entry->PT = pt;
|
---|
457 | entry->E = momentum.E();
|
---|
458 |
|
---|
459 | entry->T = position.T()*1.0E-3/c_light;
|
---|
460 |
|
---|
461 | // Isolation variables
|
---|
462 |
|
---|
463 | entry->IsolationVar = candidate->IsolationVar;
|
---|
464 | entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ;
|
---|
465 | entry->SumPtCharged = candidate->SumPtCharged ;
|
---|
466 | entry->SumPtNeutral = candidate->SumPtNeutral ;
|
---|
467 | entry->SumPtChargedPU = candidate->SumPtChargedPU ;
|
---|
468 | entry->SumPt = candidate->SumPt ;
|
---|
469 |
|
---|
470 | entry->EhadOverEem = candidate->Eem > 0.0 ? candidate->Ehad/candidate->Eem : 999.9;
|
---|
471 |
|
---|
472 | FillParticles(candidate, &entry->Particles);
|
---|
473 | }
|
---|
474 | }
|
---|
475 |
|
---|
476 | //------------------------------------------------------------------------------
|
---|
477 |
|
---|
478 | void TreeWriter::ProcessElectrons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
479 | {
|
---|
480 | TIter iterator(array);
|
---|
481 | Candidate *candidate = 0;
|
---|
482 | Electron *entry = 0;
|
---|
483 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
484 | const Double_t c_light = 2.99792458E8;
|
---|
485 |
|
---|
486 | array->Sort();
|
---|
487 |
|
---|
488 | // loop over all electrons
|
---|
489 | iterator.Reset();
|
---|
490 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
491 | {
|
---|
492 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
493 | const TLorentzVector &position = candidate->Position;
|
---|
494 |
|
---|
495 | pt = momentum.Pt();
|
---|
496 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
497 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
498 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
499 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
500 |
|
---|
501 | entry = static_cast<Electron*>(branch->NewEntry());
|
---|
502 |
|
---|
503 | entry->Eta = eta;
|
---|
504 | entry->Phi = momentum.Phi();
|
---|
505 | entry->PT = pt;
|
---|
506 |
|
---|
507 | entry->T = position.T()*1.0E-3/c_light;
|
---|
508 |
|
---|
509 | // Isolation variables
|
---|
510 |
|
---|
511 | entry->IsolationVar = candidate->IsolationVar;
|
---|
512 | entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ;
|
---|
513 | entry->SumPtCharged = candidate->SumPtCharged ;
|
---|
514 | entry->SumPtNeutral = candidate->SumPtNeutral ;
|
---|
515 | entry->SumPtChargedPU = candidate->SumPtChargedPU ;
|
---|
516 | entry->SumPt = candidate->SumPt ;
|
---|
517 |
|
---|
518 |
|
---|
519 | entry->Charge = candidate->Charge;
|
---|
520 |
|
---|
521 | entry->EhadOverEem = 0.0;
|
---|
522 |
|
---|
523 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
524 | }
|
---|
525 | }
|
---|
526 |
|
---|
527 | //------------------------------------------------------------------------------
|
---|
528 |
|
---|
529 | void TreeWriter::ProcessMuons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
530 | {
|
---|
531 | TIter iterator(array);
|
---|
532 | Candidate *candidate = 0;
|
---|
533 | Muon *entry = 0;
|
---|
534 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
535 |
|
---|
536 | const Double_t c_light = 2.99792458E8;
|
---|
537 |
|
---|
538 | array->Sort();
|
---|
539 |
|
---|
540 | // loop over all muons
|
---|
541 | iterator.Reset();
|
---|
542 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
543 | {
|
---|
544 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
545 | const TLorentzVector &position = candidate->Position;
|
---|
546 |
|
---|
547 | pt = momentum.Pt();
|
---|
548 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
549 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
550 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
551 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
552 |
|
---|
553 | entry = static_cast<Muon*>(branch->NewEntry());
|
---|
554 |
|
---|
555 | entry->SetBit(kIsReferenced);
|
---|
556 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
557 |
|
---|
558 | entry->Eta = eta;
|
---|
559 | entry->Phi = momentum.Phi();
|
---|
560 | entry->PT = pt;
|
---|
561 |
|
---|
562 | entry->T = position.T()*1.0E-3/c_light;
|
---|
563 |
|
---|
564 | // Isolation variables
|
---|
565 |
|
---|
566 | entry->IsolationVar = candidate->IsolationVar;
|
---|
567 | entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ;
|
---|
568 | entry->SumPtCharged = candidate->SumPtCharged ;
|
---|
569 | entry->SumPtNeutral = candidate->SumPtNeutral ;
|
---|
570 | entry->SumPtChargedPU = candidate->SumPtChargedPU ;
|
---|
571 | entry->SumPt = candidate->SumPt ;
|
---|
572 |
|
---|
573 | entry->Charge = candidate->Charge;
|
---|
574 |
|
---|
575 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
576 | }
|
---|
577 | }
|
---|
578 |
|
---|
579 | //------------------------------------------------------------------------------
|
---|
580 |
|
---|
581 | void TreeWriter::ProcessJets(ExRootTreeBranch *branch, TObjArray *array)
|
---|
582 | {
|
---|
583 | TIter iterator(array);
|
---|
584 | Candidate *candidate = 0, *constituent = 0;
|
---|
585 | Jet *entry = 0;
|
---|
586 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
587 | Double_t ecalEnergy, hcalEnergy;
|
---|
588 | const Double_t c_light = 2.99792458E8;
|
---|
589 | Int_t i;
|
---|
590 |
|
---|
591 | array->Sort();
|
---|
592 |
|
---|
593 | // loop over all jets
|
---|
594 | iterator.Reset();
|
---|
595 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
596 | {
|
---|
597 | TIter itConstituents(candidate->GetCandidates());
|
---|
598 |
|
---|
599 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
600 | const TLorentzVector &position = candidate->Position;
|
---|
601 |
|
---|
602 | pt = momentum.Pt();
|
---|
603 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
604 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
605 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
606 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
607 |
|
---|
608 | entry = static_cast<Jet*>(branch->NewEntry());
|
---|
609 |
|
---|
610 | entry->Eta = eta;
|
---|
611 | entry->Phi = momentum.Phi();
|
---|
612 | entry->PT = pt;
|
---|
613 |
|
---|
614 | entry->T = position.T()*1.0E-3/c_light;
|
---|
615 |
|
---|
616 | entry->Mass = momentum.M();
|
---|
617 |
|
---|
618 | entry->Area = candidate->Area;
|
---|
619 |
|
---|
620 | entry->DeltaEta = candidate->DeltaEta;
|
---|
621 | entry->DeltaPhi = candidate->DeltaPhi;
|
---|
622 |
|
---|
623 | entry->Flavor = candidate->Flavor;
|
---|
624 | entry->FlavorAlgo = candidate->FlavorAlgo;
|
---|
625 | entry->FlavorPhys = candidate->FlavorPhys;
|
---|
626 |
|
---|
627 | entry->BTag = candidate->BTag;
|
---|
628 |
|
---|
629 | entry->BTagAlgo = candidate->BTagAlgo;
|
---|
630 | entry->BTagPhys = candidate->BTagPhys;
|
---|
631 |
|
---|
632 | entry->TauTag = candidate->TauTag;
|
---|
633 |
|
---|
634 | entry->Charge = candidate->Charge;
|
---|
635 |
|
---|
636 | itConstituents.Reset();
|
---|
637 | entry->Constituents.Clear();
|
---|
638 | ecalEnergy = 0.0;
|
---|
639 | hcalEnergy = 0.0;
|
---|
640 | while((constituent = static_cast<Candidate*>(itConstituents.Next())))
|
---|
641 | {
|
---|
642 | entry->Constituents.Add(constituent);
|
---|
643 | ecalEnergy += constituent->Eem;
|
---|
644 | hcalEnergy += constituent->Ehad;
|
---|
645 | }
|
---|
646 |
|
---|
647 | entry->EhadOverEem = ecalEnergy > 0.0 ? hcalEnergy/ecalEnergy : 999.9;
|
---|
648 |
|
---|
649 | //--- Pile-Up Jet ID variables ----
|
---|
650 |
|
---|
651 | entry->NCharged = candidate->NCharged;
|
---|
652 | entry->NNeutrals = candidate->NNeutrals;
|
---|
653 | entry->Beta = candidate->Beta;
|
---|
654 | entry->BetaStar = candidate->BetaStar;
|
---|
655 | entry->MeanSqDeltaR = candidate->MeanSqDeltaR;
|
---|
656 | entry->PTD = candidate->PTD;
|
---|
657 |
|
---|
658 | //--- Sub-structure variables ----
|
---|
659 |
|
---|
660 | entry->NSubJetsTrimmed = candidate->NSubJetsTrimmed;
|
---|
661 | entry->NSubJetsPruned = candidate->NSubJetsPruned;
|
---|
662 | entry->NSubJetsSoftDropped = candidate->NSubJetsSoftDropped;
|
---|
663 |
|
---|
664 | for(i = 0; i < 5; i++)
|
---|
665 | {
|
---|
666 | entry->FracPt[i] = candidate -> FracPt[i];
|
---|
667 | entry->Tau[i] = candidate -> Tau[i];
|
---|
668 | entry->TrimmedP4[i] = candidate -> TrimmedP4[i];
|
---|
669 | entry->PrunedP4[i] = candidate -> PrunedP4[i];
|
---|
670 | entry->SoftDroppedP4[i] = candidate -> SoftDroppedP4[i];
|
---|
671 | }
|
---|
672 |
|
---|
673 | FillParticles(candidate, &entry->Particles);
|
---|
674 | }
|
---|
675 | }
|
---|
676 |
|
---|
677 | //------------------------------------------------------------------------------
|
---|
678 |
|
---|
679 | void TreeWriter::ProcessMissingET(ExRootTreeBranch *branch, TObjArray *array)
|
---|
680 | {
|
---|
681 | Candidate *candidate = 0;
|
---|
682 | MissingET *entry = 0;
|
---|
683 |
|
---|
684 | // get the first entry
|
---|
685 | if((candidate = static_cast<Candidate*>(array->At(0))))
|
---|
686 | {
|
---|
687 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
688 |
|
---|
689 | entry = static_cast<MissingET*>(branch->NewEntry());
|
---|
690 |
|
---|
691 | entry->Eta = (-momentum).Eta();
|
---|
692 | entry->Phi = (-momentum).Phi();
|
---|
693 | entry->MET = momentum.Pt();
|
---|
694 | }
|
---|
695 | }
|
---|
696 |
|
---|
697 | //------------------------------------------------------------------------------
|
---|
698 |
|
---|
699 | void TreeWriter::ProcessScalarHT(ExRootTreeBranch *branch, TObjArray *array)
|
---|
700 | {
|
---|
701 | Candidate *candidate = 0;
|
---|
702 | ScalarHT *entry = 0;
|
---|
703 |
|
---|
704 | // get the first entry
|
---|
705 | if((candidate = static_cast<Candidate*>(array->At(0))))
|
---|
706 | {
|
---|
707 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
708 |
|
---|
709 | entry = static_cast<ScalarHT*>(branch->NewEntry());
|
---|
710 |
|
---|
711 | entry->HT = momentum.Pt();
|
---|
712 | }
|
---|
713 | }
|
---|
714 |
|
---|
715 | //------------------------------------------------------------------------------
|
---|
716 |
|
---|
717 | void TreeWriter::ProcessRho(ExRootTreeBranch *branch, TObjArray *array)
|
---|
718 | {
|
---|
719 | TIter iterator(array);
|
---|
720 | Candidate *candidate = 0;
|
---|
721 | Rho *entry = 0;
|
---|
722 |
|
---|
723 | // loop over all rho
|
---|
724 | iterator.Reset();
|
---|
725 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
726 | {
|
---|
727 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
728 |
|
---|
729 | entry = static_cast<Rho*>(branch->NewEntry());
|
---|
730 |
|
---|
731 | entry->Rho = momentum.E();
|
---|
732 | entry->Edges[0] = candidate->Edges[0];
|
---|
733 | entry->Edges[1] = candidate->Edges[1];
|
---|
734 | }
|
---|
735 | }
|
---|
736 |
|
---|
737 | //------------------------------------------------------------------------------
|
---|
738 |
|
---|
739 | void TreeWriter::ProcessWeight(ExRootTreeBranch *branch, TObjArray *array)
|
---|
740 | {
|
---|
741 | Candidate *candidate = 0;
|
---|
742 | Weight *entry = 0;
|
---|
743 |
|
---|
744 | // get the first entry
|
---|
745 | if((candidate = static_cast<Candidate*>(array->At(0))))
|
---|
746 | {
|
---|
747 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
748 |
|
---|
749 | entry = static_cast<Weight*>(branch->NewEntry());
|
---|
750 |
|
---|
751 | entry->Weight = momentum.E();
|
---|
752 | }
|
---|
753 | }
|
---|
754 |
|
---|
755 | //------------------------------------------------------------------------------
|
---|
756 |
|
---|
757 | void TreeWriter::ProcessHectorHit(ExRootTreeBranch *branch, TObjArray *array)
|
---|
758 | {
|
---|
759 | TIter iterator(array);
|
---|
760 | Candidate *candidate = 0;
|
---|
761 | HectorHit *entry = 0;
|
---|
762 |
|
---|
763 | // loop over all roman pot hits
|
---|
764 | iterator.Reset();
|
---|
765 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
766 | {
|
---|
767 | const TLorentzVector &position = candidate->Position;
|
---|
768 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
769 |
|
---|
770 | entry = static_cast<HectorHit*>(branch->NewEntry());
|
---|
771 |
|
---|
772 | entry->E = momentum.E();
|
---|
773 |
|
---|
774 | entry->Tx = momentum.Px();
|
---|
775 | entry->Ty = momentum.Py();
|
---|
776 |
|
---|
777 | entry->T = position.T();
|
---|
778 |
|
---|
779 | entry->X = position.X();
|
---|
780 | entry->Y = position.Y();
|
---|
781 | entry->S = position.Z();
|
---|
782 |
|
---|
783 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
784 | }
|
---|
785 | }
|
---|
786 |
|
---|
787 | //------------------------------------------------------------------------------
|
---|
788 |
|
---|
789 | void TreeWriter::Process()
|
---|
790 | {
|
---|
791 | TBranchMap::iterator itBranchMap;
|
---|
792 | ExRootTreeBranch *branch;
|
---|
793 | TProcessMethod method;
|
---|
794 | TObjArray *array;
|
---|
795 |
|
---|
796 | for(itBranchMap = fBranchMap.begin(); itBranchMap != fBranchMap.end(); ++itBranchMap)
|
---|
797 | {
|
---|
798 | branch = itBranchMap->first;
|
---|
799 | method = itBranchMap->second.first;
|
---|
800 | array = itBranchMap->second.second;
|
---|
801 |
|
---|
802 | (this->*method)(branch, array);
|
---|
803 | }
|
---|
804 | }
|
---|
805 |
|
---|
806 | //------------------------------------------------------------------------------
|
---|