001
002
003
004
005
006
007
008
009
010
011
012
013 #include "VxJetVertex/VxVertexOnJetAxis.h"
014 #include "VxVertex/VxTrackAtVertex.h"
015 #include "VxJetVertex/VxJetCandidate.h"
016 #include "VxJetVertex/SelectedTracksInJet.h"
017
018 #include "TrkParametersBase/ParametersBase.h"
019 #include "TrkParameters/MeasuredPerigee.h"
020 #include "TrkNeutralParameters/MeasuredNeutralPerigee.h"
021
022 #include "TrkTrackLink/ITrackLink.h"
023
024 #include <TMath.h>
025
026 #include "CLHEP/Vector/LorentzVector.h"
027 #include "CLHEP/Matrix/Vector.h"
028 #include "CLHEP/Vector/ThreeVector.h"
029
030 #include "JetTagTools/JetFitterVariablesFactory.h"
031
032 #include "JetTagInfo/JetFitterTagInfo.h"
033
034 #include "JetEvent/Jet.h"
035
036 #include <vector>
037
038 namespace Analysis {
039
040
041 JetFitterVariablesFactory::JetFitterVariablesFactory(const std::string& name,
042 const std::string& n, const IInterface* p):
043 AthAlgTool(name, n,p),
044 m_jetFitterInstance("JetFitterTag"),
045 m_addNegativeTracksToPrimaryVertex(false),
046 m_usePtCorrectedEnergy(false),
047 m_usePtCorrectedMass(false),
048 m_useSingleTracksAlsoForMass(false)
049 {
050 declareProperty("JetFitterInstance",m_jetFitterInstance);
051 declareProperty("addNegativeTracksToPrimaryVertex",m_addNegativeTracksToPrimaryVertex);
052 declareProperty("usePtCorrectedEnergy",m_usePtCorrectedEnergy);
053 declareProperty("usePtCorrectedMass",m_usePtCorrectedMass);
054 declareProperty("useSingleTracksAlsoForMass",m_useSingleTracksAlsoForMass);
055
056 declareInterface<JetFitterVariablesFactory>(this);
057 }
058
059
060
061
062
063 JetFitterVariablesFactory::~JetFitterVariablesFactory() {}
064
065 StatusCode JetFitterVariablesFactory::initialize() {
066 ATH_MSG_INFO(" Initialization of JetFitterVariablesFactory succesfull");
067 return StatusCode::SUCCESS;
068 }
069
070 StatusCode JetFitterVariablesFactory::finalize() {
071 ATH_MSG_INFO(" Finalization of JetFitterVariablesFactory succesfull");
072 return StatusCode::SUCCESS;
073 }
074
075
076 JetFitterTagInfo* JetFitterVariablesFactory::getITagInfoObject(const Trk::VxJetCandidate & myJetCandidate,
077 const Trk::TwoTrackVerticesInJet* ,
078 const Trk::SelectedTracksInJet* mySelectedTracksInJet,
079 const Jet & myJet) const {
080
081
082 JetFitterTagInfo* myTagInfo=new JetFitterTagInfo(m_jetFitterInstance);
083
084
085
086 const double s_massks=497.648;
087 const double s_pion=139.57018;
088
089 int ntrackPrimaryVtx=myJetCandidate.getPrimaryVertex()->getTracksAtVertex().size();
090 double energyFromPrimary=0.;
091 double energyFromSecondary=0.;
092
093 int nVTX(0);
094 int nTracksAtVtx(0);
095 int nSingleTracks(0);
096 double energyFraction(0);
097 double mass(0);
098 double significance3d(0);
099 double deltaphi(0.);
100 double deltaeta(0.);
101
102 if (mySelectedTracksInJet!=0)
103 {
104 ATH_MSG_DEBUG(" Adding the tracks from primary vertex information ");
105 const std::vector<const Trk::ITrackLink*> & myPrimaryLinks=mySelectedTracksInJet->getPrimaryTrackLinks();
106
107 std::vector<const Trk::ITrackLink*>::const_iterator myPrimaryLinksBegin=myPrimaryLinks.begin();
108 std::vector<const Trk::ITrackLink*>::const_iterator myPrimaryLinksEnd=myPrimaryLinks.end();
109
110 for(std::vector<const Trk::ITrackLink*>::const_iterator myPrimaryLinksIter=myPrimaryLinksBegin;
111 myPrimaryLinksIter!=myPrimaryLinksEnd;
112 ++myPrimaryLinksIter)
113 {
114 ntrackPrimaryVtx+=1;
115 const Trk::ParametersBase * myParameters=(*myPrimaryLinksIter)->parameters();
116 if (myParameters)
117 {
118 energyFromPrimary+=TMath::Sqrt(s_pion*s_pion+myParameters->momentum().mag2());
119 }
120 else
121 {
122 ATH_MSG_WARNING(" no perigee in track for energy computation. Skipping primary track...");
123 }
124 }
125 } else
126 {
127 ATH_MSG_DEBUG(" No information about further primary tracks available. Normal in JetFitter vs. 1");
128 }
129
130
131 const Trk::RecVertexPositions & recVertexPositions=myJetCandidate.getRecVertexPositions();
132 const HepVector & vertexPosition=recVertexPositions.position();
133 const HepSymMatrix & vertexCovMatrix=recVertexPositions.errorPosition().covariance();
134
135 Hep3Vector primaryPos(vertexPosition[Trk::jet_xv],
136 vertexPosition[Trk::jet_yv],
137 vertexPosition[Trk::jet_zv]);
138
139 Hep3Vector jetDir(1,1,1);
140 jetDir.setPhi(vertexPosition[Trk::jet_phi]);
141 jetDir.setTheta(vertexPosition[Trk::jet_theta]);
142
143 HepLorentzVector JetVector = myJet.hlv();
144
145
146 const std::vector<Trk::VxTrackAtVertex*> & TracksAtPrimary=myJetCandidate.getPrimaryVertex()->getTracksAtVertex();
147 const std::vector<Trk::VxTrackAtVertex*>::const_iterator TracksAtPrimaryBegin=TracksAtPrimary.begin();
148 const std::vector<Trk::VxTrackAtVertex*>::const_iterator TracksAtPrimaryEnd=TracksAtPrimary.end();
149
150 for (std::vector<Trk::VxTrackAtVertex*>::const_iterator TracksAtPrimaryIter=TracksAtPrimaryBegin;
151 TracksAtPrimaryIter!=TracksAtPrimaryEnd;
152 ++TracksAtPrimaryIter) {
153
154 if (dynamic_cast<const Trk::MeasuredPerigee*>((*TracksAtPrimaryIter)->perigeeAtVertex())!=0)
155 {
156
157 energyFromPrimary+=
158 TMath::Sqrt(s_pion*s_pion+
159 (*TracksAtPrimaryIter)->perigeeAtVertex()->momentum().mag2());
160 }
161 else if (dynamic_cast<const Trk::MeasuredNeutralPerigee*>((*TracksAtPrimaryIter)->perigeeAtVertex())!=0)
162 {
163 ATH_MSG_VERBOSE(" Found KS pointing to primary vertex. Considering the correct mass. ");
164 energyFromPrimary+=
165 TMath::Sqrt(s_massks*s_massks+
166 (*TracksAtPrimaryIter)->perigeeAtVertex()->momentum().mag2());
167 } else
168 {
169 ATH_MSG_ERROR(" Track is not a normal track neither a KS. This is an ERROR (ask developer to fix it). Skipping track... ");
170 }
171 }
172
173
174
175
176 Hep3Vector sumPAllVertices(0.,0.,0.);
177 HepLorentzVector massVector(0,0,0,0);
178 double sumPtAdd(0.);
179
180 double dist(0.);
181 double inverrordist(0.);
182
183
184 std::vector<Trk::VxVertexOnJetAxis*> vectorOfVertices=myJetCandidate.getVerticesOnJetAxis();
185
186
187 std::vector<Trk::VxVertexOnJetAxis*>::iterator vectorOfClustersOfTrackBegin=vectorOfVertices.begin();
188 std::vector<Trk::VxVertexOnJetAxis*>::iterator vectorOfClustersOfTrackEnd=vectorOfVertices.end();
189
190 for (std::vector<Trk::VxVertexOnJetAxis*>::const_iterator vectorOfClustersOfTrackIter=vectorOfClustersOfTrackBegin;
191 vectorOfClustersOfTrackIter!=vectorOfClustersOfTrackEnd;
192 ++vectorOfClustersOfTrackIter) {
193
194 const std::vector<Trk::VxTrackAtVertex*> & tracksOfVertex=(*vectorOfClustersOfTrackIter)->getTracksAtVertex();
195
196 int vertexSize=tracksOfVertex.size();
197 int ntrack=(*vectorOfClustersOfTrackIter)->getNumVertex()+5;
198
199 if (vertexPosition[ntrack]>0) {
200 if (vertexSize>1) {
201 nVTX+=1;
202 nTracksAtVtx+=vertexSize;
203 } else {
204 nSingleTracks+=1;
205 }
206 }
207 }
208
209 for (std::vector<Trk::VxVertexOnJetAxis*>::const_iterator vectorOfClustersOfTrackIter=vectorOfClustersOfTrackBegin;
210 vectorOfClustersOfTrackIter!=vectorOfClustersOfTrackEnd;
211 ++vectorOfClustersOfTrackIter) {
212
213 const std::vector<Trk::VxTrackAtVertex*> & tracksOfVertex=(*vectorOfClustersOfTrackIter)->getTracksAtVertex();
214 std::vector<Trk::VxTrackAtVertex*>::const_iterator clustersOfTrackBegin=tracksOfVertex.begin();
215 std::vector<Trk::VxTrackAtVertex*>::const_iterator clustersOfTrackEnd=tracksOfVertex.end();
216
217 int vertexSize=tracksOfVertex.size();
218
219 int ntrack=(*vectorOfClustersOfTrackIter)->getNumVertex()+5;
220
221
222
223 if (vertexPosition[ntrack]<0) {
224 if (m_addNegativeTracksToPrimaryVertex)
225 {
226 ntrackPrimaryVtx+=vertexSize;
227 for (std::vector<Trk::VxTrackAtVertex*>::const_iterator clustersOfTrackIter=clustersOfTrackBegin;
228 clustersOfTrackIter!=clustersOfTrackEnd;++clustersOfTrackIter) {
229
230 energyFromPrimary+=
231 TMath::Sqrt(s_pion*s_pion+pow((*clustersOfTrackIter)->perigeeAtVertex()->momentum().mag(),2));
232 }
233 }
234 } else {
235
236 if ( (nVTX>0 && vertexSize>1) || nVTX==0 ) {
237 dist+=vertexPosition[ntrack]/vertexCovMatrix[ntrack][ntrack];
238 inverrordist+=1./vertexCovMatrix[ntrack][ntrack];
239 }
240
241 Hep3Vector sumP(0.,0.,0.);
242 HepLorentzVector massThisCluster(0.,0.,0.,0.);
243
244
245
246 for (std::vector<Trk::VxTrackAtVertex*>::const_iterator clustersOfTrackIter=clustersOfTrackBegin;
247 clustersOfTrackIter!=clustersOfTrackEnd;
248 ++clustersOfTrackIter) {
249
250
251 const Trk::ParametersBase* aMeasPer=(*clustersOfTrackIter)->perigeeAtVertex();
252
253
254 Trk::GlobalMomentum mytrack(aMeasPer->momentum());
255 sumP+=Hep3Vector(mytrack);
256 if (dynamic_cast<const Trk::MeasuredPerigee*>((*clustersOfTrackIter)->perigeeAtVertex())!=0)
257 {
258 massThisCluster+=HepLorentzVector(TMath::Sqrt(s_pion*s_pion+mytrack.mag()*mytrack.mag()),mytrack);
259 }
260 else if (dynamic_cast<const Trk::MeasuredNeutralPerigee*>((*clustersOfTrackIter)->perigeeAtVertex())!=0)
261 {
262 ATH_MSG_VERBOSE(" Found KS in one vertex. Adding the correct KS mass! ");
263 massThisCluster+=HepLorentzVector(TMath::Sqrt(s_massks*s_massks+mytrack.mag()*mytrack.mag()),mytrack);
264 if (nVTX>0)
265 {
266 nTracksAtVtx+=1;
267 }
268 }
269 else
270 {
271 ATH_MSG_ERROR(" Track is not a normal track neither a KS. This is an ERROR (ask developer to fix it). Skipping track... ");
272 }
273 }
274
275
276 sumPAllVertices+=sumP;
277 double ptadd=sumP.perp(jetDir.unit());
278 double masswithneutrals=TMath::Sqrt(massThisCluster.mag2()+ptadd*ptadd)+ptadd;
279
280 if (m_useSingleTracksAlsoForMass)
281 {
282 massVector+=massThisCluster;
283 }
284 else
285 {
286 if ( (nVTX>0 && vertexSize>1) || nVTX==0 ) {
287 massVector+=massThisCluster;
288 sumPtAdd+=ptadd;
289 }
290 }
291
292
293 if (m_usePtCorrectedEnergy)
294 {
295 energyFromSecondary+=TMath::Sqrt(masswithneutrals*masswithneutrals+
296 sumP.mag2());
297 }
298 else
299 {
300 energyFromSecondary+=TMath::Sqrt(massThisCluster.mag2()+
301 sumP.mag2());
302 }
303
304
305
306
307 }
308 }
309
310 if (energyFromSecondary+energyFromPrimary>0) {
311 energyFraction=energyFromSecondary/(energyFromSecondary+energyFromPrimary);
312 }
313
314 if (massVector.mag()>0) {
315 if (m_usePtCorrectedMass)
316 {
317 mass=TMath::Sqrt(massVector.mag2()+sumPtAdd*sumPtAdd)+sumPtAdd;
318 }
319 else
320 {
321 mass=massVector.mag();
322 }
323
324
325 if (mass>5000.) {
326 mass =
327 5000.+5000./TMath::Pi()*2.*TMath::ATan(TMath::Pi()/2./5000.*(mass-5000.));
328 }
329 }
330
331 if (inverrordist!=0) {
332 significance3d=dist/TMath::Sqrt(inverrordist);
333
334 significance3d=100./(TMath::Pi()/2.)*TMath::ATan(TMath::Pi()/2./100.*significance3d);
335 }
336
337 if (fabs(sumPAllVertices.mag())>1e-7) {
338 deltaphi=sumPAllVertices.pseudoRapidity()-JetVector.pseudoRapidity();
339 deltaeta=sumPAllVertices.deltaPhi(JetVector);
340 } else {
341 deltaphi=-10.;
342 deltaeta=-10.;
343 }
344
345
346 myTagInfo->setnVTX(nVTX);
347 myTagInfo->setnSingleTracks(nSingleTracks);
348 myTagInfo->setnTracksAtVtx(nTracksAtVtx);
349 myTagInfo->setMass(mass);
350 myTagInfo->setEnergyFraction(energyFraction);
351 myTagInfo->setSignificance3d(significance3d);
352 myTagInfo->setDeltaeta(deltaeta);
353 myTagInfo->setDeltaphi(deltaphi);
354
355 return myTagInfo;
356 }
357
358 }
359
| Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems |
|
This page was automatically generated by the
LXR engine.
|
|