CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
SimTrackManager Class Reference

#include <SimG4Core/Notification/interface/SimTrackManager.h>

Classes

class  StrictWeakOrdering
 

Public Types

typedef std::pair< int, math::XYZVectorDMapVertexPosition
 this map contains association between vertex number and position More...
 
typedef std::vector< std::pair< int, math::XYZVectorD > > MapVertexPositionVector
 
typedef std::map< int, MapVertexPositionVectorMotherParticleToVertexMap
 
typedef MotherParticleToVertexMap VertexMap
 

Public Member Functions

void addTkCaloStateInfo (uint32_t t, const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &p)
 
void addTrack (TrackWithHistory *iTrack, bool inHistory, bool withAncestor)
 
void cleanTkCaloStateInfoMap ()
 
void cleanTracksWithHistory ()
 
void deleteTracks ()
 
int giveMotherNeeded (int i) const
 
void reset ()
 
void setCollapsePrimaryVertices (bool iSet)
 
void setLHCTransportLink (const edm::LHCTransportLinkContainer *thisLHCTlink)
 
 SimTrackManager (bool iCollapsePrimaryVertices=false)
 
void storeTracks (G4SimEvent *simEvent)
 
const TrackContainertrackContainer () const
 
bool trackExists (unsigned int i) const
 
virtual ~SimTrackManager ()
 

Private Member Functions

void cleanVertexMap ()
 
void fillMotherList ()
 
int getOrCreateVertex (TrackWithHistory *, int, G4SimEvent *simEvent)
 
int idSavedTrack (int) const
 
const SimTrackManageroperator= (const SimTrackManager &)=delete
 
void reallyStoreTracks (G4SimEvent *simEvent)
 
void resetGenID ()
 
void saveTrackAndItsBranch (TrackWithHistory *)
 this saves a track and all its parents looping over the non ordered vector More...
 
 SimTrackManager (const SimTrackManager &)=delete
 

Private Attributes

std::vector< std::pair< int, int > > ancestorList
 
std::vector< std::pair< int, int > > idsave
 
unsigned int lastHist
 
unsigned int lastTrack
 
bool m_collapsePrimaryVertices
 
int m_nVertices
 
bool m_SaveSimTracks
 
TrackContainerm_trksForThisEvent
 
MotherParticleToVertexMap m_vertexMap
 
std::map< uint32_t, std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > > mapTkCaloStateInfo
 
const edm::LHCTransportLinkContainertheLHCTlink
 

Detailed Description

Description: Holds tracking information used by the sensitive detectors

Usage: <usage>

Definition at line 35 of file SimTrackManager.h.

Member Typedef Documentation

this map contains association between vertex number and position

Definition at line 47 of file SimTrackManager.h.

typedef std::vector<std::pair<int,math::XYZVectorD> > SimTrackManager::MapVertexPositionVector

Definition at line 48 of file SimTrackManager.h.

Definition at line 49 of file SimTrackManager.h.

Definition at line 50 of file SimTrackManager.h.

Constructor & Destructor Documentation

SimTrackManager::SimTrackManager ( bool  iCollapsePrimaryVertices = false)

Definition at line 28 of file SimTrackManager.cc.

Referenced by setLHCTransportLink().

28  :
29  m_trksForThisEvent(nullptr),m_nVertices(0),
30  m_collapsePrimaryVertices(iCollapsePrimaryVertices),
31  lastTrack(0),lastHist(0),theLHCTlink(nullptr){}
bool m_collapsePrimaryVertices
unsigned int lastHist
TrackContainer * m_trksForThisEvent
unsigned int lastTrack
const edm::LHCTransportLinkContainer * theLHCTlink
SimTrackManager::~SimTrackManager ( )
virtual

Definition at line 34 of file SimTrackManager.cc.

References deleteTracks(), and m_trksForThisEvent.

35 {
36  if ( m_trksForThisEvent != nullptr ) deleteTracks() ;
37 }
TrackContainer * m_trksForThisEvent
SimTrackManager::SimTrackManager ( const SimTrackManager )
privatedelete

