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

#include <MdtCablingJsonDumpAlg.h>

Inheritance diagram for MdtCablingJsonDumpAlg:
Collaboration diagram for MdtCablingJsonDumpAlg:

Public Types

using CablingData = MuonMDT_CablingMap::CablingData

Public Member Functions

virtual ~MdtCablingJsonDumpAlg ()=default
virtual StatusCode initialize () override
virtual StatusCode execute (const EventContext &ctx) override
 Execute method.
virtual unsigned int cardinality () const override final
 AthAlgorithm (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor with parameters:
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
bool filterPassed (const EventContext &ctx) const
void setFilterPassed (bool state, const EventContext &ctx) const
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
const EventContext & getContext () const
 Deprecated methods (use the ones with EventContext).
bool filterPassed () const
void setFilterPassed (bool state) const

Protected Member Functions

virtual bool isReEntrant () const override final
 Legacy algorithms are not thread-safe.
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< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
SG::ReadCondHandleKey< MuonGM::MuonDetectorManagerm_DetectorManagerKey
SG::ReadCondHandleKey< MuonMDT_CablingMapm_cablingKey {this, "ReadKey", "MuonMDT_CablingMap", "Key of input MDT cabling map"}
Gaudi::Property< std::string > m_summaryTxt {this, "SummaryFile", "SummaryFile.txt", "Summary of the extracted mapping"}
Gaudi::Property< std::string > m_mezzJSON {this, "OutMezzanineJSON", "MezzMapping.json", "Mezzanine JSON"}
Gaudi::Property< std::string > m_cablingJSON {this, "OutCablingJSON", "MdtCabling.json", "Cabling JSON"}
Gaudi::Property< bool > m_insertBISCabling {this, "insertBISCabling", false, "override the BIS cabling in the JSON file"}
DataObjIDColl m_extendedExtraObjects
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

Definition at line 22 of file MdtCablingJsonDumpAlg.h.

Member Typedef Documentation

◆ CablingData

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ ~MdtCablingJsonDumpAlg()

virtual MdtCablingJsonDumpAlg::~MdtCablingJsonDumpAlg ( )
virtualdefault

Member Function Documentation

◆ AthAlgorithm()

AthAlgorithm::AthAlgorithm ( const std::string & name,
ISvcLocator * pSvcLocator )

Constructor with parameters:

Definition at line 57 of file AthAlgorithm.cxx.

22 :
24{
25 // default cardinality for non-reentrant algorithms
26 setProperty( "Cardinality", 1 ).orThrow("Unable to set property 'Cardinality'", name);
27
28 // Set up to run AthAlgorithmDHUpdate in sysInitialize before
29 // merging dependency lists. This extends the output dependency
30 // list with any symlinks implied by inheritance relations.
31 m_updateDataHandles =
32 std::make_unique<AthenaBaseComps::AthAlgorithmDHUpdate>
34 std::move (m_updateDataHandles));
35}
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)
DataObjIDColl m_extendedExtraObjects
AthCommonDataStore(const std::string &name, T... args)

◆ cardinality()

virtual unsigned int MdtCablingJsonDumpAlg::cardinality ( ) const
inlinefinaloverridevirtual

Definition at line 28 of file MdtCablingJsonDumpAlg.h.

28{return 1;}

◆ 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 MdtCablingJsonDumpAlg::execute ( const EventContext & ctx)
overridevirtual

Execute method.

Provides access to the EventContext if needed but is non-const as opposed to AthReentrantAlgorithm.

Struct to perform the mapping between online offline tube

Create the cabling object

Test if the online channel can be found

Next step is to filter all the mezzanine cards

Assign MROD / SubDet / CSM

Offline Identifier (stationIdx, eta,phi, ml)

Tube zero

The staggering of the hedgehog cards does not coincide with the multi-layer staggering i.e. tubeZero is 2,3,4,5 or 2,3,4,5,6,7.

Check whether the same layout is already used somewhere

Subdetector identifiers 97: barrel (A), 98: barrel (C), 99 endcap (A), 100, endcap (C)

Summary file

Write mezzanine file

Implements AthAlgorithm.

Definition at line 45 of file MdtCablingJsonDumpAlg.cxx.

