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

#include <PixeldEdxAlg.h>

Inheritance diagram for PixeldEdxAlg:
Collaboration diagram for PixeldEdxAlg:

Public Member Functions

 PixeldEdxAlg (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~PixeldEdxAlg ()=default
virtual StatusCode initialize () override
virtual StatusCode execute () override
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

const PixelIDm_pixelID {}
Gaudi::Property< std::string > m_filename {this, "CalibrationFile", "mcpar_signed_234.txt","Read dEdx from this file"}
Gaudi::Property< bool > m_readfromcool {this, "ReadFromCOOL", false, "Read from COOL database"}
Gaudi::Property< double > m_mindedxformass {this, "MinimumdEdxForMass", 1.8, "Minimum dEdx for mass"}
SG::ReadCondHandleKey< AthenaAttributeListm_readKey {this, "ReadKey", "/PIXEL/PixdEdx", "Input readout folder"}
SG::WriteCondHandleKey< PixeldEdxDatam_writeKey {this, "WriteKey", "PixeldEdxData", "Output data"}
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

Definition at line 27 of file PixeldEdxAlg.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

◆ PixeldEdxAlg()

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

Definition at line 14 of file PixeldEdxAlg.cxx.

14 :
15 ::AthAlgorithm(name, pSvcLocator){ }
AthAlgorithm()
Default constructor:

◆ ~PixeldEdxAlg()

virtual PixeldEdxAlg::~PixeldEdxAlg ( )
virtualdefault

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()

StatusCode PixeldEdxAlg::execute ( )
overridevirtual

Definition at line 28 of file PixeldEdxAlg.cxx.

28 {
29 ATH_MSG_DEBUG("PixeldEdxAlg::execute()");
30
31 SG::WriteCondHandle<PixeldEdxData> writeHandle(m_writeKey);
32 if (writeHandle.isValid()) {
33 ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid.. In theory this should not be called, but may happen if multiple concurrent events are being processed out of order.");
34 return StatusCode::SUCCESS;
35 }
36
37 // Construct the output Cond Object and fill it in
38 std::unique_ptr<PixeldEdxData> writeCdo(std::make_unique<PixeldEdxData>());
39
40 const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
41 const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
42// const EventIDRange rangeW{start, stop};
43 EventIDRange rangeW{start, stop};
44
45 int fit_type{};
46 std::string fun_type;
47 std::string bb_type;
48
49 if (m_readfromcool) {
50 SG::ReadCondHandle<AthenaAttributeList> readHandle(m_readKey);
51 const AthenaAttributeList* readCdo = *readHandle;
52 if (readCdo==nullptr) {
53 ATH_MSG_FATAL("Null pointer to the read conditions object");
54 return StatusCode::FAILURE;
55 }
56 // Get the validitiy range
57 ATH_MSG_DEBUG("Size of AthenaAttributeList " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
58
59 // Get the validitiy range
60 if (not readHandle.range(rangeW)) {
61 ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key());
62 return StatusCode::FAILURE;
63 }
64 ATH_MSG_DEBUG("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
65 ATH_MSG_DEBUG("Range of input is " << rangeW);
66
67 // Get constants from string in DB.
68 std::string mystring=(*readCdo)["data"].data<std::string>();
69 std::istringstream mystringstream(mystring);
70
71 if (mystringstream.eof() || mystringstream.fail()) {
72 ATH_MSG_ERROR("Failed to read DB contents. Check DB.");
73 return StatusCode::FAILURE;
74 }
75
76 mystringstream >> fit_type;
77 mystringstream >> fun_type;
78 mystringstream >> bb_type;
79
80 writeCdo -> setFunctionType(fun_type);
81 writeCdo -> setBetheBlochType(bb_type);
82 writeCdo -> setMinimumdEdxForMass(m_mindedxformass);
83
84 if (fit_type==0) {
85 for (int i=0;i<5;i++) {
86 for (int j=0;j<9;j++) {
87 double param;
88 mystringstream >> param;
89 writeCdo -> setPar(i,param);
90 }
91 }
92 writeCdo -> setPosNeg(false);
93 }
94 else {
95 for (int i=0;i<2*5;i++) {
96 for (int j=0;j<9;j++) {
97 double param;
98 mystringstream >> param;
99 writeCdo -> setPar(i,param);
100 }
101 }
102 writeCdo -> setPosNeg(true);
103 }
104 }
105 else {
106 std::string file_name = PathResolver::find_file(m_filename,"DATAPATH");
107 if (file_name.empty()) {
108 ATH_MSG_ERROR("PixeldEdx input file " << m_filename << " not found.");
109 return StatusCode::FAILURE;
110 }
111 std::ifstream input(file_name.c_str());
112 if (!input.good()) {
113 ATH_MSG_ERROR("Cannot open " << file_name);
114 return StatusCode::FAILURE;
115 }
116 input >> fit_type;
117 input >> fun_type;
118 input >> bb_type;
119
120 writeCdo -> setFunctionType(fun_type);
121 writeCdo -> setBetheBlochType(bb_type);
122 writeCdo -> setMinimumdEdxForMass(m_mindedxformass);
123
124 if (fit_type==0) {
125 for (int i=0;i<5;i++) {
126 for (int j=0;j<9;j++) {
127 double param;
128 input >> param;
129 writeCdo -> setPar(i,param);
130 }
131 }
132 writeCdo -> setPosNeg(false);
133 }
134 else {
135 for (int i=0;i<2*5;i++) {
136 for (int j=0;j<9;j++) {
137 double param;
138 input >> param;
139 writeCdo -> setPar(i,param);
140 }
141 }
142 writeCdo -> setPosNeg(true);
143 }
144 input.close();
145 }
146
147 if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) {
148 ATH_MSG_FATAL("Could not record PixeldEdxData " << writeHandle.key() << " with EventRange " << rangeW << " into Conditions Store");
149 return StatusCode::FAILURE;
150 }
151 ATH_MSG_DEBUG("recorded new CDO " << writeHandle.key() << " with range " << rangeW << " into Conditions Store");
152
153 return StatusCode::SUCCESS;
154}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
Gaudi::Property< bool > m_readfromcool
Gaudi::Property< std::string > m_filename
Gaudi::Property< double > m_mindedxformass
SG::ReadCondHandleKey< AthenaAttributeList > m_readKey
SG::WriteCondHandleKey< PixeldEdxData > m_writeKey

◆ 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

◆ initialize()

StatusCode PixeldEdxAlg::initialize ( )
overridevirtual

Definition at line 17 of file PixeldEdxAlg.cxx.

17 {
18 ATH_MSG_DEBUG("PixeldEdxAlg::initialize()");
19
20 ATH_CHECK(detStore()->retrieve(m_pixelID,"PixelID"));
21
23 ATH_CHECK(m_writeKey.initialize());
24
25 return StatusCode::SUCCESS;
26}
#define ATH_CHECK
Evaluate an expression and check for errors.
const ServiceHandle< StoreGateSvc > & detStore() const
const PixelID * m_pixelID
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ 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 }

◆ 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}
#define ATH_MSG_WARNING(x)
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_filename

Gaudi::Property<std::string> PixeldEdxAlg::m_filename {this, "CalibrationFile", "mcpar_signed_234.txt","Read dEdx from this file"}
private

Definition at line 39 of file PixeldEdxAlg.h.

40{this, "CalibrationFile", "mcpar_signed_234.txt","Read dEdx from this file"};

◆ m_mindedxformass

Gaudi::Property<double> PixeldEdxAlg::m_mindedxformass {this, "MinimumdEdxForMass", 1.8, "Minimum dEdx for mass"}
private

Definition at line 45 of file PixeldEdxAlg.h.

46{this, "MinimumdEdxForMass", 1.8, "Minimum dEdx for mass"};

◆ m_pixelID

const PixelID* PixeldEdxAlg::m_pixelID {}
private

Definition at line 37 of file PixeldEdxAlg.h.

37{};

◆ m_readfromcool

Gaudi::Property<bool> PixeldEdxAlg::m_readfromcool {this, "ReadFromCOOL", false, "Read from COOL database"}
private

Definition at line 42 of file PixeldEdxAlg.h.

43{this, "ReadFromCOOL", false, "Read from COOL database"};

◆ m_readKey

SG::ReadCondHandleKey<AthenaAttributeList> PixeldEdxAlg::m_readKey {this, "ReadKey", "/PIXEL/PixdEdx", "Input readout folder"}
private

Definition at line 48 of file PixeldEdxAlg.h.

49{this, "ReadKey", "/PIXEL/PixdEdx", "Input readout folder"};

◆ 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.

◆ m_writeKey

SG::WriteCondHandleKey<PixeldEdxData> PixeldEdxAlg::m_writeKey {this, "WriteKey", "PixeldEdxData", "Output data"}
private

Definition at line 51 of file PixeldEdxAlg.h.

52{this, "WriteKey", "PixeldEdxData", "Output data"};

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