Member Function Documentation

void SimTrackManager::addTkCaloStateInfo ( uint32_t  t,
const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &  p 
)
inline

Definition at line 80 of file SimTrackManager.h.

References mapTkCaloStateInfo.

Referenced by EventAction::addTkCaloStateInfo().

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  }
std::map< uint32_t, std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > > mapTkCaloStateInfo
void SimTrackManager::addTrack ( TrackWithHistory iTrack,
bool  inHistory,
bool  withAncestor 
)
inline

Definition at line 70 of file SimTrackManager.h.

References ancestorList, idsave, m_trksForThisEvent, TrackWithHistory::parentID(), and TrackWithHistory::trackID().

Referenced by EventAction::addTrack().

70  {
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  }
TrackContainer * m_trksForThisEvent
std::vector< std::pair< int, int > > idsave
unsigned int trackID() const
int parentID() const
std::vector< std::pair< int, int > > ancestorList
void SimTrackManager::cleanTkCaloStateInfoMap ( )

Definition at line 199 of file SimTrackManager.cc.

References mapTkCaloStateInfo, and edm::swap().

Referenced by EventAction::EndOfEventAction(), reset(), and trackContainer().

200 {
201  mapTkCaloStateInfo.clear();
202  std::map<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD > >().swap(mapTkCaloStateInfo);
203 }
std::map< uint32_t, std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > > mapTkCaloStateInfo
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
void SimTrackManager::cleanTracksWithHistory ( )

Definition at line 296 of file SimTrackManager.cc.

References fillMotherList(), idsave, lastTrack, LogDebug, m_trksForThisEvent, pileupDistInMC::num, TrackWithHistory::saved(), saveTrackAndItsBranch(), edm::second(), lumiQTWidget::t, and TrackWithHistory::trackID().

Referenced by EventAction::prepareForNewPrimary(), storeTracks(), and trackContainer().

296  {
297 
298  if ((*m_trksForThisEvent).empty() && idsave.empty()) { return; }
299 
300 #ifdef DebugLog
301  LogDebug("SimTrackManager")
302  << "SimTrackManager::cleanTracksWithHistory has "
303  << idsave.size()
304  << " mother-daughter relationships stored with lastTrack = " << lastTrack;
305 #endif
306 
307  if ( lastTrack > 0 && lastTrack >= (*m_trksForThisEvent).size() ) {
308  lastTrack = 0;
309  edm::LogError("SimTrackManager")
310  << " SimTrackManager::cleanTracksWithHistory track index corrupted";
311  }
312 
313  stable_sort(m_trksForThisEvent->begin()+lastTrack,m_trksForThisEvent->end(),trkIDLess());
314 
315  stable_sort(idsave.begin(),idsave.end());
316 
317 #ifdef DebugLog
318  LogDebug("SimTrackManager")
319  << " SimTrackManager::cleanTracksWithHistory knows " << m_trksForThisEvent->size()
320  << " tracks with history before branching";
321  for (unsigned int it =0; it <(*m_trksForThisEvent).size(); it++) {
322  LogDebug("SimTrackManager")
323  << " 1 - Track in position " << it << " G4 track number "
324  << (*m_trksForThisEvent)[it]->trackID()
325  << " mother " << (*m_trksForThisEvent)[it]->parentID()
326  << " status " << (*m_trksForThisEvent)[it]->saved();
327  }
328 #endif
329 
330  for (unsigned int it = lastTrack; it < m_trksForThisEvent->size(); it++)
331  {
332  TrackWithHistory * t = (*m_trksForThisEvent)[it];
333  if (t->saved()) { saveTrackAndItsBranch(t); }
334  }
335  unsigned int num = lastTrack;
336  for (unsigned int it = lastTrack; it < m_trksForThisEvent->size(); it++)
337  {
338  TrackWithHistory * t = (*m_trksForThisEvent)[it];
339  int g4ID = t->trackID();
340  if (t->saved() == true)
341  {
342  if (it>num) (*m_trksForThisEvent)[num] = t;
343  num++;
344  for (unsigned int itr=0; itr<idsave.size(); itr++) {
345  if ((idsave[itr]).first == g4ID) {
346  (idsave[itr]).second = g4ID;
347  break;
348  }
349  }
350  }
351  else
352  {
353  delete t;
354  }
355  }
356 
357  (*m_trksForThisEvent).resize(num);
358 
359 #ifdef DebugLog
360  LogDebug("SimTrackManager")
361  << " AFTER CLEANING, I GET " << (*m_trksForThisEvent).size()
362  << " tracks to be saved persistently";
363  for (unsigned int it = 0; it < (*m_trksForThisEvent).size(); it++) {
364  LogDebug("SimTrackManager")
365  << " Track in position " << it
366  << " G4 track number " << (*m_trksForThisEvent)[it]->trackID()
367  << " mother " << (*m_trksForThisEvent)[it]->parentID()
368  << " Status " << (*m_trksForThisEvent)[it]->saved()
369  << " id " << (*m_trksForThisEvent)[it]->particleID()
370  << " E(MeV)= " << (*m_trksForThisEvent)[it]->totalEnergy();
371  }
372 #endif
373 
374  fillMotherList();
375 
376  lastTrack = (*m_trksForThisEvent).size();
377 }
#define LogDebug(id)
bool saved() const
TrackContainer * m_trksForThisEvent
U second(std::pair< T, U > const &p)
std::vector< std::pair< int, int > > idsave
unsigned int trackID() const
void saveTrackAndItsBranch(TrackWithHistory *)
this saves a track and all its parents looping over the non ordered vector
unsigned int lastTrack
void SimTrackManager::cleanVertexMap ( )
private

