ATLAS Offline Software
Loading...
Searching...
No Matches
ZdcRecNoiseTool Class Reference

#include <ZdcRecNoiseTool.h>

Inheritance diagram for ZdcRecNoiseTool:
Collaboration diagram for ZdcRecNoiseTool:

Public Member Functions

 ZdcRecNoiseTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~ZdcRecNoiseTool ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
int readPedestals ()
int writePedestals ()
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

std::string m_pedestalDir
std::string m_pedestalFile
std::unique_ptr< ZdcDigitsCollectionm_pedestalData {}
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 35 of file ZdcRecNoiseTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ ZdcRecNoiseTool()

ZdcRecNoiseTool::ZdcRecNoiseTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 49 of file ZdcRecNoiseTool.cxx.

51 :
52
53 AthAlgTool(type, name, parent)
54
55{
56 //Declare properties here...
57
58 declareInterface<ZdcRecNoiseTool>(this);
59
60 declareProperty("PedestalsDirectory", m_pedestalDir = "/afs/cern.ch/user/l/leite/public/ZdcData/Pedestals",
61 "Pedestal files directory");
62 declareProperty("PedestalsFile", m_pedestalFile = "zdc_pedestal_0000.data",
63 "Pedestal file name");
64
65}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::string m_pedestalDir
std::string m_pedestalFile

◆ ~ZdcRecNoiseTool()

ZdcRecNoiseTool::~ZdcRecNoiseTool ( )
virtual

Definition at line 69 of file ZdcRecNoiseTool.cxx.

70{
71}

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode ZdcRecNoiseTool::finalize ( )
virtual

Definition at line 186 of file ZdcRecNoiseTool.cxx.

187{
188 msg(MSG::INFO) << "Finalizing " << name() << endmsg;
189 return StatusCode::SUCCESS;
190}
#define endmsg
MsgStream & msg() const

◆ initialize()

StatusCode ZdcRecNoiseTool::initialize ( )
virtual

Definition at line 173 of file ZdcRecNoiseTool.cxx.

174{
175 msg(MSG::INFO) << "Initializing " << name() << endmsg;
176
177 //Get the pedestal information for the channels.
178 //For now, this is a file; later on it will be moved to a database
179
180
181 return StatusCode::SUCCESS;
182}

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & ZdcRecNoiseTool::interfaceID ( )
static

Definition at line 41 of file ZdcRecNoiseTool.cxx.

42{
44
45}
static const InterfaceID IID_IZdcRecNoiseTool("ZdcRecNoiseTool", 1, 1)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ readPedestals()

int ZdcRecNoiseTool::readPedestals ( )

Definition at line 75 of file ZdcRecNoiseTool.cxx.

76{
77 m_pedestalData = std::make_unique<ZdcDigitsCollection>();
78
79 int nsamples = 0;
80 int i = 0;
81 unsigned int id;
82
83 //Read the file name as passed to the tool for the pedestals
84 std::string str = m_pedestalDir + m_pedestalFile;
85 std::ifstream infile;
86
87 infile.open(str.data(), std::ifstream::in);
88 if (infile.fail()) {
89 msg(MSG::ERROR) << "ZDC ---> No pedestal file available - aborting ";
90 return 0;
91 }
92 else {
94 std::vector<int> fadc00(nsamples);
95 std::vector<int> fadc01(nsamples);
96 std::vector<int> fadc10(nsamples);
97 std::vector<int> fadc11(nsamples);
98 int sz = sizeof(int)*nsamples;
99 i = 0;
100 while (infile.good()) {
101 infile.read (charAddress(id),sizeof(id));
102 infile.read (charAddress(fadc00[0]),sz);
103 infile.read (charAddress(fadc01[0]),sz);
104 infile.read (charAddress(fadc10[0]),sz);
105 infile.read (charAddress(fadc11[0]),sz);
106
107 ZdcDigits* digits_p = new ZdcDigits(Identifier(id));
108 digits_p->set_digits_gain0_delay0(fadc00);
109 digits_p->set_digits_gain0_delay1(fadc01);
110 digits_p->set_digits_gain1_delay0(fadc10);
111 digits_p->set_digits_gain1_delay0(fadc11);
112 m_pedestalData->push_back(digits_p);
113 i++;
114 }
115 msg(MSG::INFO) << "ZDC ---> Read " << i << " pedestal channels from file" ;
116 }
117return i;
118}
static Double_t sz
void set_digits_gain0_delay1(const std::vector< int > &v)
void set_digits_gain0_delay0(const std::vector< int > &v)
void set_digits_gain1_delay0(const std::vector< int > &v)
std::unique_ptr< ZdcDigitsCollection > m_pedestalData
str infile
Definition run.py:13

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

◆ writePedestals()

int ZdcRecNoiseTool::writePedestals ( )

Definition at line 122 of file ZdcRecNoiseTool.cxx.

123{
124 //remove this
125 m_pedestalData = std::make_unique<ZdcDigitsCollection>();
126
127 int nsamples = 0;
128 int i = 0;
129 unsigned int id;
130
131 //Read the file name as passed to the tool for the pedestals
132 std::string str = m_pedestalDir + m_pedestalFile;
133 std::ofstream outfile;
134
135 //TODO: First check if it exists, never overwrites
136 //TODO: Check if size of pedestal collection is ok
137
138 outfile.open(str.data(), std::ofstream::out);
139 if (outfile.fail()) {
140 msg(MSG::ERROR) << "ZDC ---> Cannot create Pedestal File - aborting ";
141 return 0;
142 }
143 else {
144 std::vector<int> fadc00(nsamples);
145 std::vector<int> fadc01(nsamples);
146 std::vector<int> fadc10(nsamples);
147 std::vector<int> fadc11(nsamples);
148 outfile << nsamples;
149 int sz = sizeof(int)*nsamples;
150
151 for (const ZdcDigits* p : *m_pedestalData) {
152 id = p->identify().get_identifier32().get_compact();
153 outfile.write(charAddress(id), sizeof(id));
154
155 fadc00 = p->get_digits_gain0_delay0();
156 fadc01 = p->get_digits_gain0_delay1();
157 fadc10 = p->get_digits_gain1_delay0();
158 fadc11 = p->get_digits_gain1_delay1();
159 outfile.write (charAddress(fadc00), sz);
160 outfile.write (charAddress(fadc01), sz);
161 outfile.write (charAddress(fadc10), sz);
162 outfile.write (charAddress(fadc11), sz);
163 i++;
164 }
165 }
166 return i;
167}

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_pedestalData

std::unique_ptr<ZdcDigitsCollection> ZdcRecNoiseTool::m_pedestalData {}
private

Definition at line 57 of file ZdcRecNoiseTool.h.

57{};

◆ m_pedestalDir

std::string ZdcRecNoiseTool::m_pedestalDir
private

Definition at line 54 of file ZdcRecNoiseTool.h.

◆ m_pedestalFile

std::string ZdcRecNoiseTool::m_pedestalFile
private

Definition at line 55 of file ZdcRecNoiseTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: