5 #pragma warning(disable:2259)
11 #pragma warning(disable:4996)
44 inline std::string histoAddr
45 (
const std::string& name)
47 if ( 0 == name.find (
"/stat/" ) ){
return std::string( name , 6 ) ; }
51 inline std::string histoAddr
53 const std::string& rel )
55 if ( 0 == obj ) {
return rel ; }
57 if ( 0 == reg ) {
return rel ; }
60 if ( rel .empty() ) {
return histoAddr ( name ) ; }
61 if (
'/' == name[name.size()-1] ||
62 '/' == rel[0] ) {
return histoAddr ( name + rel ) ; }
63 return histoAddr ( name +
"/" + rel ) ;
69 std::ostringstream txt; txt <<
i;
74 std::pair<std::string,std::string> split=
i_splitPath(full);
83 if (!hObj->annotation().addItem(
"id", obj.substr(1)))
84 hObj->annotation().setValue(
"id", obj.substr(1));
88 if (!hObj->annotation().addItem(
"id", obj))
89 hObj->annotation().setValue(
"id", obj);
98 TH3D *h3d = Gaudi::getRepresentation<IHistogram3D,TH3D>(h);
100 TH2D *h2d =
dynamic_cast<TH2D*
>(h3d->Project3D(dir.c_str()));
116 if(0 != b)
return b->
print(s);
118 log <<
MSG::ERROR <<
"Unknown histogram type: Cannot cast to Gaudi::HistogramBase."
125 if(0 != b)
return b->
write(s);
127 log <<
MSG::ERROR <<
"Unknown histogram type: Cannot cast to Gaudi::HistogramBase."
134 if(0 != b)
return b->
write(file_name);
136 log <<
MSG::ERROR <<
"Unknown histogram type: Cannot cast to Gaudi::HistogramBase."
142 std::string tmp = full;
148 if (tmp.rfind(
SEPARATOR) == tmp.length()-1) {
152 return std::pair<std::string,std::string>
153 (tmp.substr(0,sep),tmp.substr(sep,tmp.length()-sep));
157 std::string tmpPath = newPath;
159 tmpPath.insert(tmpPath.begin(),
SEPARATOR);
163 if (tmpPath.rfind(
SEPARATOR) == tmpPath.length()-1) {
164 tmpPath.erase(tmpPath.rfind(
SEPARATOR),1);
172 std::string rest(tmpPath, sep+1, tmpPath.length()-sep);
173 std::string subPath(tmpPath, 0, sep);
188 if (0 != directory) {
195 log <<
MSG::ERROR <<
"Unable to create the histogram directory: "
196 << parentDir <<
"/" << subDir <<
endmsg;
203 log <<
MSG::ERROR <<
"Unable to create the histogram directory: "
204 << parentDir <<
"/" << subDir <<
endmsg;
223 std::string::size_type loc = ident.find(
" ");
224 std::string filename, auth, svc =
"", typ =
"";
225 std::string logname = ident.substr(0,loc);
226 tok.
analyse(ident.substr(loc+1,ident.length()),
" ",
"",
"",
"=",
"'",
"'");
227 for (Tokenizer::Items::iterator
i = tok.
items().begin();
229 CSTR tag = (*i).tag();
233 filename = (*i).value();
242 if (typ.length() > 0) {
246 entryname += logname;
251 filename,entryname,0,
'O');
255 filename,entryname,0,
'O');
261 log <<
MSG::INFO <<
"Added stream file:" << filename
262 <<
" as " << logname <<
endmsg;
269 log <<
MSG::ERROR <<
"Cannot add " << ident <<
" invalid filename!" <<
endmsg;
279 status =
setRoot(
"/stat", rootObj);
286 status =
service(
"HistogramPersistencySvc",svc,
true);
296 for (DBaseEntries::iterator j =
m_input.begin(); j !=
m_input.end(); j++) {
306 for ( Histo1DMap::const_iterator ih =
m_defs1D.begin() ;
310 <<
" Path='" << ih->first <<
"'"
311 <<
" Description " << ih->second <<
endmsg ;
322 (
CSTR name,
const IHistogram2D& h,
int idxY1,
int idxY2) {
323 std::pair<DataObject*,IHistogram1D*> o(0,0);
330 throw GaudiException(
"Cannot cast 2D histogram to H2D to create sliceX `"
337 throw GaudiException(
"Cannot create sliceX `" + name +
"' of 2D histogram!",
343 std::pair<DataObject*,IHistogram1D*> o(0,0);
358 throw GaudiException(
"Cannot create sliceY `"+name+
"' of 2D histogram!",
365 if ( hist )
delete hist;
372 if ( m_defs1D.empty () )
374 std::string hn = histoAddr ( pPar , rel ) ;
375 Histo1DMap::const_iterator ifound = m_defs1D.find( hn ) ;
376 if ( m_defs1D.end() == ifound )
381 <<
" Redefine the parameters for the histogram '" + hn +
"' to be "
385 m_mods1D.insert ( hn ) ;
386 return i_book ( pPar , rel , ifound -> second.title () ,
388 ( ifound -> second.title () ,
389 ifound -> second.bins () ,
390 ifound -> second.lowEdge () ,
391 ifound -> second.lowEdge () ) ) ;
406 "Histograms with predefined parameters" ) ;
417 inline size_t removeLeading
420 for ( HistogramSvc::Histo1DMap::iterator it = m.begin() ;
421 m.end() != it ; ++it )
423 if ( 0 == it->first.find ( lead ) )
425 std::string addr = std::string( it->first , lead.size() ) ;
429 return 1 + removeLeading ( m , lead ) ;
439 removeLeading (
m_defs1D ,
"/stat/" ) ;
450 <<
" Substituted histograms #" <<
m_mods1D.size() <<
" : " <<
endmsg;
451 for ( std::set<std::string>::const_iterator ih =
m_mods1D.begin() ;
455 log <<
MSG::DEBUG <<
" Path='" << (*ih) <<
"'" ;
456 Histo1DMap::const_iterator im =
m_defs1D.find( *ih ) ;
457 if (
m_defs1D.end() != im ) { log <<
" " << im->second ; }
virtual StatusCode setDataLoader(IConversionSvc *svc)
IDataManagerSvc: IDataManagerSvc: Pass a default data loader to the service.
std::pair< DataObject *, AIDA::IHistogram1D * > slice1DY(const std::string &name, const AIDA::IHistogram2D &h, int firstbin, int lastbin)
Create 1D slice from 2D histogram.
Definition of the MsgStream class used to transmit messages.
Define general base for Gaudi exception.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
const long HBOOK_StorageType
virtual StatusCode findObject(const std::string &fullPath, DataObject *&pObject)
Find object identified by its full path in the data store.
virtual StatusCode registerObject(const std::string &fullPath, DataObject *pObject)
Register object with the data store.
std::set< std::string > m_mods1D
bool destroy(IBaseHistogram *hist)
Items & items()
Access token collection.
std::pair< DataObject *, AIDA::IHistogram1D * > createH1D(const AIDA::IHistogram1D &hist)
Copy constructor.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
bool isSuccess() const
Test for a status code of SUCCESS.
std::string m_rootName
Name of root event.
virtual std::ostream & print(std::ostream &s) const =0
Print histogram to output stream.
virtual std::ostream & write(std::ostream &s) const =0
Write (binary) histogram to output stream.
virtual std::ostream & write(Base *h, std::ostream &s=std::cout) const
Write (ASCII) the 1D histogram table into the output stream.
void analyse(const std::string &s, const char *delim, const char *tagBegin, const char *tagEnd, const char *eq, const char *valBegin, const char *valEnd)
Analyse tokens from string.
virtual StatusCode initialize()
Initialise the service.
virtual H1D * book(CSTR par, CSTR rel, CSTR title, DBINS(x))
Book histogram and register it with the histogram data store.
virtual H1D * sliceY(CSTR name, const H2D &h, int indexX)
Generic Transient Address.
GAUDI_API Property * getProperty(const IProperty *p, const std::string &name)
simple function which gets the property with given name from the component
H2D * i_project(CSTR nameAndTitle, const H3D &h, CSTR dir)
Helper for 2D projections.
virtual StatusCode registerAddress(const std::string &fullPath, IOpaqueAddress *pAddress)
IDataManagerSvc: Register object address with the data store.
DBaseEntries m_input
Input streams.
StatusCode connectInput(CSTR ident)
Connect input histogram file to the service.
IRegistry * registry() const
Get pointer to Registry.
#define DECLARE_COMPONENT(type)
virtual ~HistogramSvc()
Destructor.
virtual StatusCode finalize()
finalize the service
virtual StatusCode setRoot(const std::string &root_name, DataObject *pRootObj)
Initialize data store for new event by giving new event path and root object.
virtual void declareUpdateHandler(PropertyCallbackFunctor *pf)
set new callback for update
virtual std::ostream & print(Base *h, std::ostream &s=std::cout) const
Print (ASCII) the 1D histogram into the output stream.
std::pair< std::string, std::string > i_splitPath(CSTR full)
Split full path into its components.
virtual unsigned long release()
release reference to object
HistogramSvc(CSTR name, ISvcLocator *svc)
Statndard Constructor.
This class is used for returning status codes from appropriate routines.
Simple helper class for description of 1D-histogram The class is targeted to act as the primary "hist...
virtual DataObject * createPath(CSTR newPath)
Create all directories in a given full path.
std::pair< DataObject *, AIDA::IHistogram2D * > createH2D(const AIDA::IHistogram2D &hist)
Copy constructor.
void update1Ddefs(Property &)
handler to be invoked for updating property m_defs1D
std::pair< DataObject *, AIDA::IHistogram1D * > slice1DX(const std::string &name, const AIDA::IHistogram2D &h, int firstbin, int lastbin)
Create 1D slice from 2D histogram.
static DataObject * __cast(T *p)
The IRegistry represents the entry door to the environment any data object residing in a transient da...
const long ROOT_StorageType
virtual H1D * sliceX(CSTR name, const H2D &h, int indexY)
virtual StatusCode retrieveObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)
Retrieve object from data store.
virtual StatusCode registerObject(CSTR parent, CSTR rel, Base *obj)
virtual const std::string & name() const
Retrieve name of the service.
virtual StatusCode initialize()
Service initialization.
virtual DataObject * createDirectory(CSTR parentDir, CSTR subDir)
Create a sub-directory in a directory.
virtual StatusCode findObject(IRegistry *pReg, CSTR path, P1D *&obj)
Property base class allowing Property* collections to be "homogeneous".
Common base class for all histograms Use is solely functional to minimize dynamic_casts inside Histog...
virtual unsigned long release()=0
Release Interface instance.
virtual StatusCode clearStore()
IDataManagerSvc: Remove all data objects in the data store.
Templated class to add the standard messaging functionalities.
CLID m_rootCLID
Integer Property corresponding to CLID of root entry.
static int toRootIndex(int index, int nbins)
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.
virtual const id_type & identifier() const =0
Full identifier (or key)
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
virtual StatusCode unregisterObject(Base *obj)
A DataObject is the base class of any identifiable object on any data store.
void toupper(std::string &s)
virtual StatusCode finalize()
Service initialization.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual StatusCode reinitialize()
Initialise the service.
std::map< std::string, Gaudi::Histo1DDef > Histo1DMap
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
HistogramSvc class definition.