180 likes | 341 Views
Use of Gaudi in Reconstruction. Weidong Li 23/06/2004. Video Lectures. Video Lectures in my machine: IP address: 202.122.35.59 Gaudi Tutorials GaudiAthena AthenaRec C++ Tutorial C++ training Software Engineering Software training. Reconstruction Dataflow. MDC digits. MDC digits.
E N D
Use of Gaudi in Reconstruction Weidong Li 23/06/2004
Video Lectures • Video Lectures in my machine: • IP address: 202.122.35.59 • Gaudi Tutorials • GaudiAthena • AthenaRec • C++ Tutorial • C++ training • Software Engineering • Software training
Reconstruction Dataflow MDC digits MDC digits Transient Event Data Store MDC Tracking Tracks Tracks Calorimeter Digits Calorimeter Clustering Calorimeter showers Showers Tracks, Showers Electron/photon Identification Apparent dataflow Electron/photon Real dataflow Electrons/photons
ISvcLocator ApplicationMgr IDataProviderSvc IProperty IAlgorithm EventDataSvc Concrete Algorithm IDataProviderSvc DetectorDataSvc IHistogramSvc HistogramSvc Obj_A Obj_B MessageSvc IMessageSvc IParticlePropertySvc ParticlePropertySvc Algorithm • Users write concrete Algorithms derived from base class Algorithm • Implements - at least - three methods in addition to the constructor and destructor • initialize(), execute(), finalize() • execute is called once per physics event
Algorithm’s Properties • Algorithm’s properties can be declared in the constructor: MdcHough::MdcHough(const std::string& name, ISvcLocator* pSvcLocator) : Algorithm(name, pSvcLocator) { // Declare the properties declareProperty("FittingMethod", m_fittingMethod = 2); declareProperty("ConfigFile", m_configFile = "MDCConfig.xml"); } • Algorithm’s properties are configured through jobOption file: MdcHough. FittingMethod = 3; MdcHough. ConfigFile = "MDCConfig.xml";
Accessing Services • Within the Algorithm services are readily accessible. • The most common are: • msgSvc( ) [or messageService( )] • eventSvc( ) [or eventDataService( )] • histoSvc( ) [or histogramDataService( )] • ntupleSvc( ) [or ntupleService( )] • detSvc( ) [or detDataService( )] • service<T>(…) generalized access to Services • serviceLocator( ) • Other registered services are accessible once their header file is included in the Algorithm
Retrieving Event Data (1) StatusCode MdcHough::execute() { // Part 1: Get the event header, print out event and run number SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event"); if (!eventHeader) { log << MSG::FATAL << "Could not find Event Header" << endreq; return( StatusCode::FAILURE); } //Part 2: Print out MDC digi SmartDataPtr<MdcDigiCol> mdcDigiCol(eventSvc(),"/Event/Digi/MdcDigiCol"); OR DataObject * mdcDigiCol; StatusCode sc = eventSvc()->retrieveObject("/Event/Digi/MdcDigiCol“, mdcDigiCol);
Retrieving Event Data (2) if (!mdcDigiCol) { log << MSG::FATAL << "Could not find event" << endreq; return( StatusCode::FAILURE); } MdcDigiCol::iterator iter = mdcDigiCol->begin(); for (;iter != mdcDigiCol->end(); iter++, digiId++) { } return StatusCode::SUCCESS; }
Data Service (3) Request load (2) Search in Store PersistencyService Request dispatcherObjy, ROOT,.. (5) Register Conversion Service (4) Request creation Data Store Converter Converter Converter Converter Loading from Data Store Unsuccessful ifrequested object is not present Algorithm (1) Retrieve object
Storing Data Object MdcDigiCol * mdcDigiCol = new MdcDigiCol(); StatusCode sc = eventSvc()-> registerObject("/Event/Digi/MdcDigiCol“, mdcDigiCol);
Service IMdcGeomSvc.h class IMdcGeomSvc : virtual public IInterface { public: virtual const MdcGeoWire * const Wire(unsigned id) = 0; virtual const MdcGeoLayer * const Layer(unsigned id) = 0; virtual const MdcGeoSuper * const SuperLayer(unsigned id) = 0; virtual void Dump() = 0; }; ClientAlgoritm.cpp #include “MDCGeomSvc/IMdcGeomSvc.h” ClientAlgotihm::myMethod() { IMdcGeomSvc* mdcGeomSvc; service(“MdcGeomSvc”, mdcGeomSvc ); mdcGeomSvc -> Dump(); }
Patterns for libraries • Helper packages These packages create a shared library that is designed to be linked against. library XxxCode <list of files> apply_pattern installed_library Orapply_pattern installed_library =*.cxx • Algorithm and Service packages a) component_library - for simple component libraries b) dual_use_library - for Algorithms or Services that are capable of being inherited from. • A package that uses the dual_use_library pattern creates two separate shared libraries • libXxxAlgs.so which contains the component factories and needs to be setup at run-time in the job options file, and • libXxxAlgsLib.so which is a linkable shared library containing the component code which allows inheritance.
Component Library <PackageName>_entries.cxx #include “GaudiKernel/DeclareFactoryEntries.h” DECLARE_FACTORY_ENTRIES ( <PackageName> ) { DECLARE_ALGORITH( MyAlgorithm ) DECLARE_SERVICE( MyService ) } Your components need to be added here <PackageName>_load.cxx #include “GaudiKernel/LoadFactoryEntries.h” LOAD_FACTORY_ENTRIES ( <PackageName> ) Substitute with your package name
Set CVSROOT setenv CVSROOT :pserver:liwd@koala.ihep.ac.cn:/bes/bes Setup CMT source /bes/tool/CMT/v1r14p20031120/mgr/setup.csh Set CVSIGNORE setenv CVSIGNORE 'setup.* cleanup.* *.make Makefile Linux* *~' # set the SITEROOT set SITEROOT "/bes/sw/boss" # set the offset in cvs repository set CMTCVSOFFSET "BossCvs" # Setup the CMT search path for work area, distribution area and Gaudi area macro WorkArea "${HOME}/work" macro home_dir "${HOME}" path_remove CMTPATH "${home_dir}" path_prepend CMTPATH "$(WorkArea)" Setup Environment /home/liwd/setupCVS.csh /home/liwd/setupCMT.csh /home/liwd/BossEnv/requirements
// Event Persistency Service and Conversion Service ApplicationMgr.DLLs += {"AsciiFileCnv"}; ApplicationMgr.ExtSvc += { "EvtPersistencySvc/EventPersistencySvc" }; ApplicationMgr.ExtSvc += { "AsciiFileCnvSvc","AsciiFileEventSelector/EventSelector"}; EventPersistencySvc.CnvServices = { "AsciiFileCnvSvc" }; // Reconstruction Algorithm and Geometry Service ApplicationMgr.DLLs += {"MdcDummyAlg", "MdcGeomSvc"}; ApplicationMgr.TopAlg = { "MdcDummy" }; ApplicationMgr.ExtSvc += { "MdcGeomSvc" }; MessageSvc.OutputLevel = 2; ApplicationMgr.EvtMax = 2; Job Options /home/liwd/work/TestRelease/TestRelease-00-00-01/run/jobOptions_MDCHough.txt /home/liwd/work/TestRelease/TestRelease-00-00-01/run/Ascii.txt
Running Job (1) • Get TestRelease • cmt co TestRelease • Modify TestRelease requirements file to list the packages being checked out emacs TestRelease/<release-version>/cmt/requirements & And add this line to the requirements file use MdcDummyAlg MdcDummyAlg-* Reconstruction /home/liwd/work/TestRelease/TestRelease-00-00-01/requirements
Running Job (2) • Building MdcDummyAlg • cd TestRelease/<version>/cmt • source setup.sh • cmt broadcast cmt config • cmt broadcast gmake • From /run directory • boss.exe jobOptions_MdcDummy.txt