ATLAS Offline Software
TileRawChannelGainFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Tile includes
11 
12 // Atlas includes
14 #include "StoreGate/ReadHandle.h"
15 #include "StoreGate/WriteHandle.h"
16 
17 
19 
21 
24 
25  ATH_MSG_INFO( "Input raw channel container: '" << m_inputContainerKey
26  << "' output container: '" << m_outputContainerKey << "'" );
27 
28 
29  return StatusCode::SUCCESS;
30 }
31 
32 
33 StatusCode TileRawChannelGainFilter::execute(const EventContext& ctx) const {
34 
36  ATH_CHECK( inputContainer.isValid() );
37 
38  TileRawChannelUnit::UNIT rawChanUnit = inputContainer->get_unit();
39  TileFragHash::TYPE rawChanType = inputContainer->get_type();
40 
41  // Create new container for filtered raw channels
42  auto outputContainer = std::make_unique<TileRawChannelContainer>(false, rawChanType, rawChanUnit, SG::VIEW_ELEMENTS);
43  outputContainer->set_bsflags(inputContainer->get_bsflags());
44 
45  const TileRawChannel* rawChannels[2][48] = {{0}}; // 2 gains and 48 channels
46 
47  TileRawChannelContainer::const_iterator collIt = inputContainer->begin();
48  TileRawChannelContainer::const_iterator collEnd = inputContainer->end();
49  for (; collIt != collEnd; ++collIt) {
50  const TileRawChannelCollection* rawChannelCollection = *collIt;
51 
52  memset(rawChannels, 0, sizeof(rawChannels));
53 
54  for (const TileRawChannel* rawChannel : *rawChannelCollection) {
55  HWIdentifier adcId = rawChannel->adc_HWID();
56  int channel = m_tileHWID->channel(adcId);
57  int gain = m_tileHWID->adc(adcId);
58  rawChannels[gain][channel] = rawChannel;
59  }
60 
61  auto outCollection = std::make_unique<ConstDataVector<TileRawChannelCollection>>(SG::VIEW_ELEMENTS, rawChannelCollection->identify());
62  outCollection->reserve(TileCalibUtils::MAX_CHAN);
63 
64  for (unsigned int channel = 0; channel < TileCalibUtils::MAX_CHAN; ++channel) {
65 
66  const TileRawChannel* rawChannelLG = rawChannels[0][channel];
67  const TileRawChannel* rawChannelHG = rawChannels[1][channel];
68 
69  if (rawChannelHG && rawChannelLG) {
70  if ((rawChannelHG->pedestal() > OVERFLOW_PEDESTAL_MIN) && (rawChannelHG->pedestal() < OVERFLOW_PEDESTAL_MAX)) {
71  ATH_MSG_VERBOSE("Overflowed HG: " << (std::string) *rawChannelHG << ", ped = " << rawChannelHG->pedestal());
72  ATH_MSG_VERBOSE("Save LG: " << (std::string) *rawChannelLG << ", ped = " << rawChannelLG->pedestal());
73  outCollection->push_back(rawChannelLG);
74  } else {
75  ATH_MSG_VERBOSE("Save HG: " << (std::string) *rawChannelHG << ", ped = " << rawChannelHG->pedestal());
76  outCollection->push_back(rawChannelHG);
77  }
78  } else if (rawChannelLG) {
79  ATH_MSG_VERBOSE("Save LG (only available): " << (std::string) *rawChannelLG << ", ped = " << rawChannelLG->pedestal());
80  outCollection->push_back(rawChannelLG);
81  } else if (rawChannelHG) {
82  ATH_MSG_VERBOSE("Save HG (only available): " << (std::string) *rawChannelHG << ", ped = " << rawChannelHG->pedestal());
83  outCollection->push_back(rawChannelHG);
84  }
85 
86  }
87 
88  ATH_CHECK( outputContainer->addCollection(outCollection.release()->asDataVector(), collIt.hashId()) );
89  }
90 
91  SG::WriteHandle<TileRawChannelContainer> outputRawChannelContainer(m_outputContainerKey, ctx);
92  ATH_CHECK( outputRawChannelContainer.record(std::move(outputContainer)) );
93 
94  return StatusCode::SUCCESS;
95 }
96 
97 
99 
100  ATH_MSG_DEBUG( "in finalize()" );
101 
102  return StatusCode::SUCCESS;
103 }
104 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TileRawChannel.h
TileRawChannelGainFilter::m_tileHWID
const TileHWID * m_tileHWID
Definition: TileRawChannelGainFilter.h:38
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TileRawChannelGainFilter::OVERFLOW_PEDESTAL_MAX
@ OVERFLOW_PEDESTAL_MAX
Definition: TileRawChannelGainFilter.h:39
TileRawChannelGainFilter.h
TileRawChannelGainFilter::m_inputContainerKey
SG::ReadHandleKey< TileRawChannelContainer > m_inputContainerKey
Definition: TileRawChannelGainFilter.h:32
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
TileRawChannel::pedestal
float pedestal(void) const
Definition: TileRawChannel.h:106
TileFragHash::TYPE
TYPE
initialize
Definition: TileFragHash.h:33
TileRawChannelGainFilter::finalize
StatusCode finalize() override
Definition: TileRawChannelGainFilter.cxx:98
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
TileCalibUtils.h
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
HWIdentifier
Definition: HWIdentifier.h:13
TileHWID::channel
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
Definition: TileHWID.h:189
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
TileRawChannelContainer.h
WriteHandle.h
Handle class for recording to StoreGate.
TileHWID::adc
int adc(const HWIdentifier &id) const
extract adc field from HW identifier
Definition: TileHWID.h:193
TileHWID.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TileRawDataContainer::get_bsflags
uint32_t get_bsflags() const
Definition: TileRawDataContainer.h:64
TileRawChannel
Definition: TileRawChannel.h:35
TileRawChannelGainFilter::m_outputContainerKey
SG::WriteHandleKey< TileRawChannelContainer > m_outputContainerKey
Definition: TileRawChannelGainFilter.h:35
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IdentifiableContainerMT::end
const_iterator end() const
return const_iterator for end of container
Definition: IdentifiableContainerMT.h:242
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
IdentifiableContainerMT::const_iterator
Definition: IdentifiableContainerMT.h:82
IdentifiableContainerMT::begin
const_iterator begin() const
return const_iterator for first entry
Definition: IdentifiableContainerMT.h:236
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
TileRawChannelGainFilter::OVERFLOW_PEDESTAL_MIN
@ OVERFLOW_PEDESTAL_MIN
Definition: TileRawChannelGainFilter.h:39
TileRawChannelUnit::UNIT
UNIT
Definition: TileRawChannelUnit.h:16
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
IdentifiableContainerMT::const_iterator::hashId
IdentifierHash hashId() const
hashId of the pointed-to element
Definition: IdentifiableContainerMT.h:130
TileRawChannelCollection
Definition: TileRawChannelCollection.h:12
TileRawDataContainer::get_type
TYPE get_type() const
Definition: TileRawDataContainer.h:62
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
TileRawChannelGainFilter::execute
StatusCode execute(const EventContext &ctx) const override
Definition: TileRawChannelGainFilter.cxx:33
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
TileRawDataContainer::get_unit
UNIT get_unit() const
Definition: TileRawDataContainer.h:60
TileRawChannelGainFilter::initialize
StatusCode initialize() override
Definition: TileRawChannelGainFilter.cxx:18
ReadHandle.h
Handle class for reading from StoreGate.
TileCalibUtils::MAX_CHAN
static const unsigned int MAX_CHAN
Number of channels in drawer.
Definition: TileCalibUtils.h:141