45 {
46 ATH_MSG_INFO("Dump cabling & mezzanines into JSON file");
47
48 const MuonGM::MuonDetectorManager* detectorMgr{nullptr};
49 ATH_CHECK(SG::get(detectorMgr, m_DetectorManagerKey, ctx));
50
51 const MuonMDT_CablingMap* cabling{nullptr};
52 ATH_CHECK(SG::get(cabling, m_cablingKey,ctx));
53
54 const MdtIdHelper& idHelper = m_idHelperSvc->mdtIdHelper();
55
56 std::vector<MdtMezzanineCard> cached_cards{};
57 std::set<MdtCablingData> cached_chnls{};
58 constexpr auto unsetArray{make_array<uint8_t,24>(MdtMezzanineCard::NOTSET)};
59 for (auto det_itr = idHelper.detectorElement_begin(); det_itr != idHelper.detectorElement_end(); ++det_itr){
60 const MuonGM::MdtReadoutElement* readEle = detectorMgr->getMdtReadoutElement(*det_itr);
61 if (!readEle) {
62 ATH_MSG_DEBUG("Detector element does not exist. ");
63 continue;
64 }
65 const Identifier station_id = idHelper.elementID(readEle->identify());
66 if(m_insertBISCabling && m_idHelperSvc->stationNameString(station_id)=="BIS" && readEle->getStationEta() < 7){
67 ATH_MSG_DEBUG("Will skip cabling for station "
68 <<m_idHelperSvc->toStringChamber(readEle->identify())
69 << " since it will be inserted manually");
70 continue;
71 }
72
74 MdtMezzanineCard dummy_card(Mapping{}, readEle->getNLayers(), -1);
75 std::map<TdcIdentifier, Mapping> chamber_mezz{};
76 const int nLayers{readEle->getNLayers()};
77 const int nTubes{readEle->getNtubesperlayer()};
78 const int multiLayer{readEle->getMultilayer()};
79
80 for (int layer = 1 ; layer <= nLayers; ++layer){
81 for (int tubeInLayer = 1 ; tubeInLayer <= nTubes; ++tubeInLayer) {
82 bool is_valid{false};
83 const Identifier tube_id = idHelper.channelID(station_id, multiLayer,
84 layer, tubeInLayer, is_valid);
85 if (!is_valid) {
86 ATH_MSG_VERBOSE("Invalid element");
87 continue;
88 }
90 MdtCablingData cabling_data{};
91 cabling->convert(tube_id,cabling_data);
93 if (!cabling->getOnlineId(cabling_data, msgStream())) {
94 ATH_MSG_WARNING("Could no retrieve a valid online channel for "<<m_idHelperSvc->toString(tube_id));
95 continue;
96 }
97 const TdcIdentifier tdc_id{cabling_data};
98 chamber_mezz.try_emplace(tdc_id,unsetArray);
99 chamber_mezz[tdc_id][cabling_data.channelId] = dummy_card.tubeNumber(layer, tubeInLayer);
100 }
101 }
103 for (auto&[tdc, mezz_mapping] : chamber_mezz) {
104 MdtCablingData mezzCablingId{};
105
107 static_cast<MdtCablingOnData&>(mezzCablingId) = tdc;
108 mezzCablingId.tdcId = tdc.tdcId;
109
110 MdtTdcOnlSorter chipInCab = cabling->getOnlineConvMap().at(tdc).all_modules.at(tdc.tdcId);
112 static_cast<MdtCablingOffData&>(mezzCablingId) = chipInCab->offId();
114 mezzCablingId.tube = chipInCab->tubeZero();
115
116 const uint8_t tubeOffSet = (mezzCablingId.tube-1)%dummy_card.numTubesPerLayer();
119 if (tubeOffSet) {
120 MdtMezzanineCard remap{mezz_mapping, dummy_card.numTubeLayers(), 0};
121 for (size_t chan = 0 ; chan < mezz_mapping.size(); ++chan) {
122 const OfflineCh tube_lay = remap.offlineTube(chan, msgStream());
123 if (!tube_lay.isValid) continue;
124 uint8_t tubeNumber = tube_lay.tube + tubeOffSet + 1;
125 mezz_mapping[chan] = remap.tubeNumber(tube_lay.layer, tubeNumber);
126 }
127 }
129 Mapping& mtmp = mezz_mapping; // Work around clang15 compilation error.
130 std::vector<MdtMezzanineCard>::const_iterator itr = std::find_if(cached_cards.begin(), cached_cards.end(),
131 [&dummy_card, &mtmp](const MdtMezzanineCard& card ){
132 if (dummy_card.numTubeLayers() != card.numTubeLayers()) return false;
133 for (size_t ch =0; ch < mtmp.size(); ++ch) {
134 if (mtmp[ch] != card.tdcToTubeMap()[ch]) return false;
135 }
136 return true;
137 });
138 if (itr != cached_cards.end()) {
139 mezzCablingId.mezzanine_type = itr->id();
140 } else {
141 cached_cards.emplace_back(mezz_mapping, dummy_card.numTubeLayers(), cached_cards.size() + 10);
142 if (!cached_cards.back().checkConsistency(msgStream())) {
143 ATH_MSG_ERROR("Wrong assignment for "<<mezzCablingId);
144 return StatusCode::FAILURE;
145 }
146 mezzCablingId.mezzanine_type = cached_cards.back().id();
147 }
148 cached_chnls.insert(std::move(mezzCablingId));
149 }
150 }
151
153 ATH_MSG_INFO("Inserting BIS cabling manually");
154 // defining the costum mapping to be inserted for BIS chambers
155
156 /* The BIS chambers are build using two different tube stagering configurations, one for the A side and one for the C side
157 For sectors 12 and 16 the chambers of the A and C side are swapped following space constrains in the detector,
158 bringing the readout side of those chambers to the other side. This also swaps the tube staggering configuration.
159 Following the staggering configuration two types of mezzanine cards are used to read out the BIS chambers.
160
161 Mezanine type 6 are used for the A-side type chambers. It has the following channel mapping:
162
163 23 19 15 11 7 3
164 22 18 14 10 6 2
165 21 17 13 9 5 1
166 20 16 12 8 4 0
167
168 For the C-side type chambers mezzanine type 7 is used, with the following channel mapping:
169
170 1 5 9 13 17 21
171 0 4 8 12 16 20
172 3 7 11 15 19 23
173 2 6 10 14 18 22
174
175 For the mezz type 7 channel 0 is connected to layer 3 while for mezz type 6 channel 0 is connected to layer 4 so below the mapping will be rotated accordingly. Since the chambers have Nx6 - 2 tubes there are special mezzanine cards with a 4x5 configuration. Since they maintain the above design but missing the last row of tubes (the row on the opposite side of channel 0) so a 6b and 7b design will be introduced with 4 channels set to read tube 255 as proxy for not connected channels.
176
177 The CSM modules of each chamber can read up to 20 mezzanine cards. For BIS 2-7 this is enough to read out all the tube of the chamber.
178 For the BIS1 chambers the 24 mezzanine cards are readout by two CSMs each reading out 12 mezzanine cards. In general the channel number of the CSM to which the mezzanine is connected to is even for mezzanine cards connected to multilayer 1 and odd for multilayer 2, starting to count from 0. The channel number is increased in the direction of the global z coordinate axis.
179 */
180 constexpr std::array<uint8_t,24> mezzanineType6InvertedMap{23, 17, 11, 5,
181 22, 16, 10, 4,
182 21, 15, 9, 3,
183 20, 14, 8, 2,
184 19, 13, 7, 1,
185 18, 12, 6, 0};
186
187 constexpr std::array<uint8_t,24> mezzanineType6bInvertedMap{250, 250, 250,250,
188 22, 16, 10, 4,
189 21, 15, 9, 3,
190 20, 14, 8, 2,
191 19, 13, 7, 1,
192 18, 12, 6, 0};
193 constexpr std::array<uint8_t,24> mezzanineType6b2InvertedMap{250, 250, 250, 250,
194 23, 17, 11, 5,
195 22, 16, 10, 4,
196 21, 15, 9, 3,
197 20, 14, 8, 2,
198 19, 13, 7, 1};
199
200 constexpr std::array<uint8_t,24> mezzanineType7Map{12, 18, 0, 6,
201 13, 19, 1, 7,
202 14, 20, 2, 8,
203 15, 21, 3, 9,
204 16, 22, 4, 10,
205 17, 23, 5, 11};
206
207 constexpr std::array<uint8_t,24> mezzanineType7bMap{12, 18, 0, 6,
208 13, 19, 1, 7,
209 14, 20, 2, 8,
210 15, 21, 3, 9,
211 16, 22, 4, 10,
212 250, 250, 250, 250};
213
214 constexpr std::array<uint8_t,24> mezzanineType7b2Map{ 13, 19, 1, 7,
215 14, 20, 2, 8,
216 15, 21, 3, 9,
217 16, 22, 4, 10,
218 17, 23, 5, 11,
219 250, 250, 250, 250};
220
221
222
223 // Let's add the four types to the cached cards if not already present so we can reference them later
224 std::map<std::string, MdtMezzanineCard> mezzTypes{};
225 mezzTypes.emplace(std::make_pair("mezzanineType6", MdtMezzanineCard(mezzanineType6InvertedMap, 4, 0)));
226 mezzTypes.emplace(std::make_pair("mezzanineType6b", MdtMezzanineCard(mezzanineType6bInvertedMap, 4, 0)));
227 mezzTypes.emplace(std::make_pair("mezzanineType6b2", MdtMezzanineCard(mezzanineType6b2InvertedMap, 4, 0)));
228 mezzTypes.emplace(std::make_pair("mezzanineType7", MdtMezzanineCard(mezzanineType7Map, 4, 0)));
229 mezzTypes.emplace(std::make_pair("mezzanineType7b", MdtMezzanineCard(mezzanineType7bMap, 4, 0)));
230 mezzTypes.emplace(std::make_pair("mezzanineType7b2", MdtMezzanineCard(mezzanineType7b2Map, 4, 0)));
231 std::map<std::string, int> mezzTypeIds{};
232 for(auto& [type,card] : mezzTypes){
233 auto itr = std::ranges::find_if(cached_cards,
234 [&card](const MdtMezzanineCard& cachedCard){
235 if(cachedCard.numTubeLayers() != card.numTubeLayers()) {
236 return false;
237 }
238 for(size_t ch = 0; ch < card.tdcToTubeMap().size(); ++ch){
239 if(cachedCard.tdcToTubeMap()[ch] != card.tdcToTubeMap()[ch]) {
240 return false;
241 }
242 }
243 return true;
244 });
245 if(itr != cached_cards.end()){
246 mezzTypeIds[type] = itr->id();
247 } else {
248 cached_cards.emplace_back(card.tdcToTubeMap(), card.numTubeLayers(), cached_cards.size() + 10);
249 mezzTypeIds[type] = cached_cards.back().id();
250 }
251 }
252
253 for(auto& [type,card] : mezzTypes){
254 ATH_MSG_VERBOSE("mezzz type" << type << " has id " << mezzTypeIds[type]);
255 }
256 /* We have to keep track of the MROD and CSM numbers for each partition.
257 Since there are no MRODs in phase two we can assign the new BIS stations to fantasy MROD numbers while we wait for the new FELIX based cabling scheme. Since there are up to 51 MRODs per partition in RUN3 the new chambers will be assigned to MRDOs starting from 55 upwards. Each MROD can read up to 6 CSMs so the CSM counter will be increased accordingly when we assign the cabling for each chamber.
258 */
259 std::map<uint8_t, uint8_t> mrodMap, csmMap;
260 mrodMap[97] = 55; csmMap[97] = 0; // A-side barrel
261 mrodMap[98] = 55; csmMap[98] = 0; // C-side barrel
262
263 for (auto det_itr = idHelper.detectorElement_begin(); det_itr != idHelper.detectorElement_end(); ++det_itr){
264 const MuonGM::MdtReadoutElement* readEle = detectorMgr->getMdtReadoutElement(*det_itr);
265 if (!readEle) {
266 ATH_MSG_DEBUG("Detector element does not exist. ");
267 continue;
268 }
269 // since BIS 1-6 chambers have identical layouts for multilayer 1 and 2 and for BIS78C the second multilayer has more tubes, so we will loop only over the multilayer 2 readout elements here and take care of the multilayer 1 cabling at the same time
270 if(readEle->getMultilayer()!=2) {
271 continue;
272 }
273 const Identifier station_id = idHelper.elementID(readEle->identify());
274 if( !m_insertBISCabling || m_idHelperSvc->stationNameString(station_id)!="BIS" || readEle->getStationEta() >= 7) {
275 continue;
276 }
277 //find the multilayer 1 readout element to get the number of tubes per layer
278 Identifier id_ml1 = idHelper.multilayerID(readEle->identify(),1);
279 const MuonGM::MdtReadoutElement* readEle_ml1 = detectorMgr->getMdtReadoutElement(id_ml1);
280 int tubesPerLayer_ml1 = readEle_ml1->getNtubesperlayer();
281
282 ATH_MSG_INFO("Will insert cabling for station "<<m_idHelperSvc->toString(station_id));
283
284 const int nTubes{readEle->getNtubesperlayer()};
285 uint8_t tdcId{0};
287 uint8_t subdetectorId{0};
288 if(readEle->getStationEta() > 0){
289 subdetectorId = 97;
290 } else{
291 subdetectorId = 98;
292 }
293 for(int tubeInLayer = 1 ; tubeInLayer <= nTubes;
294 tubeInLayer += mezzTypes.at("mezzanineType6").numTubesPerLayer()){
295
296 if(tubeInLayer==1 && std::abs(readEle->getStationEta()) !=7){tubeInLayer -=1;} // account for the fact that the first mezzanine card only has 5 tubes per layer for BIS 1-6
297 MdtCablingData mezzCablingId_ml1{};
298 if(tubeInLayer <= tubesPerLayer_ml1){
299 mezzCablingId_ml1.stationIndex = m_idHelperSvc->stationName(station_id);
300 mezzCablingId_ml1.eta = readEle->getStationEta();
301 mezzCablingId_ml1.phi = readEle->getStationPhi();
302 mezzCablingId_ml1.multilayer = 1;
303 mezzCablingId_ml1.subdetectorId = subdetectorId;
304 mezzCablingId_ml1.csm = csmMap[subdetectorId];
305 mezzCablingId_ml1.mrod = mrodMap[subdetectorId];
306 mezzCablingId_ml1.tdcId = tdcId;
307 mezzCablingId_ml1.tube = tubeInLayer;
308 }
309
310
311 MdtCablingData mezzCablingId_ml2{};
312 mezzCablingId_ml2.stationIndex = m_idHelperSvc->stationName(station_id);
313 mezzCablingId_ml2.eta = readEle->getStationEta();
314 mezzCablingId_ml2.phi = readEle->getStationPhi();
315 mezzCablingId_ml2.multilayer = 2;
316 mezzCablingId_ml2.subdetectorId = subdetectorId;
317 mezzCablingId_ml2.csm = csmMap[subdetectorId];
318 mezzCablingId_ml2.mrod = mrodMap[subdetectorId];
319 mezzCablingId_ml2.tdcId = tdcId +1;
320 mezzCablingId_ml2.tube = tubeInLayer;
321
322
323 // A-side type chamber
324 std::string mezzEndString = "";
325 //The first and the last mezzanine cards of BIS1-6 chambers have a 4x5 configuration
326 if(std::abs(readEle->getStationEta()) !=7 && tubeInLayer + 6 > nTubes) { mezzEndString = "b"; }
327 if(std::abs(readEle->getStationEta()) !=7 && tubeInLayer==0 ) { mezzEndString = "b2"; }
328 ATH_MSG_VERBOSE("For station "<<m_idHelperSvc->toString(station_id) << " tube " << tubeInLayer<< " assigning mezzanine types for tubeInLayer "<<tubeInLayer <<" mezzEndString "<<mezzEndString);
329 if(readEle->getStationEta() > 0 ){
330 // swapped chamber in sectors 12 and 16
331 if(readEle->getStationPhi() == 6 || readEle->getStationPhi() == 8){
332 if(tubeInLayer <= tubesPerLayer_ml1) {
333 mezzCablingId_ml1.mezzanine_type = mezzTypeIds["mezzanineType7"+mezzEndString]; // type 7 is used for type C-side chambers
334 }
335 mezzCablingId_ml2.mezzanine_type = mezzTypeIds["mezzanineType7"+mezzEndString]; // type 7 is used for type C-side chambers
336 } else {
337 if(tubeInLayer <= tubesPerLayer_ml1) {
338 mezzCablingId_ml1.mezzanine_type = mezzTypeIds["mezzanineType6"+mezzEndString];
339 }
340 mezzCablingId_ml2.mezzanine_type = mezzTypeIds["mezzanineType6"+mezzEndString];
341 }
342 } else {
343 // swapped chamber in sectors 12 and 16
344 if(readEle->getStationPhi() == 6 || readEle->getStationPhi() == 8){
345 if(tubeInLayer <= tubesPerLayer_ml1){
346 mezzCablingId_ml1.mezzanine_type = mezzTypeIds["mezzanineType6"+mezzEndString]; // type 6 is used for type A-side chambers
347 }
348 mezzCablingId_ml2.mezzanine_type = mezzTypeIds["mezzanineType6"+mezzEndString]; // type 6 is used for type A-side chambers
349 } else {
350 if(tubeInLayer <= tubesPerLayer_ml1){
351 mezzCablingId_ml1.mezzanine_type = mezzTypeIds["mezzanineType7"+mezzEndString];
352 }
353 mezzCablingId_ml2.mezzanine_type = mezzTypeIds["mezzanineType7"+mezzEndString];
354 }
355 }
356 if(tubeInLayer <= tubesPerLayer_ml1) {
357 cached_chnls.insert(std::move(mezzCablingId_ml1));
358 }
359 cached_chnls.insert(std::move(mezzCablingId_ml2));
360 // Update identifier
361 tdcId+=2;
362 // since BIS1 and BIS78C chambers are read out by two CSMs we need to update the tdcId and CSM numbers accordingly
363 if((std::abs(readEle->getStationEta()) == 1 && tdcId >=12) ||
364 (readEle->getStationEta() == -7 && tdcId >=17) ){
365
366 tdcId = 0;
367 csmMap[subdetectorId] +=1;
368 if(csmMap[subdetectorId]>5){
369 csmMap[subdetectorId]=0;
370 mrodMap[subdetectorId]+=1;
371 }
372 }
373 }
374 // Update CSM and MROD for next chamber
375 csmMap[subdetectorId] +=1;
376 if(csmMap[subdetectorId]>5){
377 csmMap[subdetectorId]=0;
378 mrodMap[subdetectorId]+=1;
379 }
380 }
381 }
383 {
384 std::ofstream summary{m_summaryTxt};
385 if (!summary.good()) {
386 ATH_MSG_ERROR("Failed to write "<<m_summaryTxt);
387 return StatusCode::FAILURE;
388 }
389 summary<<"Extracted "<<cached_cards.size()<<" mezzanine card layouts and "
390 <<cached_chnls.size()<<" chamber channels. \n\n\n";
391 for (const MdtMezzanineCard& card : cached_cards) {
392 summary<<card;
393 MdtCablingOffData chamb{};
394 for (const MdtCablingData& cabling : cached_chnls) {
395 if (cabling.mezzanine_type != card.id()) continue;
396 if (chamb != cabling) {
397 chamb = cabling;
398 summary<<std::endl<<" *** "<<idHelper.stationNameString(chamb.stationIndex);
399 summary<<static_cast<int>(std::abs(chamb.eta));
400 summary<<(chamb.eta > 0 ? "A" : "C");
401 summary<<static_cast<int>(chamb.phi);
402 summary<<"M"<<static_cast<int>(chamb.multilayer);
403 summary<<" --- tdcs: ";
404 }
405 summary<<static_cast<int>(cabling.tdcId)<<", ";
406 }
407 summary<<"\n\n"
408 <<"##############################################################\n";
409 }
410 }
412 {
413 std::ofstream mezz_json{m_mezzJSON};
414 if (!mezz_json.good()) {
415 ATH_MSG_ERROR("Failed to write "<<m_summaryTxt);
416 return StatusCode::FAILURE;
417 }
418 mezz_json<<"["<<std::endl;
419 for (size_t i = 0; i < cached_cards.size() ; ++i) {
420 const MdtMezzanineCard& card = cached_cards[i];
421 mezz_json<<" {\n";
422 mezz_json<<" \"mezzId\": "<<static_cast<int>(card.id())<<",\n";
423 mezz_json<<" \"nTubeLayer\": "<<static_cast<int>(card.numTubeLayers())<<",\n";
424 mezz_json<<" \"tdcToTubeMap\": [";
425 for (size_t ch = 0 ; ch < card.tdcToTubeMap().size(); ++ch) {
426 mezz_json<<static_cast<int>(card.tdcToTubeMap()[ch]);
427 if (ch + 1 != card.tdcToTubeMap().size())mezz_json<<",";
428 }
429 mezz_json<<"]\n";
430 mezz_json<<" }";
431 if (i +1 != cached_cards.size()) mezz_json<<",";
432 mezz_json<<"\n";
433 }
434 mezz_json<<"]";
435 }
436 {
437 std::ofstream chamb_json{m_cablingJSON};
438 if (!chamb_json.good()) {
439 ATH_MSG_FATAL("Failed to write "<<m_cablingJSON);
440 return StatusCode::FAILURE;
441 }
442 chamb_json<<"[\n";
443 size_t i =0;
444 for (const MdtCablingData& chamb : cached_chnls){
445 chamb_json<<" {\n";
446 chamb_json<<" \"station\": \""<<idHelper.stationNameString(chamb.stationIndex)<<"\",\n";
447 chamb_json<<" \"eta\": "<<static_cast<int>(chamb.eta)<<",\n";
448 chamb_json<<" \"phi\": "<<static_cast<int>(chamb.phi)<<",\n";
449 chamb_json<<" \"ml\": "<<static_cast<int>(chamb.multilayer)<<",\n";
450 chamb_json<<" \"subDet\": "<<static_cast<int>(chamb.subdetectorId)<<",\n";
451 chamb_json<<" \"csm\": "<<static_cast<int>(chamb.csm)<<",\n";
452 chamb_json<<" \"mrod\": "<<static_cast<int>(chamb.mrod)<<",\n";
453 chamb_json<<" \"tdcId\": "<<static_cast<int>(chamb.tdcId)<<",\n";
454 chamb_json<<" \"mezzId\": "<<static_cast<int>(chamb.mezzanine_type)<<",\n";
455 chamb_json<<" \"tubeZero\": "<<static_cast<int>(chamb.tube)<<"\n";
456 chamb_json<<" }";
457 if (i +1 != cached_chnls.size()) chamb_json<<",";
458 chamb_json<<"\n";
459 ++i;
460 }
461 chamb_json<<"]"<<std::endl;
462 }
463
464
465 return StatusCode::SUCCESS;
466}
constexpr std::array< T, N > make_array(const T &def_val)
Helper function to initialize in-place arrays with non-zero values.
Definition ArrayHelper.h:10
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
size_t size() const
Number of registered mappings.
Gaudi::Property< std::string > m_summaryTxt
Gaudi::Property< std::string > m_mezzJSON
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
SG::ReadCondHandleKey< MuonMDT_CablingMap > m_cablingKey
Gaudi::Property< std::string > m_cablingJSON
Gaudi::Property< bool > m_insertBISCabling
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Identifier multilayerID(const Identifier &channeldID) const
Identifier elementID(int stationName, int stationEta, int stationPhi) const
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const
static constexpr uint8_t NOTSET
const Mapping & tdcToTubeMap() const
Returns the underlying TDC -> Tube conversion map.
uint8_t id() const
returns mezzanine database identifier
uint8_t numTubeLayers() const
returns the number of layers
const MdtCablingOffData & offId() const
get the offline identifier
Definition MdtTdcMap.h:57
uint8_t tubeZero() const
Definition MdtTdcMap.h:72
int getNLayers() const
Returns the number of tube layers inside the multilayer.
int getMultilayer() const
Returns the multilayer represented by the readout element.
int getNtubesperlayer() const
Returns the number of tubes in each tube layer.
const MdtReadoutElement * getMdtReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Identifier identify() const override final
Returns the ATLAS Identifier of the MuonReadOutElement.
const std::string & stationNameString(const Identifier &id) const
const_id_iterator detectorElement_begin() const
Iterators over full set of ids.
const_id_iterator detectorElement_end() const
std::map< std::string, std::string > remap
list of directories to be explicitly remapped
Definition hcg.cxx:97
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
@ layer
Definition HitInfo.h:79
uint8_t tdcId
Mezzanine type.
uint8_t mezzanine_type
Tube number in the layer.
int tube
Layer inside the multilayer.
int8_t & multilayer
Phi sector of the MDT station.
int8_t & eta
Station of the chamber (i.e, BIL,BIS,etc.).
int8_t & phi
Eta of the MDT station.
uint8_t & subdetectorId
CSM number.
uint8_t & csm
MROD number.

