CMS 3D CMS Logo

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

#include <SimG4Core/Application/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 34 of file SimTrackManager.h.

Member Typedef Documentation

this map contains association between vertex number and position

Definition at line 46 of file SimTrackManager.h.

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

Definition at line 47 of file SimTrackManager.h.

Definition at line 48 of file SimTrackManager.h.

Definition at line 49 of file SimTrackManager.h.

Constructor & Destructor Documentation

SimTrackManager::SimTrackManager ( bool  iCollapsePrimaryVertices = false)

Definition at line 39 of file SimTrackManager.cc.

Referenced by setLHCTransportLink().

39  :
40  m_trksForThisEvent(nullptr),m_nVertices(0),
41  m_collapsePrimaryVertices(iCollapsePrimaryVertices),
42  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 45 of file SimTrackManager.cc.

References deleteTracks(), and m_trksForThisEvent.

46 {
47  if ( m_trksForThisEvent != nullptr ) deleteTracks() ;
48 }
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 79 of file SimTrackManager.h.

References mapTkCaloStateInfo.

Referenced by EventAction::addTkCaloStateInfo().

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

Definition at line 69 of file SimTrackManager.h.

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

Referenced by EventAction::addTrack().

69  {
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  }
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 210 of file SimTrackManager.cc.

References mapTkCaloStateInfo, and edm::swap().

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

211 {
212  mapTkCaloStateInfo.clear();
213  std::map<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD > >().swap(mapTkCaloStateInfo);
214 }
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 307 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().

307  {
308 
309  if ((*m_trksForThisEvent).empty() && idsave.empty()) { return; }
310 
311 #ifdef DebugLog
312  LogDebug("SimTrackManager")
313  << "SimTrackManager::cleanTracksWithHistory has "
314  << idsave.size()
315  << " mother-daughter relationships stored with lastTrack = " << lastTrack;
316 #endif
317 
318  if ( lastTrack > 0 && lastTrack >= (*m_trksForThisEvent).size() ) {
319  lastTrack = 0;
320  edm::LogError("SimTrackManager")
321  << " SimTrackManager::cleanTracksWithHistory track index corrupted";
322  }
323 
324  stable_sort(m_trksForThisEvent->begin()+lastTrack,m_trksForThisEvent->end(),trkIDLess());
325 
326  stable_sort(idsave.begin(),idsave.end());
327 
328 #ifdef DebugLog
329  LogDebug("SimTrackManager")
330  << " SimTrackManager::cleanTracksWithHistory knows " << m_trksForThisEvent->size()
331  << " tracks with history before branching";
332  for (unsigned int it =0; it <(*m_trksForThisEvent).size(); it++) {
333  LogDebug("SimTrackManager")
334  << " 1 - Track in position " << it << " G4 track number "
335  << (*m_trksForThisEvent)[it]->trackID()
336  << " mother " << (*m_trksForThisEvent)[it]->parentID()
337  << " status " << (*m_trksForThisEvent)[it]->saved();
338  }
339 #endif
340 
341  for (unsigned int it = lastTrack; it < m_trksForThisEvent->size(); it++)
342  {
343  TrackWithHistory * t = (*m_trksForThisEvent)[it];
344  if (t->saved()) { saveTrackAndItsBranch(t); }
345  }
346  unsigned int num = lastTrack;
347  for (unsigned int it = lastTrack; it < m_trksForThisEvent->size(); it++)
348  {
349  TrackWithHistory * t = (*m_trksForThisEvent)[it];
350  int g4ID = t->trackID();
351  if (t->saved() == true)
352  {
353  if (it>num) (*m_trksForThisEvent)[num] = t;
354  num++;
355  for (unsigned int itr=0; itr<idsave.size(); itr++) {
356  if ((idsave[itr]).first == g4ID) {
357  (idsave[itr]).second = g4ID;
358  break;
359  }
360  }
361  }
362  else
363  {
364  delete t;
365  }
366  }
367 
368  (*m_trksForThisEvent).resize(num);
369 
370 #ifdef DebugLog
371  LogDebug("SimTrackManager")
372  << " AFTER CLEANING, I GET " << (*m_trksForThisEvent).size()
373  << " tracks to be saved persistently";
374  for (unsigned int it = 0; it < (*m_trksForThisEvent).size(); it++) {
375  LogDebug("SimTrackManager")
376  << " Track in position " << it
377  << " G4 track number " << (*m_trksForThisEvent)[it]->trackID()
378  << " mother " << (*m_trksForThisEvent)[it]->parentID()
379  << " Status " << (*m_trksForThisEvent)[it]->saved()
380  << " id " << (*m_trksForThisEvent)[it]->particleID()
381  << " E(MeV)= " << (*m_trksForThisEvent)[it]->totalEnergy();
382  }
383 #endif
384 
385  fillMotherList();
386 
387  lastTrack = (*m_trksForThisEvent).size();
388 }
#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 203 of file SimTrackManager.cc.

References m_nVertices, and m_vertexMap.

Referenced by reset(), and setLHCTransportLink().

204 {
205  m_vertexMap.clear();
207  m_nVertices=0;
208 }
MotherParticleToVertexMap m_vertexMap
std::map< int, MapVertexPositionVector > MotherParticleToVertexMap
void SimTrackManager::deleteTracks ( )

Definition at line 72 of file SimTrackManager.cc.

References mps_fire::i, and m_trksForThisEvent.

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

73 {
74  for (unsigned int i = 0; i < m_trksForThisEvent->size(); i++) {
75  delete (*m_trksForThisEvent)[i];
76  }
77  delete m_trksForThisEvent;
78  m_trksForThisEvent = nullptr;
79 }
TrackContainer * m_trksForThisEvent
void SimTrackManager::fillMotherList ( )
private

Definition at line 271 of file SimTrackManager.cc.

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

Referenced by cleanTracksWithHistory(), and setLHCTransportLink().

272 {
273  if ( !ancestorList.empty() && lastHist > ancestorList.size() ) {
274  lastHist = ancestorList.size();
275  edm::LogError("SimTrackManager")
276  << " SimTrackManager::fillMotherList track index corrupted";
277  }
278  /*
279  std::cout << "### SimTrackManager::fillMotherList: "
280  << idsave.size() << " saved; ancestor: " << lastHist
281  << " " << ancestorList.size() << std::endl;
282  for (unsigned int i = 0; i< idsave.size(); ++i) {
283  std::cout << " ISV: Track ID = " << (idsave[i]).first
284  << " Mother ID = " << (idsave[i]).second << std::endl;
285  }
286  */
287  for (unsigned int n = lastHist; n < ancestorList.size(); n++) {
288 
289  int theMotherId = idSavedTrack((ancestorList[n]).first);
290  ancestorList[n].second = theMotherId;
291  /*
292  std::cout << " ANC: Track ID = " << (ancestorList[n]).first
293  << " Mother ID = " << (ancestorList[n]).second << std::endl;
294  */
295 #ifdef DebugLog
296  LogDebug("SimTrackManager") << "Track ID = " << (ancestorList[n]).first
297  << " Mother ID = " << (ancestorList[n]).second;
298 #endif
299  }
300 
301  lastHist = ancestorList.size();
302 
303  idsave.clear();
304 
305 }
#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 166 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().

168 {
169  int parent = iParentID;
170  int check = -1;
171 
172  for( std::vector<TrackWithHistory*>::const_iterator it = (*m_trksForThisEvent).begin();
173  it!= (*m_trksForThisEvent).end();it++)
174  {
175  if ((*it)->trackID() == uint32_t(parent)) {
176  check = 0;
177  break;
178  }
179  }
180 
181  if(check==-1) { parent = -1; }
182 
183  VertexMap::const_iterator iterator = m_vertexMap.find(parent);
184  if (iterator != m_vertexMap.end()) {
185 
186  // loop over saved vertices
187  for(unsigned int k=0; k<m_vertexMap[parent].size(); k++){
188  if(sqrt((trkH->vertexPosition()-(((m_vertexMap[parent])[k]).second)).Mag2())<0.001)
189  { return (((m_vertexMap[parent])[k]).first); }
190  }
191  }
192 
193  unsigned int ptype = 0;
194  const G4VProcess* pr = trkH->creatorProcess();
195  if(pr) { ptype = pr->GetProcessSubType(); }
196  simEvent->add(new G4SimVertex(trkH->vertexPosition(),trkH->globalTime(),parent,ptype));
198  m_nVertices++;
199  return (m_nVertices-1);
200 
201 }
void add(G4SimTrack *t)
Definition: G4SimEvent.h:35
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 92 of file SimTrackManager.h.

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

Referenced by CaloSD::saveHit().

92  {
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  }
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 216 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().

217 {
218  int idMother = id;
219  if(id > 0) {
220  unsigned int n = idsave.size();
221  if(0 < n) {
222  int jmax = n - 1;
223  int j, id1;
224 
225  // first loop forward
226  bool notFound = true;
227  for(j=0; j<=jmax; ++j) {
228  if((idsave[j]).first == idMother) {
229  id1 = (idsave[j]).second;
230  if(0 == id1 || id1 == idMother) { return id1; }
231  jmax = j - 1;
232  idMother = id1;
233  notFound = false;
234  break;
235  }
236  }
237  if(notFound) { return 0; }
238 
239  // recursive loop
240  do {
241 
242  notFound = true;
243  // search ID scan backward
244  for(j=jmax; j>=0; --j) {
245  if((idsave[j]).first == idMother) {
246  id1 = (idsave[j]).second;
247  if(0 == id1 || id1 == idMother) { return id1; }
248  jmax = j - 1;
249  idMother = id1;
250  notFound = false;
251  break;
252  }
253  }
254  if(notFound) {
255  // ID not in the list of saved track - look into ancestors
256  jmax = ancestorList.size()-1;
257  for(j=jmax; j>=0; --j) {
258  if((ancestorList[j]).first == idMother) {
259  idMother = (ancestorList[j]).second;
260  return idMother;
261  }
262  }
263  return 0;
264  }
265  } while (!notFound);
266  }
267  }
268  return idMother;
269 }
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 126 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().

127 {
128  // loop over the (now ordered) vector and really save the tracks
129 #ifdef DebugLog
130  LogDebug("SimTrackManager")
131  << "Inside the reallyStoreTracks method object to be stored = "
132  << m_trksForThisEvent->size();
133 #endif
134 
135  for (unsigned int it = 0; it < m_trksForThisEvent->size(); it++)
136  {
137  TrackWithHistory * trkH = (*m_trksForThisEvent)[it];
138  // at this stage there is one vertex per track,
139  // so the vertex id of track N is also N
140  int ivertex = -1;
141  int ig;
142 
143  math::XYZVectorD pm(0.,0.,0.);
144  unsigned int iParentID = trkH->parentID();
145  for(unsigned int iit = 0; iit < m_trksForThisEvent->size(); ++iit)
146  {
147  if((*m_trksForThisEvent)[iit]->trackID()==iParentID){
148  pm = (*m_trksForThisEvent)[iit]->momentum();
149  break;
150  }
151  }
152  ig = trkH->genParticleID();
153  ivertex = getOrCreateVertex(trkH,iParentID,simEvent);
154  std::map<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> >::const_iterator cit =
155  mapTkCaloStateInfo.find(trkH->trackID());
156  std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> tcinfo;
157  if (cit != mapTkCaloStateInfo.end()){
158  tcinfo = cit->second;
159  }
160  simEvent->add(new G4SimTrack(trkH->trackID(),trkH->particleID(),
161  trkH->momentum(),trkH->totalEnergy(),
162  ivertex,ig,pm,tcinfo.first,tcinfo.second));
163  }
164 }
#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:35
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 53 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().

54 {
55  if (m_trksForThisEvent==nullptr) { m_trksForThisEvent = new TrackContainer(); }
56  else
57  {
58  for (unsigned int i = 0; i < m_trksForThisEvent->size(); i++) {
59  delete (*m_trksForThisEvent)[i];
60  }
61  delete m_trksForThisEvent;
63  }
66  std::vector<std::pair <int, int> >().swap(idsave);
67  ancestorList.clear();
68  lastTrack=0;
69  lastHist=0;
70 }
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 390 of file SimTrackManager.cc.

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

