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 | // loop over all vertices
|
---|
251 | iterator.Reset();
|
---|
252 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
253 | {
|
---|
254 |
|
---|
255 | index = candidate->ClusterIndex;
|
---|
256 | ndf = candidate->ClusterNDF;
|
---|
257 | sigma = candidate->ClusterSigma;
|
---|
258 | sumPT2 = candidate->SumPT2;
|
---|
259 | btvSumPT2 = candidate->BTVSumPT2;
|
---|
260 | genDeltaZ = candidate->GenDeltaZ;
|
---|
261 | genSumPT2 = candidate->GenSumPT2;
|
---|
262 |
|
---|
263 | x = candidate->Position.X ();
|
---|
264 | y = candidate->Position.Y ();
|
---|
265 | z = candidate->Position.Z ();
|
---|
266 | t = candidate->Position.T()*1.0E-3/c_light;
|
---|
267 |
|
---|
268 | xError = candidate->PositionError.X ();
|
---|
269 | yError = candidate->PositionError.Y ();
|
---|
270 | zError = candidate->PositionError.Z ();
|
---|
271 |
|
---|
272 | entry = static_cast<Vertex*>(branch->NewEntry());
|
---|
273 |
|
---|
274 | entry->Index = index;
|
---|
275 | entry->NDF = ndf;
|
---|
276 | entry->Sigma = sigma;
|
---|
277 | entry->SumPT2 = sumPT2;
|
---|
278 | entry->BTVSumPT2 = btvSumPT2;
|
---|
279 | entry->GenDeltaZ = genDeltaZ;
|
---|
280 | entry->GenSumPT2 = genSumPT2;
|
---|
281 |
|
---|
282 | entry->X = x;
|
---|
283 | entry->Y = y;
|
---|
284 | entry->Z = z;
|
---|
285 | entry->T = t;
|
---|
286 |
|
---|
287 | entry->ErrorX = xError;
|
---|
288 | entry->ErrorY = yError;
|
---|
289 | entry->ErrorZ = zError;
|
---|
290 | }
|
---|
291 | }
|
---|
292 |
|
---|
293 |
|
---|
294 | //------------------------------------------------------------------------------
|
---|
295 |
|
---|
296 | void TreeWriter::ProcessTracks(ExRootTreeBranch *branch, TObjArray *array)
|
---|
297 | {
|
---|
298 | TIter iterator(array);
|
---|
299 | Candidate *candidate = 0;
|
---|
300 | Candidate *particle = 0;
|
---|
301 | Track *entry = 0;
|
---|
302 | Double_t pt, signz, cosTheta, eta, rapidity;
|
---|
303 | const Double_t c_light = 2.99792458E8;
|
---|
304 |
|
---|
305 | // loop over all tracks
|
---|
306 | iterator.Reset();
|
---|
307 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
308 | {
|
---|
309 | const TLorentzVector &position = candidate->Position;
|
---|
310 |
|
---|
311 | cosTheta = TMath::Abs(position.CosTheta());
|
---|
312 | signz = (position.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
313 | eta = (cosTheta == 1.0 ? signz*999.9 : position.Eta());
|
---|
314 | rapidity = (cosTheta == 1.0 ? signz*999.9 : position.Rapidity());
|
---|
315 |
|
---|
316 | entry = static_cast<Track*>(branch->NewEntry());
|
---|
317 |
|
---|
318 | entry->SetBit(kIsReferenced);
|
---|
319 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
320 |
|
---|
321 | entry->PID = candidate->PID;
|
---|
322 |
|
---|
323 | entry->Charge = candidate->Charge;
|
---|
324 |
|
---|
325 | entry->EtaOuter = eta;
|
---|
326 | entry->PhiOuter = position.Phi();
|
---|
327 |
|
---|
328 | entry->XOuter = position.X();
|
---|
329 | entry->YOuter = position.Y();
|
---|
330 | entry->ZOuter = position.Z();
|
---|
331 | entry->TOuter = position.T()*1.0E-3/c_light;
|
---|
332 |
|
---|
333 | entry->L = candidate->L;
|
---|
334 |
|
---|
335 | entry->D0 = candidate->D0;
|
---|
336 | entry->ErrorD0 = candidate->ErrorD0;
|
---|
337 | entry->DZ = candidate->DZ;
|
---|
338 | entry->ErrorDZ = candidate->ErrorDZ;
|
---|
339 | entry->P = candidate->P;
|
---|
340 | entry->ErrorP = candidate->ErrorP;
|
---|
341 | entry->PT = candidate->PT;
|
---|
342 | entry->ErrorPT = candidate->ErrorPT;
|
---|
343 | entry->CtgTheta = candidate->CtgTheta;
|
---|
344 | entry->ErrorCtgTheta = candidate->ErrorCtgTheta;
|
---|
345 | entry->Phi = candidate->Phi;
|
---|
346 | entry->ErrorPhi = candidate->ErrorPhi;
|
---|
347 |
|
---|
348 | entry->Xd = candidate->Xd;
|
---|
349 | entry->Yd = candidate->Yd;
|
---|
350 | entry->Zd = candidate->Zd;
|
---|
351 |
|
---|
352 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
353 |
|
---|
354 | pt = momentum.Pt();
|
---|
355 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
356 | signz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
357 | eta = (cosTheta == 1.0 ? signz*999.9 : momentum.Eta());
|
---|
358 | rapidity = (cosTheta == 1.0 ? signz*999.9 : momentum.Rapidity());
|
---|
359 |
|
---|
360 | entry->Eta = eta;
|
---|
361 |
|
---|
362 | particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
|
---|
363 | const TLorentzVector &initialPosition = particle->Position;
|
---|
364 |
|
---|
365 | entry->X = initialPosition.X();
|
---|
366 | entry->Y = initialPosition.Y();
|
---|
367 | entry->Z = initialPosition.Z();
|
---|
368 | entry->T = initialPosition.T()*1.0E-3/c_light;
|
---|
369 |
|
---|
370 | entry->Particle = particle;
|
---|
371 |
|
---|
372 | entry->VertexIndex = candidate->ClusterIndex;
|
---|
373 |
|
---|
374 | }
|
---|
375 | }
|
---|
376 |
|
---|
377 | //------------------------------------------------------------------------------
|
---|
378 |
|
---|
379 | void TreeWriter::ProcessTowers(ExRootTreeBranch *branch, TObjArray *array)
|
---|
380 | {
|
---|
381 | TIter iterator(array);
|
---|
382 | Candidate *candidate = 0;
|
---|
383 | Tower *entry = 0;
|
---|
384 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
385 | const Double_t c_light = 2.99792458E8;
|
---|
386 |
|
---|
387 | // loop over all towers
|
---|
388 | iterator.Reset();
|
---|
389 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
390 | {
|
---|
391 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
392 | const TLorentzVector &position = candidate->Position;
|
---|
393 |
|
---|
394 | pt = momentum.Pt();
|
---|
395 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
396 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
397 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
398 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
399 |
|
---|
400 | entry = static_cast<Tower*>(branch->NewEntry());
|
---|
401 |
|
---|
402 | entry->SetBit(kIsReferenced);
|
---|
403 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
404 |
|
---|
405 | entry->Eta = eta;
|
---|
406 | entry->Phi = momentum.Phi();
|
---|
407 | entry->ET = pt;
|
---|
408 | entry->E = momentum.E();
|
---|
409 | entry->Eem = candidate->Eem;
|
---|
410 | entry->Ehad = candidate->Ehad;
|
---|
411 | entry->Edges[0] = candidate->Edges[0];
|
---|
412 | entry->Edges[1] = candidate->Edges[1];
|
---|
413 | entry->Edges[2] = candidate->Edges[2];
|
---|
414 | entry->Edges[3] = candidate->Edges[3];
|
---|
415 |
|
---|
416 | entry->T = position.T()*1.0E-3/c_light;
|
---|
417 | entry->NTimeHits = candidate->NTimeHits;
|
---|
418 |
|
---|
419 | FillParticles(candidate, &entry->Particles);
|
---|
420 | }
|
---|
421 | }
|
---|
422 |
|
---|
423 | //------------------------------------------------------------------------------
|
---|
424 |
|
---|
425 | void TreeWriter::ProcessPhotons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
426 | {
|
---|
427 | TIter iterator(array);
|
---|
428 | Candidate *candidate = 0;
|
---|
429 | Photon *entry = 0;
|
---|
430 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
431 | const Double_t c_light = 2.99792458E8;
|
---|
432 |
|
---|
433 | array->Sort();
|
---|
434 |
|
---|
435 | // loop over all photons
|
---|
436 | iterator.Reset();
|
---|
437 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
438 | {
|
---|
439 | TIter it1(candidate->GetCandidates());
|
---|
440 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
441 | const TLorentzVector &position = candidate->Position;
|
---|
442 |
|
---|
443 |
|
---|
444 | pt = momentum.Pt();
|
---|
445 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
446 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
447 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
448 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
449 |
|
---|
450 | entry = static_cast<Photon*>(branch->NewEntry());
|
---|
451 |
|
---|
452 | entry->Eta = eta;
|
---|
453 | entry->Phi = momentum.Phi();
|
---|
454 | entry->PT = pt;
|
---|
455 | entry->E = momentum.E();
|
---|
456 |
|
---|
457 | entry->T = position.T()*1.0E-3/c_light;
|
---|
458 |
|
---|
459 | // Isolation variables
|
---|
460 |
|
---|
461 | entry->IsolationVar = candidate->IsolationVar;
|
---|
462 | entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ;
|
---|
463 | entry->SumPtCharged = candidate->SumPtCharged ;
|
---|
464 | entry->SumPtNeutral = candidate->SumPtNeutral ;
|
---|
465 | entry->SumPtChargedPU = candidate->SumPtChargedPU ;
|
---|
466 | entry->SumPt = candidate->SumPt ;
|
---|
467 |
|
---|
468 | entry->EhadOverEem = candidate->Eem > 0.0 ? candidate->Ehad/candidate->Eem : 999.9;
|
---|
469 |
|
---|
470 | FillParticles(candidate, &entry->Particles);
|
---|
471 | }
|
---|
472 | }
|
---|
473 |
|
---|
474 | //------------------------------------------------------------------------------
|
---|
475 |
|
---|
476 | void TreeWriter::ProcessElectrons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
477 | {
|
---|
478 | TIter iterator(array);
|
---|
479 | Candidate *candidate = 0;
|
---|
480 | Electron *entry = 0;
|
---|
481 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
482 | const Double_t c_light = 2.99792458E8;
|
---|
483 |
|
---|
484 | array->Sort();
|
---|
485 |
|
---|
486 | // loop over all electrons
|
---|
487 | iterator.Reset();
|
---|
488 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
489 | {
|
---|
490 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
491 | const TLorentzVector &position = candidate->Position;
|
---|
492 |
|
---|
493 | pt = momentum.Pt();
|
---|
494 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
495 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
496 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
497 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
498 |
|
---|
499 | entry = static_cast<Electron*>(branch->NewEntry());
|
---|
500 |
|
---|
501 | entry->Eta = eta;
|
---|
502 | entry->Phi = momentum.Phi();
|
---|
503 | entry->PT = pt;
|
---|
504 |
|
---|
505 | entry->T = position.T()*1.0E-3/c_light;
|
---|
506 |
|
---|
507 | // Isolation variables
|
---|
508 |
|
---|
509 | entry->IsolationVar = candidate->IsolationVar;
|
---|
510 | entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ;
|
---|
511 | entry->SumPtCharged = candidate->SumPtCharged ;
|
---|
512 | entry->SumPtNeutral = candidate->SumPtNeutral ;
|
---|
513 | entry->SumPtChargedPU = candidate->SumPtChargedPU ;
|
---|
514 | entry->SumPt = candidate->SumPt ;
|
---|
515 |
|
---|
516 |
|
---|
517 | entry->Charge = candidate->Charge;
|
---|
518 |
|
---|
519 | entry->EhadOverEem = 0.0;
|
---|
520 |
|
---|
521 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
522 | }
|
---|
523 | }
|
---|
524 |
|
---|
525 | //------------------------------------------------------------------------------
|
---|
526 |
|
---|
527 | void TreeWriter::ProcessMuons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
528 | {
|
---|
529 | TIter iterator(array);
|
---|
530 | Candidate *candidate = 0;
|
---|
531 | Muon *entry = 0;
|
---|
532 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
533 |
|
---|
534 | const Double_t c_light = 2.99792458E8;
|
---|
535 |
|
---|
536 | array->Sort();
|
---|
537 |
|
---|
538 | // loop over all muons
|
---|
539 | iterator.Reset();
|
---|
540 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
541 | {
|
---|
542 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
543 | const TLorentzVector &position = candidate->Position;
|
---|
544 |
|
---|
545 | pt = momentum.Pt();
|
---|
546 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
547 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
548 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
549 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
550 |
|
---|
551 | entry = static_cast<Muon*>(branch->NewEntry());
|
---|
552 |
|
---|
553 | entry->SetBit(kIsReferenced);
|
---|
554 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
555 |
|
---|
556 | entry->Eta = eta;
|
---|
557 | entry->Phi = momentum.Phi();
|
---|
558 | entry->PT = pt;
|
---|
559 |
|
---|
560 | entry->T = position.T()*1.0E-3/c_light;
|
---|
561 |
|
---|
562 | // Isolation variables
|
---|
563 |
|
---|
564 | entry->IsolationVar = candidate->IsolationVar;
|
---|
565 | entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ;
|
---|
566 | entry->SumPtCharged = candidate->SumPtCharged ;
|
---|
567 | entry->SumPtNeutral = candidate->SumPtNeutral ;
|
---|
568 | entry->SumPtChargedPU = candidate->SumPtChargedPU ;
|
---|
569 | entry->SumPt = candidate->SumPt ;
|
---|
570 |
|
---|
571 | entry->Charge = candidate->Charge;
|
---|
572 |
|
---|
573 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
574 | }
|
---|
575 | }
|
---|
576 |
|
---|
577 | //------------------------------------------------------------------------------
|
---|
578 |
|
---|
579 | void TreeWriter::ProcessJets(ExRootTreeBranch *branch, TObjArray *array)
|
---|
580 | {
|
---|
581 | TIter iterator(array);
|
---|
582 | Candidate *candidate = 0, *constituent = 0;
|
---|
583 | Jet *entry = 0;
|
---|
584 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
585 | Double_t ecalEnergy, hcalEnergy;
|
---|
586 | const Double_t c_light = 2.99792458E8;
|
---|
587 | Int_t i;
|
---|
588 |
|
---|
589 | array->Sort();
|
---|
590 |
|
---|
591 | // loop over all jets
|
---|
592 | iterator.Reset();
|
---|
593 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
594 | {
|
---|
595 | TIter itConstituents(candidate->GetCandidates());
|
---|
596 |
|
---|
597 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
598 | const TLorentzVector &position = candidate->Position;
|
---|
599 |
|
---|
600 | pt = momentum.Pt();
|
---|
601 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
602 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
603 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
604 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
605 |
|
---|
606 | entry = static_cast<Jet*>(branch->NewEntry());
|
---|
607 |
|
---|
608 | entry->Eta = eta;
|
---|
609 | entry->Phi = momentum.Phi();
|
---|
610 | entry->PT = pt;
|
---|
611 |
|
---|
612 | entry->T = position.T()*1.0E-3/c_light;
|
---|
613 |
|
---|
614 | entry->Mass = momentum.M();
|
---|
615 |
|
---|
616 | entry->Area = candidate->Area;
|
---|
617 |
|
---|
618 | entry->DeltaEta = candidate->DeltaEta;
|
---|
619 | entry->DeltaPhi = candidate->DeltaPhi;
|
---|
620 |
|
---|
621 | entry->Flavor = candidate->Flavor;
|
---|
622 | entry->FlavorAlgo = candidate->FlavorAlgo;
|
---|
623 | entry->FlavorPhys = candidate->FlavorPhys;
|
---|
624 |
|
---|
625 | entry->BTag = candidate->BTag;
|
---|
626 |
|
---|
627 | entry->BTagAlgo = candidate->BTagAlgo;
|
---|
628 | entry->BTagPhys = candidate->BTagPhys;
|
---|
629 |
|
---|
630 | entry->TauTag = candidate->TauTag;
|
---|
631 |
|
---|
632 | entry->Charge = candidate->Charge;
|
---|
633 |
|
---|
634 | itConstituents.Reset();
|
---|
635 | entry->Constituents.Clear();
|
---|
636 | ecalEnergy = 0.0;
|
---|
637 | hcalEnergy = 0.0;
|
---|
638 | while((constituent = static_cast<Candidate*>(itConstituents.Next())))
|
---|
639 | {
|
---|
640 | entry->Constituents.Add(constituent);
|
---|
641 | ecalEnergy += constituent->Eem;
|
---|
642 | hcalEnergy += constituent->Ehad;
|
---|
643 | }
|
---|
644 |
|
---|
645 | entry->EhadOverEem = ecalEnergy > 0.0 ? hcalEnergy/ecalEnergy : 999.9;
|
---|
646 |
|
---|
647 | //--- Pile-Up Jet ID variables ----
|
---|
648 |
|
---|
649 | entry->NCharged = candidate->NCharged;
|
---|
650 | entry->NNeutrals = candidate->NNeutrals;
|
---|
651 | entry->Beta = candidate->Beta;
|
---|
652 | entry->BetaStar = candidate->BetaStar;
|
---|
653 | entry->MeanSqDeltaR = candidate->MeanSqDeltaR;
|
---|
654 | entry->PTD = candidate->PTD;
|
---|
655 |
|
---|
656 | //--- Sub-structure variables ----
|
---|
657 |
|
---|
658 | entry->NSubJetsTrimmed = candidate->NSubJetsTrimmed;
|
---|
659 | entry->NSubJetsPruned = candidate->NSubJetsPruned;
|
---|
660 | entry->NSubJetsSoftDropped = candidate->NSubJetsSoftDropped;
|
---|
661 |
|
---|
662 | for(i = 0; i < 5; i++)
|
---|
663 | {
|
---|
664 | entry->FracPt[i] = candidate -> FracPt[i];
|
---|
665 | entry->Tau[i] = candidate -> Tau[i];
|
---|
666 | entry->TrimmedP4[i] = candidate -> TrimmedP4[i];
|
---|
667 | entry->PrunedP4[i] = candidate -> PrunedP4[i];
|
---|
668 | entry->SoftDroppedP4[i] = candidate -> SoftDroppedP4[i];
|
---|
669 | }
|
---|
670 |
|
---|
671 | FillParticles(candidate, &entry->Particles);
|
---|
672 | }
|
---|
673 | }
|
---|
674 |
|
---|
675 | //------------------------------------------------------------------------------
|
---|
676 |
|
---|
677 | void TreeWriter::ProcessMissingET(ExRootTreeBranch *branch, TObjArray *array)
|
---|
678 | {
|
---|
679 | Candidate *candidate = 0;
|
---|
680 | MissingET *entry = 0;
|
---|
681 |
|
---|
682 | // get the first entry
|
---|
683 | if((candidate = static_cast<Candidate*>(array->At(0))))
|
---|
684 | {
|
---|
685 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
686 |
|
---|
687 | entry = static_cast<MissingET*>(branch->NewEntry());
|
---|
688 |
|
---|
689 | entry->Eta = (-momentum).Eta();
|
---|
690 | entry->Phi = (-momentum).Phi();
|
---|
691 | entry->MET = momentum.Pt();
|
---|
692 | }
|
---|
693 | }
|
---|
694 |
|
---|
695 | //------------------------------------------------------------------------------
|
---|
696 |
|
---|
697 | void TreeWriter::ProcessScalarHT(ExRootTreeBranch *branch, TObjArray *array)
|
---|
698 | {
|
---|
699 | Candidate *candidate = 0;
|
---|
700 | ScalarHT *entry = 0;
|
---|
701 |
|
---|
702 | // get the first entry
|
---|
703 | if((candidate = static_cast<Candidate*>(array->At(0))))
|
---|
704 | {
|
---|
705 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
706 |
|
---|
707 | entry = static_cast<ScalarHT*>(branch->NewEntry());
|
---|
708 |
|
---|
709 | entry->HT = momentum.Pt();
|
---|
710 | }
|
---|
711 | }
|
---|
712 |
|
---|
713 | //------------------------------------------------------------------------------
|
---|
714 |
|
---|
715 | void TreeWriter::ProcessRho(ExRootTreeBranch *branch, TObjArray *array)
|
---|
716 | {
|
---|
717 | TIter iterator(array);
|
---|
718 | Candidate *candidate = 0;
|
---|
719 | Rho *entry = 0;
|
---|
720 |
|
---|
721 | // loop over all rho
|
---|
722 | iterator.Reset();
|
---|
723 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
724 | {
|
---|
725 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
726 |
|
---|
727 | entry = static_cast<Rho*>(branch->NewEntry());
|
---|
728 |
|
---|
729 | entry->Rho = momentum.E();
|
---|
730 | entry->Edges[0] = candidate->Edges[0];
|
---|
731 | entry->Edges[1] = candidate->Edges[1];
|
---|
732 | }
|
---|
733 | }
|
---|
734 |
|
---|
735 | //------------------------------------------------------------------------------
|
---|
736 |
|
---|
737 | void TreeWriter::ProcessWeight(ExRootTreeBranch *branch, TObjArray *array)
|
---|
738 | {
|
---|
739 | Candidate *candidate = 0;
|
---|
740 | Weight *entry = 0;
|
---|
741 |
|
---|
742 | // get the first entry
|
---|
743 | if((candidate = static_cast<Candidate*>(array->At(0))))
|
---|
744 | {
|
---|
745 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
746 |
|
---|
747 | entry = static_cast<Weight*>(branch->NewEntry());
|
---|
748 |
|
---|
749 | entry->Weight = momentum.E();
|
---|
750 | }
|
---|
751 | }
|
---|
752 |
|
---|
753 | //------------------------------------------------------------------------------
|
---|
754 |
|
---|
755 | void TreeWriter::ProcessHectorHit(ExRootTreeBranch *branch, TObjArray *array)
|
---|
756 | {
|
---|
757 | TIter iterator(array);
|
---|
758 | Candidate *candidate = 0;
|
---|
759 | HectorHit *entry = 0;
|
---|
760 |
|
---|
761 | // loop over all roman pot hits
|
---|
762 | iterator.Reset();
|
---|
763 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
764 | {
|
---|
765 | const TLorentzVector &position = candidate->Position;
|
---|
766 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
767 |
|
---|
768 | entry = static_cast<HectorHit*>(branch->NewEntry());
|
---|
769 |
|
---|
770 | entry->E = momentum.E();
|
---|
771 |
|
---|
772 | entry->Tx = momentum.Px();
|
---|
773 | entry->Ty = momentum.Py();
|
---|
774 |
|
---|
775 | entry->T = position.T();
|
---|
776 |
|
---|
777 | entry->X = position.X();
|
---|
778 | entry->Y = position.Y();
|
---|
779 | entry->S = position.Z();
|
---|
780 |
|
---|
781 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
782 | }
|
---|
783 | }
|
---|
784 |
|
---|
785 | //------------------------------------------------------------------------------
|
---|
786 |
|
---|
787 | void TreeWriter::Process()
|
---|
788 | {
|
---|
789 | TBranchMap::iterator itBranchMap;
|
---|
790 | ExRootTreeBranch *branch;
|
---|
791 | TProcessMethod method;
|
---|
792 | TObjArray *array;
|
---|
793 |
|
---|
794 | for(itBranchMap = fBranchMap.begin(); itBranchMap != fBranchMap.end(); ++itBranchMap)
|
---|
795 | {
|
---|
796 | branch = itBranchMap->first;
|
---|
797 | method = itBranchMap->second.first;
|
---|
798 | array = itBranchMap->second.second;
|
---|
799 |
|
---|
800 | (this->*method)(branch, array);
|
---|
801 | }
|
---|
802 | }
|
---|
803 |
|
---|
804 | //------------------------------------------------------------------------------
|
---|