35 static constexpr
double conversion_charge=1.6E-04;
37 static const std::array<std::string,2> MM_Side = {
"CSide",
"ASide"};
38 static const std::array<std::string,2> EtaSector = {
"1",
"2"};
40 struct MMOverviewHistogramStruct {
41 std::vector<int> statEta_strip;
42 std::vector<float> charge_all;
43 std::vector<int> strp_times;
44 std::vector<float> cl_times;
45 std::vector<int> strip_number;
46 std::vector<int> numberofstrips_percluster;
47 std::vector<float> R_mon;
48 std::vector<float> z_mon;
49 std::vector<float> x_mon;
50 std::vector<float> y_mon;
52 std::vector<int> stationPhi_ASide_ontrack;
53 std::vector<int> stationPhi_CSide_ontrack;
54 std::vector<int> sector_ASide_ontrack;
55 std::vector<int> sector_CSide_ontrack;
56 std::vector<int> stationPhi_CSide;
57 std::vector<int> stationPhi_ASide;
58 std::vector<int> sector_CSide;
59 std::vector<int> sector_ASide;
60 std::vector<int> stationPhi_ASide_onseg;
61 std::vector<int> stationPhi_CSide_onseg;
62 std::vector<int> sector_ASide_onseg;
63 std::vector<int> sector_CSide_onseg;
67 struct MMByPhiStruct {
68 std::vector<int> sector_lb;
69 std::vector<int> sector_lb_ontrack;
70 std::vector<int> sector_lb_onseg;
73 struct MMSummaryHistogramStruct {
74 std::vector<int> cl_size;
76 std::vector<int> pcb_strip;
77 std::vector<int> strip_number;
78 std::vector<int> sector_strip;
80 std::vector<int> strp_times;
81 std::vector<float> cl_times;
82 std::vector<float> x_ontrack;
83 std::vector<float> y_ontrack;
84 std::vector<float> residuals;
87 struct MMEfficiencyHistogramStruct {
89 std::vector<int> nGaps;
126 return StatusCode::SUCCESS;
133 ATH_MSG_DEBUG(
"MMRawDataMonAlg::MM RawData Monitoring Histograms being filled" );
139 MMOverviewHistogramStruct overviewPlots;
140 MMSummaryHistogramStruct summaryPlots[2][16][2][2][4];
141 MMByPhiStruct occupancyPlots[16][2];
156 if (!meTPContainer.isValid()) {
158 return StatusCode::FAILURE;
182 return StatusCode::SUCCESS;
188 const std::vector<Identifier>& stripIds = prd->
rdoList();
189 unsigned int nStrips = stripIds.size();
190 const std::vector<uint16_t>& stripNumbers = prd->
stripNumbers();
202 std::vector<short int> strip_times = prd->
stripTimes();
205 float R = std::hypot(
pos.x(),
pos.y());
209 vects.charge_all.push_back(
charge);
210 vects.numberofstrips_percluster.push_back(
nStrips);
211 vects.x_mon.push_back(
pos.x());
212 vects.y_mon.push_back(
pos.y());
213 vects.z_mon.push_back(
pos.z());
214 vects.R_mon.push_back(
R);
223 auto& thisSect = occupancyPlots[sectorPhi-1][iside];
224 const int gap_offset=4;
225 int gas_gap8 = (multiplet==1) ? gas_gap : gas_gap + gap_offset;
230 thisSect.sector_lb.push_back(
bin);
233 vects.sector_CSide.push_back(
bin);
234 vects.stationPhi_CSide.push_back(sectorPhi);
236 vects.sector_ASide.push_back(
bin);
237 vects.stationPhi_ASide.push_back(sectorPhi);
242 float cluster_time = 0;
246 int stationEta_strip =
m_idHelperSvc->mmIdHelper().stationEta(
id);
247 vects.statEta_strip.push_back(stationEta_strip);
248 vects.strip_number.push_back(stripNumbers[sIdx]);
249 vects.strp_times.push_back(strip_times.at(sIdx));
250 cluster_time += strip_times.at(sIdx);
253 cluster_time /= strip_times.size();
254 vects.cl_times.push_back(cluster_time);
256 return StatusCode::SUCCESS;
262 auto numberofstrips_percluster =
Monitored::Collection(
"numberofstrips_percluster", vects.numberofstrips_percluster);
263 fill(
"mmMonitor", charge_all, numberofstrips_percluster);
269 fill(
"mmMonitor", strip_times, cluster_times, strip_number, statEta_strip);
275 fill(
"mmMonitor", x_mon, y_mon, z_mon, R_mon);
279 for(
int statPhi=0; statPhi<16; ++statPhi) {
280 for(
int iside=0; iside<2; ++iside) {
281 auto& occ_lb = occupancyPlots[statPhi][iside];
283 std::string MM_sideGroup =
"MM_sideGroup" + MM_Side[iside];
284 fill(MM_sideGroup, lb_mon, sector_lb);
292 fill(
"mmMonitor", sector_CSide, sector_ASide, stationPhi_CSide, stationPhi_ASide );
298 const std::vector<Identifier>& stripIds = prd->
rdoList();
301 int thisStationEta =
m_idHelperSvc->mmIdHelper().stationEta(Id);
302 int thisStationPhi =
m_idHelperSvc->mmIdHelper().stationPhi(Id);
303 int thisMultiplet =
m_idHelperSvc->mmIdHelper().multilayer(Id);
306 float thisCharge=prd->
charge()*conversion_charge;
307 std::vector<short int> strip_times = prd->
stripTimes();
313 int iside = (thisStationEta>0) ? 1 : 0;
317 unsigned int csize = stripIds.size();
319 auto& Vectors = vects[iside][
phi-1][sectorEta][thisMultiplet-1][thisGasgap-1];
323 const std::vector<uint16_t>& stripNumbers=prd->
stripNumbers();
324 float cluster_time = 0;
332 Vectors.strp_times.push_back(strip_times.at(sIdx));
333 cluster_time += strip_times.at(sIdx);
335 Vectors.strip_number.push_back(stripNumbers[sIdx]);
342 Vectors.cl_size.push_back(csize);
343 Vectors.pcb.push_back(PCB);
344 cluster_time /= strip_times.size();
345 Vectors.cl_times.push_back(cluster_time);
346 Vectors.charge.push_back(thisCharge);
348 return StatusCode::SUCCESS;
353 for(
int iside=0; iside<2; ++iside) {
354 std::string MM_sideGroup =
"MM_sideGroup" + MM_Side[iside];
358 for(
int statPhi=0; statPhi<16; ++statPhi) {
359 for(
int multiplet=0; multiplet<2; ++multiplet) {
362 for(
int statEta=0; statEta<2; ++statEta) {
364 for(
int gas_gap=0; gas_gap<4; ++gas_gap) {
365 auto& Vectors = vects[iside][statPhi][statEta][multiplet][gas_gap];
369 if(!Vectors.strip_number.empty())
379 fill(MM_sideGroup, cluster_size, strip_times, cluster_time, charge_perPCB, pcb_mon, pcb_strip_mon, charge_perlayer, cluster_size_perlayer);
383 fill(MM_sideGroup, strip_number, sector_strip);
390 return StatusCode::SUCCESS;
394 return StatusCode::SUCCESS;
401 for (
const auto* rdo : *mmtp) {
402 auto sourceID = rdo->sourceID();
403 auto moduleID = rdo->moduleID();
404 int s_side = (sourceID >> 16) == 107 ? 1:-1;
406 int iside= s_side>0 ? s_side : 0;
407 uint s_sector = (moduleID & 0xF) + 1;
408 int oct = (
int)((s_sector-1)/2.);
409 float sector_pos=(45/180.)*
M_PI*oct;
410 if(s_sector%2==0 ) sector_pos=(45*oct+22.5)*
M_PI/180.;
411 if(sector_pos>
M_PI) sector_pos=sector_pos-2*
M_PI;
415 auto event_bcid=rdo->ROD_BCID();
419 std::vector<short unsigned int> art_bcids = rdo->art_BCID();
420 std::vector<unsigned char>
layers=rdo->art_layer();
423 fill(
"mmTrigger", trig_sector, lb_tri);
425 for (
long unsigned int i=0;
i< rdo->art_BCID().
size();
i++ ){
426 auto art_layer=
static_cast<unsigned int>(
layers[
i]);
430 const int rollover=3564;
431 int art_bc=art_bcids[
i];
432 int relative = art_bc - event_bcid;;
433 if (relative > rollover / 2) {
434 relative -= rollover;
435 }
else if (relative <= -rollover / 2) {
436 relative += rollover;
438 if (relative > (rollover-2048) / 2) {
439 relative -= (rollover-2048);
445 fill(
"mmTrigger", art_channel, trig_sector, art_sector_layer, art_deltaBC, art_bc_mon,
bcid, lb_tri, art_deltaBC_perSector);
448 auto bcids =rdo->trig_BCID();
449 auto dthetas=rdo->trig_dTheta();
450 auto rids=rdo->trig_ROI_rID();
451 auto phiids=rdo->trig_ROI_phiID() ;
454 std::unordered_map<int, int> NROIPerBC;
455 for (
int bc : bcids) NROIPerBC[bc]++;
456 for (
const auto& [
value,
count] : NROIPerBC) {
458 fill(
"mmTrigger_roi", nROIPerBC, trig_sector);
461 int nROI=rdo->trig_BCID().size();
462 for (
int i=0;
i< nROI;
i++ ){
463 auto phiID = (phiids[
i] & 0b11111) * ((phiids[
i] >> 5) ? 1 : -1);
464 int sign = phiID > 0 ? 1 : -1;
465 auto phi_conv = (phiID-0.5*
sign)*(16./31.)*
M_PI/180. + sector_pos;
466 if(phi_conv>
M_PI)phi_conv = phi_conv - 2*
M_PI;
468 const float z_ref=7824.46;
469 const float r_step=(5000-900)/256.;
470 auto rID =
static_cast<unsigned int>(rids[
i]);
471 float r_conv=r_step*rID+900;
472 float eta_conv=-
log(0.5*
atan(r_conv/z_ref))*s_side;
488 fill(
"mmTrigger_roi", deltaBC, phiid, rid, trig_sector, phi_roi, eta_roi,r_roi, lb_tri, rid_sector, phiid_sector, deltaBC_perSector);
489 if(s_side>0)
fill(
"mmTrigger_roi", x_roi_sideA, y_roi_sideA);
490 if(s_side<0)
fill(
"mmTrigger_roi", x_roi_sideC, y_roi_sideC);
499 MMSummaryHistogramStruct summaryPlots[2][2][4];
500 MMSummaryHistogramStruct summaryPlots_full[2][16][2][2][4];
501 MMSummaryHistogramStruct sumPlots[2][16][2][2][4];
502 MMOverviewHistogramStruct overviewPlots;
503 MMByPhiStruct occupancyPlots[16][2];
515 if(!meTrack)
continue;
527 if(!cluster)
continue;
540 int iside = (stEta > 0) ? 1 : 0;
541 auto& vects = overviewPlots;
542 auto& thisSect = occupancyPlots[sectorPhi-1][iside];
546 const std::vector<Identifier>& stripIds = prd->
rdoList();
547 unsigned int csize = stripIds.size();
548 const std::vector<uint16_t>& stripNumbers = prd->
stripNumbers();
550 std::vector<short int> s_times = prd->
stripTimes();
552 vects.charge_all.push_back(
charge);
555 for(
unsigned int sIdx=0; sIdx<stripIds.size(); ++sIdx){
556 vects.strp_times.push_back(s_times.at(sIdx));
557 c_time += s_times.at(sIdx);
559 c_time /= s_times.size();
560 vects.cl_times.push_back(c_time);
563 auto& vect = sumPlots[iside][sectorPhi-1][std::abs(stEta)-1][
multi-1][
gap-1];
564 vect.cl_size.push_back(csize);
565 vect.pcb.push_back(PCB);
566 for(
unsigned int sIdx=0; sIdx<stripIds.size(); ++sIdx)
568 vect.strip_number.push_back(stripNumbers[sIdx]);
569 vect.strp_times.push_back(s_times.at(sIdx));
572 vect.cl_times.push_back(c_time);
573 vect.charge.push_back(
charge);
577 const int gap_offset=4;
578 int gas_gap8 = (
multi==1) ?
gap :
gap + gap_offset;
582 thisSect.sector_lb_ontrack.push_back(
bin);
586 vects.sector_CSide_ontrack.push_back(
bin);
587 vects.stationPhi_CSide_ontrack.push_back(sectorPhi);
589 vects.sector_ASide_ontrack.push_back(
bin);
590 vects.stationPhi_ASide_ontrack.push_back(sectorPhi);
596 if(!(trkState))
continue;
599 Identifier surfaceId = (trkState)->surface().associatedDetectorElementIdentifier();
602 int trk_stEta =
m_idHelperSvc->mmIdHelper().stationEta(surfaceId);
603 int trk_stPhi =
m_idHelperSvc->mmIdHelper().stationPhi(surfaceId);
604 int trk_multi =
m_idHelperSvc->mmIdHelper().multilayer(surfaceId);
607 if( (trk_stPhi == stPhi) && (trk_stEta == stEta) && (trk_multi ==
multi) && (trk_gap ==
gap)) {
608 double x_trk = trkState->trackParameters()->parameters()[
Trk::loc1];
610 int side = (stEta > 0) ? 1 : 0;
611 float res_stereo = (
x - x_trk);
613 float stereo_angle = ((
multi == 1 &&
gap < 3) || (
multi == 2 &&
gap > 2)) ? 0 : 0.02618;
614 double y_trk = trkState->trackParameters()->parameters()[
Trk::locY];
616 res_stereo = (
x - x_trk)*
std::cos(stereo_angle) - stereo_correction;
621 fill(
"mmMonitor", residual_mon, eta_trk, phi_trk, stPhi_mon);
625 auto& vectors = summaryPlots_full[
side][sectorPhi-1][abs_stEta][
multi-1][
gap-1];
626 vectors.residuals.push_back(res_stereo);
634 fill(
"mmMonitor", pt_trk);
638 for(
int iside = 0; iside < 2; ++iside) {
639 std::string MM_sideGroup =
"MM_sideGroup" + MM_Side[iside];
640 for(
int statPhi = 0; statPhi < 16; ++statPhi) {
642 for(
int multiplet = 0; multiplet < 2; ++multiplet) {
643 for(
int gas_gap = 0; gas_gap < 4; ++gas_gap) {
644 auto layer=gas_gap+multiplet*4;
645 MMSummaryHistogramStruct vects;
646 for(
int statEta = 0; statEta < 2; ++statEta) {
647 vects = summaryPlots_full[iside][statPhi][statEta][multiplet][gas_gap];
651 fill(MM_sideGroup, residuals_gap,residuals_layer);
660 if(!(trkState))
continue;
662 Identifier surfaceId = (trkState)->surface().associatedDetectorElementIdentifier();
674 int stEta =
m_idHelperSvc->mmIdHelper().stationEta(surfaceId);
679 int iside = (stEta > 0) ? 1 : 0;
680 auto& Vectors = summaryPlots[iside][
multi-1][
gap-1];
683 Vectors.x_ontrack.push_back(
pos.x());
684 Vectors.y_ontrack.push_back(
pos.y());
689 fill(
"mmMonitor", ntrack);
691 auto& vects = overviewPlots;
692 auto stationPhi_CSide_ontrack =
Monitored::Collection(
"stationPhi_CSide_ontrack",vects.stationPhi_CSide_ontrack);
693 auto stationPhi_ASide_ontrack =
Monitored::Collection(
"stationPhi_ASide_ontrack",vects.stationPhi_ASide_ontrack);
694 auto sector_ASide_ontrack =
Monitored::Collection(
"sector_ASide_ontrack",vects.sector_ASide_ontrack);
695 auto sector_CSide_ontrack =
Monitored::Collection(
"sector_CSide_ontrack",vects.sector_CSide_ontrack);
703 fill(
"mmMonitor", csize,
charge,
stime, ctime, stationPhi_CSide_ontrack, stationPhi_ASide_ontrack, sector_CSide_ontrack,sector_ASide_ontrack, lb_ontrack);
705 for(
int iside = 0; iside < 2; ++iside) {
706 std::string MM_sideGroup =
"MM_sideGroup" + MM_Side[iside];
707 for(
int statPhi = 0; statPhi < 16; ++statPhi) {
708 for(
int statEta = 0; statEta < 2; ++statEta) {
709 for(
int multiplet = 0; multiplet < 2; ++multiplet) {
710 for(
int gas_gap = 0; gas_gap < 4; ++gas_gap) {
711 auto& vects = sumPlots[iside][statPhi][statEta][multiplet][gas_gap];
713 if(!vects.strip_number.empty())
724 fill(MM_sideGroup, clus_size, strip_times, cluster_time, charge_perPCB, pcb_mon, pcb_strip_mon,charge_perlayer,clus_size_perlayer);
731 auto& occ_lb = occupancyPlots[statPhi][iside];
733 fill(MM_sideGroup, lb_ontrack, sector_lb_ontrack);
735 for(
int multiplet=0; multiplet<2; ++multiplet) {
736 for(
int gas_gap=0; gas_gap<4; ++gas_gap) {
737 auto& Vectors = summaryPlots[iside][multiplet][gas_gap];
740 fill(MM_sideGroup, x_ontrack, y_ontrack);
749 MMEfficiencyHistogramStruct effPlots[2][2][16][2][4];
750 MMEfficiencyHistogramStruct Gaps[2][2][16][2];
752 static const std::array<std::string,2> MM_Side = {
"CSide",
"ASide"};
753 static const std::array<std::string,2> EtaSector = {
"1",
"2"};
760 float pt_trk = meTP->pt();
764 if(!meTrack)
continue;
775 if (!cluster)
continue;
785 int iside = (stEta > 0) ? 1 : 0;
786 if( ! (
std::find( Gaps[iside][abs_stEta][
phi-1][
multi-1].nGaps.begin(), Gaps[iside][abs_stEta][
phi-1][
multi-1].nGaps.end(),
gap ) != Gaps[iside][abs_stEta][
phi-1][
multi-1].nGaps.end()) )
787 Gaps[iside][abs_stEta][
phi-1][
multi-1].nGaps.push_back(
gap);
789 if(effPlots[iside][abs_stEta][
phi-1][
multi-1][
gap-1].
num.size()==0) effPlots[iside][abs_stEta][
phi-1][
multi-1][
gap-1].
num.push_back(pcb-1);
793 unsigned int nGaptag=3;
795 for(
int s=0;
s<2; ++
s) {
796 std::string MM_sideGroup =
"MM_sideGroup"+MM_Side[
s];
797 for(
int e=0;
e<2; ++
e) {
798 for(
int p=0;
p<16; ++
p) {
799 for(
int m=0;
m<2; ++
m) {
800 if(Gaps[
s][
e][
p][
m].nGaps.size()<nGaptag)
continue;
801 if(Gaps[
s][
e][
p][
m].nGaps.size()>4)
continue;
804 for (
unsigned int g=0;
g<Gaps[
s][
e][
p][
m].nGaps.size(); ++
g)
805 gapsum+= Gaps[
s][
e][
p][
m].nGaps.at(
g);
806 int missing_gap=10-gapsum-1;
808 if(Gaps[
s][
e][
p][
m].nGaps.size()==4){
809 for (
unsigned int ga=0; ga<Gaps[
s][
e][
p][
m].nGaps.size(); ++ga){
810 for (
unsigned int i=0;
i<effPlots[
s][
e][
p][
m][ga].num.size(); ++
i){
811 int pcb = effPlots[
s][
e][
p][
m][ga].num.at(
i);
818 fill(MM_sideGroup, traversed_pcb, traversed_gap, hitcut);
822 int ref_gap = missing_gap+1;
823 if(missing_gap==3) ref_gap=0;
825 ATH_MSG_FATAL(
"ref_gap is out of range in MMRawDataMonAlg::MMEfficiency");
828 int ref_pcb=effPlots[
s][
e][
p][
m][ref_gap].num.at(0);
834 fill(MM_sideGroup, traversed_pcb, traversed_gap, hitcut);
847 MMOverviewHistogramStruct overviewPlots;
848 MMByPhiStruct occupancyPlots[16][2];
849 MMSummaryHistogramStruct summaryPlots[2][16][2][2][4];
859 for(
unsigned int irot=0;irot<
segment->numberOfContainedROTs();irot++){
866 if(!cluster)
continue;
878 int iside = (stEta > 0) ? 1 : 0;
881 const std::vector<Identifier>& stripIds = prd->
rdoList();
882 unsigned int csize = stripIds.size();
883 const std::vector<uint16_t>& stripNumbers = prd->
stripNumbers();
885 auto& pcb_vects = summaryPlots[iside][sectorPhi-1][std::abs(stEta)-1][
multi-1][
gap-1];
886 pcb_vects.cl_size.push_back(csize);
887 pcb_vects.pcb.push_back(PCB);
888 std::vector<short int> s_times = prd->
stripTimes();
890 for(
unsigned int sIdx=0; sIdx<csize; ++sIdx) {
891 pcb_vects.strp_times.push_back(s_times.at(sIdx));
893 c_time += s_times.at(sIdx);
895 c_time /= s_times.size();
896 pcb_vects.cl_times.push_back(c_time);
899 pcb_vects.charge.push_back(
charge);
901 auto& vects = overviewPlots;
903 auto& thisSect = occupancyPlots[sectorPhi-1][iside];
905 const int gap_offset=4;
906 int gas_gap8 = (
multi==1) ?
gap :
gap + gap_offset;
910 thisSect.sector_lb_onseg.push_back(
bin);
913 vects.sector_CSide_onseg.push_back(
bin);
914 vects.stationPhi_CSide_onseg.push_back(sectorPhi);
916 vects.sector_ASide_onseg.push_back(
bin);
917 vects.stationPhi_ASide_onseg.push_back(sectorPhi);
921 if (isMM==
true) ++nseg;
925 fill(
"mmMonitor", nsegs);
927 auto& vects = overviewPlots;
928 auto stationPhi_CSide_onseg =
Monitored::Collection(
"stationPhi_CSide_onseg",vects.stationPhi_CSide_onseg);
929 auto stationPhi_ASide_onseg =
Monitored::Collection(
"stationPhi_ASide_onseg",vects.stationPhi_ASide_onseg);
935 fill(
"mmMonitor", stationPhi_CSide_onseg, stationPhi_ASide_onseg, sector_CSide_onseg, sector_ASide_onseg, lb_onseg);
937 for(
int iside = 0; iside < 2; ++iside) {
938 std::string MM_sideGroup =
"MM_sideGroup" + MM_Side[iside];
939 for(
int statPhi=0; statPhi<16; ++statPhi) {
940 auto& occ_lb = occupancyPlots[statPhi][iside];
942 fill(MM_sideGroup, lb_onseg, sector_lb_onseg);
944 for(
int statEta = 0; statEta < 2; ++statEta) {
945 for(
int multiplet = 0; multiplet < 2; ++multiplet) {
946 for(
int gas_gap = 0; gas_gap < 4; ++gas_gap) {
947 auto& pcb_vects = summaryPlots[iside][statPhi][statEta][multiplet][gas_gap];
949 if(pcb_vects.pcb.empty())
continue;
958 fill(MM_sideGroup, clus_size, strip_times, charge_perPCB, cluster_time, pcb_mon, pcb_strip_mon);
963 fill(
"mmMonitor", clus_size_all, charge_all, strip_times_all);