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 | /** \class TreeWriter
|
---|
20 | *
|
---|
21 | * Fills ROOT tree branches.
|
---|
22 | *
|
---|
23 | * \author P. Demin - UCL, Louvain-la-Neuve
|
---|
24 | *
|
---|
25 | */
|
---|
26 |
|
---|
27 | #include "modules/TreeWriter.h"
|
---|
28 |
|
---|
29 | #include "classes/DelphesClasses.h"
|
---|
30 | #include "classes/DelphesFactory.h"
|
---|
31 | #include "classes/DelphesFormula.h"
|
---|
32 |
|
---|
33 | #include "ExRootAnalysis/ExRootClassifier.h"
|
---|
34 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
35 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
36 | #include "ExRootAnalysis/ExRootTreeBranch.h"
|
---|
37 |
|
---|
38 | #include "TDatabasePDG.h"
|
---|
39 | #include "TFormula.h"
|
---|
40 | #include "TLorentzVector.h"
|
---|
41 | #include "TMath.h"
|
---|
42 | #include "TObjArray.h"
|
---|
43 | #include "TROOT.h"
|
---|
44 | #include "TRandom3.h"
|
---|
45 | #include "TString.h"
|
---|
46 |
|
---|
47 | #include <set>
|
---|
48 | #include <algorithm>
|
---|
49 | #include <iostream>
|
---|
50 | #include <sstream>
|
---|
51 | #include <stdexcept>
|
---|
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[ParticleFlowCandidate::Class()] = &TreeWriter::ProcessParticleFlowCandidates;
|
---|
76 | fClassMap[Photon::Class()] = &TreeWriter::ProcessPhotons;
|
---|
77 | fClassMap[Electron::Class()] = &TreeWriter::ProcessElectrons;
|
---|
78 | fClassMap[Muon::Class()] = &TreeWriter::ProcessMuons;
|
---|
79 | fClassMap[CscCluster::Class()] = &TreeWriter::ProcessCscCluster;
|
---|
80 | fClassMap[Jet::Class()] = &TreeWriter::ProcessJets;
|
---|
81 | fClassMap[MissingET::Class()] = &TreeWriter::ProcessMissingET;
|
---|
82 | fClassMap[ScalarHT::Class()] = &TreeWriter::ProcessScalarHT;
|
---|
83 | fClassMap[Rho::Class()] = &TreeWriter::ProcessRho;
|
---|
84 | fClassMap[Weight::Class()] = &TreeWriter::ProcessWeight;
|
---|
85 | fClassMap[HectorHit::Class()] = &TreeWriter::ProcessHectorHit;
|
---|
86 |
|
---|
87 | TBranchMap::iterator itBranchMap;
|
---|
88 | map<TClass *, TProcessMethod>::iterator itClassMap;
|
---|
89 |
|
---|
90 | // read branch configuration and
|
---|
91 | // import array with output from filter/classifier/jetfinder modules
|
---|
92 |
|
---|
93 | ExRootConfParam param = GetParam("Branch");
|
---|
94 | Long_t i, size;
|
---|
95 | TString branchName, branchClassName, branchInputArray;
|
---|
96 | TClass *branchClass;
|
---|
97 | TObjArray *array;
|
---|
98 | ExRootTreeBranch *branch;
|
---|
99 |
|
---|
100 | size = param.GetSize();
|
---|
101 | for(i = 0; i < size / 3; ++i)
|
---|
102 | {
|
---|
103 | branchInputArray = param[i * 3].GetString();
|
---|
104 | branchName = param[i * 3 + 1].GetString();
|
---|
105 | branchClassName = param[i * 3 + 2].GetString();
|
---|
106 |
|
---|
107 | branchClass = gROOT->GetClass(branchClassName);
|
---|
108 |
|
---|
109 | if(!branchClass)
|
---|
110 | {
|
---|
111 | cout << "** ERROR: cannot find class '" << branchClassName << "'" << endl;
|
---|
112 | continue;
|
---|
113 | }
|
---|
114 |
|
---|
115 | itClassMap = fClassMap.find(branchClass);
|
---|
116 | if(itClassMap == fClassMap.end())
|
---|
117 | {
|
---|
118 | cout << "** ERROR: cannot create branch for class '" << branchClassName << "'" << endl;
|
---|
119 | continue;
|
---|
120 | }
|
---|
121 |
|
---|
122 | array = ImportArray(branchInputArray);
|
---|
123 | branch = NewBranch(branchName, branchClass);
|
---|
124 |
|
---|
125 | fBranchMap.insert(make_pair(branch, make_pair(itClassMap->second, array)));
|
---|
126 | }
|
---|
127 |
|
---|
128 | param = GetParam("Info");
|
---|
129 | TString infoName;
|
---|
130 | Double_t infoValue;
|
---|
131 |
|
---|
132 | size = param.GetSize();
|
---|
133 | for(i = 0; i < size / 2; ++i)
|
---|
134 | {
|
---|
135 | infoName = param[i * 2].GetString();
|
---|
136 | infoValue = param[i * 2 + 1].GetDouble();
|
---|
137 |
|
---|
138 | AddInfo(infoName, infoValue);
|
---|
139 | }
|
---|
140 | }
|
---|
141 |
|
---|
142 | //------------------------------------------------------------------------------
|
---|
143 |
|
---|
144 | void TreeWriter::Finish()
|
---|
145 | {
|
---|
146 | }
|
---|
147 |
|
---|
148 | //------------------------------------------------------------------------------
|
---|
149 |
|
---|
150 | void TreeWriter::FillParticles(Candidate *candidate, TRefArray *array)
|
---|
151 | {
|
---|
152 | TIter it1(candidate->GetCandidates());
|
---|
153 | set<Candidate *> s;
|
---|
154 | set<Candidate *>::iterator it3;
|
---|
155 | it1.Reset();
|
---|
156 | s.clear();
|
---|
157 | array->Clear();
|
---|
158 |
|
---|
159 | while((candidate = static_cast<Candidate *>(it1.Next())))
|
---|
160 | {
|
---|
161 | TIter it2(candidate->GetCandidates());
|
---|
162 |
|
---|
163 | // particle
|
---|
164 | if(candidate->GetCandidates()->GetEntriesFast() == 0)
|
---|
165 | {
|
---|
166 | s.insert(candidate);
|
---|
167 | continue;
|
---|
168 | }
|
---|
169 |
|
---|
170 | // track
|
---|
171 | candidate = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
|
---|
172 | if(candidate->GetCandidates()->GetEntriesFast() == 0)
|
---|
173 | {
|
---|
174 | s.insert(candidate);
|
---|
175 | continue;
|
---|
176 | }
|
---|
177 |
|
---|
178 | // tower
|
---|
179 | it2.Reset();
|
---|
180 | while((candidate = static_cast<Candidate *>(it2.Next())))
|
---|
181 | {
|
---|
182 | candidate = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
|
---|
183 | if(candidate->GetCandidates()->GetEntriesFast() == 0)
|
---|
184 | {
|
---|
185 | s.insert(candidate);
|
---|
186 | }
|
---|
187 | }
|
---|
188 | }
|
---|
189 |
|
---|
190 | for(it3 = s.begin(); it3 != s.end(); ++it3)
|
---|
191 | {
|
---|
192 | array->Add(*it3);
|
---|
193 | }
|
---|
194 | }
|
---|
195 |
|
---|
196 | //------------------------------------------------------------------------------
|
---|
197 |
|
---|
198 | void TreeWriter::ProcessParticles(ExRootTreeBranch *branch, TObjArray *array)
|
---|
199 | {
|
---|
200 | TIter iterator(array);
|
---|
201 | Candidate *candidate = 0;
|
---|
202 | GenParticle *entry = 0;
|
---|
203 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
204 |
|
---|
205 | const Double_t c_light = 2.99792458E8;
|
---|
206 |
|
---|
207 | // loop over all particles
|
---|
208 | iterator.Reset();
|
---|
209 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
210 | {
|
---|
211 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
212 | const TLorentzVector &position = candidate->Position;
|
---|
213 |
|
---|
214 | entry = static_cast<GenParticle *>(branch->NewEntry());
|
---|
215 |
|
---|
216 | entry->SetBit(kIsReferenced);
|
---|
217 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
218 |
|
---|
219 | pt = momentum.Pt();
|
---|
220 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
221 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
222 | eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
|
---|
223 | rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
|
---|
224 |
|
---|
225 | entry->PID = candidate->PID;
|
---|
226 |
|
---|
227 | entry->Status = candidate->Status;
|
---|
228 | entry->IsPU = candidate->IsPU;
|
---|
229 |
|
---|
230 | entry->M1 = candidate->M1;
|
---|
231 | entry->M2 = candidate->M2;
|
---|
232 |
|
---|
233 | entry->D1 = candidate->D1;
|
---|
234 | entry->D2 = candidate->D2;
|
---|
235 |
|
---|
236 | entry->Charge = candidate->Charge;
|
---|
237 | entry->Mass = candidate->Mass;
|
---|
238 |
|
---|
239 | entry->E = momentum.E();
|
---|
240 | entry->Px = momentum.Px();
|
---|
241 | entry->Py = momentum.Py();
|
---|
242 | entry->Pz = momentum.Pz();
|
---|
243 |
|
---|
244 | entry->Eta = eta;
|
---|
245 | entry->Phi = momentum.Phi();
|
---|
246 | entry->PT = pt;
|
---|
247 |
|
---|
248 | entry->Rapidity = rapidity;
|
---|
249 |
|
---|
250 | entry->X = position.X();
|
---|
251 | entry->Y = position.Y();
|
---|
252 | entry->Z = position.Z();
|
---|
253 | entry->T = position.T() * 1.0E-3 / c_light;
|
---|
254 |
|
---|
255 | }
|
---|
256 | }
|
---|
257 |
|
---|
258 | //------------------------------------------------------------------------------
|
---|
259 |
|
---|
260 | void TreeWriter::ProcessVertices(ExRootTreeBranch *branch, TObjArray *array)
|
---|
261 | {
|
---|
262 | TIter iterator(array);
|
---|
263 | Candidate *candidate = 0, *constituent = 0;
|
---|
264 | Vertex *entry = 0;
|
---|
265 |
|
---|
266 | const Double_t c_light = 2.99792458E8;
|
---|
267 |
|
---|
268 | Double_t x, y, z, t, xError, yError, zError, tError, sigma, sumPT2, btvSumPT2, genDeltaZ, genSumPT2;
|
---|
269 | UInt_t index, ndf;
|
---|
270 |
|
---|
271 | CompBase *compare = Candidate::fgCompare;
|
---|
272 | Candidate::fgCompare = CompSumPT2<Candidate>::Instance();
|
---|
273 | array->Sort();
|
---|
274 | Candidate::fgCompare = compare;
|
---|
275 |
|
---|
276 | // loop over all vertices
|
---|
277 | iterator.Reset();
|
---|
278 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
279 | {
|
---|
280 |
|
---|
281 | index = candidate->ClusterIndex;
|
---|
282 | ndf = candidate->ClusterNDF;
|
---|
283 | sigma = candidate->ClusterSigma;
|
---|
284 | sumPT2 = candidate->SumPT2;
|
---|
285 | btvSumPT2 = candidate->BTVSumPT2;
|
---|
286 | genDeltaZ = candidate->GenDeltaZ;
|
---|
287 | genSumPT2 = candidate->GenSumPT2;
|
---|
288 |
|
---|
289 | x = candidate->Position.X();
|
---|
290 | y = candidate->Position.Y();
|
---|
291 | z = candidate->Position.Z();
|
---|
292 | t = candidate->Position.T() * 1.0E-3 / c_light;
|
---|
293 |
|
---|
294 | xError = candidate->PositionError.X();
|
---|
295 | yError = candidate->PositionError.Y();
|
---|
296 | zError = candidate->PositionError.Z();
|
---|
297 | tError = candidate->PositionError.T() * 1.0E-3 / c_light;
|
---|
298 |
|
---|
299 | entry = static_cast<Vertex *>(branch->NewEntry());
|
---|
300 |
|
---|
301 | entry->Index = index;
|
---|
302 | entry->NDF = ndf;
|
---|
303 | entry->Sigma = sigma;
|
---|
304 | entry->SumPT2 = sumPT2;
|
---|
305 | entry->BTVSumPT2 = btvSumPT2;
|
---|
306 | entry->GenDeltaZ = genDeltaZ;
|
---|
307 | entry->GenSumPT2 = genSumPT2;
|
---|
308 |
|
---|
309 | entry->X = x;
|
---|
310 | entry->Y = y;
|
---|
311 | entry->Z = z;
|
---|
312 | entry->T = t;
|
---|
313 |
|
---|
314 | entry->ErrorX = xError;
|
---|
315 | entry->ErrorY = yError;
|
---|
316 | entry->ErrorZ = zError;
|
---|
317 | entry->ErrorT = tError;
|
---|
318 |
|
---|
319 | TIter itConstituents(candidate->GetCandidates());
|
---|
320 | itConstituents.Reset();
|
---|
321 | entry->Constituents.Clear();
|
---|
322 | while((constituent = static_cast<Candidate *>(itConstituents.Next())))
|
---|
323 | {
|
---|
324 | entry->Constituents.Add(constituent);
|
---|
325 | }
|
---|
326 | }
|
---|
327 | }
|
---|
328 |
|
---|
329 | //------------------------------------------------------------------------------
|
---|
330 |
|
---|
331 | void TreeWriter::ProcessTracks(ExRootTreeBranch *branch, TObjArray *array)
|
---|
332 | {
|
---|
333 | TIter iterator(array);
|
---|
334 | Candidate *candidate = 0;
|
---|
335 | Candidate *particle = 0;
|
---|
336 | Track *entry = 0;
|
---|
337 | Double_t pt, signz, cosTheta, eta, rapidity, p, ctgTheta, phi, m;
|
---|
338 | const Double_t c_light = 2.99792458E8;
|
---|
339 |
|
---|
340 | // loop over all tracks
|
---|
341 | iterator.Reset();
|
---|
342 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
343 | {
|
---|
344 | const TLorentzVector &position = candidate->Position;
|
---|
345 |
|
---|
346 | cosTheta = TMath::Abs(position.CosTheta());
|
---|
347 | signz = (position.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
348 | eta = (cosTheta == 1.0 ? signz * 999.9 : position.Eta());
|
---|
349 | rapidity = (cosTheta == 1.0 ? signz * 999.9 : position.Rapidity());
|
---|
350 |
|
---|
351 | entry = static_cast<Track *>(branch->NewEntry());
|
---|
352 |
|
---|
353 | entry->SetBit(kIsReferenced);
|
---|
354 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
355 |
|
---|
356 | entry->PID = candidate->PID;
|
---|
357 |
|
---|
358 | entry->Charge = candidate->Charge;
|
---|
359 |
|
---|
360 | entry->EtaOuter = eta;
|
---|
361 | entry->PhiOuter = position.Phi();
|
---|
362 |
|
---|
363 | entry->XOuter = position.X();
|
---|
364 | entry->YOuter = position.Y();
|
---|
365 | entry->ZOuter = position.Z();
|
---|
366 | entry->TOuter = position.T() * 1.0E-3 / c_light;
|
---|
367 |
|
---|
368 | entry->L = candidate->L;
|
---|
369 |
|
---|
370 | entry->D0 = candidate->D0;
|
---|
371 | entry->DZ = candidate->DZ;
|
---|
372 | entry->Nclusters = candidate->Nclusters;
|
---|
373 | entry->dNdx = candidate->dNdx;
|
---|
374 |
|
---|
375 | entry->ErrorP = candidate->ErrorP;
|
---|
376 | entry->ErrorPT = candidate->ErrorPT;
|
---|
377 |
|
---|
378 | // diagonal covariance matrix terms
|
---|
379 | entry->ErrorD0 = candidate->ErrorD0;
|
---|
380 | entry->ErrorC = candidate->ErrorC;
|
---|
381 | entry->ErrorPhi = candidate->ErrorPhi;
|
---|
382 | entry->ErrorDZ = candidate->ErrorDZ;
|
---|
383 | entry->ErrorCtgTheta = candidate->ErrorCtgTheta;
|
---|
384 |
|
---|
385 | // add some offdiagonal covariance matrix elements
|
---|
386 | entry->ErrorD0Phi = candidate->TrackCovariance(0,1)*1.e3;
|
---|
387 | entry->ErrorD0C = candidate->TrackCovariance(0,2);
|
---|
388 | entry->ErrorD0DZ = candidate->TrackCovariance(0,3)*1.e6;
|
---|
389 | entry->ErrorD0CtgTheta = candidate->TrackCovariance(0,4)*1.e3;
|
---|
390 | entry->ErrorPhiC = candidate->TrackCovariance(1,2)*1.e-3;
|
---|
391 | entry->ErrorPhiDZ = candidate->TrackCovariance(1,3)*1.e3;
|
---|
392 | entry->ErrorPhiCtgTheta = candidate->TrackCovariance(1,4);
|
---|
393 | entry->ErrorCDZ = candidate->TrackCovariance(2,3);
|
---|
394 | entry->ErrorCCtgTheta = candidate->TrackCovariance(2,4)*1.e-3;
|
---|
395 | entry->ErrorDZCtgTheta = candidate->TrackCovariance(3,4)*1.e3;
|
---|
396 |
|
---|
397 | entry->Xd = candidate->Xd;
|
---|
398 | entry->Yd = candidate->Yd;
|
---|
399 | entry->Zd = candidate->Zd;
|
---|
400 |
|
---|
401 | entry->XFirstHit = candidate->XFirstHit;
|
---|
402 | entry->YFirstHit = candidate->YFirstHit;
|
---|
403 | entry->ZFirstHit = candidate->ZFirstHit;
|
---|
404 |
|
---|
405 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
406 |
|
---|
407 | pt = momentum.Pt();
|
---|
408 | p = momentum.P();
|
---|
409 | phi = momentum.Phi();
|
---|
410 | m = momentum.M();
|
---|
411 | ctgTheta = (TMath::Tan(momentum.Theta()) != 0) ? 1 / TMath::Tan(momentum.Theta()) : 1e10;
|
---|
412 |
|
---|
413 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
414 | signz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
415 | eta = (cosTheta == 1.0 ? signz * 999.9 : momentum.Eta());
|
---|
416 | rapidity = (cosTheta == 1.0 ? signz * 999.9 : momentum.Rapidity());
|
---|
417 |
|
---|
418 | entry->P = p;
|
---|
419 | entry->PT = pt;
|
---|
420 | entry->Eta = eta;
|
---|
421 | entry->Phi = phi;
|
---|
422 | entry->CtgTheta = ctgTheta;
|
---|
423 | entry->C = candidate->C;
|
---|
424 | entry->Mass = m;
|
---|
425 |
|
---|
426 | particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
|
---|
427 | //const TLorentzVector &initialPosition = particle->Position;
|
---|
428 | const TLorentzVector &initialPosition = candidate->InitialPosition;
|
---|
429 |
|
---|
430 | entry->X = initialPosition.X();
|
---|
431 | entry->Y = initialPosition.Y();
|
---|
432 | entry->Z = initialPosition.Z();
|
---|
433 | entry->T = initialPosition.T() * 1.0E-3 / c_light;
|
---|
434 | entry->ErrorT =candidate-> ErrorT * 1.0E-3 / c_light;
|
---|
435 |
|
---|
436 | entry->Particle = particle;
|
---|
437 |
|
---|
438 | entry->VertexIndex = candidate->ClusterIndex;
|
---|
439 | }
|
---|
440 | }
|
---|
441 |
|
---|
442 | //------------------------------------------------------------------------------
|
---|
443 |
|
---|
444 | void TreeWriter::ProcessTowers(ExRootTreeBranch *branch, TObjArray *array)
|
---|
445 | {
|
---|
446 | TIter iterator(array);
|
---|
447 | Candidate *candidate = 0;
|
---|
448 | Tower *entry = 0;
|
---|
449 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
450 | const Double_t c_light = 2.99792458E8;
|
---|
451 |
|
---|
452 | // loop over all towers
|
---|
453 | iterator.Reset();
|
---|
454 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
455 | {
|
---|
456 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
457 | const TLorentzVector &position = candidate->Position;
|
---|
458 |
|
---|
459 | pt = momentum.Pt();
|
---|
460 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
461 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
462 | eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
|
---|
463 | rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
|
---|
464 |
|
---|
465 | entry = static_cast<Tower *>(branch->NewEntry());
|
---|
466 |
|
---|
467 | entry->SetBit(kIsReferenced);
|
---|
468 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
469 |
|
---|
470 | entry->Eta = eta;
|
---|
471 | entry->Phi = momentum.Phi();
|
---|
472 | entry->ET = pt;
|
---|
473 | entry->E = momentum.E();
|
---|
474 | entry->Eem = candidate->Eem;
|
---|
475 | entry->Ehad = candidate->Ehad;
|
---|
476 | entry->Etrk = candidate->Etrk;
|
---|
477 | entry->Edges[0] = candidate->Edges[0];
|
---|
478 | entry->Edges[1] = candidate->Edges[1];
|
---|
479 | entry->Edges[2] = candidate->Edges[2];
|
---|
480 | entry->Edges[3] = candidate->Edges[3];
|
---|
481 |
|
---|
482 | entry->T = position.T() * 1.0E-3 / c_light;
|
---|
483 | entry->NTimeHits = candidate->NTimeHits;
|
---|
484 |
|
---|
485 | FillParticles(candidate, &entry->Particles);
|
---|
486 | }
|
---|
487 | }
|
---|
488 |
|
---|
489 | //------------------------------------------------------------------------------
|
---|
490 |
|
---|
491 | void TreeWriter::ProcessParticleFlowCandidates(ExRootTreeBranch *branch, TObjArray *array)
|
---|
492 | {
|
---|
493 |
|
---|
494 | TIter iterator(array);
|
---|
495 | Candidate *candidate = 0;
|
---|
496 | Candidate *particle = 0;
|
---|
497 | ParticleFlowCandidate *entry = 0;
|
---|
498 | Double_t e, pt, signz, cosTheta, eta, rapidity, p, ctgTheta, phi, m;
|
---|
499 | const Double_t c_light = 2.99792458E8;
|
---|
500 |
|
---|
501 | // loop over all tracks
|
---|
502 | iterator.Reset();
|
---|
503 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
504 | {
|
---|
505 | const TLorentzVector &position = candidate->Position;
|
---|
506 |
|
---|
507 | cosTheta = TMath::Abs(position.CosTheta());
|
---|
508 | signz = (position.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
509 | eta = (cosTheta == 1.0 ? signz * 999.9 : position.Eta());
|
---|
510 | rapidity = (cosTheta == 1.0 ? signz * 999.9 : position.Rapidity());
|
---|
511 |
|
---|
512 | entry = static_cast<ParticleFlowCandidate *>(branch->NewEntry());
|
---|
513 |
|
---|
514 | entry->SetBit(kIsReferenced);
|
---|
515 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
516 |
|
---|
517 | entry->PID = candidate->PID;
|
---|
518 |
|
---|
519 | entry->Charge = candidate->Charge;
|
---|
520 |
|
---|
521 | entry->EtaOuter = eta;
|
---|
522 | entry->PhiOuter = position.Phi();
|
---|
523 |
|
---|
524 | entry->XOuter = position.X();
|
---|
525 | entry->YOuter = position.Y();
|
---|
526 | entry->ZOuter = position.Z();
|
---|
527 | entry->TOuter = position.T() * 1.0E-3 / c_light;
|
---|
528 |
|
---|
529 | entry->L = candidate->L;
|
---|
530 |
|
---|
531 | entry->D0 = candidate->D0;
|
---|
532 | entry->DZ = candidate->DZ;
|
---|
533 | entry->Nclusters = candidate->Nclusters;
|
---|
534 | entry->dNdx = candidate->dNdx;
|
---|
535 |
|
---|
536 | entry->ErrorP = candidate->ErrorP;
|
---|
537 | entry->ErrorPT = candidate->ErrorPT;
|
---|
538 | entry->ErrorCtgTheta = candidate->ErrorCtgTheta;
|
---|
539 |
|
---|
540 |
|
---|
541 | // diagonal covariance matrix terms
|
---|
542 |
|
---|
543 | entry->ErrorD0 = candidate->ErrorD0;
|
---|
544 | entry->ErrorC = candidate->ErrorC;
|
---|
545 | entry->ErrorPhi = candidate->ErrorPhi;
|
---|
546 | entry->ErrorDZ = candidate->ErrorDZ;
|
---|
547 | entry->ErrorCtgTheta = candidate->ErrorCtgTheta;
|
---|
548 |
|
---|
549 | // add some offdiagonal covariance matrix elements
|
---|
550 | entry->ErrorD0Phi = candidate->TrackCovariance(0,1);
|
---|
551 | entry->ErrorD0C = candidate->TrackCovariance(0,2);
|
---|
552 | entry->ErrorD0DZ = candidate->TrackCovariance(0,3);
|
---|
553 | entry->ErrorD0CtgTheta = candidate->TrackCovariance(0,4);
|
---|
554 | entry->ErrorPhiC = candidate->TrackCovariance(1,2);
|
---|
555 | entry->ErrorPhiDZ = candidate->TrackCovariance(1,3);
|
---|
556 | entry->ErrorPhiCtgTheta = candidate->TrackCovariance(1,4);
|
---|
557 | entry->ErrorCDZ = candidate->TrackCovariance(2,3);
|
---|
558 | entry->ErrorCCtgTheta = candidate->TrackCovariance(2,4);
|
---|
559 | entry->ErrorDZCtgTheta = candidate->TrackCovariance(3,4);
|
---|
560 |
|
---|
561 | entry->Xd = candidate->Xd;
|
---|
562 | entry->Yd = candidate->Yd;
|
---|
563 | entry->Zd = candidate->Zd;
|
---|
564 |
|
---|
565 | entry->XFirstHit = candidate->XFirstHit;
|
---|
566 | entry->YFirstHit = candidate->YFirstHit;
|
---|
567 | entry->ZFirstHit = candidate->ZFirstHit;
|
---|
568 |
|
---|
569 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
570 |
|
---|
571 | e = momentum.E();
|
---|
572 | pt = momentum.Pt();
|
---|
573 | p = momentum.P();
|
---|
574 | phi = momentum.Phi();
|
---|
575 | m = momentum.M();
|
---|
576 | ctgTheta = (TMath::Tan(momentum.Theta()) != 0) ? 1 / TMath::Tan(momentum.Theta()) : 1e10;
|
---|
577 |
|
---|
578 | entry->E = e;
|
---|
579 | entry->P = p;
|
---|
580 | entry->PT = pt;
|
---|
581 | entry->Eta = eta;
|
---|
582 | entry->Phi = phi;
|
---|
583 | entry->CtgTheta = ctgTheta;
|
---|
584 | entry->C = candidate->C;
|
---|
585 | entry->Mass = m;
|
---|
586 |
|
---|
587 | particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
|
---|
588 | //const TLorentzVector &initialPosition = particle->Position;
|
---|
589 | const TLorentzVector &initialPosition = candidate->InitialPosition;
|
---|
590 |
|
---|
591 | entry->X = initialPosition.X();
|
---|
592 | entry->Y = initialPosition.Y();
|
---|
593 | entry->Z = initialPosition.Z();
|
---|
594 | entry->T = initialPosition.T() * 1.0E-3 / c_light;
|
---|
595 | entry->ErrorT = candidate-> ErrorT * 1.0E-3 / c_light;
|
---|
596 |
|
---|
597 | entry->VertexIndex = candidate->ClusterIndex;
|
---|
598 |
|
---|
599 | entry->Eem = candidate->Eem;
|
---|
600 | entry->Ehad = candidate->Ehad;
|
---|
601 | entry->Etrk = candidate->Etrk;
|
---|
602 | entry->Edges[0] = candidate->Edges[0];
|
---|
603 | entry->Edges[1] = candidate->Edges[1];
|
---|
604 | entry->Edges[2] = candidate->Edges[2];
|
---|
605 | entry->Edges[3] = candidate->Edges[3];
|
---|
606 |
|
---|
607 | //entry->T = position.T() * 1.0E-3 / c_light;
|
---|
608 | entry->NTimeHits = candidate->NTimeHits;
|
---|
609 |
|
---|
610 | FillParticles(candidate, &entry->Particles);
|
---|
611 |
|
---|
612 | }
|
---|
613 | }
|
---|
614 |
|
---|
615 | //------------------------------------------------------------------------------
|
---|
616 |
|
---|
617 | void TreeWriter::ProcessPhotons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
618 | {
|
---|
619 | TIter iterator(array);
|
---|
620 | Candidate *candidate = 0;
|
---|
621 | Photon *entry = 0;
|
---|
622 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
623 | const Double_t c_light = 2.99792458E8;
|
---|
624 |
|
---|
625 | array->Sort();
|
---|
626 |
|
---|
627 | // loop over all photons
|
---|
628 | iterator.Reset();
|
---|
629 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
630 | {
|
---|
631 | TIter it1(candidate->GetCandidates());
|
---|
632 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
633 | const TLorentzVector &position = candidate->Position;
|
---|
634 |
|
---|
635 | pt = momentum.Pt();
|
---|
636 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
637 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
638 | eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
|
---|
639 | rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
|
---|
640 |
|
---|
641 | entry = static_cast<Photon *>(branch->NewEntry());
|
---|
642 |
|
---|
643 | entry->Eta = eta;
|
---|
644 | entry->Phi = momentum.Phi();
|
---|
645 | entry->PT = pt;
|
---|
646 | entry->E = momentum.E();
|
---|
647 | entry->T = position.T() * 1.0E-3 / c_light;
|
---|
648 |
|
---|
649 | // Isolation variables
|
---|
650 |
|
---|
651 | entry->IsolationVar = candidate->IsolationVar;
|
---|
652 | entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr;
|
---|
653 | entry->SumPtCharged = candidate->SumPtCharged;
|
---|
654 | entry->SumPtNeutral = candidate->SumPtNeutral;
|
---|
655 | entry->SumPtChargedPU = candidate->SumPtChargedPU;
|
---|
656 | entry->SumPt = candidate->SumPt;
|
---|
657 |
|
---|
658 | entry->EhadOverEem = candidate->Eem > 0.0 ? candidate->Ehad / candidate->Eem : 999.9;
|
---|
659 |
|
---|
660 | // 1: prompt -- 2: non prompt -- 3: fake
|
---|
661 | entry->Status = candidate->Status;
|
---|
662 |
|
---|
663 | FillParticles(candidate, &entry->Particles);
|
---|
664 | }
|
---|
665 | }
|
---|
666 |
|
---|
667 | //------------------------------------------------------------------------------
|
---|
668 |
|
---|
669 | void TreeWriter::ProcessElectrons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
670 | {
|
---|
671 | TIter iterator(array);
|
---|
672 | Candidate *candidate = 0;
|
---|
673 | Electron *entry = 0;
|
---|
674 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
675 | const Double_t c_light = 2.99792458E8;
|
---|
676 |
|
---|
677 | array->Sort();
|
---|
678 |
|
---|
679 | // loop over all electrons
|
---|
680 | iterator.Reset();
|
---|
681 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
682 | {
|
---|
683 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
684 | const TLorentzVector &position = candidate->Position;
|
---|
685 |
|
---|
686 | pt = momentum.Pt();
|
---|
687 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
688 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
689 | eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
|
---|
690 | rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
|
---|
691 |
|
---|
692 | entry = static_cast<Electron *>(branch->NewEntry());
|
---|
693 |
|
---|
694 | entry->Eta = eta;
|
---|
695 | entry->Phi = momentum.Phi();
|
---|
696 | entry->PT = pt;
|
---|
697 |
|
---|
698 | entry->T = position.T() * 1.0E-3 / c_light;
|
---|
699 |
|
---|
700 | // displacement
|
---|
701 | entry->D0 = candidate->D0;
|
---|
702 | entry->ErrorD0 = candidate->ErrorD0;
|
---|
703 | entry->DZ = candidate->DZ;
|
---|
704 | entry->ErrorDZ = candidate->ErrorDZ;
|
---|
705 |
|
---|
706 | // Isolation variables
|
---|
707 | entry->IsolationVar = candidate->IsolationVar;
|
---|
708 | entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr;
|
---|
709 | entry->SumPtCharged = candidate->SumPtCharged;
|
---|
710 | entry->SumPtNeutral = candidate->SumPtNeutral;
|
---|
711 | entry->SumPtChargedPU = candidate->SumPtChargedPU;
|
---|
712 | entry->SumPt = candidate->SumPt;
|
---|
713 |
|
---|
714 | entry->Charge = candidate->Charge;
|
---|
715 |
|
---|
716 | entry->EhadOverEem = 0.0;
|
---|
717 |
|
---|
718 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
719 | }
|
---|
720 | }
|
---|
721 |
|
---|
722 | //------------------------------------------------------------------------------
|
---|
723 |
|
---|
724 | void TreeWriter::ProcessMuons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
725 | {
|
---|
726 | TIter iterator(array);
|
---|
727 | Candidate *candidate = 0;
|
---|
728 | Muon *entry = 0;
|
---|
729 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
730 |
|
---|
731 | const Double_t c_light = 2.99792458E8;
|
---|
732 |
|
---|
733 | array->Sort();
|
---|
734 |
|
---|
735 | // loop over all muons
|
---|
736 | iterator.Reset();
|
---|
737 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
738 | {
|
---|
739 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
740 | const TLorentzVector &position = candidate->Position;
|
---|
741 |
|
---|
742 | pt = momentum.Pt();
|
---|
743 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
744 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
745 | eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
|
---|
746 | rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
|
---|
747 |
|
---|
748 | entry = static_cast<Muon *>(branch->NewEntry());
|
---|
749 |
|
---|
750 | entry->SetBit(kIsReferenced);
|
---|
751 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
752 |
|
---|
753 | entry->Eta = eta;
|
---|
754 | entry->Phi = momentum.Phi();
|
---|
755 | entry->PT = pt;
|
---|
756 |
|
---|
757 | entry->T = position.T() * 1.0E-3 / c_light;
|
---|
758 |
|
---|
759 | // displacement
|
---|
760 | entry->D0 = candidate->D0;
|
---|
761 | entry->ErrorD0 = candidate->ErrorD0;
|
---|
762 | entry->DZ = candidate->DZ;
|
---|
763 | entry->ErrorDZ = candidate->ErrorDZ;
|
---|
764 |
|
---|
765 | // Isolation variables
|
---|
766 |
|
---|
767 | entry->IsolationVar = candidate->IsolationVar;
|
---|
768 | entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr;
|
---|
769 | entry->SumPtCharged = candidate->SumPtCharged;
|
---|
770 | entry->SumPtNeutral = candidate->SumPtNeutral;
|
---|
771 | entry->SumPtChargedPU = candidate->SumPtChargedPU;
|
---|
772 | entry->SumPt = candidate->SumPt;
|
---|
773 |
|
---|
774 | entry->Charge = candidate->Charge;
|
---|
775 |
|
---|
776 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
777 | }
|
---|
778 | }
|
---|
779 |
|
---|
780 | //------------------------------------------------------------------------------
|
---|
781 |
|
---|
782 | void TreeWriter::ProcessJets(ExRootTreeBranch *branch, TObjArray *array)
|
---|
783 | {
|
---|
784 | TIter iterator(array);
|
---|
785 | Candidate *candidate = 0, *constituent = 0;
|
---|
786 | Jet *entry = 0;
|
---|
787 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
788 | Double_t ecalEnergy, hcalEnergy;
|
---|
789 | const Double_t c_light = 2.99792458E8;
|
---|
790 | Int_t i;
|
---|
791 |
|
---|
792 | array->Sort();
|
---|
793 |
|
---|
794 | // loop over all jets
|
---|
795 | iterator.Reset();
|
---|
796 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
797 | {
|
---|
798 | TIter itConstituents(candidate->GetCandidates());
|
---|
799 |
|
---|
800 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
801 | const TLorentzVector &position = candidate->Position;
|
---|
802 |
|
---|
803 | pt = momentum.Pt();
|
---|
804 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
805 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
806 | eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
|
---|
807 | rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
|
---|
808 |
|
---|
809 | entry = static_cast<Jet *>(branch->NewEntry());
|
---|
810 |
|
---|
811 | entry->Eta = eta;
|
---|
812 | entry->Phi = momentum.Phi();
|
---|
813 | entry->PT = pt;
|
---|
814 |
|
---|
815 | entry->T = position.T() * 1.0E-3 / c_light;
|
---|
816 |
|
---|
817 | entry->Mass = momentum.M();
|
---|
818 |
|
---|
819 | entry->Area = candidate->Area;
|
---|
820 |
|
---|
821 | entry->DeltaEta = candidate->DeltaEta;
|
---|
822 | entry->DeltaPhi = candidate->DeltaPhi;
|
---|
823 |
|
---|
824 | entry->Flavor = candidate->Flavor;
|
---|
825 | entry->FlavorAlgo = candidate->FlavorAlgo;
|
---|
826 | entry->FlavorPhys = candidate->FlavorPhys;
|
---|
827 |
|
---|
828 | entry->BTag = candidate->BTag;
|
---|
829 |
|
---|
830 | entry->BTagAlgo = candidate->BTagAlgo;
|
---|
831 | entry->BTagPhys = candidate->BTagPhys;
|
---|
832 |
|
---|
833 | entry->TauTag = candidate->TauTag;
|
---|
834 | entry->TauWeight = candidate->TauWeight;
|
---|
835 |
|
---|
836 | entry->Charge = candidate->Charge;
|
---|
837 |
|
---|
838 | itConstituents.Reset();
|
---|
839 | entry->Constituents.Clear();
|
---|
840 | ecalEnergy = 0.0;
|
---|
841 | hcalEnergy = 0.0;
|
---|
842 | while((constituent = static_cast<Candidate *>(itConstituents.Next())))
|
---|
843 | {
|
---|
844 | entry->Constituents.Add(constituent);
|
---|
845 | ecalEnergy += constituent->Eem;
|
---|
846 | hcalEnergy += constituent->Ehad;
|
---|
847 | }
|
---|
848 |
|
---|
849 | entry->EhadOverEem = ecalEnergy > 0.0 ? hcalEnergy / ecalEnergy : 999.9;
|
---|
850 |
|
---|
851 | //--- Pile-Up Jet ID variables ----
|
---|
852 |
|
---|
853 | entry->NCharged = candidate->NCharged;
|
---|
854 | entry->NNeutrals = candidate->NNeutrals;
|
---|
855 |
|
---|
856 | entry->NeutralEnergyFraction = candidate->NeutralEnergyFraction;
|
---|
857 | entry->ChargedEnergyFraction = candidate->ChargedEnergyFraction;
|
---|
858 | entry->Beta = candidate->Beta;
|
---|
859 | entry->BetaStar = candidate->BetaStar;
|
---|
860 | entry->MeanSqDeltaR = candidate->MeanSqDeltaR;
|
---|
861 | entry->PTD = candidate->PTD;
|
---|
862 |
|
---|
863 | //--- Sub-structure variables ----
|
---|
864 |
|
---|
865 | entry->NSubJetsTrimmed = candidate->NSubJetsTrimmed;
|
---|
866 | entry->NSubJetsPruned = candidate->NSubJetsPruned;
|
---|
867 | entry->NSubJetsSoftDropped = candidate->NSubJetsSoftDropped;
|
---|
868 |
|
---|
869 | entry->SoftDroppedJet = candidate->SoftDroppedJet;
|
---|
870 | entry->SoftDroppedSubJet1 = candidate->SoftDroppedSubJet1;
|
---|
871 | entry->SoftDroppedSubJet2 = candidate->SoftDroppedSubJet2;
|
---|
872 |
|
---|
873 | for(i = 0; i < 5; i++)
|
---|
874 | {
|
---|
875 | entry->FracPt[i] = candidate->FracPt[i];
|
---|
876 | entry->Tau[i] = candidate->Tau[i];
|
---|
877 | entry->TrimmedP4[i] = candidate->TrimmedP4[i];
|
---|
878 | entry->PrunedP4[i] = candidate->PrunedP4[i];
|
---|
879 | entry->SoftDroppedP4[i] = candidate->SoftDroppedP4[i];
|
---|
880 | }
|
---|
881 |
|
---|
882 | //--- exclusive clustering variables ---
|
---|
883 | entry->ExclYmerge23 = candidate->ExclYmerge23;
|
---|
884 | entry->ExclYmerge34 = candidate->ExclYmerge34;
|
---|
885 | entry->ExclYmerge45 = candidate->ExclYmerge45;
|
---|
886 | entry->ExclYmerge56 = candidate->ExclYmerge56;
|
---|
887 |
|
---|
888 | FillParticles(candidate, &entry->Particles);
|
---|
889 | }
|
---|
890 | }
|
---|
891 |
|
---|
892 | //------------------------------------------------------------------------------
|
---|
893 |
|
---|
894 | void TreeWriter::ProcessMissingET(ExRootTreeBranch *branch, TObjArray *array)
|
---|
895 | {
|
---|
896 | Candidate *candidate = 0;
|
---|
897 | MissingET *entry = 0;
|
---|
898 |
|
---|
899 | // get the first entry
|
---|
900 | if((candidate = static_cast<Candidate *>(array->At(0))))
|
---|
901 | {
|
---|
902 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
903 |
|
---|
904 | entry = static_cast<MissingET *>(branch->NewEntry());
|
---|
905 |
|
---|
906 | entry->Eta = (-momentum).Eta();
|
---|
907 | entry->Phi = (-momentum).Phi();
|
---|
908 | entry->MET = momentum.Pt();
|
---|
909 | }
|
---|
910 | }
|
---|
911 | //------------------------------------------------------------------------------
|
---|
912 |
|
---|
913 | void TreeWriter::ProcessCscCluster(ExRootTreeBranch *branch, TObjArray *array)
|
---|
914 | {
|
---|
915 | TIter iterator(array);
|
---|
916 | Candidate *candidate = 0;
|
---|
917 | CscCluster *entry = 0;
|
---|
918 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
919 |
|
---|
920 | const Double_t c_light = 2.99792458E8; // in unit of m/s
|
---|
921 |
|
---|
922 | array->Sort();
|
---|
923 |
|
---|
924 |
|
---|
925 | // loop over all clusters
|
---|
926 | iterator.Reset();
|
---|
927 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
928 | {
|
---|
929 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
930 | const TLorentzVector &position = candidate->DecayPosition;
|
---|
931 |
|
---|
932 | pt = momentum.Pt();
|
---|
933 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
934 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
935 | eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
|
---|
936 |
|
---|
937 | entry = static_cast<CscCluster *>(branch->NewEntry());
|
---|
938 |
|
---|
939 | entry->SetBit(kIsReferenced);
|
---|
940 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
941 |
|
---|
942 | entry->Eta = eta;
|
---|
943 | entry->Phi = momentum.Phi();
|
---|
944 |
|
---|
945 | entry->PT = momentum.Pt(); // pt of LLP
|
---|
946 | entry->Px = momentum.Px();// px of LLP
|
---|
947 | entry->Py = momentum.Py();// py of LLP
|
---|
948 | entry->Pz = momentum.Pz();// pz of LLP
|
---|
949 | entry->E = momentum.E(); // E of LLP
|
---|
950 | entry->pid = candidate->PID; // LLP pid
|
---|
951 | entry->Eem = candidate->Eem; // LLP Eem
|
---|
952 | entry->Ehad = candidate->Ehad; // LLP Ehad
|
---|
953 | Double_t beta = momentum.P()/momentum.E();
|
---|
954 | Double_t gamma = 1.0/sqrt(1-beta*beta);
|
---|
955 | Double_t decayDistance = sqrt(pow(position.X(),2)+pow(position.Y(),2)+pow(position.Z(),2)); // mm
|
---|
956 | entry->beta = beta; // LLP pid
|
---|
957 | entry->ctau = decayDistance/(beta * gamma); // LLP travel time in its rest frame
|
---|
958 | entry->T = decayDistance*(1./beta-1)* 1.0E-3/c_light*1e9; // ns
|
---|
959 | entry->X = position.X(); // LLP decay x
|
---|
960 | entry->Y = position.Y(); // LLP decay y
|
---|
961 | entry->Z = position.Z(); // LLP decay z
|
---|
962 | }
|
---|
963 | }
|
---|
964 |
|
---|
965 | //------------------------------------------------------------------------------
|
---|
966 |
|
---|
967 | void TreeWriter::ProcessScalarHT(ExRootTreeBranch *branch, TObjArray *array)
|
---|
968 | {
|
---|
969 | Candidate *candidate = 0;
|
---|
970 | ScalarHT *entry = 0;
|
---|
971 |
|
---|
972 | // get the first entry
|
---|
973 | if((candidate = static_cast<Candidate *>(array->At(0))))
|
---|
974 | {
|
---|
975 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
976 |
|
---|
977 | entry = static_cast<ScalarHT *>(branch->NewEntry());
|
---|
978 |
|
---|
979 | entry->HT = momentum.Pt();
|
---|
980 | }
|
---|
981 | }
|
---|
982 |
|
---|
983 | //------------------------------------------------------------------------------
|
---|
984 |
|
---|
985 | void TreeWriter::ProcessRho(ExRootTreeBranch *branch, TObjArray *array)
|
---|
986 | {
|
---|
987 | TIter iterator(array);
|
---|
988 | Candidate *candidate = 0;
|
---|
989 | Rho *entry = 0;
|
---|
990 |
|
---|
991 | // loop over all rho
|
---|
992 | iterator.Reset();
|
---|
993 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
994 | {
|
---|
995 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
996 |
|
---|
997 | entry = static_cast<Rho *>(branch->NewEntry());
|
---|
998 |
|
---|
999 | entry->Rho = momentum.E();
|
---|
1000 | entry->Edges[0] = candidate->Edges[0];
|
---|
1001 | entry->Edges[1] = candidate->Edges[1];
|
---|
1002 | }
|
---|
1003 | }
|
---|
1004 |
|
---|
1005 | //------------------------------------------------------------------------------
|
---|
1006 |
|
---|
1007 | void TreeWriter::ProcessWeight(ExRootTreeBranch *branch, TObjArray *array)
|
---|
1008 | {
|
---|
1009 | Candidate *candidate = 0;
|
---|
1010 | Weight *entry = 0;
|
---|
1011 |
|
---|
1012 | // get the first entry
|
---|
1013 | if((candidate = static_cast<Candidate *>(array->At(0))))
|
---|
1014 | {
|
---|
1015 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
1016 |
|
---|
1017 | entry = static_cast<Weight *>(branch->NewEntry());
|
---|
1018 |
|
---|
1019 | entry->Weight = momentum.E();
|
---|
1020 | }
|
---|
1021 | }
|
---|
1022 |
|
---|
1023 | //------------------------------------------------------------------------------
|
---|
1024 |
|
---|
1025 | void TreeWriter::ProcessHectorHit(ExRootTreeBranch *branch, TObjArray *array)
|
---|
1026 | {
|
---|
1027 | TIter iterator(array);
|
---|
1028 | Candidate *candidate = 0;
|
---|
1029 | HectorHit *entry = 0;
|
---|
1030 |
|
---|
1031 | // loop over all roman pot hits
|
---|
1032 | iterator.Reset();
|
---|
1033 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
1034 | {
|
---|
1035 | const TLorentzVector &position = candidate->Position;
|
---|
1036 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
1037 |
|
---|
1038 | entry = static_cast<HectorHit *>(branch->NewEntry());
|
---|
1039 |
|
---|
1040 | entry->E = momentum.E();
|
---|
1041 |
|
---|
1042 | entry->Tx = momentum.Px();
|
---|
1043 | entry->Ty = momentum.Py();
|
---|
1044 |
|
---|
1045 | entry->T = position.T();
|
---|
1046 |
|
---|
1047 | entry->X = position.X();
|
---|
1048 | entry->Y = position.Y();
|
---|
1049 | entry->S = position.Z();
|
---|
1050 |
|
---|
1051 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
1052 | }
|
---|
1053 | }
|
---|
1054 |
|
---|
1055 | //------------------------------------------------------------------------------
|
---|
1056 |
|
---|
1057 | void TreeWriter::Process()
|
---|
1058 | {
|
---|
1059 | TBranchMap::iterator itBranchMap;
|
---|
1060 | ExRootTreeBranch *branch;
|
---|
1061 | TProcessMethod method;
|
---|
1062 | TObjArray *array;
|
---|
1063 |
|
---|
1064 | for(itBranchMap = fBranchMap.begin(); itBranchMap != fBranchMap.end(); ++itBranchMap)
|
---|
1065 | {
|
---|
1066 | branch = itBranchMap->first;
|
---|
1067 | method = itBranchMap->second.first;
|
---|
1068 | array = itBranchMap->second.second;
|
---|
1069 |
|
---|
1070 | (this->*method)(branch, array);
|
---|
1071 | }
|
---|
1072 | }
|
---|
1073 |
|
---|
1074 | //------------------------------------------------------------------------------
|
---|