ABC of an Object Manager.
ABC of an Object Manager.
An Object Manager manages objects of type emcManageable.
Object Manager typically is responsible for reading/writing objects to a database.
How to write a plugin.Let's assume you are writing a plugin to handle objects of type Nut (Nut must be a subclass of emcManageable). You can of course add to an existing plugin the possibility to handle this new object type. But here, we will consider that you are writing a brand new object manager from scratch.
1. You create a new class, say emcOMNut, which must have in its hierarchy an emcObjectManager. If you want your OM to access Objy, let's derive from emcObjyObjectManager.
2. Somewhere in the source file emcOMNut.C, you must make a call to the EMCALDM_REGISTER_OBJECTMANAGER macro. Like this:
EMCALDM_REGISTER_OBJECTMANAGER(classname,name,title)
where in this example classname=emcOMNut , name="a name", title="Manager for Nut objects"
Please note that there is no quote around the classname and that there is no ; at the end of the macro call.
3. Your emcOMNut class must announce which services it provides. If it can Read Nut objects from the DB, you must override the emcObjectManager method CanRead(emcManageable& obj) method to return true in case obj is of type Nut. Then you must override the Read method to do the actual job. Same story with Write and Collect if you need them. Even if you do nothing with them, you must override them as they are pure virtual member functions of emcObjectManager.
Also the Reset method is supposed to put the plugin in the same state as if it was newly created : you must override this one also.
Nothing is better than examples : have a look at the classes emcOMGains and emcOMPedestals to see how it was done for emcGains and emcPedestals classes.4. You make a library with your emcOMNut and Nut classes.
Whenever your library will be loaded, the DM will be aware of your ObjectManager automatically (that's the plugin mechanism!).
Note: this is the same mechanism as the one used to register Checkers in the EmCal Troubleshooter, or to register persistent classes in PHENIX PdbCal.
virtual bool CanCollect(const emcManageable& object)
virtual bool CanHandle(const emcManageable& object)
virtual bool CanWrite(const emcManageable& object)
virtual bool CanRead(const emcManageable& object)
virtual emcManageable* Collect(const emcManageable& object, const PHTimeStamp& when)
See the DM interface for parameters.
Unless allowed explicitely by a particular Object Manager,
in general the returned pointer should not be deleted by
the receiver !
virtual bool Read(emcManageable& object, const PHTimeStamp& time_stamp, int id)
See the DM interface for parameters.
virtual void Reset(void)
After a call to Reset, the OM must behave as if it was newly created.
virtual bool Write(const emcManageable& object, const PHTimeStamp& tStart, int id=-1)
Alphabetic index HTML hierarchy of classes or Java