ATLAS Offline Software
Loading...
Searching...
No Matches
MuonMDT_CablingAlg Class Reference

MuonMDT_CablingAlg reads raw condition data and writes derived condition data to the condition store. More...

#include <MuonMDT_CablingAlg.h>

Inheritance diagram for MuonMDT_CablingAlg:
Collaboration diagram for MuonMDT_CablingAlg:

Public Types

using CablingData = MuonMDT_CablingMap::CablingData

Public Member Functions

virtual ~MuonMDT_CablingAlg ()=default
virtual StatusCode initialize () override
virtual StatusCode execute (const EventContext &ctx) const override
virtual bool isReEntrant () const override
 Avoid scheduling algorithm multiple times.
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
 Get filter decision:
virtual void setFilterPassed (bool state, const EventContext &ctx) const
 Set filter decision:
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvc > StoreGateSvc_t

Private Member Functions

StatusCode dbPayloadToJson (SG::ReadCondHandle< CondAttrListCollection > &readHandle, nlohmann::json &jsonjson) const
bool extractStationInfo (const coral::AttributeList &atr, CablingData &map_data) const
 Retrieves the general MDT station info from the coral attribute.
bool extractLayerInfo (std::vector< std::string > &, CablingData &map_data) const
 Retrieves the channel info from the coral attribute.
StatusCode loadMezzanineSchema (const EventContext &ctx, SG::WriteCondHandle< MuonMDT_CablingMap > &writeHandle, MuonMDT_CablingMap &cabling_map) const
 Load the mezzanine schema into the cabling.
StatusCode loadMezzanineFromJSON (nlohmann::json &&payload, MuonMDT_CablingMap &cabling_map) const
StatusCode loadCablingSchema (const EventContext &ctx, SG::WriteCondHandle< MuonMDT_CablingMap > &writeHandle, MuonMDT_CablingMap &cabling_map) const
 Load the cabling schema of the tubes.
StatusCode loadCablingSchemaFromJSON (nlohmann::json &&payload, MuonMDT_CablingMap &cabling_map) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyMez {this, "MezzanineFolders", "/MDT/CABLING/MEZZANINE_SCHEMA"}
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyMap {this, "MapFolders", "/MDT/CABLING/MAP_SCHEMA"}
SG::WriteCondHandleKey< MuonMDT_CablingMap > m_writeKey {this, "WriteKey", "MuonMDT_CablingMap", "Key of output MDT cabling map"}
Gaudi::Property< bool > m_isRun3 {this, "isRun3", false, "Auxillary property to load the BIS78 cabling by hand"}
Gaudi::Property< std::string > m_mezzJSON
Gaudi::Property< std::string > m_chambJSON
Gaudi::Property< bool > m_useJSONFormat
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

MuonMDT_CablingAlg reads raw condition data and writes derived condition data to the condition store.

Definition at line 22 of file MuonMDT_CablingAlg.h.

Member Typedef Documentation

◆ CablingData

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 376 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ ~MuonMDT_CablingAlg()

virtual MuonMDT_CablingAlg::~MuonMDT_CablingAlg ( )
virtualdefault

Member Function Documentation

◆ dbPayloadToJson()

StatusCode MuonMDT_CablingAlg::dbPayloadToJson ( SG::ReadCondHandle< CondAttrListCollection > & readHandle,
nlohmann::json & json ) const
private

Definition at line 60 of file MuonMDT_CablingAlg.cxx.

60 {
61 for (CondAttrListCollection::const_iterator itr = readHandle->begin();
62 itr != readHandle->end(); ++itr) {
63 const coral::AttributeList& atr = itr->second;
64 std::string data{};
65 if (atr["data"].specification().type() == typeid(coral::Blob)) {
66
67 ATH_MSG_VERBOSE("Loading data as a BLOB, uncompressing...");
68 if (!CoralUtilities::readBlobAsString(atr["data"].data<coral::Blob>(), data)) {
69 ATH_MSG_FATAL("Cannot uncompress BLOB! Aborting...");
70 return StatusCode::FAILURE;
71 }
72 } else {
73 data = *(static_cast<const std::string*>((atr["data"]).addressOfData()));
74 }
75 json = nlohmann::json::parse(data);
76 }
77 return StatusCode::SUCCESS;
78}
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_FATAL(x,...)
nlohmann::json json
ChanAttrListMap::const_iterator const_iterator
bool readBlobAsString(const coral::Blob &, std::string &)

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode MuonMDT_CablingAlg::execute ( const EventContext & ctx) const
overridevirtual