Definition at line 192 of file SimTrackManager.cc.

References m_nVertices, and m_vertexMap.

Referenced by reset(), and setLHCTransportLink().

193 {
194  m_vertexMap.clear();
196  m_nVertices=0;
197 }
MotherParticleToVertexMap m_vertexMap
std::map< int, MapVertexPositionVector > MotherParticleToVertexMap
void SimTrackManager::deleteTracks ( )

Definition at line 61 of file SimTrackManager.cc.

References mps_fire::i, and m_trksForThisEvent.

Referenced by EventAction::EndOfEventAction(), trackContainer(), and ~SimTrackManager().

62 {
63  for (unsigned int i = 0; i < m_trksForThisEvent->size(); i++) {
64  delete (*m_trksForThisEvent)[i];
65  }
66  delete m_trksForThisEvent;
67  m_trksForThisEvent = nullptr;
68 }
TrackContainer * m_trksForThisEvent
void SimTrackManager::fillMotherList ( )
private

Definition at line 260 of file SimTrackManager.cc.

References ancestorList, plotBeamSpotDB::first, idsave, idSavedTrack(), lastHist, LogDebug, and gen::n.

Referenced by cleanTracksWithHistory(), and setLHCTransportLink().

261 {
262  if ( !ancestorList.empty() && lastHist > ancestorList.size() ) {
263  lastHist = ancestorList.size();
264  edm::LogError("SimTrackManager")
265  << " SimTrackManager::fillMotherList track index corrupted";
266  }
267  /*
268  std::cout << "### SimTrackManager::fillMotherList: "
269  << idsave.size() << " saved; ancestor: " << lastHist
270  << " " << ancestorList.size() << std::endl;
271  for (unsigned int i = 0; i< idsave.size(); ++i) {
272  std::cout << " ISV: Track ID = " << (idsave[i]).first
273  << " Mother ID = " << (idsave[i]).second << std::endl;
274  }
275  */
276  for (unsigned int n = lastHist; n < ancestorList.size(); n++) {
277 
278  int theMotherId = idSavedTrack((ancestorList[n]).first);
279  ancestorList[n].second = theMotherId;
280  /*
281  std::cout << " ANC: Track ID = " << (ancestorList[n]).first
282  << " Mother ID = " << (ancestorList[n]).second << std::endl;
283  */
284 #ifdef DebugLog
285  LogDebug("SimTrackManager") << "Track ID = " << (ancestorList[n]).first
286  << " Mother ID = " << (ancestorList[n]).second;
287 #endif
288  }
289 
290  lastHist = ancestorList.size();
291 
292  idsave.clear();
293 
294 }
#define LogDebug(id)
unsigned int lastHist
std::vector< std::pair< int, int > > idsave
int idSavedTrack(int) const
std::vector< std::pair< int, int > > ancestorList
int SimTrackManager::getOrCreateVertex ( TrackWithHistory trkH,
int  iParentID,
G4SimEvent simEvent 
)
private

