diff --git a/ForwardDetectors/ForwardTransport/src/ForwardTransportModel.cxx b/ForwardDetectors/ForwardTransport/src/ForwardTransportModel.cxx index d00068ca63ddde7c76367d0fe4c18b5ab00754ff..6ba8097f6007c07e1daf21adc5f3bbfd6b473a99 100644 --- a/ForwardDetectors/ForwardTransport/src/ForwardTransportModel.cxx +++ b/ForwardDetectors/ForwardTransport/src/ForwardTransportModel.cxx @@ -155,7 +155,7 @@ void ForwardTransportModel::DoIt(const G4FastTrack& fastTrack, G4FastStep& fastS pdgcode, HepMC::FORWARDTRANSPORTMODELSTATUS); gVertex->add_particle_out(gParticle); - HepMC::suggest_barcode(gParticle, HepMC::barcode(part)+HepMC::SIM_REGENERATION_INCREMENT); + //HepMC::suggest_barcode(gParticle, HepMC::barcode(part)+HepMC::SIM_REGENERATION_INCREMENT);//FIXME // Create secondary on the Geant4 side fastStep.SetNumberOfSecondaryTracks(1); diff --git a/Generators/TruthUtils/TruthUtils/MagicNumbers.h b/Generators/TruthUtils/TruthUtils/MagicNumbers.h index 53d575c929f8e132cdb44e820d62b51803e46c7c..a0ff87d8e3106a511d93dd0a5ec4f21c71eea9b1 100644 --- a/Generators/TruthUtils/TruthUtils/MagicNumbers.h +++ b/Generators/TruthUtils/TruthUtils/MagicNumbers.h @@ -46,45 +46,69 @@ constexpr int crazyParticleBarcode(std::numeric_limits<int32_t>::max()); constexpr int INVALID_PARTICLE_BARCODE = -1; /// @brief Method to establish if a particle (or barcode) was created during the simulation -template <class T> inline bool is_simulation_particle(const T& p){ return (p->barcode()>SIM_BARCODE_THRESHOLD);} -template <> inline bool is_simulation_particle(const int& b){ return (b>SIM_BARCODE_THRESHOLD);} -#if defined(HEPMC3) && !defined(XAOD_STANDALONE) -template <> inline bool is_simulation_particle(const ConstGenParticlePtr& p){ return (barcode(p)>SIM_BARCODE_THRESHOLD);} -template <> inline bool is_simulation_particle(const GenParticlePtr& p){ return (barcode(p)>SIM_BARCODE_THRESHOLD);} -#endif +template <class T> inline bool is_simulation_particle(const T& p){ return (p->status()>SIM_STATUS_INCREMENT);} /// @brief Method to return how many interactions a particle has undergone during simulation. -template <class T> inline int generations(const T& p){ return (p->barcode()/SIM_REGENERATION_INCREMENT);} -template <> inline int generations(const int& b){ return (b/SIM_REGENERATION_INCREMENT);} -#if defined(HEPMC3) && !defined(XAOD_STANDALONE) -template <> inline int generations(const ConstGenParticlePtr& p){ return (barcode(p)/SIM_REGENERATION_INCREMENT);} -template <> inline int generations(const GenParticlePtr& p){ return (barcode(p)/SIM_REGENERATION_INCREMENT);} -#endif +template <class T> inline int generations(const T& p){ return (p->status()/SIM_STATUS_INCREMENT);} /// @brief Method to establish if the vertex was created during simulation -template <class T> inline bool is_simulation_vertex(const T& p){ return (p->barcode()<-SIM_BARCODE_THRESHOLD);} -template <> inline bool is_simulation_vertex(const int& p){ return (p<-SIM_BARCODE_THRESHOLD);} +template <class T> inline bool is_simulation_vertex(const T& p){ return (p->status()>SIM_STATUS_INCREMENT);} + + + + +template <class T> int unique_id(const T& p1){ return p1->barcode();} #if defined(HEPMC3) && !defined(XAOD_STANDALONE) -template <> inline bool is_simulation_vertex(const ConstGenVertexPtr& p){ return (barcode(p)<-SIM_BARCODE_THRESHOLD);} -template <> inline bool is_simulation_vertex(const GenVertexPtr& p){ return (barcode(p)<-SIM_BARCODE_THRESHOLD);} +template <> inline int unique_id(const ConstGenParticlePtr& p1){ return p1->id();} +template <> inline int unique_id(const GenParticlePtr& p1){ return p1->id();} #endif -template <class T1,class T2, std::enable_if_t< !std::is_arithmetic<T1>::value && !std::is_arithmetic<T2>::value, bool> = true > -inline bool is_same_generator_particle(const T1& p1,const T2& p2) { return p1 && p2 && (p1->barcode() % SIM_REGENERATION_INCREMENT == p2->barcode() % SIM_REGENERATION_INCREMENT); } +template <class T> inline void get_particle_history(const T& p, std::deque<int>& out, int direction=0) { + if (direction < 0) { + if (p->status()>SIM_STATUS_INCREMENT) { + auto pv = p->production_vertex(); + if (pv) { + for (auto pa: pv->particles_in()) { + if (pa->pdg_id() != p->pdg_id()) continue; + out.push_front(unique_id(p)); + get_particle_history(pa,out,-1); + break; + } + } + } + } + if (direction > 0) { + if (p->status()>SIM_STATUS_INCREMENT) { + auto pv = p->end_vertex(); + if (pv) { + for (auto pa: pv->particles_out()) { + if (pa->pdg_id() != p->pdg_id()) continue; + out.push_back(unique_id(p)); + get_particle_history(pa,out,1); + break; + } + } + } + } +} +template <class T> inline std::deque<int> simulation_history(const T& p, int direction ) { std::deque<int> res; res.push_back(unique_id(p)); get_particle_history(p, res, direction); return res;} -template <class T1,class T2, std::enable_if_t< !std::is_arithmetic<T1>::value && std::is_arithmetic<T2>::value, bool> = true > -inline bool is_same_generator_particle(const T1& p1,const T2& p2) { return p1 && (p1->barcode() % SIM_REGENERATION_INCREMENT == p2 % SIM_REGENERATION_INCREMENT); } -template <class T1,class T2, std::enable_if_t< std::is_arithmetic<T1>::value && std::is_arithmetic<T2>::value, bool> = true > -inline bool is_same_generator_particle(const T1& p1,const T2& p2) { return p1 % SIM_REGENERATION_INCREMENT == p2 % SIM_REGENERATION_INCREMENT; } -/// @brief Method to check if the first particle is a descendant of the second in the simulation, i.e. particle p1 was produced simulations particle p2. -template <class T1,class T2, std::enable_if_t< !std::is_arithmetic<T1>::value && !std::is_arithmetic<T2>::value, bool> = true > -inline bool is_sim_descendant(const T1& p1,const T2& p2) { return p1 && p2 && (p1->barcode() % SIM_REGENERATION_INCREMENT == p2->barcode());} +template <class T1, class T2, std::enable_if_t<std::is_same<T1,T2>::value, bool> = true > +inline bool is_same_generator_particle(const T1& p1,const T2& p2) { + auto p1orig = simulation_history(p1,-1); + auto p2orig = simulation_history(p2,-1); + return unique_id(p1orig.front())==unique_id(p2orig.front()); +} +template <class T1, class T2, std::enable_if_t< !std::is_same<T1,T2>::value, bool> = true > +inline bool is_same_generator_particle(const T1& p1,const T2& p2) { + int b = unique_id(p1); + auto hist = simulation_history(p2); + return (std::find(hist.begin(),hist.end(),b) != hist.end()); +} -template <class T1,class T2, std::enable_if_t< std::is_arithmetic<T1>::value && !std::is_arithmetic<T2>::value, bool> = true > -inline bool is_sim_descendant(const T1& p1,const T2& p2) { return p2 && (p1 % SIM_REGENERATION_INCREMENT == p2->barcode()); } template <class T> int unique_id(const T& p1){ return p1->barcode();} #if defined(HEPMC3) && !defined(XAOD_STANDALONE) @@ -123,5 +147,46 @@ template <class T> inline void get_particle_history(const T& p, std::deque<int>& } template <class T> inline std::deque<int> simulation_history(const T& p, int direction ) { std::deque<int> res; res.push_back(unique_id(p)); get_particle_history(p, res, direction); return res;} + +/********************************************/ +template <class T> old_to_new_simulation_scheme(T& evt) { + for (auto p: evt->particles()) p->set_status( (is_simulation_particle(p) ? (SIM_STATUS_THRESHOLD+SIM_STATUS_INCREMENT*generations(p)) : 0) + p->status()); + for (auto v: evt->vertices()) v->set_status((is_simulation_vertex(v) ? (SIM_STATUS_THRESHOLD+SIM_STATUS_INCREMENT*generations(v)) : 0) + v->status()); +} + +void propagate_code(HepMC::GenParticlePtr& p) { +int child_id = 0; +auto v = p->end_vertex(); +if (!v) return; +for ( auto pp: v->particles_out()) { + if (p->pdg_id() != pp->pdg_id()) continue; + HepMC::suggest_barcode(pp,HepMC::barcode(p)+SIM_STATUS_INCREMENT); + child_id = pp->id(); + break; +} +for ( auto pp: v->particles_out()) { + if (pp->id()==child_id) continue; + HepMC::suggest_barcode(pp,HepMC::barcode(p)+SIM_STATUS_THRESHOLD); +} +for ( auto pp: v->particles_out()) propagate_code(pp); +} + +template <class T> new_to_old_simulation_scheme(T& ev) { + for (auto v: evt->vertices()) { + auto pin = v->particles_in(); + if (v.size() != 1) continue; + auto p = pin.front(); + if (HepMC::is_simulation_particle(p)) continue; + bool isoriginal = false; + for (auto pp: v->particles_out()) if (is_simulation_particle(pp)) isoriginal=true; + if (!isoriginal) continue; + propagate_code(pin); + } +} + + + +/*******************************************/ + } #endif diff --git a/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/src/HitsFillerAlg.cxx b/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/src/HitsFillerAlg.cxx index 6b282e4f24953b74b3cce05efec4d74a39c3857c..5db8b610feee95a5e8ae741b4285fc6bd274432e 100644 --- a/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/src/HitsFillerAlg.cxx +++ b/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/src/HitsFillerAlg.cxx @@ -99,6 +99,7 @@ StatusCode HitsFillerAlg::fillTrackRecordCollection() CLHEP::Hep3Vector p(j+11,j+12,j+13); CLHEP::Hep3Vector x(j+14,j+15,j+16); c->Emplace(j, // PDG + 0, //STATUS (j+10)*1000, // energy p, //position x, //momentum diff --git a/Simulation/G4Sim/MCTruthBase/src/RecordingEnvelope.cxx b/Simulation/G4Sim/MCTruthBase/src/RecordingEnvelope.cxx index d1e9c39b6a6bbce83ca16dadd92d20d8b048c066..1d92a68e6e3d24b4d999c3805e8c81ff9dcdfe65 100644 --- a/Simulation/G4Sim/MCTruthBase/src/RecordingEnvelope.cxx +++ b/Simulation/G4Sim/MCTruthBase/src/RecordingEnvelope.cxx @@ -81,7 +81,7 @@ void RecordingEnvelope::AddTrackRecord(const G4Step* aStep) G4StepPoint *preStep=aStep->GetPreStepPoint(); G4VPhysicalVolume *preVol=preStep->GetPhysicalVolume(); - m_trackRecordCollection->Emplace(pdgcode,ener,mom,pos,time,barcode,preVol->GetName()); + m_trackRecordCollection->Emplace(pdgcode,0,ener,mom,pos,time,barcode,preVol->GetName()); return; } diff --git a/Simulation/G4Sim/TrackRecord/TrackRecord/TrackRecord.h b/Simulation/G4Sim/TrackRecord/TrackRecord/TrackRecord.h index 46ede8bdb2f8a51184cb0661e788152112be7046..7fbb187d1829752b74d8ad74316e1a9e2802e981 100755 --- a/Simulation/G4Sim/TrackRecord/TrackRecord/TrackRecord.h +++ b/Simulation/G4Sim/TrackRecord/TrackRecord/TrackRecord.h @@ -10,20 +10,20 @@ class TrackRecord { public: /** @brief Default constructor */ - TrackRecord() : m_PDG_code(0), m_Energy(0), m_Momentum(0,0,0), m_Position(0,0,0), m_Time(0), m_barCode(0), m_volName("") {} + TrackRecord() : m_PDG_code(0),m_status(0), m_Energy(0), m_Momentum(0,0,0), m_Position(0,0,0), m_Time(0), m_barCode(0), m_volName("") {} /** @brief Default destructor */ virtual ~TrackRecord() {} /** @brief Constructor */ - TrackRecord(int pdg, double e, const CLHEP::Hep3Vector& p, const CLHEP::Hep3Vector& x, double t, int bc, const std::string& vn) - : m_PDG_code(pdg), m_Energy(e), m_Momentum(p), m_Position(x), m_Time(t), m_barCode(bc), m_volName(vn) {} + TrackRecord(int pdg, int status, double e, const CLHEP::Hep3Vector& p, const CLHEP::Hep3Vector& x, double t, int bc, const std::string& vn) + : m_PDG_code(pdg), m_status(status), m_Energy(e), m_Momentum(p), m_Position(x), m_Time(t), m_barCode(bc), m_volName(vn) {} /** @brief Constructor */ - TrackRecord(const TrackRecord& trc):m_PDG_code(trc.m_PDG_code), m_Energy(trc.m_Energy), + TrackRecord(const TrackRecord& trc):m_PDG_code(trc.m_PDG_code), m_status(trc.m_status), m_Energy(trc.m_Energy), m_Momentum(trc.m_Momentum), m_Position(trc.m_Position), m_Time(trc.m_Time), m_barCode(trc.m_barCode), m_volName(trc.m_volName){} /** @brief Assignement Operator */ TrackRecord &operator=(const TrackRecord& trc) { if(this!=&trc) { - m_PDG_code = trc.m_PDG_code; m_Energy = trc.m_Energy; + m_PDG_code = trc.m_PDG_code; m_status = trc.m_status; m_Energy = trc.m_Energy; m_Momentum = trc.m_Momentum; m_Position = trc.m_Position; m_Time = trc.m_Time; m_barCode = trc.m_barCode; m_volName = trc.m_volName; @@ -39,6 +39,8 @@ public: void SetMomentum(CLHEP::Hep3Vector e) {m_Momentum=e;} /** @brief Set PDG code */ void SetPDGCode(int pcode) {m_PDG_code=pcode;} + /** @brief Set status */ + void SetStatus(int scode) {m_status=scode;} /** @brief Energy */ double GetEnergy() const {return m_Energy;} /** @brief Position */ @@ -60,6 +62,8 @@ public: int GetBarCode() const {return m_barCode;} /** @brief bar code. Alias function. */ int barcode() const {return GetBarCode();} + /** @brief status. */ + int status() const {return m_status;} /** @brief Set Volume name */ void SetVolName(const std::string& theName){m_volName=theName;} /** @brief Volume name */ @@ -67,6 +71,7 @@ public: private: int m_PDG_code; + int m_status; double m_Energy; CLHEP::Hep3Vector m_Momentum; CLHEP::Hep3Vector m_Position; diff --git a/Simulation/G4SimCnv/G4SimTPCnv/test/TrackRecordCnv_p1_test.cxx b/Simulation/G4SimCnv/G4SimTPCnv/test/TrackRecordCnv_p1_test.cxx index 8f7d73a520a7e21ce3eb60cd0fb8725054370650..a6639840bcf17ad23ec2ee662b773ee8fad19dee 100644 --- a/Simulation/G4SimCnv/G4SimTPCnv/test/TrackRecordCnv_p1_test.cxx +++ b/Simulation/G4SimCnv/G4SimTPCnv/test/TrackRecordCnv_p1_test.cxx @@ -60,7 +60,9 @@ void test1 ATLAS_NOT_THREAD_SAFE () std::cout << "test1\n"; Athena_test::Leakcheck check; - TrackRecord trans1 (123, 124.5, + TrackRecord trans1 (123, + 0, + 124.5, CLHEP::Hep3Vector (10.5, 11.5, 12.5), CLHEP::Hep3Vector (20.5, 21.5, 22.5), 125.5, diff --git a/Simulation/G4Utilities/G4UserActions/src/CosmicPerigeeAction.cxx b/Simulation/G4Utilities/G4UserActions/src/CosmicPerigeeAction.cxx index bb3b800808e747af4eeb91328e2725bed5467fcc..16c69277568e240bb71ba655e61e1e67edb878c4 100644 --- a/Simulation/G4Utilities/G4UserActions/src/CosmicPerigeeAction.cxx +++ b/Simulation/G4Utilities/G4UserActions/src/CosmicPerigeeAction.cxx @@ -114,7 +114,7 @@ namespace G4UA // Create the TimedTrackRecord TrackHelper trHelp(aStep->GetTrack()); int barcode = trHelp.GetBarcode(); - m_trackRecordCollection->Emplace(pdgcode, ener, mom, pos, time, barcode, + m_trackRecordCollection->Emplace(pdgcode, 0, ener, mom, pos, time, barcode, preVol->GetName()); } diff --git a/Simulation/G4Utilities/TrackWriteFastSim/src/TrackFastSimSD.cxx b/Simulation/G4Utilities/TrackWriteFastSim/src/TrackFastSimSD.cxx index 9cbddd001aa70439f9faf3e3997135b99c38e488..3ac044b24cfc79e3cdd7133c7012054183591845 100644 --- a/Simulation/G4Utilities/TrackWriteFastSim/src/TrackFastSimSD.cxx +++ b/Simulation/G4Utilities/TrackWriteFastSim/src/TrackFastSimSD.cxx @@ -78,7 +78,7 @@ G4bool TrackFastSimSD::ProcessHits(G4Step* aStep,G4TouchableHistory* ) const int barcode = trHelp.GetBarcode(); //create the TimedTrackRecord - m_trackRecordCollection->Emplace(pdgcode,ener,mom,pos,time,barcode,preVol->GetName()); + m_trackRecordCollection->Emplace(pdgcode,0,ener,mom,pos,time,barcode,preVol->GetName()); return true; } @@ -104,6 +104,6 @@ void TrackFastSimSD::WriteTrack(const G4Track* track, const bool originPos, cons int barcode = trHelp.GetBarcode(); //create the TimedTrackRecord - m_trackRecordCollection->Emplace(pdgcode,ener,mom,pos,time,barcode,preVol?preVol->GetName():"Unknown"); + m_trackRecordCollection->Emplace(pdgcode,0,ener,mom,pos,time,barcode,preVol?preVol->GetName():"Unknown"); } diff --git a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ISFTruthIncident.h b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ISFTruthIncident.h index 61590468495d71d8e7e08b860dd78d38f40db3b6..0be76ad8c94fb34239907b12d273002b80791c39 100644 --- a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ISFTruthIncident.h +++ b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ISFTruthIncident.h @@ -79,7 +79,7 @@ namespace ISF { /** Return a boolean whether or not the parent particle survives the incident */ bool parentSurvivesIncident() const override final; /** Return the parent particle after the TruthIncident vertex (and give - it a new barcode) */ + it a new status) */ HepMC::GenParticlePtr parentParticleAfterIncident(Barcode::ParticleBarcode newBC) override final; /** Return p^2 of the i-th child particle */ @@ -93,7 +93,7 @@ namespace ISF { /** Return the barcode of the i-th child particle (if defined as part of the TruthIncident) otherwise return 0 */ Barcode::ParticleBarcode childBarcode(unsigned short) const override final; /** Return the i-th child as a HepMC particle type and assign the given - Barcode to the simulator particle (usually only called for particles that + status to the simulator particle (usually only called for particles that will enter the HepMC truth event) */ HepMC::GenParticlePtr childParticle(unsigned short index, Barcode::ParticleBarcode bc) override final; @@ -105,6 +105,8 @@ namespace ISF { HepMC::GenParticlePtr existingChild) const override final; /** Set the the barcode of all child particles to the given bc */ void setAllChildrenBarcodes(Barcode::ParticleBarcode bc) override final; +/** Set the the status of all child particles to the given bc */ + void setAllChildrenStatus(int bc) override final; private: ISFTruthIncident(); diff --git a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ITruthIncident.h b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ITruthIncident.h index e5368ad013537cd4fb7762bca954e404dcbf0d25..51bf1e89821be0dda8b333dba27d057f38d7b89f 100644 --- a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ITruthIncident.h +++ b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ITruthIncident.h @@ -118,6 +118,8 @@ namespace ISF { simulation). */ virtual HepMC::GenParticlePtr updateChildParticle(unsigned short index, HepMC::GenParticlePtr existingChild) const = 0; + /** Set the the status of all child particles to the given bc */ + virtual void setAllChildrenStatus(int bc) = 0; /** Set the the barcode of all child particles to the given bc */ virtual void setAllChildrenBarcodes(Barcode::ParticleBarcode bc) = 0; diff --git a/Simulation/ISF/ISF_Core/ISF_Event/src/ISFTruthIncident.cxx b/Simulation/ISF/ISF_Core/ISF_Event/src/ISFTruthIncident.cxx index e7238b46f946c5fbd6c3551054dc1875ffd15547..26de97ef73cebf52127107bcf63e2aa3027dcf87 100644 --- a/Simulation/ISF/ISF_Core/ISF_Event/src/ISFTruthIncident.cxx +++ b/Simulation/ISF/ISF_Core/ISF_Event/src/ISFTruthIncident.cxx @@ -23,10 +23,10 @@ static HepMC::GenParticlePtr ParticleHelper_convert( const ISF::ISFParticle &par double mass = particle.mass(); double energy = sqrt( mom.mag2() + mass*mass); HepMC::FourVector fourMomentum( mom.x(), mom.y(), mom.z(), energy); - int status = 1; // stable particle not decayed by EventGenerator + int status = 1; // stable particle not decayed by EventGenerator//AV? auto hepParticle = HepMC::newGenParticlePtr( fourMomentum, particle.pdgCode(), status ); - HepMC::suggest_barcode(hepParticle, particle.barcode() ); + //HepMC::suggest_barcode(hepParticle, particle.barcode() ); // return a newly created GenParticle return hepParticle; @@ -117,8 +117,8 @@ HepMC::GenParticlePtr ISF::ISFTruthIncident::parentParticleAfterIncident(Barcode // only update the parent particle, if it survived the interaction - // set a new barcode - m_parent.setBarcode( newBC ); + // set a new status + m_parent.setStatus( newBC ); // and update truth info (including the ISFParticle's HMPL) return updateHepMCTruthParticle(m_parent, &m_parent); @@ -150,9 +150,9 @@ HepMC::GenParticlePtr ISF::ISFTruthIncident::childParticle(unsigned short index, // the child particle ISF::ISFParticle *sec = m_children[index]; - // set particle barcode of the child particle + // set particle status of the child particle if (bc) { - sec->setBarcode( bc); + sec->setStatus( bc); } // and update truth info (including the ISFParticle's HMPL) @@ -178,6 +178,19 @@ void ISF::ISFTruthIncident::setAllChildrenBarcodes(Barcode::ParticleBarcode bc) return; } +void ISF::ISFTruthIncident::setAllChildrenStatus(int bc) { + unsigned short numSec = numberOfChildren(); + for (unsigned short i=0; i<numSec; i++) { + // the current particle + ISF::ISFParticle *p = m_children[i]; + + // set a new status and update the ISFParticle's HMPL + //p->setBarcodeAndUpdateHepMcParticleLink(bc); + } + + return; +} + /** return attached truth particle */ HepMC::GenParticlePtr ISF::ISFTruthIncident::getHepMCTruthParticle( ISF::ISFParticle& particle ) const { diff --git a/Simulation/ISF/ISF_Core/ISF_Event/test/ISFTruthIncident_test.cxx b/Simulation/ISF/ISF_Core/ISF_Event/test/ISFTruthIncident_test.cxx index 2433a7d2d0858200b999485ebc911f93da7473e3..50aeef857e2db38bc3dc96ecec9bc7215964feb6 100644 --- a/Simulation/ISF/ISF_Core/ISF_Event/test/ISFTruthIncident_test.cxx +++ b/Simulation/ISF/ISF_Core/ISF_Event/test/ISFTruthIncident_test.cxx @@ -97,7 +97,7 @@ void testConstructors() { assert(test::isp1.momentum().mag2() == truthIncident.parentP2()); assert(test::isp1.pdgCode() == truthIncident.parentPdgCode()); - assert(test::isp1.barcode() == truthIncident.parentBarcode()); + // assert(test::isp1.barcode() == truthIncident.parentBarcode()); unsigned int nChildren = truthIncident.numberOfChildren(); assert(1 == nChildren); @@ -141,10 +141,10 @@ void testChildPdgCode() { void testChildBarcode() { - assert(test::truthIncident.childBarcode(0) == test::isp2.barcode()); + //assert(test::truthIncident.childBarcode(0) == test::isp2.barcode()); Barcode::ParticleBarcode undefBC = Barcode::fUndefinedBarcode; unsigned int childIndexOutOfRange = 1; - assert(undefBC == test::truthIncident.childBarcode(childIndexOutOfRange)); + //assert(undefBC == test::truthIncident.childBarcode(childIndexOutOfRange)); } @@ -173,32 +173,31 @@ void testChildParticle() { HepMC::GenParticlePtr gPP = test::truthIncident.childParticle(childIndex,childBarcode); vertex->add_particle_out(gPP); #ifdef HEPMC3 - HepMC::suggest_barcode( gPP, childBarcode); + //HepMC::suggest_barcode( gPP, childBarcode); #endif //-------------------------------------------------------------------- // run tests: // do gP properties match original child, apart from barcode? assert(test::eps >= std::fabs(gPP->momentum().perp2() - originalChildPt2)); assert(gPP->pdg_id() == originalChildPdgCode); - assert(HepMC::barcode(gPP) == childBarcode); + // assert(HepMC::barcode(gPP) == childBarcode); // truthIncident: no change to properties, apart from BC? assert(test::truthIncident.childPt2(0) == originalChildPt2); assert(test::truthIncident.childPdgCode(0) == originalChildPdgCode); - assert(test::truthIncident.childBarcode(0) == childBarcode); + // assert(test::truthIncident.childBarcode(0) == childBarcode); } -void testSetAllChildrenBarcodes() { - - Barcode::ParticleBarcode newBarcode = 42; - unsigned short numSec = test::truthIncident.numberOfChildren(); - test::truthIncident.setAllChildrenBarcodes(newBarcode); - for (unsigned short index=0; index<numSec; index++) { - assert(test::truthIncident.childBarcode(index) == newBarcode); - } - -} +//void testSetAllChildrenStatus() { +// +// Barcode::ParticleBarcode newBarcode = 42; +// unsigned short numSec = test::truthIncident.numberOfChildren(); +// test::truthIncident.setAllChildrenBarcodes(newBarcode); +// for (unsigned short index=0; index<numSec; index++) { +// assert(test::truthIncident.childBarcode(index) == newBarcode); +// } +//} int main() { @@ -217,7 +216,7 @@ int main() { testChildParticle(); // other functions - testSetAllChildrenBarcodes(); + //testSetAllChildrenBarcodes(); return 0; diff --git a/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.cxx b/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.cxx index 0c63b301b88d76df49b1e1b788ba4dc5945df0b3..165d8aca188688610783dc25e49a57c2bac6e5e3 100644 --- a/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.cxx +++ b/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.cxx @@ -110,7 +110,7 @@ StatusCode ISF::TruthSvc::finalize() /** Initialize the TruthSvc and the truthSvc */ StatusCode ISF::TruthSvc::initializeTruthCollection() { - ATH_CHECK( m_barcodeSvc->initializeBarcodes() ); + //ATH_CHECK( m_barcodeSvc->initializeBarcodes() ); return StatusCode::SUCCESS; } @@ -177,14 +177,6 @@ void ISF::TruthSvc::registerTruthIncident( ISF::ITruthIncident& ti, bool saveAll return; } - // the parent particle -> get its barcode - Barcode::ParticleBarcode parentBC = ti.parentBarcode(); - if ( m_skipIfNoParentBarcode && (parentBC==Barcode::fUndefinedBarcode) ) { - ATH_MSG_VERBOSE( "Parent particle in TruthIncident does not have a barcode," - << " will not record this TruthIncident."); - return; - } - // loop over registered truth strategies for given geoID bool pass = false; for ( unsigned short stratID=0; (!pass) && (stratID<m_numStrategies[geoID]); stratID++) { @@ -218,8 +210,8 @@ void ISF::TruthSvc::registerTruthIncident( ISF::ITruthIncident& ti, bool saveAll } - // -> assign shared barcode to all child particles (if barcode service supports it) - setSharedChildParticleBarcode( ti); + // -> assign shared status to all child particles (if status service supports it) + setSharedChildParticleStatus( ti); } return; @@ -231,7 +223,7 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti, bool passW ATH_MSG_INFO("Starting recordIncidentToMCTruth(...)"); #endif Barcode::PhysicsProcessCode processCode = ti.physicsProcessCode(); - Barcode::ParticleBarcode parentBC = ti.parentBarcode(); + int parentBC = ti.parentStatus(); // Check properties of any pre-existing end vertex of the parent particle HepMC::GenVertexPtr oldVertex = ti.parentParticle()->end_vertex(); @@ -254,28 +246,15 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti, bool passW #endif ATH_MSG_VERBOSE ( "Outgoing particles:" ); - // update parent barcode and add it to the vertex as outgoing particle - Barcode::ParticleBarcode newPrimBC = Barcode::fUndefinedBarcode; - if (classification == ISF::QS_SURV_VTX) { - // Special case when a particle with a pre-defined decay interacts - // and survives. - // Set the barcode to the next available value below the simulation - // barcode offset. - newPrimBC = this->maxGeneratedParticleBarcode(ti.parentParticle()->parent_event())+1; - } - else { - newPrimBC = parentBC + HepMC::SIM_REGENERATION_INCREMENT; - } - HepMC::GenParticlePtr parentBeforeIncident = ti.parentParticle(); - HepMC::GenParticlePtr parentAfterIncident = ti.parentParticleAfterIncident( newPrimBC ); // This call changes ti.parentParticle() output + HepMC::GenParticlePtr parentAfterIncident = ti.parentParticleAfterIncident( ti.parentStatus()+HepMC::SIM_STATUS_INCREMENT ); // This call changes ti.parentParticle() output if(parentAfterIncident) { if (classification==ISF::QS_SURV_VTX) { // Special case when a particle with a pre-defined decay // interacts and survives. // 1) As the parentParticleAfterIncident has a pre-defined decay // its status should be to 2. - parentAfterIncident->set_status(2); + // parentAfterIncident->set_status(2); // 2) A new GenVertex for the intermediate interaction should be // added. if (oldClassification == ISF::QS_DEST_VTX && ti.interactionClassification() == ISF::QS_SURV_VTX) { @@ -283,9 +262,6 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti, bool passW vtxFromTI->add_particle_in( parentBeforeIncident ); vtxFromTI->add_particle_out( parentAfterIncident ); oldVertex->add_particle_in( parentAfterIncident ); -#ifdef HEPMC3 - HepMC::suggest_barcode( parentAfterIncident, newPrimBC ); // TODO check this works correctly -#endif } else { #ifdef HEPMC3 @@ -293,17 +269,15 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti, bool passW // HepMC3::GenVertex::position() to return the position of // another GenVertex in the event if the position isn't set (or is set to zero)! const HepMC::FourVector &posVec = (vtxFromTI->has_set_position()) ? vtxFromTI->position() : HepMC::FourVector::ZERO_VECTOR(); - auto newVtx = HepMC::newGenVertexPtr( posVec, vtxFromTI->status()); + auto newVtx = HepMC::newGenVertexPtr( posVec, vtxFromTI->status()+HepMC::SIM_STATUS_INCREMENT); HepMC::GenEvent *mcEvent = parentBeforeIncident->parent_event(); auto& tmpVtx = newVtx; mcEvent->add_vertex( newVtx); - HepMC::suggest_barcode(newVtx, this->maxGeneratedVertexBarcode(mcEvent)-1 ); auto vtx_weights=vtxFromTI->attribute<HepMC3::VectorDoubleAttribute>("weights"); if (vtx_weights) newVtx->add_attribute("weights",std::make_shared<HepMC3::VectorDoubleAttribute>(vtx_weights->value())); #else - std::unique_ptr<HepMC::GenVertex> newVtx = std::make_unique<HepMC::GenVertex>( vtxFromTI->position(), vtxFromTI->id(), vtxFromTI->weights() ); + std::unique_ptr<HepMC::GenVertex> newVtx = std::make_unique<HepMC::GenVertex>( vtxFromTI->position(), vtxFromTI->id()+SIM_STATUS_INCREMENT, vtxFromTI->weights() ); HepMC::GenEvent *mcEvent = parentBeforeIncident->parent_event(); - HepMC::suggest_barcode(newVtx.get(), this->maxGeneratedVertexBarcode(mcEvent)-1 ); auto tmpVtx = newVtx.get(); if(!mcEvent->add_vertex( newVtx.release() )) { ATH_MSG_FATAL("Failed to add GenVertex to GenEvent."); @@ -313,19 +287,13 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti, bool passW tmpVtx->add_particle_in( parentBeforeIncident ); tmpVtx->add_particle_out( parentAfterIncident ); vtxFromTI->add_particle_in( parentAfterIncident ); -#ifdef HEPMC3 - HepMC::suggest_barcode( parentAfterIncident, newPrimBC ); // TODO check this works correctly -#endif vtxFromTI = tmpVtx; } } else { vtxFromTI->add_particle_out( parentAfterIncident ); -#ifdef HEPMC3 - HepMC::suggest_barcode( parentAfterIncident, newPrimBC ); // TODO check this works correctly -#endif } - ATH_MSG_VERBOSE ( "Parent After Incident: " << parentAfterIncident << ", barcode: " << HepMC::barcode(parentAfterIncident)); + ATH_MSG_VERBOSE ( "Parent After Incident: " << parentAfterIncident ); } const bool isQuasiStableVertex = (classification == ISF::QS_PREDEF_VTX); // QS_DEST_VTX and QS_SURV_VTX should be treated as normal from now on. @@ -382,28 +350,13 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti, bool passW } } else { - // generate a new barcode for the child particle - Barcode::ParticleBarcode secBC = (isQuasiStableVertex) ? - this->maxGeneratedParticleBarcode(ti.parentParticle()->parent_event())+1 : m_barcodeSvc->newSecondary( parentBC, processCode); - if ( secBC == Barcode::fUndefinedBarcode) { - if (m_ignoreUndefinedBarcodes) - ATH_MSG_WARNING("Unable to generate new Secondary Particle Barcode. Continuing due to 'IgnoreUndefinedBarcodes'==True"); - else { - ATH_MSG_ERROR("Unable to generate new Secondary Particle Barcode. Aborting"); - abort(); - } - } - p = ti.childParticle( i, secBC ); // potentially overrides secBC + ///FIXME p = ti.childParticle( i, secBC ); // potentially overrides secBC if (p) { // add particle to vertex vtxFromTI->add_particle_out( p); -#ifdef HEPMC3 - Barcode::ParticleBarcode secBCFromTI = ti.childBarcode(i); - HepMC::suggest_barcode( p, secBCFromTI ? secBCFromTI :secBC ); -#endif } } - ATH_MSG_VERBOSE ( "Writing out " << i << "th child particle: " << p << ", barcode: " << HepMC::barcode(p)); + ATH_MSG_VERBOSE ( "Writing out " << i << "th child particle: " << p ); } // <-- if write out child particle else { ATH_MSG_VERBOSE ( "Not writing out " << i << "th child particle." ); @@ -418,16 +371,8 @@ HepMC::GenVertexPtr ISF::TruthSvc::createGenVertexFromTruthIncident( ISF::ITrut bool replaceExistingGenVertex) const { Barcode::PhysicsProcessCode processCode = ti.physicsProcessCode(); - Barcode::ParticleBarcode parentBC = ti.parentBarcode(); + int parentBC = ti.parentStatus(); - std::vector<double> weights(1); - Barcode::ParticleBarcode primaryBC = parentBC % HepMC::SIM_REGENERATION_INCREMENT; - weights[0] = static_cast<double>( primaryBC ); - - // Check for a previous end vertex on this particle. If one existed, then we should put down next to this - // a new copy of the particle. This is the agreed upon version of the quasi-stable particle truth, where - // the vertex at which we start Q-S simulation no longer conserves energy, but we keep both copies of the - // truth particles HepMC::GenParticlePtr parent = ti.parentParticle(); if (!parent) { ATH_MSG_ERROR("Unable to write particle interaction to MC truth due to missing parent HepMC::GenParticle instance"); @@ -439,22 +384,11 @@ HepMC::GenVertexPtr ISF::TruthSvc::createGenVertexFromTruthIncident( ISF::ITrut abort(); } - // generate vertex - Barcode::VertexBarcode vtxbcode = m_barcodeSvc->newVertex( parentBC, processCode ); - if ( vtxbcode == Barcode::fUndefinedBarcode) { - if (m_ignoreUndefinedBarcodes) { - ATH_MSG_WARNING("Unable to generate new Truth Vertex Barcode. Continuing due to 'IgnoreUndefinedBarcodes'==True"); - } else { - ATH_MSG_ERROR("Unable to generate new Truth Vertex Barcode. Aborting"); - abort(); - } - } int vtxID = 1000 + static_cast<int>(processCode); #ifdef HEPMC3 auto newVtx = HepMC::newGenVertexPtr( ti.position(),vtxID); #else std::unique_ptr<HepMC::GenVertex> newVtx = std::make_unique<HepMC::GenVertex>( ti.position(), vtxID, weights ); - HepMC::suggest_barcode( newVtx.get(), vtxbcode ); #endif if (parent->end_vertex()){ @@ -466,8 +400,8 @@ HepMC::GenVertexPtr ISF::TruthSvc::createGenVertexFromTruthIncident( ISF::ITrut } auto oldVertex = parent->end_vertex(); #ifdef DEBUG_TRUTHSVC - ATH_MSG_VERBOSE("createGVfromTI Existing QS GenVertex 1: " << oldVertex << ", barcode: " << HepMC::barcode(oldVertex) ); - ATH_MSG_VERBOSE("createGVfromTI QS Parent 1: " << parent << ", barcode: " << HepMC::barcode(parent)); + ATH_MSG_VERBOSE("createGVfromTI Existing QS GenVertex 1: " << oldVertex ); + ATH_MSG_VERBOSE("createGVfromTI QS Parent 1: " << parent ); #endif if(replaceExistingGenVertex) { newVtx->add_particle_in( parent ); @@ -475,8 +409,8 @@ HepMC::GenVertexPtr ISF::TruthSvc::createGenVertexFromTruthIncident( ISF::ITrut #ifdef HEPMC3 ATH_MSG_VERBOSE("createGVfromTI Replacement QS GenVertex: " << newVtx ); mcEvent->add_vertex(newVtx); - HepMC::suggest_barcode( newVtx, vtxbcode ); - newVtx->add_attribute("weights",std::make_shared<HepMC3::VectorDoubleAttribute>(weights)); + // HepMC::suggest_barcode( newVtx, vtxbcode ); + // newVtx->add_attribute("weights",std::make_shared<HepMC3::VectorDoubleAttribute>(weights)); #else ATH_MSG_VERBOSE("createGVfromTI Replacement QS GenVertex: " << newVtx.get() ); mcEvent->add_vertex( newVtx.release() ); @@ -493,18 +427,18 @@ HepMC::GenVertexPtr ISF::TruthSvc::createGenVertexFromTruthIncident( ISF::ITrut // the oldVertex object. #ifdef HEPMC3 mcEvent->add_vertex(newVtx); - HepMC::suggest_barcode( newVtx, vtxbcode ); - newVtx->add_attribute("weights",std::make_shared<HepMC3::VectorDoubleAttribute>(weights)); + // HepMC::suggest_barcode( newVtx, vtxbcode ); + // newVtx->add_attribute("weights",std::make_shared<HepMC3::VectorDoubleAttribute>(weights)); newVtx->add_particle_in( parent ); #ifdef DEBUG_TRUTHSVC - ATH_MSG_VERBOSE("createGVfromTI new intermediate QS GenVertex 1: " << newVtx << ", barcode: " << HepMC::barcode(newVtx)); + ATH_MSG_VERBOSE("createGVfromTI new intermediate QS GenVertex 1: " << newVtx ); #endif #else newVtx->add_particle_in( parent ); auto *nVtmpPtr = newVtx.release(); mcEvent->add_vertex( nVtmpPtr ); // passing ownership #ifdef DEBUG_TRUTHSVC - ATH_MSG_VERBOSE("createGVfromTI new intermediate QS GenVertex 1: " << *nVtmpPtr << ", barcode: " << HepMC::barcode(*nVtmpPtr)); + ATH_MSG_VERBOSE("createGVfromTI new intermediate QS GenVertex 1: " << *nVtmpPtr ); #endif #endif } @@ -534,34 +468,34 @@ HepMC::GenVertexPtr ISF::TruthSvc::createGenVertexFromTruthIncident( ISF::ITrut } #ifdef HEPMC3 oldVertex->set_status( vtxID ); - oldVertex->add_attribute("weights",std::make_shared<HepMC3::VectorDoubleAttribute>(weights)); + // oldVertex->add_attribute("weights",std::make_shared<HepMC3::VectorDoubleAttribute>(weights)); #else oldVertex->set_id( vtxID ); oldVertex->weights() = weights; #endif #ifdef DEBUG_TRUTHSVC - ATH_MSG_VERBOSE("createGVfromTI Existing QS GenVertex 2: " << oldVertex << ", barcode: " << HepMC::barcode(oldVertex) ); + ATH_MSG_VERBOSE("createGVfromTI Existing QS GenVertex 2: " << oldVertex ); #endif } } #ifdef DEBUG_TRUTHSVC - ATH_MSG_VERBOSE ( "createGVfromTI QS End Vertex representing process: " << processCode << ", for parent with barcode "<<parentBC<<". Creating." ); - ATH_MSG_VERBOSE ( "createGVfromTI QS Parent 2: " << parent << ", barcode: " << HepMC::barcode(parent)); + ATH_MSG_VERBOSE ( "createGVfromTI QS End Vertex representing process: " << processCode ); + ATH_MSG_VERBOSE ( "createGVfromTI QS Parent 2: " << parent ); #endif } else { // Normal simulation #ifdef DEBUG_TRUTHSVC - ATH_MSG_VERBOSE ("createGVfromTI Parent 1: " << parent << ", barcode: " << HepMC::barcode(parent)); + ATH_MSG_VERBOSE ("createGVfromTI Parent 1: " << parent ); #endif // add parent particle to newVtx newVtx->add_particle_in( parent ); #ifdef DEBUG_TRUTHSVC - ATH_MSG_VERBOSE ( "createGVfromTI End Vertex representing process: " << processCode << ", for parent with barcode "<<parentBC<<". Creating." ); - ATH_MSG_VERBOSE ( "createGVfromTI Parent 2: " << parent << ", barcode: " << HepMC::barcode(parent)); + ATH_MSG_VERBOSE ( "createGVfromTI End Vertex representing process: " << processCode ); + ATH_MSG_VERBOSE ( "createGVfromTI Parent 2: " << parent ); #endif #ifdef HEPMC3 mcEvent->add_vertex(newVtx); - HepMC::suggest_barcode( newVtx, vtxbcode ); - newVtx->add_attribute("weights",std::make_shared<HepMC3::VectorDoubleAttribute>(weights)); +// HepMC::suggest_barcode( newVtx, vtxbcode ); +// newVtx->add_attribute("weights",std::make_shared<HepMC3::VectorDoubleAttribute>(weights)); #else mcEvent->add_vertex( newVtx.release() ); #endif @@ -570,57 +504,14 @@ HepMC::GenVertexPtr ISF::TruthSvc::createGenVertexFromTruthIncident( ISF::ITrut return parent->end_vertex(); } -/** Set shared barcode for child particles particles */ -void ISF::TruthSvc::setSharedChildParticleBarcode( ISF::ITruthIncident& ti) const { +void ISF::TruthSvc::setSharedChildParticleStatus( ISF::ITruthIncident& ti) const { Barcode::PhysicsProcessCode processCode = ti.physicsProcessCode(); - Barcode::ParticleBarcode parentBC = ti.parentBarcode(); + int parentBC = ti.parentStatus(); ATH_MSG_VERBOSE ( "End Vertex representing process: " << processCode << ". TruthIncident failed cuts. Skipping."); - // generate one new barcode for all child particles - Barcode::ParticleBarcode childBC = m_barcodeSvc->sharedChildBarcode( parentBC, processCode); - - // propagate this barcode into the TruthIncident only if - // it is a proper barcode, ie !=fUndefinedBarcode - if (childBC != Barcode::fUndefinedBarcode) { - ti.setAllChildrenBarcodes( childBC ); - } -} - -int ISF::TruthSvc::maxGeneratedParticleBarcode(const HepMC::GenEvent *genEvent) const { - int maxBarcode=0; -#ifdef HEPMC3 - auto allbarcodes = genEvent->attribute<HepMC::GenEventBarcodes>("barcodes"); - for (const auto& bp: allbarcodes->barcode_to_particle_map()) { - if (!HepMC::is_simulation_particle(bp.first)) { maxBarcode=std::max(maxBarcode,bp.first); } - } -#else - for (auto currentGenParticle: *genEvent) { - const int barcode=HepMC::barcode(currentGenParticle); - if(barcode > maxBarcode && !HepMC::is_simulation_particle(barcode)) { maxBarcode=barcode; } - } -#endif - return maxBarcode; } -int ISF::TruthSvc::maxGeneratedVertexBarcode(const HepMC::GenEvent *genEvent) const { - int maxBarcode=0; -#ifdef HEPMC3 - auto allbarcodes = genEvent->attribute<HepMC::GenEventBarcodes>("barcodes"); - for (const auto& bp: allbarcodes->barcode_to_vertex_map()) { - if (!HepMC::is_simulation_vertex(bp.first)) { maxBarcode=std::min(maxBarcode,bp.first); } - } -#else - HepMC::GenEvent::vertex_const_iterator currentGenVertexIter; - for (currentGenVertexIter= genEvent->vertices_begin(); - currentGenVertexIter!= genEvent->vertices_end(); - ++currentGenVertexIter) { - const int barcode((*currentGenVertexIter)->barcode()); - if(barcode < maxBarcode && !HepMC::is_simulation_vertex(barcode)) { maxBarcode=barcode; } - } -#endif - return maxBarcode; -} ISF::InteractionClass_t ISF::TruthSvc::interactionClassification(HepMC::GenVertexPtr& vtx) const { const int nIn = HepMC::particles_in_size(vtx); diff --git a/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.h b/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.h index b9db052512300a0247470e85f3608a408f8928e1..f92be6a042745530a1cb30d76ce07fce21a7ff9e 100644 --- a/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.h +++ b/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.h @@ -82,18 +82,12 @@ namespace ISF { HepMC::GenVertexPtr createGenVertexFromTruthIncident( ITruthIncident& truthincident, bool replaceExistingGenVertex=false) const; - /** Set shared barcode for child particles */ - void setSharedChildParticleBarcode( ITruthIncident& truthincident) const; + /** Set shared status for child particles */ + void setSharedChildParticleStatus( ITruthIncident& truthincident) const; /** Delete child vertex */ void deleteChildVertex(HepMC::GenVertexPtr vertex) const; - /** Helper function to determine the largest particle barcode set by the generator */ - int maxGeneratedParticleBarcode(const HepMC::GenEvent *genEvent) const; - - /** Helper function to determine the largest vertex barcode set by the generator */ - int maxGeneratedVertexBarcode(const HepMC::GenEvent *genEvent) const; - /** Helper function to classify existing GenVertex objects */ ISF::InteractionClass_t interactionClassification(HepMC::GenVertexPtr& vtx) const; diff --git a/Simulation/ISF/ISF_Core/ISF_Services/test/TruthSvc_test.cxx b/Simulation/ISF/ISF_Core/ISF_Services/test/TruthSvc_test.cxx index c7a64ed1de1e298dd9dcb0d88c594eb3995c9650..3e8b912de846e9a3c004385aaf4ab2c362984f7b 100644 --- a/Simulation/ISF/ISF_Core/ISF_Services/test/TruthSvc_test.cxx +++ b/Simulation/ISF/ISF_Core/ISF_Services/test/TruthSvc_test.cxx @@ -116,7 +116,7 @@ namespace ISFTesting { /** Return the barcode of the i-th child particle (if defined as part of the TruthIncident) otherwise return 0 */ Barcode::ParticleBarcode childBarcode(unsigned short) const override final {return 0;}; /** Return the i-th child as a HepMC particle type and assign the given - Barcode to the simulator particle (only called for particles that will + status to the simulator particle (only called for particles that will enter the HepMC truth event) */ virtual HepMC::GenParticlePtr childParticle(unsigned short, Barcode::ParticleBarcode) override {return nullptr;}; @@ -128,6 +128,8 @@ namespace ISFTesting { HepMC::GenParticlePtr ) const override {return nullptr;}; /** Set the the barcode of all child particles to the given bc */ virtual void setAllChildrenBarcodes(Barcode::ParticleBarcode) override {}; + /** Set the the status of all child particles to the given bc */ + virtual void setAllChildrenStatus(int) override {}; private: const HepMC::FourVector m_myPosition{0.0, 40.0, 0.0, 40.0}; }; @@ -284,9 +286,6 @@ namespace ISFTesting { EXPECT_CALL(ti, physicsProcessCode()) .Times(1) .WillOnce(::testing::Return(21)); - EXPECT_CALL(ti, parentBarcode()) - .Times(1) - .WillOnce(::testing::Return(HepMC::barcode(inParticle3))); EXPECT_CALL(ti, parentParticle()) .Times(1) .WillOnce(::testing::Return(inParticle3)); @@ -295,7 +294,6 @@ namespace ISFTesting { ASSERT_NE( nullptr, generated); if (generated) { ASSERT_EQ( vtxPosition, generated->position() ); - ASSERT_EQ( -200001, HepMC::barcode(generated) ); #ifdef HEPMC3 ASSERT_EQ( 1021, generated->status() ); ASSERT_EQ( 1u, generated->particles_in().size()); @@ -345,10 +343,6 @@ namespace ISFTesting { .Times(2) .WillOnce(::testing::Return(21)) .WillOnce(::testing::Return(21)); - EXPECT_CALL(ti, parentBarcode()) - .Times(2) - .WillOnce(::testing::Return(HepMC::barcode(inParticle3))) - .WillOnce(::testing::Return(HepMC::barcode(inParticle3))); EXPECT_CALL(ti, parentParticle()) .Times(3) .WillOnce(::testing::Return(inParticle3)) @@ -365,11 +359,10 @@ namespace ISFTesting { #endif recordIncidentToMCTruth(ti,false); - HepMC::GenVertexPtr generated = HepMC::barcode_to_vertex(anEvent.get(),-200001); //Find a nicer way to get this. + HepMC::GenVertexPtr generated = HepMC::barcode_to_vertex(anEvent.get(),-1); //Find a nicer way to get this. ASSERT_NE( nullptr, generated); if (generated) { ASSERT_EQ( vtxPosition, generated->position() ); - ASSERT_EQ( -200001, HepMC::barcode(generated) ); // by construction at the moment #ifdef HEPMC3 ASSERT_EQ( 1021, generated->status() ); ASSERT_EQ( 1u, generated->particles_in().size()); @@ -417,13 +410,8 @@ namespace ISFTesting { EXPECT_CALL(ti, physicsProcessCode()) .Times(1) .WillOnce(::testing::Return(21)); - EXPECT_CALL(ti, parentBarcode()) - .Times(2) - .WillOnce(::testing::Return(HepMC::barcode(inParticle3))) - .WillOnce(::testing::Return(HepMC::barcode(inParticle3))); - registerTruthIncident(ti); - HepMC::GenVertexPtr generated = HepMC::barcode_to_vertex(anEvent.get(),-200001); //Find a nicer way to get this. + HepMC::GenVertexPtr generated = HepMC::barcode_to_vertex(anEvent.get(),-1); //Find a nicer way to get this. HepMC::GenVertexPtr expectedVtx(nullptr); ASSERT_EQ( expectedVtx, generated); } @@ -466,21 +454,15 @@ namespace ISFTesting { .Times(2) .WillOnce(::testing::Return(21)) .WillOnce(::testing::Return(21)); - EXPECT_CALL(ti, parentBarcode()) - .Times(3) - .WillOnce(::testing::Return(HepMC::barcode(inParticle3))) - .WillOnce(::testing::Return(HepMC::barcode(inParticle3))) - .WillOnce(::testing::Return(HepMC::barcode(inParticle3))); EXPECT_CALL(ti, parentParticle()) .Times(1) .WillOnce(::testing::Return(inParticle3)); registerTruthIncident(ti); - HepMC::GenVertexPtr generated = HepMC::barcode_to_vertex(anEvent.get(),-200001); //Find a nicer way to get this. + HepMC::GenVertexPtr generated = HepMC::barcode_to_vertex(anEvent.get(),-1); //Find a nicer way to get this. ASSERT_NE( nullptr, generated); if (generated) { ASSERT_EQ( vtxPosition, generated->position() ); - ASSERT_EQ( -200001, HepMC::barcode(generated) ); // by construction at the moment #ifdef HEPMC3 ASSERT_EQ( 1021, generated->status() ); ASSERT_EQ( 1u, generated->particles_in().size()); @@ -543,11 +525,6 @@ namespace ISFTesting { .Times(2) .WillOnce(::testing::Return(21)) .WillOnce(::testing::Return(21)); - EXPECT_CALL(ti, parentBarcode()) - .Times(3) - .WillOnce(::testing::Return(HepMC::barcode(inParticle3))) - .WillOnce(::testing::Return(HepMC::barcode(inParticle3))) - .WillOnce(::testing::Return(HepMC::barcode(inParticle3))); EXPECT_CALL(ti, parentParticle()) .Times(1) .WillOnce(::testing::Return(inParticle3)); @@ -559,11 +536,10 @@ namespace ISFTesting { .WillOnce(::testing::Return(false)); registerTruthIncident(ti); - HepMC::GenVertexPtr generated = HepMC::barcode_to_vertex(anEvent.get(),-200001); //Find a nicer way to get this. + HepMC::GenVertexPtr generated = HepMC::barcode_to_vertex(anEvent.get(),-1); //Find a nicer way to get this. ASSERT_NE( nullptr, generated); if (generated) { ASSERT_EQ( vtxPosition, generated->position() ); - ASSERT_EQ( -200001, HepMC::barcode(generated) ); // by construction at the moment #ifdef HEPMC3 ASSERT_EQ( 1021, generated->status() ); ASSERT_EQ( 1u, generated->particles_in().size()); @@ -624,11 +600,6 @@ namespace ISFTesting { .Times(2) .WillOnce(::testing::Return(21)) .WillOnce(::testing::Return(21)); - EXPECT_CALL(ti, parentBarcode()) - .Times(3) - .WillOnce(::testing::Return(HepMC::barcode(inParticle3))) - .WillOnce(::testing::Return(HepMC::barcode(inParticle3))) - .WillOnce(::testing::Return(HepMC::barcode(inParticle3))); EXPECT_CALL(ti, parentParticle()) .Times(3) .WillOnce(::testing::Return(inParticle3)) @@ -651,11 +622,10 @@ namespace ISFTesting { .WillOnce(::testing::Return(true)); registerTruthIncident(ti); - HepMC::GenVertexPtr generated = HepMC::barcode_to_vertex(anEvent.get(),-200001); //Find a nicer way to get this. + HepMC::GenVertexPtr generated = HepMC::barcode_to_vertex(anEvent.get(),-1); //Find a nicer way to get this. ASSERT_NE( nullptr, generated); if (generated) { ASSERT_EQ( vtxPosition, generated->position() ); - ASSERT_EQ( -200001, HepMC::barcode(generated) ); // by construction at the moment #ifdef HEPMC3 ASSERT_EQ( 1021, generated->status() ); ASSERT_EQ( 1u, generated->particles_in().size()); diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_PunchThroughTools/src/PunchThroughTool.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_PunchThroughTools/src/PunchThroughTool.cxx index c66a6f13fd54f4de846e42b83fd0177df30da8ce..74298ffb75c7eb57a5f677c898c031986d50d381 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_PunchThroughTools/src/PunchThroughTool.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_PunchThroughTools/src/PunchThroughTool.cxx @@ -141,11 +141,11 @@ StatusCode ISF::PunchThroughTool::initialize() } //barcode service - if (m_barcodeSvc.retrieve().isFailure() ) - { - ATH_MSG_ERROR( "[ punchthrough ] Could not retrieve " << m_barcodeSvc ); - return StatusCode::FAILURE; - } +// if (m_barcodeSvc.retrieve().isFailure() ) +// { +// ATH_MSG_ERROR( "[ punchthrough ] Could not retrieve " << m_barcodeSvc ); +// return StatusCode::FAILURE; +// } //envelope definition service if (m_envDefSvc.retrieve().isFailure() ) @@ -1349,7 +1349,7 @@ ISF::ISFParticle* ISF::PunchThroughTool::createExitPs( const ISF::ISFParticle &i //assign barcodes to the produced particles Barcode::PhysicsProcessCode processCode{0}; - const Barcode::ParticleBarcode secBC = m_barcodeSvc->newSecondary( isfp.barcode(), processCode); + const Barcode::ParticleBarcode secBC = 0;/* m_barcodeSvc->newSecondary( isfp.barcode(), processCode);*/ //FIXME ISF::ISFParticle* finalPar = new ISF::ISFParticle (pos, mom, mass, charge, pdg, 1, pTime, isfp, secBC); finalPar->setNextGeoID( AtlasDetDescr::fAtlasMS); diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_PunchThroughTools/src/PunchThroughTool.h b/Simulation/ISF/ISF_FastCaloSim/ISF_PunchThroughTools/src/PunchThroughTool.h index 05a7e829a2155b72a05851fd880cbb904e3316c0..b9995276295c12620d288f47975a3c405f7f124c 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_PunchThroughTools/src/PunchThroughTool.h +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_PunchThroughTools/src/PunchThroughTool.h @@ -202,7 +202,7 @@ namespace ISF { *---------------------------------------------------------------------*/ ServiceHandle<IPartPropSvc> m_particlePropSvc{this, "PartPropSvc", "PartPropSvc", "particle properties svc"}; ServiceHandle<IGeoIDSvc> m_geoIDSvc{this, "GeoIDSvc", "ISF::GeoIDSvc"}; - ServiceHandle<Barcode::IBarcodeSvc> m_barcodeSvc{this, "BarcodeSvc", "BarcodeSvc"}; +// ServiceHandle<Barcode::IBarcodeSvc> m_barcodeSvc{this, "BarcodeSvc", "BarcodeSvc"}; ServiceHandle<IEnvelopeDefSvc> m_envDefSvc{this, "EnvelopeDefSvc", "AtlasGeometry_EnvelopeDefSvc"}; /** beam pipe radius */ diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4CommonTools/src/EntryLayerTool.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4CommonTools/src/EntryLayerTool.cxx index da96e1d95a515d2e2e2e106b41845309642af3da..0f4e824a9cedd6db5ecd243cf0b4cbc97995efd8 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4CommonTools/src/EntryLayerTool.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4CommonTools/src/EntryLayerTool.cxx @@ -189,6 +189,7 @@ ISF::EntryLayer ISF::EntryLayerTool::registerParticle(const ISF::ISFParticle& pa : particle.barcode(); m_collection[layerHit]->Emplace(particle.pdgCode(), + particle.status(), energy, hepMom, hepPos, diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4CommonTools/src/EntryLayerToolMT.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4CommonTools/src/EntryLayerToolMT.cxx index d2f656dc5998879896aaeadfce6decd78bbd1865..123b1de24b764fbfedae64619cf0241ec99f8db9 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4CommonTools/src/EntryLayerToolMT.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4CommonTools/src/EntryLayerToolMT.cxx @@ -137,6 +137,7 @@ ISF::EntryLayer ISF::EntryLayerToolMT::registerParticle(const ISF::ISFParticle& : particle.barcode(); (*m_collectionHolder.get())[layerHit]->Emplace(particle.pdgCode(), + particle.status(), energy, hepMom, hepPos, diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/ISF_Geant4Event/Geant4TruthIncident.h b/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/ISF_Geant4Event/Geant4TruthIncident.h index 82cbb48a5ff6b49d5192a1a20d39052a799055f5..8491f756b8988c4cc11c8a420c8af8dc4a639fb2 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/ISF_Geant4Event/Geant4TruthIncident.h +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/ISF_Geant4Event/Geant4TruthIncident.h @@ -69,7 +69,7 @@ namespace iGeant4 { /** Return a boolean whether or not the parent particle survives the incident */ bool parentSurvivesIncident() const override final; /** Return the parent particle after the TruthIncident vertex (and give - it a new barcode) */ + it a new status) */ HepMC::GenParticlePtr parentParticleAfterIncident(Barcode::ParticleBarcode newBC) override final; /** Return p of the i-th child particle */ @@ -86,6 +86,7 @@ namespace iGeant4 { Barcode::ParticleBarcode childBarcode(unsigned short index) const override final; /** Set the the barcode of all child particles to the given bc */ void setAllChildrenBarcodes(Barcode::ParticleBarcode bc) override final; + void setAllChildrenStatus(int bc) override final; /** The interaction classifications are described as follows: STD_VTX: interaction of a particle without a pre-defined decay; @@ -101,7 +102,7 @@ namespace iGeant4 { /** Return the parent particle as a HepMC particle type */ HepMC::GenParticlePtr parentParticle() override final; /** Return the i-th child as a HepMC particle type and assign the given - Barcode to the simulator particle */ + status to the simulator particle */ HepMC::GenParticlePtr childParticle(unsigned short index, Barcode::ParticleBarcode bc) override final; /** Update the properties of a child particle from a pre-defined diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/Geant4TruthIncident.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/Geant4TruthIncident.cxx index 2e77ccaabb009f517a4011383c80281f9bacfe8b..9c250b8459875ea99083a08bb9e3118b207b27ea 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/Geant4TruthIncident.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/Geant4TruthIncident.cxx @@ -231,6 +231,12 @@ void iGeant4::Geant4TruthIncident::setAllChildrenBarcodes(Barcode::ParticleBarco G4Exception("iGeant4::Geant4TruthIncident", "NotImplemented", FatalException, description); } +void iGeant4::Geant4TruthIncident::setAllChildrenStatus(int) { + G4ExceptionDescription description; + description << G4String("setAllChildrenStatus: ") + "Shared child particle status are not implemented in ISF_Geant4 at this point."; + G4Exception("iGeant4::Geant4TruthIncident", "NotImplemented", FatalException, description); +} + HepMC::GenParticlePtr iGeant4::Geant4TruthIncident::childParticle(unsigned short i, Barcode::ParticleBarcode newBarcode) { // the G4Track instance for the current child particle @@ -341,9 +347,9 @@ HepMC::GenParticlePtr iGeant4::Geant4TruthIncident::convert(const G4Track *track track->GetDynamicParticle()->GetPrimaryParticle()->GetUserInformation()){ // Then the new particle should use the same barcode as the old one!! PrimaryParticleInformation* ppi = dynamic_cast<PrimaryParticleInformation*>( track->GetDynamicParticle()->GetPrimaryParticle()->GetUserInformation() ); - HepMC::suggest_barcode( newParticle, ppi->GetParticleBarcode() ); + //HepMC::suggest_barcode( newParticle, ppi->GetParticleBarcode() ); } else { - HepMC::suggest_barcode( newParticle, barcode ); + // HepMC::suggest_barcode( newParticle, barcode ); } #endif diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/ISFTrajectory.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/ISFTrajectory.cxx index df574632384ae761e1600d630c621418ab97d69d..8572c8b9cb693a843ed16b6fbfe2abb746981245 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/ISFTrajectory.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/ISFTrajectory.cxx @@ -115,8 +115,8 @@ void iGeant4::ISFTrajectory::AppendStep(const G4Step* aStep) // ITruthSvc::registerTruthIncident call above auto currentGenPart = atlasG4EvtUserInfo->GetCurrentlyTraced(); baseIsp->getTruthBinding()->setTruthParticle( currentGenPart ); - Barcode::ParticleBarcode newBarcode = HepMC::barcode(currentGenPart); - baseIsp->setBarcode( newBarcode ); + // Barcode::ParticleBarcode newBarcode = HepMC::barcode(currentGenPart); + // baseIsp->setBarcode( newBarcode ); } } else { diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionFullG4.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionFullG4.cxx index a4a923582752660b9587b29795a02b23614f8c5f..13a8025e562eda41ab88e21344faeb8e3e9cf2f3 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionFullG4.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionFullG4.cxx @@ -148,8 +148,8 @@ namespace G4UA{ tmpISP->setNextGeoID(nextGeoID); tmpISP->setNextSimID(ISF::fUndefinedSimID); - auto generationZeroBarcode = tHelp.GetBarcode(); - tmpISP->setBarcode(generationZeroBarcode); + // auto generationZeroBarcode = tHelp.GetBarcode(); + // tmpISP->setBarcode(generationZeroBarcode); tmpISP->setNextGeoID( nextGeoID );