123 {
124
125 uint64_t event = ctx.eventID().event_number();
126 ATH_MSG_DEBUG(
"********************************************************* EVENT NUMBER = " << event);
127
130 ATH_MSG_ERROR(
"Failed to retrieve the MuonDetectorManager conditions object");
131 return StatusCode::FAILURE;
132 }
133
138 if( !readMcEventCollection.isValid() ){
140 return StatusCode::FAILURE;
141 }
142 if(
m_doTruth) ptrMcEventCollection = readMcEventCollection.cptr();
144 if( !readMuonEntryLayer.isValid() ){
146 return StatusCode::FAILURE;
147 }
149 ptrMuonEntryLayer = readMuonEntryLayer.cptr();
150 MMLoadVariables
load = MMLoadVariables();
151 std::map<std::pair<uint64_t, unsigned int>,evInf_entry> Event_Info;
152 ATH_CHECK(
load.getTruthInfo(ctx, ptrMcEventCollection, ptrMuonEntryLayer, Event_Info));
153
154
155 for (const auto &it : Event_Info) {
156 m_trigger_trueEtaRange->push_back(
it.second.eta_ip);
157 m_trigger_truePtRange->push_back(
it.second.pt);
158 m_trigger_trueThe->push_back(
it.second.theta_ip);
159 m_trigger_truePhi->push_back(
it.second.phi_ip);
160 m_trigger_trueDth->push_back(
it.second.dtheta);
161 m_trigger_trueEtaPos->push_back(
it.second.eta_pos);
162 m_trigger_trueThePos->push_back(
it.second.theta_pos);
163 m_trigger_truePhiPos->push_back(
it.second.phi_pos);
164 m_trigger_trueEtaEnt->push_back(
it.second.eta_ent);
165 m_trigger_trueTheEnt->push_back(
it.second.theta_ent);
166 m_trigger_truePhiEnt->push_back(
it.second.phi_ent);
167 }
168 }
169 }
170
172 if( !readMmDigitContainer.isValid() ){
174 return StatusCode::FAILURE;
175 }
176
177 const NswDcsDbData* dcsData = nullptr;
179 SG::ReadCondHandle<NswDcsDbData> dcsDataHandle{
m_dcsKey, ctx};
181 ATH_MSG_ERROR(
"Failed to retrieve DCS data while running on data");
182 return StatusCode::FAILURE;
183 }
184 dcsData = dcsDataHandle.
cptr();
185 }
186
187 for (const MmDigitCollection* digitCollection : *readMmDigitContainer) {
188
189 std::vector<std::shared_ptr<MMT_Hit> > ev_hits;
190 for (const MmDigit* digit : *digitCollection) {
191 const Identifier
id =
digit->identify();
193
197 if(!dcsData->
isGoodTDaq(ctx,
id,disabled))
continue;
198 }
199
204 const int multiplet =
m_idHelperSvc->mmIdHelper().multilayer(
id);
206
208
209 const MuonGM::MMReadoutElement* readout = detManager->getMMReadoutElement(id);
210 if (channel < 1 or channel > (readout->
getDesign(
id))->totalStrips)
continue;
211
212 const float stripTime =
digit->stripResponseTime();
213
214 if (stripTime < 0.) continue;
215 const int BC = std::ceil(stripTime/25.);
216 ev_hits.emplace_back(std::make_shared<MMT_Hit>(
id, stationName, stationEta, stationPhi, sector, multiplet, gasGap, channel, stripTime, BC, detManager.
cptr()));
217
218 if (ev_hits.back()->infSlope()) {
220 ev_hits.pop_back();
221 continue;
222 }
224 m_trigger_VMM->push_back(ev_hits.back()->getVMM());
225 m_trigger_plane->push_back(ev_hits.back()->getPlane());
226 m_trigger_station->push_back(ev_hits.back()->getStationEta());
227 m_trigger_strip->push_back(ev_hits.back()->getChannel());
228 m_trigger_RZslopes->push_back(ev_hits.back()->getRZSlope());
229 }
230 }
231
232
233 if (do_MMDiamonds and ev_hits.size() >= (
m_diamond->getXthreshold()+
m_diamond->getUVthreshold())) {
234 const bool isLarge = (std::ranges::all_of(ev_hits, [](const auto &hit) { return hit->getSector() == 'L'; }));
235 const char sector = (isLarge) ? 'L' : 'S';
236 const char side = (std::ranges::all_of(ev_hits, [](
const auto &hit) {
return hit->getStationEta() < 0; })) ?
'C' :
'A';
237 const int sectorPhi = ev_hits[0]->getSectorPhi();
238 const bool allSectorPhi = (std::ranges::all_of(ev_hits, [&](const auto &hit) { return hit->getSectorPhi() == sectorPhi; }));
239 if (not allSectorPhi) {
240 ATH_MSG_ERROR(
"Available digits belongs to different sectors IDs, unable to assign an unique ID in output RDO");
241 return StatusCode::FAILURE;
242 }
243 const bool isEta1 = (std::ranges::all_of(ev_hits, [](const auto &hit) { return std::abs(hit->getStationEta()) == 1; }));
244
245
246 std::vector<MMT_Road> ev_roads;
247 m_diamond->createRoads(ev_roads, isLarge, isEta1);
248
249
250 std::vector<slope_t> diamondSlopes;
251 m_diamond->findDiamonds(ev_hits, ev_roads, diamondSlopes, sectorPhi);
252
253
254 if (not diamondSlopes.empty()) {
256 m_trigger_diamond_ntrig->push_back(diamondSlopes.size());
257 for (const auto &slope : diamondSlopes) {
258 m_trigger_diamond_sector->push_back(sector);
259 m_trigger_diamond_sectorPhi->push_back(sectorPhi);
260 m_trigger_diamond_bc->push_back(slope.BC);
261 m_trigger_diamond_totalCount->push_back(slope.totalCount);
262 m_trigger_diamond_xCount->push_back(slope.xCount);
263 m_trigger_diamond_uCount->push_back(slope.uCount);
264 m_trigger_diamond_iX->push_back(slope.iRoad);
265 m_trigger_diamond_iU->push_back(slope.iRoadu);
266 m_trigger_diamond_iV->push_back(slope.iRoadv);
267 m_trigger_diamond_age->push_back(slope.age);
268 m_trigger_diamond_mx->push_back(slope.mx);
269 m_trigger_diamond_my->push_back(slope.my);
270 m_trigger_diamond_Uavg->push_back(slope.uavg);
271 m_trigger_diamond_Vavg->push_back(slope.vavg);
272 m_trigger_diamond_mxl->push_back(slope.mxl);
273 m_trigger_diamond_theta->push_back(slope.theta);
274 m_trigger_diamond_eta->push_back(slope.eta);
275 m_trigger_diamond_dtheta->push_back(slope.dtheta);
276 m_trigger_diamond_phi->push_back(slope.phi);
277 m_trigger_diamond_phiShf->push_back(slope.phiShf);
278 }
279 }
280
281
282 std::vector<int> slopeBC;
283 for (const auto &slope : diamondSlopes) slopeBC.push_back(slope.BC);
284 std::ranges::sort(slopeBC);
285 slopeBC.erase(
std::unique(slopeBC.begin(), slopeBC.end()), slopeBC.end() );
286 for (const auto bc : slopeBC) {
287 Muon::NSW_TrigRawData* trigRawData = new Muon::NSW_TrigRawData(sectorPhi-1, side, bc);
288
289 for (const auto &slope : diamondSlopes) {
290 if (bc == slope.BC) {
291 Muon::NSW_TrigRawDataSegment* trigRawDataSegment = new Muon::NSW_TrigRawDataSegment();
292
293
296 else {
299 for (uint8_t i=0;
i<
nPhi;
i++) {
300 if ((slope.phi) < (
m_phiMin+i*phiSteps)) {
302 break;
303 }
304 }
306 }
307 if (
m_doNtuple) m_trigger_diamond_TP_phi_id->push_back(phi_id);
308
309
310 double extrapolatedR = 7824.46*std::abs(std::tan(slope.theta));
313 else {
316 for (uint8_t j=0;
j<nR;
j++) {
317 if (extrapolatedR < (
m_rMin+j*Rsteps)) {
319 break;
320 }
321 }
323 }
324 if (
m_doNtuple) m_trigger_diamond_TP_R_id->push_back(R_id);
325
326
329 else {
332 for (uint8_t k=0;
k<ndTheta;
k++) {
333 if ((slope.dtheta) < (
m_dThetaMin+k*dThetaSteps)) {
335 break;
336 }
337 }
339 }
340 if (
m_doNtuple) m_trigger_diamond_TP_dTheta_id->push_back(dTheta_id);
341
342
343 trigRawDataSegment->
setLowRes(slope.lowRes);
344
345 trigRawData->
push_back(trigRawDataSegment);
346 }
347 }
349 }
350 }
351 }
352 else {
353 ATH_MSG_DEBUG(
"Available hits are " << ev_hits.size() <<
", less than X+UV threshold, skipping digit collection");
354 }
355 }
356
357 return StatusCode::SUCCESS;
358 }
#define ATH_MSG_WARNING(x)
AtlasHitsVector< TrackRecord > TrackRecordCollection
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const MuonChannelDesign * getDesign(const Identifier &id) const
returns the MuonChannelDesign class for the given identifier
void setLowRes(bool lowRes)
void setPhiIndex(uint8_t phiIndex)
void setDeltaTheta(uint8_t deltaTheta)
void setRIndex(uint8_t rIndex)
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()
constexpr uint8_t stationPhi
station Phi 1 to 8
constexpr uint8_t stationEta
1 to 3
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
constexpr int nPhi
Default bin number of phi for vertex map.
load(f, use_proxy=1, key=None)
DataModel_detail::iterator< DVL > unique(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of unique for DataVector/List.