Referenced by setLHCTransportLink(), and storeTracks().

391 {
392  if ( theLHCTlink == nullptr ) return;
393 
394  for (unsigned int it = 0; it < m_trksForThisEvent->size(); it++)
395  {
396  TrackWithHistory * trkH = (*m_trksForThisEvent)[it];
397  int genParticleID_ = trkH->genParticleID();
398  if ( genParticleID_ == -1 ) { continue; }
399  else {
400  for ( unsigned int itrlink = 0; itrlink < (*theLHCTlink).size(); itrlink++ ) {
401  if ( (*theLHCTlink)[itrlink].afterHector() == genParticleID_ ) {
402  trkH->setGenParticleID( (*theLHCTlink)[itrlink].beforeHector() );
403  continue;
404  }
405  }
406  }
407  }
408 
409  theLHCTlink = nullptr;
410 
411 }
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 82 of file SimTrackManager.cc.

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

Referenced by cleanTracksWithHistory(), and setLHCTransportLink().

83 {
84  using namespace std;
85  TrackWithHistory * trkH = trkWHist;
86  if (trkH == nullptr)
87  {
88  edm::LogError("SimTrackManager")
89  << " SimTrackManager::saveTrackAndItsBranch got 0 pointer ";
90  throw cms::Exception("SimTrackManager::saveTrackAndItsBranch")
91  << " cannot handle hits for tracking";
92  }
93  trkH->save();
94  unsigned int parent = trkH->parentID();
95 
96  TrackContainer::const_iterator tk_itr =
97  std::lower_bound((*m_trksForThisEvent).begin(),(*m_trksForThisEvent).end(),
99 
100  TrackWithHistory * tempTk = *tk_itr;
101 
102  if (tk_itr!=m_trksForThisEvent->end() && (*tk_itr)->trackID()==parent) {
103  saveTrackAndItsBranch(tempTk);
104  }
105 }
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 89 of file SimTrackManager.h.

References m_collapsePrimaryVertices.

Referenced by EventAction::EventAction().

89  {
91  }
bool m_collapsePrimaryVertices
void SimTrackManager::setLHCTransportLink ( const edm::LHCTransportLinkContainer thisLHCTlink)
inline

Definition at line 108 of file SimTrackManager.h.

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

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

Definition at line 107 of file SimTrackManager.cc.

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

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

108 {
110 
111  // fill the map with the final mother-daughter relationship
112  idsave.swap(ancestorList);
113  stable_sort(idsave.begin(),idsave.end());
114 
115  std::vector<std::pair<int,int> >().swap(ancestorList);
116 
117  // to get a backward compatible order
118  stable_sort(m_trksForThisEvent->begin(),m_trksForThisEvent->end(),trkIDLess());
119 
120  // to reset the GenParticle ID of a SimTrack to its pre-LHCTransport value
121  resetGenID();
122 
123  reallyStoreTracks(simEvent);
124 }
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 99 of file SimTrackManager.h.

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

Referenced by CaloSD::saveHit().

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

Member Data Documentation

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

Definition at line 136 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 139 of file SimTrackManager.h.

Referenced by fillMotherList(), and reset().

unsigned int SimTrackManager::lastTrack
private

Definition at line 138 of file SimTrackManager.h.

Referenced by cleanTracksWithHistory(), and reset().

bool SimTrackManager::m_collapsePrimaryVertices
private

Definition at line 132 of file SimTrackManager.h.

Referenced by setCollapsePrimaryVertices().

int SimTrackManager::m_nVertices
private

Definition at line 131 of file SimTrackManager.h.

Referenced by cleanVertexMap(), and getOrCreateVertex().

bool SimTrackManager::m_SaveSimTracks
private

Definition at line 129 of file SimTrackManager.h.

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

Definition at line 130 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 141 of file SimTrackManager.h.

Referenced by resetGenID(), and setLHCTransportLink().