2 #include "GaudiKernel/IDataProviderSvc.h"
3 #include "GaudiKernel/IDataManagerSvc.h"
4 #include "GaudiKernel/IOpaqueAddress.h"
5 #include "GaudiKernel/IRegistry.h"
6 #include "GaudiKernel/MsgStream.h"
7 #include "GaudiKernel/NTuple.h"
9 #include "boost/optional.hpp"
15 #include "TDirectory.h"
20 #include "TProfile2D.h"
26 constexpr
struct maybe_stol_t {
27 boost::optional<int> operator()(
const std::string&
s)
const {
28 auto pos = s.find_first_of(
"0123456789+-");
29 if ( pos == std::string::npos )
return boost::none;
30 return std::stol( s.substr(pos) );
58 return createAddress(pObject, gDirectory,
nullptr, refpAddress);
60 refpAddress =
nullptr;
71 if ( createDirectory(loc).isSuccess() ) {
85 const std::string& fname = pAddr->
par()[0];
88 findTFile(full,tf).ignore();
92 TIter nextkey(gDirectory->GetListOfKeys());
93 while (TKey *key = (TKey*)nextkey()) {
95 TObject *obj = key->ReadObj();
96 std::string title = obj->GetTitle();
97 std::string sid = obj->GetName();
98 std::string f2 = full +
"/" + sid;
99 int idh = maybe_stol(sid).get_value_or(0);
101 std::string clname = key->GetClassName();
102 std::string clnm = clname.substr(0,3);
103 TClass* isa = obj->IsA();
104 if (isa->InheritsFrom(
"TTree")) {
105 createAddress(full, CLID_ColumnWiseTuple, idh, obj, pA).ignore();
106 TTree* tree = (TTree*) obj;
108 log <<
MSG::DEBUG <<
"Reg CWNT \"" << obj->GetTitle()
109 <<
"\" as " << f2 <<
endmsg;
111 }
else if (isa->InheritsFrom(
"TDirectory")) {
112 createAddress(full,CLID_NTupleDirectory, title, obj, pA).ignore();
113 }
else if ( isa == TProfile::Class() ) {
114 createAddress(full,CLID_ProfileH,idh,obj,pA).ignore();
116 }
else if ( isa == TProfile2D::Class() ) {
117 createAddress(full,CLID_ProfileH2,idh,obj,pA).ignore();
119 }
else if ( isa == TH1C::Class() ) {
120 createAddress(full,CLID_H1D,idh,obj,pA).ignore();
122 }
else if ( isa == TH1S::Class() ) {
123 createAddress(full,CLID_H1D,idh,obj,pA).ignore();
125 }
else if ( isa == TH1I::Class() ) {
126 createAddress(full,CLID_H1D,idh,obj,pA).ignore();
128 }
else if ( isa == TH1F::Class() ) {
129 createAddress(full,CLID_H1D,idh,obj,pA).ignore();
131 }
else if ( isa == TH1D::Class() ) {
132 createAddress(full,CLID_H1D,idh,obj,pA).ignore();
134 }
else if ( isa == TH2C::Class() ) {
135 createAddress(full,CLID_H2D,idh,obj,pA).ignore();
137 }
else if ( isa == TH2S::Class() ) {
138 createAddress(full,CLID_H2D,idh,obj,pA).ignore();
140 }
else if ( isa == TH2I::Class() ) {
141 createAddress(full,CLID_H2D,idh,obj,pA).ignore();
143 }
else if ( isa == TH2F::Class() ) {
144 createAddress(full,CLID_H2D,idh,obj,pA).ignore();
146 }
else if ( isa == TH2D::Class() ) {
147 createAddress(full,CLID_H2D,idh,obj,pA).ignore();
149 }
else if ( isa == TH3C::Class() ) {
150 createAddress(full,CLID_H3D,idh,obj,pA).ignore();
152 }
else if ( isa == TH3S::Class() ) {
153 createAddress(full,CLID_H3D,idh,obj,pA).ignore();
155 }
else if ( isa == TH3I::Class() ) {
156 createAddress(full,CLID_H3D,idh,obj,pA).ignore();
158 }
else if ( isa == TH3F::Class() ) {
159 createAddress(full,CLID_H3D,idh,obj,pA).ignore();
161 }
else if ( isa == TH3D::Class() ) {
162 createAddress(full,CLID_H3D,idh,obj,pA).ignore();
165 log <<
MSG::ERROR <<
"Encountered an unknown object with key: "
166 << obj->GetName() <<
" in ROOT file " << fname <<
endmsg;
170 StatusCode sc = dataManager()->registerAddress(pReg, title, pA);
176 <<
"'" << title <<
"' in " << full <<
endmsg;
virtual const std::string * par() const =0
Retrieve String parameters.
Definition of the MsgStream class used to transmit messages.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
void setDirectory(const std::string &loc)
bool isSuccess() const
Test for a status code of SUCCESS.
StatusCode createRep(DataObject *pObj, IOpaqueAddress *&refpAddr) override
Convert the transient object to the requested representation.
#define DECLARE_NAMESPACE_CONVERTER_FACTORY(n, x)
StatusCode createDirectory(const std::string &loc)
IRegistry * registry() const
Get pointer to Registry.
This class is used for returning status codes from appropriate routines.
Create persistent and transient representations of data store directories.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
StatusCode fillObjRefs(IOpaqueAddress *pAddr, DataObject *refpObj) override
Update the transient object from the other representation.
StatusCode updateRep(IOpaqueAddress *pAddr, DataObject *pObject) override
Convert the transient object to the requested representation.
virtual const id_type & identifier() const =0
Full identifier (or key)
Opaque address interface definition.
A DataObject is the base class of any identifiable object on any data store.
Small class representing an N tuple directory in the transient store.
StatusCode createAddress(DataObject *pObject, TDirectory *pDir, TObject *pTObject, IOpaqueAddress *&refpAddr)
Create address of the transient object according to the requested representation. ...
void setDiskDirectory(const std::string &loc)