27 return data.cfebData(nCFEB)->timeSlice(nSample)->timeSample(nLayer,nStrip);
65 if (
getEMUHisto(h::EMU_EVENT_DISPLAY_CATHODE, mo)) {
88 LOG_ERROR <<
"Zero pointer. DMB data are not available for unpacking";
93 int alct_unpacked = 0;
95 int cfeb_unpacked = 0;
98 int clct_kewdistrip = -1;
100 bool L1A_out_of_sync =
false;
108 if (!dmbHeader && !dmbTrailer) {
109 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;
125 if ((errors &
config->getBINCHECK_MASK()) > 0 ) {
126 LOG_WARN <<
"Format Errors " << cscTag <<
": 0x" << std::hex << errors <<
" Skipped CSC Unpacking";
130 unsigned int cscType = 0;
131 unsigned int cscPosition = 0;
132 if (!
getCSCFromMap(crateID, dmbID, cscType, cscPosition ))
return;
144 double DMBEvents = 0.0;
150 if (evDisplNo >= 5) {
156 if (
getCSCHisto(h::CSC_EVENT_DISPLAY_NOXX, crateID, dmbID, evDisplNo, mo_EventDisplay)) {
161 MonitorObject *mo_Emu_EventDisplay_Anode = 0, *mo_Emu_EventDisplay_Cathode = 0, *mo_Emu_EventDisplay_XY = 0;
162 getEMUHisto(h::EMU_EVENT_DISPLAY_ANODE, mo_Emu_EventDisplay_Anode);
163 getEMUHisto(h::EMU_EVENT_DISPLAY_CATHODE, mo_Emu_EventDisplay_Cathode);
164 getEMUHisto(h::EMU_EVENT_DISPLAY_XY, mo_Emu_EventDisplay_XY);
167 uint32_t glChamberIndex = 0;
169 if (mo_EventDisplay) {
177 if (mo_Emu_EventDisplay_Anode || mo_Emu_EventDisplay_Cathode || mo_Emu_EventDisplay_XY) {
184 if (cscType && cscPosition &&
getEMUHisto(h::EMU_CSC_UNPACKED, mo)){
185 mo->
Fill(cscPosition, cscType);
191 LOG_ERROR << cscTag <<
" has efficiency " << DMBEff <<
" which is greater than 1";
197 int dmbHeaderL1A = dmbHeader->
l1a()%64;
199 int dmb_ddu_l1a_diff = (int)(dmbHeaderL1A-(
int)(
L1ANumber%64));
200 if (dmb_ddu_l1a_diff != 0) L1A_out_of_sync =
true;
204 if (
getCSCHisto(h::CSC_DMB_L1A_DISTRIB, crateID, dmbID, mo)) mo->
Fill(dmbHeaderL1A);
206 if (
getCSCHisto(h::CSC_DMB_DDU_L1A_DIFF, crateID, dmbID, mo)) {
207 if(dmb_ddu_l1a_diff < -32) {
208 mo->
Fill(dmb_ddu_l1a_diff + 64);
210 if(dmb_ddu_l1a_diff >= 32) mo->
Fill(dmb_ddu_l1a_diff - 64);
211 else mo->
Fill(dmb_ddu_l1a_diff);
216 if (
getCSCHisto(h::CSC_DMB_L1A_VS_DDU_L1A, crateID, dmbID, mo)) mo->
Fill((
int)(
L1ANumber & 0xFF), (
int)dmbHeaderL1A);
219 int dmbHeaderBXN = 0;
220 int dmb_ddu_bxn_diff = 0;
226 dmbHeaderBXN = dmbHeader->
bxn12();
230 dmb_ddu_bxn_diff = dmbHeaderBXN%64-
BXN%64;
232 if (
getCSCHisto(h::CSC_DMB_BXN_DISTRIB, crateID, dmbID, mo)) mo->
Fill((
int)(dmbHeader->
bxn12()));
234 if (
getCSCHisto(h::CSC_DMB_DDU_BXN_DIFF, crateID, dmbID, mo)) {
235 if(dmb_ddu_bxn_diff < -32) mo->
Fill(dmb_ddu_bxn_diff + 64);
237 if(dmb_ddu_bxn_diff >= 32) mo->
Fill(dmb_ddu_bxn_diff - 64);
238 else mo->
Fill(dmb_ddu_bxn_diff);
244 if (
getCSCHisto(h::CSC_DMB_BXN_VS_DDU_BXN, crateID, dmbID, mo)) mo->
Fill(((
int)(
BXN)) % 256, ((
int)dmbHeaderBXN) % 256);
248 int cfeb_dav_num = 0;
250 int dmb_cfeb_sync = 0;
253 for (
int i = 0; i < 5; i++) cfeb_dav_num += (cfeb_dav >>
i) & 0x1;
254 cfeb_movlp = (int)dmbHeader->
cfebMovlp();
257 if (
getCSCHisto(h::CSC_DMB_CFEB_DAV, crateID, dmbID, mo)) {
258 for (
int i = 0;
i < 5;
i++) {
259 int cfeb_present = (cfeb_dav >>
i) & 0x1;
266 if (
getCSCHisto(h::CSC_DMB_CFEB_DAV_MULTIPLICITY, crateID, dmbID, mo)) mo->
Fill(cfeb_dav_num);
267 if (
getCSCHisto(h::CSC_DMB_CFEB_MOVLP, crateID, dmbID, mo)) mo->
Fill(cfeb_movlp);
268 if (
getCSCHisto(h::CSC_DMB_CFEB_SYNC, crateID, dmbID, mo)) mo->
Fill(dmb_cfeb_sync);
271 mo->
Fill(crateID, dmbID);
284 if (
getCSCHisto(h::CSC_DMB_FIFO_STATS, crateID, dmbID, mo)) {
291 for (
int i = 0;
i < 5;
i++) {
294 if ((
int)((dmbTrailer->
cfeb_full>>
i)&0x1) == 1) {
302 if (
getCSCHisto(h::CSC_DMB_FEB_TIMEOUTS, crateID, dmbID, mo)) {
311 for (
int i = 0;
i < 5;
i++) {
323 int alct_dav = dmbHeader->
nalct();
324 int tmb_dav = dmbHeader->
nclct();
326 for (
int i = 0;
i < 5;
i++) cfeb_dav2 = cfeb_dav2 + (
int)((dmbHeader->
cfebAvailable() >>
i) & 0x1);
330 if ((alct_dav > 0) && (
getCSCHisto(h::CSC_DMB_FEB_DAV_RATE, crateID, dmbID, mo))) {
333 if (
getCSCHisto(h::CSC_DMB_FEB_DAV_EFFICIENCY, crateID, dmbID, mo)) {
334 mo->
SetBinContent(1, ((
float)alct_dav_number / (
float)(DMBEvents) * 100.0));
339 if ((tmb_dav > 0) && (
getCSCHisto(h::CSC_DMB_FEB_DAV_RATE, crateID, dmbID, mo))) {
342 if (
getCSCHisto(h::CSC_DMB_FEB_DAV_EFFICIENCY, crateID, dmbID, mo)) {
343 mo->
SetBinContent(2, ((
float)tmb_dav_number / (
float)(DMBEvents) * 100.0));
348 if ((cfeb_dav2 > 0) && (
getCSCHisto(h::CSC_DMB_FEB_DAV_RATE, crateID, dmbID, mo))) {
351 if (
getCSCHisto(h::CSC_DMB_FEB_DAV_EFFICIENCY, crateID, dmbID, mo)) {
352 mo->
SetBinContent(3, ((
float)cfeb_dav2_number / (
float)(DMBEvents) * 100.0));
357 float feb_combination_dav = -1.0;
359 if (
getCSCHisto(h::CSC_DMB_FEB_COMBINATIONS_DAV_RATE, crateID, dmbID, mo)) {
360 if(alct_dav == 0 && tmb_dav == 0 && cfeb_dav2 == 0) feb_combination_dav = 0.0;
361 if(alct_dav > 0 && tmb_dav == 0 && cfeb_dav2 == 0) feb_combination_dav = 1.0;
362 if(alct_dav == 0 && tmb_dav > 0 && cfeb_dav2 == 0) feb_combination_dav = 2.0;
363 if(alct_dav == 0 && tmb_dav == 0 && cfeb_dav2 > 0) feb_combination_dav = 3.0;
364 if(alct_dav == 0 && tmb_dav > 0 && cfeb_dav2 > 0) feb_combination_dav = 4.0;
365 if(alct_dav > 0 && tmb_dav > 0 && cfeb_dav2 == 0) feb_combination_dav = 5.0;
366 if(alct_dav > 0 && tmb_dav == 0 && cfeb_dav2 > 0) feb_combination_dav = 6.0;
367 if(alct_dav > 0 && tmb_dav > 0 && cfeb_dav2 > 0) feb_combination_dav = 7.0;
368 mo->
Fill(feb_combination_dav);
369 float feb_combination_dav_number = mo->
GetBinContent((
int)(feb_combination_dav + 1.0));
370 if (
getCSCHisto(h::CSC_DMB_FEB_COMBINATIONS_DAV_EFFICIENCY, crateID, dmbID, mo)) {
371 mo->
SetBinContent((
int)(feb_combination_dav + 1.0), ((
float)feb_combination_dav_number / (
float)(DMBEvents) * 100.0));
384 if (alctHeader && alctTrailer) {
386 std::vector<CSCALCTDigi> alctsDatasTmp = alctHeader->
ALCTDigis();
387 std::vector<CSCALCTDigi> alctsDatas;
389 for (uint32_t lct = 0; lct < alctsDatasTmp.size(); lct++) {
390 if (alctsDatasTmp[lct].isValid()) alctsDatas.push_back(alctsDatasTmp[lct]);
393 FEBunpacked = FEBunpacked + 1;
397 if (
getCSCHisto(h::CSC_CSC_RATE, crateID, dmbID, mo)) {
401 if (
getCSCHisto(h::CSC_CSC_EFFICIENCY, crateID, dmbID, mo)){
405 mo->
SetBinContent(1, ((
float)ALCTEvent / (
float)(DMBEvents) * 100.0));
412 if ((alct_dav >0) && (
getCSCHisto(h::CSC_DMB_FEB_UNPACKED_VS_DAV, crateID, dmbID, mo))) {
421 if (
getCSCHisto(h::CSC_ALCT_DMB_L1A_DIFF, crateID, dmbID, mo)) {
423 int alct_dmb_l1a_diff = (int)(alctHeader->
L1Acc() % 64 - dmbHeader->
l1a() % 64);
424 if (alct_dmb_l1a_diff != 0) L1A_out_of_sync =
true;
425 if(alct_dmb_l1a_diff < -32) mo->
Fill(alct_dmb_l1a_diff + 64);
427 if(alct_dmb_l1a_diff >= 32) mo->
Fill(alct_dmb_l1a_diff - 64);
428 else mo->
Fill(alct_dmb_l1a_diff);
434 if (
getCSCHisto(h::CSC_DMB_L1A_VS_ALCT_L1A, crateID, dmbID, mo)) mo->
Fill(alctHeader->
L1Acc() % 256, dmbHeader->
l1a());
438 if (
getCSCHisto(h::CSC_ALCT_DMB_BXN_DIFF, crateID, dmbID, mo)) {
439 int alct_dmb_bxn_diff = (int)(alctHeader->
BXNCount()-dmbHeader->
bxn12());
440 if (alct_dmb_bxn_diff > 0) alct_dmb_bxn_diff -= 3564;
441 alct_dmb_bxn_diff %= 64;
442 mo->
Fill(alct_dmb_bxn_diff);
449 if (
getCSCHisto(h::CSC_ALCT_BXN_VS_DMB_BXN, crateID, dmbID, mo)) mo->
Fill((
int)((alctHeader->
BXNCount()) % 256), (int)(dmbHeader->
bxn12()) % 256);
451 if (
getCSCHisto(h::CSC_ALCT_NUMBER_RATE, crateID, dmbID, mo)) {
452 mo->
Fill(alctsDatas.size());
453 int nALCT = (int)mo->
GetBinContent((
int)(alctsDatas.size() + 1));
454 if (
getCSCHisto(h::CSC_ALCT_NUMBER_EFFICIENCY, crateID, dmbID, mo))
455 mo->
SetBinContent((
int)(alctsDatas.size() + 1), (
float)(nALCT) / (
float)(DMBEvents) * 100.0);
462 if (alctsDatas.size() == 2) {
463 if (
getCSCHisto(h::CSC_ALCT1_VS_ALCT0_KEYWG, crateID, dmbID, mo))
464 mo->
Fill(alctsDatas[0].getKeyWG(),alctsDatas[1].getKeyWG());
468 getEMUHisto(h::EMU_CSC_ALCT0_BXN_MEAN, mo_CSC_ALCT0_BXN_mean);
471 getEMUHisto(h::EMU_CSC_ALCT0_BXN_RMS, mo_CSC_ALCT0_BXN_rms);
474 getEMUHisto(h::EMU_CSC_ALCT0_ENDCAP_PLUS_DTIME, mo_CSC_Plus_endcap_ALCT0_dTime);
477 getEMUHisto(h::EMU_CSC_ALCT0_ENDCAP_MINUS_DTIME, mo_CSC_Minus_endcap_ALCT0_dTime);
479 for (uint32_t lct = 0; lct < alctsDatas.size(); lct++) {
482 if (lct >= 2)
continue;
484 if (
getCSCHisto(h::CSC_ALCTXX_KEYWG, crateID, dmbID, lct, mo)) {
485 mo->
Fill(alctsDatas[lct].getKeyWG());
488 if(lct == 0) alct_keywg = alctsDatas[lct].getKeyWG();
491 if (fwVersion == 2007) {
492 alct_dtime = alctsDatas[lct].getBX();
495 alct_dtime = (int) (alctsDatas[lct].getBX() - (alctHeader->
BXNCount()&0x1F));
498 if (
getCSCHisto(h::CSC_ALCTXX_DTIME, crateID, dmbID, lct, mo)) {
500 if(alct_dtime < -16) {
501 mo->
Fill(alct_dtime + 32);
503 if(alct_dtime >= 16) mo->
Fill(alct_dtime - 32);
504 else mo->
Fill(alct_dtime);
509 double dTime_mean = mo->
getTH1()->GetMean();
510 double dTime_rms = mo->
getTH1()->GetRMS();
515 if (mo_CSC_Plus_endcap_ALCT0_dTime) mo_CSC_Plus_endcap_ALCT0_dTime->
Fill(alct_dtime);
518 if (mo_CSC_Minus_endcap_ALCT0_dTime) mo_CSC_Minus_endcap_ALCT0_dTime->
Fill(alct_dtime);
520 if (cscPosition && cscType && mo_CSC_ALCT0_BXN_mean) {
521 mo_CSC_ALCT0_BXN_mean->
SetBinContent(cscPosition, cscType + 1, dTime_mean);
523 if (cscPosition && cscType && mo_CSC_ALCT0_BXN_rms) {
524 mo_CSC_ALCT0_BXN_rms->
SetBinContent(cscPosition, cscType + 1, dTime_rms);
530 if (
getCSCHisto(h::CSC_ALCTXX_DTIME_VS_KEYWG, crateID, dmbID, lct, mo)) {
531 if(alct_dtime < -16) {
532 mo->
Fill(alctsDatas[lct].getKeyWG(), alct_dtime + 32);
534 if(alct_dtime >= 16) mo->
Fill(alctsDatas[lct].getKeyWG(), alct_dtime - 32);
535 else mo->
Fill(alctsDatas[lct].getKeyWG(), alct_dtime);
539 if (
getCSCHisto(h::CSC_ALCTXX_DTIME_PROFILE, crateID, dmbID, lct, mo)) {
540 if(alct_dtime < -16) {
541 mo->
Fill(alctsDatas[lct].getKeyWG(), alct_dtime + 32);
543 if (alct_dtime >= 16) mo->
Fill(alctsDatas[lct].getKeyWG(), alct_dtime - 32);
544 else mo->
Fill(alctsDatas[lct].getKeyWG(), alct_dtime);
548 int alct_bxn = alctsDatas[lct].getBX();
549 if (fwVersion == 2007) {
550 alct_bxn = (alct_bxn + alctHeader->
BXNCount())&0x1F;
553 if (
getCSCHisto(h::CSC_ALCTXX_BXN, crateID, dmbID, lct, mo)) mo->
Fill(alct_bxn);
555 if (
getCSCHisto(h::CSC_ALCTXX_QUALITY, crateID, dmbID, lct, mo)) mo->
Fill(alctsDatas[lct].getKeyWG(), alctsDatas[lct].getQuality());
557 if (mo_EventDisplay) {
558 mo_EventDisplay->
SetBinContent(2, alctsDatas[lct].getKeyWG(), alct_bxn + 1 );
559 mo_EventDisplay->
SetBinContent(3, alctsDatas[lct].getKeyWG(), alctsDatas[lct].getQuality());
562 if (
getCSCHisto(h::CSC_ALCTXX_QUALITY_DISTR, crateID, dmbID, lct, mo)) {
563 mo->
Fill(alctsDatas[lct].getQuality());
566 if (cscType && cscPosition &&
getEMUHisto(h::EMU_CSC_ALCT0_QUALITY, mo1)) {
572 if (
getCSCHisto(h::CSC_ALCTXX_QUALITY_PROFILE, crateID, dmbID, lct, mo)) mo->
Fill(alctsDatas[lct].getKeyWG(), alctsDatas[lct].getQuality());
574 if (
getCSCHisto(h::CSC_ALCTXX_PATTERN, crateID, dmbID, lct, mo)) {
575 int pattern = (alctsDatas[lct].getAccelerator() << 1) + alctsDatas[lct].getCollisionB();
576 int keywg = alctsDatas[lct].getKeyWG();
577 mo->
Fill(keywg, pattern );
580 if (
getCSCHisto(h::CSC_ALCTXX_PATTERN_DISTR, crateID, dmbID, lct, mo)) {
581 int pattern = (alctsDatas[lct].getAccelerator()<<1) + alctsDatas[lct].getCollisionB();
587 int NumberOfLayersWithHitsInALCT = 0;
588 int NumberOfWireGroupsWithHitsInALCT = 0;
593 getCSCHisto(h::CSC_CFEB_AFEB_RAWHITS_TIMEBINS, crateID, dmbID, mo_AFEB_RawHits_TimeBins);
596 getEMUHisto(h::EMU_CSC_AFEB_ENDCAP_PLUS_RAWHITS_TIME, mo_CSC_Plus_endcap_AFEB_RawHits_Time);
599 getEMUHisto(h::EMU_CSC_AFEB_ENDCAP_MINUS_RAWHITS_TIME, mo_CSC_Minus_endcap_AFEB_RawHits_Time);
602 getEMUHisto(h::EMU_CSC_AFEB_RAWHITS_TIME_MEAN, mo_CSC_AFEB_RawHits_Time_mean);
605 getEMUHisto(h::EMU_CSC_AFEB_RAWHITS_TIME_RMS, mo_CSC_AFEB_RawHits_Time_rms);
607 for (
int nLayer = 1; nLayer <= 6; nLayer++) {
609 int wg_previous = -1;
610 int tbin_previous = -1;
611 bool CheckLayerALCT =
true;
613 std::vector<CSCWireDigi> wireDigis = alctData->
wireDigis(nLayer);
614 for (std::vector<CSCWireDigi>::iterator wireDigisItr = wireDigis.begin(); wireDigisItr != wireDigis.end(); ++wireDigisItr) {
616 int wg = wireDigisItr->getWireGroup();
618 std::vector<int> tbins = wireDigisItr->getTimeBinsOn();
619 int tbin = wireDigisItr->getTimeBin();
621 if (mo_EventDisplay) {
622 mo_EventDisplay->
SetBinContent(nLayer + 3, wg - 1, tbin + 1);
627 if (CheckLayerALCT) {
628 NumberOfLayersWithHitsInALCT = NumberOfLayersWithHitsInALCT + 1;
629 CheckLayerALCT =
false;
632 for (uint32_t
n = 0;
n < tbins.size();
n++) {
635 if(wg != wg_previous || (tbin != tbin_previous + 1 && tbin != tbin_previous - 1) ) {
637 if (
getCSCHisto(h::CSC_ALCTTIME_LYXX, crateID, dmbID, nLayer, mo)) mo->
Fill(wg - 1, tbin);
639 if (
getCSCHisto(h::CSC_ALCTTIME_LYXX_PROFILE, crateID, dmbID, nLayer, mo)) mo->
Fill(wg - 1, tbin);
641 if (mo_AFEB_RawHits_TimeBins) mo_AFEB_RawHits_TimeBins->
Fill(tbin);
644 if (mo_CSC_Plus_endcap_AFEB_RawHits_Time) mo_CSC_Plus_endcap_AFEB_RawHits_Time->
Fill(tbin);
647 if (mo_CSC_Minus_endcap_AFEB_RawHits_Time) mo_CSC_Minus_endcap_AFEB_RawHits_Time->
Fill(tbin);
650 if (
getCSCHisto(h::CSC_ALCT_LYXX_RATE, crateID, dmbID, nLayer, mo)) {
653 Double_t Number_of_entries_ALCT = mo->
GetEntries();
654 if (
getCSCHisto(h::CSC_ALCT_LYXX_EFFICIENCY, crateID, dmbID, nLayer, mo)) {
656 if((Double_t)(DMBEvents) > 0.0) {
657 mo->
SetNormFactor(100.0*Number_of_entries_ALCT/(Double_t)(DMBEvents));
665 if(wg != wg_previous) {
666 NumberOfWireGroupsWithHitsInALCT = NumberOfWireGroupsWithHitsInALCT + 1;
670 tbin_previous = tbin;
675 if (mo_AFEB_RawHits_TimeBins) {
677 double rawhits_time_mean = mo_AFEB_RawHits_TimeBins->
getTH1()->GetMean();
678 double rawhits_time_rms = mo_AFEB_RawHits_TimeBins->
getTH1()->GetRMS();
680 if (cscType && cscPosition && mo_CSC_AFEB_RawHits_Time_mean) {
681 mo_CSC_AFEB_RawHits_Time_mean->
SetBinContent(cscPosition, cscType + 1, rawhits_time_mean);
684 if (cscType && cscPosition && mo_CSC_AFEB_RawHits_Time_rms) {
685 mo_CSC_AFEB_RawHits_Time_rms->
SetBinContent(cscPosition, cscType + 1, rawhits_time_rms);
693 LOG_ERROR << cscTag <<
" Can not unpack Anode Data";
696 if (
getCSCHisto(h::CSC_ALCT_NUMBER_OF_LAYERS_WITH_HITS, crateID, dmbID, mo)) {
697 mo->
Fill(NumberOfLayersWithHitsInALCT);
699 if (cscType && cscPosition &&
getEMUHisto(h::EMU_CSC_ALCT_PLANES_WITH_HITS, mo1)) {
704 if (
getCSCHisto(h::CSC_ALCT_NUMBER_OF_WIREGROUPS_WITH_HITS, crateID, dmbID, mo)) mo->
Fill(NumberOfWireGroupsWithHitsInALCT);
707 LOG_ERROR << cscTag <<
" Can not unpack ALCT Header or/and Trailer";
712 if (
getCSCHisto(h::CSC_ALCT_NUMBER_RATE, crateID, dmbID, mo)) {
715 if (
getCSCHisto(h::CSC_ALCT_NUMBER_EFFICIENCY, crateID, dmbID, mo))
716 mo->
SetBinContent(1, (
float)(nALCT) / (
float)(DMBEvents) * 100.0);
719 if ((alct_dav > 0) && (
getCSCHisto(h::CSC_DMB_FEB_UNPACKED_VS_DAV, crateID, dmbID, mo))) {
730 std::vector<CSCALCTDigi> alctsDatasTmp = alctHeader->
ALCTDigis();
731 std::vector<CSCALCTDigi> alctsDatas;
733 for (uint32_t lct = 0; lct < alctsDatasTmp.size(); lct++) {
734 if (alctsDatasTmp[lct].isValid())
735 alctsDatas.push_back(alctsDatasTmp[lct]);
743 if (
getCSCHisto(h::CSC_TMB_BXN_VS_ALCT_BXN, crateID, dmbID, mo))
746 if (
getCSCHisto(h::CSC_TMB_ALCT_BXN_DIFF, crateID, dmbID, mo)) {
747 int clct_alct_bxn_diff = (int)(alctHeader->
BXNCount() - tmbHeader->
BXNCount());
748 if(clct_alct_bxn_diff < -2048) mo->
Fill(clct_alct_bxn_diff + 4096);
750 if(clct_alct_bxn_diff > 2048) mo->
Fill(clct_alct_bxn_diff - 4096);
751 else mo->
Fill(clct_alct_bxn_diff);
756 if (
getCSCHisto(h::CSC_TMB_L1A_VS_ALCT_L1A, crateID, dmbID, mo))
759 if (
getCSCHisto(h::CSC_TMB_ALCT_L1A_DIFF, crateID, dmbID, mo)) {
760 int clct_alct_l1a_diff = (int)(tmbHeader->
L1ANumber() - alctHeader->
L1Acc());
761 if(clct_alct_l1a_diff < -2048) mo->
Fill(clct_alct_l1a_diff + 4096);
763 if(clct_alct_l1a_diff > 2048) mo->
Fill(clct_alct_l1a_diff - 4096);
764 else mo->
Fill(clct_alct_l1a_diff);
769 LOG_ERROR << cscTag <<
" Can not unpack TMB Header";
773 LOG_ERROR << cscTag <<
" Can not unpack TMB Data";
776 LOG_ERROR << cscTag <<
" Can not unpack ALCT Header";
791 if (tmbHeader && tmbTrailer) {
795 std::vector<CSCCLCTDigi> clctsDatasTmp = tmbHeader->
CLCTDigis(cid.
rawId());
796 std::vector<CSCCLCTDigi> clctsDatas;
798 for (uint32_t lct = 0; lct < clctsDatasTmp.size(); lct++) {
799 if (clctsDatasTmp[lct].isValid()) clctsDatas.push_back(clctsDatasTmp[lct]);
802 FEBunpacked = FEBunpacked +1;
805 if (
getCSCHisto(h::CSC_ALCT_MATCH_TIME, crateID, dmbID, mo)) {
808 double alct_match_mean = mo->
getTH1()->GetMean();
809 double alct_match_rms = mo->
getTH1()->GetRMS();
813 if (cscType && cscPosition &&
getEMUHisto(h::EMU_CSC_ENDCAP_PLUS_ALCT_CLCT_MATCH_TIME, mo1)) {
819 if (cscType && cscPosition &&
getEMUHisto(h::EMU_CSC_ENDCAP_MINUS_ALCT_CLCT_MATCH_TIME, mo1)) {
824 if (cscType && cscPosition &&
getEMUHisto(h::EMU_CSC_ALCT_CLCT_MATCH_MEAN, mo1)) {
825 mo1->
SetBinContent(cscPosition, cscType + 1, alct_match_mean);
828 if (cscType && cscPosition &&
getEMUHisto(h::EMU_CSC_ALCT_CLCT_MATCH_RMS, mo1)) {
829 mo1->
SetBinContent(cscPosition, cscType + 1, alct_match_rms);
834 if (
getCSCHisto(h::CSC_LCT_MATCH_STATUS, crateID, dmbID, mo)) {
843 if ((tmb_dav > 0) && (
getCSCHisto(h::CSC_DMB_FEB_UNPACKED_VS_DAV, crateID, dmbID, mo))) {
848 if (
getCSCHisto(h::CSC_CSC_RATE, crateID, dmbID, mo)) {
852 if (
getCSCHisto(h::CSC_CSC_EFFICIENCY, crateID, dmbID, mo)) {
854 mo->
SetBinContent(2,((
float)CLCTEvent/(
float)(DMBEvents)*100.0));
863 if (
getCSCHisto(h::CSC_CLCT_DMB_L1A_DIFF, crateID, dmbID, mo)) {
864 int clct_dmb_l1a_diff = (int)((tmbHeader->
L1ANumber() % 64)-dmbHeader->
l1a() % 64);
865 if (clct_dmb_l1a_diff != 0) L1A_out_of_sync =
true;
866 if(clct_dmb_l1a_diff < -32) mo->
Fill(clct_dmb_l1a_diff + 64);
868 if(clct_dmb_l1a_diff >= 32) mo->
Fill(clct_dmb_l1a_diff - 64);
869 else mo->
Fill(clct_dmb_l1a_diff);
877 if (
getCSCHisto(h::CSC_CLCT_DMB_BXN_DIFF, crateID, dmbID, mo)) {
878 int clct_dmb_bxn_diff = (int)(tmbHeader->
BXNCount()%64-dmbHeader->
bxn12()%64);
879 if(clct_dmb_bxn_diff < -32) mo->
Fill(clct_dmb_bxn_diff + 64);
881 if(clct_dmb_bxn_diff >= 32) mo->
Fill(clct_dmb_bxn_diff - 64);
882 else mo->
Fill(clct_dmb_bxn_diff);
892 if (
getCSCHisto(h::CSC_CLCT_NUMBER_RATE, crateID, dmbID, mo)) {
893 mo->
Fill(clctsDatas.size());
894 int nCLCT = (int)mo->
GetBinContent((
int)(clctsDatas.size()+1));
895 if (
getCSCHisto(h::CSC_CLCT_NUMBER, crateID, dmbID, mo)) mo->
SetBinContent((
int)(clctsDatas.size() + 1), (
float)(nCLCT) / (
float)(DMBEvents) * 100.0);
898 if (clctsDatas.size() == 1) {
899 if (
getCSCHisto(h::CSC_CLCT0_CLSSIFICATION, crateID, dmbID, mo)) {
900 if (clctsDatas[0].getStripType()) mo->
Fill(0.0);
905 if (clctsDatas.size() == 2) {
906 if (
getCSCHisto(h::CSC_CLCT1_VS_CLCT0_KEY_STRIP, crateID, dmbID, mo))
907 mo->
Fill(clctsDatas[0].getKeyStrip(),clctsDatas[1].getKeyStrip());
908 if (
getCSCHisto(h::CSC_CLCT0_CLCT1_CLSSIFICATION, crateID, dmbID, mo)) {
909 if ( clctsDatas[0].getStripType() && clctsDatas[1].getStripType()) mo->
Fill(0.0);
910 if ( clctsDatas[0].getStripType() && !clctsDatas[1].getStripType()) mo->
Fill(1.0);
911 if (!clctsDatas[0].getStripType() && clctsDatas[1].getStripType()) mo->
Fill(2.0);
912 if (!clctsDatas[0].getStripType() && !clctsDatas[1].getStripType()) mo->
Fill(3.0);
920 getEMUHisto(h::EMU_CSC_ENDCAP_PLUS_CLCT0_DTIME, mo_CSC_Plus_endcap_CLCT0_dTime);
923 getEMUHisto(h::EMU_CSC_ENDCAP_MINUS_CLCT0_DTIME, mo_CSC_Minus_endcap_CLCT0_dTime);
926 getEMUHisto(h::EMU_CSC_CLCT0_BXN_MEAN, mo_CSC_CLCT0_BXN_mean);
929 getEMUHisto(h::EMU_CSC_CLCT0_BXN_RMS, mo_CSC_CLCT0_BXN_rms);
931 for (uint32_t lct = 0; lct < clctsDatas.size(); lct++) {
933 if (
getCSCHisto(h::CSC_CLCTXX_BXN, crateID, dmbID, lct, mo)) mo->
Fill(clctsDatas[lct].getFullBX()%64);
935 int clct_dtime = clctsDatas[lct].getFullBX() - tmbHeader->
BXNCount();
936 if (clct_dtime > 0) {
940 if (
getCSCHisto(h::CSC_CLCTXX_DTIME, crateID, dmbID, lct, mo)) {
941 int dTime = clct_dtime;
953 double dTime_mean = mo->
getTH1()->GetMean();
954 double dTime_rms = mo->
getTH1()->GetRMS();
959 if (mo_CSC_Plus_endcap_CLCT0_dTime) mo_CSC_Plus_endcap_CLCT0_dTime->
Fill(dTime);
962 if (mo_CSC_Minus_endcap_CLCT0_dTime) mo_CSC_Minus_endcap_CLCT0_dTime->
Fill(dTime);
964 if ( cscType && cscPosition && mo_CSC_CLCT0_BXN_mean) {
965 mo_CSC_CLCT0_BXN_mean->
SetBinContent(cscPosition, cscType + 1, dTime_mean);
967 if (cscType && cscPosition && mo_CSC_CLCT0_BXN_rms) {
968 mo_CSC_CLCT0_BXN_rms->
SetBinContent(cscPosition, cscType + 1, dTime_rms);
976 LOG_DEBUG <<
"LCT:" << lct <<
" Type:" << clctsDatas[lct].getStripType() <<
" Strip:" << clctsDatas[lct].getKeyStrip();
978 if (clctsDatas[lct].getStripType()) {
980 if (
getCSCHisto(h::CSC_CLCTXX_KEYHALFSTRIP, crateID, dmbID, lct, mo))
981 mo->
Fill(clctsDatas[lct].getKeyStrip());
983 if (
getCSCHisto(h::CSC_CLCTXX_DTIME_VS_HALF_STRIP, crateID, dmbID, lct, mo)) {
984 mo->
Fill((
int)(clctsDatas[lct].getKeyStrip()), clct_dtime);
995 if (
getCSCHisto(h::CSC_CLCTXX_DTIME_PROFILE, crateID, dmbID, lct, mo)) {
996 mo->
Fill((
int)(clctsDatas[lct].getKeyStrip()), clct_dtime);
1007 if (
getCSCHisto(h::CSC_CLCTXX_HALF_STRIP_PATTERN, crateID, dmbID, lct, mo)) {
1009 int pattern_clct = clctsDatas[lct].getPattern();
1015 switch (pattern_clct) {
1016 case 0: tbin=0.;
break;
1017 case 1: tbin=1.;
break;
1018 case 2: tbin=2.;
break;
1019 case 3: tbin=10.;
break;
1020 case 4: tbin=3.;
break;
1021 case 5: tbin=9.;
break;
1022 case 6: tbin=4.;
break;
1023 case 7: tbin=8.;
break;
1024 case 8: tbin=5.;
break;
1025 case 9: tbin=7.;
break;
1026 case 10: tbin=6.;
break;
1029 if (tbin >= 0) mo->
Fill(clctsDatas[lct].getKeyStrip(), tbin);
1032 if (
getCSCHisto(h::CSC_CLCT_HALF_STRIP_PATTERN_DISTR, crateID, dmbID, lct, mo1)) mo1->
Fill(tbin);
1036 if (
getCSCHisto(h::CSC_CLCTXX_HALF_STRIP_QUALITY, crateID, dmbID, lct, mo))
1037 mo->
Fill((
int)(clctsDatas[lct].getKeyStrip()),(
int)(clctsDatas[lct].getQuality()));
1039 if (mo_EventDisplay) {
1040 mo_EventDisplay->
SetBinContent(10, clctsDatas[lct].getKeyStrip(), clct_dtime);
1041 mo_EventDisplay->
SetBinContent(11, clctsDatas[lct].getKeyStrip(), clctsDatas[lct].getQuality());
1044 if (
getCSCHisto(h::CSC_CLCTXX_HALF_STRIP_QUALITY_DISTR, crateID, dmbID, lct, mo)) {
1045 mo->
Fill((
int)(clctsDatas[lct].getQuality()));
1048 if (cscType && cscPosition &&
getEMUHisto(h::EMU_CSC_CLCT0_QUALITY, mo1))
1053 if (
getCSCHisto(h::CSC_CLCTXX_HALF_STRIP_QUALITY_PROFILE, crateID, dmbID, lct, mo))
1054 mo->
Fill((
int)(clctsDatas[lct].getKeyStrip()), (
int)(clctsDatas[lct].getQuality()));
1060 if (
getCSCHisto(h::CSC_CLCTXX_KEYDISTRIP, crateID, dmbID, lct, mo)) mo->
Fill(clctsDatas[lct].getKeyStrip());
1061 else LOG_ERROR <<
"Not found h::CSC_CLCTXX_KEYDISTRIP = " << h::CSC_CLCTXX_KEYDISTRIP;
1063 if(lct == 0) clct_kewdistrip = clctsDatas[lct].getKeyStrip();
1065 if (
getCSCHisto(h::CSC_CLCTXX_DTIME_VS_DISTRIP, crateID, dmbID, lct, mo)) {
1066 mo->
Fill((
int)(clctsDatas[lct].getKeyStrip()), clct_dtime);
1076 if (
getCSCHisto(h::CSC_CLCTXX_DISTRIP_PATTERN, crateID, dmbID, lct, mo)) {
1077 int pattern_clct = (int)((clctsDatas[lct].getPattern() >> 1) & 0x3);
1080 if(pattern_clct == 1) mo->
Fill(clctsDatas[lct].getKeyStrip(), 7.0);
1081 if(pattern_clct == 3) mo->
Fill(clctsDatas[lct].getKeyStrip(), 6.0);
1082 if(pattern_clct == 5) mo->
Fill(clctsDatas[lct].getKeyStrip(), 5.0);
1083 if(pattern_clct == 7) mo->
Fill(clctsDatas[lct].getKeyStrip(), 4.0);
1084 if(pattern_clct == 6) mo->
Fill(clctsDatas[lct].getKeyStrip(), 3.0);
1085 if(pattern_clct == 4) mo->
Fill(clctsDatas[lct].getKeyStrip(), 2.0);
1086 if(pattern_clct == 2) mo->
Fill(clctsDatas[lct].getKeyStrip(), 1.0);
1087 if(pattern_clct == 0) mo->
Fill(clctsDatas[lct].getKeyStrip(), 0.0);
1090 if (
getCSCHisto(h::CSC_CLCTXX_DISTRIP_QUALITY, crateID, dmbID, lct, mo))
1091 mo->
Fill((
int)(clctsDatas[lct].getKeyStrip()),(
int)(clctsDatas[lct].getQuality()));
1093 if (
getCSCHisto(h::CSC_CLCTXX_DISTRIP_QUALITY_PROFILE, crateID, dmbID, lct, mo))
1094 mo->
Fill((
int)(clctsDatas[lct].getKeyStrip()), (
int)(clctsDatas[lct].getQuality()));
1100 int NumberOfLayersWithHitsInCLCT = 0;
1101 int NumberOfHalfStripsWithHitsInCLCT = 0;
1103 if (clctData && clctData->
check()) {
1106 getCSCHisto(h::CSC_CFEB_COMPARATORS_TIMESAMPLES, crateID, dmbID, mo_CFEB_Comparators_TimeSamples);
1108 MonitorObject* mo_CSC_Plus_endcap_CFEB_Comparators_Time = 0;
1109 getEMUHisto(h::EMU_CSC_ENDCAP_PLUS_CFEB_COMPARATORS_TIME, mo_CSC_Plus_endcap_CFEB_Comparators_Time);
1111 MonitorObject* mo_CSC_Minus_endcap_CFEB_Comparators_Time = 0;
1112 getEMUHisto(h::EMU_CSC_ENDCAP_MINUS_CFEB_COMPARATORS_TIME, mo_CSC_Minus_endcap_CFEB_Comparators_Time);
1115 getEMUHisto(h::EMU_CSC_CFEB_COMPARATORS_TIME_MEAN, mo_CSC_CFEB_Comparators_Time_mean);
1118 getEMUHisto(h::EMU_CSC_CFEB_COMPARATORS_TIME_RMS, mo_CSC_CFEB_Comparators_Time_rms);
1120 for(
int nCFEB = 0; nCFEB < N_CFEBs; ++nCFEB) {
1121 for (
int nLayer = 1; nLayer <= 6; nLayer++) {
1123 int hstrip_previous = -1;
1124 int tbin_clct_previous = -1;
1125 bool CheckLayerCLCT =
true;
1127 std::vector<CSCComparatorDigi> compOutData = clctData->
comparatorDigis(nLayer, nCFEB);
1129 for (std::vector<CSCComparatorDigi>::iterator compOutDataItr = compOutData.begin(); compOutDataItr != compOutData.end(); ++compOutDataItr) {
1131 int hstrip = 2 * (compOutDataItr->getStrip() - 1) + compOutDataItr->getComparator();
1132 std::vector<int> tbins_clct = compOutDataItr->getTimeBinsOn();
1133 int tbin_clct = (int)compOutDataItr->getTimeBin();
1135 if (mo_EventDisplay) {
1136 mo_EventDisplay->
SetBinContent(nLayer + 11, hstrip, tbin_clct + 1);
1141 if(CheckLayerCLCT) {
1142 NumberOfLayersWithHitsInCLCT = NumberOfLayersWithHitsInCLCT + 1;
1143 CheckLayerCLCT =
false;
1146 for (uint32_t
n=0;
n < tbins_clct.size();
n++) {
1147 tbin_clct = tbins_clct[
n];
1148 if(hstrip != hstrip_previous || (tbin_clct != tbin_clct_previous + 1 && tbin_clct != tbin_clct_previous - 1) ) {
1150 if (
getCSCHisto(h::CSC_CLCTTIME_LYXX, crateID, dmbID, nLayer, mo)) mo->
Fill(hstrip, tbin_clct);
1152 if (mo_CFEB_Comparators_TimeSamples) mo_CFEB_Comparators_TimeSamples->
Fill(tbin_clct);
1155 if (mo_CSC_Plus_endcap_CFEB_Comparators_Time) mo_CSC_Plus_endcap_CFEB_Comparators_Time->
Fill(tbin_clct);
1159 if (mo_CSC_Minus_endcap_CFEB_Comparators_Time) mo_CSC_Minus_endcap_CFEB_Comparators_Time->
Fill(tbin_clct);
1162 if (
getCSCHisto(h::CSC_CLCTTIME_LYXX_PROFILE, crateID, dmbID, nLayer, mo)) mo->
Fill(hstrip, tbin_clct);
1164 if (
getCSCHisto(h::CSC_CLCT_LYXX_RATE, crateID, dmbID, nLayer, mo)) {
1169 double Number_of_entries_CLCT = mo->
GetEntries();
1171 if (
getCSCHisto(h::CSC_CLCT_LYXX_EFFICIENCY, crateID, dmbID, nLayer, mo)) {
1174 double norm = (100.0 * Number_of_entries_CLCT) / ((
double)(DMBEvents));
1185 if(hstrip != hstrip_previous) {
1186 NumberOfHalfStripsWithHitsInCLCT = NumberOfHalfStripsWithHitsInCLCT + 1;
1188 hstrip_previous = hstrip;
1189 tbin_clct_previous = tbin_clct;
1195 if (mo_CFEB_Comparators_TimeSamples) {
1197 double comps_time_mean = mo_CFEB_Comparators_TimeSamples->
getTH1()->GetMean();
1198 double comps_time_rms = mo_CFEB_Comparators_TimeSamples->
getTH1()->GetRMS();
1200 if ( cscType && cscPosition && mo_CSC_CFEB_Comparators_Time_mean) {
1201 mo_CSC_CFEB_Comparators_Time_mean->
SetBinContent(cscPosition, cscType + 1, comps_time_mean);
1203 if ( cscType && cscPosition && mo_CSC_CFEB_Comparators_Time_rms) {
1204 mo_CSC_CFEB_Comparators_Time_rms->
SetBinContent(cscPosition, cscType + 1, comps_time_rms);
1210 LOG_ERROR << cscTag <<
" Can not unpack CLCT Data";
1213 if (
getCSCHisto(h::CSC_CLCT_NUMBER_OF_LAYERS_WITH_HITS, crateID, dmbID, mo)) {
1214 mo->
Fill(NumberOfLayersWithHitsInCLCT);
1216 if (cscType && cscPosition &&
getEMUHisto(h::EMU_CSC_CLCT_PLANES_WITH_HITS, mo1)) {
1221 if (
getCSCHisto(h::CSC_CLCT_NUMBER_OF_HALFSTRIPS_WITH_HITS, crateID, dmbID, mo))
1222 mo->
Fill(NumberOfHalfStripsWithHitsInCLCT);
1224 LOG_ERROR << cscTag <<
" Can not unpack TMB Header or/and Trailer";
1227 LOG_ERROR << cscTag <<
" Can not unpack TMB Data";
1233 if (
getCSCHisto(h::CSC_CLCT_NUMBER_RATE, crateID, dmbID, mo)) {
1236 if (
getCSCHisto(h::CSC_CLCT_NUMBER, crateID, dmbID, mo)) mo->
SetBinContent(1, (
float)(nCLCT) / (
float)(DMBEvents) * 100.0);
1238 if ((tmb_dav > 0) && (
getCSCHisto(h::CSC_DMB_FEB_UNPACKED_VS_DAV, crateID, dmbID, mo))) {
1244 int NumberOfUnpackedCFEBs = 0;
1245 const int N_CFEBs = 5, N_Samples = 16, N_Layers = 6, N_Strips = 16;
1246 int ADC = 0, OutOffRange, Threshold = 30;
1251 int Pedestal[5][6][16];
1252 std::pair<int,int> CellPeak[5][6][16];
1253 memset(CellPeak, 0,
sizeof(CellPeak));
1256 bool CheckCFEB =
true;
1258 float Clus_Sum_Charge;
1259 int TrigTime, L1APhase, UnpackedTrigTime, LCTPhase, SCA_BLK, NmbTimeSamples;
1261 int FreeCells, LCT_Pipe_Empty, LCT_Pipe_Full, LCT_Pipe_Count, L1_Pipe_Empty, L1_Pipe_Full, Buffer_Count;
1264 bool CheckThresholdStripInTheLayer[6][80];
1265 for(
int i=0;
i<6;
i++) {
1266 for(
int j = 0;
j < 80;
j++) CheckThresholdStripInTheLayer[
i][
j] =
true;
1269 bool CheckOutOffRangeStripInTheLayer[6][80];
1270 for(
int i=0;
i<6;
i++) {
1271 for(
int j=0;
j<80;
j++) CheckOutOffRangeStripInTheLayer[
i][
j] =
true;
1275 float cscdata[N_CFEBs * 16][N_Samples][N_Layers];
1277 int SCABlockData[N_CFEBs * 16][N_Samples][N_Layers];
1278 memset(cscdata, 0,
sizeof(cscdata));
1280 memset(SCABlockData, 0,
sizeof(SCABlockData));
1284 memset(hbuf, 0,
sizeof(hbuf));
1287 getCSCHisto(h::CSC_CFEB_SCA_CELLPEAK_TIME, crateID, dmbID, mo_CFEB_SCA_CellPeak_Time);
1289 MonitorObject* mo_CSC_Plus_endcap_CFEB_SCA_CellPeak_Time = 0;
1290 getEMUHisto(h::EMU_CSC_PLUS_ENDCAP_CFEB_SCA_CELLPEAK_TIME, mo_CSC_Plus_endcap_CFEB_SCA_CellPeak_Time);
1292 MonitorObject* mo_CSC_Minus_endcap_CFEB_SCA_CellPeak_Time = 0;
1293 getEMUHisto(h::EMU_CSC_MINUS_ENDCAP_CFEB_SCA_CELLPEAK_TIME, mo_CSC_Minus_endcap_CFEB_SCA_CellPeak_Time);
1296 getEMUHisto(h::EMU_CSC_CFEB_SCA_CELLPEAK_TIME_MEAN, mo_CSC_CFEB_SCA_CellPeak_Time_mean);
1299 getEMUHisto(h::EMU_CSC_CFEB_SCA_CELLPEAK_TIME_RMS, mo_CSC_CFEB_SCA_CellPeak_Time_rms);
1301 for(
int nCFEB = 0; nCFEB < N_CFEBs; ++nCFEB) {
1307 FEBunpacked = FEBunpacked +1;
1308 NumberOfUnpackedCFEBs = NumberOfUnpackedCFEBs + 1;
1310 if(CheckCFEB ==
true){
1311 if (
getCSCHisto(h::CSC_CSC_RATE, crateID, dmbID, mo)) {
1315 if (
getCSCHisto(h::CSC_CSC_EFFICIENCY, crateID, dmbID, mo)) {
1317 mo->
SetBinContent(3, ((
float)CFEBEvent/(
float)(DMBEvents)*100.0));
1323 if ((cfeb_dav2 > 0) && (
getCSCHisto(h::CSC_DMB_FEB_UNPACKED_VS_DAV, crateID, dmbID, mo))) {
1329 NmbTimeSamples= (data.
cfebData(nCFEB))->nTimeSamples();
1336 getCSCHisto(h::CSC_CFEBXX_SCA_BLOCK_OCCUPANCY, crateID, dmbID, nCFEB + 1, mo_CFEB_SCA_Block_Occupancy);
1338 getCSCHisto(h::CSC_CFEBXX_FREE_SCA_CELLS, crateID, dmbID, nCFEB + 1, mo_CFEB_Free_SCA_Cells);
1340 getCSCHisto(h::CSC_CFEBXX_SCA_BLOCKS_LOCKED_BY_LCTS, crateID, dmbID, nCFEB + 1, mo_CFEB_SCA_Blocks_Locked_by_LCTs);
1342 getCSCHisto(h::CSC_CFEBXX_SCA_BLOCKS_LOCKED_BY_LCTXL1, crateID, dmbID, nCFEB + 1, mo_CFEB_SCA_Blocks_Locked_by_LCTxL1);
1344 getCSCHisto(h::CSC_CFEBXX_DMB_L1A_DIFF, crateID, dmbID, nCFEB + 1, mo_CFEB_DMB_L1A_diff);
1348 for(
int nLayer = 1; nLayer <= N_Layers; ++nLayer) {
1351 getCSCHisto(h::CSC_CFEB_OUT_OFF_RANGE_STRIPS_LYXX, crateID, dmbID, nLayer, mo_CFEB_Out_Off_Range_Strips);
1353 getCSCHisto(h::CSC_CFEB_ACTIVE_SAMPLES_VS_STRIP_LYXX, crateID, dmbID, nLayer, mo_CFEB_Active_Samples_vs_Strip);
1354 MonitorObject * mo_CFEB_Active_Samples_vs_Strip_Profile = 0;
1355 getCSCHisto(h::CSC_CFEB_ACTIVE_SAMPLES_VS_STRIP_LYXX_PROFILE, crateID, dmbID, nLayer, mo_CFEB_Active_Samples_vs_Strip_Profile);
1357 getCSCHisto(h::CSC_CFEB_ACTIVESTRIPS_LYXX, crateID, dmbID, nLayer, mo_CFEB_ActiveStrips);
1359 getCSCHisto(h::CSC_CFEB_SCA_CELL_PEAK_LY_XX, crateID, dmbID, nLayer, mo_CFEB_SCA_Cell_Peak);
1362 getCSCHisto(h::CSC_CFEB_PEDESTAL_WITHEMV_SAMPLE_01_LYXX, crateID, dmbID, nLayer, mo_CFEB_Pedestal_withEMV_Sample);
1364 getCSCHisto(h::CSC_CFEB_PEDESTAL_WITHRMS_SAMPLE_01_LYXX, crateID, dmbID, nLayer, mo_CFEB_Pedestal_withRMS_Sample);
1366 getCSCHisto(h::CSC_CFEB_PEDESTALRMS_SAMPLE_01_LYXX, crateID, dmbID, nLayer, mo_CFEB_PedestalRMS_Sample);
1368 for(
int nSample = 0; nSample < NmbTimeSamples; ++nSample) {
1370 if (
timeSlice(data, nCFEB, nSample) == 0) {
1371 LOG_WARN <<
"CFEB" << nCFEB <<
" nSample: " << nSample <<
" - B-Word";
1377 int cfeb_dmb_l1a_diff = (int)((
timeSlice(data, nCFEB, nSample)->get_L1A_number())-dmbHeader->
l1a()%64);
1378 if (cfeb_dmb_l1a_diff != 0) {
1379 L1A_out_of_sync =
true;
1381 if(cfeb_dmb_l1a_diff < -32) mo->
Fill(cfeb_dmb_l1a_diff + 64);
1383 if(cfeb_dmb_l1a_diff >= 32) mo->
Fill(cfeb_dmb_l1a_diff - 64);
1384 else mo_CFEB_DMB_L1A_diff->
Fill(cfeb_dmb_l1a_diff);
1408 for(
int nStrip = 0; nStrip < N_Strips; ++nStrip) {
1409 SCABlockData[nCFEB*16+nStrip][nSample][nLayer-1] = SCA_BLK;
1416 if (mo_CFEB_SCA_Block_Occupancy) mo_CFEB_SCA_Block_Occupancy->
Fill(SCA_BLK);
1420 if (mo_CFEB_Free_SCA_Cells) {
1421 if (
timeSlice(data, nCFEB, nSample)->scaControllerWord(nLayer).sca_full == 1) mo_CFEB_Free_SCA_Cells->
Fill(-1);
1422 mo_CFEB_Free_SCA_Cells->
Fill(FreeCells);
1427 if (mo_CFEB_SCA_Blocks_Locked_by_LCTs) {
1428 if (LCT_Pipe_Empty == 1) mo_CFEB_SCA_Blocks_Locked_by_LCTs->
Fill(-0.5);
1429 if (LCT_Pipe_Full == 1) mo_CFEB_SCA_Blocks_Locked_by_LCTs->
Fill(16.5);
1430 mo_CFEB_SCA_Blocks_Locked_by_LCTs->
Fill(LCT_Pipe_Count);
1435 if (mo_CFEB_SCA_Blocks_Locked_by_LCTxL1) {
1436 if (L1_Pipe_Empty == 1) mo_CFEB_SCA_Blocks_Locked_by_LCTxL1->
Fill(-0.5);
1437 if (L1_Pipe_Full == 1) mo_CFEB_SCA_Blocks_Locked_by_LCTxL1->
Fill(31.5);
1438 mo_CFEB_SCA_Blocks_Locked_by_LCTxL1->
Fill(Buffer_Count);
1443 if(nSample == 0 && nLayer == 1) {
1446 while (((TrigTime >> (k-1)) & 0x1) != 1 && k <= 8) {
1450 UnpackedTrigTime = ((k << 1) & 0xE) + L1APhase;
1452 if (
getCSCHisto(h::CSC_CFEBXX_L1A_SYNC_TIME, crateID, dmbID, nCFEB + 1, mo))
1453 mo->
Fill((
int)UnpackedTrigTime);
1454 LCTPhase = (int)((
timeSlice(data, nCFEB, nSample)->scaControllerWord(nLayer).lct_phase)&0x1);
1456 if (
getCSCHisto(h::CSC_CFEBXX_LCT_PHASE_VS_L1A_PHASE, crateID, dmbID, nCFEB + 1, mo))
1457 mo->
Fill(LCTPhase, L1APhase);
1461 if (
getCSCHisto(h::CSC_CFEBXX_L1A_SYNC_TIME_VS_DMB, crateID, dmbID, nCFEB + 1, mo))
1464 if (
getCSCHisto(h::CSC_CFEBXX_L1A_SYNC_TIME_DMB_DIFF, crateID, dmbID, nCFEB + 1, mo)) {
1465 int cfeb_dmb_L1A_sync_time = (int)(dmbHeader->
dmbCfebSync()) - (
int)UnpackedTrigTime;
1466 if(cfeb_dmb_L1A_sync_time < -8) mo->
Fill(cfeb_dmb_L1A_sync_time+16);
1468 if(cfeb_dmb_L1A_sync_time >= 8) mo->
Fill(cfeb_dmb_L1A_sync_time-16);
1469 else mo->
Fill(cfeb_dmb_L1A_sync_time);
1477 for(
int nStrip = 1; nStrip <= N_Strips; ++nStrip) {
1484 CellPeak[nCFEB][nLayer-1][nStrip-1] = std::make_pair(nSample,ADC);
1485 Pedestal[nCFEB][nLayer-1][nStrip-1] =
ADC;
1489 if(OutOffRange == 1 && CheckOutOffRangeStripInTheLayer[nLayer - 1][nCFEB * 16 + nStrip - 1] ==
true) {
1491 if ( mo_CFEB_Out_Off_Range_Strips)
1492 mo_CFEB_Out_Off_Range_Strips->
Fill((
int)(nCFEB * 16 + nStrip - 1));
1493 CheckOutOffRangeStripInTheLayer[nLayer - 1][nCFEB * 16 + nStrip - 1] =
false;
1495 if(ADC - Pedestal[nCFEB][nLayer - 1][nStrip - 1] > Threshold && OutOffRange != 1) {
1497 if (mo_CFEB_Active_Samples_vs_Strip)
1498 mo_CFEB_Active_Samples_vs_Strip->
Fill((
int)(nCFEB * 16 + nStrip - 1), nSample);
1501 if (mo_CFEB_Active_Samples_vs_Strip_Profile)
1502 mo_CFEB_Active_Samples_vs_Strip_Profile->
Fill((
int)(nCFEB * 16 + nStrip - 1), nSample);
1504 if(CheckThresholdStripInTheLayer[nLayer - 1][nCFEB * 16 + nStrip - 1] ==
true) {
1506 if (mo_CFEB_ActiveStrips)
1507 mo_CFEB_ActiveStrips->
Fill((
int)(nCFEB * 16 + nStrip));
1508 CheckThresholdStripInTheLayer[nLayer - 1][nCFEB * 16 + nStrip - 1] =
false;
1511 if(ADC - Pedestal[nCFEB][nLayer - 1][nStrip - 1] > Threshold) {
1513 cscdata[nCFEB * 16 + nStrip - 1][nSample][nLayer - 1] = ADC - Pedestal[nCFEB][nLayer - 1][nStrip - 1];
1516 if(ADC > CellPeak[nCFEB][nLayer - 1][nStrip - 1].
second) {
1517 CellPeak[nCFEB][nLayer - 1][nStrip - 1].first = nSample;
1518 CellPeak[nCFEB][nLayer - 1][nStrip - 1].second =
ADC;
1524 int channel_threshold = 40;
1525 if (
std::abs(ADC - Pedestal[nCFEB][nLayer - 1][nStrip - 1]) < channel_threshold) {
1527 if (mo_CFEB_Pedestal_withEMV_Sample)
1528 mo_CFEB_Pedestal_withEMV_Sample->
Fill((
int)(nCFEB * 16 + nStrip - 1), Pedestal[nCFEB][nLayer - 1][nStrip - 1]);
1531 if (mo_CFEB_Pedestal_withRMS_Sample) {
1532 mo_CFEB_Pedestal_withRMS_Sample->
Fill((
int)(nCFEB * 16 + nStrip - 1), Pedestal[nCFEB][nLayer - 1][nStrip - 1]);
1536 if (mo_CFEB_PedestalRMS_Sample) {
1537 mo_CFEB_PedestalRMS_Sample->
SetBinContent(nCFEB * 16 + nStrip - 1, mo_CFEB_Pedestal_withRMS_Sample->
GetBinError(nCFEB * 16 + nStrip));
1538 mo_CFEB_PedestalRMS_Sample->
SetBinError(nCFEB * 16 + nStrip - 1, 0.00000000001);
1542 Pedestal[nCFEB][nLayer-1][nStrip-1] +=
ADC;
1543 Pedestal[nCFEB][nLayer-1][nStrip-1] /= 2;
1549 for(
int nStrip = 1; nStrip <= N_Strips; ++nStrip) {
1550 if (mo_CFEB_SCA_Cell_Peak && CellPeak[nCFEB][nLayer - 1][nStrip - 1].
first) {
1551 mo_CFEB_SCA_Cell_Peak->
Fill((
int)(nCFEB * 16 + nStrip - 1), CellPeak[nCFEB][nLayer - 1][nStrip - 1].
first);
1552 if (mo_CFEB_SCA_CellPeak_Time) {
1553 mo_CFEB_SCA_CellPeak_Time->
Fill(CellPeak[nCFEB][nLayer - 1][nStrip - 1].
first);
1556 if (mo_EventDisplay) {
1557 int peak_sample = CellPeak[nCFEB][nLayer-1][nStrip-1].first;
1558 int peak_adc = CellPeak[nCFEB][nLayer-1][nStrip-1].second;
1559 int pedestal = Pedestal[nCFEB][nLayer-1][nStrip-1];
1560 int peak_sca_charge = peak_adc - pedestal;
1562 if (peak_adc - pedestal > Threshold) {
1563 if (peak_sample >=1) {
1564 peak_sca_charge += ((
timeSample(data, nCFEB, peak_sample-1, nLayer, nStrip)->
adcCounts)&0xFFF)-pedestal;
1566 if (peak_sample < NmbTimeSamples-1) {
1567 peak_sca_charge += ((
timeSample(data, nCFEB, peak_sample+1, nLayer, nStrip)->
adcCounts)&0xFFF)-pedestal;
1569 mo_EventDisplay->
SetBinContent(nLayer + 17, nCFEB * 16 + nStrip - 1, peak_sca_charge);
1570 setEmuEventDisplayBit(mo_Emu_EventDisplay_Cathode, glChamberIndex, nCFEB * 16 + nStrip - 1, nLayer - 1);
1575 if (mo_CSC_Plus_endcap_CFEB_SCA_CellPeak_Time)
1576 mo_CSC_Plus_endcap_CFEB_SCA_CellPeak_Time->
Fill(CellPeak[nCFEB][nLayer - 1][nStrip - 1].
first);
1579 if (mo_CSC_Minus_endcap_CFEB_SCA_CellPeak_Time)
1580 mo_CSC_Minus_endcap_CFEB_SCA_CellPeak_Time->
Fill(CellPeak[nCFEB][nLayer - 1][nStrip - 1].
first);
1591 if (mo_CFEB_SCA_CellPeak_Time) {
1592 double cellpeak_time_mean = mo_CFEB_SCA_CellPeak_Time->
getTH1()->GetMean();
1593 double cellpeak_time_rms = mo_CFEB_SCA_CellPeak_Time->
getTH1()->GetRMS();
1594 if (cscType && cscPosition && mo_CSC_CFEB_SCA_CellPeak_Time_mean) {
1595 mo_CSC_CFEB_SCA_CellPeak_Time_mean->
SetBinContent(cscPosition, cscType + 1, cellpeak_time_mean);
1597 if (cscType && cscPosition && mo_CSC_CFEB_SCA_CellPeak_Time_rms) {
1598 mo_CSC_CFEB_SCA_CellPeak_Time_rms->
SetBinContent(cscPosition, cscType + 1 ,cellpeak_time_rms);
1604 const int a = N_CFEBs * N_Strips;
1605 const int b = a * N_Samples;
1606 float Cathodes[b * N_Layers];
1607 for(
int i = 0;
i < N_Layers; ++
i) {
1608 const int b1 =
i *
b;
1609 for(
int j = 0;
j <
a; ++
j) {
1610 const int b2 = b1 +
j;
1611 for(
int k = 0;
k < N_Samples; ++
k) {
1612 Cathodes[b2 + a *
k] = cscdata[
j][
k][
i];
1617 std::vector<StripCluster> Clus;
1621 for(
int nLayer = 1; nLayer <= N_Layers; ++nLayer) {
1625 ClusterFinder.
DoAction(nLayer - 1, Cathodes);
1630 if (
getCSCHisto(h::CSC_CFEB_NUMBER_OF_CLUSTERS_LY_XX, crateID, dmbID, nLayer, mo)) {
1633 mo->
Fill(Clus.size());
1636 for(uint32_t u = 0; u < Clus.size(); u++){
1638 Clus_Sum_Charge = 0.0;
1640 for(uint32_t
k = 0;
k < Clus[u].ClusterPulseMapHeight.size();
k++) {
1644 for(
int n = Clus[u].LFTBNDTime;
n < Clus[u].IRTBNDTime;
n++) {
1645 Clus_Sum_Charge = Clus_Sum_Charge + Clus[u].ClusterPulseMapHeight[
k].height_[
n];
1651 if (
getCSCHisto(h::CSC_CFEB_CLUSTERS_CHARGE_LY_XX, crateID, dmbID, nLayer, mo)) {
1652 mo->
Fill(Clus_Sum_Charge);
1656 if (
getCSCHisto(h::CSC_CFEB_WIDTH_OF_CLUSTERS_LY_XX, crateID, dmbID, nLayer, mo)) {
1657 mo->
Fill(Clus[u].IRTBNDStrip - Clus[u].LFTBNDStrip + 1);
1661 if (
getCSCHisto(h::CSC_CFEB_CLUSTER_DURATION_LY_XX, crateID, dmbID, nLayer, mo)) {
1662 mo->
Fill(Clus[u].IRTBNDTime - Clus[u].LFTBNDTime + 1);
1675 if (
getCSCHisto(h::CSC_DMB_FEB_COMBINATIONS_UNPACKED_VS_DAV, crateID, dmbID, mo)) {
1676 float feb_combination_unpacked = -1.0;
1677 if(alct_unpacked == 0 && tmb_unpacked == 0 && cfeb_unpacked == 0) feb_combination_unpacked = 0.0;
1678 if(alct_unpacked > 0 && tmb_unpacked == 0 && cfeb_unpacked == 0) feb_combination_unpacked = 1.0;
1679 if(alct_unpacked == 0 && tmb_unpacked > 0 && cfeb_unpacked == 0) feb_combination_unpacked = 2.0;
1680 if(alct_unpacked == 0 && tmb_unpacked == 0 && cfeb_unpacked > 0) feb_combination_unpacked = 3.0;
1681 if(alct_unpacked > 0 && tmb_unpacked > 0 && cfeb_unpacked == 0) feb_combination_unpacked = 4.0;
1682 if(alct_unpacked > 0 && tmb_unpacked == 0 && cfeb_unpacked > 0) feb_combination_unpacked = 5.0;
1683 if(alct_unpacked == 0 && tmb_unpacked > 0 && cfeb_unpacked > 0) feb_combination_unpacked = 6.0;
1684 if(alct_unpacked > 0 && tmb_unpacked > 0 && cfeb_unpacked > 0) feb_combination_unpacked = 7.0;
1685 mo->
Fill(feb_combination_dav, feb_combination_unpacked);
1688 if((clct_kewdistrip > -1 && alct_keywg > -1) && (
getCSCHisto(h::CSC_CLCT0_KEYDISTRIP_VS_ALCT0_KEYWIREGROUP, crateID, dmbID, mo))) {
1689 mo->
Fill(alct_keywg, clct_kewdistrip);
1692 if (L1A_out_of_sync && cscType && cscPosition &&
getEMUHisto(h::EMU_CSC_L1A_OUT_OF_SYNC, mo)){
1693 mo->
Fill(cscPosition, cscType);
1696 if (L1A_out_of_sync &&
getEMUHisto(h::EMU_DMB_L1A_OUT_OF_SYNC, mo)){
1697 mo->
Fill(crateID, dmbID);
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
const unsigned long getNEvents() 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
bool isChamberStandby(unsigned int side, unsigned int station, unsigned int ring, unsigned int chamber) const
Check if chamber is in standby?
unsigned short adcOverflow
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
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.
const std::string getPath() const
Get path part of the histogram (used only for DDUs and CSCs)
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...
virtual const TH1 * getTH1(void) const =0
CSCAnodeData * alctData() const
user must check if nalct > 0
virtual const int GetMaximumBin()=0
virtual void SetNormFactor(const double factor=1)=0
CSCALCTHeader * alctHeader() const
user must check if nalct > 0
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
uint32_t rawId() const
get the raw id
U second(std::pair< T, U > const &p)
CSCCLCTData * clctData() const
user must check if nclct > 0
CSCALCTTrailer * alctTrailer() const
user must check if nalct > 0
virtual TH1 * getTH1Lock(void)=0
unsigned get_lctpipe_empty() const
unsigned cfeb_starttimeout
virtual void SetBinContent(const int binX, const double value)=0
CSCTMBData * tmbData() const
user must check in nclct > 0
boost::function< bool(const unsigned int, const unsigned int, CSCDetId &) > fnGetCSCDetId
CSCDetId chamberID(const CSCDetId &cscDetId)
takes layer ID, converts to chamber ID, switching ME1A to ME11
void setChamberCounterValue(const ChamberCounterType counter, const HwId crateId, const HwId dmbId, const uint32_t value)
Set Chamber counter value.
const Detector getDetector() 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 get_l1pipe_empty() 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
const uint32_t getChamberCounterValue(const ChamberCounterType counter, const HwId crateId, const HwId dmbId) const
Get Chamber counter value.
CSCCFEBTimeSlice const *const timeSlice(T const &data, int nCFEB, int nSample)
void copyChamberCounterValue(const ChamberCounterType counter_from, const ChamberCounterType counter_to, const HwId crateId, const HwId dmbId)
Copy Chamber counter value from one counter to another.
CSCTMBHeader * tmbHeader()
virtual double GetBinContent(const int binX)=0
char data[epos_bytes_allocation]
CSCCFEBDataWord const *const timeSample(T const &data, int nCFEB, int nSample, int nLayer, int nStrip)
CSCCFEBData * cfebData(unsigned icfeb) const
unpacked in long mode: has overflow and error bits decoded
void resetEmuEventDisplays()
Reset Emu level EventDisplay histograms once per event.
bool fCloseL1As
Total Number of TMBs per event from DMB DAV.
unsigned int GlobalChamberIndex(unsigned int side, unsigned int station, unsigned int ring, unsigned int chamber) const
Return global chamber index on his geometric location.
bool EmuEventDisplayWasReset
const bool getEMUHisto(const HistoId &histo, MonitorObject *&me)
Get EMU (Top Level) Monitoring Object.
const CSCDMBHeader * dmbHeader() const
the DAQ motherboard header. A good place for event and chamber info
unsigned get_lctpipe_count() const
unsigned get_lctpipe_full() const