Definition at line 37 of file MuonMDT_CablingAlg.cxx.

37 {
38 ATH_MSG_VERBOSE("MuonMDT_CablingAlg::execute()");
39 // Write Cond Handle
40 SG::WriteCondHandle<MuonMDT_CablingMap> writeHandle{m_writeKey, ctx};
41 if (writeHandle.isValid()) {
42 ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
43 << ". In theory this should not be called, but may happen"
44 << " if multiple concurrent events are being processed out of order.");
45 return StatusCode::SUCCESS;
46 }
47 writeHandle.addDependency(EventIDRange(IOVInfiniteRange::infiniteRunLB()));
48 ATH_MSG_INFO("Load the Mdt cabling");
49 std::unique_ptr<MuonMDT_CablingMap> writeCdo{std::make_unique<MuonMDT_CablingMap>()};
50
51 ATH_CHECK(loadMezzanineSchema(ctx, writeHandle, *writeCdo));
52 ATH_CHECK(loadCablingSchema(ctx, writeHandle, *writeCdo));
53 if (!writeCdo->finalize_init(msgStream())) return StatusCode::FAILURE;
54
55 ATH_CHECK(writeHandle.record(std::move(writeCdo)));
56 ATH_MSG_INFO("recorded new " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
57 return StatusCode::SUCCESS;
58}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_INFO(x,...)
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
StatusCode loadCablingSchema(const EventContext &ctx, SG::WriteCondHandle< MuonMDT_CablingMap > &writeHandle, MuonMDT_CablingMap &cabling_map) const
Load the cabling schema of the tubes.
SG::WriteCondHandleKey< MuonMDT_CablingMap > m_writeKey
StatusCode loadMezzanineSchema(const EventContext &ctx, SG::WriteCondHandle< MuonMDT_CablingMap > &writeHandle, MuonMDT_CablingMap &cabling_map) const
Load the mezzanine schema into the cabling.
const std::string & key() const
void addDependency(const EventIDRange &range)
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const

◆ extractLayerInfo()

bool MuonMDT_CablingAlg::extractLayerInfo ( std::vector< std::string > & info_map,
CablingData & map_data ) const
private

Retrieves the channel info from the coral attribute.

The map data is endcoded in repitive blocks of <tdcId>,<channelId>,<tube_numbering>,<tdcId>,<channelId>,<tube_numbering>,...

unpack the tube Id

Definition at line 261 of file MuonMDT_CablingAlg.cxx.

261 {
262 ATH_MSG_VERBOSE(" parsing of the map");
265 constexpr unsigned int coding_block_size = 3;
266 const unsigned int n = info_map.size() >= coding_block_size ? coding_block_size : info_map.size();
267 bool decoded_full_block{false};
268 for (unsigned int i = 0; i < n; ++i) {
269 ATH_MSG_VERBOSE(i << "..." << info_map[i]);
270 int info = CxxUtils::atoi(info_map[i]);
271 // this is a tdcid
272 if (i == 0) {
273 map_data.tdcId = info;
274 }
275 // this is a channel Id
276 else if (i == 1) {
277 map_data.channelId = info;
278 }
279 // this is a tube id that must be unpacked
280 else if (i == 2) {
282 map_data.tube = info % map_data.tubes_per_layer;
283 map_data.layer = ((info - map_data.tube) / map_data.tubes_per_layer) % map_data.layer_block;
284 map_data.multilayer = (((info - map_data.tube) / map_data.tubes_per_layer) - map_data.layer) / map_data.layer_block;
285 decoded_full_block = true;
286 }
287 }
288
289 // the stationIndex is later on passed to the MdtIdHelper, thus, it must be a reasonable station name, i.e. not < 0
290 if (decoded_full_block) info_map.erase(info_map.begin(), info_map.begin() + coding_block_size);
291 return decoded_full_block;
292}
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...

◆ extractStationInfo()

bool MuonMDT_CablingAlg::extractStationInfo ( const coral::AttributeList & atr,
CablingData & map_data ) const
private

Retrieves the general MDT station info from the coral attribute.

Hack for the BIS78 sMDT chambers

Temporary hack to remove all EI chambers until the proper data base tag arrives

It's still useful to keep the C-side chamber if the asymmetric geometry is loaded

Definition at line 209 of file MuonMDT_CablingAlg.cxx.

