CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SimTrackManager.h
Go to the documentation of this file.
1 #ifndef Application_SimTrackManager_h
2 #define Application_SimTrackManager_h
3 // -*- C++ -*-
4 //
5 // Package: Application
6 // Class : SimTrackManager
7 //
16 //
17 // Original Author:
18 // Created: Fri Nov 25 17:36:41 EST 2005
19 // $Id: SimTrackManager.h,v 1.12 2009/06/10 08:20:27 fabiocos Exp $
20 //
21 
22 // system include files
23 #include <map>
24 #include <vector>
25 
26 // user include files
30 
32 
33 // forward declarations
34 
36 {
37 
38 public:
39 
41  public:
42  bool operator() ( TrackWithHistory * & p,const unsigned int& i) const {return p->trackID() < i;}
43  };
44  // enum SpecialNumbers {InvalidID = 65535};
46  typedef std::pair<int,math::XYZVectorD> MapVertexPosition;
47  typedef std::vector<std::pair<int,math::XYZVectorD> > MapVertexPositionVector;
48  typedef std::map<int,MapVertexPositionVector> MotherParticleToVertexMap;
50 
51  SimTrackManager(bool iCollapsePrimaryVertices =false);
52  virtual ~SimTrackManager();
53 
54  // ---------- const member functions ---------------------
55  const TrackContainer * trackContainer() const {
56  return m_trksForThisEvent;
57  }
58 
59 
60  // ---------- member functions ---------------------------
61  void storeTracks(G4SimEvent * simEvent);
62 
63  void reset();
64  void deleteTracks();
66 
67  void addTrack(TrackWithHistory* iTrack, bool inHistory, bool withAncestor) {
68  std::pair<int, int> thePair(iTrack->trackID(),iTrack->parentID());
69  idsave.push_back(thePair);
70  if (inHistory) m_trksForThisEvent->push_back(iTrack);
71  if (withAncestor) { std::pair<int,int> thisPair(iTrack->trackID(),0); ancestorList.push_back(thisPair); }
72  }
73 
74  void addTkCaloStateInfo(uint32_t t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> p){
75  std::map<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> >::const_iterator it =
76  mapTkCaloStateInfo.find(t);
77 
78  if (it == mapTkCaloStateInfo.end())
79  mapTkCaloStateInfo.insert(std::pair<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> >(t,p));
80 
81  }
82  void setCollapsePrimaryVertices(bool iSet) {
84  }
85  int giveMotherNeeded(int i) const {
86  int theResult = 0;
87  for (unsigned int itr=0; itr<idsave.size(); itr++) { if ((idsave[itr]).first == i) { theResult = (idsave[itr]).second; break; } }
88  return theResult ;
89  }
90  bool trackExists(unsigned int i) const {
91  bool flag = false;
92  for (unsigned int itr=0; itr<(*m_trksForThisEvent).size(); ++itr) {
93  if ((*m_trksForThisEvent)[itr]->trackID() == i) {
94  flag = true; break;
95  }
96  }
97  return flag;
98  }
100  void setLHCTransportLink( const edm::LHCTransportLinkContainer * thisLHCTlink ) { theLHCTlink = thisLHCTlink; }
101 
102 private:
103  SimTrackManager(const SimTrackManager&); // stop default
104 
105  const SimTrackManager& operator=(const SimTrackManager&); // stop default
106 
108  int getOrCreateVertex(TrackWithHistory *,int,G4SimEvent * simEvent);
109  void cleanVertexMap();
110  void reallyStoreTracks(G4SimEvent * simEvent);
111  void fillMotherList();
112  int idSavedTrack (int) const;
113 
114  // to restore the pre-LHCTransport GenParticle id link to a SimTrack
115  void resetGenID();
116 
117  // ---------- member data --------------------------------
123  std::map<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD > > mapTkCaloStateInfo;
124  std::vector< std::pair<int, int> > idsave;
125 
126  std::vector<std::pair<int, int> > ancestorList;
127 
128  unsigned int lastTrack;
129  unsigned int lastHist;
130 
132 
133 };
134 
135 
137 {
138 public:
139  bool operator()(TrackWithHistory * trk1, TrackWithHistory * trk2) const
140  { return (trk1->trackID() < trk2->trackID()); }
141 };
142 
143 #endif
void addTrack(TrackWithHistory *iTrack, bool inHistory, bool withAncestor)
int i
Definition: DBlmapReader.cc:9
long int flag
Definition: mlp_lapack.h:47
int getOrCreateVertex(TrackWithHistory *, int, G4SimEvent *simEvent)
bool m_collapsePrimaryVertices
void addTkCaloStateInfo(uint32_t t, std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > p)
SimTrackManager(bool iCollapsePrimaryVertices=false)
void cleanTkCaloStateInfoMap()
std::map< uint32_t, std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > > mapTkCaloStateInfo
unsigned int lastHist
virtual ~SimTrackManager()
TrackContainer * m_trksForThisEvent
U second(std::pair< T, U > const &p)
const TrackContainer * trackContainer() const
std::vector< TrackWithHistory * > TrackContainer
Definition: TrackContainer.h:8
std::vector< std::pair< int, int > > idsave
unsigned int trackID() const
bool trackExists(unsigned int i) const
void cleanTracksWithHistory()
std::pair< int, math::XYZVectorD > MapVertexPosition
this map contains association between vertex number and position
MotherParticleToVertexMap m_vertexMap
int giveMotherNeeded(int i) const
void storeTracks(G4SimEvent *simEvent)
int idSavedTrack(int) const
int parentID() const
std::map< int, MapVertexPositionVector > MotherParticleToVertexMap
void saveTrackAndItsBranch(TrackWithHistory *)
this saves a track and all its parents looping over the non ordered vector
unsigned int lastTrack
std::vector< std::pair< int, math::XYZVectorD > > MapVertexPositionVector
void setLHCTransportLink(const edm::LHCTransportLinkContainer *thisLHCTlink)
std::vector< LHCTransportLink > LHCTransportLinkContainer
const edm::LHCTransportLinkContainer * theLHCTlink
void reallyStoreTracks(G4SimEvent *simEvent)
std::vector< std::pair< int, int > > ancestorList
void setCollapsePrimaryVertices(bool iSet)
const SimTrackManager & operator=(const SimTrackManager &)
bool operator()(TrackWithHistory *&p, const unsigned int &i) const
MotherParticleToVertexMap VertexMap
bool operator()(TrackWithHistory *trk1, TrackWithHistory *trk2) const