7#include "GaudiKernel/TypeNameString.h"
8#include "GaudiKernel/MsgStream.h"
9#include "GaudiKernel/Bootstrap.h"
10#include "GaudiKernel/ISvcLocator.h"
11#include "GaudiKernel/IToolSvc.h"
24 (
"LArRodDecoder", 1, 0);
32 declareInterface< LArRodDecoder >(
this );
64 m_StatusNMask = !m_StatusMask;
66 StatusCode
sc = detStore()->retrieve(m_onlineHelper,
"LArOnlineID");
74 std::vector<std::string>::const_iterator it = m_LArCellCorrNames.begin();
75 std::vector<std::string>::const_iterator it_end = m_LArCellCorrNames.end();
76 for(; it!=it_end;++it)
80 Gaudi::Utils::TypeNameString li(*it);
81 if((toolSvc()->retrieveTool(li.type(), li.name(), tool)).isFailure() )
84 return StatusCode::FAILURE;
91 return StatusCode::FAILURE;
93 m_LArCellCorrTools.push_back(corr);
97 if (m_vBEPreselection.size() && m_vPosNegPreselection.size() && m_vFTPreselection.size()) {
99 for (
const unsigned BE : m_vBEPreselection) {
100 for (
const unsigned PN : m_vPosNegPreselection) {
101 for (
const unsigned FT : m_vFTPreselection) {
102 HWIdentifier finalFTId=m_onlineHelper->feedthrough_Id(BE,PN,FT);
104 ATH_MSG_INFO(
"Adding feedthrough Barrel/Endcap=" << BE <<
" pos/neg=" << PN <<
" FT=" << FT
105 <<
" (0x" << std::hex << finalFTId32 << std::dec <<
")");
106 m_vFinalPreselection.push_back(finalFTId32);
110 std::sort(m_vFinalPreselection.begin(),m_vFinalPreselection.end());
113 if (m_vBEPreselection.size() || m_vPosNegPreselection.size() || m_vFTPreselection.size()) {
114 ATH_MSG_ERROR(
"Feedthrough preselection: jobOption inconsistency! ");
115 ATH_MSG_ERROR(
"Need to set all three jobOptions BEPreselection PNPreselecton and FTPreselection");
116 return StatusCode::FAILURE;
137 if (!BlStruct)
return;
143 ATH_MSG_WARNING(
"Invalid FEB identifer " << std::hex << fId32 << std::dec <<
". Skipping");
158 ATH_MSG_DEBUG(
"No Physics Data for this FEB - NULL event for FEBID 0x" << std::hex << BlStruct->
getFEBID() << std::dec);
166 for(; it_feb!=it_feb_end;++it_feb)
174 ATH_MSG_WARNING(
"RodStatus&0x" << std::hex <<
m_StatusNMask <<
" indicates corrupt data for FEB "<< std::hex << fId32 << std::dec <<
". Ignored.");
192 int ftId=
m_onlineHelper->feedthrough_Id(fId).get_identifier32().get_compact();
194 ATH_MSG_DEBUG(
"Feedthrough with id " << std::hex << ftId << std::dec <<
" not in preselection. Ignored.");
199 while (BlStruct->
getNextEnergy(fcNb,energy,time,quality,gain)) {
200 if (fcNb>=NthisFebChannel)
203 uint16_t iquality = 0;
204 uint16_t iprovenance = 0x1000;
206 iprovenance |= 0x2000;
207 iquality = (quality & 0xFFFF);
210 coll.push_back(chan);
220 const unsigned MAXMINOR = 12;
221 const unsigned MAXTYPE = 10;
223 if (rodMinorVersion > MAXMINOR || robBlockType > MAXTYPE) {
225 <<
" / " << rodMinorVersion);
228 std::vector<std::unique_ptr<LArRodBlockStructure> >& blstructs =
230 unsigned int index = robBlockType * (MAXMINOR+1) + rodMinorVersion;
231 if (blstructs.empty()) {
232 blstructs.resize ((MAXMINOR+1)*(MAXTYPE+1));
234 if (!blstructs[
index]) {
237 if (!blstructs[
index]) {
239 <<
" / " << rodMinorVersion);
244 ATH_MSG_DEBUG(
"Found version " << rodMinorVersion <<
" of Rod block type " << robBlockType);
247 return blstructs[
index].get();
256 ATH_MSG_DEBUG(
"Prepare LArRodBlockStructure. Got a fragement of size " << n);
260 eformat::helper::Version ver(robFrag.rod_version());
261 const uint16_t rodMinorVersion=ver.minor_version();
262 const uint32_t rodBlockType=robFrag.rod_detev_type()&0xff;
269 constexpr int maxMess = 100;
270 static std::atomic<int> nMess = 1;
271 int thismess = nMess++;
272 if (thismess <= maxMess) {
273 ATH_MSG_ERROR(
"Could not set fragment (wrong number of samples in data ?) - container will not be filled");
274 if (thismess == maxMess)
283 BlStruct->
setGain(RequestedGain);
292std::unique_ptr<LArRodBlockStructure>
294 unsigned int rodMinorVersion)
const
296 switch (rodBlockType) {
307 switch (rodMinorVersion) {
311 auto bl = std::make_unique<LArRodBlockPhysicsV5>(this->msgSvc().
get());
319 auto bl = std::make_unique<LArRodBlockPhysicsV6>(this->msgSvc().
get());
354 return std::unique_ptr<LArRodBlockStructure>();
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
StatusCode LArRodDecoder::initialize ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
static const InterfaceID IID_ILArRodDecoder("LArRodDecoder", 1, 0)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Container for LArRawChannel (IDC using LArRawChannelCollection).
Liquid Argon ROD output object base class.
bool setFragment(const uint32_t *p, uint32_t n)
virtual uint32_t hasPhysicsBlock() const
virtual int getNextEnergy(int &channelNumber, int32_t &energy, int32_t &time, int32_t &quality, uint32_t &gain)
uint32_t getFEBID() const
virtual int setGain(const int GainValue)
virtual uint32_t offlineCheckSum() const
void setFirstSample(const int rearrangeFirstSample)
virtual uint32_t getStatus() const
virtual uint32_t onlineCheckSum() const
virtual ~LArRodDecoder()
Destructor.
std::vector< std::string > m_LArCellCorrNames
LArRodBlockStructure * prepareBlockStructure1(const uint16_t rodMinorVersion, const uint32_t robBlockType) const
std::vector< int > m_vFTPreselection
const LArOnlineID * m_onlineHelper
std::vector< unsigned int > m_IgnoreCheckFEBs
std::unique_ptr< LArRodBlockStructure > makeBlockStructure(unsigned int rodBlockType, unsigned int rodMinorVersion) const
static const InterfaceID & interfaceID()
float m_LArCellEthreshold
unsigned short m_requiredPhysicsNSamples
std::vector< int > m_vBEPreselection
void fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, const uint32_t *p, uint32_t n, LArRawChannelContainer &coll, const CaloGain::CaloGain gain) const
LArRodBlockStructure * prepareBlockStructure(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, const uint32_t *p, uint32_t n, const CaloGain::CaloGain RequestedGain) const
std::vector< int > m_vPosNegPreselection
LArRodDecoder(const std::string &type, const std::string &name, const IInterface *parent)
Constructor Standard AlgTool constructor.
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
eformat::ROBFragment< PointerType > ROBFragment
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.