209 {
210 map_data.eta = *(static_cast<const int*>((atr["Eta"]).addressOfData()));
211 map_data.phi = *(static_cast<const int*>((atr["Phi"]).addressOfData()));
212 map_data.mrod = *(static_cast<const int*>((atr["MROD"]).addressOfData()));
213 map_data.csm = *(static_cast<const int*>((atr["CSM"]).addressOfData()));
214 map_data.channelId = *(static_cast<const int*>((atr["Chan"]).addressOfData()));
215 map_data.mezzanine_type = *(static_cast<const int*>((atr["Mezzanine_Type"]).addressOfData()));
216
217 const std::string chamber_name = *(static_cast<const std::string*>((atr["Chamber_Name"]).addressOfData()));
218 const std::string subdetector_id = *(static_cast<const std::string*>((atr["SubDet_Id"]).addressOfData()));
219
220 // convert the string name to index
221 std::string stationNameString = chamber_name.substr(0, 3);
222 // fix for the BOE chambers, which in the offline are treated as BOL
223 if (stationNameString == "BOE") { stationNameString = "BOL"; }
225 if (stationNameString == "BIX" || stationNameString == "BIY") {
226 stationNameString = "BIS";
227 static std::atomic<bool> sInfoPrinted{false};
228 if (!sInfoPrinted)
229 ATH_MSG_INFO("Found an entry concerning the new BIS78 chambers. Will increase the number of tube per layer to "
231 sInfoPrinted = true;
232
233 map_data.tubes_per_layer = MdtIdHelper::maxNTubesPerLayer;
234 }
236 if (m_isRun3) {
238 if ((stationNameString == "EIS" && (!m_idHelperSvc->hasCSC() || chamber_name.find('A') != std::string::npos)) ||
239 chamber_name.find("BIS7A") != std::string::npos) {
240 ATH_MSG_VERBOSE("It's sooo sad but the chamber " << chamber_name << " is no longer with us");
241 return false;
242 }
243 }
244 map_data.stationIndex = m_idHelperSvc->mdtIdHelper().stationNameIndex(stationNameString);
245 ATH_MSG_VERBOSE("station name: " << stationNameString << " index: " << static_cast<int>(map_data.stationIndex));
246 // convert the subdetector id to integer
247 map_data.subdetectorId = CxxUtils::atoi(subdetector_id);
248
249 ATH_MSG_VERBOSE("Data load is chamber_Name = " << chamber_name <<" translated to "<<map_data<<" FINISHED HERE ");
250
251 if (map_data.stationIndex < 0) {
252 static std::atomic<bool> stWarningPrinted{false};
253 if (!stWarningPrinted) {
254 ATH_MSG_WARNING("Found stationIndex=" << static_cast<int>(map_data.stationIndex)
255 << " which is not reasonable, maybe related to ATLASRECTS-5961, continuing...");
256 stWarningPrinted = true;
257 }
258 }
259 return map_data.stationIndex >= 0;
260}
#define ATH_MSG_WARNING(x,...)
static constexpr int maxNTubesPerLayer
The maxNTubesPerLayer represents the absolute maximum of tubes which are built into a single multilay...
Definition MdtIdHelper.h:68
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Gaudi::Property< bool > m_isRun3

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthCommonAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 89 of file AthCommonAlgorithm.cxx.

54{
55 // If we didn't find any symlinks to add, just return the collection
56 // from the base class. Otherwise, return the extended collection.
57 if (!m_extendedExtraObjects.empty()) {
59 }
61}
Common base class for algorithms.

◆ filterPassed()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Get filter decision:

Definition at line 93 of file AthCommonAlgorithm.h.

93 {
94 return execState( ctx ).filterPassed();
95 }
virtual bool filterPassed(const EventContext &ctx) const
Get filter decision:

◆ initialize()

StatusCode MuonMDT_CablingAlg::initialize ( )
overridevirtual

Definition at line 26 of file MuonMDT_CablingAlg.cxx.

26 {
27 ATH_MSG_DEBUG("initialize " << name());
28 const bool initCondKey = m_mezzJSON.value().empty() &&
29 m_chambJSON.value().empty();
30 ATH_CHECK(m_readKeyMez.initialize(initCondKey));
31 ATH_CHECK(m_readKeyMap.initialize(initCondKey));
32 ATH_CHECK(m_writeKey.initialize());
33 ATH_CHECK(m_idHelperSvc.retrieve());
34 return StatusCode::SUCCESS;
35}
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyMap
Gaudi::Property< std::string > m_chambJSON
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyMez
Gaudi::Property< std::string > m_mezzJSON

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isClonable()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::isClonable ( ) const
inlineoverridevirtualinherited

Specify if the algorithm is clonable.

Only relevant for non-reentrant algorithms. Actual number of clones needs to be set via the "Cardinality" property.

Reimplemented in AFP_DigiTop, AlgB, AlgT, BCM_Digitization, CscDigitBuilder, CscDigitToCscRDO, G4AtlasAlg, G4RunAlg, HGTD_Digitization, HiveAlgBase, InDet::GNNSeedingTrackMaker, InDet::SCT_Clusterization, InDet::SiSPGNNTrackMaker, InDet::SiSPSeededTrackFinder, InDet::SiTrackerSpacePointFinder, ISF::SimKernelMT, ITk::StripDigitization, ITkPixelCablingAlg, ITkStripCablingAlg, LArHitEMapMaker, LArTTL1Maker, LUCID_DigiTop, LVL1::L1TopoSimulation, MergeCalibHits, MergeGenericMuonSimHitColl, MergeHijingPars, MergeMcEventCollection, MergeTrackRecordCollection, MergeTruthJets, MergeTruthParticles, MuonDigitizer, PileUpMTAlg, PixelDigitization, RoIBResultToxAOD, SCT_ByteStreamErrorsTestAlg, SCT_CablingCondAlgFromCoraCool, SCT_CablingCondAlgFromText, SCT_ConditionsParameterTestAlg, SCT_ConditionsSummaryTestAlg, SCT_ConfigurationConditionsTestAlg, SCT_Digitization, SCT_FlaggedConditionTestAlg, SCT_LinkMaskingTestAlg, SCT_MajorityConditionsTestAlg, SCT_ModuleVetoTestAlg, SCT_MonitorConditionsTestAlg, SCT_PrepDataToxAOD, SCT_RawDataToxAOD, SCT_ReadCalibChipDataTestAlg, SCT_ReadCalibDataTestAlg, SCT_RODVetoTestAlg, SCT_SensorsTestAlg, SCT_SiliconConditionsTestAlg, SCT_StripVetoTestAlg, SCT_TdaqEnabledTestAlg, SCT_TestCablingAlg, SCTEventFlagWriter, SCTRawDataProvider, SCTSiLorentzAngleTestAlg, SCTSiPropertiesTestAlg, SGInputLoader, Simulation::BeamEffectsAlg, TileHitVecToCnt, TileMuonFitter, TilePulseForTileMuonReceiver, TileRawChannelMaker, TRTDigitization, and ZDC_DigiTop.

Definition at line 68 of file AthCommonAlgorithm.h.

68 {
69 return true;
70 }

◆ isReEntrant()

virtual bool AthCondAlgorithm::isReEntrant ( ) const
inlineoverridevirtualinherited

Avoid scheduling algorithm multiple times.

With multiple concurrent events, conditions objects often expire simultaneously for all slots. To avoid that the scheduler runs the CondAlg in each slot, we declare it as "non-reentrant". This ensures that the conditions objects are only created once.

In case a particular CondAlg should behave differently, it can override this method again and return true.

See also
ATEAM-836

Definition at line 39 of file AthCondAlgorithm.h.

39{ return false; }

◆ loadCablingSchema()

StatusCode MuonMDT_CablingAlg::loadCablingSchema ( const EventContext & ctx,
SG::WriteCondHandle< MuonMDT_CablingMap > & writeHandle,
MuonMDT_CablingMap & cabling_map ) const
private

Load the cabling schema of the tubes.

now this mezzanine can be added to the map:

Load manually the BIX7 / BIY7 chambers into the data base if neccessary

That translates to 54 tubes per layer per CSM

The mrod numbering is 8 for sector 2, 9 for sector 4 etc.. For BIY it's 1 for sector 2, 2 for sector 4, etc.

Definition at line 80 of file MuonMDT_CablingAlg.cxx.

81 {
82
83 if (m_chambJSON.value().size()){
84 std::ifstream in_json{m_chambJSON};
85 if (!in_json.good()) {
86 ATH_MSG_FATAL("Failed to open external JSON file "<<m_chambJSON);
87 return StatusCode::FAILURE;
88 }
89 nlohmann::json payload{};
90 in_json >> payload;
91 ATH_CHECK(loadCablingSchemaFromJSON( std::move(payload), cabling_map));
92 return StatusCode::SUCCESS;
93 }
94 SG::ReadCondHandle<CondAttrListCollection> readHandleMap{m_readKeyMap, ctx};
95 if (!readHandleMap.isValid()) {
96 ATH_MSG_ERROR("Null pointer to the read conditions object "<<readHandleMap.fullKey());
97 return StatusCode::FAILURE;
98 }
99 writeHandle.addDependency(readHandleMap);
100
101 ATH_MSG_INFO("Size of CondAttrListCollection " << readHandleMap.fullKey()
102 << " readCdoMap->size()= " << readHandleMap->size());
103
104 ATH_MSG_VERBOSE("Collection CondAttrListCollection CLID " << readHandleMap->clID());
105 if (m_useJSONFormat) {
106 nlohmann::json json;
107 ATH_CHECK(dbPayloadToJson(readHandleMap, json));
108 ATH_CHECK(loadCablingSchemaFromJSON(std::move(json),cabling_map));
109 return StatusCode::SUCCESS;
110 }
111 // access to Map Schema Table to obtained the Map
113 for (itrMap = readHandleMap->begin(); itrMap != readHandleMap->end(); ++itrMap) {
114 const coral::AttributeList& atr = itrMap->second;
115
116 CablingData map_data;
117 if (!extractStationInfo(atr, map_data)) continue;
118
119 constexpr std::string_view delimiter{","};
120 const std::string map = *(static_cast<const std::string*>((atr["Map"]).addressOfData()));
121 std::vector<std::string> info_map = CxxUtils::tokenize(map, delimiter);
122
123 while (extractLayerInfo(info_map, map_data)) {
125 ATH_MSG_VERBOSE("Adding new mezzanine stationName: " << m_idHelperSvc->mdtIdHelper().stationNameString(map_data.stationIndex)
126 << " " << map_data);
127 if (!cabling_map.addMezzanine(map_data, DataSource::LegacyCOOL, msgStream())) {
128 ATH_MSG_ERROR("Failed to add cabling " << map_data);
129 return StatusCode::FAILURE;
130 } else
131 ATH_MSG_VERBOSE("Added new cabling channel " << map_data);
132 }
133 } // end of CondAttrListCollection loop
135 if (m_isRun3) {
136 ATH_MSG_INFO("Found a round 3 setup. Will add the cabling for BIS78 manually");
137 const int BIS_stat = m_idHelperSvc->mdtIdHelper().stationNameIndex("BIS");
138 constexpr int eta_index = 7;
139 const std::string zeroStr{"0"};
140 const std::string emptyStr{""};
141 for (unsigned int sector = 1; sector <= 8; ++sector) {
142 int is_biy{0}, tdcId{0};
143 auto increment_tdc = [&is_biy, &tdcId]() {
144 ++tdcId;
145 constexpr int tdcMax = 17; // Maximum 18 tdcs per CSM
146 if (tdcId > tdcMax) {
147 tdcId = 0;
148 ++is_biy;
149 }
150 };
151 constexpr int tubesPerCsm = 54;
152 bool added_tdc = true;
153 std::vector<std::string> db_coding{std::to_string(tdcId), zeroStr, emptyStr};
154 while (added_tdc) {
155 added_tdc = false;
156 for (int ml = 1; ml <= 2; ++ml) {
157 const Identifier layer_id = m_idHelperSvc->mdtIdHelper().channelID(BIS_stat, eta_index, sector, ml, 1, 1);
158 const int tubes_per_layer = m_idHelperSvc->mdtIdHelper().tubeMax(layer_id);
159
160 const int first_tube = 6 * (1 + tdcId / 2) + tubesPerCsm * is_biy;
161 const bool valid_tube = (first_tube <= tubes_per_layer);
162 added_tdc |= valid_tube;
163 if (!valid_tube) {
164 increment_tdc();
165 continue;
166 }
167
168 CablingData bis78_data{};
169 bis78_data.tubes_per_layer = MdtIdHelper::maxNTubesPerLayer;
170 bis78_data.stationIndex = BIS_stat;
171 bis78_data.eta = eta_index;
172 bis78_data.phi = sector;
175 bis78_data.mrod = (is_biy ? -1 : 7) + sector;
176 bis78_data.csm = is_biy ? 5 : 0;
177 bis78_data.subdetectorId = 99;
178
179 bis78_data.mezzanine_type = sector != 6 ? 61 : 71;
180 const unsigned int tube_coding = first_tube + bis78_data.tubes_per_layer * (4 + bis78_data.layer_block * ml);
181 ATH_MSG_VERBOSE("ooooh BIS78 is being hacked in " << m_idHelperSvc->toString(layer_id) << " tubes_per_layer "
182 << m_idHelperSvc->mdtIdHelper().tubeMax(layer_id) << " tdcId: "
183 << tdcId << " is_Biy: " << is_biy << " first_tube: " << first_tube);
184
185 db_coding[2] = std::to_string(tube_coding);
186 if (extractLayerInfo(db_coding, bis78_data)) {
187 ATH_MSG_VERBOSE("Adding new mezzanine stationName: "
188 << m_idHelperSvc->mdtIdHelper().stationNameString(bis78_data.stationIndex) << " " << bis78_data);
189 if (!cabling_map.addMezzanine(bis78_data, DataSource::LegacyCOOL, msgStream())) {
190 ATH_MSG_ERROR("Failed to add mezzanine card " << bis78_data);
191 return StatusCode::FAILURE;
192 }
193 }
194 if (bis78_data.tube != first_tube) {
195 ATH_MSG_ERROR("BIS78 data tube encoding failed. Expected " << first_tube << " got " << bis78_data.tube << ".");
196 return StatusCode::FAILURE;
197 } else if (bis78_data.multilayer != ml) {
198 ATH_MSG_ERROR("BIS78 data ml encoding failed. Expected " << ml << " got " << bis78_data.multilayer << ".");
199 return StatusCode::FAILURE;
200 }
201 increment_tdc();
202 }
203 }
204 }
205 }
206 return StatusCode::SUCCESS;
207}
#define ATH_MSG_ERROR(x,...)
Gaudi::Property< bool > m_useJSONFormat
StatusCode dbPayloadToJson(SG::ReadCondHandle< CondAttrListCollection > &readHandle, nlohmann::json &json) const
StatusCode loadCablingSchemaFromJSON(nlohmann::json &&payload, MuonMDT_CablingMap &cabling_map) const
bool extractStationInfo(const coral::AttributeList &atr, CablingData &map_data) const
Retrieves the general MDT station info from the coral attribute.
bool extractLayerInfo(std::vector< std::string > &, CablingData &map_data) const
Retrieves the channel info from the coral attribute.
MuonMDT_CablingMap::CablingData CablingData
bool addMezzanine(CablingData cabling_data, DataSource source, MsgStream &log)
Add a new fully configured mezzanine card.
const DataObjID & fullKey() const
static const std::string delimiter("/")
std::vector< std::string > tokenize(std::string_view the_str, std::string_view delimiters)
Splits the string into smaller substrings.

◆ loadCablingSchemaFromJSON()

StatusCode MuonMDT_CablingAlg::loadCablingSchemaFromJSON ( nlohmann::json && payload,
MuonMDT_CablingMap & cabling_map ) const
private

Definition at line 358 of file MuonMDT_CablingAlg.cxx.

358 {
359 const MdtIdHelper& id_helper = m_idHelperSvc->mdtIdHelper();
360 for (const auto &db_channel : payload.items()) {
361 nlohmann::json ms_payload = db_channel.value();
362 CablingData ms_channel{};
363 ms_channel.stationIndex = id_helper.stationNameIndex(ms_payload["station"]);
364 ms_channel.eta = ms_payload["eta"];
365 ms_channel.phi = ms_payload["phi"];
366 ms_channel.multilayer = ms_payload["ml"];
367
368 ms_channel.subdetectorId = ms_payload["subDet"];
369 ms_channel.csm = ms_payload["csm"];
370 ms_channel.mrod = ms_payload["mrod"];
371
372 ms_channel.mezzanine_type = ms_payload["mezzId"];
373 ms_channel.tdcId = ms_payload["tdcId"];
374 ms_channel.tube = ms_payload["tubeZero"];
375
376 ms_channel.layer = 1;
377 MdtMezzanineCard::MezzCardPtr hedgeHogCard = cabling_map.getHedgeHogMapping(ms_channel.mezzanine_type);
378 ms_channel.channelId = hedgeHogCard ? (*std::min_element(
379 hedgeHogCard->tubeToTdcMap().begin(),
380 hedgeHogCard->tubeToTdcMap().end())) : 0;
381 if (!cabling_map.addMezzanine(std::move(ms_channel), DataSource::JSON, msgStream())) return StatusCode::FAILURE;
382 }
383 return StatusCode::SUCCESS;
384}
const Mapping & tubeToTdcMap() const
Returns the underlying Tube -> Tdc conversion map.
std::shared_ptr< const MdtMezzanineCard > MezzCardPtr
int stationNameIndex(const std::string &name) const
MezzCardPtr getHedgeHogMapping(uint8_t mezzCardId) const

◆ loadMezzanineFromJSON()

StatusCode MuonMDT_CablingAlg::loadMezzanineFromJSON ( nlohmann::json && payload,
MuonMDT_CablingMap & cabling_map ) const
private

Definition at line 346 of file MuonMDT_CablingAlg.cxx.

346 {
347 using MezzMapping = MdtMezzanineCard::Mapping;
348 for (const auto &cabl_chan : payload.items()) {
349 nlohmann::json mezz_payload = cabl_chan.value();
350 const uint8_t id = mezz_payload["mezzId"];
351 const uint8_t nLay = mezz_payload["nTubeLayer"];
352 const MezzMapping mapping = mezz_payload["tdcToTubeMap"];
353 if(!cabling_map.addMezanineLayout(std::make_unique<MdtMezzanineCard>(mapping, nLay, id),
354 msgStream())) return StatusCode::FAILURE;
355 }
356 return StatusCode::SUCCESS;
357}
std::array< uint8_t, 24 > Mapping
bool addMezanineLayout(std::unique_ptr< MdtMezzanineCard > card, MsgStream &log)
Adds a new mezzanine card mapping.

◆ loadMezzanineSchema()

StatusCode MuonMDT_CablingAlg::loadMezzanineSchema ( const EventContext & ctx,
SG::WriteCondHandle< MuonMDT_CablingMap > & writeHandle,
MuonMDT_CablingMap & cabling_map ) const
private

Load the mezzanine schema into the cabling.

Read Cond Handle

Definition at line 294 of file MuonMDT_CablingAlg.cxx.

295 {
296 if (m_mezzJSON.value().size()){
297 std::ifstream in_json{m_mezzJSON};
298 if (!in_json.good()) {
299 ATH_MSG_FATAL("Failed to open external JSON file "<<m_mezzJSON);
300 return StatusCode::FAILURE;
301 }
302 nlohmann::json payload{};
303 in_json >> payload;
304 ATH_CHECK(loadMezzanineFromJSON(std::move(payload), cabling_map));
305 return StatusCode::SUCCESS;
306 }
307
309 SG::ReadCondHandle<CondAttrListCollection> readHandleMez{m_readKeyMez, ctx};
310 if (!readHandleMez.isValid()) {
311 ATH_MSG_ERROR("Null pointer to the read conditions object "<<m_readKeyMez.fullKey());
312 return StatusCode::FAILURE;
313 }
314 writeHandle.addDependency(readHandleMez);
315
316 ATH_MSG_INFO("Size of CondAttrListCollection " << readHandleMez.fullKey()
317 << " readCdoMez->size()= " << readHandleMez->size());
318
319 if (m_useJSONFormat) {
320 nlohmann::json json;
321 ATH_CHECK(dbPayloadToJson(readHandleMez, json));
322 ATH_CHECK(loadMezzanineFromJSON(std::move(json),cabling_map));
323 return StatusCode::SUCCESS;
324 }
326 for (itrMez = readHandleMez->begin(); itrMez != readHandleMez->end(); ++itrMez) {
327 const coral::AttributeList& atr = itrMez->second;
328 int sequence{0}, layer{0}, mezzanine_type{0};
329
330 mezzanine_type = *(static_cast<const int*>((atr["Mezzanine_Type"]).addressOfData()));
331 layer = *(static_cast<const int*>((atr["Layer"]).addressOfData()));
332 sequence = *(static_cast<const int*>((atr["Sequence"]).addressOfData()));
333 ATH_MSG_VERBOSE("Sequence load is " << sequence << " for the mezzanine type = " << mezzanine_type
334 << " for the layer number = " << layer);
335
336 // here add the mezzanine type to the cabling class
337 if (!cabling_map.addMezzanineLine(mezzanine_type, layer, sequence, msgStream())) {
338 ATH_MSG_ERROR("Could not add the mezzanine sequence to the map ");
339 return StatusCode::FAILURE;
340 } else {
341 ATH_MSG_VERBOSE("Sequence added successfully to the map");
342 }
343 }
344 return StatusCode::SUCCESS;
345}
StatusCode loadMezzanineFromJSON(nlohmann::json &&payload, MuonMDT_CablingMap &cabling_map) const
bool addMezzanineLine(const int type, const int layer, const int sequence, MsgStream &log)
Add a new line describing a mezzanine type.
@ layer
Definition HitInfo.h:79

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 368 of file AthCommonDataStore.h.

369 {
370 h.renounce();
372 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 352 of file AthCommonDataStore.h.

352 {
354 }

◆ setFilterPassed()

virtual void AthCommonAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Set filter decision:

Definition at line 99 of file AthCommonAlgorithm.h.

99 {
101 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Set filter decision:

◆ sysExecute()

StatusCode AthCommonAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Reimplemented in AthAnalysisAlgorithm.

Definition at line 80 of file AthCommonAlgorithm.cxx.

41{
42 return BaseAlg::sysExecute (ctx);
43}

◆ sysInitialize()

StatusCode AthCommonAlgorithm< Gaudi::Algorithm >::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthHistogramAlgorithm, HypoBase, InputMakerBase, and PyAthena::Alg.

Definition at line 60 of file AthCommonAlgorithm.cxx.

71 {
73
74 if (sc.isFailure()) {
75 return sc;
76 }
77
78 ServiceHandle<ICondSvc> cs("CondSvc",name());
79 for (auto h : outputHandles()) {
80 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
81 // do this inside the loop so we don't create the CondSvc until needed
82 if ( cs.retrieve().isFailure() ) {
83 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
85 }
86 if (cs->regHandle(this,*h).isFailure()) {
88 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
89 << " with CondSvc");
90 }
91 }
92 }
93 return sc;
94}
virtual StatusCode sysInitialize() override
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 298 of file AthCommonDataStore.h.

298 {
299 for (auto &a : m_vhka) {
301 for (auto k : keys) {
302 k->setOwner(this);
303 }
304 }
305 }

Member Data Documentation

◆ m_chambJSON

Gaudi::Property<std::string> MuonMDT_CablingAlg::m_chambJSON
private
Initial value:
{this, "CablingJSON", "",
"External JSON file to read the MDT cabling from"}

Definition at line 61 of file MuonMDT_CablingAlg.h.

61 {this, "CablingJSON", "",
62 "External JSON file to read the MDT cabling from"};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 381 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 378 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 108 of file AthCommonAlgorithm.h.

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> MuonMDT_CablingAlg::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Definition at line 33 of file MuonMDT_CablingAlg.h.

33{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_isRun3

Gaudi::Property<bool> MuonMDT_CablingAlg::m_isRun3 {this, "isRun3", false, "Auxillary property to load the BIS78 cabling by hand"}
private

Definition at line 38 of file MuonMDT_CablingAlg.h.

38{this, "isRun3", false, "Auxillary property to load the BIS78 cabling by hand"};

◆ m_mezzJSON

Gaudi::Property<std::string> MuonMDT_CablingAlg::m_mezzJSON
private
Initial value:
{this, "MezzanineJSON", "" ,
"External JSON file to read the mezzanine mapping from"}

Definition at line 58 of file MuonMDT_CablingAlg.h.

58 {this, "MezzanineJSON", "" ,
59 "External JSON file to read the mezzanine mapping from"};

◆ m_readKeyMap

SG::ReadCondHandleKey<CondAttrListCollection> MuonMDT_CablingAlg::m_readKeyMap {this, "MapFolders", "/MDT/CABLING/MAP_SCHEMA"}
private

Definition at line 35 of file MuonMDT_CablingAlg.h.

35{this, "MapFolders", "/MDT/CABLING/MAP_SCHEMA"};

◆ m_readKeyMez

SG::ReadCondHandleKey<CondAttrListCollection> MuonMDT_CablingAlg::m_readKeyMez {this, "MezzanineFolders", "/MDT/CABLING/MEZZANINE_SCHEMA"}
private

Definition at line 34 of file MuonMDT_CablingAlg.h.

34{this, "MezzanineFolders", "/MDT/CABLING/MEZZANINE_SCHEMA"};

◆ m_useJSONFormat

Gaudi::Property<bool> MuonMDT_CablingAlg::m_useJSONFormat
private
Initial value:
{this, "UseJSONFormat", false,
"Read out the cabling database JSON based"}

Definition at line 64 of file MuonMDT_CablingAlg.h.

64 {this, "UseJSONFormat", false,
65 "Read out the cabling database JSON based"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 387 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
privateinherited

Definition at line 386 of file AthCommonDataStore.h.

◆ m_writeKey

SG::WriteCondHandleKey<MuonMDT_CablingMap> MuonMDT_CablingAlg::m_writeKey {this, "WriteKey", "MuonMDT_CablingMap", "Key of output MDT cabling map"}
private

Definition at line 36 of file MuonMDT_CablingAlg.h.

36{this, "WriteKey", "MuonMDT_CablingMap", "Key of output MDT cabling map"};

The documentation for this class was generated from the following files: