ATLAS Offline Software
LArAccumulatedCalibDigitContSplitter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "GaudiKernel/MsgStream.h"
8 
11 
14 
17 
18 #include <fstream>
19 
21  : AthAlgorithm(name, pSvcLocator),m_recAll(false), m_numLine(4),
22  m_event_counter(0)
23 {
24  declareProperty("KeyList", m_keylist);
25  declareProperty("RecAllCells", m_recAll);
26  declareProperty("NumberSplitted", m_numLine);
27 
28  declareProperty("KeyOutputList", m_OutputList);
29 }
30 
32 = default;
33 
35 {
36  // Default list
37  if (m_keylist.empty()){ // Not key list given
38  m_keylist.emplace_back("HIGH");
39  m_keylist.emplace_back("MEDIUM");
40  m_keylist.emplace_back("LOW");
41  }
42 
43  m_event_counter = 0;
44 
45  return StatusCode::SUCCESS;
46 }
47 
48 
50 {
51  if ( m_event_counter < 100 || ( m_event_counter < 1000 && m_event_counter%100==0 ) || m_event_counter%1000==0 )
52  ATH_MSG_INFO ( "Processing event " << m_event_counter );
54 
55  if (m_keylist.empty()) {
56  ATH_MSG_ERROR ( "Key list is empty! No containers to process!" );
57  return StatusCode::FAILURE;
58  }
59 
60  // execute() method...
62  return StatusCode::SUCCESS;
63 
64 }
65 
67 {
68  typedef ConstDataVector<LArAccumulatedCalibDigitContainer> ConstAccumContainer;
69  const LArAccumulatedCalibDigitContainer* larAccumulatedCalibDigitContainer;
70 
71  // First loop over containers to get delayScale.
72  float delayScale = 1*CLHEP::ns;
73  for (const std::string& key : m_keylist) {
74  if (evtStore()->retrieve(larAccumulatedCalibDigitContainer,key).isSuccess()) {
75  if (!larAccumulatedCalibDigitContainer->empty()) {
76  delayScale = larAccumulatedCalibDigitContainer->getDelayScale();
77  }
78  }
79  }
80 
81  std::vector<std::unique_ptr<ConstAccumContainer> > calibDigitCont (m_numLine);
82  for (unsigned int i=0;i<m_numLine;++i) {
83  calibDigitCont[i]= std::make_unique<ConstAccumContainer>(SG::VIEW_ELEMENTS,
84  delayScale);
85  }
86 
87  //Loop over all containers that are to be processed (e.g. different gains)
88  for (const std::string& key : m_keylist) {
89  StatusCode sc = evtStore()->retrieve(larAccumulatedCalibDigitContainer,key);
90  if (sc.isFailure()) {
91  ATH_MSG_WARNING ( "Cannot read LArAccumulatedCalibDigitContainer from StoreGate! key=" << key );
92  continue; // Try next container
93  }
94 
95  if (larAccumulatedCalibDigitContainer->empty()) {
96  ATH_MSG_DEBUG ( "LArAccumulatedCalibDigitContainer with key=" << key << " is empty " );
97  continue; // at this event LArAccumulatedCalibDigitContainer is empty, do not even try to loop on it...
98  }
99 
100  for (const LArAccumulatedCalibDigit* digit : *larAccumulatedCalibDigitContainer) {
101  //HWIdentifier chid=digit->hardwareID();
102  CaloGain::CaloGain gain=digit->gain();
103 
104  if (gain<0 || gain>CaloGain::LARNGAIN) {
105  ATH_MSG_ERROR ( "Found not-matching gain number ("<< (int)gain <<")" );
106  return StatusCode::FAILURE;
107  }
108 
109  if ( (!m_recAll) && (!digit->isPulsed()) ) continue ; // If not all cells and not pulsed, skip cell
110 
111  for(unsigned int iLine=1;iLine<=m_numLine;++iLine){
112  if(digit->isPulsed(iLine)){
113  calibDigitCont[iLine-1]->push_back(digit);
114  }
115  }
116  } //End loop over all cells
117 
118  } //End loop over all containers
119 
120  // Record splitted containers
121  for (unsigned int i=0;i<m_OutputList.size();++i) {
122  std::string key = m_OutputList[i];
123  ATH_CHECK( evtStore()->record(std::move(calibDigitCont[i]),key) );
124  }
125 
126  return StatusCode::SUCCESS;
127 }
128 
129 
130 
132 {
133 // MsgStream log(msgSvc(), name());
134 // log << MSG::INFO << " finished." << endmsg;
135  return StatusCode::SUCCESS;
136 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArCalibDigitContainer.h
LArAccumulatedCalibDigit
Data class for calibration ADC samples preprocessed by the DSP.
Definition: LArAccumulatedCalibDigit.h:42
LArEM_ID.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArAccumulatedCalibDigitContSplitter::m_numLine
unsigned m_numLine
Definition: LArAccumulatedCalibDigitContSplitter.h:41
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.
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
LArAccumulatedCalibDigitContSplitter.h
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
CaloGain::LARNGAIN
@ LARNGAIN
Definition: CaloGain.h:19
LArAccumulatedCalibDigitContSplitter::m_recAll
bool m_recAll
Definition: LArAccumulatedCalibDigitContSplitter.h:40
LArAccumulatedCalibDigitContSplitter::executeWithAccumulatedDigits
StatusCode executeWithAccumulatedDigits()
Definition: LArAccumulatedCalibDigitContSplitter.cxx:66
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
LArAccumulatedCalibDigitContSplitter::execute
StatusCode execute()
Definition: LArAccumulatedCalibDigitContSplitter.cxx:49
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
LArAccumulatedCalibDigitContSplitter::LArAccumulatedCalibDigitContSplitter
LArAccumulatedCalibDigitContSplitter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArAccumulatedCalibDigitContSplitter.cxx:20
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArAccumulatedCalibDigitContSplitter::~LArAccumulatedCalibDigitContSplitter
~LArAccumulatedCalibDigitContSplitter()
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
LArAccumulatedCalibDigitContSplitter::initialize
StatusCode initialize()
Definition: LArAccumulatedCalibDigitContSplitter.cxx:34
LArAccumulatedCalibDigitContainer.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthAlgorithm
Definition: AthAlgorithm.h:47
LArAccumulatedCalibDigitContSplitter::stop
StatusCode stop()
Definition: LArAccumulatedCalibDigitContSplitter.cxx:131
LArAccumulatedCalibDigitContSplitter::m_keylist
std::vector< std::string > m_keylist
Definition: LArAccumulatedCalibDigitContSplitter.h:37
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
LArAccumulatedCalibDigitContSplitter::m_event_counter
unsigned m_event_counter
Definition: LArAccumulatedCalibDigitContSplitter.h:43
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
LArWaveHelper.h
LArAccumulatedCalibDigitContainer::getDelayScale
double getDelayScale() const
get the delay Scale
Definition: LArAccumulatedCalibDigitContainer.h:38
LArAccumulatedCalibDigitContSplitter::m_OutputList
std::vector< std::string > m_OutputList
Definition: LArAccumulatedCalibDigitContSplitter.h:38
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
python.SystemOfUnits.ns
int ns
Definition: SystemOfUnits.py:130
LArAccumulatedCalibDigitContainer
Container class for LArAccumulatedCalibDigit.
Definition: LArAccumulatedCalibDigitContainer.h:25
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
LArOnlineID.h
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37