Project

General

Profile

Exercise 8

  1. Example code
    1. art -c Ex08/ex08.fcl It only runs one event.
  2. Activities
    1. Inspect the printout and relate it to the classes:
    1. $ART_WORKBOOK_BASE_INC/artwb/Geometry/Geometry.h # $ART_WORKBOOK_BASE_INC/artwb/Geometry/Tracker.h # $ART_WORKBOOK_BASE_INC/artwb/Geometry/Shell.h # Also relate it to the file that defines the geometry: $ART_WORKBOOK_BASE_DIR/databaseFiles/geom01.fcl
    1. In a mature, real experiment this information would live in a data base, not a file but we don't need that complexity for illustration purposes. # This file is written in fhicl and is parsed by $ART_WORKBOOK_BASE_DIR/source/artwb/Geometry/Geometry_service.cc
  3. Ideas
    1. Big picture: The Geometry service is user written code that should know about the intervals of validity of geometry information. should recognize boundaries of validity intervals and update information as boundaries are crossed. The end user (module code) just asks the geometry service for information and does not need to be aware of the behind the scenes word that ensures validity. This is all a per-experiment responisbility, not an art responsibility. # In the code used for this example, the Geometry service assumes that all information is valid from the start of the first beginRun call until the end of the job. That is enough to illustrate the big ideas without getting bogged down in details. # The idea of a user written service; in this case the geometry service. # A user written service is just a C++ class that obeys some conventions defined by art. # A service may arrange to be called at the start of each run, at the start of each event, before any module is called and at many other times. The details are different than for a module but the big picture is much the same. # A module gets access to a service by asking art to give it a ServiceHandle to the requested service. A ServiceHandle is a form of smart pointer. # We need to distinguish two notions of validity. A ServiceHandle may be valid in the sense that it points to a properly instantiated service object. But a service may be invalid internally. For example the geometry may be run dependent so it may not legal to ask the Geometry service for information when no run is current; but it is still legal to ask the framework for a ServiceHandle to the Geometry Service. The validity of the insides of a service is an experiment dependent idea. Whether or not the ServiceHandle is valid is an art idea. # The service handle is guaranteed to be valid before the constructor of any module is called. It is guaranteed to remain valid until after the calls to each module's endJob method. (It may even be valid during the call to the d'tor ?). # It is moderately expensive to get a service handle since it involves traversing an std::map whose key is a long string. # Therefore we typically get service handles in the c'tor and hold them as member data; we may use them anywhere within the module code. # We always need to be aware when the internals of the service as valid; a well written service will issue an error if someone asks for invalid information; but this is an experiment concern, not an art concern. # The header for Service Handle is at: $ART_INC/art/Framework/Services/Registry/ServiceHandle.h # The header for the Geometry class is at $ART_WORKBOOK_BASE_INC/artwb/Geometry/Geometry.h # This file tells you what information is available from the service. For this example, the information does not change as a function of run number but it is not defined until the first run is encountered. So module code may use it in their beginRun, beginSubRun and analyze methods. They may not use it in their constructors or beginJob methods ( even though the service handle is valid at those times ).
      itself lives in $ART_WORKBOOK_BASE_LIB/libartwb_Geometry_Geometry_service.so. # To use the service we had to: # Add two lines to the link list in CMakeLists.txt # Provide a parameter set for the Service in the .fcl file. # In the fcl file, the services parameter has a sub parameter set named user. This is an art convention that mocks up namespaces. The parameter sets to initialize the art supplied services must live in the services parameter set but outside the user block; those for user defined services must live inside the user block. # In geom01.fcl the sigma parameters are ignored. They have been superseded by those in the Conditions service; they will be removed in the next release.