ATLAS Offline Software
Public Member Functions | Private Attributes | Friends | List of all members
TrigInDetTrackTruthMap Class Reference

#include <TrigInDetTrackTruthMap.h>

Collaboration diagram for TrigInDetTrackTruthMap:

Public Member Functions

 TrigInDetTrackTruthMap ()
 Constructors: POOL needs default constructor. More...
 
virtual ~TrigInDetTrackTruthMap ()
 
void addMatch (const TrigInDetTrackCollection *trkColl, unsigned int trk_indx, TrigInDetTrackTruth &p_trk_tru)
 accessors to fill map More...
 
bool hasTruth (const TrigInDetTrack *p_trig_trk) const
 methods to get truth-match objects More...
 
const TrigInDetTrackTruthtruth (const TrigInDetTrack *p_trig_trk) const
 
const HepMcParticleLinkbestMatchSi (const TrigInDetTrack *p_trig_trk) const
 
const HepMcParticleLinkbestMatchTRT (const TrigInDetTrack *p_trig_trk) const
 
int bestMatchSiHits (const TrigInDetTrack *p_trig_trk) const
 
int bestMatchTRTHits (const TrigInDetTrack *p_trig_trk) const
 
void print () const
 
size_t size () const
 
const TrigInDetTrackTruthtruthi (size_t i) const
 
const ElementLink< TrigInDetTrackCollectiontrackiLink (size_t i) const
 
const TrigInDetTracktracki (size_t i) const
 

Private Attributes

ElementLinkVector< TrigInDetTrackCollectionm_elink_vec
 
std::vector< TrigInDetTrackTruthm_truth_vec
 

Friends

class TrigInDetTrackTruthMapCnv_p1
 
class TrigInDetTrackTruthMap_old_cnv
 

Detailed Description

Definition at line 38 of file TrigInDetTrackTruthMap.h.

Constructor & Destructor Documentation

◆ TrigInDetTrackTruthMap()

TrigInDetTrackTruthMap::TrigInDetTrackTruthMap ( )
inline

Constructors: POOL needs default constructor.

Definition at line 59 of file TrigInDetTrackTruthMap.h.

81  :
82  friend class TrigInDetTrackTruthMapCnv_p1;

◆ ~TrigInDetTrackTruthMap()

virtual TrigInDetTrackTruthMap::~TrigInDetTrackTruthMap ( )
inlinevirtual

Definition at line 65 of file TrigInDetTrackTruthMap.h.

81 :
82  friend class TrigInDetTrackTruthMapCnv_p1;

Member Function Documentation

◆ addMatch()

void TrigInDetTrackTruthMap::addMatch ( const TrigInDetTrackCollection trkColl,
unsigned int  trk_indx,
TrigInDetTrackTruth p_trk_tru 
)

accessors to fill map

Definition at line 32 of file TrigInDetTrackTruthMap.cxx.

35 {
36  std::string thisName("TrigInDetTrackTruthMap::addMatch");
37  MsgStream log(Athena::getMessageSvc(), thisName);
38 
39  log << MSG::DEBUG << "Adding TrigInDetTrack to map" << endmsg;
40 
41  // check entry for this track doesn't exist (otherwise we have a multimap)
42  const TrigInDetTrack* p_trig_trk((*trkColl)[trk_indx]);
43 
44  if ( !hasTruth( p_trig_trk ) ) {
45  ElementLink< TrigInDetTrackCollection > p_trk_lnk(*trkColl,trk_indx);
46  m_elink_vec.push_back(p_trk_lnk);
48  if (!status)
49  log << MSG::DEBUG << "ERROR: could not set ElementLink persistent" << endmsg;
50  m_truth_vec.push_back(p_trk_tru);
51  } else {
52  log << MSG::DEBUG << "TrigInDetTrack already in map!" << endmsg;
53  }
54 }

◆ bestMatchSi()

const HepMcParticleLink * TrigInDetTrackTruthMap::bestMatchSi ( const TrigInDetTrack p_trig_trk) const

Definition at line 114 of file TrigInDetTrackTruthMap.cxx.

115 {
116  if ( hasTruth(p_trig_trk) ) {
117  return ( truth(p_trig_trk)->bestSiMatch() );
118  } else {
119  return NULL;
120  }
121 }

◆ bestMatchSiHits()

int TrigInDetTrackTruthMap::bestMatchSiHits ( const TrigInDetTrack p_trig_trk) const

Definition at line 123 of file TrigInDetTrackTruthMap.cxx.

124 {
125  if ( hasTruth(p_trig_trk) ) {
126  return ( truth(p_trig_trk)->nrCommonHitsBestSi() );
127  } else {
128  return 0;
129  }
130 }

◆ bestMatchTRT()

const HepMcParticleLink * TrigInDetTrackTruthMap::bestMatchTRT ( const TrigInDetTrack p_trig_trk) const

Definition at line 134 of file TrigInDetTrackTruthMap.cxx.

135 {
136  if ( hasTruth(p_trig_trk) ) {
137  return ( truth(p_trig_trk)->bestTRTMatch() );
138  } else {
139  return NULL;
140  }
141 }

◆ bestMatchTRTHits()

int TrigInDetTrackTruthMap::bestMatchTRTHits ( const TrigInDetTrack p_trig_trk) const

Definition at line 143 of file TrigInDetTrackTruthMap.cxx.

144 {
145  if ( hasTruth(p_trig_trk) ) {
146  return ( truth(p_trig_trk)->nrCommonHitsBestTRT() );
147  } else {
148  return 0;
149  }
150 }

◆ hasTruth()

bool TrigInDetTrackTruthMap::hasTruth ( const TrigInDetTrack p_trig_trk) const

methods to get truth-match objects

Definition at line 58 of file TrigInDetTrackTruthMap.cxx.

59 {
60  // must loop over map because ElementLink is a unidirectional link
61  bool found=false;
62  for (unsigned int i=0; i < m_elink_vec.size(); ++i) {
63  // if ( p_trig_trk == *(m_elink_vec[i]) ) {
64  if(!m_elink_vec[i].isValid())
65  continue;
66  if ((*(m_elink_vec[i]))->param()) {
67  if ((*(m_elink_vec[i]))->algorithmId() == p_trig_trk->algorithmId() &&
68  (*(m_elink_vec[i]))->param()->pT() == p_trig_trk->param()->pT() &&
69  (*(m_elink_vec[i]))->param()->eta() == p_trig_trk->param()->eta() &&
70  (*(m_elink_vec[i]))->param()->phi0() == p_trig_trk->param()->phi0()) {
71  found=true;
72  break;
73  }
74  }
75  }
76  // true if this track pointer exists at least once in the vector
77  return (found);
78 }

◆ print()

void TrigInDetTrackTruthMap::print ( ) const

Definition at line 153 of file TrigInDetTrackTruthMap.cxx.

