From fa13fc057a4426d1a9a1bd0f7c6e86c3028c0c47 Mon Sep 17 00:00:00 2001 From: Fang Wenxing <wxfang@lxslc709.ihep.ac.cn> Date: Tue, 26 Jan 2021 15:58:41 +0800 Subject: [PATCH] update SimHitMergeAlg --- Digitisers/SimHitMerge/src/SimHitMergeAlg.cpp | 21 ++++-------- Digitisers/SimHitMerge/src/SimHitMergeAlg.h | 4 +++ .../Pandora/GaudiPandora/src/PandoraPFAlg.cpp | 34 +++++++++---------- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/Digitisers/SimHitMerge/src/SimHitMergeAlg.cpp b/Digitisers/SimHitMerge/src/SimHitMergeAlg.cpp index 3ff8d126..cdbcbfe2 100644 --- a/Digitisers/SimHitMerge/src/SimHitMergeAlg.cpp +++ b/Digitisers/SimHitMerge/src/SimHitMergeAlg.cpp @@ -57,7 +57,6 @@ StatusCode SimHitMergeAlg::initialize() { StatusCode SimHitMergeAlg::execute() { - bool sanity_check = true; for (unsigned int k0 = 0; k0 < m_inputColNames.size(); k0++) { @@ -85,18 +84,13 @@ StatusCode SimHitMergeAlg::execute() } else id_vconb_map[id] = tmp_vconb; - if(sanity_check){ - if ( test_id_hits_map.find(id) != test_id_hits_map.end()) test_id_hits_map[id].push_back(Simhit); - else{ - std::vector<edm4hep::SimCalorimeterHit> tmp_vec ; - tmp_vec.push_back(Simhit); - test_id_hits_map[id] = tmp_vec; - } + if(m_sanity_check){ + test_id_hits_map[id].push_back(Simhit); } } - if(sanity_check){ + if(m_sanity_check){ for(std::map<unsigned long long, std::vector<edm4hep::SimCalorimeterHit> >::iterator iter = test_id_hits_map.begin(); iter != test_id_hits_map.end(); iter++){ for(unsigned int i=0; i< iter->second.size(); i++){ float pos1_x = iter->second.at(i).getPosition()[0]; @@ -107,8 +101,9 @@ StatusCode SimHitMergeAlg::execute() float pos2_y = iter->second.at(j).getPosition()[1]; float pos2_z = iter->second.at(j).getPosition()[2]; float dis = sqrt( (pos1_x-pos2_x)*(pos1_x-pos2_x) + (pos1_y-pos2_y)*(pos1_y-pos2_y) + (pos1_z-pos2_z)*(pos1_z-pos2_z) ); - if( dis > sqrt(10*10 + 10*10 + 1.2*1.2) ) - std::cout<<"found id="<<iter->first<<",dis="<<dis<<",x1="<<pos1_x<<",y1="<<pos1_y<<",z1="<<pos1_z<<",x2="<<pos2_x<<",y2="<<pos2_y<<",z2="<<pos2_z<<std::endl; + if( dis > sqrt(m_cell_x*m_cell_x + m_cell_y*m_cell_y + m_cell_z*m_cell_z) ){ + std::cout<<"found id="<<iter->first<<",dis="<<dis<<",x1="<<pos1_x<<",y1="<<pos1_y<<",z1="<<pos1_z<<",x2="<<pos2_x<<",y2="<<pos2_y<<",z2="<<pos2_z<<std::endl; + } } } } @@ -119,9 +114,7 @@ StatusCode SimHitMergeAlg::execute() { edm4hep::SimCalorimeterHit Simhit = iter->second ; dd4hep::Position position = m_cellIDConverter->position(Simhit.getCellID());//cm - float dd4hep_mm = dd4hep::mm; - edm4hep::Vector3f hitPos((1/dd4hep_mm)*position.x(), (1/dd4hep_mm)*position.y(), (1/dd4hep_mm)*position.z());//to mm - //edm4hep::Vector3f hitPos(position.x()*10, position.y()*10, position.z()*10);//to mm + edm4hep::Vector3f hitPos(position.x()/(dd4hep::mm), position.y()/(dd4hep::mm), position.z()/(dd4hep::mm));//to mm //std::cout<<"id="<<Simhit.getCellID()<<",hitPos.x="<<hitPos[0]<<",y="<<hitPos[1]<<",z="<<hitPos[2]<<",ori x="<<Simhit.getPosition()[0]<<",y="<<Simhit.getPosition()[1]<<",z="<<Simhit.getPosition()[2]<<std::endl; auto Mergedhit = mergedCol->create(); Mergedhit.setCellID (Simhit.getCellID()); diff --git a/Digitisers/SimHitMerge/src/SimHitMergeAlg.h b/Digitisers/SimHitMerge/src/SimHitMergeAlg.h index d91de40f..04b74aa0 100644 --- a/Digitisers/SimHitMerge/src/SimHitMergeAlg.h +++ b/Digitisers/SimHitMerge/src/SimHitMergeAlg.h @@ -44,6 +44,10 @@ protected: Gaudi::Property<std::vector<std::string>> m_outputColNames{this, "OutputCollections", {"ECALBarrel", "ECALEndcap", "ECALOther"}, "Name of merged Hit Collections"}; std::vector<SimCaloType*> m_InputCollections; std::vector<SimCaloType*> m_OutputCollections; + Gaudi::Property< bool > m_sanity_check{this, "sanity_check", false, "sanity check"}; + Gaudi::Property< float > m_cell_x{this, "cell_x", 10, ""};//mm + Gaudi::Property< float > m_cell_y{this, "cell_y", 10, ""};//mm + Gaudi::Property< float > m_cell_z{this, "cell_z", 10, ""};//mm SmartIF<IGeomSvc> m_geosvc; dd4hep::Detector* m_dd4hep_geo; diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/PandoraPFAlg.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/PandoraPFAlg.cpp index df2d3f5d..eef2087e 100644 --- a/Reconstruction/PFA/Pandora/GaudiPandora/src/PandoraPFAlg.cpp +++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/PandoraPFAlg.cpp @@ -482,9 +482,9 @@ StatusCode PandoraPFAlg::updateMap() std::vector<edm4hep::MCParticle> v_mc; m_CollectionMaps->collectionMap_MC [v.first] = v_mc; for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_MC [v.first].push_back(po->at(i)); - if(m_debug) std::cout<<"saved col name="<<v.first<<std::endl; + debug()<<"saved col name="<<v.first<<endmsg; } - else if(m_debug) std::cout<<"don't find col name="<<v.first<<std::endl; + debug()<<"don't find col name="<<v.first<<endmsg; } else if(m_collections[v.first]=="CalorimeterHit"){ @@ -494,9 +494,9 @@ StatusCode PandoraPFAlg::updateMap() std::vector<edm4hep::CalorimeterHit> v_cal; m_CollectionMaps->collectionMap_CaloHit[v.first] = v_cal ; for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_CaloHit [v.first].push_back(po->at(i)); - if(m_debug) std::cout<<"saved col name="<<v.first<<std::endl; + debug()<<"saved col name="<<v.first<<endmsg; } - else if(m_debug) std::cout<<"don't find col name="<<v.first<<std::endl; + debug()<<"don't find col name="<<v.first<<endmsg; } else if(m_collections[v.first]=="Track"){ @@ -506,10 +506,10 @@ StatusCode PandoraPFAlg::updateMap() std::vector<edm4hep::Track> v_cal; m_CollectionMaps->collectionMap_Track[v.first] = v_cal ; for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_Track [v.first].push_back(po->at(i)); - if(m_debug) std::cout<<"saved col name="<<v.first<<std::endl; + debug() <<"saved col name="<<v.first<<endmsg; m_marlinTrack = po->size(); } - else if(m_debug) std::cout<<"don't find col name="<<v.first<<std::endl; + debug() <<"don't find col name="<<v.first<<endmsg; } else if(m_collections[v.first]=="Vertex"){ @@ -519,9 +519,9 @@ StatusCode PandoraPFAlg::updateMap() std::vector<edm4hep::Vertex> v_cal; m_CollectionMaps->collectionMap_Vertex[v.first] = v_cal ; for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_Vertex [v.first].push_back(po->at(i)); - if(m_debug) std::cout<<"saved col name="<<v.first<<std::endl; + debug() <<"saved col name="<<v.first<<endmsg; } - else if(m_debug) std::cout<<"don't find col name="<<v.first<<std::endl; + debug() <<"don't find col name="<<v.first<<endmsg; } else if(m_collections[v.first]=="MCRecoCaloAssociation"){ @@ -531,9 +531,9 @@ StatusCode PandoraPFAlg::updateMap() std::vector<edm4hep::MCRecoCaloAssociation> v_cal; m_CollectionMaps->collectionMap_CaloRel[v.first] = v_cal ; for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_CaloRel [v.first].push_back(po->at(i)); - if(m_debug) std::cout<<"saved col name="<<v.first<<std::endl; + debug() <<"saved col name="<<v.first<<endmsg; } - else if(m_debug) std::cout<<"don't find col name="<<v.first<<std::endl; + debug() <<"don't find col name="<<v.first<<endmsg; } else if(m_collections[v.first]=="MCRecoTrackerAssociation"){ @@ -543,9 +543,9 @@ StatusCode PandoraPFAlg::updateMap() std::vector<edm4hep::MCRecoTrackerAssociation> v_cal; m_CollectionMaps->collectionMap_TrkRel[v.first] = v_cal ; for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_TrkRel [v.first].push_back(po->at(i)); - if(m_debug) std::cout<<"saved col name="<<v.first<<std::endl; + debug() <<"saved col name="<<v.first<<endmsg; } - else if(m_debug) std::cout<<"don't find col name="<<v.first<<std::endl; + debug() <<"don't find col name="<<v.first<<endmsg; } else{ @@ -553,8 +553,8 @@ StatusCode PandoraPFAlg::updateMap() } }//try catch(...){ - if(m_debug) std::cout<<"don't find "<<v.first<<" in event"<<std::endl; - if(m_debug) std::cout<<"don't find col name="<<v.first<<",with type="<<m_collections[v.first]<<" in this event"<<std::endl; + debug() <<"don't find "<<v.first<<" in event"<<endmsg; + debug() <<"don't find col name="<<v.first<<",with type="<<m_collections[v.first]<<" in this event"<<endmsg; } } return StatusCode::SUCCESS; @@ -587,11 +587,11 @@ StatusCode PandoraPFAlg::Ana() m_pReco_py [m_n_rec]=py; m_pReco_pz [m_n_rec]=pz; m_n_rec ++ ; - if(m_debug) std::cout<<"rec type="<<type<<",energy="<<energy<<std::endl; + debug() <<"rec type="<<type<<",energy="<<energy<<endmsg; for(int j=0; j < reco_associa_col->size(); j++) { if(reco_associa_col->at(j).getRec().id() != pReco.id() ) continue; - if(m_debug) std::cout<<"MC pid ="<<reco_associa_col->at(j).getSim().getPDG()<<",weight="<<reco_associa_col->at(j).getWeight()<<", px="<<reco_associa_col->at(j).getSim().getMomentum()[0]<<", py="<<reco_associa_col->at(j).getSim().getMomentum()[1]<<",pz="<<reco_associa_col->at(j).getSim().getMomentum()[2]<<std::endl; + debug() <<"MC pid ="<<reco_associa_col->at(j).getSim().getPDG()<<",weight="<<reco_associa_col->at(j).getWeight()<<", px="<<reco_associa_col->at(j).getSim().getMomentum()[0]<<", py="<<reco_associa_col->at(j).getSim().getMomentum()[1]<<",pz="<<reco_associa_col->at(j).getSim().getMomentum()[2]<<endmsg; } } const edm4hep::MCParticleCollection* MCParticle = nullptr; @@ -608,7 +608,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]); - if(m_debug) std::cout<<"mc type="<<MCParticle->at(i).getPDG()<<",energy="<<mc_E<<std::endl; + debug() <<"mc type="<<MCParticle->at(i).getPDG()<<",energy="<<mc_E<<endmsg; m_n_mc ++ ; if (MCParticle->at(i).getPDG() != 22) continue; int hasEm = 0; -- GitLab