7 #include "GaudiKernel/ListItem.h"
8 #include "GaudiKernel/MsgStream.h"
9 #include "GaudiKernel/Bootstrap.h"
10 #include "GaudiKernel/ISvcLocator.h"
11 #include "GaudiKernel/IToolSvc.h"
37 static const InterfaceID IID_ILArRodDecoder
38 (
"LArRodDecoder", 1, 0);
42 m_LArCellEthreshold(-100.),
46 declareInterface< LArRodDecoder >(
this );
72 {
return IID_ILArRodDecoder; }
78 m_StatusNMask = !m_StatusMask;
83 msg(MSG::ERROR) <<
"Could not get LArOnlineID helper !" <<
endmsg;
88 sc = service(
"ToolSvc",toolSvc);
90 {
msg(MSG::ERROR) <<
"Unable to get ToolSvc" <<
endmsg;
96 std::vector<std::string>::const_iterator
it = m_LArCellCorrNames.begin();
97 std::vector<std::string>::const_iterator it_end = m_LArCellCorrNames.end();
98 for(;
it!=it_end;++
it)
102 if((toolSvc->retrieveTool(li.type(), li.name(),
tool)).isFailure() )
103 {
msg(MSG::ERROR) <<
" Can't get AlgTool for CaloCellCorrection " <<
endmsg;
104 return StatusCode::FAILURE;
109 {
msg(MSG::ERROR) <<
" Can't d-cast to CaloCellCorrection* " <<
endmsg;
110 return StatusCode::FAILURE;
112 m_LArCellCorrTools.push_back(corr);
116 if (m_vBEPreselection.size() && m_vPosNegPreselection.size() && m_vFTPreselection.size()) {
118 for (
const unsigned BE : m_vBEPreselection) {
119 for (
const unsigned PN : m_vPosNegPreselection) {
120 for (
const unsigned FT : m_vFTPreselection) {
123 ATH_MSG_INFO(
"Adding feedthrough Barrel/Endcap=" << BE <<
" pos/neg=" << PN <<
" FT=" <<
FT
124 <<
" (0x" << std::hex << finalFTId32 << std::dec <<
")");
125 m_vFinalPreselection.push_back(finalFTId32);
129 std::sort(m_vFinalPreselection.begin(),m_vFinalPreselection.end());
132 if (m_vBEPreselection.size() || m_vPosNegPreselection.size() || m_vFTPreselection.size()) {
133 msg(MSG::ERROR) <<
"Feedthrough preselection: jobOption inconsistency! "<<
endmsg;
134 msg(MSG::ERROR) <<
"Need to set all three jobOptions BEPreselection PNPreselecton and FTPreselection" <<
endmsg;
135 return StatusCode::FAILURE;
153 if (!BlStruct)
return;
159 msg(MSG::WARNING) <<
"Invalid FEB identifer 0x" << std::hex << fId32 << std::dec <<
". Skipping" <<
endmsg;
177 ATH_MSG_DEBUG(
"No Raw Data for this FEB - NULL event for FEBID 0x"<< std::hex << BlStruct->
getFEBID() << std::dec);
185 for(; it_feb!=it_feb_end;++it_feb)
193 msg(MSG::WARNING) <<
"RodStatus&0x" << std::hex <<
m_StatusNMask <<
" indicates corrupt data for FEB "<< std::hex << fId32 << std::dec <<
". Ignored." <<
endmsg;
202 msg(MSG::WARNING) <<
"Checksum error for FEB: " << MSG::hex << fId32 <<
endmsg;
203 msg(MSG::WARNING) <<
" online checksum = " << MSG::hex << onsum <<
endmsg;
204 msg(MSG::WARNING) <<
" offline checksum = " << MSG::hex << offsum << MSG::dec <<
endmsg;
212 ATH_MSG_DEBUG(
"Feedthrough with id 0x" << MSG::hex << ftId << MSG::dec <<
" not in preselection. Ignored.");
218 {
if (fcNb>=NthisFebChannel)
220 if (
samples.size()==0)
continue;
245 if (!BlStruct)
return;
251 msg(MSG::WARNING) <<
"Invalid FEB identifer " << std::hex << fId32 << std::dec <<
". Skipping" <<
endmsg;
267 ATH_MSG_DEBUG(
"No Physics Data for this FEB - NULL event for FEBID 0x" << std::hex << BlStruct->
getFEBID() << std::dec);
275 for(; it_feb!=it_feb_end;++it_feb)
283 msg(MSG::WARNING) <<
"RodStatus&0x" << std::hex <<
m_StatusNMask <<
" indicates corrupt data for FEB "<< std::hex << fId32 << std::dec <<
". Ignored." <<
endmsg;
293 msg(MSG::WARNING) <<
"Checksum error:" <<
endmsg;
294 msg(MSG::WARNING) <<
" online checksum = " << MSG::hex << onsum <<
endmsg;
295 msg(MSG::WARNING) <<
" offline checksum = " << MSG::hex << offsum <<
endmsg;
303 ATH_MSG_DEBUG(
"Feedthrough with id " << std::hex << ftId << std::dec <<
" not in preselection. Ignored.");
309 if (fcNb>=NthisFebChannel)
315 iprovenance |= 0x2000;
316 iquality = (quality & 0xFFFF);
319 coll.push_back(
chan);
343 ATH_MSG_VERBOSE(
"FillCollection for LArCalibDigitContainer is called.");
345 if (!BlStruct)
return;
354 ATH_MSG_DEBUG(
"No Raw Data for this FEB - NULL event for FEBID " << std::hex << BlStruct->
getFEBID());
361 ATH_MSG_DEBUG(
"Bad FebID=0x"<< std::hex << BlStruct->
getFEBID() <<
" found for this FEB, skipping it!");
368 for(; it_feb!=it_feb_end;++it_feb)
376 msg(MSG::WARNING) <<
"RodStatus&0x" << std::hex <<
m_StatusNMask <<
" indicates corrupt data for FEB "<< std::hex << fId32 << std::dec <<
". Ignored." <<
endmsg;
385 msg(MSG::WARNING) <<
"Checksum error:" <<
endmsg;
386 msg(MSG::WARNING) <<
" online checksum = " << MSG::hex << onsum <<
endmsg;
387 msg(MSG::WARNING) <<
" offline checksum = " << MSG::hex << offsum <<
endmsg;
405 ATH_MSG_DEBUG(
"Feedthrough with id 0x" << std::hex << ftId << std::dec <<
" not in preselection. Ignored.");
411 {
if (fcNb>=NthisFebChannel)
413 if (
samples.size()==0)
continue;
426 ATH_MSG_VERBOSE(
"Not LArCalibDigit data block found. Building it using DB values");
431 {
msg(MSG::ERROR) <<
"Cannot load LArCalibParams from DetStore!" <<
endmsg;
436 if (!
evt.isValid()) {
440 const unsigned eventNb=
evt->eventNumber();
441 const std::vector<HWIdentifier>* calibChannelIDs;
446 ATH_MSG_DEBUG(
"No Raw Data for this FEB - NULL event for FEBID 0x" << std::hex << BlStruct->
getFEBID() << std::dec);
453 ATH_MSG_DEBUG(
"Bad FebID=0x" << std::hex << BlStruct->
getFEBID() <<
" found for this FEB, skipping it!" << std::dec);
473 while ( (!onOffIdMapping.
isOnlineConnected(cId) || calibChannelIDs->size()==0) && fcNb<128);
475 if ( calibChannelIDs->size()==0 ) {
476 msg(MSG::ERROR) <<
"Cannot get calibration Channel ID for FEB " << std::hex << fId32 << std::dec <<
endmsg;
483 std::vector<HWIdentifier>::const_iterator csl_it=calibChannelIDs->begin();
485 dac=calibParams->
DAC(eventNb,*csl_it);
497 if (fcNb>=NthisFebChannel)
continue;
498 if (
samples.size()==0)
continue;
505 if (calibChannelIDs->size()!=0) {
506 csl_it=calibChannelIDs->begin();
507 ispulsed=calibParams->
isPulsed(eventNb,*csl_it);
534 int dac,
delay, NStep=-1, StepIndex=-1;
540 std::vector< uint64_t > samplesSum;
541 std::vector< uint64_t > samples2Sum;
547 if (!BlStruct)
return;
564 ATH_MSG_DEBUG(
"Bad FebID=0x" << std::hex << BlStruct->
getFEBID() <<
" found for this FEB, skipping it!" << std::dec);
571 for(; it_feb!=it_feb_end;++it_feb)
579 msg(MSG::WARNING) <<
"RodStatus&0x" << std::hex <<
m_StatusNMask <<
" indicates corrupt data for FEB "<< std::hex << fId32 << std::dec <<
". Ignored." <<
endmsg;
588 msg(MSG::WARNING) <<
"Checksum error:" <<
endmsg;
589 msg(MSG::WARNING) <<
" online checksum = " << MSG::hex << onsum <<
endmsg;
590 msg(MSG::WARNING) <<
" offline checksum = " << MSG::hex << offsum <<
endmsg;
608 ATH_MSG_DEBUG(
"Feedthrough with id " << std::hex << ftId << std::dec <<
" not in preselection. Ignored.");
618 if (fcNb>=NthisFebChannel)
continue;
619 if (samplesSum.size()==0)
continue;
629 const std::vector<HWIdentifier>& calibChannelIDs = calibLineMapping.
calibSlotLine(cId);
630 if (calibChannelIDs.size()==0) {
636 for(std::vector<HWIdentifier>::const_iterator csl_it=calibChannelIDs.begin(); csl_it!=calibChannelIDs.end();++csl_it){
639 ispulsed_int=( ispulsed_int | ((
uint16_t)ispulsed<<bitShift) );
644 (
uint16_t)ispulsed_int, NStep, StepIndex);
662 std::vector<uint64_t> sampleSum;
663 std::vector< uint64_t > sampleSquare;
669 if (!BlStruct)
return;
681 ATH_MSG_DEBUG(
"Bad FebID=0x" << std::hex << BlStruct->
getFEBID() <<
" found for this FEB, skipping it!" << std::dec);
688 for(; it_feb!=it_feb_end;++it_feb)
696 msg(MSG::WARNING) <<
"RodStatus&0x" << std::hex <<
m_StatusNMask <<
" indicates corrupt data for FEB "<< std::hex << fId32 << std::dec <<
". Ignored." <<
endmsg;
705 msg(MSG::WARNING) <<
"Checksum error:" <<
endmsg;
706 msg(MSG::WARNING) <<
" online checksum = " << MSG::hex << onsum <<
endmsg;
707 msg(MSG::WARNING) <<
" offline checksum = " << MSG::hex << offsum <<
endmsg;
725 ATH_MSG_DEBUG(
"Feedthrough with id " << std::hex << ftId << std::dec <<
" not in preselection. Ignored.");
735 if (fcNb>=NthisFebChannel)
continue;
736 if (sampleSquare.size()==0)
continue;
759 if (!BlStruct)
return;
769 msg(MSG::WARNING) <<
"Invalid FEB identifer " << std:: hex << FEBID32 << std::dec <<
". Skipping" <<
endmsg;
787 ATH_MSG_DEBUG(
"Feedthrough with id 0x" << std::hex << ftId << std::dec <<
" not in preselection. Ignored.");
798 larFebHeader->
SetSourceId(robFrag.rod_source_id());
800 larFebHeader->
SetELVL1Id(robFrag.rod_lvl1_id());
801 larFebHeader->
SetBCId(robFrag.rod_bc_id());
821 larFebHeader->
SetFebBCId(robFrag.rod_bc_id());
828 for(
int iadc=0;iadc<16;iadc++) {
833 for(
unsigned int i = 0;
i<nsample;
i++ ) {
847 const unsigned MAXMINOR = 12;
848 const unsigned MAXTYPE = 10;
850 if (rodMinorVersion > MAXMINOR || robBlockType > MAXTYPE) {
851 msg(MSG::ERROR) <<
"Bad Rod block type " << robBlockType
852 <<
" / " << rodMinorVersion <<
endmsg;
855 std::vector<std::unique_ptr<LArRodBlockStructure> >& blstructs =
857 unsigned int index = robBlockType * (MAXMINOR+1) + rodMinorVersion;
858 if (blstructs.empty()) {
859 blstructs.resize ((MAXMINOR+1)*(MAXTYPE+1));
861 if (!blstructs[
index]) {
864 if (!blstructs[
index]) {
865 msg(MSG::ERROR) <<
"Bad Rod block type " << robBlockType
866 <<
" / " << rodMinorVersion <<
endmsg;
871 ATH_MSG_DEBUG(
"Found version " << rodMinorVersion <<
" of Rod block type " << robBlockType);
874 return blstructs[
index].get();
883 ATH_MSG_DEBUG(
"Prepare LArRodBlockStructure. Got a fragement of size " <<
n);
887 eformat::helper::Version
ver(robFrag.rod_version());
888 const uint16_t rodMinorVersion=
ver.minor_version();
889 const uint32_t rodBlockType=robFrag.rod_detev_type()&0xff;
897 constexpr
int maxMess = 100;
898 static std::atomic<int> nMess = 1;
899 int thismess = nMess++;
900 if (thismess <= maxMess) {
901 msg(MSG::ERROR) <<
"Could not set fragment (wrong number of samples in data ?) - container will not be filled" <<
endmsg;
902 if (thismess == maxMess)
903 msg(MSG::ERROR) <<
"This message will not be repeated" <<
endmsg;
911 BlStruct->
setGain(RequestedGain);
920 std::unique_ptr<LArRodBlockStructure>
922 unsigned int rodMinorVersion)
const
924 switch (rodBlockType) {
927 switch (rodMinorVersion) {
933 return std::make_unique<LArRodBlockTransparentV0<LArRodBlockHeaderTransparentV0> >();
935 return std::make_unique<LArRodBlockCalibrationV1>();
943 return std::make_unique<LArRodBlockCalibrationV3>();
951 return std::make_unique<LArRodBlockTransparentV0<LArRodBlockHeaderTransparentV0> >();
955 switch (rodMinorVersion) {
957 return std::make_unique<LArRodBlockPhysicsV0>();
959 return std::make_unique<LArRodBlockPhysicsV1>();
967 return std::make_unique<LArRodBlockPhysicsV2>();
969 return std::make_unique<LArRodBlockPhysicsV4>();
973 auto bl = std::make_unique<LArRodBlockPhysicsV5>();
981 auto bl = std::make_unique<LArRodBlockPhysicsV6>();
995 return std::make_unique<LArRodBlockPhysicsV3>();
999 switch (rodMinorVersion) {
1001 return std::make_unique<LArRodBlockPhysicsV0>();
1004 return std::make_unique<LArRodBlockPhysicsV2>();
1012 switch (rodMinorVersion) {
1014 return std::make_unique<LArRodBlockCalibrationV0<LArRodBlockHeaderCalibrationV0> >();
1019 return std::make_unique<LArRodBlockCalibrationV1>();
1021 return std::make_unique<LArRodBlockCalibrationV2>();
1029 return std::make_unique<LArRodBlockCalibrationV3>();
1038 return std::make_unique<LArRodBlockAccumulatedV3>();
1044 return std::unique_ptr<LArRodBlockStructure>();