LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
sim::ParticleList Class Reference

#include "ParticleList.h"

Classes

struct  archived_info_type
 

Public Types

typedef std::map< int, simb::MCParticle * > list_type
 
typedef list_type::key_type key_type
 
typedef list_type::mapped_type mapped_type
 
typedef list_type::value_type value_type
 
typedef list_type::iterator iterator
 
typedef list_type::const_iterator const_iterator
 
typedef list_type::reverse_iterator reverse_iterator
 
typedef list_type::const_reverse_iterator const_reverse_iterator
 
typedef list_type::size_type size_type
 
typedef list_type::difference_type difference_type
 
typedef list_type::key_compare key_compare
 
typedef list_type::allocator_type allocator_type
 

Public Member Functions

 ParticleList ()
 
virtual ~ParticleList ()
 
 ParticleList (const ParticleList &rhs)=delete
 
ParticleListoperator= (const ParticleList &rhs)=delete
 
 ParticleList (ParticleList &&rhs)=default
 
ParticleListoperator= (ParticleList &&rhs)=default
 
ParticleList MakeCopy () const
 Returns a copy of this object. More...
 
void Cut (const double &)
 
const key_typeTrackId (const size_type) const
 
mapped_type const & Particle (const size_type) const
 
mapped_type Particle (const size_type)
 
bool HasParticle (int trackID) const
 Returns whether we have this particle, live (with full information) More...
 
bool KnownParticle (int trackID) const
 Returns whether we have had this particle, archived or live. More...
 
bool IsPrimary (int trackID) const
 
int NumberOfPrimaries () const
 
std::vector< const simb::MCParticle * > GetPrimaries () const
 
const simb::MCParticlePrimary (const int) const
 
simb::MCParticlePrimary (const int)
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
size_type size () const
 
bool empty () const
 
void swap (ParticleList &other)
 
iterator find (const key_type &key)
 
const_iterator find (const key_type &key) const
 
iterator upper_bound (const key_type &key)
 
const_iterator upper_bound (const key_type &key) const
 
iterator lower_bound (const key_type &key)
 
const_iterator lower_bound (const key_type &key) const
 
mapped_type const & operator[] (const key_type &key) const
 
mapped_type operator[] (const key_type &key)
 
mapped_type at (const key_type &key)
 
mapped_type const & at (const key_type &key) const
 
key_type key (mapped_type const &part) const
 Extracts the key from the specified value. More...
 
void insert (simb::MCParticle *value)
 
void Add (simb::MCParticle *value)
 
void Archive (const key_type &key)
 Removes the particle from the list, keeping minimal info of it. More...
 
void Archive (const mapped_type &key)
 
int GetMotherOf (const key_type &key) const
 This function seeks for the exact key, not its absolute value. More...
 
void clear ()
 
size_type erase (const key_type &key)
 
iterator erase (iterator key)
 
int EveId (const int trackID) const
 

Static Public Member Functions

static void AdoptEveIdCalculator (EveIdCalculator *)
 

Private Types

typedef std::set< int > primaries_type
 
typedef std::map< int, archived_info_typearchive_type
 
typedef primaries_type::iterator primaries_iterator
 
typedef primaries_type::const_iterator primaries_const_iterator
 

Private Attributes

list_type m_particleList
 Sorted list of particles in the event. More...
 
primaries_type m_primaries
 
archive_type m_archive
 archive of the particles no longer among us More...
 

Friends

std::ostream & operator<< (std::ostream &output, const ParticleList &)
 
std::ostream & operator<< (std::ostream &output, const ParticleList::archived_info_type &)
 

Detailed Description

Definition at line 122 of file ParticleList.h.

Member Typedef Documentation

typedef list_type::allocator_type sim::ParticleList::allocator_type

Definition at line 138 of file ParticleList.h.

typedef std::map<int, archived_info_type> sim::ParticleList::archive_type
private

Definition at line 166 of file ParticleList.h.

typedef list_type::const_iterator sim::ParticleList::const_iterator

Definition at line 132 of file ParticleList.h.

typedef list_type::const_reverse_iterator sim::ParticleList::const_reverse_iterator

