ATLAS Offline Software
TauTrackFinder.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef XAOD_ANALYSIS
8 
9 #include "xAODTau/TauJet.h"
11 
12 #include "TauTrackFinder.h"
13 #include "tauRecTools/TrackSort.h"
14 
15 
16 TauTrackFinder::TauTrackFinder(const std::string& name) :
18  m_EMSamplings {CaloSampling::EME1, CaloSampling::EMB1},
20 {
21 }
22 
24 }
25 
26 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
28 
29  // retrieve tools
30  ATH_CHECK( m_trackSelectorTool_tau.retrieve() );
31  ATH_CHECK( m_trackToVertexTool.retrieve() );
32  ATH_CHECK( m_caloExtensionTool.retrieve() );
34 
35  // initialize ReadHandleKey
37  // use CaloExtensionTool when key is empty
39  // allow empty for LRT
41 
42  if(m_useGhostTracks) {
43  if(inTrigger()) {
44  ATH_MSG_ERROR ("Ghost matching is not a valid tau-track association scheme for trigger, use cone association. Aborting.");
45  return StatusCode::FAILURE;
46  }
47  ATH_MSG_INFO ("Using ghost matching for tau-track association" << m_ghostTrackDR );
48  // allow empty for trigger
50  }
51 
53 
54  return StatusCode::SUCCESS;
55 }
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
59 
60  std::vector<const xAOD::TrackParticle*> tauTracks;
61  std::vector<const xAOD::TrackParticle*> wideTracks;
62  std::vector<const xAOD::TrackParticle*> otherTracks;
63 
64  //Retrieve standard track container
65  const xAOD::TrackParticleContainer* trackParticleCont = nullptr;
66 
68  if (!trackPartInHandle.isValid()) {
69  ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << trackPartInHandle.key());
70  return StatusCode::FAILURE;
71  }
72  trackParticleCont = trackPartInHandle.cptr();
73 
74  //Retrieve LRT container
75  const xAOD::TrackParticleContainer* largeD0TracksParticleCont = nullptr;
76  std::vector<const xAOD::TrackParticle*> vecTrksLargeD0;
79  if (!trackPartInHandle.isValid()) {
80  ATH_MSG_VERBOSE ("Could not retrieve HiveDataObj with key " << trackPartInHandle.key());
81  ATH_MSG_VERBOSE ("LRT container " << trackPartInHandle.key()<<" is not being used for tau tracks");
82  }
83  else {
84  largeD0TracksParticleCont = trackPartInHandle.cptr();
85  vecTrksLargeD0 = std::vector<const xAOD::TrackParticle*>(largeD0TracksParticleCont->begin(), largeD0TracksParticleCont->end());
86  }
87  }
88 
89 
90 
91  // retrieve the seed jet container when using ghost-matching
92  const xAOD::JetContainer* jetContainer = nullptr;
93  if (! m_jetContainer.empty()) {
95  if (!jetContHandle.isValid()) {
96  ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << jetContHandle.key());
97  return StatusCode::FAILURE;
98  }
99  jetContainer = jetContHandle.cptr();
100  }
101  // in EleRM reco, we need the original track particles
102  std::vector<const xAOD::TrackParticle*> vecTrks;
103  vecTrks.reserve( trackParticleCont->size() );
104  for (auto trk : *trackParticleCont){
105  if (!inEleRM()) { vecTrks.push_back(trk); }
106  else{
107  static const SG::ConstAccessor<ElementLink<xAOD::TrackParticleContainer>> acc_originalObject("ERMOriginalTrack");
108  auto original_id_track_link = acc_originalObject(*trk);
109  if (!original_id_track_link.isValid()) {
110  ATH_MSG_ERROR("Original track link is not valid");
111  continue;
112  }
113  vecTrks.push_back(*original_id_track_link);
114  }
115  }
116 
117  // get the primary vertex
118  const xAOD::Vertex* pVertex = pTau.vertex();
119 
120  // retrieve tracks wrt a vertex
121  // as a vertex is used: tau origin / PV / beamspot / 0,0,0 (in this order, depending on availability)
122 
123  getTauTracksFromPV(pTau, vecTrks, pVertex, m_useGhostTracks, jetContainer, tauTracks, wideTracks, otherTracks);
124 
125  bool foundLRTCont = bool (largeD0TracksParticleCont != nullptr);
126  // additional LRT with vertex association added to tracks
127  if (foundLRTCont){
128  // for now, use cone association for LRTs, not ghost association
129  getTauTracksFromPV(pTau, vecTrksLargeD0, pVertex, false, nullptr, tauTracks, wideTracks, otherTracks);
130  }
131 
132  // remove core and wide tracks outside a maximal delta z0 wrt lead core track
133  if (m_applyZ0cut) {
134  this->removeOffsideTracksWrtLeadTrk(tauTracks, wideTracks, otherTracks, pVertex, m_z0maxDelta);
135  }
136 
138  bool alreadyUsed = false;
139  for (std::vector<const xAOD::TrackParticle*>::iterator track_it = tauTracks.begin(); track_it != tauTracks.end() ;)
140  {
141  alreadyUsed = false;
142  //loop over all up-to-now core tracks
143  for( const xAOD::TauTrack* tau_trk : tauTrackCon ) {
144  //originally it was coreTrack&passTrkSelector
146  if( (*track_it) == tau_trk->track()) alreadyUsed = true;
147  }
148  //if this track has already been used by another tau, don't associate it to this new one
149  if(alreadyUsed) ATH_MSG_INFO( "Found Already Used track new, now removing: " << *track_it );
150  if (alreadyUsed) track_it = tauTracks.erase(track_it);
151  else ++track_it;
152  }
153  }
154 
155  // associate track to tau candidate and calculate charge
156  float charge = 0.;
157  for (unsigned int i = 0; i < tauTracks.size(); ++i) {
158  const xAOD::TrackParticle* trackParticle = tauTracks.at(i);
159 
160  ATH_MSG_VERBOSE(name() << " adding core track nr: " << i
161  << " eta " << trackParticle->eta()
162  << " phi " << trackParticle->phi());
163 
164  charge += trackParticle->charge();
165 
167  tauTrackCon.push_back(track);
168 
169  ElementLink<xAOD::TrackParticleContainer> linkToTrackParticle;
170  linkToTrackParticle.toContainedElement(*static_cast<const xAOD::TrackParticleContainer*>(trackParticle->container()), trackParticle);
171  if (foundLRTCont && isLargeD0Track(trackParticle)){//Check LRT track and link to container
173  }
174  else {
176  }
177  track->addTrackLink(linkToTrackParticle);
178 
179  track->setP4(trackParticle->pt(), trackParticle->eta(), trackParticle->phi(), trackParticle->m());
182  // in case TrackClassifier is not run, still get sensible results
185 
187  linkToTauTrack.toContainedElement(tauTrackCon, track);
188  pTau.addTauTrackLink(linkToTauTrack);
189 
190  ATH_MSG_VERBOSE(name() << " added core track nr: " << i
191  << " eta " << pTau.track(i)->eta()
192  << " phi " << pTau.track(i)->phi());
193  }
194  // set the charge, which is defined by the core tau tracks only
195  pTau.setCharge(charge);
196 
197  for (unsigned int i = 0; i < wideTracks.size(); ++i) {
198  const xAOD::TrackParticle* trackParticle = wideTracks.at(i);
199 
200  ATH_MSG_VERBOSE(name() << " adding wide track nr: " << i
201  << " eta " << trackParticle->eta()
202  << " phi " << trackParticle->phi());
203 
205  tauTrackCon.push_back(track);
206 
207  ElementLink<xAOD::TrackParticleContainer> linkToTrackParticle;
208  linkToTrackParticle.toContainedElement(*static_cast<const xAOD::TrackParticleContainer*>(trackParticle->container()), trackParticle);
209  if (foundLRTCont && isLargeD0Track(trackParticle)){//Check LRT track and link to container
211  }
212  else {
214  }
215  track->addTrackLink(linkToTrackParticle);
216 
217  track->setP4(trackParticle->pt(), trackParticle->eta(), trackParticle->phi(), trackParticle->m());
220  // in case TrackClassifier is not run, still get sensible results
221  track->setFlag(xAOD::TauJetParameters::TauTrackFlag::classifiedIsolation, true); // for sake of trigger, reset in TauTrackClassifier
222  track->setFlag(xAOD::TauJetParameters::TauTrackFlag::modifiedIsolationTrack, true); // for sake of trigger, reset in TauTrackClassifier
224 
226  linkToTauTrack.toContainedElement(tauTrackCon, track);
227  pTau.addTauTrackLink(linkToTauTrack);
228  }
229 
230  //These are set again in TauTrackClassifier
233 
234  for (unsigned int i = 0; i < otherTracks.size(); ++i) {
235  const xAOD::TrackParticle* trackParticle = otherTracks.at(i);
236 
237  ATH_MSG_VERBOSE(name() << " adding other track nr: " << i
238  << " eta " << trackParticle->eta()
239  << " phi " << trackParticle->phi());
240 
242  tauTrackCon.push_back(track);
243 
244  ElementLink<xAOD::TrackParticleContainer> linkToTrackParticle;
245  if (foundLRTCont && isLargeD0Track(trackParticle)){//Check LRT track and link to container
246  linkToTrackParticle.toContainedElement(*static_cast<const xAOD::TrackParticleContainer*>(trackParticle->container()), trackParticle);
248  }
249  else {
250  linkToTrackParticle.toContainedElement(*static_cast<const xAOD::TrackParticleContainer*>(trackParticle->container()), trackParticle);
252  }
253  track->addTrackLink(linkToTrackParticle);
254 
255  track->setP4(trackParticle->pt(), trackParticle->eta(), trackParticle->phi(), trackParticle->m());
256  float dR = track->p4().DeltaR(pTau.p4());
257  if(dR<=0.2) track->setFlag(xAOD::TauJetParameters::TauTrackFlag::coreTrack, true);
260 
262  linkToTauTrack.toContainedElement(tauTrackCon, track);
263  pTau.addTauTrackLink(linkToTauTrack);
264  }
265 
267  // keep track of total number of associated tracks, in case of tau track thinning
269 
270  ATH_MSG_DEBUG("numTrack: " << "/" << pTau.nTracks());
271  ATH_MSG_DEBUG("charge: " << "/" << pTau.charge());
272 
273  // impact parameter variables w.r.t. tau vertex
274  const xAOD::Vertex* vxcand = nullptr;
275 
276  xAOD::Vertex vxbkp;
277  vxbkp.makePrivateStore();
278 
279  // FIXME: don't we want to use the beamspot in the offline reconstruction too, when there is no reconstructed primary vertex?
280  if (pTau.vertex()!=nullptr && pTau.vertex()->vertexType() != xAOD::VxType::NoVtx) {
281  vxcand = pTau.vertex();
282  }
283  else if (inTrigger()) { // online: use vertex with x-y coordinates from the beamspot and the z from the leading track
284  vxbkp.setX(0); vxbkp.setY(0); vxbkp.setZ(0);
285 
287  if(beamSpotHandle.isValid()) {
288  vxbkp.setPosition(beamSpotHandle->beamPos());
289  const auto& cov = beamSpotHandle->beamVtx().covariancePosition();
290  vxbkp.setCovariancePosition(cov);
291 
292  if(!tauTracks.empty()) {
293  vxbkp.setZ(tauTracks.at(0)->z0());
294  }
295  }
296  else {
297  ATH_MSG_DEBUG("No Beamspot object in tau candidate");
298  }
299  vxcand = & vxbkp;
300  }
301 
302 
303  // this could be replaced with TauTrack::setDetail
304  static const SG::Accessor<float> dec_d0TJVA("d0TJVA");
305  static const SG::Accessor<float> dec_z0sinthetaTJVA("z0sinthetaTJVA");
306  static const SG::Accessor<float> dec_d0SigTJVA("d0SigTJVA");
307  static const SG::Accessor<float> dec_z0sinthetaSigTJVA("z0sinthetaSigTJVA");
308 
309  for(const ElementLink<xAOD::TauTrackContainer>& trackLink : pTau.allTauTrackLinks())
310  {
311  assert (trackLink.getStorableObjectPointer() == &tauTrackCon);
312  xAOD::TauTrack* track = tauTrackCon[trackLink.index()];
313  dec_d0TJVA(*track) = track->track()->d0();
314  dec_z0sinthetaTJVA(*track) = track->z0sinThetaTJVA(pTau);
315  dec_d0SigTJVA(*track) = -999.;
316  dec_z0sinthetaSigTJVA(*track) = -999.;
317 
318  // in the trigger, z0sintheta and corresponding significance are meaningless if we use the beamspot
319  if(vxcand) {
320  std::unique_ptr<const Trk::ImpactParametersAndSigma> myIPandSigma
321  = std::unique_ptr<const Trk::ImpactParametersAndSigma>(m_trackToVertexIPEstimator->estimate(track->track(), vxcand));
322 
323  if(myIPandSigma) {
324  dec_d0TJVA(*track) = myIPandSigma->IPd0;
325  dec_z0sinthetaTJVA(*track) = myIPandSigma->IPz0SinTheta;
326  dec_d0SigTJVA(*track) = (myIPandSigma->sigmad0 != 0.) ? (float)( myIPandSigma->IPd0 / myIPandSigma->sigmad0 ) : -999.;
327  dec_z0sinthetaSigTJVA(*track) = (myIPandSigma->sigmaz0SinTheta != 0.) ? (float)( myIPandSigma->IPz0SinTheta / myIPandSigma->sigmaz0SinTheta ) : -999.;
328  }
329  }
330  }
331 
332  // extrapolate core tracks to calorimeter surface
333  // store information only in ExtraDetailsContainer
335  {
336  StatusCode sc = extrapolateToCaloSurface(pTau, tauTrackCon);
337  if (sc.isFailure() && !sc.isRecoverable()) {
338  ATH_MSG_ERROR("couldn't extrapolate tracks to calo surface");
339  return StatusCode::FAILURE;
340  }
341  }
342 
343  return StatusCode::SUCCESS;
344 }
345 
346 
347 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
349  const xAOD::TrackParticle& trackParticle,
350  const xAOD::Vertex* primaryVertex) const
351 {
352  double dR = pTau.p4().DeltaR(trackParticle.p4());
353 
354  if (dR > m_maxJetDr_wide) return NotTauTrack;
355 
356  bool goodTrack = true;
357  if(!m_bypassSelector)
358  goodTrack = m_trackSelectorTool_tau->decision(trackParticle, primaryVertex);
359 
360  if (goodTrack) {
361  if (dR > m_maxJetDr_tau)
362  return TauTrackWide;
363  else
364  return TauTrackCore;
365  } else
366  return TauTrackOther;
367 }
368 
369 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
371  const std::vector<const xAOD::TrackParticle*>& vecTrackParticles,
372  const xAOD::Vertex* primaryVertex,
373  const bool& useGhostTracks,
374  const xAOD::JetContainer* jetContainer,
375  std::vector<const xAOD::TrackParticle*> &tauTracks,
376  std::vector<const xAOD::TrackParticle*> &wideTracks,
377  std::vector<const xAOD::TrackParticle*> &otherTracks) const
378 {
379  std::vector<const xAOD::TrackParticle*> ghostTracks;
380  if(useGhostTracks) {
381  const xAOD::Jet* seedJet = pTau.jet();
382  if(seedJet) {
383  if(!seedJet->getAssociatedObjects("GhostTrack", ghostTracks)) {
384  ATH_MSG_WARNING("Could not retrieve GhostTrack from seed jet.");
385  }
386  }
387  }
388  // in EleRM reco, we need the original track particles
389  if (inEleRM()){
390  for (uint i = 0; i < ghostTracks.size(); i++){
391  static const SG::ConstAccessor<ElementLink<xAOD::TrackParticleContainer>> acc_originalTrack("ERMOriginalTrack");
392  auto original_id_track_link = acc_originalTrack(*(ghostTracks[i]));
393  if (!original_id_track_link.isValid()) {
394  ATH_MSG_ERROR("Original track link is not valid");
395  continue;
396  }
397  ghostTracks[i] = *original_id_track_link;
398  }
399  }
400 
401  for (const xAOD::TrackParticle *trackParticle : vecTrackParticles) {
402  TauTrackType type = tauTrackType(pTau, *trackParticle, primaryVertex);
403  if(type == NotTauTrack) continue;
404 
405  if(useGhostTracks) {
406  // require that tracks are ghost-matched with the seed jet at large dR(tau,track), to avoid using tracks from another tau
407  double dR = pTau.p4().DeltaR(trackParticle->p4());
408  if (dR > m_ghostTrackDR) {
409  if (std::find(ghostTracks.begin(), ghostTracks.end(), trackParticle) == ghostTracks.end()) {
410  // check whether the jet closest to the track is the current seed jet
411  // if so, recover the track even if not ghost-matched, to improve tau-track association efficiency at low pt (esp. for 3p)
412  double dRmin = 999.;
413  bool isSeedClosest = false;
414  for (const xAOD::Jet* jet : *jetContainer) {
416  TLorentzVector jetLV;
417  jetLV.SetPtEtaPhiM(jetP4.Pt(), jetP4.Eta(), jetP4.Phi(), jetP4.M());
418  double dRjet = trackParticle->p4().DeltaR(jetLV);
419  if(dRjet < dRmin) {
420  dRmin = dRjet;
421  isSeedClosest = (jet == pTau.jet());
422  }
423  }
424  if(!isSeedClosest) continue;
425  }
426  }
427  }
428 
429  if (type == TauTrackCore)
430  tauTracks.push_back(trackParticle);
431  else if (type == TauTrackWide)
432  wideTracks.push_back(trackParticle);
433  else if (type == TauTrackOther)
434  otherTracks.push_back(trackParticle);
435  }
436  std::sort(tauTracks.begin(), tauTracks.end(), TrackSort());
437  std::sort(wideTracks.begin(), wideTracks.end(), TrackSort());
438  std::sort(otherTracks.begin(), otherTracks.end(), TrackSort());
439 }
440 
441 
442 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
444  xAOD::TauTrackContainer& tauTrackCon) const
445 {
446  Trk::TrackParametersIdHelper parsIdHelper;
447 
448  int trackIndex = -1;
449  const Trk::CaloExtension * caloExtension = nullptr;
450  std::unique_ptr<Trk::CaloExtension> uniqueExtension;
451  for(const ElementLink<xAOD::TauTrackContainer>& trackLink : pTau.allTauTrackLinks())
452  {
453  assert (trackLink.getStorableObjectPointer() == &tauTrackCon);
454  xAOD::TauTrack* tauTrack = tauTrackCon[trackLink.index()];
455  const xAOD::TrackParticle *orgTrack = tauTrack->track();
456  if( !orgTrack ) continue;
457  trackIndex = orgTrack->index();
458 
459  // set default values
460  float etaEM = -10.0;
461  float phiEM = -10.0;
462  float etaHad = -10.0;
463  float phiHad = -10.0;
464 
465  // get the extrapolation into the calo
466  ATH_MSG_DEBUG( "Try extrapolation of track with pt = " << orgTrack->pt()
467  << ", eta " << orgTrack->eta()
468  << ", phi" << orgTrack->phi() );
469 
470  if(!m_ParticleCacheKey.key().empty()){
471  /*get the CaloExtension object*/
472  ATH_MSG_VERBOSE("Using the CaloExtensionBuilder Cache");
474  caloExtension = (*particleCache)[trackIndex];
475  ATH_MSG_VERBOSE("Getting element " << trackIndex << " from the particleCache");
476  if( not caloExtension ){
477  ATH_MSG_VERBOSE("Cache does not contain a calo extension -> "
478  "Calculating with the a CaloExtensionTool");
479  uniqueExtension = m_caloExtensionTool->caloExtension(
480  Gaudi::Hive::currentContext(), *orgTrack);
481  caloExtension = uniqueExtension.get();
482  }
483  }
484  else {
485  /* If CaloExtensionBuilder is unavailable, use the calo extension tool */
486  ATH_MSG_VERBOSE("Using the CaloExtensionTool");
487  uniqueExtension = m_caloExtensionTool->caloExtension(
488  Gaudi::Hive::currentContext(), *orgTrack);
489  caloExtension = uniqueExtension.get();
490  }
491 
492  if (!caloExtension)
493  {
494  ATH_MSG_DEBUG("Track extrapolation failed");
495  }
496  else {
497  const std::vector<Trk::CurvilinearParameters>& clParametersVector = caloExtension->caloLayerIntersections();
498  if (clParametersVector.empty()) {
499  ATH_MSG_DEBUG("Track extrapolation failed");
500  }
501 
502  ATH_MSG_DEBUG("Scanning samplings");
503  bool validECal = false;
504  bool validHCal = false;
505  for( const Trk::CurvilinearParameters& cur : clParametersVector ){
506  ATH_MSG_DEBUG("Sampling " << parsIdHelper.caloSample(cur.cIdentifier()) );
507 
508  // only use entry layer
509  if( not parsIdHelper.isEntryToVolume(cur.cIdentifier()) ) continue;
510 
511  CaloSampling::CaloSample sample = parsIdHelper.caloSample(cur.cIdentifier());
512 
513  // ECal
514  if( not validECal and m_EMSamplings.count(sample))
515  {
516  validECal = true;
517  etaEM = cur.position().eta();
518  phiEM = cur.position().phi();
519  ATH_MSG_DEBUG("Extrapolated to ECal layer " << sample);
520  }
521 
522  // HCal
523  if( not validHCal and m_HadSamplings.count(sample))
524  {
525  validHCal = true;
526  etaHad = cur.position().eta();
527  phiHad = cur.position().phi();
528  ATH_MSG_DEBUG("Extrapolated to HCal layer " << sample);
529  }
530  if( validECal and validHCal ) break;
531  }
532  // EM failure warn if within acceptance
533  if( not validECal and std::abs(orgTrack->pt()) < 2.48 ){
534  ATH_MSG_DEBUG("Failed extrapolation to ECal");
535  }
536  // Had failure warn if enough pt to reach HCal
537  if( not validHCal and orgTrack->pt() > 2000. ){
538  ATH_MSG_DEBUG("Failed extrapolation to HCal");
539  }
540 
541  ATH_MSG_DEBUG( "Extrapolated track with eta=" << orgTrack->eta()
542  << " phi="<<orgTrack->phi()
543  << " to ECal eta=" << etaEM
544  << " phi="<< phiEM
545  << " HCal eta=" << etaHad
546  << " phi="<< phiHad
547  );
548  }
553  }
554 
555  return StatusCode::SUCCESS;
556 
557 }
558 
559 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
560 void TauTrackFinder::removeOffsideTracksWrtLeadTrk(std::vector<const xAOD::TrackParticle*> &tauTracks,
561  std::vector<const xAOD::TrackParticle*> &wideTracks,
562  std::vector<const xAOD::TrackParticle*> &otherTracks,
563  const xAOD::Vertex* tauOrigin,
564  double maxDeltaZ0) const
565 {
566  float MAX=1e5;
567 
568  // need at least one core track to have a leading trk to compare with
569  if (tauTracks.empty()) return;
570 
571  // get lead trk parameters
572  const xAOD::TrackParticle *leadTrack = tauTracks.at(0);
573  float z0_leadTrk = getZ0(leadTrack, tauOrigin);
574 
575  if (z0_leadTrk > MAX-1) return; // bad lead trk -> do nothing
576 
577  ATH_MSG_VERBOSE("before z0 cut: #coreTracks=" << tauTracks.size() << ", #wideTracks=" << wideTracks.size() << ", #otherTracks=" << otherTracks.size());
578 
580 
581  // skip leading track, because it is the reference
582  itr = tauTracks.begin()+1;
583  while (itr!=tauTracks.end()) {
584  float z0 = getZ0(*itr, tauOrigin);
585  float deltaZ0=z0 - z0_leadTrk;
586  ATH_MSG_VERBOSE("core Trks: deltaZ0= " << deltaZ0);
587 
588  if ( std::abs(deltaZ0) < maxDeltaZ0 ) {++itr;}
589  else {
590  if (m_storeInOtherTrks) otherTracks.push_back(*itr);
591  itr = tauTracks.erase(itr); //remove from core track collection
592  }
593  }
594 
595  // check wide tracks
596  itr = wideTracks.begin();
597  while (itr!=wideTracks.end()) {
598  float z0 = getZ0(*itr, tauOrigin);
599  float deltaZ0=z0 - z0_leadTrk;
600  ATH_MSG_VERBOSE("wide Trks: deltaZ0= " << deltaZ0);
601 
602  if ( std::abs(deltaZ0) < maxDeltaZ0 ) { ++itr; }
603  else {
604  if (m_storeInOtherTrks) otherTracks.push_back(*itr);
605  itr = wideTracks.erase(itr); //remove from wide track collection
606  }
607  }
608 
609  ATH_MSG_VERBOSE("after z0 cut: #coreTracks=" << tauTracks.size() << ", #wideTracks=" << wideTracks.size() << ", #otherTracks=" << otherTracks.size());
610 
611  // sort again
612  std::sort(tauTracks.begin(), tauTracks.end(), TrackSort());
613  std::sort(wideTracks.begin(), wideTracks.end(), TrackSort());
614  std::sort(otherTracks.begin(), otherTracks.end(), TrackSort());
615 }
616 
617 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
619 {
620  float MAX=1e5;
621 
622  if (!track) return MAX;
623 
624  std::unique_ptr<Trk::Perigee> perigee;
625  if (vertex) perigee = m_trackToVertexTool->perigeeAtVertex(Gaudi::Hive::currentContext(), *track, vertex->position());
626  else perigee = m_trackToVertexTool->perigeeAtVertex(Gaudi::Hive::currentContext(), *track); //will use beamspot or 0,0,0 instead
627 
628  if (!perigee) {
629  ATH_MSG_WARNING("Bad track; can't find perigee at vertex.");
630  return MAX;
631  }
632 
633  float z0 = perigee->parameters()[Trk::z0];
634 
635  return z0;
636 }
637 
639 {
640  const std::bitset<xAOD::NumberOfTrackRecoInfo> patternReco = track->patternRecoInfo();
642  ATH_MSG_DEBUG("LargeD0Track found");
643  return true;
644  }
645 
646  return false;
647 }
648 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
xAOD::TrackParticle_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: TrackParticle_v1.cxx:73
TauTrackFinder::extrapolateToCaloSurface
StatusCode extrapolateToCaloSurface(xAOD::TauJet &pTau, xAOD::TauTrackContainer &tauTrackCon) const
Extrapolate track eta and phi to the calorimeter middle surface.
Definition: TauTrackFinder.cxx:443
xAOD::Vertex_v1::setPosition
void setPosition(const Amg::Vector3D &position)
Sets the 3-position.
xAOD::TauJetParameters::nIsolatedTracks
@ nIsolatedTracks
Definition: TauDefs.h:323
xAOD::TrackParticle_v1::m
virtual double m() const override final
The invariant mass of the particle..
Definition: TrackParticle_v1.cxx:83
xAOD::TauJet_v3::jet
const Jet * jet() const
TauTrackFinder::TauTrackType
TauTrackType
Enumerator defining type of tau track.
Definition: TauTrackFinder.h:52
constants.EMB1
int EMB1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:53
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
MAX
#define MAX(x, y)
Definition: ALFA_SvdCalc.h:28
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
xAOD::TauJet_v3::nAllTracks
size_t nAllTracks() const
Definition: TauJet_v3.cxx:554
SG::Accessor< float >
TauTrackFinder::m_trackPartInputContainer
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackPartInputContainer
Definition: TauTrackFinder.h:117
Trk::CaloExtension
Tracking class to hold the extrapolation from a particle from the ID to the muon system (or the other...
Definition: CaloExtension.h:18
xAOD::TrackParticle_v1::charge
float charge() const
Returns the charge.
Definition: TrackParticle_v1.cxx:150
beamspotman.cur
def cur
Definition: beamspotman.py:671
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
xAOD::TauJetParameters::CaloSamplingPhiEM
@ CaloSamplingPhiEM
Definition: TauDefs.h:422
xAOD::TrackParticle_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: TrackParticle_v1.cxx:77
CaloCell_ID_FCS::TileBar1
@ TileBar1
Definition: FastCaloSim_CaloCell_ID.h:32
xAOD::TauTrack_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
xAOD::TauJet_v3::setCharge
void setCharge(float)
TauTrackFinder::m_largeD0TracksInputContainer
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_largeD0TracksInputContainer
Definition: TauTrackFinder.h:118
xAOD::TauJet_v3::nTracks
size_t nTracks(TauJetParameters::TauTrackFlag flag=TauJetParameters::TauTrackFlag::classifiedCharged) const
Definition: TauJet_v3.cxx:526
xAOD::TauJetParameters::classifiedCharged
@ classifiedCharged
Definition: TauDefs.h:406
TauRecToolBase
The base class for all tau tools.
Definition: TauRecToolBase.h:21
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
TrackSort
Helper method to sort tracks.
Definition: TrackSort.h:24
TrackSort.h
TauTrackFinder::removeOffsideTracksWrtLeadTrk
void removeOffsideTracksWrtLeadTrk(std::vector< const xAOD::TrackParticle * > &tauTracks, std::vector< const xAOD::TrackParticle * > &wideTracks, std::vector< const xAOD::TrackParticle * > &otherTracks, const xAOD::Vertex *tauOrigin, double maxDeltaZ0) const
Definition: TauTrackFinder.cxx:560
Trk::z0
@ z0
Definition: ParamDefs.h:64
TauTrackFinder::NotTauTrack
@ NotTauTrack
Definition: TauTrackFinder.h:56
xAOD::TauJetParameters::CaloSamplingEtaHad
@ CaloSamplingEtaHad
Definition: TauDefs.h:421
Trk::ImpactParametersAndSigma::IPd0
double IPd0
Definition: ITrackToVertexIPEstimator.h:34
Trk::TrackParametersIdHelper::caloSample
CaloSampling::CaloSample caloSample(TrackParametersIdentifier id) const
CaloSample encoded in id, returns CaloSampling::Unknown if id is not valid
Definition: TrackParametersIdHelper.h:91
TauTrackFinder::m_ghostTrackDR
Gaudi::Property< double > m_ghostTrackDR
Definition: TauTrackFinder.h:115
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
xAOD::TauJetParameters::nAllTracks
@ nAllTracks
Definition: TauDefs.h:325
Trk::ImpactParametersAndSigma::IPz0SinTheta
double IPz0SinTheta
Definition: ITrackToVertexIPEstimator.h:36
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TauTrackContainer.h
TauRecToolBase::inTrigger
bool inTrigger() const
Definition: TauRecToolBase.h:87
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
xAOD::Vertex_v1::setX
void setX(float value)
Sets the x position.
TauTrackFinder::getZ0
float getZ0(const xAOD::TrackParticle *track, const xAOD::Vertex *vertex) const
Some internally used functions.
Definition: TauTrackFinder.cxx:618
xAOD::TauJetParameters::LargeRadiusTrack
@ LargeRadiusTrack
Definition: TauDefs.h:413
Trk::TrackParametersIdHelper::isEntryToVolume
bool isEntryToVolume(TrackParametersIdentifier id) const
returns true if the id belongs to the volume entrance
Definition: TrackParametersIdHelper.h:81
TauTrackFinder.h
xAOD::Vertex_v1::vertexType
VxType::VertexType vertexType() const
The type of the vertex.
xAOD::VxType::NoVtx
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
Definition: TrackingPrimitives.h:570
TauRecToolBase::inEleRM
bool inEleRM() const
Definition: TauRecToolBase.h:89
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
TauTrackFinder::m_z0maxDelta
Gaudi::Property< float > m_z0maxDelta
Definition: TauTrackFinder.h:109
TauTrackFinder::m_bypassExtrapolator
Gaudi::Property< bool > m_bypassExtrapolator
Definition: TauTrackFinder.h:113
xAOD::Jet_v1::getAssociatedObjects
std::vector< const T * > getAssociatedObjects(const std::string &name) const
get associated objects as a vector<object> this compact form throws an exception if the object is not...
xAOD::JetConstitScaleMomentum
@ JetConstitScaleMomentum
Definition: JetTypes.h:29
xAOD::TrackParticle_v1::p4
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
Definition: TrackParticle_v1.cxx:129
TauTrackFinder::m_bypassSelector
Gaudi::Property< bool > m_bypassSelector
Definition: TauTrackFinder.h:112
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
Trk::TrackParametersIdHelper
helper class to encode and decode a TrackParametersIdentifier
Definition: TrackParametersIdHelper.h:18
xAOD::TauJetParameters::passTrkSelector
@ passTrkSelector
Definition: TauDefs.h:405
xAOD::Vertex_v1::setZ
void setZ(float value)
Sets the z position.
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
CaloCell_ID_FCS::HEC1
@ HEC1
Definition: FastCaloSim_CaloCell_ID.h:28
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrackParametersIdHelper.h
xAOD::Vertex_v1::setY
void setY(float value)
Sets the y position.
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:113
lumiFormat.i
int i
Definition: lumiFormat.py:85
xAOD::TauJet_v3::allTauTrackLinks
const TauTrackLinks_t & allTauTrackLinks() const
Definition: TauJet_v3.cxx:420
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::TauJetParameters::nLargeRadiusTracks
@ nLargeRadiusTracks
Definition: TauDefs.h:326
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
xAOD::TauJetParameters::nChargedTracks
@ nChargedTracks
Definition: TauDefs.h:322
TauTrackFinder::m_applyZ0cut
Gaudi::Property< bool > m_applyZ0cut
Definition: TauTrackFinder.h:108
xAOD::TauJet_v3::track
const TauTrack * track(size_t i, TauJetParameters::TauTrackFlag flag=TauJetParameters::TauTrackFlag::classifiedCharged, int *container_index=0) const
Get the pointer to a given tauTrack associated with this tau /*container index needed by trackNonCons...
Definition: TauJet_v3.cxx:450
TauTrackFinder::TauTrackFinder
TauTrackFinder(const std::string &name)
Constructor and Destructor.
Definition: TauTrackFinder.cxx:16
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
xAOD::TauJet_v3::addTauTrackLink
void addTauTrackLink(const ElementLink< TauTrackContainer > &tr)
add a TauTrack to the tau
Definition: TauJet_v3.cxx:563
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TauTrackFinder::m_storeInOtherTrks
Gaudi::Property< bool > m_storeInOtherTrks
Definition: TauTrackFinder.h:110
Trk::ImpactParametersAndSigma::sigmad0
double sigmad0
Definition: ITrackToVertexIPEstimator.h:37
xAOD::TauJetParameters::coreTrack
@ coreTrack
Definition: TauDefs.h:403
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
Trk::CurvilinearParametersT
Definition: CurvilinearParametersT.h:48
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
xAOD::TauTrack_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
xAOD::SiSpacePointsSeedMaker_LargeD0
@ SiSpacePointsSeedMaker_LargeD0
Definition: TrackingPrimitives.h:183
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TauTrackFinder::m_maxJetDr_tau
Gaudi::Property< double > m_maxJetDr_tau
Definition: TauTrackFinder.h:106
xAOD::TauJetParameters::classifiedIsolation
@ classifiedIsolation
Definition: TauDefs.h:407
TauTrackFinder::m_caloExtensionTool
ToolHandle< Trk::IParticleCaloExtensionTool > m_caloExtensionTool
tools
Definition: TauTrackFinder.h:101
TauTrackFinder::tauTrackType
TauTrackType tauTrackType(const xAOD::TauJet &tauJet, const xAOD::TrackParticle &trackParticle, const xAOD::Vertex *primaryVertex) const
Definition: TauTrackFinder.cxx:348
xAOD::JetFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition: JetTypes.h:17
TauTrackFinder::m_jetContainer
SG::ReadHandleKey< xAOD::JetContainer > m_jetContainer
Definition: TauTrackFinder.h:119
TauTrackFinder::TauTrackCore
@ TauTrackCore
Definition: TauTrackFinder.h:53
xAOD::TauTrack_v1::setDetail
void setDetail(TauJetParameters::TrackDetail detail, float value)
Definition: TauTrack_v1.cxx:178
TauTrackFinder::m_trackSelectorTool_tau
ToolHandle< Trk::ITrackSelectorTool > m_trackSelectorTool_tau
Definition: TauTrackFinder.h:102
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CaloCell_ID_FCS::TileExt1
@ TileExt1
Definition: FastCaloSim_CaloCell_ID.h:38
TauTrackFinder::m_trackToVertexIPEstimator
ToolHandle< Trk::ITrackToVertexIPEstimator > m_trackToVertexIPEstimator
Definition: TauTrackFinder.h:104
charge
double charge(const T &p)
Definition: AtlasPID.h:756
TauTrackFinder::isLargeD0Track
bool isLargeD0Track(const xAOD::TrackParticle *track) const
Definition: TauTrackFinder.cxx:638
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:192
TauTrackFinder::TauTrackOther
@ TauTrackOther
Definition: TauTrackFinder.h:55
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
TauTrackFinder::m_useGhostTracks
Gaudi::Property< bool > m_useGhostTracks
Definition: TauTrackFinder.h:114
xAOD::TauTrack
TauTrack_v1 TauTrack
Definition of the current version.
Definition: TauTrack.h:16
xAOD::TauJetParameters::CaloSamplingPhiHad
@ CaloSamplingPhiHad
Definition: TauDefs.h:423
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
TauTrackFinder::initialize
virtual StatusCode initialize() override
Algorithm functions.
Definition: TauTrackFinder.cxx:27
Trk::ImpactParametersAndSigma::sigmaz0SinTheta
double sigmaz0SinTheta
Definition: ITrackToVertexIPEstimator.h:39
TauTrackFinder::TauTrackWide
@ TauTrackWide
Definition: TauTrackFinder.h:54
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
xAOD::TauJet_v3::vertex
const Vertex * vertex() const
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TauTrackFinder::m_maxJetDr_wide
Gaudi::Property< double > m_maxJetDr_wide
Definition: TauTrackFinder.h:107
xAOD::TauTrack_v1
Definition: TauTrack_v1.h:27
xAOD::TauJet_v3::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: TauJet_v3.cxx:97
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::TauJetParameters::modifiedIsolationTrack
@ modifiedIsolationTrack
Definition: TauDefs.h:412
TauJet.h
TauTrackFinder::executeTrackFinder
virtual StatusCode executeTrackFinder(xAOD::TauJet &pTau, xAOD::TauTrackContainer &tauTrackCon) const override
Definition: TauTrackFinder.cxx:58
xAOD::TauJet_v3::charge
float charge() const
xAOD::TauJet_v3::setDetail
void setDetail(TauJetParameters::Detail detail, int value)
Definition: TauJet_v3.cxx:337
xAOD::TauJetParameters::wideTrack
@ wideTrack
Definition: TauDefs.h:404
TauTrackFinder::getTauTracksFromPV
void getTauTracksFromPV(const xAOD::TauJet &tauJet, const std::vector< const xAOD::TrackParticle * > &vecTrackParticles, const xAOD::Vertex *primaryVertex, const bool &useGhostTracks, const xAOD::JetContainer *jetContainer, std::vector< const xAOD::TrackParticle * > &tauTracks, std::vector< const xAOD::TrackParticle * > &wideTracks, std::vector< const xAOD::TrackParticle * > &otherTracks) const
Definition: TauTrackFinder.cxx:370
xAOD::TauTrack_v1::track
const TrackParticle * track() const
TauTrackFinder::m_trackToVertexTool
ToolHandle< Reco::ITrackToVertex > m_trackToVertexTool
Definition: TauTrackFinder.h:103
TauTrackFinder::~TauTrackFinder
~TauTrackFinder()
Definition: TauTrackFinder.cxx:23
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
SG::AuxElement::container
const SG::AuxVectorData * container() const
Return the container holding this element.
Trk::CaloExtension::caloLayerIntersections
const std::vector< CurvilinearParameters > & caloLayerIntersections() const
access to the intersections with the calorimeter layers.
Definition: CaloExtension.h:76
xAOD::TauJetParameters::CaloSamplingEtaEM
@ CaloSamplingEtaEM
Definition: TauDefs.h:420
ITrackSelectorTool.h
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::Vertex_v1::setCovariancePosition
void setCovariancePosition(const AmgSymMatrix(3)&covariancePosition)
Sets the vertex covariance matrix.
TauTrackFinder::m_beamSpotKey
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
Definition: TauTrackFinder.h:122
TauTrackFinder::m_EMSamplings
std::set< CaloSampling::CaloSample > m_EMSamplings
Definition: TauTrackFinder.h:124
readCCLHist.float
float
Definition: readCCLHist.py:83
TauTrackFinder::m_HadSamplings
std::set< CaloSampling::CaloSample > m_HadSamplings
Definition: TauTrackFinder.h:125
TauTrackFinder::m_removeDuplicateCoreTracks
Gaudi::Property< bool > m_removeDuplicateCoreTracks
Definition: TauTrackFinder.h:111
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
xAOD::TrackParticle_v1::phi
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)
xAOD::TauJetParameters::unclassified
@ unclassified
Definition: TauDefs.h:410
TauTrackFinder::m_ParticleCacheKey
SG::ReadHandleKey< CaloExtensionCollection > m_ParticleCacheKey
Definition: TauTrackFinder.h:120