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;
162 bool legacyHLT=
false, phase1HLT=
false;
170 if (currentRunNo < 472553){
171 legacyHLT = ((
ctp.getBunchCrossing(bcPos-1).getTBP().test(180)) or (
ctp.getBunchCrossing(bcPos+1).getTBP().test(180)));
172 phase1HLT = ((
ctp.getBunchCrossing(bcPos-1).getTBP().test(224)) or (
ctp.getBunchCrossing(bcPos+1).getTBP().test(224)));
174 else if (currentRunNo < 476718){
175 legacyHLT = ((
ctp.getBunchCrossing(bcPos-1).getTBP().test(184)) or (
ctp.getBunchCrossing(bcPos+1).getTBP().test(184)));
176 phase1HLT = ((
ctp.getBunchCrossing(bcPos-1).getTBP().test(228)) or (
ctp.getBunchCrossing(bcPos+1).getTBP().test(228)));
179 legacyHLT = ((
ctp.getBunchCrossing(bcPos-1).getTBP().test(185)) or (
ctp.getBunchCrossing(bcPos+1).getTBP().test(185)));
180 phase1HLT = ((
ctp.getBunchCrossing(bcPos-1).getTBP().test(229)) or (
ctp.getBunchCrossing(bcPos+1).getTBP().test(229)));
185 ATH_MSG_DEBUG(
"TrigDec don't pass HLT_mistimemonj400_L1All");
186 return StatusCode::SUCCESS;
189 ATH_MSG_DEBUG(
"TrigDec don't pass HLT_mistimemonj400_L1All");
190 return StatusCode::SUCCESS;
200 if(! ( (
m_trigDec->isPassed(
"L1_eEM26M")) or
201 (
m_trigDec->isPassed(
"L1_gJ100p0ETA25")) or
202 (
m_trigDec->isPassed(
"L1_gJ400p0ETA25")) or
207 return StatusCode::SUCCESS;
214 return StatusCode::SUCCESS;
220 return StatusCode::FAILURE;
224 bool legacyTrigger=
false;
225 bool phase1Trigger=
false;
226 std::string trigger =
"";
240 if ( (
m_trigDec->isPassed(
"L1_gJ400p0ETA25")) or (
m_trigDec->isPassed(
"L1_gJ100p0ETA25")) ) {
254 int good3Counter = 0;
255 int good2Counter = 0;
256 int eFexintimeCounter = 0;
257 int eFexoutoftimeCounter = 0;
260 int emActivityCounter = 0;
262 double dEta = 0.,
dPhi = 0., dPhi1 = 0., dR = 0.;
263 double etaIn = 0., phiIn = 0., etIn = 0.;
264 double etaOut = 0., phiOut = 0., etOut = 0.;
265 bool overlap =
false;
268 if(!jFexSRJetContainer.isValid()) {
277 std::unique_ptr<xAOD::TriggerTowerContainer> ttContainer = std::make_unique<xAOD::TriggerTowerContainer>();
278 std::unique_ptr<xAOD::TriggerTowerAuxContainer> ttContainerAux = std::make_unique<xAOD::TriggerTowerAuxContainer>();
279 ttContainer->setStore(ttContainerAux.get());
286 float ttPulseCategory = 0;
287 const std::vector<uint16_t>& ttADC = (
tt)->
adc();
288 std::vector<uint16_t> readoutCorrectedADC;
289 if(!readout80ModePpm){
291 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-2));
292 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-1));
293 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice));
294 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+1));
295 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+2));
298 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-4));
299 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-2));
300 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice));
301 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+2));
302 readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+4));
306 auto maxValIterator = std::max_element(readoutCorrectedADC.begin(), readoutCorrectedADC.end());
307 int maxADCval = *maxValIterator;
311 ttPulseCategory = 0.1;
313 else if(maxADCval == 1023) {
315 if(! (
tt)->
layer()) emActivityCounter++;
318 bool goodQual =
pulseQuality(readoutCorrectedADC, adcPeakPositon);
319 if(! (
tt)->
layer()) emActivityCounter++;
321 if(adcPeakPositon == 2){
333 else if(adcPeakPositon == 3){
351 if (trigger ==
"jFex") {
357 etIn = tob->tobEt()/5;
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 > 160.)) {
384 if (trigger ==
"gFex") {
389 if ( !jetContainer.
isValid() ) {
398 etIn = tob->gFexTobEt()/10;
400 if( (adcPeakPositon == 3) and (goodQual) ) {
403 dEta = std::abs(etaIn-etaOut);
404 dPhi = std::abs(phiIn-phiOut);
405 if ((phiIn < 0) and (phiOut > 0)){
406 dPhi1 = std::abs((phiIn+2*
M_PI)-phiOut);
411 else if ((phiIn > 0) and (phiOut < 0)){
412 dPhi1 = std::abs(phiIn-(phiOut+2*
M_PI));
418 if ((dR < .2) and (etIn > 100.)) {
433 pulseClassificationAcc(*newTT) = ttPulseCategory;
437 for(
auto key : {
"L1_eEMxRoI",
"L1_eEMxRoIOutOfTime"}) {
442 for(
auto tob : *emTobs) {
443 if (tob->et() > 5000) {
444 if (tob->bcn4() == ((ctx.eventID().bunch_crossing_id()) & 0xf )) {
447 else if (tob->bcn4() == (((ctx.eventID().bunch_crossing_id())+1) & 0xf )) {
448 eFexoutoftimeCounter++;
458 for(
auto tob : *gFexLRJetRoI) {
459 if (tob->et() > 50) {
467 for(
auto tob : *jFexJetRoI) {
468 if (tob->et() > 25) {
475 return StatusCode::SUCCESS;
482 return StatusCode::SUCCESS;
489 return StatusCode::SUCCESS;
494 if( (good3Counter < 2) or ((trigger ==
"eFex") and (eFexoutoftimeCounter < 2)) ){
496 return StatusCode::SUCCESS;
501 if( (good2Counter > 3) or
502 ((trigger ==
"eFex") and (eFexintimeCounter > 3)) or
503 ((trigger ==
"jFex") and (jFexCounter > 3)) or
504 ((trigger ==
"gFex") and (gFexCounter > 3)) ){
506 return StatusCode::SUCCESS;
511 if(!emActivityCounter){
513 return StatusCode::SUCCESS;
518 if (trigger ==
"eFex") {
524 for(
auto tob : *emTobs) {
527 etIn = tob->et()/1000;
529 for(
auto tobOut : *emTobsOut) {
530 etaOut = tobOut->eta();
531 phiOut = tobOut->phi();
532 etOut = tobOut->et()/1000;
534 dEta = std::abs(etaIn-etaOut);
535 dPhi = std::abs(phiIn-phiOut);
536 if ((phiIn < 0) and (phiOut > 0)){
537 dPhi1 = std::abs((phiIn+2*
M_PI)-phiOut);
542 else if ((phiIn > 0) and (phiOut < 0)){
543 dPhi1 = std::abs(phiIn-(phiOut+2*
M_PI));
549 if ((dR < .2) and (etIn > 26.) and (etOut > 26.)){
556 if ((legacyTrigger) and !(phase1Trigger)){
562 return StatusCode::SUCCESS;
570 std::lock_guard<std::mutex> lock(
m_mutex);
571 m_event_counter[lumiNo]+=1;
590 std::vector<MonitorTT> vecMonTTDecor;
596 ATH_MSG_DEBUG(
"tt->pulseClassification :: " << pulseClassificationAcc(*
tt));
603 for (
auto& myTower : vecMonTTDecor) {
606 pulseCat = pulseClassificationAcc(*myTower.tower);
607 bcidWord = (myTower.tower)->bcidVec()[0];
613 if(pulseCat > 0.5 && bcidWord > 0) {
617 else if(
layer == 1 ) {
625 std::vector<MonitorCPM> vecMonCPM;
643 for (
auto& myTower : vecMonCPM) {
645 std::vector<uint8_t> cpmEMenergy = (myTower.tower)->emEnergyVec();
646 std::vector<uint8_t> cpmHADenergy = (myTower.tower)->hadEnergyVec();
648 etalut = myTower.etaScaled;
650 for (
auto phi: myTower.phiScaled) {
654 if(cpmEMenergy.size() > 2){
655 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)));
657 emLUT0 =
static_cast<int>(cpmEMenergy.at(0));
658 if(cpmEMenergy.at(0) > 0)
fill(
groupName+
"lut_EM0",etalut,philut, emLUT0);
660 emLUT1 =
static_cast<int>(cpmEMenergy.at(1));
661 if(cpmEMenergy.at(1) > 0)
fill(
groupName+
"lut_EM1",etalut,philut, emLUT1);
663 emLUT2 =
static_cast<int>(cpmEMenergy.at(2));
664 if(cpmEMenergy.at(2) > 0)
fill(
groupName+
"lut_EM2",etalut,philut, emLUT2);
666 if(cpmHADenergy.size() > 2){
667 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)));
669 hadLUT0 =
static_cast<int>(cpmHADenergy.at(0));
670 if(cpmHADenergy.at(0) > 0)
fill(
groupName+
"lut_HAD0",etalut,philut, hadLUT0);
671 hadLUT1 =
static_cast<int>(cpmHADenergy.at(1));
672 if(cpmHADenergy.at(1) > 0)
fill(
groupName+
"lut_HAD1",etalut,philut, hadLUT1);
673 hadLUT2 =
static_cast<int>(cpmHADenergy.at(2));
674 if(cpmHADenergy.at(2) > 0)
fill(
groupName+
"lut_HAD2",etalut,philut, hadLUT2);
679 std::vector<MonitorJE> vecMonJE;
687 for (
auto&
jet : vecMonJE) {
689 std::vector<uint16_t> jepEMenergy = (
jet.element)->emJetElementETVec();
690 std::vector<uint16_t> jepHADenergy = (
jet.element)->hadJetElementETVec();
692 for (
auto eta:
jet.etaScaled) {
694 if ( std::abs(eta) > 2.5){
695 for (
auto phi:
jet.phiScaled) {
697 if(jepEMenergy.size() > 2){
698 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)));
700 emLUT0 =
static_cast<int>(jepEMenergy.at(0));
701 if(jepEMenergy.at(0) > 0)
fill(
groupName+
"lut_EM0",etalut,philut, emLUT0);
703 emLUT1 =
static_cast<int>(jepEMenergy.at(1));
704 if(jepEMenergy.at(1) > 0)
fill(
groupName+
"lut_EM1",etalut,philut, emLUT1);
706 emLUT2 =
static_cast<int>(jepEMenergy.at(2));
707 if(jepEMenergy.at(2) > 0)
fill(
groupName+
"lut_EM2",etalut,philut, emLUT2);
709 if(jepHADenergy.size()> 2){
710 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)));
712 hadLUT0 =
static_cast<int>(jepHADenergy.at(0));
713 if(jepHADenergy.at(0) > 0)
fill(
groupName+
"lut_HAD0",etalut,philut, hadLUT0);
715 hadLUT1 =
static_cast<int>(jepHADenergy.at(1));
716 if(jepHADenergy.at(1) > 0)
fill(
groupName+
"lut_HAD1",etalut,philut, hadLUT1);
718 hadLUT2 =
static_cast<int>(jepHADenergy.at(2));
719 if(jepHADenergy.at(2) > 0)
fill(
groupName+
"lut_HAD2",etalut,philut, hadLUT2);
727 if ( !eFexContainer.
isValid() ) {
745 for(
auto key : {
"L1_eEMxRoI",
"L1_eEMxRoIOutOfTime"}) {
750 for(
auto tob : *emTobs) {
751 TOBeT = tob->et()/1000;
755 if (tob->phi() < 0) {
756 TOBphi = tob->phi()+2*
M_PI;
763 if (tob->bcn4() == (((ctx.eventID().bunch_crossing_id())-1) & 0xf )) {
768 else if (tob->bcn4() == ((ctx.eventID().bunch_crossing_id()) & 0xf )) {
770 if (TOBeT_max_in < TOBeT) {
771 TOBeT_max_in = tob->et()/1000;
772 TOBeta_max_in = tob->eta();
773 if (tob->phi() < 0) {
774 TOBphi_max_in = tob->phi()+2*
M_PI;
777 TOBphi_max_in = tob->phi();
781 if (trigger ==
"eFex") {
782 fill(
"Efex_maxTOB_in", TOBeT);
786 else if (tob->bcn4() == (((ctx.eventID().bunch_crossing_id())+1) & 0xf )) {
788 if (TOBeT_max < TOBeT) {
789 TOBeT_max = tob->et()/1000;
790 TOBeta_max = tob->eta();
791 if (tob->phi() < 0) {
792 TOBphi_max = tob->phi()+2*
M_PI;
795 TOBphi_max = tob->phi();
799 if (trigger ==
"eFex") {
800 fill(
"Efex_maxTOB_out", TOBeT);
806 if (trigger ==
"eFex") {
807 fill(
"Efex_maxTOB_out", TOBeta_max, TOBphi_max);
808 fill(
"Efex_maxTOB_in", TOBeta_max_in, TOBphi_max_in);
825 if(!jEmulatedTowerContainer.
isValid()) {
826 ATH_MSG_WARNING(
"No jFex Tower container valid in storegate with key: "<< jEmulatedTowerContainer.
key()<<
". Will be skipped!");
830 jFexEt=emulTower->et_count().at(0);
832 jFexeta=emulTower->eta()+1
e-5;
833 if (emulTower->phi() < 0) {
834 jFexphi=emulTower->phi()+2*
M_PI;
837 jFexphi=emulTower->phi();
856 if (TOBeT_max < jFexEt) {
867 if (trigger ==
"jFex") {
868 fill(
"Jfex_maxTOB", jFexEt);
871 if (trigger ==
"jFex") {
872 fill(
"Jfex_maxTOB", TOBeta_max, TOBphi_max);
876 if(!jFexTauContainer.isValid()) {
904 if ( !jetContainer.
isValid() ) {
917 if (TOBeT_max < gFexEt) {
927 if (key_index == 0) {
930 else if (key_index == 1) {
933 if (trigger ==
"gFex") {
934 fill(
"Gfex_maxTOB", gFexEt);
940 if (trigger ==
"gFex") {
941 fill(
"Gfex_maxTOB", TOBeta_max, TOBphi_max);
950 fill(
"Event_all_", eventMonitor_all_legacy, lbMonitor_all );
953 fill(
"Event_all_", eventMonitor_all_phaseI, lbMonitor_all );
957 return StatusCode::SUCCESS;
962 std::vector<MonitorTT> &vecMonTT)
const
965 const double phi =
tt->phi();
975 vecMonTT.push_back(monTT);
977 return StatusCode::SUCCESS;
982 std::vector<MonitorCPM> &vecMonCPM)
const
985 const double phi = cpm->
phi();
996 const std::vector<double> offset32 = {1.5, 0.5, -0.5, -1.5};
997 const std::vector<double> offset25 = {0.5, -0.5};
998 std::vector<double>
offset = {};
1002 phiMod = std::floor(phiMod/4)*4. + 2.;
1007 phiMod = std::floor(phiMod/2)*2. + 1.;
1017 for (
auto phiOffset :
offset) {
1018 monCPM.
phiScaled.push_back(phiMod + phiOffset);
1024 vecMonCPM.push_back(monCPM);
1026 return StatusCode::SUCCESS;
1030 std::vector<MonitorJE> &vecMonJE)
const
1036 const double phi = je->
phi();
1046 if(
etaMod < 0) signeta = -1;
1049 const std::vector<double> offset32 = {1.5, 0.5, -0.5, -1.5};
1050 const std::vector<double> offset25 = {0.5, -0.5};
1051 std::vector<double>
offset = {};
1055 phiMod = std::floor(phiMod/4)*4. + 2.;
1063 phiMod = std::floor(phiMod/2)*2. + 1.;
1065 monJE.
etaScaled.push_back(signeta*3.15);
1071 phiMod = std::floor(phiMod/2)*2. + 1.;
1082 for (
auto phiOffset :
offset) {
1083 monJE.
phiScaled.push_back(phiMod + phiOffset);
1086 vecMonJE.push_back(monJE);
1088 return StatusCode::SUCCESS;
1094 const std::string& weightName,
1102 const std::vector<double> offset32 = {1.5, 0.5, -0.5, -1.5};
1103 const std::vector<double> offset25 = {0.5, -0.5};
1104 std::vector<double>
offset = {};
1108 phiMod = std::floor(phiMod/4)*4. + 2.;
1113 phiMod = std::floor(phiMod/2)*2. + 1.;
1123 for (
auto phiOffset :
offset) {
1135 return StatusCode::SUCCESS;
1141 bool goodPulse =
true;
1142 int size = ttPulse.size();
1143 if (peakSlice >
size) {
1144 ATH_MSG_ERROR(
"Peak Slice " << peakSlice <<
" supress the ttPulse vector size " <<
size );
1149 ATH_MSG_ERROR(
"The ttPulse vector size " <<
size <<
" not valid for Peak Slice " << peakSlice );
1153 int a = ttPulse[peakSlice-1];
1154 int b = ttPulse[peakSlice];
1155 int c = ttPulse[peakSlice+1];
1156 double tim = (0.5*
a-0.5*
c)/(
a+
c-2*
b);
1157 double wid = (
a+
c-64.0)/(
b-32.0);
1158 if ( tim < 0.0 ) goodPulse =
false;
1159 else if ( tim > 0.3 ) goodPulse =
false;
1160 if ( wid < 1.0 ) goodPulse =
false;
1161 else if ( wid > 1.6 ) goodPulse =
false;
1163 ATH_MSG_DEBUG(
"Pulse qual= "<< goodPulse<<
" tim = "<<tim<<
" wid = "<<wid);