[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 | /** \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"
|
---|
[341014c] | 34 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
| 35 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
[d7d2da3] | 36 | #include "ExRootAnalysis/ExRootTreeBranch.h"
|
---|
| 37 |
|
---|
| 38 | #include "TDatabasePDG.h"
|
---|
[341014c] | 39 | #include "TFormula.h"
|
---|
[d7d2da3] | 40 | #include "TLorentzVector.h"
|
---|
[341014c] | 41 | #include "TMath.h"
|
---|
| 42 | #include "TObjArray.h"
|
---|
| 43 | #include "TROOT.h"
|
---|
| 44 | #include "TRandom3.h"
|
---|
| 45 | #include "TString.h"
|
---|
[d7d2da3] | 46 |
|
---|
[4e8e72b] | 47 | #include <set>
|
---|
[d7d2da3] | 48 | #include <algorithm>
|
---|
| 49 | #include <iostream>
|
---|
| 50 | #include <sstream>
|
---|
[341014c] | 51 | #include <stdexcept>
|
---|
[d7d2da3] | 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;
|
---|
[4d7014e] | 75 | fClassMap[ParticleFlowCandidate::Class()] = &TreeWriter::ProcessParticleFlowCandidates;
|
---|
[d7d2da3] | 76 | fClassMap[Photon::Class()] = &TreeWriter::ProcessPhotons;
|
---|
| 77 | fClassMap[Electron::Class()] = &TreeWriter::ProcessElectrons;
|
---|
| 78 | fClassMap[Muon::Class()] = &TreeWriter::ProcessMuons;
|
---|
[cc8716b] | 79 | fClassMap[CscCluster::Class()] = &TreeWriter::ProcessCscCluster;
|
---|
[d7d2da3] | 80 | fClassMap[Jet::Class()] = &TreeWriter::ProcessJets;
|
---|
| 81 | fClassMap[MissingET::Class()] = &TreeWriter::ProcessMissingET;
|
---|
| 82 | fClassMap[ScalarHT::Class()] = &TreeWriter::ProcessScalarHT;
|
---|
[71648c2] | 83 | fClassMap[Rho::Class()] = &TreeWriter::ProcessRho;
|
---|
[2e229c9] | 84 | fClassMap[Weight::Class()] = &TreeWriter::ProcessWeight;
|
---|
[8f7db23] | 85 | fClassMap[HectorHit::Class()] = &TreeWriter::ProcessHectorHit;
|
---|
[d7d2da3] | 86 |
|
---|
| 87 | TBranchMap::iterator itBranchMap;
|
---|
[341014c] | 88 | map<TClass *, TProcessMethod>::iterator itClassMap;
|
---|
[d7d2da3] | 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();
|
---|
[341014c] | 101 | for(i = 0; i < size / 3; ++i)
|
---|
[d7d2da3] | 102 | {
|
---|
[341014c] | 103 | branchInputArray = param[i * 3].GetString();
|
---|
| 104 | branchName = param[i * 3 + 1].GetString();
|
---|
| 105 | branchClassName = param[i * 3 + 2].GetString();
|
---|
[d7d2da3] | 106 |
|
---|
| 107 | branchClass = gROOT->GetClass(branchClassName);
|
---|
| 108 |
|
---|
| 109 | if(!branchClass)
|
---|
| 110 | {
|
---|
| 111 | cout << "** ERROR: cannot find class '" << branchClassName << "'" << endl;
|
---|
| 112 | continue;
|
---|
| 113 | }
|
---|
[8f7db23] | 114 |
|
---|
[d7d2da3] | 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 | }
|
---|
[dc883b4] | 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 | }
|
---|
[d7d2da3] | 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());
|
---|
[4e8e72b] | 153 | set<Candidate *> s;
|
---|
| 154 | set<Candidate *>::iterator it3;
|
---|
[d7d2da3] | 155 | it1.Reset();
|
---|
[4e8e72b] | 156 | s.clear();
|
---|
[d7d2da3] | 157 | array->Clear();
|
---|
[dc883b4] | 158 |
|
---|
[341014c] | 159 | while((candidate = static_cast<Candidate *>(it1.Next())))
|
---|
[d7d2da3] | 160 | {
|
---|
| 161 | TIter it2(candidate->GetCandidates());
|
---|
| 162 |
|
---|
| 163 | // particle
|
---|
| 164 | if(candidate->GetCandidates()->GetEntriesFast() == 0)
|
---|
| 165 | {
|
---|
[4e8e72b] | 166 | s.insert(candidate);
|
---|
[d7d2da3] | 167 | continue;
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 | // track
|
---|
[341014c] | 171 | candidate = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
|
---|
[d7d2da3] | 172 | if(candidate->GetCandidates()->GetEntriesFast() == 0)
|
---|
| 173 | {
|
---|
[4e8e72b] | 174 | s.insert(candidate);
|
---|
[d7d2da3] | 175 | continue;
|
---|
| 176 | }
|
---|
| 177 |
|
---|
| 178 | // tower
|
---|
| 179 | it2.Reset();
|
---|
[341014c] | 180 | while((candidate = static_cast<Candidate *>(it2.Next())))
|
---|
[d7d2da3] | 181 | {
|
---|
[2a2f310] | 182 | candidate = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
|
---|
| 183 | if(candidate->GetCandidates()->GetEntriesFast() == 0)
|
---|
| 184 | {
|
---|
[4e8e72b] | 185 | s.insert(candidate);
|
---|
[2a2f310] | 186 | }
|
---|
[d7d2da3] | 187 | }
|
---|
| 188 | }
|
---|
[4e8e72b] | 189 |
|
---|
| 190 | for(it3 = s.begin(); it3 != s.end(); ++it3)
|
---|
| 191 | {
|
---|
| 192 | array->Add(*it3);
|
---|
| 193 | }
|
---|
[d7d2da3] | 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;
|
---|
[8f7db23] | 204 |
|
---|
[22dc7fd] | 205 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 206 |
|
---|
[d7d2da3] | 207 | // loop over all particles
|
---|
| 208 | iterator.Reset();
|
---|
[341014c] | 209 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
[d7d2da3] | 210 | {
|
---|
| 211 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 212 | const TLorentzVector &position = candidate->Position;
|
---|
| 213 |
|
---|
[341014c] | 214 | entry = static_cast<GenParticle *>(branch->NewEntry());
|
---|
[d7d2da3] | 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;
|
---|
[341014c] | 222 | eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
|
---|
| 223 | rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
|
---|
[d7d2da3] | 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();
|
---|
[341014c] | 253 | entry->T = position.T() * 1.0E-3 / c_light;
|
---|
[cc8716b] | 254 |
|
---|
[d7d2da3] | 255 | }
|
---|
| 256 | }
|
---|
| 257 |
|
---|
| 258 | //------------------------------------------------------------------------------
|
---|
| 259 |
|
---|
[d07e957] | 260 | void TreeWriter::ProcessVertices(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 261 | {
|
---|
| 262 | TIter iterator(array);
|
---|
[5496767] | 263 | Candidate *candidate = 0, *constituent = 0;
|
---|
[d07e957] | 264 | Vertex *entry = 0;
|
---|
[8f7db23] | 265 |
|
---|
[22dc7fd] | 266 | const Double_t c_light = 2.99792458E8;
|
---|
[5496767] | 267 |
|
---|
[332025f] | 268 | Double_t x, y, z, t, xError, yError, zError, tError, sigma, sumPT2, btvSumPT2, genDeltaZ, genSumPT2;
|
---|
[2600216] | 269 | UInt_t index, ndf;
|
---|
[5496767] | 270 |
|
---|
[3e2bb2b] | 271 | CompBase *compare = Candidate::fgCompare;
|
---|
| 272 | Candidate::fgCompare = CompSumPT2<Candidate>::Instance();
|
---|
[3c46e17] | 273 | array->Sort();
|
---|
[3e2bb2b] | 274 | Candidate::fgCompare = compare;
|
---|
[5496767] | 275 |
|
---|
[d07e957] | 276 | // loop over all vertices
|
---|
| 277 | iterator.Reset();
|
---|
[341014c] | 278 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
[d07e957] | 279 | {
|
---|
[5496767] | 280 |
|
---|
[2600216] | 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;
|
---|
[5496767] | 288 |
|
---|
[7bcca65] | 289 | x = candidate->Position.X();
|
---|
| 290 | y = candidate->Position.Y();
|
---|
| 291 | z = candidate->Position.Z();
|
---|
[341014c] | 292 | t = candidate->Position.T() * 1.0E-3 / c_light;
|
---|
[5496767] | 293 |
|
---|
[341014c] | 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;
|
---|
[d07e957] | 298 |
|
---|
[341014c] | 299 | entry = static_cast<Vertex *>(branch->NewEntry());
|
---|
[d07e957] | 300 |
|
---|
[2600216] | 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;
|
---|
[5496767] | 308 |
|
---|
[2600216] | 309 | entry->X = x;
|
---|
| 310 | entry->Y = y;
|
---|
| 311 | entry->Z = z;
|
---|
| 312 | entry->T = t;
|
---|
[5496767] | 313 |
|
---|
[2600216] | 314 | entry->ErrorX = xError;
|
---|
| 315 | entry->ErrorY = yError;
|
---|
| 316 | entry->ErrorZ = zError;
|
---|
[332025f] | 317 | entry->ErrorT = tError;
|
---|
[5496767] | 318 |
|
---|
[3e2bb2b] | 319 | TIter itConstituents(candidate->GetCandidates());
|
---|
| 320 | itConstituents.Reset();
|
---|
| 321 | entry->Constituents.Clear();
|
---|
[341014c] | 322 | while((constituent = static_cast<Candidate *>(itConstituents.Next())))
|
---|
[5496767] | 323 | {
|
---|
| 324 | entry->Constituents.Add(constituent);
|
---|
| 325 | }
|
---|
[d07e957] | 326 | }
|
---|
| 327 | }
|
---|
| 328 |
|
---|
| 329 | //------------------------------------------------------------------------------
|
---|
| 330 |
|
---|
[d7d2da3] | 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;
|
---|
[fd4b326] | 337 | Double_t pt, signz, cosTheta, eta, rapidity, p, ctgTheta, phi, m;
|
---|
[22dc7fd] | 338 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 339 |
|
---|
[d07e957] | 340 | // loop over all tracks
|
---|
[d7d2da3] | 341 | iterator.Reset();
|
---|
[341014c] | 342 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
[d7d2da3] | 343 | {
|
---|
| 344 | const TLorentzVector &position = candidate->Position;
|
---|
| 345 |
|
---|
| 346 | cosTheta = TMath::Abs(position.CosTheta());
|
---|
| 347 | signz = (position.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
[341014c] | 348 | eta = (cosTheta == 1.0 ? signz * 999.9 : position.Eta());
|
---|
| 349 | rapidity = (cosTheta == 1.0 ? signz * 999.9 : position.Rapidity());
|
---|
[d7d2da3] | 350 |
|
---|
[341014c] | 351 | entry = static_cast<Track *>(branch->NewEntry());
|
---|
[d7d2da3] | 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();
|
---|
[341014c] | 366 | entry->TOuter = position.T() * 1.0E-3 / c_light;
|
---|
[5496767] | 367 |
|
---|
[acd0621] | 368 | entry->L = candidate->L;
|
---|
[5496767] | 369 |
|
---|
[341014c] | 370 | entry->D0 = candidate->D0;
|
---|
| 371 | entry->DZ = candidate->DZ;
|
---|
[a95da74] | 372 | entry->Nclusters = candidate->Nclusters;
|
---|
[781af69] | 373 | entry->dNdx = candidate->dNdx;
|
---|
[2a3eb22] | 374 |
|
---|
[341014c] | 375 | entry->ErrorP = candidate->ErrorP;
|
---|
| 376 | entry->ErrorPT = candidate->ErrorPT;
|
---|
[2671df6] | 377 |
|
---|
| 378 | // diagonal covariance matrix terms
|
---|
| 379 | entry->ErrorD0 = candidate->ErrorD0;
|
---|
| 380 | entry->ErrorC = candidate->ErrorC;
|
---|
[341014c] | 381 | entry->ErrorPhi = candidate->ErrorPhi;
|
---|
[2671df6] | 382 | entry->ErrorDZ = candidate->ErrorDZ;
|
---|
| 383 | entry->ErrorCtgTheta = candidate->ErrorCtgTheta;
|
---|
| 384 |
|
---|
| 385 | // add some offdiagonal covariance matrix elements
|
---|
[b750b0a] | 386 | entry->ErrorD0Phi = candidate->TrackCovariance(0,1)*1.e3;
|
---|
[2671df6] | 387 | entry->ErrorD0C = candidate->TrackCovariance(0,2);
|
---|
[b750b0a] | 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;
|
---|
[2671df6] | 392 | entry->ErrorPhiCtgTheta = candidate->TrackCovariance(1,4);
|
---|
| 393 | entry->ErrorCDZ = candidate->TrackCovariance(2,3);
|
---|
[b750b0a] | 394 | entry->ErrorCCtgTheta = candidate->TrackCovariance(2,4)*1.e-3;
|
---|
| 395 | entry->ErrorDZCtgTheta = candidate->TrackCovariance(3,4)*1.e3;
|
---|
[5496767] | 396 |
|
---|
[e4c3fef] | 397 | entry->Xd = candidate->Xd;
|
---|
| 398 | entry->Yd = candidate->Yd;
|
---|
| 399 | entry->Zd = candidate->Zd;
|
---|
[9040259] | 400 |
|
---|
[3a105e5] | 401 | entry->XFirstHit = candidate->XFirstHit;
|
---|
| 402 | entry->YFirstHit = candidate->YFirstHit;
|
---|
| 403 | entry->ZFirstHit = candidate->ZFirstHit;
|
---|
| 404 |
|
---|
[d7d2da3] | 405 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 406 |
|
---|
| 407 | pt = momentum.Pt();
|
---|
[2a3eb22] | 408 | p = momentum.P();
|
---|
| 409 | phi = momentum.Phi();
|
---|
[fd4b326] | 410 | m = momentum.M();
|
---|
[341014c] | 411 | ctgTheta = (TMath::Tan(momentum.Theta()) != 0) ? 1 / TMath::Tan(momentum.Theta()) : 1e10;
|
---|
[2a3eb22] | 412 |
|
---|
[d7d2da3] | 413 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
| 414 | signz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
[341014c] | 415 | eta = (cosTheta == 1.0 ? signz * 999.9 : momentum.Eta());
|
---|
| 416 | rapidity = (cosTheta == 1.0 ? signz * 999.9 : momentum.Rapidity());
|
---|
[d7d2da3] | 417 |
|
---|
[c1ea422] | 418 | entry->P = p;
|
---|
[341014c] | 419 | entry->PT = pt;
|
---|
[d7d2da3] | 420 | entry->Eta = eta;
|
---|
[2a3eb22] | 421 | entry->Phi = phi;
|
---|
| 422 | entry->CtgTheta = ctgTheta;
|
---|
[17cd992] | 423 | entry->C = candidate->C;
|
---|
[fd4b326] | 424 | entry->Mass = m;
|
---|
[5496767] | 425 |
|
---|
[56af73f] | 426 | particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
|
---|
[0060caa] | 427 | //const TLorentzVector &initialPosition = particle->Position;
|
---|
| 428 | const TLorentzVector &initialPosition = candidate->InitialPosition;
|
---|
[d7d2da3] | 429 |
|
---|
| 430 | entry->X = initialPosition.X();
|
---|
| 431 | entry->Y = initialPosition.Y();
|
---|
| 432 | entry->Z = initialPosition.Z();
|
---|
[341014c] | 433 | entry->T = initialPosition.T() * 1.0E-3 / c_light;
|
---|
[d248604] | 434 | entry->ErrorT =candidate-> ErrorT * 1.0E-3 / c_light;
|
---|
[d7d2da3] | 435 |
|
---|
| 436 | entry->Particle = particle;
|
---|
[2600216] | 437 |
|
---|
| 438 | entry->VertexIndex = candidate->ClusterIndex;
|
---|
[d7d2da3] | 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;
|
---|
[22dc7fd] | 450 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 451 |
|
---|
[d07e957] | 452 | // loop over all towers
|
---|
[d7d2da3] | 453 | iterator.Reset();
|
---|
[341014c] | 454 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
[d7d2da3] | 455 | {
|
---|
| 456 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
[22dc7fd] | 457 | const TLorentzVector &position = candidate->Position;
|
---|
[8f7db23] | 458 |
|
---|
[d7d2da3] | 459 | pt = momentum.Pt();
|
---|
| 460 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
| 461 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
[341014c] | 462 | eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
|
---|
| 463 | rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
|
---|
[d7d2da3] | 464 |
|
---|
[341014c] | 465 | entry = static_cast<Tower *>(branch->NewEntry());
|
---|
[d7d2da3] | 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;
|
---|
[61dccd3] | 476 | entry->Etrk = candidate->Etrk;
|
---|
[d7d2da3] | 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];
|
---|
[8f7db23] | 481 |
|
---|
[341014c] | 482 | entry->T = position.T() * 1.0E-3 / c_light;
|
---|
[839deb7] | 483 | entry->NTimeHits = candidate->NTimeHits;
|
---|
[8f7db23] | 484 |
|
---|
[d7d2da3] | 485 | FillParticles(candidate, &entry->Particles);
|
---|
| 486 | }
|
---|
| 487 | }
|
---|
| 488 |
|
---|
| 489 | //------------------------------------------------------------------------------
|
---|
| 490 |
|
---|
[4d7014e] | 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;
|
---|
[fd4b326] | 498 | Double_t e, pt, signz, cosTheta, eta, rapidity, p, ctgTheta, phi, m;
|
---|
[4d7014e] | 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;
|
---|
[a95da74] | 533 | entry->Nclusters = candidate->Nclusters;
|
---|
[781af69] | 534 | entry->dNdx = candidate->dNdx;
|
---|
[4d7014e] | 535 |
|
---|
| 536 | entry->ErrorP = candidate->ErrorP;
|
---|
| 537 | entry->ErrorPT = candidate->ErrorPT;
|
---|
| 538 | entry->ErrorCtgTheta = candidate->ErrorCtgTheta;
|
---|
[2671df6] | 539 |
|
---|
| 540 |
|
---|
| 541 | // diagonal covariance matrix terms
|
---|
| 542 |
|
---|
| 543 | entry->ErrorD0 = candidate->ErrorD0;
|
---|
| 544 | entry->ErrorC = candidate->ErrorC;
|
---|
[4d7014e] | 545 | entry->ErrorPhi = candidate->ErrorPhi;
|
---|
[2671df6] | 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 |
|
---|
[4d7014e] | 561 | entry->Xd = candidate->Xd;
|
---|
| 562 | entry->Yd = candidate->Yd;
|
---|
| 563 | entry->Zd = candidate->Zd;
|
---|
| 564 |
|
---|
[3a105e5] | 565 | entry->XFirstHit = candidate->XFirstHit;
|
---|
| 566 | entry->YFirstHit = candidate->YFirstHit;
|
---|
| 567 | entry->ZFirstHit = candidate->ZFirstHit;
|
---|
| 568 |
|
---|
[4d7014e] | 569 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 570 |
|
---|
| 571 | e = momentum.E();
|
---|
| 572 | pt = momentum.Pt();
|
---|
| 573 | p = momentum.P();
|
---|
| 574 | phi = momentum.Phi();
|
---|
[fd4b326] | 575 | m = momentum.M();
|
---|
[4d7014e] | 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;
|
---|
[17cd992] | 584 | entry->C = candidate->C;
|
---|
[fd4b326] | 585 | entry->Mass = m;
|
---|
[dc883b4] | 586 |
|
---|
[56af73f] | 587 | particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
|
---|
[0060caa] | 588 | //const TLorentzVector &initialPosition = particle->Position;
|
---|
| 589 | const TLorentzVector &initialPosition = candidate->InitialPosition;
|
---|
[4d7014e] | 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;
|
---|
[d248604] | 595 | entry->ErrorT = candidate-> ErrorT * 1.0E-3 / c_light;
|
---|
[4d7014e] | 596 |
|
---|
| 597 | entry->VertexIndex = candidate->ClusterIndex;
|
---|
| 598 |
|
---|
| 599 | entry->Eem = candidate->Eem;
|
---|
| 600 | entry->Ehad = candidate->Ehad;
|
---|
[61dccd3] | 601 | entry->Etrk = candidate->Etrk;
|
---|
[4d7014e] | 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 |
|
---|
[0060caa] | 607 | //entry->T = position.T() * 1.0E-3 / c_light;
|
---|
[4d7014e] | 608 | entry->NTimeHits = candidate->NTimeHits;
|
---|
| 609 |
|
---|
| 610 | FillParticles(candidate, &entry->Particles);
|
---|
| 611 |
|
---|
| 612 | }
|
---|
| 613 | }
|
---|
| 614 |
|
---|
| 615 | //------------------------------------------------------------------------------
|
---|
| 616 |
|
---|
[d7d2da3] | 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;
|
---|
[22dc7fd] | 623 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 624 |
|
---|
[d7d2da3] | 625 | array->Sort();
|
---|
| 626 |
|
---|
| 627 | // loop over all photons
|
---|
| 628 | iterator.Reset();
|
---|
[341014c] | 629 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
[d7d2da3] | 630 | {
|
---|
| 631 | TIter it1(candidate->GetCandidates());
|
---|
| 632 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
[22dc7fd] | 633 | const TLorentzVector &position = candidate->Position;
|
---|
[8f7db23] | 634 |
|
---|
[d7d2da3] | 635 | pt = momentum.Pt();
|
---|
| 636 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
| 637 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
[341014c] | 638 | eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
|
---|
| 639 | rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
|
---|
[d7d2da3] | 640 |
|
---|
[341014c] | 641 | entry = static_cast<Photon *>(branch->NewEntry());
|
---|
[d7d2da3] | 642 |
|
---|
| 643 | entry->Eta = eta;
|
---|
| 644 | entry->Phi = momentum.Phi();
|
---|
| 645 | entry->PT = pt;
|
---|
| 646 | entry->E = momentum.E();
|
---|
[341014c] | 647 | entry->T = position.T() * 1.0E-3 / c_light;
|
---|
[8f7db23] | 648 |
|
---|
[d5cae2b] | 649 | // Isolation variables
|
---|
[9040259] | 650 |
|
---|
[d5cae2b] | 651 | entry->IsolationVar = candidate->IsolationVar;
|
---|
[341014c] | 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;
|
---|
[d5cae2b] | 657 |
|
---|
[341014c] | 658 | entry->EhadOverEem = candidate->Eem > 0.0 ? candidate->Ehad / candidate->Eem : 999.9;
|
---|
[d7d2da3] | 659 |
|
---|
[0e0f211] | 660 | // 1: prompt -- 2: non prompt -- 3: fake
|
---|
| 661 | entry->Status = candidate->Status;
|
---|
| 662 |
|
---|
[d7d2da3] | 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;
|
---|
[22dc7fd] | 675 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 676 |
|
---|
[d7d2da3] | 677 | array->Sort();
|
---|
| 678 |
|
---|
| 679 | // loop over all electrons
|
---|
| 680 | iterator.Reset();
|
---|
[341014c] | 681 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
[d7d2da3] | 682 | {
|
---|
| 683 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
[22dc7fd] | 684 | const TLorentzVector &position = candidate->Position;
|
---|
[8f7db23] | 685 |
|
---|
[d7d2da3] | 686 | pt = momentum.Pt();
|
---|
| 687 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
| 688 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
[341014c] | 689 | eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
|
---|
| 690 | rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
|
---|
[d7d2da3] | 691 |
|
---|
[341014c] | 692 | entry = static_cast<Electron *>(branch->NewEntry());
|
---|
[d7d2da3] | 693 |
|
---|
| 694 | entry->Eta = eta;
|
---|
| 695 | entry->Phi = momentum.Phi();
|
---|
| 696 | entry->PT = pt;
|
---|
[8f7db23] | 697 |
|
---|
[341014c] | 698 | entry->T = position.T() * 1.0E-3 / c_light;
|
---|
[8f7db23] | 699 |
|
---|
[0518688] | 700 | // displacement
|
---|
[341014c] | 701 | entry->D0 = candidate->D0;
|
---|
| 702 | entry->ErrorD0 = candidate->ErrorD0;
|
---|
| 703 | entry->DZ = candidate->DZ;
|
---|
| 704 | entry->ErrorDZ = candidate->ErrorDZ;
|
---|
[9040259] | 705 |
|
---|
[0518688] | 706 | // Isolation variables
|
---|
[d5cae2b] | 707 | entry->IsolationVar = candidate->IsolationVar;
|
---|
[341014c] | 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;
|
---|
[d5cae2b] | 713 |
|
---|
[d7d2da3] | 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;
|
---|
[8f7db23] | 730 |
|
---|
[22dc7fd] | 731 | const Double_t c_light = 2.99792458E8;
|
---|
[8f7db23] | 732 |
|
---|
[d7d2da3] | 733 | array->Sort();
|
---|
| 734 |
|
---|
| 735 | // loop over all muons
|
---|
| 736 | iterator.Reset();
|
---|
[341014c] | 737 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
[d7d2da3] | 738 | {
|
---|
| 739 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
[22dc7fd] | 740 | const TLorentzVector &position = candidate->Position;
|
---|
[8f7db23] | 741 |
|
---|
[d7d2da3] | 742 | pt = momentum.Pt();
|
---|
| 743 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
| 744 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
[341014c] | 745 | eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
|
---|
| 746 | rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
|
---|
[d7d2da3] | 747 |
|
---|
[341014c] | 748 | entry = static_cast<Muon *>(branch->NewEntry());
|
---|
[d7d2da3] | 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 |
|
---|
[341014c] | 757 | entry->T = position.T() * 1.0E-3 / c_light;
|
---|
[0518688] | 758 |
|
---|
| 759 | // displacement
|
---|
[341014c] | 760 | entry->D0 = candidate->D0;
|
---|
| 761 | entry->ErrorD0 = candidate->ErrorD0;
|
---|
| 762 | entry->DZ = candidate->DZ;
|
---|
| 763 | entry->ErrorDZ = candidate->ErrorDZ;
|
---|
[0518688] | 764 |
|
---|
[d5cae2b] | 765 | // Isolation variables
|
---|
[9040259] | 766 |
|
---|
[d5cae2b] | 767 | entry->IsolationVar = candidate->IsolationVar;
|
---|
[341014c] | 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;
|
---|
[8f7db23] | 773 |
|
---|
[d7d2da3] | 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;
|
---|
[22dc7fd] | 789 | const Double_t c_light = 2.99792458E8;
|
---|
[de6d698] | 790 | Int_t i;
|
---|
[8f7db23] | 791 |
|
---|
[d7d2da3] | 792 | array->Sort();
|
---|
| 793 |
|
---|
| 794 | // loop over all jets
|
---|
| 795 | iterator.Reset();
|
---|
[341014c] | 796 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
[d7d2da3] | 797 | {
|
---|
| 798 | TIter itConstituents(candidate->GetCandidates());
|
---|
[8f7db23] | 799 |
|
---|
[d7d2da3] | 800 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
[22dc7fd] | 801 | const TLorentzVector &position = candidate->Position;
|
---|
[8f7db23] | 802 |
|
---|
[d7d2da3] | 803 | pt = momentum.Pt();
|
---|
| 804 | cosTheta = TMath::Abs(momentum.CosTheta());
|
---|
| 805 | signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
|
---|
[341014c] | 806 | eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
|
---|
| 807 | rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
|
---|
[d7d2da3] | 808 |
|
---|
[341014c] | 809 | entry = static_cast<Jet *>(branch->NewEntry());
|
---|
[d7d2da3] | 810 |
|
---|
| 811 | entry->Eta = eta;
|
---|
| 812 | entry->Phi = momentum.Phi();
|
---|
| 813 | entry->PT = pt;
|
---|
| 814 |
|
---|
[341014c] | 815 | entry->T = position.T() * 1.0E-3 / c_light;
|
---|
[8f7db23] | 816 |
|
---|
[d7d2da3] | 817 | entry->Mass = momentum.M();
|
---|
| 818 |
|
---|
[ba1f1ee] | 819 | entry->Area = candidate->Area;
|
---|
| 820 |
|
---|
[d7d2da3] | 821 | entry->DeltaEta = candidate->DeltaEta;
|
---|
| 822 | entry->DeltaPhi = candidate->DeltaPhi;
|
---|
| 823 |
|
---|
[fe0273c] | 824 | entry->Flavor = candidate->Flavor;
|
---|
| 825 | entry->FlavorAlgo = candidate->FlavorAlgo;
|
---|
| 826 | entry->FlavorPhys = candidate->FlavorPhys;
|
---|
| 827 |
|
---|
[d7d2da3] | 828 | entry->BTag = candidate->BTag;
|
---|
[9040259] | 829 |
|
---|
| 830 | entry->BTagAlgo = candidate->BTagAlgo;
|
---|
[fe0273c] | 831 | entry->BTagPhys = candidate->BTagPhys;
|
---|
[9040259] | 832 |
|
---|
[d7d2da3] | 833 | entry->TauTag = candidate->TauTag;
|
---|
[7429c6a] | 834 | entry->TauWeight = candidate->TauWeight;
|
---|
[d7d2da3] | 835 |
|
---|
| 836 | entry->Charge = candidate->Charge;
|
---|
| 837 |
|
---|
| 838 | itConstituents.Reset();
|
---|
| 839 | entry->Constituents.Clear();
|
---|
| 840 | ecalEnergy = 0.0;
|
---|
| 841 | hcalEnergy = 0.0;
|
---|
[341014c] | 842 | while((constituent = static_cast<Candidate *>(itConstituents.Next())))
|
---|
[d7d2da3] | 843 | {
|
---|
| 844 | entry->Constituents.Add(constituent);
|
---|
| 845 | ecalEnergy += constituent->Eem;
|
---|
| 846 | hcalEnergy += constituent->Ehad;
|
---|
| 847 | }
|
---|
| 848 |
|
---|
[341014c] | 849 | entry->EhadOverEem = ecalEnergy > 0.0 ? hcalEnergy / ecalEnergy : 999.9;
|
---|
[8f7db23] | 850 |
|
---|
[24d005f] | 851 | //--- Pile-Up Jet ID variables ----
|
---|
| 852 |
|
---|
| 853 | entry->NCharged = candidate->NCharged;
|
---|
| 854 | entry->NNeutrals = candidate->NNeutrals;
|
---|
[c614dd7] | 855 |
|
---|
| 856 | entry->NeutralEnergyFraction = candidate->NeutralEnergyFraction;
|
---|
| 857 | entry->ChargedEnergyFraction = candidate->ChargedEnergyFraction;
|
---|
[24d005f] | 858 | entry->Beta = candidate->Beta;
|
---|
| 859 | entry->BetaStar = candidate->BetaStar;
|
---|
| 860 | entry->MeanSqDeltaR = candidate->MeanSqDeltaR;
|
---|
| 861 | entry->PTD = candidate->PTD;
|
---|
[9040259] | 862 |
|
---|
[de6d698] | 863 | //--- Sub-structure variables ----
|
---|
[9040259] | 864 |
|
---|
| 865 | entry->NSubJetsTrimmed = candidate->NSubJetsTrimmed;
|
---|
| 866 | entry->NSubJetsPruned = candidate->NSubJetsPruned;
|
---|
[de6d698] | 867 | entry->NSubJetsSoftDropped = candidate->NSubJetsSoftDropped;
|
---|
[9040259] | 868 |
|
---|
[341014c] | 869 | entry->SoftDroppedJet = candidate->SoftDroppedJet;
|
---|
| 870 | entry->SoftDroppedSubJet1 = candidate->SoftDroppedSubJet1;
|
---|
[ba75867] | 871 | entry->SoftDroppedSubJet2 = candidate->SoftDroppedSubJet2;
|
---|
| 872 |
|
---|
[de6d698] | 873 | for(i = 0; i < 5; i++)
|
---|
| 874 | {
|
---|
[341014c] | 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];
|
---|
[de6d698] | 880 | }
|
---|
[9040259] | 881 |
|
---|
[e9c0d73] | 882 | //--- exclusive clustering variables ---
|
---|
| 883 | entry->ExclYmerge23 = candidate->ExclYmerge23;
|
---|
| 884 | entry->ExclYmerge34 = candidate->ExclYmerge34;
|
---|
| 885 | entry->ExclYmerge45 = candidate->ExclYmerge45;
|
---|
[341014c] | 886 | entry->ExclYmerge56 = candidate->ExclYmerge56;
|
---|
[e9c0d73] | 887 |
|
---|
[d7d2da3] | 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
|
---|
[341014c] | 900 | if((candidate = static_cast<Candidate *>(array->At(0))))
|
---|
[d7d2da3] | 901 | {
|
---|
| 902 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 903 |
|
---|
[341014c] | 904 | entry = static_cast<MissingET *>(branch->NewEntry());
|
---|
[d7d2da3] | 905 |
|
---|
[3b465ca] | 906 | entry->Eta = (-momentum).Eta();
|
---|
[d7d2da3] | 907 | entry->Phi = (-momentum).Phi();
|
---|
| 908 | entry->MET = momentum.Pt();
|
---|
| 909 | }
|
---|
| 910 | }
|
---|
[cc8716b] | 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 | }
|
---|
[d7d2da3] | 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
|
---|
[341014c] | 973 | if((candidate = static_cast<Candidate *>(array->At(0))))
|
---|
[d7d2da3] | 974 | {
|
---|
| 975 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 976 |
|
---|
[341014c] | 977 | entry = static_cast<ScalarHT *>(branch->NewEntry());
|
---|
[d7d2da3] | 978 |
|
---|
| 979 | entry->HT = momentum.Pt();
|
---|
| 980 | }
|
---|
| 981 | }
|
---|
| 982 |
|
---|
| 983 | //------------------------------------------------------------------------------
|
---|
| 984 |
|
---|
[71648c2] | 985 | void TreeWriter::ProcessRho(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 986 | {
|
---|
[3b465ca] | 987 | TIter iterator(array);
|
---|
[71648c2] | 988 | Candidate *candidate = 0;
|
---|
| 989 | Rho *entry = 0;
|
---|
| 990 |
|
---|
[3b465ca] | 991 | // loop over all rho
|
---|
| 992 | iterator.Reset();
|
---|
[341014c] | 993 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
[71648c2] | 994 | {
|
---|
| 995 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 996 |
|
---|
[341014c] | 997 | entry = static_cast<Rho *>(branch->NewEntry());
|
---|
[71648c2] | 998 |
|
---|
[8608ef8] | 999 | entry->Rho = momentum.E();
|
---|
[3b465ca] | 1000 | entry->Edges[0] = candidate->Edges[0];
|
---|
| 1001 | entry->Edges[1] = candidate->Edges[1];
|
---|
[71648c2] | 1002 | }
|
---|
| 1003 | }
|
---|
| 1004 |
|
---|
| 1005 | //------------------------------------------------------------------------------
|
---|
| 1006 |
|
---|
[2e229c9] | 1007 | void TreeWriter::ProcessWeight(ExRootTreeBranch *branch, TObjArray *array)
|
---|
| 1008 | {
|
---|
| 1009 | Candidate *candidate = 0;
|
---|
| 1010 | Weight *entry = 0;
|
---|
| 1011 |
|
---|
| 1012 | // get the first entry
|
---|
[341014c] | 1013 | if((candidate = static_cast<Candidate *>(array->At(0))))
|
---|
[2e229c9] | 1014 | {
|
---|
| 1015 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 1016 |
|
---|
[341014c] | 1017 | entry = static_cast<Weight *>(branch->NewEntry());
|
---|
[2e229c9] | 1018 |
|
---|
| 1019 | entry->Weight = momentum.E();
|
---|
| 1020 | }
|
---|
| 1021 | }
|
---|
| 1022 |
|
---|
| 1023 | //------------------------------------------------------------------------------
|
---|
| 1024 |
|
---|
[8f7db23] | 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();
|
---|
[341014c] | 1033 | while((candidate = static_cast<Candidate *>(iterator.Next())))
|
---|
[8f7db23] | 1034 | {
|
---|
| 1035 | const TLorentzVector &position = candidate->Position;
|
---|
| 1036 | const TLorentzVector &momentum = candidate->Momentum;
|
---|
| 1037 |
|
---|
[341014c] | 1038 | entry = static_cast<HectorHit *>(branch->NewEntry());
|
---|
[8f7db23] | 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();
|
---|
[64a4950] | 1050 |
|
---|
| 1051 | entry->Particle = candidate->GetCandidates()->At(0);
|
---|
[8f7db23] | 1052 | }
|
---|
| 1053 | }
|
---|
| 1054 |
|
---|
| 1055 | //------------------------------------------------------------------------------
|
---|
| 1056 |
|
---|
[d7d2da3] | 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 | //------------------------------------------------------------------------------
|
---|