58 ATH_MSG_DEBUG(
"MistimedStreamMonitorAlgorith::fillHistograms");
65 ATH_MSG_DEBUG(
"RunParameters:: readoutConfigID " << readoutConfigID);
69 unsigned int channelID = 0;
70 unsigned int numFadcSlices = 0;
71 unsigned int l1aFadcSlice = 0;
72 unsigned int readout80ModePpm = 0;
91 return StatusCode::FAILURE;
98 return StatusCode::FAILURE;
103 if(!triggerTowerTES.
isValid()){
105 return StatusCode::FAILURE;
110 unsigned int currentRunNo = ctx.eventID().run_number();
111 unsigned int currentEventNo = ctx.eventID().event_number();
125 if(readout80ModePpm){
126 if(numFadcSlices < 9){
127 ATH_MSG_DEBUG(
"Number of ADC slices < 9 for 80 MHz readout, algorithm cannot run, aborting...");
128 return StatusCode::SUCCESS;
130 if(l1aFadcSlice < 4){
131 ATH_MSG_DEBUG(
"L1a readout pointer < 4 for 80 MHz readout, algorithm cannot run, aborting...");
132 return StatusCode::SUCCESS;
134 if(numFadcSlices - l1aFadcSlice < 4){
135 ATH_MSG_DEBUG(
"L1a readout pointer is at "<< l1aFadcSlice <<
" with "<< numFadcSlices <<
"slices at 80 MHz readout mode, algorithm cannot run, aborting...");
136 return StatusCode::SUCCESS;
140 if(numFadcSlices < 5){
141 ATH_MSG_DEBUG(
"Number of ADC slices < 5 for 40 MHz readout, algorithm cannot run, aborting...");
142 return StatusCode::SUCCESS;
144 if(l1aFadcSlice < 2){
145 ATH_MSG_DEBUG(
"L1a readout pointer < 2 for 40 MHz readout, algorithm cannot run, aborting...");
146 return StatusCode::SUCCESS;
148 if(numFadcSlices - l1aFadcSlice < 2){
149 ATH_MSG_DEBUG(
"L1a readout pointer is at "<< l1aFadcSlice <<
" with "<< numFadcSlices <<
"slices at 40 MHz readout mode, algorithm cannot run, aborting...");
150 return StatusCode::SUCCESS;
157 if(! (
m_trigDec->isPassed(
"HLT_mistimemonj400_L1All",TrigDefs::requireDecision))){
158 ATH_MSG_DEBUG(
"TrigDec don't pass HLT_mistimemonj400_L1All");
159 return StatusCode::SUCCESS;
168 if(! ( (
m_trigDec->isPassed(
"L1_eEM26M")) or
169 (
m_trigDec->isPassed(
"L1_gLJ140p0ETA25")) or
170 (
m_trigDec->isPassed(
"L1_gJ400p0ETA25")) or
175 return StatusCode::SUCCESS;
182 return StatusCode::SUCCESS;
188 return StatusCode::FAILURE;
192 bool legacyTrigger=
false;
193 bool phase1Trigger=
false;
194 std::string trigger =
"";
208 if ( (
m_trigDec->isPassed(
"L1_gJ400p0ETA25")) or (
m_trigDec->isPassed(
"L1_gLJ140p0ETA25")) ) {
219 int good3Counter = 0;
220 int good2Counter = 0;
221 int eFexintimeCounter = 0;
222 int eFexoutoftimeCounter = 0;
226 double dEta = 0.,
dPhi = 0., dPhi1 = 0., dR = 0.;
227 double etaIn = 0., phiIn = 0., etIn = 0.;
228 double etaOut = 0., phiOut = 0., etOut = 0.;
229 bool overlap =
false;
232 if(!jFexSRJetContainer.isValid()) {
241 std::unique_ptr<xAOD::TriggerTowerContainer> ttContainer = std::make_unique<xAOD::TriggerTowerContainer>();
242 std::unique_ptr<xAOD::TriggerTowerAuxContainer> ttContainerAux = std::make_unique<xAOD::TriggerTowerAuxContainer>();
243 ttContainer->setStore(ttContainerAux.get());
250 float ttPulseCategory = 0;
251 const std::vector<uint16_t>& ttADC = (
tt)->
adc();
252 std::vector<uint16_t> readoutCorrectedADC;
253 if(!readout80ModePpm){
255 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-2));
256 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-1));
257 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice));
258 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+1));
259 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+2));
262 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-4));
263 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-2));
264 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice));
265 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+2));
266 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+4));
270 auto maxValIterator = std::max_element(readoutCorrectedADC.begin(), readoutCorrectedADC.end());
271 int maxADCval = *maxValIterator;
275 ttPulseCategory = 0.1;
277 else if(maxADCval == 1023) {
281 bool goodQual =
pulseQuality(readoutCorrectedADC, adcPeakPositon);
283 if(adcPeakPositon == 2){
294 else if(adcPeakPositon == 3){
310 if (trigger ==
"jFex") {
316 etIn = tob->tobEt()/5;
318 if( (adcPeakPositon == 3) and (goodQual) ) {
321 dEta = std::abs(etaIn-etaOut);
322 dPhi = std::abs(phiIn-phiOut);
323 if ((phiIn < 0) and (phiOut > 0)){
324 dPhi1 = std::abs((phiIn+2*
M_PI)-phiOut);
329 else if ((phiIn > 0) and (phiOut < 0)){
330 dPhi1 = std::abs(phiIn-(phiOut+2*
M_PI));
336 if ((dR < .2) and (etIn > 160.)) {
343 if (trigger ==
"gFex") {
348 if ( !jetContainer.
isValid() ) {
357 etIn = tob->gFexTobEt()/10;
359 if( (adcPeakPositon == 3) and (goodQual) ) {
362 dEta = std::abs(etaIn-etaOut);
363 dPhi = std::abs(phiIn-phiOut);
364 if ((phiIn < 0) and (phiOut > 0)){
365 dPhi1 = std::abs((phiIn+2*
M_PI)-phiOut);
370 else if ((phiIn > 0) and (phiOut < 0)){
371 dPhi1 = std::abs(phiIn-(phiOut+2*
M_PI));
377 if ((dR < .2) and (etIn > 100.)) {
392 pulseClassificationAcc(*newTT) = ttPulseCategory;
396 for(
auto key : {
"L1_eEMxRoI",
"L1_eEMxRoIOutOfTime"}) {
401 for(
auto tob : *emTobs) {
402 if (tob->et() > 5000) {
403 if (tob->bcn4() == ((ctx.eventID().bunch_crossing_id()) & 0xf )) {
406 else if (tob->bcn4() == (((ctx.eventID().bunch_crossing_id())+1) & 0xf )) {
407 eFexoutoftimeCounter++;
417 for(
auto tob : *gFexLRJetRoI) {
418 if (tob->et() > 50) {
426 for(
auto tob : *jFexJetRoI) {
427 if (tob->et() > 25) {
432 if( (good3Counter < 2) or ((trigger ==
"eFex") and (eFexoutoftimeCounter < 2)) ){
434 return StatusCode::SUCCESS;
439 if( (good2Counter > 3) or
440 ((trigger ==
"eFex") and (eFexintimeCounter > 3)) or
441 ((trigger ==
"jFex") and (jFexCounter > 3)) or
442 ((trigger ==
"gFex") and (gFexCounter > 3)) ){
444 return StatusCode::SUCCESS;
449 if (trigger ==
"eFex") {
455 for(
auto tob : *emTobs) {
458 etIn = tob->et()/1000;
460 for(
auto tobOut : *emTobsOut) {
461 etaOut = tobOut->eta();
462 phiOut = tobOut->phi();
463 etOut = tobOut->et()/1000;
465 dEta = std::abs(etaIn-etaOut);
466 dPhi = std::abs(phiIn-phiOut);
467 if ((phiIn < 0) and (phiOut > 0)){
468 dPhi1 = std::abs((phiIn+2*
M_PI)-phiOut);
473 else if ((phiIn > 0) and (phiOut < 0)){
474 dPhi1 = std::abs(phiIn-(phiOut+2*
M_PI));
480 if ((dR < .2) and (etIn > 26.) and (etOut > 26.)){
487 if ((legacyTrigger) and !(phase1Trigger)){
493 return StatusCode::SUCCESS;
502 m_event_counter[lumiNo]+=1;
521 std::vector<MonitorTT> vecMonTTDecor;
527 ATH_MSG_DEBUG(
"tt->pulseClassification :: " << pulseClassificationAcc(*
tt));
534 for (
auto& myTower : vecMonTTDecor) {
537 pulseCat = pulseClassificationAcc(*myTower.tower);
538 bcidWord = (myTower.tower)->bcidVec()[0];
544 if(pulseCat > 0.5 && bcidWord > 0) {
548 else if(
layer == 1 ) {
556 std::vector<MonitorCPM> vecMonCPM;
574 for (
auto& myTower : vecMonCPM) {
576 std::vector<uint8_t> cpmEMenergy = (myTower.tower)->emEnergyVec();
577 std::vector<uint8_t> cpmHADenergy = (myTower.tower)->hadEnergyVec();
579 etalut = myTower.etaScaled;
581 for (
auto phi: myTower.phiScaled) {
585 if(cpmEMenergy.size() > 2){
586 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)));
588 emLUT0 =
static_cast<int>(cpmEMenergy.at(0));
589 if(cpmEMenergy.at(0) > 0)
fill(
groupName+
"lut_EM0",etalut,philut, emLUT0);
591 emLUT1 =
static_cast<int>(cpmEMenergy.at(1));
592 if(cpmEMenergy.at(1) > 0)
fill(
groupName+
"lut_EM1",etalut,philut, emLUT1);
594 emLUT2 =
static_cast<int>(cpmEMenergy.at(2));
595 if(cpmEMenergy.at(2) > 0)
fill(
groupName+
"lut_EM2",etalut,philut, emLUT2);
597 if(cpmHADenergy.size() > 2){
598 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)));
600 hadLUT0 =
static_cast<int>(cpmHADenergy.at(0));
601 if(cpmHADenergy.at(0) > 0)
fill(
groupName+
"lut_HAD0",etalut,philut, hadLUT0);
602 hadLUT1 =
static_cast<int>(cpmHADenergy.at(1));
603 if(cpmHADenergy.at(1) > 0)
fill(
groupName+
"lut_HAD1",etalut,philut, hadLUT1);
604 hadLUT2 =
static_cast<int>(cpmHADenergy.at(2));
605 if(cpmHADenergy.at(2) > 0)
fill(
groupName+
"lut_HAD2",etalut,philut, hadLUT2);
610 std::vector<MonitorJE> vecMonJE;
618 for (
auto&
jet : vecMonJE) {
620 std::vector<uint16_t> jepEMenergy = (
jet.element)->emJetElementETVec();
621 std::vector<uint16_t> jepHADenergy = (
jet.element)->hadJetElementETVec();
623 for (
auto eta:
jet.etaScaled) {
625 if ( std::abs(
eta) > 2.5){
626 for (
auto phi:
jet.phiScaled) {
628 if(jepEMenergy.size() > 2){
629 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)));
631 emLUT0 =
static_cast<int>(jepEMenergy.at(0));
632 if(jepEMenergy.at(0) > 0)
fill(
groupName+
"lut_EM0",etalut,philut, emLUT0);
634 emLUT1 =
static_cast<int>(jepEMenergy.at(1));
635 if(jepEMenergy.at(1) > 0)
fill(
groupName+
"lut_EM1",etalut,philut, emLUT1);
637 emLUT2 =
static_cast<int>(jepEMenergy.at(2));
638 if(jepEMenergy.at(2) > 0)
fill(
groupName+
"lut_EM2",etalut,philut, emLUT2);
640 if(jepHADenergy.size()> 2){
641 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)));
643 hadLUT0 =
static_cast<int>(jepHADenergy.at(0));
644 if(jepHADenergy.at(0) > 0)
fill(
groupName+
"lut_HAD0",etalut,philut, hadLUT0);
646 hadLUT1 =
static_cast<int>(jepHADenergy.at(1));
647 if(jepHADenergy.at(1) > 0)
fill(
groupName+
"lut_HAD1",etalut,philut, hadLUT1);
649 hadLUT2 =
static_cast<int>(jepHADenergy.at(2));
650 if(jepHADenergy.at(2) > 0)
fill(
groupName+
"lut_HAD2",etalut,philut, hadLUT2);
658 if ( !eFexContainer.
isValid() ) {
676 for(
auto key : {
"L1_eEMxRoI",
"L1_eEMxRoIOutOfTime"}) {
681 for(
auto tob : *emTobs) {
682 TOBeT = tob->et()/1000;
686 if (tob->phi() < 0) {
687 TOBphi = tob->phi()+2*
M_PI;
694 if (tob->bcn4() == (((ctx.eventID().bunch_crossing_id())-1) & 0xf )) {
699 else if (tob->bcn4() == ((ctx.eventID().bunch_crossing_id()) & 0xf )) {
701 if (TOBeT_max_in < TOBeT) {
702 TOBeT_max_in = tob->et()/1000;
703 TOBeta_max_in = tob->eta();
704 if (tob->phi() < 0) {
705 TOBphi_max_in = tob->phi()+2*
M_PI;
708 TOBphi_max_in = tob->phi();
714 else if (tob->bcn4() == (((ctx.eventID().bunch_crossing_id())+1) & 0xf )) {
716 if (TOBeT_max < TOBeT) {
717 TOBeT_max = tob->et()/1000;
718 TOBeta_max = tob->eta();
719 if (tob->phi() < 0) {
720 TOBphi_max = tob->phi()+2*
M_PI;
723 TOBphi_max = tob->phi();
731 if (trigger ==
"eFex") {
732 fill(
"Efex_maxTOB_in", TOBeT_max_in);
733 fill(
"Efex_maxTOB_out", TOBeT_max);
734 fill(
"Efex_maxTOB_out", TOBeta_max, TOBphi_max);
735 fill(
"Efex_maxTOB_in", TOBeta_max_in, TOBphi_max_in);
752 if(!jEmulatedTowerContainer.
isValid()) {
753 ATH_MSG_WARNING(
"No jFex Tower container valid in storegate with key: "<< jEmulatedTowerContainer.
key()<<
". Will be skipped!");
757 jFexEt=emulTower->et_count().at(0);
759 jFexeta=emulTower->eta()+1
e-5;
760 if (emulTower->phi() < 0) {
761 jFexphi=emulTower->phi()+2*
M_PI;
764 jFexphi=emulTower->phi();
783 if (TOBeT_max < jFexEt) {
795 if (trigger ==
"jFex") {
796 fill(
"Jfex_maxTOB", TOBeT_max);
797 fill(
"Jfex_maxTOB", TOBeta_max, TOBphi_max);
801 if(!jFexTauContainer.isValid()) {
829 if ( !jetContainer.
isValid() ) {
842 if (TOBeT_max < gFexEt) {
852 if (key_index == 0) {
855 else if (key_index == 1) {
862 if (trigger ==
"gFex") {
863 fill(
"Gfex_maxTOB", TOBeT_max);
864 fill(
"Gfex_maxTOB", TOBeta_max, TOBphi_max);
873 fill(
"Event_all_", eventMonitor_all_legacy, lbMonitor_all );
876 fill(
"Event_all_", eventMonitor_all_phaseI, lbMonitor_all );
880 if ( !eFexContainer.
isValid() ) {
898 for(
auto key : {
"L1_eEMxRoI",
"L1_eEMxRoIOutOfTime"}) {
903 for(
auto tob : *emTobs) {
904 TOBeT = tob->et()/1000;
908 if (tob->phi() < 0) {
909 TOBphi = tob->phi()+2*
M_PI;
915 if (tob->bcn4() == ((ctx.eventID().bunch_crossing_id()) & 0xf )) {
917 if (TOBeT_max_in < TOBeT) {
918 TOBeT_max_in = tob->et()/1000;
919 TOBeta_max_in = tob->eta();
920 if (tob->phi() < 0) {
921 TOBphi_max_in = tob->phi()+2*
M_PI;
924 TOBphi_max_in = tob->phi();
929 else if (tob->bcn4() == (((ctx.eventID().bunch_crossing_id())+1) & 0xf )) {
931 if (TOBeT_max < TOBeT) {
932 TOBeT_max = tob->et()/1000;
933 TOBeta_max = tob->eta();
934 if (tob->phi() < 0) {
935 TOBphi_max = tob->phi()+2*
M_PI;
938 TOBphi_max = tob->phi();
945 if (trigger ==
"eFex") {
946 fill(
"Efex_maxTOB_in", TOBeT_max_in);
947 fill(
"Efex_maxTOB_out", TOBeT_max);
948 fill(
"Efex_maxTOB_out", TOBeta_max, TOBphi_max);
949 fill(
"Efex_maxTOB_in", TOBeta_max_in, TOBphi_max_in);
974 if (TOBeT_max < jFexEt) {
985 if (trigger ==
"jFex") {
986 fill(
"Jfex_maxTOB", TOBeT_max);
987 fill(
"Jfex_maxTOB", TOBeta_max, TOBphi_max);
999 if ( !jetContainer.
isValid() ) {
1012 if (TOBeT_max < gFexEt) {
1025 if (trigger ==
"gFex") {
1026 fill(
"Gfex_maxTOB", TOBeT_max);
1027 fill(
"Gfex_maxTOB", TOBeta_max, TOBphi_max);
1032 return StatusCode::SUCCESS;
1037 std::vector<MonitorTT> &vecMonTT)
const
1040 const double phi =
tt->phi();
1050 vecMonTT.push_back(monTT);
1052 return StatusCode::SUCCESS;
1057 std::vector<MonitorCPM> &vecMonCPM)
const
1060 const double phi = cpm->
phi();
1071 const std::vector<double> offset32 = {1.5, 0.5, -0.5, -1.5};
1072 const std::vector<double> offset25 = {0.5, -0.5};
1073 std::vector<double>
offset = {};
1077 phiMod = std::floor(phiMod/4)*4. + 2.;
1082 phiMod = std::floor(phiMod/2)*2. + 1.;
1092 for (
auto phiOffset :
offset) {
1093 monCPM.
phiScaled.push_back(phiMod + phiOffset);
1099 vecMonCPM.push_back(monCPM);
1101 return StatusCode::SUCCESS;
1105 std::vector<MonitorJE> &vecMonJE)
const
1111 const double phi = je->
phi();
1121 if(
etaMod < 0) signeta = -1;
1124 const std::vector<double> offset32 = {1.5, 0.5, -0.5, -1.5};
1125 const std::vector<double> offset25 = {0.5, -0.5};
1126 std::vector<double>
offset = {};
1130 phiMod = std::floor(phiMod/4)*4. + 2.;
1138 phiMod = std::floor(phiMod/2)*2. + 1.;
1140 monJE.
etaScaled.push_back(signeta*3.15);
1146 phiMod = std::floor(phiMod/2)*2. + 1.;
1157 for (
auto phiOffset :
offset) {
1158 monJE.
phiScaled.push_back(phiMod + phiOffset);
1161 vecMonJE.push_back(monJE);
1163 return StatusCode::SUCCESS;
1169 const std::string& weightName,
1177 const std::vector<double> offset32 = {1.5, 0.5, -0.5, -1.5};
1178 const std::vector<double> offset25 = {0.5, -0.5};
1179 std::vector<double>
offset = {};
1183 phiMod = std::floor(phiMod/4)*4. + 2.;
1188 phiMod = std::floor(phiMod/2)*2. + 1.;
1198 for (
auto phiOffset :
offset) {
1210 return StatusCode::SUCCESS;
1216 bool goodPulse =
true;
1217 int size = ttPulse.size();
1218 if (peakSlice >
size) {
1219 ATH_MSG_ERROR(
"Peak Slice " << peakSlice <<
" supress the ttPulse vector size " <<
size );
1224 ATH_MSG_ERROR(
"The ttPulse vector size " <<
size <<
" not valid for Peak Slice " << peakSlice );
1228 int a = ttPulse[peakSlice-1];
1229 int b = ttPulse[peakSlice];
1230 int c = ttPulse[peakSlice+1];
1231 double tim = (0.5*
a-0.5*
c)/(
a+
c-2*
b);
1232 double wid = (
a+
c-64.0)/(
b-32.0);
1233 if ( tim < 0.0 ) goodPulse =
false;
1234 else if ( tim > 0.3 ) goodPulse =
false;
1235 if ( wid < 1.0 ) goodPulse =
false;
1236 else if ( wid > 1.6 ) goodPulse =
false;
1238 ATH_MSG_DEBUG(
"Pulse qual= "<< goodPulse<<
" tim = "<<tim<<
" wid = "<<wid);