27 return data.cfebData(nCFEB)->timeSlice(nSample)->timeSample(nLayer,nStrip,data.cfebData(nCFEB)->isDCFEB());
31 timeSlice(
T const &
data,
int nCFEB,
int nSample) {
return data.cfebData(nCFEB)->timeSlice(nSample);}
88 int alct_unpacked = 0;
90 int cfeb_unpacked = 0;
93 int clct_kewdistrip = -1;
95 bool L1A_out_of_sync =
false;
105 if (!dmbHeader && !dmbTrailer) {
106 LOG_ERROR <<
"Can not unpack DMB Header or/and Trailer";
114 unsigned int crateID = 0xFF;
115 unsigned int dmbID = 0xF;
118 crateID = dmbHeader->
crateID();
119 dmbID = dmbHeader->
dmbID();
120 chamberID = (((crateID) << 4) + dmbID) & 0xFFF;
126 if ((errors &
config->getBINCHECK_MASK()) > 0 ) {
127 LOG_WARN <<
"Format Errors " << cscTag <<
": 0x" << std::hex << errors <<
" Skipped CSC Unpacking";
131 unsigned int cscType = 0;
132 unsigned int cscPosition = 0;
133 if (!
getCSCFromMap(crateID, dmbID, cscType, cscPosition ))
return;
137 if (!
config->fnGetCSCDetId(crateID, dmbID, cid)) {
149 double DMBEvents = 0.0;
155 if (evDisplNo >= 5) {
166 MonitorObject *mo_Emu_EventDisplay_Anode =
nullptr, *mo_Emu_EventDisplay_Cathode =
nullptr, *mo_Emu_EventDisplay_XY =
nullptr;
172 uint32_t glChamberIndex = 0;
174 if (mo_EventDisplay) {
182 if (mo_Emu_EventDisplay_Anode || mo_Emu_EventDisplay_Cathode || mo_Emu_EventDisplay_XY) {
190 mo->
Fill(cscPosition, cscType);
196 LOG_ERROR << cscTag <<
" has efficiency " << DMBEff <<
" which is greater than 1";
202 int dmbHeaderL1A = dmbHeader->
l1a24()%64;
204 int dmb_ddu_l1a_diff = (
int)(dmbHeaderL1A-(
int)(
L1ANumber%64));
205 if (dmb_ddu_l1a_diff != 0) L1A_out_of_sync =
true;
212 if(dmb_ddu_l1a_diff < -32) {
213 mo->
Fill(dmb_ddu_l1a_diff + 64);
215 if(dmb_ddu_l1a_diff >= 32) mo->
Fill(dmb_ddu_l1a_diff - 64);
216 else mo->
Fill(dmb_ddu_l1a_diff);
224 int dmbHeaderBXN = 0;
225 int dmb_ddu_bxn_diff = 0;
231 dmbHeaderBXN = dmbHeader->
bxn12();
235 dmb_ddu_bxn_diff = dmbHeaderBXN%64-
BXN%64;
240 if(dmb_ddu_bxn_diff < -32) mo->
Fill(dmb_ddu_bxn_diff + 64);
242 if(dmb_ddu_bxn_diff >= 32) mo->
Fill(dmb_ddu_bxn_diff - 64);
243 else mo->
Fill(dmb_ddu_bxn_diff);
253 int cfeb_dav_num = 0;
255 int dmb_cfeb_sync = 0;
258 for (
int i = 0; i < nCFEBs; i++) cfeb_dav_num += (cfeb_dav >>
i) & 0
x1;
263 for (
int i = 0;
i < nCFEBs;
i++) {
264 int cfeb_present = (cfeb_dav >>
i) & 0
x1;
276 mo->
Fill(crateID, dmbID);
296 for (
int i = 0;
i < nCFEBs;
i++) {
316 for (
int i = 0;
i < nCFEBs;
i++) {
328 int alct_dav = dmbHeader->
nalct();
329 int tmb_dav = dmbHeader->
nclct();
331 for (
int i = 0;
i < nCFEBs;
i++) cfeb_dav2 = cfeb_dav2 + (
int)((dmbHeader->
cfebAvailable() >>
i) & 0
x1);
339 mo->
SetBinContent(1, ((
float)alct_dav_number / (
float)(DMBEvents) * 100.0));
348 mo->
SetBinContent(2, ((
float)tmb_dav_number / (
float)(DMBEvents) * 100.0));
357 mo->
SetBinContent(3, ((
float)cfeb_dav2_number / (
float)(DMBEvents) * 100.0));
362 float feb_combination_dav = -1.0;
365 if(alct_dav == 0 && tmb_dav == 0 && cfeb_dav2 == 0) feb_combination_dav = 0.0;
366 if(alct_dav > 0 && tmb_dav == 0 && cfeb_dav2 == 0) feb_combination_dav = 1.0;
367 if(alct_dav == 0 && tmb_dav > 0 && cfeb_dav2 == 0) feb_combination_dav = 2.0;
368 if(alct_dav == 0 && tmb_dav == 0 && cfeb_dav2 > 0) feb_combination_dav = 3.0;
369 if(alct_dav == 0 && tmb_dav > 0 && cfeb_dav2 > 0) feb_combination_dav = 4.0;
370 if(alct_dav > 0 && tmb_dav > 0 && cfeb_dav2 == 0) feb_combination_dav = 5.0;
371 if(alct_dav > 0 && tmb_dav == 0 && cfeb_dav2 > 0) feb_combination_dav = 6.0;
372 if(alct_dav > 0 && tmb_dav > 0 && cfeb_dav2 > 0) feb_combination_dav = 7.0;
373 mo->
Fill(feb_combination_dav);
374 float feb_combination_dav_number = mo->
GetBinContent((
int)(feb_combination_dav + 1.0));
376 mo->
SetBinContent((
int)(feb_combination_dav + 1.0), ((
float)feb_combination_dav_number / (
float)(DMBEvents) * 100.0));
390 if (alctHeader && alctTrailer) {
392 std::vector<CSCALCTDigi> alctsDatasTmp = alctHeader->
ALCTDigis();
393 std::vector<CSCALCTDigi> alctsDatas;
395 for (uint32_t lct = 0; lct < alctsDatasTmp.size(); lct++) {
396 if (alctsDatasTmp[lct].isValid()) alctsDatas.push_back(alctsDatasTmp[lct]);
399 FEBunpacked = FEBunpacked + 1;
408 if(
config->getNEvents() > 0) {
411 mo->
SetBinContent(1, ((
float)ALCTEvent / (
float)(DMBEvents) * 100.0));
429 int alct_dmb_l1a_diff = (
int)(alctHeader->
L1Acc() % 64 - dmbHeader->
l1a24() % 64);
430 if (alct_dmb_l1a_diff != 0) L1A_out_of_sync =
true;
431 if(alct_dmb_l1a_diff < -32) mo->
Fill(alct_dmb_l1a_diff + 64);
433 if(alct_dmb_l1a_diff >= 32) mo->
Fill(alct_dmb_l1a_diff - 64);
434 else mo->
Fill(alct_dmb_l1a_diff);
446 if (alct_dmb_bxn_diff > 0) alct_dmb_bxn_diff -= 3564;
447 alct_dmb_bxn_diff %= 32;
448 mo->
Fill(alct_dmb_bxn_diff);
458 mo->
Fill(alctsDatas.size());
461 mo->
SetBinContent((
int)(alctsDatas.size() + 1), (
float)(nALCT) / (
float)(DMBEvents) * 100.0);
468 if (alctsDatas.size() == 2) {
470 mo->
Fill(alctsDatas[0].getKeyWG(),alctsDatas[1].getKeyWG());
485 for (uint32_t lct = 0; lct < alctsDatas.size(); lct++) {
488 if (lct >= 2)
continue;
491 mo->
Fill(alctsDatas[lct].getKeyWG());
494 if(lct == 0) alct_keywg = alctsDatas[lct].getKeyWG();
497 if (fwVersion == 2007) {
498 alct_dtime = alctsDatas[lct].getBX();
501 alct_dtime = (
int) (alctsDatas[lct].getBX() - (alctHeader->
BXNCount()&0x1F));
508 if (mo_CSC_Plus_endcap_ALCT0_dTime) mo_CSC_Plus_endcap_ALCT0_dTime->
Fill(alct_dtime);
511 if (mo_CSC_Minus_endcap_ALCT0_dTime) mo_CSC_Minus_endcap_ALCT0_dTime->
Fill(alct_dtime);
517 if(alct_dtime < -16) {
518 mo->
Fill(alct_dtime + 32);
520 if(alct_dtime >= 16) mo->
Fill(alct_dtime - 32);
521 else mo->
Fill(alct_dtime);
526 double dTime_mean = mo->
getTH1()->GetMean();
527 double dTime_rms = mo->
getTH1()->GetRMS();
539 if (cscPosition && mo_CSC_ALCT0_BXN_mean) {
540 mo_CSC_ALCT0_BXN_mean->
SetBinContent(cscPosition, cscType + 1, dTime_mean);
542 if (cscPosition && mo_CSC_ALCT0_BXN_rms) {
543 mo_CSC_ALCT0_BXN_rms->
SetBinContent(cscPosition, cscType + 1, dTime_rms);
550 if(alct_dtime < -16) {
551 mo->
Fill(alctsDatas[lct].getKeyWG(), alct_dtime + 32);
553 if(alct_dtime >= 16) mo->
Fill(alctsDatas[lct].getKeyWG(), alct_dtime - 32);
554 else mo->
Fill(alctsDatas[lct].getKeyWG(), alct_dtime);
559 if(alct_dtime < -16) {
560 mo->
Fill(alctsDatas[lct].getKeyWG(), alct_dtime + 32);
562 if (alct_dtime >= 16) mo->
Fill(alctsDatas[lct].getKeyWG(), alct_dtime - 32);
563 else mo->
Fill(alctsDatas[lct].getKeyWG(), alct_dtime);
567 int alct_bxn = alctsDatas[lct].getBX();
568 if (fwVersion == 2007) {
569 alct_bxn = (alct_bxn + alctHeader->
BXNCount())&0x1F;
576 if (mo_EventDisplay) {
577 mo_EventDisplay->
SetBinContent(2, alctsDatas[lct].getKeyWG(), alct_bxn + 1 );
578 mo_EventDisplay->
SetBinContent(3, alctsDatas[lct].getKeyWG(), alctsDatas[lct].getQuality());
582 mo->
Fill(alctsDatas[lct].getQuality());
594 int pattern = (alctsDatas[lct].getAccelerator() << 1) + alctsDatas[lct].getCollisionB();
595 int keywg = alctsDatas[lct].getKeyWG();
596 mo->
Fill(keywg, pattern );
600 int pattern = (alctsDatas[lct].getAccelerator()<<1) + alctsDatas[lct].getCollisionB();
606 int NumberOfLayersWithHitsInALCT = 0;
607 int NumberOfWireGroupsWithHitsInALCT = 0;
614 MonitorObject* mo_CSC_Plus_endcap_AFEB_RawHits_Time =
nullptr;
617 MonitorObject* mo_CSC_Minus_endcap_AFEB_RawHits_Time =
nullptr;
626 for (
int nLayer = 1; nLayer <= 6; nLayer++) {
628 int wg_previous = -1;
629 int tbin_previous = -1;
630 bool CheckLayerALCT =
true;
632 std::vector<CSCWireDigi> wireDigis = alctData->
wireDigis(nLayer);
633 for (std::vector<CSCWireDigi>::iterator wireDigisItr = wireDigis.begin(); wireDigisItr != wireDigis.end(); ++wireDigisItr) {
635 int wg = wireDigisItr->getWireGroup();
637 std::vector<int> tbins = wireDigisItr->getTimeBinsOn();
638 int tbin = wireDigisItr->getTimeBin();
640 if (mo_EventDisplay) {
641 mo_EventDisplay->
SetBinContent(nLayer + 3, wg - 1, tbin + 1);
646 if (CheckLayerALCT) {
647 NumberOfLayersWithHitsInALCT = NumberOfLayersWithHitsInALCT + 1;
648 CheckLayerALCT =
false;
651 for (uint32_t
n = 0;
n < tbins.size();
n++) {
654 if(wg != wg_previous || (tbin != tbin_previous + 1 && tbin != tbin_previous - 1) ) {
660 if (mo_AFEB_RawHits_TimeBins) mo_AFEB_RawHits_TimeBins->
Fill(tbin);
663 if (mo_CSC_Plus_endcap_AFEB_RawHits_Time) mo_CSC_Plus_endcap_AFEB_RawHits_Time->
Fill(tbin);
666 if (mo_CSC_Minus_endcap_AFEB_RawHits_Time) mo_CSC_Minus_endcap_AFEB_RawHits_Time->
Fill(tbin);
672 Double_t Number_of_entries_ALCT = mo->
GetEntries();
675 if((Double_t)(DMBEvents) > 0.0) {
676 mo->
SetNormFactor(100.0*Number_of_entries_ALCT/(Double_t)(DMBEvents));
684 if(wg != wg_previous) {
685 NumberOfWireGroupsWithHitsInALCT = NumberOfWireGroupsWithHitsInALCT + 1;
689 tbin_previous = tbin;
694 if (mo_AFEB_RawHits_TimeBins) {
696 double rawhits_time_mean = mo_AFEB_RawHits_TimeBins->
getTH1()->GetMean();
697 double rawhits_time_rms = mo_AFEB_RawHits_TimeBins->
getTH1()->GetRMS();
699 if ( cscPosition && mo_CSC_AFEB_RawHits_Time_mean) {
700 mo_CSC_AFEB_RawHits_Time_mean->
SetBinContent(cscPosition, cscType + 1, rawhits_time_mean);
703 if ( cscPosition && mo_CSC_AFEB_RawHits_Time_rms) {
704 mo_CSC_AFEB_RawHits_Time_rms->
SetBinContent(cscPosition, cscType + 1, rawhits_time_rms);
712 LOG_ERROR << cscTag <<
" Can not unpack Anode Data";
716 mo->
Fill(NumberOfLayersWithHitsInALCT);
726 LOG_ERROR << cscTag <<
" Can not unpack ALCT Header or/and Trailer";
735 mo->
SetBinContent(1, (
float)(nALCT) / (
float)(DMBEvents) * 100.0);
749 std::vector<CSCALCTDigi> alctsDatasTmp = alctHeader->
ALCTDigis();
750 std::vector<CSCALCTDigi> alctsDatas;
752 for (uint32_t lct = 0; lct < alctsDatasTmp.size(); lct++) {
753 if (alctsDatasTmp[lct].isValid())
754 alctsDatas.push_back(alctsDatasTmp[lct]);
767 if(clct_alct_bxn_diff < -2048) mo->
Fill(clct_alct_bxn_diff + 4096);
769 if(clct_alct_bxn_diff > 2048) mo->
Fill(clct_alct_bxn_diff - 4096);
770 else mo->
Fill(clct_alct_bxn_diff);
780 if(clct_alct_l1a_diff < -2048) mo->
Fill(clct_alct_l1a_diff + 4096);
782 if(clct_alct_l1a_diff > 2048) mo->
Fill(clct_alct_l1a_diff - 4096);
783 else mo->
Fill(clct_alct_l1a_diff);
788 LOG_ERROR << cscTag <<
" Can not unpack TMB Header";
792 LOG_ERROR << cscTag <<
" Can not unpack TMB Data";
795 LOG_ERROR << cscTag <<
" Can not unpack ALCT Header";
811 if (tmbHeader && tmbTrailer) {
815 std::vector<CSCCLCTDigi> clctsDatasTmp = tmbHeader->
CLCTDigis(cid.
rawId());
816 std::vector<CSCCLCTDigi> clctsDatas;
818 for (uint32_t lct = 0; lct < clctsDatasTmp.size(); lct++) {
819 if (clctsDatasTmp[lct].isValid()) clctsDatas.push_back(clctsDatasTmp[lct]);
822 FEBunpacked = FEBunpacked +1;
828 double alct_match_mean = mo->
getTH1()->GetMean();
829 double alct_match_rms = mo->
getTH1()->GetRMS();
845 mo1->
SetBinContent(cscPosition, cscType + 1, alct_match_mean);
849 mo1->
SetBinContent(cscPosition, cscType + 1, alct_match_rms);
873 if(
config->getNEvents() > 0) {
874 mo->
SetBinContent(2,((
float)CLCTEvent/(
float)(DMBEvents)*100.0));
884 int clct_dmb_l1a_diff = (
int)((tmbHeader->
L1ANumber() % 64)-dmbHeader->
l1a24() % 64);
885 if (clct_dmb_l1a_diff != 0) L1A_out_of_sync =
true;
886 if(clct_dmb_l1a_diff < -32) mo->
Fill(clct_dmb_l1a_diff + 64);
888 if(clct_dmb_l1a_diff >= 32) mo->
Fill(clct_dmb_l1a_diff - 64);
889 else mo->
Fill(clct_dmb_l1a_diff);
898 int clct_dmb_bxn_diff = (
int)(tmbHeader->
BXNCount()%64-dmbHeader->
bxn12()%64);
899 if(clct_dmb_bxn_diff < -32) mo->
Fill(clct_dmb_bxn_diff + 64);
901 if(clct_dmb_bxn_diff >= 32) mo->
Fill(clct_dmb_bxn_diff - 64);
902 else mo->
Fill(clct_dmb_bxn_diff);
913 mo->
Fill(clctsDatas.size());
918 if (clctsDatas.size() == 1) {
920 if (clctsDatas[0].getStripType()) mo->
Fill(0.0);
925 if (clctsDatas.size() == 2) {
927 mo->
Fill(clctsDatas[0].getKeyStrip(),clctsDatas[1].getKeyStrip());
929 if ( clctsDatas[0].getStripType() && clctsDatas[1].getStripType()) mo->
Fill(0.0);
930 if ( clctsDatas[0].getStripType() && !clctsDatas[1].getStripType()) mo->
Fill(1.0);
931 if (!clctsDatas[0].getStripType() && clctsDatas[1].getStripType()) mo->
Fill(2.0);
932 if (!clctsDatas[0].getStripType() && !clctsDatas[1].getStripType()) mo->
Fill(3.0);
951 for (uint32_t lct = 0; lct < clctsDatas.size(); lct++) {
955 int clct_dtime = clctsDatas[lct].getFullBX() - tmbHeader->
BXNCount();
956 if (clct_dtime > 0) {
960 int dTime = clct_dtime;
964 if (mo_CSC_Plus_endcap_CLCT0_dTime) mo_CSC_Plus_endcap_CLCT0_dTime->
Fill(dTime);
967 if (mo_CSC_Minus_endcap_CLCT0_dTime) mo_CSC_Minus_endcap_CLCT0_dTime->
Fill(dTime);
984 double dTime_mean = mo->
getTH1()->GetMean();
985 double dTime_rms = mo->
getTH1()->GetRMS();
997 if (cscPosition && mo_CSC_CLCT0_BXN_mean) {
998 mo_CSC_CLCT0_BXN_mean->
SetBinContent(cscPosition, cscType + 1, dTime_mean);
1000 if (cscPosition && mo_CSC_CLCT0_BXN_rms) {
1001 mo_CSC_CLCT0_BXN_rms->
SetBinContent(cscPosition, cscType + 1, dTime_rms);
1009 LOG_DEBUG <<
"LCT:" << lct <<
" Type:" << clctsDatas[lct].getStripType() <<
" Strip:" << clctsDatas[lct].getKeyStrip();
1011 if (clctsDatas[lct].getStripType()) {
1014 mo->
Fill(clctsDatas[lct].getKeyStrip());
1017 mo->
Fill((
int)(clctsDatas[lct].getKeyStrip()), clct_dtime);
1029 mo->
Fill((
int)(clctsDatas[lct].getKeyStrip()), clct_dtime);
1042 int pattern_clct = clctsDatas[lct].getPattern();
1048 switch (pattern_clct) {
1049 case 0: tbin=0.;
break;
1050 case 1: tbin=1.;
break;
1051 case 2: tbin=2.;
break;
1052 case 3: tbin=10.;
break;
1053 case 4: tbin=3.;
break;
1054 case 5: tbin=9.;
break;
1055 case 6: tbin=4.;
break;
1056 case 7: tbin=8.;
break;
1057 case 8: tbin=5.;
break;
1058 case 9: tbin=7.;
break;
1059 case 10: tbin=6.;
break;
1062 if (tbin >= 0) mo->
Fill(clctsDatas[lct].getKeyStrip(), tbin);
1070 mo->
Fill((
int)(clctsDatas[lct].getKeyStrip()),(
int)(clctsDatas[lct].getQuality()));
1072 if (mo_EventDisplay) {
1073 mo_EventDisplay->
SetBinContent(10, clctsDatas[lct].getKeyStrip(), clct_dtime);
1074 mo_EventDisplay->
SetBinContent(11, clctsDatas[lct].getKeyStrip(), clctsDatas[lct].getQuality());
1078 mo->
Fill((
int)(clctsDatas[lct].getQuality()));
1088 mo->
Fill((
int)(clctsDatas[lct].getKeyStrip()), (
int)(clctsDatas[lct].getQuality()));
1097 if(lct == 0) clct_kewdistrip = clctsDatas[lct].getKeyStrip();
1100 mo->
Fill((
int)(clctsDatas[lct].getKeyStrip()), clct_dtime);
1111 int pattern_clct = (
int)((clctsDatas[lct].getPattern() >> 1) & 0x3);
1114 if(pattern_clct == 1) mo->
Fill(clctsDatas[lct].getKeyStrip(), 7.0);
1115 if(pattern_clct == 3) mo->
Fill(clctsDatas[lct].getKeyStrip(), 6.0);
1116 if(pattern_clct == 5) mo->
Fill(clctsDatas[lct].getKeyStrip(), 5.0);
1117 if(pattern_clct == 7) mo->
Fill(clctsDatas[lct].getKeyStrip(), 4.0);
1118 if(pattern_clct == 6) mo->
Fill(clctsDatas[lct].getKeyStrip(), 3.0);
1119 if(pattern_clct == 4) mo->
Fill(clctsDatas[lct].getKeyStrip(), 2.0);
1120 if(pattern_clct == 2) mo->
Fill(clctsDatas[lct].getKeyStrip(), 1.0);
1121 if(pattern_clct == 0) mo->
Fill(clctsDatas[lct].getKeyStrip(), 0.0);
1125 mo->
Fill((
int)(clctsDatas[lct].getKeyStrip()),(
int)(clctsDatas[lct].getQuality()));
1128 mo->
Fill((
int)(clctsDatas[lct].getKeyStrip()), (
int)(clctsDatas[lct].getQuality()));
1133 int N_CFEBs=tmbHeader->
NCFEBs();
1135 int NumberOfLayersWithHitsInCLCT = 0;
1136 int NumberOfHalfStripsWithHitsInCLCT = 0;
1138 if (clctData && clctData->
check()) {
1143 MonitorObject* mo_CSC_Plus_endcap_CFEB_Comparators_Time =
nullptr;
1146 MonitorObject* mo_CSC_Minus_endcap_CFEB_Comparators_Time =
nullptr;
1155 for(
int nCFEB = 0; nCFEB < N_CFEBs; ++nCFEB) {
1156 for (
int nLayer = 1; nLayer <= 6; nLayer++) {
1158 int hstrip_previous = -1;
1159 int tbin_clct_previous = -1;
1160 bool CheckLayerCLCT =
true;
1162 std::vector<CSCComparatorDigi> compOutData = clctData->
comparatorDigis(nLayer, nCFEB);
1164 for (std::vector<CSCComparatorDigi>::iterator compOutDataItr = compOutData.begin(); compOutDataItr != compOutData.end(); ++compOutDataItr) {
1166 int hstrip = 2 * (compOutDataItr->getStrip() - 1) + compOutDataItr->getComparator();
1167 std::vector<int> tbins_clct = compOutDataItr->getTimeBinsOn();
1168 int tbin_clct = (
int)compOutDataItr->getTimeBin();
1170 if (mo_EventDisplay) {
1171 mo_EventDisplay->
SetBinContent(nLayer + 11, hstrip, tbin_clct + 1);
1176 if(CheckLayerCLCT) {
1177 NumberOfLayersWithHitsInCLCT = NumberOfLayersWithHitsInCLCT + 1;
1178 CheckLayerCLCT =
false;
1181 for (uint32_t
n=0;
n < tbins_clct.size();
n++) {
1182 tbin_clct = tbins_clct[
n];
1183 if(hstrip != hstrip_previous || (tbin_clct != tbin_clct_previous + 1 && tbin_clct != tbin_clct_previous - 1) ) {
1187 if (mo_CFEB_Comparators_TimeSamples) mo_CFEB_Comparators_TimeSamples->
Fill(tbin_clct);
1190 if (mo_CSC_Plus_endcap_CFEB_Comparators_Time) mo_CSC_Plus_endcap_CFEB_Comparators_Time->
Fill(tbin_clct);
1194 if (mo_CSC_Minus_endcap_CFEB_Comparators_Time) mo_CSC_Minus_endcap_CFEB_Comparators_Time->
Fill(tbin_clct);
1204 double Number_of_entries_CLCT = mo->
GetEntries();
1209 double norm = (100.0 * Number_of_entries_CLCT) / ((
double)(DMBEvents));
1220 if(hstrip != hstrip_previous) {
1221 NumberOfHalfStripsWithHitsInCLCT = NumberOfHalfStripsWithHitsInCLCT + 1;
1223 hstrip_previous = hstrip;
1224 tbin_clct_previous = tbin_clct;
1230 if (mo_CFEB_Comparators_TimeSamples) {
1232 double comps_time_mean = mo_CFEB_Comparators_TimeSamples->
getTH1()->GetMean();
1233 double comps_time_rms = mo_CFEB_Comparators_TimeSamples->
getTH1()->GetRMS();
1235 if (cscPosition && mo_CSC_CFEB_Comparators_Time_mean) {
1236 mo_CSC_CFEB_Comparators_Time_mean->
SetBinContent(cscPosition, cscType + 1, comps_time_mean);
1238 if (cscPosition && mo_CSC_CFEB_Comparators_Time_rms) {
1239 mo_CSC_CFEB_Comparators_Time_rms->
SetBinContent(cscPosition, cscType + 1, comps_time_rms);
1245 LOG_ERROR << cscTag <<
" Can not unpack CLCT Data";
1249 mo->
Fill(NumberOfLayersWithHitsInCLCT);
1257 mo->
Fill(NumberOfHalfStripsWithHitsInCLCT);
1259 LOG_ERROR << cscTag <<
" Can not unpack TMB Header or/and Trailer";
1262 LOG_ERROR << cscTag <<
" Can not unpack TMB Data";
1279 int NumberOfUnpackedCFEBs = 0;
1280 const int N_CFEBs = nCFEBs, N_Samples = 16, N_Layers = 6, N_Strips = 16, nStrips = nCFEBs * N_Strips;
1286 int Pedestal[N_CFEBs][6][16]; memset(Pedestal, 0,
sizeof(Pedestal));
1288 std::vector<std::array<std::array<std::pair<int,int>, 6>, 16>> CellPeak(N_CFEBs);
1289 std::fill(CellPeak.begin(), CellPeak.end(), std::array<std::array<std::pair<int,int>, 6>, 16>{});
1291 std::pair<int,int> CellPeak[N_CFEBs][6][16];
1292 memset(CellPeak, 0,
sizeof(CellPeak));
1296 bool CheckCFEB =
true;
1298 float Clus_Sum_Charge;
1299 int TrigTime, L1APhase, UnpackedTrigTime, LCTPhase, SCA_BLK, NmbTimeSamples;
1301 int FreeCells, LCT_Pipe_Empty, LCT_Pipe_Full, LCT_Pipe_Count, L1_Pipe_Empty, L1_Pipe_Full, Buffer_Count;
1304 bool CheckThresholdStripInTheLayer[6][nStrips];
1305 for(
int i=0;
i<6;
i++) {
1306 for(
int j = 0; j < nStrips; j++) CheckThresholdStripInTheLayer[
i][j] =
true;
1309 bool CheckOutOffRangeStripInTheLayer[6][nStrips];
1310 for(
int i=0;
i<6;
i++) {
1311 for(
int j=0; j<nStrips; j++) CheckOutOffRangeStripInTheLayer[
i][j] =
true;
1315 float cscdata[N_CFEBs * 16][N_Samples][N_Layers];
1317 int SCABlockData[N_CFEBs * 16][N_Samples][N_Layers];
1318 memset(cscdata, 0,
sizeof(cscdata));
1320 memset(SCABlockData, 0,
sizeof(SCABlockData));
1324 memset(hbuf, 0,
sizeof(hbuf));
1329 MonitorObject* mo_CSC_Plus_endcap_CFEB_SCA_CellPeak_Time =
nullptr;
1332 MonitorObject* mo_CSC_Minus_endcap_CFEB_SCA_CellPeak_Time =
nullptr;
1335 MonitorObject* mo_CSC_CFEB_SCA_CellPeak_Time_mean =
nullptr;
1341 for(
int nCFEB = 0; nCFEB < N_CFEBs; ++nCFEB) {
1344 if (data.
cfebData(nCFEB) !=
nullptr) {
1348 FEBunpacked = FEBunpacked +1;
1349 NumberOfUnpackedCFEBs = NumberOfUnpackedCFEBs + 1;
1351 if(CheckCFEB ==
true){
1357 if(
config->getNEvents() > 0) {
1358 mo->
SetBinContent(3, ((
float)CFEBEvent/(
float)(DMBEvents)*100.0));
1370 NmbTimeSamples= (data.
cfebData(nCFEB))->nTimeSamples();
1382 MonitorObject* mo_CFEB_SCA_Blocks_Locked_by_LCTxL1 =
nullptr;
1389 for(
int nLayer = 1; nLayer <= N_Layers; ++nLayer) {
1395 MonitorObject * mo_CFEB_Active_Samples_vs_Strip_Profile =
nullptr;
1409 for(
int nSample = 0; nSample < NmbTimeSamples; ++nSample) {
1411 if (
timeSlice(data, nCFEB, nSample) ==
nullptr) {
1412 LOG_WARN <<
"CFEB" << nCFEB <<
" nSample: " << nSample <<
" - B-Word";
1418 int cfeb_dmb_l1a_diff = (
int)((
timeSlice(data, nCFEB, nSample)->get_L1A_number())-dmbHeader->
l1a24()%64);
1419 if (cfeb_dmb_l1a_diff != 0) {
1420 L1A_out_of_sync =
true;
1422 if(cfeb_dmb_l1a_diff < -32) mo->
Fill(cfeb_dmb_l1a_diff + 64);
1424 if(cfeb_dmb_l1a_diff >= 32) mo->
Fill(cfeb_dmb_l1a_diff - 64);
1425 else mo_CFEB_DMB_L1A_diff->
Fill(cfeb_dmb_l1a_diff);
1449 for(
int nStrip = 0; nStrip < N_Strips; ++nStrip) {
1450 SCABlockData[nCFEB*16+nStrip][nSample][nLayer-1] = SCA_BLK;
1457 if (mo_CFEB_SCA_Block_Occupancy) mo_CFEB_SCA_Block_Occupancy->
Fill(SCA_BLK);
1461 if (mo_CFEB_Free_SCA_Cells) {
1462 if (
timeSlice(data, nCFEB, nSample)->scaControllerWord(nLayer).sca_full == 1) mo_CFEB_Free_SCA_Cells->
Fill(-1);
1463 mo_CFEB_Free_SCA_Cells->
Fill(FreeCells);
1468 if (mo_CFEB_SCA_Blocks_Locked_by_LCTs) {
1469 if (LCT_Pipe_Empty == 1) mo_CFEB_SCA_Blocks_Locked_by_LCTs->
Fill(-0.5);
1470 if (LCT_Pipe_Full == 1) mo_CFEB_SCA_Blocks_Locked_by_LCTs->
Fill(16.5);
1471 mo_CFEB_SCA_Blocks_Locked_by_LCTs->
Fill(LCT_Pipe_Count);
1476 if (mo_CFEB_SCA_Blocks_Locked_by_LCTxL1) {
1477 if (L1_Pipe_Empty == 1) mo_CFEB_SCA_Blocks_Locked_by_LCTxL1->
Fill(-0.5);
1478 if (L1_Pipe_Full == 1) mo_CFEB_SCA_Blocks_Locked_by_LCTxL1->
Fill(31.5);
1479 mo_CFEB_SCA_Blocks_Locked_by_LCTxL1->
Fill(Buffer_Count);
1484 if(nSample == 0 && nLayer == 1) {
1487 while (((TrigTime >> (k-1)) & 0
x1) != 1 && k <= 8) {
1491 UnpackedTrigTime = ((k << 1) & 0xE) + L1APhase;
1494 mo->
Fill((
int)UnpackedTrigTime);
1495 LCTPhase = (
int)((
timeSlice(data, nCFEB, nSample)->scaControllerWord(nLayer).lct_phase)&0x1);
1498 mo->
Fill(LCTPhase, L1APhase);
1506 int cfeb_dmb_L1A_sync_time = (
int)(dmbHeader->
dmbCfebSync()) - (
int)UnpackedTrigTime;
1507 if(cfeb_dmb_L1A_sync_time < -8) mo->
Fill(cfeb_dmb_L1A_sync_time+16);
1509 if(cfeb_dmb_L1A_sync_time >= 8) mo->
Fill(cfeb_dmb_L1A_sync_time-16);
1510 else mo->
Fill(cfeb_dmb_L1A_sync_time);
1518 for(
int nStrip = 1; nStrip <= N_Strips; ++nStrip) {
1525 CellPeak[nCFEB][nLayer-1][nStrip-1] = std::make_pair(nSample,ADC);
1526 Pedestal[nCFEB][nLayer-1][nStrip-1] =
ADC;
1530 if(OutOffRange == 1 && CheckOutOffRangeStripInTheLayer[nLayer - 1][nCFEB * 16 + nStrip - 1] ==
true) {
1532 if ( mo_CFEB_Out_Off_Range_Strips)
1533 mo_CFEB_Out_Off_Range_Strips->
Fill((
int)(nCFEB * 16 + nStrip - 1));
1534 CheckOutOffRangeStripInTheLayer[nLayer - 1][nCFEB * 16 + nStrip - 1] =
false;
1536 if(ADC - Pedestal[nCFEB][nLayer - 1][nStrip - 1] > Threshold && OutOffRange != 1) {
1538 if (mo_CFEB_Active_Samples_vs_Strip)
1539 mo_CFEB_Active_Samples_vs_Strip->
Fill((
int)(nCFEB * 16 + nStrip - 1), nSample);
1542 if (mo_CFEB_Active_Samples_vs_Strip_Profile)
1543 mo_CFEB_Active_Samples_vs_Strip_Profile->
Fill((
int)(nCFEB * 16 + nStrip - 1), nSample);
1545 if(CheckThresholdStripInTheLayer[nLayer - 1][nCFEB * 16 + nStrip - 1] ==
true) {
1547 if (mo_CFEB_ActiveStrips)
1548 mo_CFEB_ActiveStrips->
Fill((
int)(nCFEB * 16 + nStrip));
1549 CheckThresholdStripInTheLayer[nLayer - 1][nCFEB * 16 + nStrip - 1] =
false;
1552 if(ADC - Pedestal[nCFEB][nLayer - 1][nStrip - 1] > Threshold) {
1554 cscdata[nCFEB * 16 + nStrip - 1][nSample][nLayer - 1] = ADC - Pedestal[nCFEB][nLayer - 1][nStrip - 1];
1557 if(ADC > CellPeak[nCFEB][nLayer - 1][nStrip - 1].
second) {
1558 CellPeak[nCFEB][nLayer - 1][nStrip - 1].first = nSample;
1559 CellPeak[nCFEB][nLayer - 1][nStrip - 1].second =
ADC;
1565 int channel_threshold = 40;
1566 if (
std::abs(ADC - Pedestal[nCFEB][nLayer - 1][nStrip - 1]) < channel_threshold) {
1568 if (mo_CFEB_Pedestal_withEMV_Sample)
1569 mo_CFEB_Pedestal_withEMV_Sample->
Fill((
int)(nCFEB * 16 + nStrip - 1), Pedestal[nCFEB][nLayer - 1][nStrip - 1]);
1572 if (mo_CFEB_Pedestal_withRMS_Sample) {
1573 mo_CFEB_Pedestal_withRMS_Sample->
Fill((
int)(nCFEB * 16 + nStrip - 1), Pedestal[nCFEB][nLayer - 1][nStrip - 1]);
1577 if (mo_CFEB_PedestalRMS_Sample) {
1578 mo_CFEB_PedestalRMS_Sample->
SetBinContent(nCFEB * 16 + nStrip - 1, mo_CFEB_Pedestal_withRMS_Sample->
GetBinError(nCFEB * 16 + nStrip));
1579 mo_CFEB_PedestalRMS_Sample->
SetBinError(nCFEB * 16 + nStrip - 1, 0.00000000001);
1583 Pedestal[nCFEB][nLayer-1][nStrip-1] +=
ADC;
1584 Pedestal[nCFEB][nLayer-1][nStrip-1] /= 2;
1590 for(
int nStrip = 1; nStrip <= N_Strips; ++nStrip) {
1591 if (mo_CFEB_SCA_Cell_Peak && CellPeak[nCFEB][nLayer - 1][nStrip - 1].
first) {
1592 mo_CFEB_SCA_Cell_Peak->
Fill((
int)(nCFEB * 16 + nStrip - 1), CellPeak[nCFEB][nLayer - 1][nStrip - 1].
first);
1593 if (mo_CFEB_SCA_CellPeak_Time) {
1594 mo_CFEB_SCA_CellPeak_Time->
Fill(CellPeak[nCFEB][nLayer - 1][nStrip - 1].
first);
1597 if (mo_EventDisplay) {
1598 int peak_sample = CellPeak[nCFEB][nLayer-1][nStrip-1].first;
1599 int peak_adc = CellPeak[nCFEB][nLayer-1][nStrip-1].second;
1600 int pedestal = Pedestal[nCFEB][nLayer-1][nStrip-1];
1601 int peak_sca_charge = peak_adc -
pedestal;
1603 if (peak_adc - pedestal > Threshold) {
1604 if (peak_sample >=1) {
1607 if (peak_sample < NmbTimeSamples-1) {
1610 mo_EventDisplay->
SetBinContent(nLayer + 17, nCFEB * 16 + nStrip - 1, peak_sca_charge);
1611 setEmuEventDisplayBit(mo_Emu_EventDisplay_Cathode, glChamberIndex, nCFEB * 16 + nStrip - 1, nLayer - 1);
1616 if (mo_CSC_Plus_endcap_CFEB_SCA_CellPeak_Time)
1617 mo_CSC_Plus_endcap_CFEB_SCA_CellPeak_Time->
Fill(CellPeak[nCFEB][nLayer - 1][nStrip - 1].
first);
1620 if (mo_CSC_Minus_endcap_CFEB_SCA_CellPeak_Time)
1621 mo_CSC_Minus_endcap_CFEB_SCA_CellPeak_Time->
Fill(CellPeak[nCFEB][nLayer - 1][nStrip - 1].
first);
1632 if (mo_CFEB_SCA_CellPeak_Time) {
1633 double cellpeak_time_mean = mo_CFEB_SCA_CellPeak_Time->
getTH1()->GetMean();
1634 double cellpeak_time_rms = mo_CFEB_SCA_CellPeak_Time->
getTH1()->GetRMS();
1635 if (cscPosition && mo_CSC_CFEB_SCA_CellPeak_Time_mean) {
1636 mo_CSC_CFEB_SCA_CellPeak_Time_mean->
SetBinContent(cscPosition, cscType + 1, cellpeak_time_mean);
1638 if (cscPosition && mo_CSC_CFEB_SCA_CellPeak_Time_rms) {
1639 mo_CSC_CFEB_SCA_CellPeak_Time_rms->
SetBinContent(cscPosition, cscType + 1 ,cellpeak_time_rms);
1645 const int a = N_CFEBs * N_Strips;
1646 const int b = a * N_Samples;
1647 float Cathodes[b * N_Layers];
1648 for(
int i = 0;
i < N_Layers; ++
i) {
1649 const int b1 =
i *
b;
1650 for(
int j = 0; j <
a; ++j) {
1651 const int b2 = b1 + j;
1652 for(
int k = 0;
k < N_Samples; ++
k) {
1653 Cathodes[b2 + a *
k] = cscdata[j][
k][
i];
1658 std::vector<StripCluster> Clus;
1662 for(
int nLayer = 1; nLayer <= N_Layers; ++nLayer) {
1666 ClusterFinder.
DoAction(nLayer - 1, Cathodes);
1674 mo->
Fill(Clus.size());
1677 for(uint32_t u = 0; u < Clus.size(); u++){
1679 Clus_Sum_Charge = 0.0;
1681 for(uint32_t
k = 0;
k < Clus[u].ClusterPulseMapHeight.size();
k++) {
1685 for(
int n = Clus[u].LFTBNDTime;
n < Clus[u].IRTBNDTime;
n++) {
1686 Clus_Sum_Charge = Clus_Sum_Charge + Clus[u].ClusterPulseMapHeight[
k].height_[
n];
1693 mo->
Fill(Clus_Sum_Charge);
1698 mo->
Fill(Clus[u].IRTBNDStrip - Clus[u].LFTBNDStrip + 1);
1703 mo->
Fill(Clus[u].IRTBNDTime - Clus[u].LFTBNDTime + 1);
1717 float feb_combination_unpacked = -1.0;
1718 if(alct_unpacked == 0 && tmb_unpacked == 0 && cfeb_unpacked == 0) feb_combination_unpacked = 0.0;
1719 if(alct_unpacked > 0 && tmb_unpacked == 0 && cfeb_unpacked == 0) feb_combination_unpacked = 1.0;
1720 if(alct_unpacked == 0 && tmb_unpacked > 0 && cfeb_unpacked == 0) feb_combination_unpacked = 2.0;
1721 if(alct_unpacked == 0 && tmb_unpacked == 0 && cfeb_unpacked > 0) feb_combination_unpacked = 3.0;
1722 if(alct_unpacked > 0 && tmb_unpacked > 0 && cfeb_unpacked == 0) feb_combination_unpacked = 4.0;
1723 if(alct_unpacked > 0 && tmb_unpacked == 0 && cfeb_unpacked > 0) feb_combination_unpacked = 5.0;
1724 if(alct_unpacked == 0 && tmb_unpacked > 0 && cfeb_unpacked > 0) feb_combination_unpacked = 6.0;
1725 if(alct_unpacked > 0 && tmb_unpacked > 0 && cfeb_unpacked > 0) feb_combination_unpacked = 7.0;
1726 mo->
Fill(feb_combination_dav, feb_combination_unpacked);
1730 mo->
Fill(alct_keywg, clct_kewdistrip);
1734 mo->
Fill(cscPosition, cscType);
1738 mo->
Fill(crateID, dmbID);
unsigned tmb_half() const
CSCTMBTrailer * tmbTrailer()
const bool getCSCFromMap(const unsigned int &crateId, const unsigned int &dmbId, unsigned int &cscType, unsigned int &cscPosition) const
Get CSC type and position from crate and dmb identifiers.
int nclct() const
the number of CLCTs
unsigned cfeb_empty() const
virtual void SetAxisRange(const double from, const double to, const std::string &axis)=0
std::vector< StripCluster > getClusters()
virtual void SetEntries(const double value)=0
unsigned alct_full() const
bool isChamberStandby(unsigned int side, unsigned int station, unsigned int ring, unsigned int chamber) const
Check if chamber is in standby?
unsigned short adcOverflow
unsigned tmb_empty() const
unsigned cfeb_endtimeout() const
const CSCDMBTrailer * dmbTrailer() const
DMB trailer.
virtual void Fill(float x)=0
Monitoring Object interface used to cover Root object and provide common interface to EventProcessor ...
unsigned get_l1pipe_full() const
virtual const double GetBinError(const int bin)=0
virtual const double GetEntries()=0
constexpr uint32_t rawId() const
get the raw id
Object used to find Strip Clusters.
ExaminerStatusType errorsForChamber(CSCIdType chamber) const
void processCSC(const CSCEventData &data, const int dduID, const CSCDCCExaminer &binChecker)
Process Chamber Data and fill MOs.
void setEmuEventDisplayBit(MonitorObject *&mo, const unsigned int x, const unsigned int y, const unsigned int bit)
Set a single bit in the 3D Histogram (aka EMU level event display). Checks if mo and x != null...
CSCAnodeData * alctData() const
user must check if nalct > 0
virtual const int GetMaximumBin()=0
virtual void SetNormFactor(const double factor=1)=0
virtual const TH1 * getTH1(void) const =0
CSCALCTHeader * alctHeader() const
user must check if nalct > 0
const std::string getPath() const override
Get path part of the histogram (used only for DDUs and CSCs)
bool check() const
makes sure each time slice has a trailer
CSCCFEBSCAControllerWord scaControllerWord(int layer) const
unpacked from the controller words for each channel in the layer
int nalct() const
the flag for existence of ALCT data
const bool getCSCHisto(const HistoId &histo, const HwId &crateID, const HwId &dmbSlot, MonitorObject *&me)
Get CSC (Chamber) Level Monitoring Object.
unsigned get_buffer_count() const
U second(std::pair< T, U > const &p)
uint16_t getFormatVersion() const
CSCCLCTData * clctData() const
user must check if nclct > 0
CSCALCTTrailer * alctTrailer() const
user must check if nalct > 0
unsigned cfeb_starttimeout() const
virtual TH1 * getTH1Lock(void)=0
unsigned get_lctpipe_empty() const
unsigned tmb_starttimeout() const
virtual void SetBinContent(const int binX, const double value)=0
CSCTMBData * tmbData() const
user must check in nclct > 0
Abs< T >::type abs(const T &t)
unsigned alct_starttimeout() const
unsigned tmb_full() const
CSCDetId chamberID(const CSCDetId &cscDetId)
takes layer ID, converts to chamber ID, switching ME1A to ME11
const Detector getDetector() const
unsigned alct_half() const
std::vector< CSCComparatorDigi > comparatorDigis(int layer)
layers count from one
unsigned get_n_free_sca_blocks() const
void DoAction(int layerId, float *cathodes)
unsigned cfeb_half() const
unsigned get_l1pipe_empty() const
unsigned cfeb_full() const
virtual void SetBinError(const int bin, const double error)=0
std::vector< CSCWireDigi > wireDigis(int layer) const
input layer is from 1 to 6
CSCCFEBTimeSlice const *const timeSlice(T const &data, int nCFEB, int nSample)
CSCTMBHeader * tmbHeader()
virtual double GetBinContent(const int binX)=0
const CSCCFEBData * cfebData(unsigned icfeb) const
unpacked in long mode: has overflow and error bits decoded
char data[epos_bytes_allocation]
CSCCFEBDataWord const *const timeSample(T const &data, int nCFEB, int nSample, int nLayer, int nStrip)
void resetEmuEventDisplays()
Reset Emu level EventDisplay histograms once per event.
bool fCloseL1As
Data Format version (2005, 2013)
unsigned tmb_endtimeout() const
unsigned int GlobalChamberIndex(unsigned int side, unsigned int station, unsigned int ring, unsigned int chamber) const
Return global chamber index on his geometric location.
uint16_t theFormatVersion
Total Number of TMBs per event from DMB DAV.
bool EmuEventDisplayWasReset
unsigned alct_endtimeout() const
const bool getEMUHisto(const HistoId &histo, MonitorObject *&me)
Get EMU (Top Level) Monitoring Object.
unsigned alct_empty() const
const CSCDMBHeader * dmbHeader() const
the DAQ motherboard header. A good place for event and chamber info
unsigned get_lctpipe_count() const
unsigned dmb_l1pipe() const
unsigned get_lctpipe_full() const