Skip to content
Snippets Groups Projects
Commit a07f70bb authored by Duc Ta's avatar Duc Ta
Browse files

Merge branch 'LArIdCablingTest1' into '24.0'

add test to verify LAr online/offline identifier consistency

See merge request !70905
parents a45547de 4ac388b5
No related branches found
No related tags found
3 merge requests!70996Draft: ZDC pulse analysis updates in support of analyses,!709742024-04-29: merge of 24.0 into main,!70905add test to verify LAr online/offline identifier consistency
......@@ -30,4 +30,6 @@ atlas_install_runtime( share/FEBtoRODfred_v10.data )
if( NOT SIMULATIONBASE AND NOT GENERATIONBASE )
atlas_add_test( LArCablingConfig SCRIPT python -m LArCabling.LArCablingConfig POST_EXEC_SCRIPT nopost.sh )
atlas_add_test( LArIdCablingTest SCRIPT python -m LArCabling.LArIdCablingTest POST_EXEC_SCRIPT noerror.sh )
atlas_add_test( LArIdCablingTestSC SCRIPT python -m LArCabling.LArIdCablingTest --SC POST_EXEC_SCRIPT noerror.sh )
endif()
#Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
from AthenaConfiguration.ComponentFactory import CompFactory
def LArIdCablingTestCfg(flags,isSC=False):
from LArGeoAlgsNV.LArGMConfig import LArGMCfg
result=LArGMCfg(flags)
if isSC:
#Setup SuperCell cabling
from LArCabling.LArCablingConfig import LArOnOffIdMappingSCCfg
result.merge(LArOnOffIdMappingSCCfg(flags))
else:
#Setup regular cabling
from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
result.merge(LArOnOffIdMappingCfg(flags))
result.addEventAlgo(CompFactory.LArIdCablingTest("LArIdCablingTest",isSC=isSC,
CablingKey= "LArOnOffIdMapSC" if isSC else "LArOnOffIdMap",
))
return result
if __name__=="__main__":
import sys,argparse
parser= argparse.ArgumentParser()
parser.add_argument("--loglevel", default=None, help="logging level (ALL, VERBOSE, DEBUG,INFO, WARNING, ERROR, or FATAL")
parser.add_argument("-r","--runnumber",default=0x7fffffff, type=int, help="run number to query the DB")
parser.add_argument("-d","--database",default="LAR_ONL", help="Database name or sqlite file name")
parser.add_argument("--SC", action='store_true', help="Work on SuperCells")
(args,leftover)=parser.parse_known_args(sys.argv[1:])
if len(leftover)>0:
print("ERROR, unhandled argument(s):",leftover)
sys.exit(-1)
from AthenaConfiguration.AllConfigFlags import initConfigFlags
flags=initConfigFlags()
flags.Input.isMC = False
flags.IOVDb.DatabaseInstance="CONDBR2"
flags.LAr.doAlign=False
flags.Input.RunNumbers=[args.runnumber]
flags.IOVDb.GlobalTag="CONDBR2-ES1PA-2023-02"
from AthenaConfiguration.TestDefaults import defaultGeometryTags
flags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
flags.lock()
isSC=args.SC
from AthenaConfiguration.MainServicesConfig import MainServicesCfg
cfg=MainServicesCfg(flags)
#MC Event selector since we have no input data file
from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
cfg.merge(McEventSelectorCfg(flags,
EventsPerRun = 1,
FirstEvent = 1,
InitialTimeStamp = 0,
TimeStampInterval = 1))
cfg.merge(LArIdCablingTestCfg(flags,isSC))
cfg.getService("MessageSvc").errorLimit=5000000
cfg.run(1)
/*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#include "LArIdCablingTest.h"
#include "LArIdentifier/LArOnline_SuperCellID.h"
#include "LArIdentifier/LArOnlineID.h"
#include "CaloIdentifier/CaloCell_ID.h"
#include "CaloIdentifier/CaloCell_SuperCell_ID.h"
LArIdCablingTest::~LArIdCablingTest() = default;
StatusCode LArIdCablingTest::initialize() {
ATH_MSG_INFO ( "initialize()" );
if (m_isSC && m_cablingKey.key()=="LArOnOffIdMap") {
ATH_MSG_ERROR("Unexpected cabling key for SuperCellCase, found " << m_cablingKey);
}
ATH_CHECK(m_cablingKey.initialize());
return StatusCode::SUCCESS;
}
StatusCode LArIdCablingTest::execute() {
SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKey};
const LArOnOffIdMapping* cabling=(*cablingHdl);
const LArOnlineID_Base* larOnlineID;
if (m_isSC) {
const LArOnline_SuperCellID* ll;
ATH_CHECK(detStore()->retrieve(ll, "LArOnline_SuperCellID"));
larOnlineID = ll;
ATH_MSG_DEBUG("Found the LArOnlineID helper");
} else { // m_isSC
const LArOnlineID* ll;
ATH_CHECK(detStore()->retrieve(ll, "LArOnlineID"));
larOnlineID = ll;
ATH_MSG_DEBUG(" Found the LArOnlineID helper. ");
}
const CaloCell_Base_ID* caloId;
if (m_isSC) {
const CaloCell_SuperCell_ID* cs;
ATH_CHECK(detStore()->retrieve(cs, "CaloCell_SuperCell_ID"));
caloId = cs;
} else { // m_isSC
const CaloCell_ID* cc;
ATH_CHECK(detStore()->retrieve(cc, "CaloCell_ID"));
caloId = cc;
}
unsigned nConnected = 0;
std::array<unsigned,2> nEMECIW{0,0};
std::array<unsigned,2> nEMECOW{0,0};
std::array<unsigned,2> nBarrel{0,0};
std::array<unsigned,2> nHEC{0,0};
std::array<unsigned,2> nFCAL{0,0};
for ( const HWIdentifier chid : larOnlineID->channel_range()) {
if (!cabling->isOnlineConnected(chid)) continue;
++nConnected;
const Identifier id=cabling->cnvToIdentifier(chid);
if (!id.is_valid()) {
ATH_MSG_ERROR("Invalid offline id for online id 0x" << std::hex << chid.get_identifier32().get_compact() << std::dec << " " << larOnlineID->channel_name(chid));
}
else {
std::string subdet="Unkown";
int posneg=larOnlineID->pos_neg(chid);
if (caloId->is_em_barrel(id)) {subdet="Barrel"; ++nBarrel[posneg];}
if (caloId->is_em_endcap_inner(id)) {subdet="EMECIW"; ++nEMECIW[posneg];}
if (caloId->is_em_endcap_outer(id)) {subdet="EMECOW"; ++nEMECOW[posneg];}
if (caloId->is_hec(id)) {subdet="HEC"; ++nHEC[posneg];}
if (caloId->is_fcal(id)) {subdet="FCAL"; ++nFCAL[posneg];}
ATH_MSG_DEBUG("Channel 0x" << std::hex << chid.get_identifier32().get_compact() << std::dec << " " << larOnlineID->channel_name(chid)
<< " offline id 0x" << std::hex << id.get_identifier32().get_compact() << std::dec << " " << subdet);
if (larOnlineID->isEMBchannel(chid) != caloId->is_em_barrel(id)) {
ATH_MSG_ERROR("isEMB mismatch online Id 0x" << std::hex << chid.get_identifier32().get_compact() << std::dec << " " << larOnlineID->channel_name(chid)
<< " offline id 0x" << std::hex << id.get_identifier32().get_compact() << std::dec << " onl "
<< larOnlineID->isEMBchannel(chid) << " / ofl " << caloId->is_em_barrel(id));
}
if (larOnlineID->isEMECIW(chid) != caloId->is_em_endcap_inner(id)) {
ATH_MSG_ERROR("isEMECIW mismatch online Id 0x" << std::hex << chid.get_identifier32().get_compact() << std::dec << " " << larOnlineID->channel_name(chid)
<< " offline id 0x" << std::hex << id.get_identifier32().get_compact() << std::dec << " onl "
<< larOnlineID->isEMECIW(chid) << " / ofl " << caloId->is_em_endcap_inner(id));
}
if (larOnlineID->isEMECOW(chid) != caloId->is_em_endcap_outer(id)) {
ATH_MSG_ERROR("isEMECOW mismatch online Id 0x" << std::hex << chid.get_identifier32().get_compact() << std::dec << " " << larOnlineID->channel_name(chid)
<< " offline id 0x" << std::hex << id.get_identifier32().get_compact() << std::dec << " onl "
<< larOnlineID->isEMECOW(chid) << " / ofl " << caloId->is_em_endcap_outer(id));
}
if (larOnlineID->isHECchannel(chid) != caloId->is_hec(id)) {
ATH_MSG_ERROR("isHEC mismatch online Id 0x" << std::hex << chid.get_identifier32().get_compact() << std::dec << " " << larOnlineID->channel_name(chid)
<< " offline id 0x" << std::hex << id.get_identifier32().get_compact() << std::dec << " onl "
<< larOnlineID->isHECchannel(chid) << " / ofl " << caloId->is_hec(id));
}
if (larOnlineID->isFCALchannel(chid) != caloId->is_fcal(id)) {
ATH_MSG_ERROR("isFCAL mismatch online Id 0x" << std::hex << chid.get_identifier32().get_compact() << std::dec << " " << larOnlineID->channel_name(chid)
<< " offline id 0x" << std::hex << id.get_identifier32().get_compact() << std::dec << " onl "
<< larOnlineID->isFCALchannel(chid) << "/ ofl" << caloId->is_fcal(id));
}
}//end if connected
} //end loop over online identifiers
if (m_isSC) {
ATH_MSG_INFO("checked " << nConnected << " super-cell channels.");
} else {
ATH_MSG_INFO("checked " << nConnected << " regular channels.");
}
ATH_MSG_INFO("Number of channels A/C side:");
ATH_MSG_INFO("Barrel " << nBarrel[0] << "/" << nBarrel[1]);
if ( nBarrel[0] != nBarrel[1]) ATH_MSG_ERROR("MISMATCH!");
ATH_MSG_INFO("EMECOW " << nEMECIW[0] << "/" << nEMECIW[1]);
if (nEMECIW[0]!=nEMECIW[1]) ATH_MSG_ERROR("MISMATCH!");
ATH_MSG_INFO("EMECIW " << nEMECOW[0] << "/" << nEMECOW[1]);
if (nEMECOW[0]!=nEMECOW[1]) ATH_MSG_ERROR("MISMATCH!");
ATH_MSG_INFO("HEC " << nHEC[0] << "/" << nHEC[1]);
if (nHEC[0]!=nHEC[1]) ATH_MSG_ERROR("MISMATCH!");
ATH_MSG_INFO("FCAL " << nFCAL[0] << "/" << nFCAL[1]);
if (nFCAL[0]!=nFCAL[1]) ATH_MSG_ERROR("MISMATCH!");
return StatusCode::SUCCESS;
}
//Dear emacs, this is -*-c++-*-
/*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#ifndef LARIDCABLINGTEST_H
#define LARIDCABLINGTEST_H
#include "AthenaBaseComps/AthAlgorithm.h"
#include "StoreGate/ReadCondHandleKey.h"
#include "LArCabling/LArOnOffIdMapping.h"
class LArIdCablingTest : public AthAlgorithm
{
public:
using AthAlgorithm::AthAlgorithm;
~LArIdCablingTest();
virtual StatusCode initialize() final;
virtual StatusCode execute() final;
private:
SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this,"CablingKey","LArOnOffIdMap"};
Gaudi::Property<bool>m_isSC{this,"isSC",false};
};
#endif
#include "LArCabling/LArHVCablingSimTool.h"
#include "../LArIdCablingTest.h"
DECLARE_COMPONENT( LArHVCablingSimTool )
DECLARE_COMPONENT( LArIdCablingTest )
\ No newline at end of file
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