39 #include "CaloGeoHelpers/CaloSampling.h"
92 constexpr
unsigned expSize=
MAXLYRNS*2+1;
94 ATH_MSG_ERROR(
"Unexpected size of LayerNames property. Expect "<< expSize <<
" entries, found "<<
m_layerNames.size() <<
" entries");
95 return StatusCode::FAILURE;
237 if (!hLArDigitContainer.isValid()) {
238 ATH_MSG_WARNING(
"The requested digit container key could not be retrieved. Was there a problem retrieving information from the run logger?");
240 ATH_MSG_DEBUG(
"hLArDigitContainer.size() " << hLArDigitContainer->size());
243 if (!hSCetContainer.isValid()) {
244 ATH_MSG_WARNING(
"The requested SC ET container key could not be retrieved. Was there a problem retrieving information from the run logger?");
246 ATH_MSG_DEBUG(
"hSCetContainer.size() " << hSCetContainer->size());
249 if (!hSCetRecoContainer.isValid()) {
250 ATH_MSG_WARNING(
"The requested SC ET reco container key could not be retrieved. Was there a problem retrieving information from the run logger?");
252 ATH_MSG_DEBUG(
"hSCetRecoContainer.size() " << hSCetRecoContainer->size());
257 if (!hLArLATOMEHeaderContainer.isValid()) {
258 ATH_MSG_WARNING(
"The requested LATOME header container key could not be retrieved. Was there a problem retrieving information from the run logger?");
260 ATH_MSG_DEBUG(
"hLArLATOMEHeaderContainer.size() " << hLArLATOMEHeaderContainer->size());
264 auto isEmptyCont=[](
auto&
c) {
return (!
c.isValid() ||
c->empty()); };
265 if (isEmptyCont(hLArDigitContainer) && isEmptyCont(hSCetContainer) && isEmptyCont(hSCetRecoContainer) && isEmptyCont(hLArLATOMEHeaderContainer)) {
267 ATH_MSG_WARNING(
"All of the requested containers are empty. Was there a problem retrieving information from the run logger?");
268 return StatusCode::SUCCESS;
271 BCID = thisEvent->bcid();
272 lumi_block = thisEvent->lumiBlock();
273 time_stamp = thisEvent->timeStamp();
295 if ( (hLArDigitContainer.isValid()) ){
296 std::vector<std::vector<Digi_MonValues>> digiMonValueVec(
m_layerNames.size());
297 for (
auto& innerVec : digiMonValueVec) {
298 innerVec.reserve(1600);
302 for (
const LArDigit* pLArDigit : *hLArDigitContainer) {
305 if(!
cabling->isOnlineConnected(
id))
continue;
307 const unsigned trueNSamples = pLArDigit->nsamples();
308 if(trueNSamples==0)
continue;
309 Digi_Nsamples = trueNSamples;
310 const int cgain = pLArDigit->gain();
314 if(caloDetElement == 0 ){
318 Digi_eta = caloDetElement->
eta_raw();
319 Digi_phi = caloDetElement->
phi_raw();
324 const int calosample=caloDetElement->
getSampling();
328 const unsigned iLyr=iLyrNS*2+
side;
329 auto& lvaluemap_digi = digiMonValueVec[iLyr];
330 auto& lvaluemap_digi_ALL = digiMonValueVec.back();
335 Digi_partition = ThisPartition;
346 Pedestal = pedestals->
pedestal(
id,cgain);
355 Digi_SCChannel = scdigi->
Channel();
356 Digi_latomeSourceId = scdigi->
SourceId();
360 const std::vector<short>* digito = &pLArDigit->samples();
363 std::vector<short>::const_iterator maxSam = std::max_element(digito->begin(), digito->end());
365 Digi_maxpos=thismaxPos+1;
366 float ADC_max = pLArDigit->samples().at(Digi_maxpos-1);
368 float ADC_0 = pLArDigit->samples().at(0);
374 Digi_Diff_ADC0_Ped = ADC_0 - Pedestal;
375 for(
unsigned i=0;
i<trueNSamples;++
i) {
376 badNotMasked =
false;
381 Digi_ADC = pLArDigit->samples().at(
i);
386 Digi_Diff_ADC_Ped = Digi_ADC - Pedestal;
387 if ( ADC_max != Pedestal ){
388 Digi_Diff_ADC_Ped_Norm = (Digi_ADC - Pedestal) / std::abs(ADC_max - Pedestal);
399 if(ADC_max - Pedestal > 10*PedestalRMS) {
402 if ( notMasked && notBadQual && ADCped10RMS ){
406 lvaluemap_digi.emplace_back(Digi_eta, Digi_phi, Digi_ieta, Digi_iphi, Digi_sampos, Digi_ADC, Digi_latomeSourceIdBIN, Pedestal, Digi_maxpos, Digi_partition, Digi_Diff_ADC_Ped_Norm, Digi_Diff_ADC_Ped, Digi_Diff_ADC0_Ped,
BCID, lumi_block, passDigiNom, badNotMasked);
407 lvaluemap_digi_ALL.emplace_back(Digi_eta, Digi_phi, Digi_ieta, Digi_iphi, Digi_sampos, Digi_ADC, Digi_latomeSourceIdBIN, Pedestal, Digi_maxpos, Digi_partition, Digi_Diff_ADC_Ped_Norm, Digi_Diff_ADC_Ped, Digi_Diff_ADC0_Ped,
BCID, lumi_block, passDigiNom, badNotMasked);
415 for (
size_t ilayer = 0; ilayer < digiMonValueVec.size(); ++ilayer) {
416 const auto&
tool = digiMonValueVec[ilayer];
423 auto digi_part_latomesourceidbin =
Monitored::Collection(
"Digi_part_latomesourceidbin",
tool,[](
const auto&
v){
return v.digi_latomesourceidbin;});
427 auto digi_part_diff_adc_ped_norm =
Monitored::Collection(
"Digi_part_diff_adc_ped_norm",
tool,[](
const auto&
v){
return v.digi_diff_adc_ped_norm;});
429 auto digi_part_diff_adc0_ped =
Monitored::Collection(
"Digi_part_diff_adc0_ped",
tool,[](
const auto&
v){
return v.digi_diff_adc0_ped;});
436 digi_part_eta, digi_part_phi, digi_part_ieta, digi_part_iphi, digi_part_sampos, digi_part_adc, digi_part_latomesourceidbin, digi_part_pedestal, digi_part_maxpos, digi_part_diff_adc_ped_norm, digi_part_diff_adc_ped, digi_part_diff_adc0_ped, digi_part_bcid, digi_part_lb, digi_part_passDigiNom, digi_part_badNotMasked);
443 if ( hSCetContainer.isValid() && hSCetRecoContainer.isValid() ){
450 std::vector<std::vector<SC_MonValues>> scMonValueVec(
m_layerNames.size());
451 for (
auto& innerVec : scMonValueVec) {
452 innerVec.reserve(1600);
456 for ( ; itSC!=itSC_e;++itSC,++itSCReco) {
458 if ( itSCReco < hSCetRecoContainer->
end() ){
459 rawSCReco = *itSCReco;
461 ATH_MSG_WARNING(
"Looping SC ET container, but we have reached the end of the SC ET Reco iterator. Check the sizes of these containers. Is SC ET Reco size zero? Is there a problem with the digit container name sent by the run logger?");
464 SC_SCChannel = rawSC->
chan();
467 if(!
cabling->isOnlineConnected(
id))
continue;
472 if (caloDetElement == 0) {
473 ATH_MSG_ERROR(
"Cannot retrieve (eta,phi) coordinates for raw channels");
477 SC_eta = caloDetElement->
eta_raw();
478 SC_phi = caloDetElement->
phi_raw();
486 const unsigned iLyr=iLyrNS*2+
side;
488 auto& lvaluemap_sc = scMonValueVec[iLyr];
489 auto& lvaluemap_sc_ALL = scMonValueVec.back();
503 onlofflEmismatch=
false;
507 passSCNom10tauGt3 =
false;
508 saturNotMasked =
false;
509 OFCbOFNotMasked =
false;
510 notMaskedEoflNe0 =
false;
511 notMaskedEoflGt1 =
false;
512 nonZeroETofl =
false;
522 unsigned int bcid_ind = 0;
524 for (
auto & SCe : rawSC->
bcids() ){
525 if ( SCe ==
BCID )
break;
528 if ( bcid_ind >= rawSC->
bcids().size() ){
529 ATH_MSG_WARNING(
"BCID not found in SC bcids list!! "<<
BCID<<
" BCIDs size: "<<rawSC->
bcids().size()<<
", proposed index: "<<bcid_ind);
530 }
else if ( rawSC->
bcids().at(bcid_ind) !=
BCID ){
534 if (rawSC->
energies().size() > bcid_ind){
535 SC_energy_onl = rawSC->
energies().at(bcid_ind);
537 ATH_MSG_WARNING(
"rawSC energies vector is too small for the requested BCID index "<<bcid_ind<<
" (size is "<<rawSC->
energies().size()<<
", bcid vec size is "<<rawSC->
bcids().size()<<
")");
545 if ( rawSCReco != 0 ){
546 if ( rawSCReco->
energies().size()>0 ){
547 SC_energy_ofl = rawSCReco->
energies().at(0);
553 SC_ET_diff = SC_energy_onl - SC_energy_ofl;
554 SC_ET_onl = ( SC_energy_onl* 12.5 ) / 1000;
555 SC_ET_ofl = ( SC_energy_ofl* 12.5 ) / 1000;
556 SC_ET_onl_muscaled = event_mu > 0. ? SC_ET_onl / event_mu : SC_ET_onl;
558 if ( rawSCReco != 0 ){
561 SC_time = (SC_energy_ofl != 0) ? (
float)Etau / (
float)SC_energy_ofl : Etau;
563 ATH_MSG_DEBUG(
"Energy onl - Energy ofl: "<<SC_energy_onl<<
", "<<SC_energy_ofl<<std::endl);
564 if (SC_ET_onl != 0 ){
573 if (SC_ET_ofl != 0 ) {
579 if ( rawSC->
satur().size()>bcid_ind ){
580 if ( rawSC->
satur().at(bcid_ind) ){
582 saturNotMasked =
true;
591 if ( rawSCReco != 0 && rawSCReco->
ofcbOverflow() ==
false ){
595 OFCbOFNotMasked =
true;
598 if ( std::abs(SC_time) > 3 ){
602 if ( notMasked && notSatur && notOFCbOF ){
604 notMaskedEoflNe0 =
true;
607 notMaskedEoflGt1 =
true;
620 passSCNom10tauGt3 =
true;
623 if (SC_energy_onl != SC_energy_ofl){
624 onlofflEmismatch =
true;
629 lvaluemap_sc.emplace_back(SC_eta, SC_phi, SC_ieta, SC_iphi, SC_latomeSourceIdBIN, SC_ET_ofl, SC_ET_diff, SC_ET_onl, SC_ET_onl_muscaled, SC_time,
BCID, lumi_block, passSCNom, passSCNom1, passSCNom10, passSCNom10tauGt3, saturNotMasked, OFCbOFNotMasked, notMaskedEoflNe0, notMaskedEoflGt1);
630 lvaluemap_sc_ALL.emplace_back(SC_eta, SC_phi, SC_ieta, SC_iphi, SC_latomeSourceIdBIN, SC_ET_ofl, SC_ET_diff, SC_ET_onl, SC_ET_onl_muscaled, SC_time,
BCID, lumi_block, passSCNom, passSCNom1, passSCNom10, passSCNom10tauGt3, saturNotMasked, OFCbOFNotMasked, notMaskedEoflNe0, notMaskedEoflGt1);
636 for (
size_t ilayer = 0; ilayer < scMonValueVec.size(); ++ilayer) {
637 const auto&
tool = scMonValueVec[ilayer];
642 auto sc_part_latomesourceidbin =
Monitored::Collection(
"SC_part_latomesourceidbin",
tool,[](
const auto&
v){
return v.sc_latomesourceidbin;});
646 auto sc_part_et_onl_muscaled =
Monitored::Collection(
"SC_part_et_onl_muscaled",
tool,[](
const auto&
v){
return v.sc_et_onl_muscaled;});
653 auto sc_part_passSCNom10tauGt3 =
Monitored::Collection(
"SC_part_passSCNom10tauGt3",
tool,[](
const auto&
v){
return v.sc_passSCNom10tauGt3;});
655 auto sc_part_OFCbOFNotMasked =
Monitored::Collection(
"SC_part_OFCbOFNotMasked",
tool,[](
const auto&
v){
return v.sc_OFCbOFNotMasked;});
656 auto sc_part_notMaskedEoflNe0 =
Monitored::Collection(
"SC_part_notMaskedEoflNe0",
tool,[](
const auto&
v){
return v.sc_notMaskedEoflNe0;});
657 auto sc_part_notMaskedEoflGt1 =
Monitored::Collection(
"SC_part_notMaskedEoflGt1",
tool,[](
const auto&
v){
return v.sc_notMaskedEoflGt1;});
661 sc_part_eta, sc_part_phi, sc_part_ieta, sc_part_iphi, sc_part_latomesourceidbin, sc_part_et_ofl, sc_part_et_diff, sc_part_et_onl, sc_part_et_onl_muscaled, sc_part_time, sc_part_bcid, sc_part_lb, sc_part_passSCNom, sc_part_passSCNom1, sc_part_passSCNom10, sc_part_passSCNom10tauGt3, sc_part_saturNotMasked, sc_part_OFCbOFNotMasked, sc_part_notMaskedEoflNe0, sc_part_notMaskedEoflGt1);
670 if ( (hLArLATOMEHeaderContainer.isValid()) ){
672 for (
const LArLATOMEHeader* pLArLATOMEHeader : *hLArLATOMEHeaderContainer) {
673 event_size += pLArLATOMEHeader->ROBFragSize() + 48;
675 event_size /= (1024*1024/4);
683 return StatusCode::SUCCESS;
693 if(
side==0)
return 0;
696 if(
side==0)
return 2;
699 if(
side==0)
return 4;
702 if(
side==0)
return 6;
713 const unsigned detID = sourceID >> 16;
714 const unsigned value = sourceID & 0xF;
717 detStartingBin=mapit->second;
720 unsigned binx = detStartingBin+
value;