| The Gaudi Framework v29r1 (5cd95fa2)

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

- File List
- File Members

RHistogramCnv.h
Go to the documentation of this file.
1 #ifndef ROOTHISTCNV_RHISTOGRAMCNV_H
2 #define ROOTHISTCNV_RHISTOGRAMCNV_H 1
3
4 // Include files
5 #include "GaudiKernel/DataObject.h"
6 #include "GaudiKernel/HistogramBase.h"
7 #include "GaudiKernel/IOpaqueAddress.h"
8 #include "GaudiKernel/IRegistry.h"
9 #include "GaudiKernel/ObjectFactory.h"
10 #include "GaudiKernel/SmartIF.h"
11 #include "RConverter.h"
12 #include "RootObjAddress.h"
13 #include "TArray.h"
14 #include <memory>
15
16 namespace RootHistCnv
17 {
18
31 template <typename T, typename S, typename Q>
32 class RHistogramCnv : public RConverter
33 {
34 template <typename CLASS>
35 struct TTH : public CLASS {
36 void CopyH( TObject& o ) { CLASS::Copy( o ); }
37 };
38
39 public:
41 StatusCode createObj( IOpaqueAddress* pAddr, DataObject*& refpObj ) override
42 {
43 refpObj = DataObjFactory::create( objType() );
44 RootObjAddress* r = dynamic_cast<RootObjAddress*>( pAddr );
45 Q* h = dynamic_cast<Q*>( refpObj );
46 if ( r && h ) {
47 // Need to flip representation .... clumsy for the time being, because
48 // THXY constructor has no "generic" copy constructor
49 std::unique_ptr<T> p( new T() );
50 S* s = dynamic_cast<S*>( r->tObj() );
51 if ( s && p.get() ) {
52 TTH<S>* casted = (TTH<S>*)s;
53 TArray* a = dynamic_cast<TArray*>( s );
54 casted->CopyH( *p );
55 if ( 0 != a ) {
56 p->Set( a->GetSize() );
57 p->Reset();
58 p->Add( s );
59 h->adoptRepresentation( p.release() );
60 return StatusCode::SUCCESS;
61 }
62 }
63 }
64 return error( "Cannot create histogram - invalid address." );
65 }
67 StatusCode updateObj( IOpaqueAddress* /* pAddr */, DataObject* /* pObj */ ) override { return StatusCode::SUCCESS; }
69 TObject* createPersistent( DataObject* pObj ) override
70 {
71 Q* h = dynamic_cast<Q*>( pObj );
72 if ( 0 != h ) {
73 T* r = dynamic_cast<T*>( h->representation() );
74 if ( r ) {
75 T* c = new T();
76 TArray* a = dynamic_cast<TArray*>( r );
77 ( (TTH<S>*)r )->CopyH( *c );
78 if ( 0 != a ) {
79 c->Set( a->GetSize() );
80 c->Reset();
81 c->Add( r );
82 c->SetName( pObj->registry()->name().c_str() + 1 );
83 return c;
84 }
85 }
86 }
87 error( "Histogram object is invalid!" );
88 return 0;
89 }
91 static const CLID& classID();
93 RHistogramCnv( ISvcLocator* svc ) : RConverter( classID(), svc ) {}
94 ~RHistogramCnv() override = default;
95 };
96 } // namespace RootHistCnv
97 #endif // ROOTHISTCNV_RHISTOGRAMCNV_H
RootHistCnv::RConverter
Root Converter.
Definition: RConverter.h:33
StatusCode::SUCCESS
Definition: StatusCode.h:31
RootHistCnv::RHistogramCnv::RHistogramCnv
RHistogramCnv(ISvcLocator *svc)
Standard constructor.
Definition: RHistogramCnv.h:93
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
gaudirun.c
c
Definition: gaudirun.py:407
Converter::objType
const CLID & objType() const override
Retrieve the class type of objects the converter produces.
Definition: Converter.cpp:14
RootHistCnv::RHistogramCnv::createPersistent
TObject * createPersistent(DataObject *pObj) override
Create the persistent representation of the histogram object.
Definition: RHistogramCnv.h:69
ObjectFactory.h
IRegistry::name
virtual const name_type & name() const =0
Name of the directory (or key)
RootHistCnv::RootObjAddress
Definition: RootObjAddress.h:11
RConverter.h
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:72
std::unique_ptr::release
T release(T...args)
RootHistCnv::RHistogramCnv::classID
static const CLID & classID()
Inquire class type.
Definition: RHistogramCnv.cpp:9
HistogramBase.h
HiveAlgSequencer.h
h
Definition: HiveAlgSequencer.py:24
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
RootHistCnv::RootObjAddress::tObj
virtual TObject * tObj() const
Retrieve TObject* ptr.
Definition: RootObjAddress.h:91
SmartIF.h
RootHistCnv::RHistogramCnv
Generic converter to save/read AIDA_ROOT histograms using ROOT.
Definition: RHistogramCnv.h:32
RootHistCnv
Definition: DirectoryCnv.h:17
IRegistry.h
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
IOpaqueAddress.h
std::unique_ptr::get
T get(T...args)
RootObjAddress.h
std::unique_ptr
STL class.
RootHistCnv::RConverter::error
StatusCode error(const std::string &msg)
Definition: RConverter.cpp:337
RootHistCnv::RHistogramCnv::TTH::CopyH
void CopyH(TObject &o)
Definition: RHistogramCnv.h:36
std::string::c_str
T c_str(T...args)
gaudirun.s
string s
Definition: gaudirun.py:253
RootHistCnv::RHistogramCnv::~RHistogramCnv
~RHistogramCnv() override=default
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
RootHistCnv::RHistogramCnv::updateObj
StatusCode updateObj(IOpaqueAddress *, DataObject *) override
Update the transient object from the other representation.
Definition: RHistogramCnv.h:67
RootHistCnv::RHistogramCnv::createObj
StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&refpObj) override
Create the transient representation of an object.
Definition: RHistogramCnv.h:41
RootHistCnv::RHistogramCnv::TTH
Definition: RHistogramCnv.h:35
DataObject.h