| The Gaudi Framework v27r1

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