ATLAS Offline Software
ReadTBLArCalibDigits.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include <vector>
8 
9 ReadTBLArCalibDigits::ReadTBLArCalibDigits(const std::string& name, ISvcLocator* pSvcLocator)
10  : AthAlgorithm(name, pSvcLocator),
11  m_count(0),
12  m_onlineHelper(0)
13 {
14  declareProperty("ContainerKey",m_containerKey="");
15  declareProperty("DumpFile",m_dumpFile="");
16 }
17 
19 {
20 }
21 
23 {
24  MsgStream log(msgSvc(), name());
25  log << MSG::INFO << "Initialize" << endmsg;
26 
27  StatusCode sc = detStore()->retrieve(m_onlineHelper, "LArOnlineID");
28  if (sc.isFailure()) {
29  log << MSG::ERROR << "Could not get LArOnlineID helper" << endmsg;
30  return StatusCode::FAILURE;
31  }
32 
33  if (m_dumpFile.size()>0)
34  m_outfile.open(m_dumpFile.c_str(),std::ios::out);
35 
36  m_count=0;
37 
38  log << MSG::INFO << "======== ReadTBLArCalibDigits initialize successfully ========" << endmsg;
39  return StatusCode::SUCCESS;
40 }
41 
42 
44  MsgStream log(msgSvc(), name());
45 
46  m_count++;
47 
48  int cellCounter = 0;
49 
50  StatusCode sc;
51 
52  log << MSG::DEBUG << "======== executing event "<< m_count << " ========" << endmsg;
53  log << MSG::DEBUG << "Retrieving TBLArCalibDigitContainer. Key= " << m_containerKey << endmsg;
54  TBLArCalibDigitContainer* larCalibDigitCont;
55  sc = evtStore()->retrieve(larCalibDigitCont ,m_containerKey);
56 
57  if (sc.isFailure()) {
58  log << MSG::FATAL << " Cannot read TBLArCalibDigitContainer from StoreGate! key=" << m_containerKey << endmsg;
59  return StatusCode::FAILURE;
60  }
61 
62  log << MSG::VERBOSE << "Now loop over container " << endmsg;
63 
64  for (const LArCalibDigit* digit : *larCalibDigitCont) {
65 
66  log << MSG::VERBOSE << " Get hardware ID " << endmsg;
67 
68  HWIdentifier chid=digit->hardwareID();
69 
70  log << MSG::VERBOSE << " chid = " << chid << endmsg;
71 
72  const std::vector<short>& vSamples=digit->samples();
73  int nSamples=vSamples.size();
74 
75  log << MSG::VERBOSE << " nSamples = " << nSamples << endmsg;
76 
77  if (m_outfile.is_open()) {
78  m_outfile << "Evt="<< m_count << " ";
79  m_outfile << "FebId= 0x" << std::hex << m_onlineHelper->feb_Id(chid).get_compact()
80  << std::dec << " Ch= " << m_onlineHelper->channel(chid) << " ";
81  for(int i=0; i<nSamples; i++) {
82  m_outfile << " " << vSamples[i];
83  }
84  m_outfile << " G=" << digit->gain() << std::endl;
85  }
86 
87  cellCounter++;
88 
89  log << MSG::VERBOSE << " cellCounter = " << cellCounter << endmsg;
90 
91  }
92 
93  log << MSG::DEBUG << "Event " << m_count << " contains " << cellCounter << " channels" << endmsg;
94 
95  return StatusCode::SUCCESS;
96 
97 }
98 
100 {
101  MsgStream log(msgSvc(), name());
102  if (m_outfile.is_open())
103  m_outfile.close();
104  log << MSG::INFO << "finalize ReadTBLArCalibDigits" << endmsg;
105  return StatusCode::SUCCESS;
106 }
ReadTBLArCalibDigits::finalize
StatusCode finalize()
Definition: ReadTBLArCalibDigits.cxx:99
ReadTBLArCalibDigits::initialize
StatusCode initialize()
Definition: ReadTBLArCalibDigits.cxx:22
ReadTBLArCalibDigits::m_containerKey
std::string m_containerKey
Definition: ReadTBLArCalibDigits.h:32
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
ReadTBLArCalibDigits::m_onlineHelper
const LArOnlineID * m_onlineHelper
Definition: ReadTBLArCalibDigits.h:30
ReadTBLArCalibDigits::m_dumpFile
std::string m_dumpFile
Definition: ReadTBLArCalibDigits.h:33
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
HWIdentifier
Definition: HWIdentifier.h:13
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
TBLArCalibDigitContainer
Liquid Argon Calibration Digit Container
Definition: TBLArCalibDigitContainer.h:26
LArOnlineID_Base::channel
int channel(const HWIdentifier id) const
Return the channel number of a hardware cell identifier channel = [0,127] in all FEB.
Definition: LArOnlineID_Base.cxx:1967
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ReadTBLArCalibDigits::~ReadTBLArCalibDigits
~ReadTBLArCalibDigits()
Definition: ReadTBLArCalibDigits.cxx:18
ReadTBLArCalibDigits::m_outfile
std::ofstream m_outfile
Definition: ReadTBLArCalibDigits.h:31
AthAlgorithm
Definition: AthAlgorithm.h:47
LArOnlineID_Base::feb_Id
HWIdentifier feb_Id(int barrel_ec, int pos_neg, int feedthrough, int slot) const
Create feb_Id from fields.
Definition: LArOnlineID_Base.cxx:1483
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArCalibDigit
Base class for LArDigits taken during calibration runs.
Definition: LArCalibDigit.h:29
ReadTBLArCalibDigits::m_count
int m_count
Definition: ReadTBLArCalibDigits.h:29
ReadTBLArCalibDigits::execute
StatusCode execute()
Definition: ReadTBLArCalibDigits.cxx:43
Identifier::get_compact
value_type get_compact(void) const
Get the compact id.
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LArDigits2NtupleDumper.nSamples
nSamples
Definition: LArDigits2NtupleDumper.py:70
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
ReadTBLArCalibDigits.h
ReadTBLArCalibDigits::ReadTBLArCalibDigits
ReadTBLArCalibDigits(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ReadTBLArCalibDigits.cxx:9
LArOnlineID.h