Definition at line 155 of file SimTrackManager.cc.

References G4SimEvent::add(), trackerTree::check(), TrackWithHistory::creatorProcess(), plotBeamSpotDB::first, TrackWithHistory::globalTime(), gen::k, m_nVertices, m_vertexMap, class-composition::parent, mathSSE::sqrt(), and TrackWithHistory::vertexPosition().

Referenced by reallyStoreTracks(), and setLHCTransportLink().

157 {
158  int parent = iParentID;
159  int check = -1;
160 
161  for( std::vector<TrackWithHistory*>::const_iterator it = (*m_trksForThisEvent).begin();
162  it!= (*m_trksForThisEvent).end();it++)
163  {
164  if ((*it)->trackID() == uint32_t(parent)) {
165  check = 0;
166  break;
167  }
168  }
169 
170  if(check==-1) { parent = -1; }
171 
172  VertexMap::const_iterator iterator = m_vertexMap.find(parent);
173  if (iterator != m_vertexMap.end()) {
174 
175  // loop over saved vertices
176  for(unsigned int k=0; k<m_vertexMap[parent].size(); k++){
177  if(sqrt((trkH->vertexPosition()-(((m_vertexMap[parent])[k]).second)).Mag2())<0.001)
178  { return (((m_vertexMap[parent])[k]).first); }
179  }
180  }
181 
182  unsigned int ptype = 0;
183  const G4VProcess* pr = trkH->creatorProcess();
184  if(pr) { ptype = pr->GetProcessSubType(); }
185  simEvent->add(new G4SimVertex(trkH->vertexPosition(),trkH->globalTime(),parent,ptype));
187  m_nVertices++;
188  return (m_nVertices-1);
189 
190 }
void add(G4SimTrack *t)
Definition: G4SimEvent.h:34
T sqrt(T t)
Definition: SSEVec.h:18
std::pair< int, math::XYZVectorD > MapVertexPosition
this map contains association between vertex number and position
MotherParticleToVertexMap m_vertexMap
int k[5][pyjets_maxn]
const G4VProcess * creatorProcess() const
double globalTime() const
const math::XYZVectorD & vertexPosition() const
def check(config)
Definition: trackerTree.py:14
int SimTrackManager::giveMotherNeeded ( int  i) const
inline

Definition at line 93 of file SimTrackManager.h.

References mps_fire::i, idsave, and edm::second().

Referenced by CaloSD::saveHit().

93  {
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  }
U second(std::pair< T, U > const &p)
std::vector< std::pair< int, int > > idsave
int SimTrackManager::idSavedTrack ( int  id) const
private

Definition at line 205 of file SimTrackManager.cc.

References ancestorList, plotBeamSpotDB::first, triggerObjects_cff::id, globals_cff::id1, idsave, gen::n, notFound, and edm::second().

Referenced by fillMotherList(), and setLHCTransportLink().

