[193c267c] | 1 | /*
|
---|
| 2 | * Delphes: a framework for fast simulation of a generic collider experiment
|
---|
| 3 | * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
|
---|
| 4 | *
|
---|
| 5 | * This program is free software: you can redistribute it and/or modify
|
---|
| 6 | * it under the terms of the GNU General Public License as published by
|
---|
| 7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 8 | * (at your option) any later version.
|
---|
| 9 | *
|
---|
| 10 | * This program is distributed in the hope that it will be useful,
|
---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 13 | * GNU General Public License for more details.
|
---|
| 14 | *
|
---|
| 15 | * You should have received a copy of the GNU General Public License
|
---|
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 17 | */
|
---|
| 18 |
|
---|
| 19 | /** \class TimeOfFlight
|
---|
| 20 | *
|
---|
| 21 | * Calculates Time-Of-Flight
|
---|
| 22 | *
|
---|
| 23 | * \author Michele Selvaggi - CERN
|
---|
| 24 | *
|
---|
| 25 | */
|
---|
| 26 |
|
---|
| 27 | #include "modules/TimeOfFlight.h"
|
---|
| 28 |
|
---|
| 29 | #include "classes/DelphesClasses.h"
|
---|
| 30 | #include "classes/DelphesFactory.h"
|
---|
| 31 | #include "classes/DelphesFormula.h"
|
---|
| 32 |
|
---|
| 33 | #include "ExRootAnalysis/ExRootClassifier.h"
|
---|
| 34 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
| 35 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
| 36 |
|
---|
| 37 | #include "TDatabasePDG.h"
|
---|
| 38 | #include "TFormula.h"
|
---|
| 39 | #include "TLorentzVector.h"
|
---|
| 40 | #include "TMath.h"
|
---|
| 41 | #include "TObjArray.h"
|
---|
| 42 | #include "TRandom3.h"
|
---|
| 43 | #include "TString.h"
|
---|
| 44 |
|
---|
| 45 | #include <algorithm>
|
---|
| 46 | #include <iostream>
|
---|
| 47 | #include <sstream>
|
---|
| 48 | #include <stdexcept>
|
---|
| 49 |
|
---|
| 50 | using namespace std;
|
---|
| 51 | //------------------------------------------------------------------------------
|
---|
| 52 |
|
---|
| 53 | TimeOfFlight::TimeOfFlight() :
|
---|
| 54 | fItTrackInputArray(0), fItVertexInputArray(0)
|
---|
| 55 | {
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | //------------------------------------------------------------------------------
|
---|
| 59 |
|
---|
| 60 | TimeOfFlight::~TimeOfFlight()
|
---|
| 61 | {
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | //------------------------------------------------------------------------------
|
---|
| 65 |
|
---|
| 66 | void TimeOfFlight::Init()
|
---|
| 67 | {
|
---|
| 68 |
|
---|
| 69 | // method to compute vertex time
|
---|
| 70 | fVertexTimeMode = GetInt("VertexTimeMode", 0);
|
---|
| 71 |
|
---|
| 72 | // import track input array
|
---|
| 73 | fTrackInputArray = ImportArray(GetString("TrackInputArray", "MuonMomentumSmearing/muons"));
|
---|
| 74 | fItTrackInputArray = fTrackInputArray->MakeIterator();
|
---|
| 75 |
|
---|
| 76 | // import vertex input array
|
---|
| 77 | fVertexInputArray = ImportArray(GetString("VertexInputArray", "TruthVertexFinder/vertices"));
|
---|
| 78 | fItVertexInputArray = fVertexInputArray->MakeIterator();
|
---|
| 79 |
|
---|
| 80 | // create output array
|
---|
| 81 | fOutputArray = ExportArray(GetString("OutputArray", "tracks"));
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | //------------------------------------------------------------------------------
|
---|
| 85 |
|
---|
| 86 | void TimeOfFlight::Finish()
|
---|
| 87 | {
|
---|
| 88 | if(fItTrackInputArray) delete fItTrackInputArray;
|
---|
| 89 | if(fItVertexInputArray) delete fItVertexInputArray;
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | //------------------------------------------------------------------------------
|
---|
| 93 |
|
---|
| 94 | void TimeOfFlight::Process()
|
---|
| 95 | {
|
---|
| 96 | Candidate *candidate, *particle, *vertex, *constituent, *mother;
|
---|
| 97 | Double_t ti, t_truth, tf;
|
---|
| 98 | Double_t l, tof, beta, p, mass;
|
---|
| 99 |
|
---|
| 100 | const Double_t c_light = 2.99792458E8;
|
---|
| 101 |
|
---|
| 102 | // first compute momenta of vertices based on reconstructed tracks
|
---|
| 103 | ComputeVertexMomenta();
|
---|
| 104 |
|
---|
| 105 | fItTrackInputArray->Reset();
|
---|
| 106 | while((candidate = static_cast<Candidate *>(fItTrackInputArray->Next())))
|
---|
| 107 | {
|
---|
| 108 |
|
---|
| 109 | particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
|
---|
| 110 |
|
---|
| 111 | const TLorentzVector &candidateInitialPosition = particle->Position;
|
---|
[a52e99e] | 112 | const TLorentzVector &candidateInitialPositionSmeared = candidate->InitialPosition;
|
---|
[193c267c] | 113 | const TLorentzVector &candidateFinalPosition = candidate->Position;
|
---|
| 114 | const TLorentzVector &candidateMomentum = particle->Momentum;
|
---|
| 115 |
|
---|
| 116 | // time at vertex from MC truth
|
---|
| 117 | t_truth = candidateInitialPosition.T() * 1.0E-3 / c_light;
|
---|
| 118 |
|
---|
| 119 | if (candidate->Position.Vect().Mag() < 5.) continue;
|
---|
| 120 |
|
---|
| 121 | // various options on how to calculate the vertex time
|
---|
| 122 | ti=0;
|
---|
| 123 | switch (fVertexTimeMode)
|
---|
| 124 | {
|
---|
| 125 | case 0:
|
---|
| 126 | {
|
---|
| 127 | // assume ti from MC truth
|
---|
| 128 | // most aggressive, we are cheating and assume we can perfectly reconstruct time of primary and secondary vertices
|
---|
| 129 | ti = t_truth;
|
---|
| 130 | break;
|
---|
| 131 | }
|
---|
| 132 | case 1:
|
---|
| 133 | {
|
---|
| 134 | // always assume t=0, most conservative assumption
|
---|
| 135 | // reasonable assumption for particles originating from PV, if beamSpot has small time spread compared to timing resolution
|
---|
| 136 | // probably bad assumption for particles from highly displaced vertices (i.e Ks)
|
---|
| 137 | ti=0;
|
---|
| 138 | break;
|
---|
| 139 | }
|
---|
| 140 | case 2:
|
---|
| 141 | {
|
---|
| 142 | // same as 2 but attempt at estimate beta from vertex mass and momentum
|
---|
| 143 | beta = 1.;
|
---|
| 144 | fItVertexInputArray->Reset();
|
---|
| 145 | while((vertex = static_cast<Candidate *>(fItVertexInputArray->Next())))
|
---|
| 146 | {
|
---|
| 147 | TIter itGenParts(vertex->GetCandidates());
|
---|
| 148 | itGenParts.Reset();
|
---|
| 149 |
|
---|
| 150 | while((constituent = static_cast<Candidate *>(itGenParts.Next())))
|
---|
| 151 | {
|
---|
| 152 | if (particle == constituent)
|
---|
| 153 | {
|
---|
| 154 | beta = vertex->Momentum.Beta();
|
---|
| 155 | break;
|
---|
| 156 | }
|
---|
| 157 | }
|
---|
| 158 | } // end vertex loop
|
---|
| 159 |
|
---|
| 160 | // track displacement to be possibily replaced by vertex fitted position
|
---|
[a52e99e] | 161 | ti = candidateInitialPositionSmeared.Vect().Mag() * 1.0E-3 /(beta*c_light);
|
---|
[193c267c] | 162 | }
|
---|
| 163 | break;
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 |
|
---|
[a52e99e] | 167 | //ti = ti - t_truth;
|
---|
[193c267c] | 168 |
|
---|
| 169 | p = candidateMomentum.P();
|
---|
| 170 |
|
---|
| 171 | // this quantity has already been smeared by another module
|
---|
| 172 | tf = candidateFinalPosition.T() * 1.0E-3 / c_light;
|
---|
| 173 |
|
---|
| 174 | // calculate time-of-flight
|
---|
| 175 | tof = tf - ti;
|
---|
| 176 | // path length of the full helix
|
---|
| 177 | l = candidate->L * 1.0E-3;
|
---|
| 178 |
|
---|
| 179 | // particle velocity
|
---|
| 180 | beta = l/(c_light*tof);
|
---|
| 181 |
|
---|
| 182 | // calculate particle mass (i.e particle ID)
|
---|
| 183 | mass = 0.;
|
---|
| 184 | if (beta<1) mass = p* TMath::Sqrt(1/(beta*beta) - 1);
|
---|
| 185 |
|
---|
| 186 | mother = candidate;
|
---|
| 187 | candidate = static_cast<Candidate*>(candidate->Clone());
|
---|
| 188 |
|
---|
| 189 | // update time at vertex based on option
|
---|
| 190 | candidate->InitialPosition.SetT(ti * 1.0E3 * c_light);
|
---|
| 191 |
|
---|
| 192 | // update particle mass based on TOF-based PID
|
---|
| 193 | candidate->Momentum.SetVectM(candidateMomentum.Vect(), mass);
|
---|
| 194 |
|
---|
| 195 | candidate->AddCandidate(mother);
|
---|
| 196 | fOutputArray->Add(candidate);
|
---|
| 197 | }
|
---|
| 198 | }
|
---|
| 199 |
|
---|
| 200 | //------------------------------------------------------------------------------
|
---|
| 201 |
|
---|
| 202 | void TimeOfFlight::ComputeVertexMomenta()
|
---|
| 203 | {
|
---|
| 204 | Candidate *track, *constituent, *particle, *vertex;
|
---|
| 205 |
|
---|
| 206 | fItVertexInputArray->Reset();
|
---|
| 207 | while((vertex = static_cast<Candidate *>(fItVertexInputArray->Next())))
|
---|
| 208 | {
|
---|
| 209 |
|
---|
| 210 | TIter itGenParts(vertex->GetCandidates());
|
---|
| 211 | itGenParts.Reset();
|
---|
| 212 |
|
---|
| 213 | while((constituent = static_cast<Candidate *>(itGenParts.Next())))
|
---|
| 214 | {
|
---|
| 215 | fItTrackInputArray->Reset();
|
---|
| 216 | while((track = static_cast<Candidate *>(fItTrackInputArray->Next())))
|
---|
| 217 | {
|
---|
| 218 | // get gen part that generated track
|
---|
| 219 | particle = static_cast<Candidate *>(track->GetCandidates()->At(0));
|
---|
| 220 | if (particle == constituent)
|
---|
| 221 | {
|
---|
| 222 | vertex->Momentum += track->Momentum;
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | } // end track loop
|
---|
| 226 | } // end vertex consitutent loop
|
---|
| 227 | } // end vertex loop
|
---|
| 228 | }
|
---|