◆ 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 & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

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

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}

◆ filterPassed() [1/2]

bool AthAlgorithm::filterPassed ( ) const
inherited

Definition at line 94 of file AthAlgorithm.cxx.

94 {
95 return filterPassed( Gaudi::Hive::currentContext() );
96}
bool filterPassed() const

◆ filterPassed() [2/2]

bool AthAlgorithm::filterPassed ( const EventContext & ctx) const
inherited

Definition at line 98 of file AthAlgorithm.cxx.

98 {
99 return execState( ctx ).filterPassed();
100}

◆ getContext()

const EventContext & AthAlgorithm::getContext ( ) const
inherited

Deprecated methods (use the ones with EventContext).

Definition at line 90 of file AthAlgorithm.cxx.

90 {
91 return Gaudi::Hive::currentContext();
92}

◆ initialize()

StatusCode MdtCablingJsonDumpAlg::initialize ( )
overridevirtual

Definition at line 37 of file MdtCablingJsonDumpAlg.cxx.

37 {
38 ATH_CHECK(m_idHelperSvc.retrieve());
39 ATH_CHECK(m_DetectorManagerKey.initialize());
40 ATH_CHECK(m_cablingKey.initialize());
41 return StatusCode::SUCCESS;
42}

◆ 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.

◆ isReEntrant()

