17 << std::setfill(
' ') << std::setiosflags(std::ios::right) );
25 if(
m_doNtuple and Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents() > 1) {
26 ATH_MSG_ERROR(
"DoNtuple is not possible in multi-threaded mode");
27 return StatusCode::FAILURE;
32 return StatusCode::SUCCESS;
36 m_trigger_diamond_ntrig = std::make_shared<MuonVal::VectorBranch<unsigned int> >(
tree,
"MM_diamond_ntrig");
37 m_trigger_diamond_bc = std::make_shared<MuonVal::VectorBranch<int> >(
tree,
"MM_diamond_bc");
38 m_trigger_diamond_sector = std::make_shared<MuonVal::VectorBranch<char> >(
tree,
"MM_diamond_sector");
39 m_trigger_diamond_sectorPhi = std::make_shared<MuonVal::VectorBranch<int> >(
tree,
"MM_diamond_sectorPhi");
40 m_trigger_diamond_totalCount = std::make_shared<MuonVal::VectorBranch<unsigned int> >(
tree,
"MM_diamond_totalCount");
41 m_trigger_diamond_realCount = std::make_shared<MuonVal::VectorBranch<unsigned int> >(
tree,
"MM_diamond_realCount");
42 m_trigger_diamond_iX = std::make_shared<MuonVal::VectorBranch<int> >(
tree,
"MM_diamond_iX");
43 m_trigger_diamond_iU = std::make_shared<MuonVal::VectorBranch<int> >(
tree,
"MM_diamond_iU");
44 m_trigger_diamond_iV = std::make_shared<MuonVal::VectorBranch<int> >(
tree,
"MM_diamond_iV");
45 m_trigger_diamond_XbkgCount = std::make_shared<MuonVal::VectorBranch<unsigned int> >(
tree,
"MM_diamond_XbkgCount");
46 m_trigger_diamond_UVbkgCount = std::make_shared<MuonVal::VectorBranch<unsigned int> >(
tree,
"MM_diamond_UVbkgCount");
47 m_trigger_diamond_XmuonCount = std::make_shared<MuonVal::VectorBranch<unsigned int> >(
tree,
"MM_diamond_XmuonCount");
48 m_trigger_diamond_UVmuonCount = std::make_shared<MuonVal::VectorBranch<unsigned int> >(
tree,
"MM_diamond_UVmuonCount");
49 m_trigger_diamond_age = std::make_shared<MuonVal::VectorBranch<int> >(
tree,
"MM_diamond_age");
50 m_trigger_diamond_mx = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_diamond_mx");
51 m_trigger_diamond_my = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_diamond_my");
52 m_trigger_diamond_Uavg = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_diamond_Uavg");
53 m_trigger_diamond_Vavg = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_diamond_Vavg");
54 m_trigger_diamond_mxl = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_diamond_mxl");
55 m_trigger_diamond_theta = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_diamond_theta");
56 m_trigger_diamond_eta = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_diamond_eta");
57 m_trigger_diamond_dtheta = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_diamond_dtheta");
58 m_trigger_diamond_phi = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_diamond_phi");
59 m_trigger_diamond_phiShf = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_diamond_phiShf");
60 m_trigger_diamond_TP_phi_id = std::make_shared<MuonVal::VectorBranch<uint8_t> >(
tree,
"MM_diamond_TP_phi_id");
61 m_trigger_diamond_TP_R_id = std::make_shared<MuonVal::VectorBranch<uint8_t> >(
tree,
"MM_diamond_TP_R_id");
62 m_trigger_diamond_TP_dTheta_id = std::make_shared<MuonVal::VectorBranch<uint8_t> >(
tree,
"MM_diamond_TP_dTheta_id");
63 m_trigger_RZslopes = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_RZslopes");
64 m_trigger_trueEtaRange = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_trueEtaRange");
65 m_trigger_truePtRange = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_truePtRange");
66 m_trigger_VMM = std::make_shared<MuonVal::VectorBranch<int> >(
tree,
"MM_VMM");
67 m_trigger_plane = std::make_shared<MuonVal::VectorBranch<int> >(
tree,
"MM_plane");
68 m_trigger_station = std::make_shared<MuonVal::VectorBranch<int> >(
tree,
"MM_station");
69 m_trigger_strip = std::make_shared<MuonVal::VectorBranch<int> >(
tree,
"MM_strip");
70 m_trigger_slope = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_slope");
71 m_trigger_trueThe = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_trueThe");
72 m_trigger_truePhi = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_truePhi");
73 m_trigger_trueDth = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_trueDth");
74 m_trigger_trueEtaEnt = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_trueEtaEnt");
75 m_trigger_trueTheEnt = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_trueTheEnt");
76 m_trigger_truePhiEnt = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_truePhiEnt");
77 m_trigger_trueEtaPos = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_trueEtaPos");
78 m_trigger_trueThePos = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_trueThePos");
79 m_trigger_truePhiPos = std::make_shared<MuonVal::VectorBranch<double> >(
tree,
"MM_truePhiPos");
81 tree.addBranch(m_trigger_diamond_ntrig);
82 tree.addBranch(m_trigger_diamond_bc);
83 tree.addBranch(m_trigger_diamond_sector);
84 tree.addBranch(m_trigger_diamond_sectorPhi);
85 tree.addBranch(m_trigger_diamond_totalCount);
86 tree.addBranch(m_trigger_diamond_realCount);
87 tree.addBranch(m_trigger_diamond_iX);
88 tree.addBranch(m_trigger_diamond_iU);
89 tree.addBranch(m_trigger_diamond_iV);
90 tree.addBranch(m_trigger_diamond_XbkgCount);
91 tree.addBranch(m_trigger_diamond_UVbkgCount);
92 tree.addBranch(m_trigger_diamond_XmuonCount);
93 tree.addBranch(m_trigger_diamond_UVmuonCount);
94 tree.addBranch(m_trigger_diamond_age);
95 tree.addBranch(m_trigger_diamond_mx);
96 tree.addBranch(m_trigger_diamond_my);
97 tree.addBranch(m_trigger_diamond_Uavg);
98 tree.addBranch(m_trigger_diamond_Vavg);
99 tree.addBranch(m_trigger_diamond_mxl);
100 tree.addBranch(m_trigger_diamond_theta);
101 tree.addBranch(m_trigger_diamond_eta);
102 tree.addBranch(m_trigger_diamond_dtheta);
103 tree.addBranch(m_trigger_diamond_phi);
104 tree.addBranch(m_trigger_diamond_phiShf);
105 tree.addBranch(m_trigger_diamond_TP_phi_id);
106 tree.addBranch(m_trigger_diamond_TP_R_id);
107 tree.addBranch(m_trigger_diamond_TP_dTheta_id);
108 tree.addBranch(m_trigger_RZslopes);
109 tree.addBranch(m_trigger_trueEtaRange);
110 tree.addBranch(m_trigger_truePtRange);
111 tree.addBranch(m_trigger_VMM);
112 tree.addBranch(m_trigger_plane);
113 tree.addBranch(m_trigger_station);
114 tree.addBranch(m_trigger_strip);
115 tree.addBranch(m_trigger_slope);
116 tree.addBranch(m_trigger_trueThe);
117 tree.addBranch(m_trigger_truePhi);
118 tree.addBranch(m_trigger_trueDth);
119 tree.addBranch(m_trigger_trueEtaEnt);
120 tree.addBranch(m_trigger_trueTheEnt);
121 tree.addBranch(m_trigger_truePhiEnt);
122 tree.addBranch(m_trigger_trueEtaPos);
123 tree.addBranch(m_trigger_trueThePos);
124 tree.addBranch(m_trigger_truePhiPos);
125 return StatusCode::SUCCESS;
130 uint64_t event = ctx.eventID().event_number();
131 ATH_MSG_DEBUG(
"********************************************************* EVENT NUMBER = " <<
event);
134 if(!detManager.isValid()){
135 ATH_MSG_ERROR(
"Failed to retrieve the MuonDetectorManager conditions object");
136 return StatusCode::FAILURE;
143 if( !readMcEventCollection.
isValid() ){
145 return StatusCode::FAILURE;
147 if(
m_doTruth) ptrMcEventCollection = readMcEventCollection.
cptr();
149 if( !readMuonEntryLayer.
isValid() ){
151 return StatusCode::FAILURE;
154 ptrMuonEntryLayer = readMuonEntryLayer.
cptr();
156 std::map<std::pair<uint64_t, unsigned int>,
evInf_entry> Event_Info;
157 ATH_CHECK(
load.getTruthInfo(ctx, ptrMcEventCollection, ptrMuonEntryLayer, Event_Info));
160 for (
const auto &
it : Event_Info) {
161 m_trigger_trueEtaRange->push_back(
it.second.eta_ip);
162 m_trigger_truePtRange->push_back(
it.second.pt);
163 m_trigger_trueThe->push_back(
it.second.theta_ip);
164 m_trigger_truePhi->push_back(
it.second.phi_ip);
165 m_trigger_trueDth->push_back(
it.second.dtheta);
166 m_trigger_trueEtaPos->push_back(
it.second.eta_pos);
167 m_trigger_trueThePos->push_back(
it.second.theta_pos);
168 m_trigger_truePhiPos->push_back(
it.second.phi_pos);
169 m_trigger_trueEtaEnt->push_back(
it.second.eta_ent);
170 m_trigger_trueTheEnt->push_back(
it.second.theta_ent);
171 m_trigger_truePhiEnt->push_back(
it.second.phi_ent);
177 if( !readMmDigitContainer.
isValid() ){
179 return StatusCode::FAILURE;
184 std::vector<std::shared_ptr<MMT_Hit> > ev_hits;
193 const int multiplet =
m_idHelperSvc->mmIdHelper().multilayer(
id);
199 if (channel < 1 or channel > (readout->
getDesign(
id))->totalStrips)
continue;
201 const float stripTime =
digit->stripResponseTime();
203 if (stripTime < 0.)
continue;
204 const int BC = std::ceil(stripTime/25.);
205 ev_hits.emplace_back(std::make_shared<MMT_Hit>(
id,
stationName, stationEta, stationPhi, sector, multiplet,
gasGap,
channel, stripTime,
BC, detManager.cptr()));
207 if (ev_hits.back()->infSlope()) {
213 m_trigger_VMM->push_back(ev_hits.back()->getVMM());
214 m_trigger_plane->push_back(ev_hits.back()->getPlane());
215 m_trigger_station->push_back(ev_hits.back()->getStationEta());
216 m_trigger_strip->push_back(ev_hits.back()->getChannel());
217 m_trigger_RZslopes->push_back(ev_hits.back()->getRZSlope());
222 if (do_MMDiamonds and ev_hits.size() >= (
m_diamond->getXthreshold()+
m_diamond->getUVthreshold())) {
223 const bool isLarge = (std::all_of(ev_hits.begin(), ev_hits.end(), [] (
const auto &hit) { return hit->getSector() ==
'L'; }));
224 const char sector = (isLarge) ?
'L' :
'S';
225 const char side = (std::all_of(ev_hits.begin(), ev_hits.end(), [] (
const auto &hit) { return hit->getStationEta() < 0; })) ?
'C' :
'A';
226 const int sectorPhi = ev_hits[0]->getSectorPhi();
227 const bool allSectorPhi = (std::all_of(ev_hits.begin(), ev_hits.end(), [&] (
const auto &hit) { return hit->getSectorPhi() == sectorPhi; }));
228 if (not allSectorPhi) {
229 ATH_MSG_ERROR(
"Available digits belongs to different sectors IDs, unable to assign an unique ID in output RDO");
230 return StatusCode::FAILURE;
234 std::vector<std::shared_ptr<MMT_Road> > ev_roads;
235 m_diamond->createRoads(ev_roads, isLarge);
238 std::vector<slope_t> diamondSlopes;
239 m_diamond->findDiamonds(ev_hits, ev_roads, diamondSlopes, sectorPhi);
242 if (not diamondSlopes.empty()) {
244 m_trigger_diamond_ntrig->push_back(diamondSlopes.size());
245 for (
const auto &slope : diamondSlopes) {
246 m_trigger_diamond_sector->push_back(sector);
247 m_trigger_diamond_sectorPhi->push_back(sectorPhi);
248 m_trigger_diamond_bc->push_back(slope.BC);
249 m_trigger_diamond_totalCount->push_back(slope.totalCount);
250 m_trigger_diamond_realCount->push_back(slope.realCount);
251 m_trigger_diamond_XbkgCount->push_back(slope.xbkg);
252 m_trigger_diamond_UVbkgCount->push_back(slope.uvbkg);
253 m_trigger_diamond_XmuonCount->push_back(slope.xmuon);
254 m_trigger_diamond_UVmuonCount->push_back(slope.uvmuon);
255 m_trigger_diamond_iX->push_back(slope.iRoad);
256 m_trigger_diamond_iU->push_back(slope.iRoadu);
257 m_trigger_diamond_iV->push_back(slope.iRoadv);
258 m_trigger_diamond_age->push_back(slope.age);
259 m_trigger_diamond_mx->push_back(slope.mx);
260 m_trigger_diamond_my->push_back(slope.my);
261 m_trigger_diamond_Uavg->push_back(slope.uavg);
262 m_trigger_diamond_Vavg->push_back(slope.vavg);
263 m_trigger_diamond_mxl->push_back(slope.mxl);
264 m_trigger_diamond_theta->push_back(slope.theta);
265 m_trigger_diamond_eta->push_back(slope.eta);
266 m_trigger_diamond_dtheta->push_back(slope.dtheta);
267 m_trigger_diamond_phi->push_back(slope.phi);
268 m_trigger_diamond_phiShf->push_back(slope.phiShf);
273 std::vector<int> slopeBC;
274 for (
const auto &slope : diamondSlopes) slopeBC.push_back(slope.BC);
275 std::sort(slopeBC.begin(), slopeBC.end());
276 slopeBC.erase( std::unique(slopeBC.begin(), slopeBC.end()), slopeBC.end() );
277 for (
const auto &bc : slopeBC) {
280 for (
const auto &slope : diamondSlopes) {
281 if (bc == slope.BC) {
298 if (
m_doNtuple) m_trigger_diamond_TP_phi_id->push_back(phi_id);
301 double extrapolatedR = 7824.46*std::abs(
std::tan(slope.theta));
308 if (extrapolatedR < (
m_rMin+j*Rsteps)) {
315 if (
m_doNtuple) m_trigger_diamond_TP_R_id->push_back(R_id);
331 if (
m_doNtuple) m_trigger_diamond_TP_dTheta_id->push_back(dTheta_id);
334 trigRawDataSegment->
setLowRes(slope.lowRes);
336 trigRawData->
push_back(trigRawDataSegment);
344 ATH_MSG_DEBUG(
"Available hits are " << ev_hits.size() <<
", less than X+UV threshold, skipping digit collection");
348 return StatusCode::SUCCESS;