23 #include "G4VProcess.hh"
39 m_trksForThisEvent(0),m_nVertices(0),
40 m_collapsePrimaryVertices(iCollapsePrimaryVertices),
41 lastTrack(0),lastHist(0),theLHCTlink(0){}
58 delete (*m_trksForThisEvent)[
i];
65 std::vector<std::pair <int, int> >().
swap(
idsave);
74 delete (*m_trksForThisEvent)[
i];
88 <<
" SimTrackManager::saveTrackAndItsBranch got 0 pointer ";
92 unsigned int parent = trkH->parentID();
94 TrackContainer::const_iterator tk_itr =
95 std::lower_bound((*m_trksForThisEvent).begin(),(*m_trksForThisEvent).end(),
129 <<
"Inside the reallyStoreTracks method object to be stored = "
142 unsigned int iParentID = trkH->
parentID();
146 pm = (*m_trksForThisEvent)[iit]->momentum();
152 std::map<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> >::const_iterator cit =
154 std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> tcinfo;
156 tcinfo = cit->second;
160 ivertex,ig,pm,tcinfo.first,tcinfo.second));
170 for( std::vector<TrackWithHistory*>::const_iterator it = (*m_trksForThisEvent).begin();
171 it!= (*m_trksForThisEvent).end();it++)
173 if ((*it)->trackID() == uint32_t(parent)) {
179 if(check==-1) { parent = -1; }
181 VertexMap::const_iterator iterator =
m_vertexMap.find(parent);
191 unsigned int ptype = 0;
193 if(pr) { ptype = pr->GetProcessSubType(); }
218 unsigned int n =
idsave.size();
225 for(j=0; j<=jmax; ++
j) {
228 if(0 == id1 || id1 == idMother) {
return id1; }
235 if(notFound) {
return 0; }
242 for(j=jmax; j>=0; --
j) {
243 if((
idsave[j]).first == idMother) {
245 if(0 == id1 || id1 == idMother) {
return id1; }
255 for(j=jmax; j>=0; --
j) {
274 <<
" SimTrackManager::fillMotherList track index corrupted";
309 if ((*m_trksForThisEvent).size() == 0 &&
idsave.size() == 0) {
return; }
313 <<
"SimTrackManager::cleanTracksWithHistory has "
315 <<
" mother-daughter relationships stored with lastTrack = " <<
lastTrack;
321 <<
" SimTrackManager::cleanTracksWithHistory track index corrupted";
331 <<
" tracks with history before branching";
332 for (
unsigned int it =0; it <(*m_trksForThisEvent).size(); it++) {
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();
351 if (t->
saved() ==
true)
353 if (it>
num) (*m_trksForThisEvent)[
num] =
t;
355 for (
unsigned int itr=0; itr<
idsave.size(); itr++) {
356 if ((
idsave[itr]).first == g4ID) {
368 (*m_trksForThisEvent).resize(
num);
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++) {
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();
385 lastTrack = (*m_trksForThisEvent).size();
397 if ( genParticleID_ == -1 ) {
continue; }
399 for (
unsigned int itrlink = 0; itrlink < (*theLHCTlink).size(); itrlink++ ) {
400 if ( (*
theLHCTlink)[itrlink].afterHector() == genParticleID_ ) {
void swap(ora::Record &rh, ora::Record &lh)
int getOrCreateVertex(TrackWithHistory *, int, G4SimEvent *simEvent)
double totalEnergy() const
SimTrackManager(bool iCollapsePrimaryVertices=false)
void setGenParticleID(int i)
void cleanTkCaloStateInfoMap()
std::map< uint32_t, std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > > mapTkCaloStateInfo
virtual ~SimTrackManager()
TrackContainer * m_trksForThisEvent
U second(std::pair< T, U > const &p)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
std::vector< TrackWithHistory * > TrackContainer
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
std::vector< std::pair< int, int > > idsave
unsigned int trackID() const
void cleanTracksWithHistory()
std::pair< int, math::XYZVectorD > MapVertexPosition
this map contains association between vertex number and position
MotherParticleToVertexMap m_vertexMap
void storeTracks(G4SimEvent *simEvent)
int idSavedTrack(int) const
const G4VProcess * creatorProcess() const
std::map< int, MapVertexPositionVector > MotherParticleToVertexMap
const math::XYZVectorD & momentum() const
void saveTrackAndItsBranch(TrackWithHistory *)
this saves a track and all its parents looping over the non ordered vector
double globalTime() const
static const GlobalPoint notFound(0, 0, 0)
const edm::LHCTransportLinkContainer * theLHCTlink
void reallyStoreTracks(G4SimEvent *simEvent)
std::vector< std::pair< int, int > > ancestorList
const math::XYZVectorD & vertexPosition() const
int genParticleID() const