206 {
207  int idMother = id;
208  if(id > 0) {
209  unsigned int n = idsave.size();
210  if(0 < n) {
211  int jmax = n - 1;
212  int j, id1;
213 
214  // first loop forward
215  bool notFound = true;
216  for(j=0; j<=jmax; ++j) {
217  if((idsave[j]).first == idMother) {
218  id1 = (idsave[j]).second;
219  if(0 == id1 || id1 == idMother) { return id1; }
220  jmax = j - 1;
221  idMother = id1;
222  notFound = false;
223  break;
224  }
225  }
226  if(notFound) { return 0; }
227 
228  // recursive loop
229  do {
230 
231  notFound = true;
232  // search ID scan backward
233  for(j=jmax; j>=0; --j) {
234  if((idsave[j]).first == idMother) {
235  id1 = (idsave[j]).second;
236  if(0 == id1 || id1 == idMother) { return id1; }
237  jmax = j - 1;
238  idMother = id1;
239  notFound = false;
240  break;
241  }
242  }
243  if(notFound) {
244  // ID not in the list of saved track - look into ancestors
245  jmax = ancestorList.size()-1;
246  for(j=jmax; j>=0; --j) {
247  if((ancestorList[j]).first == idMother) {
248  idMother = (ancestorList[j]).second;
249  return idMother;
250  }
251  }
252  return 0;
253  }
254  } while (!notFound);
255  }
256  }
257  return idMother;
258 }
U second(std::pair< T, U > const &p)
std::vector< std::pair< int, int > > idsave
static const GlobalPoint notFound(0, 0, 0)
std::vector< std::pair< int, int > > ancestorList
const SimTrackManager& SimTrackManager::operator= ( const SimTrackManager )
privatedelete

Referenced by setLHCTransportLink().

void SimTrackManager::reallyStoreTracks ( G4SimEvent simEvent)
private

Definition at line 115 of file SimTrackManager.cc.

References G4SimEvent::add(), TrackWithHistory::genParticleID(), getOrCreateVertex(), LogDebug, m_trksForThisEvent, mapTkCaloStateInfo, TrackWithHistory::momentum(), TrackWithHistory::parentID(), TrackWithHistory::particleID(), TrackWithHistory::totalEnergy(), and TrackWithHistory::trackID().

Referenced by setLHCTransportLink(), and storeTracks().

116 {
117  // loop over the (now ordered) vector and really save the tracks
118 #ifdef DebugLog
119  LogDebug("SimTrackManager")
120  << "Inside the reallyStoreTracks method object to be stored = "
121  << m_trksForThisEvent->size();
122 #endif
123 
124  for (unsigned int it = 0; it < m_trksForThisEvent->size(); it++)
125  {
126  TrackWithHistory * trkH = (*m_trksForThisEvent)[it];
127  // at this stage there is one vertex per track,
128  // so the vertex id of track N is also N
129  int ivertex = -1;
130  int ig;
131 
132  math::XYZVectorD pm(0.,0.,0.);
133  unsigned int iParentID = trkH->parentID();
134  for(unsigned int iit = 0; iit < m_trksForThisEvent->size(); ++iit)
135  {
136  if((*m_trksForThisEvent)[iit]->trackID()==iParentID){
137  pm = (*m_trksForThisEvent)[iit]->momentum();
138  break;
139  }
140  }
141  ig = trkH->genParticleID();
142  ivertex = getOrCreateVertex(trkH,iParentID,simEvent);
143  std::map<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> >::const_iterator cit =
144  mapTkCaloStateInfo.find(trkH->trackID());
145  std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> tcinfo;
146  if (cit != mapTkCaloStateInfo.end()){
147  tcinfo = cit->second;
148  }
149  simEvent->add(new G4SimTrack(trkH->trackID(),trkH->particleID(),
150  trkH->momentum(),trkH->totalEnergy(),
151  ivertex,ig,pm,tcinfo.first,tcinfo.second));
152  }
153 }
#define LogDebug(id)
int getOrCreateVertex(TrackWithHistory *, int, G4SimEvent *simEvent)
double totalEnergy() const
std::map< uint32_t, std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > > mapTkCaloStateInfo
TrackContainer * m_trksForThisEvent
void add(G4SimTrack *t)
Definition: G4SimEvent.h:34
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
unsigned int trackID() const
int particleID() const
int parentID() const
const math::XYZVectorD & momentum() const
int genParticleID() const
void SimTrackManager::reset ( void  )

