diff --git a/Digitisers/G2CDArbor/src/G2CDArborAlg.cpp b/Digitisers/G2CDArbor/src/G2CDArborAlg.cpp index 50c742297b177932097ec179d12b07ff37043062..a38826b9d85301ed9e5990145e7a21f9b47b9ef8 100644 --- a/Digitisers/G2CDArbor/src/G2CDArborAlg.cpp +++ b/Digitisers/G2CDArbor/src/G2CDArborAlg.cpp @@ -494,8 +494,8 @@ StatusCode G2CDArborAlg::execute() // get the DD4hep readout m_decoder = m_geosvc->getDecoder(tmp_readout); if (!m_decoder) { - error() << "Failed to get the decoder. " << endmsg; - return StatusCode::FAILURE; + error() << "Failed to get the decoder. Skip this collection:"<<m_ecalColNames.value().at(k0)<< endmsg; + continue; } } @@ -618,7 +618,7 @@ StatusCode G2CDArborAlg::execute() for(auto SimHcalhit: *Hcalcol){ // SimCalorimeterHit * SimHcalhit = dynamic_cast<SimCalorimeterHit*>( Hcalcol->getElementAt( k4 ) ) ; - cout<<"hcal"<<endl; + //cout<<"hcal"<<endl; currTime = 0; EmaxStep = 0; HitStepEn = 0; diff --git a/Digitisers/SimHitMerge/src/SimHitMergeAlg.cpp b/Digitisers/SimHitMerge/src/SimHitMergeAlg.cpp index 4a1eda3b4ac450b5ea90653ce102b8036acfc9a0..3ff8d12603d2e116031f908c23786503f0de2e32 100644 --- a/Digitisers/SimHitMerge/src/SimHitMergeAlg.cpp +++ b/Digitisers/SimHitMerge/src/SimHitMergeAlg.cpp @@ -6,6 +6,7 @@ #include "DD4hep/Detector.h" #include "DD4hep/IDDescriptor.h" #include "DD4hep/Plugins.h" +#include "DD4hep/DD4hepUnits.h" #include <string> #include <iostream> @@ -56,10 +57,12 @@ StatusCode SimHitMergeAlg::initialize() { StatusCode SimHitMergeAlg::execute() { - + bool sanity_check = true; + for (unsigned int k0 = 0; k0 < m_inputColNames.size(); k0++) { std::map<unsigned long long, edm4hep::SimCalorimeterHit> id_hit_map; + std::map<unsigned long long, std::vector<edm4hep::SimCalorimeterHit> > test_id_hits_map; std::map<unsigned long long, std::vector<edm4hep::ConstCaloHitContribution> > id_vconb_map; edm4hep::SimCalorimeterHitCollection* mergedCol = m_OutputCollections[k0]->createAndPut(); auto col = m_InputCollections[k0]->get(); @@ -67,6 +70,7 @@ StatusCode SimHitMergeAlg::execute() for (auto Simhit: *col){ auto id = Simhit.getCellID(); if(Simhit.getEnergy() <=0 ) continue; + //std::cout<<"DD_sim_hit::ProcessHits, sp x="<<Simhit.getPosition()[0]<<", y="<<Simhit.getPosition()[1]<<", z="<<Simhit.getPosition()[2]<<",edep="<<Simhit.getEnergy()<<std::endl; if ( id_hit_map.find(id) != id_hit_map.end()) id_hit_map[id].setEnergy(id_hit_map[id].getEnergy() + Simhit.getEnergy()); else id_hit_map[id] = Simhit; std::vector<edm4hep::ConstCaloHitContribution> tmp_vconb ; @@ -81,13 +85,43 @@ 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(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]; + float pos1_y = iter->second.at(i).getPosition()[1]; + float pos1_z = iter->second.at(i).getPosition()[2]; + for(unsigned int j=i+1; j< iter->second.size(); j++){ + float pos2_x = iter->second.at(j).getPosition()[0]; + 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; + } + } + } + } + + for(std::map<unsigned long long, edm4hep::SimCalorimeterHit>::iterator iter = id_hit_map.begin(); iter != id_hit_map.end(); iter++) { edm4hep::SimCalorimeterHit Simhit = iter->second ; dd4hep::Position position = m_cellIDConverter->position(Simhit.getCellID());//cm - edm4hep::Vector3f hitPos(position.x()*10, position.y()*10, position.z()*10);//to mm + 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 //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/Reconstruction/PFA/Pandora/GaudiPandora/include/GeometryCreator.h b/Reconstruction/PFA/Pandora/GaudiPandora/include/GeometryCreator.h index 442a356b05b90fe2dbf8999159e08aa6fac7872a..7a7620155704acc69cabb7f33ddc28b3c382fb77 100644 --- a/Reconstruction/PFA/Pandora/GaudiPandora/include/GeometryCreator.h +++ b/Reconstruction/PFA/Pandora/GaudiPandora/include/GeometryCreator.h @@ -97,6 +97,7 @@ private: * @param subDetectorNameMap the sub detector name map (for smaller sub detectors, identified uniquely only by name) */ void SetAdditionalSubDetectorParameters(SubDetectorNameMap &subDetectorNameMap) const; + void SetAdditionalSubDetectorParametersDD(SubDetectorNameMap &subDetectorNameMap) const; /** * @brief Set sub detector parameters to their gear default values diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/include/Utility.h b/Reconstruction/PFA/Pandora/GaudiPandora/include/Utility.h index ed30bf2f653d59b6cbff735caafc451943bc293d..aa70ea794f68a872745eb4caada0a8482b4fbefe 100644 --- a/Reconstruction/PFA/Pandora/GaudiPandora/include/Utility.h +++ b/Reconstruction/PFA/Pandora/GaudiPandora/include/Utility.h @@ -9,7 +9,7 @@ #include "DD4hep/DetectorSelector.h" namespace PanUtil{ std::string Convert (float number); - dd4hep::rec::LayeredCalorimeterData * getExtension(unsigned int includeFlag, unsigned int excludeFlag) ; + dd4hep::rec::LayeredCalorimeterData * getExtension(unsigned int includeFlag, unsigned int excludeFlag=0) ; void line_a_b(float x1, float y1, float x2, float y2, float& a, float& b); float getPhi(float x, float y); int partition(float x, float y); diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp index 7e0836c9330ad81423000b6c6beebd22ee2cb1cd..873ae8c3c7087bd513f6568857f63986d30e5f8c 100644 --- a/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp +++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp @@ -54,45 +54,155 @@ CaloHitCreator::CaloHitCreator(const Settings &settings, const pandora::Pandora if (!sc) throw "Failed to find GeomSvc."; } if(m_settings.m_use_dd4hep_geo){ - const dd4hep::rec::LayeredCalorimeterData * eCalBarrelExtension= PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::BARREL), - ( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) ); - m_eCalBarrelOuterZ = eCalBarrelExtension->extent[3]/dd4hep::mm; - m_eCalBarrelInnerPhi0 = eCalBarrelExtension->inner_phi0/dd4hep::rad; - m_eCalBarrelInnerSymmetry = eCalBarrelExtension->inner_symmetry; + const dd4hep::rec::LayeredCalorimeterData * eCalBarrelExtension= PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::BARREL), ( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) ); + if(eCalBarrelExtension){ + m_eCalBarrelOuterZ = eCalBarrelExtension->extent[3]/dd4hep::mm; + m_eCalBarrelInnerPhi0 = eCalBarrelExtension->inner_phi0/dd4hep::rad; + m_eCalBarrelInnerSymmetry = eCalBarrelExtension->inner_symmetry; + } + else{ + /* + std::cout<<"CaloHitCreator:WARNING, Can't get ECAL geo info from dd4hep, set it to dummy value. "<<std::endl; + m_eCalBarrelOuterZ = 2400; + m_eCalBarrelInnerPhi0 = 0; + m_eCalBarrelInnerSymmetry = 8; + */ + std::cout<<"CaloHitCreator:WARNING, Can't get ECAL geo info from dd4hep, get it from Gear. "<<std::endl; + m_eCalBarrelOuterZ = (_GEAR->getEcalBarrelParameters().getExtent()[3]); + m_eCalBarrelInnerPhi0 = (_GEAR->getEcalBarrelParameters().getPhi0()); + m_eCalBarrelInnerSymmetry = (_GEAR->getEcalBarrelParameters().getSymmetryOrder()); + } + //Get HCal Barrel extension by type, ignore plugs and rings + const dd4hep::rec::LayeredCalorimeterData * hCalBarrelExtension= PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::HADRONIC | dd4hep::DetType::BARREL),( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) ); + //Get HCal Endcap extension by type, ignore plugs and rings + const dd4hep::rec::LayeredCalorimeterData * hCalEndcapExtension= PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::HADRONIC | dd4hep::DetType::ENDCAP),( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) ); + if(hCalBarrelExtension){ + m_hCalBarrelOuterZ = hCalBarrelExtension->extent[3]/dd4hep::mm; + m_hCalBarrelInnerPhi0 = hCalBarrelExtension->inner_phi0/dd4hep::rad; + m_hCalBarrelInnerSymmetry = hCalBarrelExtension->inner_symmetry; + m_hCalBarrelOuterR = hCalBarrelExtension->extent[1]/dd4hep::mm; + m_hCalBarrelOuterPhi0 = hCalBarrelExtension->outer_phi0/dd4hep::rad; + m_hCalBarrelOuterSymmetry = hCalBarrelExtension->outer_symmetry; + const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer>& barrelLayers= hCalBarrelExtension->layers; + //Take thicknesses from last layer (was like that before with gear) + m_hCalBarrelLayerThickness =(barrelLayers.back().inner_thickness+barrelLayers.back().outer_thickness)/dd4hep::mm; + } + else{ + /* + std::cout<<"CaloHitCreator:WARNING, Can't get HCAL Barrel geo info from dd4hep, set it to dummy value. "<<std::endl; + m_hCalBarrelOuterZ = 0; + m_hCalBarrelInnerPhi0 = 0; + m_hCalBarrelInnerSymmetry = 0; + m_hCalBarrelOuterR = 0; + m_hCalBarrelOuterPhi0 = 0; + m_hCalBarrelOuterSymmetry = 0; + m_hCalBarrelLayerThickness = 1; + */ + std::cout<<"CaloHitCreator:WARNING, Can't get HCAL Barrel geo info from dd4hep, get it from Gear"<<std::endl; + m_hCalBarrelOuterZ = (_GEAR->getHcalBarrelParameters().getExtent()[3]); + m_hCalBarrelInnerPhi0 = (_GEAR->getHcalBarrelParameters().getPhi0()); + m_hCalBarrelInnerSymmetry = (_GEAR->getHcalBarrelParameters().getSymmetryOrder()); + m_hCalBarrelOuterR = (_GEAR->getHcalBarrelParameters().getExtent()[1]); + m_hCalBarrelOuterPhi0 = ((std::find(_GEAR->getHcalBarrelParameters().getIntKeys().begin(), + _GEAR->getHcalBarrelParameters().getIntKeys().end(), + "Hcal_outer_polygon_phi0") != _GEAR->getHcalBarrelParameters().getIntKeys().end() ? + _GEAR->getHcalBarrelParameters().getIntVal("Hcal_outer_polygon_phi0") + : 0)); + m_hCalBarrelOuterSymmetry = ((std::find(_GEAR->getHcalBarrelParameters().getIntKeys().begin(), + _GEAR->getHcalBarrelParameters().getIntKeys().end(), + "Hcal_outer_polygon_order") != _GEAR->getHcalBarrelParameters().getIntKeys().end() ? + _GEAR->getHcalBarrelParameters().getIntVal("Hcal_outer_polygon_order") + : 0)); + const gear::LayerLayout &hCalBarrelLayerLayout(_GEAR->getHcalBarrelParameters().getLayerLayout()); + m_hCalBarrelLayerThickness = hCalBarrelLayerLayout.getThickness(hCalBarrelLayerLayout.getNLayers() - 1); + } + if(hCalEndcapExtension){ + m_hCalEndCapOuterR = hCalEndcapExtension->extent[1]/dd4hep::mm; + m_hCalEndCapOuterZ = hCalEndcapExtension->extent[3]/dd4hep::mm; + const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer>& endcapLayers= hCalEndcapExtension->layers; + //Take thicknesses from last layer (was like that before with gear) + m_hCalEndCapLayerThickness =(endcapLayers.back().inner_thickness+endcapLayers.back().outer_thickness)/dd4hep::mm; + } + else{ + /* + std::cout<<"CaloHitCreator:WARNING, Can't get HCAL Endcap geo info from dd4hep, set it to dummy value. "<<std::endl; + m_hCalEndCapOuterR = 0; + m_hCalEndCapOuterZ = 0; + m_hCalEndCapLayerThickness = 1; + */ + std::cout<<"CaloHitCreator:WARNING, Can't get HCAL Endcap geo info from dd4hep, get it from Gear. "<<std::endl; + m_hCalEndCapOuterR = (_GEAR->getHcalEndcapParameters().getExtent()[1]); + m_hCalEndCapOuterZ = (_GEAR->getHcalEndcapParameters().getExtent()[3]); + const gear::LayerLayout &hCalEndCapLayerLayout(_GEAR->getHcalEndcapParameters().getLayerLayout()); + m_hCalEndCapLayerThickness = hCalEndCapLayerLayout.getThickness(hCalEndCapLayerLayout.getNLayers() - 1); + + } + //Get Muon Barrel extension by type, ignore plugs and rings + const dd4hep::rec::LayeredCalorimeterData * muonBarrelExtension= PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::MUON | dd4hep::DetType::BARREL),( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) ); + //fg: muon endcap is not used : + //Get Muon Endcap extension by type, ignore plugs and rings + // const dd4hep::rec::LayeredCalorimeterData * muonEndcapExtension= getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::MUON | dd4hep::DetType::ENDCAP), ( dd4hep::DetType::AUXILIARY ) ); + if(muonBarrelExtension){ + m_muonBarrelOuterZ = muonBarrelExtension->extent[3]/dd4hep::mm; + m_muonBarrelInnerPhi0 = muonBarrelExtension->inner_phi0/dd4hep::rad; + m_muonBarrelInnerSymmetry = muonBarrelExtension->inner_symmetry; + } + else{ + /* + std::cout<<"CaloHitCreator:WARNING, Can't get Muon Barrel geo info from dd4hep, set it to dummy value. "<<std::endl; + m_muonBarrelOuterZ = 0; + m_muonBarrelInnerPhi0 = 0; + m_muonBarrelInnerSymmetry = 0; + */ + std::cout<<"CaloHitCreator:WARNING, Can't get Muon Barrel geo info from dd4hep, get it from Gear. "<<std::endl; + m_muonBarrelInnerPhi0 = (_GEAR->getYokeBarrelParameters().getPhi0()); + m_muonBarrelOuterZ = (_GEAR->getYokeBarrelParameters().getExtent()[3]); + m_muonBarrelInnerSymmetry = (_GEAR->getYokeBarrelParameters().getSymmetryOrder()); + } + //Get COIL extension + const dd4hep::rec::LayeredCalorimeterData * coilExtension= PanUtil::getExtension( ( dd4hep::DetType::COIL ) ); + if(coilExtension){ + m_coilOuterR = coilExtension->extent[1]/dd4hep::mm; + } + else{ + /* + std::cout<<"CaloHitCreator:WARNING, Can't get Coil geo info from dd4hep, set it to dummy value. "<<std::endl; + m_coilOuterR = 0; + */ + std::cout<<"CaloHitCreator:WARNING, Can't get Coil geo info from dd4hep, get it from Gear. "<<std::endl; + m_coilOuterR = (_GEAR->getGearParameters("CoilParameters").getDoubleVal("Coil_cryostat_outer_radius")); + } } else{ m_eCalBarrelOuterZ = (_GEAR->getEcalBarrelParameters().getExtent()[3]); m_eCalBarrelInnerPhi0 = (_GEAR->getEcalBarrelParameters().getPhi0()); m_eCalBarrelInnerSymmetry = (_GEAR->getEcalBarrelParameters().getSymmetryOrder()); + m_hCalBarrelOuterZ = (_GEAR->getHcalBarrelParameters().getExtent()[3]); + m_hCalBarrelInnerPhi0 = (_GEAR->getHcalBarrelParameters().getPhi0()); + m_hCalBarrelInnerSymmetry = (_GEAR->getHcalBarrelParameters().getSymmetryOrder()); + m_hCalBarrelOuterR = (_GEAR->getHcalBarrelParameters().getExtent()[1]); + m_hCalBarrelOuterPhi0 = ((std::find(_GEAR->getHcalBarrelParameters().getIntKeys().begin(), + _GEAR->getHcalBarrelParameters().getIntKeys().end(), + "Hcal_outer_polygon_phi0") != _GEAR->getHcalBarrelParameters().getIntKeys().end() ? + _GEAR->getHcalBarrelParameters().getIntVal("Hcal_outer_polygon_phi0") + : 0)); + m_hCalBarrelOuterSymmetry = ((std::find(_GEAR->getHcalBarrelParameters().getIntKeys().begin(), + _GEAR->getHcalBarrelParameters().getIntKeys().end(), + "Hcal_outer_polygon_order") != _GEAR->getHcalBarrelParameters().getIntKeys().end() ? + _GEAR->getHcalBarrelParameters().getIntVal("Hcal_outer_polygon_order") + : 0)); + const gear::LayerLayout &hCalBarrelLayerLayout(_GEAR->getHcalBarrelParameters().getLayerLayout()); + m_hCalBarrelLayerThickness = hCalBarrelLayerLayout.getThickness(hCalBarrelLayerLayout.getNLayers() - 1); + m_hCalEndCapOuterR = (_GEAR->getHcalEndcapParameters().getExtent()[1]); + m_hCalEndCapOuterZ = (_GEAR->getHcalEndcapParameters().getExtent()[3]); + const gear::LayerLayout &hCalEndCapLayerLayout(_GEAR->getHcalEndcapParameters().getLayerLayout()); + m_hCalEndCapLayerThickness = hCalEndCapLayerLayout.getThickness(hCalEndCapLayerLayout.getNLayers() - 1); + m_coilOuterR = (_GEAR->getGearParameters("CoilParameters").getDoubleVal("Coil_cryostat_outer_radius")); + m_muonBarrelInnerPhi0 = (_GEAR->getYokeBarrelParameters().getPhi0()); + m_muonBarrelOuterZ = (_GEAR->getYokeBarrelParameters().getExtent()[3]); + m_muonBarrelInnerSymmetry = (_GEAR->getYokeBarrelParameters().getSymmetryOrder()); } - - m_hCalBarrelOuterZ = (_GEAR->getHcalBarrelParameters().getExtent()[3]); - m_muonBarrelOuterZ = (_GEAR->getYokeBarrelParameters().getExtent()[3]); - m_coilOuterR = (_GEAR->getGearParameters("CoilParameters").getDoubleVal("Coil_cryostat_outer_radius")); - m_hCalBarrelInnerPhi0 = (_GEAR->getHcalBarrelParameters().getPhi0()); - m_hCalBarrelInnerSymmetry = (_GEAR->getHcalBarrelParameters().getSymmetryOrder()); - m_muonBarrelInnerPhi0 = (_GEAR->getYokeBarrelParameters().getPhi0()); - m_muonBarrelInnerSymmetry = (_GEAR->getYokeBarrelParameters().getSymmetryOrder()); - m_hCalEndCapOuterR = (_GEAR->getHcalEndcapParameters().getExtent()[1]); - m_hCalEndCapOuterZ = (_GEAR->getHcalEndcapParameters().getExtent()[3]); - m_hCalBarrelOuterR = (_GEAR->getHcalBarrelParameters().getExtent()[1]); - m_hCalBarrelOuterPhi0 =((std::find(_GEAR->getHcalBarrelParameters().getIntKeys().begin(), - _GEAR->getHcalBarrelParameters().getIntKeys().end(), - "Hcal_outer_polygon_phi0") != _GEAR->getHcalBarrelParameters().getIntKeys().end() ? - _GEAR->getHcalBarrelParameters().getIntVal("Hcal_outer_polygon_phi0") - : 0)); - m_hCalBarrelOuterSymmetry = ((std::find(_GEAR->getHcalBarrelParameters().getIntKeys().begin(), - _GEAR->getHcalBarrelParameters().getIntKeys().end(), - "Hcal_outer_polygon_order") != _GEAR->getHcalBarrelParameters().getIntKeys().end() ? - _GEAR->getHcalBarrelParameters().getIntVal("Hcal_outer_polygon_order") - : 0)); - - - const gear::LayerLayout &hCalEndCapLayerLayout(_GEAR->getHcalEndcapParameters().getLayerLayout()); - const gear::LayerLayout &hCalBarrelLayerLayout(_GEAR->getHcalBarrelParameters().getLayerLayout()); - m_hCalEndCapLayerThickness = hCalEndCapLayerLayout.getThickness(hCalEndCapLayerLayout.getNLayers() - 1); - m_hCalBarrelLayerThickness = hCalBarrelLayerLayout.getThickness(hCalBarrelLayerLayout.getNLayers() - 1); if ((m_hCalEndCapLayerThickness < std::numeric_limits<float>::epsilon()) || (m_hCalBarrelLayerThickness < std::numeric_limits<float>::epsilon())) throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER); @@ -126,7 +236,7 @@ pandora::StatusCode CaloHitCreator::CreateECalCaloHits(const CollectionMaps& col for (unsigned int k = 0; k < m_settings.m_eCalCaloHitCollections.size(); k++) { std::string tmp_col_name = m_settings.m_eCalCaloHitCollections.at(k); - if(collectionMaps.collectionMap_CaloHit.find(tmp_col_name) == collectionMaps.collectionMap_CaloHit.end()) { std::cout<<"not find "<<tmp_col_name<<std::endl; continue;} + if(collectionMaps.collectionMap_CaloHit.find(tmp_col_name) == collectionMaps.collectionMap_CaloHit.end()) { if(m_settings.m_debug) std::cout<<"not find "<<tmp_col_name<<std::endl; continue;} try { if(m_settings.m_debug) std::cout<<"CaloHitCreator for "<<tmp_col_name<<std::endl; @@ -136,8 +246,6 @@ pandora::StatusCode CaloHitCreator::CreateECalCaloHits(const CollectionMaps& col if (0 == nElements) continue; - const gear::LayerLayout &endcapLayerLayout(_GEAR->getEcalEndcapParameters().getLayerLayout()); - const gear::LayerLayout &barrelLayerLayout(_GEAR->getEcalBarrelParameters().getLayerLayout()); ID_UTIL::CellIDDecoder<const edm4hep::CalorimeterHit> cellIdDecoder(m_encoder_str); const std::string layerCodingString(m_encoder_str); @@ -150,6 +258,18 @@ pandora::StatusCode CaloHitCreator::CreateECalCaloHits(const CollectionMaps& col m_decoder = m_geosvc->getDecoder(name_readout); if (!m_decoder) throw "Failed to get the decoder. "; } + const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer>* barrelLayers=nullptr; + const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer>* endcapLayers=nullptr; + const gear::LayerLayout* barrelLayerLayout=nullptr; + const gear::LayerLayout* endcapLayerLayout=nullptr; + if(m_settings.m_use_dd4hep_geo){ + barrelLayers= &(PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::BARREL), ( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) )->layers); + endcapLayers= &(PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::ENDCAP), ( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) )->layers); + } + else{ + barrelLayerLayout = &(_GEAR->getEcalBarrelParameters().getLayerLayout()); + endcapLayerLayout = &(_GEAR->getEcalEndcapParameters().getLayerLayout()); + } for (int i = 0; i < nElements; ++i) { @@ -214,27 +334,15 @@ pandora::StatusCode CaloHitCreator::CreateECalCaloHits(const CollectionMaps& col if (std::fabs(pCaloHit->getPosition()[2]) < m_eCalBarrelOuterZ) { - if(m_settings.m_use_dd4hep_geo){ - const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer>& barrelLayers= PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::BARREL), ( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) )->layers; - this->GetBarrelCaloHitProperties(pCaloHit, barrelLayers, m_eCalBarrelInnerSymmetry, m_eCalBarrelInnerPhi0, - Stave, caloHitParameters, absorberCorrection); - } - else{ - this->GetBarrelCaloHitProperties(pCaloHit, barrelLayerLayout, m_eCalBarrelInnerSymmetry, m_eCalBarrelInnerPhi0, - Stave, caloHitParameters, absorberCorrection); - } - + if(m_settings.m_use_dd4hep_geo) this->GetBarrelCaloHitProperties(pCaloHit, *barrelLayers, m_eCalBarrelInnerSymmetry, m_eCalBarrelInnerPhi0, Stave, caloHitParameters, absorberCorrection); + else this->GetBarrelCaloHitProperties(pCaloHit, *barrelLayerLayout, m_eCalBarrelInnerSymmetry, m_eCalBarrelInnerPhi0, Stave, caloHitParameters, absorberCorrection); caloHitParameters.m_hadronicEnergy = eCalToHadGeVBarrel * pCaloHit->getEnergy(); } else { - if(m_settings.m_use_dd4hep_geo){ - const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer>& endcapLayers= PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::ENDCAP), ( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) )->layers; - this->GetEndCapCaloHitProperties(pCaloHit, endcapLayers, caloHitParameters, absorberCorrection); - } - else{ - this->GetEndCapCaloHitProperties(pCaloHit, endcapLayerLayout, caloHitParameters, absorberCorrection); - } + if(m_settings.m_use_dd4hep_geo) this->GetEndCapCaloHitProperties(pCaloHit, *endcapLayers, caloHitParameters, absorberCorrection); + + else this->GetEndCapCaloHitProperties(pCaloHit, *endcapLayerLayout, caloHitParameters, absorberCorrection); caloHitParameters.m_hadronicEnergy = eCalToHadGeVEndCap * pCaloHit->getEnergy(); } @@ -280,25 +388,42 @@ pandora::StatusCode CaloHitCreator::CreateECalCaloHits(const CollectionMaps& col pandora::StatusCode CaloHitCreator::CreateHCalCaloHits(const CollectionMaps& collectionMaps) { - for (StringVector::const_iterator iter = m_settings.m_hCalCaloHitCollections.begin(), iterEnd = m_settings.m_hCalCaloHitCollections.end(); - iter != iterEnd; ++iter) + for (unsigned int k = 0; k < m_settings.m_hCalCaloHitCollections.size(); k++) { - if(collectionMaps.collectionMap_CaloHit.find(*iter) == collectionMaps.collectionMap_CaloHit.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;} + std::string tmp_col_name = m_settings.m_hCalCaloHitCollections.at(k); + if(collectionMaps.collectionMap_CaloHit.find(tmp_col_name) == collectionMaps.collectionMap_CaloHit.end()) { if(m_settings.m_debug) std::cout<<"not find "<<tmp_col_name<<std::endl; continue;} try { - const std::vector<edm4hep::CalorimeterHit>& pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second; + const std::vector<edm4hep::CalorimeterHit>& pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(tmp_col_name))->second; const int nElements(pCaloHitCollection.size()); if (0 == nElements) continue; - const gear::LayerLayout &endcapLayerLayout(_GEAR->getHcalEndcapParameters().getLayerLayout()); - const gear::LayerLayout &barrelLayerLayout(_GEAR->getHcalBarrelParameters().getLayerLayout()); ID_UTIL::CellIDDecoder<const edm4hep::CalorimeterHit> cellIdDecoder(m_encoder_str); const std::string layerCodingString(m_encoder_str); const std::string layerCoding(this->GetLayerCoding(layerCodingString)); const std::string staveCoding(this->GetStaveCoding(layerCodingString)); + // get the DD4hep readout + const std::string name_readout = m_settings.m_hCalCaloReadOuts.at(k); + if(m_settings.m_debug) std::cout<<"readout= "<<name_readout<<std::endl; + if( m_settings.m_use_dd4hep_decoder ){ + m_decoder = m_geosvc->getDecoder(name_readout); + if (!m_decoder) throw "Failed to get the decoder. "; + } + const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer>* barrelLayers=nullptr; + const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer>* endcapLayers=nullptr; + const gear::LayerLayout* barrelLayerLayout=nullptr; + const gear::LayerLayout* endcapLayerLayout=nullptr; + if(m_settings.m_use_dd4hep_geo){ + barrelLayers= &(PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::HADRONIC | dd4hep::DetType::BARREL),( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) )->layers); + endcapLayers= &(PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::HADRONIC | dd4hep::DetType::ENDCAP),( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) )->layers); + } + else{ + barrelLayerLayout = &(_GEAR->getHcalBarrelParameters().getLayerLayout()); + endcapLayerLayout = &(_GEAR->getHcalEndcapParameters().getLayerLayout()); + } for (int i = 0; i < nElements; ++i) { @@ -313,20 +438,29 @@ 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 = cellIdDecoder(pCaloHit)[layerCoding.c_str()]; + caloHitParameters.m_layer = m_settings.m_use_dd4hep_decoder == false ? cellIdDecoder(pCaloHit)[layerCoding.c_str()] : m_decoder->get(pCaloHit->getCellID(), "layer"); caloHitParameters.m_isInOuterSamplingLayer = (this->GetNLayersFromEdge(pCaloHit) <= m_settings.m_nOuterSamplingLayers); this->GetCommonCaloHitProperties(pCaloHit, caloHitParameters); + int Stave = 0 ; + if (m_settings.m_use_dd4hep_decoder == false){ + Stave = cellIdDecoder(pCaloHit)[ staveCoding]; + } + else{ + Stave = m_decoder->get(pCaloHit->getCellID(), "stave"); + Stave = Stave <=2 ? Stave+5 : Stave-3 ;//FIXME , need check!! + } float absorberCorrection(1.); if (std::fabs(pCaloHit->getPosition()[2]) < m_hCalBarrelOuterZ) { - this->GetBarrelCaloHitProperties(pCaloHit, barrelLayerLayout, m_hCalBarrelInnerSymmetry, m_hCalBarrelInnerPhi0, - m_hCalBarrelInnerSymmetry - int(cellIdDecoder(pCaloHit)[ staveCoding] / 2), caloHitParameters, absorberCorrection); + if(m_settings.m_use_dd4hep_geo) this->GetBarrelCaloHitProperties(pCaloHit, *barrelLayers, m_hCalBarrelInnerSymmetry, m_hCalBarrelInnerPhi0, m_hCalBarrelInnerSymmetry - int(Stave / 2), caloHitParameters, absorberCorrection); + else this->GetBarrelCaloHitProperties(pCaloHit, *barrelLayerLayout, m_hCalBarrelInnerSymmetry, m_hCalBarrelInnerPhi0, m_hCalBarrelInnerSymmetry - int(Stave / 2), caloHitParameters, absorberCorrection); } else { - this->GetEndCapCaloHitProperties(pCaloHit, endcapLayerLayout, caloHitParameters, absorberCorrection); + if(m_settings.m_use_dd4hep_geo) this->GetEndCapCaloHitProperties(pCaloHit, *endcapLayers, caloHitParameters, absorberCorrection); + else this->GetEndCapCaloHitProperties(pCaloHit, *endcapLayerLayout, caloHitParameters, absorberCorrection); } //caloHitParameters.m_mipEquivalentEnergy = pCaloHit->getEnergy() * m_settings.m_hCalToMip * absorberCorrection; @@ -353,7 +487,7 @@ pandora::StatusCode CaloHitCreator::CreateHCalCaloHits(const CollectionMaps& col } catch (...) { - std::cout << "Failed to extract hcal calo hit collection: " << *iter << std::endl; + std::cout << "Failed to extract hcal calo hit collection: " << tmp_col_name << std::endl; } } @@ -364,26 +498,44 @@ pandora::StatusCode CaloHitCreator::CreateHCalCaloHits(const CollectionMaps& col pandora::StatusCode CaloHitCreator::CreateMuonCaloHits(const CollectionMaps& collectionMaps) { - for (StringVector::const_iterator iter = m_settings.m_muonCaloHitCollections.begin(), iterEnd = m_settings.m_muonCaloHitCollections.end(); - iter != iterEnd; ++iter) + for (unsigned int k = 0; k < m_settings.m_muonCaloHitCollections.size(); k++) { - if(collectionMaps.collectionMap_CaloHit.find(*iter) == collectionMaps.collectionMap_CaloHit.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;} + std::string tmp_col_name = m_settings.m_muonCaloHitCollections.at(k); + if(collectionMaps.collectionMap_CaloHit.find(tmp_col_name) == collectionMaps.collectionMap_CaloHit.end()) {if(m_settings.m_debug) std::cout<<"not find "<<tmp_col_name<<std::endl; continue;} try { - const std::vector<edm4hep::CalorimeterHit>& pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second; + const std::vector<edm4hep::CalorimeterHit>& pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(tmp_col_name))->second; const int nElements(pCaloHitCollection.size()); if (0 == nElements) continue; - const gear::LayerLayout &endcapLayerLayout(_GEAR->getYokeEndcapParameters().getLayerLayout()); - const gear::LayerLayout &barrelLayerLayout(_GEAR->getYokeBarrelParameters().getLayerLayout()); - const gear::LayerLayout &plugLayerLayout(_GEAR->getYokePlugParameters().getLayerLayout()); ID_UTIL::CellIDDecoder<const edm4hep::CalorimeterHit> cellIdDecoder(m_encoder_str_MUON); const std::string layerCodingString(m_encoder_str_MUON); const std::string layerCoding(this->GetLayerCoding(layerCodingString)); const std::string staveCoding(this->GetStaveCoding(layerCodingString)); + // get the DD4hep readout + const std::string name_readout = m_settings.m_muonCalCaloReadOuts.at(k); + if(m_settings.m_debug) std::cout<<"readout= "<<name_readout<<std::endl; + if( m_settings.m_use_dd4hep_decoder ){ + m_decoder = m_geosvc->getDecoder(name_readout); + if (!m_decoder) throw "Failed to get the decoder. "; + } + const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer>* barrelLayers=nullptr; + const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer>* endcapLayers=nullptr; + const gear::LayerLayout* barrelLayerLayout=nullptr; + const gear::LayerLayout* plugLayerLayout=nullptr; + const gear::LayerLayout* endcapLayerLayout=nullptr; + if(m_settings.m_use_dd4hep_geo){ + barrelLayers= &(PanUtil::getExtension(( dd4hep::DetType::CALORIMETER | dd4hep::DetType::MUON| dd4hep::DetType::BARREL), ( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ))->layers); + endcapLayers = &(PanUtil::getExtension(( dd4hep::DetType::CALORIMETER | dd4hep::DetType::MUON| dd4hep::DetType::ENDCAP), ( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ))->layers); + } + else{ + plugLayerLayout= &(_GEAR->getYokePlugParameters().getLayerLayout()); + barrelLayerLayout = &(_GEAR->getYokeBarrelParameters().getLayerLayout()); + endcapLayerLayout = &(_GEAR->getYokeEndcapParameters().getLayerLayout()); + } for (int i = 0; i < nElements; ++i) { @@ -397,9 +549,17 @@ pandora::StatusCode CaloHitCreator::CreateMuonCaloHits(const CollectionMaps& col PandoraApi::CaloHit::Parameters caloHitParameters; caloHitParameters.m_hitType = pandora::MUON; - caloHitParameters.m_layer = cellIdDecoder(pCaloHit)[layerCoding.c_str()] + 1; + caloHitParameters.m_layer = m_settings.m_use_dd4hep_decoder == false ? cellIdDecoder(pCaloHit)[layerCoding.c_str()] + 1 : m_decoder->get(pCaloHit->getCellID(), "layer"); caloHitParameters.m_isInOuterSamplingLayer = true; this->GetCommonCaloHitProperties(pCaloHit, caloHitParameters); + int Stave = 0 ; + if (m_settings.m_use_dd4hep_decoder == false){ + Stave = cellIdDecoder(pCaloHit)[ staveCoding]; + } + else{ + Stave = m_decoder->get(pCaloHit->getCellID(), "stave"); + Stave = Stave <=2 ? Stave+5 : Stave-3 ;//FIXME , need check!! + } const float radius(std::sqrt(pCaloHit->getPosition()[0] * pCaloHit->getPosition()[0] + pCaloHit->getPosition()[1] * pCaloHit->getPosition()[1])); @@ -411,16 +571,17 @@ pandora::StatusCode CaloHitCreator::CreateMuonCaloHits(const CollectionMaps& col if (isInBarrelRegion && isWithinCoil) { - this->GetEndCapCaloHitProperties(pCaloHit, plugLayerLayout, caloHitParameters, absorberCorrection); + if(m_settings.m_use_dd4hep_geo) std::cout<<"BIG WARNING: CANNOT HANDLE PLUG HITS (no plug), DO NOTHING!"<<std::endl; + else this->GetEndCapCaloHitProperties(pCaloHit, *plugLayerLayout, caloHitParameters, absorberCorrection); } else if (isInBarrelRegion) - { - this->GetBarrelCaloHitProperties(pCaloHit, barrelLayerLayout, m_muonBarrelInnerSymmetry, m_muonBarrelInnerPhi0, - cellIdDecoder(pCaloHit)[ staveCoding ], caloHitParameters, absorberCorrection); + { if(m_settings.m_use_dd4hep_geo) this->GetBarrelCaloHitProperties(pCaloHit, *barrelLayers , m_muonBarrelInnerSymmetry, m_muonBarrelInnerPhi0, Stave, caloHitParameters, absorberCorrection); + else this->GetBarrelCaloHitProperties(pCaloHit, *barrelLayerLayout, m_muonBarrelInnerSymmetry, m_muonBarrelInnerPhi0, Stave, caloHitParameters, absorberCorrection); } else { - this->GetEndCapCaloHitProperties(pCaloHit, endcapLayerLayout, caloHitParameters, absorberCorrection); + if(m_settings.m_use_dd4hep_geo) this->GetEndCapCaloHitProperties(pCaloHit, *endcapLayers , caloHitParameters, absorberCorrection); + else this->GetEndCapCaloHitProperties(pCaloHit, *endcapLayerLayout, caloHitParameters, absorberCorrection); } if (m_settings.m_muonDigitalHits > 0) @@ -455,7 +616,7 @@ pandora::StatusCode CaloHitCreator::CreateMuonCaloHits(const CollectionMaps& col } catch (...) { - std::cout << "Failed to extract muon hit collection: " << *iter << std::endl; + std::cout << "Failed to extract muon hit collection: " << tmp_col_name << std::endl; } } @@ -469,7 +630,7 @@ pandora::StatusCode CaloHitCreator::CreateLCalCaloHits(const CollectionMaps& col for (StringVector::const_iterator iter = m_settings.m_lCalCaloHitCollections.begin(), iterEnd = m_settings.m_lCalCaloHitCollections.end(); iter != iterEnd; ++iter) { - if(collectionMaps.collectionMap_CaloHit.find(*iter) == collectionMaps.collectionMap_CaloHit.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;} + if(collectionMaps.collectionMap_CaloHit.find(*iter) == collectionMaps.collectionMap_CaloHit.end()) {if(m_settings.m_debug)std::cout<<"not find "<<(*iter)<<std::endl; continue;} try { const std::vector<edm4hep::CalorimeterHit>& pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second; @@ -542,7 +703,7 @@ pandora::StatusCode CaloHitCreator::CreateLHCalCaloHits(const CollectionMaps& co for (StringVector::const_iterator iter = m_settings.m_lHCalCaloHitCollections.begin(), iterEnd = m_settings.m_lHCalCaloHitCollections.end(); iter != iterEnd; ++iter) { - if(collectionMaps.collectionMap_CaloHit.find(*iter) == collectionMaps.collectionMap_CaloHit.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;} + if(collectionMaps.collectionMap_CaloHit.find(*iter) == collectionMaps.collectionMap_CaloHit.end()) {if(m_settings.m_debug) std::cout<<"not find "<<(*iter)<<std::endl; continue;} try { const std::vector<edm4hep::CalorimeterHit>& pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second; @@ -793,7 +954,7 @@ void CaloHitCreator::GetBarrelCaloHitProperties(const edm4hep::CalorimeterHit *c const int physicalLayer(std::min(static_cast<int>(caloHitParameters.m_layer.Get()), static_cast<int>(layers.size()-1))); caloHitParameters.m_cellSize0 = layers[physicalLayer].cellSize0/dd4hep::mm; caloHitParameters.m_cellSize1 = layers[physicalLayer].cellSize1/dd4hep::mm; - //std::cout<<"DD m_cellSize0="<<caloHitParameters.m_cellSize0.Get()<<",m_cellSize1="<<caloHitParameters.m_cellSize1.Get()<<std::endl; + if(m_settings.m_debug) std::cout<<"DD m_cellSize0="<<caloHitParameters.m_cellSize0.Get()<<",m_cellSize1="<<caloHitParameters.m_cellSize1.Get()<<std::endl; double thickness = (layers[physicalLayer].inner_thickness+layers[physicalLayer].sensitive_thickness/2.0)/dd4hep::mm; double nRadLengths = layers[physicalLayer].inner_nRadiationLengths; double nIntLengths = layers[physicalLayer].inner_nInteractionLengths; diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/GeometryCreator.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/GeometryCreator.cpp index 7a9a74cfe3ce2de993ba4c6a68a48bf00ab2ba00..a69feb3682b4671978392f57196c98410d562360 100644 --- a/Reconstruction/PFA/Pandora/GaudiPandora/src/GeometryCreator.cpp +++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/GeometryCreator.cpp @@ -16,6 +16,7 @@ #include "GeometryCreator.h" #include "Utility.h" + GeometryCreator::GeometryCreator(const Settings &settings, const pandora::Pandora *const pPandora) : m_settings(settings), m_pPandora(pPandora) @@ -47,7 +48,8 @@ pandora::StatusCode GeometryCreator::CreateGeometry(ISvcLocator* svcloc) this->SetMandatorySubDetectorParameters(subDetectorTypeMap); SubDetectorNameMap subDetectorNameMap; - this->SetAdditionalSubDetectorParameters(subDetectorNameMap); + if(m_settings.m_use_dd4hep_geo) this->SetAdditionalSubDetectorParametersDD(subDetectorNameMap); + else this->SetAdditionalSubDetectorParameters (subDetectorNameMap); if (std::string::npos != _GEAR->getDetectorName().find("ILD")) this->SetILDSpecificGeometry(subDetectorTypeMap, subDetectorNameMap); @@ -71,23 +73,62 @@ pandora::StatusCode GeometryCreator::CreateGeometry(ISvcLocator* svcloc) void GeometryCreator::SetMandatorySubDetectorParameters(SubDetectorTypeMap &subDetectorTypeMap) const { - std::cout << "Begin SetMandatorySubDetectorParameters:" << std::endl; - PandoraApi::Geometry::SubDetector::Parameters eCalBarrelParameters, eCalEndCapParameters, hCalBarrelParameters, hCalEndCapParameters, - muonBarrelParameters, muonEndCapParameters; + std::cout << "GeometryCreator SetMandatorySubDetectorParameters:" << std::endl; + PandoraApi::Geometry::SubDetector::Parameters eCalBarrelParameters, eCalEndCapParameters, hCalBarrelParameters, hCalEndCapParameters, muonBarrelParameters, muonEndCapParameters; + if(m_settings.m_use_dd4hep_geo){ - std::cout << "Use dd4hep geo info for ECAL" << std::endl; - this->SetDefaultSubDetectorParameters(*const_cast<dd4hep::rec::LayeredCalorimeterData*>(PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::BARREL), ( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) )), "ECalBarrel", pandora::ECAL_BARREL, eCalBarrelParameters); - this->SetDefaultSubDetectorParameters(*const_cast<dd4hep::rec::LayeredCalorimeterData*>(PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::ENDCAP), ( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) )), "ECalEndCap", pandora::ECAL_ENDCAP, eCalEndCapParameters); + std::cout << "Use dd4hep geo info for ECAL, HCAL and Muon" << std::endl; + dd4hep::rec::LayeredCalorimeterData* layer_ecal_barrel = const_cast<dd4hep::rec::LayeredCalorimeterData*>(PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::BARREL), ( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) ) ); + if(layer_ecal_barrel) this->SetDefaultSubDetectorParameters(*layer_ecal_barrel, "ECalBarrel", pandora::ECAL_BARREL, eCalBarrelParameters); + else{ + std::cout << "GeometryCreator:Do not find ECAL Barrel geo info from dd4hep, Try to get it from Gear" << std::endl; + this->SetDefaultSubDetectorParameters(_GEAR->getEcalBarrelParameters(), "ECalBarrel", pandora::ECAL_BARREL, eCalBarrelParameters); + } + + dd4hep::rec::LayeredCalorimeterData* layer_ecal_endcap = const_cast<dd4hep::rec::LayeredCalorimeterData*>(PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::ENDCAP), ( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) ) ); + if(layer_ecal_endcap) this->SetDefaultSubDetectorParameters(*layer_ecal_endcap, "ECalEndCap", pandora::ECAL_ENDCAP, eCalEndCapParameters); + else{ + std::cout << "GeometryCreator:Do not find ECAL Endcap geo info from dd4hep, Try to get it from Gear" << std::endl; + this->SetDefaultSubDetectorParameters(_GEAR->getEcalEndcapParameters(), "ECalEndCap", pandora::ECAL_ENDCAP, eCalEndCapParameters); + } + + dd4hep::rec::LayeredCalorimeterData* layer_hcal_barrel = const_cast<dd4hep::rec::LayeredCalorimeterData*>(PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::HADRONIC | dd4hep::DetType::BARREL),( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) ) ); + if(layer_hcal_barrel) this->SetDefaultSubDetectorParameters(*layer_hcal_barrel, "HCalBarrel", pandora::HCAL_BARREL, hCalBarrelParameters); + else{ + std::cout << "GeometryCreator:Do not find HCAL Barrel geo info from dd4hep, Try to get it from Gear" << std::endl; + this->SetDefaultSubDetectorParameters(_GEAR->getHcalBarrelParameters(), "HCalBarrel", pandora::HCAL_BARREL, hCalBarrelParameters); + } + + dd4hep::rec::LayeredCalorimeterData* layer_hcal_endcap = const_cast<dd4hep::rec::LayeredCalorimeterData*>(PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::HADRONIC | dd4hep::DetType::ENDCAP),( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) ) ); + if(layer_hcal_endcap) this->SetDefaultSubDetectorParameters(*layer_hcal_endcap, "HCalEndCap", pandora::HCAL_ENDCAP, hCalEndCapParameters); + else{ + std::cout << "GeometryCreator:Do not find HCAL Endcap geo info from dd4hep, Try to get it from Gear" << std::endl; + this->SetDefaultSubDetectorParameters(_GEAR->getHcalEndcapParameters(), "HCalEndCap", pandora::HCAL_ENDCAP, hCalEndCapParameters); + } + + dd4hep::rec::LayeredCalorimeterData * layer_muon_barrel = const_cast<dd4hep::rec::LayeredCalorimeterData*>(PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::MUON | dd4hep::DetType::BARREL),( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) ) ); + if(layer_muon_barrel) this->SetDefaultSubDetectorParameters(*layer_muon_barrel, "MuonBarrel", pandora::MUON_BARREL, muonBarrelParameters); + else{ + std::cout << "GeometryCreator:Do not find Muon Barrel geo info from dd4hep, Try to get it from Gear" << std::endl; + this->SetDefaultSubDetectorParameters(_GEAR->getYokeBarrelParameters(), "MuonBarrel", pandora::MUON_BARREL, muonBarrelParameters); + } + + dd4hep::rec::LayeredCalorimeterData* layer_muon_endcap = const_cast<dd4hep::rec::LayeredCalorimeterData*>(PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::MUON | dd4hep::DetType::ENDCAP), ( dd4hep::DetType::AUXILIARY ) ) ); + if(layer_muon_endcap) this->SetDefaultSubDetectorParameters(*layer_muon_endcap, "MuonEndCap", pandora::MUON_ENDCAP, muonEndCapParameters); + else{ + std::cout << "GeometryCreator:Do not find Muon Endcap geo info from dd4hep, Try to get it from Gear" << std::endl; + this->SetDefaultSubDetectorParameters(_GEAR->getYokeEndcapParameters(), "MuonEndCap", pandora::MUON_ENDCAP, muonEndCapParameters); + } } else{ this->SetDefaultSubDetectorParameters(_GEAR->getEcalBarrelParameters(), "ECalBarrel", pandora::ECAL_BARREL, eCalBarrelParameters); this->SetDefaultSubDetectorParameters(_GEAR->getEcalEndcapParameters(), "ECalEndCap", pandora::ECAL_ENDCAP, eCalEndCapParameters); + this->SetDefaultSubDetectorParameters(_GEAR->getHcalBarrelParameters(), "HCalBarrel", pandora::HCAL_BARREL, hCalBarrelParameters); + this->SetDefaultSubDetectorParameters(_GEAR->getHcalEndcapParameters(), "HCalEndCap", pandora::HCAL_ENDCAP, hCalEndCapParameters); + this->SetDefaultSubDetectorParameters(_GEAR->getYokeBarrelParameters(), "MuonBarrel", pandora::MUON_BARREL, muonBarrelParameters); + this->SetDefaultSubDetectorParameters(_GEAR->getYokeEndcapParameters(), "MuonEndCap", pandora::MUON_ENDCAP, muonEndCapParameters); } - this->SetDefaultSubDetectorParameters(_GEAR->getHcalBarrelParameters(), "HCalBarrel", pandora::HCAL_BARREL, hCalBarrelParameters); - this->SetDefaultSubDetectorParameters(_GEAR->getHcalEndcapParameters(), "HCalEndCap", pandora::HCAL_ENDCAP, hCalEndCapParameters); - this->SetDefaultSubDetectorParameters(_GEAR->getYokeBarrelParameters(), "MuonBarrel", pandora::MUON_BARREL, muonBarrelParameters); - this->SetDefaultSubDetectorParameters(_GEAR->getYokeEndcapParameters(), "MuonEndCap", pandora::MUON_ENDCAP, muonEndCapParameters); subDetectorTypeMap[pandora::ECAL_BARREL] = eCalBarrelParameters; subDetectorTypeMap[pandora::ECAL_ENDCAP] = eCalEndCapParameters; @@ -141,10 +182,67 @@ void GeometryCreator::SetMandatorySubDetectorParameters(SubDetectorTypeMap &subD } //------------------------------------------------------------------------------------------------------------------------------------------ +void GeometryCreator::SetAdditionalSubDetectorParametersDD(SubDetectorNameMap &subDetectorNameMap) const +{ + + dd4hep::Detector & mainDetector = dd4hep::Detector::getInstance(); + const std::vector< dd4hep::DetElement>& theECalOtherDetectors = dd4hep::DetectorSelector(mainDetector).detectors(dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::AUXILIARY ) ; + for (std::vector< dd4hep::DetElement>::const_iterator iter = theECalOtherDetectors.begin(), iterEnd = theECalOtherDetectors.end();iter != iterEnd; ++iter){ + try + { + const dd4hep::DetElement& theDetector = *iter; + const dd4hep::rec::LayeredCalorimeterData * theExtension = theDetector.extension<dd4hep::rec::LayeredCalorimeterData>(); + + PandoraApi::Geometry::SubDetector::Parameters parameters; + this->SetDefaultSubDetectorParameters(*const_cast<dd4hep::rec::LayeredCalorimeterData*>(theExtension),theDetector.name(), pandora::SUB_DETECTOR_OTHER, parameters); + subDetectorNameMap[parameters.m_subDetectorName.Get()] = parameters; + } + catch (std::runtime_error &exception) + { + std::cout << "pandora geometry creator during Other ECal construction: " << exception.what() << std::endl; + } + } + + const std::vector< dd4hep::DetElement>& theHCalOtherDetectors = dd4hep::DetectorSelector(mainDetector).detectors(dd4hep::DetType::CALORIMETER | dd4hep::DetType::HADRONIC | dd4hep::DetType::AUXILIARY ) ; + for (std::vector< dd4hep::DetElement>::const_iterator iter = theHCalOtherDetectors.begin(), iterEnd = theHCalOtherDetectors.end();iter != iterEnd; ++iter){ + try + { + const dd4hep::DetElement& theDetector = *iter; + const dd4hep::rec::LayeredCalorimeterData * theExtension = theDetector.extension<dd4hep::rec::LayeredCalorimeterData>(); + + PandoraApi::Geometry::SubDetector::Parameters parameters; + this->SetDefaultSubDetectorParameters(*const_cast<dd4hep::rec::LayeredCalorimeterData*>(theExtension),theDetector.name(), pandora::SUB_DETECTOR_OTHER, parameters); + subDetectorNameMap[parameters.m_subDetectorName.Get()] = parameters; + } + catch (std::runtime_error &exception) + { + std::cout << "pandora geometry creator during Other HCal construction: " << exception.what() << std::endl; + } + } + + const std::vector< dd4hep::DetElement>& theMuonOtherDetectors = dd4hep::DetectorSelector(mainDetector).detectors(dd4hep::DetType::CALORIMETER | dd4hep::DetType::MUON| dd4hep::DetType::AUXILIARY ) ; + for (std::vector< dd4hep::DetElement>::const_iterator iter = theMuonOtherDetectors.begin(), iterEnd = theMuonOtherDetectors.end();iter != iterEnd; ++iter){ + try + { + const dd4hep::DetElement& theDetector = *iter; + const dd4hep::rec::LayeredCalorimeterData * theExtension = theDetector.extension<dd4hep::rec::LayeredCalorimeterData>(); + + PandoraApi::Geometry::SubDetector::Parameters parameters; + this->SetDefaultSubDetectorParameters(*const_cast<dd4hep::rec::LayeredCalorimeterData*>(theExtension),theDetector.name(), pandora::SUB_DETECTOR_OTHER, parameters); + subDetectorNameMap[parameters.m_subDetectorName.Get()] = parameters; + } + catch (std::runtime_error &exception) + { + std::cout << "pandora geometry creator during Other Muon construction: " << exception.what() << std::endl; + } + } + +} + void GeometryCreator::SetAdditionalSubDetectorParameters(SubDetectorNameMap &subDetectorNameMap) const { - std::cout << "Begin SetAdditionalSubDetectorParameters:" << std::endl; + std::cout << "SetAdditionalSubDetectorParameters:" << std::endl; try { PandoraApi::Geometry::SubDetector::Parameters parameters; @@ -164,7 +262,7 @@ void GeometryCreator::SetAdditionalSubDetectorParameters(SubDetectorNameMap &sub } catch (gear::Exception &exception) { - std::cout<< "warning pandora geometry creator: " << exception.what() << std::endl; + std::cout << "warning pandora geometry creator: " << exception.what() << std::endl; } try @@ -192,7 +290,29 @@ void GeometryCreator::SetAdditionalSubDetectorParameters(SubDetectorNameMap &sub } //------------------------------------------------------------------------------------------------------------------------------------------ +/* +void GeometryCreator::SetDummySubDetectorParameters(const std::map<std::string, float>& para_map, const std::string &subDetectorName, + const pandora::SubDetectorType subDetectorType, PandoraApi::Geometry::SubDetector::Parameters ¶meters) const +{ + parameters.m_subDetectorName = subDetectorName; + parameters.m_subDetectorType = subDetectorType; + parameters.m_innerRCoordinate = para_map["innerRCoordinate"]; + parameters.m_innerZCoordinate = para_map["innerZCoordinate"]; + parameters.m_innerPhiCoordinate = para_map["innerPhiCoordinate"]; + parameters.m_innerSymmetryOrder = para_map["innerSymmetryOrder"]; + parameters.m_outerRCoordinate = para_map["outerRCoordinate"]; + parameters.m_outerZCoordinate = para_map["outerZCoordinate"]; + parameters.m_outerPhiCoordinate = para_map["outerPhiCoordinate"]; + parameters.m_outerSymmetryOrder = para_map["outerSymmetryOrder"]; + parameters.m_isMirroredInZ = true; + PandoraApi::Geometry::LayerParameters layerParameters; + layerParameters.m_closestDistanceToIp = para_map["closestDistanceToIp"]; + layerParameters.m_nRadiationLengths = 1; + layerParameters.m_nInteractionLengths = 1; + parameters.m_layerParametersVector.push_back(layerParameters); +} +*/ void GeometryCreator::SetDefaultSubDetectorParameters(const gear::CalorimeterParameters &inputParameters, const std::string &subDetectorName, const pandora::SubDetectorType subDetectorType, PandoraApi::Geometry::SubDetector::Parameters ¶meters) const { @@ -211,6 +331,7 @@ void GeometryCreator::SetDefaultSubDetectorParameters(const gear::CalorimeterPar parameters.m_isMirroredInZ = true; parameters.m_nLayers = layerLayout.getNLayers(); + std::cout <<"Gear m_subDetectorName="<<subDetectorName<<",m_subDetectorType="<<subDetectorType<<",m_innerRCoordinate="<<parameters.m_innerRCoordinate.Get()<<",m_innerZCoordinate="<<parameters.m_innerZCoordinate.Get()<<",m_innerPhiCoordinate="<<parameters.m_innerPhiCoordinate.Get()<<",m_innerSymmetryOrder="<<parameters.m_innerSymmetryOrder.Get()<<",m_outerRCoordinate="<<parameters.m_outerRCoordinate.Get()<<",m_outerZCoordinate="<<parameters.m_outerZCoordinate.Get()<<",m_outerPhiCoordinate="<<parameters.m_outerPhiCoordinate.Get()<<",m_outerSymmetryOrder="<<parameters.m_outerSymmetryOrder.Get()<<",m_nLayers="<<parameters.m_nLayers.Get()<<std::endl; // ATTN Not always going to be correct for any optional subdetectors, but impact of this is negligible for ILD const float radiationLength(((pandora::ECAL_BARREL == subDetectorType) || (pandora::ECAL_ENDCAP == subDetectorType)) ? m_settings.m_absorberRadLengthECal : ((pandora::HCAL_BARREL == subDetectorType) || (pandora::HCAL_ENDCAP == subDetectorType)) ? m_settings.m_absorberRadLengthHCal : m_settings.m_absorberRadLengthOther); @@ -224,6 +345,7 @@ void GeometryCreator::SetDefaultSubDetectorParameters(const gear::CalorimeterPar layerParameters.m_nRadiationLengths = radiationLength * layerLayout.getAbsorberThickness(i); layerParameters.m_nInteractionLengths = interactionLength * layerLayout.getAbsorberThickness(i); parameters.m_layerParametersVector.push_back(layerParameters); + std::cout <<"layer="<<i<<",m_closestDistanceToIp="<<layerParameters.m_closestDistanceToIp.Get()<<",m_nRadiationLengths="<<layerParameters.m_nRadiationLengths.Get()<<",m_nInteractionLengths="<<layerParameters.m_nInteractionLengths.Get()<<std::endl; } } @@ -244,7 +366,7 @@ void GeometryCreator::SetDefaultSubDetectorParameters(const dd4hep::rec::Layered parameters.m_isMirroredInZ = true; parameters.m_nLayers = layers.size(); - std::cout<<"DD m_subDetectorName="<<subDetectorName<<",m_subDetectorType="<<subDetectorType<<",m_innerRCoordinate="<<parameters.m_innerRCoordinate.Get()<<",m_innerZCoordinate="<<parameters.m_innerZCoordinate.Get()<<",m_innerPhiCoordinate="<<parameters.m_innerPhiCoordinate.Get()<<",m_innerSymmetryOrder="<<parameters.m_innerSymmetryOrder.Get()<<",m_outerRCoordinate="<<parameters.m_outerRCoordinate.Get()<<",m_outerZCoordinate="<<parameters.m_outerZCoordinate.Get()<<",m_outerPhiCoordinate="<<parameters.m_outerPhiCoordinate.Get()<<",m_outerSymmetryOrder="<<parameters.m_outerSymmetryOrder.Get()<<",m_nLayers="<<parameters.m_nLayers.Get()<<std::endl; + std::cout <<"DD m_subDetectorName="<<subDetectorName<<",m_subDetectorType="<<subDetectorType<<",m_innerRCoordinate="<<parameters.m_innerRCoordinate.Get()<<",m_innerZCoordinate="<<parameters.m_innerZCoordinate.Get()<<",m_innerPhiCoordinate="<<parameters.m_innerPhiCoordinate.Get()<<",m_innerSymmetryOrder="<<parameters.m_innerSymmetryOrder.Get()<<",m_outerRCoordinate="<<parameters.m_outerRCoordinate.Get()<<",m_outerZCoordinate="<<parameters.m_outerZCoordinate.Get()<<",m_outerPhiCoordinate="<<parameters.m_outerPhiCoordinate.Get()<<",m_outerSymmetryOrder="<<parameters.m_outerSymmetryOrder.Get()<<",m_nLayers="<<parameters.m_nLayers.Get()<<std::endl; for (size_t i = 0; i< layers.size(); i++) { const dd4hep::rec::LayeredCalorimeterStruct::Layer & theLayer = layers.at(i); @@ -260,13 +382,13 @@ void GeometryCreator::SetDefaultSubDetectorParameters(const dd4hep::rec::Layered totalNumberOfIntLengths += layers.at(i-1).outer_nInteractionLengths; } - + std::cout <<"layer="<<i<<",theLayer.distance="<<theLayer.distance<<std::endl; layerParameters.m_closestDistanceToIp = (theLayer.distance+theLayer.inner_thickness)/dd4hep::mm; //Distance to center of sensitive element layerParameters.m_nRadiationLengths = totalNumberOfRadLengths; layerParameters.m_nInteractionLengths = totalNumberOfIntLengths; parameters.m_layerParametersVector.push_back(layerParameters); - std::cout<<"layer="<<i<<",m_closestDistanceToIp="<<layerParameters.m_closestDistanceToIp.Get()<<",m_nRadiationLengths="<<layerParameters.m_nRadiationLengths.Get()<<",m_nInteractionLengths="<<layerParameters.m_nInteractionLengths.Get()<<",outer_thickness="<<theLayer.outer_thickness<<",inner_thickness="<<theLayer.inner_thickness<<",sensitive_thickness="<<theLayer.sensitive_thickness<<std::endl; + std::cout <<"layer="<<i<<",m_closestDistanceToIp="<<layerParameters.m_closestDistanceToIp.Get()<<",m_nRadiationLengths="<<layerParameters.m_nRadiationLengths.Get()<<",m_nInteractionLengths="<<layerParameters.m_nInteractionLengths.Get()<<",outer_thickness="<<theLayer.outer_thickness<<",inner_thickness="<<theLayer.inner_thickness<<",sensitive_thickness="<<theLayer.sensitive_thickness<<std::endl; } } //------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/PandoraPFAlg.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/PandoraPFAlg.cpp index 9d94a93931dd76458ac5da6cdc49a4762ad2ba59..df2d3f5d83d0d0fd4bed32380e141ee7a0eb1ff8 100644 --- a/Reconstruction/PFA/Pandora/GaudiPandora/src/PandoraPFAlg.cpp +++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/PandoraPFAlg.cpp @@ -220,10 +220,10 @@ StatusCode PandoraPFAlg::initialize() // Name of PFO collection written by GaudiPandora m_pfoCreatorSettings.m_debug = m_debug; - m_pfoCreatorSettings.m_clusterCollectionName = m_ClusterCollectionName;// not used - m_pfoCreatorSettings.m_pfoCollectionName = m_PFOCollectionName;// - m_pfoCreatorSettings.m_startVertexCollectionName = m_StartVertexCollectionName; // - m_pfoCreatorSettings.m_startVertexAlgName = m_StartVertexAlgorithmName;// + m_pfoCreatorSettings.m_clusterCollectionName = m_ClusterCollectionName; + m_pfoCreatorSettings.m_pfoCollectionName = m_PFOCollectionName; + m_pfoCreatorSettings.m_startVertexCollectionName = m_StartVertexCollectionName; + m_pfoCreatorSettings.m_startVertexAlgName = m_StartVertexAlgorithmName; m_pfoCreatorSettings.m_emStochasticTerm = m_EMStochasticTerm; m_pfoCreatorSettings.m_hadStochasticTerm = m_HadStochasticTerm; @@ -283,6 +283,7 @@ StatusCode PandoraPFAlg::initialize() // Additional geometry parameters + m_geometryCreatorSettings.m_use_dd4hep_geo = m_use_dd4hep_geo; m_geometryCreatorSettings.m_eCalEndCapInnerSymmetryOrder = m_ECalEndCapInnerSymmetryOrder; m_geometryCreatorSettings.m_eCalEndCapInnerPhiCoordinate = m_ECalEndCapInnerPhiCoordinate; m_geometryCreatorSettings.m_eCalEndCapOuterSymmetryOrder = m_ECalEndCapOuterSymmetryOrder; @@ -295,8 +296,15 @@ StatusCode PandoraPFAlg::initialize() m_geometryCreatorSettings.m_hCalRingInnerPhiCoordinate = m_HCalRingInnerPhiCoordinate; m_geometryCreatorSettings.m_hCalRingOuterSymmetryOrder = m_HCalRingOuterSymmetryOrder; m_geometryCreatorSettings.m_hCalRingOuterPhiCoordinate = m_HCalRingOuterPhiCoordinate; - m_geometryCreatorSettings.m_use_dd4hep_geo = m_use_dd4hep_geo; - + if(m_use_dd4hep_geo){ + std::cout<<"get hCalEndCapInner geo info from dd4hep."<<std::endl; + //Get HCal Endcap extension by type, ignore plugs and rings + const dd4hep::rec::LayeredCalorimeterData * hCalEndcapExtension= PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::HADRONIC | dd4hep::DetType::ENDCAP),( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) ); + if(hCalEndcapExtension){ + m_geometryCreatorSettings.m_hCalEndCapInnerSymmetryOrder = hCalEndcapExtension->inner_symmetry; + m_geometryCreatorSettings.m_hCalEndCapInnerPhiCoordinate = hCalEndcapExtension->inner_phi0/dd4hep::rad; + } + } // For Strip Splitting method and also for hybrid ECAL m_caloHitCreatorSettings.m_stripSplittingOn = m_StripSplittingOn; m_caloHitCreatorSettings.m_useEcalScLayers = m_UseEcalScLayers; @@ -474,11 +482,10 @@ 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)); - std::cout<<"saved col name="<<v.first<<std::endl; - } - else{ - std::cout<<"don't find col name="<<v.first<<std::endl; + if(m_debug) std::cout<<"saved col name="<<v.first<<std::endl; } + else if(m_debug) std::cout<<"don't find col name="<<v.first<<std::endl; + } else if(m_collections[v.first]=="CalorimeterHit"){ auto handle = dynamic_cast<DataHandle<edm4hep::CalorimeterHitCollection>*> (v.second); @@ -487,11 +494,10 @@ 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)); - std::cout<<"saved col name="<<v.first<<std::endl; - } - else{ - std::cout<<"don't find col name="<<v.first<<std::endl; + if(m_debug) std::cout<<"saved col name="<<v.first<<std::endl; } + else if(m_debug) std::cout<<"don't find col name="<<v.first<<std::endl; + } else if(m_collections[v.first]=="Track"){ auto handle = dynamic_cast<DataHandle<edm4hep::TrackCollection>*> (v.second); @@ -500,12 +506,11 @@ 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)); - std::cout<<"saved col name="<<v.first<<std::endl; + if(m_debug) std::cout<<"saved col name="<<v.first<<std::endl; m_marlinTrack = po->size(); } - else{ - std::cout<<"don't find col name="<<v.first<<std::endl; - } + else if(m_debug) std::cout<<"don't find col name="<<v.first<<std::endl; + } else if(m_collections[v.first]=="Vertex"){ auto handle = dynamic_cast<DataHandle<edm4hep::VertexCollection>*> (v.second); @@ -514,11 +519,10 @@ 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)); - std::cout<<"saved col name="<<v.first<<std::endl; - } - else{ - std::cout<<"don't find col name="<<v.first<<std::endl; + if(m_debug) std::cout<<"saved col name="<<v.first<<std::endl; } + else if(m_debug) std::cout<<"don't find col name="<<v.first<<std::endl; + } else if(m_collections[v.first]=="MCRecoCaloAssociation"){ auto handle = dynamic_cast<DataHandle<edm4hep::MCRecoCaloAssociationCollection>*> (v.second); @@ -527,11 +531,10 @@ 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)); - std::cout<<"saved col name="<<v.first<<std::endl; - } - else{ - std::cout<<"don't find col name="<<v.first<<std::endl; + if(m_debug) std::cout<<"saved col name="<<v.first<<std::endl; } + else if(m_debug) std::cout<<"don't find col name="<<v.first<<std::endl; + } else if(m_collections[v.first]=="MCRecoTrackerAssociation"){ auto handle = dynamic_cast<DataHandle<edm4hep::MCRecoTrackerAssociationCollection>*> (v.second); @@ -540,19 +543,18 @@ 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)); - std::cout<<"saved col name="<<v.first<<std::endl; - } - else{ - std::cout<<"don't find col name="<<v.first<<std::endl; + if(m_debug) std::cout<<"saved col name="<<v.first<<std::endl; } + else if(m_debug) std::cout<<"don't find col name="<<v.first<<std::endl; + } else{ std::cout<<"wrong type name for col :"<<v.first<<std::endl; } }//try catch(...){ - std::cout<<"don't find "<<v.first<<"in event"<<std::endl; - std::cout<<"don't find col name="<<v.first<<",with type="<<m_collections[v.first]<<" in this event"<<std::endl; + 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; } } return StatusCode::SUCCESS; diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/TrackCreator.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/TrackCreator.cpp index f9fd064f1a7195bb046ebcb4efcf5d24895e69e2..4b67db277fcb73218e559c6acd1521b7a28a637f 100644 --- a/Reconstruction/PFA/Pandora/GaudiPandora/src/TrackCreator.cpp +++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/TrackCreator.cpp @@ -42,16 +42,45 @@ TrackCreator::TrackCreator(const Settings &settings, const pandora::Pandora *con { + IGearSvc* iSvc = 0; + StatusCode sc = svcloc->service("GearSvc", iSvc, false); + if ( !sc ) throw "Failed to find GearSvc ..."; + _GEAR = iSvc->getGearMgr(); + if(m_settings.m_use_dd4hep_geo){ m_bField = PanUtil::getFieldFromCompact(); const dd4hep::rec::LayeredCalorimeterData * eCalBarrelExtension= PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::BARREL), ( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) ); const dd4hep::rec::LayeredCalorimeterData * eCalEndcapExtension= PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::ENDCAP), ( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) ); - m_eCalBarrelInnerPhi0 = eCalBarrelExtension->inner_phi0/dd4hep::rad; - m_eCalBarrelInnerSymmetry = eCalBarrelExtension->inner_symmetry; - m_eCalBarrelInnerR = eCalBarrelExtension->extent[0]/dd4hep::mm; - m_eCalEndCapInnerZ = eCalEndcapExtension->extent[2]/dd4hep::mm; + if(eCalBarrelExtension){ + m_eCalBarrelInnerPhi0 = eCalBarrelExtension->inner_phi0/dd4hep::rad; + m_eCalBarrelInnerSymmetry = eCalBarrelExtension->inner_symmetry; + m_eCalBarrelInnerR = eCalBarrelExtension->extent[0]/dd4hep::mm; + } + else{ + /* + std::cout<<"TrackCreator:WARNING: can get ECAL barrel info from dd4hep, set it to dummy"<<std::endl; + m_eCalBarrelInnerPhi0 = 0; + m_eCalBarrelInnerSymmetry = 0; + m_eCalBarrelInnerR = 1850; + */ + std::cout<<"TrackCreator:WARNING: can get ECAL barrel info from dd4hep, get it from Gear"<<std::endl; + m_eCalBarrelInnerSymmetry = (_GEAR->getEcalBarrelParameters().getSymmetryOrder()); + m_eCalBarrelInnerPhi0 = (_GEAR->getEcalBarrelParameters().getPhi0()); + m_eCalBarrelInnerR = (_GEAR->getEcalBarrelParameters().getExtent()[0]); + } + if(eCalEndcapExtension){ + m_eCalEndCapInnerZ = eCalEndcapExtension->extent[2]/dd4hep::mm; + } + else{ + /* + std::cout<<"TrackCreator:WARNING: can get ECAL endcap info from dd4hep, set it to dummy"<<std::endl; + m_eCalEndCapInnerZ = 100; + */ + std::cout<<"TrackCreator:WARNING: can get ECAL endcap info from dd4hep, get it from Gear"<<std::endl; + m_eCalEndCapInnerZ = (_GEAR->getEcalEndcapParameters().getExtent()[2]); + } dd4hep::Detector & mainDetector = dd4hep::Detector::getInstance(); try{ @@ -68,25 +97,56 @@ TrackCreator::TrackCreator(const Settings &settings, const pandora::Pandora *con m_tpcMaxRow = theExtension->maxRow; std::cout<<"DD4HEP m_tpcInnerR="<<m_tpcInnerR<<",m_tpcOuterR="<<m_tpcOuterR<<",m_tpcMaxRow="<<m_tpcMaxRow<<",m_tpcZmax="<<m_tpcZmax<<std::endl; } - else{ + else{ + /* m_tpcInnerR = 100 ; m_tpcOuterR = 1800; m_tpcMaxRow = 100 ; m_tpcZmax = 2500; std::cout<<"TrackCreator WARNING:Does not find TPC parameter from dd4hep and set it to dummy value"<<std::endl; + */ + std::cout<<"TrackCreator WARNING:Does not find TPC parameter from dd4hep and get it from Gear"<<std::endl; + m_tpcInnerR = (_GEAR->getTPCParameters().getPadLayout().getPlaneExtent()[0]); + m_tpcOuterR = (_GEAR->getTPCParameters().getPadLayout().getPlaneExtent()[1]); + m_tpcMaxRow = (_GEAR->getTPCParameters().getPadLayout().getNRows()); + m_tpcZmax = (_GEAR->getTPCParameters().getMaxDriftLength()); } - } + } catch (std::runtime_error &exception){ std::cout<<"TrackCreator WARNING:exception during TPC parameter construction:"<<exception.what()<<std::endl; } //Instead of gear, loop over a provided list of forward (read: endcap) tracking detectors. const std::vector< dd4hep::DetElement>& endcapDets = dd4hep::DetectorSelector(mainDetector).detectors( ( dd4hep::DetType::TRACKER | dd4hep::DetType::ENDCAP )) ; if(endcapDets.size()==0){ + /* m_ftdInnerRadii.push_back(100); m_ftdOuterRadii.push_back(200); m_ftdZPositions.push_back(2000); m_nFtdLayers = 1; std::cout<<"TrackCreator WARNING:Does not find forward tracking parameter from dd4hep, so set it to dummy value"<<std::endl; + */ + std::cout<<"TrackCreator WARNING:Does not find forward tracking parameter from dd4hep, so get it from Gear"<<std::endl; + try{ + m_ftdInnerRadii = _GEAR->getGearParameters("FTD").getDoubleVals("FTDInnerRadius"); + m_ftdOuterRadii = _GEAR->getGearParameters("FTD").getDoubleVals("FTDOuterRadius"); + m_ftdZPositions = _GEAR->getGearParameters("FTD").getDoubleVals("FTDZCoordinate"); + m_nFtdLayers = m_ftdZPositions.size(); + } + catch (gear::UnknownParameterException &){ + const gear::FTDLayerLayout &ftdLayerLayout(_GEAR->getFTDParameters().getFTDLayerLayout()); + std::cout << " Filling FTD parameters from gear::FTDParameters - n layers: " << ftdLayerLayout.getNLayers() << std::endl; + for(unsigned int i = 0, N = ftdLayerLayout.getNLayers(); i < N; ++i) + { + // Create a disk to represent even number petals front side + m_ftdInnerRadii.push_back(ftdLayerLayout.getSensitiveRinner(i)); + m_ftdOuterRadii.push_back(ftdLayerLayout.getMaxRadius(i)); + // Take the mean z position of the staggered petals + const double zpos(ftdLayerLayout.getZposition(i)); + m_ftdZPositions.push_back(zpos); + std::cout << "Gear: layer " << i << " - mean z position = " << zpos << std::endl; + } + m_nFtdLayers = m_ftdZPositions.size() ; + } } for (std::vector< dd4hep::DetElement>::const_iterator iter = endcapDets.begin(), iterEnd = endcapDets.end();iter != iterEnd; ++iter){ try{ @@ -121,10 +181,10 @@ TrackCreator::TrackCreator(const Settings &settings, const pandora::Pandora *con }// if m_use_dd4hep_geo else{ - IGearSvc* iSvc = 0; - StatusCode sc = svcloc->service("GearSvc", iSvc, false); - if ( !sc ) throw "Failed to find GearSvc ..."; - _GEAR = iSvc->getGearMgr(); + //IGearSvc* iSvc = 0; + //StatusCode sc = svcloc->service("GearSvc", iSvc, false); + //if ( !sc ) throw "Failed to find GearSvc ..."; + //_GEAR = iSvc->getGearMgr(); m_bField = (_GEAR->getBField().at(gear::Vector3D(0., 0., 0.)).z()); m_eCalBarrelInnerSymmetry = (_GEAR->getEcalBarrelParameters().getSymmetryOrder()); m_eCalBarrelInnerPhi0 = (_GEAR->getEcalBarrelParameters().getPhi0()); diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/Utility.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/Utility.cpp index 83edea103d7fab42363d57e7076ba8b4c7829177..3f054df12ae7fc59912e142d67610672a1992d0a 100644 --- a/Reconstruction/PFA/Pandora/GaudiPandora/src/Utility.cpp +++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/Utility.cpp @@ -35,7 +35,7 @@ std::vector<double> PanUtil::getTrackingRegionExtent(){ return extent; } -dd4hep::rec::LayeredCalorimeterData * PanUtil::getExtension(unsigned int includeFlag, unsigned int excludeFlag=0) { +dd4hep::rec::LayeredCalorimeterData * PanUtil::getExtension(unsigned int includeFlag, unsigned int excludeFlag) { dd4hep::rec::LayeredCalorimeterData * theExtension = 0; @@ -50,12 +50,12 @@ dd4hep::rec::LayeredCalorimeterData * PanUtil::getExtension(unsigned int include if( theDetectors.size() != 1 ){ std::stringstream es ; - es << " getExtension: selection is not unique (or empty) includeFlag: " << dd4hep::DetType( includeFlag ) << " excludeFlag: " << dd4hep::DetType( excludeFlag ) - << " --- found detectors : " ; + es << "return nullptr! getExtension: selection is not unique (or empty) includeFlag: " << dd4hep::DetType( includeFlag ) << " excludeFlag: " << dd4hep::DetType( excludeFlag ) << " --- found detectors : " ; for( unsigned i=0, N= theDetectors.size(); i<N ; ++i ){ es << theDetectors.at(i).name() << ", " ; } - throw std::runtime_error( es.str() ) ; + //throw std::runtime_error( es.str() ) ; + return nullptr; } theExtension = theDetectors.at(0).extension<dd4hep::rec::LayeredCalorimeterData>();