Skip to content
Snippets Groups Projects
Commit 7604017c authored by Andrii Verbytskyi's avatar Andrii Verbytskyi Committed by Walter Lampl
Browse files

Hepmc3 nightly fixes 22122020 part 1

parent 72dd8fc3
No related branches found
No related tags found
No related merge requests found
......@@ -1040,14 +1040,24 @@ void PixelPrepDataToxAOD::addNNTruthInfo( xAOD::TrackMeasurementValidation* xp
auto particle = siHit.particleLink();
pdgid[hitNumber] = particle->pdg_id();
truep[hitNumber] = particle->momentum().rho();
if ( particle->production_vertex() ){
auto vertex = particle->production_vertex();
HepMC::FourVector mom=particle->momentum();
truep[hitNumber] = std::sqrt(mom.x()*mom.x()+mom.y()*mom.y()+mom.z()*mom.z());
auto vertex = particle->production_vertex();
//AV Please note that taking the first particle as a mother is ambiguous.
#ifdef HEPMC3
if ( vertex && vertex->particles_in().size()>0){
auto mother_of_particle=vertex->particles_in().at(0);
motherBarcode[hitNumber] = HepMC::barcode(mother_of_particle);
motherPdgid[hitNumber] = mother_of_particle->pdg_id();
}
#else
if ( vertex ){
if( vertex->particles_in_const_begin() != vertex->particles_in_const_end() ){
motherBarcode[hitNumber] = (*vertex->particles_in_const_begin())->barcode();
motherPdgid[hitNumber] = (*vertex->particles_in_const_begin())->pdg_id();
}
}
#endif
}
chargeDep[hitNumber] = siHit.energyLoss() ;
......
......@@ -298,7 +298,7 @@ StatusCode InDet::InDetRecStatisticsAlg::execute(const EventContext &ctx) const
// apply pt, eta etc cuts to generated tracks
// devide generated tracks into primary, truncated, secondary
std::vector <std::pair<HepMC::GenParticle *,int> > GenSignal;
std::vector <std::pair<HepMC::GenParticlePtr,int> > GenSignal;
// GenSignalPrimary, GenSignalTruncated, GenSignalSecondary;
unsigned int inTimeStart = 0;
unsigned int inTimeEnd = 0;
......@@ -583,7 +583,7 @@ void InDet::InDetRecStatisticsAlg::selectRecSignal(const TrackCollection* RecCol
// select charged, stable particles in allowed pt and eta range
void InDet :: InDetRecStatisticsAlg ::
selectGenSignal (const McEventCollection* SimTracks,
std::vector <std::pair<HepMC::GenParticle *,int> > & GenSignal,
std::vector <std::pair<HepMC::GenParticlePtr,int> > & GenSignal,
unsigned int /*inTimeStart*/, unsigned int /*inTimeEnd*/,
InDet::InDetRecStatisticsAlg::CounterLocal &counter) const //'unused' compiler warning
{
......@@ -604,7 +604,11 @@ selectGenSignal (const McEventCollection* SimTracks,
for(unsigned int ievt=0; ievt<nb_mc_event; ++ievt)
{
const HepMC::GenEvent* genEvent = SimTracks->at(ievt);
counter.m_counter[kN_gen_tracks_processed] += ((SimTracks->at(ievt)))->particles_size();
#ifdef HEPMC3
counter.m_counter[kN_gen_tracks_processed] += genEvent->particles().size();
#else
counter.m_counter[kN_gen_tracks_processed] += genEvent->particles_size();
#endif
if (put && inTimeMBbegin != inTimeMBend) // if not, inTimeStart and End are untouched
{
//if (genEvent == *inTimeMBbegin) inTimeStart = ievt;
......
......@@ -407,7 +407,7 @@ void InDet::TrackStatHelper::addEvent(const TrackCollection * recTr
Eta = 0;
Region = ETA_ALL;
int classification=-999;
for (std::vector <std::pair<HepMC::GenParticle *,int> >::const_iterator truth = gen.begin(); truth != gen.end(); ++truth) {
for (auto truth = gen.begin(); truth != gen.end(); ++truth) {
classification=-999;
bool inTimePileup = truth->second == 0
|| (truth->second >= (int)*inTimeStart && truth->second <= (int)*inTimeEnd);
......@@ -494,7 +494,7 @@ void InDet::TrackStatHelper::addEvent(const TrackCollection * recTr
Region = ETA_ALL;
classification=-999;
for (std::vector <std::pair<HepMC::GenParticle *,int> >::const_iterator truth = gen.begin(); truth != gen.end(); ++truth)
for (auto truth = gen.begin(); truth != gen.end(); ++truth)
{
if (truth->second != 0) // only signal event GenParticles
continue;
......@@ -868,7 +868,7 @@ bool InDet::TrackStatHelper::PassTrackCuts(const Trk::TrackParameters *para) con
}
int InDet::TrackStatHelper::ClassifyParticle( const HepMC::GenParticle *particle, const double prob) const {
int InDet::TrackStatHelper::ClassifyParticle( HepMC::ConstGenParticlePtr particle, const double prob) const {
int partClass=-999;
......
......@@ -84,9 +84,9 @@ TruthLeptonParentAssociationTool::reset (const TruthParticle& p)
return StatusCode::SUCCESS;
}
void TruthLeptonParentAssociationTool::addLeptonParent(const HepMC::GenParticle* part) {
void TruthLeptonParentAssociationTool::addLeptonParent(HepMC::ConstGenParticlePtr part) {
HepMC::GenVertex* begvx = part->production_vertex();
auto begvx = part->production_vertex();
if(!begvx){ // no parents
return;
}
......@@ -95,22 +95,27 @@ void TruthLeptonParentAssociationTool::addLeptonParent(const HepMC::GenParticle*
if (begvx==part->end_vertex()) return;
// More complex loop catch
if ( find(m_barcode_trace.begin(),m_barcode_trace.end(),begvx->barcode()) != m_barcode_trace.end()){
if ( find(m_barcode_trace.begin(),m_barcode_trace.end(),HepMC::barcode(begvx)) != m_barcode_trace.end()){
ATH_MSG_DEBUG( "Found a loop (a la Sherpa sample). Backing out." );
return;
}
m_barcode_trace.push_back(begvx->barcode());
m_barcode_trace.push_back(HepMC::barcode(begvx));
// Loop over the parents of this particle.
#ifdef HEPMC3
auto itrPar = begvx->particles_in().begin();
auto endPar = begvx->particles_in().end();
#else
HepMC::GenVertex::particle_iterator itrPar = begvx->particles_begin(HepMC::parents);
HepMC::GenVertex::particle_iterator endPar = begvx->particles_end(HepMC::parents);
#endif
int n_iter=0;
for(;itrPar!=endPar; ++itrPar){
if ( !(*itrPar) ) continue; // parent didn't exist
n_iter++;
if (n_iter>2) break; // No point in trying - this vertex does not have a quantum meaning...
int pdg = abs((*itrPar)->pdg_id());
int pdg = std::abs((*itrPar)->pdg_id());
if ( (31<pdg && pdg<38) || // BSM Higgs / W' / Z' / etc
pdg==39 ||
......@@ -125,7 +130,7 @@ void TruthLeptonParentAssociationTool::addLeptonParent(const HepMC::GenParticle*
(pdg == 15 && !m_primary_is_tau) || // Tau
HepPID::isHadron (pdg) // from a hadron!
){
m_parent_barcodes.push_back( (*itrPar)->barcode() );
m_parent_barcodes.push_back( HepMC::barcode(*itrPar) );
} else { // Will get to here if we are coming from the same lepton again
addLeptonParent( *itrPar );
} // End of catch on PDG ID
......
......@@ -59,7 +59,7 @@ public:
private:
/// Function for association to a specific lepton
void addLeptonParent(const HepMC::GenParticle*);
void addLeptonParent(HepMC::ConstGenParticlePtr);
/// TruthParticle iterator
std::vector<const TruthParticle*> m_parents;
......
......@@ -78,25 +78,23 @@ TruthTauDecayAssociationTool::reset (const TruthParticle& p)
return StatusCode::SUCCESS;
}
void TruthTauDecayAssociationTool::addStableDaughters(const HepMC::GenParticle* part) {
void TruthTauDecayAssociationTool::addStableDaughters(HepMC::ConstGenParticlePtr part) {
// Sanity check
if (!part) return;
HepMC::GenVertex* endvx = part->end_vertex();
auto endvx = part->end_vertex();
if(!endvx){ // no children
if ( part && part->status()==1 ) m_tau_prod_barcodes.push_back( part->barcode() );
if ( part && part->status()==1 ) m_tau_prod_barcodes.push_back( HepMC::barcode(part) );
return;
}
// Loop over the parents of this particle.
HepMC::GenVertex::particle_iterator itrChild = endvx->particles_begin(HepMC::children);
HepMC::GenVertex::particle_iterator endChild = endvx->particles_end(HepMC::children);
for(;itrChild!=endChild; ++itrChild){
if ( (*itrChild) && (*itrChild)->status()==1 ){
for(auto Child: *endvx){
if ( (Child) && (Child)->status()==1 ){
// Found a stable child!
m_tau_prod_barcodes.push_back( (*itrChild)->barcode() );
} else if ( (*itrChild) ){
addStableDaughters( (*itrChild) );
m_tau_prod_barcodes.push_back( HepMC::barcode(Child) );
} else if ( (Child) ){
addStableDaughters( (Child) );
}
} // End loop over children
......
......@@ -59,7 +59,7 @@ public:
private:
/// Function for association to a specific tau
void addStableDaughters(const HepMC::GenParticle*);
void addStableDaughters(HepMC::ConstGenParticlePtr);
/// TruthParticle iterator
std::vector<const TruthParticle*> m_tau_prods;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment