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

Dump out shape information to a ROOT file. More...

#include <LArDumpShapes.h>

Inheritance diagram for LArDumpShapes:
Collaboration diagram for LArDumpShapes:

Public Member Functions

 LArDumpShapes (const std::string &name, ISvcLocator *svcloc)
 Standard Algorithm constructor.
StatusCode initialize ()
 Standard algorithm methods.
StatusCode execute ()
 Standard Gaudi execute method.
StatusCode finalize ()
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

SG::ReadCondHandleKey< LArOnOffIdMappingm_cablingKey {this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"}
std::string m_filename
 JO property: The nmae of the ROOT file to create.
int m_gain
 JO property: The desired gain.
bool m_first
 True for the first event.
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

Dump out shape information to a ROOT file.

On the first event, this algorithm will retrieve the LAr pulse shape information from the detector store and dump it to a ROOT file for analysis.

On subsequent events, this algorithm does nothing.

Definition at line 49 of file LArDumpShapes.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

◆ LArDumpShapes()

LArDumpShapes::LArDumpShapes ( const std::string & name,
ISvcLocator * svcloc )

Standard Algorithm constructor.

name The name of the algorithm.

svcloc The service locator object.

Definition at line 30 of file LArDumpShapes.cxx.

31 : AthAlgorithm (name, svcloc),
32 m_first (true)
33{
34 // Set up properties.
35 declareProperty ("filename", m_filename = "shapes.root");
37}
AthAlgorithm()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::string m_filename
JO property: The nmae of the ROOT file to create.
bool m_first
True for the first event.
int m_gain
JO property: The desired gain.
@ LARHIGHGAIN
Definition CaloGain.h:18

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 }

◆ 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 LArDumpShapes::execute ( )

Standard Gaudi execute method.

Definition at line 54 of file LArDumpShapes.cxx.

55{
56 // Only do this for the first event.
57 if (!m_first)
58 return StatusCode::SUCCESS;
59
60 // Get the shapes from the detector store.
61 const ILArShape* dd_shape = nullptr;
62 CHECK( detStore()->retrieve (dd_shape) );
63
64 SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKey};
65 const LArOnOffIdMapping* cabling{*cablingHdl};
66 if(!cabling){
67 ATH_MSG_ERROR("Do not have mapping object " << m_cablingKey.key() );
68 return StatusCode::FAILURE;
69 }
70 // Get the calorimeter identifier helper.
71 const CaloCell_ID* idHelper = nullptr;
72 ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_ID") );
73 const LArEM_ID* em_id = idHelper->em_idHelper();
74
75 // Open the ROOT file.
76 TFile f (m_filename.c_str(), "RECREATE");
77
78 // Loop over all EM cells.
79 typedef std::vector<Identifier>::const_iterator It;
80 It beg = em_id->em_begin();
81 It end = em_id->em_end();
82 for (; beg != end; ++beg) {
83 // Check that this is a valid cell.
84 Identifier id = *beg;
85 if (!id.is_valid()) continue;
86 HWIdentifier chid = cabling->createSignalChannelID (id);
87 if (!chid.is_valid()) continue;
88
89 // Get the shape information for this cell.
90 ILArShape::ShapeRef_t shape = dd_shape->Shape(chid, m_gain, 0);
91 ILArShape::ShapeRef_t shapeder = dd_shape->ShapeDer(chid, m_gain, 0);
92
93 // Construct the name to use for the histogram.
94 char name[50];
95 std::sprintf(name, "shap%.9d_%.1d%.1d%.1d%.1d%.3d%.3d",
96 (int)chid.get_identifier32().get_compact(),
97 m_gain,
98 em_id->barrel_ec (id)+3,
99 em_id->sampling(id),
100 em_id->region(id),
101 em_id->phi(id),
102 em_id->eta(id));
103
104 // Create the histogram.
105 unsigned sz1 = shape.size();
106 unsigned sz2 = shapeder.size();
107 TH1* h1 = new TH1F (name, name, sz1 + sz2, 0, sz1 + sz2);
108
109 // Copy the data to the histogram.
110 for (unsigned int i=0; i < sz1; i++)
111 h1->SetBinContent (i+1, shape[i]);
112 for (unsigned int i=0; i < sz2; i++) {
113 double der = shapeder[i];
114 // ShapeDer uses 1e100 as a flag, which is not
115 // convertable to a float...
116 if (std::abs(der) > 1e10) der = 1e10;
117 h1->SetBinContent (i+sz1+1, der);
118 }
119
120 // Write the histogram to the ROOT file.
121 h1->Write();
122 delete h1;
123 }
124
125 // Close the ROOT file and remember that we did this.
126 f.Close();
127 m_first = false;
128 return StatusCode::SUCCESS;
129}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define CHECK(...)
Evaluate an expression and check for errors.
const ServiceHandle< StoreGateSvc > & detStore() const
const LArEM_ID * em_idHelper() const
access to EM idHelper
Definition CaloCell_ID.h:63
LArVectorProxy ShapeRef_t
This class defines the interface for accessing Shape (Nsample variable, Dt = 25 ns fixed) @stereotype...
Definition ILArShape.h:26
virtual ShapeRef_t Shape(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0
virtual ShapeRef_t ShapeDer(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0
value_type get_compact() const
Get the compact id.
bool is_valid() const
Check if id is in a valid state.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
int region(const Identifier id) const
return region according to :
int eta(const Identifier id) const
return eta according to :
int phi(const Identifier id) const
return phi according to :
id_iterator em_begin() const
begin iterator over full set of EM Identifiers
int barrel_ec(const Identifier id) const
return barrel_ec according to :
int sampling(const Identifier id) const
return sampling according to :
id_iterator em_end() const
end iterator over full set of EM Identifiers
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)

◆ 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

◆ finalize()

StatusCode LArDumpShapes::finalize ( )
inline

Definition at line 63 of file LArDumpShapes.h.

63{return StatusCode::SUCCESS;}

◆ initialize()

StatusCode LArDumpShapes::initialize ( )

Standard algorithm methods.

Standard Gaudi initialize method.

Definition at line 43 of file LArDumpShapes.cxx.

44{
45 ATH_CHECK( m_cablingKey.initialize() );
46
47 return StatusCode::SUCCESS;
48}

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

SG::ReadCondHandleKey<LArOnOffIdMapping> LArDumpShapes::m_cablingKey {this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"}
private

Definition at line 67 of file LArDumpShapes.h.

67{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"};

◆ 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

std::string LArDumpShapes::m_filename
private

JO property: The nmae of the ROOT file to create.

Definition at line 70 of file LArDumpShapes.h.

◆ m_first

bool LArDumpShapes::m_first
private

True for the first event.

Definition at line 76 of file LArDumpShapes.h.

◆ m_gain

int LArDumpShapes::m_gain
private

JO property: The desired gain.

Definition at line 73 of file LArDumpShapes.h.

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