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

Hepmc3 nightly fixes 02122020 part 5

parent b1bbd3f9
No related branches found
No related tags found
No related merge requests found
......@@ -46,12 +46,20 @@ SimpleTruthParticleFilterTool::isAccepted (const HepMC::GenParticle* p)
bool last = std::abs(p->pdg_id())==15;
if ( abs(p->pdg_id())==15 && p->status()!=1 && p->end_vertex() ){
// Special handling for taus - take the ones that are last in the tau chain
#ifdef HEPMC3
for (auto pit: p->end_vertex()->particles_out()){
if (!pit || std::abs(pit->pdg_id())!=15) continue;
last=false;
break;
}
#else
for (HepMC::GenVertex::particles_out_const_iterator pit=p->end_vertex()->particles_out_const_begin(); pit!=p->end_vertex()->particles_out_const_end();++pit){
if (!(*pit) ||
abs((*pit)->pdg_id())!=15) continue;
last=false;
break;
}
#endif
if (!last) return false;
}
......
......@@ -134,15 +134,18 @@ StatusCode Trk::TrueTracksNtupleTool::fillTrueTracksInfo(const TrackCollection&
if (msgLvl(MSG::DEBUG)) msg (MSG::DEBUG) << " truth is missing" << endmsg;
} else {
TrackTruth trk_truth=found->second;
const HepMC::GenParticle * particle;
particle = trk_truth.particleLink();
HepMC:: GenVertex* prod_vtx = particle->production_vertex();
auto particle = trk_truth.particleLink();
auto prod_vtx = particle->production_vertex();
//fill prod vertex
m_prod_x->push_back(prod_vtx->position().x());
m_prod_y->push_back(prod_vtx->position().y());
m_prod_z->push_back(prod_vtx->position().z());
#ifdef HEPMC3
auto parent_iter = prod_vtx->particles_in().begin();
#else
HepMC::GenVertex::particle_iterator parent_iter = prod_vtx->particles_begin(HepMC::parents);
#endif
m_parent_id->push_back((*parent_iter)->pdg_id());
m_particle_id->push_back(particle->pdg_id());
}
......
......@@ -71,18 +71,22 @@ MMLoadVariables::MMLoadVariables(StoreGateSvc* evtStore, const MuonGM::MuonDetec
for(const auto it : *truthContainer) { //first loop in MMT_loader::load_event
const HepMC::GenEvent *subEvent = it;
#ifdef HEPMC3
for(auto particle : subEvent->particles()) {
#else
HepMC::ConstGenEventParticleRange particle_range = subEvent->particle_range();
for(const auto pit : particle_range) {
const HepMC::GenParticle *particle = pit;
const HepMC::FourVector& momentum = particle->momentum();
#endif
const HepMC::FourVector momentum = particle->momentum();
int k=trackRecordCollection->size(); //number of mu entries
if(particle->barcode() == 10001 && std::abs(particle->pdg_id())==13){
if(HepMC::barcode(particle) == 10001 && std::abs(particle->pdg_id())==13){
thePart.SetPtEtaPhiE(momentum.perp(),momentum.eta(),momentum.phi(),momentum.e());
for(const auto & mit : *trackRecordCollection ) {
if(k>0&&j<k){
const CLHEP::Hep3Vector mumomentum = mit.GetMomentum();
const CLHEP::Hep3Vector muposition = mit.GetPosition();
pdg=particle->barcode();
pdg=HepMC::barcode(particle);
phiEntry = mumomentum.getPhi();
etaEntry = mumomentum.getEta();
phiPosition = muposition.getPhi();
......@@ -90,10 +94,14 @@ MMLoadVariables::MMLoadVariables(StoreGateSvc* evtStore, const MuonGM::MuonDetec
}
}//muentry loop
int l=0;
#ifdef HEPMC3
for(auto vertex1 : subEvent->vertices()) {
#else
HepMC::ConstGenEventVertexRange vertex_range = subEvent->vertex_range();
for(const auto vit : vertex_range) {
if(l!=0){break;}//get first vertex of iteration, may want to change this
const HepMC::GenVertex *vertex1 = vit;
#endif
const HepMC::FourVector& position = vertex1->position();
vertex=TVector3(position.x(),position.y(),position.z());
l++;
......@@ -160,11 +168,8 @@ MMLoadVariables::MMLoadVariables(StoreGateSvc* evtStore, const MuonGM::MuonDetec
//match to truth particle
TLorentzVector truthPart;
for(auto it1 : *truthContainer) { //Must be a more elegant way... should work for now though
const HepMC::GenEvent *subEvent1 = it1;
HepMC::ConstGenEventParticleRange particle_range1 = subEvent1->particle_range();
for(auto pit1 : particle_range1) {
const HepMC::GenParticle *particle1 = pit1;
const HepMC::FourVector& momentum1 = particle1->momentum();
for(auto particle1 : *it1) {
const HepMC::FourVector momentum1 = particle1->momentum();
truthPart.SetPtEtaPhiE(momentum1.perp(),momentum1.eta(),momentum1.phi(),momentum1.e());
}//end particle loop
}//end truth container loop (1 iteration) for matching
......
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