Skip to content
Snippets Groups Projects
Commit 20477b2b authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'add_HVcurr' into 'master'

Add usage of current to LAr HV computation

See merge request atlas/athena!37513
parents cfbc3339 29e3502f
No related branches found
No related tags found
No related merge requests found
......@@ -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))
......
......@@ -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
......
......@@ -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"))
......
......@@ -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;
......
/*
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;
......
......@@ -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;
}
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment