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

#include <CaloReadLCOutOfClusterFile.h>

Inheritance diagram for CaloReadLCOutOfClusterFile:
Collaboration diagram for CaloReadLCOutOfClusterFile:

Public Member Functions

 CaloReadLCOutOfClusterFile (const std::string &name, ISvcLocator *pSvcLocator)
 ~CaloReadLCOutOfClusterFile ()
StatusCode initialize ()
StatusCode execute (const EventContext &ctx)
 Execute method.
StatusCode finalize ()
StatusCode initDataFromFile (const std::string &theLCOutOfClusterFileName, CaloLocalHadCoeff &data)
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
bool filterPassed (const EventContext &ctx) const
void setFilterPassed (bool state, const EventContext &ctx) const
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
const EventContext & getContext () const
 Deprecated methods (use the ones with EventContext).
bool filterPassed () const
void setFilterPassed (bool state) const

Protected Member Functions

virtual bool isReEntrant () const override final
 Legacy algorithms are not thread-safe.
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_key
std::string m_LCOutOfClusterFileName
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 14 of file CaloReadLCOutOfClusterFile.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ CaloReadLCOutOfClusterFile()

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

Definition at line 17 of file CaloReadLCOutOfClusterFile.cxx.

18 :
19 AthAlgorithm(name,pSvcLocator) {
20 declareProperty("LCOutOfClusterFileName",m_LCOutOfClusterFileName);
21 declareProperty("CorrectionKey",m_key="OOC");
22}
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ ~CaloReadLCOutOfClusterFile()

CaloReadLCOutOfClusterFile::~CaloReadLCOutOfClusterFile ( )

Definition at line 25 of file CaloReadLCOutOfClusterFile.cxx.

25{}

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::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 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::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< Gaudi::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< Gaudi::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 CaloReadLCOutOfClusterFile::execute ( const EventContext & ctx)
virtual

Execute method.

Provides access to the EventContext if needed but is non-const as opposed to AthReentrantAlgorithm.

Implements AthAlgorithm.

Definition at line 145 of file CaloReadLCOutOfClusterFile.cxx.

146{
147 return StatusCode::SUCCESS;
148}

◆ extraDeps_update_handler()

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

◆ filterPassed() [1/2]

bool AthAlgorithm::filterPassed ( ) const
inherited

Definition at line 94 of file AthAlgorithm.cxx.

94 {
95 return filterPassed( Gaudi::Hive::currentContext() );
96}
bool filterPassed() const

◆ filterPassed() [2/2]

bool AthAlgorithm::filterPassed ( const EventContext & ctx) const
inherited

Definition at line 98 of file AthAlgorithm.cxx.

98 {
99 return execState( ctx ).filterPassed();
100}

◆ finalize()

StatusCode CaloReadLCOutOfClusterFile::finalize ( )

Definition at line 150 of file CaloReadLCOutOfClusterFile.cxx.

151{
152 return StatusCode::SUCCESS;
153}

◆ getContext()

const EventContext & AthAlgorithm::getContext ( ) const
inherited

Deprecated methods (use the ones with EventContext).

Definition at line 90 of file AthAlgorithm.cxx.

90 {
91 return Gaudi::Hive::currentContext();
92}

◆ initDataFromFile()

StatusCode CaloReadLCOutOfClusterFile::initDataFromFile ( const std::string & theLCOutOfClusterFileName,
CaloLocalHadCoeff & data )

Definition at line 28 of file CaloReadLCOutOfClusterFile.cxx.

30{
31 // Find the full path to filename:
32 std::string file = PathResolver::find_file (theLCOutOfClusterFileName, "DATAPATH");
33 ATH_MSG_INFO( "Reading file " << file );
34 TFile* theLCOutOfClusterFile = new TFile(file.c_str());
35 if ( !theLCOutOfClusterFile ) {
36 return StatusCode::FAILURE;
37 }
38
39 CaloLocalHadCoeff::LocalHadArea theArea("OutOfCluster",0,3);
40
41 TList * theKeyList = theLCOutOfClusterFile->GetListOfKeys();
42 while ( theKeyList->GetEntries() ) {
43 TProfile2D * prof = (TProfile2D *)theLCOutOfClusterFile->Get(theKeyList->First()->GetTitle());
44 // parse histogram title to find all dimensions and bins
45 std::string sTitle(prof->GetTitle());
46 bool allValid(true);
47
48 std::vector<std::string> keys;
49 keys.emplace_back("_iside_");
50 keys.emplace_back("_iphi_");
51 keys.emplace_back("_ilogE_");
52
53 std::vector<std::string> names;
54 names.emplace_back("side");
55 names.emplace_back("phi");
56 names.emplace_back("log10(E_clus (MeV))");
57 names.emplace_back(prof->GetXaxis()->GetTitle());
58 names.emplace_back(prof->GetYaxis()->GetTitle());
59
60 std::vector<int> types;
66
67 std::vector<int> ibin(names.size(),-1);
68 std::vector<double> rmin(names.size(),-1);
69 std::vector<double> rmax(names.size(),-1);
70 std::vector<int> nbin(names.size(),-1);
71 unsigned int idim;
72
73 for (idim=0;idim<keys.size();idim++) {
74 size_t found = sTitle.find(keys[idim]);
75 if ( found == std::string::npos ) {
76 ATH_MSG_ERROR( "Could not find key " << keys[idim] << " in current histogram." );
77 allValid = false;
78 }
79 else {
80 char c;
81 std::istringstream tstr(sTitle.substr(found+keys[idim].length()));
82 tstr >> ibin[idim] >> c >> c >> rmin[idim] >> c >> rmax[idim] >> c >> nbin[idim];
83 if ( ibin[idim] < 0 || ibin[idim] >= nbin[idim] ) {
84 ATH_MSG_ERROR( "Found invalid bin number " << ibin[idim] << " not in valid range [0," << nbin[idim] << " in current histogram." );
85 allValid = false;
86 }
87 }
88 }
89 if ( allValid ) {
90 // final 2 dimensions are from TProfile2D itself
91 nbin[names.size()-2] = prof->GetNbinsX();
92 rmin[names.size()-2] = prof->GetXaxis()->GetXmin();
93 rmax[names.size()-2] = prof->GetXaxis()->GetXmax();
94 nbin[names.size()-1] = prof->GetNbinsY();
95 rmin[names.size()-1] = prof->GetYaxis()->GetXmin();
96 rmax[names.size()-1] = prof->GetYaxis()->GetXmax();
97 // book new area from the first histo found
98 if ( theArea.getNdim() == 0 ) {
99 for (idim = 0;idim<names.size();idim++) {
100 CaloLocalHadCoeff::LocalHadDimension theDim(names[idim].c_str(),types[idim],nbin[idim],rmin[idim],rmax[idim]);
101 ATH_MSG_INFO( "adding dimension " << names[idim].c_str() << " " << types[idim]<< " " << nbin[idim]<< " " << rmin[idim]<< " " << rmax[idim] );
102 theArea.addDimension(theDim);
103 }
104 ATH_MSG_INFO( "adding Area with nDim = " << theArea.getNdim() );
105 data.addArea(theArea);
106 }
107 // now fill all data for current histogram
108 TAxis * xax = prof->GetXaxis();
109 TAxis * yax = prof->GetYaxis();
110 for (ibin[names.size()-2]=0;ibin[names.size()-2]<prof->GetNbinsX();ibin[names.size()-2]++) {
111 for (ibin[names.size()-1]=0;ibin[names.size()-1]<prof->GetNbinsY();ibin[names.size()-1]++) {
112 float abseta = xax->GetBinCenter(ibin[names.size()-2]+1);
113 float loglambda = yax->GetBinCenter(ibin[names.size()-1]+1);
114 int iBin = prof->FindBin(abseta,loglambda);
115
117 theData[CaloLocalHadDefs::BIN_WEIGHT] = prof->GetBinContent(iBin);
118 theData[CaloLocalHadDefs::BIN_ENTRIES] = prof->GetBinEntries(iBin);
119 theData[CaloLocalHadDefs::BIN_ERROR] = prof->GetBinError(iBin);
120
121 msg() << MSG::INFO << "Now set data for bins: ";
122 for(unsigned int ii=0;ii<ibin.size();ii++)
123 msg() << ibin[ii] << " ";
124 msg() << endmsg;
125 int dbin = data.getBin(0,ibin);
126 if (dbin >= 0)
127 data.setCoeff(dbin,theData);
128 }
129 }
130 }
131 theKeyList->RemoveFirst();
132 }
133
134 return StatusCode::SUCCESS;
135}
#define endmsg
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static const std::vector< std::string > types
std::vector< float > LocalHadCoeff
Correction parameters for one general bin.
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
TFile * file

◆ initialize()

StatusCode CaloReadLCOutOfClusterFile::initialize ( )

Definition at line 137 of file CaloReadLCOutOfClusterFile.cxx.

137 {
138 ATH_MSG_INFO( " Building CaloLocalHadCoeff object " );
139 auto data = std::make_unique<CaloLocalHadCoeff>();
141 ATH_CHECK( detStore()->record(std::move(data), m_key, false) );
142 return StatusCode::SUCCESS;
143}
#define ATH_CHECK
Evaluate an expression and check for errors.
const ServiceHandle< StoreGateSvc > & detStore() const
StatusCode initDataFromFile(const std::string &theLCOutOfClusterFileName, CaloLocalHadCoeff &data)

◆ inputHandles()

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

◆ isReEntrant()

virtual bool AthAlgorithm::isReEntrant ( ) const
inlinefinaloverrideprotectedvirtualinherited

Legacy algorithms are not thread-safe.

Definition at line 111 of file AthAlgorithm.h.

111{ return false; }

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msgLvl()

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

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed() [1/2]

void AthAlgorithm::setFilterPassed ( bool state) const
inherited

Definition at line 102 of file AthAlgorithm.cxx.

102 {
103 setFilterPassed( state, Gaudi::Hive::currentContext() );
104}
void setFilterPassed(bool state) const

◆ setFilterPassed() [2/2]

void AthAlgorithm::setFilterPassed ( bool state,
const EventContext & ctx ) const
inherited

Definition at line 106 of file AthAlgorithm.cxx.

106 {
107 execState( ctx ).setFilterPassed(state);
108}

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

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::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< Gaudi::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 114 of file AthAlgorithm.h.

◆ m_key

std::string CaloReadLCOutOfClusterFile::m_key
private

Definition at line 27 of file CaloReadLCOutOfClusterFile.h.

◆ m_LCOutOfClusterFileName

std::string CaloReadLCOutOfClusterFile::m_LCOutOfClusterFileName
private

Definition at line 28 of file CaloReadLCOutOfClusterFile.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.


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