95 {
96
99 ATH_MSG_ERROR(
"Failed to retrieve the MuonDetectorManager conditions object");
100 return StatusCode::FAILURE;
101 }
102
104 if(!sTGCdigits.isValid()) {
105 ATH_MSG_ERROR(
"Failed to retrieve the sTGC Digit container");
106 return StatusCode::FAILURE;
107 }
108
109 const NswDcsDbData* dcsData = nullptr;
111 SG::ReadCondHandle<NswDcsDbData> dcsDataHandle{
m_dcsKey, ctx};
113 ATH_MSG_ERROR(
"Failed to retrieve DCS data while running on data");
114 return StatusCode::FAILURE;
115 }
116 dcsData = dcsDataHandle.
cptr();
117 }
118
119 const std::array<uint16_t, 8> bcWindow = {0, 1, 2, 3, 4, UINT16_MAX-1, UINT16_MAX-2, UINT16_MAX-3};
120 for(const sTgcDigitCollection* digitCollection : *sTGCdigits) {
121
122 std::vector<uint32_t> hits_sourceid{}, hits_pfeb{}, hits_padchan{}, hits_relbcid{};
123 for(const sTgcDigit* digit : *digitCollection) {
125 if(std::find(bcWindow.begin(), bcWindow.end(),
digit->bcTag()) != bcWindow.end()) {
126 const Identifier Id =
digit->identify();
130 if(!dcsData->
isGoodTDaq(ctx,Id,disabled))
continue;
131 }
132
135 const int multilayer =
m_idHelperSvc->stgcIdHelper().multilayer(Id);
139
140
142 const char wheel = (stEta > 0) ? 'A' : 'C';
144 hits_sourceid.emplace_back(sourceid);
145
146
148 hits_pfeb.emplace_back(pfeb);
149
150
152 hits_padchan.emplace_back(padchan);
153
154
155 hits_relbcid.emplace_back(
digit->bcTag());
156
158 m_padTrigger_digits_sector->push_back(sector);
159 m_padTrigger_digits_eta->push_back(stEta);
160 m_padTrigger_digits_phi->push_back(stPhi);
161 m_padTrigger_digits_multilayer->push_back(multilayer);
162 m_padTrigger_digits_gasgap->push_back(gasGap);
163 m_padTrigger_digits_source_id->push_back(sourceid);
164 m_padTrigger_digits_pfeb->push_back(pfeb);
165 m_padTrigger_digits_pad_channel->push_back(padchan);
166 m_padTrigger_digits_relbcid->push_back(
digit->bcTag());
167 }
168 }
169 }
170 }
171 ATH_MSG_DEBUG(
"Processed sTGC digit collection with size " << digitCollection->size() <<
", finding a total of " << hits_sourceid.size() <<
" pad hits");
172
174 if(hits_sourceid.empty() or hits_pfeb.empty() or hits_padchan.empty() or hits_relbcid.empty()) continue;
175
176
177 std::vector<uint32_t> hits_indices{};
178 for(
size_t index{0};
index < hits_sourceid.size(); ++
index) {
179 if(hits_sourceid.at(index) == rob) hits_indices.emplace_back(index);
180 }
181
182 if(hits_indices.empty()) continue;
183
184
185 const auto& sourceid = hits_sourceid.at(hits_indices.front());
186 const bool isLarge = (sourceid % 2 == 0);
188 const char whl =
isA ?
'A' :
'C';
189 const auto sec = (sourceid & 0xf);
192
193
194 for(const auto& index: hits_indices) {
195 const auto& pfeb = hits_pfeb.at(index);
196 const auto&
chan = hits_padchan.at(index);
198 ATH_MSG_DEBUG(
"PadTrigger sector " << whl << sec+1 << std::dec <<
" -> Hit " << index <<
" pfeb " << pfeb <<
" padchan " << chan <<
" bcid " << bcid);
199
200
201
202
203
204
205
206
209 if(
patterns.at(it).getPfebs().at(layer) == pfeb and
patterns.at(it).getPadChannels().at(layer) == chan) {
213 }
214 }
215 }
216 }
217
218
219 std::string secstr = whl + std::to_string(sec+1);
223 masks.at(patind + bcid*
patterns.size()) |= tomask;
224 }
225 }
226 }
227
228
231
232 bool isTrigger;
233 std::vector<PadEmulatorTrigger> triggersBc{};
238 isTrigger =
trigger_4over8(hitmask & 0x01, hitmask & 0x02, hitmask & 0x04, hitmask & 0x08,
239 hitmask & 0x10, hitmask & 0x20, hitmask & 0x40, hitmask & 0x80);
240 }
242 isTrigger =
trigger_3and1(hitmask & 0x01, hitmask & 0x02, hitmask & 0x04, hitmask & 0x08,
243 hitmask & 0x10, hitmask & 0x20, hitmask & 0x40, hitmask & 0x80);
244 }
246 isTrigger =
trigger_2and2(hitmask & 0x01, hitmask & 0x02, hitmask & 0x04, hitmask & 0x08,
247 hitmask & 0x10, hitmask & 0x20, hitmask & 0x40, hitmask & 0x80);
248 }
251 hitmask & 0x10, hitmask & 0x20, hitmask & 0x40, hitmask & 0x80);
252 }
254 isTrigger =
trigger_5over8(hitmask & 0x01, hitmask & 0x02, hitmask & 0x04, hitmask & 0x08,
255 hitmask & 0x10, hitmask & 0x20, hitmask & 0x40, hitmask & 0x80);
256 }
259 hitmask & 0x10, hitmask & 0x20, hitmask & 0x40, hitmask & 0x80);
260 }
263 hitmask & 0x10, hitmask & 0x20, hitmask & 0x40, hitmask & 0x80);
264 }
266 isTrigger =
trigger_2X_3over4(hitmask & 0x01, hitmask & 0x02, hitmask & 0x04, hitmask & 0x08,
267 hitmask & 0x10, hitmask & 0x20, hitmask & 0x40, hitmask & 0x80);
268 }
270 isTrigger =
trigger_6over8(hitmask & 0x01, hitmask & 0x02, hitmask & 0x04, hitmask & 0x08,
271 hitmask & 0x10, hitmask & 0x20, hitmask & 0x40, hitmask & 0x80);
272 }
274 isTrigger =
trigger_8over8(hitmask & 0x01, hitmask & 0x02, hitmask & 0x04, hitmask & 0x08,
275 hitmask & 0x10, hitmask & 0x20, hitmask & 0x40, hitmask & 0x80);
276 }
277 else {
279 return StatusCode::FAILURE;
280 }
281 if(not isTrigger) continue;
282
283
284 triggersBc.emplace_back(
285 PadEmulatorTrigger(whl, sec,
pattern.getBandid(),
pattern.getPhiid(
isA), relbcid, pattern, hitmask)
286 );
287 }
289 m_padTrigger_efficiency->push_back(triggersBc.size());
290 for(const auto& trigger : triggersBc) {
291 if(relbcid != trigger.getRelbcid()) continue;
292 m_padTrigger_TP_R_id_init->push_back(trigger.getBandid());
293 m_padTrigger_TP_phi_id_init->push_back(trigger.getPhiid());
294 m_padTrigger_TP_relbcid_init->push_back(trigger.getRelbcid());
295 }
296 }
297
298
300 if(
m_doNtuple) m_padTrigger_efficiency->push_back(triggersBc.size());
301
302
304 if(
m_doNtuple) m_padTrigger_efficiency->push_back(triggersBc.size());
305
306
308 if(
m_doNtuple) m_padTrigger_efficiency->push_back(triggersBc.size());
309
310
311 if(not triggersBc.empty()) {
312 auto newCollection =
new Muon::NSW_PadTriggerData(
isA, sec, relbcid, 0);
313 for(const auto& trigger : triggersBc) {
314 if(relbcid != trigger.getRelbcid()) continue;
315 newCollection->addTrigger(trigger.getBandid(), trigger.getPhiid(), 0);
317 m_padTrigger_TP_R_id->push_back(trigger.getBandid());
318 m_padTrigger_TP_phi_id->push_back(trigger.getPhiid());
319 m_padTrigger_TP_relbcid->push_back(trigger.getRelbcid());
320 m_padTrigger_wheel->push_back(trigger.getWheel());
321 m_padTrigger_sector->push_back(trigger.getSector());
322 m_padTrigger_hitmask->push_back(trigger.getHitMask());
323 }
324 }
325 if(
out->addCollection(newCollection,
out->numberOfCollections()).isFailure()) {
326 ATH_MSG_ERROR(
"Failed while storing output in the Muon::NSW_PadTriggerDataContainer");
327 return StatusCode::FAILURE;
328 }
329 }
330 }
331 }
332 }
333 return StatusCode::SUCCESS;
334 }
bool isGoodEltx(const Identifier &channelId) const
bool isGood(const EventContext &ctx, const Identifier &channelId, bool issTgcQ1OuterHv=false) const
Returns whether the channel is alive, i.e. DCS state on, etc...
bool isConnectedChannel(const Identifier &channelId) const
bool isGoodHv(const Identifier &channelId, bool issTgcQ1OuterHv=false) const
bool isGoodTDaq(const EventContext &ctx, const Identifier &channelId, bool &permanentlyDisabled) const
const_pointer_type cptr()
std::vector< std::string > patterns
constexpr uint32_t NPFEB_PER_RADIUS
constexpr uint32_t PAD_TRIGGER_READOUT_NBC
uint32_t getPadchAthena(const int athCh, const int pfeb, const int sector, int gasGap)
uint32_t wheelSectorToSourceID(const char wheel, const uint32_t sector)
uint32_t getpFEBAthena(const int gas_gap, const int multiplet, const int stationEta)
bool trigger_superspecific5over8(const bool in0, const bool in1, const bool in2, const bool in3, const bool in4, const bool in5, const bool in6, const bool in7)
bool isA(const uint32_t sourceid)
bool trigger_2and2(const bool in0, const bool in1, const bool in2, const bool in3, const bool in4, const bool in5, const bool in6, const bool in7)
bool trigger_6over8(const bool in0, const bool in1, const bool in2, const bool in3, const bool in4, const bool in5, const bool in6, const bool in7)
bool trigger_4over8(const bool in0, const bool in1, const bool in2, const bool in3, const bool in4, const bool in5, const bool in6, const bool in7)
bool trigger_specific4over8(const bool in0, const bool in1, const bool in2, const bool in3, const bool in4, const bool in5, const bool in6, const bool in7)
bool trigger_3and1(const bool in0, const bool in1, const bool in2, const bool in3, const bool in4, const bool in5, const bool in6, const bool in7)
bool trigger_8over8(const bool in0, const bool in1, const bool in2, const bool in3, const bool in4, const bool in5, const bool in6, const bool in7)
bool trigger_2X_3over4(const bool in0, const bool in1, const bool in2, const bool in3, const bool in4, const bool in5, const bool in6, const bool in7)
bool trigger_specific5over8(const bool in0, const bool in1, const bool in2, const bool in3, const bool in4, const bool in5, const bool in6, const bool in7)
bool trigger_5over8(const bool in0, const bool in1, const bool in2, const bool in3, const bool in4, const bool in5, const bool in6, const bool in7)
setEventNumber setTimeStamp bcid