Definition at line 134 of file ParticleList.h.

typedef list_type::difference_type sim::ParticleList::difference_type

Definition at line 136 of file ParticleList.h.

typedef list_type::iterator sim::ParticleList::iterator

Definition at line 131 of file ParticleList.h.

typedef list_type::key_compare sim::ParticleList::key_compare

Definition at line 137 of file ParticleList.h.

typedef list_type::key_type sim::ParticleList::key_type

Definition at line 128 of file ParticleList.h.

Definition at line 127 of file ParticleList.h.

typedef list_type::mapped_type sim::ParticleList::mapped_type

Definition at line 129 of file ParticleList.h.

typedef std::set< int > sim::ParticleList::primaries_type
private

Definition at line 165 of file ParticleList.h.

typedef list_type::reverse_iterator sim::ParticleList::reverse_iterator

Definition at line 133 of file ParticleList.h.

typedef list_type::size_type sim::ParticleList::size_type

Definition at line 135 of file ParticleList.h.

typedef list_type::value_type sim::ParticleList::value_type

Definition at line 130 of file ParticleList.h.

Constructor & Destructor Documentation

sim::ParticleList::ParticleList ( )

Definition at line 30 of file ParticleList.cxx.

Referenced by ClusteringValidation::ClusterAnalyser::Analyse().

31  {
32  }
sim::ParticleList::~ParticleList ( )
virtual

Definition at line 36 of file ParticleList.cxx.

References clear().

37  {
38  this->clear();
39  }
sim::ParticleList::ParticleList ( const ParticleList rhs)
delete
sim::ParticleList::ParticleList ( ParticleList &&  rhs)
default

Member Function Documentation

void sim::ParticleList::Add ( simb::MCParticle value)
inline

Definition at line 315 of file ParticleList.h.

References insert().

Referenced by KnownParticle(), larg4::ParticleListAction::PreTrackingAction(), and cheat::PhotonBackTracker::Rebuild().

315 { insert(value); }
void insert(simb::MCParticle *value)
void sim::ParticleList::AdoptEveIdCalculator ( EveIdCalculator calc)
static

Definition at line 418 of file ParticleList.cxx.

Referenced by EveId(), KnownParticle(), cheat::PhotonBackTracker::Rebuild(), cheat::PhotonBackTracker::SetEveIdCalculator(), and cheat::ParticleInventory::SetEveIdCalculator().

419  {
420  eveIdCalculator.reset(calc);
421  }
static std::unique_ptr< EveIdCalculator > eveIdCalculator
void sim::ParticleList::Archive ( const key_type key)

Removes the particle from the list, keeping minimal info of it.

Definition at line 295 of file ParticleList.cxx.

References key(), m_archive, m_particleList, and part.

Referenced by Archive(), KnownParticle(), and larg4::ParticleListAction::PostTrackingAction().

296  {
297  auto& part = m_particleList.at(key);
298  if (part == nullptr) return; // already archived, nothing to do
299 
300  // create a new archive item with the particle;
301  m_archive[key] = archived_info_type(*part);
302 
303  // dispose of the particle in the list (the cell will still be there
304  delete part;
305  part = nullptr;
306  } // ParticleList::Archive()
key_type key(mapped_type const &part) const
Extracts the key from the specified value.
Definition: ParticleList.h:338
TString part[npart]
Definition: Style.C:32
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
archive_type m_archive
archive of the particles no longer among us
Definition: ParticleList.h:173
void sim::ParticleList::Archive ( const mapped_type key)

Definition at line 310 of file ParticleList.cxx.

References Archive(), and key().

310  {
311  Archive(key(part));
312  }
key_type key(mapped_type const &part) const
Extracts the key from the specified value.
Definition: ParticleList.h:338
TString part[npart]
Definition: Style.C:32
void Archive(const key_type &key)
Removes the particle from the list, keeping minimal info of it.
sim::ParticleList::mapped_type sim::ParticleList::at ( const key_type key)
inline

Definition at line 330 of file ParticleList.h.

References m_particleList.