virtual bool AthAlgorithm::isReEntrant ( ) const
inlinefinaloverrideprotectedvirtualinherited

Legacy algorithms are not thread-safe.

Definition at line 111 of file AthAlgorithm.h.

111{ return false; }

◆ 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 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
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 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed() [1/2]

void AthAlgorithm::setFilterPassed ( bool state) const
inherited

Definition at line 102 of file AthAlgorithm.cxx.

102 {
103 setFilterPassed( state, Gaudi::Hive::currentContext() );
104}
void setFilterPassed(bool state) const

◆ setFilterPassed() [2/2]

void AthAlgorithm::setFilterPassed ( bool state,
const EventContext & ctx ) const
inherited

Definition at line 106 of file AthAlgorithm.cxx.

106 {
107 execState( ctx ).setFilterPassed(state);
108}

◆ sysInitialize()

StatusCode AthAlgorithm::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, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

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

◆ 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 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }

Member Data Documentation

◆ m_cablingJSON

Gaudi::Property<std::string> MdtCablingJsonDumpAlg::m_cablingJSON {this, "OutCablingJSON", "MdtCabling.json", "Cabling JSON"}
private

Definition at line 42 of file MdtCablingJsonDumpAlg.h.

42{this, "OutCablingJSON", "MdtCabling.json", "Cabling JSON"};

◆ m_cablingKey

SG::ReadCondHandleKey<MuonMDT_CablingMap> MdtCablingJsonDumpAlg::m_cablingKey {this, "ReadKey", "MuonMDT_CablingMap", "Key of input MDT cabling map"}
private

Definition at line 38 of file MdtCablingJsonDumpAlg.h.

38{this, "ReadKey", "MuonMDT_CablingMap", "Key of input MDT cabling map"};

◆ m_DetectorManagerKey

SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> MdtCablingJsonDumpAlg::m_DetectorManagerKey
private
Initial value:
{this, "DetectorManagerKey", "MuonDetectorManager",
"Key of input MuonDetectorManager condition data"}

Definition at line 35 of file MdtCablingJsonDumpAlg.h.

35 {this, "DetectorManagerKey", "MuonDetectorManager",
36 "Key of input MuonDetectorManager condition data"};

◆ m_detStore

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

Pointer to StoreGate (detector store by default).

Definition at line 393 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 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 114 of file AthAlgorithm.h.

◆ m_idHelperSvc

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

Definition at line 33 of file MdtCablingJsonDumpAlg.h.

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

◆ m_insertBISCabling

Gaudi::Property<bool> MdtCablingJsonDumpAlg::m_insertBISCabling {this, "insertBISCabling", false, "override the BIS cabling in the JSON file"}
private

Definition at line 43 of file MdtCablingJsonDumpAlg.h.

43{this, "insertBISCabling", false, "override the BIS cabling in the JSON file"};

◆ m_mezzJSON

Gaudi::Property<std::string> MdtCablingJsonDumpAlg::m_mezzJSON {this, "OutMezzanineJSON", "MezzMapping.json", "Mezzanine JSON"}
private

Definition at line 41 of file MdtCablingJsonDumpAlg.h.

41{this, "OutMezzanineJSON", "MezzMapping.json", "Mezzanine JSON"};

◆ m_summaryTxt

Gaudi::Property<std::string> MdtCablingJsonDumpAlg::m_summaryTxt {this, "SummaryFile", "SummaryFile.txt", "Summary of the extracted mapping"}
private

Definition at line 40 of file MdtCablingJsonDumpAlg.h.

40{this, "SummaryFile", "SummaryFile.txt", "Summary of the extracted mapping"};

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.


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