Difference: FAQCondDB (9 vs. 10)

Revision 102006-02-09 - MarcoClemencicSecondary

Line: 1 to 1
 

Frequently Asked Questions about the Conditions Database

This FAQ presents answers to questions regarding the functionnalities and usage of the Conditions Database and the Condition management framework of LHCb. We hope it to be as up to date as possible, as the CondDB project is presently in a strong mutation phase. Do not hesitate to contact me if your question is not answered below.

Line: 48 to 48
 

Using the Conditions

Added:
>
>
  • Where do I find examples? In the LHCb package Ex/DetCondExample. A good idea is to start from the two files ExampleAlg.h and ExampleAlg.cpp. They are a good example of how one can use conditions and the Update Manager Service from a GaudiAlgorithm (or a GaudiTool).
 
  • How do I use the conditions ?
    Actually only the users can answer to this questions. When you ask to the detector data store a condition, you will get a pointer to a Condition object which is essentially a ParamValidDataObject. You can access the informations inside a Condition object using the paramAs* methods.
    An example (from an algorithm):

Changed:
<
<
SmartDataPtr myCond(detSvc(),"/dd/Conditions/MyDetector/SlowControlCondition"); double crate1Temp = myCond->paramAsDouble("Crate1Temperature");
>
>
Condition* myCond = getDet("/dd/Conditions/Environment/MyDet/Crate1"); double crate1Temp = myCond->param("Crate1Temperature");
 
Changed:
<
<
  • How to register a condition to the Update Manager ?
>
>
  • How to register for a condition to the Update Manager Service?
  The UpdateManagerSvc is a service (of course) that notifies objects of changes in conditions.
An object (Algorithm, Tool... anything) has only to tell the UpdateManagerSvc which method to call when which condition changes. Each object may have many methods that have to be called when conditions change and each mathod can depend on many conditions. It is also possible to tell the UpdateManagerSvc that you want a condition to be always up-to-date, but you do not need a method to be called.
In some cases, it can be useful to be notified when an object, which depends on a condition, has been updated. For those cases it's enough that the object has already been register to the UpdateManagerSvc.
Changed:
<
<
An example.
Assume that your algorithm MyAlg features the methods:
StatusCode MyAlg::method1();
StatusCode MyAlg::method2();
StatusCode MyAlg::method3();
   
Your initialize method should look like:
StatusCode MyAlg::initialize() {

  // ... some stuff ...

  IUpdateManagerSvc *ums;
  sc = serviceLocator()->service("UpdateManagerSvc",ums,true);

  // call method1 when MyCond1 is updated
  ums->registerCondition(this,"/dd/Conditions/MyCond1",&MyAlg::method1);

  // call method2 when MyCond2 and MyCond3 are updated
  ums->registerCondition(this,"/dd/Conditions/MyCond2",&MyAlg::method2);
  ums->registerCondition(this,"/dd/Conditions/MyCond3",&MyAlg::method2);

  // just to be sure that MyCond4 is always up-to-date
  ums->registerCondition(this,"/dd/Conditions/MyCond4",NULL);

  // I have a pointer to an object:
  // ThatClass *m_thatObject
  // and I want that method3 is called when it is updated
  ums->registerCondition(this,m_thatObject,&MyAlg::method3);

  // Algorithms do not need this, but other objects (Tools) do
  // Force an update now.
  ums->update(this);

  // I do not need anymore the pointer to the UpdateManagerSvc
  ums->release();

  // ... other stuff ...

}
   
>
>
An example is in ExampleAlg.h and ExampleAlg.cpp.
 
  • How do I make a condition value available to other running algorithms ?
    Conditions are always available to all agorithms since they are in the detector data store. If you want to create your own Condition objects and allow other algorithms to access them, you just have to register the new conditions to the detector data service.
    If you want to change the numbers inside a Condition object and you want to trigger an update of all the objects depending on that condition, you can use the invalidate method of UpdateManageSvc.
    Usual example:

Changed:
<
<
SmartDataPtr myCond(detSvc(),"/dd/Conditions/MyCondition"); myCond->addParam("Pressure1","double","comment","10",(double)10);

IUpdateManagerSvc *ums; sc = serviceLocator()->service("UpdateManagerSvc",ums,true);

>
>
Condition* myCond = getDet("/dd/Conditions/Environment/MyDet/Crate1"); myCond->addParam("Pressure1",1024,"comment");
 
Changed:
<
<
ums->invalidate(myCond.ptr());
>
>
updMgrSvc()->invalidate(myCond);
  // if you don't want to wait for the next event before the update...
Changed:
<
<
ums->newEvent();

ums->release();

>
>
updMgrSvc()->newEvent();
 

Line: 128 to 86
  -- MarcoClemencic - 03 May 2005
Added:
>
>
-- MarcoClemencic - 09 Feb 2006
 
META FILEATTACHMENT attr="" comment="Identification of a conditions in the database" date="1114766166" name="conditions.png" path="conditions.png" size="13726" user="ngilardi" version="1.1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback