[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 |
|
---|
| 217 | entry->Eta = eta;
|
---|
| 218 | entry->Phi = momentum.Phi();
|
---|
| 219 | entry->PT = pt;
|
---|
| 220 |
|
---|
| 221 | entry->Rapidity = rapidity;
|
---|
| 222 |
|
---|
| 223 | entry->X = position.X();
|
---|
| 224 | entry->Y = position.Y();
|
---|
| 225 | entry->Z = position.Z();
|
---|
[22dc7fd] | 226 | entry->T = position.T()*1.0E-3/c_light;
|
---|
[d7d2da3] | 227 | }
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 | //------------------------------------------------------------------------------
|
---|
| 231 |
|
---|
[d07e957] | 232 | void TreeWriter::ProcessVertices(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 233 | {
|
---|
| 234 | TIter iterator(array);
|
---|
| 235 | Candidate *candidate = 0;
|
---|
| 236 | Vertex *entry = 0;
|
---|
[8f7db23] | 237 |
|
---|
[22dc7fd] | 238 | const Double_t c_light = 2.99792458E8;
|
---|
[d07e957] | 239 |
|
---|
| 240 | // loop over all vertices
|
---|
| 241 | iterator.Reset();
|
---|
| 242 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
| 243 | {
|
---|
| 244 | const TLorentzVector &position = candidate->Position;
|
---|
| 245 |
|
---|
| 246 | entry = static_cast<Vertex*>(branch->NewEntry());
|
---|
| 247 |
|
---|
| 248 | entry->X = position.X();
|
---|
| 249 | entry->Y = position.Y();
|
---|
| 250 | entry->Z = position.Z();
|
---|
[22dc7fd] | 251 | entry->T = position.T()*1.0E-3/c_light;
|
---|
[d07e957] | 252 | }
|
---|
| 253 | }
|
---|
| 254 |
|
---|
| 255 | //------------------------------------------------------------------------------
|
---|
| 256 |
|
---|
[d7d2da3] | 257 | void TreeWriter::ProcessTracks(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 258 | {
|
---|
| 259 | TIter iterator(array);
|
---|
| 260 | Candidate *candidate = 0;
|
---|
| 261 | Candidate *particle = 0;
|
---|
| 262 | Track *entry = 0;
|
---|
| 263 | Double_t pt, signz, cosTheta, eta, rapidity;
|
---|
[22dc7fd] | 264 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 265 |
|
---|
[d07e957] | 266 | // loop over all tracks
|
---|
[d7d2da3] | 267 | iterator.Reset();
|
---|
| 268 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
| 269 | {
|
---|
| 270 | const TLorentzVector &position = candidate->Position;
|
---|
| 271 |
|
---|
| 272 | cosTheta = TMath::Abs(position.CosTheta());
|
---|
| 273 | signz = (position.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
| 274 | eta = (cosTheta == 1.0 ? signz*999.9 : position.Eta());
|
---|
| 275 | rapidity = (cosTheta == 1.0 ? signz*999.9 : position.Rapidity());
|
---|
| 276 |
|
---|
| 277 | entry = static_cast<Track*>(branch->NewEntry());
|
---|
| 278 |
|
---|
| 279 | entry->SetBit(kIsReferenced);
|
---|
| 280 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
| 281 |
|
---|
| 282 | entry->PID = candidate->PID;
|
---|
| 283 |
|
---|
| 284 | entry->Charge = candidate->Charge;
|
---|
| 285 |
|
---|
| 286 | entry->EtaOuter = eta;
|
---|
| 287 | entry->PhiOuter = position.Phi();
|
---|
| 288 |
|
---|
| 289 | entry->XOuter = position.X();
|
---|
| 290 | entry->YOuter = position.Y();
|
---|
| 291 | entry->ZOuter = position.Z();
|
---|
[22dc7fd] | 292 | entry->TOuter = position.T()*1.0E-3/c_light;
|
---|
[a0431dc] | 293 |
|
---|
| 294 | entry->Dxy = candidate->Dxy;
|
---|
| 295 | entry->SDxy = candidate->SDxy ;
|
---|
[e4c3fef] | 296 | entry->Xd = candidate->Xd;
|
---|
| 297 | entry->Yd = candidate->Yd;
|
---|
| 298 | entry->Zd = candidate->Zd;
|
---|
[a0431dc] | 299 |
|
---|
[d7d2da3] | 300 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 301 |
|
---|
| 302 | pt = momentum.Pt();
|
---|
| 303 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
| 304 | signz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
| 305 | eta = (cosTheta == 1.0 ? signz*999.9 : momentum.Eta());
|
---|
| 306 | rapidity = (cosTheta == 1.0 ? signz*999.9 : momentum.Rapidity());
|
---|
| 307 |
|
---|
| 308 | entry->Eta = eta;
|
---|
| 309 | entry->Phi = momentum.Phi();
|
---|
| 310 | entry->PT = pt;
|
---|
| 311 |
|
---|
| 312 | particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
|
---|
| 313 | const TLorentzVector &initialPosition = particle->Position;
|
---|
| 314 |
|
---|
| 315 | entry->X = initialPosition.X();
|
---|
| 316 | entry->Y = initialPosition.Y();
|
---|
| 317 | entry->Z = initialPosition.Z();
|
---|
[22dc7fd] | 318 | entry->T = initialPosition.T()*1.0E-3/c_light;
|
---|
[d7d2da3] | 319 |
|
---|
| 320 | entry->Particle = particle;
|
---|
| 321 | }
|
---|
| 322 | }
|
---|
| 323 |
|
---|
| 324 | //------------------------------------------------------------------------------
|
---|
| 325 |
|
---|
| 326 | void TreeWriter::ProcessTowers(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 327 | {
|
---|
| 328 | TIter iterator(array);
|
---|
| 329 | Candidate *candidate = 0;
|
---|
| 330 | Tower *entry = 0;
|
---|
| 331 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
[22dc7fd] | 332 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 333 |
|
---|
[d07e957] | 334 | // loop over all towers
|
---|
[d7d2da3] | 335 | iterator.Reset();
|
---|
| 336 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
| 337 | {
|
---|
| 338 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
[22dc7fd] | 339 | const TLorentzVector &position = candidate->Position;
|
---|
[8f7db23] | 340 |
|
---|
[d7d2da3] | 341 | pt = momentum.Pt();
|
---|
| 342 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
| 343 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
| 344 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
| 345 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
| 346 |
|
---|
| 347 | entry = static_cast<Tower*>(branch->NewEntry());
|
---|
| 348 |
|
---|
| 349 | entry->SetBit(kIsReferenced);
|
---|
| 350 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
| 351 |
|
---|
| 352 | entry->Eta = eta;
|
---|
| 353 | entry->Phi = momentum.Phi();
|
---|
| 354 | entry->ET = pt;
|
---|
| 355 | entry->E = momentum.E();
|
---|
| 356 | entry->Eem = candidate->Eem;
|
---|
| 357 | entry->Ehad = candidate->Ehad;
|
---|
| 358 | entry->Edges[0] = candidate->Edges[0];
|
---|
| 359 | entry->Edges[1] = candidate->Edges[1];
|
---|
| 360 | entry->Edges[2] = candidate->Edges[2];
|
---|
| 361 | entry->Edges[3] = candidate->Edges[3];
|
---|
[8f7db23] | 362 |
|
---|
[22dc7fd] | 363 | entry->T = position.T()*1.0E-3/c_light;
|
---|
[3db5282] | 364 | entry->Ntimes = candidate->Ntimes;
|
---|
[8f7db23] | 365 |
|
---|
[d7d2da3] | 366 | FillParticles(candidate, &entry->Particles);
|
---|
| 367 | }
|
---|
| 368 | }
|
---|
| 369 |
|
---|
| 370 | //------------------------------------------------------------------------------
|
---|
| 371 |
|
---|
| 372 | void TreeWriter::ProcessPhotons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 373 | {
|
---|
| 374 | TIter iterator(array);
|
---|
| 375 | Candidate *candidate = 0;
|
---|
| 376 | Photon *entry = 0;
|
---|
| 377 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
[22dc7fd] | 378 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 379 |
|
---|
[d7d2da3] | 380 | array->Sort();
|
---|
| 381 |
|
---|
| 382 | // loop over all photons
|
---|
| 383 | iterator.Reset();
|
---|
| 384 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
| 385 | {
|
---|
| 386 | TIter it1(candidate->GetCandidates());
|
---|
| 387 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
[22dc7fd] | 388 | const TLorentzVector &position = candidate->Position;
|
---|
[8f7db23] | 389 |
|
---|
[d7d2da3] | 390 |
|
---|
| 391 | pt = momentum.Pt();
|
---|
| 392 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
| 393 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
| 394 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
| 395 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
| 396 |
|
---|
| 397 | entry = static_cast<Photon*>(branch->NewEntry());
|
---|
| 398 |
|
---|
| 399 | entry->Eta = eta;
|
---|
| 400 | entry->Phi = momentum.Phi();
|
---|
| 401 | entry->PT = pt;
|
---|
| 402 | entry->E = momentum.E();
|
---|
[8f7db23] | 403 |
|
---|
[22dc7fd] | 404 | entry->T = position.T()*1.0E-3/c_light;
|
---|
[8f7db23] | 405 |
|
---|
[d5cae2b] | 406 | // Isolation variables
|
---|
| 407 |
|
---|
| 408 | entry->IsolationVar = candidate->IsolationVar;
|
---|
| 409 | entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ;
|
---|
| 410 | entry->SumPtCharged = candidate->SumPtCharged ;
|
---|
| 411 | entry->SumPtNeutral = candidate->SumPtNeutral ;
|
---|
| 412 | entry->SumPtChargedPU = candidate->SumPtChargedPU ;
|
---|
| 413 | entry->SumPt = candidate->SumPt ;
|
---|
| 414 |
|
---|
[d7d2da3] | 415 | entry->EhadOverEem = candidate->Eem > 0.0 ? candidate->Ehad/candidate->Eem : 999.9;
|
---|
| 416 |
|
---|
| 417 | FillParticles(candidate, &entry->Particles);
|
---|
| 418 | }
|
---|
| 419 | }
|
---|
| 420 |
|
---|
| 421 | //------------------------------------------------------------------------------
|
---|
| 422 |
|
---|
| 423 | void TreeWriter::ProcessElectrons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 424 | {
|
---|
| 425 | TIter iterator(array);
|
---|
| 426 | Candidate *candidate = 0;
|
---|
| 427 | Electron *entry = 0;
|
---|
| 428 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
[22dc7fd] | 429 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 430 |
|
---|
[d7d2da3] | 431 | array->Sort();
|
---|
| 432 |
|
---|
| 433 | // loop over all electrons
|
---|
| 434 | iterator.Reset();
|
---|
| 435 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
| 436 | {
|
---|
| 437 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
[22dc7fd] | 438 | const TLorentzVector &position = candidate->Position;
|
---|
[8f7db23] | 439 |
|
---|
[d7d2da3] | 440 | pt = momentum.Pt();
|
---|
| 441 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
| 442 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
| 443 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
| 444 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
| 445 |
|
---|
| 446 | entry = static_cast<Electron*>(branch->NewEntry());
|
---|
| 447 |
|
---|
| 448 | entry->Eta = eta;
|
---|
| 449 | entry->Phi = momentum.Phi();
|
---|
| 450 | entry->PT = pt;
|
---|
[8f7db23] | 451 |
|
---|
[22dc7fd] | 452 | entry->T = position.T()*1.0E-3/c_light;
|
---|
[8f7db23] | 453 |
|
---|
[d5cae2b] | 454 | // Isolation variables
|
---|
| 455 |
|
---|
| 456 | entry->IsolationVar = candidate->IsolationVar;
|
---|
| 457 | entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ;
|
---|
| 458 | entry->SumPtCharged = candidate->SumPtCharged ;
|
---|
| 459 | entry->SumPtNeutral = candidate->SumPtNeutral ;
|
---|
| 460 | entry->SumPtChargedPU = candidate->SumPtChargedPU ;
|
---|
| 461 | entry->SumPt = candidate->SumPt ;
|
---|
| 462 |
|
---|
| 463 |
|
---|
[d7d2da3] | 464 | entry->Charge = candidate->Charge;
|
---|
| 465 |
|
---|
| 466 | entry->EhadOverEem = 0.0;
|
---|
| 467 |
|
---|
| 468 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
| 469 | }
|
---|
| 470 | }
|
---|
| 471 |
|
---|
| 472 | //------------------------------------------------------------------------------
|
---|
| 473 |
|
---|
| 474 | void TreeWriter::ProcessMuons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 475 | {
|
---|
| 476 | TIter iterator(array);
|
---|
| 477 | Candidate *candidate = 0;
|
---|
| 478 | Muon *entry = 0;
|
---|
| 479 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
[8f7db23] | 480 |
|
---|
[22dc7fd] | 481 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 482 |
|
---|
[d7d2da3] | 483 | array->Sort();
|
---|
| 484 |
|
---|
| 485 | // loop over all muons
|
---|
| 486 | iterator.Reset();
|
---|
| 487 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
| 488 | {
|
---|
| 489 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
[22dc7fd] | 490 | const TLorentzVector &position = candidate->Position;
|
---|
[8f7db23] | 491 |
|
---|
[d7d2da3] | 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<Muon*>(branch->NewEntry());
|
---|
| 500 |
|
---|
| 501 | entry->SetBit(kIsReferenced);
|
---|
| 502 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
| 503 |
|
---|
| 504 | entry->Eta = eta;
|
---|
| 505 | entry->Phi = momentum.Phi();
|
---|
| 506 | entry->PT = pt;
|
---|
| 507 |
|
---|
[22dc7fd] | 508 | entry->T = position.T()*1.0E-3/c_light;
|
---|
[d5cae2b] | 509 |
|
---|
| 510 | // Isolation variables
|
---|
| 511 |
|
---|
| 512 | entry->IsolationVar = candidate->IsolationVar;
|
---|
| 513 | entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ;
|
---|
| 514 | entry->SumPtCharged = candidate->SumPtCharged ;
|
---|
| 515 | entry->SumPtNeutral = candidate->SumPtNeutral ;
|
---|
| 516 | entry->SumPtChargedPU = candidate->SumPtChargedPU ;
|
---|
| 517 | entry->SumPt = candidate->SumPt ;
|
---|
[8f7db23] | 518 |
|
---|
[d7d2da3] | 519 | entry->Charge = candidate->Charge;
|
---|
| 520 |
|
---|
| 521 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
| 522 | }
|
---|
| 523 | }
|
---|
| 524 |
|
---|
| 525 | //------------------------------------------------------------------------------
|
---|
| 526 |
|
---|
| 527 | void TreeWriter::ProcessJets(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 528 | {
|
---|
| 529 | TIter iterator(array);
|
---|
| 530 | Candidate *candidate = 0, *constituent = 0;
|
---|
| 531 | Jet *entry = 0;
|
---|
| 532 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
| 533 | Double_t ecalEnergy, hcalEnergy;
|
---|
[22dc7fd] | 534 | const Double_t c_light = 2.99792458E8;
|
---|
[de6d698] | 535 | Int_t i;
|
---|
[8f7db23] | 536 |
|
---|
[d7d2da3] | 537 | array->Sort();
|
---|
| 538 |
|
---|
| 539 | // loop over all jets
|
---|
| 540 | iterator.Reset();
|
---|
| 541 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
| 542 | {
|
---|
| 543 | TIter itConstituents(candidate->GetCandidates());
|
---|
[8f7db23] | 544 |
|
---|
[d7d2da3] | 545 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
[22dc7fd] | 546 | const TLorentzVector &position = candidate->Position;
|
---|
[8f7db23] | 547 |
|
---|
[d7d2da3] | 548 | pt = momentum.Pt();
|
---|
| 549 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
| 550 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
| 551 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
| 552 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
| 553 |
|
---|
| 554 | entry = static_cast<Jet*>(branch->NewEntry());
|
---|
| 555 |
|
---|
| 556 | entry->Eta = eta;
|
---|
| 557 | entry->Phi = momentum.Phi();
|
---|
| 558 | entry->PT = pt;
|
---|
| 559 |
|
---|
[22dc7fd] | 560 | entry->T = position.T()*1.0E-3/c_light;
|
---|
[8f7db23] | 561 |
|
---|
[d7d2da3] | 562 | entry->Mass = momentum.M();
|
---|
| 563 |
|
---|
[ba1f1ee] | 564 | entry->Area = candidate->Area;
|
---|
| 565 |
|
---|
[d7d2da3] | 566 | entry->DeltaEta = candidate->DeltaEta;
|
---|
| 567 | entry->DeltaPhi = candidate->DeltaPhi;
|
---|
| 568 |
|
---|
| 569 | entry->BTag = candidate->BTag;
|
---|
| 570 | entry->TauTag = candidate->TauTag;
|
---|
| 571 |
|
---|
| 572 | entry->Charge = candidate->Charge;
|
---|
| 573 |
|
---|
| 574 | itConstituents.Reset();
|
---|
| 575 | entry->Constituents.Clear();
|
---|
| 576 | ecalEnergy = 0.0;
|
---|
| 577 | hcalEnergy = 0.0;
|
---|
| 578 | while((constituent = static_cast<Candidate*>(itConstituents.Next())))
|
---|
| 579 | {
|
---|
| 580 | entry->Constituents.Add(constituent);
|
---|
| 581 | ecalEnergy += constituent->Eem;
|
---|
| 582 | hcalEnergy += constituent->Ehad;
|
---|
| 583 | }
|
---|
| 584 |
|
---|
| 585 | entry->EhadOverEem = ecalEnergy > 0.0 ? hcalEnergy/ecalEnergy : 999.9;
|
---|
[8f7db23] | 586 |
|
---|
[24d005f] | 587 | //--- Pile-Up Jet ID variables ----
|
---|
| 588 |
|
---|
| 589 | entry->NCharged = candidate->NCharged;
|
---|
| 590 | entry->NNeutrals = candidate->NNeutrals;
|
---|
| 591 | entry->Beta = candidate->Beta;
|
---|
| 592 | entry->BetaStar = candidate->BetaStar;
|
---|
| 593 | entry->MeanSqDeltaR = candidate->MeanSqDeltaR;
|
---|
| 594 | entry->PTD = candidate->PTD;
|
---|
[9687203] | 595 |
|
---|
[de6d698] | 596 | //--- Sub-structure variables ----
|
---|
| 597 |
|
---|
| 598 | entry->NSubJetsTrimmed = candidate->NSubJetsTrimmed;
|
---|
| 599 | entry->NSubJetsPruned = candidate->NSubJetsPruned;
|
---|
| 600 | entry->NSubJetsSoftDropped = candidate->NSubJetsSoftDropped;
|
---|
| 601 |
|
---|
| 602 | for(i = 0; i < 5; i++)
|
---|
| 603 | {
|
---|
| 604 | entry->FracPt[i] = candidate -> FracPt[i];
|
---|
| 605 | entry->Tau[i] = candidate -> Tau[i];
|
---|
| 606 | entry->TrimmedP4[i] = candidate -> TrimmedP4[i];
|
---|
| 607 | entry->PrunedP4[i] = candidate -> PrunedP4[i];
|
---|
| 608 | entry->SoftDroppedP4[i] = candidate -> SoftDroppedP4[i];
|
---|
| 609 | }
|
---|
[9687203] | 610 |
|
---|
[d7d2da3] | 611 | FillParticles(candidate, &entry->Particles);
|
---|
| 612 | }
|
---|
| 613 | }
|
---|
| 614 |
|
---|
| 615 | //------------------------------------------------------------------------------
|
---|
| 616 |
|
---|
| 617 | void TreeWriter::ProcessMissingET(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 618 | {
|
---|
| 619 | Candidate *candidate = 0;
|
---|
| 620 | MissingET *entry = 0;
|
---|
| 621 |
|
---|
| 622 | // get the first entry
|
---|
| 623 | if((candidate = static_cast<Candidate*>(array->At(0))))
|
---|
| 624 | {
|
---|
| 625 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 626 |
|
---|
| 627 | entry = static_cast<MissingET*>(branch->NewEntry());
|
---|
| 628 |
|
---|
[3b465ca] | 629 | entry->Eta = (-momentum).Eta();
|
---|
[d7d2da3] | 630 | entry->Phi = (-momentum).Phi();
|
---|
| 631 | entry->MET = momentum.Pt();
|
---|
| 632 | }
|
---|
| 633 | }
|
---|
| 634 |
|
---|
| 635 | //------------------------------------------------------------------------------
|
---|
| 636 |
|
---|
| 637 | void TreeWriter::ProcessScalarHT(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 638 | {
|
---|
| 639 | Candidate *candidate = 0;
|
---|
| 640 | ScalarHT *entry = 0;
|
---|
| 641 |
|
---|
| 642 | // get the first entry
|
---|
| 643 | if((candidate = static_cast<Candidate*>(array->At(0))))
|
---|
| 644 | {
|
---|
| 645 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 646 |
|
---|
| 647 | entry = static_cast<ScalarHT*>(branch->NewEntry());
|
---|
| 648 |
|
---|
| 649 | entry->HT = momentum.Pt();
|
---|
| 650 | }
|
---|
| 651 | }
|
---|
| 652 |
|
---|
| 653 | //------------------------------------------------------------------------------
|
---|
| 654 |
|
---|
[71648c2] | 655 | void TreeWriter::ProcessRho(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 656 | {
|
---|
[3b465ca] | 657 | TIter iterator(array);
|
---|
[71648c2] | 658 | Candidate *candidate = 0;
|
---|
| 659 | Rho *entry = 0;
|
---|
| 660 |
|
---|
[3b465ca] | 661 | // loop over all rho
|
---|
| 662 | iterator.Reset();
|
---|
| 663 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
[71648c2] | 664 | {
|
---|
| 665 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 666 |
|
---|
| 667 | entry = static_cast<Rho*>(branch->NewEntry());
|
---|
| 668 |
|
---|
[8608ef8] | 669 | entry->Rho = momentum.E();
|
---|
[3b465ca] | 670 | entry->Edges[0] = candidate->Edges[0];
|
---|
| 671 | entry->Edges[1] = candidate->Edges[1];
|
---|
[71648c2] | 672 | }
|
---|
| 673 | }
|
---|
| 674 |
|
---|
| 675 | //------------------------------------------------------------------------------
|
---|
| 676 |
|
---|
[2e229c9] | 677 | void TreeWriter::ProcessWeight(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 678 | {
|
---|
| 679 | Candidate *candidate = 0;
|
---|
| 680 | Weight *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<Weight*>(branch->NewEntry());
|
---|
| 688 |
|
---|
| 689 | entry->Weight = momentum.E();
|
---|
| 690 | }
|
---|
| 691 | }
|
---|
| 692 |
|
---|
| 693 | //------------------------------------------------------------------------------
|
---|
| 694 |
|
---|
[8f7db23] | 695 | void TreeWriter::ProcessHectorHit(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 696 | {
|
---|
| 697 | TIter iterator(array);
|
---|
| 698 | Candidate *candidate = 0;
|
---|
| 699 | HectorHit *entry = 0;
|
---|
| 700 |
|
---|
| 701 | // loop over all roman pot hits
|
---|
| 702 | iterator.Reset();
|
---|
| 703 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
| 704 | {
|
---|
| 705 | const TLorentzVector &position = candidate->Position;
|
---|
| 706 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 707 |
|
---|
| 708 | entry = static_cast<HectorHit*>(branch->NewEntry());
|
---|
| 709 |
|
---|
| 710 | entry->E = momentum.E();
|
---|
| 711 |
|
---|
| 712 | entry->Tx = momentum.Px();
|
---|
| 713 | entry->Ty = momentum.Py();
|
---|
| 714 |
|
---|
| 715 | entry->T = position.T();
|
---|
| 716 |
|
---|
| 717 | entry->X = position.X();
|
---|
| 718 | entry->Y = position.Y();
|
---|
| 719 | entry->S = position.Z();
|
---|
[64a4950] | 720 |
|
---|
| 721 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
[8f7db23] | 722 | }
|
---|
| 723 | }
|
---|
| 724 |
|
---|
| 725 | //------------------------------------------------------------------------------
|
---|
| 726 |
|
---|
[d7d2da3] | 727 | void TreeWriter::Process()
|
---|
| 728 | {
|
---|
| 729 | TBranchMap::iterator itBranchMap;
|
---|
| 730 | ExRootTreeBranch *branch;
|
---|
| 731 | TProcessMethod method;
|
---|
| 732 | TObjArray *array;
|
---|
| 733 |
|
---|
| 734 | for(itBranchMap = fBranchMap.begin(); itBranchMap != fBranchMap.end(); ++itBranchMap)
|
---|
| 735 | {
|
---|
| 736 | branch = itBranchMap->first;
|
---|
| 737 | method = itBranchMap->second.first;
|
---|
| 738 | array = itBranchMap->second.second;
|
---|
| 739 |
|
---|
| 740 | (this->*method)(branch, array);
|
---|
| 741 | }
|
---|
| 742 | }
|
---|
| 743 |
|
---|
| 744 | //------------------------------------------------------------------------------
|
---|