[694] | 1 |
|
---|
[815] | 2 | /** \class TreeWriter
|
---|
| 3 | *
|
---|
| 4 | * Fills ROOT tree branches.
|
---|
| 5 | *
|
---|
| 6 | * $Date: 2013-05-26 00:00:39 +0000 (Sun, 26 May 2013) $
|
---|
| 7 | * $Revision: 1123 $
|
---|
| 8 | *
|
---|
| 9 | *
|
---|
| 10 | * \author P. Demin - UCL, Louvain-la-Neuve
|
---|
| 11 | *
|
---|
| 12 | */
|
---|
| 13 |
|
---|
[694] | 14 | #include "modules/TreeWriter.h"
|
---|
| 15 |
|
---|
[703] | 16 | #include "classes/DelphesClasses.h"
|
---|
| 17 | #include "classes/DelphesFactory.h"
|
---|
[766] | 18 | #include "classes/DelphesFormula.h"
|
---|
[694] | 19 |
|
---|
| 20 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
[703] | 21 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
| 22 | #include "ExRootAnalysis/ExRootClassifier.h"
|
---|
[694] | 23 | #include "ExRootAnalysis/ExRootTreeBranch.h"
|
---|
| 24 |
|
---|
| 25 | #include "TROOT.h"
|
---|
[703] | 26 | #include "TMath.h"
|
---|
[694] | 27 | #include "TString.h"
|
---|
[703] | 28 | #include "TFormula.h"
|
---|
| 29 | #include "TRandom3.h"
|
---|
| 30 | #include "TObjArray.h"
|
---|
| 31 | #include "TDatabasePDG.h"
|
---|
[694] | 32 | #include "TLorentzVector.h"
|
---|
| 33 |
|
---|
[988] | 34 | #include <algorithm>
|
---|
[703] | 35 | #include <stdexcept>
|
---|
[694] | 36 | #include <iostream>
|
---|
[703] | 37 | #include <sstream>
|
---|
[694] | 38 |
|
---|
| 39 | using namespace std;
|
---|
| 40 |
|
---|
| 41 | //------------------------------------------------------------------------------
|
---|
| 42 |
|
---|
| 43 | TreeWriter::TreeWriter()
|
---|
| 44 | {
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | //------------------------------------------------------------------------------
|
---|
| 48 |
|
---|
| 49 | TreeWriter::~TreeWriter()
|
---|
| 50 | {
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | //------------------------------------------------------------------------------
|
---|
| 54 |
|
---|
| 55 | void TreeWriter::Init()
|
---|
| 56 | {
|
---|
| 57 | fClassMap[GenParticle::Class()] = &TreeWriter::ProcessParticles;
|
---|
| 58 | fClassMap[Track::Class()] = &TreeWriter::ProcessTracks;
|
---|
| 59 | fClassMap[Tower::Class()] = &TreeWriter::ProcessTowers;
|
---|
| 60 | fClassMap[Photon::Class()] = &TreeWriter::ProcessPhotons;
|
---|
| 61 | fClassMap[Electron::Class()] = &TreeWriter::ProcessElectrons;
|
---|
| 62 | fClassMap[Muon::Class()] = &TreeWriter::ProcessMuons;
|
---|
| 63 | fClassMap[Jet::Class()] = &TreeWriter::ProcessJets;
|
---|
| 64 | fClassMap[MissingET::Class()] = &TreeWriter::ProcessMissingET;
|
---|
[893] | 65 | fClassMap[ScalarHT::Class()] = &TreeWriter::ProcessScalarHT;
|
---|
[1114] | 66 | fClassMap[Rho::Class()] = &TreeWriter::ProcessRho;
|
---|
[1123] | 67 | fClassMap[Weight::Class()] = &TreeWriter::ProcessWeight;
|
---|
[694] | 68 |
|
---|
| 69 | TBranchMap::iterator itBranchMap;
|
---|
| 70 | map< TClass *, TProcessMethod >::iterator itClassMap;
|
---|
| 71 |
|
---|
| 72 | // read branch configuration and
|
---|
| 73 | // import array with output from filter/classifier/jetfinder modules
|
---|
| 74 |
|
---|
| 75 | ExRootConfParam param = GetParam("Branch");
|
---|
| 76 | Long_t i, size;
|
---|
| 77 | TString branchName, branchClassName, branchInputArray;
|
---|
| 78 | TClass *branchClass;
|
---|
[895] | 79 | TObjArray *array;
|
---|
[694] | 80 | ExRootTreeBranch *branch;
|
---|
| 81 |
|
---|
| 82 | size = param.GetSize();
|
---|
[703] | 83 | for(i = 0; i < size/3; ++i)
|
---|
[694] | 84 | {
|
---|
[703] | 85 | branchInputArray = param[i*3].GetString();
|
---|
| 86 | branchName = param[i*3 + 1].GetString();
|
---|
| 87 | branchClassName = param[i*3 + 2].GetString();
|
---|
[694] | 88 |
|
---|
| 89 | branchClass = gROOT->GetClass(branchClassName);
|
---|
| 90 |
|
---|
| 91 | if(!branchClass)
|
---|
| 92 | {
|
---|
| 93 | cout << "** ERROR: cannot find class '" << branchClassName << "'" << endl;
|
---|
| 94 | continue;
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | itClassMap = fClassMap.find(branchClass);
|
---|
| 98 | if(itClassMap == fClassMap.end())
|
---|
| 99 | {
|
---|
| 100 | cout << "** ERROR: cannot create branch for class '" << branchClassName << "'" << endl;
|
---|
| 101 | continue;
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | array = ImportArray(branchInputArray);
|
---|
| 105 | branch = NewBranch(branchName, branchClass);
|
---|
| 106 |
|
---|
[895] | 107 | fBranchMap.insert(make_pair(branch, make_pair(itClassMap->second, array)));
|
---|
[694] | 108 | }
|
---|
| 109 |
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | //------------------------------------------------------------------------------
|
---|
| 113 |
|
---|
| 114 | void TreeWriter::Finish()
|
---|
| 115 | {
|
---|
| 116 |
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | //------------------------------------------------------------------------------
|
---|
| 120 |
|
---|
[930] | 121 | void TreeWriter::FillParticles(Candidate *candidate, TRefArray *array)
|
---|
| 122 | {
|
---|
| 123 | TIter it1(candidate->GetCandidates());
|
---|
| 124 | it1.Reset();
|
---|
| 125 | array->Clear();
|
---|
| 126 | while((candidate = static_cast<Candidate*>(it1.Next())))
|
---|
| 127 | {
|
---|
| 128 | TIter it2(candidate->GetCandidates());
|
---|
| 129 |
|
---|
| 130 | // particle
|
---|
| 131 | if(candidate->GetCandidates()->GetEntriesFast() == 0)
|
---|
| 132 | {
|
---|
| 133 | array->Add(candidate);
|
---|
| 134 | continue;
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | // track
|
---|
| 138 | candidate = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
|
---|
| 139 | if(candidate->GetCandidates()->GetEntriesFast() == 0)
|
---|
| 140 | {
|
---|
| 141 | array->Add(candidate);
|
---|
| 142 | continue;
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | // tower
|
---|
| 146 | it2.Reset();
|
---|
| 147 | while((candidate = static_cast<Candidate*>(it2.Next())))
|
---|
| 148 | {
|
---|
| 149 | array->Add(candidate->GetCandidates()->At(0));
|
---|
| 150 | }
|
---|
| 151 | }
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | //------------------------------------------------------------------------------
|
---|
| 155 |
|
---|
[895] | 156 | void TreeWriter::ProcessParticles(ExRootTreeBranch *branch, TObjArray *array)
|
---|
[694] | 157 | {
|
---|
[895] | 158 | TIter iterator(array);
|
---|
[694] | 159 | Candidate *candidate = 0;
|
---|
| 160 | GenParticle *entry = 0;
|
---|
[771] | 161 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
[694] | 162 |
|
---|
| 163 | // loop over all particles
|
---|
[895] | 164 | iterator.Reset();
|
---|
| 165 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
[694] | 166 | {
|
---|
| 167 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 168 | const TLorentzVector &position = candidate->Position;
|
---|
| 169 |
|
---|
| 170 | entry = static_cast<GenParticle*>(branch->NewEntry());
|
---|
| 171 |
|
---|
[921] | 172 | entry->SetBit(kIsReferenced);
|
---|
| 173 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
[923] | 174 |
|
---|
[694] | 175 | pt = momentum.Pt();
|
---|
[771] | 176 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
[694] | 177 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
[771] | 178 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
| 179 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
[694] | 180 |
|
---|
| 181 | entry->PID = candidate->PID;
|
---|
| 182 |
|
---|
| 183 | entry->Status = candidate->Status;
|
---|
[1014] | 184 | entry->IsPU = candidate->IsPU;
|
---|
[694] | 185 |
|
---|
| 186 | entry->M1 = candidate->M1;
|
---|
| 187 | entry->M2 = candidate->M2;
|
---|
| 188 |
|
---|
[845] | 189 | entry->D1 = candidate->D1;
|
---|
| 190 | entry->D2 = candidate->D2;
|
---|
| 191 |
|
---|
[694] | 192 | entry->Charge = candidate->Charge;
|
---|
| 193 | entry->Mass = candidate->Mass;
|
---|
| 194 |
|
---|
| 195 | entry->E = momentum.E();
|
---|
| 196 | entry->Px = momentum.Px();
|
---|
| 197 | entry->Py = momentum.Py();
|
---|
| 198 | entry->Pz = momentum.Pz();
|
---|
| 199 |
|
---|
| 200 | entry->Eta = eta;
|
---|
| 201 | entry->Phi = momentum.Phi();
|
---|
| 202 | entry->PT = pt;
|
---|
| 203 |
|
---|
| 204 | entry->Rapidity = rapidity;
|
---|
| 205 |
|
---|
| 206 | entry->X = position.X();
|
---|
| 207 | entry->Y = position.Y();
|
---|
| 208 | entry->Z = position.Z();
|
---|
| 209 | entry->T = position.T();
|
---|
| 210 | }
|
---|
| 211 | }
|
---|
| 212 |
|
---|
| 213 | //------------------------------------------------------------------------------
|
---|
| 214 |
|
---|
[895] | 215 | void TreeWriter::ProcessTracks(ExRootTreeBranch *branch, TObjArray *array)
|
---|
[694] | 216 | {
|
---|
[895] | 217 | TIter iterator(array);
|
---|
[694] | 218 | Candidate *candidate = 0;
|
---|
[920] | 219 | Candidate *particle = 0;
|
---|
[694] | 220 | Track *entry = 0;
|
---|
[771] | 221 | Double_t pt, signz, cosTheta, eta, rapidity;
|
---|
[694] | 222 |
|
---|
| 223 | // loop over all jets
|
---|
[895] | 224 | iterator.Reset();
|
---|
| 225 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
[694] | 226 | {
|
---|
[920] | 227 | const TLorentzVector &position = candidate->Position;
|
---|
[694] | 228 |
|
---|
[920] | 229 | cosTheta = TMath::Abs(position.CosTheta());
|
---|
| 230 | signz = (position.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
| 231 | eta = (cosTheta == 1.0 ? signz*999.9 : position.Eta());
|
---|
| 232 | rapidity = (cosTheta == 1.0 ? signz*999.9 : position.Rapidity());
|
---|
[694] | 233 |
|
---|
| 234 | entry = static_cast<Track*>(branch->NewEntry());
|
---|
| 235 |
|
---|
[936] | 236 | entry->SetBit(kIsReferenced);
|
---|
| 237 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
| 238 |
|
---|
[703] | 239 | entry->PID = candidate->PID;
|
---|
| 240 |
|
---|
| 241 | entry->Charge = candidate->Charge;
|
---|
| 242 |
|
---|
[694] | 243 | entry->EtaOuter = eta;
|
---|
[920] | 244 | entry->PhiOuter = position.Phi();
|
---|
[696] | 245 |
|
---|
[920] | 246 | entry->XOuter = position.X();
|
---|
| 247 | entry->YOuter = position.Y();
|
---|
| 248 | entry->ZOuter = position.Z();
|
---|
[988] | 249 |
|
---|
[920] | 250 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
[694] | 251 |
|
---|
| 252 | pt = momentum.Pt();
|
---|
[771] | 253 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
[694] | 254 | signz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
[771] | 255 | eta = (cosTheta == 1.0 ? signz*999.9 : momentum.Eta());
|
---|
| 256 | rapidity = (cosTheta == 1.0 ? signz*999.9 : momentum.Rapidity());
|
---|
[694] | 257 |
|
---|
| 258 | entry->Eta = eta;
|
---|
| 259 | entry->Phi = momentum.Phi();
|
---|
| 260 | entry->PT = pt;
|
---|
[988] | 261 |
|
---|
[920] | 262 | particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
|
---|
| 263 | const TLorentzVector &initialPosition = particle->Position;
|
---|
| 264 |
|
---|
| 265 | entry->X = initialPosition.X();
|
---|
| 266 | entry->Y = initialPosition.Y();
|
---|
| 267 | entry->Z = initialPosition.Z();
|
---|
[988] | 268 |
|
---|
[920] | 269 | entry->Particle = particle;
|
---|
[694] | 270 | }
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 | //------------------------------------------------------------------------------
|
---|
| 274 |
|
---|
[895] | 275 | void TreeWriter::ProcessTowers(ExRootTreeBranch *branch, TObjArray *array)
|
---|
[694] | 276 | {
|
---|
[895] | 277 | TIter iterator(array);
|
---|
[694] | 278 | Candidate *candidate = 0;
|
---|
| 279 | Tower *entry = 0;
|
---|
[771] | 280 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
[694] | 281 |
|
---|
| 282 | // loop over all jets
|
---|
[895] | 283 | iterator.Reset();
|
---|
| 284 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
[694] | 285 | {
|
---|
| 286 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 287 |
|
---|
| 288 | pt = momentum.Pt();
|
---|
[771] | 289 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
[694] | 290 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
[771] | 291 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
| 292 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
[694] | 293 |
|
---|
| 294 | entry = static_cast<Tower*>(branch->NewEntry());
|
---|
| 295 |
|
---|
[936] | 296 | entry->SetBit(kIsReferenced);
|
---|
| 297 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
| 298 |
|
---|
[694] | 299 | entry->Eta = eta;
|
---|
| 300 | entry->Phi = momentum.Phi();
|
---|
| 301 | entry->ET = pt;
|
---|
[696] | 302 | entry->E = momentum.E();
|
---|
| 303 | entry->Eem = candidate->Eem;
|
---|
| 304 | entry->Ehad = candidate->Ehad;
|
---|
[898] | 305 | entry->Edges[0] = candidate->Edges[0];
|
---|
| 306 | entry->Edges[1] = candidate->Edges[1];
|
---|
| 307 | entry->Edges[2] = candidate->Edges[2];
|
---|
| 308 | entry->Edges[3] = candidate->Edges[3];
|
---|
[988] | 309 |
|
---|
[930] | 310 | FillParticles(candidate, &entry->Particles);
|
---|
[694] | 311 | }
|
---|
| 312 | }
|
---|
| 313 |
|
---|
| 314 | //------------------------------------------------------------------------------
|
---|
| 315 |
|
---|
[895] | 316 | void TreeWriter::ProcessPhotons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
[694] | 317 | {
|
---|
[895] | 318 | TIter iterator(array);
|
---|
[694] | 319 | Candidate *candidate = 0;
|
---|
| 320 | Photon *entry = 0;
|
---|
[771] | 321 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
[694] | 322 |
|
---|
[1066] | 323 | array->Sort();
|
---|
| 324 |
|
---|
| 325 | // loop over all photons
|
---|
[895] | 326 | iterator.Reset();
|
---|
| 327 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
[694] | 328 | {
|
---|
[930] | 329 | TIter it1(candidate->GetCandidates());
|
---|
[694] | 330 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 331 |
|
---|
| 332 | pt = momentum.Pt();
|
---|
[771] | 333 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
[694] | 334 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
[771] | 335 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
| 336 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
[694] | 337 |
|
---|
| 338 | entry = static_cast<Photon*>(branch->NewEntry());
|
---|
| 339 |
|
---|
| 340 | entry->Eta = eta;
|
---|
| 341 | entry->Phi = momentum.Phi();
|
---|
| 342 | entry->PT = pt;
|
---|
[923] | 343 | entry->E = momentum.E();
|
---|
| 344 |
|
---|
[988] | 345 | entry->EhadOverEem = candidate->Eem > 0.0 ? candidate->Ehad/candidate->Eem : 999.9;
|
---|
| 346 |
|
---|
[930] | 347 | FillParticles(candidate, &entry->Particles);
|
---|
[694] | 348 | }
|
---|
| 349 | }
|
---|
| 350 |
|
---|
| 351 | //------------------------------------------------------------------------------
|
---|
| 352 |
|
---|
[895] | 353 | void TreeWriter::ProcessElectrons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
[694] | 354 | {
|
---|
[895] | 355 | TIter iterator(array);
|
---|
[694] | 356 | Candidate *candidate = 0;
|
---|
| 357 | Electron *entry = 0;
|
---|
[771] | 358 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
[694] | 359 |
|
---|
[1066] | 360 | array->Sort();
|
---|
| 361 |
|
---|
| 362 | // loop over all electrons
|
---|
[895] | 363 | iterator.Reset();
|
---|
| 364 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
[694] | 365 | {
|
---|
| 366 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 367 |
|
---|
| 368 | pt = momentum.Pt();
|
---|
[771] | 369 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
[694] | 370 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
[771] | 371 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
| 372 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
[694] | 373 |
|
---|
| 374 | entry = static_cast<Electron*>(branch->NewEntry());
|
---|
| 375 |
|
---|
| 376 | entry->Eta = eta;
|
---|
| 377 | entry->Phi = momentum.Phi();
|
---|
| 378 | entry->PT = pt;
|
---|
| 379 |
|
---|
| 380 | entry->Charge = candidate->Charge;
|
---|
[920] | 381 |
|
---|
[988] | 382 | entry->EhadOverEem = 0.0;
|
---|
| 383 |
|
---|
[920] | 384 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
[694] | 385 | }
|
---|
| 386 | }
|
---|
| 387 |
|
---|
| 388 | //------------------------------------------------------------------------------
|
---|
| 389 |
|
---|
[895] | 390 | void TreeWriter::ProcessMuons(ExRootTreeBranch *branch, TObjArray *array)
|
---|
[694] | 391 | {
|
---|
[895] | 392 | TIter iterator(array);
|
---|
[694] | 393 | Candidate *candidate = 0;
|
---|
| 394 | Muon *entry = 0;
|
---|
[771] | 395 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
[694] | 396 |
|
---|
[1066] | 397 | array->Sort();
|
---|
| 398 |
|
---|
| 399 | // loop over all muons
|
---|
[895] | 400 | iterator.Reset();
|
---|
| 401 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
[694] | 402 | {
|
---|
| 403 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 404 |
|
---|
| 405 | pt = momentum.Pt();
|
---|
[771] | 406 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
[694] | 407 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
[771] | 408 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
| 409 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
[694] | 410 |
|
---|
| 411 | entry = static_cast<Muon*>(branch->NewEntry());
|
---|
| 412 |
|
---|
[939] | 413 | entry->SetBit(kIsReferenced);
|
---|
| 414 | entry->SetUniqueID(candidate->GetUniqueID());
|
---|
| 415 |
|
---|
[694] | 416 | entry->Eta = eta;
|
---|
| 417 | entry->Phi = momentum.Phi();
|
---|
| 418 | entry->PT = pt;
|
---|
| 419 |
|
---|
| 420 | entry->Charge = candidate->Charge;
|
---|
[920] | 421 |
|
---|
| 422 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
[694] | 423 | }
|
---|
| 424 | }
|
---|
| 425 |
|
---|
| 426 | //------------------------------------------------------------------------------
|
---|
| 427 |
|
---|
[895] | 428 | void TreeWriter::ProcessJets(ExRootTreeBranch *branch, TObjArray *array)
|
---|
[694] | 429 | {
|
---|
[895] | 430 | TIter iterator(array);
|
---|
[936] | 431 | Candidate *candidate = 0, *constituent = 0;
|
---|
[694] | 432 | Jet *entry = 0;
|
---|
[771] | 433 | Double_t pt, signPz, cosTheta, eta, rapidity;
|
---|
[988] | 434 | Double_t ecalEnergy, hcalEnergy;
|
---|
[694] | 435 |
|
---|
[1066] | 436 | array->Sort();
|
---|
| 437 |
|
---|
[694] | 438 | // loop over all jets
|
---|
[895] | 439 | iterator.Reset();
|
---|
| 440 | while((candidate = static_cast<Candidate*>(iterator.Next())))
|
---|
[694] | 441 | {
|
---|
[936] | 442 | TIter itConstituents(candidate->GetCandidates());
|
---|
[694] | 443 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 444 |
|
---|
| 445 | pt = momentum.Pt();
|
---|
[771] | 446 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
[694] | 447 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
[771] | 448 | eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
|
---|
| 449 | rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
|
---|
[694] | 450 |
|
---|
| 451 | entry = static_cast<Jet*>(branch->NewEntry());
|
---|
| 452 |
|
---|
| 453 | entry->Eta = eta;
|
---|
| 454 | entry->Phi = momentum.Phi();
|
---|
| 455 | entry->PT = pt;
|
---|
| 456 |
|
---|
| 457 | entry->Mass = momentum.M();
|
---|
[696] | 458 |
|
---|
[900] | 459 | entry->DeltaEta = candidate->DeltaEta;
|
---|
| 460 | entry->DeltaPhi = candidate->DeltaPhi;
|
---|
[696] | 461 |
|
---|
| 462 | entry->BTag = candidate->BTag;
|
---|
[926] | 463 | entry->TauTag = candidate->TauTag;
|
---|
[900] | 464 |
|
---|
[926] | 465 | entry->Charge = candidate->Charge;
|
---|
| 466 |
|
---|
[936] | 467 | itConstituents.Reset();
|
---|
| 468 | entry->Constituents.Clear();
|
---|
[988] | 469 | ecalEnergy = 0.0;
|
---|
| 470 | hcalEnergy = 0.0;
|
---|
[936] | 471 | while((constituent = static_cast<Candidate*>(itConstituents.Next())))
|
---|
| 472 | {
|
---|
| 473 | entry->Constituents.Add(constituent);
|
---|
[988] | 474 | ecalEnergy += constituent->Eem;
|
---|
| 475 | hcalEnergy += constituent->Ehad;
|
---|
[936] | 476 | }
|
---|
[988] | 477 |
|
---|
| 478 | entry->EhadOverEem = ecalEnergy > 0.0 ? hcalEnergy/ecalEnergy : 999.9;
|
---|
| 479 |
|
---|
[930] | 480 | FillParticles(candidate, &entry->Particles);
|
---|
[694] | 481 | }
|
---|
| 482 | }
|
---|
| 483 |
|
---|
| 484 | //------------------------------------------------------------------------------
|
---|
| 485 |
|
---|
[895] | 486 | void TreeWriter::ProcessMissingET(ExRootTreeBranch *branch, TObjArray *array)
|
---|
[694] | 487 | {
|
---|
| 488 | Candidate *candidate = 0;
|
---|
| 489 | MissingET *entry = 0;
|
---|
| 490 |
|
---|
[893] | 491 | // get the first entry
|
---|
[895] | 492 | if((candidate = static_cast<Candidate*>(array->At(0))))
|
---|
[694] | 493 | {
|
---|
| 494 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 495 |
|
---|
| 496 | entry = static_cast<MissingET*>(branch->NewEntry());
|
---|
| 497 |
|
---|
[1092] | 498 | entry->Phi = (-momentum).Phi();
|
---|
[893] | 499 | entry->MET = momentum.Pt();
|
---|
[694] | 500 | }
|
---|
| 501 | }
|
---|
| 502 |
|
---|
| 503 | //------------------------------------------------------------------------------
|
---|
| 504 |
|
---|
[895] | 505 | void TreeWriter::ProcessScalarHT(ExRootTreeBranch *branch, TObjArray *array)
|
---|
[893] | 506 | {
|
---|
| 507 | Candidate *candidate = 0;
|
---|
| 508 | ScalarHT *entry = 0;
|
---|
| 509 |
|
---|
| 510 | // get the first entry
|
---|
[895] | 511 | if((candidate = static_cast<Candidate*>(array->At(0))))
|
---|
[893] | 512 | {
|
---|
| 513 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 514 |
|
---|
| 515 | entry = static_cast<ScalarHT*>(branch->NewEntry());
|
---|
| 516 |
|
---|
| 517 | entry->HT = momentum.Pt();
|
---|
| 518 | }
|
---|
| 519 | }
|
---|
| 520 |
|
---|
| 521 | //------------------------------------------------------------------------------
|
---|
| 522 |
|
---|
[1114] | 523 | void TreeWriter::ProcessRho(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 524 | {
|
---|
| 525 | Candidate *candidate = 0;
|
---|
| 526 | Rho *entry = 0;
|
---|
| 527 |
|
---|
| 528 | // get the first entry
|
---|
| 529 | if((candidate = static_cast<Candidate*>(array->At(0))))
|
---|
| 530 | {
|
---|
| 531 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 532 |
|
---|
| 533 | entry = static_cast<Rho*>(branch->NewEntry());
|
---|
| 534 |
|
---|
[1115] | 535 | entry->Rho = momentum.E();
|
---|
[1114] | 536 | }
|
---|
| 537 | }
|
---|
| 538 |
|
---|
| 539 | //------------------------------------------------------------------------------
|
---|
| 540 |
|
---|
[1123] | 541 | void TreeWriter::ProcessWeight(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 542 | {
|
---|
| 543 | Candidate *candidate = 0;
|
---|
| 544 | Weight *entry = 0;
|
---|
| 545 |
|
---|
| 546 | // get the first entry
|
---|
| 547 | if((candidate = static_cast<Candidate*>(array->At(0))))
|
---|
| 548 | {
|
---|
| 549 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 550 |
|
---|
| 551 | entry = static_cast<Weight*>(branch->NewEntry());
|
---|
| 552 |
|
---|
| 553 | entry->Weight = momentum.E();
|
---|
| 554 | }
|
---|
| 555 | }
|
---|
| 556 |
|
---|
| 557 | //------------------------------------------------------------------------------
|
---|
| 558 |
|
---|
[694] | 559 | void TreeWriter::Process()
|
---|
| 560 | {
|
---|
| 561 | TBranchMap::iterator itBranchMap;
|
---|
| 562 | ExRootTreeBranch *branch;
|
---|
| 563 | TProcessMethod method;
|
---|
[895] | 564 | TObjArray *array;
|
---|
[694] | 565 |
|
---|
| 566 | for(itBranchMap = fBranchMap.begin(); itBranchMap != fBranchMap.end(); ++itBranchMap)
|
---|
| 567 | {
|
---|
| 568 | branch = itBranchMap->first;
|
---|
| 569 | method = itBranchMap->second.first;
|
---|
[895] | 570 | array = itBranchMap->second.second;
|
---|
[694] | 571 |
|
---|
[895] | 572 | (this->*method)(branch, array);
|
---|
[694] | 573 | }
|
---|
| 574 | }
|
---|
| 575 |
|
---|
| 576 | //------------------------------------------------------------------------------
|
---|