diff --git a/Calorimeter/CaloCondPhysAlgs/CaloCondPhysAlgs/LArHVMapTool.h b/Calorimeter/CaloCondPhysAlgs/CaloCondPhysAlgs/LArHVMapTool.h deleted file mode 100644 index 15e73e63ec3916fe1bf5e8a19b4f344560efaf1f..0000000000000000000000000000000000000000 --- a/Calorimeter/CaloCondPhysAlgs/CaloCondPhysAlgs/LArHVMapTool.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ -#ifndef LARHVMAPTOOL_H -#define LARHVMAPTOOL_H - -#include "GaudiKernel/ToolHandle.h" -#include "StoreGate/DataHandle.h" -#include "AthenaBaseComps/AthAlgTool.h" - -#include "LArCabling/LArHVCablingTool.h" -#include "CxxUtils/checker_macros.h" - -class CaloDetDescrManager; -class Identifier; -class CaloIdManager; -class LArEM_ID; -class LArHEC_ID; -class LArFCAL_ID; -//class LArHVCablingTool; - -static const InterfaceID IID_LArHVMapTool("LArHVMapTool", 1 ,0); - -class ATLAS_NOT_THREAD_SAFE LArHVMapTool: public AthAlgTool -{ - - public: - LArHVMapTool(const std::string& type, const std::string& name, - const IInterface* parent); - - virtual ~LArHVMapTool(){} - - static const InterfaceID& interfaceID() { return IID_LArHVMapTool; } - - virtual StatusCode initialize(); - virtual StatusCode execute(); - virtual StatusCode finalize(){return StatusCode::SUCCESS;} - - - std::vector<int> GetHVLines ATLAS_NOT_THREAD_SAFE(const Identifier& id); - - private: - - const DataHandle<CaloIdManager> m_caloIdMgr; - const DataHandle<CaloDetDescrManager> m_calodetdescrmgr; - const LArEM_ID* m_larem_id; - const LArHEC_ID* m_larhec_id; - const LArFCAL_ID* m_larfcal_id; - - ToolHandle<LArHVCablingTool> m_hvCablingTool; -}; - -#endif diff --git a/Calorimeter/CaloCondPhysAlgs/share/EMB_EMEC_PS_HV_Energy_Rescale.py b/Calorimeter/CaloCondPhysAlgs/share/EMB_EMEC_PS_HV_Energy_Rescale.py index 28b45c8ae67bb79beef49bf8607face95fcaeb17..a243a279bc4a5488005f52ba52d32d94ea5f35ce 100644 --- a/Calorimeter/CaloCondPhysAlgs/share/EMB_EMEC_PS_HV_Energy_Rescale.py +++ b/Calorimeter/CaloCondPhysAlgs/share/EMB_EMEC_PS_HV_Energy_Rescale.py @@ -107,10 +107,6 @@ theRescaler.HVvalues = [ 0.992, 0.992, 0.992, 0.992, 0.992, 0.992, 0.992, 0.992, topSequence += theRescaler -from CaloCondPhysAlgs.CaloCondPhysAlgsConf import LArHVMapTool -theLArHV=LArHVMapTool("LArHVMapTool") -ToolSvc += theLArHV - #-------------------------------------------------------------- #--- Dummy event loop parameters #-------------------------------------------------------------- diff --git a/Calorimeter/CaloCondPhysAlgs/src/CaloCellCalcEnergyCorr.cxx b/Calorimeter/CaloCondPhysAlgs/src/CaloCellCalcEnergyCorr.cxx index c52d8665666503f92363838f20b012b521beb37e..9cbdbee7759a8983d78988564df645baa27d7930 100644 --- a/Calorimeter/CaloCondPhysAlgs/src/CaloCellCalcEnergyCorr.cxx +++ b/Calorimeter/CaloCondPhysAlgs/src/CaloCellCalcEnergyCorr.cxx @@ -34,7 +34,34 @@ #include "CoolKernel/types.h" #include "CoolKernel/Record.h" #include "CoralBase/AttributeListSpecification.h" -#include "CaloCondPhysAlgs/LArHVMapTool.h" + +#include "CxxUtils/checker_macros.h" + + +struct ATLAS_NOT_THREAD_SAFE CaloCellCalcEnergyCorr::HVData +{ + HVData (const LArHVManager& manager); + EMBHVManager::EMBHVData m_hvdata_EMB; + EMBPresamplerHVManager::EMBPresamplerHVData m_hvdata_EMBPS; + EMECHVManager::EMECHVData m_hvdata_EMEC_IN; + EMECHVManager::EMECHVData m_hvdata_EMEC_OUT; + EMECPresamplerHVManager::EMECPresamplerHVData m_hvdata_EMECPS; + HECHVManager::HECHVData m_hvdata_HEC; + FCALHVManager::FCALHVData m_hvdata_FCAL; +}; + + +CaloCellCalcEnergyCorr::HVData::HVData (const LArHVManager& manager) + : m_hvdata_EMB (manager.getEMBHVManager().getData()), + m_hvdata_EMBPS (manager.getEMBPresamplerHVManager().getData()), + m_hvdata_EMEC_IN (manager.getEMECHVManager(EMECHVModule::IOType::INNER).getData()), + m_hvdata_EMEC_OUT (manager.getEMECHVManager(EMECHVModule::IOType::OUTER).getData()), + m_hvdata_EMECPS (manager.getEMECPresamplerHVManager().getData()), + m_hvdata_HEC (manager.getHECHVManager().getData()), + m_hvdata_FCAL (manager.getFCALHVManager().getData()) +{ +} + CaloCellCalcEnergyCorr::CaloCellCalcEnergyCorr( const std::string& name, ISvcLocator* pSvcLocator ) : @@ -95,7 +122,7 @@ StatusCode CaloCellCalcEnergyCorr::execute() return StatusCode::SUCCESS; } -StatusCode CaloCellCalcEnergyCorr::stop() +StatusCode CaloCellCalcEnergyCorr::stop ATLAS_NOT_THREAD_SAFE () { const CaloCell_ID* calocell_id; @@ -145,6 +172,10 @@ StatusCode CaloCellCalcEnergyCorr::stop() CHECK(detStore()->record(attrList,m_folder)); + const LArHVManager* manager = nullptr; + CHECK( detStore()->retrieve (manager) ); + HVData hvdata (*manager); + std::vector<float> setVec(1,1); unsigned nSet=0; unsigned nSetHV=0; @@ -159,8 +190,7 @@ StatusCode CaloCellCalcEnergyCorr::stop() // check if we have also HVLine for this cell if(!m_hvlines.empty() && m_hvlines[0]>0) { Identifier offId=calocell_id->cell_id(h); - std::vector<int> hvlineId = GetHVLines(offId); - //std::cout<<offId.getString()<<" : "; + std::vector<int> hvlineId = GetHVLines(hvdata, offId); int nfound=0; float hvval=-1; std::vector<int>::const_iterator poshv; @@ -176,7 +206,6 @@ StatusCode CaloCellCalcEnergyCorr::stop() } } } - //std::cout << h << " " << value << std::endl; setVec[0]=value; flt->setData(h,0,setVec); }//end loop over hash @@ -188,7 +217,8 @@ StatusCode CaloCellCalcEnergyCorr::stop() } -std::vector<int> CaloCellCalcEnergyCorr::GetHVLines(const Identifier& id) { +std::vector<int> CaloCellCalcEnergyCorr::GetHVLines(const HVData& hvdata, + const Identifier& id) { std::set<int> hv; // LAr EMB @@ -200,7 +230,7 @@ std::vector<int> CaloCellCalcEnergyCorr::GetHVLines(const Identifier& id) { unsigned int nelec = cell->getNumElectrodes(); for (unsigned int i=0;i<nelec;i++) { const EMBHVElectrode& electrode = cell->getElectrode(i); - for (unsigned int igap=0;igap<2;igap++) hv.insert(electrode.hvLineNo(igap)); + for (unsigned int igap=0;igap<2;igap++) hv.insert(hvdata.m_hvdata_EMB.hvLineNo (electrode, igap)); } } else { // LAr EMEC const EMECDetectorElement* emecElement = dynamic_cast<const EMECDetectorElement*>(m_calodetdescrmgr->get_element(id)); @@ -209,7 +239,13 @@ std::vector<int> CaloCellCalcEnergyCorr::GetHVLines(const Identifier& id) { unsigned int nelec = cell->getNumElectrodes(); for (unsigned int i=0;i<nelec;i++) { const EMECHVElectrode& electrode = cell->getElectrode(i); - for (unsigned int igap=0;igap<2;igap++) hv.insert(electrode.hvLineNo(igap)); + const EMECHVManager::EMECHVData& hvdata_EMEC = + electrode.getModule().getWheelIndex() == EMECHVModule::INNER ? + hvdata.m_hvdata_EMEC_IN : + hvdata.m_hvdata_EMEC_OUT ; + for (unsigned int igap=0;igap<2;igap++) { + hv.insert(hvdata_EMEC.hvLineNo (electrode, igap)); + } } } } else if (m_larhec_id->is_lar_hec(id)) { // LAr HEC @@ -219,7 +255,7 @@ std::vector<int> CaloCellCalcEnergyCorr::GetHVLines(const Identifier& id) { unsigned int nsubgaps = cell->getNumSubgaps(); for (unsigned int igap=0;igap<nsubgaps;igap++) { const HECHVSubgap& subgap = cell->getSubgap(igap); - hv.insert(subgap.hvLineNo()); + hv.insert(hvdata.m_hvdata_HEC.hvLineNo (subgap)); } } else if (m_larfcal_id->is_lar_fcal(id)) { // LAr FCAL const FCALDetectorElement* fcalElement = dynamic_cast<const FCALDetectorElement*>(m_calodetdescrmgr->get_element(id)); @@ -228,7 +264,7 @@ std::vector<int> CaloCellCalcEnergyCorr::GetHVLines(const Identifier& id) { unsigned int nlines = tile->getNumHVLines(); for (unsigned int i=0;i<nlines;i++) { const FCALHVLine* line = tile->getHVLine(i); - if(line) hv.insert(line->hvLineNo()); + if(line) hv.insert(hvdata.m_hvdata_FCAL.hvLineNo (*line)); } } else if (m_larem_id->is_lar_em(id) && m_larem_id->sampling(id)==0) { // Presamplers if (abs(m_larem_id->barrel_ec(id))==1) { @@ -236,13 +272,13 @@ std::vector<int> CaloCellCalcEnergyCorr::GetHVLines(const Identifier& id) { if (!embElement) std::abort(); const EMBCellConstLink cell = embElement->getEMBCell(); const EMBPresamplerHVModule& hvmodule = cell->getPresamplerHVModule(); - for (unsigned int igap=0;igap<2;igap++) hv.insert(hvmodule.hvLineNo(igap)); + for (unsigned int igap=0;igap<2;igap++) hv.insert(hvdata.m_hvdata_EMBPS.hvLineNo (hvmodule, igap)); } else { const EMECDetectorElement* emecElement = dynamic_cast<const EMECDetectorElement*>(m_calodetdescrmgr->get_element(id)); if (!emecElement) std::abort(); const EMECCellConstLink cell = emecElement->getEMECCell(); const EMECPresamplerHVModule& hvmodule = cell->getPresamplerHVModule (); - for (unsigned int igap=0;igap<2;igap++) hv.insert(hvmodule.hvLineNo(igap)); + for (unsigned int igap=0;igap<2;igap++) hv.insert(hvdata.m_hvdata_EMECPS.hvLineNo (hvmodule, igap)); } } diff --git a/Calorimeter/CaloCondPhysAlgs/src/CaloCellCalcEnergyCorr.h b/Calorimeter/CaloCondPhysAlgs/src/CaloCellCalcEnergyCorr.h index fcef8d3bb89ffba609d21b93f088b5c95e98e7b0..fb44b125a58eca9b24922ad78e9bc9ef8389a9aa 100644 --- a/Calorimeter/CaloCondPhysAlgs/src/CaloCellCalcEnergyCorr.h +++ b/Calorimeter/CaloCondPhysAlgs/src/CaloCellCalcEnergyCorr.h @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef CALOCONDPHYSALGS_CALOCELLCALCENERGYCORR_H @@ -37,9 +37,11 @@ class CaloCellCalcEnergyCorr: public AthAlgorithm virtual StatusCode initialize(); virtual StatusCode execute(); virtual StatusCode finalize(); - virtual StatusCode stop ATLAS_NOT_THREAD_SAFE /* calls ctor of AthenaAttributeList*/(); + virtual StatusCode stop ATLAS_NOT_THREAD_SAFE /* Calls getData() method of HV managers */(); private: + struct ATLAS_NOT_THREAD_SAFE HVData; + // Properties std::string m_folder; std::vector<int> m_calosample; // which CaloSamples to be filled (numbers from CaloSample enum in CaloCell_Base_ID @@ -53,7 +55,7 @@ private: const LArHEC_ID* m_larhec_id; const LArFCAL_ID* m_larfcal_id; - std::vector<int> GetHVLines(const Identifier& id) ; + std::vector<int> GetHVLines(const HVData& hvdata, const Identifier& id) ; }; #endif //> !CALOCONDPHYSALGS_CALOCELLCALCENERGYCORR_H diff --git a/Calorimeter/CaloCondPhysAlgs/src/LArHVMapTool.cxx b/Calorimeter/CaloCondPhysAlgs/src/LArHVMapTool.cxx deleted file mode 100644 index c982ef7d0c5fe72c50c235785d4569b6934a754d..0000000000000000000000000000000000000000 --- a/Calorimeter/CaloCondPhysAlgs/src/LArHVMapTool.cxx +++ /dev/null @@ -1,168 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -#include "CaloCondPhysAlgs/LArHVMapTool.h" -#include "CaloDetDescr/CaloDetDescrManager.h" -#include "CaloDetDescr/CaloDetectorElements.h" -#include "CaloIdentifier/LArEM_ID.h" -#include "CaloIdentifier/LArHEC_ID.h" -#include "CaloIdentifier/LArFCAL_ID.h" -#include "CaloIdentifier/CaloIdManager.h" - -#include "LArHV/EMBHVElectrode.h" -#include "LArHV/EMBPresamplerHVModule.h" -#include "LArHV/EMECHVElectrode.h" -#include "LArHV/EMECPresamplerHVModule.h" -#include "LArHV/HECHVSubgap.h" -#include "LArHV/FCALHVLine.h" -#include "LArReadoutGeometry/EMECCell.h" -#include "LArReadoutGeometry/HECCell.h" -#include "LArReadoutGeometry/EMBCell.h" -#include "LArReadoutGeometry/FCALTile.h" -#include "LArReadoutGeometry/EMBCellConstLink.h" -#include "LArReadoutGeometry/EMECCellConstLink.h" -#include "LArReadoutGeometry/HECCellConstLink.h" -#include "LArReadoutGeometry/FCALTubeConstLink.h" - -#include "LArHV/LArHVManager.h" - - - -LArHVMapTool::LArHVMapTool(const std::string& type, const std::string& name, const IInterface* parent) - : AthAlgTool(type,name,parent) - { - declareInterface<LArHVMapTool>( this ); - } - -StatusCode LArHVMapTool::initialize(){ - - CHECK(detStore()->retrieve(m_caloIdMgr)); - - m_larem_id = m_caloIdMgr->getEM_ID(); - m_larhec_id = m_caloIdMgr->getHEC_ID(); - m_larfcal_id = m_caloIdMgr->getFCAL_ID(); - - CHECK(detStore()->retrieve(m_calodetdescrmgr)); - - - return StatusCode::SUCCESS; -} - -StatusCode LArHVMapTool::execute() { - - - CHECK(m_hvCablingTool.retrieve()); - - IdentifierHash h=0; - Identifier offId; - m_larem_id->get_id(h,offId); - std::vector<int> hvlineId = GetHVLines(offId); - //std::cout<<"LArHVMapTool::execute "<<offId.getString()<<" : "<<hvlineId.size()<<std::endl; - //if(hvlineId.size()>0) std::cout<<hvlineId[0]<<std::endl; - - return StatusCode::SUCCESS; -} - - -std::vector<int> LArHVMapTool::GetHVLines(const Identifier& id) { - std::set<int> hv; - - // LAr EMB - if (m_larem_id->is_lar_em(id) && m_larem_id->sampling(id)>0) { - if (abs(m_larem_id->barrel_ec(id))==1) { - const EMBDetectorElement* embElement = dynamic_cast<const EMBDetectorElement*>(m_calodetdescrmgr->get_element(id)); - if (embElement) { - const EMBCellConstLink cell = embElement->getEMBCell(); - unsigned int nelec = cell->getNumElectrodes(); - for (unsigned int i=0;i<nelec;i++) { - const EMBHVElectrode& electrode = cell->getElectrode(i); - for (unsigned int igap=0;igap<2;igap++) { - hv.insert(electrode.hvLineNo(igap)); - } - } - } - else { - ATH_MSG_ERROR( "Failed d'cast to EMBDetectorElement" ); - } - } else { // LAr EMEC - const EMECDetectorElement* emecElement = dynamic_cast<const EMECDetectorElement*>(m_calodetdescrmgr->get_element(id)); - if (emecElement) { - const EMECCellConstLink cell = emecElement->getEMECCell(); - unsigned int nelec = cell->getNumElectrodes(); - for (unsigned int i=0;i<nelec;i++) { - const EMECHVElectrode& electrode = cell->getElectrode(i); - for (unsigned int igap=0;igap<2;igap++) hv.insert(electrode.hvLineNo(igap)); - } - } - else { - ATH_MSG_ERROR( "Failed d'cast to EMECDetectorElement" ); - } - } - } else if (m_larhec_id->is_lar_hec(id)) { // LAr HEC - const HECDetectorElement* hecElement = dynamic_cast<const HECDetectorElement*>(m_calodetdescrmgr->get_element(id)); - if (hecElement) { - const HECCellConstLink cell = hecElement->getHECCell(); - unsigned int nsubgaps = cell->getNumSubgaps(); - for (unsigned int igap=0;igap<nsubgaps;igap++) { - const HECHVSubgap& subgap = cell->getSubgap(igap); - hv.insert(subgap.hvLineNo()); - } - } - else { - ATH_MSG_ERROR( "Failed d'cast to HECDetectorElement" ); - } - } else if (m_larfcal_id->is_lar_fcal(id)) { // LAr FCAL - const FCALDetectorElement* fcalElement = dynamic_cast<const FCALDetectorElement*>(m_calodetdescrmgr->get_element(id)); - if (fcalElement) { - const FCALTile* tile = fcalElement->getFCALTile(); - unsigned int nlines = tile->getNumHVLines(); - unsigned int nlines_found=0; - for (unsigned int i=0;i<nlines;i++) { - const FCALHVLine* line = tile->getHVLine(i); - if (line) nlines_found++; - } - if ( nlines_found>0 ) { - for (unsigned int i=0;i<nlines;i++) { - const FCALHVLine* line = tile->getHVLine(i); - if (!line) continue; - hv.insert(line->hvLineNo()); - } - } - } - else { - ATH_MSG_ERROR( "Failed d'cast to FCALDetectorElement" ); - } - - } else if (m_larem_id->is_lar_em(id) && m_larem_id->sampling(id)==0) { // Presamplers - if (abs(m_larem_id->barrel_ec(id))==1) { - const EMBDetectorElement* embElement = dynamic_cast<const EMBDetectorElement*>(m_calodetdescrmgr->get_element(id)); - if (embElement) { - const EMBCellConstLink cell = embElement->getEMBCell(); - const EMBPresamplerHVModule& hvmodule = cell->getPresamplerHVModule(); - for (unsigned int igap=0;igap<2;igap++) hv.insert(hvmodule.hvLineNo(igap)); - } - else { - ATH_MSG_ERROR( "Failed d'cast to EMBDetectorElement (for presampler)" ); - } - } else { - const EMECDetectorElement* emecElement = dynamic_cast<const EMECDetectorElement*>(m_calodetdescrmgr->get_element(id)); - if (emecElement) { - const EMECCellConstLink cell = emecElement->getEMECCell(); - const EMECPresamplerHVModule& hvmodule = cell->getPresamplerHVModule (); - for (unsigned int igap=0;igap<2;igap++) hv.insert(hvmodule.hvLineNo(igap)); - } - else { - ATH_MSG_ERROR( "Failed d'cast to EMECDetectorElement (for presampler)" ); - } - } - } - - std::vector<int> hvlines; - for (std::set<int>::iterator i=hv.begin();i!=hv.end();++i) hvlines.push_back(*i); - //std::cout<<"LArHVMapTool hvlines size: "<<hvlines.size()<<std::endl; - //if(hvlines.size()>0) std::cout<<hvlines[0]<<std::endl; - return hvlines; -} - - diff --git a/LArCalorimeter/LArCondUtils/share/LArHV2Ntuple_jobOptions.py b/LArCalorimeter/LArCondUtils/share/LArHV2Ntuple_jobOptions.py index 5a4a42e8aa4350b03015f2a572d9191097ae99d3..685ca6d6df54442b06e427052a693e582c946a25 100644 --- a/LArCalorimeter/LArCondUtils/share/LArHV2Ntuple_jobOptions.py +++ b/LArCalorimeter/LArCondUtils/share/LArHV2Ntuple_jobOptions.py @@ -76,10 +76,7 @@ include("LArConditionsCommon/LArConditionsCommon_comm_jobOptions.py") #include( "LArCondAthenaPool/LArCondAthenaPool_joboptions.py" ) -from IOVDbSvc.CondDB import conddb -conddb.addFolder("LAR_OFL","/LAR/IdentifierOfl/HVLineToElectrodeMap"); -conddb.addFolder("DCS_OFL","/LAR/DCS/HV/BARREl/I16") -conddb.addFolder("DCS_OFL","/LAR/DCS/HV/BARREL/I8") +from LArConditionsCommon import LArHVDB from LArCondUtils.LArCondUtilsConf import LArHV2Ntuple theLArHV2Ntuple = LArHV2Ntuple("LArHV2Ntuple") diff --git a/LArCalorimeter/LArCondUtils/share/LArHVPathologyDbRead.py b/LArCalorimeter/LArCondUtils/share/LArHVPathologyDbRead.py index 386e7d26794b87a64a70ec3d73f6342c5a9ee2ca..8e8d0e9472f9f4547cd719009829e09db8a419b2 100755 --- a/LArCalorimeter/LArCondUtils/share/LArHVPathologyDbRead.py +++ b/LArCalorimeter/LArCondUtils/share/LArHVPathologyDbRead.py @@ -72,9 +72,7 @@ include( "LArDetDescr/LArDetDescr_joboptions.py" ) #include("LArConditionsCommon/LArConditionsCommon_comm_jobOptions.py") include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) -conddb.addFolder("LAR_OFL","/LAR/IdentifierOfl/HVLineToElectrodeMap") -conddb.addFolder("DCS_OFL","/LAR/DCS/HV/BARREl/I16") -conddb.addFolder("DCS_OFL","/LAR/DCS/HV/BARREL/I8") +from LArConditionsCommon import LArHVDB #-------------------------------------------------------------- # Access to IOVSvc, IOVDbSvc and CondDBMySQLCnvSvc #-------------------------------------------------------------- diff --git a/LArCalorimeter/LArCondUtils/share/LArHVPathologyDbWrite.py b/LArCalorimeter/LArCondUtils/share/LArHVPathologyDbWrite.py index 376c4f9b4889edf9c569549c106710193fa0aef0..2e6e09c61f0f9bd77c86ed7d4943ea82a6a405fc 100755 --- a/LArCalorimeter/LArCondUtils/share/LArHVPathologyDbWrite.py +++ b/LArCalorimeter/LArCondUtils/share/LArHVPathologyDbWrite.py @@ -75,12 +75,8 @@ include( "LArDetDescr/LArDetDescr_joboptions.py" ) #include("TileConditions/TileConditions_jobOptions.py" ) #include("LArConditionsCommon/LArConditionsCommon_comm_jobOptions.py") -#from LArConditionsCommon import LArHVDB +from LArConditionsCommon import LArHVDB -from IOVDbSvc.CondDB import conddb -conddb.addFolder("LAR_OFL","/LAR/IdentifierOfl/HVLineToElectrodeMap") -conddb.addFolder("DCS_OFL","/LAR/DCS/HV/BARREl/I16") -conddb.addFolder("DCS_OFL","/LAR/DCS/HV/BARREL/I8") #-------------------------------------------------------------- diff --git a/LArCalorimeter/LArCondUtils/src/LArHV2Ntuple.cxx b/LArCalorimeter/LArCondUtils/src/LArHV2Ntuple.cxx index d09418a3424e4a9c7ff52a1c54735cbf72421289..4cbcfa44341726b9c52c6df0d93ee18ed5ff8be5 100644 --- a/LArCalorimeter/LArCondUtils/src/LArHV2Ntuple.cxx +++ b/LArCalorimeter/LArCondUtils/src/LArHV2Ntuple.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArHV2Ntuple.h" @@ -26,6 +26,8 @@ #include "CaloDetDescr/CaloDetDescrManager.h" #include "CaloDetDescr/CaloDetectorElements.h" #include "CaloGeoHelpers/CaloPhiRange.h" +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "GaudiKernel/ThreadLocalContext.h" //Constructor LArHV2Ntuple:: LArHV2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): @@ -83,6 +85,8 @@ ATH_CHECK( detStore()->retrieve(m_calodetdescrmgr) ); } + ATH_CHECK( m_hvCablingKey.initialize() ); + ATH_CHECK( m_DCSFolderKeys.initialize() ); ATH_CHECK( m_thistSvc->regTree("/file1/hv/mytree",m_tree) ); return StatusCode::SUCCESS; @@ -91,37 +95,76 @@ //__________________________________________________________________________ StatusCode LArHV2Ntuple::execute() { + const EventContext& ctx = Gaudi::Hive::currentContext(); + //............................................. + + // FIXME: Use LArHVData instead? + SG::ReadCondHandle<LArHVIdMapping> hvCabling (m_hvCablingKey, ctx); + std::vector<const CondAttrListCollection*> attrLists; + for (const SG::ReadCondHandleKey<CondAttrListCollection>& k : m_DCSFolderKeys) + { + SG::ReadCondHandle<CondAttrListCollection> attrList (k, ctx); + attrLists.push_back (*attrList); + } - ATH_MSG_DEBUG ( "LArHV2Ntuple execute()" ); - if(m_hvonlId_map.size()==0) { - SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKey}; - const LArOnOffIdMapping* cabling{*cablingHdl}; - if(!cabling) { + const LArHVManager *manager = NULL; + ATH_CHECK( detStore()->retrieve(manager) ); + + const EMBHVManager& hvManager_EMB=manager->getEMBHVManager(); + const EMBHVManager::EMBHVData hvdata_EMB = hvManager_EMB.getData (**hvCabling, attrLists); + + const EMBPresamplerHVManager& hvManager_EMBPS=manager->getEMBPresamplerHVManager(); + const EMBPresamplerHVManager::EMBPresamplerHVData hvdata_EMBPS = hvManager_EMBPS.getData (**hvCabling, attrLists); + + const EMECPresamplerHVManager& hvManager_EMECPS=manager->getEMECPresamplerHVManager(); + const EMECPresamplerHVManager::EMECPresamplerHVData hvdata_EMECPS = hvManager_EMECPS.getData (**hvCabling, attrLists); + + const EMECHVManager& hvManager_EMEC_OUT=manager->getEMECHVManager(EMECHVModule::OUTER); + const EMECHVManager::EMECHVData hvdata_EMEC_OUT = hvManager_EMEC_OUT.getData (**hvCabling, attrLists); + + const EMECHVManager& hvManager_EMEC_IN=manager->getEMECHVManager(EMECHVModule::INNER); + const EMECHVManager::EMECHVData hvdata_EMEC_IN = hvManager_EMEC_IN.getData (**hvCabling, attrLists); + + const HECHVManager& hvManager_HEC=manager->getHECHVManager(); + const HECHVManager::HECHVData hvdata_HEC = hvManager_HEC.getData (**hvCabling, attrLists); + + const FCALHVManager& hvManager_FCAL=manager->getFCALHVManager(); + const FCALHVManager::FCALHVData hvdata_FCAL = hvManager_FCAL.getData (**hvCabling, attrLists); + + ATH_MSG_DEBUG ( "LArHV2Ntuple execute()" ); + if(m_hvonlId_map.size()==0) { + SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKey, ctx}; + const LArOnOffIdMapping* cabling{*cablingHdl}; + if(!cabling) { ATH_MSG_ERROR("Do not have mapping object " << m_cablingKey.key()); return StatusCode::FAILURE; - } - std::vector<Identifier>::const_iterator cell_b=m_caloId->cell_begin(); - std::vector<Identifier>::const_iterator cell_e=m_caloId->cell_end(); - for(;cell_b!=cell_e; ++cell_b) { - if(m_caloId->is_tile(*cell_b)) continue; - HWIdentifier onlid = cabling->createSignalChannelID(*cell_b); - std::vector<int> hvlines = GetHVLines(*cell_b); - for(unsigned i=0; i<hvlines.size(); ++i ) { - if(m_hvonlId_map.find(hvlines[i]) == m_hvonlId_map.end()) { // new key - std::vector<HWIdentifier> vec; - vec.push_back(onlid); - m_hvonlId_map[hvlines[i]] = vec; - } else { // existing key - m_hvonlId_map[hvlines[i]].push_back(onlid); - } - } - }// end map filling - } + } + std::vector<Identifier>::const_iterator cell_b=m_caloId->cell_begin(); + std::vector<Identifier>::const_iterator cell_e=m_caloId->cell_end(); + for(;cell_b!=cell_e; ++cell_b) { + if(m_caloId->is_tile(*cell_b)) continue; + HWIdentifier onlid = cabling->createSignalChannelID(*cell_b); + std::vector<int> hvlines = GetHVLines (hvdata_EMB, + hvdata_EMBPS, + hvdata_EMEC_OUT, + hvdata_EMEC_IN, + hvdata_EMECPS, + hvdata_HEC, + hvdata_FCAL, + *cell_b); + for(unsigned i=0; i<hvlines.size(); ++i ) { + if(m_hvonlId_map.find(hvlines[i]) == m_hvonlId_map.end()) { // new key + std::vector<HWIdentifier> vec; + vec.push_back(onlid); + m_hvonlId_map[hvlines[i]] = vec; + } else { // existing key + m_hvonlId_map[hvlines[i]].push_back(onlid); + } + } + }// end map filling + } - const LArHVManager *manager = NULL; - if (detStore()->retrieve(manager)==StatusCode::SUCCESS) { - const EMBHVManager& hvManager_EMB=manager->getEMBHVManager(); for (unsigned int iSide=hvManager_EMB.beginSideIndex();iSide<hvManager_EMB.endSideIndex();iSide++) { // loop over HV modules for (unsigned int iPhi=hvManager_EMB.beginPhiIndex();iPhi<hvManager_EMB.endPhiIndex();iPhi++) { for (unsigned int iSector=hvManager_EMB.beginSectorIndex();iSector<hvManager_EMB.endSectorIndex();iSector++) { @@ -131,8 +174,8 @@ for (unsigned int ielec=0;ielec<32;ielec++) { //use hvMod->getNumElectrodes when bug is corrected const EMBHVElectrode& electrode = hvMod.getElectrode(ielec); for (unsigned int iGap=0;iGap<2;iGap++) { // EMB : 2, TRY TO FIND AUTOMATICALLY NB OF GAPS - float hv=electrode.voltage(iGap); - float current = electrode.current(iGap); + float hv = hvdata_EMB.voltage (electrode, iGap); + float current = hvdata_EMB.current (electrode, iGap); float phi = electrode.getPhi(); m_bec=0; @@ -143,7 +186,7 @@ m_gap = iGap; m_hv = hv; m_current= current; - m_hvline = electrode.hvLineNo(iGap); + m_hvline = hvdata_EMB.hvLineNo (electrode, iGap); if(m_addcells) { for(unsigned i=0; i<m_hvonlId_map[m_hvline].size(); ++i) { @@ -163,14 +206,13 @@ } } //EMBHVManager - const EMBPresamplerHVManager& hvManager_EMBPS=manager->getEMBPresamplerHVManager(); for (unsigned int iSide=hvManager_EMBPS.beginSideIndex();iSide<hvManager_EMBPS.endSideIndex();iSide++) { // loop over HV modules for (unsigned int iPhi=hvManager_EMBPS.beginPhiIndex();iPhi<hvManager_EMBPS.endPhiIndex();iPhi++) { for (unsigned int iEta=hvManager_EMBPS.beginEtaIndex();iEta<hvManager_EMBPS.endEtaIndex();iEta++) { //0 to 7 const EMBPresamplerHVModule& hvMod = hvManager_EMBPS.getHVModule(iSide,iEta,iPhi); for (int iGap=0;iGap<2;iGap++) { - float hv = hvMod.voltage(iGap); - float current =hvMod.current(iGap); + float hv = hvdata_EMBPS.voltage (hvMod, iGap); + float current = hvdata_EMBPS.current (hvMod, iGap); float eta = 0.5*(hvMod.getEtaMin()+hvMod.getEtaMax()); float phi= 0.5*(hvMod.getPhiMin()+hvMod.getPhiMax()); @@ -182,7 +224,7 @@ m_gap = iGap; m_hv = hv; m_current= current; - m_hvline = hvMod.hvLineNo(iGap); + m_hvline = hvdata_EMBPS.hvLineNo (hvMod, iGap); if(m_addcells) { for(unsigned i=0; i<m_hvonlId_map[m_hvline].size(); ++i) { @@ -200,13 +242,12 @@ } } //EMBPresampler - const EMECPresamplerHVManager& hvManager_EMECPS=manager->getEMECPresamplerHVManager(); for (unsigned int iSide=hvManager_EMECPS.beginSideIndex();iSide<hvManager_EMECPS.endSideIndex();iSide++) { // loop over HV modules for (unsigned int iPhi=hvManager_EMECPS.beginPhiIndex();iPhi<hvManager_EMECPS.endPhiIndex();iPhi++) { const EMECPresamplerHVModule& hvMod = hvManager_EMECPS.getHVModule(iSide,iPhi); for (int iGap=0;iGap<2;iGap++) { - float hv = hvMod.voltage(iGap); - float current =hvMod.current(iGap); + float hv = hvdata_EMECPS.voltage (hvMod, iGap); + float current = hvdata_EMECPS.current (hvMod, iGap); float eta = 0.5*(hvMod.getEtaMin()+hvMod.getEtaMax()); float phi=0.5*(hvMod.getPhiMin()+hvMod.getPhiMax()); @@ -218,7 +259,7 @@ m_gap = iGap; m_hv = hv; m_current= current; - m_hvline = hvMod.hvLineNo(iGap); + m_hvline = hvdata_EMECPS.hvLineNo (hvMod, iGap); if(m_addcells) { for(unsigned i=0; i<m_hvonlId_map[m_hvline].size(); ++i) { @@ -237,7 +278,6 @@ - const EMECHVManager& hvManager_EMEC_OUT=manager->getEMECHVManager(EMECHVModule::OUTER); for (unsigned int iSide=hvManager_EMEC_OUT.beginSideIndex();iSide<hvManager_EMEC_OUT.endSideIndex();iSide++) { // loop over HV modules for (unsigned int iPhi=hvManager_EMEC_OUT.beginPhiIndex();iPhi<hvManager_EMEC_OUT.endPhiIndex();iPhi++) { for (unsigned int iSector=hvManager_EMEC_OUT.beginSectorIndex();iSector<hvManager_EMEC_OUT.endSectorIndex();iSector++) { @@ -247,8 +287,8 @@ for (unsigned int ielec=0;ielec<hvMod.getNumElectrodes();ielec++) { //use hvMod.getNumElectrodes when bug is corrected const EMECHVElectrode& electrode = hvMod.getElectrode(ielec); for (unsigned int iGap=0;iGap<2;iGap++) { //EMEC : 2 gaps, TRY TO FIND AUTOMATICALLY NB OF GAPS - float hv=electrode.voltage(iGap); - float current = electrode.current(iGap); + float hv = hvdata_EMEC_OUT.voltage (electrode, iGap); + float current = hvdata_EMEC_OUT.current (electrode, iGap); float phi = electrode.getPhi(); m_bec=1; @@ -259,7 +299,7 @@ m_gap = iGap; m_hv = hv; m_current= current; - m_hvline = electrode.hvLineNo(iGap); + m_hvline = hvdata_EMEC_OUT.hvLineNo (electrode, iGap); if(m_addcells) { for(unsigned i=0; i<m_hvonlId_map[m_hvline].size(); ++i) { @@ -279,7 +319,6 @@ } }//EMEC Outer - const EMECHVManager& hvManager_EMEC_IN=manager->getEMECHVManager(EMECHVModule::INNER); for (unsigned int iSide=hvManager_EMEC_IN.beginSideIndex();iSide<hvManager_EMEC_IN.endSideIndex();iSide++) { // loop over HV modules for (unsigned int iPhi=hvManager_EMEC_IN.beginPhiIndex();iPhi<hvManager_EMEC_IN.endPhiIndex();iPhi++) { for (unsigned int iSector=hvManager_EMEC_IN.beginSectorIndex();iSector<hvManager_EMEC_IN.endSectorIndex();iSector++) { @@ -289,8 +328,8 @@ for (unsigned int ielec=0;ielec<hvMod.getNumElectrodes();ielec++) { //use hvMod.getNumElectrodes when bug is corrected const EMECHVElectrode& electrode = hvMod.getElectrode(ielec); for (unsigned int iGap=0;iGap<2;iGap++) { //EMEC : 2 gaps, TRY TO FIND AUTOMATICALLY NB OF GAPS - float hv=electrode.voltage(iGap); - float current = electrode.current(iGap); + float hv = hvdata_EMEC_IN.voltage (electrode, iGap); + float current = hvdata_EMEC_IN.current (electrode, iGap); float phi = electrode.getPhi(); m_bec=2; @@ -301,7 +340,7 @@ m_gap = iGap; m_hv = hv; m_current= current; - m_hvline = electrode.hvLineNo(iGap); + m_hvline = hvdata_EMEC_IN.hvLineNo (electrode, iGap); if(m_addcells) { for(unsigned i=0; i<m_hvonlId_map[m_hvline].size(); ++i) { @@ -321,7 +360,6 @@ } }// EMEC Inner - const HECHVManager& hvManager_HEC=manager->getHECHVManager(); float etamax_layer[4]={3.3,3.1,3.1,3.3}; float etamin_layer[4]={1.5,1.5,1.6,1.7}; @@ -343,8 +381,8 @@ for (unsigned int iGap=0;iGap<hvMod.getNumSubgaps();iGap++) {//HEC : 4 gaps, TRY TO FIND AUTOMATICALLY NB OF GAPS const HECHVSubgap& subgap=hvMod.getSubgap(iGap); - float hv = subgap.voltage(); - float current = subgap.current(); + float hv = hvdata_HEC.voltage (subgap); + float current = hvdata_HEC.current (subgap); m_bec = 10+iSampling; m_isPresampler=0; m_eta=eta; @@ -353,7 +391,7 @@ m_gap = iGap; m_hv=hv; m_current=current; - m_hvline = subgap.hvLineNo(); + m_hvline = hvdata_HEC.hvLineNo (subgap); if(m_addcells) { for(unsigned i=0; i<m_hvonlId_map[m_hvline].size(); ++i) { m_barrelec=m_onlId->barrel_ec(m_hvonlId_map[m_hvline][i]); @@ -369,7 +407,6 @@ } }//HECHVManager - const FCALHVManager& hvManager_FCAL=manager->getFCALHVManager(); for (unsigned int iSide=hvManager_FCAL.beginSideIndex();iSide<hvManager_FCAL.endSideIndex();iSide++) { // loop over HV modules float eta_min=3.1,eta_max=4.9; if (iSide==0) { eta_min=-4.9; eta_max=-3.1; } @@ -379,8 +416,6 @@ for (unsigned int iSector=hvManager_FCAL.beginSectorIndex(iSampling);iSector<hvManager_FCAL.endSectorIndex(iSampling);iSector++) { const FCALHVModule& hvMod = hvManager_FCAL.getHVModule(iSide,iSector,iSampling); - //std::cout << " FCAL HVModule side,sampling,sector " << iSide << " " << iSampling << " " << iSector << std::endl; - //std::cout << " HV nominal " << HVnominal << std::endl; float dphi=CaloPhiRange::twopi()/16; if (iSampling==1) dphi=CaloPhiRange::twopi()/8.; @@ -392,8 +427,8 @@ for (unsigned int iLine=0;iLine<hvMod.getNumHVLines();iLine++) { const FCALHVLine& hvline = hvMod.getHVLine(iLine); - float hv = hvline.voltage(); - float current = hvline.current(); + float hv = hvdata_FCAL.voltage (hvline); + float current = hvdata_FCAL.current (hvline); m_bec = 14+iSampling; m_isPresampler=0; m_eta=eta; @@ -402,7 +437,7 @@ m_gap = iLine; m_hv=hv; m_current=current; - m_hvline = hvline.hvLineNo(); + m_hvline = hvdata_FCAL.hvLineNo (hvline); if(m_addcells) { for(unsigned i=0; i<m_hvonlId_map[m_hvline].size(); ++i) { m_barrelec=m_onlId->barrel_ec(m_hvonlId_map[m_hvline][i]); @@ -418,12 +453,17 @@ }//iSampling }//iSide - }//LArHVManager - return StatusCode::SUCCESS; } -std::vector<int> LArHV2Ntuple::GetHVLines(const Identifier& id) { +std::vector<int> LArHV2Ntuple::GetHVLines (const EMBHVManager::EMBHVData& hvdata_EMB, + const EMBPresamplerHVManager::EMBPresamplerHVData& hvdata_EMBPS, + const EMECHVManager::EMECHVData& hvdata_EMEC_OUT, + const EMECHVManager::EMECHVData& hvdata_EMEC_IN, + const EMECPresamplerHVManager::EMECPresamplerHVData& hvdata_EMECPS, + const HECHVManager::HECHVData& hvdata_HEC, + const FCALHVManager::FCALHVData& hvdata_FCAL, + const Identifier& id) { std::set<int> hv; @@ -436,7 +476,7 @@ std::vector<int> LArHV2Ntuple::GetHVLines(const Identifier& id) { unsigned int nelec = cell->getNumElectrodes(); for (unsigned int i=0;i<nelec;i++) { const EMBHVElectrode& electrode = cell->getElectrode(i); - for (unsigned int igap=0;igap<2;igap++) hv.insert(electrode.hvLineNo(igap)); + for (unsigned int igap=0;igap<2;igap++) hv.insert(hvdata_EMB.hvLineNo(electrode, igap)); } } else { // LAr EMEC const EMECDetectorElement* emecElement = dynamic_cast<const EMECDetectorElement*>(m_calodetdescrmgr->get_element(id)); @@ -445,7 +485,12 @@ std::vector<int> LArHV2Ntuple::GetHVLines(const Identifier& id) { unsigned int nelec = cell->getNumElectrodes(); for (unsigned int i=0;i<nelec;i++) { const EMECHVElectrode& electrode = cell->getElectrode(i); - for (unsigned int igap=0;igap<2;igap++) hv.insert(electrode.hvLineNo(igap)); + const EMECHVModule& module = electrode.getModule(); + const EMECHVManager::EMECHVData& hvdata = + module.getWheelIndex() == EMECHVModule::INNER ? + hvdata_EMEC_IN : + hvdata_EMEC_OUT; + for (unsigned int igap=0;igap<2;igap++) hv.insert(hvdata.hvLineNo (electrode, igap)); } } } else if (m_caloId->is_hec(id)) { // LAr HEC @@ -455,7 +500,7 @@ std::vector<int> LArHV2Ntuple::GetHVLines(const Identifier& id) { unsigned int nsubgaps = cell->getNumSubgaps(); for (unsigned int igap=0;igap<nsubgaps;igap++) { const HECHVSubgap& subgap = cell->getSubgap(igap); - hv.insert(subgap.hvLineNo()); + hv.insert(hvdata_HEC.hvLineNo (subgap)); } } else if (m_caloId->is_fcal(id)) { // LAr FCAL const FCALDetectorElement* fcalElement = dynamic_cast<const FCALDetectorElement*>(m_calodetdescrmgr->get_element(id)); @@ -464,7 +509,7 @@ std::vector<int> LArHV2Ntuple::GetHVLines(const Identifier& id) { unsigned int nlines = tile->getNumHVLines(); for (unsigned int i=0;i<nlines;i++) { const FCALHVLine* line = tile->getHVLine(i); - if (line) hv.insert(line->hvLineNo()); + if (line) hv.insert(hvdata_FCAL.hvLineNo (*line)); } } else if (m_caloId->is_em(id) && m_caloId->sampling(id)==0) { // Presamplers if (abs(m_caloId->em_idHelper()->barrel_ec(id))==1) { @@ -472,13 +517,13 @@ std::vector<int> LArHV2Ntuple::GetHVLines(const Identifier& id) { if (!embElement) std::abort(); const EMBCellConstLink cell = embElement->getEMBCell(); const EMBPresamplerHVModule& hvmodule = cell->getPresamplerHVModule(); - for (unsigned int igap=0;igap<2;igap++) hv.insert(hvmodule.hvLineNo(igap)); + for (unsigned int igap=0;igap<2;igap++) hv.insert(hvdata_EMBPS.hvLineNo (hvmodule, igap)); } else { const EMECDetectorElement* emecElement = dynamic_cast<const EMECDetectorElement*>(m_calodetdescrmgr->get_element(id)); if (!emecElement) std::abort(); const EMECCellConstLink cell = emecElement->getEMECCell(); const EMECPresamplerHVModule& hvmodule = cell->getPresamplerHVModule (); - for (unsigned int igap=0;igap<2;igap++) hv.insert(hvmodule.hvLineNo(igap)); + for (unsigned int igap=0;igap<2;igap++) hv.insert(hvdata_EMECPS.hvLineNo (hvmodule, igap)); } } diff --git a/LArCalorimeter/LArCondUtils/src/LArHV2Ntuple.h b/LArCalorimeter/LArCondUtils/src/LArHV2Ntuple.h index 0397f29f774a52f201ff43a7415caf962d413cbc..69a15118fda3fbaea1a5852d7f0b8b34464b568c 100644 --- a/LArCalorimeter/LArCondUtils/src/LArHV2Ntuple.h +++ b/LArCalorimeter/LArCondUtils/src/LArHV2Ntuple.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // TheLArHV2Ntuple.h @@ -16,7 +16,15 @@ #include "StoreGate/StoreGateSvc.h" #include "GaudiKernel/ITHistSvc.h" #include "StoreGate/ReadCondHandleKey.h" +#include "StoreGate/CondHandleKeyArray.h" #include "LArCabling/LArOnOffIdMapping.h" +#include "LArRecConditions/LArHVIdMapping.h" +#include "LArHV/EMBHVManager.h" +#include "LArHV/EMECHVManager.h" +#include "LArHV/EMBPresamplerHVManager.h" +#include "LArHV/EMECPresamplerHVManager.h" +#include "LArHV/HECHVManager.h" +#include "LArHV/FCALHVManager.h" #include "TTree.h" @@ -25,6 +33,7 @@ class LArOnlineID; class Identifier; class HWIdentifier; class CaloDetDescrManager; +class CondAttrListCollection; class LArHV2Ntuple : public AthAlgorithm { public: @@ -32,18 +41,21 @@ class LArHV2Ntuple : public AthAlgorithm { /** Standard Athena-Algorithm Constructor */ LArHV2Ntuple(const std::string& name, ISvcLocator* pSvcLocator); /** Default Destructor */ - ~LArHV2Ntuple(); + virtual ~LArHV2Ntuple(); /** standard Athena-Algorithm method */ - StatusCode initialize(); + virtual StatusCode initialize() override; /** standard Athena-Algorithm method */ - StatusCode execute(); - /** standard Athena-Algorithm method */ - StatusCode finalize(){return StatusCode::SUCCESS;} + virtual StatusCode execute() override; private: SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this, "OnOffMap", "LArOnOffIdMap", "SG key for mapping object"}; + SG::ReadCondHandleKey<LArHVIdMapping> m_hvCablingKey + {this, "LArHVIdMapping", "LArHVIdMap", "SG key for HV ID mapping"}; + SG::ReadCondHandleKeyArray<CondAttrListCollection> m_DCSFolderKeys + { this, "DCSFolderNames", {"/LAR/DCS/HV/BARREl/I16", "/LAR/DCS/HV/BARREL/I8"}, "DCS folders with HV values"}; + //--------------------------------------------------- // Member variables @@ -76,6 +88,13 @@ class LArHV2Ntuple : public AthAlgorithm { const DataHandle<CaloDetDescrManager> m_calodetdescrmgr; std::map<int, std::vector<HWIdentifier> >m_hvonlId_map; - std::vector<int> GetHVLines(const Identifier& id) ; + std::vector<int> GetHVLines (const EMBHVManager::EMBHVData& hvdata_EMB, + const EMBPresamplerHVManager::EMBPresamplerHVData& hvdata_EMBPS, + const EMECHVManager::EMECHVData& hvdata_EMEC_OUT, + const EMECHVManager::EMECHVData& hvdata_EMEC_IN, + const EMECPresamplerHVManager::EMECPresamplerHVData& hvdata_EMECPS, + const HECHVManager::HECHVData& hvdata_HEC, + const FCALHVManager::FCALHVData& hvdata_FCAL, + const Identifier& id) ; }; #endif diff --git a/LArCalorimeter/LArCondUtils/src/LArHVPathologyDbAlg.cxx b/LArCalorimeter/LArCondUtils/src/LArHVPathologyDbAlg.cxx index ececa8c4aaa241eac7d78dae43216f1340f41bc2..4c605b444f144499ad355938447b39e565f404af 100644 --- a/LArCalorimeter/LArCondUtils/src/LArHVPathologyDbAlg.cxx +++ b/LArCalorimeter/LArCondUtils/src/LArHVPathologyDbAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArHVPathologyDbAlg.h" @@ -27,6 +27,7 @@ #include "LArHV/HECHVSubgap.h" #include "LArReadoutGeometry/FCALTile.h" #include "LArHV/FCALHVLine.h" +#include "GaudiKernel/ThreadLocalContext.h" #include <fstream> #include <cstdlib> @@ -117,6 +118,8 @@ StatusCode LArHVPathologyDbAlg::initialize() return StatusCode::FAILURE; } + ATH_CHECK( m_hvCablingKey.initialize() ); + return sc; } @@ -124,13 +127,15 @@ StatusCode LArHVPathologyDbAlg::execute() { msg(MSG::INFO) <<" in execute()" <<endmsg; - int nevt = getContext().eventID().event_number(); + const EventContext& ctx = Gaudi::Hive::currentContext(); + + int nevt = ctx.eventID().event_number(); if(m_writeCondObjs && nevt==1) { msg(MSG::INFO) << "Creating conditions objects" << endmsg; // Create cond objects - if(!createCondObjects().isSuccess()) { + if(!createCondObjects(ctx).isSuccess()) { msg(MSG::ERROR) << "Could not create cond objects " << endmsg; m_writeCondObjs = false; return StatusCode::FAILURE; @@ -138,7 +143,7 @@ StatusCode LArHVPathologyDbAlg::execute() } // Dump cond objects - StatusCode sc = printCondObjects(); + StatusCode sc = printCondObjects (ctx); if(!sc.isSuccess()) { msg(MSG::ERROR) << "Could not print out cond objects" << endmsg; return sc; @@ -166,7 +171,7 @@ StatusCode LArHVPathologyDbAlg::stop() return sc; } -StatusCode LArHVPathologyDbAlg::createCondObjects() +StatusCode LArHVPathologyDbAlg::createCondObjects (const EventContext & ctx) { msg(MSG::INFO) <<" in createCondObjects() " <<endmsg; @@ -174,6 +179,8 @@ StatusCode LArHVPathologyDbAlg::createCondObjects() msg(MSG::INFO) << "EMB Pathologies already in SG, skipping " <<endmsg; } else { + SG::ReadCondHandle<LArHVIdMapping> hvIdMapping (m_hvCablingKey, ctx); + // Read input file and construct LArHVPathologiesDb for given folder std::ifstream infile; infile.open(m_inpFile.value().c_str()); @@ -229,7 +236,7 @@ StatusCode LArHVPathologyDbAlg::createCondObjects() HWIdentifier hwid = m_laronline_id->channel_Id(bec,pos_neg,FT,slot,channel); Identifier id = m_cablingService->cnvToIdentifier( hwid); cellID = (unsigned int)(id.get_identifier32().get_compact()); - elecList=getElectInd(id,hvModule,hvLine); + elecList=getElectInd(**hvIdMapping, id,hvModule,hvLine); msg(MSG::INFO) << " cellId , elecList size " << cellID << " " << elecList.size() << endmsg; } for (unsigned int i=0;i<elecList.size();i++) { @@ -272,9 +279,12 @@ StatusCode LArHVPathologyDbAlg::createCondObjects() return StatusCode::SUCCESS; } -StatusCode LArHVPathologyDbAlg::printCondObjects() +StatusCode LArHVPathologyDbAlg::printCondObjects (const EventContext& ctx) { msg(MSG::INFO) <<" in printCondObjects() " <<endmsg; + + SG::ReadCondHandle<LArHVIdMapping> hvIdMapping (m_hvCablingKey, ctx); + std::ofstream *fout=0; const AthenaAttributeList* attrlist; StatusCode sc = detStore()->retrieve(attrlist,m_folder); @@ -302,7 +312,7 @@ StatusCode LArHVPathologyDbAlg::printCondObjects() } else { msg(MSG::INFO) << "Got pathology for cell ID: " << electPath.cellID << endmsg; HWIdentifier hwid = m_cablingService->createSignalChannelID(Identifier32(electPath.cellID)); - int HVLine=getHVline(Identifier(electPath.cellID),electPath.electInd); + int HVLine=getHVline(**hvIdMapping,Identifier(electPath.cellID),electPath.electInd); if(HVLine<0) { msg(MSG::ERROR) << "No HVline for cell "<<electPath.cellID<< endmsg; } else { @@ -340,7 +350,11 @@ StatusCode LArHVPathologyDbAlg::registerCondObjects() return sc; } -std::vector<unsigned int> LArHVPathologyDbAlg::getElectInd(const Identifier & id,unsigned int module, unsigned int line) +std::vector<unsigned int> +LArHVPathologyDbAlg::getElectInd(const LArHVIdMapping& hvIdMapping, + const Identifier & id, + unsigned int module, + unsigned int line) { std::vector<unsigned int> list; @@ -356,7 +370,7 @@ std::vector<unsigned int> LArHVPathologyDbAlg::getElectInd(const Identifier & id for (unsigned int i=0;i<nelec;i++) { const EMBHVElectrode& electrode = cell->getElectrode(i); for (unsigned int igap=0;igap<2;igap++) { - if (electrode.hvLineNo(igap)==HVline) { + if (electrode.hvLineNo(igap, &hvIdMapping)==HVline) { list.push_back(2*i+igap); } } @@ -371,7 +385,7 @@ std::vector<unsigned int> LArHVPathologyDbAlg::getElectInd(const Identifier & id for (unsigned int i=0;i<nelec;i++) { const EMECHVElectrode& electrode = cell->getElectrode(i); for (unsigned int igap=0;igap<2;igap++) { - if (electrode.hvLineNo(igap)==HVline) { + if (electrode.hvLineNo(igap, &hvIdMapping)==HVline) { list.push_back(2*i+igap); } } @@ -384,7 +398,7 @@ std::vector<unsigned int> LArHVPathologyDbAlg::getElectInd(const Identifier & id const EMBCellConstLink cell = embElement->getEMBCell(); const EMBPresamplerHVModule& hvmodule = cell->getPresamplerHVModule (); for (unsigned int igap=0;igap<2;igap++) { - if (hvmodule.hvLineNo(igap)==HVline) { + if (hvmodule.hvLineNo(igap, &hvIdMapping)==HVline) { list.push_back(igap); } } @@ -396,7 +410,7 @@ std::vector<unsigned int> LArHVPathologyDbAlg::getElectInd(const Identifier & id const EMECCellConstLink cell = emecElement->getEMECCell(); const EMECPresamplerHVModule& hvmodule = cell->getPresamplerHVModule (); for (unsigned int igap=0;igap<2;igap++) { - if (hvmodule.hvLineNo(igap)==HVline) { + if (hvmodule.hvLineNo(igap, &hvIdMapping)==HVline) { list.push_back(igap); } } @@ -410,7 +424,7 @@ std::vector<unsigned int> LArHVPathologyDbAlg::getElectInd(const Identifier & id unsigned int nsubgaps = cell->getNumSubgaps(); for (unsigned int i=0;i<nsubgaps;i++) { const HECHVSubgap& subgap = cell->getSubgap(i); - if (subgap.hvLineNo()==HVline) { + if (subgap.hvLineNo(&hvIdMapping)==HVline) { list.push_back(i); } } @@ -424,7 +438,7 @@ std::vector<unsigned int> LArHVPathologyDbAlg::getElectInd(const Identifier & id for (unsigned int i=0;i<nlines;i++) { const FCALHVLine* line2 = tile->getHVLine(i); if(line2) { - if (line2->hvLineNo()==HVline) { + if (line2->hvLineNo(&hvIdMapping)==HVline) { list.push_back(i); } } @@ -436,7 +450,9 @@ std::vector<unsigned int> LArHVPathologyDbAlg::getElectInd(const Identifier & id } -int LArHVPathologyDbAlg::getHVline(const Identifier & id, short unsigned int ElectInd) +int LArHVPathologyDbAlg::getHVline(const LArHVIdMapping& hvIdMapping, + const Identifier & id, + short unsigned int ElectInd) { unsigned int igap, ielec; @@ -453,7 +469,7 @@ int LArHVPathologyDbAlg::getHVline(const Identifier & id, short unsigned int Ele msg(MSG::ERROR) << "Wrong electrode number " << ielec << " for cell "<< id.get_identifier32().get_compact() <<endmsg; return -1; } else { - return cell->getElectrode(ielec).hvLineNo(igap); + return cell->getElectrode(ielec).hvLineNo(igap, &hvIdMapping); } } } @@ -468,7 +484,7 @@ int LArHVPathologyDbAlg::getHVline(const Identifier & id, short unsigned int Ele msg(MSG::ERROR) << "Wrong electrode number " << ielec << " for cell "<< id.get_identifier32().get_compact() <<endmsg; return -1; } else { - return cell->getElectrode(ielec).hvLineNo(igap); + return cell->getElectrode(ielec).hvLineNo(igap, &hvIdMapping); } } } @@ -481,7 +497,7 @@ int LArHVPathologyDbAlg::getHVline(const Identifier & id, short unsigned int Ele msg(MSG::ERROR) << "Wrong igap "<<ElectInd<<" for EMBPS cell "<<id.get_identifier32().get_compact() <<endmsg; return -1; } else { - return hvmodule.hvLineNo(ElectInd); + return hvmodule.hvLineNo(ElectInd, &hvIdMapping); } } } @@ -494,7 +510,7 @@ int LArHVPathologyDbAlg::getHVline(const Identifier & id, short unsigned int Ele msg(MSG::ERROR) << "Wrong igap "<<ElectInd<<" for EMECPS cell "<<id.get_identifier32().get_compact() <<endmsg; return -1; } else { - return hvmodule.hvLineNo(ElectInd); + return hvmodule.hvLineNo(ElectInd, &hvIdMapping); } } } @@ -508,7 +524,7 @@ int LArHVPathologyDbAlg::getHVline(const Identifier & id, short unsigned int Ele msg(MSG::ERROR) << "Wrong igap "<<ElectInd<<" for HEC cell "<<id.get_identifier32().get_compact() <<endmsg; return -1; } else { - return cell->getSubgap(ElectInd).hvLineNo(); + return cell->getSubgap(ElectInd).hvLineNo(&hvIdMapping); } } } @@ -523,7 +539,7 @@ int LArHVPathologyDbAlg::getHVline(const Identifier & id, short unsigned int Ele } else { const FCALHVLine* line2 = tile->getHVLine(ElectInd); if(line2) { - return line2->hvLineNo(); + return line2->hvLineNo(&hvIdMapping); } else { msg(MSG::ERROR) << "Do not have HVLine for "<<ElectInd<<" for FCAL cell "<<id.get_identifier32().get_compact() <<endmsg; return -1; diff --git a/LArCalorimeter/LArCondUtils/src/LArHVPathologyDbAlg.h b/LArCalorimeter/LArCondUtils/src/LArHVPathologyDbAlg.h index 043209796780498ba579176cc1a8e2d40327d39c..2446378512cf3d3dd34d108a3b5babe6c2f8267e 100644 --- a/LArCalorimeter/LArCondUtils/src/LArHVPathologyDbAlg.h +++ b/LArCalorimeter/LArCondUtils/src/LArHVPathologyDbAlg.h @@ -1,11 +1,13 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef LARCONDUTILS_LARHVPATHOLOGYDBALG_H #define LARCONDUTILS_LARHVPATHOLOGYDBALG_H #include "AthenaBaseComps/AthAlgorithm.h" +#include "LArRecConditions/LArHVIdMapping.h" +#include "StoreGate/ReadCondHandleKey.h" #include "GaudiKernel/ToolHandle.h" class IIOVRegistrationSvc; @@ -31,11 +33,13 @@ class LArHVPathologyDbAlg : public AthAlgorithm StatusCode stop(); private: - StatusCode createCondObjects(); - StatusCode printCondObjects(); + StatusCode createCondObjects (const EventContext& ctx); + StatusCode printCondObjects (const EventContext& ctx); StatusCode registerCondObjects(); - std::vector<unsigned int> getElectInd(const Identifier& id, unsigned int module, unsigned int line); - int getHVline(const Identifier& id, short unsigned int ElectInd); + std::vector<unsigned int> getElectInd(const LArHVIdMapping& hvIdMapping, + const Identifier& id, unsigned int module, unsigned int line); + int getHVline(const LArHVIdMapping& hvIdMapping, + const Identifier& id, short unsigned int ElectInd); BooleanProperty m_writeCondObjs; StringProperty m_inpFile; @@ -57,6 +61,8 @@ class LArHVPathologyDbAlg : public AthAlgorithm const LArFCAL_ID* m_larfcal_id; const LArOnlineID* m_laronline_id; + SG::ReadCondHandleKey<LArHVIdMapping> m_hvCablingKey + {this, "LArHVIdMapping", "LArHVIdMap", "SG key for HV ID mapping"}; }; #endif diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.cxx index 479ce1c36b02e631ce48851d4fa2c9c64bcd367c..1f4e0fdc8aa129a68feda511820f6a67926daaeb 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.cxx +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "AccMap.h" @@ -43,7 +43,6 @@ AccMap::AccMap() //fileLocation=larLocation+"/calo_data/"+filename; fileLocation=larLocation+"/"+filename; #endif - // std::cout << " try to open map " << fileLocation << std::endl; CurrMap* cm = new CurrMap(fileLocation,xnorm); int code=10*ifold+iregion; m_theMap[code]=cm; @@ -66,7 +65,6 @@ AccMap::AccMap() //fileLocation=larLocation+"/calo_data/"+filename; fileLocation=larLocation+"/"+filename; #endif - // std::cout << " try to open map " << fileLocation << std::endl; CurrMap* cm = new CurrMap(fileLocation,xnorm); int code=10*(20+istr)+iregion; m_theMap[code]=cm; @@ -98,7 +96,6 @@ CurrMap* AccMap::GetMap(int ifold, int region, int sampling, int eta) const CurrMap* AccMap::GetMap(int ifold, int ielecregion) const { const int code=10*ifold+ielecregion; - // std::cout << " code is " << code << std::endl; const auto mapIter = m_theMap.find(code); if (mapIter != m_theMap.end()) return mapIter->second; diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/CurrMap.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/CurrMap.cxx index 8279a740dc654e7f042d83b6a188c5c58f73d079..db032a17977447c1335876766fbdd998ff0c7665 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/CurrMap.cxx +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/CurrMap.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "CurrMap.h" @@ -39,8 +39,6 @@ CurrMap::CurrMap(std::string filename,double xnorm) if(m_nx>0 && m_ny>0 && m_nx<10000 && m_ny<10000) {//coverity issue. This is a tainted variable protection, 10000 can be changed if required. m_dx = (m_xmax-m_xmin)/((float) m_nx); m_dy = (m_ymax-m_ymin)/((float) m_ny); - //std::cout << " nx,xmin,xmax,ny,ymin,ymax " << m_nx << " " << m_xmin << " " << m_xmax << " " - // << m_ny << " " << m_ymin << " " << m_ymax << std::endl; m_gap = new float[m_nx*m_ny]; m_curr0 = new float[m_nx*m_ny]; @@ -66,7 +64,6 @@ CurrMap::CurrMap(std::string filename,double xnorm) m_curr0[iy*m_nx+ix]=cur1/m_norm; m_curr1[iy*m_nx+ix]=cur2/m_norm; m_curr2[iy*m_nx+ix]=cur3/m_norm; - // std::cout << "read " << ix << " " << iy << " " << m_curr0[iy*m_nx+ix] << std::endl; } } } diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalculator.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalculator.cxx index 9e763dc55bc15b45934a5368a3943c24c6c6c861..e693994b06ca3a40420c00f28ed50cda9b6fa8eb 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalculator.cxx +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalculator.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // The Cell Identifier for the EM Barrel readout cells @@ -468,16 +468,9 @@ G4bool LArBarrelCalculator::Process(const G4Step* step, std::vector<LArHitData>& // HV extrapolation double current; double hv=m_hv[ipm][ielec][ieta][iside]; - // std::cout << " etaBin,phiBin " << etaBin << " " << phiBin << std::endl; - // std::cout << " ipm,ielec,ieta,iside " << ipm << " " << ielec << " " << ieta - // << " " << iside << std::endl; - // std::cout << " hv " << hv << std::endl; - // std::cout << " current0,current1,current2 " << current0 << " " << current1 - // << " " << current2 << std::endl; if (hv>1995.) current=current0; else if (hv>5.) current=ScaleHV(hv,current0,current1,current2); else current=0.; - // std::cout << " current " << current << std::endl; // extrapolation for non nominal gap (allows to include sagging effect) // i ~ (gap/gap2)**1.3 @@ -699,6 +692,7 @@ void LArBarrelCalculator::InitHV() const LArHVManager *manager = nullptr; if (pDetStore->retrieve(manager)==StatusCode::SUCCESS) { const EMBHVManager& hvManager=manager->getEMBHVManager(); + const EMBHVManager::EMBHVData hvdata = hvManager.getData(); ATH_MSG_INFO(" got HV Manager "); // loop over HV modules for (unsigned int iSide=0;iSide<2;iSide++) { @@ -710,7 +704,7 @@ void LArBarrelCalculator::InitHV() const EMBHVElectrode& electrode = hvMod.getElectrode(ielec); unsigned jElec = ielec+32*iSector+64*iPhi; for (unsigned int iGap=0;iGap<2;iGap++) { - double hv = electrode.voltage(iGap); + double hv = hvdata.voltage (electrode, iGap); ATH_MSG_DEBUG(" iSide,jElec,iEta,iGap,hv " << iSide << " " << jElec << " " << iEta << " " << iGap << " " << hv); if (hv>-999.) m_hv[iSide][jElec][iEta][iGap] = hv; } diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeAbsorbers.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeAbsorbers.cxx index 214e155fe6151ca23da0e1f8e458f19f0b6a930d..03d0946776798c3745be91d676f96ab5de8d5b0b 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeAbsorbers.cxx +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeAbsorbers.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArCoudeAbsorbers.h" @@ -36,19 +36,11 @@ LArCoudeAbsorbers::LArCoudeAbsorbers(std::string strDetector) } m_filled=false; - // std::cout << " *** List of Fold Absorbers " << std::endl; for (int stackid=0; stackid<15; stackid++) { for (int cellid=0; cellid<1024; cellid++) { m_xcent[cellid][stackid] = XCentCoude(stackid,cellid); m_ycent[cellid][stackid] = YCentCoude(stackid,cellid); m_phirot[cellid][stackid] = PhiRot(stackid,cellid); - // std::cout << "cell,stack,x,y,phirot " - // << cellid << " " - // << stackid << " " - // << m_xcent[cellid][stackid] << " " - // << m_ycent[cellid][stackid] << " " - // << m_phirot[cellid][stackid] - // <<std::endl; } } m_filled=true; diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeElectrodes.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeElectrodes.cxx index 01b24c6833f8a736c986f668e663faeb5647f19d..7e25af5ef357f2ed154ce2f08edfd16a9d38c16a 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeElectrodes.cxx +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeElectrodes.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArCoudeElectrodes.h" @@ -35,19 +35,11 @@ LArCoudeElectrodes::LArCoudeElectrodes(std::string strDetector) } } m_filled=false; - // std::cout << " *** List of fold electrodes " << std::endl; for (int stackid=0; stackid<15; stackid++) { for (int cellid=0; cellid<1024; cellid++) { m_xcent[cellid][stackid] = XCentCoude(stackid,cellid); m_ycent[cellid][stackid] = YCentCoude(stackid,cellid); m_phirot[cellid][stackid] = PhiRot(stackid,cellid); - // std::cout << "cell,stack,x,y,phirot " - // << cellid << " " - // << stackid << " " - // << m_xcent[cellid][stackid] << " " - // << m_ycent[cellid][stackid] << " " - // << m_phirot[cellid][stackid] - // <<std::endl; } } diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightAbsorbers.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightAbsorbers.cxx index 56db63f5ab60383d0322dfdea69c24b8aa9bb6b3..484ddd7ac8d2c8fa611a74957b890636b7971912 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightAbsorbers.cxx +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightAbsorbers.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArStraightAbsorbers.h" @@ -36,7 +36,6 @@ LArStraightAbsorbers::LArStraightAbsorbers(std::string strDetector) strDetector+"::LAr::EMB::ThinAbs::Straight"); } m_filled=false; - // std::cout << " *** List of Straight absorbers " << std::endl; for (int stackid=0; stackid<14; stackid++) { for (int cellid=0; cellid<1024; cellid++) { m_xcent[cellid][stackid] = XCentAbs(stackid,cellid); @@ -45,15 +44,6 @@ LArStraightAbsorbers::LArStraightAbsorbers(std::string strDetector) m_cosu[cellid][stackid] = cos(slant); m_sinu[cellid][stackid] = sin(slant); m_halflength[cellid][stackid] = HalfLength(stackid,cellid); - // std::cout << "cell,stack,x,y,slant,HalfL " - // << cellid << " " - // << stackid << " " - // << m_xcent[cellid][stackid] << " " - // << m_ycent[cellid][stackid] << " " - // << slant << " " - // << m_halflength[cellid][stackid] - // <<std::endl; - } } m_filled=true; diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightElectrodes.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightElectrodes.cxx index b55255902d57e430fb30dc214e379016c743e210..a7f5285040985b5f67d8e281b83b7a07b49ccf04 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightElectrodes.cxx +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightElectrodes.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArStraightElectrodes.h" @@ -34,7 +34,6 @@ LArStraightElectrodes::LArStraightElectrodes(std::string strDetector) s_theElectrodes=new PhysicalVolumeAccessor(strDetector+"::LAr::EMB::STAC", strDetector+"::LAr::EMB::Electrode::Straight"); } - // std::cout << "*** List of StraightElectrodes " << s_theElectrodes << std::endl; m_filled=false; for (int stackid=0; stackid<14; stackid++) { for (int cellid=0; cellid<1024; cellid++) { @@ -44,14 +43,6 @@ LArStraightElectrodes::LArStraightElectrodes(std::string strDetector) m_cosu[cellid][stackid] = cos(slant); m_sinu[cellid][stackid] = sin(slant); m_halflength[cellid][stackid] = HalfLength(stackid,cellid); - // std::cout << "cell,stack,x,y,slant,HalfL " - // << cellid << " " - // << stackid << " " - // << m_xcent[cellid][stackid] << " " - // << m_ycent[cellid][stackid] << " " - // << slant << " " - // << m_halflength[cellid][stackid] - // <<std::endl; } } m_filled=true; diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/MapEta.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/MapEta.cxx index e66cb189387029fb06906ba14634760a9d78d71c..f62105b1cc6e075d1621ad8e0027e6f37371fbbb 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/MapEta.cxx +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/MapEta.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "MapEta.h" @@ -70,7 +70,6 @@ void MapEta::Initialize(int isampling) { in>>m_nx>>m_xmin>>m_xmax>>m_ny>>m_ymin>>m_ymax; if(m_nx>0 && m_ny>0 && m_nx<10000 && m_ny<10000){//coverity issue. This is a tainted variable protection, 10000 can be changed if required. - //std::cout<<"nx"<<";"<<"ny="<<m_nx<<";"<<m_ny<<std::endl; m_deltax=(m_xmax-m_xmin)/((float) m_nx); m_deltay=(m_ymax-m_ymin)/((float) m_ny); // what is written as xmax in the map is x of last point + delta x diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/PhysicalVolumeAccessor.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/PhysicalVolumeAccessor.cxx index 41a9f28d524433e890678d1090f16a047ed736f0..621e3c05a6cef5bf9bff63e779002c5d9d8342fd 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/PhysicalVolumeAccessor.cxx +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/PhysicalVolumeAccessor.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "PhysicalVolumeAccessor.h" @@ -16,8 +16,6 @@ G4LogicalVolume* PhysicalVolumeAccessor::GetLV(std::string name) if (name==lname) return (lvs->operator[](i)); } - // std::cout<<"PhysicalVolumeAccessor::GetLV Warning!!! Volume "<<name - // <<" not found!!! returning nullptr"<<std::endl; return nullptr; } @@ -48,8 +46,6 @@ const G4VPhysicalVolume* PhysicalVolumeAccessor::GetPhysicalVolume(int icopy) co return physVolIter->second; else { - // std::cout<<"Physical Volume copy "<<icopy<<" not found in" - // <<m_theLogicalVolume->GetName()<<"!!! return nullptr"<<std::endl; return nullptr; } } diff --git a/LArCalorimeter/LArG4/LArG4EC/src/EnergyCalculator.cc b/LArCalorimeter/LArG4/LArG4EC/src/EnergyCalculator.cc index 416f9b29703687eca07ef8e238af823149ba0940..591dd6675f1b3b7fbeb3622d0abd1ef79632bbe9 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/EnergyCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/EnergyCalculator.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // EnergyCalculator @@ -318,7 +318,6 @@ StatusCode EnergyCalculator::initialize() const std::string A0 = A0STR.str(); const std::string colName = "ZIW" + A0; ziw[i] = (*emecSamplingSep)[0]->getDouble(colName)*CLHEP::cm; - // cout<<"i,ziw= "<<i<<" "<<ziw[i]<<endl; } for(int i = 0; i < 44; i ++){ std::ostringstream A0STR; @@ -326,7 +325,6 @@ StatusCode EnergyCalculator::initialize() const std::string A0 = A0STR.str(); const std::string colName = "ZSEP12" + A0; zsep12[i] = (*emecSamplingSep)[0]->getDouble(colName)*CLHEP::cm; - // cout<<"i,zsep12= "<<i<<" "<<zsep12[i]<<endl; } for(int i = 0; i < 22; i ++){ std::ostringstream A0STR; @@ -334,7 +332,6 @@ StatusCode EnergyCalculator::initialize() const std::string A0 = A0STR.str(); const std::string colName = "ZSEP23" + A0; zsep23[i] = (*emecSamplingSep)[0]->getDouble(colName)*CLHEP::cm; - // cout<<"i,zsep23= "<<i<<" "<<zsep23[i]<<endl; } m_ElectrodeFanHalfThickness = LArWheelCalculator::GetFanHalfThickness(LArG4::InnerElectrodWheel); @@ -544,9 +541,6 @@ G4double EnergyCalculator::CalculateChargeCollection( G4double Barret_PhiStart) const // **************************************************************************** { - // std::cout<<"*** CalculateChargeCollection is called, a_energy="<<a_energy - // <<std::endl; - ATH_MSG_DEBUG("starting CalculateChargeCollection:" << "a_energy = " << a_energy << ", startPoint = " << MSG_VECTOR(a_startPoint) @@ -892,30 +886,22 @@ G4bool EnergyCalculator::FindIdentifier_Default( if(pinLocal.z() > lwc()->GetWheelThickness()-zEndofC9e19 && pinLocal.z() <= lwc()->GetWheelThickness()-zSepofC9e18 && pinLocal.perp() < r0aofC9e18 ) { - // G4cout<<" Skip of Hit in aC9e18"<<" r="<<pinLocal.perp()<< - // " zinWheel="<<pinLocal.z()<<G4endl; validhit=false; } if(pinLocal.z() > lwc()->GetWheelThickness()-zSepofC9e18 && pinLocal.perp() < r0cofC9e18+txofC9e18*(pinLocal.z()-(lwc()->GetWheelThickness()-zSepofC9e18))){ - // G4cout<<" Skip of Hit in cC9e18"<<" r="<<pinLocal.perp()<< - // " zinWheel="<<pinLocal.z()<<G4endl; validhit=false; } break; case 19: if(pinLocal.z() > lwc()->GetWheelThickness()-zEndofC9e19) { - // G4cout<<" Skip of Hit in z crack C9e19"<<" r="<<pinLocal.perp()<< - // " zinWheel="<<pinLocal.z()<<G4endl; validhit=false; } if(DistanceToEtaLine( pforcell, eta_mid) < DistMinatEdgeinCrack) { - // G4cout<<" Skip of Hit in eta crack of C9e19"<< - // " r="<<pinLocal.perp()<< " zinWheel="<<pinLocal.z()<<G4endl; validhit=false; } break; @@ -998,18 +984,11 @@ G4bool EnergyCalculator::FindIdentifier_Default( if(cnew >= 0 && cnew <= 10 ){ - /* G4cout<<" edep in HV bus: old:comp="<<c+1<<" sampl="<<sampling<< - " eta="<<etaBin<<" reg="<<region - <<G4endl;*/ - c=cnew; compartment = c + 1; sampling = s_geometry[c].sampling; region = s_geometry[c].region; etaBin = G4int(eta * s_geometry[c].etaScale - s_geometry[c].etaOffset); - /* G4cout<<" edep in HV bus: new:comp="<<c+1<<" sampl="<<sampling<< - " eta="<<etaBin<<" reg="<<region - <<G4endl;*/ } //=== end of edge and HV bus treatment================ diff --git a/LArCalorimeter/LArG4/LArG4EC/src/GetCurrent1.cc b/LArCalorimeter/LArG4/LArG4EC/src/GetCurrent1.cc index f668a8e15b57ed66523bb0a1f62ed31f36c40b43..dbef82c228787cc386f92af324d5bbb7391cd4f0 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/GetCurrent1.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/GetCurrent1.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include <cassert> @@ -37,7 +37,6 @@ G4int LArG4::EC::EnergyCalculator::_getIRlayerA(G4double fold_angle_deg) const { break; } } - //std::cout << "\tirlayer: " << irlayer << ", R " << R << std::endl; assert(irlayer >= 0 && irlayer < n_layers - 1); return irlayer; } @@ -69,7 +68,6 @@ G4double LArG4::EC::EnergyCalculator::_interpolateCurrentSubStep1(G4double rfor const G4double a_e = elc()->AmplitudeOfSurface(Pe, side_dte, Pe_fan); const G4double a_a = lwc()->AmplitudeOfSurface(Pa, side_dta, Pa_fan); - //std::cout << "\ta_e: " << a_e << ", a_a: " << a_a << std::endl; const G4double x_e = fabs(Pe.x() - a_e); const G4double x_a = fabs(Pa.x() - a_a); @@ -87,7 +85,6 @@ G4double LArG4::EC::EnergyCalculator::_interpolateCurrentSubStep1(G4double rfor // get relative y coordinate G4double yratio = ((side > 0)? x_e: x_a) / (x_e + x_a); - //std::cout << "\tyratio: " << yratio << std::endl; if(yratio <= 0.) yratio = 0.00001; // pull the point into the gap if it wouldn't be there; else if(yratio >= 1.) yratio = 0.99999; // this may happen bec.G4 does not grantee that the full @@ -100,11 +97,9 @@ G4double LArG4::EC::EnergyCalculator::_interpolateCurrentSubStep1(G4double rfor WheelGeometry wg; SetHalfWave(shift + vmap[2], wg); - //std::cout << "\tPointFoldMapArea: " << PointFoldMapArea << ", SetHalfWave(" << shift + vmap[2] << ")" << std::endl; G4double Ylimits[4]; SetYlimitsofPhigapinFieldMap(irlayer, wg, Ylimits); //on the lower layer - //std::cout << "\tFieldmap limits: " << Ylimits[0] << " " << Ylimits[1] << " " << Ylimits[2] << " " << Ylimits[3] << std::endl; G4double pos_low = 0.; if(side < 0) pos_low = Ylimits[0] * (1. - yratio) + Ylimits[1] * yratio; else if(side > 0) pos_low = Ylimits[2] * (1. - yratio) + Ylimits[3] * yratio; @@ -125,32 +120,6 @@ G4double LArG4::EC::EnergyCalculator::_interpolateCurrentSubStep1(G4double rfor G4double LArG4::EC::EnergyCalculator::GetCurrent1(const G4ThreeVector &P1, const G4ThreeVector &P2, G4double edep) const { - /* - FILE *F = fopen("test1.dat", "w"); - if(F == 0) abort(); - G4ThreeVector a(0., 1200., 0.); - for(double z = 0; z <= WheelThickness; z += 0.1){ - fprintf(F, "%f", z); - // for(double x = -20.; x <= 20.; x += 1.){ - // a[0] = x; - a[2] = z; - // std::cout << "(" << z << ", " << x << ") " << DistanceToTheNeutralFibre(a) << std::endl; - for(int s = -1; s <= 1; s ++){ - // std::cout << "\t" << s << " " << elc()->AmplitudeOfSurface(a, s) << std::endl; - fprintf(F, " %f", elc()->AmplitudeOfSurface(a, s)); - } - // } - fprintf(F, "\n"); - } - fclose(F); - - abort(); - */ - - //std::cout << "GetCurrent1 -------------------------------------------------------------------------" << std::endl; - //std::cout << "input: (" << P1.x() << ", " << P1.y() << ", " << P1.z() << "), (" - // << P2.x() << ", " << P2.y() << ", " << P2.z() << "), " << edep << std::endl; - G4int gaperr = 0; const std::pair<G4int, G4int> gap2 = lwc()->GetPhiGapAndSide(P2); @@ -177,19 +146,11 @@ G4double LArG4::EC::EnergyCalculator::GetCurrent1(const G4ThreeVector &P1, cons G4double current = 0.; //current to be returned const G4double step_current = edep / nofstep / s_AverageCurrent; // base current for each step - //std::cout << "gap1: " << gap1.first << ", " << gap1.second - // << "; gap2: " << gap2.first << ", " << gap2.second << std::endl; - //std::cout << "input: (" << P1.x() << ", " << P1.y() << ", " << P1.z() << "), (" - // << P2.x() << ", " << P2.y() << ", " << P2.z() << "), " << edep << std::endl; - - const G4double inv_nofstep = 1. / static_cast<double>(nofstep); for(G4int i = 0; i < nofstep; ++ i){ G4double ds = (i + 0.5) * inv_nofstep; G4ThreeVector Pe = P1 * (1. - ds) + P2 * ds; G4ThreeVector Pa = Pe; - //std::cout << "step " << i << std::endl; - //std::cout << "\tpoint (" << Pe.x() << ", " << Pe.y() << ", " << Pe.z() << ")" << std::endl; SetFoldArea(Pe.z(), fa); // set fold type SetHalfWave(Pe.z(), wg); // set halfwave parameters for substep @@ -206,16 +167,8 @@ G4double LArG4::EC::EnergyCalculator::GetCurrent1(const G4ThreeVector &P1, cons const G4double yshift_on_map = rforalpha*M_PI/lwc()->GetNumberOfFans()-(FanAbsThickness() + FanEleThickness() )/2.; const G4double yshift_on_wheel=sqrt(rvstep2)*M_PI/lwc()->GetNumberOfFans()-(FanAbsThickness() + FanEleThickness() )/2.; const G4double cylgapcorr=yshift_on_wheel/yshift_on_map; // scale difference between plane and cylindrical surface - /* - std::cout<< " GetCurrent1**Nabs="<<lwc()->GetNumberOfFans()<<" absthick="<<FanAbsThickness<<" elethick="<<FanEleThickness - <<" cylgapcorr-1="<<cylgapcorr-1 - <<" ZinHalfWave="<<ZinHalfWave<<" HalfWaveNumber="<<HalfWaveNumber - <<std::endl; - */ //<<<JT - //std::cout << "\tvmap: (" << vmap[0] << ", " << vmap[1] << ", " << vmap[2] << ")" << std::endl; - const G4double HV_value = m_HVHelper->GetVoltage(Pe, gap1); int Pe_fan = 0; @@ -223,13 +176,9 @@ G4double LArG4::EC::EnergyCalculator::GetCurrent1(const G4ThreeVector &P1, cons //G4int side = signof(dte); int Pa_fan = 0; const G4double dta = lwc()->DistanceToTheNearestFan(Pa, Pa_fan); - //std::cout << "\tdte: " << dte << ", dta: " << dta << std::endl; - //std::cout << "\tPe: (" << Pe.x() << ", " << Pe.y() << ", " << Pe.z() << ")" << std::endl; - //std::cout << "\tPa: (" << Pa.x() << ", " << Pa.y() << ", " << Pa.z() << ")" << std::endl; const G4double suppression_range = ElectrodeFanHalfThickness() + CHC_Esr(); if(fabs(dte) < suppression_range){ - // std::cout << " S"; continue; //skip point if too close to the electrode } @@ -237,7 +186,6 @@ G4double LArG4::EC::EnergyCalculator::GetCurrent1(const G4ThreeVector &P1, cons + fabs(dta) - lwc()->GetFanHalfThickness(); //correction to electrode suppression not to G4double suppression = agap / ( agap - CHC_Esr() ); // change av. signal in the gap if(suppression < 0.) suppression = 1.; - //std::cout << "\tagap: " << agap << ", suppression: " << suppression << std::endl; const G4double cur = _interpolateCurrentSubStep1( rforalpha, vmap, Pe, signof(dte), Pe_fan, Pa, signof(dta), Pa_fan, fa, gaperr ); //(25-05-2005) new current calculation: edep*1/U*IonReco*E*v_drift @@ -263,7 +211,6 @@ G4double LArG4::EC::EnergyCalculator::GetCurrent1(const G4ThreeVector &P1, cons current += substep_current; // } } // end of loop for substeps - //std::cout << std::endl; if(current < 0.){ gaperr -= 1000; current = 0.; @@ -282,7 +229,6 @@ G4double LArG4::EC::EnergyCalculator::GetCurrent1(const G4ThreeVector &P1, cons } #endif - //std::cout<<"GetCurrent1::edep="<<edep<<" current="<<current <<" gaperr="<<gaperr<<std::endl; return current; } diff --git a/LArCalorimeter/LArG4/LArG4EC/src/HVHelper.cc b/LArCalorimeter/LArG4/LArG4EC/src/HVHelper.cc index 9f7306435cfacfde3fa19d4ba282955f67a740cc..854fd9ff2bf1e0b1b84648256ef3782679f05093 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/HVHelper.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/HVHelper.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArHV/LArHVManager.h" @@ -211,6 +211,7 @@ void HVHelper::GetMapFromDB(void) const EMECHVManager& hvManager = manager->getEMECHVManager( isInner? EMECHVModule::INNER: EMECHVModule::OUTER ); + const EMECHVManager::EMECHVData hvdata = hvManager.getData(); ATH_MSG_INFO("got LAr HV Manager for " << (isInner? "inner": "outer") << " wheel"); const EMECHVDescriptor& dsc = hvManager.getDescriptor(); @@ -244,7 +245,7 @@ void HVHelper::GetMapFromDB(void) if(jElec >= nFans) jElec -= nFans; } for(unsigned int iGap = 0; iGap < 2; ++ iGap){ - double hv = electrode.voltage(iGap); + double hv = hvdata.voltage (electrode, iGap); ATH_MSG_DEBUG("Side, Eta, Elec, Gap, hv " << jSide << " " << jEta << " " << jElec << " " << iGap << " " diff --git a/LArCalorimeter/LArG4/LArG4EC/src/LArEMECChargeCollection.cc b/LArCalorimeter/LArG4/LArG4EC/src/LArEMECChargeCollection.cc index b327e8dcdd11dc8fc12ba80c344d5348cd276500..d2bfcbacb95d82183e775dab3c93b90a2b3a7945 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/LArEMECChargeCollection.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/LArEMECChargeCollection.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // LArEMECChargeCollection.cc @@ -98,9 +98,6 @@ void LArG4::EC::EnergyCalculator::CreateArrays(Wheel_Efield_Map &wheel, G4int n){ // *************************************************************************** - // std::cout<<"***CreateArrays wheeltype; n="<<n - // <<std::endl; - wheel.NumberOfRadialLayer = n; wheel.RadiusOfLayers =new G4double [n]; wheel.FoldinAngleOfLayers =new G4double [n]; @@ -526,11 +523,6 @@ void LArG4::EC::EnergyCalculator::LoadFieldMaps(const G4String fname){ ATH_MSG_ERROR("GetFieldMaps Error reading field map"); } - /* if(j<10) G4cout<<" z,y,weight=" - <<ChCollFoldType->FieldMap[Index(ChCollFoldType,i,0,j)]<<" " - <<ChCollFoldType->FieldMap[Index(ChCollFoldType,i,1,j)]<<" " - <<ChCollFoldType->FieldMap[Index(ChCollFoldType,i,2,j)] - <<G4endl; */ } // end of loop(j) on points } @@ -631,11 +623,6 @@ void LArG4::EC::EnergyCalculator::PrepareFieldMap(Wheel_Efield_Map* ChCollWheelT ChCollFoldType->FieldMap[Index(ChCollFoldType,i,0,ipnt)]=z; ChCollFoldType->FieldMap[Index(ChCollFoldType,i,1,ipnt)]=y; ChCollFoldType->FieldMap[Index(ChCollFoldType,i,2,ipnt)]=wx; - - /* if(ipnt<10) - G4cout<<" ilayer="<<i<<" ipnt="<<ipnt<<" weights=" - <<ChCollFoldType->FieldMap[Index(ChCollFoldType,i,2,ipnt)] - <<G4endl;*/ } } // end j loop for points @@ -962,7 +949,6 @@ G4double LArG4::EC::EnergyCalculator::GetCurrent( } } - //std::cout <<"GetCurrent0:: edep="<<edep<<" current="<<current<<" gaperr="<<gaperr<<std::endl; #endif return current; @@ -1142,8 +1128,6 @@ void LArG4::EC::EnergyCalculator::SetFoldArea(G4double zinwheel, FoldArea & fa) void LArG4::EC::EnergyCalculator::SetHalfWave(G4double zinwheel, WheelGeometry & wg) const { // *********************************************************** - // G4cout<<"***SetHalfWave zin="<<zinwheel<<G4endl; - const G4double z = zinwheel - lwc()->GetStraightStartSection(); wg.HalfWaveNumber = int((z+lwc()->GetQuarterWaveLength())/lwc()->GetHalfWaveLength()); wg.ZinHalfWave=z - wg.HalfWaveNumber*lwc()->GetHalfWaveLength(); @@ -1346,10 +1330,8 @@ G4double LArG4::EC::EnergyCalculator::YofSurface(G4double alpha,G4double rho,G4d return wg.SignofSlopeofHalfWave*wg.ZinHalfWave/t+th/s; } - // std::cout<<"*** ERROR1 in YofSURF!!!!"<<std::endl; return 0.; } - //std::cout<<"*** ERROR2 in YofSURF!!!!"<<std::endl; return 0.; } diff --git a/LArCalorimeter/LArG4/LArG4FCAL/CMakeLists.txt b/LArCalorimeter/LArG4/LArG4FCAL/CMakeLists.txt index 6c082c84e29614492a522380a59eb84d384275b3..0a12952cf7a9502139c7c79c9fb42ab86767a99c 100644 --- a/LArCalorimeter/LArG4/LArG4FCAL/CMakeLists.txt +++ b/LArCalorimeter/LArG4/LArG4FCAL/CMakeLists.txt @@ -18,8 +18,8 @@ atlas_add_component( LArG4FCAL src/components/*.cxx PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} PRIVATE_DEFINITIONS ${CLHEP_DEFINITIONS} - LINK_LIBRARIES LArG4Code LArReadoutGeometry CaloG4SimLib StoreGateLib SGtests - PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} GaudiKernel LArG4RunControl PathResolver GeoModelInterfaces RDBAccessSvcLib ) + LINK_LIBRARIES LArG4Code LArReadoutGeometry CaloG4SimLib StoreGateLib SGtests CxxUtils + PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} GaudiKernel LArG4RunControl PathResolver GeoModelInterfaces RDBAccessSvcLib LArHV ) atlas_install_python_modules( python/*.py ) diff --git a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.cc b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.cc index d64d04a97876fc4401b58273e6456bb1fafe1868..7d250e4dad4e769982c540f5633026c2c7883b65 100644 --- a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.cc +++ b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.cc @@ -48,7 +48,8 @@ LArFCALCalculatorBase::LArFCALCalculatorBase(const std::string& name, ISvcLocato //m_FCalSampling.verifier().setUpper(3); //Would need to make m_FCalSampling an IntegerProperty for this to work. Overkill? } -StatusCode LArFCALCalculatorBase::initialize() +// Uses not-thread-safe FCALHVManager::getData() +StatusCode LArFCALCalculatorBase::initialize ATLAS_NOT_THREAD_SAFE () { ServiceHandle<StoreGateSvc> detStore ("DetectorStore" ,"LArFCALCalculatorBase"); ATH_CHECK(detStore->retrieve(m_ChannelMap)); @@ -67,6 +68,8 @@ StatusCode LArFCALCalculatorBase::initialize() const FCALDetectorManager* fcalManager=manager->getFcalManager(); m_posModule = fcalManager->getFCAL(FCALModule::Module(m_FCalSampling),FCALModule::POS); m_negModule = fcalManager->getFCAL(FCALModule::Module(m_FCalSampling),FCALModule::NEG); + + m_hvdata = fcalManager->getHVManager().getData(); } } return StatusCode::SUCCESS; @@ -136,9 +139,9 @@ G4bool LArFCALCalculatorBase::Process(const G4Step* a_step, std::vector<LArHitDa FCALTubeConstLink tube=tile->getTube(i); if (tube->getXLocal() == (*t).second.x() && tube->getYLocal()==(*t).second.y()) { const FCALHVLine& line =tube->getHVLine(); - double voltage = line.voltage(); + double voltage = m_hvdata.voltage (line); //double current = line->current(); - bool hvOn = line.hvOn(); + bool hvOn = m_hvdata.hvOn (line); if (!hvOn) hdata[0].energy=0.0; hdata[0].energy *= pow((voltage)/2000.0,0.6); tubeFound=true; diff --git a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.h b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.h index 659ea37100b86735e3f3ad5307d723a69cb72863..2a9a987fad0ba6fabbbdf18950258f40a775eb34 100644 --- a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.h +++ b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // LArFCALCalculator @@ -19,6 +19,8 @@ #include "LArG4Code/LArG4Identifier.h" #include "LArG4Code/LArCalculatorSvcImp.h" #include "LArReadoutGeometry/FCAL_ChannelMap.h" +#include "LArHV/FCALHVManager.h" +#include "CxxUtils/checker_macros.h" #include "globals.hh" #include <stdexcept> class LArG4BirksLaw; @@ -29,7 +31,7 @@ class LArFCALCalculatorBase : public LArCalculatorSvcImp public: // constructor LArFCALCalculatorBase(const std::string& name, ISvcLocator *pSvcLocator); - virtual StatusCode initialize() override; + virtual StatusCode initialize ATLAS_NOT_THREAD_SAFE () override; virtual StatusCode finalize() override; ///////////////////////////////////////////// @@ -58,6 +60,8 @@ class LArFCALCalculatorBase : public LArCalculatorSvcImp G4int m_FCalSampling; LArG4BirksLaw *m_birksLaw; + FCALHVManager::FCALHVData m_hvdata; + LArFCALCalculatorBase (const LArFCALCalculatorBase&); LArFCALCalculatorBase operator= (const LArFCALCalculatorBase&); }; diff --git a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.cc b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.cc index 228f307ee57c7e681cb454679447437196162312..bedd89822a825e433ca6cc216e362e71186cc568 100644 --- a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.cc +++ b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.cc @@ -193,24 +193,6 @@ namespace LArG4 { << etaIndex << phiIndex; - // std::cout << "LArG4FCAL/LArFCALCalibCalculatorBase: 4/3/" - // <<zSide<<"/" - // <<sampling<<"/" - // <<etaIndex<<"/" - // <<phiIndex<<": " - // << energies[0] << ", " - // << energies[1] << ", " - // << energies[2] << ", " - // << energies[3] - // << ", i=" << i - // << ", j=" << j - // << ", l.x=" << theLocalPoint.x() - // << ", l.y=" << theLocalPoint.y() - // << ", p.x=" << p.x() - // << ", p.y=" << p.y() - // << ", deltaX=" << m_deltaX - // << ", deltaY=" << m_deltaY - // << std::endl; } else { // S.M.: we have a hit which fails the electrode identifier @@ -270,25 +252,6 @@ namespace LArG4 { << etaIndex << phiIndex; - // std::cout << "LArG4FCAL/LArFCALCalibCalculatorBase: 10/4/" - // <<type<<"/" - // <<sampling<<"/" - // <<region<<"/" - // <<etaIndex<<"/" - // <<phiIndex<<": " - // << energies[0] << ", " - // << energies[1] << ", " - // << energies[2] << ", " - // << energies[3] - // << ", i=" << i - // << ", j=" << j - // << ", l.x=" << theLocalPoint.x() - // << ", l.y=" << theLocalPoint.y() - // << ", p.x=" << p.x() - // << ", p.y=" << p.y() - // << ", deltaX=" << m_deltaX - // << ", deltaY=" << m_deltaY - // << std::endl; } return true; diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECLocalCalculator.cc b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECLocalCalculator.cc index 4d29073571dcb22772c6d89c75916f852af98c0e..dc94a92918234b8fcc5e9df2c55860aead390c1d 100644 --- a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECLocalCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECLocalCalculator.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArHECLocalCalculator.h" @@ -89,6 +89,5 @@ G4bool LArHECLocalCalculator::Process(const G4Step* a_step, int depthadd, double // Calculate the identifier. hdata[0].id = m_Geometry->CalculateIdentifier( a_step, LArG4::HEC::kLocActive, depthadd, deadzone); -// std::cout<<"LArHECLocalCalculator::Process "<<depthadd<<std::endl; return true; } diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.cc b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.cc index e48969f419e07181d506d7b180b7d42c756909f2..ae4e849e4e67b23c3354e65375185963f7a60ef5 100644 --- a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.cc @@ -49,7 +49,8 @@ LArHECWheelCalculator::~LArHECWheelCalculator() if(m_birksLaw) delete m_birksLaw; } -StatusCode LArHECWheelCalculator::initialize() +// not thread safe due to HECHVManager::getData() +StatusCode LArHECWheelCalculator::initialize ATLAS_NOT_THREAD_SAFE () { ATH_MSG_DEBUG("Use the LArHECWheelCalculator for the HEC"); @@ -68,6 +69,7 @@ StatusCode LArHECWheelCalculator::initialize() ATH_CHECK(detStore.retrieve() ); ATH_CHECK(detStore->retrieve(manager)); m_DetectorManager=manager->getHecManager(); + m_hvdata = m_DetectorManager->getHVManager().getData(); } return StatusCode::SUCCESS; @@ -113,7 +115,7 @@ G4bool LArHECWheelCalculator::Process(const G4Step* a_step, std::vector<LArHitDa const HECDetectorRegion *hecRegion=m_DetectorManager->getDetectorRegion(zSide<0? 0: 1, sampling, region); HECCellConstLink cell=hecRegion->getHECCell(eta, phi); const HECHVSubgap& subgap = cell->getSubgap(subgapIndex); - hdata[0].energy *= (pow(subgap.voltage()/1800.0,0.6)); + hdata[0].energy *= (pow(m_hvdata.voltage(subgap)/1800.0,0.6)); } return true; diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.h b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.h index 9d017e3d9162aacc2ef8d1f0ef58204f3933bcc8..53956741609cb222169fdff88cdd2bcede7aab9d 100644 --- a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.h +++ b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // LArHECWheelCalculator.hh @@ -8,11 +8,13 @@ // Jan-2008: (M.Fincke) To be used for new Module-Geometry -#ifndef __LArG4HECWheelCalculator_H__ -#define __LArG4HECWheelCalculator_H__ +#ifndef LARG4HEC_LARHECWHEELCALCULATOR_H +#define LARG4HEC_LARHECWHEELCALCULATOR_H #include "LArG4Code/LArG4Identifier.h" #include "LArG4Code/LArCalculatorSvcImp.h" +#include "LArHV/HECHVManager.h" +#include "CxxUtils/checker_macros.h" #include <stdexcept> // Forward declarations. @@ -33,7 +35,7 @@ class LArHECWheelCalculator : virtual public LArCalculatorSvcImp { public: LArHECWheelCalculator(const std::string& name, ISvcLocator * pSvcLocator); - virtual StatusCode initialize() override final; + virtual StatusCode initialize ATLAS_NOT_THREAD_SAFE () override final; virtual StatusCode finalize() override final; ~LArHECWheelCalculator(); ///////////////////////////////////////////// @@ -57,6 +59,8 @@ private: LArG4BirksLaw *m_birksLaw; bool m_doHV; + HECHVManager::HECHVData m_hvdata; + LArHECWheelCalculator (const LArHECWheelCalculator&); LArHECWheelCalculator& operator= (const LArHECWheelCalculator&); }; diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/LocalCalibrationCalculator.cc b/LArCalorimeter/LArG4/LArG4HEC/src/LocalCalibrationCalculator.cc index c50b71729dd8a3c1280ab88cafa3b127fddf65b4..24c73ebab4541f8a8fc114ec11dbb181c68c331b 100644 --- a/LArCalorimeter/LArG4/LArG4HEC/src/LocalCalibrationCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4HEC/src/LocalCalibrationCalculator.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LocalCalibrationCalculator.h" @@ -23,9 +23,6 @@ namespace LArG4 { declareProperty("GeometryCalculator", m_geometryCalculator); declareProperty("GeometryType",m_strgeometryType="ACTIVE"); m_strgeometryType.declareUpdateHandler(&LocalCalibrationCalculator::GeometryTypeUpdateHandler, this); -#ifdef DEBUG_HITS - std::cout << "LArG4::HEC::LocalCalibrationCalculator constructed" << std::endl; -#endif } void LocalCalibrationCalculator::GeometryTypeUpdateHandler(Gaudi::Details::PropertyBase&) @@ -73,15 +70,9 @@ namespace LArG4 { const eCalculatorProcessing process) const { -#ifdef DEBUG_HITS - std::cout << "LArG4::HEC::LocalCalibrationCalculator::Process" << std::endl; -#endif energies.clear(); if ( process == kEnergyAndID || process == kOnlyEnergy ) { -#ifdef DEBUG_HITS - std::cout << " calling SimulationEnergies" << std::endl; -#endif m_energyCalculator.Energies( step, energies ); } else @@ -95,9 +86,6 @@ namespace LArG4 { const G4TouchableHistory* theTouchable = static_cast<const G4TouchableHistory*>(pre_step_point->GetTouchable()); // Volume name G4String hitVolume = theTouchable->GetVolume(0)->GetName(); -#ifdef DEBUG_HITS - std::cout<<"LArHECLocalCalibrationCalculator::Process Volume: "<<hitVolume<<std::endl; -#endif if(hitVolume.contains("::") ) { const int last = hitVolume.last(':'); hitVolume.remove(0,last+1); @@ -121,18 +109,6 @@ namespace LArG4 { } else identifier = LArG4Identifier(); } else identifier = m_geometryCalculator->CalculateIdentifier(step, m_geometryType, 0, 4.*CLHEP::mm); -#ifdef DEBUG_HITS - G4double energy = accumulate(energies.begin(),energies.end(),0.); - std::cout << "LArG4::HEC::LocalCalibrationCalculator::Process" - << " ID=" << std::string(identifier) - << " energy=" << energy - << " energies=(" << energies[0] - << "," << energies[1] - << "," << energies[2] - << "," << energies[3] << ")" - << std::endl; -#endif - // Check for bad result. if ( identifier == LArG4Identifier() ) return false; diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/LocalGeometry.cc b/LArCalorimeter/LArG4/LArG4HEC/src/LocalGeometry.cc index b38d67781f67282e4f71de55e4d1015866fc6ce5..dca57ab71839672618071ec183069ead4c498115 100644 --- a/LArCalorimeter/LArG4/LArG4HEC/src/LocalGeometry.cc +++ b/LArCalorimeter/LArG4/LArG4HEC/src/LocalGeometry.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // LArG4::HEC::LocalGeometry @@ -48,21 +48,16 @@ namespace LArG4 { xh = 4; } - // std::cout<<"binSearch::ly "<<ly<<" depth: "<<depth<<" reg: "<<reg<<std::endl; - // if(ly < m_pads[depth][xl] || ly > m_pads[depth][xh] ) return -1; if(ly < m_pads[depth][xl]) return xl; if(ly > m_pads[depth][xh] ) return xh-1; while( xl < xh - 1 ) { const int ires(xl + (xh - xl)/2); - // G4cout<<"xl: "<<xl<<" xh: "<<xh<<" ires: "<<ires<<" m_pads[depth][ires]: "<< m_pads[depth][ires]<<endl; if (ly == m_pads[depth][ires]) return ires - 1; if (ly < m_pads[depth][ires]) xh = ires; else xl = ires; } - // std::cout<<xl<<std::endl; - return xl; } @@ -72,20 +67,16 @@ namespace LArG4 { int xh(14); // = NUM_ETABIN-1 int ires(0); - // std::cout<<"binSearchAll::ly "<<ly<<" depth: "<<depth<<" regular: "<<regular<<std::endl; - // if(ly < m_pads[depth][xl] || ly > m_pads[depth][xh] ) return -1; if(ly < m_pads[depth][xl]) return xl; if(ly > m_pads[depth][xh] ) return xh-1; while( xl < xh - 1 ) { ires = xl + (xh - xl)/2; - // G4cout<<"xl: "<<xl<<" xh: "<<xh<<" ires: "<<ires<<" m_pads[depth][ires]: "<< m_pads[depth][ires]<<endl; if (ly == m_pads[depth][ires]) return ires - 1; if (ly < m_pads[depth][ires]) xh = ires; else xl = ires; } - // std::cout<<xl<<" "<<m_pads[depth][xl]<<" "<<m_pads[depth][xl+1]<<std::endl; if(regular) { // we should recompute to 0.1 eta binning overall numbering if(xl < 4) { ires = xl; @@ -95,7 +86,6 @@ namespace LArG4 { xl += 4; } } - // std::cout<<"After recomput.: "<<xl<<std::endl; return xl; } @@ -209,9 +199,6 @@ namespace LArG4 { // if(g_type == kLocDead) { if(deadzone == 0.) { // The hitted volume's identier is possible to get by the name of his "mother" volume. - // G4cout <<" hitLogiVolume->GetNoDaughters= " <<hitLogiVolume->GetNoDaughters()<<G4endl; - // G4cout <<"+++++"<<hitLogiVolume->GetDaughter(1)->GetLogicalVolume()->GetMaterial()->GetName()<<G4endl; - // G4cout <<"+++++"<<hitLogiVolume->GetName()<<G4endl; G4String hitVolume=a_step->GetPreStepPoint()->GetPhysicalVolume()->GetName(); @@ -317,9 +304,6 @@ namespace LArG4 { // Check, if we are not in dead zone double distance = deadZone(fabs(locx),locy); if(depthadd < 0 || distance < deadzone) { // we return the dead identifier -#ifdef DEBUG_HEC - std::cout<<" In active copyModule = "<< copyModule<<std::endl; -#endif if(zSide * locx < 0) phiBin = copyModule; else { if(copyModule == 31) phiBin = 0; else phiBin=copyModule+1; @@ -332,10 +316,6 @@ namespace LArG4 { << region+2 << etaBin << phiBin; -#ifdef DEBUG_HEC - std::cout <<"HEC::LocalGeometry ++Dead in active zSide = "<<zSide<<" type = 2"<<" , sampling = "<<sampling - <<" , region="<<region+2 << " , phiBin="<<phiBin<< " , etaBin="<<etaBin <<std::endl; -#endif } else { // we return regular ID @@ -362,10 +342,6 @@ namespace LArG4 { << region << etaBin << phiBin; -#ifdef DEBUG_HEC - std::cout <<"HEC::LocalGeometry ++Active zSide = "<<zSide<<" , sampling = "<<sampling<<" , region="<<region << - " , phiBin="<<phiBin<< " , etaBin="<<etaBin <<std::endl; -#endif } return result; @@ -417,13 +393,7 @@ namespace LArG4 { if(zSide * pinLocal.x() > 0) ++phiBin; } */ -#ifdef DEBUG_HEC_OLD_DIAGNOSTIC - std::cout<<"HEC::LocalGeometry Module locy: "<<locy<<" locz: "<<locz<<std::endl; -#endif if(abslocz < m_firstAbsorber[0]) { // in front of HEC -#ifdef DEBUG_HEC_OLD_DIAGNOSTIC - std::cout<<"In front of HEC"<<std::endl; -#endif type = 1; sampling = 2; region = 3; @@ -431,9 +401,6 @@ namespace LArG4 { etaBin = 16 - binSearchAll(locy, 0, true); if( etaBin < 0 ) etaBin = 0; } else if(abslocz > m_depthSize[0] + m_depthSize[1] + m_depthSize[2] && abslocz < m_depthSize[0] + m_depthSize[1] + m_depthSize[2] + m_betweenWheel + m_firstAbsorber[3]) { // interwheel gap -#ifdef DEBUG_HEC_OLD_DIAGNOSTIC - std::cout<<"interwheel gap"<<std::endl; -#endif type = 1; sampling = 2; region = 4; @@ -443,9 +410,6 @@ namespace LArG4 { // sampling = localSampling(pinLocal.z()/Units::mm); double distance = deadZone(fabs(pinLocal.x()/Units::mm),locy); if(distance > deadzone) { // We should return the inactive Id !!!! -#ifdef DEBUG_HEC_OLD_DIAGNOSTIC - std::cout<<"inactive Id"<<std::endl; -#endif int depthNum; if(abslocz < m_depthSize[0]) { sampling = 0; depthNum=0; @@ -475,10 +439,6 @@ namespace LArG4 { etaBin = 13; } etaBin -= binSearch(locy, depthNum, region); -#ifdef DEBUG_HEC - std::cout <<"HEC::LocalGeometry zSide = "<<zSide<<" , sampling = "<<sampling<<" , region="<<region << - " , phiBin="<<phiBin<< " , etaBin="<<etaBin <<std::endl; -#endif if(region==1 && etaBin == 3 && (sampling == 1 || sampling == 2)) etaBin = 2; if(region==0 && etaBin == 0 && sampling == 2) etaBin = 1; if(region==0 && etaBin < 2 && sampling == 3) etaBin = 2; @@ -491,9 +451,6 @@ namespace LArG4 { << phiBin; return result; } // intermodule cracks otherwise -#ifdef DEBUG_HEC_OLD_DIAGNOSTIC - std::cout<<"intermodule crack"<<std::endl; -#endif if(zSide<0) { if(copyN-1<16) copyModule = abs(copyN - 1 - 15); else copyModule = 47 - (copyN - 1); } else { @@ -528,9 +485,6 @@ namespace LArG4 { region = 2; etaBin = 13; } -#ifdef DEBUG_HEC_OLD_DIAGNOSTIC - std::cout<<locy<<" "<<m_pads[depthNum][4]<<" "<<region<<std::endl; -#endif etaBin -= binSearch(locy, depthNum, region-2); } } else if (copyN==50 ) { // First Absorber - in front of HEC @@ -605,7 +559,6 @@ namespace LArG4 { } else { // intermodule cracks double distance = deadZone(fabs(locx),locy); if(distance > deadzone) { // We should return the inactive Id !!!! - // std::cout<<"Calling kLocInactive"<<std::endl; return CalculateIdentifier(a_step, kLocInactive, -1, deadzone); } copyModule = theTouchable->GetVolume(1)->GetCopyNo() - 1; @@ -635,10 +588,6 @@ namespace LArG4 { } } -#ifdef DEBUG_HEC - std::cout <<"HEC::LocalGeometry ++Dead zSide = "<<zSide<<" type = "<<type<<" , sampling = "<<sampling - <<" , region="<<region << " , phiBin="<<phiBin<< " , etaBin="<<etaBin <<std::endl; -#endif result << 10 // DeadM << 2*zSide // LAr diff --git a/LArCalorimeter/LArGeoModel/LArHV/LArHV/ATLAS_CHECK_THREAD_SAFETY b/LArCalorimeter/LArGeoModel/LArHV/LArHV/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 0000000000000000000000000000000000000000..3398454a4ea0c5a19258a20e0c0fec3996412cd4 --- /dev/null +++ b/LArCalorimeter/LArGeoModel/LArHV/LArHV/ATLAS_CHECK_THREAD_SAFETY @@ -0,0 +1 @@ +LArCalorimeter/LArGeoModel/LArHV diff --git a/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMBHVElectrode.h b/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMBHVElectrode.h index a19b2ad1dd07f62a1923d0bb87504ec695677849..5d12fb57eca9ef591cf7e82f8b2f5c9c25712c1e 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMBHVElectrode.h +++ b/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMBHVElectrode.h @@ -26,21 +26,10 @@ class EMBHVElectrode double getPhi() const; - // HV Status - bool hvOn(int iGap) const; - - double voltage(int iGap) const; - double current(int iGap) const; - #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) - int hvLineNo(int iGap, const LArHVIdMapping* hvIdMapping=nullptr) const; -#else - int hvLineNo(int iGap) const; + int hvLineNo(int iGap, const LArHVIdMapping* hvIdMapping) const; #endif - // Voltage and current at the same tine.: - void voltage_current(int iGap, double& v, double& i) const; - private: EMBHVElectrode(const EMBHVElectrode& right); EMBHVElectrode& operator=(const EMBHVElectrode& right); diff --git a/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMBHVManager.h b/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMBHVManager.h index 7518b08f24ad167092ec25af494d8b413af49eee..29ae93eb57415c4dac9356eb3eb17bcb2559b419 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMBHVManager.h +++ b/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMBHVManager.h @@ -7,11 +7,16 @@ #include "LArHV/EMBHVModule.h" #include "LArHV/EMBHVDescriptor.h" +#include "Identifier/HWIdentifier.h" +#include "CxxUtils/checker_macros.h" +#include <memory> +#include <functional> #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) class LArHVIdMapping; #endif +class CondAttrListCollection; struct EMBHVPayload; /** @@ -31,6 +36,24 @@ struct EMBHVPayload; class EMBHVManager { public: + class EMBHVData + { + public: + static constexpr double INVALID = -99999; + class Payload; + EMBHVData(); + EMBHVData (std::unique_ptr<Payload> payload); + EMBHVData& operator= (EMBHVData&& other); + ~EMBHVData(); + bool hvOn (const EMBHVElectrode& electrode, const int& iGap) const; + double voltage (const EMBHVElectrode& electrode, const int& iGap) const; + double current (const EMBHVElectrode& electrode, const int& iGap) const; + int hvLineNo (const EMBHVElectrode& electrode, const int& iGap) const; + private: + int index (const EMBHVElectrode& electrode) const; + std::unique_ptr<Payload> m_payload; + }; + EMBHVManager(); ~EMBHVManager(); @@ -56,16 +79,12 @@ class EMBHVManager unsigned int beginSideIndex() const; unsigned int endSideIndex() const; - // Refresh from the database if needed - void update() const; - - // Make the data stale. Force update of data. - void reset() const; - // Get the database payload - EMBHVPayload *getPayload(const EMBHVElectrode &) const; + EMBHVData getData ATLAS_NOT_THREAD_SAFE () const; #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) + EMBHVData getData (const LArHVIdMapping& hvIdMapping, + const std::vector<const CondAttrListCollection*>& attrLists) const; // Get hvLine for an electrode int hvLineNo(const EMBHVElectrode& electrode , int gap @@ -73,12 +92,16 @@ class EMBHVManager #endif private: - EMBHVManager(const EMBHVManager& right); - EMBHVManager& operator=(const EMBHVManager& right); + using idfunc_t = std::function<std::vector<HWIdentifier>(HWIdentifier)>; + EMBHVData getData (idfunc_t idfunc, + const std::vector<const CondAttrListCollection*>& attrLists) const; + + EMBHVManager(const EMBHVManager& right) = delete; + EMBHVManager& operator=(const EMBHVManager& right) = delete; friend class ImaginaryFriend; class Clockwork; - Clockwork *m_c; + std::unique_ptr<const Clockwork> m_c; }; #endif diff --git a/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMBPresamplerHVManager.h b/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMBPresamplerHVManager.h index bc8fbbd9443e5e6ed21f15e2b4d06a70d46af48c..607cd64aaffce7d8b4b646282c925edebbf85f3c 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMBPresamplerHVManager.h +++ b/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMBPresamplerHVManager.h @@ -6,12 +6,18 @@ #define LARHV_EMBPRESAMPLERHVMANAGER_H #include "LArHV/EMBPresamplerHVModule.h" +#include "Identifier/HWIdentifier.h" +#include "CxxUtils/checker_macros.h" +#include <memory> +#include <functional> #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) class LArHVIdMapping; #endif +class CondAttrListCollection; class EMBPresamplerHVDescriptor; +class EMBPresamplerHVModule; struct EMBPresamplerHVPayload; /** @@ -31,6 +37,24 @@ struct EMBPresamplerHVPayload; class EMBPresamplerHVManager { public: + class EMBPresamplerHVData + { + public: + static constexpr double INVALID = -99999; + class Payload; + EMBPresamplerHVData(); + EMBPresamplerHVData (std::unique_ptr<Payload> payload); + EMBPresamplerHVData& operator= (EMBPresamplerHVData&& other); + ~EMBPresamplerHVData(); + bool hvOn (const EMBPresamplerHVModule& module, const int& iGap) const; + double voltage (const EMBPresamplerHVModule& module, const int& iGap) const; + double current (const EMBPresamplerHVModule& module, const int& iGap) const; + int hvLineNo (const EMBPresamplerHVModule& module, const int& iGap) const; + private: + int index (const EMBPresamplerHVModule& module) const; + std::unique_ptr<Payload> m_payload; + }; + EMBPresamplerHVManager(); ~EMBPresamplerHVManager(); @@ -51,16 +75,12 @@ class EMBPresamplerHVManager unsigned int beginSideIndex() const; unsigned int endSideIndex() const; - // Refresh from the database if needed - void update() const; - - // Make the data stale. Force update of data. - void reset() const; - // Get the database payload - EMBPresamplerHVPayload *getPayload(const EMBPresamplerHVModule &) const; + EMBPresamplerHVData getData ATLAS_NOT_THREAD_SAFE () const; #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) + EMBPresamplerHVData getData (const LArHVIdMapping& hvIdMapping, + const std::vector<const CondAttrListCollection*>& attrLists) const; // Get hvLine for a module int hvLineNo(const EMBPresamplerHVModule& module , int gap @@ -68,13 +88,17 @@ class EMBPresamplerHVManager #endif private: + using idfunc_t = std::function<std::vector<HWIdentifier>(HWIdentifier)>; + EMBPresamplerHVData getData (idfunc_t idfunc, + const std::vector<const CondAttrListCollection*>& attrLists) const; + // Illegal operations - EMBPresamplerHVManager(const EMBPresamplerHVManager& right); - EMBPresamplerHVManager& operator=(const EMBPresamplerHVManager& right); + EMBPresamplerHVManager(const EMBPresamplerHVManager& right) = delete; + EMBPresamplerHVManager& operator=(const EMBPresamplerHVManager& right) = delete; friend class ImaginaryFriend; class Clockwork; - Clockwork *m_c; + std::unique_ptr<const Clockwork> m_c; }; #endif diff --git a/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMBPresamplerHVModule.h b/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMBPresamplerHVModule.h index 56a8bf4fa37fa1ace335a0ee1e91b9cbd0b38242..00f8dd48ee674e8ac69cd844467897c3d0980b07 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMBPresamplerHVModule.h +++ b/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMBPresamplerHVModule.h @@ -38,19 +38,8 @@ class EMBPresamplerHVModule double getPhiMin() const; double getPhiMax() const; - // HV Status - bool hvOn(int iGap) const; - - double voltage(int iGap) const; - double current(int iGap) const; - - // Voltage and current at the same time... - void voltage_current(int iGap, double& v, double& i) const; - #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) - int hvLineNo(int iGap, const LArHVIdMapping* hvIdMapping=nullptr) const; -#else - int hvLineNo(int iGap) const; + int hvLineNo(int iGap, const LArHVIdMapping* hvIdMapping) const; #endif const EMBPresamplerHVManager& getManager() const; diff --git a/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMECHVElectrode.h b/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMECHVElectrode.h index 2bb5a64b479397ff0b38ba6485f86a742909aa1a..87beae4bde87259e4d9b89c0a18744952a05f446 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMECHVElectrode.h +++ b/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMECHVElectrode.h @@ -25,23 +25,9 @@ class EMECHVElectrode double getPhi() const; - // HV Status - bool hvOn(int iGap) const; - - // Voltage - double voltage(int iGap) const; - - // Current - double current(int iGap) const; - - // Voltage and current at the same time - void voltage_current(int iGap, double& v, double& i) const; - // HVLine no #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) - int hvLineNo(int iGap, const LArHVIdMapping* hvIdMapping=nullptr) const; -#else - int hvLineNo(int iGap) const; + int hvLineNo(int iGap, const LArHVIdMapping* hvIdMapping) const; #endif private: diff --git a/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMECHVManager.h b/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMECHVManager.h index 5316fb7a540cb28969f97b983956e73e9ff6b3af..3162c653ab97883f660d3365990a96bb05e3dffe 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMECHVManager.h +++ b/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMECHVManager.h @@ -7,12 +7,17 @@ #include "LArHV/EMECHVModule.h" #include "LArHV/EMECHVDescriptor.h" +#include "Identifier/HWIdentifier.h" +#include "CxxUtils/checker_macros.h" +#include <memory> +#include <functional> #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) class LArHVIdMapping; #endif struct EMECHVPayload; +class CondAttrListCollection; /** * @class EMECHVManager @@ -33,6 +38,24 @@ class EMECHVManager public: typedef EMECHVModule::IOType IOType; + class EMECHVData + { + public: + static constexpr double INVALID = -99999; + class Payload; + EMECHVData(); + EMECHVData (std::unique_ptr<Payload> payload); + EMECHVData& operator= (EMECHVData&& other); + ~EMECHVData(); + bool hvOn (const EMECHVElectrode& electrode, const int& iGap) const; + double voltage (const EMECHVElectrode& electrode, const int& iGap) const; + double current (const EMECHVElectrode& electrode, const int& iGap) const; + int hvLineNo (const EMECHVElectrode& electrode, const int& iGap) const; + private: + int index (const EMECHVElectrode& electrode) const; + std::unique_ptr<Payload> m_payload; + }; + EMECHVManager(IOType wheel); ~EMECHVManager(); @@ -59,16 +82,12 @@ class EMECHVManager // Gets the Wheel, 0 for the Outer Wheel HV Manager and 1 for the inner Wheel HV Manager EMECHVManager::IOType getWheelIndex() const; - // Refresh from the database if needed - void update() const; - - // Make the data stale. Force update of data. - void reset() const; - // Get the database payload - EMECHVPayload *getPayload(const EMECHVElectrode &) const; + EMECHVData getData ATLAS_NOT_THREAD_SAFE () const; #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) + EMECHVData getData (const LArHVIdMapping& hvIdMapping, + const std::vector<const CondAttrListCollection*>& attrLists) const; // Get hvLine for an electrode int hvLineNo(const EMECHVElectrode& electrode , int gap @@ -76,11 +95,15 @@ class EMECHVManager #endif private: - EMECHVManager& operator=(const EMECHVManager& right); - EMECHVManager(const EMECHVManager& right); + using idfunc_t = std::function<std::vector<HWIdentifier>(HWIdentifier)>; + EMECHVData getData (idfunc_t idfunc, + const std::vector<const CondAttrListCollection*>& attrLists) const; + + EMECHVManager& operator=(const EMECHVManager& right) = delete; + EMECHVManager(const EMECHVManager& right) = delete; class Clockwork; - Clockwork *m_c; + std::unique_ptr<const Clockwork> m_c; }; #endif diff --git a/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMECPresamplerHVManager.h b/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMECPresamplerHVManager.h index fa10b0b66398fdabcf1a5cb4d06d6d2f95a7a16d..51e6797f684b5dc6daebf7285fa944e62270b699 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMECPresamplerHVManager.h +++ b/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMECPresamplerHVManager.h @@ -6,11 +6,16 @@ #define LARHV_EMECPRESAMPLERHVMANAGER_H #include "LArHV/EMECPresamplerHVModule.h" +#include "Identifier/HWIdentifier.h" +#include "CxxUtils/checker_macros.h" +#include <memory> +#include <functional> #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) class LArHVIdMapping; #endif +class CondAttrListCollection; struct EMECPresamplerHVPayload; class CellBinning; @@ -31,6 +36,24 @@ class CellBinning; class EMECPresamplerHVManager { public: + class EMECPresamplerHVData + { + public: + static constexpr double INVALID = -99999; + class Payload; + EMECPresamplerHVData(); + EMECPresamplerHVData (std::unique_ptr<Payload> payload); + EMECPresamplerHVData& operator= (EMECPresamplerHVData&& other); + ~EMECPresamplerHVData(); + bool hvOn (const EMECPresamplerHVModule& module, const int& iGap) const; + double voltage (const EMECPresamplerHVModule& module, const int& iGap) const; + double current (const EMECPresamplerHVModule& module, const int& iGap) const; + int hvLineNo (const EMECPresamplerHVModule& module, const int& iGap) const; + private: + int index (const EMECPresamplerHVModule& module) const; + std::unique_ptr<Payload> m_payload; + }; + EMECPresamplerHVManager(); ~EMECPresamplerHVManager(); @@ -46,28 +69,28 @@ class EMECPresamplerHVManager // Get a link to the HV module: const EMECPresamplerHVModule& getHVModule(unsigned int iSide, unsigned int iPhi) const; - // Refresh from the database if needed - void update() const; - - // Make the data stale. Force update of data. - void reset() const; - // Get the database payload - EMECPresamplerHVPayload *getPayload(const EMECPresamplerHVModule &) const; + EMECPresamplerHVData getData ATLAS_NOT_THREAD_SAFE () const; #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) + EMECPresamplerHVData getData (const LArHVIdMapping& hvIdMapping, + const std::vector<const CondAttrListCollection*>& attrLists) const; // Get hvLine for a module int hvLineNo(const EMECPresamplerHVModule& module , const LArHVIdMapping* hvIdMapping) const; #endif private: + using idfunc_t = std::function<std::vector<HWIdentifier>(HWIdentifier)>; + EMECPresamplerHVData getData (idfunc_t idfunc, + const std::vector<const CondAttrListCollection*>& attrLists) const; + // Illegal operations - EMECPresamplerHVManager& operator=(const EMECPresamplerHVManager& right); - EMECPresamplerHVManager(const EMECPresamplerHVManager& right); + EMECPresamplerHVManager& operator=(const EMECPresamplerHVManager& right) = delete; + EMECPresamplerHVManager(const EMECPresamplerHVManager& right) = delete; class Clockwork; - Clockwork *m_c; + std::unique_ptr<const Clockwork> m_c; }; diff --git a/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMECPresamplerHVModule.h b/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMECPresamplerHVModule.h index 624a9a1d4fc639fabe0cdc730fc63848f753bfa8..f3e6b02ca818c54cf5199b3af5f70ef0998ed926 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMECPresamplerHVModule.h +++ b/LArCalorimeter/LArGeoModel/LArHV/LArHV/EMECPresamplerHVModule.h @@ -37,19 +37,8 @@ class EMECPresamplerHVModule // Side Index (0=Negative, 1=Positive) unsigned int getSideIndex() const; - // HV Status - bool hvOn(int iGap) const; - - double voltage(int iGap) const; - double current(int iGap) const; - - // Current and voltage at the same time: - void voltage_current(int iGap, double& v, double& i) const; - #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) - int hvLineNo(int iGap, const LArHVIdMapping* hvIdMapping=nullptr) const; -#else - int hvLineNo(int iGap) const; + int hvLineNo(int iGap, const LArHVIdMapping* hvIdMapping) const; #endif const EMECPresamplerHVManager& getManager() const; diff --git a/LArCalorimeter/LArGeoModel/LArHV/LArHV/FCALHVLine.h b/LArCalorimeter/LArGeoModel/LArHV/LArHV/FCALHVLine.h index 711b93630575ef951c262875a4e0a09b61666572..498a7bed56cfa3bcff1ec707a763ba76c269e6cd 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/LArHV/FCALHVLine.h +++ b/LArCalorimeter/LArGeoModel/LArHV/LArHV/FCALHVLine.h @@ -22,17 +22,8 @@ class FCALHVLine unsigned int getLineIndex() const; - bool hvOn() const; - double voltage() const; - double current() const; - - // Voltage and current at the same time: - void voltage_current(double& v, double& i) const; - #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) - int hvLineNo(const LArHVIdMapping* hvIdMapping=nullptr) const; -#else - int hvLineNo() const; + int hvLineNo(const LArHVIdMapping* hvIdMapping) const; #endif private: diff --git a/LArCalorimeter/LArGeoModel/LArHV/LArHV/FCALHVManager.h b/LArCalorimeter/LArGeoModel/LArHV/LArHV/FCALHVManager.h index 632472942233d76066410bc77a166e62dca28fb4..af8509e693c05094740bb62da850b879c2983c96 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/LArHV/FCALHVManager.h +++ b/LArCalorimeter/LArGeoModel/LArHV/LArHV/FCALHVManager.h @@ -6,11 +6,16 @@ #define LARHV_FCALHVMANAGER_H #include "LArHV/FCALHVModule.h" +#include "Identifier/HWIdentifier.h" +#include "CxxUtils/checker_macros.h" +#include <memory> +#include <functional> #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) class LArHVIdMapping; #endif +class CondAttrListCollection; struct FCALHVPayload; /** @@ -30,6 +35,24 @@ struct FCALHVPayload; class FCALHVManager { public: + class FCALHVData + { + public: + static constexpr double INVALID = -99999; + class Payload; + FCALHVData(); + FCALHVData (std::unique_ptr<Payload> payload); + FCALHVData& operator= (FCALHVData&& other); + ~FCALHVData(); + bool hvOn (const FCALHVLine& line) const; + double voltage (const FCALHVLine& line) const; + double current (const FCALHVLine& line) const; + int hvLineNo (const FCALHVLine& line) const; + private: + int index (const FCALHVLine& line) const; + std::unique_ptr<Payload> m_payload; + }; + FCALHVManager(); ~FCALHVManager(); @@ -47,27 +70,27 @@ class FCALHVManager , unsigned int iSector , unsigned int iSampling) const; - // Refresh from the database if needed - void update() const; - - // Make the data stale. Force update of data. - void reset() const; - // Get the database payload - FCALHVPayload *getPayload(const FCALHVLine &) const; + FCALHVData getData ATLAS_NOT_THREAD_SAFE () const; #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) - // Get hvLine for a subgap + FCALHVData getData (const LArHVIdMapping& hvIdMapping, + const std::vector<const CondAttrListCollection*>& attrLists) const; + // Get hvLine for an electrode int hvLineNo(const FCALHVLine& line , const LArHVIdMapping* hvIdMapping) const; #endif private: - FCALHVManager(const FCALHVManager& right); - FCALHVManager& operator=(const FCALHVManager& right); + using idfunc_t = std::function<std::vector<HWIdentifier>(HWIdentifier)>; + FCALHVData getData (idfunc_t idfunc, + const std::vector<const CondAttrListCollection*>& attrLists) const; + + FCALHVManager(const FCALHVManager& right) = delete; + FCALHVManager& operator=(const FCALHVManager& right) = delete; class Clockwork; - Clockwork *m_c; + std::unique_ptr<const Clockwork> m_c; }; #endif diff --git a/LArCalorimeter/LArGeoModel/LArHV/LArHV/HECHVManager.h b/LArCalorimeter/LArGeoModel/LArHV/LArHV/HECHVManager.h index a91a94a1016befeee217b137c17390d91a7732dd..4640810f2b68c9d235d262b73c13b673509a482b 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/LArHV/HECHVManager.h +++ b/LArCalorimeter/LArGeoModel/LArHV/LArHV/HECHVManager.h @@ -7,11 +7,16 @@ #include "LArHV/HECHVDescriptor.h" #include "LArHV/HECHVModule.h" +#include "Identifier/HWIdentifier.h" +#include "CxxUtils/checker_macros.h" +#include <memory> +#include <functional> #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) class LArHVIdMapping; #endif +class CondAttrListCollection; struct HECHVPayload; /** @@ -31,6 +36,24 @@ struct HECHVPayload; class HECHVManager { public: + class HECHVData + { + public: + static constexpr double INVALID = -99999; + class Payload; + HECHVData(); + HECHVData (std::unique_ptr<Payload> payload); + HECHVData& operator= (HECHVData&& other); + ~HECHVData(); + bool hvOn (const HECHVSubgap& subgap) const; + double voltage (const HECHVSubgap& subgap) const; + double current (const HECHVSubgap& subgap) const; + int hvLineNo (const HECHVSubgap& subgap) const; + private: + int index (const HECHVSubgap& subgap) const; + std::unique_ptr<Payload> m_payload; + }; + HECHVManager(); ~HECHVManager(); @@ -50,27 +73,27 @@ class HECHVManager , unsigned int iPhi , unsigned int iSampling) const; - // Refresh from the database if needed - void update() const; - - // Make the data stale. Force update of data. - void reset() const; - // Get the database payload - HECHVPayload *getPayload(const HECHVSubgap &) const; + HECHVData getData ATLAS_NOT_THREAD_SAFE () const; #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) + HECHVData getData (const LArHVIdMapping& hvIdMapping, + const std::vector<const CondAttrListCollection*>& attrLists) const; // Get hvLine for a subgap int hvLineNo(const HECHVSubgap& subgap , const LArHVIdMapping* hvIdMapping) const; #endif private: - HECHVManager(const HECHVManager& right); - HECHVManager& operator=(const HECHVManager& right); + using idfunc_t = std::function<std::vector<HWIdentifier>(HWIdentifier)>; + HECHVData getData (idfunc_t idfunc, + const std::vector<const CondAttrListCollection*>& attrLists) const; + + HECHVManager(const HECHVManager& right) = delete; + HECHVManager& operator=(const HECHVManager& right) = delete; class Clockwork; - Clockwork *m_c; + std::unique_ptr<const Clockwork> m_c; }; #endif diff --git a/LArCalorimeter/LArGeoModel/LArHV/LArHV/HECHVSubgap.h b/LArCalorimeter/LArGeoModel/LArHV/LArHV/HECHVSubgap.h index 20385fae6354c025a7875921b4a1351951f915f7..19ccaef7e76438ef844a54292635fcf36b37d994 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/LArHV/HECHVSubgap.h +++ b/LArCalorimeter/LArGeoModel/LArHV/LArHV/HECHVSubgap.h @@ -23,19 +23,10 @@ class HECHVSubgap // Returns the index of this electrode. unsigned int getSubgapIndex() const; - bool hvOn() const; - double voltage() const; - double current() const; - #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) - int hvLineNo(const LArHVIdMapping* hvIdMapping=nullptr) const; -#else - int hvLineNo() const; + int hvLineNo(const LArHVIdMapping* hvIdMapping) const; #endif - // Voltage and current at the same time: - void voltage_current(double& v, double& i) const; - private: HECHVSubgap(const HECHVSubgap& right); HECHVSubgap& operator=(const HECHVSubgap& right); diff --git a/LArCalorimeter/LArGeoModel/LArHV/LArHV/LArHVManager.h b/LArCalorimeter/LArGeoModel/LArHV/LArHV/LArHVManager.h index 4ea6a3c16b33aa151190bdfafe7e94201c0e2ddf..f79f2af9ab49a7f9c8f87939f53938c467317b66 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/LArHV/LArHVManager.h +++ b/LArCalorimeter/LArGeoModel/LArHV/LArHV/LArHVManager.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef LARHV_LARHVMANAGER_H @@ -47,7 +47,6 @@ class LArHVManager // Returns the FCALHVManager const FCALHVManager& getFCALHVManager() const; - void reset() const; protected: diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/EMBHVElectrode.cxx b/LArCalorimeter/LArGeoModel/LArHV/src/EMBHVElectrode.cxx index 5c641572cfee8873fe8f06872e30383c10a5973a..339b36da7a7fd0b8ab0ff507a834a2ae5acc1e3a 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/EMBHVElectrode.cxx +++ b/LArCalorimeter/LArGeoModel/LArHV/src/EMBHVElectrode.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArHV/EMBHVElectrode.h" @@ -39,40 +39,12 @@ double EMBHVElectrode::getPhi() const return m_c->module->getPhiMin()+m_c->iElectrode*2.0*M_PI/1024.0; } -bool EMBHVElectrode::hvOn(int iGap) const -{ - EMBHVPayload *payload = m_c->module->getManager().getPayload(*this); - return (payload->voltage[iGap]>=-9999); -} - -double EMBHVElectrode::voltage(int iGap) const { - EMBHVPayload *payload = m_c->module->getManager().getPayload(*this); - return payload->voltage[iGap]; -} - -double EMBHVElectrode::current(int iGap) const { - EMBHVPayload *payload = m_c->module->getManager().getPayload(*this); - return payload->current[iGap]; -} - #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) int EMBHVElectrode::hvLineNo(int iGap, const LArHVIdMapping* hvIdMapping) const { - return hvIdMapping - ? m_c->module->getManager().hvLineNo(*this, iGap, hvIdMapping) - : m_c->module->getManager().getPayload(*this)->hvLineNo[iGap]; -} -#else -int EMBHVElectrode::hvLineNo(int iGap) const { - return m_c->module->getManager().getPayload(*this)->hvLineNo[iGap]; + return m_c->module->getManager().hvLineNo(*this, iGap, hvIdMapping); } #endif -void EMBHVElectrode::voltage_current(int iGap,double& voltage, double¤t) const { - EMBHVPayload *payload = m_c->module->getManager().getPayload(*this); - voltage = payload->voltage[iGap]; - current = payload->current[iGap]; -} - unsigned int EMBHVElectrode::getElectrodeIndex() const{ return m_c->iElectrode; } diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/EMBHVManager.cxx b/LArCalorimeter/LArGeoModel/LArHV/src/EMBHVManager.cxx index d92032af94022997a9b55c995fda86f83420aebb..2d72e88ad2bf8135a89bba83136b346d6ca2c529 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/EMBHVManager.cxx +++ b/LArCalorimeter/LArGeoModel/LArHV/src/EMBHVManager.cxx @@ -33,6 +33,34 @@ #include <mutex> #include <atomic> + +namespace { + + +struct ATLAS_NOT_THREAD_SAFE LegacyIdFunc +{ + LegacyIdFunc(); + std::vector<HWIdentifier> operator()(HWIdentifier id) + { + return m_cablingTool->getLArElectrodeIDvec (id); + } + LArHVCablingTool* m_cablingTool; +}; + + +LegacyIdFunc::LegacyIdFunc() +{ + ToolHandle<LArHVCablingTool> tool ("LArHVCablingTool"); + if (!tool.retrieve().isSuccess()) { + std::abort(); + } + m_cablingTool = tool.get(); +} + + +} // Anonymous namespace + + class EMBHVManager::Clockwork { public: Clockwork(const EMBHVManager* manager) { @@ -40,7 +68,7 @@ public: for(int iEta=0; iEta<8; ++iEta) { for(int iPhi=0; iPhi<16; ++iPhi) { for(int iSector=0; iSector<2; ++iSector) { - moduleArray[iSide][iEta][iPhi][iSector] = new EMBHVModule(manager,iSide,iEta,iPhi,iSector); + moduleArray[iSide][iEta][iPhi][iSector] = std::make_unique<EMBHVModule>(manager,iSide,iEta,iPhi,iSector); } } } @@ -57,33 +85,91 @@ public: } Clockwork(const Clockwork&) = delete; ~Clockwork() { - for(int iSide=0; iSide<2; ++iSide) { - for(int iEta=0; iEta<8; ++iEta) { - for(int iPhi=0; iPhi<16; ++iPhi) { - for(int iSector=0; iSector<2; ++iSector) { - delete moduleArray[iSide][iEta][iPhi][iSector]; - } - } - } - } } EMBHVDescriptor descriptor{CellBinning(0.0, 1.4, 7, 1),CellBinning(0.0, 2*M_PI, 16)}; - const EMBHVModule* moduleArray[2][8][16][2]; - std::atomic<bool> init{false}; - std::mutex mtx; - std::vector<EMBHVPayload> payloadArray; + std::unique_ptr<const EMBHVModule> moduleArray[2][8][16][2]; const LArElectrodeID* elecId; const LArHVLineID* hvId; }; + +class EMBHVManager::EMBHVData::Payload +{ +public: + std::vector<EMBHVPayload> m_payloadArray; +}; + + +EMBHVManager::EMBHVData::EMBHVData() +{ +} + + +EMBHVManager::EMBHVData::EMBHVData (std::unique_ptr<Payload> payload) + : m_payload (std::move (payload)) +{ +} + + +EMBHVManager::EMBHVData& +EMBHVManager::EMBHVData::operator= (EMBHVData&& other) +{ + if (this != &other) { + m_payload = std::move (other.m_payload); + } + return *this; +} + + +EMBHVManager::EMBHVData::~EMBHVData() +{ +} + + +bool EMBHVManager::EMBHVData::hvOn (const EMBHVElectrode& electrode, const int& iGap) const +{ + return voltage (electrode, iGap) > INVALID; +} + + +double EMBHVManager::EMBHVData::voltage (const EMBHVElectrode& electrode, const int& iGap) const +{ + return m_payload->m_payloadArray[index(electrode)].voltage[iGap]; +} + + +double EMBHVManager::EMBHVData::current (const EMBHVElectrode& electrode, const int& iGap) const +{ + return m_payload->m_payloadArray[index(electrode)].current[iGap]; +} + + +int EMBHVManager::EMBHVData::hvLineNo (const EMBHVElectrode& electrode, const int& iGap) const +{ + return m_payload->m_payloadArray[index(electrode)].hvLineNo[iGap]; +} + + +int EMBHVManager::EMBHVData::index (const EMBHVElectrode& electrode) const +{ + unsigned int electrodeIndex = electrode.getElectrodeIndex(); + const EMBHVModule& module = electrode.getModule(); + unsigned int etaIndex = module.getEtaIndex(); + unsigned int phiIndex = module.getPhiIndex(); + unsigned int sectorIndex = module.getSectorIndex(); + unsigned int sideIndex = module.getSideIndex(); + unsigned int index = 8192*sideIndex+1024*etaIndex+64*phiIndex+32*sectorIndex+electrodeIndex; + return index; +} + + EMBHVManager::EMBHVManager() - : m_c(new Clockwork(this)) + : m_c (std::make_unique<Clockwork> (this)) { } EMBHVManager::~EMBHVManager() { - delete m_c; } const EMBHVDescriptor& EMBHVManager::getDescriptor() const @@ -136,70 +222,44 @@ unsigned int EMBHVManager::endSideIndex() const return 2; } -void EMBHVManager::update() const { - std::lock_guard<std::mutex> lock(m_c->mtx); - if (!(m_c->init)) { - m_c->init=true; - m_c->payloadArray.reserve(2*8*16*2*32); +EMBHVManager::EMBHVData +EMBHVManager::getData (idfunc_t idfunc, + const std::vector<const CondAttrListCollection*>& attrLists) const +{ + auto payload = std::make_unique<EMBHVData::Payload>(); + payload->m_payloadArray.reserve(2*8*16*2*32); - for (int i=0;i<16384;i++) { - m_c->payloadArray[i].voltage[0]=-99999.; - m_c->payloadArray[i].voltage[1]=-99999.; - } + for (int i=0;i<16384;i++) { + payload->m_payloadArray[i].voltage[0] = EMBHVData::INVALID; + payload->m_payloadArray[i].voltage[1] = EMBHVData::INVALID; + } - ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "HECHVManager"); - - ISvcLocator* svcLocator = Gaudi::svcLocator(); - IToolSvc* toolSvc; - LArHVCablingTool* hvcablingTool; - - if(StatusCode::SUCCESS!=svcLocator->service("ToolSvc",toolSvc)) - return; - - if(StatusCode::SUCCESS!=toolSvc->retrieveTool("LArHVCablingTool",hvcablingTool)) - return; + for (const CondAttrListCollection* atrlistcol : attrLists) { - std::vector<std::string> colnames; - colnames.push_back("/LAR/DCS/HV/BARREl/I16"); - colnames.push_back("/LAR/DCS/HV/BARREL/I8"); - - std::vector<std::string>::const_iterator it = colnames.begin(); - std::vector<std::string>::const_iterator ie = colnames.end(); - - for (;it!=ie;it++) { - - //std::cout << " --- Start reading folder " << (*it) << std::endl; - const CondAttrListCollection* atrlistcol; - if (StatusCode::SUCCESS!=detStore->retrieve(atrlistcol,*it)) - return; - - for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { + for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { - // Construct HWIdentifier - // 1. decode COOL Channel ID - unsigned int chanID = (*citr).first; - int cannode = chanID/1000; - int line = chanID%1000; - //std::cout << " ++ found data for cannode, line " << cannode << " " << line << std::endl; + // Construct HWIdentifier + // 1. decode COOL Channel ID + unsigned int chanID = (*citr).first; + int cannode = chanID/1000; + int line = chanID%1000; - // 2. Construct the identifier - HWIdentifier id = m_c->hvId->HVLineId(1,1,cannode,line); + // 2. Construct the identifier + HWIdentifier id = m_c->hvId->HVLineId(1,1,cannode,line); - std::vector<HWIdentifier> electrodeIdVec = hvcablingTool->getLArElectrodeIDvec(id); + std::vector<HWIdentifier> electrodeIdVec = idfunc(id); - for(size_t i=0;i<electrodeIdVec.size();i++) - { - HWIdentifier& elecHWID = electrodeIdVec[i]; - int detector = m_c->elecId->detector(elecHWID); - if (detector==0) { - - //std::cout << " in Barrel " << std::endl; + for(size_t i=0;i<electrodeIdVec.size();i++) + { + HWIdentifier& elecHWID = electrodeIdVec[i]; + int detector = m_c->elecId->detector(elecHWID); + if (detector==0) { // side in standard offline 0 for z<0 (C) 1 for z>0 (A) // in electrode numbering, this is the opposite (0 for A and 1 for C) - unsigned int sideIndex=1-m_c->elecId->zside(elecHWID); + unsigned int sideIndex=1-m_c->elecId->zside(elecHWID); // eta index, no trouble - unsigned int etaIndex=m_c->elecId->hv_eta(elecHWID); + unsigned int etaIndex=m_c->elecId->hv_eta(elecHWID); // phi index // offline 0 to 2pi in 2pi/16 bins // this is module in the electrode numbering: on the A side 0 to 15, 0 is halfway around phi=0 (FT-1 (hv_phi=1 is a lower phi) @@ -209,12 +269,12 @@ void EMBHVManager::update() const { // hv_phi 0 1 0 0 1 // phiIndex 0 0 1 15 15 // sector Index 0 1 0 0 1 - unsigned int phiIndex; - unsigned int sectorIndex; - if (sideIndex==1) { - phiIndex=m_c->elecId->module(elecHWID); - sectorIndex=m_c->elecId->hv_phi(elecHWID); - } + unsigned int phiIndex; + unsigned int sectorIndex; + if (sideIndex==1) { + phiIndex=m_c->elecId->module(elecHWID); + sectorIndex=m_c->elecId->hv_phi(elecHWID); + } // module numbering on the C side 0 around phi=pi, running backwards // offline phi 0 pi 2pi // Module P8 P7 P7 P0 P0 P9 P8 @@ -222,74 +282,77 @@ void EMBHVManager::update() const { // hv_phi 1 0 1 0 1 1 0 // phiIndex 0 0 1 7 8 15 15 // sectorIndex 0 1 0 1 0 0 1 - else { - int imodule=m_c->elecId->module(elecHWID); - if (imodule<9) phiIndex = 8 - imodule; - else phiIndex = 24 - imodule; - sectorIndex = 1-m_c->elecId->hv_phi(elecHWID); - } - - if (sectorIndex==1) { - if (phiIndex>0) phiIndex = phiIndex - 1; - else phiIndex=15; - } - - unsigned int electrodeIndex=m_c->elecId->electrode(elecHWID); - if (sideIndex==0) { - if (m_c->elecId->hv_phi(elecHWID)==1) electrodeIndex=31-electrodeIndex; // FT-1 change 0->31 to 31->0 - else electrodeIndex=63-electrodeIndex; // FT 0 change 32->63 to 31-0 - } - else { - if (m_c->elecId->hv_phi(elecHWID)==0) electrodeIndex=electrodeIndex-32; // FT 0 change 31-63 to 0-31 - } + else { + int imodule=m_c->elecId->module(elecHWID); + if (imodule<9) phiIndex = 8 - imodule; + else phiIndex = 24 - imodule; + sectorIndex = 1-m_c->elecId->hv_phi(elecHWID); + } + + if (sectorIndex==1) { + if (phiIndex>0) phiIndex = phiIndex - 1; + else phiIndex=15; + } + + unsigned int electrodeIndex=m_c->elecId->electrode(elecHWID); + if (sideIndex==0) { + if (m_c->elecId->hv_phi(elecHWID)==1) electrodeIndex=31-electrodeIndex; // FT-1 change 0->31 to 31->0 + else electrodeIndex=63-electrodeIndex; // FT 0 change 32->63 to 31-0 + } + else { + if (m_c->elecId->hv_phi(elecHWID)==0) electrodeIndex=electrodeIndex-32; // FT 0 change 31-63 to 0-31 + } - unsigned int index = 8192*sideIndex+1024*etaIndex+64*phiIndex+32*sectorIndex+electrodeIndex; + unsigned int index = 8192*sideIndex+1024*etaIndex+64*phiIndex+32*sectorIndex+electrodeIndex; - unsigned int gapIndex=m_c->elecId->gap(elecHWID); - if (sideIndex==0) gapIndex=1-gapIndex; - - float voltage = -99999.; - if (!((*citr).second)["R_VMEAS"].isNull()) voltage = ((*citr).second)["R_VMEAS"].data<float>(); - float current = 0.; - if (!((*citr).second)["R_IMEAS"].isNull()) current = ((*citr).second)["R_IMEAS"].data<float>(); - unsigned int status = 0; - if (!((*citr).second)["R_STAT"].isNull()) status = ((*citr).second)["R_STAT"].data<unsigned int>(); + unsigned int gapIndex=m_c->elecId->gap(elecHWID); + if (sideIndex==0) gapIndex=1-gapIndex; - // std::cout << " hvlineId,elecHWID,cannode,line, side,phi module, sector,eta,electrode,gap,index " << std::hex << id << " " << elecHWID << std::dec << " " << cannode << " " << line << " " << m_c->elecId->zside(elecHWID) << " " << m_c->elecId->module(elecHWID) << " " << m_c->elecId->hv_phi(elecHWID) << " " << m_c->elecId->hv_eta(elecHWID) << " " << m_c->elecId->electrode(elecHWID) - // << " " << gapIndex << " " << index << " " << voltage << std::endl; + float voltage = EMBHVData::INVALID; + if (!((*citr).second)["R_VMEAS"].isNull()) voltage = ((*citr).second)["R_VMEAS"].data<float>(); + float current = 0.; + if (!((*citr).second)["R_IMEAS"].isNull()) current = ((*citr).second)["R_IMEAS"].data<float>(); - m_c->payloadArray[index].voltage[gapIndex]=voltage; - m_c->payloadArray[index].current[gapIndex]=current; - m_c->payloadArray[index].status[gapIndex]=status; - m_c->payloadArray[index].hvLineNo[gapIndex]=chanID; - } -// std::cerr << "\n"; + payload->m_payloadArray[index].voltage[gapIndex]=voltage; + payload->m_payloadArray[index].current[gapIndex]=current; + payload->m_payloadArray[index].hvLineNo[gapIndex]=chanID; } } } - } -} -void EMBHVManager::reset() const { - m_c->init=false; + return EMBHVManager::EMBHVData (std::move (payload)); } -EMBHVPayload* EMBHVManager::getPayload(const EMBHVElectrode &electrode) const { - update(); - unsigned int electrodeIndex = electrode.getElectrodeIndex(); - const EMBHVModule& module = electrode.getModule(); - unsigned int etaIndex = module.getEtaIndex(); - unsigned int phiIndex = module.getPhiIndex(); - unsigned int sectorIndex = module.getSectorIndex(); - unsigned int sideIndex = module.getSideIndex(); - unsigned int index = 8192*sideIndex+1024*etaIndex+64*phiIndex+32*sectorIndex+electrodeIndex; - return &m_c->payloadArray[index]; + +EMBHVManager::EMBHVData +EMBHVManager::getData ATLAS_NOT_THREAD_SAFE () const +{ + std::vector<const CondAttrListCollection*> attrLists; + ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "EMBHVManager"); + const CondAttrListCollection* atrlistcol = nullptr; + if (detStore->retrieve(atrlistcol, "/LAR/DCS/HV/BARREl/I16").isSuccess()) { + attrLists.push_back (atrlistcol); + } + if (detStore->retrieve(atrlistcol, "/LAR/DCS/HV/BARREl/I8").isSuccess()) { + attrLists.push_back (atrlistcol); + } + return getData (LegacyIdFunc(), attrLists); } + #ifndef SIMULATIONBASE #ifndef GENERATIONBASE +EMBHVManager::EMBHVData +EMBHVManager::getData (const LArHVIdMapping& hvIdMapping, + const std::vector<const CondAttrListCollection*>& attrLists) const +{ + auto idfunc = [&] (HWIdentifier id) { return hvIdMapping.getLArElectrodeIDvec(id); }; + return getData (idfunc, attrLists); +} + + int EMBHVManager::hvLineNo(const EMBHVElectrode& electrode , int gap , const LArHVIdMapping* hvIdMapping) const diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/EMBHVPayload.h b/LArCalorimeter/LArGeoModel/LArHV/src/EMBHVPayload.h index cc04799758c940585427fa36049f782e09ca7acc..bb4dad93373ca9aa133a4765ac42138ad2d0ead2 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/EMBHVPayload.h +++ b/LArCalorimeter/LArGeoModel/LArHV/src/EMBHVPayload.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef LARHV_EMBHVPAYLOAD_H @@ -8,13 +8,12 @@ struct EMBHVPayload { double voltage[2]; double current[2]; - unsigned int status[2]; int hvLineNo[2]; }; inline std::ostream & operator << (std::ostream & o, const EMBHVPayload & payload) { - o << "Half Gap #0: HV Line No " << payload.hvLineNo[0] << ' ' << payload.voltage[0] << " volts; " << payload.current[0] << " amps; status = " << payload.status[0] << std::endl; - o << "Half Gap #1: HV Line No " << payload.hvLineNo[1] << ' ' << payload.voltage[1] << " volts; " << payload.current[1] << " amps; status = " << payload.status[1] << std::endl; + o << "Half Gap #0: HV Line No " << payload.hvLineNo[0] << ' ' << payload.voltage[0] << " volts; " << payload.current[0] << " amps" << std::endl; + o << "Half Gap #1: HV Line No " << payload.hvLineNo[1] << ' ' << payload.voltage[1] << " volts; " << payload.current[1] << " amps" << std::endl; return o; } #endif diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/EMBPresamplerHVManager.cxx b/LArCalorimeter/LArGeoModel/LArHV/src/EMBPresamplerHVManager.cxx index dd040ea2802d4efc67c1bc58c1c600fbc0f04f02..5b91cc46220a447ee0d414269c1717b58fc177b4 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/EMBPresamplerHVManager.cxx +++ b/LArCalorimeter/LArGeoModel/LArHV/src/EMBPresamplerHVManager.cxx @@ -34,18 +34,46 @@ #include <atomic> + +namespace { + + +struct ATLAS_NOT_THREAD_SAFE LegacyIdFunc +{ + LegacyIdFunc(); + std::vector<HWIdentifier> operator()(HWIdentifier id) + { + return m_cablingTool->getLArElectrodeIDvec (id); + } + LArHVCablingTool* m_cablingTool; +}; + + +LegacyIdFunc::LegacyIdFunc() +{ + ToolHandle<LArHVCablingTool> tool ("LArHVCablingTool"); + if (!tool.retrieve().isSuccess()) { + std::abort(); + } + m_cablingTool = tool.get(); +} + + +} // Anonymous namespace + + class EMBPresamplerHVManager::Clockwork { public: Clockwork(const EMBPresamplerHVManager* manager) { CellPartitioning etaPartitioning; for (unsigned int i= 0; i<4; i++) etaPartitioning.addValue(i*0.4); etaPartitioning.addValue(1.525); - descriptor = new EMBPresamplerHVDescriptor(etaPartitioning,CellBinning(0.0, 2*M_PI, 32)); + descriptor = std::make_unique<EMBPresamplerHVDescriptor>(etaPartitioning,CellBinning(0.0, 2*M_PI, 32)); for(int iSide=0; iSide<2; ++iSide) { for(int iEta=0; iEta<4; ++iEta) { for(int iPhi=0; iPhi<32; ++iPhi) { - moduleArray[iSide][iEta][iPhi] = new EMBPresamplerHVModule(manager, iSide, iEta,iPhi); + moduleArray[iSide][iEta][iPhi] = std::make_unique<EMBPresamplerHVModule>(manager, iSide, iEta,iPhi); } } } @@ -60,37 +88,99 @@ public: } } ~Clockwork() { - delete descriptor; - for(int iSide=0; iSide<2; ++iSide) { - for(int iEta=0; iEta<4; ++iEta) { - for(int iPhi=0; iPhi<32; ++iPhi) { - delete moduleArray[iSide][iEta][iPhi]; - } - } - } } - EMBPresamplerHVDescriptor* descriptor; - const EMBPresamplerHVModule* moduleArray[2][4][32]; - std::atomic<bool> init{false}; - std::mutex mtx; - std::vector<EMBPresamplerHVPayload> payloadArray; + std::unique_ptr<EMBPresamplerHVDescriptor> descriptor; + std::unique_ptr<const EMBPresamplerHVModule> moduleArray[2][4][32]; const LArElectrodeID* elecId; const LArHVLineID* hvId; }; + +class EMBPresamplerHVManager::EMBPresamplerHVData::Payload +{ +public: + std::vector<EMBPresamplerHVPayload> m_payloadArray; +}; + + +EMBPresamplerHVManager::EMBPresamplerHVData::EMBPresamplerHVData() +{ +} + + +EMBPresamplerHVManager::EMBPresamplerHVData::EMBPresamplerHVData + (std::unique_ptr<Payload> payload) + : m_payload (std::move (payload)) +{ +} + + +EMBPresamplerHVManager::EMBPresamplerHVData& +EMBPresamplerHVManager::EMBPresamplerHVData::operator= (EMBPresamplerHVData&& other) +{ + if (this != &other) { + m_payload = std::move (other.m_payload); + } + return *this; +} + + +EMBPresamplerHVManager::EMBPresamplerHVData::~EMBPresamplerHVData() +{ +} + + +bool EMBPresamplerHVManager::EMBPresamplerHVData::hvOn + (const EMBPresamplerHVModule& module, const int& iGap) const +{ + return voltage (module, iGap) > INVALID; +} + + +double EMBPresamplerHVManager::EMBPresamplerHVData::voltage + (const EMBPresamplerHVModule& module, const int& iGap) const +{ + return m_payload->m_payloadArray[index(module)].voltage[iGap]; +} + + +double EMBPresamplerHVManager::EMBPresamplerHVData::current + (const EMBPresamplerHVModule& module, const int& iGap) const +{ + return m_payload->m_payloadArray[index(module)].current[iGap]; +} + + +int EMBPresamplerHVManager::EMBPresamplerHVData::hvLineNo + (const EMBPresamplerHVModule& module, const int& iGap) const +{ + return m_payload->m_payloadArray[index(module)].hvLineNo[iGap]; +} + + +int EMBPresamplerHVManager::EMBPresamplerHVData::index + (const EMBPresamplerHVModule& module) const +{ + unsigned int sideIndex = module.getSideIndex(); + unsigned int phiIndex = module.getPhiIndex(); + unsigned int etaIndex = module.getEtaIndex(); + unsigned int index = 128*sideIndex+32*etaIndex+phiIndex; + return index; +} + + EMBPresamplerHVManager::EMBPresamplerHVManager() - : m_c(new Clockwork(this)) + : m_c (std::make_unique<Clockwork> (this)) { } EMBPresamplerHVManager::~EMBPresamplerHVManager() { - delete m_c; } const EMBPresamplerHVDescriptor* EMBPresamplerHVManager::getDescriptor() const { - return m_c->descriptor; + return m_c->descriptor.get(); } unsigned int EMBPresamplerHVManager::beginPhiIndex() const @@ -128,72 +218,46 @@ unsigned int EMBPresamplerHVManager::endSideIndex() const return 2; } -void EMBPresamplerHVManager::update() const { - std::lock_guard<std::mutex> lock(m_c->mtx); - if (!(m_c->init)) { - m_c->init=true; - m_c->payloadArray.reserve(2*4*32); +EMBPresamplerHVManager::EMBPresamplerHVData +EMBPresamplerHVManager::getData (idfunc_t idfunc, + const std::vector<const CondAttrListCollection*>& attrLists) const +{ + auto payload = std::make_unique<EMBPresamplerHVData::Payload>(); + payload->m_payloadArray.reserve(2*4*32); - for (int i=0;i<256;i++) { - m_c->payloadArray[i].voltage[0]=-99999.; - m_c->payloadArray[i].voltage[1]=-99999.; - } + for (int i=0;i<256;i++) { + payload->m_payloadArray[i].voltage[0] = EMBPresamplerHVData::INVALID; + payload->m_payloadArray[i].voltage[1] = EMBPresamplerHVData::INVALID; + } - ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "HECHVManager"); - - ISvcLocator* svcLocator = Gaudi::svcLocator(); - IToolSvc* toolSvc; - LArHVCablingTool* hvcablingTool; + for (const CondAttrListCollection* atrlistcol : attrLists) { - if(StatusCode::SUCCESS!=svcLocator->service("ToolSvc",toolSvc)) - return; - - if(StatusCode::SUCCESS!=toolSvc->retrieveTool("LArHVCablingTool",hvcablingTool)) - return; - - std::vector<std::string> colnames; - colnames.push_back("/LAR/DCS/HV/BARREl/I16"); - colnames.push_back("/LAR/DCS/HV/BARREL/I8"); - - std::vector<std::string>::const_iterator it = colnames.begin(); - std::vector<std::string>::const_iterator ie = colnames.end(); - - for (;it!=ie;it++) { - - //std::cout << " --- Start reading folder " << (*it) << std::endl; - const CondAttrListCollection* atrlistcol; - if (StatusCode::SUCCESS!=detStore->retrieve(atrlistcol,*it)) - return; - - for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { + for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { - // Construct HWIdentifier - // 1. decode COOL Channel ID - unsigned int chanID = (*citr).first; - int cannode = chanID/1000; - int line = chanID%1000; - //std::cout << " ++ found data for cannode, line " << cannode << " " << line << std::endl; + // Construct HWIdentifier + // 1. decode COOL Channel ID + unsigned int chanID = (*citr).first; + int cannode = chanID/1000; + int line = chanID%1000; - // 2. Construct the identifier - HWIdentifier id = m_c->hvId->HVLineId(1,1,cannode,line); + // 2. Construct the identifier + HWIdentifier id = m_c->hvId->HVLineId(1,1,cannode,line); - std::vector<HWIdentifier> electrodeIdVec = hvcablingTool->getLArElectrodeIDvec(id); + std::vector<HWIdentifier> electrodeIdVec = idfunc(id); - for(size_t i=0;i<electrodeIdVec.size();i++) - { - HWIdentifier& elecHWID = electrodeIdVec[i]; - int detector = m_c->elecId->detector(elecHWID); - if (detector==1) { - - //std::cout << " in Barrel " << std::endl; + for(size_t i=0;i<electrodeIdVec.size();i++) + { + HWIdentifier& elecHWID = electrodeIdVec[i]; + int detector = m_c->elecId->detector(elecHWID); + if (detector==1) { // side in standard offline 0 for z<0 (C) 1 for z>0 (A) // in electrode numbering, this is the opposite (0 for A and 1 for C) - unsigned int sideIndex=1-m_c->elecId->zside(elecHWID); + unsigned int sideIndex=1-m_c->elecId->zside(elecHWID); // eta index, no trouble - unsigned int etaIndex=m_c->elecId->hv_eta(elecHWID)-1; + unsigned int etaIndex=m_c->elecId->hv_eta(elecHWID)-1; // phi index // offline 0 to 2pi in 2pi/32 bins (2 presampler cells per phi_HV) // module from elecID : 0 to 31 @@ -202,68 +266,71 @@ void EMBPresamplerHVManager::update() const { // FT 0 -1 0 -1 0 -1 // Module 0 1 2 3 4 5 6 7 9 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 39 30 31 // offline phi 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 - unsigned int phiIndex; - if (sideIndex==1) { - phiIndex=m_c->elecId->module(elecHWID); - } + unsigned int phiIndex; + if (sideIndex==1) { + phiIndex=m_c->elecId->module(elecHWID); + } // module numbering on the C side 0 around phi=pi, running backwards // phi 0 pi 2pi // P8 P7 P6 P5 P4 P3 P2 P1 P0 P15 P14 P13 P12 P11 P10 P9 P8 // FT -1 0 0 -1 0 -1 0 // Module 15 14 9 8 7 6 5 4 3 2 1 0 31 30 29 38 27 26 25 24 23 22 21 20 19 18 17 16 // offline phi 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 - else { - int imodule=m_c->elecId->module(elecHWID); - if (imodule<16) phiIndex = 15 - imodule; - else phiIndex = 47 - imodule; - } + else { + int imodule=m_c->elecId->module(elecHWID); + if (imodule<16) phiIndex = 15 - imodule; + else phiIndex = 47 - imodule; + } - unsigned int index = 128*sideIndex+32*etaIndex+phiIndex; + unsigned int index = 128*sideIndex+32*etaIndex+phiIndex; - unsigned int gapIndex=m_c->elecId->gap(elecHWID); - if (sideIndex==0) gapIndex=1-gapIndex; - - - float voltage = -99999.; - if (!((*citr).second)["R_VMEAS"].isNull()) voltage = ((*citr).second)["R_VMEAS"].data<float>(); - float current = 0.; - if (!((*citr).second)["R_IMEAS"].isNull()) current = ((*citr).second)["R_IMEAS"].data<float>(); - unsigned int status = 0; - if (!((*citr).second)["R_STAT"].isNull()) status = ((*citr).second)["R_STAT"].data<unsigned int>(); + unsigned int gapIndex=m_c->elecId->gap(elecHWID); + if (sideIndex==0) gapIndex=1-gapIndex; - // std::cout << " hvlineId,elecHWID,cannode,line, side,phi module, sector,eta,electrode,gap,index " << std::hex << id << " " << elecHWID << std::dec << " " << cannode << " " << line << " " << m_c->elecId->zside(elecHWID) << " " << m_c->elecId->module(elecHWID) << " " << m_c->elecId->hv_phi(elecHWID) << " " << m_c->elecId->hv_eta(elecHWID) << " " << m_c->elecId->electrode(elecHWID) - // << " " << gapIndex << " " << index << " " << voltage << std::endl; + float voltage = EMBPresamplerHVData::INVALID; + if (!((*citr).second)["R_VMEAS"].isNull()) voltage = ((*citr).second)["R_VMEAS"].data<float>(); + float current = 0.; + if (!((*citr).second)["R_IMEAS"].isNull()) current = ((*citr).second)["R_IMEAS"].data<float>(); - - m_c->payloadArray[index].voltage[gapIndex]=voltage; - m_c->payloadArray[index].current[gapIndex]=current; - m_c->payloadArray[index].status[gapIndex]=status; - m_c->payloadArray[index].hvLineNo[gapIndex]=chanID; - } -// std::cerr << "\n"; + payload->m_payloadArray[index].voltage[gapIndex]=voltage; + payload->m_payloadArray[index].current[gapIndex]=current; + payload->m_payloadArray[index].hvLineNo[gapIndex]=chanID; } } } - } -} -void EMBPresamplerHVManager::reset() const { - m_c->init=false; + return EMBPresamplerHVManager::EMBPresamplerHVData (std::move (payload)); } -EMBPresamplerHVPayload *EMBPresamplerHVManager::getPayload(const EMBPresamplerHVModule &module) const { - update(); - unsigned int sideIndex = module.getSideIndex(); - unsigned int phiIndex = module.getPhiIndex(); - unsigned int etaIndex = module.getEtaIndex(); - unsigned int index = 128*sideIndex+32*etaIndex+phiIndex; - return &m_c->payloadArray[index]; +EMBPresamplerHVManager::EMBPresamplerHVData +EMBPresamplerHVManager::getData ATLAS_NOT_THREAD_SAFE () const +{ + std::vector<const CondAttrListCollection*> attrLists; + ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "EMBHVManager"); + const CondAttrListCollection* atrlistcol = nullptr; + if (detStore->retrieve(atrlistcol, "/LAR/DCS/HV/BARREl/I16").isSuccess()) { + attrLists.push_back (atrlistcol); + } + if (detStore->retrieve(atrlistcol, "/LAR/DCS/HV/BARREl/I8").isSuccess()) { + attrLists.push_back (atrlistcol); + } + return getData (LegacyIdFunc(), attrLists); } + #ifndef SIMULATIONBASE #ifndef GENERATIONBASE +EMBPresamplerHVManager::EMBPresamplerHVData +EMBPresamplerHVManager::getData (const LArHVIdMapping& hvIdMapping, + const std::vector<const CondAttrListCollection*>& attrLists) const +{ + auto idfunc = [&] (HWIdentifier id) { return hvIdMapping.getLArElectrodeIDvec(id); }; + return getData (idfunc, attrLists); +} + + int EMBPresamplerHVManager::hvLineNo(const EMBPresamplerHVModule& module , int gap , const LArHVIdMapping* hvIdMapping) const { diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/EMBPresamplerHVModule.cxx b/LArCalorimeter/LArGeoModel/LArHV/src/EMBPresamplerHVModule.cxx index 13ff4ad396b6889c9a22f5f5e091ee5e428932e0..fae04e731ab45e56185fd92dc973e400f63de1ef 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/EMBPresamplerHVModule.cxx +++ b/LArCalorimeter/LArGeoModel/LArHV/src/EMBPresamplerHVModule.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArHV/EMBPresamplerHVModule.h" @@ -87,36 +87,8 @@ const EMBPresamplerHVManager& EMBPresamplerHVModule::getManager() const return *(m_c->manager); } -bool EMBPresamplerHVModule::hvOn(int iGap) const -{ - EMBPresamplerHVPayload *payload = m_c->manager->getPayload(*this); - return (payload->voltage[iGap]>=-9999); -} - -double EMBPresamplerHVModule::voltage(int iGap) const { - EMBPresamplerHVPayload *payload = m_c->manager->getPayload(*this); - return payload->voltage[iGap]; -} - -double EMBPresamplerHVModule::current(int iGap) const { - EMBPresamplerHVPayload *payload = m_c->manager->getPayload(*this); - return payload->current[iGap]; -} - -void EMBPresamplerHVModule::voltage_current(int iGap,double& voltage, double¤t) const { - EMBPresamplerHVPayload *payload = m_c->manager->getPayload(*this); - voltage = payload->voltage[iGap]; - current = payload->current[iGap]; -} - #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) int EMBPresamplerHVModule::hvLineNo(int iGap, const LArHVIdMapping* hvIdMapping) const { - return hvIdMapping - ? m_c->manager->hvLineNo(*this,iGap,hvIdMapping) - : m_c->manager->getPayload(*this)->hvLineNo[iGap]; -} -#else -int EMBPresamplerHVModule::hvLineNo(int iGap) const { - return m_c->manager->getPayload(*this)->hvLineNo[iGap]; + return m_c->manager->hvLineNo(*this,iGap,hvIdMapping); } #endif diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/EMBPresamplerHVPayload.h b/LArCalorimeter/LArGeoModel/LArHV/src/EMBPresamplerHVPayload.h index 2f97804b80ab7b61f9dcb9e85d8e1b767e15e947..6510ec53bcf54ab5a4ca4a940651e3143f247b74 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/EMBPresamplerHVPayload.h +++ b/LArCalorimeter/LArGeoModel/LArHV/src/EMBPresamplerHVPayload.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef LARHV_EMBPRESAMPLERHVPAYLOAD_H @@ -8,13 +8,12 @@ struct EMBPresamplerHVPayload { double voltage[2]; double current[2]; - unsigned int status[2]; int hvLineNo[2]; }; inline std::ostream & operator << (std::ostream & o, const EMBPresamplerHVPayload & payload) { - o << "Half Gap #0: HV Line No " << payload.hvLineNo[0] << ' ' << payload.voltage[0] << " volts; " << payload.current[0] << " amps; status = " << payload.status[0] << std::endl; - o << "Half Gap #1: HV Line No " << payload.hvLineNo[1] << ' ' << payload.voltage[1] << " volts; " << payload.current[1] << " amps; status = " << payload.status[1] << std::endl; + o << "Half Gap #0: HV Line No " << payload.hvLineNo[0] << ' ' << payload.voltage[0] << " volts; " << payload.current[0] << " amps" << std::endl; + o << "Half Gap #1: HV Line No " << payload.hvLineNo[1] << ' ' << payload.voltage[1] << " volts; " << payload.current[1] << " amps" << std::endl; return o; } #endif diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/EMECHVElectrode.cxx b/LArCalorimeter/LArGeoModel/LArHV/src/EMECHVElectrode.cxx index ae9a06dfbfce0cc5bfcb73a11fa6afed537c61e4..582d82b0b9716eaafd8be40d854c5a23757abb00 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/EMECHVElectrode.cxx +++ b/LArCalorimeter/LArGeoModel/LArHV/src/EMECHVElectrode.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArHV/EMECHVElectrode.h" @@ -45,36 +45,8 @@ double EMECHVElectrode::getPhi() const return m_c->module->getPhiMin()+m_c->iElectrode*2.0*M_PI/N; } -bool EMECHVElectrode::hvOn(int iGap ) const -{ - EMECHVPayload *payload = m_c->module->getManager().getPayload(*this); - return payload->voltage[iGap]>=-9999; -} - -double EMECHVElectrode::voltage(int iGap) const { - EMECHVPayload *payload = m_c->module->getManager().getPayload(*this); - return payload->voltage[iGap]; -} - -double EMECHVElectrode::current(int iGap) const { - EMECHVPayload *payload = m_c->module->getManager().getPayload(*this); - return payload->current[iGap]; -} - -void EMECHVElectrode::voltage_current(int iGap,double& voltage, double¤t) const { - EMECHVPayload *payload = m_c->module->getManager().getPayload(*this); - voltage = payload->voltage[iGap]; - current = payload->current[iGap]; -} - #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) int EMECHVElectrode::hvLineNo(int iGap, const LArHVIdMapping* hvIdMapping) const { - return hvIdMapping - ? m_c->module->getManager().hvLineNo(*this, iGap, hvIdMapping) - : m_c->module->getManager().getPayload(*this)->hvLineNo[iGap]; -} -#else -int EMECHVElectrode::hvLineNo(int iGap) const { - return m_c->module->getManager().getPayload(*this)->hvLineNo[iGap]; + return m_c->module->getManager().hvLineNo(*this, iGap, hvIdMapping); } #endif diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/EMECHVManager.cxx b/LArCalorimeter/LArGeoModel/LArHV/src/EMECHVManager.cxx index c059da3103e8f647473e4d3c2f909073071fee00..cedcf32b49ebdf76d30535b3635b24dd14c9c0ff 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/EMECHVManager.cxx +++ b/LArCalorimeter/LArGeoModel/LArHV/src/EMECHVManager.cxx @@ -11,6 +11,7 @@ #include "EMECHVPayload.h" #include "StoreGate/StoreGateSvc.h" +#include "AthenaKernel/getMessageSvc.h" #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/IToolSvc.h" #include "GaudiKernel/Bootstrap.h" @@ -33,16 +34,46 @@ #include <atomic> + +namespace { + + +struct ATLAS_NOT_THREAD_SAFE LegacyIdFunc +{ + LegacyIdFunc(); + std::vector<HWIdentifier> operator()(HWIdentifier id) + { + return m_cablingTool->getLArElectrodeIDvec (id); + } + LArHVCablingTool* m_cablingTool; +}; + + +LegacyIdFunc::LegacyIdFunc() +{ + ToolHandle<LArHVCablingTool> tool ("LArHVCablingTool"); + if (!tool.retrieve().isSuccess()) { + std::abort(); + } + m_cablingTool = tool.get(); +} + + +} // Anonymous namespace + + class EMECHVManager::Clockwork { public: - Clockwork(const EMECHVManager* manager, IOType wheel) - : iWheel(wheel) + Clockwork(const EMECHVManager* manager, IOType wheel, + std::unique_ptr<EMECHVDescriptor> the_descriptor) + : descriptor(std::move(the_descriptor)), + iWheel(wheel) { for(int iSide=0; iSide<2; ++iSide) { for(int iEta=0; iEta<8; ++iEta) { for(int iPhi=0; iPhi<8; ++iPhi) { for(int iSector=0; iSector<8; ++iSector) { - moduleArray[iSide][iEta][iPhi][iSector] = new EMECHVModule(manager,wheel,iSide,iEta,iPhi,iSector); + moduleArray[iSide][iEta][iPhi][iSector] = std::make_unique<EMECHVModule>(manager,wheel,iSide,iEta,iPhi,iSector); } } } @@ -58,31 +89,92 @@ public: } } ~Clockwork() { - for(int iSide=0; iSide<2; ++iSide) { - for(int iEta=0; iEta<8; ++iEta) { - for(int iPhi=0; iPhi<8; ++iPhi) { - for(int iSector=0; iSector<8; ++iSector) { - delete moduleArray[iSide][iEta][iPhi][iSector]; - } - } - } - } - delete descriptor; } - EMECHVDescriptor* descriptor{nullptr}; + std::unique_ptr<EMECHVDescriptor> descriptor; IOType iWheel; - const EMECHVModule* moduleArray[2][8][8][8]; // not dense - std::atomic<bool> init{false}; - std::mutex mtx; - std::vector<EMECHVPayload> payloadArray; + std::unique_ptr<const EMECHVModule> moduleArray[2][8][8][8]; // not dense const LArElectrodeID* elecId; const LArHVLineID* hvId; }; +class EMECHVManager::EMECHVData::Payload +{ +public: + std::vector<EMECHVPayload> m_payloadArray; +}; + + +EMECHVManager::EMECHVData::EMECHVData() +{ +} + + +EMECHVManager::EMECHVData::EMECHVData (std::unique_ptr<Payload> payload) + : m_payload (std::move (payload)) +{ +} + + +EMECHVManager::EMECHVData& +EMECHVManager::EMECHVData::operator= (EMECHVData&& other) +{ + if (this != &other) { + m_payload = std::move (other.m_payload); + } + return *this; +} + + +EMECHVManager::EMECHVData::~EMECHVData() +{ +} + + +bool EMECHVManager::EMECHVData::hvOn (const EMECHVElectrode& electrode, const int& iGap) const +{ + return voltage (electrode, iGap) > INVALID; +} + + +double EMECHVManager::EMECHVData::voltage (const EMECHVElectrode& electrode, const int& iGap) const +{ + return m_payload->m_payloadArray[index(electrode)].voltage[iGap]; +} + + +double EMECHVManager::EMECHVData::current (const EMECHVElectrode& electrode, const int& iGap) const +{ + return m_payload->m_payloadArray[index(electrode)].current[iGap]; +} + + +int EMECHVManager::EMECHVData::hvLineNo (const EMECHVElectrode& electrode, const int& iGap) const +{ + return m_payload->m_payloadArray[index(electrode)].hvLineNo[iGap]; +} + + +int EMECHVManager::EMECHVData::index (const EMECHVElectrode& electrode) const +{ + unsigned int electrodeIndex = electrode.getElectrodeIndex(); + const EMECHVModule& module = electrode.getModule(); + unsigned int etaIndex = module.getEtaIndex(); + unsigned int phiIndex = module.getPhiIndex(); + unsigned int sectorIndex = module.getSectorIndex(); + unsigned int sideIndex = module.getSideIndex(); + + unsigned int index=0; + if (module.getWheelIndex()==EMECHVModule::OUTER) index= 5376*sideIndex+768*etaIndex+96*phiIndex+24*sectorIndex+electrodeIndex; + else if (module.getWheelIndex()==EMECHVModule::INNER) index= 512*sideIndex+256*etaIndex+32*phiIndex+4*sectorIndex+electrodeIndex; + + return index; +} + + EMECHVManager::EMECHVManager(IOType wheel) - : m_c(new Clockwork(this,wheel)) { + std::unique_ptr<EMECHVDescriptor> descriptor; if (wheel==EMECHVModule::OUTER) { CellPartitioning etaBinning; etaBinning.addValue(1.375); @@ -93,15 +185,16 @@ EMECHVManager::EMECHVManager(IOType wheel) etaBinning.addValue(2.1); etaBinning.addValue(2.3); etaBinning.addValue(2.5); - m_c->descriptor = new EMECHVDescriptor(etaBinning,CellBinning(0.0, 2*M_PI, 8),CellBinning(0,M_PI/4.0,4)); + descriptor = std::make_unique<EMECHVDescriptor>(etaBinning,CellBinning(0.0, 2*M_PI, 8),CellBinning(0,M_PI/4.0,4)); } else { CellPartitioning etaBinning; etaBinning.addValue(2.5); etaBinning.addValue(2.8); etaBinning.addValue(3.2); - m_c->descriptor=new EMECHVDescriptor(etaBinning,CellBinning(0.0, 2*M_PI, 8),CellBinning(0,M_PI/4.0,8)); + descriptor = std::make_unique<EMECHVDescriptor>(etaBinning,CellBinning(0.0, 2*M_PI, 8),CellBinning(0,M_PI/4.0,8)); } + m_c = std::make_unique<Clockwork> (this, wheel, std::move(descriptor)); } const EMECHVDescriptor& EMECHVManager::getDescriptor() const @@ -136,7 +229,6 @@ const EMECHVModule& EMECHVManager::getHVModule(unsigned int iSide, unsigned int EMECHVManager::~EMECHVManager() { - delete m_c; } unsigned int EMECHVManager::beginSideIndex() const @@ -164,163 +256,146 @@ EMECHVManager::IOType EMECHVManager::getWheelIndex() const return m_c->iWheel; } -void EMECHVManager::update() const { - std::lock_guard<std::mutex> lock(m_c->mtx); - if (!(m_c->init)) { - m_c->init=true; - if (m_c->iWheel==EMECHVModule::OUTER) { - m_c->payloadArray.reserve(2*7*8*4*24); - for (unsigned int i=0;i<10752;i++) { - m_c->payloadArray[i].voltage[0]=-99999; - m_c->payloadArray[i].voltage[1]=-99999; - } +EMECHVManager::EMECHVData +EMECHVManager::getData (idfunc_t idfunc, + const std::vector<const CondAttrListCollection*>& attrLists) const +{ + auto payload = std::make_unique<EMECHVData::Payload>(); + + if (m_c->iWheel==EMECHVModule::OUTER) { + payload->m_payloadArray.reserve(2*7*8*4*24); + for (unsigned int i=0;i<10752;i++) { + payload->m_payloadArray[i].voltage[0] = EMECHVData::INVALID; + payload->m_payloadArray[i].voltage[1] = EMECHVData::INVALID; } - else if (m_c->iWheel==EMECHVModule::INNER) { - m_c->payloadArray.reserve(2*2*8*8*4); - for (unsigned int i=0;i<1024;i++) { - m_c->payloadArray[i].voltage[0]=-99999; - m_c->payloadArray[i].voltage[1]=-99999; - } + } + else if (m_c->iWheel==EMECHVModule::INNER) { + payload->m_payloadArray.reserve(2*2*8*8*4); + for (unsigned int i=0;i<1024;i++) { + payload->m_payloadArray[i].voltage[0] = EMECHVData::INVALID; + payload->m_payloadArray[i].voltage[1] = EMECHVData::INVALID; } + } - ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "HECHVManager"); - - ISvcLocator* svcLocator = Gaudi::svcLocator(); - IToolSvc* toolSvc; - LArHVCablingTool* hvcablingTool; - - if(StatusCode::SUCCESS!=svcLocator->service("ToolSvc",toolSvc)) - return; - - if(StatusCode::SUCCESS!=toolSvc->retrieveTool("LArHVCablingTool",hvcablingTool)) - return; - - std::vector<std::string> colnames; - colnames.push_back("/LAR/DCS/HV/BARREl/I16"); - colnames.push_back("/LAR/DCS/HV/BARREL/I8"); - - std::vector<std::string>::const_iterator it = colnames.begin(); - std::vector<std::string>::const_iterator ie = colnames.end(); - - for (;it!=ie;it++) { - //std::cout << " --- Start reading folder " << (*it) << std::endl; - const CondAttrListCollection* atrlistcol; - if (StatusCode::SUCCESS!=detStore->retrieve(atrlistcol,*it)) - return; + for (const CondAttrListCollection* atrlistcol : attrLists) { - for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { - // Construct HWIdentifier - // 1. decode COOL Channel ID - unsigned int chanID = (*citr).first; - int cannode = chanID/1000; - int line = chanID%1000; - //std::cout << " ++ found data for cannode, line " << cannode << " " << line << std::endl; + for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { + // Construct HWIdentifier + // 1. decode COOL Channel ID + unsigned int chanID = (*citr).first; + int cannode = chanID/1000; + int line = chanID%1000; - // 2. Construct the identifier - HWIdentifier id = m_c->hvId->HVLineId(1,1,cannode,line); + // 2. Construct the identifier + HWIdentifier id = m_c->hvId->HVLineId(1,1,cannode,line); - std::vector<HWIdentifier> electrodeIdVec = hvcablingTool->getLArElectrodeIDvec(id); + std::vector<HWIdentifier> electrodeIdVec = idfunc(id); - for(size_t i=0;i<electrodeIdVec.size();i++) { - HWIdentifier& elecHWID = electrodeIdVec[i]; + for(size_t i=0;i<electrodeIdVec.size();i++) { + HWIdentifier& elecHWID = electrodeIdVec[i]; - int detector = m_c->elecId->detector(elecHWID); - // check we are in EMEC - if (detector==2) { + int detector = m_c->elecId->detector(elecHWID); + // check we are in EMEC + if (detector==2) { - unsigned int etaIndex=m_c->elecId->hv_eta(elecHWID); + unsigned int etaIndex=m_c->elecId->hv_eta(elecHWID); - if ( (etaIndex>6 && m_c->iWheel==EMECHVModule::INNER) || (etaIndex<7 && m_c->iWheel==EMECHVModule::OUTER) ) { + if ( (etaIndex>6 && m_c->iWheel==EMECHVModule::INNER) || (etaIndex<7 && m_c->iWheel==EMECHVModule::OUTER) ) { - unsigned int sideIndex=1-m_c->elecId->zside(elecHWID); - unsigned int phiIndex=m_c->elecId->module(elecHWID); // 0 to 7 + unsigned int sideIndex=1-m_c->elecId->zside(elecHWID); + unsigned int phiIndex=m_c->elecId->module(elecHWID); // 0 to 7 // rotation for C side - if (sideIndex==0) { - if (phiIndex<4) phiIndex=3-phiIndex; - else phiIndex=11-phiIndex; - } - unsigned int sectorIndex=m_c->elecId->hv_phi(elecHWID)-1; // 0 to 3 in Outer, 0 to 7 in Inner + if (sideIndex==0) { + if (phiIndex<4) phiIndex=3-phiIndex; + else phiIndex=11-phiIndex; + } + unsigned int sectorIndex=m_c->elecId->hv_phi(elecHWID)-1; // 0 to 3 in Outer, 0 to 7 in Inner // rotation for C side - if (sideIndex==0) { - if (m_c->iWheel==EMECHVModule::OUTER) sectorIndex=3-sectorIndex; - else sectorIndex=7-sectorIndex; - } - unsigned int electrodeIndex = m_c->iWheel==EMECHVModule::OUTER ? - m_c->elecId->electrode(elecHWID)%24: - m_c->elecId->electrode(elecHWID)%4; + if (sideIndex==0) { + if (m_c->iWheel==EMECHVModule::OUTER) sectorIndex=3-sectorIndex; + else sectorIndex=7-sectorIndex; + } + unsigned int electrodeIndex = m_c->iWheel==EMECHVModule::OUTER ? + m_c->elecId->electrode(elecHWID)%24: + m_c->elecId->electrode(elecHWID)%4; // rotation for C side - if (sideIndex==0) { - if (m_c->iWheel==EMECHVModule::OUTER) electrodeIndex=23-electrodeIndex; - else electrodeIndex=3-electrodeIndex; - } + if (sideIndex==0) { + if (m_c->iWheel==EMECHVModule::OUTER) electrodeIndex=23-electrodeIndex; + else electrodeIndex=3-electrodeIndex; + } - unsigned int index = m_c->iWheel==EMECHVModule::OUTER ? - 5376*sideIndex+768*etaIndex+96*phiIndex+24*sectorIndex+electrodeIndex: - 512*sideIndex+256*(etaIndex-7)+32*phiIndex+4*sectorIndex+electrodeIndex; - - if (m_c->iWheel==EMECHVModule::OUTER && index>10752) { - std::cout << "invalid index outer " << index << " side,eta,phi,sector,electrode " << sideIndex << " " << etaIndex << " " << phiIndex << - " " << sectorIndex << " " << electrodeIndex << std::endl; - continue; - } - if (m_c->iWheel==EMECHVModule::INNER && index>1024) { - std::cout << "invalid index inner " << index << " side,eta,phi,sector,electrode " << sideIndex << " " << etaIndex << " " << phiIndex << - " " << sectorIndex << " " << electrodeIndex << std::endl; - continue; - } + unsigned int index = m_c->iWheel==EMECHVModule::OUTER ? + 5376*sideIndex+768*etaIndex+96*phiIndex+24*sectorIndex+electrodeIndex: + 512*sideIndex+256*(etaIndex-7)+32*phiIndex+4*sectorIndex+electrodeIndex; + + if (m_c->iWheel==EMECHVModule::OUTER && index>10752) { + MsgStream msg (Athena::getMessageSvc(), "EMECHVManager"); + msg << MSG::ERROR << "invalid index outer " << index << " side,eta,phi,sector,electrode " << sideIndex << " " << etaIndex << " " << phiIndex << + " " << sectorIndex << " " << electrodeIndex << endmsg; + continue; + } + if (m_c->iWheel==EMECHVModule::INNER && index>1024) { + MsgStream msg (Athena::getMessageSvc(), "EMECHVManager"); + msg << MSG::ERROR << "invalid index inner " << index << " side,eta,phi,sector,electrode " << sideIndex << " " << etaIndex << " " << phiIndex << + " " << sectorIndex << " " << electrodeIndex << endmsg; + continue; + } - unsigned int gapIndex=m_c->elecId->gap(elecHWID); - if (gapIndex>1) { - std::cout << "invalid gapIndex " << gapIndex << std::endl; - continue; - } - if (sideIndex==0) gapIndex=1-gapIndex; + unsigned int gapIndex=m_c->elecId->gap(elecHWID); + if (gapIndex>1) { + MsgStream msg (Athena::getMessageSvc(), "EMECHVManager"); + msg << MSG::ERROR << "invalid gapIndex " << gapIndex << endmsg; + continue; + } + if (sideIndex==0) gapIndex=1-gapIndex; - float voltage = -99999.; - if (!((*citr).second)["R_VMEAS"].isNull()) voltage = ((*citr).second)["R_VMEAS"].data<float>(); - float current = 0.; - if (!((*citr).second)["R_IMEAS"].isNull()) current = ((*citr).second)["R_IMEAS"].data<float>(); - unsigned int status = 0; - if (!((*citr).second)["R_STAT"].isNull()) status = ((*citr).second)["R_STAT"].data<unsigned int>(); - - //std::cout << " hvlineId,elecHWID,cannode,line, side,phi module, sector,eta,electrode,gap,index " << std::hex << id << " " << elecHWID << std::dec << " " << cannode << " " << line << " " << m_c->elecId->zside(elecHWID) << " " << m_c->elecId->module(elecHWID) << " " << m_c->elecId->hv_phi(elecHWID) << " " << m_c->elecId->hv_eta(elecHWID) << " " << m_c->elecId->electrode(elecHWID) - // << " " << gapIndex << " " << index << " " << voltage << std::endl; + float voltage = EMECHVData::INVALID;; + if (!((*citr).second)["R_VMEAS"].isNull()) voltage = ((*citr).second)["R_VMEAS"].data<float>(); + float current = 0.; + if (!((*citr).second)["R_IMEAS"].isNull()) current = ((*citr).second)["R_IMEAS"].data<float>(); - m_c->payloadArray[index].voltage[gapIndex]=voltage; - m_c->payloadArray[index].current[gapIndex]=current; - m_c->payloadArray[index].status[gapIndex]=status; - m_c->payloadArray[index].hvLineNo[gapIndex]=chanID; - } // if etaIndex... - } // for (electrodeIdVec) - } // is EMEC - } // for (atrlistcol) - } - } // if(!m_c->init) -} + payload->m_payloadArray[index].voltage[gapIndex]=voltage; + payload->m_payloadArray[index].current[gapIndex]=current; + payload->m_payloadArray[index].hvLineNo[gapIndex]=chanID; + } // if etaIndex... + } // for (electrodeIdVec) + } // is EMEC + } // for (atrlistcol) + } -void EMECHVManager::reset() const { - m_c->init=false; + return EMECHVManager::EMECHVData (std::move (payload)); } -EMECHVPayload *EMECHVManager::getPayload(const EMECHVElectrode &electrode) const { - update(); - unsigned int electrodeIndex = electrode.getElectrodeIndex(); - const EMECHVModule& module = electrode.getModule(); - unsigned int etaIndex = module.getEtaIndex(); - unsigned int phiIndex = module.getPhiIndex(); - unsigned int sectorIndex = module.getSectorIndex(); - unsigned int sideIndex = module.getSideIndex(); - unsigned int index=0; - if (m_c->iWheel==EMECHVModule::OUTER) index= 5376*sideIndex+768*etaIndex+96*phiIndex+24*sectorIndex+electrodeIndex; - else if (m_c->iWheel==EMECHVModule::INNER) index= 512*sideIndex+256*etaIndex+32*phiIndex+4*sectorIndex+electrodeIndex; - return &m_c->payloadArray[index]; +EMECHVManager::EMECHVData +EMECHVManager::getData ATLAS_NOT_THREAD_SAFE () const +{ + std::vector<const CondAttrListCollection*> attrLists; + ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "EMBHVManager"); + const CondAttrListCollection* atrlistcol = nullptr; + if (detStore->retrieve(atrlistcol, "/LAR/DCS/HV/BARREl/I16").isSuccess()) { + attrLists.push_back (atrlistcol); + } + if (detStore->retrieve(atrlistcol, "/LAR/DCS/HV/BARREl/I8").isSuccess()) { + attrLists.push_back (atrlistcol); + } + return getData (LegacyIdFunc(), attrLists); } + #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) +EMECHVManager::EMECHVData +EMECHVManager::getData (const LArHVIdMapping& hvIdMapping, + const std::vector<const CondAttrListCollection*>& attrLists) const +{ + auto idfunc = [&] (HWIdentifier id) { return hvIdMapping.getLArElectrodeIDvec(id); }; + return getData (idfunc, attrLists); +} + + int EMECHVManager::hvLineNo(const EMECHVElectrode& electrode , int gap , const LArHVIdMapping* hvIdMapping) const diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/EMECHVPayload.h b/LArCalorimeter/LArGeoModel/LArHV/src/EMECHVPayload.h index d61e6fc3157006af7b2a3e7d4b267a2b4156db21..22f174b7731efaac084ece1a7cf4e2be68be785e 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/EMECHVPayload.h +++ b/LArCalorimeter/LArGeoModel/LArHV/src/EMECHVPayload.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef LARHV_EMECHVPAYLOAD_H @@ -8,14 +8,13 @@ struct EMECHVPayload { double voltage[2]; double current[2]; - unsigned int status[2]; int hvLineNo[2]; }; inline std::ostream & operator << (std::ostream & o, const EMECHVPayload & payload) { - o << "Half Gap #0: HV Line No " << payload.hvLineNo[0] << ' ' << payload.voltage[0] << " volts; " << payload.current[0] << " amps; status = " << payload.status[0] << std::endl; - o << "Half Gap #1: HV Line No " << payload.hvLineNo[1] << ' ' << payload.voltage[1] << " volts; " << payload.current[1] << " amps; status = " << payload.status[1] << std::endl; + o << "Half Gap #0: HV Line No " << payload.hvLineNo[0] << ' ' << payload.voltage[0] << " volts; " << payload.current[0] << " amps" << std::endl; + o << "Half Gap #1: HV Line No " << payload.hvLineNo[1] << ' ' << payload.voltage[1] << " volts; " << payload.current[1] << " amps" << std::endl; return o; } #endif diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/EMECPresamplerHVManager.cxx b/LArCalorimeter/LArGeoModel/LArHV/src/EMECPresamplerHVManager.cxx index 655edf3f95ad6f003d1446d93e100fbaf01ac31f..a3e84b41fee453d0e4c3563a313341e1e29845c1 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/EMECPresamplerHVManager.cxx +++ b/LArCalorimeter/LArGeoModel/LArHV/src/EMECPresamplerHVManager.cxx @@ -32,12 +32,40 @@ #include <atomic> + +namespace { + + +struct ATLAS_NOT_THREAD_SAFE LegacyIdFunc +{ + LegacyIdFunc(); + std::vector<HWIdentifier> operator()(HWIdentifier id) + { + return m_cablingTool->getLArElectrodeIDvec (id); + } + LArHVCablingTool* m_cablingTool; +}; + + +LegacyIdFunc::LegacyIdFunc() +{ + ToolHandle<LArHVCablingTool> tool ("LArHVCablingTool"); + if (!tool.retrieve().isSuccess()) { + std::abort(); + } + m_cablingTool = tool.get(); +} + + +} // Anonymous namespace + + class EMECPresamplerHVManager::Clockwork { public: Clockwork(const EMECPresamplerHVManager* manager) { for(int iSide=0; iSide<2; ++iSide) { for(int iPhi=0; iPhi<64; ++iPhi) { - moduleArray[iSide][iPhi] = new EMECPresamplerHVModule(manager, iSide, iPhi); + moduleArray[iSide][iPhi] = std::make_unique<EMECPresamplerHVModule>(manager, iSide, iPhi); } } ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "HECHVManager"); @@ -50,29 +78,93 @@ public: } } ~Clockwork() { - for(int iSide=0; iSide<2; ++iSide) { - for(int iPhi=0; iPhi<64; ++iPhi) { - delete moduleArray[iSide][iPhi]; - } - } } CellBinning phiBinning{0.0, 2*M_PI, 64}; - const EMECPresamplerHVModule* moduleArray[2][64]; // not dense - std::atomic<bool> init{false}; - std::mutex mtx; - std::vector<EMECPresamplerHVPayload> payloadArray; + std::unique_ptr<const EMECPresamplerHVModule> moduleArray[2][64]; // not dense const LArElectrodeID* elecId; const LArHVLineID* hvId; }; + +class EMECPresamplerHVManager::EMECPresamplerHVData::Payload +{ +public: + std::vector<EMECPresamplerHVPayload> m_payloadArray; +}; + + +EMECPresamplerHVManager::EMECPresamplerHVData::EMECPresamplerHVData() +{ +} + + +EMECPresamplerHVManager::EMECPresamplerHVData::EMECPresamplerHVData + (std::unique_ptr<Payload> payload) + : m_payload (std::move (payload)) +{ +} + + +EMECPresamplerHVManager::EMECPresamplerHVData& +EMECPresamplerHVManager::EMECPresamplerHVData::operator= (EMECPresamplerHVData&& other) +{ + if (this != &other) { + m_payload = std::move (other.m_payload); + } + return *this; +} + + +EMECPresamplerHVManager::EMECPresamplerHVData::~EMECPresamplerHVData() +{ +} + + +bool EMECPresamplerHVManager::EMECPresamplerHVData::hvOn + (const EMECPresamplerHVModule& module, const int& iGap) const +{ + return voltage (module, iGap) > INVALID; +} + + +double EMECPresamplerHVManager::EMECPresamplerHVData::voltage + (const EMECPresamplerHVModule& module, const int& /*iGap*/) const +{ + return m_payload->m_payloadArray[index(module)].voltage; +} + + +double EMECPresamplerHVManager::EMECPresamplerHVData::current + (const EMECPresamplerHVModule& module, const int& /*iGap*/) const +{ + return m_payload->m_payloadArray[index(module)].current; +} + + +int EMECPresamplerHVManager::EMECPresamplerHVData::hvLineNo + (const EMECPresamplerHVModule& module, const int& /*iGap*/) const +{ + return m_payload->m_payloadArray[index(module)].hvLineNo; +} + + +int EMECPresamplerHVManager::EMECPresamplerHVData::index + (const EMECPresamplerHVModule& module) const +{ + unsigned int phiIndex = module.getPhiIndex(); + unsigned int sideIndex = module.getSideIndex(); + unsigned int index = 64*sideIndex+phiIndex; + return index; +} + + EMECPresamplerHVManager::EMECPresamplerHVManager() - : m_c(new Clockwork(this)) + : m_c (std::make_unique<Clockwork> (this)) { } EMECPresamplerHVManager::~EMECPresamplerHVManager() { - delete m_c; } const CellBinning *EMECPresamplerHVManager::getPhiBinning() const @@ -105,73 +197,46 @@ unsigned int EMECPresamplerHVManager::endSideIndex() const return 2; } -void EMECPresamplerHVManager::update() const { - std::lock_guard<std::mutex> lock(m_c->mtx); - if (!(m_c->init)) { - m_c->init=true; - { - m_c->payloadArray.reserve(2*64); - for (unsigned int i=0;i<64;i++) { - m_c->payloadArray[i].voltage[0]=-99999; - m_c->payloadArray[i].voltage[1]=-99999; - } - } +EMECPresamplerHVManager::EMECPresamplerHVData +EMECPresamplerHVManager::getData (idfunc_t idfunc, + const std::vector<const CondAttrListCollection*>& attrLists) const +{ + auto payload = std::make_unique<EMECPresamplerHVData::Payload>(); + payload->m_payloadArray.reserve(2*64); + for (unsigned int i=0;i<64;i++) { + payload->m_payloadArray[i].voltage = EMECPresamplerHVData::INVALID; + } - ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "HECHVManager"); + for (const CondAttrListCollection* atrlistcol : attrLists) { - ISvcLocator* svcLocator = Gaudi::svcLocator(); - IToolSvc* toolSvc; - LArHVCablingTool* hvcablingTool; - - if(StatusCode::SUCCESS!=svcLocator->service("ToolSvc",toolSvc)) - return; - - if(StatusCode::SUCCESS!=toolSvc->retrieveTool("LArHVCablingTool",hvcablingTool)) - return; - - std::vector<std::string> colnames; - colnames.push_back("/LAR/DCS/HV/BARREl/I16"); - colnames.push_back("/LAR/DCS/HV/BARREL/I8"); - - std::vector<std::string>::const_iterator it = colnames.begin(); - std::vector<std::string>::const_iterator ie = colnames.end(); - - for (;it!=ie;it++) { - - //std::cout << " --- Start reading folder " << (*it) << std::endl; - const CondAttrListCollection* atrlistcol; - if (StatusCode::SUCCESS!=detStore->retrieve(atrlistcol,*it)) - return; - - for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { + for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { - // Construct HWIdentifier - // 1. decode COOL Channel ID - unsigned int chanID = (*citr).first; - int cannode = chanID/1000; - int line = chanID%1000; - //std::cout << " ++ found data for cannode, line " << cannode << " " << line << std::endl; + // Construct HWIdentifier + // 1. decode COOL Channel ID + unsigned int chanID = (*citr).first; + int cannode = chanID/1000; + int line = chanID%1000; - // 2. Construct the identifier - HWIdentifier id = m_c->hvId->HVLineId(1,1,cannode,line); + // 2. Construct the identifier + HWIdentifier id = m_c->hvId->HVLineId(1,1,cannode,line); - std::vector<HWIdentifier> electrodeIdVec = hvcablingTool->getLArElectrodeIDvec(id); + std::vector<HWIdentifier> electrodeIdVec = idfunc(id); - for(size_t i=0;i<electrodeIdVec.size();i++) { - HWIdentifier& elecHWID = electrodeIdVec[i]; - int detector = m_c->elecId->detector(elecHWID); - // check we are in EMECPresampler - if (detector==3) { + for(size_t i=0;i<electrodeIdVec.size();i++) { + HWIdentifier& elecHWID = electrodeIdVec[i]; + int detector = m_c->elecId->detector(elecHWID); + // check we are in EMECPresampler + if (detector==3) { - unsigned int sideIndex=1-m_c->elecId->zside(elecHWID); - unsigned int phiIndex=m_c->elecId->module(elecHWID); // from 0 to 31 + unsigned int sideIndex=1-m_c->elecId->zside(elecHWID); + unsigned int phiIndex=m_c->elecId->module(elecHWID); // from 0 to 31 // rotation for C side - if (sideIndex==0) { - if (phiIndex<16) phiIndex=15-phiIndex; - else phiIndex=47-phiIndex; - } + if (sideIndex==0) { + if (phiIndex<16) phiIndex=15-phiIndex; + else phiIndex=47-phiIndex; + } // GU January 2017 - fix for HV EMEC PS distribution // 0-31 in phi module @@ -181,48 +246,55 @@ void EMECPresamplerHVManager::update() const { // so in total 64 sectors in phi given by 2*phiIndex+gapIndex // the two gap of these sectors are powered by the same line and have the same HV - unsigned int gapIndex=m_c->elecId->gap(elecHWID); + unsigned int gapIndex=m_c->elecId->gap(elecHWID); - unsigned int index = 64*sideIndex+2*phiIndex+gapIndex; + unsigned int index = 64*sideIndex+2*phiIndex+gapIndex; - float voltage = -99999.; - if (!((*citr).second)["R_VMEAS"].isNull()) voltage = ((*citr).second)["R_VMEAS"].data<float>(); - float current = 0.; - if (!((*citr).second)["R_IMEAS"].isNull()) current = ((*citr).second)["R_IMEAS"].data<float>(); - unsigned int status = 0; - if (!((*citr).second)["R_STAT"].isNull()) status = ((*citr).second)["R_STAT"].data<unsigned int>(); - - - for (unsigned int gap=0;gap<2;gap++) { - m_c->payloadArray[index].voltage[gap]=voltage; - m_c->payloadArray[index].current[gap]=current; - m_c->payloadArray[index].status[gap]=status; - m_c->payloadArray[index].hvLineNo[gap]=chanID; - } - } // for (electrodeIdVec) - } // is EMECPresampler - } // for (atrlistcol) - } - } // if(!m_c->init) + float voltage = EMECPresamplerHVData::INVALID; + if (!((*citr).second)["R_VMEAS"].isNull()) voltage = ((*citr).second)["R_VMEAS"].data<float>(); + float current = 0.; + if (!((*citr).second)["R_IMEAS"].isNull()) current = ((*citr).second)["R_IMEAS"].data<float>(); + + + payload->m_payloadArray[index].voltage=voltage; + payload->m_payloadArray[index].current=current; + payload->m_payloadArray[index].hvLineNo=chanID; + } // for (electrodeIdVec) + } // is EMECPresampler + } // for (atrlistcol) + } + + return EMECPresamplerHVManager::EMECPresamplerHVData (std::move (payload)); } -void EMECPresamplerHVManager::reset() const { - m_c->init=false; +EMECPresamplerHVManager::EMECPresamplerHVData +EMECPresamplerHVManager::getData ATLAS_NOT_THREAD_SAFE () const +{ + std::vector<const CondAttrListCollection*> attrLists; + ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "EMBHVManager"); + const CondAttrListCollection* atrlistcol = nullptr; + if (detStore->retrieve(atrlistcol, "/LAR/DCS/HV/BARREl/I16").isSuccess()) { + attrLists.push_back (atrlistcol); + } + if (detStore->retrieve(atrlistcol, "/LAR/DCS/HV/BARREl/I8").isSuccess()) { + attrLists.push_back (atrlistcol); + } + return getData (LegacyIdFunc(), attrLists); } -EMECPresamplerHVPayload *EMECPresamplerHVManager::getPayload(const EMECPresamplerHVModule & module) const { - update(); - unsigned int phiIndex = module.getPhiIndex(); - unsigned int sideIndex = module.getSideIndex(); - - unsigned int index = 64*sideIndex+phiIndex; - return &m_c->payloadArray[index]; +#if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) +EMECPresamplerHVManager::EMECPresamplerHVData +EMECPresamplerHVManager::getData (const LArHVIdMapping& hvIdMapping, + const std::vector<const CondAttrListCollection*>& attrLists) const +{ + auto idfunc = [&] (HWIdentifier id) { return hvIdMapping.getLArElectrodeIDvec(id); }; + return getData (idfunc, attrLists); } -#if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) + int EMECPresamplerHVManager::hvLineNo(const EMECPresamplerHVModule& module , const LArHVIdMapping* hvIdMapping) const { int sideIndex = module.getSideIndex(); diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/EMECPresamplerHVModule.cxx b/LArCalorimeter/LArGeoModel/LArHV/src/EMECPresamplerHVModule.cxx index 077dee06afa7290ebfc5b044ef65c41e1362e542..7ab3bbe7c825f007e82b3c5636fa6855941c9690 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/EMECPresamplerHVModule.cxx +++ b/LArCalorimeter/LArGeoModel/LArHV/src/EMECPresamplerHVModule.cxx @@ -70,39 +70,9 @@ const EMECPresamplerHVManager& EMECPresamplerHVModule::getManager() const return *(m_c->manager); } -bool EMECPresamplerHVModule::hvOn(int iGap ) const -{ - EMECPresamplerHVPayload *payload = getManager().getPayload(*this); - return (payload->voltage[iGap]>=-9999); -} - -double EMECPresamplerHVModule::voltage(int iGap) const { - EMECPresamplerHVPayload *payload = getManager().getPayload(*this); - return payload->voltage[iGap]; -} - -double EMECPresamplerHVModule::current(int iGap) const { - EMECPresamplerHVPayload *payload = getManager().getPayload(*this); - return payload->current[iGap]; -} - -void EMECPresamplerHVModule::voltage_current(int iGap,double& voltage, double¤t) const -{ - EMECPresamplerHVPayload *payload = getManager().getPayload(*this); - voltage = payload->voltage[iGap]; - current = payload->current[iGap]; -} - #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) -int EMECPresamplerHVModule::hvLineNo(int iGap, const LArHVIdMapping* hvIdMapping) const -{ - return hvIdMapping - ? getManager().hvLineNo(*this,hvIdMapping) - : getManager().getPayload(*this)->hvLineNo[iGap]; -} -#else -int EMECPresamplerHVModule::hvLineNo(int iGap) const +int EMECPresamplerHVModule::hvLineNo(int /*iGap*/, const LArHVIdMapping* hvIdMapping) const { - return getManager().getPayload(*this)->hvLineNo[iGap]; + return getManager().hvLineNo(*this,hvIdMapping); } #endif diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/EMECPresamplerHVPayload.h b/LArCalorimeter/LArGeoModel/LArHV/src/EMECPresamplerHVPayload.h index a4796090e4e3ccbe5a2ce559b8c286aa3da9b469..a6544ebcb90154d73bd96942f9fee7778aee718d 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/EMECPresamplerHVPayload.h +++ b/LArCalorimeter/LArGeoModel/LArHV/src/EMECPresamplerHVPayload.h @@ -1,20 +1,18 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef LARHV_EMECPRESAMPLERHVPAYLOAD_H #define LARHV_EMECPRESAMPLERHVPAYLOAD_H #include <iostream> struct EMECPresamplerHVPayload { - double voltage[2]; - double current[2]; - unsigned int status[2]; - int hvLineNo[2]; + double voltage; + double current; + int hvLineNo; }; inline std::ostream & operator << (std::ostream & o, const EMECPresamplerHVPayload & payload) { - o << "Half Gap #0: HV Line No " << payload.hvLineNo[0] << ' ' << payload.voltage[0] << " volts; " << payload.current[0] << " amps; status = " << payload.status[0] << std::endl; - o << "Half Gap #1: HV Line No " << payload.hvLineNo[1] << ' ' << payload.voltage[1] << " volts; " << payload.current[1] << " amps; status = " << payload.status[1] << std::endl; + o << "HV Line No " << payload.hvLineNo << ' ' << payload.voltage << " volts; " << payload.current << " amps" << std::endl; return o; } #endif diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/FCALHVLine.cxx b/LArCalorimeter/LArGeoModel/LArHV/src/FCALHVLine.cxx index 16c671eb3f14550a48226b61e0451f568e61de62..f2681297e593d5668559ce4002b0cab7f5f41639 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/FCALHVLine.cxx +++ b/LArCalorimeter/LArGeoModel/LArHV/src/FCALHVLine.cxx @@ -40,36 +40,8 @@ unsigned int FCALHVLine::getLineIndex() const return m_c->iLine; } -bool FCALHVLine::hvOn() const -{ - FCALHVPayload *payload = m_c->module->getManager().getPayload(*this); - return (payload->voltage>=-9999); -} - -double FCALHVLine::voltage() const { - FCALHVPayload *payload = m_c->module->getManager().getPayload(*this); - return payload->voltage; -} - -double FCALHVLine::current() const { - FCALHVPayload *payload = m_c->module->getManager().getPayload(*this); - return payload->current; -} - -void FCALHVLine::voltage_current(double& voltage, double¤t) const { - FCALHVPayload *payload = m_c->module->getManager().getPayload(*this); - voltage = payload->voltage; - current = payload->current; -} - #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) int FCALHVLine::hvLineNo(const LArHVIdMapping* hvIdMapping) const { - return hvIdMapping - ? m_c->module->getManager().hvLineNo(*this,hvIdMapping) - : m_c->module->getManager().getPayload(*this)->hvLineNo; -} -#else -int FCALHVLine::hvLineNo() const { - return m_c->module->getManager().getPayload(*this)->hvLineNo; + return m_c->module->getManager().hvLineNo(*this,hvIdMapping); } #endif diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/FCALHVManager.cxx b/LArCalorimeter/LArGeoModel/LArHV/src/FCALHVManager.cxx index 632e1295db295f9b02a333f402235ab9bf85f5f5..d380deb649338fbb7f575e3a533f17798e1cdbc1 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/FCALHVManager.cxx +++ b/LArCalorimeter/LArGeoModel/LArHV/src/FCALHVManager.cxx @@ -7,6 +7,7 @@ #include "FCALHVPayload.h" +#include "AthenaKernel/getMessageSvc.h" #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/IToolSvc.h" #include "GaudiKernel/Bootstrap.h" @@ -25,6 +26,34 @@ #include <atomic> + +namespace { + + +struct ATLAS_NOT_THREAD_SAFE LegacyIdFunc +{ + LegacyIdFunc(); + std::vector<HWIdentifier> operator()(HWIdentifier id) + { + return m_cablingTool->getLArElectrodeIDvec (id); + } + LArHVCablingTool* m_cablingTool; +}; + + +LegacyIdFunc::LegacyIdFunc() +{ + ToolHandle<LArHVCablingTool> tool ("LArHVCablingTool"); + if (!tool.retrieve().isSuccess()) { + std::abort(); + } + m_cablingTool = tool.get(); +} + + +} // Anonymous namespace + + class FCALHVManager::Clockwork { public: Clockwork(const FCALHVManager* manager) @@ -32,7 +61,7 @@ public: for(int iSide=0; iSide<2; ++iSide) { for(int iSector=0; iSector<16; ++iSector) { for(int iSampling=0; iSampling<3; ++iSampling) { - moduleArray[iSide][iSector][iSampling] = new FCALHVModule(manager,iSide,iSector,iSampling); + moduleArray[iSide][iSector][iSampling] = std::make_unique<FCALHVModule>(manager,iSide,iSector,iSampling); } } } @@ -48,30 +77,89 @@ public: } ~Clockwork() { - for(int iSide=0; iSide<2; ++iSide) { - for(int iSector=0; iSector<16; ++iSector) { - for(int iSampling=0; iSampling<3; ++iSampling) { - delete moduleArray[iSide][iSector][iSampling]; - } - } - } } - const FCALHVModule* moduleArray[2][16][3]; - std::atomic<bool> init{false}; - std::mutex mtx; - std::vector<FCALHVPayload> payloadArray; + std::unique_ptr<const FCALHVModule> moduleArray[2][16][3]; const LArElectrodeID* elecId; const LArHVLineID* hvId; }; + +class FCALHVManager::FCALHVData::Payload +{ +public: + std::vector<FCALHVPayload> m_payloadArray; +}; + + +FCALHVManager::FCALHVData::FCALHVData() +{ +} + + +FCALHVManager::FCALHVData::FCALHVData (std::unique_ptr<Payload> payload) + : m_payload (std::move (payload)) +{ +} + + +FCALHVManager::FCALHVData& +FCALHVManager::FCALHVData::operator= (FCALHVData&& other) +{ + if (this != &other) { + m_payload = std::move (other.m_payload); + } + return *this; +} + + +FCALHVManager::FCALHVData::~FCALHVData() +{ +} + + +bool FCALHVManager::FCALHVData::hvOn (const FCALHVLine& line) const +{ + return voltage (line) > INVALID; +} + + +double FCALHVManager::FCALHVData::voltage (const FCALHVLine& line) const +{ + return m_payload->m_payloadArray[index(line)].voltage; +} + + +double FCALHVManager::FCALHVData::current (const FCALHVLine& line) const +{ + return m_payload->m_payloadArray[index(line)].current; +} + + +int FCALHVManager::FCALHVData::hvLineNo (const FCALHVLine& line) const +{ + return m_payload->m_payloadArray[index(line)].hvLineNo; +} + + +int FCALHVManager::FCALHVData::index (const FCALHVLine& line) const +{ + unsigned int lineIndex = line.getLineIndex(); + const FCALHVModule& module = line.getModule(); + unsigned int sectorIndex = module.getSectorIndex(); + unsigned int sideIndex = module.getSideIndex(); + unsigned int samplingIndex = module.getSamplingIndex(); + unsigned int index = 192*sideIndex+12*sectorIndex+4*samplingIndex+lineIndex; + return index; +} + + FCALHVManager::FCALHVManager() - : m_c(new Clockwork(this)) + : m_c (std::make_unique<Clockwork> (this)) { } FCALHVManager::~FCALHVManager() { - delete m_c; } unsigned int FCALHVManager::beginSideIndex() const @@ -112,115 +200,94 @@ const FCALHVModule& FCALHVManager::getHVModule(unsigned int iSide, unsigned int return *(m_c->moduleArray[iSide][iSector][iSampling]); } -void FCALHVManager::update() const { - std::lock_guard<std::mutex> lock(m_c->mtx); - if (!(m_c->init)) { - m_c->init=true; - m_c->payloadArray.reserve(2*16*3*4); - for (unsigned int i=0;i<384;i++) { - m_c->payloadArray[i].voltage = -99999; - } - - ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "HECHVManager"); - - ISvcLocator* svcLocator = Gaudi::svcLocator(); - IToolSvc* toolSvc; - LArHVCablingTool* hvcablingTool; - - if(StatusCode::SUCCESS!=svcLocator->service("ToolSvc",toolSvc)) - return; - - if(StatusCode::SUCCESS!=toolSvc->retrieveTool("LArHVCablingTool",hvcablingTool)) - return; - - std::vector<std::string> colnames; - colnames.push_back("/LAR/DCS/HV/BARREl/I16"); - colnames.push_back("/LAR/DCS/HV/BARREL/I8"); - - std::vector<std::string>::const_iterator it = colnames.begin(); - std::vector<std::string>::const_iterator ie = colnames.end(); - - for (;it!=ie;it++) { - - //std::cout << " --- Start reading folder " << (*it) << std::endl; - const CondAttrListCollection* atrlistcol; - if (StatusCode::SUCCESS!=detStore->retrieve(atrlistcol,*it)) - return; +FCALHVManager::FCALHVData +FCALHVManager::getData (idfunc_t idfunc, + const std::vector<const CondAttrListCollection*>& attrLists) const +{ + auto payload = std::make_unique<FCALHVData::Payload>(); + payload->m_payloadArray.reserve(2*16*3*4); + for (unsigned int i=0;i<384;i++) { + payload->m_payloadArray[i].voltage = FCALHVData::INVALID; + } - for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { + for (const CondAttrListCollection* atrlistcol : attrLists) { - // 1. decode COOL Channel ID - unsigned int chanID = (*citr).first; - int cannode = chanID/1000; - int line = chanID%1000; - //std::cout << " cannode,line " << cannode << " " << line << std::endl; + for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { - // 2. Construct the identifier - HWIdentifier id = m_c->hvId->HVLineId(1,1,cannode,line); + // 1. decode COOL Channel ID + unsigned int chanID = (*citr).first; + int cannode = chanID/1000; + int line = chanID%1000; - std::vector<HWIdentifier> electrodeIdVec = hvcablingTool->getLArElectrodeIDvec(id); + // 2. Construct the identifier + HWIdentifier id = m_c->hvId->HVLineId(1,1,cannode,line); - for(size_t i=0;i<electrodeIdVec.size();i++) { + std::vector<HWIdentifier> electrodeIdVec = idfunc(id); - HWIdentifier& elecHWID = electrodeIdVec[i]; - int detector = m_c->elecId->detector(elecHWID); - if (detector==5) { + for(size_t i=0;i<electrodeIdVec.size();i++) { - //std::cout << " FCAl channel found " << (*citr).first << std::endl; + HWIdentifier& elecHWID = electrodeIdVec[i]; + int detector = m_c->elecId->detector(elecHWID); + if (detector==5) { - float voltage = -99999.; - if (!((*citr).second)["R_VMEAS"].isNull()) voltage = ((*citr).second)["R_VMEAS"].data<float>(); - float current = 0.; - if (!((*citr).second)["R_IMEAS"].isNull()) current = ((*citr).second)["R_IMEAS"].data<float>(); - unsigned int status = 0; - if (!((*citr).second)["R_STAT"].isNull()) status = ((*citr).second)["R_STAT"].data<unsigned int>(); + float voltage = FCALHVData::INVALID;; + if (!((*citr).second)["R_VMEAS"].isNull()) voltage = ((*citr).second)["R_VMEAS"].data<float>(); + float current = 0.; + if (!((*citr).second)["R_IMEAS"].isNull()) current = ((*citr).second)["R_IMEAS"].data<float>(); - unsigned int sideIndex=1-m_c->elecId->zside(elecHWID); // 0 C side, 1 A side (unline HV numbering) - unsigned int samplingIndex=m_c->elecId->hv_eta(elecHWID)-1; // 0 to 2 for the FCAL modules 1-2-3 - unsigned int sectorIndex=m_c->elecId->module(elecHWID); // 0-15 FCAL1, 0-7 FCAl2, 0-3 FCAL3 - unsigned int lineIndex=m_c->elecId->gap(elecHWID); // 0-3 + unsigned int sideIndex=1-m_c->elecId->zside(elecHWID); // 0 C side, 1 A side (unline HV numbering) + unsigned int samplingIndex=m_c->elecId->hv_eta(elecHWID)-1; // 0 to 2 for the FCAL modules 1-2-3 + unsigned int sectorIndex=m_c->elecId->module(elecHWID); // 0-15 FCAL1, 0-7 FCAl2, 0-3 FCAL3 + unsigned int lineIndex=m_c->elecId->gap(elecHWID); // 0-3 - //std::cout << " channel found " << sideIndex << " " << samplingIndex << " " << sectorIndex << " " << lineIndex << " "<< voltage << std::endl; + // do we have to worry about phi sector numbering running backwards in phi for z<0 like in EM/HEC ???? - // do we have to worry about phi sector numbering running backwards in phi for z<0 like in EM/HEC ???? + unsigned int index = 192*sideIndex+12*sectorIndex+4*samplingIndex+lineIndex; - unsigned int index = 192*sideIndex+12*sectorIndex+4*samplingIndex+lineIndex; - - if (index>384) { - std::cout << " invalid index for FCAL " << sideIndex << " " << samplingIndex << " " << sectorIndex << " " << lineIndex << std::endl; - continue; - } + if (index>384) { + MsgStream msg (Athena::getMessageSvc(), "EMECHVManager"); + msg << MSG::ERROR << " invalid index for FCAL " << sideIndex << " " << samplingIndex << " " << sectorIndex << " " << lineIndex << endmsg; + continue; + } - m_c->payloadArray[index].voltage=voltage; - m_c->payloadArray[index].current=current; - m_c->payloadArray[index].status=status; - m_c->payloadArray[index].hvLineNo=chanID; - } // if FCAL - } // loop over electrodes - } // loop over collection - } // loop over folders - } // m_c->init + payload->m_payloadArray[index].voltage=voltage; + payload->m_payloadArray[index].current=current; + payload->m_payloadArray[index].hvLineNo=chanID; + } // if FCAL + } // loop over electrodes + } // loop over collection + } // loop over folders + + return FCALHVManager::FCALHVData (std::move (payload)); } -void FCALHVManager::reset() const { - m_c->init=false; +FCALHVManager::FCALHVData +FCALHVManager::getData ATLAS_NOT_THREAD_SAFE () const +{ + std::vector<const CondAttrListCollection*> attrLists; + ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "EMBHVManager"); + const CondAttrListCollection* atrlistcol = nullptr; + if (detStore->retrieve(atrlistcol, "/LAR/DCS/HV/BARREl/I16").isSuccess()) { + attrLists.push_back (atrlistcol); + } + if (detStore->retrieve(atrlistcol, "/LAR/DCS/HV/BARREl/I8").isSuccess()) { + attrLists.push_back (atrlistcol); + } + return getData (LegacyIdFunc(), attrLists); } -FCALHVPayload *FCALHVManager::getPayload(const FCALHVLine &line) const { - update(); - unsigned int lineIndex = line.getLineIndex(); - const FCALHVModule& module = line.getModule(); - unsigned int sectorIndex = module.getSectorIndex(); - unsigned int sideIndex = module.getSideIndex(); - unsigned int samplingIndex = module.getSamplingIndex(); - unsigned int index = 192*sideIndex+12*sectorIndex+4*samplingIndex+lineIndex; - //std::cout << "in Fcal getPayload: " << this << ' ' << index << ' ' << sideIndex << ' ' << sectorIndex << ' ' << samplingIndex << ' ' << lineIndex << std::endl; - return &m_c->payloadArray[index]; + +#if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) +FCALHVManager::FCALHVData +FCALHVManager::getData (const LArHVIdMapping& hvIdMapping, + const std::vector<const CondAttrListCollection*>& attrLists) const +{ + auto idfunc = [&] (HWIdentifier id) { return hvIdMapping.getLArElectrodeIDvec(id); }; + return getData (idfunc, attrLists); } -#if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) int FCALHVManager::hvLineNo(const FCALHVLine& line , const LArHVIdMapping* hvIdMapping) const { diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/FCALHVPayload.h b/LArCalorimeter/LArGeoModel/LArHV/src/FCALHVPayload.h index cfff045575b8043399dc0f226e91a921c452add5..96dacaaafef109f69021eab3ad0d34b6e83bc2a1 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/FCALHVPayload.h +++ b/LArCalorimeter/LArGeoModel/LArHV/src/FCALHVPayload.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef LARHV_FCALHVPAYLOAD_H @@ -8,12 +8,11 @@ struct FCALHVPayload { double voltage; double current; - unsigned int status; int hvLineNo; }; inline std::ostream & operator << (std::ostream & o, const FCALHVPayload & payload) { - o << "FCAL Line: HV Line No " << payload.hvLineNo << ' ' << payload.voltage << " volts; " << payload.current << " amps; status = " << payload.status << std::endl; + o << "FCAL Line: HV Line No " << payload.hvLineNo << ' ' << payload.voltage << " volts; " << payload.current << " amps" << std::endl; return o; } #endif diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/HECHVManager.cxx b/LArCalorimeter/LArGeoModel/LArHV/src/HECHVManager.cxx index 0849948926979b383b112ea58a1e66603419c62f..aba9ba52aadf0f72fa40ed5d299e4274d4eaf798 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/HECHVManager.cxx +++ b/LArCalorimeter/LArGeoModel/LArHV/src/HECHVManager.cxx @@ -10,6 +10,7 @@ #include "HECHVPayload.h" #include "StoreGate/StoreGateSvc.h" +#include "AthenaKernel/getMessageSvc.h" #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/IToolSvc.h" #include "GaudiKernel/Bootstrap.h" @@ -28,6 +29,34 @@ #include "Identifier/HWIdentifier.h" + +namespace { + + +struct ATLAS_NOT_THREAD_SAFE LegacyIdFunc +{ + LegacyIdFunc(); + std::vector<HWIdentifier> operator()(HWIdentifier id) + { + return m_cablingTool->getLArElectrodeIDvec (id); + } + LArHVCablingTool* m_cablingTool; +}; + + +LegacyIdFunc::LegacyIdFunc() +{ + ToolHandle<LArHVCablingTool> tool ("LArHVCablingTool"); + if (!tool.retrieve().isSuccess()) { + std::abort(); + } + m_cablingTool = tool.get(); +} + + +} // Anonymous namespace + + class HECHVManager::Clockwork { public: Clockwork(const HECHVManager* manager) @@ -35,7 +64,7 @@ public: for(int iSide=0; iSide<2; ++iSide) { for(int iPhi=0; iPhi<32; ++iPhi) { for(int iSampling=0; iSampling<4; ++iSampling) { - moduleArray[iSide][iPhi][iSampling] = new HECHVModule(manager,iSide,iPhi,iSampling); + moduleArray[iSide][iPhi][iSampling] = std::make_unique<HECHVModule>(manager,iSide,iPhi,iSampling); } } } @@ -51,25 +80,85 @@ public: } ~Clockwork() { - for(int iSide=0; iSide<2; ++iSide) { - for(int iPhi=0; iPhi<32; ++iPhi) { - for(int iSampling=0; iSampling<4; ++iSampling) { - delete moduleArray[iSide][iPhi][iSampling]; - } - } - } } HECHVDescriptor descriptor{CellBinning(0,2*M_PI,32)}; - const HECHVModule* moduleArray[2][32][4]; - std::atomic<bool> init{false}; - std::mutex mtx; - std::vector<HECHVPayload> payloadArray; + std::unique_ptr<const HECHVModule> moduleArray[2][32][4]; const LArElectrodeID* elecId; const LArHVLineID* hvId; }; + +class HECHVManager::HECHVData::Payload +{ +public: + std::vector<HECHVPayload> m_payloadArray; +}; + + +HECHVManager::HECHVData::HECHVData() +{ +} + + +HECHVManager::HECHVData::HECHVData (std::unique_ptr<Payload> payload) + : m_payload (std::move (payload)) +{ +} + + +HECHVManager::HECHVData& +HECHVManager::HECHVData::operator= (HECHVData&& other) +{ + if (this != &other) { + m_payload = std::move (other.m_payload); + } + return *this; +} + + +HECHVManager::HECHVData::~HECHVData() +{ +} + + +bool HECHVManager::HECHVData::hvOn (const HECHVSubgap& subgap) const +{ + return voltage (subgap) > INVALID; +} + + +double HECHVManager::HECHVData::voltage (const HECHVSubgap& subgap) const +{ + return m_payload->m_payloadArray[index(subgap)].voltage; +} + + +double HECHVManager::HECHVData::current (const HECHVSubgap& subgap) const +{ + return m_payload->m_payloadArray[index(subgap)].current; +} + + +int HECHVManager::HECHVData::hvLineNo (const HECHVSubgap& subgap) const +{ + return m_payload->m_payloadArray[index(subgap)].hvLineNo; +} + + +int HECHVManager::HECHVData::index (const HECHVSubgap& subgap) const +{ + unsigned int subgapIndex = subgap.getSubgapIndex(); + const HECHVModule& module = subgap.getModule(); + unsigned int phiIndex = module.getPhiIndex(); + unsigned int samplingIndex = module.getSamplingIndex(); + unsigned int sideIndex = module.getSideIndex(); + unsigned int index = 512*sideIndex+16*phiIndex+4*samplingIndex+subgapIndex; + return index; +} + + HECHVManager::HECHVManager() - : m_c(new Clockwork(this)) + : m_c (std::make_unique<Clockwork> (this)) { } @@ -117,116 +206,101 @@ const HECHVModule& HECHVManager::getHVModule(unsigned int iSide HECHVManager::~HECHVManager() { - delete m_c; } -void HECHVManager::update() const { - std::lock_guard<std::mutex> lock(m_c->mtx); - if (!(m_c->init)) { - m_c->init=true; - m_c->payloadArray.reserve(2*32*4*4); - for (unsigned int i=0;i<1024;i++) { - m_c->payloadArray[i].voltage = -99999; - } - - ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "HECHVManager"); - - ISvcLocator* svcLocator = Gaudi::svcLocator(); - IToolSvc* toolSvc; - LArHVCablingTool* hvcablingTool; - - if(StatusCode::SUCCESS!=svcLocator->service("ToolSvc",toolSvc)) - return; - - if(StatusCode::SUCCESS!=toolSvc->retrieveTool("LArHVCablingTool",hvcablingTool)) - return; +HECHVManager::HECHVData +HECHVManager::getData (idfunc_t idfunc, + const std::vector<const CondAttrListCollection*>& attrLists) const +{ + auto payload = std::make_unique<HECHVData::Payload>(); + payload->m_payloadArray.reserve(2*32*4*4); + for (unsigned int i=0;i<1024;i++) { + payload->m_payloadArray[i].voltage = HECHVData::INVALID; + } - std::vector<std::string> colnames; - colnames.push_back("/LAR/DCS/HV/BARREl/I16"); - colnames.push_back("/LAR/DCS/HV/BARREL/I8"); + for (const CondAttrListCollection* atrlistcol : attrLists) { - std::vector<std::string>::const_iterator it = colnames.begin(); - std::vector<std::string>::const_iterator ie = colnames.end(); + for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { - for (;it!=ie;it++) { + // Construct HWIdentifier + // 1. decode COOL Channel ID + unsigned int chanID = (*citr).first; + int cannode = chanID/1000; + int line = chanID%1000; - //std::cout << " --- Start reading folder " << (*it) << std::endl; - const CondAttrListCollection* atrlistcol; - if (StatusCode::SUCCESS!=detStore->retrieve(atrlistcol,*it)) - return; + // 2. Construct the identifier + HWIdentifier id = m_c->hvId->HVLineId(1,1,cannode,line); - for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { + std::vector<HWIdentifier> electrodeIdVec = idfunc(id); - // Construct HWIdentifier - // 1. decode COOL Channel ID - unsigned int chanID = (*citr).first; - int cannode = chanID/1000; - int line = chanID%1000; + for(size_t i=0;i<electrodeIdVec.size();i++) { + HWIdentifier& elecHWID = electrodeIdVec[i]; - // 2. Construct the identifier - HWIdentifier id = m_c->hvId->HVLineId(1,1,cannode,line); + int detector = m_c->elecId->detector(elecHWID); - std::vector<HWIdentifier> electrodeIdVec = hvcablingTool->getLArElectrodeIDvec(id); + // check we are in HEC + if (detector != 4) { + continue; + } - for(size_t i=0;i<electrodeIdVec.size();i++) { - HWIdentifier& elecHWID = electrodeIdVec[i]; + float voltage = HECHVData::INVALID; + if (!((*citr).second)["R_VMEAS"].isNull()) voltage = ((*citr).second)["R_VMEAS"].data<float>(); + float current = 0.; + if (!((*citr).second)["R_IMEAS"].isNull()) current = ((*citr).second)["R_IMEAS"].data<float>(); - int detector = m_c->elecId->detector(elecHWID); + + unsigned int sideIndex=1-m_c->elecId->zside(elecHWID); // 0 for C side, 1 for A side, opposite to HV numbering + unsigned int phiIndex=m_c->elecId->module(elecHWID); // 0 to 31 + unsigned int samplingIndex=m_c->elecId->hv_eta(elecHWID)-1; // 0 to 3 + unsigned int subgapIndex=m_c->elecId->gap(elecHWID); // 0 to 3 - // check we are in HEC - if (detector != 4) { - //std::cout << " Not HEC ??? " << std::endl; - continue; - } + unsigned int index = 512*sideIndex+16*phiIndex+4*samplingIndex+subgapIndex; - float voltage = -99999.; - if (!((*citr).second)["R_VMEAS"].isNull()) voltage = ((*citr).second)["R_VMEAS"].data<float>(); - float current = 0.; - if (!((*citr).second)["R_IMEAS"].isNull()) current = ((*citr).second)["R_IMEAS"].data<float>(); - unsigned int status = 0; - if (!((*citr).second)["R_STAT"].isNull()) status = ((*citr).second)["R_STAT"].data<unsigned int>(); + if (index>1023) { + MsgStream msg (Athena::getMessageSvc(), "EMECHVManager"); + msg << MSG::ERROR << "invalid index " << index << " side,phi,sampling,gap " << sideIndex << " " << phiIndex << " " << samplingIndex + << " " << subgapIndex << endmsg; + continue; + } - unsigned int sideIndex=1-m_c->elecId->zside(elecHWID); // 0 for C side, 1 for A side, opposite to HV numbering - unsigned int phiIndex=m_c->elecId->module(elecHWID); // 0 to 31 - unsigned int samplingIndex=m_c->elecId->hv_eta(elecHWID)-1; // 0 to 3 - unsigned int subgapIndex=m_c->elecId->gap(elecHWID); // 0 to 3 + payload->m_payloadArray[index].voltage=voltage; + payload->m_payloadArray[index].current=current; + payload->m_payloadArray[index].hvLineNo=chanID; + } // For (electrodeIdVec) + } // for (atrlistcol) + } - unsigned int index = 512*sideIndex+16*phiIndex+4*samplingIndex+subgapIndex; + return HECHVManager::HECHVData (std::move (payload)); +} - if (index>1023) { - std::cout << "invalid index " << index << " side,phi,sampling,gap " << sideIndex << " " << phiIndex << " " << samplingIndex - << " " << subgapIndex << std::endl; - continue; - } - - m_c->payloadArray[index].voltage=voltage; - m_c->payloadArray[index].current=current; - m_c->payloadArray[index].status=status; - m_c->payloadArray[index].hvLineNo=chanID; - } // For (electrodeIdVec) - } // for (atrlistcol) - } - } // if(!m_c->init) +HECHVManager::HECHVData +HECHVManager::getData ATLAS_NOT_THREAD_SAFE () const +{ + std::vector<const CondAttrListCollection*> attrLists; + ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "EMBHVManager"); + const CondAttrListCollection* atrlistcol = nullptr; + if (detStore->retrieve(atrlistcol, "/LAR/DCS/HV/BARREl/I16").isSuccess()) { + attrLists.push_back (atrlistcol); + } + if (detStore->retrieve(atrlistcol, "/LAR/DCS/HV/BARREl/I8").isSuccess()) { + attrLists.push_back (atrlistcol); + } + return getData (LegacyIdFunc(), attrLists); } -void HECHVManager::reset() const { - m_c->init=false; -} -HECHVPayload *HECHVManager::getPayload(const HECHVSubgap &subgap) const { - update(); - unsigned int subgapIndex = subgap.getSubgapIndex(); - const HECHVModule& module = subgap.getModule(); - unsigned int phiIndex = module.getPhiIndex(); - unsigned int samplingIndex = module.getSamplingIndex(); - unsigned int sideIndex = module.getSideIndex(); - unsigned int index = 512*sideIndex+16*phiIndex+4*samplingIndex+subgapIndex; - return &m_c->payloadArray[index]; +#if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) +HECHVManager::HECHVData +HECHVManager::getData (const LArHVIdMapping& hvIdMapping, + const std::vector<const CondAttrListCollection*>& attrLists) const +{ + auto idfunc = [&] (HWIdentifier id) { return hvIdMapping.getLArElectrodeIDvec(id); }; + return getData (idfunc, attrLists); } -#if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) + int HECHVManager::hvLineNo(const HECHVSubgap& subgap , const LArHVIdMapping* hvIdMapping) const { const HECHVModule& module = subgap.getModule(); diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/HECHVPayload.h b/LArCalorimeter/LArGeoModel/LArHV/src/HECHVPayload.h index 977dff9d7984b159ceafa46d2837091c8bb3ea02..bbaa5d2b26d57643c86785b2e3f655589d2b3bc8 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/HECHVPayload.h +++ b/LArCalorimeter/LArGeoModel/LArHV/src/HECHVPayload.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef LARHV_HECHVPAYLOAD_H @@ -8,12 +8,11 @@ struct HECHVPayload { double voltage; double current; - unsigned int status; int hvLineNo; }; inline std::ostream & operator << (std::ostream & o, const HECHVPayload & payload) { - o << "HEC Subgap: HV Line No " << payload.hvLineNo << ' ' << payload.voltage << " volts; " << payload.current << " amps; status = " << payload.status << std::endl; + o << "HEC Subgap: HV Line No " << payload.hvLineNo << ' ' << payload.voltage << " volts; " << payload.current << " amps" << std::endl; return o; } #endif diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/HECHVSubgap.cxx b/LArCalorimeter/LArGeoModel/LArHV/src/HECHVSubgap.cxx index 8a0297cefdd4f0730bb4d0e738460699954cbee7..e2c94187b5f21e63499f81353026635137283a3d 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/HECHVSubgap.cxx +++ b/LArCalorimeter/LArGeoModel/LArHV/src/HECHVSubgap.cxx @@ -41,37 +41,8 @@ unsigned int HECHVSubgap::getSubgapIndex() const return m_c->iSubgap; } -bool HECHVSubgap::hvOn() const -{ - HECHVPayload *payload = m_c->module->getManager().getPayload(*this); - return (payload->voltage>=-9999); -} - -double HECHVSubgap::voltage() const { - HECHVPayload *payload = m_c->module->getManager().getPayload(*this); - return payload->voltage; -} - - -double HECHVSubgap::current() const { - HECHVPayload *payload = m_c->module->getManager().getPayload(*this); - return payload->current; -} - -void HECHVSubgap::voltage_current(double& voltage, double¤t) const { - HECHVPayload *payload = m_c->module->getManager().getPayload(*this); - voltage = payload->voltage; - current = payload->current; -} - #if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE)) int HECHVSubgap::hvLineNo(const LArHVIdMapping* hvIdMapping) const { - return hvIdMapping - ? m_c->module->getManager().hvLineNo(*this,hvIdMapping) - : m_c->module->getManager().getPayload(*this)->hvLineNo; -} -#else -int HECHVSubgap::hvLineNo() const { - return m_c->module->getManager().getPayload(*this)->hvLineNo; + return m_c->module->getManager().hvLineNo(*this,hvIdMapping); } #endif diff --git a/LArCalorimeter/LArGeoModel/LArHV/src/LArHVManager.cxx b/LArCalorimeter/LArGeoModel/LArHV/src/LArHVManager.cxx index 1bcef1d250729d8e3c43a22017a9538118d038d2..94e3a9afec476074de7a3acf3d9d75c752940972 100644 --- a/LArCalorimeter/LArGeoModel/LArHV/src/LArHVManager.cxx +++ b/LArCalorimeter/LArGeoModel/LArHV/src/LArHVManager.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArHV/LArHVManager.h" @@ -21,18 +21,6 @@ LArHVManager::LArHVManager() { } -void LArHVManager::reset() const -{ - m_embHV.reset(); - m_emecHVInner.reset(); - m_emecHVOuter.reset(); - m_hecHV.reset(); - m_fcalHV.reset(); - m_embPreHV.reset(); - m_emecPreHV.reset(); -} - - LArHVManager::~LArHVManager() { } diff --git a/LArCalorimeter/LArRecUtils/src/LArADC2MeVTool.cxx b/LArCalorimeter/LArRecUtils/src/LArADC2MeVTool.cxx index d0cb9f9ed5f23f73f5b64b5a4a1c4fc1058dc210..9bebaac9a3b32803e59efbf7763b176219cb83b1 100644 --- a/LArCalorimeter/LArRecUtils/src/LArADC2MeVTool.cxx +++ b/LArCalorimeter/LArRecUtils/src/LArADC2MeVTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArADC2MeVTool.h" @@ -396,13 +396,6 @@ StatusCode LArADC2MeVTool::getADC2MeV() const { for(unsigned int igain=0;igain<ngains;igain++) if ( m_isSC ) m_ADC2MeV_vec[idhash] = std::vector<float>(0); else m_ADC2MeV->setPdata(id,std::vector<float>(0),igain); - // -// std::vector<float> vADC2MeV; -// vADC2MeV.push_back(0); -// //std::cout << "setting disconnected Feb id "<< feb.get_compact() <<" channel " << chan << std::endl; -// m_ADC2MeV->setPdata(id,vADC2MeV,igain); -// } - }//End loop over channels ATH_MSG_INFO("Ntotal = " << count); diff --git a/LArCalorimeter/LArRecUtils/src/LArFCalTowerStore.cxx b/LArCalorimeter/LArRecUtils/src/LArFCalTowerStore.cxx index 1b849095818946d7dd157f30b9a8740ed96315e0..4932ba90feb8acbe8e8639b83f6124bc2112e510 100644 --- a/LArCalorimeter/LArRecUtils/src/LArFCalTowerStore.cxx +++ b/LArCalorimeter/LArRecUtils/src/LArFCalTowerStore.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /******************************************************************** @@ -126,11 +126,8 @@ bool LArFCalTowerStore::buildLookUp(const CaloCell_ID& cellIdHelper, for( size_t cellIndex = m_indxOffset; cellIndex <= m_indxBound; cellIndex++){ - //size_t anIndex = this->getLookupIndex(cellIndex); - - //std::cout<<"cell:"<<anIndex<<std::endl; - // get cell geometry + // get cell geometry const CaloDetDescrElement* theElement = theManager.get_element(cellIndex); if (!theElement) { msg << MSG::ERROR<< "Can't find element for index " << cellIndex diff --git a/LArCalorimeter/LArRecUtils/src/LArHVCondAlg.cxx b/LArCalorimeter/LArRecUtils/src/LArHVCondAlg.cxx index 13d246781def7bcb89f3aa92eb45550beba5b17a..aeef11103c4704f825188ed321347b30d29155d6 100755 --- a/LArCalorimeter/LArRecUtils/src/LArHVCondAlg.cxx +++ b/LArCalorimeter/LArRecUtils/src/LArHVCondAlg.cxx @@ -197,10 +197,6 @@ StatusCode LArHVCondAlg::execute(const EventContext& ctx) const { } } - const LArHVManager *manager = NULL; - if (detStore()->retrieve(manager)==StatusCode::SUCCESS) { - manager->reset(); - } std::vector<float> voltage; std::vector<float> current; std::vector<unsigned int> hvlineidx; @@ -382,7 +378,6 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata v.clear(); ihv.clear(); if (abs(m_larem_id->barrel_ec(id))==1 && m_larem_id->sampling(id) > 0) { // LAr EMB - //std::cout << " in barrel " << m_larem_id->show_to_string(id) << std::endl; unsigned int index = (unsigned int)(m_larem_id->channel_hash(id)); bool hasPathology=false; if (index<hasPathologyEM.size()) { @@ -395,13 +390,11 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata if (!embElement) std::abort(); const EMBCellConstLink cell = embElement->getEMBCell(); unsigned int nelec = cell->getNumElectrodes(); - //std::cout << " nelec: " << nelec << std::endl; unsigned int ngap = 2*nelec; double wt = 1./ngap; v.clear(); ihv.clear(); for (unsigned int i=0;i<nelec;i++) { const EMBHVElectrode& electrode = cell->getElectrode(i); - //std::cout << "electrode: endcap index, eta index , phi index, sector index , electrode index " << electrode->getModule()->getSideIndex() << // " " << electrode->getModule()->getEtaIndex() << " " << electrode->getModule()->getPhiIndex() << // " " << electrode->getModule()->getSectorIndex() << " " << electrode->getElectrodeIndex() << std::endl; for (unsigned int igap=0;igap<2;igap++) { @@ -441,8 +434,6 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata } msg(MSG::VERBOSE) << "set hv: "<<hv<<endmsg; } - //std::cout << " hv value " << hv << std::endl; - //if (igap==1 && hv>1.) std::cout << " --- non zero value found for gap1 in barrel " << std::endl; addHV(v,hv,wt); addCurr(ihv,curr,wt); } @@ -490,7 +481,6 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata } } else if (abs(m_larem_id->barrel_ec(id))>1 && m_larem_id->sampling(id) > 0){ // LAr EMEC - //std::cout << " in EMEC " << m_larem_id->show_to_string(id) << std::endl; unsigned int index = (unsigned int)(m_larem_id->channel_hash(id)); bool hasPathology=false; if (index<hasPathologyEM.size()) { @@ -504,14 +494,10 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata if (!emecElement) std::abort(); const EMECCellConstLink cell = emecElement->getEMECCell(); unsigned int nelec = cell->getNumElectrodes(); - //std::cout << " nelec " << nelec << std::endl; unsigned int ngap = 2*nelec; double wt = 1./ngap; for (unsigned int i=0;i<nelec;i++) { const EMECHVElectrode& electrode = cell->getElectrode(i); - // std::cout << "electrode: endcap index, eta index , phi index, sector index , electrode index " << electrode->getModule()->getSideIndex() << - // " " << electrode->getModule()->getEtaIndex() << " " << electrode->getModule()->getPhiIndex() << - // " " << electrode->getModule()->getSectorIndex() << " " << electrode->getElectrodeIndex() << std::endl; for (unsigned int igap=0;igap<2;igap++) { unsigned int hvline = electrode.hvLineNo(igap,hvCabling); const std::vector<unsigned int>::const_iterator itrLine=std::lower_bound(hvlineidx.begin(), hvlineidx.end(), hvline); @@ -546,8 +532,6 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata } } } - //std::cout << " hv value " << hv << std::endl; - //if (igap==1 && hv>1.) std::cout << " --- non zero value found for gap1 in endcap " << std::endl; addHV(v,hv,wt); addCurr(ihv,curr,wt); } @@ -626,7 +610,6 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata for( auto id: m_larhec_id->channel_ids()) { v.clear(); ihv.clear(); - //std::cout << " in HEC " << std::endl; unsigned int index = (unsigned int)(m_larhec_id->channel_hash(id)); bool hasPathology=false; if (index<hasPathologyHEC.size()) { @@ -640,7 +623,6 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata const HECCellConstLink cell = hecElement->getHECCell(); unsigned int nsubgaps = cell->getNumSubgaps(); double wt = 1./nsubgaps; - //std::cout << " nsubgaps " << nsubgaps << std::endl; for (unsigned int i=0;i<nsubgaps;i++) { const HECHVSubgap& subgap = cell->getSubgap(i); unsigned int hvline = subgap.hvLineNo(hvCabling); @@ -668,7 +650,6 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata )); curr *= uAkOhm * rValues[ridx]; } - //std::cout << " hv value " << hv << std::endl; if (hasPathology) { msg(MSG::VERBOSE) << "Has pathology for id: "<< m_larhec_id->print_to_string(id)<<" "<<hasPathologyHEC[index]<<endmsg; for (unsigned int ii=0;ii<listElec.size();ii++) { @@ -710,7 +691,6 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata for(auto id: m_larfcal_id->channel_ids()) { // LAr FCAL v.clear(); ihv.clear(); - //std::cout << " in FCAL " << std::endl; unsigned int index = (unsigned int)(m_larfcal_id->channel_hash(id)); bool hasPathology=false; if (index<hasPathologyFCAL.size()) { @@ -722,16 +702,12 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata const FCALDetectorElement* fcalElement = dynamic_cast<const FCALDetectorElement*>(calodetdescrmgr->get_element(id)); if (!fcalElement) std::abort(); const FCALTile* tile = fcalElement->getFCALTile(); - //std::cout << " --- in FCAL cell id " << m_larfcal_id->show_to_string(id) << std::endl; - //std::cout << " Side, Module, I,J index " << tile->getModule()->getEndcapIndex() << " " << tile->getModule()->getModuleIndex() - // << " " << tile->getIndexI() << " " << tile->getIndexJ() << std::endl; unsigned int nlines = tile->getNumHVLines(); unsigned int nlines_found=0; for (unsigned int i=0;i<nlines;i++) { const FCALHVLine* line = tile->getHVLine(i); if (line) nlines_found++; } - //std::cout << " nlines " << nlines << " " << nlines_found << std::endl; if (nlines_found>0) { double wt = 1./nlines_found; for (unsigned int i=0;i<nlines;i++) { @@ -762,7 +738,6 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata )); curr *= uAkOhm * rValues[ridx]; } - //std::cout << " line " << line; if (hasPathology) { msg(MSG::VERBOSE) << "Has pathology for id: "<< m_larfcal_id->print_to_string(id)<<" "<<hasPathologyFCAL[index]<<endmsg; for (unsigned int ii=0;ii<listElec.size();ii++) { @@ -772,7 +747,6 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata } } } - //std::cout << " hv value " << hv << std::endl; addHV(v,hv,wt); addCurr(ihv,curr,wt); } @@ -1565,7 +1539,6 @@ StatusCode LArHVCondAlg::updateMethod(CaloAffectedRegionInfoVec *vAffected, cons extendPhiRegion(current_phi_low,phi_min_additive1,phi_max_additive1); extendPhiRegion(current_phi_high,phi_min_additive1,phi_max_additive1); - // std::cout << "found the special case, icha=" << icha << ", etamin=" << eta_min_additive1 << ", current layer=" << current_layer << ", current eta=" << current_eta << std::endl; } else { //normal case is_normal=1; // normal case diff --git a/LArCalorimeter/LArRecUtils/src/LArHVIdMappingAlg.cxx b/LArCalorimeter/LArRecUtils/src/LArHVIdMappingAlg.cxx index 19ec59b8cdc4a6ca1070dc1ecb00108376776ddd..ada5c82c2d292de50af5bcb8be4f4ef63dc66f2a 100644 --- a/LArCalorimeter/LArRecUtils/src/LArHVIdMappingAlg.cxx +++ b/LArCalorimeter/LArRecUtils/src/LArHVIdMappingAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArHVIdMappingAlg.h" @@ -200,8 +200,6 @@ void LArHVIdMappingAlg::fillHVMap(std::map<HWIdentifier,HWIdentifier> & elmap, s electrodeIdvec.clear(); HWIdentifier hvlineId = hvlineHelper->HVLineId(hvpartition,hvcanline,hvcannode,hvline); - //std::cout << " module, line " << hvcannode << " " << hvline << " ---- > hvLineId " << hvlineId << std::endl; - if( max > min ){ if (min < 0) min = 0; if (max < 0) max = 0; @@ -222,12 +220,6 @@ void LArHVIdMappingAlg::fillHVMap(std::map<HWIdentifier,HWIdentifier> & elmap, s //ATH_MSG_DEBUG("[fillHVMap] push_back in electrodeId vector..." ); // Check if electrode is already in map ? - // std::map<HWIdentifier,HWIdentifier>::iterator testIt = elmap.find(electrodeId); - // if (testIt != elmap.end()) { - // std::cout << " ----- Electrode Id " << side << " " << mod << " " << hvphi << " " << hveta << " " << hvgap << " " << ielec << - // " read for HvLine " << hvcannode << " " << hvline << " " << hvlineId << " already exist for " << (testIt)->second << std::endl; - // } - elmap.insert(std::pair<HWIdentifier,HWIdentifier>(electrodeId,hvlineId)); } } @@ -237,12 +229,6 @@ void LArHVIdMappingAlg::fillHVMap(std::map<HWIdentifier,HWIdentifier> & elmap, s electrodeIdvec.push_back(electrodeId); // Check if electrode is already in map ? - // std::map<HWIdentifier,HWIdentifier>::iterator testIt = elmap.find(electrodeId); - // if (testIt != elmap.end()) { - // std::cout << " ----- Electrode Id " << side << " " << mod << " " << hvphi << " " << hveta << " " << hvgap << " " << min << - // " read for HvLine " << hvcannode << " " << hvline << " " << hvlineId << " already exist for " << (testIt)->second << std::endl; - // } - elmap.insert(std::pair<HWIdentifier,HWIdentifier>(electrodeId,hvlineId)); } diff --git a/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.cxx b/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.cxx index 96361de3c3c5de40899fa485a2fcb4a128b158bb..d3971fe10491b7289855ee405dda86727d739023 100644 --- a/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.cxx +++ b/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.cxx @@ -532,7 +532,6 @@ float LArHVScaleCorrCondAlg::Scale_barrel(const float hv) const else { resp=facteur[0]*(hv/hvref[0]); } - //std::cout << " hv,i1,i2,resp " << hv << " " << i1 << " " << i2 << " " << resp << std::endl; return resp; } diff --git a/LArCalorimeter/LArRecUtils/src/LArOFPeakRecoTool.cxx b/LArCalorimeter/LArRecUtils/src/LArOFPeakRecoTool.cxx index e03488903ac58dd4736b4714467575821eb2067f..fa475919b67f5ee2023b76b33773593b5be45454 100644 --- a/LArCalorimeter/LArRecUtils/src/LArOFPeakRecoTool.cxx +++ b/LArCalorimeter/LArRecUtils/src/LArOFPeakRecoTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArRecUtils/LArOFPeakRecoTool.h" @@ -121,7 +121,6 @@ LArOFIterResults LArOFPeakRecoTool::peak(const std::vector<float>& samples, // r //Computation is done as double double At=0; double A=0; - //std::cout << "***** ChannelID=" << (int)chID << " ; Gain=" << (int)gain << " ; Delay=" << delay << " nIter=" << nIter << std::endl ; //Tying to avoid doing all checks for every event/channel/iteation step by assuming that //the number of OFC samples is the same for all delays of a certain cell/gain. @@ -175,13 +174,10 @@ LArOFIterResults LArOFPeakRecoTool::peak(const std::vector<float>& samples, // r delayIdx=(unsigned)floor(0.5+delay/timeBinWidth); } - //std::cout << "Timebinwidth=" << timeBinWidth << " nOFCPhase=" << nOFCPhase << std::endl; - //std::cout << "Delay= " << delay << " Index=" << delayIdx << std::endl; //Get first set of OFC's ILArOFC::OFCRef_t this_OFC_a = dd_ofc->OFC_a(chID,(int)usedGain,delayIdx); ILArOFC::OFCRef_t this_OFC_b = dd_ofc->OFC_b(chID,(int)usedGain,delayIdx); const unsigned ofcSize=this_OFC_a.size(); //Assumed to be the same of all delay-indices - //std::cout << " got OFC " << this_OFC_a.size() << " " << this_OFC_b.size() << std::endl; //some sanity check on the OFCs if ( ofcSize == 0 || this_OFC_b.size() == 0 ) { @@ -207,17 +203,6 @@ LArOFIterResults LArOFPeakRecoTool::peak(const std::vector<float>& samples, // r if(kMax<peak_low) kMax=peak_low; if(kMax>peak_high) kMax=peak_high; - /* - std::cout << "Samples: "; - for ( unsigned k=0;k<samples.size();k++) - std::cout << " " << samples[k]; - std::cout << std::endl; - std::cout << "OFC_a: "; - for ( unsigned k=0;k<this_OFC_a.size();k++) - std::cout << " " << this_OFC_a.at(k); - std::cout << std::endl; - */ - float amplitude_save=0.; float tau_save= 99999.; unsigned int kMax_save=0; @@ -227,7 +212,6 @@ LArOFIterResults LArOFPeakRecoTool::peak(const std::vector<float>& samples, // r unsigned int mynIter = nIter; do { - //std::cout << "*** Start iteration step: "<< kIter << " kmax=" <<kMax << " delay=" << delay << std::endl; // Uncomment the following if you suspect that the ofc are corrupt for some phases: /* @@ -264,7 +248,6 @@ LArOFIterResults LArOFPeakRecoTool::peak(const std::vector<float>& samples, // r } result.m_amplitude=A; result.m_tau = At / A ; - //std::cout << "Iteration step: " << kIter << " Delay=" << delay << " A = " << A << " tau=" << result.m_tau << std::endl; //First iteration done, break loop if possible.... if (mynIter<=1) { @@ -281,13 +264,11 @@ LArOFIterResults LArOFPeakRecoTool::peak(const std::vector<float>& samples, // r // if we are within +-0.5*Dt of time bin, we have converged for sure if (fabs(result.m_tau) <= (0.5*timeBinWidth)) { result.m_converged=true; - // std::cout << "Converged." << std::endl; delay = delayIdx*timeBinWidth; break; } if (kIter>=mynIter) { //Max. number of iterations reached - //std::cout << "Did not converge after " << nIter << " iterations." << std::endl; delay = delayIdx*timeBinWidth; if (result.m_converged) { if (fabs(tau_save) < fabs(result.m_tau)) { @@ -314,7 +295,6 @@ LArOFIterResults LArOFPeakRecoTool::peak(const std::vector<float>& samples, // r delayIdx_save = delayIdx; } - //std::cout << "not yet converged" << std::endl ; delay = delay - result.m_tau; // moved this line up so first iteration delay results treated like subsequent if(delay<(-0.5*timeBinWidth)) { @@ -323,9 +303,7 @@ LArOFIterResults LArOFPeakRecoTool::peak(const std::vector<float>& samples, // r delay=delay+m_samplingPeriod; if( delay < 0 ) delay = 0; if (delay > timeMax ) delay = timeMax-epsilon; - //std::cout << " delay too small, shift sample, set delay to " << delay << std::endl ; } else { // don't shift sample - //std::cout << " delay too small, set delay to 0 "<< std::endl ; delay = 0 ; } }//else if delay<0 @@ -336,10 +314,8 @@ LArOFIterResults LArOFPeakRecoTool::peak(const std::vector<float>& samples, // r delay=delay-m_samplingPeriod; if (delay < 0 ) delay=0.; if( delay > timeMax ) delay = timeMax-epsilon; - //std::cout << " delay too large , shift sample "<< std::endl ; } else { // don't shift sample - //std::cout << " delay too large set delay to max "<< std::endl ; delay = timeMax-epsilon; } }//end if delay>nOFCPhase @@ -347,7 +323,6 @@ LArOFIterResults LArOFPeakRecoTool::peak(const std::vector<float>& samples, // r kIter++; delayIdx=(unsigned)floor(0.5+delay/timeBinWidth); if (delayIdx>=nOFCPhase) delayIdx = nOFCPhase-1; - //std::cout << " new kMax, delay,delayIdx " << kMax << " " << delay << " " << delayIdx << std::endl; //Get next set of OFC's this_OFC_a = dd_ofc->OFC_a(chID,(int)usedGain,delayIdx); this_OFC_b = dd_ofc->OFC_b(chID,(int)usedGain,delayIdx); @@ -357,7 +332,6 @@ LArOFIterResults LArOFPeakRecoTool::peak(const std::vector<float>& samples, // r // go back to overal time delay = delay + timeOffset; // sign to check - //std::cout << "Done! A= " << result.m_amplitude << " ; tau= " << result.m_tau << " kIter=" << kIter << " nIter=" << nIter << std::endl; // get shape if (m_useShape){ const ILArShape* dd_shape=nullptr; diff --git a/LArCalorimeter/LArRecUtils/src/LArOnOffMappingAlg.cxx b/LArCalorimeter/LArRecUtils/src/LArOnOffMappingAlg.cxx index 1eb01fc333509b0bf1de08e2492650d5601ed1fd..cc55fd2f5c69b0254658327ceb702a7e984016db 100644 --- a/LArCalorimeter/LArRecUtils/src/LArOnOffMappingAlg.cxx +++ b/LArCalorimeter/LArRecUtils/src/LArOnOffMappingAlg.cxx @@ -1,7 +1,7 @@ //dear emacs, this is -*-c++-*- /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArOnOffMappingAlg.h" @@ -111,7 +111,6 @@ StatusCode LArOnOffMappingAlg::execute() { for (unsigned i=0;i<nChan;++i) { const Identifier id=Identifier(Identifier32(pBlobOnOff[i])); - //std::cout << "id[" << i <<"] " << std::hex << id.get_compact() << std::dec << std::endl; if (id.is_valid()) { const IdentifierHash oflHash=calocellID->calo_cell_hash(id); const HWIdentifier hwid=larOnlineID->channel_Id(IdentifierHash(i)); diff --git a/LArCalorimeter/LArRecUtils/src/LArParabolaPeakRecoTool.cxx b/LArCalorimeter/LArRecUtils/src/LArParabolaPeakRecoTool.cxx index 84a58b36be417aa62742b7b2804018133728df4b..faf83eb1046b12eae023e09223202a5395ed476d 100644 --- a/LArCalorimeter/LArRecUtils/src/LArParabolaPeakRecoTool.cxx +++ b/LArCalorimeter/LArRecUtils/src/LArParabolaPeakRecoTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArRecUtils/LArParabolaPeakRecoTool.h" @@ -125,7 +125,6 @@ std::vector<float> LArParabolaPeakRecoTool::peak (const std::vector<float>& samp HepVector beta(3); for (int i=0;i<3;i++) {beta[i]=*(it_max-1+i); - //std::cout << " " << beta[i]; for (int j=0;j<3;j++) alpha[i][j]=pow(-1+i,j); } @@ -159,8 +158,6 @@ std::vector<float> LArParabolaPeakRecoTool::peak (const std::vector<float>& samp } } - //std::cout << "Parabola: Time=" << tmax << " adcmax=" << maxadc << " retval= " << retval << std::endl; - solution.push_back(retval); if(!m_correctBias){ solution.push_back(tmax); diff --git a/LArCalorimeter/LArRecUtils/src/LArShapePeakRecoTool.cxx b/LArCalorimeter/LArRecUtils/src/LArShapePeakRecoTool.cxx index 28b8e31e06938653f550b81a726997a99b599099..dc59a42d831b99f54d9989ffda006e0ecfdc317f 100644 --- a/LArCalorimeter/LArRecUtils/src/LArShapePeakRecoTool.cxx +++ b/LArCalorimeter/LArRecUtils/src/LArShapePeakRecoTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "LArRecUtils/LArShapePeakRecoTool.h" @@ -52,8 +52,6 @@ std::vector<float> LArShapePeakRecoTool::peak (const std::vector<float>& samples delay_max = distance(wave.begin(),wave_max); - // std::cout << "wave[0] = " << wave[0] << std::endl; - // parabola approximation of shape maximum d = (int) delay_max; GetShapeParMax(delay_max,shape_max,delay_max-1,wave[d-1], @@ -96,15 +94,10 @@ std::vector<float> LArShapePeakRecoTool::peak (const std::vector<float>& samples s2 = sample_2ndmax + 1; } - // std::cout << "sample_max = " << sample_max << ", sample_2ndmax = " << sample_2ndmax << ", s1 = " << s1 << ", s2 = " << s2 << std::endl; - // Get delay Limits d1 = 0; d2 = nbin-1-(s2-s1)*24; - // std::cout << "d2 = " << d2 << ", s1 = " << s1 << ", s2 = " << s2 << std::endl; - // std::cout << "sample max = " << sample_max << std::endl; - // Loop on all delays to find the best chi2 // i.e. minimise // chi2 = yi2-yigi*lambda = yi2-yigi*yigi/gi2 @@ -142,9 +135,6 @@ std::vector<float> LArShapePeakRecoTool::peak (const std::vector<float>& samples float adc_reco = lambda*shape_max; - // std::cout << "shape max = " << shape_max << ", adc max = " << adc_max << ", lambda = " << lambda << std::endl; - // std::cout << "delay best = " << delay_best << std::endl; - float time_reco = delay_best; if(delay_best<adc_max) time_reco = delay_best; diff --git a/LArCalorimeter/LArRecUtils/src/MakeLArCellFromRaw.cxx b/LArCalorimeter/LArRecUtils/src/MakeLArCellFromRaw.cxx index c20397cb439e890b3a1bd1461188f69379e2ac54..451f897387605c116f3549c07db165d73c757b86 100644 --- a/LArCalorimeter/LArRecUtils/src/MakeLArCellFromRaw.cxx +++ b/LArCalorimeter/LArRecUtils/src/MakeLArCellFromRaw.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // implementation of MakeLArCellFromRaw @@ -378,7 +378,6 @@ MakeLArCellFromRaw::getCorrection(LArCell* cell, } double c= cell->energy()/en; -// std::cout<<" Correction init = "<<c<<std::endl; return c; } diff --git a/graphics/VP1/VP1Systems/VP1CaloReadoutSystems/src/VP1CaloReadoutSystem.cxx b/graphics/VP1/VP1Systems/VP1CaloReadoutSystems/src/VP1CaloReadoutSystem.cxx index 9342eb2d443ac4e114f3af9edb5b765b9d5d05ae..2ab7b3a52035a93cde344081e79c53cb0cd6ae91 100755 --- a/graphics/VP1/VP1Systems/VP1CaloReadoutSystems/src/VP1CaloReadoutSystem.cxx +++ b/graphics/VP1/VP1Systems/VP1CaloReadoutSystems/src/VP1CaloReadoutSystem.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "VP1CaloReadoutSystems/VP1CaloReadoutSystem.h" @@ -774,6 +774,7 @@ void VP1CaloReadoutSystem::createHV() { const EMBHVManager& embHVManager = larHVManager->getEMBHVManager(); + const EMBHVManager::EMBHVData hvdata_EMB = embHVManager.getData(); for (unsigned int e=embHVManager.beginSideIndex();e!=embHVManager.endSideIndex();e++) { for (unsigned int s=embHVManager.beginSectorIndex();s!=embHVManager.endSectorIndex();s++) { for (unsigned int y=embHVManager.beginEtaIndex();y!=embHVManager.endEtaIndex();y++) { @@ -807,8 +808,8 @@ void VP1CaloReadoutSystem::createHV() { for (unsigned int i=0;i<embMod.getNumElectrodes();i++) { const EMBHVElectrode& electrode = embMod.getElectrode(i); - double voltage0 = electrode.voltage(0); - double voltage1 = electrode.voltage(1); + double voltage0 = hvdata_EMB.voltage (electrode, 0); + double voltage1 = hvdata_EMB.voltage (electrode, 1); double nominalVoltage = m_clockwork->ui.embNominalSpinBox->value(); bool outOfTolerance = (fabs(voltage0-nominalVoltage) > double (tolerance)) || (fabs(voltage1-nominalVoltage) > double (tolerance)) ; bool missing = voltage0 == -99999 || voltage1 == -99999; @@ -840,6 +841,7 @@ void VP1CaloReadoutSystem::createHV() { } const EMBPresamplerHVManager& embPreHVManager = larHVManager->getEMBPresamplerHVManager(); + const EMBPresamplerHVManager::EMBPresamplerHVData hvdata_EMBPS = embPreHVManager.getData(); for (unsigned int e=embPreHVManager.beginSideIndex();e!=embPreHVManager.endSideIndex();e++) { for (unsigned int y=embPreHVManager.beginEtaIndex();y!=embPreHVManager.endEtaIndex();y++) { for (unsigned int p=embPreHVManager.beginPhiIndex();p!=embPreHVManager.endPhiIndex();p++) { @@ -865,8 +867,8 @@ void VP1CaloReadoutSystem::createHV() { ls->vertexProperty=vtxProperty; m_clockwork->embPreModsSeparator->addChild(ls); - double voltage0 = embMod.voltage(0); - double voltage1 = embMod.voltage(1); + double voltage0 = hvdata_EMBPS.voltage (embMod, 0); + double voltage1 = hvdata_EMBPS.voltage (embMod, 1); double nominalVoltage = m_clockwork->ui.embPresamplerNominalSpinBox->value(); bool outOfTolerance = (fabs(voltage0-nominalVoltage) > double (tolerance)) || (fabs(voltage1-nominalVoltage) > double (tolerance)) ; bool missing = voltage0 == -99999 || voltage1 == -99999; @@ -905,6 +907,7 @@ void VP1CaloReadoutSystem::createHV() { QSpinBox **spinBoxes = iotype==EMECHVModule::OUTER ? emecSpinBoxOuter : emecSpinBoxInner; const EMECHVManager& emecHVManager = larHVManager->getEMECHVManager(iotype); + const EMECHVManager::EMECHVData hvdata_EMEC = emecHVManager.getData(); for (unsigned int e=emecHVManager.beginSideIndex();e!=emecHVManager.endSideIndex();e++) { double z = e==0 ? -3740:3740; for (unsigned int s=emecHVManager.beginSectorIndex();s!=emecHVManager.endSectorIndex();s++) { @@ -936,8 +939,8 @@ void VP1CaloReadoutSystem::createHV() { for (unsigned int i=0;i<emecMod.getNumElectrodes();i++) { const EMECHVElectrode& electrode = emecMod.getElectrode(i); - double voltage0 = electrode.voltage(0); - double voltage1 = electrode.voltage(1); + double voltage0 = hvdata_EMEC.voltage (electrode, 0); + double voltage1 = hvdata_EMEC.voltage (electrode, 1); double nominalVoltage = spinBoxes[y]->value(); bool outOfTolerance = (fabs(voltage0-nominalVoltage) > double (tolerance)) || (fabs(voltage1-nominalVoltage) > double (tolerance)) ; bool missing = voltage0 == -99999 || voltage1 == -99999; @@ -975,6 +978,7 @@ void VP1CaloReadoutSystem::createHV() { } const EMECPresamplerHVManager& emecPreHVManager = larHVManager->getEMECPresamplerHVManager(); + const EMECPresamplerHVManager::EMECPresamplerHVData hvdata_EMECPS = emecPreHVManager.getData(); for (unsigned int e=emecPreHVManager.beginSideIndex();e!=emecPreHVManager.endSideIndex();e++) { double z = e==0 ? -3650:3650; for (unsigned int p=emecPreHVManager.beginPhiIndex();p!=emecPreHVManager.endPhiIndex();p++) { @@ -1002,8 +1006,8 @@ void VP1CaloReadoutSystem::createHV() { ls->vertexProperty=vtxProperty; m_clockwork->emecPreModsSeparator->addChild(ls); - double voltage0 = emecMod.voltage(0); - double voltage1 = emecMod.voltage(1); + double voltage0 = hvdata_EMECPS.voltage (emecMod, 0); + double voltage1 = hvdata_EMECPS.voltage (emecMod, 1); double nominalVoltage = m_clockwork->ui.emecPresamplerNominalSpinBox->value(); bool outOfTolerance = (fabs(voltage0-nominalVoltage) > double (tolerance)) || (fabs(voltage1-nominalVoltage) > double (tolerance)) ; bool missing = voltage0 == -99999 || voltage1 == -99999; @@ -1025,13 +1029,14 @@ void VP1CaloReadoutSystem::createHV() { const HECDetectorManager *hecManager = VP1DetInfo::hecDetMgr(); const HECHVManager& hecHVManager = larHVManager->getHECHVManager(); + const HECHVManager::HECHVData hvdata_HEC = hecHVManager.getData(); for (unsigned int e=hecHVManager.beginSideIndex();e!=hecHVManager.endSideIndex();e++) { for (unsigned int s=hecHVManager.beginSamplingIndex();s!=hecHVManager.endSamplingIndex();s++) { for (unsigned int p=hecHVManager.beginPhiIndex();p!=hecHVManager.endPhiIndex();p++) { const HECHVModule& hecMod=hecHVManager.getHVModule(e,p,s); for (unsigned int i=0;i<hecMod.getNumSubgaps();i++) { const HECHVSubgap& subgap = hecMod.getSubgap(i); - double voltage = subgap.voltage(); + double voltage = hvdata_HEC.voltage (subgap); double nominalVoltage = m_clockwork->ui.hecNominalSpinBox->value(); bool outOfTolerance = fabs(voltage-nominalVoltage) > double (tolerance); bool missing = voltage == -99999; @@ -1085,13 +1090,14 @@ void VP1CaloReadoutSystem::createHV() { } const FCALHVManager& fcalHVManager = larHVManager->getFCALHVManager(); + const FCALHVManager::FCALHVData hvdata_FCAL = fcalHVManager.getData(); for (unsigned int e=fcalHVManager.beginSideIndex();e!=fcalHVManager.endSideIndex();e++) { for (unsigned int s=fcalHVManager.beginSamplingIndex();s!=fcalHVManager.endSamplingIndex();s++) { for (unsigned int x=fcalHVManager.beginSectorIndex(s);x!=fcalHVManager.endSectorIndex(s);x++) { const FCALHVModule& fcalMod=fcalHVManager.getHVModule(e,x,s); for (unsigned int l=0;l<fcalMod.getNumHVLines();l++) { const FCALHVLine& fcalLine=fcalMod.getHVLine(l); - double voltage = fcalLine.voltage(); + double voltage = hvdata_FCAL.voltage (fcalLine); // // Determine whether this is in bounds, or not.. @@ -1680,9 +1686,20 @@ void VP1CaloReadoutSystem::userPickedNode(SoNode* mySelectedNode, SoPath */*pick std::map < SoNode *, const EMBHVElectrode*>::const_iterator p = m_clockwork->EMBHVMap.find(mySelectedNode); if (p!=m_clockwork->EMBHVMap.end()) { - const EMBHVElectrode* electrode = (*p).second; + const EMBHVElectrode& electrode = *p->second; + const EMBHVModule& module = electrode.getModule(); + const EMBHVManager& manager = module.getManager(); + const EMBHVManager::EMBHVData hvdata = manager.getData(); std::ostringstream outstream; - outstream << "Side: " << electrode->getModule().getSideIndex() <<" Eta: " << electrode->getModule().getEtaIndex() << " Phi: " << electrode->getModule().getPhiIndex() << " Sector: " << electrode->getModule().getSectorIndex() << " Electrode " << electrode->getElectrodeIndex() << " Voltages: " << electrode->voltage(0) << "/" << electrode->voltage(1) << "; currents: " << electrode->current(0) << "/" << electrode->current(1); + outstream << "Side: " << module.getSideIndex() + <<" Eta: " << module.getEtaIndex() + << " Phi: " << module.getPhiIndex() + << " Sector: " << module.getSectorIndex() + << " Electrode " << electrode.getElectrodeIndex() + << " Voltages: " << hvdata.voltage (electrode, 0) + << "/" << hvdata.voltage (electrode, 1) + << "; currents: " << hvdata.current (electrode, 0) + << "/" << hvdata.current (electrode, 1); message (outstream.str().c_str()); } } @@ -1691,9 +1708,21 @@ void VP1CaloReadoutSystem::userPickedNode(SoNode* mySelectedNode, SoPath */*pick std::map < SoNode *, const EMECHVElectrode*>::const_iterator p = m_clockwork->EMECHVMap.find(mySelectedNode); if (p!=m_clockwork->EMECHVMap.end()) { - const EMECHVElectrode* electrode = (*p).second; + const EMECHVElectrode& electrode = *p->second; + const EMECHVModule& module = electrode.getModule(); + const EMECHVManager& manager = module.getManager(); + const EMECHVManager::EMECHVData hvdata = manager.getData(); std::ostringstream outstream; - outstream << "Side: " << electrode->getModule().getSideIndex() << " Wheel: " << electrode->getModule().getWheelIndex() << " Eta: " << electrode->getModule().getEtaIndex() << " Phi: " << electrode->getModule().getPhiIndex() << " Sector: " << electrode->getModule().getSectorIndex() << " Electrode: " << electrode->getElectrodeIndex() << "Voltages: " << electrode->voltage(0) << "/" << electrode->voltage(1) << "; currents: " << electrode->current(0) << "/" << electrode->current(1); + outstream << "Side: " << module.getSideIndex() + << " Wheel: " << module.getWheelIndex() + << " Eta: " << module.getEtaIndex() + << " Phi: " << module.getPhiIndex() + << " Sector: " << module.getSectorIndex() + << " Electrode: " << electrode.getElectrodeIndex() + << "Voltages: " << hvdata.voltage (electrode, 0) + << "/" << hvdata.voltage (electrode, 1) + << "; currents: " << hvdata.current (electrode, 0) + << "/" << hvdata.current (electrode, 1); message (outstream.str().c_str()); } } @@ -1703,9 +1732,17 @@ void VP1CaloReadoutSystem::userPickedNode(SoNode* mySelectedNode, SoPath */*pick std::map < SoNode *, const HECHVSubgap*>::const_iterator p = m_clockwork->HECHVMap.find(mySelectedNode); if (p!=m_clockwork->HECHVMap.end()) { - const HECHVSubgap* subgap = (*p).second; + const HECHVSubgap& subgap = *p->second; + const HECHVModule& module = subgap.getModule(); + const HECHVManager& manager = module.getManager(); + const HECHVManager::HECHVData hvdata = manager.getData(); std::ostringstream outstream; - outstream << "Side: " << subgap->getModule().getSideIndex() << " Phi: " << subgap->getModule().getPhiIndex() << " Sampling: " << subgap->getModule().getSamplingIndex() << " Subgap: " << subgap->getSubgapIndex() << "Voltage: " << subgap->voltage() << "; current: " << subgap->current(); + outstream << "Side: " << module.getSideIndex() + << " Phi: " << module.getPhiIndex() + << " Sampling: " << module.getSamplingIndex() + << " Subgap: " << subgap.getSubgapIndex() + << "Voltage: " << hvdata.voltage (subgap) + << "; current: " << hvdata.current (subgap); message (outstream.str().c_str()); } } @@ -1714,9 +1751,17 @@ void VP1CaloReadoutSystem::userPickedNode(SoNode* mySelectedNode, SoPath */*pick std::map < SoNode *, const FCALHVLine*>::const_iterator p = m_clockwork->FCALHVMap.find(mySelectedNode); if (p!=m_clockwork->FCALHVMap.end()) { - const FCALHVLine* line = (*p).second; + const FCALHVLine& line = *p->second; + const FCALHVModule& module = line.getModule(); + const FCALHVManager& manager = module.getManager(); + const FCALHVManager::FCALHVData hvdata = manager.getData(); std::ostringstream outstream; - outstream << "Side: " << line->getModule().getSideIndex() << " Sector: " << line->getModule().getSectorIndex() << " Sampling: " << line->getModule().getSamplingIndex() << " Line: " << line->getLineIndex() << "Voltage: " << line->voltage() << "; current: " << line->current(); + outstream << "Side: " << module.getSideIndex() + << " Sector: " << module.getSectorIndex() + << " Sampling: " << module.getSamplingIndex() + << " Line: " << line.getLineIndex() + << "Voltage: " << hvdata.voltage (line) + << "; current: " << hvdata.current (line); message (outstream.str().c_str()); } } @@ -1734,11 +1779,25 @@ void VP1CaloReadoutSystem::userPickedNode(SoNode* mySelectedNode, SoPath */*pick std::ostringstream highVoltageStream; highVoltageStream << "There are " << element->getNumHVLines() << " high voltage lines. Status: " << std::endl; message(highVoltageStream.str().c_str()); + + const FCALHVLine* line = nullptr; for (unsigned int i=0;i<element->getNumHVLines();i++) { - std::ostringstream highVoltageStream; - if (element->getHVLine(i)) highVoltageStream << i << ' ' << element->getHVLine(i)->voltage() << std::endl; - message(highVoltageStream.str().c_str()); - } + line = element->getHVLine(i); + if (line) break; + } + + if (line) { + const FCALHVModule& module = line->getModule(); + const FCALHVManager& manager = module.getManager(); + const FCALHVManager::FCALHVData hvdata = manager.getData(); + for (unsigned int i=0;i<element->getNumHVLines();i++) { + std::ostringstream highVoltageStream; + if (element->getHVLine(i)) { + highVoltageStream << i << ' ' << hvdata.voltage (*element->getHVLine(i)) << std::endl; + } + message(highVoltageStream.str().c_str()); + } + } } @@ -1857,70 +1916,78 @@ void VP1CaloReadoutSystem::userPickedNode(SoNode* mySelectedNode, SoPath */*pick message (highVoltageStream.str().c_str()); } std::set<const HECHVModule*> modSet; - for (unsigned int i=0;i<element->getNumSubgaps();i++) { - if (m_clockwork->ui.highVoltageCheckBox->isChecked()) { - std::ostringstream highVoltageStream; - highVoltageStream << i << " Status " << element->getSubgap(i).hvOn() << " voltage: " << element->getSubgap(i).voltage() << " current: " << element->getSubgap(i).current() << std::endl; - message(highVoltageStream.str().c_str()); - } - // - // Now let's show the module, and where she is: - // - const HECHVModule& module = element->getSubgap(i).getModule(); - - if (!m_clockwork->ui.highVoltageCheckBox->isChecked()) continue; - - SoSeparator * sep = new SoSeparator(); - - SoMaterial *white = new SoMaterial(); - white->diffuseColor.setValue(1.00,1.00, 1.00); - - SoDrawStyle *drawStyle = new SoDrawStyle(); - drawStyle->lineWidth=3; - drawStyle->pointSize=3; - - SoLightModel *lm = new SoLightModel(); - lm->model=SoLightModel::BASE_COLOR; - - - // we comment out to avoid compilation warnings, because they're not used, apparently -// HECCell::CELLPOS pos=HECCell::FRONT; -// if (m_clockwork->pos==BACK) pos=HECCell::BACK; -// if (m_clockwork->pos==CENTER) pos=HECCell::CENTER; - - - const HECDetectorManager *hecManager = VP1DetInfo::hecDetMgr(); - const HECDetectorRegion *region = hecManager->getDetectorRegion(element->getEndcapIndex(),element->getSamplingIndex(),element->getRegionIndex()); - const HepGeom::Transform3D &XF= Amg::EigenTransformToCLHEP(region->getAbsoluteTransform()); - double z = (XF*HepGeom::Point3D<double>(0,0,element->getZLocal(HECCell::FRONT))).z(); - - double phiMin = module.getPhiMin(); - double phiMax = module.getPhiMax(); - - - double rMax=2130; - double rMin=element->getSamplingIndex()==0 ? 371 : 474; - - sep->addChild(white); - sep->addChild(drawStyle); - sep->addChild(lm); - if (modSet.find(&module)==modSet.end()) { - modSet.insert(&module); - int cc=0; - SoVertexProperty *vtxProperty = new SoVertexProperty(); - vtxProperty->vertex.set1Value(cc++, SbVec3f(rMin*cos(phiMin),rMin*sin(phiMin) ,z)); - vtxProperty->vertex.set1Value(cc++, SbVec3f(rMin*cos(phiMax),rMin*sin(phiMax) ,z)); - vtxProperty->vertex.set1Value(cc++, SbVec3f(rMax*cos(phiMax),rMax*sin(phiMax) ,z)); - vtxProperty->vertex.set1Value(cc++, SbVec3f(rMax*cos(phiMin),rMax*sin(phiMin) ,z)); - vtxProperty->vertex.set1Value(cc++, SbVec3f(rMin*cos(phiMin),rMin*sin(phiMin) ,z)); - - - SoLineSet *ls = new SoLineSet(); - ls->numVertices=5; - ls->vertexProperty=vtxProperty; - sep->addChild(ls); - } - m_clockwork->volatileSeparator->addChild(sep); + if (element->getNumSubgaps() > 0) { + const HECHVModule& module0 = element->getSubgap(0).getModule(); + const HECHVManager& manager = module0.getManager(); + const HECHVManager::HECHVData hvdata = manager.getData(); + for (unsigned int i=0;i<element->getNumSubgaps();i++) { + if (m_clockwork->ui.highVoltageCheckBox->isChecked()) { + std::ostringstream highVoltageStream; + highVoltageStream << i << " Status " << hvdata.hvOn (element->getSubgap(i)) + << " voltage: " << hvdata.voltage (element->getSubgap(i)) + << " current: " << hvdata.current (element->getSubgap(i)) + << std::endl; + message(highVoltageStream.str().c_str()); + } + // + // Now let's show the module, and where she is: + // + const HECHVModule& module = element->getSubgap(i).getModule(); + + if (!m_clockwork->ui.highVoltageCheckBox->isChecked()) continue; + + SoSeparator * sep = new SoSeparator(); + + SoMaterial *white = new SoMaterial(); + white->diffuseColor.setValue(1.00,1.00, 1.00); + + SoDrawStyle *drawStyle = new SoDrawStyle(); + drawStyle->lineWidth=3; + drawStyle->pointSize=3; + + SoLightModel *lm = new SoLightModel(); + lm->model=SoLightModel::BASE_COLOR; + + + // we comment out to avoid compilation warnings, because they're not used, apparently + // HECCell::CELLPOS pos=HECCell::FRONT; + // if (m_clockwork->pos==BACK) pos=HECCell::BACK; + // if (m_clockwork->pos==CENTER) pos=HECCell::CENTER; + + + const HECDetectorManager *hecManager = VP1DetInfo::hecDetMgr(); + const HECDetectorRegion *region = hecManager->getDetectorRegion(element->getEndcapIndex(),element->getSamplingIndex(),element->getRegionIndex()); + const HepGeom::Transform3D &XF= Amg::EigenTransformToCLHEP(region->getAbsoluteTransform()); + double z = (XF*HepGeom::Point3D<double>(0,0,element->getZLocal(HECCell::FRONT))).z(); + + double phiMin = module.getPhiMin(); + double phiMax = module.getPhiMax(); + + + double rMax=2130; + double rMin=element->getSamplingIndex()==0 ? 371 : 474; + + sep->addChild(white); + sep->addChild(drawStyle); + sep->addChild(lm); + if (modSet.find(&module)==modSet.end()) { + modSet.insert(&module); + int cc=0; + SoVertexProperty *vtxProperty = new SoVertexProperty(); + vtxProperty->vertex.set1Value(cc++, SbVec3f(rMin*cos(phiMin),rMin*sin(phiMin) ,z)); + vtxProperty->vertex.set1Value(cc++, SbVec3f(rMin*cos(phiMax),rMin*sin(phiMax) ,z)); + vtxProperty->vertex.set1Value(cc++, SbVec3f(rMax*cos(phiMax),rMax*sin(phiMax) ,z)); + vtxProperty->vertex.set1Value(cc++, SbVec3f(rMax*cos(phiMin),rMax*sin(phiMin) ,z)); + vtxProperty->vertex.set1Value(cc++, SbVec3f(rMin*cos(phiMin),rMin*sin(phiMin) ,z)); + + + SoLineSet *ls = new SoLineSet(); + ls->numVertices=5; + ls->vertexProperty=vtxProperty; + sep->addChild(ls); + } + m_clockwork->volatileSeparator->addChild(sep); + } } } } @@ -1939,12 +2006,16 @@ void VP1CaloReadoutSystem::userPickedNode(SoNode* mySelectedNode, SoPath */*pick if (m_clockwork->ui.highVoltageCheckBox->isChecked()) { const EMECPresamplerHVModule& module = element->getPresamplerHVModule(); + const EMECPresamplerHVManager& manager = module.getManager(); + const EMECPresamplerHVManager::EMECPresamplerHVData hvdata = manager.getData(); std::ostringstream highVoltageStream; highVoltageStream << "Presampler cell. HV Status: " << '\n'; message(highVoltageStream.str().c_str()); - highVoltageStream << "Status: " << module.hvOn(0) << ' ' << module.hvOn(1) << '\n'; - highVoltageStream << "Current: " << module.current(0) << ' ' << module.current(1) << '\n'; - highVoltageStream << "Voltage: " << module.voltage(0) << ' ' << module.voltage(1) << '\n'; + highVoltageStream << "Status: " + << hvdata.hvOn (module, 0) << ' ' + << hvdata.hvOn (module, 1) << '\n'; + highVoltageStream << "Current: " << hvdata.current(module, 0) << ' ' << hvdata.current (module, 1) << '\n'; + highVoltageStream << "Voltage: " << hvdata.voltage (module, 0) << ' ' << hvdata.voltage (module, 1) << '\n'; message(highVoltageStream.str().c_str()); @@ -2006,93 +2077,107 @@ void VP1CaloReadoutSystem::userPickedNode(SoNode* mySelectedNode, SoPath */*pick message(highVoltageStream.str().c_str()); } std::set<const EMECHVModule*> modSet; - for (unsigned int i=0;i<element->getNumElectrodes();i++) { - if (m_clockwork->ui.highVoltageCheckBox->isChecked()) { - { - std::ostringstream highVoltageStream; - highVoltageStream << i << ' ' << element->getElectrode(i).getElectrodeIndex() << ") status: " << element->getElectrode(i).hvOn(0) << ' ' << element->getElectrode(i).hvOn(1) << std::endl; - message(highVoltageStream.str().c_str()); - } - { - std::ostringstream highVoltageStream; - highVoltageStream << i << '(' << element->getElectrode(i).getElectrodeIndex() << ") voltage: " << element->getElectrode(i).voltage(0) << ' ' << element->getElectrode(i).voltage(1) << std::endl; - message(highVoltageStream.str().c_str()); - } - { - std::ostringstream highVoltageStream; - highVoltageStream << i << '(' << element->getElectrode(i).getElectrodeIndex() << ") currents: " << element->getElectrode(i).current(0) << ' ' << element->getElectrode(i).current(1) << std::endl; - message(highVoltageStream.str().c_str()); - } - } - // - // Now let's show the module, and where she is: - // - const EMECHVModule& module = element->getElectrode(i).getModule(); + if (element->getNumElectrodes() > 0) { + for (unsigned int i=0;i<element->getNumElectrodes();i++) { + const EMECHVElectrode& electrode = element->getElectrode(0); + const EMECHVModule& module0 = electrode.getModule(); + const EMECHVManager& manager = module0.getManager(); + const EMECHVManager::EMECHVData hvdata = manager.getData(); + if (m_clockwork->ui.highVoltageCheckBox->isChecked()) { + { + std::ostringstream highVoltageStream; + highVoltageStream << i << ' ' + << element->getElectrode(i).getElectrodeIndex() << ") status: " + << hvdata.hvOn(element->getElectrode(i),0) << ' ' + << hvdata.hvOn(element->getElectrode(i),1) << std::endl; + message(highVoltageStream.str().c_str()); + } + { + std::ostringstream highVoltageStream; + highVoltageStream << i << '(' + << element->getElectrode(i).getElectrodeIndex() << ") voltage: " + << hvdata.voltage(element->getElectrode(i),0) << ' ' + << hvdata.voltage(element->getElectrode(i),1) << std::endl; + message(highVoltageStream.str().c_str()); + } + { + std::ostringstream highVoltageStream; + highVoltageStream << i << '(' << element->getElectrode(i).getElectrodeIndex() << ") currents: " + << hvdata.current(element->getElectrode(i),0) << ' ' + << hvdata.current(element->getElectrode(i),1) << std::endl; + message(highVoltageStream.str().c_str()); + } + } + // + // Now let's show the module, and where she is: + // + const EMECHVModule& module = element->getElectrode(i).getModule(); - if (!m_clockwork->ui.highVoltageCheckBox->isChecked()) continue; + if (!m_clockwork->ui.highVoltageCheckBox->isChecked()) continue; - SoSeparator * sep = new SoSeparator(); + SoSeparator * sep = new SoSeparator(); - SoMaterial *white = new SoMaterial(); - white->diffuseColor.setValue(1.00,1.00, 1.00); + SoMaterial *white = new SoMaterial(); + white->diffuseColor.setValue(1.00,1.00, 1.00); - SoDrawStyle *drawStyle = new SoDrawStyle(); - drawStyle->lineWidth=3; - drawStyle->pointSize=3; + SoDrawStyle *drawStyle = new SoDrawStyle(); + drawStyle->lineWidth=3; + drawStyle->pointSize=3; - SoLightModel *lm = new SoLightModel(); - lm->model=SoLightModel::BASE_COLOR; + SoLightModel *lm = new SoLightModel(); + lm->model=SoLightModel::BASE_COLOR; - EMECCell::CELLPOS pos=EMECCell::FRONT; - if (m_clockwork->pos==BACK) pos=EMECCell::BACK; - if (m_clockwork->pos==CENTER) pos=EMECCell::CENTER; + EMECCell::CELLPOS pos=EMECCell::FRONT; + if (m_clockwork->pos==BACK) pos=EMECCell::BACK; + if (m_clockwork->pos==CENTER) pos=EMECCell::CENTER; - double z = (element->getZLocal(pos)+ - element->getDescriptor()->getManager()->getFocalToRef() + - element->getDescriptor()->getManager()->getRefToActive())* (element->getEndcapIndex()==0 ? -1:1); - double phiMin = module.getPhiMin(); - double phiMax = module.getPhiMax(); - double etaMin = module.getEtaMin(); - double etaMax = module.getEtaMax(); + double z = (element->getZLocal(pos)+ + element->getDescriptor()->getManager()->getFocalToRef() + + element->getDescriptor()->getManager()->getRefToActive())* (element->getEndcapIndex()==0 ? -1:1); + double phiMin = module.getPhiMin(); + double phiMax = module.getPhiMax(); + double etaMin = module.getEtaMin(); + double etaMax = module.getEtaMax(); - double rMax=fabs(z/sinh(etaMin)); - double rMin=fabs(z/sinh(etaMax)); + double rMax=fabs(z/sinh(etaMin)); + double rMin=fabs(z/sinh(etaMax)); - sep->addChild(white); - sep->addChild(drawStyle); - sep->addChild(lm); - if (modSet.find(&module)==modSet.end()) { - modSet.insert(&module); - int cc=0; - SoVertexProperty *vtxProperty = new SoVertexProperty(); - vtxProperty->vertex.set1Value(cc++, SbVec3f(rMin*cos(phiMin),rMin*sin(phiMin) ,z)); - vtxProperty->vertex.set1Value(cc++, SbVec3f(rMin*cos(phiMax),rMin*sin(phiMax) ,z)); - vtxProperty->vertex.set1Value(cc++, SbVec3f(rMax*cos(phiMax),rMax*sin(phiMax) ,z)); - vtxProperty->vertex.set1Value(cc++, SbVec3f(rMax*cos(phiMin),rMax*sin(phiMin) ,z)); - vtxProperty->vertex.set1Value(cc++, SbVec3f(rMin*cos(phiMin),rMin*sin(phiMin) ,z)); + sep->addChild(white); + sep->addChild(drawStyle); + sep->addChild(lm); + if (modSet.find(&module)==modSet.end()) { + modSet.insert(&module); + int cc=0; + SoVertexProperty *vtxProperty = new SoVertexProperty(); + vtxProperty->vertex.set1Value(cc++, SbVec3f(rMin*cos(phiMin),rMin*sin(phiMin) ,z)); + vtxProperty->vertex.set1Value(cc++, SbVec3f(rMin*cos(phiMax),rMin*sin(phiMax) ,z)); + vtxProperty->vertex.set1Value(cc++, SbVec3f(rMax*cos(phiMax),rMax*sin(phiMax) ,z)); + vtxProperty->vertex.set1Value(cc++, SbVec3f(rMax*cos(phiMin),rMax*sin(phiMin) ,z)); + vtxProperty->vertex.set1Value(cc++, SbVec3f(rMin*cos(phiMin),rMin*sin(phiMin) ,z)); - SoLineSet *ls = new SoLineSet(); - ls->numVertices=5; - ls->vertexProperty=vtxProperty; - sep->addChild(ls); - } - { + SoLineSet *ls = new SoLineSet(); + ls->numVertices=5; + ls->vertexProperty=vtxProperty; + sep->addChild(ls); + } + { - int cc=0; - SoVertexProperty *vtxProperty = new SoVertexProperty(); - vtxProperty->vertex.set1Value(cc++, SbVec3f(rMin*cos(element->getElectrode(i).getPhi()),rMin*sin(element->getElectrode(i).getPhi()) ,z)); - vtxProperty->vertex.set1Value(cc++, SbVec3f(rMax*cos(element->getElectrode(i).getPhi()),rMax*sin(element->getElectrode(i).getPhi()) ,z)); - SoLineSet *ls = new SoLineSet(); - ls->numVertices=2; - ls->vertexProperty=vtxProperty; - sep->addChild(ls); - } + int cc=0; + SoVertexProperty *vtxProperty = new SoVertexProperty(); + vtxProperty->vertex.set1Value(cc++, SbVec3f(rMin*cos(element->getElectrode(i).getPhi()),rMin*sin(element->getElectrode(i).getPhi()) ,z)); + vtxProperty->vertex.set1Value(cc++, SbVec3f(rMax*cos(element->getElectrode(i).getPhi()),rMax*sin(element->getElectrode(i).getPhi()) ,z)); + SoLineSet *ls = new SoLineSet(); + ls->numVertices=2; + ls->vertexProperty=vtxProperty; + sep->addChild(ls); + } - m_clockwork->volatileSeparator->addChild(sep); + m_clockwork->volatileSeparator->addChild(sep); + } } } } @@ -2113,13 +2198,21 @@ void VP1CaloReadoutSystem::userPickedNode(SoNode* mySelectedNode, SoPath */*pick if (m_clockwork->ui.highVoltageCheckBox->isChecked()) { if (element->getSamplingIndex()==0) { const EMBPresamplerHVModule& module = element->getPresamplerHVModule(); + const EMBPresamplerHVManager& manager = module.getManager(); + const EMBPresamplerHVManager::EMBPresamplerHVData hvdata = manager.getData(); std::ostringstream highVoltageStream; highVoltageStream << "Presampler cell. HV Status: " << '\n'; message(highVoltageStream.str().c_str()); - highVoltageStream << "Status: " << module.hvOn(0) << ' ' << module.hvOn(1) << '\n'; - highVoltageStream << "Current: " << module.current(0) << ' ' << module.current(1) << '\n'; - highVoltageStream << "Voltage: " << module.voltage(0) << ' ' << module.voltage(1) << '\n'; + highVoltageStream << "Status: " + << hvdata.hvOn (module, 0) << ' ' + << hvdata.hvOn (module, 1) << '\n'; + highVoltageStream << "Current: " + << hvdata.current (module, 0) << ' ' + << hvdata.current (module, 1) << '\n'; + highVoltageStream << "Voltage: " + << hvdata.voltage (module, 0) << ' ' + << hvdata.voltage (module, 1) << '\n'; message(highVoltageStream.str().c_str()); @@ -2172,80 +2265,92 @@ void VP1CaloReadoutSystem::userPickedNode(SoNode* mySelectedNode, SoPath */*pick highVoltageStream << "There are " << element->getNumElectrodes() << " electrodes. Status: " << '\n'; message(highVoltageStream.str().c_str()); std::set<const EMBHVModule*> modSet; - for (unsigned int i=0;i<element->getNumElectrodes();i++) { - highVoltageStream << i << "Status: " << element->getElectrode(i).getElectrodeIndex() << ' ' << element->getElectrode(i).hvOn(0) << ' ' << element->getElectrode(i).hvOn(1) << '\n'; - highVoltageStream << i << "Current: " << element->getElectrode(i).getElectrodeIndex() << ' ' << element->getElectrode(i).current(0) << ' ' << element->getElectrode(i).current(1) << '\n'; - highVoltageStream << i << "Voltage: " << element->getElectrode(i).getElectrodeIndex() << ' ' << element->getElectrode(i).voltage(0) << ' ' << element->getElectrode(i).voltage(1) << '\n'; - message(highVoltageStream.str().c_str()); - // - // Now let's show the module, and where she is: - // - const EMBHVModule& module = element->getElectrode(i).getModule(); + if (element->getNumElectrodes() > 0) { + const EMBHVModule& module0 = element->getElectrode(0).getModule(); + const EMBHVManager& manager = module0.getManager(); + const EMBHVManager::EMBHVData hvdata = manager.getData(); + for (unsigned int i=0;i<element->getNumElectrodes();i++) { + highVoltageStream << i << "Status: " << element->getElectrode(i).getElectrodeIndex() << ' ' + << hvdata.hvOn (element->getElectrode(i), 0) << ' ' + << hvdata.hvOn (element->getElectrode(i), 1) << '\n'; + highVoltageStream << i << "Current: " + << element->getElectrode(i).getElectrodeIndex() << ' ' + << hvdata.current (element->getElectrode(i), 0) << ' ' + << hvdata.current (element->getElectrode(i), 1) << '\n'; + highVoltageStream << i << "Voltage: " << element->getElectrode(i).getElectrodeIndex() << ' ' + << hvdata.voltage (element->getElectrode(i), 0) << ' ' + << hvdata.voltage (element->getElectrode(i), 1) << '\n'; + message(highVoltageStream.str().c_str()); + // + // Now let's show the module, and where she is: + // + const EMBHVModule& module = element->getElectrode(i).getModule(); - if (!m_clockwork->ui.highVoltageCheckBox->isChecked()) continue; + if (!m_clockwork->ui.highVoltageCheckBox->isChecked()) continue; - SoSeparator * sep = new SoSeparator(); + SoSeparator * sep = new SoSeparator(); - SoMaterial *white = new SoMaterial(); - white->diffuseColor.setValue(1.00,1.00, 1.00); + SoMaterial *white = new SoMaterial(); + white->diffuseColor.setValue(1.00,1.00, 1.00); - SoDrawStyle *drawStyle = new SoDrawStyle(); - drawStyle->lineWidth=3; - drawStyle->pointSize=3; + SoDrawStyle *drawStyle = new SoDrawStyle(); + drawStyle->lineWidth=3; + drawStyle->pointSize=3; - SoLightModel *lm = new SoLightModel(); - lm->model=SoLightModel::BASE_COLOR; + SoLightModel *lm = new SoLightModel(); + lm->model=SoLightModel::BASE_COLOR; - EMBCell::CELLPOS pos=EMBCell::FRONT; - if (m_clockwork->pos==BACK) pos=EMBCell::BACK; - if (m_clockwork->pos==CENTER) pos=EMBCell::CENTER; + EMBCell::CELLPOS pos=EMBCell::FRONT; + if (m_clockwork->pos==BACK) pos=EMBCell::BACK; + if (m_clockwork->pos==CENTER) pos=EMBCell::CENTER; - double r = element->getRLocal(pos); - double phiMin = module.getPhiMin(); - double phiMax = module.getPhiMax(); - double etaMin = module.getEtaMin(); - double etaMax = module.getEtaMax(); - sep->addChild(white); - sep->addChild(drawStyle); - sep->addChild(lm); + double r = element->getRLocal(pos); + double phiMin = module.getPhiMin(); + double phiMax = module.getPhiMax(); + double etaMin = module.getEtaMin(); + double etaMax = module.getEtaMax(); + sep->addChild(white); + sep->addChild(drawStyle); + sep->addChild(lm); - if (modSet.find(&module)==modSet.end()) { - modSet.insert(&module); + if (modSet.find(&module)==modSet.end()) { + modSet.insert(&module); - int cc=0; - SoVertexProperty *vtxProperty = new SoVertexProperty(); - vtxProperty->vertex.set1Value(cc++, SbVec3f(r*cos(phiMin),r*sin(phiMin) ,r*sinh(etaMin))); - vtxProperty->vertex.set1Value(cc++, SbVec3f(r*cos(phiMax),r*sin(phiMax) ,r*sinh(etaMin))); - vtxProperty->vertex.set1Value(cc++, SbVec3f(r*cos(phiMax),r*sin(phiMax) ,r*sinh(etaMax))); - vtxProperty->vertex.set1Value(cc++, SbVec3f(r*cos(phiMin),r*sin(phiMin) ,r*sinh(etaMax))); - vtxProperty->vertex.set1Value(cc++, SbVec3f(r*cos(phiMin),r*sin(phiMin) ,r*sinh(etaMin))); + int cc=0; + SoVertexProperty *vtxProperty = new SoVertexProperty(); + vtxProperty->vertex.set1Value(cc++, SbVec3f(r*cos(phiMin),r*sin(phiMin) ,r*sinh(etaMin))); + vtxProperty->vertex.set1Value(cc++, SbVec3f(r*cos(phiMax),r*sin(phiMax) ,r*sinh(etaMin))); + vtxProperty->vertex.set1Value(cc++, SbVec3f(r*cos(phiMax),r*sin(phiMax) ,r*sinh(etaMax))); + vtxProperty->vertex.set1Value(cc++, SbVec3f(r*cos(phiMin),r*sin(phiMin) ,r*sinh(etaMax))); + vtxProperty->vertex.set1Value(cc++, SbVec3f(r*cos(phiMin),r*sin(phiMin) ,r*sinh(etaMin))); - SoLineSet *ls = new SoLineSet(); - ls->numVertices=5; - ls->vertexProperty=vtxProperty; - sep->addChild(ls); + SoLineSet *ls = new SoLineSet(); + ls->numVertices=5; + ls->vertexProperty=vtxProperty; + sep->addChild(ls); - } - { - int cc=0; - SoVertexProperty *vtxProperty = new SoVertexProperty(); - vtxProperty->vertex.set1Value(cc++, SbVec3f(r*cos(element->getElectrode(i).getPhi()),r*sin(element->getElectrode(i).getPhi()) ,r*sinh(etaMin))); - vtxProperty->vertex.set1Value(cc++, SbVec3f(r*cos(element->getElectrode(i).getPhi()),r*sin(element->getElectrode(i).getPhi()) ,r*sinh(etaMax))); + } + { + int cc=0; + SoVertexProperty *vtxProperty = new SoVertexProperty(); + vtxProperty->vertex.set1Value(cc++, SbVec3f(r*cos(element->getElectrode(i).getPhi()),r*sin(element->getElectrode(i).getPhi()) ,r*sinh(etaMin))); + vtxProperty->vertex.set1Value(cc++, SbVec3f(r*cos(element->getElectrode(i).getPhi()),r*sin(element->getElectrode(i).getPhi()) ,r*sinh(etaMax))); - SoLineSet *ls = new SoLineSet(); - ls->numVertices=2; - ls->vertexProperty=vtxProperty; + SoLineSet *ls = new SoLineSet(); + ls->numVertices=2; + ls->vertexProperty=vtxProperty; - sep->addChild(ls); - } + sep->addChild(ls); + } - m_clockwork->volatileSeparator->addChild(sep); - } - } + m_clockwork->volatileSeparator->addChild(sep); + } + } + } } } }