Referenced by cluster::DBclusterAna::analyze(), hit::HitFinderAna::analyze(), KnownParticle(), and operator[]().

331 { return m_particleList.at(std::abs(key)); }
key_type key(mapped_type const &part) const
Extracts the key from the specified value.
Definition: ParticleList.h:338
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
sim::ParticleList::mapped_type const & sim::ParticleList::at ( const key_type key) const
inline

Definition at line 332 of file ParticleList.h.

References m_particleList.

333 { return m_particleList.at(std::abs(key)); }
key_type key(mapped_type const &part) const
Extracts the key from the specified value.
Definition: ParticleList.h:338
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
sim::ParticleList::const_iterator sim::ParticleList::begin ( ) const
inline

Definition at line 306 of file ParticleList.h.

References m_particleList.

306 { return m_particleList.begin(); }
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
void sim::ParticleList::clear ( void  )

Definition at line 323 of file ParticleList.cxx.

References m_archive, m_particleList, and m_primaries.

Referenced by larg4::ParticleListAction::BeginOfEventAction(), cheat::ParticleInventory::ClearEvent(), KnownParticle(), cheat::PhotonBackTracker::Rebuild(), and ~ParticleList().

324  {
325  for ( iterator i = m_particleList.begin(); i != m_particleList.end(); ++i ){
326  delete (*i).second;
327  }
328 
329  m_particleList.clear();
330  m_archive.clear();
331  m_primaries.clear();
332  }
primaries_type m_primaries
Definition: ParticleList.h:171
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
archive_type m_archive
archive of the particles no longer among us
Definition: ParticleList.h:173
void sim::ParticleList::Cut ( const double &  cut)

Definition at line 59 of file ParticleList.cxx.

References simb::MCParticle::E(), erase(), and m_particleList.

60  {
61  // The safest way to do this is to create a list of track IDs that
62  // fail the cut, then delete those IDs.
63 
64  // Define a list of IDs.
65  typedef std::set< key_type > keyList_type;
66  keyList_type keyList;
67 
68  // Add each ID that fails the cut to the list.
69  for ( const_iterator i = m_particleList.begin(); i != m_particleList.end(); ++i ){
70  const simb::MCParticle* particle = (*i).second;
71  if (!particle) continue;
72  Double_t totalInitialEnergy = particle->E();
73  if ( totalInitialEnergy < cut ) {
74  keyList.insert( (*i).first );
75  }
76  }
77 
78  // Go through the list, deleting the particles that are on the list.
79  for ( keyList_type::const_iterator i = keyList.begin(); i != keyList.end(); ++i ){
80  this->erase( *i );
81  }
82  }
double E(const int i=0) const
Definition: MCParticle.h:237
intermediate_table::const_iterator const_iterator
size_type erase(const key_type &key)
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
bool sim::ParticleList::empty ( void  ) const
inline

Definition at line 314 of file ParticleList.h.

References m_particleList.

Referenced by KnownParticle(), evd::SimulationDrawer::MCTruthVectors2D(), and cheat::ParticleInventory::ParticleListReady().

314 { return m_particleList.empty(); }
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
sim::ParticleList::const_iterator sim::ParticleList::end ( void  ) const
inline

Definition at line 308 of file ParticleList.h.

References m_particleList.

308 { return m_particleList.end(); }
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
ParticleList::size_type sim::ParticleList::erase ( const key_type key)

Definition at line 342 of file ParticleList.cxx.

References m_particleList.

Referenced by Cut(), and KnownParticle().

343  {
344  iterator entry = m_particleList.find( abs(key) );
345  if (entry == m_particleList.end()) return 0;
346  erase(entry);
347  return 1;
348  }
key_type key(mapped_type const &part) const
Extracts the key from the specified value.
Definition: ParticleList.h:338
size_type erase(const key_type &key)
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
ParticleList::iterator sim::ParticleList::erase ( iterator  key)

Definition at line 336 of file ParticleList.cxx.

References m_particleList.

337  {
338  delete position->second;
339  return m_particleList.erase( position );
340  }
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
int sim::ParticleList::EveId ( const int  trackID) const

Definition at line 392 of file ParticleList.cxx.

References AdoptEveIdCalculator().

Referenced by cheat::CheckBackTracking::analyze(), cheat::PhotonBackTracker::GetSetOfEveIDs(), cheat::ParticleInventory::GetSetOfEveIds(), KnownParticle(), cheat::PhotonBackTracker::OpHitToEveSDPs(), tca::PrintAll(), cheat::ParticleInventory::TrackIdToEveTrackId(), cheat::PhotonBackTracker::TrackIDToMotherParticle(), and cheat::ParticleInventory::TrackIdToMotherParticle_P().

393  {
394  // If the eve ID calculator has never been initialized, use the
395  // default method.
396  if ( eveIdCalculator.get() == 0 ){
397  AdoptEveIdCalculator( new EveIdCalculator );
398  }
399 
400  // If the eve ID calculator has changed, or we're looking at a
401  // different ParticleList, initialize the calculator.
402  static EveIdCalculator* saveEveIdCalculator = 0;
403  if ( saveEveIdCalculator != eveIdCalculator.get() ) {
404  saveEveIdCalculator = eveIdCalculator.get();
405  eveIdCalculator->Init( this );
406  }
407  if ( eveIdCalculator->ParticleList() != this ){
408  eveIdCalculator->Init( this );
409  }
410 
411  // After the "bookkeeping" tests, here's where we actually do the
412  // calculation.
413  return eveIdCalculator->CalculateEveId( trackID );
414  }
static std::unique_ptr< EveIdCalculator > eveIdCalculator
static void AdoptEveIdCalculator(EveIdCalculator *)
sim::ParticleList::iterator sim::ParticleList::find ( const key_type key)
inline

Definition at line 318 of file ParticleList.h.

References m_particleList.

Referenced by larg4::LArG4Ana::analyze(), hit::HitFinderAna::analyze(), opdet::SimPhotonCounter::analyze(), HasParticle(), KnownParticle(), sim::ParticleHistory::ParticleHistory(), cheat::PhotonBackTracker::TrackIDToParticle(), and cheat::ParticleInventory::TrackIdToParticle_P().

319 { return m_particleList.find(abs(key)); }
key_type key(mapped_type const &part) const
Extracts the key from the specified value.
Definition: ParticleList.h:338
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
sim::ParticleList::const_iterator sim::ParticleList::find ( const key_type key) const
inline

Definition at line 320 of file ParticleList.h.

References m_particleList.

321 { return m_particleList.find(abs(key)); }
key_type key(mapped_type const &part) const
Extracts the key from the specified value.
Definition: ParticleList.h:338
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
int sim::ParticleList::GetMotherOf ( const key_type key) const

This function seeks for the exact key, not its absolute value.

Definition at line 315 of file ParticleList.cxx.

References m_archive, m_particleList, and part.

Referenced by KnownParticle().

316  {
317  auto part = m_particleList.at(key);
318  return part? part->Mother(): m_archive.at(key).Mother();
319  } // ParticleList::GetMotherOf()
key_type key(mapped_type const &part) const
Extracts the key from the specified value.
Definition: ParticleList.h:338
TString part[npart]
Definition: Style.C:32
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
archive_type m_archive
archive of the particles no longer among us
Definition: ParticleList.h:173
std::vector< const simb::MCParticle * > sim::ParticleList::GetPrimaries ( ) const

Definition at line 156 of file ParticleList.cxx.

References m_particleList, and m_primaries.

Referenced by KnownParticle().

157  {
158  std::vector<const simb::MCParticle*> primaries;
159  primaries.reserve(m_primaries.size());
160  // for each particle, check if its track ID is in the primaries list
161  // iPartPair is std::pair<const int, simb::MCParticle*>
162  for (auto& iPartPair: m_particleList) {
163  if (m_primaries.count(iPartPair.first))
164  primaries.push_back(iPartPair.second);
165  } // for
166  if (primaries.size() != m_primaries.size()) {
167  throw cet::exception("ParticleList")
168  << "sim::ParticleList::GetPrimaries() collected " << primaries.size()
169  << " primaries, not " << m_primaries.size() << " as expected\n";
170  }
171  return primaries;
172  } // ParticleList::GetPrimaries()
primaries_type m_primaries
Definition: ParticleList.h:171
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool sim::ParticleList::HasParticle ( int  trackID) const
inline

Returns whether we have this particle, live (with full information)

Definition at line 208 of file ParticleList.h.

References end(), and find().

209  {
210  auto iParticle = find(trackID);
211  return (iParticle != end()) && (iParticle->second != nullptr);
212  }
iterator find(const key_type &key)
Definition: ParticleList.h:318
void sim::ParticleList::insert ( simb::MCParticle value)

Definition at line 267 of file ParticleList.cxx.

References key(), m_particleList, m_primaries, and simb::MCParticle::Process().

Referenced by Add(), KnownParticle(), and MakeCopy().

268  {
269  int trackID = key(particle);
270  iterator insertion = m_particleList.lower_bound( trackID );
271  if ( insertion == m_particleList.end() ){
272  // The best "hint" we can give is that the particle will go at
273  // the end of the list.
274  m_particleList.insert( insertion, value_type( trackID, particle ) );
275  }
276  else if ( (*insertion).first == trackID ){
277  throw cet::exception("ParticleList") << "sim::ParticleList::insert - ERROR - "
278  << "track ID=" << trackID
279  << " is already in the list\n";
280  }
281  else{
282  // It turns out that the best hint we can give is one more
283  // than the result of lower_bound.
284  m_particleList.insert( ++insertion, value_type( trackID, particle ) );
285  }
286 
287  // If this is a primary particle, add it to the list. use
288  // rimary as the process string to look for as the P may or may not
289  // be capitalized
290  if ( particle->Process().find("rimary") != std::string::npos )
291  m_primaries.insert( trackID );
292  }
key_type key(mapped_type const &part) const
Extracts the key from the specified value.
Definition: ParticleList.h:338
primaries_type m_primaries
Definition: ParticleList.h:171
list_type::value_type value_type
Definition: ParticleList.h:130
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool sim::ParticleList::IsPrimary ( int  trackID) const

Definition at line 109 of file ParticleList.cxx.

References m_primaries.

Referenced by KnownParticle(), and sim::ParticleHistory::ParticleHistory().

110  {
111  return m_primaries.find( trackID ) != m_primaries.end();
112  }
primaries_type m_primaries
Definition: ParticleList.h:171
sim::ParticleList::key_type sim::ParticleList::key ( mapped_type const &  part) const
inline

Extracts the key from the specified value.

Definition at line 338 of file ParticleList.h.

Referenced by Archive(), insert(), and KnownParticle().

338 { return part->TrackId(); }
TString part[npart]
Definition: Style.C:32
bool sim::ParticleList::KnownParticle ( int  trackID) const
inline
sim::ParticleList::iterator sim::ParticleList::lower_bound ( const key_type key)
inline

Definition at line 326 of file ParticleList.h.

References m_particleList.

Referenced by KnownParticle().

327 { return m_particleList.lower_bound(abs(key)); }
key_type key(mapped_type const &part) const
Extracts the key from the specified value.
Definition: ParticleList.h:338
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
sim::ParticleList::const_iterator sim::ParticleList::lower_bound ( const key_type key) const
inline

Definition at line 328 of file ParticleList.h.

References m_particleList.

329 { return m_particleList.lower_bound(abs(key)); }
key_type key(mapped_type const &part) const
Extracts the key from the specified value.
Definition: ParticleList.h:338
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
ParticleList sim::ParticleList::MakeCopy ( ) const

Returns a copy of this object.

Definition at line 44 of file ParticleList.cxx.

References insert(), m_archive, and m_particleList.

45  {
46  ParticleList list;
47 
48  // Copy each entry in the other ParticleList.
49  for (std::pair<int, simb::MCParticle*> const& partInfo: m_particleList)
50  list.insert(partInfo.second? new simb::MCParticle(*(partInfo.second)): nullptr);
51 
52  list.m_archive = m_archive;
53 
54  return list;
55  } // ParticleList::MakeCopy()
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
archive_type m_archive
archive of the particles no longer among us
Definition: ParticleList.h:173
int sim::ParticleList::NumberOfPrimaries ( ) const

Definition at line 115 of file ParticleList.cxx.

References m_primaries.

Referenced by KnownParticle().

116  {
117  return m_primaries.size();
118  }
primaries_type m_primaries
Definition: ParticleList.h:171
ParticleList& sim::ParticleList::operator= ( const ParticleList rhs)
delete
ParticleList& sim::ParticleList::operator= ( ParticleList &&  rhs)
default
sim::ParticleList::mapped_type const & sim::ParticleList::operator[] ( const key_type key) const
inline

Definition at line 336 of file ParticleList.h.

References at().

Referenced by KnownParticle().

337 { return at(key); }
key_type key(mapped_type const &part) const
Extracts the key from the specified value.
Definition: ParticleList.h:338
mapped_type at(const key_type &key)
Definition: ParticleList.h:330
sim::ParticleList::mapped_type sim::ParticleList::operator[] ( const key_type key)
inline

Definition at line 334 of file ParticleList.h.

References at().

335 { return at(key); }
key_type key(mapped_type const &part) const
Extracts the key from the specified value.
Definition: ParticleList.h:338
mapped_type at(const key_type &key)
Definition: ParticleList.h:330
ParticleList::mapped_type const & sim::ParticleList::Particle ( const size_type  index) const

Definition at line 93 of file ParticleList.cxx.

References m_particleList.

94  {
95  const_iterator i = m_particleList.begin();
96  std::advance(i,index);
97  return (*i).second;
98  }
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
ParticleList::mapped_type sim::ParticleList::Particle ( const size_type  index)

Definition at line 101 of file ParticleList.cxx.

References m_particleList.

102  {
103  iterator i = m_particleList.begin();
104  std::advance(i,index);
105  return (*i).second;
106  }
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
const simb::MCParticle * sim::ParticleList::Primary ( const int  index) const

Definition at line 121 of file ParticleList.cxx.

References m_particleList, and m_primaries.

Referenced by KnownParticle().

122  {
123  // Advance "index" entries from the beginning of the primary list.
124  primaries_const_iterator primary = m_primaries.begin();
125  std::advance( primary, index );
126 
127  // Get the track ID from that entry in the list.
128  int trackID = *primary;
129 
130  // Find the entry in the particle list with that track ID.
131  const_iterator entry = m_particleList.find(trackID);
132 
133  // Return the Particle object in that entry.
134  return (*entry).second;
135  }
primaries_type m_primaries
Definition: ParticleList.h:171
primaries_type::const_iterator primaries_const_iterator
Definition: ParticleList.h:168
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
simb::MCParticle * sim::ParticleList::Primary ( const int  index)

Definition at line 138 of file ParticleList.cxx.

References m_particleList, and m_primaries.

139  {
140  // Advance "index" entries from the beginning of the primary list.
141  primaries_const_iterator primary = m_primaries.begin();
142  std::advance( primary, index );
143 
144  // Get the track ID from that entry in the list.
145  int trackID = *primary;
146 
147  // Find the entry in the particle list with that track ID.
148  iterator entry = m_particleList.find(trackID);
149 
150  // Return the Particle object in that entry.
151  return (*entry).second;
152  }
primaries_type m_primaries
Definition: ParticleList.h:171
primaries_type::const_iterator primaries_const_iterator
Definition: ParticleList.h:168
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
sim::ParticleList::reverse_iterator sim::ParticleList::rbegin ( )
inline

Definition at line 309 of file ParticleList.h.

References m_particleList.

Referenced by KnownParticle().

309 { return m_particleList.rbegin(); }
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
sim::ParticleList::const_reverse_iterator sim::ParticleList::rbegin ( ) const
inline

Definition at line 310 of file ParticleList.h.

References m_particleList.

310 { return m_particleList.rbegin(); }
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
sim::ParticleList::reverse_iterator sim::ParticleList::rend ( )
inline

Definition at line 311 of file ParticleList.h.

References m_particleList.

Referenced by KnownParticle().

311 { return m_particleList.rend(); }
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
sim::ParticleList::const_reverse_iterator sim::ParticleList::rend ( ) const
inline

Definition at line 312 of file ParticleList.h.

References m_particleList.

312 { return m_particleList.rend(); }
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
sim::ParticleList::size_type sim::ParticleList::size ( void  ) const
inline
void sim::ParticleList::swap ( sim::ParticleList other)
inline

Definition at line 316 of file ParticleList.h.

References m_archive, m_particleList, and m_primaries.

Referenced by KnownParticle().

317 { m_particleList.swap( other.m_particleList ); m_archive.swap( other.m_archive ); m_primaries.swap( other.m_primaries); }
primaries_type m_primaries
Definition: ParticleList.h:171
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
archive_type m_archive
archive of the particles no longer among us
Definition: ParticleList.h:173
const ParticleList::key_type & sim::ParticleList::TrackId ( const size_type  index) const

Definition at line 86 of file ParticleList.cxx.

References m_particleList.

Referenced by cluster::TrajCluster::produce().

87  {
88  const_iterator i = m_particleList.begin();
89  std::advance(i,index);
90  return (*i).first;
91  }
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
sim::ParticleList::iterator sim::ParticleList::upper_bound ( const key_type key)
inline

Definition at line 322 of file ParticleList.h.

References m_particleList.

Referenced by KnownParticle().

323 { return m_particleList.upper_bound(abs(key)); }
key_type key(mapped_type const &part) const
Extracts the key from the specified value.
Definition: ParticleList.h:338
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170
sim::ParticleList::const_iterator sim::ParticleList::upper_bound ( const key_type key) const
inline

Definition at line 324 of file ParticleList.h.

References m_particleList.

325 { return m_particleList.upper_bound(abs(key)); }
key_type key(mapped_type const &part) const
Extracts the key from the specified value.
Definition: ParticleList.h:338
list_type m_particleList
Sorted list of particles in the event.
Definition: ParticleList.h:170

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  output,
const ParticleList list 
)
friend

Definition at line 352 of file ParticleList.cxx.

353  {
354  // Determine a field width for the particle number.
355  ParticleList::size_type numberOfParticles = list.size();
356  int numberOfDigits = (int) std::log10( (double) numberOfParticles ) + 1;
357 
358  // A simple header.
359  output.width( numberOfDigits );
360  output << "#" << ": < ID, particle >" << std::endl;
361 
362  // Write each particle on a separate line.
363  ParticleList::size_type nParticle = 0;
364  for ( ParticleList::const_iterator particle = list.begin();
365  particle != list.end(); ++particle, ++nParticle ){
366  output.width( numberOfDigits );
367  output << nParticle << ": "
368  << "<" << (*particle).first << ",";
369  if (particle->second)
370  output << *(particle->second);
371  else {
372  auto iArch = list.m_archive.find(particle->first);
373  if (iArch == list.m_archive.end())
374  output << "lost [INTERNAL ERROR!]";
375  else
376  output << "(archived) " << iArch->second;
377  }
378  output << ">" << std::endl;
379  }
380 
381  return output;
382  }
list_type::const_iterator const_iterator
Definition: ParticleList.h:132
list_type::size_type size_type
Definition: ParticleList.h:135
std::ostream& operator<< ( std::ostream &  output,
const ParticleList::archived_info_type info 
)
friend

Definition at line 425 of file ParticleList.cxx.

426  {
427  output << "Mother ID=" << info.Mother() << std::endl;
428  return output;
429  }

Member Data Documentation

archive_type sim::ParticleList::m_archive
private

archive of the particles no longer among us

Definition at line 173 of file ParticleList.h.

Referenced by Archive(), clear(), GetMotherOf(), MakeCopy(), sim::operator<<(), and swap().

list_type sim::ParticleList::m_particleList
private
primaries_type sim::ParticleList::m_primaries
private

Sorted list of the track IDs of primary particles.

Definition at line 171 of file ParticleList.h.

Referenced by clear(), GetPrimaries(), insert(), IsPrimary(), NumberOfPrimaries(), Primary(), and swap().


The documentation for this class was generated from the following files: