CMS 3D CMS Logo

SimTrackManager.h
Go to the documentation of this file.
1 #ifndef Notification_SimTrackManager_h
2 #define Notification_SimTrackManager_h
3 // -*- C++ -*-
4 //
5 // Package: Notification
6 // Class : SimTrackManager
7 //
16 //
17 // Original Author:
18 // Created: Fri Nov 25 17:36:41 EST 2005
19 //
20 
21 // system include files
22 #include <map>
23 #include <vector>
24 
25 // user include files
28 
30 
31 // forward declarations
32 
33 class G4SimEvent;
34 
36 {
37 
38 public:
39 
41  public:
42  bool operator() ( TrackWithHistory * & p,const unsigned int& i) const
43  {return p->trackID() < i;}
44  };
45  // enum SpecialNumbers {InvalidID = 65535};
47  typedef std::pair<int,math::XYZVectorD> MapVertexPosition;
48  typedef std::vector<std::pair<int,math::XYZVectorD> > MapVertexPositionVector;
49  typedef std::map<int,MapVertexPositionVector> MotherParticleToVertexMap;
50  typedef MotherParticleToVertexMap VertexMap;
51 
52  SimTrackManager(bool iCollapsePrimaryVertices = false);
53  virtual ~SimTrackManager();
54 
55  // ---------- const member functions ---------------------
56  const TrackContainer * trackContainer() const {
57  return m_trksForThisEvent;
58  }
59 
60 
61  // ---------- member functions ---------------------------
62  void storeTracks(G4SimEvent * simEvent);
63 
64  void reset();
65  void deleteTracks();
67 
69 
70  void addTrack(TrackWithHistory* iTrack, bool inHistory, bool withAncestor) {
71  std::pair<int, int> thePair(iTrack->trackID(),iTrack->parentID());
72  idsave.push_back(thePair);
73  if (inHistory) { m_trksForThisEvent->push_back(iTrack); }
74  if (withAncestor) {
75  std::pair<int,int> thisPair(iTrack->trackID(),0);
76  ancestorList.push_back(thisPair);
77  }
78  }
79 
80  void addTkCaloStateInfo(uint32_t t,
81  const std::pair<math::XYZVectorD,math::XYZTLorentzVectorD>& p)
82  {
83  std::map<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> >::const_iterator it =
84  mapTkCaloStateInfo.find(t);
85 
86  if (it == mapTkCaloStateInfo.end()) {
87  mapTkCaloStateInfo.insert(std::pair<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> >(t,p));
88  }
89  }
90  void setCollapsePrimaryVertices(bool iSet) {
92  }
93  int giveMotherNeeded(int i) const {
94  int theResult = 0;
95  for (unsigned int itr=0; itr<idsave.size(); itr++) {
96  if ((idsave[itr]).first == i) { theResult = (idsave[itr]).second; break; }
97  }
98  return theResult ;
99  }
100  bool trackExists(unsigned int i) const {
101  bool flag = false;
102  for (unsigned int itr=0; itr<(*m_trksForThisEvent).size(); ++itr) {
103  if ((*m_trksForThisEvent)[itr]->trackID() == i) {
104  flag = true; break;
105  }
106  }
107  return flag;
108  }
109  void setLHCTransportLink( const edm::LHCTransportLinkContainer * thisLHCTlink ) {
110  theLHCTlink = thisLHCTlink;
111  }
112 
113 private:
114  // stop default
115  SimTrackManager(const SimTrackManager&) = delete;
116  const SimTrackManager& operator=(const SimTrackManager&) = delete;
117 
119  int getOrCreateVertex(TrackWithHistory *,int,G4SimEvent * simEvent);
120  void cleanVertexMap();
121  void reallyStoreTracks(G4SimEvent * simEvent);
122  void fillMotherList();
123  int idSavedTrack (int) const;
124 
125  // to restore the pre-LHC Transport GenParticle id link to a SimTrack
126  void resetGenID();
127 
128  // ---------- member data --------------------------------
131  MotherParticleToVertexMap m_vertexMap;
134  std::map<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD > > mapTkCaloStateInfo;
135  std::vector< std::pair<int, int> > idsave;
136 
137  std::vector<std::pair<int, int> > ancestorList;
138 
139  unsigned int lastTrack;
140  unsigned int lastHist;
141 
143 
144 };
145 
146 
148 {
149 public:
150  bool operator()(TrackWithHistory * trk1, TrackWithHistory * trk2) const
151  { return (trk1->trackID() < trk2->trackID()); }
152 };
153 
154 #endif
void addTrack(TrackWithHistory *iTrack, bool inHistory, bool withAncestor)
int getOrCreateVertex(TrackWithHistory *, int, G4SimEvent *simEvent)
bool m_collapsePrimaryVertices
SimTrackManager(bool iCollapsePrimaryVertices=false)
const SimTrackManager & operator=(const SimTrackManager &)=delete
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)
void addTkCaloStateInfo(uint32_t t, const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &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)
bool operator()(TrackWithHistory *&p, const unsigned int &i) const
MotherParticleToVertexMap VertexMap
bool operator()(TrackWithHistory *trk1, TrackWithHistory *trk2) const