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

This algorithm allows to read wave forms from asci file and builds a LArPhysWaveContainer containing the corresponding PhysWave. More...

#include <LArPhysWaveFromAscii.h>

Inheritance diagram for LArPhysWaveFromAscii:
Collaboration diagram for LArPhysWaveFromAscii:

Public Member Functions

 LArPhysWaveFromAscii (const std::string &name, ISvcLocator *pSvcLocator)
 ~LArPhysWaveFromAscii ()
virtual StatusCode execute ()
 StatusCode initialize() = default;.
virtual StatusCode stop () final
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
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 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

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

UnsignedIntegerProperty m_skipPoints {this, "SkipPoints", 0}
 the first m_skipPoints points of the waveform in the file are skipped
UnsignedIntegerProperty m_prefixPoints {this, "PrefixPoints", 0}
 make a PhysWave with the first m_prefixPoints as zeros
StringProperty m_input_file_name {this, "InputFile", {}, "Input ascii file name" }
 list of input ntuple file names
StringProperty m_groupingType {this,"GroupingType", "ExtendedFeedThrough", "Which COOL channel grouping to use"}
 Grouping type. Default is Feedthrough.
UnsignedIntegerProperty m_gain {this, "Gain", 0}
 which gain to store ?
BooleanProperty m_isSC {this,"isSC",false,"Running for SuperCells ?"}
 is SC ?
BooleanProperty m_interpolate {this,"Interpolate",false,"Needs interpolate input data ?"}
 needs interpolation ?
BooleanProperty m_hasIndex {this,"Index",false,"Has index in input data ?"}
 has index in input data ?
StringProperty m_store_key {this, "StoreKey", "FromAscii", "SG key to create"}
 key of the PhysWave collection
DataObjIDColl m_extendedExtraObjects
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

This algorithm allows to read wave forms from asci file and builds a LArPhysWaveContainer containing the corresponding PhysWave.

Definition at line 17 of file LArPhysWaveFromAscii.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ LArPhysWaveFromAscii()

LArPhysWaveFromAscii::LArPhysWaveFromAscii ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 18 of file LArPhysWaveFromAscii.cxx.

18:AthAlgorithm(name, pSvcLocator) {};
AthAlgorithm()
Default constructor:

◆ ~LArPhysWaveFromAscii()

LArPhysWaveFromAscii::~LArPhysWaveFromAscii ( )
default

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::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 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::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< Algorithm > >::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< Algorithm > >::evtStore ( )
inlineinherited

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

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

virtual StatusCode LArPhysWaveFromAscii::execute ( )
inlinevirtual

StatusCode initialize() = default;.

Definition at line 26 of file LArPhysWaveFromAscii.h.

26{return StatusCode::SUCCESS;}

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::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

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::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.

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msgLvl()

bool AthCommonMsg< Algorithm >::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< Algorithm > >::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.

◆ 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< Algorithm > >::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< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ stop()

StatusCode LArPhysWaveFromAscii::stop ( )
finalvirtual

Definition at line 22 of file LArPhysWaveFromAscii.cxx.

23{
24 ATH_MSG_INFO ( "... in stop()" );
25
26 // input file
27 std::ifstream inf(m_input_file_name);
28 if(!inf.is_open()){
29 ATH_MSG_ERROR("Could not open input file "<<m_input_file_name);
30 return StatusCode::FAILURE;
31 }
32
33 // Create new LArPhysWaveContainer
34 auto larPhysWaveContainerNew = std::make_unique<LArPhysWaveContainer>();
35 ATH_CHECK ( larPhysWaveContainerNew->setGroupingType(m_groupingType, msg()) );
36 ATH_CHECK ( larPhysWaveContainerNew->initialize() );
37
38 unsigned int hwid=0;
39 unsigned int lcounter=0;
40 float timdiff=0;
41 float lasttime=0;
42 // loop over lines
43 std::string line="";
44 std::vector<double> wave;
45 std::vector<double> wave_err;
46 std::vector<int> wave_trig;
47
48 unsigned lsize = m_hasIndex ? 4 : 3;
49
50 while ( ! std::getline(inf, line).eof() )
51 {
52 std::vector<std::string> strvec;
53 boost::split(strvec, line, boost::is_any_of(" "));
54 if(strvec.size() != lsize) {
55 ATH_MSG_WARNING("Wrong line: "<<line<<", skipped "<<strvec.size());
56 continue;
57 }
58 //check if we have new channel
59 if(!hwid) { // first line
60 if(std::stoi(strvec[1]) != 0) {
61 ATH_MSG_WARNING("Inconsistent first line of channel: "<<line);
62 continue;
63 }
64 hwid = std::stoi(strvec[0]);
65 lcounter=0;
66 timdiff=0;
67 lasttime=std::stof(strvec[lsize - 2]);
68 wave.push_back(std::stod(strvec[lsize - 1]));
69 wave_err.push_back(0);
70 wave_trig.push_back(1);
71 } else if(hwid != std::stoul(strvec[0])) { // new channels
72 // store previous wave
73 unsigned int skipped = 0;
74 unsigned int limit = wave.size();
76 std::vector<double> store_wave(limit,0);
77 std::vector<double> store_wave_err(limit,0);
78 std::vector<int> store_wave_trig(limit,1);
79 for ( unsigned int i = 0; i < limit; i++ ) {
80 if ( skipped >= m_skipPoints ) {
81 store_wave[i-m_skipPoints+m_prefixPoints]=wave[i];
82 store_wave_err[i-m_skipPoints+m_prefixPoints]=wave_err[i];
83 store_wave_trig[i-m_skipPoints+m_prefixPoints]=wave_trig[i];
84 }
85 else skipped++;
86 }
87
88 LArPhysWave newLArPhysWave(store_wave, store_wave_err, store_wave_trig, timdiff, 0, 0);
89 // Add physics wave to container
90 larPhysWaveContainerNew->setPdata(HWIdentifier(hwid), newLArPhysWave, (CaloGain::CaloGain)m_gain.value());
91
92 // reset vectors
93 wave.clear();
94 wave_err.clear();
95 wave_trig.clear();
96
97 if(m_hasIndex && std::stoi(strvec[1]) != 0) {
98 ATH_MSG_WARNING("Inconsistent first line of channel: "<<line);
99 continue;
100 }
101 hwid = std::stoi(strvec[0]);
102 lcounter=0;
103 timdiff=0;
104 lasttime=std::stof(strvec[lsize - 2]);
105 wave.push_back(std::stod(strvec[lsize - 1]));
106 wave_err.push_back(0);
107 wave_trig.push_back(1);
108
109 } else { // next line in channel
110 if(m_hasIndex && lcounter+1 != std::stoul(strvec[1])){ // wrong series ?
111 ATH_MSG_WARNING("Wrong next line: "<<line);
112 ATH_MSG_WARNING(lcounter+1 << " " << std::stoi(strvec[1]));
113 continue;
114 }
115 if(!timdiff) {
116 timdiff= std::stof(strvec[lsize - 2]) - lasttime;
117 } else {
118 if(int(timdiff) != int(std::stof(strvec[lsize - 2]) - lasttime)) {
119 ATH_MSG_WARNING("Non equal time bins ? "<<line);
120 ATH_MSG_WARNING(int(timdiff)<<" "<<int(std::stof(strvec[lsize - 2]) - lasttime)<<" "<<lasttime);
121 ++lcounter;
122 continue;
123 }
124 }
125 lasttime=std::stof(strvec[lsize - 2]);
126 wave.push_back(std::stod(strvec[lsize - 1]));
127 wave_err.push_back(0);
128 wave_trig.push_back(1);
129 ++lcounter;
130 }
131
132 }
133 // store last wave
134 unsigned int skipped = 0;
135 unsigned int limit = wave.size();
137 std::vector<double> store_wave(limit,0);
138 std::vector<double> store_wave_err(limit,0);
139 std::vector<int> store_wave_trig(limit,1);
140 for ( unsigned int i = 0; i < limit; i++ ) {
141 if ( skipped >= m_skipPoints ) {
142 store_wave[i-m_skipPoints+m_prefixPoints]=wave[i];
143 store_wave_err[i-m_skipPoints+m_prefixPoints]=wave_err[i];
144 store_wave_trig[i-m_skipPoints+m_prefixPoints]=wave_trig[i];
145 }
146 else skipped++;
147 }
148
149 LArPhysWave newLArPhysWave(store_wave, store_wave_err, store_wave_trig, timdiff, 0, 0);
150 // Add physics wave to container
151 larPhysWaveContainerNew->setPdata(HWIdentifier(hwid), newLArPhysWave, (CaloGain::CaloGain)m_gain.value());
152
153 ATH_CHECK( detStore()->record(std::move(larPhysWaveContainerNew),m_store_key) );
154 ATH_MSG_INFO ( "LArPhysWaveFromAscii finalized!" );
155 return StatusCode::SUCCESS;
156}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
const ServiceHandle< StoreGateSvc > & detStore() const
MsgStream & msg() const
StringProperty m_groupingType
Grouping type. Default is Feedthrough.
UnsignedIntegerProperty m_skipPoints
the first m_skipPoints points of the waveform in the file are skipped
UnsignedIntegerProperty m_gain
which gain to store ?
StringProperty m_input_file_name
list of input ntuple file names
UnsignedIntegerProperty m_prefixPoints
make a PhysWave with the first m_prefixPoints as zeros
StringProperty m_store_key
key of the PhysWave collection
BooleanProperty m_hasIndex
has index in input data ?
TStreamerInfo * inf

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
static Double_t sc
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::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< Algorithm > >::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

