Page History
...
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
Code Block |
---|
StoreManagerHManager *sManagerhMan = new RootStoreManagerRootHist("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
Code Block |
---|
Tuple *nt = sManagerhMan->ntuple("EXP Data"); |
and histograms
Code Block |
---|
H1 *pHis1i = hMan->his1i("His1 int title",100,0.,1.); H1 *pHis1pHis1f = sManagerhMan->his1>his1f("His1 float Title title",100,0.,1.); H1 *pHis1d = hMan->his1d("His1 double title",100,0.,1.); H2 *pHis2pHis2d = sManagerhMan->his2>his2d("His2 Titledouble title",100,0.,1.,100,0.,1.); |
When the ntuple is created, its parameters need to be defined once,
Code Block |
---|
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 ,using pointers
Code Block |
---|
pBeamEnergy ->fill(E); pBeamCurrent->fill(I); nt ->addColumn>addRow(); |
or parameter names
Code Block |
---|
nt pHis1 ->fill("beamEnergy", E); nt ->fill("beamCurrent", I); nt ->addRow(); |
Histograms can be accumulated using their pointers
Code Block |
---|
pHis1i ->fill(x,[weight]); ... pHis2 ->fill(x,y,[weight]); |
where we assume thap that all parameters like x
, y
, E
, and I
and optional weight
were earlier defined.
When you are all done, write the data into a file:
Code Block |
---|
sManagerhMan->write(); delete sManagerhMan; |
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.
...
Histogramming in BABAR
Code Block |
---|
#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();
|
Histogramming in CLEO
Histograms
Declare Histogram in your .h file
Code Block |
---|
#include "HistogramInterface/HistogramPackage.h’’
...
HIHist1D *m_trackMom;
|
Define Histogram in your Processor
Code Block |
---|
m_trackMom = iHistoManager.histogram("track momentum (GeV)",50, 0, 1.5);
|
Fill Histogram in event() method of your Processor
Code Block |
---|
m_trackMom->fill(momentum); |
Load Conversion Module in .tcl script
Code Block |
---|
module sel RootHistogramModule
root file root_suez_style_example_data31.root
root init
|
NTuple
Declare Ntuple in your Processor’s .h file
Code Block |
---|
#include "HistogramInterface/HistogramPackage.h’’ #include ‘‘HistogramInterface/HINtupleVarNames.h’’ ... HINtuple *m_trackTuple; |
Make an enum of variable names
Code Block |
---|
enum{kpx, kpy, kpz, kd0, kz0, knum_vars}; |
Define Ntuple in hist_book()
// make an object that holds the names of the variables in your ntuple
Code Block |
---|
HINtupleVarNames knames(knum_vars);
knames.addVar(kpx,"px");
knames.addVar(kpy,"py");
knames.addVar(kpz,"pz");
knames.addVar(kd0,"d0");
knames.addVar(kz0,"z0");
m_trackTuple = iHistoManager.ntuple(1,"tracktuple",knum_vars,50000,knames.names());
|
Fill Ntuple in event() method
Code Block |
---|
trackTuple[kpx] = px;
trackTuple[kpy] = py;
trackTuple[kpz] = pz;
trackTuple[kd0] = d0;
trackTuple[kz0] = z0;
m_trackTuple->fill(trackTuple);
|