The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
THistWrite Class Reference

#include </builds/gaudi/Gaudi/GaudiTestSuite/src/THist/THistWrite.h>

Inheritance diagram for THistWrite:
Collaboration diagram for THistWrite:

Public Member Functions

 THistWrite (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize () override
 
StatusCode execute () override
 
StatusCode finalize () override
 
- Public Member Functions inherited from Algorithm
 LegacyAlgorithmAdapter (std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
 
- Public Member Functions inherited from Gaudi::details::LegacyAlgorithmAdapter
 LegacyAlgorithmAdapter (std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
 
const EventContextgetContext () const
 
bool isExecuted () const
 Has this algorithm been executed since the last reset?
 
void setExecuted (bool state) const
 Set the executed flag to the specified state.
 
bool filterPassed () const
 Did this algorithm pass or fail its filter criterion for the last event?
 
void setFilterPassed (bool state) const
 Set the filter passed flag to the specified state.
 
- Public Member Functions inherited from Gaudi::Algorithm
 Algorithm (std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
 Constructor.
 
StatusCode sysStart () override
 Reinitialization method invoked by the framework.
 
StatusCode sysInitialize () override
 Initialization method invoked by the framework.
 
StatusCode sysReinitialize () override
 Reinitialization method invoked by the framework.
 
StatusCode sysRestart () override
 Restart method invoked by the framework.
 
StatusCode sysExecute (const EventContext &ctx) override
 The actions to be performed by the algorithm on an event.
 
StatusCode sysStop () override
 System stop.
 
StatusCode sysFinalize () override
 System finalization.
 
const std::string & name () const override
 The identifying name of the algorithm object.
 
const Gaudi::StringKeynameKey () const override
 
const std::string & type () const override
 The type of the algorithm object.
 
void setType (std::string type) override
 
const std::string & version () const override
 
unsigned int index () const override
 
StatusCode configure () override
 Dummy implementation of IStateful::configure() method.
 
StatusCode terminate () override
 Dummy implementation of IStateful::terminate() method.
 
StatusCode initialize () override
 the default (empty) implementation of IStateful::initialize() method
 
StatusCode start () override
 the default (empty) implementation of IStateful::start() method
 
StatusCode stop () override
 the default (empty) implementation of IStateful::stop() method
 
StatusCode finalize () override
 the default (empty) implementation of IStateful::finalize() method
 
StatusCode reinitialize () override
 the default (empty) implementation of IStateful::reinitialize() method
 
StatusCode restart () override
 the default (empty) implementation of IStateful::restart() method
 
Gaudi::StateMachine::State FSMState () const override
 returns the current state of the algorithm
 
Gaudi::StateMachine::State targetFSMState () const override
 returns the state the algorithm will be in after the ongoing transition
 
bool isEnabled () const override
 Is this algorithm enabled or disabled?
 
bool isSequence () const override
 Are we a Sequence?
 
unsigned int errorCount () const
 Get the number of failures of the algorithm.
 
SmartIF< IServiceservice (std::string_view name, const bool createIf=true, const bool quiet=false) const
 Return a pointer to the service identified by name (or "type/name")
 
template<class T>
SmartIF< T > service (std::string_view name, bool createIf=true, bool quiet=false) const
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
SmartIF< IChronoStatSvc > & chronoSvc () const
 The standard Chrono & Stat service, Return a pointer to the service if present.
 
SmartIF< IDataProviderSvc > & detSvc () const
 The standard detector data service.
 
SmartIF< IConversionSvc > & detCnvSvc () const
 The standard detector data persistency conversion service.
 
SmartIF< IDataProviderSvc > & eventSvc () const
 The standard event data service.
 
SmartIF< IDataProviderSvc > & evtSvc () const
 shortcut for method eventSvc
 
SmartIF< IConversionSvc > & eventCnvSvc () const
 The standard event data persistency conversion service.
 
SmartIF< IHistogramSvc > & histoSvc () const
 The standard histogram service.
 
SmartIF< INTupleSvc > & ntupleSvc () const
 The standard N tuple service.
 
SmartIF< IRndmGenSvc > & randSvc () const
 The standard RandomGen service, Return a pointer to the service if present.
 
SmartIF< IToolSvc > & toolSvc () const
 The standard ToolSvc service, Return a pointer to the service if present.
 
SmartIF< IExceptionSvc > & exceptionSvc () const
 Get the exception Service.
 
SmartIF< IAlgContextSvc > & contextSvc () const
 get Algorithm Context Service
 
SmartIF< ITimelineSvc > & timelineSvc () const
 
SmartIF< ISvcLocator > & serviceLocator () const override
 The standard service locator.
 
SmartIF< ISvcLocator > & svcLoc () const
 shortcut for method serviceLocator
 
SmartIF< IHiveWhiteBoard > & whiteboard () const
 
SmartIF< IAlgExecStateSvc > & algExecStateSvc () const
 
bool registerContext () const
 register for Algorithm Context Service?
 
template<class T>
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T>
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
SmartIF< IMonitorSvc > & monitorSvc () const
 Access the monitor service.
 
template<class T>
void declareInfo (const std::string &name, const T &var, const std::string &desc) const
 Declare monitoring information.
 
void declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const
 Declare monitoring information (special case)
 
void acceptDHVisitor (IDataHandleVisitor *) const override
 
void registerTool (IAlgTool *tool) const
 
void deregisterTool (IAlgTool *tool) const
 
template<class T>
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T>
StatusCode declareTool (ToolHandle< T > &handle, const std::string &toolTypeAndName, bool createIf=true)
 
template<class T>
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
bool isAsynchronous () const
 
void setAsynchronous (bool value)
 
unsigned int cardinality () const override
 Return the cardinality.
 
const std::vector< std::string > & neededResources () const override
 
AlgExecStateRef execState (const EventContext &ctx) const override
 get the AlgExecStateRef of current algorithm Actually a small wrapper around it, thus the plain object return type
 
std::ostream & toControlFlowExpression (std::ostream &os) const override
 Produce string represention of the control flow expression.
 
- Public Member Functions inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
std::vector< Gaudi::DataHandle * > inputHandles () const override
 
std::vector< Gaudi::DataHandle * > outputHandles () const override
 
virtual const DataObjIDCollextraInputDeps () const override
 
virtual const DataObjIDCollextraOutputDeps () const override
 
void declare (Gaudi::DataHandle &handle) override
 
void renounce (Gaudi::DataHandle &handle) override
 
bool renounceInput (const DataObjID &id) override
 
const DataObjIDCollinputDataObjs () const override
 
const DataObjIDColloutputDataObjs () const override
 
void addDependency (const DataObjID &id, const Gaudi::DataHandle::Mode &mode) override
 
- Public Member Functions inherited from extends< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >, IDataHandleHolder >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property.
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property.
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation.
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property.
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name.
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream)
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor.
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 

Private Member Functions

void listKeys (TDirectory *td)
 

Private Attributes

ServiceHandle< ITHistSvcm_ths { this, "HistSvc", "THistSvc" }
 

Additional Inherited Members

- Public Types inherited from Gaudi::Algorithm
typedef Gaudi::PluginService::Factory< IAlgorithm *(const std::string &, ISvcLocator *)> Factory
 
- Public Types inherited from extends< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >, IDataHandleHolder >
using base_class
 Typedef to this class.
 
using extend_interfaces_base
 Typedef to the base of this class.
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
using PropertyHolderImpl
 Typedef used to refer to this class from derived classes, as in.
 
- Public Types inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
using base_class
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
 
- Public Attributes inherited from Gaudi::Algorithm
friend AlgorithmManager
 
- Protected Member Functions inherited from Gaudi::details::LegacyAlgorithmAdapter
bool isReEntrant () const override
 
- Protected Member Functions inherited from Gaudi::Algorithm
std::vector< IAlgTool * > & tools ()
 
bool isInitialized () const override
 Has the Algorithm already been initialized?
 
bool isFinalized () const override
 Has the Algorithm already been finalized?
 
void setIndex (const unsigned int &idx) override
 set instantiation index of Alg
 
bool isReEntrant () const override
 
- Protected Member Functions inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
void initDataHandleHolder ()
 initializes all handles - called by the sysInitialize method of any descendant of this
 
- Protected Member Functions inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches.
 
MSG::Level resetMessaging ()
 Reinitialize internal states.
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream.
 
- Protected Attributes inherited from Gaudi::Algorithm
std::unique_ptr< IDataHandleVisitorm_updateDataHandles
 Hook for for derived classes to provide a custom visitor for data handles.
 
- Protected Attributes inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
DataObjIDColl m_inputDataObjs
 
DataObjIDColl m_outputDataObjs
 

Detailed Description

Definition at line 21 of file THistWrite.h.

Constructor & Destructor Documentation

◆ THistWrite()

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

Definition at line 32 of file THistWrite.cpp.

33 : Algorithm( name, pSvcLocator )
34//------------------------------------------------------------------------------
35{}
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition Algorithm.h:98
const std::string & name() const override
The identifying name of the algorithm object.

Member Function Documentation

◆ execute()

StatusCode THistWrite::execute ( )
overridevirtual

Implements Algorithm.

Definition at line 143 of file THistWrite.cpp.

145{
146 Rndm::Numbers gauss( randSvc(), Rndm::Gauss( 0., 15. ) );
147
148 static int n = 0;
149
150 double x = sin( double( n ) ) * 52. + 50.;
151
152 TH1* h( nullptr );
153 if ( m_ths->getHist( "TempHist1", h ).isSuccess() ) {
154 h->Fill( x );
155 } else {
156 error() << "Couldn't retrieve TempHist 1" << endmsg;
157 }
158
159 if ( m_ths->getHist( "other/TempHist1a", h ).isSuccess() ) {
160 h->Fill( x );
161 } else {
162 error() << "Couldn't retrieve TempHist 1a" << endmsg;
163 }
164
165 if ( m_ths->getHist( "/new/Tree2", h ).isSuccess() ) {
166 h->Fill( x );
167 } else {
168 error() << "Couldn't retrieve Tree2" << endmsg;
169 }
170
171 if ( m_ths->getHist( "/upd/xxx/gauss1d", h ).isSuccess() ) {
172 for ( int i = 0; i < 1000; ++i ) { h->Fill( gauss(), 1. ); }
173 } else {
174 error() << "Couldn't retrieve 1Dgauss" << endmsg;
175 }
176
177 TH2* h2( nullptr );
178 if ( m_ths->getHist( "/rec/gauss2d", h2 ).isSuccess() ) {
179 for ( int i = 0; i < 1000; ++i ) { h2->Fill( gauss(), gauss(), 1. ); }
180 } else {
181 error() << "Couldn't retrieve 2Dgauss" << endmsg;
182 }
183
184 TH3* h3( nullptr );
185 if ( m_ths->getHist( "/rec/gauss3d", h3 ).isSuccess() ) {
186 for ( int i = 0; i < 1000; ++i ) { h3->Fill( gauss(), gauss(), gauss(), 1. ); }
187 } else {
188 error() << "Couldn't retrieve 3Dgauss" << endmsg;
189 }
190
191 if ( m_ths->getHist( "TempHist5", h ).isSuccess() ) {
192 h->Fill( x );
193 } else {
194 error() << "Couldn't retrieve TempHist 5" << endmsg;
195 }
196
197 LockedHandle<TH1> lh1( nullptr, nullptr );
198 if ( m_ths->getShared( "/upd/xxx/gauss1d_shared", lh1 ).isSuccess() ) {
199 for ( int i = 0; i < 1000; ++i ) { lh1->Fill( gauss(), 1. ); }
200 } else {
201 error() << "Couldn't retrieve 1Dgauss_shared" << endmsg;
202 }
203
204 LockedHandle<TH2> lh2( nullptr, nullptr );
205 if ( m_ths->getShared( "/rec/gauss2d_shared", lh2 ).isSuccess() ) {
206 for ( int i = 0; i < 1000; ++i ) { lh2->Fill( gauss(), gauss(), 1. ); }
207 } else {
208 error() << "Couldn't retrieve 2Dgauss_shared" << endmsg;
209 }
210
211 LockedHandle<TH3> lh3( nullptr, nullptr );
212 if ( m_ths->getShared( "/rec/gauss3d_shared", lh3 ).isSuccess() ) {
213 for ( int i = 0; i < 1000; ++i ) { lh3->Fill( gauss(), gauss(), gauss(), 1. ); }
214 } else {
215 error() << "Couldn't retrieve 3Dgauss_shared" << endmsg;
216 }
217
218 TTree* tr( nullptr );
219 if ( m_ths->getTree( "/rec/trees/stuff/tree1", tr ).isFailure() ) {
220 error() << "Couldn't retrieve tree tree1" << endmsg;
221 } else {
222 if ( n == 0 ) {
223 int p1, p2, p3;
224 tr->Branch( "branch1", &p1, "point1/I" );
225 tr->Branch( "branch2", &p2, "point2/I" );
226 tr->Branch( "branch3", &p3, "point3/I" );
227
228 for ( int i = 0; i < 1000; i++ ) {
229 p1 = i;
230 p2 = i % 10;
231 p3 = i % 7;
232
233 tr->Fill();
234 }
235 }
236 }
237
238 n++;
239 return StatusCode::SUCCESS;
240}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
SmartIF< IRndmGenSvc > & randSvc() const
The standard RandomGen service, Return a pointer to the service if present.
constexpr static const auto SUCCESS
Definition StatusCode.h:99
ServiceHandle< ITHistSvc > m_ths
Definition THistWrite.h:33
constexpr double gauss

◆ finalize()

StatusCode THistWrite::finalize ( )
override

Definition at line 264 of file THistWrite.cpp.

266{
267 info() << "Finalizing..." << endmsg;
268
269 TH1* h7 = nullptr;
270 if ( m_ths->getHist( "TempHist7", h7 ).isFailure() ) { error() << "Couldn't retrieve TempHist7" << endmsg; }
271 if ( m_ths->deReg( h7 ).isFailure() ) { error() << "Failed to deregister histogram TempHist7" << endmsg; }
272
273 return StatusCode::SUCCESS;
274}
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)

◆ initialize()

StatusCode THistWrite::initialize ( )
override

Definition at line 38 of file THistWrite.cpp.

40{
41
42 // FIXME - Code here generates a lot of memory leak errors with the leak sanitizers, e.g.
43 //
44 // clang-format off
45 // Indirect leak of 816 byte(s) in 1 object(s) allocated from:
46 // #0 0x7f817fd0aec8 in operator new[](unsigned long) /afs/cern.ch/cms/CAF/CMSCOMM/COMM_ECAL/dkonst/GCC/build/contrib/gcc-8.2.0/src/gcc/8.2.0/libsanitizer/lsan/lsan_interceptors.cc:231
47 // #1 0x7f817bedf4b6 in TArrayD::Set(int) /mnt/build/jenkins/workspace/lcg_release_tar/BUILDTYPE/Debug/COMPILER/gcc8binutils/LABEL/centos7/build/projects/ROOT-6.18.00/src/ROOT/6.18.00/core/cont/src/TArrayD.cxx:112
48 // #2 0x7f81796c52bf in TH1D::TH1D(char const*, char const*, int, double, double) /mnt/build/jenkins/workspace/lcg_release_tar/BUILDTYPE/Debug/COMPILER/gcc8binutils/LABEL/centos7/build/projects/ROOT-6.18.00/src/ROOT/6.18.00/hist/hist/src/TH1.cxx:9627
49 // #3 0x7f817782ab5d in THistWrite::initialize() ../GaudiTestSuite/src/THist/THistWrite.cpp:94
50 // clang-format on
51 //
52 // These leaks are currently suppressed in Gaudi/job/Gaudi-LSan.supp - remove entry there to reactivate
53
54 if ( m_ths.retrieve().isFailure() ) {
55 error() << "Couldn't get THistSvc" << endmsg;
57 }
58
59 // Temporary Trees
60 std::unique_ptr<TH1F> h1 = std::make_unique<TH1F>( "TempHist1", "Temporary Tree 1", 100, 0., 100. );
61 if ( m_ths->regHist( "TempHist1", std::move( h1 ) ).isFailure() ) {
62 error() << "Couldn't register TempHist1" << endmsg;
63 }
64
65 std::unique_ptr<TH1F> h1a = std::make_unique<TH1F>( "TempHist1a", "Temporary Tree 1a", 100, 0., 100. );
66 if ( m_ths->regHist( "other/TempHist1a", std::move( h1a ) ).isFailure() ) {
67 error() << "Couldn't register TempHist1a" << endmsg;
68 }
69
70 // Write to stream "new"
71 std::unique_ptr<TH1F> h2 = std::make_unique<TH1F>( "Tree2", "Tree 2", 100, 0., 100. );
72 if ( m_ths->regHist( "/new/Tree2", std::move( h2 ) ).isFailure() ) { error() << "Couldn't register Tree2" << endmsg; }
73
74 // Update to stream "upd", dir "/xxx"
75 std::unique_ptr<TH1F> h3 = std::make_unique<TH1F>( "1Dgauss", "1D Gaussian", 100, -50., 50. );
76 if ( m_ths->regHist( "/upd/xxx/gauss1d", std::move( h3 ) ).isFailure() ) {
77 error() << "Couldn't register gauss1d" << endmsg;
78 }
79
80 // Recreate 2D tree in "/"
81 std::unique_ptr<TH2F> h3a = std::make_unique<TH2F>( "2Dgauss", "2D Gaussian", 100, -50., 50., 100, -50, 50 );
82 if ( m_ths->regHist( "/rec/gauss2d", std::move( h3a ) ).isFailure() ) {
83 error() << "Couldn't register gauss2d" << endmsg;
84 }
85
86 // 3D tree in "/"
87 std::unique_ptr<TH3F> h4 =
88 std::make_unique<TH3F>( "3Dgauss", "3D Gaussian", 100, -50., 50., 100, -50, 50, 100, -50, 50 );
89 if ( m_ths->regHist( "/rec/gauss3d", std::move( h4 ) ).isFailure() ) {
90 error() << "Couldn't register gauss3d" << endmsg;
91 }
92
93 TH1F* h5 = new TH1F( "TempHist5", "Temporary Tree 5", 100, 0., 100. );
94 if ( m_ths->regHist( "TempHist5", std::unique_ptr<TH1F>( h5 ) ).isFailure() ) {
95 error() << "Couldn't register TempHist5" << endmsg;
96 }
97 if ( strcmp( h5->GetName(), "TempHist5" ) ) {
98 error() << "Couldn't use TempHist5 afterwards. getName = " << h5->GetName() << endmsg;
99 }
100
101 TH1D* h7 = new TH1D( "TempHist7", "Temporary Tree 7", 100, 0., 100. );
102 if ( m_ths->regHist( "TempHist7", h7 ).isFailure() ) { error() << "Couldn't register TempHist7" << endmsg; }
103 if ( strcmp( h7->GetName(), "TempHist7" ) ) {
104 error() << "Couldn't use TempHist7 afterwards. getName = " << h7->GetName() << endmsg;
105 }
106
107 // Profile in "/"
108 std::unique_ptr<TH1> tp = std::make_unique<TProfile>( "profile", "profile", 100, -50., -50. );
109 if ( m_ths->regHist( "/rec/prof", std::move( tp ) ).isFailure() ) { error() << "Couldn't register prof" << endmsg; }
110
111 // Tree with branches in "/trees/stuff"
112 std::unique_ptr<TTree> tr = std::make_unique<TTree>( "treename", "tree title" );
113 if ( m_ths->regTree( "/rec/trees/stuff/tree1", std::move( tr ) ).isFailure() ) {
114 error() << "Couldn't register tr" << endmsg;
115 }
116
117 // Update to stream "upd", dir "/xxx"
118 std::unique_ptr<TH1F> h3s = std::make_unique<TH1F>( "1Dgauss_shared", "1D Gaussian", 100, -50., 50. );
119 LockedHandle<TH1> lh1( nullptr, nullptr );
120 if ( m_ths->regShared( "/upd/xxx/gauss1d_shared", std::move( h3s ), lh1 ).isFailure() ) {
121 error() << "Couldn't register gauss1d_shared" << endmsg;
122 }
123
124 // Recreate 2D tree in "/"
125 std::unique_ptr<TH2F> h3sa = std::make_unique<TH2F>( "2Dgauss_shared", "2D Gaussian", 100, -50., 50., 100, -50, 50 );
126 LockedHandle<TH2> lh2( nullptr, nullptr );
127 if ( m_ths->regShared( "/rec/gauss2d_shared", std::move( h3sa ), lh2 ).isFailure() ) {
128 error() << "Couldn't register gauss2d_shared" << endmsg;
129 }
130
131 // 3D tree in "/"
132 std::unique_ptr<TH3F> h4s =
133 std::make_unique<TH3F>( "3Dgauss_shared", "3D Gaussian", 100, -50., 50., 100, -50, 50, 100, -50, 50 );
134 LockedHandle<TH3> lh3( nullptr, nullptr );
135 if ( m_ths->regShared( "/rec/gauss3d_shared", std::move( h4s ), lh3 ).isFailure() ) {
136 error() << "Couldn't register gauss3d_shared" << endmsg;
137 }
138
139 return StatusCode::SUCCESS;
140}
constexpr static const auto FAILURE
Definition StatusCode.h:100

◆ listKeys()

void THistWrite::listKeys ( TDirectory * td)
private

Definition at line 243 of file THistWrite.cpp.

243 {
244 //------------------------------------------------------------------------------
245
246 info() << "printing keys for: " << td->GetPath() << " (" << td->GetList()->GetSize() << ")" << endmsg;
247 TIter nextkey( td->GetList() );
248 while ( TKey* key = (TKey*)nextkey() ) {
249 if ( key != 0 ) {
250 info() << key->GetName() << " (" << key->IsA()->GetName()
251 << ") "
252 // << key->GetObjectStat()
253 // << " " << key->IsOnHeap()
254 << key->GetCycle() << endmsg;
255 } else {
256 info() << "key == 0" << endmsg;
257 }
258 }
259
260 return;
261}

Member Data Documentation

◆ m_ths

ServiceHandle<ITHistSvc> THistWrite::m_ths { this, "HistSvc", "THistSvc" }
private

Definition at line 33 of file THistWrite.h.

33{ this, "HistSvc", "THistSvc" };

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