Fork me on GitHub

source: git/modules/TrackCovariance.cc@ 2a2f310

Last change on this file since 2a2f310 was 3a105e5, checked in by michele <michele.selvaggi@…>, 3 years ago

added first hit to track

  • Property mode set to 100644
File size: 6.1 KB
RevLine 
[fd4b326]1 /*
[ff9fb2d9]2 * Delphes: a framework for fast simulation of a generic collider experiment
3 * Copyright (C) 2020 Universite catholique de Louvain (UCLouvain), 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 TrackCovariance
20 *
21 * Smears track parameters according to appropriate covariance matrix.
22 *
[170a11d]23 * \authors F. Bedeschi - INFN Pisa
24* P. Demin - UCLouvain, Louvain-la-Neuve
[1388e73]25 * M. Selvaggi - CERN
[ff9fb2d9]26 *
[170a11d]27 *
[ff9fb2d9]28 */
29
[7d790c1]30//FIXME add reference to Bedeschi-code
[1388e73]31//FIXME make sure about units of P, X
32//FIXME fix pt > 200 GeV issue and angle > 6.41
[7d790c1]33
[ff9fb2d9]34#include "modules/TrackCovariance.h"
35
36#include "classes/DelphesClasses.h"
37
38#include "TrackCovariance/SolGeom.h"
39#include "TrackCovariance/SolGridCov.h"
40#include "TrackCovariance/ObsTrk.h"
41
42#include "TLorentzVector.h"
43#include "TMath.h"
44#include "TObjArray.h"
45
[1388e73]46#include <iostream>
47#include <sstream>
48
49using namespace std;
50
[ff9fb2d9]51//------------------------------------------------------------------------------
52
53TrackCovariance::TrackCovariance() :
[170a11d]54 fGeometry(0), fCovariance(0), fAcx(0), fItInputArray(0)
[ff9fb2d9]55{
56 fGeometry = new SolGeom();
57 fCovariance = new SolGridCov();
58}
59
60//------------------------------------------------------------------------------
61
62TrackCovariance::~TrackCovariance()
63{
64 if(fGeometry) delete fGeometry;
65 if(fCovariance) delete fCovariance;
66}
67
68//------------------------------------------------------------------------------
69
70void TrackCovariance::Init()
71{
72 fBz = GetDouble("Bz", 0.0);
73 fGeometry->Read(GetString("DetectorGeometry", ""));
[170a11d]74 fNMinHits = GetInt("NMinHits", 6);
[ff9fb2d9]75
[170a11d]76 // load geometry
[ff9fb2d9]77 fCovariance->Calc(fGeometry);
[170a11d]78 fCovariance->SetMinHits(fNMinHits);
79 // load geometry
80 fAcx = fCovariance->AccPnt();
[ff9fb2d9]81
82 // import input array
83 fInputArray = ImportArray(GetString("InputArray", "TrackMerger/tracks"));
84 fItInputArray = fInputArray->MakeIterator();
85
86 // create output array
87
88 fOutputArray = ExportArray(GetString("OutputArray", "tracks"));
89}
90
91//------------------------------------------------------------------------------
92
93void TrackCovariance::Finish()
94{
95 if(fItInputArray) delete fItInputArray;
96}
97
98//------------------------------------------------------------------------------
99
100void TrackCovariance::Process()
101{
[7143a0e]102 Candidate *candidate, *mother, *particle;
[1388e73]103 Double_t mass, p, pt, q, ct;
[3051ea17]104 Double_t dd0, ddz, dphi, dct, dp, dpt, dC;
[ebf40fd]105 //
106 // Get cylindrical box for fast track simulation
107 //
108 Double_t Rin = fGeometry->GetRmin();
109 Double_t ZinPos = fGeometry->GetZminPos();
110 Double_t ZinNeg = fGeometry->GetZminNeg();
[170a11d]111
[ff9fb2d9]112 fItInputArray->Reset();
113 while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
114 {
[2ca681a]115
[c9e7466]116 // converting to meters
[7143a0e]117 particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
118
[825beb7]119 // converting to meters
[7143a0e]120 const TLorentzVector &candidatePosition = particle->Position*1e-03;
121 const TLorentzVector &candidateMomentum = particle->Momentum;
[ff9fb2d9]122
[3a105e5]123
[ebf40fd]124 Bool_t inside = TrkUtil::IsInside(candidatePosition.Vect(), Rin, ZinNeg, ZinPos); // Check if in inner box
125 Bool_t Accept = kTRUE;
126 if(inside) Accept = fCovariance->IsAccepted(candidateMomentum.Vect());
127 else Accept = fCovariance->IsAccepted(candidatePosition.Vect(),candidateMomentum.Vect(), fGeometry);
128 if(!Accept) continue;
[170a11d]129
[7b518f0]130 mass = candidateMomentum.M();
[ff9fb2d9]131
[ebf40fd]132 ObsTrk track(candidatePosition.Vect(), candidateMomentum.Vect(), candidate->Charge, fCovariance, fGeometry);
[ff9fb2d9]133
[3a105e5]134
[46c8df8]135 mother = candidate;
[170a11d]136 candidate = static_cast<Candidate*>(candidate->Clone());
[1388e73]137
[7b518f0]138 candidate->Momentum.SetVectM(track.GetObsP(), mass);
[170a11d]139
[2ca681a]140 // converting back to mm
141 candidate->InitialPosition.SetXYZT(track.GetObsX().X()*1e03,track.GetObsX().Y()*1e03,track.GetObsX().Z()*1e03,candidatePosition.T()*1e03);
142
[3051ea17]143 // save full covariance 5x5 matrix internally (D0, phi, Curvature, dz, ctg(theta))
144 candidate->TrackCovariance = track.GetCov();
[1388e73]145
146 pt = candidate->Momentum.Pt();
147 p = candidate->Momentum.P();
148 q = track.GetObsQ();
149 ct = track.GetObsPar()[4];
150
[2ca681a]151 candidate->Xd = track.GetObsX().X()*1e03;
152 candidate->Yd = track.GetObsX().Y()*1e03;
153 candidate->Zd = track.GetObsX().Z()*1e03;
[170a11d]154
[3a105e5]155 candidate->XFirstHit = track.GetFirstHit().X()*1e03;
156 candidate->YFirstHit = track.GetFirstHit().Y()*1e03;
157 candidate->ZFirstHit = track.GetFirstHit().Z()*1e03;
158
[2ca681a]159 candidate->D0 = track.GetObsPar()[0]*1e03;
160 candidate->Phi = track.GetObsPar()[1];
[ae5b7b7]161
162 // inverse of curvature
163 candidate->C = track.GetObsPar()[2]*1e-03;
[2ca681a]164 candidate->DZ = track.GetObsPar()[3]*1e03;
[1388e73]165 candidate->CtgTheta = track.GetObsPar()[4];
[2ca681a]166 candidate->P = track.GetObsP().Mag();
167 candidate->PT = pt;
168 candidate->Charge = q;
[1388e73]169
[170a11d]170 dd0 = TMath::Sqrt(track.GetCov()(0, 0))*1e03;
171 ddz = TMath::Sqrt(track.GetCov()(3, 3))*1e03;
172 dphi = TMath::Sqrt(track.GetCov()(1, 1));
173 dct = TMath::Sqrt(track.GetCov()(4, 4));
[1388e73]174 dpt = 2 * TMath::Sqrt( track.GetCov()(2, 2))*pt*pt / (0.2998*fBz);
175 dp = TMath::Sqrt((1.+ct*ct)*dpt*dpt + 4*pt*pt*ct*ct*dct*dct/(1.+ct*ct)/(1.+ct*ct));
[ae5b7b7]176 dC = TMath::Sqrt(track.GetCov()(2, 2))*1e-03;
[1388e73]177
178 candidate->ErrorD0 = dd0;
179 candidate->ErrorDZ = ddz;
180 candidate->ErrorP = dp;
[3051ea17]181 candidate->ErrorC = dC;
[1388e73]182 candidate->ErrorCtgTheta = dct;
183 candidate->ErrorPhi = dphi;
184 candidate->ErrorPT = dpt;
185 //candidate->TrackResolution = dpt / pt;
186 candidate->TrackResolution = dp / p;
[ff9fb2d9]187
188 candidate->AddCandidate(mother);
189
190 fOutputArray->Add(candidate);
191 }
192}
193
194//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.