Access to detector components in Phat

Introduction

Macros:

To extract detector components from Oracle
To initialize detector from ROOT files extracted from Oracle

Details:

Accessing detector components in Oracle
Accesing detector components in ROOT files

TPhDetCompHandler - general access class

Initialization of the user environment
Setting the run number information
Deciding on the type of the source
Deciding on the mode of access
Unavailability of some methods to handle detector components
Current availability of detector components in Oracle
Current availability of detector components in ROOT files
The order in construction of the TPhDetector component objects


-----------------------------------------------------------------------

Introduction:

Detector components are objects describing the detector setup and its current properties. Depending on the type of processing performed in Phat, one or several of them needs first to be initialized before processing can be started.

Currently the following detector components exist:

  1. Sensor geometry
  2. Map of electronics connections to sensor pads
  3. Raw data properties - pedestals, noise in electronics channels
  4. Gain calibration in electronics channels
  5. Mercury hardware parameter settings
  6. Map of magnetic field

The pointers to detector component objects are stored inside the singleton TPhDetector object. Using them is the primary way to access these objects from any place in Phat. After the component objects has been created they are stored permanently on a disk for future reference. In Phobos it has been decided to store detector structure and properties information in the remote Oracle database. As a backup secondary storage, ROOT files can be created to allow making calculations in Phat on computers without network connection or in case the Oracle database is down.  

- Oracle database - 
access to detector components

The following detector components can be found in the Oracle database.

  1. Map of sensor pad to electronic channels connections.
  2. Pedestals and noise properties of the electronic channels
  3. Gain calibration values for all the electronic channels

 

  - ROOT files - 
access to detector components

Reading/writing of detector components to ROOT files can be done with a help of functions that can be found in the TPhDetector class. The set of functions is comprehensive enough to allow separate loading and saving of different components of the detector. If no file paths are given, files will be read from/written to $PHATHOME/init directory under some standard names and with standard key names.
 

- Generic access - 
the TPhDetCompHandler class

In addition to the specific interfaces, a class named TPhDetCompHandler has been developed to make it easier for a user to collect all information of various detector components from different places according to the user defined environment stored in a single definition file.

In the following I will describe use of the TPhDetCompHandler interface functions. In the future, calls to this class may be isolated into a separate initialization module.

Initialization of the user environment:

First element used by this class is a central environment setting macro. It is stored in $PHATHOME/init directory in file called Phat_env.C. In this macro some global variables, like "PHATHOME", "ORACLE_HOME", remote Oracle server name ("phdb"), global name of the remote directory where root files will be stored, ("RemoteRootFileDirectory") can be (re)defined as well as the names and paths of all the specific detector component elements. If they are not defined in this file then some defaults are used. The defaults are also described in the Phat_env.C file provided together with Phat distribution. When the object of this class is created, the Phat_env.C is executed and user environment is setup. It is possible later to change some or all of the settings by calling one more time the initialization function with a different file name, like:
det_comp->InitPhatEnvironment("envfilepath");

Setting the run number information

Before program can look for the run specific components, the run number must be set in the TPhDetCompHandler object:
det_comp->SetNRun(1600);

Deciding on the type of the source

There are three places where the detector components can be handled using this class:

  1. Local ROOT file in $PHATHOME/init directory
  2. Remote Oracle database
  3. Remote directory(ies) with ROOT files

Parallel to the three different places, there are three types of functions used to access information. For example to readin electronic map of sensor pad connections one can call:

Similarly there are three types of functions that store information on detector components into three different places.

Deciding on the mode of access

In addition to functions accessing info in specific way, there is also a set of general functions, one for each type of the detector component, that allows to read from the currently available source, as defined in the Phat_env.C file and according to the way the additonal switch called SearchMode is set in the class.
The use of these general functions is recommended, since they are able to intelligently sense the presence of the Oracle support in the version of Phat used and avoid crashes due to calls to nonexistent code. The following three modes are available:

  1. TPhDetCompHandler::ESearchMode kAutoSwitchMode
  2. TPhDetCompHandler::ESearchMode kOracleDBMode
  3. TPhDetCompHandler::ESearchMode kRootFilesMode

The later two modes behave according to their name meaning. The first, auto-switch mode, detects status of the availability of Oracle in Phat and goes either to Oracle or to the ROOT files directory for the detector component information, with the preference to Oracle. In the future it is planned that failure to access Oracle database will also result in switching to ROOT file source.

Use of these general functions is simple. First one sets the mode, by calling:
This could be done once, at the beginning of the macro. Later calls to read/write detector information can be issued for the given run number. After changing run number, detector components for a new run will be retrieved.

Unavailability of some methods to handle detector components

There are interfaces in Phat that make it possible to write/read to/from both types of storage, however Oracle database can now provide only the map of electronics connections to sensor pads, pedestals, and gain calibration. In TPhDetCompHandler all function are implemented for future compatibility, however those that have no underlying Oracle implementation will return a warning instead of the object info. These methods are:

Availability of detector components in Oracle

As of 11/29/99:

Current availability of detector components in ROOT files

As of 11/29/99:

The order in construction of the TPhDetector component objects

Some of the components can not be installed before some others has not been constructed yet. Also checking the compatibility between some components is not yet in a final shape and may work better if the correct order of initialization is kept. The recommended way to build detector components is to:

 

How to use macro extracting detector components from Oracle

  1. Copy file $PHATHOME/macros/phatdet/ora_extract.C to your working directory, or make sure it is in your macros path.
  2. Use Phat version compiled with Oracle support

  3. it has it compiled in if at Phat prompt:
    .class TPhDatabase
    produces a listing of the class' members
  4. Use computer with network connection to the Phobos database server

  5. check it with command:
    ping phobosdb.chm.bnl.gov (^C to stop)
  6. Edit file $PHATHOME/init/Phat_env.C with definitions of directories and file names that the detector components will be written to.

  7. The simplest is to comment out everything except RemoteRootFileDirectory definition.
  8. At Phat prompt (root [0]) type

  9. .x ora_extract.C(1700,1710)
    where (1700,1710) is a range of run numbers to extract detector components for.
  10. Ignore warnings and comments that will eventually show on the screen. If something is not available in the Oracle database at present, it will not be written to the file.

To initialize detector from ROOT files extracted from Oracle

In your macro, or at Phat prompt you may include a call to a detector initializing macro.

  1. Macro called det_init_from_files.C should be copied to your working directory, or you should make sure it is on your macros path.
  2. Definitions in your $PHATHOME/init/Phat_env.C file should point to the directories where extracted ROOT files reside.
  3. At Phat prompt call:

  4. gROOT->LoadMacro("det_init_from_files.C");
    det_init_from_files(1712);
    TPhDetector *det = TPhDetector::GetInstance();
    where, 1712 is the number of the run that you want to have your detector initialized for.
  5. Now, det should point to an initialized TPhDetector object.
  6. If some information is not found in the files, or a compatibility check fails, a warning is issued. It says that a compatible part of the detector could not be found in the files.

andrzej.olszewski@ifj.edu.pl