Definition at line 42 of file SimTrackManager.cc.

References ancestorList, cleanTkCaloStateInfoMap(), cleanVertexMap(), mps_fire::i, idsave, lastHist, lastTrack, m_trksForThisEvent, and edm::swap().

Referenced by EventAction::BeginOfEventAction(), and trackContainer().

43 {
44  if (m_trksForThisEvent==nullptr) { m_trksForThisEvent = new TrackContainer(); }
45  else
46  {
47  for (unsigned int i = 0; i < m_trksForThisEvent->size(); i++) {
48  delete (*m_trksForThisEvent)[i];
49  }
50  delete m_trksForThisEvent;
52  }
55  std::vector<std::pair <int, int> >().swap(idsave);
56  ancestorList.clear();
57  lastTrack=0;
58  lastHist=0;
59 }
void cleanTkCaloStateInfoMap()
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
unsigned int lastHist
TrackContainer * m_trksForThisEvent
std::vector< TrackWithHistory * > TrackContainer
Definition: TrackContainer.h:8
std::vector< std::pair< int, int > > idsave
unsigned int lastTrack
std::vector< std::pair< int, int > > ancestorList
void SimTrackManager::resetGenID ( )
private

Definition at line 379 of file SimTrackManager.cc.

References TrackWithHistory::genParticleID(), m_trksForThisEvent, TrackWithHistory::setGenParticleID(), and theLHCTlink.

Referenced by setLHCTransportLink(), and storeTracks().

380 {
381  if ( theLHCTlink == nullptr ) return;
382 
383  for (unsigned int it = 0; it < m_trksForThisEvent->size(); it++)
384  {
385  TrackWithHistory * trkH = (*m_trksForThisEvent)[it];
386  int genParticleID_ = trkH->genParticleID();
387  if ( genParticleID_ == -1 ) { continue; }
388  else {
389  for ( unsigned int itrlink = 0; itrlink < (*theLHCTlink).size(); itrlink++ ) {
390  if ( (*theLHCTlink)[itrlink].afterHector() == genParticleID_ ) {
391  trkH->setGenParticleID( (*theLHCTlink)[itrlink].beforeHector() );
392  continue;
393  }
394  }
395  }
396  }
397 
398  theLHCTlink = nullptr;
399 
400 }
void setGenParticleID(int i)
TrackContainer * m_trksForThisEvent
const edm::LHCTransportLinkContainer * theLHCTlink
int genParticleID() const
void SimTrackManager::saveTrackAndItsBranch ( TrackWithHistory trkWHist)
private

this saves a track and all its parents looping over the non ordered vector

Definition at line 71 of file SimTrackManager.cc.

References Exception, m_trksForThisEvent, class-composition::parent, TrackWithHistory::parentID(), and TrackWithHistory::save().

Referenced by cleanTracksWithHistory(), and setLHCTransportLink().

