You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Abstract

We discuss a PSTuple package, which is intended for creation, accumulation and storage of histograms and tuples in psana project.

Objectives

In psana project we need in package which allows to accumulate data in form of histograms and tuples and save them in file for further analysis. Though it might be based on well-known underlying packages like HBOOK, ROOT, or HippoTuple , we prefer to use an uniform interface with abstract base class, substituting the direct interaction with underlying methods. This intermediate abstract layer provides a flexibility in implementation of new things, for example multithreding in analysis, which algorithm is not yet defined.

Interface

An example of the program interface for this histogram-tuple-management package can be presented as follows. First, the underlying (derived) package needs to be choisen and instantiated. For example for ROOT

      StoreManager *sManager = new RootStoreManager("my-data-file.root"); // for ROOT

Then later in the program we may create ntuple(s) without knowing what is the underlying histogram-tuple-storage management system

      Tuple *nt = sManager->ntuple("EXP Data");

and histograms

      H1 *pHis1 = sManager->his1("His1 Title",100,0.,1.);
      H2 *pHis2 = sManager->his2("His2 Title",100,0.,1.,100,0.,1.);

When the ntuple is created, its parameters need to be defined once,

      TuplePar *pBeamEnergy  = nt->parameter("beamEnergy");  // minValue, maxValue, dtype ?
      TuplePar *pBeamCurrent = nt->parameter("beamCurrent");

Then, in data processing stage, for example for each event, we may accumulate data in created histogram and ntuple objects,

      pBeamEnergy ->fill(E);
      pBeamCurrent->fill(I);
      nt          ->addColumn();

      pHis1      ->fill(x,[weight]);
      pHis2      ->fill(x,y,[weight]);

where we assume thap all parameters like x, y, E, and optional weight were earlier defined.

When you are all done, write the data into a file:

      sManager->write();
      delete sManager;

Structure and content of the package

Package PSTuple contains the base abstract class and methods, which have to be implemented in derived classes for HBOOK, ROOT, HippoTuple, etc., i.e. in packages HBookTuple, RootTuple, HippoTuple, etc.

Example from BABAR

#include "HepTuple/Histogram.h"
#include "HepTuple/TupleManager.h"

    HepTupleManager* manager = gblEnv->getGen()->ntupleManager();

    HepTuple *_ntuple = manager->ntuple("file-name.root");

   _ntuple->column("run",   eventID->run(), -99, "Event" );
   _ntuple->column("event", eventCounter,   -99, "Event" );

   _ntuple->dumpData(); 
  • No labels