diff --git a/LArCalorimeter/LArCalibUtils/python/LArHVScaleConfig.py b/LArCalorimeter/LArCalibUtils/python/LArHVScaleConfig.py index 1f3db3321df7f03a4fc5731ff1a87b23b311b64b..9699fcd7ba0cdad21dc48b18390c06eb5ea2dc30 100644 --- a/LArCalorimeter/LArCalibUtils/python/LArHVScaleConfig.py +++ b/LArCalorimeter/LArCalibUtils/python/LArHVScaleConfig.py @@ -23,6 +23,7 @@ def LArHVScaleCfg(configFlags): result.merge(addFolders(configFlags,["/LAR/IdentifierOfl/HVLineToElectrodeMap"], "LAR_OFL", className="AthenaAttributeList")) result.merge(addFolders(configFlags,["/LAR/HVPathologiesOfl/Pathologies"], "LAR_OFL", className="AthenaAttributeList")) + result.merge(addFolders(configFlags,["/LAR/HVPathologiesOfl/Rvalues"], "LAR_OFL", className="AthenaAttributeList")) from LArBadChannelTool.LArBadChannelConfig import LArBadChannelCfg, LArBadFebCfg result.merge(LArBadChannelCfg(configFlags)) diff --git a/LArCalorimeter/LArExample/LArConditionsCommon/python/LArHVDB.py b/LArCalorimeter/LArExample/LArConditionsCommon/python/LArHVDB.py index f9bdca79be57cf021f3ce459c5f0ae87fa8df98d..d5124cea7ae4117d5898e588921313a83cb27965 100644 --- a/LArCalorimeter/LArExample/LArConditionsCommon/python/LArHVDB.py +++ b/LArCalorimeter/LArExample/LArConditionsCommon/python/LArHVDB.py @@ -8,6 +8,7 @@ if not conddb.isMC and not conddb.isOnline: conddb.addFolder("DCS_OFL","/LAR/DCS/HV/BARREL/I8",className="CondAttrListCollection") conddb.addFolder("LAR_OFL","/LAR/IdentifierOfl/HVLineToElectrodeMap",className="AthenaAttributeList") conddb.addFolder("LAR_OFL","/LAR/HVPathologiesOfl/Pathologies",className="AthenaAttributeList") + conddb.addFolder("LAR_OFL","/LAR/HVPathologiesOfl/Rvalues",className="AthenaAttributeList") from AthenaCommon.AlgSequence import AthSequencer from Gaudi.Configuration import DEBUG diff --git a/LArCalorimeter/LArMonitoring/python/LArHVDBConfig.py b/LArCalorimeter/LArMonitoring/python/LArHVDBConfig.py index e34f4a3f6ac61acd0a8fb2475999e9967ce55215..a0bfe0b5a4beaef925491f8fff22aac4d2fd6f03 100644 --- a/LArCalorimeter/LArMonitoring/python/LArHVDBConfig.py +++ b/LArCalorimeter/LArMonitoring/python/LArHVDBConfig.py @@ -15,7 +15,7 @@ def LArHVDBCfg(configFlags): if not isMC and not isOnline: result.merge(addFolders(configFlags,["/LAR/DCS/HV/BARREl/I16","/LAR/DCS/HV/BARREL/I8"],detDb="DCS_OFL",className="CondAttrListCollection")) - result.merge(addFolders(configFlags,["/LAR/IdentifierOfl/HVLineToElectrodeMap","/LAR/HVPathologiesOfl/Pathologies"],detDb="LAR_OFL",className="AthenaAttributeList")) + result.merge(addFolders(configFlags,["/LAR/IdentifierOfl/HVLineToElectrodeMap","/LAR/HVPathologiesOfl/Pathologies","/LAR/HVPathologiesOfl/Rvalues"],detDb="LAR_OFL",className="AthenaAttributeList")) from LArRecUtils.LArRecUtilsConf import LArHVIdMappingAlg result.addCondAlgo(LArHVIdMappingAlg(ReadKey="/LAR/IdentifierOfl/HVLineToElectrodeMap",WriteKey="LArHVIdMap")) diff --git a/LArCalorimeter/LArRecUtils/src/LArHVCondAlg.cxx b/LArCalorimeter/LArRecUtils/src/LArHVCondAlg.cxx index efd57860c318deaa00189da08ea2270415eadc70..e1124df25bb4e2a5dcac451f95730e264952cea8 100755 --- a/LArCalorimeter/LArRecUtils/src/LArHVCondAlg.cxx +++ b/LArCalorimeter/LArRecUtils/src/LArHVCondAlg.cxx @@ -39,6 +39,8 @@ #include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "CoralBase/Blob.h" + //#include <iostream> #include <cmath> #include <cstdlib> @@ -64,6 +66,7 @@ LArHVCondAlg::LArHVCondAlg( const std::string& name, ISvcLocator* pSvcLocator ) m_condSvc("CondSvc",name) { declareProperty("doHV",m_doHV=true,"create HV data"); + declareProperty("doR",m_doR=true,"Use R values with current to improve HV"); declareProperty("doAffected",m_doAffected=true,"create affected region info"); declareProperty("doAffectedHV",m_doAffectedHV=true,"include HV non nominal regions info"); @@ -94,6 +97,7 @@ StatusCode LArHVCondAlg::initialize(){ ATH_CHECK( m_cablingKey.initialize()); ATH_CHECK( m_BFKey.initialize() ); ATH_CHECK(m_hvMappingKey.initialize (m_doHV || m_doAffectedHV)); + ATH_CHECK( m_hvRKey.initialize(m_doR && (m_doHV || m_doAffectedHV))); // Write Handle @@ -149,6 +153,7 @@ StatusCode LArHVCondAlg::execute(const EventContext& ctx) const { std::vector<const CondAttrListCollection*> attrvec; const LArHVIdMapping* hvCabling{nullptr}; + const float* rValues{nullptr}; if(doHVData || (doAffected && m_doAffectedHV) ) { SG::ReadCondHandle<LArHVIdMapping> mappingHdl{m_hvMappingKey, ctx}; @@ -175,6 +180,21 @@ StatusCode LArHVCondAlg::execute(const EventContext& ctx) const { ATH_MSG_WARNING("Why do not have DCS folder " << fldkey.fullKey()); } } // over DCS folders + if(m_doR) { + SG::ReadCondHandle<AthenaAttributeList> readAttrHandle{m_hvRKey, ctx}; + const AthenaAttributeList* attr = *readAttrHandle; + if(!attr) { + ATH_MSG_ERROR("Unable to access R values Cond Object"); + return StatusCode::FAILURE; + } + // store the conditions blob + const coral::Blob& rBlob = (*attr)["ElectrodeRvalues"].data<coral::Blob>(); + if(rBlob.size()/sizeof(float) != m_electrodeID->electrodeHashMax()) { + ATH_MSG_ERROR("Expected " << m_electrodeID->electrodeHashMax() << " R values, but got " << rBlob.size()/sizeof(float) << " aborting"); + return StatusCode::FAILURE; + } + rValues = static_cast<const float*>(rBlob.startingAddress()); + } } const LArHVManager *manager = NULL; @@ -271,7 +291,7 @@ StatusCode LArHVCondAlg::execute(const EventContext& ctx) const { std::unique_ptr<LArHVData> hvdata = std::make_unique<LArHVData>(); - ATH_CHECK(fillPayload(hvdata.get(), hvdataOld, hvCabling, voltage, current, hvlineidx, pathologyContainer, hasPathologyEM, hasPathologyHEC, hasPathologyFCAL)); + ATH_CHECK(fillPayload(hvdata.get(), hvdataOld, hvCabling, voltage, current, hvlineidx, pathologyContainer, hasPathologyEM, hasPathologyHEC, hasPathologyFCAL, rValues)); ATH_CHECK(writeHandle.record(std::move(hvdata))); @@ -337,7 +357,8 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata , const LArHVPathology& pathologies , pathVec& hasPathologyEM , pathVec& hasPathologyHEC - , pathVec& hasPathologyFCAL) const + , pathVec& hasPathologyFCAL + , const float* rValues) const { LArHVData::hvMap &hvmap = hvdata->m_voltage; LArHVData::currMap &currmap = hvdata->m_current; @@ -372,7 +393,7 @@ 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; + //std::cout << " nelec: " << nelec << std::endl; unsigned int ngap = 2*nelec; double wt = 1./ngap; v.clear(); ihv.clear(); @@ -396,6 +417,17 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata unsigned idx = itrLine - hvlineidx.begin(); double hv=voltage[idx]; double curr=current[idx]; + if(rValues) { // modify the current record + const EMBHVModule &hvmod = electrode.getModule(); + unsigned ridx = m_electrodeID->electrodeHash(m_electrodeID->ElectrodeId(0, + hvmod.getSideIndex(), + hvCabling->getCellModule(id), + hvmod.getPhiIndex(), + hvmod.getEtaIndex(), + igap, + electrode.getElectrodeIndex() )); + curr *= rValues[ridx]; + } if (hasPathology) { ATH_MSG_VERBOSE( "Has pathology for id: "<< m_larem_id->print_to_string(id)<<" "<<hasPathologyEM[index]); msg(MSG::VERBOSE) << "Original hv: "<<hv<<" "; @@ -439,6 +471,17 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata unsigned idx = itrLine - hvlineidx.begin(); double hv=voltage[idx]; double curr=current[idx]; + if(rValues) { // modify the current record + unsigned ridx = m_electrodeID->electrodeHash(m_electrodeID->ElectrodeId(1, + hvmodule.getSideIndex(), + hvCabling->getCellModule(id), + 0, // not used in EMBPS + hvmodule.getEtaIndex(), + igap, + 0 // not used in EMBPS + )); + curr *= rValues[ridx]; + } addHV(v,hv,wt); addCurr(ihv,curr,wt); } @@ -481,6 +524,17 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata unsigned idx = itrLine - hvlineidx.begin(); double hv=voltage[idx]; double curr=current[idx]; + if(rValues) { // modify the current record + const EMECHVModule &hvmod = electrode.getModule(); + unsigned ridx = m_electrodeID->electrodeHash(m_electrodeID->ElectrodeId(2, + hvmod.getSideIndex(), + hvCabling->getCellModule(id), + hvmod.getPhiIndex(), + hvmod.getEtaIndex(), + hvmod.getSectorIndex(), + electrode.getElectrodeIndex() )); + curr *= rValues[ridx]; + } if (hasPathology) { msg(MSG::VERBOSE) << "Has pathology for id: "<< m_larem_id->print_to_string(id)<<" "<<hasPathologyEM[index]<<endmsg; for (unsigned int ii=0;ii<listElec.size();ii++) { @@ -521,6 +575,17 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata unsigned idx = itrLine - hvlineidx.begin(); double hv=voltage[idx]; double curr=current[idx]; + if(rValues) { // modify the current record + unsigned ridx = m_electrodeID->electrodeHash(m_electrodeID->ElectrodeId(3, + hvmodule.getSideIndex(), + hvCabling->getCellModule(id), + 0, // not used in EMECPS + 0, + igap, + 0 // not used in EMECPS + )); + curr *= rValues[ridx]; + } addHV(v,hv,wt); addCurr(ihv,curr,wt); } @@ -589,6 +654,18 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata unsigned idx = itrLine - hvlineidx.begin(); double hv=voltage[idx]; double curr=current[idx]; + if(rValues) { // modify the current record + const HECHVModule &hvmod = subgap.getModule(); + unsigned ridx = m_electrodeID->electrodeHash(m_electrodeID->ElectrodeId(4, + hvmod.getSideIndex(), + hvCabling->getCellModule(id), + 0, // not used in HEC + hvmod.getSamplingIndex(), + subgap.getSubgapIndex(), + 0 // not used in HEC + )); + curr *= 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; @@ -627,7 +704,7 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata updatedCells.emplace(id); } } - } // loop over HEC + } // loop over FCAL for(auto id: m_larfcal_id->channel_ids()) { // LAr FCAL v.clear(); ihv.clear(); @@ -671,6 +748,18 @@ StatusCode LArHVCondAlg::fillPayload(LArHVData* hvdata unsigned idx = itrLine - hvlineidx.begin(); double hv=voltage[idx]; double curr=current[idx]; + if(rValues) { // modify the current record + const FCALHVModule& hvmod = line->getModule(); + unsigned ridx = m_electrodeID->electrodeHash(m_electrodeID->ElectrodeId(5, + hvmod.getSideIndex(), + hvCabling->getCellModule(id), + 0, // not used in FCAL + hvmod.getSamplingIndex(), + hvmod.getSectorIndex(), + line->getLineIndex() + )); + curr *= 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; diff --git a/LArCalorimeter/LArRecUtils/src/LArHVCondAlg.h b/LArCalorimeter/LArRecUtils/src/LArHVCondAlg.h index 9cc78a393444613665e3af2bfbdec478f2eab5e8..f289427ddb5dec2d4aa37433cd8d2b07957a43c4 100755 --- a/LArCalorimeter/LArRecUtils/src/LArHVCondAlg.h +++ b/LArCalorimeter/LArRecUtils/src/LArHVCondAlg.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 */ /** @@ -70,6 +70,8 @@ class LArHVCondAlg: public AthReentrantAlgorithm SG::ReadCondHandleKey<LArHVIdMapping> m_hvMappingKey {this, "HVMappingKey", "LArHVIdMap", "Key for mapping object" }; + SG::ReadCondHandleKey<AthenaAttributeList> m_hvRKey{this, "RvaluesKey", "/LAR/HVPathologiesOfl/Rvalues", "Cool folder with HV R values"}; + // Conditions keys write: SG::WriteCondHandleKey<LArHVData> m_hvDataKey {this, "OutputHVData", "LArHVData", "Key for output HV data object"}; @@ -86,6 +88,7 @@ class LArHVCondAlg: public AthReentrantAlgorithm ServiceHandle<ICondSvc> m_condSvc; bool m_doHV; + bool m_doR; bool m_doAffected; bool m_doAffectedHV; @@ -104,7 +107,8 @@ class LArHVCondAlg: public AthReentrantAlgorithm , const LArHVPathology& pathologies , pathVec& hasPathologyEM , pathVec& hasPathologyHEC - , pathVec& hasPathologyFCAL) const; + , pathVec& hasPathologyFCAL + , const float* rValues) const; void addHV(std::vector< LArHVData::HV_t > & v, double hv, double wt) const; void addCurr(std::vector< LArHVData::CURRENT_t > & ihv, double curr, double wt) const; diff --git a/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.cxx b/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.cxx index 8b163eefe04183a51119d6edd17e63497f3d2790..96361de3c3c5de40899fa485a2fcb4a128b158bb 100644 --- a/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.cxx +++ b/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.cxx @@ -35,7 +35,9 @@ LArHVScaleCorrCondAlg::LArHVScaleCorrCondAlg(const std::string& name, ISvcLocato declareProperty("fixHVCorr", m_fixHVStrings); declareProperty("UndoOnlineHVCorr",m_undoOnlineHVCorr=true,"Undo the HVCorr done online"); - + declareProperty("UseCurrentsInHVEMB", m_useCurrentEMB=false, "Use currents in EMB as well"); + declareProperty("UseCurrentsInHVFCAL1", m_useCurrentFCAL1=false, "Use currents in FCAL1 as well"); + declareProperty("UseCurrentsInHVOthers", m_useCurrentOthers=false, "Use currents in other partitions as well"); } @@ -331,30 +333,45 @@ StatusCode LArHVScaleCorrCondAlg::getScale(const HASHRANGEVEC& hashranges, if (notfound) { ATH_MSG_WARNING( " At least one HV value not found in database for cell " << m_larem_id->show_to_string(offid) ); } + std::vector<LArHVData::CURRENT_t> currlist; + if(m_useCurrentEMB || m_useCurrentFCAL1 || m_useCurrentOthers) { + sc = hvdata->getCurrent(offid,currlist); + if (sc.isFailure() || currlist.size() != hvlist.size()) { + ATH_MSG_WARNING( " Current values not the same size as hv for cell " << m_larem_id->show_to_string(offid) << " resetting to 0" ); + currlist.resize(hvlist.size(),LArHVData::CURRENT_t{0,0}); + } + + } mycorr=0.; mynorm=0.; for (unsigned int i=0;i<hvlist.size();i++) { - double E = champ_e(hvlist[i].hv,d); - - // dont correct if E is very close to E nominal to avoid small glitches - if (std::fabs(E_nominal)>1e-3) { - const double deviation = std::fabs((E-E_nominal)/E_nominal); - if (deviation<1e-3) E = E_nominal; - } - // barrel accordion if (isbarrelEM) { - const double corr = this->Scale_barrel(hvlist[i].hv)*hvlist[i].weight; - mycorr += corr; + //const double corr = this->Scale_barrel(hvlist[i].hv)*hvlist[i].weight; + //mycorr += corr; + if(m_useCurrentEMB) mycorr += this->Scale_barrel(hvlist[i].hv-currlist[i].current)*hvlist[i].weight; + else mycorr += this->Scale_barrel(hvlist[i].hv)*hvlist[i].weight; } //FCAL module 1 else if (isFCAL1) { - const double corr = this->Scale_FCAL1(hvlist[i].hv) * hvlist[i].weight; - mycorr+=corr; + //const double corr = this->Scale_FCAL1(hvlist[i].hv) * hvlist[i].weight; + //mycorr+=corr; + if(m_useCurrentFCAL1) mycorr += this->Scale_FCAL1(hvlist[i].hv-currlist[i].current) * hvlist[i].weight; + else mycorr += this->Scale_FCAL1(hvlist[i].hv) * hvlist[i].weight; } // other subdetectors else { + double E; + if(m_useCurrentOthers) E = champ_e(hvlist[i].hv-currlist[i].current,d); + else E = champ_e(hvlist[i].hv,d); + + // dont correct if E is very close to E nominal to avoid small glitches + if (std::fabs(E_nominal)>1e-3) { + const double deviation = std::fabs((E-E_nominal)/E_nominal); + if (deviation<1e-3) E = E_nominal; + } + const double corr = Respo(E,E_nominal,T)*hvlist[i].weight; mycorr+= corr; } diff --git a/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.h b/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.h index f30ff43e01b0d1f32f6d7d734d667b527478f948..f66c00129ba15e21d17cb12ea65969676285c9e3 100644 --- a/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.h +++ b/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.h @@ -92,6 +92,9 @@ class LArHVScaleCorrCondAlg: public AthAlgorithm bool m_undoOnlineHVCorr; + bool m_useCurrentEMB; + bool m_useCurrentFCAL1; + bool m_useCurrentOthers; struct HVfix_t { unsigned int subdet; // 0-1-2-3 for EMB-EMEC-HEC-FCAL