57 ATH_MSG_DEBUG(
"MistimedStreamMonitorAlgorith::fillHistograms");
64 ATH_MSG_DEBUG(
"RunParameters:: readoutConfigID " << readoutConfigID);
68 unsigned int channelID = 0;
69 unsigned int numFadcSlices = 0;
70 unsigned int l1aFadcSlice = 0;
71 unsigned int readout80ModePpm = 0;
90 return StatusCode::FAILURE;
97 return StatusCode::FAILURE;
102 if(!triggerTowerTES.
isValid()){
104 return StatusCode::FAILURE;
109 unsigned int currentRunNo = ctx.eventID().run_number();
110 unsigned int currentEventNo = ctx.eventID().event_number();
124 if(readout80ModePpm){
125 if(numFadcSlices < 9){
126 ATH_MSG_DEBUG(
"Number of ADC slices < 9 for 80 MHz readout, algorithm cannot run, aborting...");
127 return StatusCode::SUCCESS;
129 if(l1aFadcSlice < 4){
130 ATH_MSG_DEBUG(
"L1a readout pointer < 4 for 80 MHz readout, algorithm cannot run, aborting...");
131 return StatusCode::SUCCESS;
133 if(numFadcSlices - l1aFadcSlice < 4){
134 ATH_MSG_DEBUG(
"L1a readout pointer is at "<< l1aFadcSlice <<
" with "<< numFadcSlices <<
"slices at 80 MHz readout mode, algorithm cannot run, aborting...");
135 return StatusCode::SUCCESS;
139 if(numFadcSlices < 5){
140 ATH_MSG_DEBUG(
"Number of ADC slices < 5 for 40 MHz readout, algorithm cannot run, aborting...");
141 return StatusCode::SUCCESS;
143 if(l1aFadcSlice < 2){
144 ATH_MSG_DEBUG(
"L1a readout pointer < 2 for 40 MHz readout, algorithm cannot run, aborting...");
145 return StatusCode::SUCCESS;
147 if(numFadcSlices - l1aFadcSlice < 2){
148 ATH_MSG_DEBUG(
"L1a readout pointer is at "<< l1aFadcSlice <<
" with "<< numFadcSlices <<
"slices at 40 MHz readout mode, algorithm cannot run, aborting...");
149 return StatusCode::SUCCESS;
156 if(! (
m_trigDec->isPassed(
"HLT_mistimemonj400_L1All",TrigDefs::requireDecision))){
157 ATH_MSG_DEBUG(
"TrigDec don't pass HLT_mistimemonj400_L1All");
158 return StatusCode::SUCCESS;
166 if(! ( (
m_trigDec->isPassed(
"L1_J100")) or
169 (
m_trigDec->isPassed(
"L1_gJ100p0ETA25")) or
170 (
m_trigDec->isPassed(
"L1_gJ400p0ETA25")) or
174 return StatusCode::SUCCESS;
178 std::string
trigger=
"legacy";;
186 else if ( (
m_trigDec->isPassed(
"L1_gJ400p0ETA25")) or (
m_trigDec->isPassed(
"L1_gJ100p0ETA25")) ) {
198 int good3Counter = 0;
199 int good2Counter = 0;
200 int eFexintimeCounter = 0;
201 int eFexoutoftimeCounter = 0;
204 int emActivityCounter = 0;
211 std::unique_ptr<xAOD::TriggerTowerContainer> ttContainer = std::make_unique<xAOD::TriggerTowerContainer>();
212 std::unique_ptr<xAOD::TriggerTowerAuxContainer> ttContainerAux = std::make_unique<xAOD::TriggerTowerAuxContainer>();
213 ttContainer->setStore(ttContainerAux.get());
220 float ttPulseCategory = 0;
221 const std::vector<uint16_t>& ttADC = (
tt)->
adc();
222 std::vector<uint16_t> readoutCorrectedADC;
223 if(!readout80ModePpm){
225 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-2));
226 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-1));
227 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice));
228 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+1));
229 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+2));
232 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-4));
233 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-2));
234 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice));
235 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+2));
236 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+4));
240 auto maxValIterator = std::max_element(readoutCorrectedADC.begin(), readoutCorrectedADC.end());
241 int maxADCval = *maxValIterator;
245 ttPulseCategory = 0.1;
247 else if(maxADCval == 1023) {
249 if(! (
tt)->
layer()) emActivityCounter++;
252 bool goodQual =
pulseQuality(readoutCorrectedADC, adcPeakPositon);
253 if(! (
tt)->
layer()) emActivityCounter++;
255 if(adcPeakPositon == 2){
267 else if(adcPeakPositon == 3){
290 pulseClassificationAcc(*newTT) = ttPulseCategory;
294 for(
auto key : {
"L1_eEMxRoI",
"L1_eEMxRoIOutOfTime"}) {
299 for(
auto tob : *emTobs) {
300 if (tob->et() > 5000) {
301 if (tob->bcn4() == ((ctx.eventID().bunch_crossing_id()) & 0xf )) {
304 else if (tob->bcn4() == (((ctx.eventID().bunch_crossing_id())+1) & 0xf )) {
305 eFexoutoftimeCounter++;
315 for(
auto tob : *gFexLRJetRoI) {
316 if (tob->et() > 50) {
324 for(
auto tob : *jFexJetRoI) {
325 if (tob->et() > 25) {
332 return StatusCode::SUCCESS;
339 return StatusCode::SUCCESS;
346 return StatusCode::SUCCESS;
351 if( (good3Counter < 2) or ((
trigger ==
"eFex") and (eFexoutoftimeCounter < 2)) ){
353 return StatusCode::SUCCESS;
358 if( (good2Counter > 3) or
359 ((
trigger ==
"eFex") and (eFexintimeCounter > 3)) or
360 ((
trigger ==
"jFex") and (jFexCounter > 3)) or
361 ((
trigger ==
"gFex") and (gFexCounter > 3)) ){
363 return StatusCode::SUCCESS;
368 if(!emActivityCounter){
370 return StatusCode::SUCCESS;
375 double dEta = 0.,
dPhi = 0., dPhi1 = 0., dR = 0.;
376 double etaIn = 0., phiIn = 0;
377 double etaOut = 0., phiOut = 0;
378 bool overlap =
false;
386 for(
auto tob : *emTobs) {
390 for(
auto tobOut : *emTobsOut) {
391 etaOut = tobOut->eta();
392 phiOut = tobOut->phi();
393 dEta = std::abs(etaIn-etaOut);
394 dPhi = std::abs(phiIn-phiOut);
395 if ((phiIn < 0) and (phiOut > 0)){
396 dPhi1 = std::abs((phiIn+2*
M_PI)-phiOut);
401 else if ((phiIn > 0) and (phiOut < 0)){
402 dPhi1 = std::abs(phiIn-(phiOut+2*
M_PI));
416 if(!jFexSRJetContainer.isValid()) {
428 const std::vector<uint16_t>& ttADC = (
tt)->
adc();
429 std::vector<uint16_t> readoutCorrectedADC;
430 if(!readout80ModePpm){
432 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-2));
433 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-1));
434 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice));
435 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+1));
436 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+2));
440 auto maxValIterator = std::max_element(readoutCorrectedADC.begin(), readoutCorrectedADC.end());
442 bool goodQual =
pulseQuality(readoutCorrectedADC, adcPeakPositon);
444 if( (adcPeakPositon == 3) and (goodQual) ) {
447 dEta = std::abs(etaIn-etaOut);
448 dPhi = std::abs(phiIn-phiOut);
449 if ((phiIn < 0) and (phiOut > 0)){
450 dPhi1 = std::abs((phiIn+2*
M_PI)-phiOut);
455 else if ((phiIn > 0) and (phiOut < 0)){
456 dPhi1 = std::abs(phiIn-(phiOut+2*
M_PI));
486 const std::vector<uint16_t>& ttADC = (
tt)->
adc();
487 std::vector<uint16_t> readoutCorrectedADC;
488 if(!readout80ModePpm){
490 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-2));
491 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-1));
492 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice));
493 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+1));
494 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+2));
498 auto maxValIterator = std::max_element(readoutCorrectedADC.begin(), readoutCorrectedADC.end());
500 bool goodQual =
pulseQuality(readoutCorrectedADC, adcPeakPositon);
502 if( (adcPeakPositon == 3) and (goodQual) ) {
505 dEta = std::abs(etaIn-etaOut);
506 dPhi = std::abs(phiIn-phiOut);
507 if ((phiIn < 0) and (phiOut > 0)){
508 dPhi1 = std::abs((phiIn+2*
M_PI)-phiOut);
513 else if ((phiIn > 0) and (phiOut < 0)){
514 dPhi1 = std::abs(phiIn-(phiOut+2*
M_PI));
532 return StatusCode::SUCCESS;
540 std::lock_guard<std::mutex> lock(
m_mutex);
541 m_event_counter[lumiNo]+=1;
560 std::vector<MonitorTT> vecMonTTDecor;
566 ATH_MSG_DEBUG(
"tt->pulseClassification :: " << pulseClassificationAcc(*
tt));
573 for (
auto& myTower : vecMonTTDecor) {
576 pulseCat = pulseClassificationAcc(*myTower.tower);
577 bcidWord = (myTower.tower)->bcidVec()[0];
583 if(pulseCat > 0.5 && bcidWord > 0) {
587 else if(
layer == 1 ) {
595 std::vector<MonitorCPM> vecMonCPM;
613 for (
auto& myTower : vecMonCPM) {
615 std::vector<uint8_t> cpmEMenergy = (myTower.tower)->emEnergyVec();
616 std::vector<uint8_t> cpmHADenergy = (myTower.tower)->hadEnergyVec();
618 etalut = myTower.etaScaled;
620 for (
auto phi: myTower.phiScaled) {
624 if(cpmEMenergy.size() > 2){
625 ATH_MSG_DEBUG(
"CPM :: emLUT0 :: " <<
static_cast<unsigned>(cpmEMenergy.at(0)) <<
":: emLUT1 :: " <<
static_cast<unsigned>(cpmEMenergy.at(1)) <<
":: emLUT2 :: " <<
static_cast<unsigned>(cpmEMenergy.at(2)));
627 emLUT0 =
static_cast<int>(cpmEMenergy.at(0));
628 if(cpmEMenergy.at(0) > 0)
fill(
groupName+
"lut_EM0",etalut,philut, emLUT0);
630 emLUT1 =
static_cast<int>(cpmEMenergy.at(1));
631 if(cpmEMenergy.at(1) > 0)
fill(
groupName+
"lut_EM1",etalut,philut, emLUT1);
633 emLUT2 =
static_cast<int>(cpmEMenergy.at(2));
634 if(cpmEMenergy.at(2) > 0)
fill(
groupName+
"lut_EM2",etalut,philut, emLUT2);
636 if(cpmHADenergy.size() > 2){
637 ATH_MSG_DEBUG(
"CPM :: hadLUT0 :: " <<
static_cast<unsigned>(cpmHADenergy.at(0)) <<
":: hadLUT1 :: " <<
static_cast<unsigned>(cpmHADenergy.at(1)) <<
":: hadLUT2 :: " <<
static_cast<unsigned>(cpmHADenergy.at(2)));
639 hadLUT0 =
static_cast<int>(cpmHADenergy.at(0));
640 if(cpmHADenergy.at(0) > 0)
fill(
groupName+
"lut_HAD0",etalut,philut, hadLUT0);
641 hadLUT1 =
static_cast<int>(cpmHADenergy.at(1));
642 if(cpmHADenergy.at(1) > 0)
fill(
groupName+
"lut_HAD1",etalut,philut, hadLUT1);
643 hadLUT2 =
static_cast<int>(cpmHADenergy.at(2));
644 if(cpmHADenergy.at(2) > 0)
fill(
groupName+
"lut_HAD2",etalut,philut, hadLUT2);
649 std::vector<MonitorJE> vecMonJE;
657 for (
auto&
jet : vecMonJE) {
659 std::vector<uint16_t> jepEMenergy = (
jet.element)->emJetElementETVec();
660 std::vector<uint16_t> jepHADenergy = (
jet.element)->hadJetElementETVec();
662 for (
auto eta:
jet.etaScaled) {
664 if ( std::abs(
eta) > 2.5){
665 for (
auto phi:
jet.phiScaled) {
667 if(jepEMenergy.size() > 2){
668 ATH_MSG_DEBUG(
"JetElement :: emLUT0 :: " <<
static_cast<unsigned>(jepEMenergy.at(0)) <<
":: emLUT1 :: " <<
static_cast<unsigned>(jepEMenergy.at(1)) <<
":: emLUT2 :: " <<
static_cast<unsigned>(jepEMenergy.at(2)));
670 emLUT0 =
static_cast<int>(jepEMenergy.at(0));
671 if(jepEMenergy.at(0) > 0)
fill(
groupName+
"lut_EM0",etalut,philut, emLUT0);
673 emLUT1 =
static_cast<int>(jepEMenergy.at(1));
674 if(jepEMenergy.at(1) > 0)
fill(
groupName+
"lut_EM1",etalut,philut, emLUT1);
676 emLUT2 =
static_cast<int>(jepEMenergy.at(2));
677 if(jepEMenergy.at(2) > 0)
fill(
groupName+
"lut_EM2",etalut,philut, emLUT2);
679 if(jepHADenergy.size()> 2){
680 ATH_MSG_DEBUG(
"JetElement :: hadLUT0 :: " <<
static_cast<unsigned>(jepHADenergy.at(0)) <<
":: hadLUT1 :: " <<
static_cast<unsigned>(jepHADenergy.at(1)) <<
":: hadLUT2 :: " <<
static_cast<unsigned>(jepHADenergy.at(2)));
682 hadLUT0 =
static_cast<int>(jepHADenergy.at(0));
683 if(jepHADenergy.at(0) > 0)
fill(
groupName+
"lut_HAD0",etalut,philut, hadLUT0);
685 hadLUT1 =
static_cast<int>(jepHADenergy.at(1));
686 if(jepHADenergy.at(1) > 0)
fill(
groupName+
"lut_HAD1",etalut,philut, hadLUT1);
688 hadLUT2 =
static_cast<int>(jepHADenergy.at(2));
689 if(jepHADenergy.at(2) > 0)
fill(
groupName+
"lut_HAD2",etalut,philut, hadLUT2);
697 if ( !eFexContainer.
isValid() ) {
715 for(
auto key : {
"L1_eEMxRoI",
"L1_eEMxRoIOutOfTime"}) {
720 for(
auto tob : *emTobs) {
721 TOBeT = tob->et()/1000;
725 if (tob->phi() < 0) {
726 TOBphi = tob->phi()+2*
M_PI;
733 if (tob->bcn4() == (((ctx.eventID().bunch_crossing_id())-1) & 0xf )) {
738 else if (tob->bcn4() == ((ctx.eventID().bunch_crossing_id()) & 0xf )) {
740 if (TOBeT_max_in < TOBeT) {
741 TOBeT_max_in = tob->et()/1000;
742 TOBeta_max_in = tob->eta();
743 if (tob->phi() < 0) {
744 TOBphi_max_in = tob->phi()+2*
M_PI;
747 TOBphi_max_in = tob->phi();
752 fill(
"Efex_maxTOB_in", TOBeT);
756 else if (tob->bcn4() == (((ctx.eventID().bunch_crossing_id())+1) & 0xf )) {
758 if (TOBeT_max < TOBeT) {
759 TOBeT_max = tob->et()/1000;
760 TOBeta_max = tob->eta();
761 if (tob->phi() < 0) {
762 TOBphi_max = tob->phi()+2*
M_PI;
765 TOBphi_max = tob->phi();
770 fill(
"Efex_maxTOB_out", TOBeT);
777 fill(
"Efex_maxTOB_out", TOBeta_max, TOBphi_max);
778 fill(
"Efex_maxTOB_in", TOBeta_max_in, TOBphi_max_in);
795 if(!jEmulatedTowerContainer.
isValid()) {
796 ATH_MSG_WARNING(
"No jFex Tower container valid in storegate with key: "<< jEmulatedTowerContainer.
key()<<
". Will be skipped!");
800 jFexEt=emulTower->et_count().at(0);
802 jFexeta=emulTower->eta()+1
e-5;
803 if (emulTower->phi() < 0) {
804 jFexphi=emulTower->phi()+2*
M_PI;
807 jFexphi=emulTower->phi();
826 if (TOBeT_max < jFexEt) {
838 fill(
"Jfex_maxTOB", jFexEt);
842 fill(
"Jfex_maxTOB", TOBeta_max, TOBphi_max);
846 if(!jFexTauContainer.isValid()) {
887 if (TOBeT_max < gFexEt) {
897 if (key_index == 0) {
900 else if (key_index == 1) {
904 fill(
"Gfex_maxTOB", gFexEt);
911 fill(
"Gfex_maxTOB", TOBeta_max, TOBphi_max);
920 fill(
"Event_all_", eventMonitor_all_legacy, lbMonitor_all );
923 fill(
"Event_all_", eventMonitor_all_phaseI, lbMonitor_all );
927 return StatusCode::SUCCESS;
932 std::vector<MonitorTT> &vecMonTT)
const
935 const double phi =
tt->phi();
945 vecMonTT.push_back(monTT);
947 return StatusCode::SUCCESS;
952 std::vector<MonitorCPM> &vecMonCPM)
const
955 const double phi = cpm->
phi();
966 const std::vector<double> offset32 = {1.5, 0.5, -0.5, -1.5};
967 const std::vector<double> offset25 = {0.5, -0.5};
968 std::vector<double>
offset = {};
972 phiMod = std::floor(phiMod/4)*4. + 2.;
977 phiMod = std::floor(phiMod/2)*2. + 1.;
987 for (
auto phiOffset :
offset) {
988 monCPM.
phiScaled.push_back(phiMod + phiOffset);
994 vecMonCPM.push_back(monCPM);
996 return StatusCode::SUCCESS;
1000 std::vector<MonitorJE> &vecMonJE)
const
1006 const double phi = je->
phi();
1016 if(
etaMod < 0) signeta = -1;
1019 const std::vector<double> offset32 = {1.5, 0.5, -0.5, -1.5};
1020 const std::vector<double> offset25 = {0.5, -0.5};
1021 std::vector<double>
offset = {};
1025 phiMod = std::floor(phiMod/4)*4. + 2.;
1033 phiMod = std::floor(phiMod/2)*2. + 1.;
1035 monJE.
etaScaled.push_back(signeta*3.15);
1041 phiMod = std::floor(phiMod/2)*2. + 1.;
1052 for (
auto phiOffset :
offset) {
1053 monJE.
phiScaled.push_back(phiMod + phiOffset);
1056 vecMonJE.push_back(monJE);
1058 return StatusCode::SUCCESS;
1064 const std::string& weightName,
1072 const std::vector<double> offset32 = {1.5, 0.5, -0.5, -1.5};
1073 const std::vector<double> offset25 = {0.5, -0.5};
1074 std::vector<double>
offset = {};
1078 phiMod = std::floor(phiMod/4)*4. + 2.;
1083 phiMod = std::floor(phiMod/2)*2. + 1.;
1093 for (
auto phiOffset :
offset) {
1105 return StatusCode::SUCCESS;
1111 bool goodPulse =
true;
1112 int size = ttPulse.size();
1113 if (peakSlice >
size) {
1114 ATH_MSG_ERROR(
"Peak Slice " << peakSlice <<
" supress the ttPulse vector size " <<
size );
1117 int a = ttPulse[peakSlice-1];
1118 int b = ttPulse[peakSlice];
1119 int c = ttPulse[peakSlice+1];
1120 double tim = (0.5*
a-0.5*
c)/(
a+
c-2*
b);
1121 double wid = (
a+
c-64.0)/(
b-32.0);
1122 if ( tim < 0.0 ) goodPulse =
false;
1123 else if ( tim > 0.3 ) goodPulse =
false;
1124 if ( wid < 1.0 ) goodPulse =
false;
1125 else if ( wid > 1.6 ) goodPulse =
false;
1127 ATH_MSG_DEBUG(
"Pulse qual= "<< goodPulse<<
" tim = "<<tim<<
" wid = "<<wid);