1 | /*
|
---|
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 | *
|
---|
23 | * \authors F. Bedeschi - INFN Pisa
|
---|
24 | * P. Demin - UCLouvain, Louvain-la-Neuve
|
---|
25 | * M. Selvaggi - CERN
|
---|
26 | *
|
---|
27 | *
|
---|
28 | */
|
---|
29 |
|
---|
30 | //FIXME add reference to Bedeschi-code
|
---|
31 | //FIXME make sure about units of P, X
|
---|
32 | //FIXME fix pt > 200 GeV issue and angle > 6.41
|
---|
33 |
|
---|
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 |
|
---|
46 | #include <iostream>
|
---|
47 | #include <sstream>
|
---|
48 |
|
---|
49 | using namespace std;
|
---|
50 |
|
---|
51 | //------------------------------------------------------------------------------
|
---|
52 |
|
---|
53 | TrackCovariance::TrackCovariance() :
|
---|
54 | fGeometry(0), fCovariance(0), fAcx(0), fItInputArray(0)
|
---|
55 | {
|
---|
56 | fGeometry = new SolGeom();
|
---|
57 | fCovariance = new SolGridCov();
|
---|
58 | }
|
---|
59 |
|
---|
60 | //------------------------------------------------------------------------------
|
---|
61 |
|
---|
62 | TrackCovariance::~TrackCovariance()
|
---|
63 | {
|
---|
64 | if(fGeometry) delete fGeometry;
|
---|
65 | if(fCovariance) delete fCovariance;
|
---|
66 | }
|
---|
67 |
|
---|
68 | //------------------------------------------------------------------------------
|
---|
69 |
|
---|
70 | void TrackCovariance::Init()
|
---|
71 | {
|
---|
72 | fBz = GetDouble("Bz", 0.0);
|
---|
73 | fGeometry->Read(GetString("DetectorGeometry", ""));
|
---|
74 | fNMinHits = GetInt("NMinHits", 6);
|
---|
75 |
|
---|
76 | // load geometry
|
---|
77 | fCovariance->Calc(fGeometry);
|
---|
78 | fCovariance->SetMinHits(fNMinHits);
|
---|
79 | // load geometry
|
---|
80 | fAcx = fCovariance->AccPnt();
|
---|
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 |
|
---|
93 | void TrackCovariance::Finish()
|
---|
94 | {
|
---|
95 | if(fItInputArray) delete fItInputArray;
|
---|
96 | }
|
---|
97 |
|
---|
98 | //------------------------------------------------------------------------------
|
---|
99 |
|
---|
100 | void TrackCovariance::Process()
|
---|
101 | {
|
---|
102 | Candidate *candidate, *mother, *particle;
|
---|
103 | Double_t mass, p, pt, q, ct;
|
---|
104 | Double_t dd0, ddz, dphi, dct, dp, dpt, dC;
|
---|
105 |
|
---|
106 | fItInputArray->Reset();
|
---|
107 | while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
|
---|
108 | {
|
---|
109 |
|
---|
110 | // converting to meters
|
---|
111 | particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
|
---|
112 |
|
---|
113 | // converting to meters
|
---|
114 | const TLorentzVector &candidatePosition = particle->Position*1e-03;
|
---|
115 | const TLorentzVector &candidateMomentum = particle->Momentum;
|
---|
116 |
|
---|
117 | if ( !fCovariance->IsAccepted(candidateMomentum.Vect()) ) continue;
|
---|
118 |
|
---|
119 | mass = candidateMomentum.M();
|
---|
120 |
|
---|
121 | ObsTrk track(candidatePosition.Vect(), candidateMomentum.Vect(), candidate->Charge, fBz, fCovariance);
|
---|
122 |
|
---|
123 | mother = candidate;
|
---|
124 | candidate = static_cast<Candidate*>(candidate->Clone());
|
---|
125 |
|
---|
126 | candidate->Momentum.SetVectM(track.GetObsP(), mass);
|
---|
127 |
|
---|
128 | // converting back to mm
|
---|
129 | candidate->InitialPosition.SetXYZT(track.GetObsX().X()*1e03,track.GetObsX().Y()*1e03,track.GetObsX().Z()*1e03,candidatePosition.T()*1e03);
|
---|
130 |
|
---|
131 | // save full covariance 5x5 matrix internally (D0, phi, Curvature, dz, ctg(theta))
|
---|
132 | candidate->TrackCovariance = track.GetCov();
|
---|
133 |
|
---|
134 | pt = candidate->Momentum.Pt();
|
---|
135 | p = candidate->Momentum.P();
|
---|
136 | q = track.GetObsQ();
|
---|
137 | ct = track.GetObsPar()[4];
|
---|
138 |
|
---|
139 | candidate->Xd = track.GetObsX().X()*1e03;
|
---|
140 | candidate->Yd = track.GetObsX().Y()*1e03;
|
---|
141 | candidate->Zd = track.GetObsX().Z()*1e03;
|
---|
142 |
|
---|
143 | candidate->D0 = track.GetObsPar()[0]*1e03;
|
---|
144 | candidate->Phi = track.GetObsPar()[1];
|
---|
145 |
|
---|
146 | // inverse of curvature
|
---|
147 | candidate->C = track.GetObsPar()[2]*1e-03;
|
---|
148 | candidate->DZ = track.GetObsPar()[3]*1e03;
|
---|
149 | candidate->CtgTheta = track.GetObsPar()[4];
|
---|
150 | candidate->P = track.GetObsP().Mag();
|
---|
151 | candidate->PT = pt;
|
---|
152 | candidate->Charge = q;
|
---|
153 |
|
---|
154 | dd0 = TMath::Sqrt(track.GetCov()(0, 0))*1e03;
|
---|
155 | ddz = TMath::Sqrt(track.GetCov()(3, 3))*1e03;
|
---|
156 | dphi = TMath::Sqrt(track.GetCov()(1, 1));
|
---|
157 | dct = TMath::Sqrt(track.GetCov()(4, 4));
|
---|
158 | dpt = 2 * TMath::Sqrt( track.GetCov()(2, 2))*pt*pt / (0.2998*fBz);
|
---|
159 | dp = TMath::Sqrt((1.+ct*ct)*dpt*dpt + 4*pt*pt*ct*ct*dct*dct/(1.+ct*ct)/(1.+ct*ct));
|
---|
160 | dC = TMath::Sqrt(track.GetCov()(2, 2))*1e-03;
|
---|
161 |
|
---|
162 | candidate->ErrorD0 = dd0;
|
---|
163 | candidate->ErrorDZ = ddz;
|
---|
164 | candidate->ErrorP = dp;
|
---|
165 | candidate->ErrorC = dC;
|
---|
166 | candidate->ErrorCtgTheta = dct;
|
---|
167 | candidate->ErrorPhi = dphi;
|
---|
168 | candidate->ErrorPT = dpt;
|
---|
169 | //candidate->TrackResolution = dpt / pt;
|
---|
170 | candidate->TrackResolution = dp / p;
|
---|
171 |
|
---|
172 | candidate->AddCandidate(mother);
|
---|
173 |
|
---|
174 | fOutputArray->Add(candidate);
|
---|
175 | }
|
---|
176 | }
|
---|
177 |
|
---|
178 | //------------------------------------------------------------------------------
|
---|