Member Data Documentation

◆ m_detStore

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

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

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

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_gain

UnsignedIntegerProperty LArPhysWaveFromAscii::m_gain {this, "Gain", 0}
private

which gain to store ?

Definition at line 40 of file LArPhysWaveFromAscii.h.

40{this, "Gain", 0};

◆ m_groupingType

StringProperty LArPhysWaveFromAscii::m_groupingType {this,"GroupingType", "ExtendedFeedThrough", "Which COOL channel grouping to use"}
private

Grouping type. Default is Feedthrough.

Definition at line 38 of file LArPhysWaveFromAscii.h.

38{this,"GroupingType", "ExtendedFeedThrough", "Which COOL channel grouping to use"};

◆ m_hasIndex

BooleanProperty LArPhysWaveFromAscii::m_hasIndex {this,"Index",false,"Has index in input data ?"}
private

has index in input data ?

Definition at line 46 of file LArPhysWaveFromAscii.h.

46{this,"Index",false,"Has index in input data ?"};

◆ m_input_file_name

StringProperty LArPhysWaveFromAscii::m_input_file_name {this, "InputFile", {}, "Input ascii file name" }
private

list of input ntuple file names

Definition at line 36 of file LArPhysWaveFromAscii.h.

36{this, "InputFile", {}, "Input ascii file name" };

◆ m_interpolate

BooleanProperty LArPhysWaveFromAscii::m_interpolate {this,"Interpolate",false,"Needs interpolate input data ?"}
private

needs interpolation ?

Definition at line 44 of file LArPhysWaveFromAscii.h.

44{this,"Interpolate",false,"Needs interpolate input data ?"};

◆ m_isSC

BooleanProperty LArPhysWaveFromAscii::m_isSC {this,"isSC",false,"Running for SuperCells ?"}
private

is SC ?

Definition at line 42 of file LArPhysWaveFromAscii.h.

42{this,"isSC",false,"Running for SuperCells ?"};

◆ m_prefixPoints

UnsignedIntegerProperty LArPhysWaveFromAscii::m_prefixPoints {this, "PrefixPoints", 0}
private

make a PhysWave with the first m_prefixPoints as zeros

Definition at line 34 of file LArPhysWaveFromAscii.h.

34{this, "PrefixPoints", 0};

◆ m_skipPoints

UnsignedIntegerProperty LArPhysWaveFromAscii::m_skipPoints {this, "SkipPoints", 0}
private

the first m_skipPoints points of the waveform in the file are skipped

Definition at line 32 of file LArPhysWaveFromAscii.h.

32{this, "SkipPoints", 0};

◆ m_store_key

StringProperty LArPhysWaveFromAscii::m_store_key {this, "StoreKey", "FromAscii", "SG key to create"}
private

key of the PhysWave collection

Definition at line 49 of file LArPhysWaveFromAscii.h.

49{this, "StoreKey", "FromAscii", "SG key to create"};

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.


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