| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
THistSvc Class Reference

`#include <src/THistSvc/THistSvc.h>`

Inheritance diagram for THistSvc:
[legend]
Collaboration diagram for THistSvc:
[legend]

## Classes
class | GlobalDirectoryRestore
struct | THistID

## Public Member Functions
StatusCode | initialize () override
StatusCode | reinitialize () override
StatusCode | finalize () override
StatusCode | regHist (const std::string &name) override
StatusCode | regHist (const std::string &name, TH1 *) override
StatusCode | regHist (const std::string &name, TH2 *) override
StatusCode | regHist (const std::string &name, TH3 *) override
StatusCode | getHist (const std::string &name, TH1 *&) const override
StatusCode | getHist (const std::string &name, TH2 *&) const override
StatusCode | getHist (const std::string &name, TH3 *&) const override
StatusCode | regTree (const std::string &name) override
StatusCode | regTree (const std::string &name, TTree *) override
StatusCode | getTree (const std::string &name, TTree *&) const override
StatusCode | regGraph (const std::string &name) override
StatusCode | regGraph (const std::string &name, TGraph *) override
StatusCode | getGraph (const std::string &name, TGraph *&) const override
StatusCode | deReg (TObject *obj) override
StatusCode | deReg (const std::string &name) override
std::vector< std::string > | getHists () const override
std::vector< std::string > | getTrees () const override
std::vector< std::string > | getGraphs () const override
StatusCode | getTHists (TDirectory *td, TList &, bool recurse=false) const override
StatusCode | getTHists (const std::string &name, TList &, bool recurse=false) const override
StatusCode | getTHists (TDirectory *td, TList &tl, bool recurse=false, bool reg=false) override
StatusCode | getTHists (const std::string &name, TList &tl, bool recurse=false, bool reg=false) override
StatusCode | getTTrees (TDirectory *td, TList &, bool recurse=false) const override
StatusCode | getTTrees (const std::string &name, TList &, bool recurse=false) const override
StatusCode | getTTrees (TDirectory *td, TList &tl, bool recurse=false, bool reg=false) override
StatusCode | getTTrees (const std::string &name, TList &tl, bool recurse=false, bool reg=false) override
bool | exists (const std::string &name) const override
| THistSvc (const std::string &name, ISvcLocator *svc)
void | handle (const Incident &) override
StatusCode | io_reinit () override
| callback method to reinitialize the internal state of the component for I/O purposes (e.g. More...
Public Member Functions inherited from extends< Service, ITHistSvc, IIncidentListener, IIoComponent >
void * | i_cast (const InterfaceID &tid) const override
| Implementation of IInterface::i_cast. More...
StatusCode | queryInterface (const InterfaceID &ti, void **pp) override
| Implementation of IInterface::queryInterface. More...
std::vector< std::string > | getInterfaceNames () const override
| Implementation of IInterface::getInterfaceNames. More...
| ~extends () override=default
| Virtual destructor. More...
Public Member Functions inherited from Service
const std::string & | name () const override
| Retrieve name of the service. More...
StatusCode | configure () override
StatusCode | initialize () override
StatusCode | start () override
StatusCode | stop () override
StatusCode | finalize () override
StatusCode | terminate () override
Gaudi::StateMachine::State | FSMState () const override
Gaudi::StateMachine::State | targetFSMState () const override
StatusCode | reinitialize () override
StatusCode | restart () override
StatusCode | sysInitialize () override
| Initialize Service. More...
StatusCode | sysStart () override
| Initialize Service. More...
StatusCode | sysStop () override
| Initialize Service. More...
StatusCode | sysFinalize () override
| Finalize Service. More...
StatusCode | sysReinitialize () override
| Re-initialize the Service. More...
StatusCode | sysRestart () override
| Re-initialize the Service. More...
| Service (std::string name, ISvcLocator *svcloc)
| Standard Constructor. More...
SmartIF< ISvcLocator > & | serviceLocator () const override
| Retrieve pointer to service locator. More...
StatusCode | setProperties ()
| Method for setting declared properties to the values specified for the job. More...
template<class T >
StatusCode | service (const std::string &name, const T *&psvc, bool createIf=true) const
| Access a service by name, creating it if it doesn't already exist. More...
template<class T >
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const
template<typename IFace = IService>
SmartIF< IFace > | service (const std::string &name, bool createIf=true) const
template<class T >
StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const
| Access a service by name and type, creating it if it doesn't already exist. More...
template<class T >
StatusCode | declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
| Declare used tool. More...
SmartIF< IAuditorSvc > & | auditorSvc () const
| The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| PropertyHolder ()=default
| ~PropertyHolder () override=default
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Details::PropertyBase &prop)
| Declare a property. More...
Gaudi::Details::PropertyBase * | declareProperty (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. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
| Declare a PropertyBase instance setting name and documentation. More...
Gaudi::Details::PropertyBase * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
| Declare a remote property. More...
StatusCode | setProperty (const Gaudi::Details::PropertyBase &p) override
| set the property form another property More...
StatusCode | setProperty (const std::string &s) override
| set the property from the formatted string More...
StatusCode | setProperty (const std::string &n, const std::string &v) override
| set the property from name and the value More...
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value More...
StatusCode | getProperty (Gaudi::Details::PropertyBase *p) const override
| get the property More...
const Gaudi::Details::PropertyBase & | getProperty (const std::string &name) const override
| get the property by name More...
StatusCode | getProperty (const std::string &n, std::string &v) const override
| convert the property to the string More...
const std::vector< Gaudi::Details::PropertyBase * > & | getProperties () const override
| get all properties More...
bool | hasProperty (const std::string &name) const override
| Return true if we have a property with the given name. More...
| PropertyHolder (const PropertyHolder &)=delete
PropertyHolder & | operator= (const PropertyHolder &)=delete
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
| Specializations for various GaudiHandles. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
const SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...
MSG::Level | msgLevel () const
| get the cached level (originally extracted from the embedded MsgStream) More...
MSG::Level | outputLevel () const __attribute__((deprecated))
| Backward compatibility function for getting the output level. More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
Public Member Functions inherited from extend_interfaces< Interfaces... >
| ~extend_interfaces () override=default
| Virtual destructor. More...

## Protected Member Functions
| ~THistSvc () override=default
Protected Member Functions inherited from Service
| ~Service () override
| Standard Destructor. More...
int | outputLevel () const
| get the `Service's` output level More...
Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBase * | property (const std::string &name) const
Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level | setUpMessaging ()
| Set up local caches. More...
MSG::Level | resetMessaging ()
| Reinitialize internal states. More...
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...

## Private Types
enum | Mode { READ, WRITE, UPDATE, APPEND, SHARE, INVALID }
typedef std::map< std::string, THistID > | uidMap
typedef std::multimap< std::string, THistID > | idMap
typedef std::map< TObject *, THistID > | objMap
typedef std::multimap< std::string, std::string > | streamMap

## Private Member Functions
template<typename T >
StatusCode | regHist_i (T *hist, const std::string &name)
template<typename T >
StatusCode | getHist_i (const std::string &name, T *&hist, bool quiet=false) const
template<typename T >
StatusCode | readHist_i (const std::string &name, T *&hist) const
StatusCode | readHist (const std::string &name, TH1 *&) const
StatusCode | readHist (const std::string &name, TH2 *&) const
StatusCode | readHist (const std::string &name, TH3 *&) const
StatusCode | readTree (const std::string &name, TTree *&) const
void | updateFiles ()
StatusCode | write ()
StatusCode | connect (const std::string &)
TDirectory * | changeDir (const THistSvc::THistID &hid) const
std::string | dirname (std::string &dir) const
void | removeDoubleSlash (std::string &) const
bool | browseTDir (TDirectory *dir) const
bool | findStream (const std::string &name, std::string &root, std::string &rem, TFile *&file) const
void | parseString (const std::string &id, std::string &root, std::string &rem) const
void | setupInputFile (Gaudi::Details::PropertyBase &inputfile)
| call-back method to handle input stream property More...
void | setupOutputFile (Gaudi::Details::PropertyBase &outputfile)
| call-back method to handle output stream property More...
void | setupCompressionLevel (Gaudi::Details::PropertyBase &cmp)
void | copyFileLayout (TDirectory *, TDirectory *)
| helper function to recursively copy the layout of a TFile into a new TFile More...
void | MergeRootFile (TDirectory *target, TDirectory *source)
StatusCode | rootOpenAction (FILEMGR_CALLBACK_ARGS)
StatusCode | rootOpenErrAction (FILEMGR_CALLBACK_ARGS)

## Private Attributes
Gaudi::Property< int > | m_autoSave {this, "AutoSave", 0}
Gaudi::Property< int > | m_autoFlush {this, "AutoFlush", 0}
Gaudi::Property< bool > | m_print {this, "PrintAll", false}
Gaudi::Property< int > | m_maxFileSize
Gaudi::Property< int > | m_compressionLevel {this, "CompressionLevel", 1}
Gaudi::Property< std::vector< std::string > > | m_outputfile {this, "Output", {}}
Gaudi::Property< std::vector< std::string > > | m_inputfile {this, "Input", {}}
std::vector< std::string > | m_Rstream
std::vector< std::string > | m_Wstream
std::set< std::string > | m_alreadyConnectedInFiles
| list of already connected files. More...
std::set< std::string > | m_alreadyConnectedOutFiles
| list of already connected files. More...
uidMap | m_uids
idMap | m_ids
objMap | m_tobjs
std::map< std::string, std::pair< TFile *, Mode > > | m_files
streamMap | m_fileStreams
std::map< std::string, std::string > | m_sharedFiles
bool | signaledStop = false
bool | m_delayConnect = false
bool | m_okToConnect = false
std::string | m_curstream
IIncidentSvc * | p_incSvc = nullptr
IFileMgr * | p_fileMgr = nullptr

## Additional Inherited Members
Public Types inherited from extends< Service, ITHistSvc, IIncidentListener, IIoComponent >
using | base_class = extends
| Typedef to this class. More...
using | extend_interfaces_base = extend_interfaces< Interfaces... >
| Typedef to the base of this class. More...
Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > | Factory
Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using | PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| Typedef used to refer to this class from derived classes, as in. More...
Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using | base_class = CommonMessaging
Public Types inherited from extend_interfaces< Interfaces... >
using | ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
| take union of the ext_iids of all Interfaces... More...
Protected Attributes inherited from Service
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::Property< int > | m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
Gaudi::Property< bool > | m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
Gaudi::Property< bool > | m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
Gaudi::Property< bool > | m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
Gaudi::Property< bool > | m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
Gaudi::Property< bool > | m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
Gaudi::Property< bool > | m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
Gaudi::Property< bool > | m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
SmartIF< IAuditorSvc > | m_pAuditorSvc
| Auditor Service. More...

## Detailed Description

Definition at line 25 of file THistSvc.h.

## Member Typedef Documentation

typedef std::multimap<std::string, THistID> THistSvc::idMap
| private

Definition at line 174 of file THistSvc.h.

typedef std::map<TObject*, THistID> THistSvc::objMap
| private

Definition at line 175 of file THistSvc.h.

typedef std::multimap<std::string, std::string> THistSvc::streamMap
| private

Definition at line 176 of file THistSvc.h.

typedef std::map<std::string, THistID> THistSvc::uidMap
| private

Definition at line 173 of file THistSvc.h.

## Member Enumeration Documentation

enum THistSvc::Mode
| private

Enumerator
READ |
WRITE |
UPDATE |
APPEND |
SHARE |
INVALID |

Definition at line 94 of file THistSvc.h.

94 { READ, WRITE, UPDATE, APPEND, SHARE, INVALID };
THistSvc::INVALID
Definition: THistSvc.h:94
THistSvc::APPEND
Definition: THistSvc.h:94
THistSvc::UPDATE
Definition: THistSvc.h:94
THistSvc::SHARE
Definition: THistSvc.h:94
THistSvc::READ
Definition: THistSvc.h:94
THistSvc::WRITE
Definition: THistSvc.h:94

## Constructor & Destructor Documentation

THistSvc::THistSvc | ( | const std::string & | name,
|  | ISvcLocator * | svc
| ) |  |

Definition at line 61 of file THistSvc.cpp.

61 : base_class( name, svc )
62 {
63 m_compressionLevel.declareUpdateHandler( &THistSvc::setupCompressionLevel, this );
64 m_outputfile.declareUpdateHandler( &THistSvc::setupOutputFile, this );
65 m_inputfile.declareUpdateHandler( &THistSvc::setupInputFile, this );
66 }
extends< Service, ITHistSvc, IIncidentListener, IIoComponent >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:15
THistSvc::setupCompressionLevel
void setupCompressionLevel(Gaudi::Details::PropertyBase &cmp)
Definition: THistSvc.cpp:1041
THistSvc::m_outputfile
Gaudi::Property< std::vector< std::string > > m_outputfile
Definition: THistSvc.h:160
THistSvc::m_inputfile
Gaudi::Property< std::vector< std::string > > m_inputfile
Definition: THistSvc.h:161
THistSvc::m_compressionLevel
Gaudi::Property< int > m_compressionLevel
Definition: THistSvc.h:159
THistSvc::setupInputFile
void setupInputFile(Gaudi::Details::PropertyBase &inputfile)
call-back method to handle input stream property
Definition: THistSvc.cpp:1050
THistSvc::setupOutputFile
void setupOutputFile(Gaudi::Details::PropertyBase &outputfile)
call-back method to handle output stream property
Definition: THistSvc.cpp:1082

THistSvc::~THistSvc | ( |  | ) |
| override protected default

## Member Function Documentation

bool THistSvc::browseTDir | ( | TDirectory * | dir | ) | const
| private

Definition at line 344 of file THistSvc.cpp.

345 {
346
347 if ( !dir ) {
348 std::cerr << "TDirectory == 0" << std::endl;
349 return false;
350 }
351
352 GlobalDirectoryRestore restore;
353
354 dir->cd();
355
356 cout << "-> " << dir->GetPath() << " " << dir->GetListOfKeys()->GetSize() << endl;
357
358 // TIter nextkey(dir->GetListOfKeys());
359 TIter nextkey( dir->GetList() );
360 while ( TKey* key = (TKey*)nextkey() ) {
361
362 TObject* obj = key->ReadObj();
363 if ( !obj ) {
364 cout << key->GetName() << " obj==0" << endl;
365 continue;
366 }
367 // if (obj->IsA()->InheritsFrom("TDirectory")) {
368 cout << " Key: " << key->GetName() << " "
369 << " tit: " << obj->GetTitle() << " "
370 << " (" << key->GetClassName() << ")" << endl;
371 // }
372 }
373
374 nextkey = dir->GetListOfKeys();
375 while ( TKey* key = (TKey*)nextkey() ) {
376
377 TObject* obj = key->ReadObj();
378 if ( !obj ) {
379 cout << key->GetName() << " obj==0" << endl;
380 continue;
381 }
382 if ( obj->IsA()->InheritsFrom( "TDirectory" ) ) {
383 TDirectory* tt = dynamic_cast<TDirectory*>( obj );
384 browseTDir( tt );
385 }
386 }
387
388 return true;
389 }
THistSvc::browseTDir
bool browseTDir(TDirectory *dir) const
Definition: THistSvc.cpp:344
std::endl
T endl(T...args)
GlobalDirectoryRestore
Definition: RConverter.h:16
std::cerr

TDirectory * THistSvc::changeDir | ( | const THistSvc::THistID & | hid | ) | const
| private

Definition at line 1411 of file THistSvc.cpp.

1412 {
1413
1414 string uid = hid.id;
1415 TFile* file = hid.file;
1416 string stream, fdir, bdir, dir, id;
1417
1418 if ( file ) {
1419 file->cd( "/" );
1420 } else {
1421 gROOT->cd();
1422 }
1423
1424 fdir = uid;
1425 bdir = dirname( fdir );
1426
1427 while ( ( dir = dirname( fdir ) ) != "" ) {
1428 if ( !gDirectory->GetKey( dir.c_str() ) ) {
1429 gDirectory->mkdir( dir.c_str() );
1430 }
1431 gDirectory->cd( dir.c_str() );
1432 }
1433
1434 return gDirectory;
1435 }
THistSvc::THistID::file
TFile * file
Definition: THistSvc.h:100
THistSvc::THistID::id
std::string id
Definition: THistSvc.h:97
THistSvc::dirname
std::string dirname(std::string &dir) const
Definition: THistSvc.cpp:1439
std::string::c_str
T c_str(T...args)

StatusCode THistSvc::connect | ( | const std::string & | ident | ) |
| private

Definition at line 1217 of file THistSvc.cpp.

1218 {
1219
1220 auto loc = ident.find( " " );
1221 string stream = ident.substr( 0, loc );
1222 char typ( 0 );
1223 typedef std::pair<std::string, std::string> Prop;
1224 std::vector<Prop> props;
1225 string filename, db_typ( "ROOT" );
1226 int cl( 1 );
1227
1228 if ( loc != string::npos ) {
1229 using Parser = Gaudi::Utils::AttribStringParser;
1230 for ( auto attrib : Parser( ident.substr( loc + 1 ) ) ) {
1231 auto TAG = boost::algorithm::to_upper_copy( attrib.tag );
1232 auto VAL = boost::algorithm::to_upper_copy( attrib.value );
1233
1234 if ( TAG == "FILE" || TAG == "DATAFILE" ) {
1235 filename = attrib.value;
1236 removeDoubleSlash( filename );
1237 } else if ( TAG == "OPT" ) {
1238 if ( VAL == "APPEND" || VAL == "UPDATE" ) {
1239 typ = 'A';
1240 } else if ( VAL == "CREATE" || VAL == "NEW" || VAL == "WRITE" ) {
1241 typ = 'N';
1242 } else if ( VAL == "RECREATE" ) {
1243 typ = 'R';
1244 } else if ( VAL == "SHARE" ) {
1245 typ = 'S';
1246 } else if ( VAL == "OLD" || VAL == "READ" ) {
1247 typ = 'O';
1248 } else {
1249 error() << "Unknown OPT: \"" << attrib.value << "\"" << endmsg;
1250 typ = 0;
1251 }
1252 } else if ( TAG == "TYP" ) {
1253 db_typ = std::move( attrib.value );
1254 } else if ( TAG == "CL" ) {
1255 cl = std::stoi( attrib.value );
1256 } else {
1257 props.emplace_back( attrib.tag, attrib.value );
1258 }
1259 }
1260 }
1261
1262 if ( stream == "temp" ) {
1263 error() << "in JobOption \"" << ident << "\": stream name \"temp\" reserved." << endmsg;
1264 return StatusCode::FAILURE;
1265 }
1266
1267 if ( db_typ != "ROOT" ) {
1268 error() << "in JobOption \"" << ident << "\": technology type \"" << db_typ << "\" not supported." << endmsg;
1269 return StatusCode::FAILURE;
1270 }
1271
1272 if ( m_files.find( stream ) != m_files.end() ) {
1273 error() << "in JobOption \"" << ident << "\":\n stream \"" << stream << "\" already connected to file: \""
1274 << m_files[stream].first->GetName() << "\"" << endmsg;
1275 return StatusCode::FAILURE;
1276 }
1277
1278 Mode newMode;
1279 if ( typ == 'O' ) {
1280 newMode = THistSvc::READ;
1281 } else if ( typ == 'N' ) {
1282 newMode = THistSvc::WRITE;
1283 } else if ( typ == 'A' ) {
1284 newMode = THistSvc::APPEND;
1285 } else if ( typ == 'R' ) {
1286 newMode = THistSvc::UPDATE;
1287 } else if ( typ == 'S' ) {
1288 newMode = THistSvc::SHARE;
1289 } else {
1290 // something else?
1291 error() << "No OPT= specified or unknown access mode in: " << ident << endmsg;
1292 return StatusCode::FAILURE;
1293 }
1294
1295 // Is this file already connected to another stream?
1296 if ( m_fileStreams.find( filename ) != m_fileStreams.end() ) {
1297 auto fitr = m_fileStreams.equal_range( filename );
1298
1299 const std::string& oldstream = fitr.first->second;
1300
1301 const auto& f_info = m_files[oldstream];
1302
1303 if ( newMode != f_info.second ) {
1304 error() << "in JobOption \"" << ident << "\":\n file \"" << filename << "\" already opened by stream: \""
1305 << oldstream << "\" with different access mode." << endmsg;
1306 return StatusCode::FAILURE;
1307 } else {
1308 TFile* f2 = f_info.first;
1309 m_files[stream] = make_pair( f2, newMode );
1310 if ( msgLevel( MSG::DEBUG ) )
1311 debug() << "Connecting stream: \"" << stream << "\" to previously opened TFile: \"" << filename << "\""
1312 << endmsg;
1313 return StatusCode::SUCCESS;
1314 }
1315 }
1316
1317 IIncidentSvc* pi = nullptr;
1318 if ( service( "IncidentSvc", pi ).isFailure() ) {
1319 error() << "Unable to get the IncidentSvc" << endmsg;
1320 return StatusCode::FAILURE;
1321 }
1322
1323 void* vf = nullptr;
1324 TFile* f = nullptr;
1325
1326 if ( newMode == THistSvc::READ ) {
1327 // old file
1328
1329 int r = p_fileMgr->open( Io::ROOT, name(), filename, Io::READ, vf, "HIST" );
1330
1331 if ( r != 0 ) {
1332 error() << "Unable to open ROOT file " << filename << " for reading" << endmsg;
1333 return StatusCode::FAILURE;
1334 }
1335
1336 f = (TFile*)vf;
1337
1338 // FIX ME!
1339 pi->fireIncident( FileIncident( name(), "BeginHistFile", filename ) );
1340
1341 } else if ( newMode == THistSvc::WRITE ) {
1342 // new file. error if file exists
1343
1344 int r = p_fileMgr->open( Io::ROOT, name(), filename, ( Io::WRITE | Io::CREATE | Io::EXCL ), vf, "HIST" );
1345
1346 if ( r != 0 ) {
1347 error() << "Unable to open ROOT file " << filename << " for writing" << endmsg;
1348 return StatusCode::FAILURE;
1349 }
1350
1351 f = (TFile*)vf;
1352
1353 } else if ( newMode == THistSvc::APPEND ) {
1354 // update file
1355
1356 int r = p_fileMgr->open( Io::ROOT, name(), filename, ( Io::WRITE | Io::APPEND ), vf, "HIST" );
1357 if ( r != 0 ) {
1358 error() << "unable to open file \"" << filename << "\" for appending" << endmsg;
1359 return StatusCode::FAILURE;
1360 }
1361
1362 f = (TFile*)vf;
1363
1364 } else if ( newMode == THistSvc::SHARE ) {
1365 // SHARE file type
1366 // For SHARE files, all data will be stored in a temp file and will be merged into the target file
1367 // in write() when finalize(), this help to solve some confliction. e.g. with storegate
1368
1369 static int ishared = 0;
1370 string realfilename = filename;
1371 filename = "tmp_THistSvc_" + std::to_string( ishared++ ) + ".root";
1372
1373 if ( msgLevel( MSG::DEBUG ) )
1374 debug() << "Creating temp file \"" << filename << "\" and realfilename=" << realfilename << endmsg;
1375 m_sharedFiles[stream] = realfilename;
1376
1377 int r = p_fileMgr->open( Io::ROOT, name(), filename, ( Io::WRITE | Io::CREATE | Io::EXCL ), vf, "HIST" );
1378
1379 if ( r != 0 ) {
1380 error() << "Unable to open ROOT file " << filename << " for writing" << endmsg;
1381 return StatusCode::FAILURE;
1382 }
1383
1384 f = (TFile*)vf;
1385
1386 } else if ( newMode == THistSvc::UPDATE ) {
1387 // update file
1388
1389 int r = p_fileMgr->open( Io::ROOT, name(), filename, ( Io::WRITE | Io::CREATE ), vf, "HIST" );
1390
1391 if ( r != 0 ) {
1392 error() << "Unable to open ROOT file " << filename << " for appending" << endmsg;
1393 return StatusCode::FAILURE;
1394 }
1395
1396 f = (TFile*)vf;
1397 }
1398
1399 m_files[stream] = make_pair( f, newMode );
1400 m_fileStreams.insert( make_pair( filename, stream ) );
1401
1402 if ( msgLevel( MSG::DEBUG ) )
1403 debug() << "Opening TFile \"" << filename << "\" stream: \"" << stream << "\" mode: \"" << typ << "\""
1404 << " comp level: " << cl << endmsg;
1405
1406 return StatusCode::SUCCESS;
1407 }
Gaudi::Utils::AttribStringParser
Parse attribute strings allowing iteration over the various attributes.
Definition: AttribStringParser.h:32
StatusCode::SUCCESS
Definition: StatusCode.h:31
FileIncident
This class is the FileIncident.
Definition: FileIncident.h:17
Io::ROOT
Definition: IFileMgr.h:157
IFileMgr::open
virtual Io::open_t open(const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, Io::Fd &, void *&, const std::string &desc, const bool shared=false)=0
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
StatusCode::FAILURE
Definition: StatusCode.h:31
THistSvc::APPEND
Definition: THistSvc.h:94
std::to_string
T to_string(T...args)
MSG::DEBUG
Definition: IMessageSvc.h:16
std::map::end
T end(T...args)
graphanalysis.filename
string filename
Definition: graphanalysis.py:117
Io::EXCL
Definition: IFileMgr.h:32
THistSvc::UPDATE
Definition: THistSvc.h:94
THistSvc::SHARE
Definition: THistSvc.h:94
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
IIncidentSvc::fireIncident
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
Io::WRITE
Definition: IFileMgr.h:28
Io::READ
Definition: IFileMgr.h:27
std::make_pair
T make_pair(T...args)
std::move
T move(T...args)
THistSvc::Mode
Mode
Definition: THistSvc.h:94
std::pair< std::string, std::string >
std::multimap::insert
T insert(T...args)
std::string::find
T find(T...args)
Io::APPEND
Definition: IFileMgr.h:35
std::vector
STL class.
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
Io::CREATE
Definition: IFileMgr.h:31
THistSvc::m_files
std::map< std::string, std::pair< TFile *, Mode > > m_files
Definition: THistSvc.h:182
THistSvc::READ
Definition: THistSvc.h:94
THistSvc::p_fileMgr
IFileMgr * p_fileMgr
Definition: THistSvc.h:193
std::string::substr
T substr(T...args)
THistSvc::m_sharedFiles
std::map< std::string, std::string > m_sharedFiles
Definition: THistSvc.h:185
Service::service
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:85
THistSvc::WRITE
Definition: THistSvc.h:94
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
std::stoi
T stoi(T...args)
std::multimap::equal_range
T equal_range(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi::Units::pi
constexpr double pi
Definition: PhysicalConstants.h:47
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23
THistSvc::m_fileStreams
streamMap m_fileStreams
Definition: THistSvc.h:183
THistSvc::removeDoubleSlash
void removeDoubleSlash(std::string &) const
Definition: THistSvc.cpp:1475
std::vector::emplace_back
T emplace_back(T...args)

void THistSvc::copyFileLayout | ( | TDirectory * | dst,
|  | TDirectory * | src
| ) |  |
| private

helper function to recursively copy the layout of a TFile into a new TFile

Definition at line 1609 of file THistSvc.cpp.

1610 {
1611
1612 if ( msgLevel( MSG::DEBUG ) ) debug() << "copyFileLayout() to dst path: " << dst->GetPath() << endmsg;
1613
1614 // strip out URLs
1615 TString path( (char*)strstr( dst->GetPath(), ":" ) );
1616 path.Remove( 0, 2 );
1617
1618 src->cd( path );
1619 TDirectory* cur_src_dir = gDirectory;
1620
1621 // loop over all keys in this directory
1622 TList* key_list = cur_src_dir->GetListOfKeys();
1623 int n = key_list->GetEntries();
1624 for ( int j = 0; j < n; ++j ) {
1625 TKey* k = (TKey*)key_list->At( j );
1626 const std::string src_pathname = cur_src_dir->GetPath() + std::string( "/" ) + k->GetName();
1627 TObject* o = src->Get( src_pathname.c_str() );
1628
1629 if ( o && o->IsA()->InheritsFrom( "TDirectory" ) ) {
1630 if ( msgLevel( MSG::VERBOSE ) ) verbose() << " subdir [" << o->GetName() << "]..." << endmsg;
1631 dst->cd();
1632 TDirectory* dst_dir = dst->mkdir( o->GetName(), o->GetTitle() );
1633 copyFileLayout( dst_dir, src );
1634 }
1635 } // loop over keys
1636 return;
1637 }
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:895
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:118
MSG::DEBUG
Definition: IMessageSvc.h:16
THistSvc::copyFileLayout
void copyFileLayout(TDirectory *, TDirectory *)
helper function to recursively copy the layout of a TFile into a new TFile
Definition: THistSvc.cpp:1609
MSG::VERBOSE
Definition: IMessageSvc.h:16
std::string
STL class.
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:228
ReadAndWriteWhiteBoard.dst
dst
Definition: ReadAndWriteWhiteBoard.py:17
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
std::string::c_str
T c_str(T...args)
std::strstr
T strstr(T...args)
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

StatusCode THistSvc::deReg | ( | TObject * | obj | ) |
| override

Definition at line 795 of file THistSvc.cpp.

796 {
797
798 auto itr = m_tobjs.find( obj );
799 if ( itr != m_tobjs.end() ) {
800 THistID hid = itr->second;
801
802 auto itr2 = m_uids.find( hid.id );
803 if ( itr2 == m_uids.end() ) {
804 error() << "Problems deregistering TObject \"" << obj->GetName() << "\" with id \"" << hid.id << "\"" << endmsg;
805 return StatusCode::FAILURE;
806 }
807
808 std::string id, root, rem;
809 parseString( hid.id, root, rem );
810
811 auto mitr = m_ids.equal_range( rem );
812 auto itr3 =
813 std::find_if( mitr.first, mitr.second, [&]( idMap::const_reference i ) { return i.second.obj == obj; } );
814 if ( itr3 == mitr.second ) {
815 error() << "Problems deregistering TObject \"" << obj->GetName() << "\" with id \"" << hid.id << "\"" << endmsg;
816 return StatusCode::FAILURE;
817 }
818
819 m_tobjs.erase( itr );
820 m_uids.erase( itr2 );
821 m_ids.erase( itr3 );
822
823 return StatusCode::SUCCESS;
824
825 } else {
826 error() << "Cannot unregister TObject \"" << obj->GetName() << "\": not known to THistSvc" << endmsg;
827 return StatusCode::FAILURE;
828 }
829 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
std::map::end
T end(T...args)
THistSvc::m_tobjs
objMap m_tobjs
Definition: THistSvc.h:180
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
std::map::erase
T erase(T...args)
THistSvc::parseString
void parseString(const std::string &id, std::string &root, std::string &rem) const
Definition: THistSvc.cpp:1024
std::map::find
T find(T...args)
THistSvc::m_uids
uidMap m_uids
Definition: THistSvc.h:178
THistSvc::m_ids
idMap m_ids
Definition: THistSvc.h:179
gaudiComponentHelp.root
root
Definition: gaudiComponentHelp.py:18
std::multimap::equal_range
T equal_range(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

StatusCode THistSvc::deReg | ( | const std::string & | name | ) |
| override

Definition at line 833 of file THistSvc.cpp.

834 {
835
836 auto itr = m_uids.find( id );
837 if ( itr == m_uids.end() ) {
838 error() << "Problems deregistering id \"" << id << "\"" << endmsg;
839 return StatusCode::FAILURE;
840 }
841
842 TObject* obj = itr->second.obj;
843 return deReg( obj );
844 }
StatusCode::FAILURE
Definition: StatusCode.h:31
std::map::end
T end(T...args)
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
std::map::find
T find(T...args)
THistSvc::m_uids
uidMap m_uids
Definition: THistSvc.h:178
THistSvc::deReg
StatusCode deReg(TObject *obj) override
Definition: THistSvc.cpp:795
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

std::string THistSvc::dirname | ( | std::string & | dir | ) | const
| private

Definition at line 1439 of file THistSvc.cpp.

1440 {
1441
1442 string::size_type i = dir.find( "/" );
1443
1444 if ( i == string::npos ) return {};
1445
1446 if ( i == 0 ) {
1447 dir.erase( 0, 1 );
1448 return dirname( dir );
1449 }
1450
1451 string root = dir.substr( 0, i );
1452 dir.erase( 0, i );
1453
1454 return root;
1455 }
THistSvc::dirname
std::string dirname(std::string &dir) const
Definition: THistSvc.cpp:1439
std::string::erase
T erase(T...args)
std::string::find
T find(T...args)
std::string::substr
T substr(T...args)
gaudiComponentHelp.root
root
Definition: gaudiComponentHelp.py:18

bool THistSvc::exists | ( | const std::string & | name | ) | const
| override

Definition at line 1552 of file THistSvc.cpp.

1553 {
1554
1555 TH1* h;
1556 return getHist_i( name, h, true ).isSuccess();
1557 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
HiveAlgSequencer.h
h
Definition: HiveAlgSequencer.py:24
THistSvc::getHist_i
StatusCode getHist_i(const std::string &name, T *&hist, bool quiet=false) const
Definition: THistSvc.icc:142

StatusCode THistSvc::finalize | ( |  | ) |
| override

Definition at line 199 of file THistSvc.cpp.

200 {
201
202 GlobalDirectoryRestore restore;
203
204 if ( msgLevel( MSG::DEBUG ) ) debug() << "THistSvc::finalize" << endmsg;
205
206 #ifndef NDEBUG
207 if ( msgLevel( MSG::DEBUG ) ) {
208 for ( const auto& uid : m_uids ) {
209
210 TObject* to = uid.second.obj;
211
212 string dirname( "none" );
213 if ( to && to->IsA()->InheritsFrom( "TTree" ) ) {
214 TTree* tr = dynamic_cast<TTree*>( to );
215 if ( tr->GetDirectory() != 0 ) {
216 dirname = tr->GetDirectory()->GetPath();
217 }
218 } else if ( to && to->IsA()->InheritsFrom( "TGraph" ) ) {
219 if ( !uid.second.temp ) {
220 dirname = uid.second.file->GetPath();
221 string id2( uid.second.id );
222 id2.erase( 0, id2.find( "/", 1 ) );
223 id2.erase( id2.rfind( "/" ), id2.length() );
224 if ( id2.find( "/" ) == 0 ) {
225 id2.erase( 0, 1 );
226 }
227 dirname += id2;
228 } else {
229 dirname = "/tmp";
230 }
231 } else if ( to && to->IsA()->InheritsFrom( "TH1" ) ) {
232 TH1* th = dynamic_cast<TH1*>( to );
233 if ( th == 0 ) {
234 error() << "Couldn't dcast: " << uid.first << endmsg;
235 } else {
236 if ( th->GetDirectory() != 0 ) {
237 dirname = th->GetDirectory()->GetPath();
238 }
239 }
240 } else if ( !to ) {
241 warning() << uid.first << " has NULL TObject ptr" << endmsg;
242 }
243
244 debug() << "uid: \"" << uid.first << "\" temp: " << uid.second.temp << " dir: " << dirname << endmsg;
245 }
246 }
247 #endif
248
249 StatusCode sc = write();
250 if ( sc.isFailure() ) {
251 error() << "problems writing histograms" << endmsg;
252 }
253
254 if ( m_print ) {
255 info() << "Listing contents of ROOT files: " << endmsg;
256 }
257 vector<TFile*> deleted_files;
258 for ( auto& itr : m_files ) {
259
260 if ( find( deleted_files.begin(), deleted_files.end(), itr.second.first ) == deleted_files.end() ) {
261 deleted_files.push_back( itr.second.first );
262
263 #ifndef NDEBUG
264 if ( msgLevel( MSG::DEBUG ) )
265 debug() << "finalizing stream/file " << itr.first << ":" << itr.second.first->GetName() << endmsg;
266 #endif
267 } else {
268 #ifndef NDEBUG
269 if ( msgLevel( MSG::DEBUG ) ) debug() << "already finalized stream " << itr.first << endmsg;
270 #endif
271 continue;
272 }
273
274 if ( m_print && msgLevel( MSG::INFO ) ) {
275
276 info() << "==> File: " << itr.second.first->GetName() << " stream: " << itr.first << endmsg;
277
278 itr.second.first->Print( "base" );
279 }
280
281 string tmpfn = itr.second.first->GetName();
282
283 p_fileMgr->close( itr.second.first, name() );
284
285 IIncidentSvc* pi = nullptr;
286 if ( service( "IncidentSvc", pi ).isFailure() ) {
287 error() << "Unable to get the IncidentSvc" << endmsg;
288 return StatusCode::FAILURE;
289 }
290
291 if ( itr.second.second == SHARE ) {
292
293 // Merge File
294 void* vf = nullptr;
295 int r = p_fileMgr->open( Io::ROOT, name(), m_sharedFiles[itr.first], Io::WRITE | Io::APPEND, vf, "HIST" );
296
297 if ( r ) {
298 error() << "unable to open Final Output File: \"" << m_sharedFiles[itr.first] << "\" for merging" << endmsg;
299 return StatusCode::FAILURE;
300 }
301
302 TFile* outputfile = (TFile*)vf;
303 pi->fireIncident( FileIncident( name(), IncidentType::WroteToOutputFile, m_sharedFiles[itr.first] ) );
304
305 if ( msgLevel( MSG::DEBUG ) ) debug() << "THistSvc::write()::Merging Rootfile " << endmsg;
306
307 vf = nullptr;
308 r = p_fileMgr->open( Io::ROOT, name(), tmpfn, Io::READ, vf, "HIST" );
309
310 if ( r ) {
311 error() << "unable to open temporary file: \"" << tmpfn << endmsg;
312 return StatusCode::FAILURE;
313 }
314
315 TFile* inputfile = (TFile*)vf;
316
317 outputfile->SetCompressionLevel( inputfile->GetCompressionLevel() );
318
319 MergeRootFile( outputfile, inputfile );
320
321 outputfile->Write();
322 p_fileMgr->close( outputfile, name() );
323 p_fileMgr->close( inputfile, name() );
324
325 if ( msgLevel( MSG::DEBUG ) ) debug() << "Trying to remove temporary file \"" << tmpfn << "\"" << endmsg;
326
327 std::remove( tmpfn.c_str() );
328 }
329 delete itr.second.first;
330 }
331
332 m_sharedFiles.clear();
333 m_fileStreams.clear();
334 m_files.clear();
335 m_uids.clear();
336 m_ids.clear();
337 m_tobjs.clear();
338
339 return Service::finalize();
340 }
FileIncident
This class is the FileIncident.
Definition: FileIncident.h:17
Io::ROOT
Definition: IFileMgr.h:157
IFileMgr::open
virtual Io::open_t open(const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, Io::Fd &, void *&, const std::string &desc, const bool shared=false)=0
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
StatusCode::FAILURE
Definition: StatusCode.h:31
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:174
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:112
MSG::DEBUG
Definition: IMessageSvc.h:16
std::vector::end
T end(T...args)
std::remove
T remove(T...args)
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
THistSvc::m_tobjs
objMap m_tobjs
Definition: THistSvc.h:180
THistSvc::write
StatusCode write()
Definition: THistSvc.cpp:1188
THistSvc::SHARE
Definition: THistSvc.h:94
std::vector::push_back
T push_back(T...args)
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
IIncidentSvc::fireIncident
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:109
THistSvc::dirname
std::string dirname(std::string &dir) const
Definition: THistSvc.cpp:1439
Io::WRITE
Definition: IFileMgr.h:28
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
THistSvc::m_print
Gaudi::Property< bool > m_print
Definition: THistSvc.h:156
Io::READ
Definition: IFileMgr.h:27
std::map::clear
T clear(T...args)
std::find
T find(T...args)
Io::APPEND
Definition: IFileMgr.h:35
std::vector
STL class.
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
THistSvc::m_uids
uidMap m_uids
Definition: THistSvc.h:178
std::vector::begin
T begin(T...args)
GlobalDirectoryRestore
Definition: RConverter.h:16
std::string::c_str
T c_str(T...args)
THistSvc::m_files
std::map< std::string, std::pair< TFile *, Mode > > m_files
Definition: THistSvc.h:182
THistSvc::m_ids
idMap m_ids
Definition: THistSvc.h:179
THistSvc::p_fileMgr
IFileMgr * p_fileMgr
Definition: THistSvc.h:193
THistSvc::m_sharedFiles
std::map< std::string, std::string > m_sharedFiles
Definition: THistSvc.h:185
Service::service
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:85
MSG::INFO
Definition: IMessageSvc.h:16
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi::Units::pi
constexpr double pi
Definition: PhysicalConstants.h:47
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23
THistSvc::m_fileStreams
streamMap m_fileStreams
Definition: THistSvc.h:183
THistSvc::MergeRootFile
void MergeRootFile(TDirectory *target, TDirectory *source)
Definition: THistSvc.cpp:1485
IFileMgr::close
virtual Io::close_t close(const Io::Fd, const std::string &caller)=0

bool THistSvc::findStream | ( | const std::string & | name,
|  | std::string & | root,
|  | std::string & | rem,
|  | TFile *& | file
| ) |  | const
| private

Definition at line 985 of file THistSvc.cpp.

986 {
987
988 auto pos = id.find( "/" );
989
990 if ( pos == string::npos ) {
991 stream = "temp";
992 rem = id;
993 } else if ( pos != 0 ) {
994 stream = "temp";
995 rem = id;
996 } else {
997
998 auto pos2 = id.find( "/", pos + 1 );
999
1000 if ( pos2 == string::npos ) {
1001 error() << "badly formed Hist/Tree id: \"" << id << "\"" << endmsg;
1002 return false;
1003 }
1004
1005 parseString( id, stream, rem );
1006 }
1007
1008 if ( stream == "temp" ) {
1009 file = nullptr;
1010 return true;
1011 }
1012
1013 auto itr = m_files.find( stream );
1014 file = ( itr != m_files.end() ? itr->second.first : nullptr );
1015 if ( !file ) {
1016 warning() << "no stream \"" << stream << "\" associated with id: \"" << id << "\"" << endmsg;
1017 }
1018
1019 return true;
1020 }
std::map::end
T end(T...args)
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:109
THistSvc::parseString
void parseString(const std::string &id, std::string &root, std::string &rem) const
Definition: THistSvc.cpp:1024
std::string::find
T find(T...args)
THistSvc::m_files
std::map< std::string, std::pair< TFile *, Mode > > m_files
Definition: THistSvc.h:182
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

StatusCode THistSvc::getGraph | ( | const std::string & | name,
|  | TGraph *& | hist
| ) |  | const
| override

Definition at line 954 of file THistSvc.cpp.

954 { return getHist_i( id, hist ); }
THistSvc::getHist_i
StatusCode getHist_i(const std::string &name, T *&hist, bool quiet=false) const
Definition: THistSvc.icc:142

std::vector< std::string > THistSvc::getGraphs | ( |  | ) | const
| override

Definition at line 958 of file THistSvc.cpp.

959 {
960
961 std::vector<std::string> names;
962 names.reserve( m_uids.size() );
963 transform_if( std::begin( m_uids ), std::end( m_uids ), std::back_inserter( names ), select1st,
964 []( uidMap::const_reference i ) { return i.second.obj->IsA()->InheritsFrom( "TTree" ); } );
965 return names;
966 }
std::end
T end(T...args)
std::map::size
T size(T...args)
std::vector< std::string >
THistSvc::m_uids
uidMap m_uids
Definition: THistSvc.h:178
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
std::vector::reserve
T reserve(T...args)

StatusCode THistSvc::getHist | ( | const std::string & | name,
|  | TH1 *& | hist
| ) |  | const
| override

Definition at line 916 of file THistSvc.cpp.

916 { return getHist_i( id, hist ); }
THistSvc::getHist_i
StatusCode getHist_i(const std::string &name, T *&hist, bool quiet=false) const
Definition: THistSvc.icc:142

StatusCode THistSvc::getHist | ( | const std::string & | name,
|  | TH2 *& | hist
| ) |  | const
| override

Definition at line 920 of file THistSvc.cpp.

920 { return getHist_i( id, hist ); }
THistSvc::getHist_i
StatusCode getHist_i(const std::string &name, T *&hist, bool quiet=false) const
Definition: THistSvc.icc:142

StatusCode THistSvc::getHist | ( | const std::string & | name,
|  | TH3 *& | hist
| ) |  | const
| override

Definition at line 924 of file THistSvc.cpp.

924 { return getHist_i( id, hist ); }
THistSvc::getHist_i
StatusCode getHist_i(const std::string &name, T *&hist, bool quiet=false) const
Definition: THistSvc.icc:142
template<typename T >

StatusCode THistSvc::getHist_i | ( | const std::string & | name,
|  | T *& | hist,
|  | bool | quiet = `false`
| ) |  | const
| private

Definition at line 142 of file THistSvc.icc.

142 {
143 // id starts with "/": unique
144
145 GlobalDirectoryRestore restore;
146
147 std::string idr(id);
148 removeDoubleSlash( idr );
149
150 if (idr.find("/") == 0) {
151 auto itr = m_uids.find(id);
152 if (itr == m_uids.end()) {
153 if (!quiet) {
154 error() << "Could not locate Hist with id \"" << idr << "\""
155 << endmsg;
156 }
157 hist = nullptr;
158 return StatusCode::FAILURE;
159 }
160
161 THistID hid = itr->second;
162 if (!quiet) {
163 hist = dynamic_cast<T*>(hid.obj);
164 if ( !hist ) {
165 error() << "dcast failed, Hist id: \"" << idr << "\""
166 << endmsg;
167 return StatusCode::FAILURE;
168 }
169 if (msgLevel(MSG::VERBOSE)) {
170 verbose() << "found unique Hist title: \""
171 << hist->GetTitle()
172 << "\" id: \"" << idr << "\"" << endmsg;
173 }
174 } else {
175 if (msgLevel(MSG::VERBOSE)) {
176 verbose() << "found unique Hist id: \"" << idr
177 << "\" type: \"" << hid.obj->IsA()->GetName() << "\""
178 << endmsg;
179 }
180 }
181
182 return StatusCode::SUCCESS;
183
184
185 // not necessarily unique
186 } else {
187
188 auto mitr = m_ids.equal_range(idr);
189
190
191 if (mitr.first == mitr.second) {
192 error() << "Could not locate Hist with id \"" << idr << "\""
193 << endmsg;
194 hist = nullptr;
195 return StatusCode::FAILURE;
196 } else {
197
198 if (distance(mitr.first,mitr.second) == 1) {
199 THistID hid = mitr.first->second;
200 if (!quiet) {
201 hist = dynamic_cast<T*>(hid.obj);
202 if (hist == 0) {
203 error() << "dcast failed" << endmsg;
204 return StatusCode::FAILURE;
205 }
206 if (msgLevel(MSG::VERBOSE)) {
207 verbose() << "found Hist title: \"" << hist->GetTitle()
208 << "\" id: \"" << idr << "\"" << endmsg;
209 }
210 } else {
211 if (msgLevel(MSG::VERBOSE)) {
212 verbose() << "found Hist id: \"" << idr << "\" type: \""
213 << hid.obj->IsA()->GetName() << "\""
214 << endmsg;
215 }
216 }
217 return StatusCode::SUCCESS;
218 } else {
219 if (!quiet) {
220 // return failure if trying to GET a single hist
221 error() << "Multiple matches with id \"" << idr << "\"."
222 << " Further specifications required."
223 << endmsg;
224 hist = nullptr;
225 return StatusCode::FAILURE;
226 } else {
227 // return a SUCCESS if just INQUIRING
228 info() << "Found multiple matches with id \"" << idr
229 << "\"" << endmsg;
230 hist = nullptr;
231 return StatusCode::SUCCESS;
232 }
233 }
234 }
235 }
236 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
std::distance
T distance(T...args)
StatusCode::FAILURE
Definition: StatusCode.h:31
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:112
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:118
std::map::end
T end(T...args)
MSG::VERBOSE
Definition: IMessageSvc.h:16
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
std::map::find
T find(T...args)
THistSvc::m_uids
uidMap m_uids
Definition: THistSvc.h:178
GlobalDirectoryRestore
Definition: RConverter.h:16
THistSvc::m_ids
idMap m_ids
Definition: THistSvc.h:179
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
std::multimap::equal_range
T equal_range(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
THistSvc::removeDoubleSlash
void removeDoubleSlash(std::string &) const
Definition: THistSvc.cpp:1475

std::vector< std::string > THistSvc::getHists | ( |  | ) | const
| override

Definition at line 928 of file THistSvc.cpp.

929 {
930
931 std::vector<std::string> names;
932 names.reserve( m_uids.size() );
933 transform_if( std::begin( m_uids ), std::end( m_uids ), std::back_inserter( names ), select1st,
934 []( uidMap::const_reference i ) { return i.second.obj->IsA()->InheritsFrom( "TH1" ); } );
935 return names;
936 }
std::end
T end(T...args)
std::map::size
T size(T...args)
std::vector< std::string >
THistSvc::m_uids
uidMap m_uids
Definition: THistSvc.h:178
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
std::vector::reserve
T reserve(T...args)

StatusCode THistSvc::getTHists | ( | TDirectory * | td,
|  | TList & | tl,
|  | bool | recurse = `false`
| ) |  | const
| override

Definition at line 393 of file THistSvc.cpp.

394 {
395 GlobalDirectoryRestore restore;
396
397 gErrorIgnoreLevel = kBreak;
398
399 if ( !td->cd() ) {
400 error() << "getTHists: No such TDirectory \"" << td->GetPath() << "\"" << endmsg;
401 return StatusCode::FAILURE;
402 }
403
404 if ( msgLevel( MSG::DEBUG ) )
405 debug() << "getTHists: \"" << td->GetPath() << "\": found " << td->GetListOfKeys()->GetSize() << " keys" << endmsg;
406
407 TIter nextkey( td->GetListOfKeys() );
408 while ( TKey* key = (TKey*)nextkey() ) {
409 auto& log = debug();
410 if ( msgLevel( MSG::DEBUG ) ) log << " key: " << key->GetName();
411 TObject* obj = key->ReadObj();
412 if ( obj != 0 && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
413 if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
414 } else if ( obj != 0 && obj->IsA()->InheritsFrom( "TH1" ) ) {
415 if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
416 tl.Add( obj );
417 } else if ( obj != 0 ) {
418 if ( msgLevel( MSG::DEBUG ) ) log << " [" << obj->IsA()->GetName() << "]";
419 }
420 if ( msgLevel( MSG::DEBUG ) ) log << endmsg;
421 }
422
423 // operate recursively
424 if ( rcs ) {
425 nextkey = td->GetListOfKeys();
426 while ( TKey* key = (TKey*)nextkey() ) {
427 TObject* obj = key->ReadObj();
428 if ( obj && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
429 TDirectory* tt = dynamic_cast<TDirectory*>( obj );
430 getTHists( tt, tl, rcs );
431 }
432 }
433 }
434
435 return StatusCode::SUCCESS;
436 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
THistSvc::getTHists
StatusCode getTHists(TDirectory *td, TList &, bool recurse=false) const override
Definition: THistSvc.cpp:393
MSG::DEBUG
Definition: IMessageSvc.h:16
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
GlobalDirectoryRestore
Definition: RConverter.h:16
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13

StatusCode THistSvc::getTHists | ( | const std::string & | name,
|  | TList & | tl,
|  | bool | recurse = `false`
| ) |  | const
| override

Definition at line 440 of file THistSvc.cpp.

441 {
442
443 GlobalDirectoryRestore restore;
444
445 gErrorIgnoreLevel = kBreak;
446
447 StatusCode sc;
448
449 std::string stream, rem, r2;
450 parseString( dir, stream, rem );
451
452 auto itr = m_files.find( stream );
453 if ( itr != m_files.end() ) {
454 r2 = itr->second.first->GetName();
455 r2 += ":/";
456 r2 += rem;
457
458 if ( msgLevel( MSG::DEBUG ) )
459 debug() << "getTHists: \"" << dir << "\" looks like a stream name."
460 << " associated TFile: \"" << itr->second.first->GetName() << "\"" << endmsg;
461
462 if ( gDirectory->cd( r2.c_str() ) ) {
463 m_curstream = stream;
464 sc = getTHists( gDirectory, tl, rcs );
465 m_curstream = "";
466 return sc;
467 } else {
468 if ( msgLevel( MSG::DEBUG ) ) debug() << "getTHists: no such TDirectory \"" << r2 << "\"" << endmsg;
469 }
470
471 } else {
472 if ( msgLevel( MSG::DEBUG ) ) debug() << "getTHists: stream \"" << stream << "\" not found" << endmsg;
473 }
474
475 if ( !gDirectory->cd( dir.c_str() ) ) {
476 error() << "getTHists: No such TDirectory/stream \"" << dir << "\"" << endmsg;
477 sc = StatusCode::FAILURE;
478 } else {
479 sc = getTHists( gDirectory, tl, rcs );
480 }
481
482 return sc;
483 }
StatusCode::FAILURE
Definition: StatusCode.h:31
THistSvc::m_curstream
std::string m_curstream
Definition: THistSvc.h:190
THistSvc::getTHists
StatusCode getTHists(TDirectory *td, TList &, bool recurse=false) const override
Definition: THistSvc.cpp:393
MSG::DEBUG
Definition: IMessageSvc.h:16
std::map::end
T end(T...args)
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
THistSvc::parseString
void parseString(const std::string &id, std::string &root, std::string &rem) const
Definition: THistSvc.cpp:1024
std::map::find
T find(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
GlobalDirectoryRestore
Definition: RConverter.h:16
std::string::c_str
T c_str(T...args)
THistSvc::m_files
std::map< std::string, std::pair< TFile *, Mode > > m_files
Definition: THistSvc.h:182
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

StatusCode THistSvc::getTHists | ( | TDirectory * | td,
|  | TList & | tl,
|  | bool | recurse = `false`,
|  | bool | reg = `false`
| ) |  |
| override

Definition at line 573 of file THistSvc.cpp.

574 {
575
576 GlobalDirectoryRestore restore;
577
578 gErrorIgnoreLevel = kBreak;
579
580 if ( !td->cd() ) {
581 error() << "getTHists: No such TDirectory \"" << td->GetPath() << "\"" << endmsg;
582 return StatusCode::FAILURE;
583 }
584
585 if ( msgLevel( MSG::DEBUG ) )
586 debug() << "getTHists: \"" << td->GetPath() << "\": found " << td->GetListOfKeys()->GetSize() << " keys" << endmsg;
587
588 TIter nextkey( td->GetListOfKeys() );
589 while ( TKey* key = (TKey*)nextkey() ) {
590 auto& log = debug();
591 if ( msgLevel( MSG::DEBUG ) ) log << " key: " << key->GetName();
592 TObject* obj = key->ReadObj();
593 if ( obj && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
594 if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
595 } else if ( obj && obj->IsA()->InheritsFrom( "TH1" ) ) {
596 if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
597 tl.Add( obj );
598 if ( reg && m_curstream != "" ) {
599 string dir = td->GetPath();
600 string fil = td->GetFile()->GetName();
601 dir.erase( 0, fil.length() + 1 );
602 string id = "/" + m_curstream;
603 if ( dir == "/" ) {
604 id = id + "/" + key->GetName();
605 } else {
606 id = id + dir + "/" + key->GetName();
607 }
608 if ( !exists( id ) ) {
609 if ( msgLevel( MSG::DEBUG ) ) log << " reg as \"" << id << "\"";
610 regHist( id ).ignore();
611 } else {
612 if ( msgLevel( MSG::DEBUG ) ) log << " already registered";
613 }
614 }
615 } else if ( obj ) {
616 if ( msgLevel( MSG::DEBUG ) ) log << " [" << obj->IsA()->GetName() << "]";
617 }
618 if ( msgLevel( MSG::DEBUG ) ) log << endmsg;
619 }
620
621 // operate recursively
622 if ( rcs ) {
623 nextkey = td->GetListOfKeys();
624 while ( TKey* key = (TKey*)nextkey() ) {
625 TObject* obj = key->ReadObj();
626 if ( obj && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
627 TDirectory* tt = dynamic_cast<TDirectory*>( obj );
628 getTHists( tt, tl, rcs, reg );
629 }
630 }
631 }
632
633 return StatusCode::SUCCESS;
634 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
THistSvc::m_curstream
std::string m_curstream
Definition: THistSvc.h:190
THistSvc::exists
bool exists(const std::string &name) const override
Definition: THistSvc.cpp:1552
THistSvc::getTHists
StatusCode getTHists(TDirectory *td, TList &, bool recurse=false) const override
Definition: THistSvc.cpp:393
MSG::DEBUG
Definition: IMessageSvc.h:16
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
std::string::erase
T erase(T...args)
THistSvc::regHist
StatusCode regHist(const std::string &name) override
Definition: THistSvc.cpp:848
std::string::length
T length(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
GlobalDirectoryRestore
Definition: RConverter.h:16
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:109
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13

StatusCode THistSvc::getTHists | ( | const std::string & | name,
|  | TList & | tl,
|  | bool | recurse = `false`,
|  | bool | reg = `false`
| ) |  |
| override

Definition at line 638 of file THistSvc.cpp.

639 {
640
641 GlobalDirectoryRestore restore;
642
643 gErrorIgnoreLevel = kBreak;
644
645 StatusCode sc;
646
647 std::string stream, rem, r2;
648 parseString( dir, stream, rem );
649
650 auto itr = m_files.find( stream );
651 if ( itr != m_files.end() ) {
652 r2 = itr->second.first->GetName();
653 r2 += ":/";
654 r2 += rem;
655
656 if ( msgLevel( MSG::DEBUG ) )
657 debug() << "getTHists: \"" << dir << "\" looks like a stream name."
658 << " associated TFile: \"" << itr->second.first->GetName() << "\"" << endmsg;
659
660 if ( gDirectory->cd( r2.c_str() ) ) {
661 m_curstream = stream;
662 sc = getTHists( gDirectory, tl, rcs, reg );
663 m_curstream.clear();
664 return sc;
665 }
666 if ( msgLevel( MSG::DEBUG ) ) debug() << "getTHists: no such TDirectory \"" << r2 << "\"" << endmsg;
667
668 } else {
669 if ( msgLevel( MSG::DEBUG ) ) debug() << "getTHists: stream \"" << stream << "\" not found" << endmsg;
670 }
671
672 if ( !gDirectory->cd( dir.c_str() ) ) {
673 error() << "getTHists: No such TDirectory/stream \"" << dir << "\"" << endmsg;
674 sc = StatusCode::FAILURE;
675 } else {
676 if ( reg ) {
677 warning() << "Unable to register histograms automatically "
678 << "without a valid stream name" << endmsg;
679 reg = false;
680 }
681 sc = getTHists( gDirectory, tl, rcs, reg );
682 }
683
684 return sc;
685 }
StatusCode::FAILURE
Definition: StatusCode.h:31
THistSvc::m_curstream
std::string m_curstream
Definition: THistSvc.h:190
THistSvc::getTHists
StatusCode getTHists(TDirectory *td, TList &, bool recurse=false) const override
Definition: THistSvc.cpp:393
MSG::DEBUG
Definition: IMessageSvc.h:16
std::map::end
T end(T...args)
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:109
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
THistSvc::parseString
void parseString(const std::string &id, std::string &root, std::string &rem) const
Definition: THistSvc.cpp:1024
std::string::clear
T clear(T...args)
std::map::find
T find(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
GlobalDirectoryRestore
Definition: RConverter.h:16
std::string::c_str
T c_str(T...args)
THistSvc::m_files
std::map< std::string, std::pair< TFile *, Mode > > m_files
Definition: THistSvc.h:182
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

StatusCode THistSvc::getTree | ( | const std::string & | name,
|  | TTree *& | hist
| ) |  | const
| override

Definition at line 939 of file THistSvc.cpp.

939 { return getHist_i( id, hist ); }
THistSvc::getHist_i
StatusCode getHist_i(const std::string &name, T *&hist, bool quiet=false) const
Definition: THistSvc.icc:142

std::vector< std::string > THistSvc::getTrees | ( |  | ) | const
| override

Definition at line 943 of file THistSvc.cpp.

944 {
945
946 std::vector<std::string> names;
947 names.reserve( m_uids.size() );
948 transform_if( std::begin( m_uids ), std::end( m_uids ), std::back_inserter( names ), select1st,
949 []( uidMap::const_reference i ) { return i.second.obj->IsA()->InheritsFrom( "TTree" ); } );
950 return names;
951 }
std::end
T end(T...args)
std::map::size
T size(T...args)
std::vector< std::string >
THistSvc::m_uids
uidMap m_uids
Definition: THistSvc.h:178
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
std::vector::reserve
T reserve(T...args)

StatusCode THistSvc::getTTrees | ( | TDirectory * | td,
|  | TList & | tl,
|  | bool | recurse = `false`
| ) |  | const
| override

Definition at line 486 of file THistSvc.cpp.

487 {
488 GlobalDirectoryRestore restore;
489
490 gErrorIgnoreLevel = kBreak;
491
492 if ( !td->cd() ) {
493 error() << "getTTrees: No such TDirectory \"" << td->GetPath() << "\"" << endmsg;
494 return StatusCode::FAILURE;
495 }
496
497 if ( msgLevel( MSG::DEBUG ) )
498 debug() << "getTHists: \"" << td->GetPath() << "\": found " << td->GetListOfKeys()->GetSize() << " keys" << endmsg;
499
500 TIter nextkey( td->GetListOfKeys() );
501 while ( TKey* key = (TKey*)nextkey() ) {
502 auto& log = debug();
503 if ( msgLevel( MSG::DEBUG ) ) log << " key: " << key->GetName();
504 TObject* obj = key->ReadObj();
505 if ( obj != 0 && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
506 if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
507 } else if ( obj != 0 && obj->IsA()->InheritsFrom( "TTree" ) ) {
508 if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
509 tl.Add( obj );
510 } else if ( obj != 0 ) {
511 if ( msgLevel( MSG::DEBUG ) ) log << " [" << obj->IsA()->GetName() << "]";
512 }
513 log << endmsg;
514 }
515
516 // operate recursively
517 if ( rcs ) {
518 nextkey = td->GetListOfKeys();
519 while ( TKey* key = (TKey*)nextkey() ) {
520 TObject* obj = key->ReadObj();
521 if ( obj && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
522 TDirectory* tt = dynamic_cast<TDirectory*>( obj );
523 getTTrees( tt, tl, rcs );
524 }
525 }
526 }
527
528 return StatusCode::SUCCESS;
529 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
MSG::DEBUG
Definition: IMessageSvc.h:16
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
THistSvc::getTTrees
StatusCode getTTrees(TDirectory *td, TList &, bool recurse=false) const override
Definition: THistSvc.cpp:486
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
GlobalDirectoryRestore
Definition: RConverter.h:16
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13

StatusCode THistSvc::getTTrees | ( | const std::string & | name,
|  | TList & | tl,
|  | bool | recurse = `false`
| ) |  | const
| override

Definition at line 533 of file THistSvc.cpp.

534 {
535 GlobalDirectoryRestore restore;
536
537 gErrorIgnoreLevel = kBreak;
538
539 StatusCode sc;
540
541 std::string stream, rem, r2;
542 parseString( dir, stream, rem );
543
544 auto itr = m_files.find( stream );
545 if ( itr != m_files.end() ) {
546 r2 = itr->second.first->GetName();
547 r2 += ":/";
548 r2 += rem;
549
550 if ( msgLevel( MSG::DEBUG ) )
551 debug() << "getTTrees: \"" << dir << "\" looks like a stream name."
552 << " associated TFile: \"" << itr->second.first->GetName() << "\"" << endmsg;
553
554 if ( gDirectory->cd( r2.c_str() ) ) {
555 return getTTrees( gDirectory, tl, rcs );
556 }
557 if ( msgLevel( MSG::DEBUG ) ) debug() << "getTTrees: no such TDirectory \"" << r2 << "\"" << endmsg;
558 } else {
559 if ( msgLevel( MSG::DEBUG ) ) debug() << "getTTrees: stream \"" << stream << "\" not found" << endmsg;
560 }
561
562 if ( !gDirectory->cd( dir.c_str() ) ) {
563 error() << "getTTrees: No such TDirectory/stream \"" << dir << "\"" << endmsg;
564 sc = StatusCode::FAILURE;
565 } else {
566 sc = getTTrees( gDirectory, tl, rcs );
567 }
568 return sc;
569 }
StatusCode::FAILURE
Definition: StatusCode.h:31
MSG::DEBUG
Definition: IMessageSvc.h:16
std::map::end
T end(T...args)
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
THistSvc::parseString
void parseString(const std::string &id, std::string &root, std::string &rem) const
Definition: THistSvc.cpp:1024
THistSvc::getTTrees
StatusCode getTTrees(TDirectory *td, TList &, bool recurse=false) const override
Definition: THistSvc.cpp:486
std::map::find
T find(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
GlobalDirectoryRestore
Definition: RConverter.h:16
std::string::c_str
T c_str(T...args)
THistSvc::m_files
std::map< std::string, std::pair< TFile *, Mode > > m_files
Definition: THistSvc.h:182
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

StatusCode THistSvc::getTTrees | ( | TDirectory * | td,
|  | TList & | tl,
|  | bool | recurse = `false`,
|  | bool | reg = `false`
| ) |  |
| override

Definition at line 688 of file THistSvc.cpp.

689 {
690
691 GlobalDirectoryRestore restore;
692
693 gErrorIgnoreLevel = kBreak;
694
695 if ( !td->cd() ) {
696 error() << "getTTrees: No such TDirectory \"" << td->GetPath() << "\"" << endmsg;
697 return StatusCode::FAILURE;
698 }
699
700 if ( msgLevel( MSG::DEBUG ) )
701 debug() << "getTHists: \"" << td->GetPath() << "\": found " << td->GetListOfKeys()->GetSize() << " keys" << endmsg;
702
703 TIter nextkey( td->GetListOfKeys() );
704 while ( TKey* key = (TKey*)nextkey() ) {
705 auto& log = debug();
706 if ( msgLevel( MSG::DEBUG ) ) log << " key: " << key->GetName();
707 TObject* obj = key->ReadObj();
708 if ( obj && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
709 if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
710 } else if ( obj && obj->IsA()->InheritsFrom( "TTree" ) ) {
711 if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
712 tl.Add( obj );
713 if ( reg && m_curstream != "" ) {
714 string dir = td->GetPath();
715 string fil = td->GetFile()->GetName();
716 dir.erase( 0, fil.length() + 1 );
717 string id = "/" + m_curstream;
718 if ( dir == "/" ) {
719 id = id + "/" + key->GetName();
720 } else {
721 id = id + dir + "/" + key->GetName();
722 }
723 if ( !exists( id ) ) {
724 if ( msgLevel( MSG::DEBUG ) ) log << " reg as \"" << id << "\"";
725 regHist( id ).ignore();
726 } else {
727 if ( msgLevel( MSG::DEBUG ) ) log << " already registered";
728 }
729 }
730 } else if ( obj != 0 ) {
731 if ( msgLevel( MSG::DEBUG ) ) log << " [" << obj->IsA()->GetName() << "]";
732 }
733 if ( msgLevel( MSG::DEBUG ) ) log << endmsg;
734 }
735
736 // operate recursively
737 if ( rcs ) {
738 nextkey = td->GetListOfKeys();
739 while ( TKey* key = (TKey*)nextkey() ) {
740 TObject* obj = key->ReadObj();
741 if ( obj && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
742 TDirectory* tt = dynamic_cast<TDirectory*>( obj );
743 getTTrees( tt, tl, rcs, reg );
744 }
745 }
746 }
747
748 return StatusCode::SUCCESS;
749 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
THistSvc::m_curstream
std::string m_curstream
Definition: THistSvc.h:190
THistSvc::exists
bool exists(const std::string &name) const override
Definition: THistSvc.cpp:1552
MSG::DEBUG
Definition: IMessageSvc.h:16
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
std::string::erase
T erase(T...args)
THistSvc::regHist
StatusCode regHist(const std::string &name) override
Definition: THistSvc.cpp:848
THistSvc::getTTrees
StatusCode getTTrees(TDirectory *td, TList &, bool recurse=false) const override
Definition: THistSvc.cpp:486
std::string::length
T length(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
GlobalDirectoryRestore
Definition: RConverter.h:16
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:109
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13

StatusCode THistSvc::getTTrees | ( | const std::string & | name,
|  | TList & | tl,
|  | bool | recurse = `false`,
|  | bool | reg = `false`
| ) |  |
| override

Definition at line 753 of file THistSvc.cpp.

754 {
755
756 GlobalDirectoryRestore restore;
757
758 gErrorIgnoreLevel = kBreak;
759
760 StatusCode sc;
761
762 std::string stream, rem, r2;
763 parseString( dir, stream, rem );
764
765 auto itr = m_files.find( stream );
766 if ( itr != m_files.end() ) {
767 r2 = itr->second.first->GetName();
768 r2 += ":/";
769 r2 += rem;
770
771 if ( msgLevel( MSG::DEBUG ) )
772 debug() << "getTTrees: \"" << dir << "\" looks like a stream name."
773 << " associated TFile: \"" << itr->second.first->GetName() << "\"" << endmsg;
774
775 if ( gDirectory->cd( r2.c_str() ) ) {
776 return getTTrees( gDirectory, tl, rcs, reg );
777 } else {
778 if ( msgLevel( MSG::DEBUG ) ) debug() << "getTTrees: no such TDirectory \"" << r2 << "\"" << endmsg;
779 }
780
781 } else {
782 if ( msgLevel( MSG::DEBUG ) ) debug() << "getTTrees: stream \"" << stream << "\" not found" << endmsg;
783 }
784
785 if ( !gDirectory->cd( dir.c_str() ) ) {
786 error() << "getTTrees: No such TDirectory/stream \"" << dir << "\"" << endmsg;
787 return StatusCode::FAILURE;
788 }
789
790 return getTTrees( gDirectory, tl, rcs, reg );
791 }
StatusCode::FAILURE
Definition: StatusCode.h:31
MSG::DEBUG
Definition: IMessageSvc.h:16
std::map::end
T end(T...args)
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
THistSvc::parseString
void parseString(const std::string &id, std::string &root, std::string &rem) const
Definition: THistSvc.cpp:1024
THistSvc::getTTrees
StatusCode getTTrees(TDirectory *td, TList &, bool recurse=false) const override
Definition: THistSvc.cpp:486
std::map::find
T find(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
GlobalDirectoryRestore
Definition: RConverter.h:16
std::string::c_str
T c_str(T...args)
THistSvc::m_files
std::map< std::string, std::pair< TFile *, Mode > > m_files
Definition: THistSvc.h:182
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

void THistSvc::handle | ( | const Incident & |  | ) |
| override

Definition at line 1561 of file THistSvc.cpp.

1562 {
1563
1564 if ( signaledStop ) return;
1565
1566 if ( m_maxFileSize.value() == -1 ) return;
1567
1568 // convert to bytes.
1569 Long64_t mfs = (Long64_t)m_maxFileSize.value() * (Long64_t)1048576;
1570 Long64_t mfs_warn = mfs * 95 / 100;
1571
1572 updateFiles();
1573
1574 map<string, pair<TFile*, Mode>>::const_iterator itr;
1575 for ( const auto& f : m_files ) {
1576 TFile* tf = f.second.first;
1577
1578 #ifndef NDEBUG
1579 if ( msgLevel( MSG::DEBUG ) )
1580 debug() << "stream: " << f.first << " name: " << tf->GetName() << " size: " << tf->GetSize() << endmsg;
1581 #endif
1582
1583 // Signal job to terminate if output file is too large
1584 if ( tf->GetSize() > mfs ) {
1585
1586 signaledStop = true;
1587
1588 fatal() << "file \"" << tf->GetName() << "\" associated with stream \"" << f.first
1589 << "\" has exceeded the max file size of " << m_maxFileSize.value() << "MB. Terminating Job." << endmsg;
1590
1591 IEventProcessor* evt = nullptr;
1592 if ( service( "ApplicationMgr", evt, true ).isSuccess() ) {
1593 evt->stopRun();
1594 evt->release();
1595 } else {
1596 abort();
1597 }
1598 } else if ( tf->GetSize() > mfs_warn ) {
1599 warning() << "file \"" << tf->GetName() << "\" associated with stream \"" << f.first
1600 << "\" is at 95% of its maximum allowable file size of " << m_maxFileSize.value() << "MB" << endmsg;
1601 }
1602 }
1603 }
IEventProcessor::stopRun
virtual StatusCode stopRun()=0
Schedule a stop of the current event processing.
MSG::DEBUG
Definition: IMessageSvc.h:16
THistSvc::signaledStop
bool signaledStop
Definition: THistSvc.h:187
std::map
STL class.
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:109
THistSvc::m_maxFileSize
Gaudi::Property< int > m_maxFileSize
Definition: THistSvc.h:157
IInterface::release
virtual unsigned long release()=0
Release Interface instance.
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
THistSvc::m_files
std::map< std::string, std::pair< TFile *, Mode > > m_files
Definition: THistSvc.h:182
IEventProcessor
The IEventProcessor is the interface to process events.
Definition: IEventProcessor.h:16
std::abort
T abort(T...args)
Service::service
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:85
CommonMessagingBase::fatal
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Definition: CommonMessaging.h:100
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
IOTest.evt
evt
Definition: IOTest.py:96
THistSvc::updateFiles
void updateFiles()
Definition: THistSvc.cpp:1108

StatusCode THistSvc::initialize | ( |  | ) |
| override

Definition at line 70 of file THistSvc.cpp.

71 {
72 GlobalDirectoryRestore restore;
73
74 StatusCode status = Service::initialize();
75
76 if ( status.isFailure() ) {
77 error() << "initializing service" << endmsg;
78 return status;
79 }
80
81 StatusCode st( StatusCode::SUCCESS );
82
83 try {
84 setupOutputFile( m_outputfile );
85 } catch ( GaudiException& err ) {
86 error() << "Caught: " << err << endmsg;
87 st = StatusCode::FAILURE;
88 }
89
90 try {
91 setupInputFile( m_inputfile );
92 } catch ( GaudiException& err ) {
93 error() << "Caught: " << err << endmsg;
94 st = StatusCode::FAILURE;
95 }
96
97 // Protect against multiple instances of TROOT
98 if ( !gROOT ) {
99 static TROOT root( "root", "ROOT I/O" );
100 // gDebug = 99;
101 } else {
102 if ( msgLevel( MSG::VERBOSE ) ) verbose() << "ROOT already initialized, debug = " << gDebug << endmsg;
103 }
104
105 if ( service( "IncidentSvc", p_incSvc, true ).isFailure() ) {
106 error() << "unable to get the IncidentSvc" << endmsg;
107 st = StatusCode::FAILURE;
108 } else {
109 p_incSvc->addListener( this, "EndEvent", 100, true );
110 }
111
112 if ( service( "FileMgr", p_fileMgr, true ).isFailure() ) {
113 error() << "unable to get the FileMgr" << endmsg;
114 st = StatusCode::FAILURE;
115 } else {
116 debug() << "got the FileMgr" << endmsg;
117 }
118
119 // Register open/close callback actions
120
121 using namespace std::placeholders;
122 auto boa = [this]( const Io::FileAttr* fa, const std::string& caller ) { return this->rootOpenAction( fa, caller ); };
123 if ( p_fileMgr->regAction( boa, Io::OPEN, Io::ROOT ).isFailure() ) {
124 error() << "unable to register ROOT file open action with FileMgr" << endmsg;
125 }
126 auto bea = [this]( const Io::FileAttr* fa, const std::string& caller ) {
127 return this->rootOpenErrAction( fa, caller );
128 };
129 if ( p_fileMgr->regAction( bea, Io::OPEN_ERR, Io::ROOT ).isFailure() ) {
130 error() << "unable to register ROOT file open Error action with FileMgr" << endmsg;
131 }
132
133 m_okToConnect = true;
134
135 if ( m_delayConnect ) {
136 if ( !m_inputfile.value().empty() ) {
137 setupInputFile( m_inputfile );
138 }
139 if ( !m_outputfile.value().empty() ) {
140 setupOutputFile( m_outputfile );
141 }
142
143 m_delayConnect = false;
144 }
145 m_alreadyConnectedOutFiles.clear();
146 m_alreadyConnectedInFiles.clear();
147
148 IIoComponentMgr* iomgr = nullptr;
149
150 if ( service( "IoComponentMgr", iomgr, true ).isFailure() ) {
151 error() << "unable to get the IoComponentMgr" << endmsg;
152 st = StatusCode::FAILURE;
153 } else {
154
155 if ( !iomgr->io_register( this ).isSuccess() ) {
156 error() << "could not register with the I/O component manager !" << endmsg;
157 st = StatusCode::FAILURE;
158 } else {
159 bool all_good = true;
160 // register input/output files...
161 for ( const auto& reg : m_files ) {
162 const std::string& fname = reg.second.first->GetName();
163 const IIoComponentMgr::IoMode::Type iomode =
164 ( reg.second.second == THistSvc::READ ? IIoComponentMgr::IoMode::READ : IIoComponentMgr::IoMode::WRITE );
165 if ( !iomgr->io_register( this, iomode, fname ).isSuccess() ) {
166 warning() << "could not register file [" << fname << "] with the I/O component manager..." << endmsg;
167 all_good = false;
168 } else {
169 info() << "registered file [" << fname << "]... [ok]" << endmsg;
170 }
171 }
172 if ( !all_good ) {
173 error() << "problem while registering input/output files with "
174 << "the I/O component manager !" << endmsg;
175 st = StatusCode::FAILURE;
176 }
177 }
178 }
179
180 if ( st.isFailure() ) {
181 fatal() << "Unable to initialize THistSvc" << endmsg;
182 }
183
184 return st;
185 }
THistSvc::m_delayConnect
bool m_delayConnect
Definition: THistSvc.h:188
IIoComponentMgr
Definition: IIoComponentMgr.h:22
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:64
StatusCode::SUCCESS
Definition: StatusCode.h:31
Io::ROOT
Definition: IFileMgr.h:157
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
std::placeholders
StatusCode::FAILURE
Definition: StatusCode.h:31
Io::OPEN
Definition: IFileMgr.h:284
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:112
THistSvc::p_incSvc
IIncidentSvc * p_incSvc
Definition: THistSvc.h:192
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:118
THistSvc::rootOpenAction
StatusCode rootOpenAction(FILEMGR_CALLBACK_ARGS)
Definition: THistSvc.cpp:1741
MSG::VERBOSE
Definition: IMessageSvc.h:16
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
THistSvc::m_outputfile
Gaudi::Property< std::vector< std::string > > m_outputfile
Definition: THistSvc.h:160
CommonMessagingBase::err
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:103
std::string
STL class.
IFileMgr::regAction
virtual StatusCode regAction(Io::bfcn_action_t, const Io::Action &, const std::string &d="")=0
IIoComponentMgr::IoMode::Type
Type
Definition: IIoComponentMgr.h:32
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:109
THistSvc::m_inputfile
Gaudi::Property< std::vector< std::string > > m_inputfile
Definition: THistSvc.h:161
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
THistSvc::m_okToConnect
bool m_okToConnect
Definition: THistSvc.h:188
THistSvc::rootOpenErrAction
StatusCode rootOpenErrAction(FILEMGR_CALLBACK_ARGS)
Definition: THistSvc.cpp:1769
std::set::clear
T clear(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
GlobalDirectoryRestore
Definition: RConverter.h:16
IIncidentSvc::addListener
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
THistSvc::m_files
std::map< std::string, std::pair< TFile *, Mode > > m_files
Definition: THistSvc.h:182
THistSvc::READ
Definition: THistSvc.h:94
IIoComponentMgr::io_register
virtual StatusCode io_register(IIoComponent *iocomponent)=0
: allow a IIoComponent to register itself with this manager so appropriate actions can be taken when ...
THistSvc::p_fileMgr
IFileMgr * p_fileMgr
Definition: THistSvc.h:193
THistSvc::m_alreadyConnectedOutFiles
std::set< std::string > m_alreadyConnectedOutFiles
list of already connected files.
Definition: THistSvc.h:171
gaudiComponentHelp.root
root
Definition: gaudiComponentHelp.py:18
Service::service
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:85
IIoComponentMgr::IoMode::WRITE
Definition: IIoComponentMgr.h:32
CommonMessagingBase::fatal
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Definition: CommonMessaging.h:100
THistSvc::m_alreadyConnectedInFiles
std::set< std::string > m_alreadyConnectedInFiles
list of already connected files.
Definition: THistSvc.h:167
THistSvc::setupInputFile
void setupInputFile(Gaudi::Details::PropertyBase &inputfile)
call-back method to handle input stream property
Definition: THistSvc.cpp:1050
THistSvc::setupOutputFile
void setupOutputFile(Gaudi::Details::PropertyBase &outputfile)
call-back method to handle output stream property
Definition: THistSvc.cpp:1082
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
IIoComponentMgr::IoMode::READ
Definition: IIoComponentMgr.h:32
Io::OPEN_ERR
Definition: IFileMgr.h:284
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Io::FileAttr
Definition: IFileMgr.h:173

StatusCode THistSvc::io_reinit | ( |  | ) |
| override

callback method to reinitialize the internal state of the component for I/O purposes (e.g.

upon `fork(2)`)

Definition at line 1643 of file THistSvc.cpp.

1644 {
1645 bool all_good = true;
1646 if ( msgLevel( MSG::DEBUG ) ) debug() << "reinitializing I/O..." << endmsg;
1647
1648 // retrieve the I/O component manager...
1649
1650 IIoComponentMgr* iomgr = nullptr;
1651
1652 if ( service( "IoComponentMgr", iomgr, true ).isFailure() ) {
1653 error() << "could not retrieve I/O component manager !" << endmsg;
1654 return StatusCode::FAILURE;
1655 }
1656
1657 GlobalDirectoryRestore restore;
1658 // to hide the expected errors upon closing the files whose
1659 // file descriptors have been swept under the rug...
1660 gErrorIgnoreLevel = kFatal;
1661
1662 for ( auto& ifile : m_files ) {
1663 TFile* f = ifile.second.first;
1664 std::string fname = f->GetName();
1665 if ( msgLevel( MSG::DEBUG ) )
1666 debug() << "file [" << fname << "] mode: [" << f->GetOption() << "] r:" << f->GetFileBytesRead()
1667 << " w:" << f->GetFileBytesWritten() << " cnt:" << f->GetFileCounter() << endmsg;
1668
1669 if ( ifile.second.second == READ ) {
1670 if ( msgLevel( MSG::DEBUG ) ) debug() << " TFile opened in READ mode: not reassigning names" << endmsg;
1671 continue;
1672 }
1673
1674 if ( !iomgr->io_retrieve( this, fname ).isSuccess() ) {
1675 error() << "could not retrieve new name for [" << fname << "] !!" << endmsg;
1676 all_good = false;
1677 continue;
1678 } else {
1679 if ( msgLevel( MSG::DEBUG ) ) debug() << "got a new name [" << fname << "]..." << endmsg;
1680 }
1681 // create a new TFile
1682 // TFile *newfile = TFile::Open (fname.c_str(), f->GetOption());
1683
1684 void* vf;
1685 Option_t* opts = f->GetOption();
1686 int r = p_fileMgr->open( Io::ROOT, name(), fname, Io::WRITE, vf, "HIST" );
1687 if ( r != 0 ) {
1688 error() << "unable to open file \"" << fname << "\" for writing" << endmsg;
1689 return StatusCode::FAILURE;
1690 }
1691 TFile* newfile = (TFile*)vf;
1692 newfile->SetOption( opts );
1693
1694 if ( ifile.second.second != THistSvc::READ ) {
1695 copyFileLayout( newfile, f );
1696 ifile.second.first = newfile;
1697 }
1698
1699 // loop over all uids and migrate them to the new file
1700 // XXX FIXME: this double loop sucks...
1701 for ( auto& uid : m_uids ) {
1702 THistID& hid = uid.second;
1703 if ( hid.file != f ) continue;
1704 TDirectory* olddir = this->changeDir( hid );
1705 hid.file = newfile;
1706 // side-effect: create needed directories...
1707 TDirectory* newdir = this->changeDir( hid );
1708 TClass* cl = hid.obj->IsA();
1709
1710 // migrate the objects to the new file.
1711 // thanks to the object model of ROOT, it is super easy.
1712 if ( cl->InheritsFrom( "TTree" ) ) {
1713 dynamic_cast<TTree*>( hid.obj )->SetDirectory( newdir );
1714 dynamic_cast<TTree*>( hid.obj )->Reset();
1715 } else if ( cl->InheritsFrom( "TH1" ) ) {
1716 dynamic_cast<TH1*>( hid.obj )->SetDirectory( newdir );
1717 dynamic_cast<TH1*>( hid.obj )->Reset();
1718 } else if ( cl->InheritsFrom( "TGraph" ) ) {
1719 olddir->Remove( hid.obj );
1720 newdir->Append( hid.obj );
1721 } else {
1722 error() << "id: \"" << hid.id << "\" is not a inheriting from a class "
1723 << "we know how to handle (received [" << cl->GetName() << "], "
1724 << "expected [TTree, TH1 or TGraph]) !" << endmsg << "attaching to current dir [" << newdir->GetPath()
1725 << "] "
1726 << "nonetheless..." << endmsg;
1727 olddir->Remove( hid.obj );
1728 newdir->Append( hid.obj );
1729 }
1730 }
1731 f->ReOpen( "READ" );
1732 p_fileMgr->close( f, name() );
1733 f = newfile;
1734 }
1735
1736 return all_good ? StatusCode::SUCCESS : StatusCode::FAILURE;
1737 }
IIoComponentMgr::io_retrieve
virtual StatusCode io_retrieve(IIoComponent *iocomponent, std::string &fname)=0
: retrieve the new filename for a given IIoComponent and
IIoComponentMgr
Definition: IIoComponentMgr.h:22
StatusCode::SUCCESS
Definition: StatusCode.h:31
Io::ROOT
Definition: IFileMgr.h:157
IFileMgr::open
virtual Io::open_t open(const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, Io::Fd &, void *&, const std::string &desc, const bool shared=false)=0
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
StatusCode::FAILURE
Definition: StatusCode.h:31
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
MSG::DEBUG
Definition: IMessageSvc.h:16
THistSvc::copyFileLayout
void copyFileLayout(TDirectory *, TDirectory *)
helper function to recursively copy the layout of a TFile into a new TFile
Definition: THistSvc.cpp:1609
THistSvc::changeDir
TDirectory * changeDir(const THistSvc::THistID &hid) const
Definition: THistSvc.cpp:1411
gaudirun.opts
opts
Definition: gaudirun.py:244
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
Io::WRITE
Definition: IFileMgr.h:28
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
THistSvc::m_uids
uidMap m_uids
Definition: THistSvc.h:178
GlobalDirectoryRestore
Definition: RConverter.h:16
THistSvc::m_files
std::map< std::string, std::pair< TFile *, Mode > > m_files
Definition: THistSvc.h:182
THistSvc::READ
Definition: THistSvc.h:94
THistSvc::p_fileMgr
IFileMgr * p_fileMgr
Definition: THistSvc.h:193
Service::service
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:85
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
IFileMgr::close
virtual Io::close_t close(const Io::Fd, const std::string &caller)=0

void THistSvc::MergeRootFile | ( | TDirectory * | target,
|  | TDirectory * | source
| ) |  |
| private

Definition at line 1485 of file THistSvc.cpp.

1486 {
1487
1488 if ( msgLevel( MSG::DEBUG ) ) debug() << "Target path: " << target->GetPath() << endmsg;
1489 TString path( (char*)strstr( target->GetPath(), ":" ) );
1490 path.Remove( 0, 2 );
1491
1492 source->cd( path );
1493 TDirectory* current_sourcedir = gDirectory;
1494
1495 // loop over all keys in this directory
1496 TList* lkeys = current_sourcedir->GetListOfKeys();
1497 int nkeys = lkeys->GetEntries();
1498 TKey* key;
1499 for ( int jj = 0; jj < nkeys; jj++ ) {
1500 key = (TKey*)lkeys->At( jj );
1501 string pathnameinsource = current_sourcedir->GetPath() + string( "/" ) + key->GetName();
1502 if ( msgLevel( MSG::DEBUG ) ) debug() << "Reading Key:" << pathnameinsource << endmsg;
1503 // key->Dump();
1504 // TObject *obj=key->ReadObj();
1505 TObject* obj = source->Get( pathnameinsource.c_str() );
1506
1507 if ( obj ) {
1508 if ( obj->IsA()->InheritsFrom( "TDirectory" ) ) {
1509 // it's a subdirectory
1510
1511 if ( msgLevel( MSG::DEBUG ) ) debug() << "Found subdirectory " << obj->GetName() << endmsg;
1512
1513 // create a new subdir of same name and title in the target file
1514 target->cd();
1515 TDirectory* newtargetdir = target->mkdir( obj->GetName(), obj->GetTitle() );
1516
1517 MergeRootFile( newtargetdir, source );
1518
1519 } else if ( obj->IsA()->InheritsFrom( "TTree" ) ) {
1520 if ( msgLevel( MSG::DEBUG ) ) debug() << "Found TTree " << obj->GetName() << endmsg;
1521 TTree* mytree = dynamic_cast<TTree*>( obj );
1522 int nentries = (int)mytree->GetEntries();
1523 mytree->SetBranchStatus( "*", 1 );
1524
1525 if ( msgLevel( MSG::DEBUG ) ) debug() << "Dumping TTree " << nentries << " entries" << endmsg;
1526 // mytree->Print();
1527 // for (int ij=0; ij<nentries; ij++) {
1528 // debug() << "Dumping TTree Show( " << ij <<" )"
1529 //<< endmsg;
1530 // mytree->Show(ij);
1531 //}
1532 target->cd();
1533 mytree->CloneTree();
1534
1535 // debug() << "Writing TTree to target file: ( "
1536 //<< mycopiedtree->Write(key->GetName()) <<" ) bytes written"
1537 //<< endmsg;
1538
1539 } else {
1540 target->cd();
1541 obj->Write( key->GetName() );
1542 }
1543 }
1544
1545 } // while ( ( TKey *key = (TKey*)nextkey() ) )
1546
1547 // save modifications to target file
1548 }
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:895
MSG::DEBUG
Definition: IMessageSvc.h:16
std::string
STL class.
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
std::string::c_str
T c_str(T...args)
std::strstr
T strstr(T...args)
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
THistSvc::MergeRootFile
void MergeRootFile(TDirectory *target, TDirectory *source)
Definition: THistSvc.cpp:1485

void THistSvc::parseString | ( | const std::string & | id,
|  | std::string & | root,
|  | std::string & | rem
| ) |  | const
| private

Definition at line 1024 of file THistSvc.cpp.

1025 {
1026 auto pos = id.find( "/" );
1027
1028 if ( pos == string::npos ) {
1029 root.clear();
1030 rem = id;
1031 } else if ( pos == 0 ) {
1032 parseString( id.substr( 1 ), root, rem );
1033 } else {
1034 root = id.substr( 0, pos );
1035 rem = id.substr( pos + 1 );
1036 }
1037 }
THistSvc::parseString
void parseString(const std::string &id, std::string &root, std::string &rem) const
Definition: THistSvc.cpp:1024
std::string::clear
T clear(T...args)
std::string::substr
T substr(T...args)

StatusCode THistSvc::readHist | ( | const std::string & | name,
|  | TH1 *& | hist
| ) |  | const
| private

Definition at line 969 of file THistSvc.cpp.

969 { return readHist_i( id, hist ); }
THistSvc::readHist_i
StatusCode readHist_i(const std::string &name, T *&hist) const
Definition: THistSvc.icc:242

StatusCode THistSvc::readHist | ( | const std::string & | name,
|  | TH2 *& | hist
| ) |  | const
| private

Definition at line 973 of file THistSvc.cpp.

973 { return readHist_i( id, hist ); }
THistSvc::readHist_i
StatusCode readHist_i(const std::string &name, T *&hist) const
Definition: THistSvc.icc:242

StatusCode THistSvc::readHist | ( | const std::string & | name,
|  | TH3 *& | hist
| ) |  | const
| private

Definition at line 977 of file THistSvc.cpp.

977 { return readHist_i( id, hist ); }
THistSvc::readHist_i
StatusCode readHist_i(const std::string &name, T *&hist) const
Definition: THistSvc.icc:242
template<typename T >

StatusCode THistSvc::readHist_i | ( | const std::string & | name,
|  | T *& | hist
| ) |  | const
| private

Definition at line 242 of file THistSvc.icc.

242 {
243
244 GlobalDirectoryRestore restore;
245
246 std::string idr(id);
247 removeDoubleSlash( idr );
248
249 std::string stream, rem, dir, fdir, bdir, fdir2;
250 TFile *file;
251
252 if (!findStream(idr, stream, rem, file) ) {
253 return StatusCode::FAILURE;
254 }
255
256 if ( !file ) {
257 error() << "no associated file found" << endmsg;
258 return StatusCode::FAILURE;
259 }
260
261 file->cd("/");
262
263 fdir = idr;
264 bdir = dirname(fdir);
265 fdir2 = fdir;
266 while ( (dir=dirname(fdir)) != "" ) {
267 if (! gDirectory->GetKey(dir.c_str())) {
268 error() << "Directory \"" << fdir2 << "\" doesnt exist in "
269 << file->GetName() << endmsg;
270 return StatusCode::FAILURE;
271 }
272 gDirectory->cd(dir.c_str());
273 }
274
275 TObject *to=nullptr;
276 gDirectory->GetObject(fdir.c_str(), to);
277
278 if ( !to ) {
279 error() << "Could not get obj \"" << fdir << "\" in "
280 << gDirectory->GetPath() << endmsg;
281 return StatusCode::FAILURE;
282 }
283
284
285
286 hist = dynamic_cast<T*>(to);
287 if ( !hist ) {
288 error() << "Could not convert \"" << idr << "\" to a "
289 << System::typeinfoName(typeid(*hist)) << " as is a "
290 << to->IsA()->GetName()
291 << endmsg;
292 return StatusCode::FAILURE;
293 }
294
295
296 if (msgLevel(MSG::DEBUG)) {
297 debug() << "Read in " << hist->IsA()->GetName() << " \""
298 << hist->GetName() << "\" from file "
299 << file->GetName() << endmsg;
300 hist->Print();
301 }
302
303 return StatusCode::SUCCESS;
304
305 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:329
THistSvc::findStream
bool findStream(const std::string &name, std::string &root, std::string &rem, TFile *&file) const
Definition: THistSvc.cpp:985
MSG::DEBUG
Definition: IMessageSvc.h:16
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
THistSvc::dirname
std::string dirname(std::string &dir) const
Definition: THistSvc.cpp:1439
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
GlobalDirectoryRestore
Definition: RConverter.h:16
std::string::c_str
T c_str(T...args)
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
THistSvc::removeDoubleSlash
void removeDoubleSlash(std::string &) const
Definition: THistSvc.cpp:1475

StatusCode THistSvc::readTree | ( | const std::string & | name,
|  | TTree *& | hist
| ) |  | const
| private

Definition at line 981 of file THistSvc.cpp.

981 { return readHist_i( id, hist ); }
THistSvc::readHist_i
StatusCode readHist_i(const std::string &name, T *&hist) const
Definition: THistSvc.icc:242

StatusCode THistSvc::regGraph | ( | const std::string & | name | ) |
| override

Definition at line 889 of file THistSvc.cpp.

890 {
891 TGraph* hist = nullptr;
892 return regHist_i( hist, id );
893 }
THistSvc::regHist_i
StatusCode regHist_i(T *hist, const std::string &name)
Definition: THistSvc.icc:17

StatusCode THistSvc::regGraph | ( | const std::string & | name,
|  | TGraph * | hist
| ) |  |
| override

Definition at line 897 of file THistSvc.cpp.

898 {
899 if ( strcmp( hist->GetName(), "Graph" ) == 0 ) {
900
901 std::string id2( id );
902 string::size_type i = id2.rfind( "/" );
903 if ( i != string::npos ) {
904 id2.erase( 0, i + 1 );
905 }
906
907 info() << "setting name of TGraph id: \"" << id << "\" to \"" << id2 << "\" since it is unset" << endmsg;
908 hist->SetName( id2.c_str() );
909 }
910
911 return regHist_i( hist, id );
912 }
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:112
std::string
STL class.
std::strcmp
T strcmp(T...args)
THistSvc::regHist_i
StatusCode regHist_i(T *hist, const std::string &name)
Definition: THistSvc.icc:17
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

StatusCode THistSvc::regHist | ( | const std::string & | name | ) |
| override

Definition at line 848 of file THistSvc.cpp.

849 {
850
851 TH1* hist = nullptr;
852 return regHist_i( hist, id );
853 }
THistSvc::regHist_i
StatusCode regHist_i(T *hist, const std::string &name)
Definition: THistSvc.icc:17

StatusCode THistSvc::regHist | ( | const std::string & | name,
|  | TH1 * | hist
| ) |  |
| override

Definition at line 857 of file THistSvc.cpp.

857 { return regHist_i( hist, id ); }
THistSvc::regHist_i
StatusCode regHist_i(T *hist, const std::string &name)
Definition: THistSvc.icc:17

StatusCode THistSvc::regHist | ( | const std::string & | name,
|  | TH2 * | hist
| ) |  |
| override

Definition at line 861 of file THistSvc.cpp.

861 { return regHist_i( hist, id ); }
THistSvc::regHist_i
StatusCode regHist_i(T *hist, const std::string &name)
Definition: THistSvc.icc:17

StatusCode THistSvc::regHist | ( | const std::string & | name,
|  | TH3 * | hist
| ) |  |
| override

Definition at line 865 of file THistSvc.cpp.

865 { return regHist_i( hist, id ); }
THistSvc::regHist_i
StatusCode regHist_i(T *hist, const std::string &name)
Definition: THistSvc.icc:17
template<typename T >

StatusCode THistSvc::regHist_i | ( | T * | hist,
|  | const std::string & | name
| ) |  |
| private

Definition at line 17 of file THistSvc.icc.

17 {
18
19 GlobalDirectoryRestore restore;
20
21 std::string idr(id);
22 removeDoubleSlash( idr );
23
24 if (idr.find("/") == idr.length()) {
25 error() << "Badly formed identifier \"" << idr << "\": "
26 << "Must not end with a /" << endmsg;
27 return StatusCode::FAILURE;
28 }
29
30
31 TFile *f = nullptr;
32 std::string stream,rem;
33 if (!findStream(idr, stream, rem, f)) {
34 error() << "Could not register id: \"" << idr << "\""
35 << endmsg;
36 return StatusCode::FAILURE;
37 }
38
39 std::string uid = "/" + stream + "/" + rem;
40 auto itr = m_uids.find(uid);
41 if (itr != m_uids.end()) {
42 error() << "already registered an object with identifier \""
43 << idr << "\"" << endmsg;
44 return StatusCode::FAILURE;
45 }
46
47
48 bool temp = false;
49 if ( !f ) {
50 temp = true;
51 if (msgLevel(MSG::DEBUG))
52 debug() << "Historgram with id \"" << idr << "\" is temporary"
53 << endmsg;
54 }
55
56
57 TObject *to = nullptr;
58 THistID hid;
59
60 // check to see if this hist is to be read in;
61 if (!temp && m_files.find(stream)->second.second == READ) {
62
63 if (hist != 0) {
64 warning() << "Registering id: \"" << idr
65 << "\" with non zero pointer!" << endmsg;
66 }
67
68 if (readHist_i(idr,hist).isFailure()) {
69 error() << "Unable to read in hist" << endmsg;
70 return StatusCode::FAILURE;
71 }
72 to = dynamic_cast<TObject*>(hist);
73 hid = THistID(uid,temp,to,f,m_files.find(stream)->second.second);
74
75 } else if (hist == 0) {
76 error() << "Unable to read in hist with id: \""
77 << idr << "\"" << endmsg;
78 return StatusCode::FAILURE;
79
80 } else {
81
82 to = dynamic_cast<TObject*>(hist);
83 if (to == 0) {
84 error() << "Could not dcast to TObject. id: \"" << idr
85 << "\"" << endmsg;
86 return StatusCode::FAILURE;
87 }
88
89 auto oitr = m_tobjs.find(to);
90 if (oitr != m_tobjs.end()) {
91 error() << "already registered id: \"" << idr
92 << "\" with identifier \"" << oitr->second.id << "\"" << endmsg;
93 return StatusCode::FAILURE;
94 }
95
96 hid = THistID(uid,temp,to,f,m_files.find(stream)->second.second);
97 TDirectory* dir = changeDir(hid);
98
99 if ( dynamic_cast<TTree*>(hist) ) {
100 dynamic_cast<TTree*>(hist)->SetDirectory(dir);
101 } else if ( dynamic_cast<TH1*>(hist) ) {
102 dynamic_cast<TH1*>(hist)->SetDirectory(dir);
103 } else if ( dynamic_cast<TGraph*>(hist) ) {
104 dir->Append(hist);
105 } else {
106 error() << "id: \"" << idr
107 << "\" is not a TH, TTree, or TGraph. Attaching it to current dir."
108 << endmsg;
109 dir->Append(hist);
110 }
111
112 }
113
114 std::string fname;
115 if ( !f ) {
116 fname = "none";
117 } else {
118 fname = f->GetName();
119 }
120
121 if (msgLevel(MSG::DEBUG))
122 debug() << "Registering " << System::typeinfoName(typeid(*hist))
123 << " title: \"" << hist->GetTitle()
124 << "\" id: \"" << uid << "\" dir: "
125 // << hist->GetDirectory()->GetPath() << " "
126 << changeDir(hid)->GetPath()
127 << " file: " << fname
128 << endmsg;
129
130 m_ids.emplace(rem, hid);
131 m_uids[uid] = hid;
132 m_tobjs[to] = hid;
133
134 return StatusCode::SUCCESS;
135
136 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:329
THistSvc::findStream
bool findStream(const std::string &name, std::string &root, std::string &rem, TFile *&file) const
Definition: THistSvc.cpp:985
MSG::DEBUG
Definition: IMessageSvc.h:16
std::map::end
T end(T...args)
THistSvc::changeDir
TDirectory * changeDir(const THistSvc::THistID &hid) const
Definition: THistSvc.cpp:1411
THistSvc::m_tobjs
objMap m_tobjs
Definition: THistSvc.h:180
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:109
std::map::find
T find(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
THistSvc::m_uids
uidMap m_uids
Definition: THistSvc.h:178
THistSvc::readHist_i
StatusCode readHist_i(const std::string &name, T *&hist) const
Definition: THistSvc.icc:242
GlobalDirectoryRestore
Definition: RConverter.h:16
THistSvc::m_files
std::map< std::string, std::pair< TFile *, Mode > > m_files
Definition: THistSvc.h:182
std::multimap::emplace
T emplace(T...args)
THistSvc::READ
Definition: THistSvc.h:94
THistSvc::m_ids
idMap m_ids
Definition: THistSvc.h:179
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
THistSvc::removeDoubleSlash
void removeDoubleSlash(std::string &) const
Definition: THistSvc.cpp:1475

StatusCode THistSvc::regTree | ( | const std::string & | name | ) |
| override

Definition at line 869 of file THistSvc.cpp.

870 {
871 TTree* hist = nullptr;
872 return regHist_i( hist, id );
873 }
THistSvc::regHist_i
StatusCode regHist_i(T *hist, const std::string &name)
Definition: THistSvc.icc:17

StatusCode THistSvc::regTree | ( | const std::string & | name,
|  | TTree * | hist
| ) |  |
| override

Definition at line 877 of file THistSvc.cpp.

878 {
879 StatusCode sc = regHist_i( hist, id );
880 if ( hist && sc.isSuccess() ) {
881 if ( m_autoSave != 0 ) hist->SetAutoSave( m_autoSave );
882 hist->SetAutoFlush( m_autoFlush );
883 }
884 return sc;
885 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
THistSvc::m_autoSave
Gaudi::Property< int > m_autoSave
Definition: THistSvc.h:154
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
THistSvc::regHist_i
StatusCode regHist_i(T *hist, const std::string &name)
Definition: THistSvc.icc:17
THistSvc::m_autoFlush
Gaudi::Property< int > m_autoFlush
Definition: THistSvc.h:155

StatusCode THistSvc::reinitialize | ( |  | ) |
| override

Definition at line 189 of file THistSvc.cpp.

190 {
191
192 GlobalDirectoryRestore restore;
193 warning() << "reinitialize not implemented" << endmsg;
194 return StatusCode::SUCCESS;
195 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:109
GlobalDirectoryRestore
Definition: RConverter.h:16
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

void THistSvc::removeDoubleSlash | ( | std::string & | id | ) | const
| private

Definition at line 1475 of file THistSvc.cpp.

1476 {
1477
1478 while ( id.find( "//" ) != std::string::npos ) {
1479 id.replace( id.find( "//" ), 2, "/" );
1480 }
1481 }
std::find
T find(T...args)

StatusCode THistSvc::rootOpenAction | ( | FILEMGR_CALLBACK_ARGS |  | ) |
| private

Definition at line 1741 of file THistSvc.cpp.

1742 {
1743
1744 if ( fa->tech() != Io::ROOT ) {
1745 // This should never happen
1746 return StatusCode::SUCCESS;
1747 }
1748
1749 if ( fa->desc() != "HIST" ) {
1750 return StatusCode::SUCCESS;
1751 }
1752
1753 p_incSvc->fireIncident( FileIncident( caller, "OpenHistFile", fa->name() ) );
1754
1755 if ( fa->flags().isRead() ) {
1756 p_incSvc->fireIncident( FileIncident( caller, "BeginHistFile", fa->name() ) );
1757 } else if ( fa->flags().isWrite() ) {
1758 p_incSvc->fireIncident( FileIncident( caller, IncidentType::BeginOutputFile, fa->name() ) );
1759 } else {
1760 // for Io::RW
1761 p_incSvc->fireIncident( FileIncident( caller, IncidentType::BeginOutputFile, fa->name() ) );
1762 }
1763
1764 return StatusCode::SUCCESS;
1765 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
FileIncident
This class is the FileIncident.
Definition: FileIncident.h:17
Io::ROOT
Definition: IFileMgr.h:157
THistSvc::p_incSvc
IIncidentSvc * p_incSvc
Definition: THistSvc.h:192
IIncidentSvc::fireIncident
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.

StatusCode THistSvc::rootOpenErrAction | ( | FILEMGR_CALLBACK_ARGS |  | ) |
| private

Definition at line 1769 of file THistSvc.cpp.

1770 {
1771
1772 if ( fa->tech() != Io::ROOT ) {
1773 // This should never happen
1774 return StatusCode::SUCCESS;
1775 }
1776
1777 if ( fa->desc() != "HIST" ) {
1778 return StatusCode::SUCCESS;
1779 }
1780
1781 if ( fa->flags().isRead() ) {
1782 p_incSvc->fireIncident( FileIncident( caller, IncidentType::FailInputFile, fa->name() ) );
1783 } else if ( fa->flags().isWrite() ) {
1784 p_incSvc->fireIncident( FileIncident( caller, IncidentType::FailOutputFile, fa->name() ) );
1785 } else {
1786 // for Io::RW
1787 p_incSvc->fireIncident( FileIncident( caller, "FailRWFile", fa->name() ) );
1788 }
1789
1790 return StatusCode::SUCCESS;
1791 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
FileIncident
This class is the FileIncident.
Definition: FileIncident.h:17
Io::ROOT
Definition: IFileMgr.h:157
THistSvc::p_incSvc
IIncidentSvc * p_incSvc
Definition: THistSvc.h:192
IIncidentSvc::fireIncident
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.

void THistSvc::setupCompressionLevel | ( | Gaudi::Details::PropertyBase & | cmp | ) |
| private

Definition at line 1041 of file THistSvc.cpp.

1042 {
1043
1044 warning() << "\"CompressionLevel\" Property has been deprecated. "
1045 << "Set it via the \"CL=\" parameter in the \"Output\" Property" << endmsg;
1046 }
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:109
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

void THistSvc::setupInputFile | ( | Gaudi::Details::PropertyBase & | inputfile | ) |
| private

call-back method to handle input stream property

Definition at line 1050 of file THistSvc.cpp.

1051 {
1052
1053 if ( FSMState() < Gaudi::StateMachine::CONFIGURED || !m_okToConnect ) {
1054
1055 debug() << "Delaying connection of Input Files until Initialize"
1056 << ". now in " << FSMState() << endmsg;
1057
1058 m_delayConnect = true;
1059 } else {
1060
1061 debug() << "Now connecting of Input Files" << endmsg;
1062
1063 StatusCode sc = StatusCode::SUCCESS;
1064
1065 for ( const auto& itr : m_inputfile.value() ) {
1066 if ( m_alreadyConnectedInFiles.end() != m_alreadyConnectedInFiles.find( itr ) ) continue;
1067 if ( connect( itr ).isFailure() ) {
1068 sc = StatusCode::FAILURE;
1069 } else {
1070 m_alreadyConnectedInFiles.insert( itr );
1071 }
1072 }
1073
1074 if ( !sc.isSuccess() ) {
1075 throw GaudiException( "Problem connecting inputfile !!", name(), StatusCode::FAILURE );
1076 }
1077 }
1078 }
THistSvc::m_delayConnect
bool m_delayConnect
Definition: THistSvc.h:188
StatusCode::SUCCESS
Definition: StatusCode.h:31
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
Gaudi::StateMachine::CONFIGURED
Definition: StateMachine.h:16
StatusCode::FAILURE
Definition: StatusCode.h:31
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
std::set::end
T end(T...args)
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
THistSvc::m_inputfile
Gaudi::Property< std::vector< std::string > > m_inputfile
Definition: THistSvc.h:161
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
THistSvc::m_okToConnect
bool m_okToConnect
Definition: THistSvc.h:188
std::set::insert
T insert(T...args)
std::set::find
T find(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
Service::FSMState
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:54
THistSvc::connect
StatusCode connect(const std::string &)
Definition: THistSvc.cpp:1217
THistSvc::m_alreadyConnectedInFiles
std::set< std::string > m_alreadyConnectedInFiles
list of already connected files.
Definition: THistSvc.h:167
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

void THistSvc::setupOutputFile | ( | Gaudi::Details::PropertyBase & | outputfile | ) |
| private

call-back method to handle output stream property

Definition at line 1082 of file THistSvc.cpp.

1083 {
1084 if ( FSMState() < Gaudi::StateMachine::CONFIGURED || !m_okToConnect ) {
1085 debug() << "Delaying connection of Input Files until Initialize"
1086 << ". now in " << FSMState() << endmsg;
1087 m_delayConnect = true;
1088 } else {
1089
1090 StatusCode sc = StatusCode::SUCCESS;
1091 for ( const auto& itr : m_outputfile.value() ) {
1092 if ( m_alreadyConnectedOutFiles.end() != m_alreadyConnectedOutFiles.find( itr ) ) continue;
1093 if ( connect( itr ).isFailure() ) {
1094 sc = StatusCode::FAILURE;
1095 } else {
1096 m_alreadyConnectedOutFiles.insert( itr );
1097 }
1098 }
1099
1100 if ( !sc.isSuccess() ) {
1101 throw GaudiException( "Problem connecting outputfile !!", name(), StatusCode::FAILURE );
1102 }
1103 }
1104 }
THistSvc::m_delayConnect
bool m_delayConnect
Definition: THistSvc.h:188
StatusCode::SUCCESS
Definition: StatusCode.h:31
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
Gaudi::StateMachine::CONFIGURED
Definition: StateMachine.h:16
StatusCode::FAILURE
Definition: StatusCode.h:31
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
std::set::end
T end(T...args)
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
THistSvc::m_outputfile
Gaudi::Property< std::vector< std::string > > m_outputfile
Definition: THistSvc.h:160
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
THistSvc::m_okToConnect
bool m_okToConnect
Definition: THistSvc.h:188
std::set::insert
T insert(T...args)
std::set::find
T find(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
Service::FSMState
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:54
THistSvc::connect
StatusCode connect(const std::string &)
Definition: THistSvc.cpp:1217
THistSvc::m_alreadyConnectedOutFiles
std::set< std::string > m_alreadyConnectedOutFiles
list of already connected files.
Definition: THistSvc.h:171
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

void THistSvc::updateFiles | ( |  | ) |
| private

Definition at line 1108 of file THistSvc.cpp.

1109 {
1110
1111 // If TTrees grow beyond TTree::fgMaxTreeSize, a new file is
1112 // automatically created by root, and the old one closed. We
1113 // need to migrate all the UIDs over to show the correct file
1114 // pointer. This is ugly.
1115
1116 if ( msgLevel( MSG::DEBUG ) ) debug() << "updateFiles()" << endmsg;
1117
1118 for ( auto uitr = m_uids.begin(); uitr != m_uids.end(); ++uitr ) {
1119 #ifndef NDEBUG
1120 if ( msgLevel( MSG::VERBOSE ) )
1121 verbose() << " update: " << uitr->first << " " << uitr->second.id << " " << uitr->second.mode << endmsg;
1122 #endif
1123 TObject* to = uitr->second.obj;
1124 TFile* oldFile = uitr->second.file;
1125 if ( !to ) {
1126 warning() << uitr->first << ": TObject == 0" << endmsg;
1127 } else if ( uitr->second.temp || uitr->second.mode == READ ) {
1128 // do nothing - no need to check how big the file is since we
1129 // are just reading it.
1130 #ifndef NDEBUG
1131 if ( msgLevel( MSG::VERBOSE ) ) verbose() << " skipping" << endmsg;
1132 #endif
1133
1134 } else if ( to->IsA()->InheritsFrom( "TTree" ) ) {
1135 TTree* tr = dynamic_cast<TTree*>( to );
1136 TFile* newFile = tr->GetCurrentFile();
1137
1138 if ( oldFile != newFile ) {
1139 std::string newFileName = newFile->GetName();
1140 std::string oldFileName, streamName, rem;
1141 TFile* dummy = nullptr;
1142 findStream( uitr->second.id, streamName, rem, dummy );
1143
1144 for ( auto& itr : m_files ) {
1145 if ( itr.second.first == oldFile ) itr.second.first = newFile;
1146 }
1147
1148 for ( auto uitr2 = uitr; uitr2 != m_uids.end(); ++uitr2 ) {
1149 if ( uitr2->second.file == oldFile ) {
1150 uitr2->second.file = newFile;
1151 }
1152 }
1153
1154 auto sitr = std::find_if( std::begin( m_fileStreams ), std::end( m_fileStreams ),
1155 [&]( streamMap::const_reference s ) { return s.second == streamName; } );
1156 if ( sitr != std::end( m_fileStreams ) ) oldFileName = sitr->first;
1157
1158 #ifndef NDEBUG
1159 if ( msgLevel( MSG::DEBUG ) )
1160 debug() << "migrating uid: " << uitr->second.id << " stream: " << streamName
1161 << " oldFile: " << oldFileName << " newFile: " << newFileName << endmsg;
1162 #endif
1163
1164 if ( !oldFileName.empty() ) {
1165 auto i = m_fileStreams.lower_bound( oldFileName );
1166 while ( i != std::end( m_fileStreams ) && i->first == oldFileName ) {
1167
1168 #ifndef NDEBUG
1169 if ( msgLevel( MSG::DEBUG ) )
1170 debug() << "changing filename \"" << i->first << "\" to \"" << newFileName << "\" for stream \""
1171 << i->second << "\"" << endmsg;
1172 #endif
1173 std::string nm = std::move( i->second );
1174 i = m_fileStreams.erase( i );
1175 m_fileStreams.emplace( newFileName, std::move( nm ) );
1176 }
1177
1178 } else {
1179 error() << "Problems updating fileStreams with new file name" << endmsg;
1180 }
1181 }
1182 }
1183 }
1184 }
std::string::empty
T empty(T...args)
THistSvc::findStream
bool findStream(const std::string &name, std::string &root, std::string &rem, TFile *&file) const
Definition: THistSvc.cpp:985
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:118
MSG::DEBUG
Definition: IMessageSvc.h:16
std::map::end
T end(T...args)
std::multimap::lower_bound
T lower_bound(T...args)
MSG::VERBOSE
Definition: IMessageSvc.h:16
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:109
std::multimap::erase
T erase(T...args)
std::move
T move(T...args)
Gaudi::Units::nm
constexpr double nm
Definition: SystemOfUnits.h:83
std::find_if
T find_if(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
THistSvc::m_uids
uidMap m_uids
Definition: THistSvc.h:178
std::map::begin
T begin(T...args)
THistSvc::m_files
std::map< std::string, std::pair< TFile *, Mode > > m_files
Definition: THistSvc.h:182
std::multimap::emplace
T emplace(T...args)
gaudirun.s
string s
Definition: gaudirun.py:253
THistSvc::READ
Definition: THistSvc.h:94
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
THistSvc::m_fileStreams
streamMap m_fileStreams
Definition: THistSvc.h:183

StatusCode THistSvc::write | ( |  | ) |
| private

Definition at line 1188 of file THistSvc.cpp.

1189 {
1190
1191 updateFiles();
1192
1193 std::for_each( m_files.begin(), m_files.end(), []( std::pair<const std::string, std::pair<TFile*, Mode>>& i ) {
1194 auto mode = i.second.second;
1195 auto file = i.second.first;
1196 if ( mode == WRITE || mode == UPDATE || mode == SHARE ) {
1197 file->Write( "", TObject::kOverwrite );
1198 } else if ( mode == APPEND ) {
1199 file->Write( "" );
1200 }
1201 } );
1202
1203 if ( msgLevel( MSG::DEBUG ) ) {
1204 debug() << "THistSvc::write()::List of Files connected in ROOT " << endmsg;
1205 TSeqCollection* filelist = gROOT->GetListOfFiles();
1206 for ( int ii = 0; ii < filelist->GetEntries(); ii++ ) {
1207 debug() << "THistSvc::write()::List of Files connected in ROOT: \"" << filelist->At( ii )->GetName() << "\""
1208 << endmsg;
1209 }
1210 }
1211
1212 return StatusCode::SUCCESS;
1213 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
THistSvc::APPEND
Definition: THistSvc.h:94
MSG::DEBUG
Definition: IMessageSvc.h:16
std::map::end
T end(T...args)
THistSvc::UPDATE
Definition: THistSvc.h:94
THistSvc::SHARE
Definition: THistSvc.h:94
std::pair
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
std::map::begin
T begin(T...args)
THistSvc::m_files
std::map< std::string, std::pair< TFile *, Mode > > m_files
Definition: THistSvc.h:182
THistSvc::WRITE
Definition: THistSvc.h:94
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
std::for_each
T for_each(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
THistSvc::updateFiles
void updateFiles()
Definition: THistSvc.cpp:1108

## Member Data Documentation

std::set<std::string> THistSvc::m_alreadyConnectedInFiles
| private

list of already connected files.

This is to keep track of files registered by the setupInputFile callback method

Definition at line 167 of file THistSvc.h.

std::set<std::string> THistSvc::m_alreadyConnectedOutFiles
| private

list of already connected files.

This is to keep track of files registered by the setupOutputFile callback method

Definition at line 171 of file THistSvc.h.

Gaudi::Property<int> THistSvc::m_autoFlush {this, "AutoFlush", 0}
| private

Definition at line 155 of file THistSvc.h.

Gaudi::Property<int> THistSvc::m_autoSave {this, "AutoSave", 0}
| private

Definition at line 154 of file THistSvc.h.

Gaudi::Property<int> THistSvc::m_compressionLevel {this, "CompressionLevel", 1}
| private

Definition at line 159 of file THistSvc.h.

std::string THistSvc::m_curstream
| mutable private

Definition at line 190 of file THistSvc.h.

bool THistSvc::m_delayConnect = false
| private

Definition at line 188 of file THistSvc.h.

std::map<std::string, std::pair<TFile*, Mode> > THistSvc::m_files
| private

Definition at line 182 of file THistSvc.h.

streamMap THistSvc::m_fileStreams
| private

Definition at line 183 of file THistSvc.h.

idMap THistSvc::m_ids
| private

Definition at line 179 of file THistSvc.h.

Gaudi::Property<std::vector<std::string> > THistSvc::m_inputfile {this, "Input", {}}
| private

Definition at line 161 of file THistSvc.h.

Gaudi::Property<int> THistSvc::m_maxFileSize
| private

Initial value:
{this, "MaxFileSize", 10240,
"maximum file size in MB. if exceeded, will cause an abort. -1 to never check."}

Definition at line 157 of file THistSvc.h.

bool THistSvc::m_okToConnect = false
| private

Definition at line 188 of file THistSvc.h.

Gaudi::Property<std::vector<std::string> > THistSvc::m_outputfile {this, "Output", {}}
| private

Definition at line 160 of file THistSvc.h.

Gaudi::Property<bool> THistSvc::m_print {this, "PrintAll", false}
| private

Definition at line 156 of file THistSvc.h.

std::vector<std::string> THistSvc::m_Rstream
| private

Definition at line 163 of file THistSvc.h.

std::map<std::string, std::string> THistSvc::m_sharedFiles
| private

Definition at line 185 of file THistSvc.h.

objMap THistSvc::m_tobjs
| private

Definition at line 180 of file THistSvc.h.

uidMap THistSvc::m_uids
| private

Definition at line 178 of file THistSvc.h.

std::vector<std::string> THistSvc::m_Wstream
| private

Definition at line 163 of file THistSvc.h.

IFileMgr* THistSvc::p_fileMgr = nullptr
| private

Definition at line 193 of file THistSvc.h.

IIncidentSvc* THistSvc::p_incSvc = nullptr
| private

Definition at line 192 of file THistSvc.h.

bool THistSvc::signaledStop = false
| private

Definition at line 187 of file THistSvc.h.

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

- GaudiSvc/src/THistSvc/THistSvc.h
- GaudiSvc/src/THistSvc/THistSvc.cpp
- GaudiSvc/src/THistSvc/THistSvc.icc