Commit fc0c708e authored by Andrii Verbytskyi's avatar Andrii Verbytskyi Committed by Adam Edward Barton
Browse files

Fix compilation for HepMC3 and crashes for pythia8

parent 4f9c24c9
......@@ -110,6 +110,10 @@ private:
std::vector<std::string> m_userParams;
std::vector<std::string> m_userModes;
#ifdef HEPMC3
std::shared_ptr<HepMC3::GenRunInfo> m_runinfo;
#endif
enum PDGID {PROTON=2212, ANTIPROTON=-2212, LEAD=1000822080, NEUTRON=2112, ANTINEUTRON=-2112, MUON=13, ANTIMUON=-13, ELECTRON=11, POSITRON=-11, INVALID=0};
double m_collisionEnergy;
......
......@@ -117,6 +117,12 @@ m_athenaTool("")
ATH_MSG_INFO("XML Path is " + xmlpath());
m_pythia = std::make_unique<Pythia8::Pythia> (xmlpath());
#ifdef HEPMC3
m_runinfo = std::shared_ptr<HepMC3::GenRunInfo>();
/// Here one can fill extra information.
struct HepMC3::GenRunInfo::ToolInfo generator={std::string("Pythia8"),std::to_string(PYTHIA_VERSION).substr(0,5),std::string("Used generator")};
m_runinfo->tools().push_back(generator);
#endif
}
////////////////////////////////////////////////////////////////////////////////
......@@ -557,6 +563,7 @@ std::to_string(iw);
if(m_internal_event_number == 1){
std::vector<std::string> names;
for (auto w: fWeights) names.push_back(w.first);
if (!evt->run_info()) evt->set_run_info(m_runinfo);
evt->run_info()->set_weight_names(names);
}
for (auto w: fWeights) {evt->weight(w.first)=w.second;}
......
......@@ -1409,7 +1409,7 @@ bool CompactHardTruth::isParton(HepMC::ConstGenParticlePtr p) {
// It should have been detached from hadronization vertex.
bool CompactHardTruth::isFinalParton(HepMC::ConstGenParticlePtr p) {
if (!isParton(p)) return false;
auto *endp = p->end_vertex();
auto endp = p->end_vertex();
return endp == nullptr;
}
......
......@@ -86,12 +86,12 @@ MMLoadVariables::MMLoadVariables(StoreGateSvc* evtStore, const MuonGM::MuonDetec
#endif
const HepMC::FourVector momentum = particle->momentum();
int k=trackRecordCollection->size(); //number of mu
if(particle->barcode() < 1e06 && std::abs(particle->pdg_id())==13){
if(HepMC::barcode(particle) < 1e06 && std::abs(particle->pdg_id())==13){
thePart.SetCoordinates(momentum.perp(),momentum.eta(),momentum.phi(),momentum.e());
for(const auto & mit : *trackRecordCollection ) {
const CLHEP::Hep3Vector mumomentum = mit.GetMomentum();
const CLHEP::Hep3Vector muposition = mit.GetPosition();
if(k>0 && j<k && particle->barcode()==mit.GetBarCode()) {
if(k>0 && j<k && HepMC::barcode(particle)==mit.GetBarCode()) {
pdg_tmp = HepMC::barcode(particle);
phiEntry_tmp = mumomentum.getPhi();
etaEntry_tmp = mumomentum.getEta();
......@@ -115,7 +115,7 @@ MMLoadVariables::MMLoadVariables(StoreGateSvc* evtStore, const MuonGM::MuonDetec
}
j++;
if(thePart.Pt() > 0. && particle->barcode() < 1e06){
if(thePart.Pt() > 0. && HepMC::barcode(particle) < 1e06){
bool addIt = true;
for(unsigned int ipart=0; ipart < truthParticles.size(); ipart++){
if( std::abs(thePart.Pt()-truthParticles[ipart].Pt()) < 0.001 ||
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment