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 //
20 
21 // system include files
22 #include <map>
23 #include <vector>
24 
25 // user include files
29 
31 
32 // forward declarations
33 
35 {
36 
37 public:
38 
40  public:
41  bool operator() ( TrackWithHistory * & p,const unsigned int& i) const
42  {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 
68 
69  void addTrack(TrackWithHistory* iTrack, bool inHistory, bool withAncestor) {
70  std::pair<int, int> thePair(iTrack->trackID(),iTrack->parentID());
71  idsave.push_back(thePair);
72  if (inHistory) { m_trksForThisEvent->push_back(iTrack); }
73  if (withAncestor) {
74  std::pair<int,int> thisPair(iTrack->trackID(),0);
75  ancestorList.push_back(thisPair);
76  }
77  }
78 
79  void addTkCaloStateInfo(uint32_t t,
80  const std::pair<math::XYZVectorD,math::XYZTLorentzVectorD>& p)
81  {
82  std::map<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> >::const_iterator it =
83  mapTkCaloStateInfo.find(t);
84 
85  if (it == mapTkCaloStateInfo.end()) {
86  mapTkCaloStateInfo.insert(std::pair<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> >(t,p));
87  }
88  }
89  void setCollapsePrimaryVertices(bool iSet) {
91  }
92  int giveMotherNeeded(int i) const {
93  int theResult = 0;
94  for (unsigned int itr=0; itr<idsave.size(); itr++) {
95  if ((idsave[itr]).first == i) { theResult = (idsave[itr]).second; break; }
96  }
97  return theResult ;
98  }
99  bool trackExists(unsigned int i) const {
100  bool flag = false;
101  for (unsigned int itr=0; itr<(*m_trksForThisEvent).size(); ++itr) {
102  if ((*m_trksForThisEvent)[itr]->trackID() == i) {
103  flag = true; break;
104  }
105  }
106  return flag;
107  }
108  void setLHCTransportLink( const edm::LHCTransportLinkContainer * thisLHCTlink ) {
109  theLHCTlink = thisLHCTlink;
110  }
111 
112 private:
113  // stop default
115  const SimTrackManager& operator=(const SimTrackManager&);
116 
118  int getOrCreateVertex(TrackWithHistory *,int,G4SimEvent * simEvent);
119  void cleanVertexMap();
120  void reallyStoreTracks(G4SimEvent * simEvent);
121  void fillMotherList();
122  int idSavedTrack (int) const;
123 
124  // to restore the pre-LHC Transport GenParticle id link to a SimTrack
125  void resetGenID();
126 
127  // ---------- member data --------------------------------
133  std::map<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD > > mapTkCaloStateInfo;
134  std::vector< std::pair<int, int> > idsave;
135 
136  std::vector<std::pair<int, int> > ancestorList;
137 
138  unsigned int lastTrack;
139  unsigned int lastHist;
140 
142 
143 };
144 
145 
147 {
148 public:
149  bool operator()(TrackWithHistory * trk1, TrackWithHistory * trk2) const
150  { return (trk1->trackID() < trk2->trackID()); }
151 };
152 
153 #endif
void addTrack(TrackWithHistory *iTrack, bool inHistory, bool withAncestor)
int i
Definition: DBlmapReader.cc:9
int getOrCreateVertex(TrackWithHistory *, int, G4SimEvent *simEvent)
bool m_collapsePrimaryVertices
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)
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)
const SimTrackManager & operator=(const SimTrackManager &)
bool operator()(TrackWithHistory *&p, const unsigned int &i) const
MotherParticleToVertexMap VertexMap
bool operator()(TrackWithHistory *trk1, TrackWithHistory *trk2) const