From 652823204cfda1269a99702529d9351e0d683140 Mon Sep 17 00:00:00 2001 From: Fang Wenxing <wxfang@lxslc708.ihep.ac.cn> Date: Tue, 2 Mar 2021 14:54:48 +0800 Subject: [PATCH] update Pandora to use correct Stave number --- .../GaudiPandora/include/PandoraPFAlg.h | 2 ++ .../GaudiPandora/src/CaloHitCreator.cpp | 18 ++++++++-- .../Pandora/GaudiPandora/src/PandoraPFAlg.cpp | 33 ++++++++++++++----- 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/include/PandoraPFAlg.h b/Reconstruction/PFA/Pandora/GaudiPandora/include/PandoraPFAlg.h index a74b8a77..6a7a1bac 100644 --- a/Reconstruction/PFA/Pandora/GaudiPandora/include/PandoraPFAlg.h +++ b/Reconstruction/PFA/Pandora/GaudiPandora/include/PandoraPFAlg.h @@ -279,6 +279,8 @@ protected: NTuple::Array<float> m_mc_charge; + Gaudi::Property<int> m_max_mc {this, "max_mc", 1000,""}; + Gaudi::Property<int> m_max_rec {this, "max_rec", 1000,""}; Gaudi::Property<bool> m_debug {this, "debug", false,"if do debug"}; diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp index 873ae8c3..72262b60 100644 --- a/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp +++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp @@ -438,7 +438,8 @@ pandora::StatusCode CaloHitCreator::CreateHCalCaloHits(const CollectionMaps& col PandoraApi::CaloHit::Parameters caloHitParameters; caloHitParameters.m_hitType = pandora::HCAL; caloHitParameters.m_isDigital = false;// if it is DHCAL or AHCAL - caloHitParameters.m_layer = m_settings.m_use_dd4hep_decoder == false ? cellIdDecoder(pCaloHit)[layerCoding.c_str()] : m_decoder->get(pCaloHit->getCellID(), "layer"); + caloHitParameters.m_layer = m_settings.m_use_dd4hep_decoder == false ? cellIdDecoder(pCaloHit)[layerCoding.c_str()]+1 : m_decoder->get(pCaloHit->getCellID(), "layer");//from 1 to 40 + //std::cout<<"HCAL layer="<<caloHitParameters.m_layer.Get()<<std::endl; caloHitParameters.m_isInOuterSamplingLayer = (this->GetNLayersFromEdge(pCaloHit) <= m_settings.m_nOuterSamplingLayers); this->GetCommonCaloHitProperties(pCaloHit, caloHitParameters); int Stave = 0 ; @@ -447,7 +448,7 @@ pandora::StatusCode CaloHitCreator::CreateHCalCaloHits(const CollectionMaps& col } else{ Stave = m_decoder->get(pCaloHit->getCellID(), "stave"); - Stave = Stave <=2 ? Stave+5 : Stave-3 ;//FIXME , need check!! + Stave = Stave ==0 ? Stave+7 : Stave-1 ;//correct, same with LCIO } float absorberCorrection(1.); @@ -550,15 +551,26 @@ pandora::StatusCode CaloHitCreator::CreateMuonCaloHits(const CollectionMaps& col PandoraApi::CaloHit::Parameters caloHitParameters; caloHitParameters.m_hitType = pandora::MUON; caloHitParameters.m_layer = m_settings.m_use_dd4hep_decoder == false ? cellIdDecoder(pCaloHit)[layerCoding.c_str()] + 1 : m_decoder->get(pCaloHit->getCellID(), "layer"); + //std::cout<<"Muon layer="<<caloHitParameters.m_layer.Get()<<std::endl; caloHitParameters.m_isInOuterSamplingLayer = true; this->GetCommonCaloHitProperties(pCaloHit, caloHitParameters); int Stave = 0 ; if (m_settings.m_use_dd4hep_decoder == false){ Stave = cellIdDecoder(pCaloHit)[ staveCoding]; + /* + float tmp_x = pCaloHit->getPosition()[0]; + float tmp_y = pCaloHit->getPosition()[1]; + float tmp_z = pCaloHit->getPosition()[2]; + float tmp_phi = atan(tmp_y/tmp_x)*180/acos(-1); + if(tmp_x<0) tmp_phi += 180; + if(tmp_x>0 && tmp_y<0) tmp_phi += 360; + if(abs(tmp_z) < 2000 )std::cout<<"Muon ILC Stave="<<Stave<<",phi="<<tmp_phi<<std::endl; + */ } else{ Stave = m_decoder->get(pCaloHit->getCellID(), "stave"); - Stave = Stave <=2 ? Stave+5 : Stave-3 ;//FIXME , need check!! + Stave = 12 - Stave ;//correct to be same with LCIO + if(Stave<0) throw("throw wrong stave number?"); } const float radius(std::sqrt(pCaloHit->getPosition()[0] * pCaloHit->getPosition()[0] + diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/PandoraPFAlg.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/PandoraPFAlg.cpp index eef2087e..18030dbd 100644 --- a/Reconstruction/PFA/Pandora/GaudiPandora/src/PandoraPFAlg.cpp +++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/PandoraPFAlg.cpp @@ -109,8 +109,8 @@ StatusCode PandoraPFAlg::initialize() else { m_tuple = ntupleSvc()->book( "MyTuples/Pan_reco_evt", CLID_ColumnWiseTuple, "Pan_reco_evt" ); if ( m_tuple ) { - m_tuple->addItem( "N_mc" , m_n_mc , 0, 1000 ).ignore(); - m_tuple->addItem( "N_rec", m_n_rec, 0, 1000 ).ignore(); + m_tuple->addItem( "N_mc" , m_n_mc , 0, m_max_mc.value() ).ignore(); + m_tuple->addItem( "N_rec", m_n_rec, 0, m_max_rec.value()).ignore(); m_tuple->addItem( "m_pReco_PID" , m_n_rec, m_pReco_PID ).ignore(); m_tuple->addItem( "m_pReco_mass" , m_n_rec, m_pReco_mass ).ignore(); m_tuple->addItem( "m_pReco_energy", m_n_rec, m_pReco_energy ).ignore(); @@ -484,7 +484,9 @@ StatusCode PandoraPFAlg::updateMap() for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_MC [v.first].push_back(po->at(i)); debug()<<"saved col name="<<v.first<<endmsg; } - debug()<<"don't find col name="<<v.first<<endmsg; + else{ + debug()<<"don't find col name="<<v.first<<endmsg; + } } else if(m_collections[v.first]=="CalorimeterHit"){ @@ -496,7 +498,9 @@ StatusCode PandoraPFAlg::updateMap() for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_CaloHit [v.first].push_back(po->at(i)); debug()<<"saved col name="<<v.first<<endmsg; } - debug()<<"don't find col name="<<v.first<<endmsg; + else{ + debug()<<"don't find col name="<<v.first<<endmsg; + } } else if(m_collections[v.first]=="Track"){ @@ -509,7 +513,9 @@ StatusCode PandoraPFAlg::updateMap() debug() <<"saved col name="<<v.first<<endmsg; m_marlinTrack = po->size(); } - debug() <<"don't find col name="<<v.first<<endmsg; + else{ + debug()<<"don't find col name="<<v.first<<endmsg; + } } else if(m_collections[v.first]=="Vertex"){ @@ -521,7 +527,9 @@ StatusCode PandoraPFAlg::updateMap() for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_Vertex [v.first].push_back(po->at(i)); debug() <<"saved col name="<<v.first<<endmsg; } - debug() <<"don't find col name="<<v.first<<endmsg; + else{ + debug()<<"don't find col name="<<v.first<<endmsg; + } } else if(m_collections[v.first]=="MCRecoCaloAssociation"){ @@ -533,7 +541,9 @@ StatusCode PandoraPFAlg::updateMap() for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_CaloRel [v.first].push_back(po->at(i)); debug() <<"saved col name="<<v.first<<endmsg; } - debug() <<"don't find col name="<<v.first<<endmsg; + else{ + debug()<<"don't find col name="<<v.first<<endmsg; + } } else if(m_collections[v.first]=="MCRecoTrackerAssociation"){ @@ -545,7 +555,9 @@ StatusCode PandoraPFAlg::updateMap() for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_TrkRel [v.first].push_back(po->at(i)); debug() <<"saved col name="<<v.first<<endmsg; } - debug() <<"don't find col name="<<v.first<<endmsg; + else{ + debug()<<"don't find col name="<<v.first<<endmsg; + } } else{ @@ -571,6 +583,7 @@ StatusCode PandoraPFAlg::Ana() const edm4hep::MCRecoParticleAssociationCollection* reco_associa_col = m_MCRecoParticleAssociation_w.get(); for(int i=0; i<reco_col->size();i++) { + if( m_n_rec >= m_max_rec) break; const edm4hep::ReconstructedParticle pReco = reco_col->at(i); const float px = pReco.getMomentum()[0]; const float py = pReco.getMomentum()[1]; @@ -600,6 +613,8 @@ StatusCode PandoraPFAlg::Ana() { for(unsigned int i=0 ; i< MCParticle->size(); i++) { + if( m_n_mc >= m_max_mc) break; + if( MCParticle->at(i).parents_size() !=0 ) continue;// only save primary m_mc_p_size[m_n_mc] = MCParticle->at(i).parents_size(); m_mc_pid [m_n_mc] = MCParticle->at(i).getPDG(); m_mc_mass [m_n_mc] = MCParticle->at(i).getMass(); @@ -608,7 +623,7 @@ StatusCode PandoraPFAlg::Ana() m_mc_pz [m_n_mc] = MCParticle->at(i).getMomentum()[2]; m_mc_charge[m_n_mc] = MCParticle->at(i).getCharge(); float mc_E = sqrt( MCParticle->at(i).getMass()*MCParticle->at(i).getMass() + MCParticle->at(i).getMomentum()[0]*MCParticle->at(i).getMomentum()[0] + MCParticle->at(i).getMomentum()[1]*MCParticle->at(i).getMomentum()[1] + MCParticle->at(i).getMomentum()[2]*MCParticle->at(i).getMomentum()[2]); - debug() <<"mc type="<<MCParticle->at(i).getPDG()<<",energy="<<mc_E<<endmsg; + //debug() <<"mc type="<<MCParticle->at(i).getPDG()<<",energy="<<mc_E<<",m_mc_p_size="<<m_mc_p_size->size()<<endmsg; m_n_mc ++ ; if (MCParticle->at(i).getPDG() != 22) continue; int hasEm = 0; -- GitLab