All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MCTruthParticleHistory.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file MCTruthParticleHistory.cxx
3 /// \brief A "chain" of particles associated with production of a Particle in a ParticleList.
4 ///
5 /// \version $Id: MCTruthParticleHistory.cxx,v 1.1 2010/04/29 15:38:01 seligman Exp $
6 /// \author seligman@nevis.columbia.edu
7 ////////////////////////////////////////////////////////////////////////
8 
11 
12 #include <cmath>
13 
14 namespace truth {
15 
16 //----------------------------------------------------------------------------
17 // Nothing special need be done for the constructor.
19  : m_particleList(list)
20  , m_trackID(trackID)
21 {
22  // Look for the track in the particle list.
24 
25  // While we're still finding particles in the chain...
26  while ( search != m_particleList->end() ){
27  const simb::MCParticle* particle = (*search).second;
28  push_front( particle );
29 
30  // If this is a primary particle, we're done.
31  int trackID = particle->TrackId();
32  if ( m_particleList->IsPrimary( trackID ) ) break;
33 
34  // Now look for the parent of this particle.
35  int parentID = particle->Mother();
36  search = m_particleList->find( parentID );
37 
38  } // while we're finding particles in the chain
39 }
40 
41 //----------------------------------------------------------------------------
42 // Nothing special for the destructor.
44 {}
45 
46 //----------------------------------------------------------------------------
47 std::ostream& operator<< ( std::ostream& output, const MCTruthParticleHistory& list )
48 {
49  // Determine a field width for the particle number.
50  MCTruthParticleHistory::size_type numberOfParticles = list.size();
51  int numberOfDigits = (int) std::log10( (double) numberOfParticles ) + 1;
52 
53  // A simple header.
54  output.width( numberOfDigits );
55  output << "#" << ": < ID, particle >" << "\n";
56 
57  // Write each particle on a separate line.
58  MCTruthParticleHistory::size_type nParticle = 0;
59  for ( MCTruthParticleHistory::const_iterator particle = list.begin();
60  particle != list.end(); ++particle, ++nParticle ){
61  output.width( numberOfDigits );
62  output << nParticle << ": "
63  << (*particle)
64  << "\n";
65  }
66 
67  return output;
68 }
69 
70 } // namespace sim
std::ostream & operator<<(std::ostream &output, const MCTruthParticleHistory &list)
list_type::const_iterator const_iterator
Particle list in DetSim contains Monte Carlo particle information.
int m_trackID
The ParticleList associated with this chain.
A &quot;chain&quot; of particles associated with production of a Particle in a ParticleList.
const MCTruthParticleList * m_particleList
MCTruthParticleHistory(const MCTruthParticleList *list, const int trackID)
iterator find(const key_type &key)
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
bool IsPrimary(int trackID) const
list
Definition: file_to_url.sh:28