[b443089] | 1 | /*
|
---|
| 2 | * Delphes: a framework for fast simulation of a generic collider experiment
|
---|
| 3 | * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
|
---|
[1fa50c2] | 4 | *
|
---|
[b443089] | 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.
|
---|
[1fa50c2] | 9 | *
|
---|
[b443089] | 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.
|
---|
[1fa50c2] | 14 | *
|
---|
[b443089] | 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 |
|
---|
[d7d2da3] | 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;
|
---|
[2de4dcd] | 72 | fClassMap[Vertex::Class()] = &TreeWriter::ProcessVertices;
|
---|
[d7d2da3] | 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;
|
---|
[71648c2] | 81 | fClassMap[Rho::Class()] = &TreeWriter::ProcessRho;
|
---|
[2e229c9] | 82 | fClassMap[Weight::Class()] = &TreeWriter::ProcessWeight;
|
---|
[8f7db23] | 83 | fClassMap[HectorHit::Class()] = &TreeWriter::ProcessHectorHit;
|
---|
[d7d2da3] | 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 | }
|
---|
[8f7db23] | 112 |
|
---|
[d7d2da3] | 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;
|
---|
[8f7db23] | 177 |
|
---|
[22dc7fd] | 178 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 179 |
|
---|
[d7d2da3] | 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 |
|
---|
[acd0621] | 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 |
|
---|
[d7d2da3] | 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();
|
---|
[22dc7fd] | 233 | entry->T = position.T()*1.0E-3/c_light;
|
---|
[d7d2da3] | 234 | }
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | //------------------------------------------------------------------------------
|
---|
| 238 |
|
---|
[d07e957] | 239 | void TreeWriter::ProcessVertices(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 240 | {
|
---|
| 241 | TIter iterator(array);
|
---|
| 242 | Candidate *candidate = 0;
|
---|
| 243 | Vertex *entry = 0;
|
---|
[8f7db23] | 244 |
|
---|
[22dc7fd] | 245 | const Double_t c_light = 2.99792458E8;
|
---|
[2600216] | 246 |
|
---|
| 247 | Double_t x, y, z, t, xError, yError, zError, sigma, sumPT2, btvSumPT2, genDeltaZ, genSumPT2;
|
---|
| 248 | UInt_t index, ndf;
|
---|
| 249 |
|
---|
[3c46e17] | 250 | array->Sort();
|
---|
| 251 |
|
---|
[d07e957] | 252 | // loop over all vertices
|
---|
| 253 | iterator.Reset();
|
---|
| 254 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
| 255 | {
|
---|
[2600216] | 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;
|
---|
[7bcca65] | 264 |
|
---|
| 265 | x = candidate->Position.X();
|
---|
| 266 | y = candidate->Position.Y();
|
---|
| 267 | z = candidate->Position.Z();
|
---|
[2600216] | 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 ();
|
---|
[d07e957] | 273 |
|
---|
| 274 | entry = static_cast<Vertex*>(branch->NewEntry());
|
---|
| 275 |
|
---|
[2600216] | 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;
|
---|
[7bcca65] | 283 |
|
---|
[2600216] | 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;
|
---|
[d07e957] | 292 | }
|
---|
| 293 | }
|
---|
| 294 |
|
---|
[2600216] | 295 |
|
---|
[d07e957] | 296 | //------------------------------------------------------------------------------
|
---|
| 297 |
|
---|
[d7d2da3] | 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;
|
---|
[22dc7fd] | 305 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 306 |
|
---|
[d07e957] | 307 | // loop over all tracks
|
---|
[d7d2da3] | 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();
|
---|
[22dc7fd] | 333 | entry->TOuter = position.T()*1.0E-3/c_light;
|
---|
[acd0621] | 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 |
|
---|
[e4c3fef] | 350 | entry->Xd = candidate->Xd;
|
---|
| 351 | entry->Yd = candidate->Yd;
|
---|
| 352 | entry->Zd = candidate->Zd;
|
---|
[9040259] | 353 |
|
---|
[d7d2da3] | 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;
|
---|
[acd0621] | 363 |
|
---|
[d7d2da3] | 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();
|
---|
[22dc7fd] | 370 | entry->T = initialPosition.T()*1.0E-3/c_light;
|
---|
[d7d2da3] | 371 |
|
---|
| 372 | entry->Particle = particle;
|
---|
[2600216] | 373 |
|
---|
| 374 | entry->VertexIndex = candidate->ClusterIndex;
|
---|
| 375 |
|
---|
[d7d2da3] | 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;
|
---|
[22dc7fd] | 387 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 388 |
|
---|
[d07e957] | 389 | // loop over all towers
|
---|
[d7d2da3] | 390 | iterator.Reset();
|
---|
| 391 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
| 392 | {
|
---|
| 393 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
[22dc7fd] | 394 | const TLorentzVector &position = candidate->Position;
|
---|
[8f7db23] | 395 |
|
---|
[d7d2da3] | 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];
|
---|
[8f7db23] | 417 |
|
---|
[22dc7fd] | 418 | entry->T = position.T()*1.0E-3/c_light;
|
---|
[839deb7] | 419 | entry->NTimeHits = candidate->NTimeHits;
|
---|
[8f7db23] | 420 |
|
---|
[d7d2da3] | 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;
|
---|
[22dc7fd] | 433 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 434 |
|
---|
[d7d2da3] | 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;
|
---|
[22dc7fd] | 443 | const TLorentzVector &position = candidate->Position;
|
---|
[8f7db23] | 444 |
|
---|
[d7d2da3] | 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();
|
---|
[8f7db23] | 458 |
|
---|
[22dc7fd] | 459 | entry->T = position.T()*1.0E-3/c_light;
|
---|
[8f7db23] | 460 |
|
---|
[d5cae2b] | 461 | // Isolation variables
|
---|
[9040259] | 462 |
|
---|
[d5cae2b] | 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 |
|
---|
[d7d2da3] | 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;
|
---|
[22dc7fd] | 484 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 485 |
|
---|
[d7d2da3] | 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;
|
---|
[22dc7fd] | 493 | const TLorentzVector &position = candidate->Position;
|
---|
[8f7db23] | 494 |
|
---|
[d7d2da3] | 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;
|
---|
[8f7db23] | 506 |
|
---|
[22dc7fd] | 507 | entry->T = position.T()*1.0E-3/c_light;
|
---|
[8f7db23] | 508 |
|
---|
[d5cae2b] | 509 | // Isolation variables
|
---|
[9040259] | 510 |
|
---|
[d5cae2b] | 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 |
|
---|
[d7d2da3] | 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;
|
---|
[8f7db23] | 535 |
|
---|
[22dc7fd] | 536 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 537 |
|
---|
[d7d2da3] | 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;
|
---|
[22dc7fd] | 545 | const TLorentzVector &position = candidate->Position;
|
---|
[8f7db23] | 546 |
|
---|
[d7d2da3] | 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 |
|
---|
[22dc7fd] | 562 | entry->T = position.T()*1.0E-3/c_light;
|
---|
[9040259] | 563 |
|
---|
[d5cae2b] | 564 | // Isolation variables
|
---|
[9040259] | 565 |
|
---|
[d5cae2b] | 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 ;
|
---|
[8f7db23] | 572 |
|
---|
[d7d2da3] | 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;
|
---|
[22dc7fd] | 588 | const Double_t c_light = 2.99792458E8;
|
---|
[de6d698] | 589 | Int_t i;
|
---|
[8f7db23] | 590 |
|
---|
[d7d2da3] | 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());
|
---|
[8f7db23] | 598 |
|
---|
[d7d2da3] | 599 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
[22dc7fd] | 600 | const TLorentzVector &position = candidate->Position;
|
---|
[8f7db23] | 601 |
|
---|
[d7d2da3] | 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 |
|
---|
[22dc7fd] | 614 | entry->T = position.T()*1.0E-3/c_light;
|
---|
[8f7db23] | 615 |
|
---|
[d7d2da3] | 616 | entry->Mass = momentum.M();
|
---|
| 617 |
|
---|
[ba1f1ee] | 618 | entry->Area = candidate->Area;
|
---|
| 619 |
|
---|
[d7d2da3] | 620 | entry->DeltaEta = candidate->DeltaEta;
|
---|
| 621 | entry->DeltaPhi = candidate->DeltaPhi;
|
---|
| 622 |
|
---|
[fe0273c] | 623 | entry->Flavor = candidate->Flavor;
|
---|
| 624 | entry->FlavorAlgo = candidate->FlavorAlgo;
|
---|
| 625 | entry->FlavorPhys = candidate->FlavorPhys;
|
---|
| 626 |
|
---|
[d7d2da3] | 627 | entry->BTag = candidate->BTag;
|
---|
[9040259] | 628 |
|
---|
| 629 | entry->BTagAlgo = candidate->BTagAlgo;
|
---|
[fe0273c] | 630 | entry->BTagPhys = candidate->BTagPhys;
|
---|
[9040259] | 631 |
|
---|
[d7d2da3] | 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;
|
---|
[8f7db23] | 648 |
|
---|
[24d005f] | 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;
|
---|
[9040259] | 657 |
|
---|
[de6d698] | 658 | //--- Sub-structure variables ----
|
---|
[9040259] | 659 |
|
---|
| 660 | entry->NSubJetsTrimmed = candidate->NSubJetsTrimmed;
|
---|
| 661 | entry->NSubJetsPruned = candidate->NSubJetsPruned;
|
---|
[de6d698] | 662 | entry->NSubJetsSoftDropped = candidate->NSubJetsSoftDropped;
|
---|
[9040259] | 663 |
|
---|
[de6d698] | 664 | for(i = 0; i < 5; i++)
|
---|
| 665 | {
|
---|
[9040259] | 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];
|
---|
[de6d698] | 670 | entry->SoftDroppedP4[i] = candidate -> SoftDroppedP4[i];
|
---|
| 671 | }
|
---|
[9040259] | 672 |
|
---|
[d7d2da3] | 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 |
|
---|
[3b465ca] | 691 | entry->Eta = (-momentum).Eta();
|
---|
[d7d2da3] | 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 |
|
---|
[71648c2] | 717 | void TreeWriter::ProcessRho(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 718 | {
|
---|
[3b465ca] | 719 | TIter iterator(array);
|
---|
[71648c2] | 720 | Candidate *candidate = 0;
|
---|
| 721 | Rho *entry = 0;
|
---|
| 722 |
|
---|
[3b465ca] | 723 | // loop over all rho
|
---|
| 724 | iterator.Reset();
|
---|
| 725 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
[71648c2] | 726 | {
|
---|
| 727 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 728 |
|
---|
| 729 | entry = static_cast<Rho*>(branch->NewEntry());
|
---|
| 730 |
|
---|
[8608ef8] | 731 | entry->Rho = momentum.E();
|
---|
[3b465ca] | 732 | entry->Edges[0] = candidate->Edges[0];
|
---|
| 733 | entry->Edges[1] = candidate->Edges[1];
|
---|
[71648c2] | 734 | }
|
---|
| 735 | }
|
---|
| 736 |
|
---|
| 737 | //------------------------------------------------------------------------------
|
---|
| 738 |
|
---|
[2e229c9] | 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 |
|
---|
[8f7db23] | 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();
|
---|
[64a4950] | 782 |
|
---|
| 783 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
[8f7db23] | 784 | }
|
---|
| 785 | }
|
---|
| 786 |
|
---|
| 787 | //------------------------------------------------------------------------------
|
---|
| 788 |
|
---|
[d7d2da3] | 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 | //------------------------------------------------------------------------------
|
---|