154 {
155  std::string thisName("TrigInDetTrackTruthMap::print");
156  MsgStream log(Athena::getMessageSvc(), thisName);
157 
158  std::ostringstream oss;
159  oss << "TrigInDetTruthMap: " << m_elink_vec.size()
160  << " track-truth associations" << std::endl;
161 
162  oss << "---------------------------------------------------------------------------------------------------------------------------------" << std::endl;
163  oss << "#track|algo| pointer | pT | eta | phi |#match|mother|Sihits|TRThits|ev.index| barcode | pdg id | pT | eta | phi |"<< std::endl;
164  for (unsigned int i=0; i < m_elink_vec.size(); ++i) {
165  oss << std::setiosflags(std::ios::dec) << std::setw(6) << i << "|"
166  << std::setiosflags(std::ios::dec) << std::setw(4) << (*(m_elink_vec[i]))->algorithmId() << "|"
167  << std::setw(11) << *(m_elink_vec[i]) << "|";
168 
169  if(!m_elink_vec[i].isValid()) {
170  oss << std::setiosflags(std::ios::dec) << "Invalid TrigInDetTrack link !"
171  << std::setiosflags(std::ios::dec) << std::setw(8) << "|";
172  }
173  else {
174  // print reconstructed track parameters
175  if ((*(m_elink_vec[i]))->param()) {
176  oss << std::setiosflags(std::ios::dec) << std::setw(14) << (*(m_elink_vec[i]))->param()->pT() << "|"
177  << std::setiosflags(std::ios::dec) << std::setw(10) << (*(m_elink_vec[i]))->param()->eta() << "|"
178  << std::setiosflags(std::ios::dec) << std::setw(10) << (*(m_elink_vec[i]))->param()->phi0()<< "|";
179  } else {
180  oss << std::setiosflags(std::ios::dec) << std::setw(15) << "|"
181  << std::setiosflags(std::ios::dec) << std::setw(11) << "|"
182  << std::setiosflags(std::ios::dec) << std::setw(11) << "|";
183  }
184  }
185 
186  if (m_truth_vec[i].nrMatches() == 0) oss << std::endl;
187  // print parameters of truth particles which have hits in common with track
188  for (unsigned int j=0; j < m_truth_vec[i].nrMatches(); ++j) {
189 
190  // find if this matching true particle has a mother which also matches the track
191  HepMcParticleLink p_link( *((m_truth_vec[i]).truthMatch(j)) );
192  int child_indx = (m_truth_vec[i]).index(p_link);
193  int mother_indx = -1;
194  if (child_indx >= 0) mother_indx = (m_truth_vec[i]).motherIndexInChain(child_indx);
195 
196  if (j>0) {
197 
198  oss << std::setiosflags(std::ios::dec) << std::setw(7) << "|"
199  << std::setiosflags(std::ios::dec) << std::setw(5) << "|";
200  oss << std::setiosflags(std::ios::dec) << std::setw(15) << "|"
201  << std::setiosflags(std::ios::dec) << std::setw(11) << "|"
202  << std::setiosflags(std::ios::dec) << std::setw(11) << "|";
203  }
204 
205  oss << std::setiosflags(std::ios::dec) << std::setw(6) << j+1 << "|";
206 
207  if (mother_indx >= 0) {
208  oss << std::setiosflags(std::ios::dec) << std::setw(6) << mother_indx << "|";
209  } else {
210  oss << " -- |";
211  }
212  oss << std::setiosflags(std::ios::dec) << std::setw(6) << (m_truth_vec[i]).nrCommonSiHits(j) << "|"
213  << std::setiosflags(std::ios::dec) << std::setw(7) << (m_truth_vec[i]).nrCommonTRTHits(j) << "|"
214  << std::setiosflags(std::ios::dec) << std::setw(8) << (m_truth_vec[i]).truthMatch(j)->eventIndex() << "|"
215  << std::setiosflags(std::ios::dec) << std::setw(9) << (m_truth_vec[i]).truthMatch(j)->barcode() << "|";
216 
217  if ((m_truth_vec[i]).truthMatch(j)->cptr()) {
218 
219  oss << std::setiosflags(std::ios::dec) << std::setw(10) << (m_truth_vec[i]).truthMatch(j)->cptr()->pdg_id() << "|"
220  << std::setiosflags(std::ios::dec) << std::setw(14) << (m_truth_vec[i]).truthMatch(j)->cptr()->momentum().perp()<< "|"
221  << std::setiosflags(std::ios::dec) << std::setw(10) << (m_truth_vec[i]).truthMatch(j)->cptr()->momentum().eta() << "|"
222  << std::setiosflags(std::ios::dec) << std::setw(10) << (m_truth_vec[i]).truthMatch(j)->cptr()->momentum().phi() << "|";
223  } else {
224  oss << std::setiosflags(std::ios::dec) << std::setw(11) << "|"
225  << std::setiosflags(std::ios::dec) << std::setw(15) << "|"
226  << std::setiosflags(std::ios::dec) << std::setw(11) << "|"
227  << std::setiosflags(std::ios::dec) << std::setw(11) << "|";
228  }
229  oss << std::endl;
230  }
231  }
232  oss << "---------------------------------------------------------------------------------------------------------------------------------" << std::endl;
233 
234  log << MSG::DEBUG << oss.str() << endmsg;
235 }

◆ size()

size_t TrigInDetTrackTruthMap::size ( ) const

Definition at line 237 of file TrigInDetTrackTruthMap.cxx.

238 {
239  assert (m_elink_vec.size() == m_truth_vec.size());
240  return m_elink_vec.size();
241 }

◆ tracki()

const TrigInDetTrack * TrigInDetTrackTruthMap::tracki ( size_t  i) const

Definition at line 251 of file TrigInDetTrackTruthMap.cxx.

252 {
253  assert (i < m_elink_vec.size());
254  return *m_elink_vec[i];
255 }

◆ trackiLink()

const ElementLink< TrigInDetTrackCollection > TrigInDetTrackTruthMap::trackiLink ( size_t  i) const

Definition at line 258 of file TrigInDetTrackTruthMap.cxx.

259 {
260  assert (i < m_elink_vec.size());
261  return m_elink_vec[i];
262 }

◆ truth()

const TrigInDetTrackTruth * TrigInDetTrackTruthMap::truth ( const TrigInDetTrack p_trig_trk) const

Definition at line 82 of file TrigInDetTrackTruthMap.cxx.

83 {
84  std::string thisName("TrigInDetTrackTruthMap::truth");
85  MsgStream log(Athena::getMessageSvc(), thisName);
86 
87  log << MSG::DEBUG<<"Searching truth for track at ptr="<<p_trig_trk<<endmsg;
88 
89  // must loop over map because ElementLink is a unidirectional link
90  for (unsigned int i=0; i < m_elink_vec.size(); ++i) {
91  // if ( p_trig_trk == *(m_elink_vec[i]) ) {
92  if(!m_elink_vec[i].isValid())
93  continue;
94  if ((*(m_elink_vec[i]))->param()) {
95  if ((*(m_elink_vec[i]))->algorithmId() == p_trig_trk->algorithmId() &&
96  (*(m_elink_vec[i]))->param()->pT() == p_trig_trk->param()->pT() &&
97  (*(m_elink_vec[i]))->param()->eta() == p_trig_trk->param()->eta() &&
98  (*(m_elink_vec[i]))->param()->phi0() == p_trig_trk->param()->phi0()) {
99  // found position in vector corresponding to this track pointer
100  log << MSG::DEBUG << "Truth match for track at ptr=" << p_trig_trk
101  << " found in map at index " << i <<endmsg;
102  return &m_truth_vec[i];
103  }
104  }
105  }
106  // didn't find it: return null pointer
107  log << MSG::DEBUG <<"Truth match for track at ptr="<<p_trig_trk <<" not in map"<<endmsg;
108  return NULL;
109 }

◆ truthi()

const TrigInDetTrackTruth * TrigInDetTrackTruthMap::truthi ( size_t  i) const

Definition at line 244 of file TrigInDetTrackTruthMap.cxx.

245 {
246  assert (i < m_truth_vec.size());
247  return &m_truth_vec[i];
248 }

Friends And Related Function Documentation

◆ TrigInDetTrackTruthMap_old_cnv

friend class TrigInDetTrackTruthMap_old_cnv
friend

Definition at line 98 of file TrigInDetTrackTruthMap.h.

◆ TrigInDetTrackTruthMapCnv_p1

friend class TrigInDetTrackTruthMapCnv_p1
friend

Definition at line 97 of file TrigInDetTrackTruthMap.h.

Member Data Documentation

◆ m_elink_vec

ElementLinkVector< TrigInDetTrackCollection > TrigInDetTrackTruthMap::m_elink_vec
private

Definition at line 103 of file TrigInDetTrackTruthMap.h.

◆ m_truth_vec

std::vector< TrigInDetTrackTruth > TrigInDetTrackTruthMap::m_truth_vec
private

Definition at line 104 of file TrigInDetTrackTruthMap.h.


The documentation for this class was generated from the following files:
TrigInDetTrack::param
void param(const TrigInDetTrackFitPar *param)
Definition: TrigInDetTrack.h:126
isValid
bool isValid(const T &p)
Definition: AtlasPID.h:214
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
ElementLinkVector::push_back
void push_back(const ElemLink &link)
Definition: AthLinks/ElementLinkVector.h:316
TrigInDetTrack
Definition: TrigInDetTrack.h:34
TrigInDetTrackTruthMap::hasTruth
bool hasTruth(const TrigInDetTrack *p_trig_trk) const
methods to get truth-match objects
Definition: TrigInDetTrackTruthMap.cxx:58
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TrigInDetTrackTruthMapCnv_p1
Definition: TrigInDetTrackTruthMapCnv_p1.h:30
TrigInDetTrackTruthMap::m_elink_vec
ElementLinkVector< TrigInDetTrackCollection > m_elink_vec
Definition: TrigInDetTrackTruthMap.h:103
DeMoScan.index
string index
Definition: DeMoScan.py:362
ElementLinkVector::size
size_type size() const
Definition: AthLinks/ElementLinkVector.h:292
TrigInDetTrackTruthMap::m_truth_vec
std::vector< TrigInDetTrackTruth > m_truth_vec
Definition: TrigInDetTrackTruthMap.h:104
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
ElementLinkVector::back
const_reference back() const
Definition: AthLinks/ElementLinkVector.h:311
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TrigInDetTrackTruthMap::truth
const TrigInDetTrackTruth * truth(const TrigInDetTrack *p_trig_trk) const
Definition: TrigInDetTrackTruthMap.cxx:82
merge.status
status
Definition: merge.py:17
TrigInDetTrack::algorithmId
void algorithmId(const AlgoId id)
Definition: TrigInDetTrack.h:125