72 {
73  using namespace std;
74  TrackWithHistory * trkH = trkWHist;
75  if (trkH == nullptr)
76  {
77  edm::LogError("SimTrackManager")
78  << " SimTrackManager::saveTrackAndItsBranch got 0 pointer ";
79  throw cms::Exception("SimTrackManager::saveTrackAndItsBranch")
80  << " cannot handle hits for tracking";
81  }
82  trkH->save();
83  unsigned int parent = trkH->parentID();
84 
85  TrackContainer::const_iterator tk_itr =
86  std::lower_bound((*m_trksForThisEvent).begin(),(*m_trksForThisEvent).end(),
88 
89  TrackWithHistory * tempTk = *tk_itr;
90 
91  if (tk_itr!=m_trksForThisEvent->end() && (*tk_itr)->trackID()==parent) {
92  saveTrackAndItsBranch(tempTk);
93  }
94 }
TrackContainer * m_trksForThisEvent
int parentID() const
void saveTrackAndItsBranch(TrackWithHistory *)
this saves a track and all its parents looping over the non ordered vector
void SimTrackManager::setCollapsePrimaryVertices ( bool  iSet)
inline

Definition at line 90 of file SimTrackManager.h.

References m_collapsePrimaryVertices.

Referenced by EventAction::EventAction().

90  {
92  }
bool m_collapsePrimaryVertices
void SimTrackManager::setLHCTransportLink ( const edm::LHCTransportLinkContainer thisLHCTlink)
inline

Definition at line 109 of file SimTrackManager.h.

References cleanVertexMap(), fillMotherList(), getOrCreateVertex(), idSavedTrack(), operator=(), reallyStoreTracks(), resetGenID(), saveTrackAndItsBranch(), SimTrackManager(), and theLHCTlink.

109  {
110  theLHCTlink = thisLHCTlink;
111  }
const edm::LHCTransportLinkContainer * theLHCTlink
void SimTrackManager::storeTracks ( G4SimEvent simEvent)

Definition at line 96 of file SimTrackManager.cc.

References ancestorList, cleanTracksWithHistory(), idsave, m_trksForThisEvent, reallyStoreTracks(), resetGenID(), and edm::swap().

Referenced by EventAction::EndOfEventAction(), and trackContainer().

97 {
99 
100  // fill the map with the final mother-daughter relationship
101  idsave.swap(ancestorList);
102  stable_sort(idsave.begin(),idsave.end());
103 
104  std::vector<std::pair<int,int> >().swap(ancestorList);
105 
106  // to get a backward compatible order
107  stable_sort(m_trksForThisEvent->begin(),m_trksForThisEvent->end(),trkIDLess());
108 
109  // to reset the GenParticle ID of a SimTrack to its pre-LHCTransport value
110  resetGenID();
111 
112  reallyStoreTracks(simEvent);
113 }
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
TrackContainer * m_trksForThisEvent
std::vector< std::pair< int, int > > idsave
void cleanTracksWithHistory()
void reallyStoreTracks(G4SimEvent *simEvent)
std::vector< std::pair< int, int > > ancestorList
const TrackContainer* SimTrackManager::trackContainer ( ) const
inline
bool SimTrackManager::trackExists ( unsigned int  i) const
inline

Definition at line 100 of file SimTrackManager.h.

References RemoveAddSevLevel::flag, mps_fire::i, and m_trksForThisEvent.

Referenced by CaloSD::saveHit().

100  {
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  }
TrackContainer * m_trksForThisEvent

Member Data Documentation

std::vector<std::pair<int, int> > SimTrackManager::ancestorList
private

Definition at line 137 of file SimTrackManager.h.

Referenced by addTrack(), fillMotherList(), idSavedTrack(), reset(), and storeTracks().

std::vector< std::pair<int, int> > SimTrackManager::idsave
private
unsigned int SimTrackManager::lastHist
private

Definition at line 140 of file SimTrackManager.h.

Referenced by fillMotherList(), and reset().

unsigned int SimTrackManager::lastTrack
private

Definition at line 139 of file SimTrackManager.h.

Referenced by cleanTracksWithHistory(), and reset().

bool SimTrackManager::m_collapsePrimaryVertices
private

Definition at line 133 of file SimTrackManager.h.

Referenced by setCollapsePrimaryVertices().

int SimTrackManager::m_nVertices
private

Definition at line 132 of file SimTrackManager.h.

Referenced by cleanVertexMap(), and getOrCreateVertex().

bool SimTrackManager::m_SaveSimTracks
private

Definition at line 130 of file SimTrackManager.h.

TrackContainer* SimTrackManager::m_trksForThisEvent
private
MotherParticleToVertexMap SimTrackManager::m_vertexMap
private

Definition at line 131 of file SimTrackManager.h.

Referenced by cleanVertexMap(), and getOrCreateVertex().

std::map<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD > > SimTrackManager::mapTkCaloStateInfo
private
const edm::LHCTransportLinkContainer* SimTrackManager::theLHCTlink
private

Definition at line 142 of file SimTrackManager.h.

Referenced by resetGenID(), and setLHCTransportLink().