Skip to content

Experimental data analysis

Dmytro Kresan edited this page Aug 12, 2014 · 14 revisions

General information

Data sources

Unpacking and analysis of experimental data is to be performed using an instance of the FairRunOnline class.

Multiple types of data source (remote-event-server, local LMD file, etc.) are supported by deriving from the base abstract class FairSource. Such derived objects (FairRemoteSource, FairLmdSource) have to override following member functions:

virtual Bool_t Init();      // initialisation of the source
virtual Int_t  ReadEvent(); // data parsing
virtual void   Close();     // close file, socket, etc.

The instance of a source is the parameter in the standard constructor of FairRunOnline.

Unpackers

A detector-specific unpacker (derived from the abstract class FairUnpack), parses and converts data subset from a source into ROOT objects. Unpacker has to override member functions:

public:
 virtual Bool_t Init();                            // initialisation
 virtual Bool_t DoUnpack(Int_t *data, Int_t size); // data - pointer to an MBS sub-event, size - data size in double words
 virtual void   Reset();                           // clear data structures
protected:
 virtual void   Register();                        // register data structures (using FairRootManager)

MBS parameters of a detector (type, sub-type, crate, etc.) have to be set in the call to standard constructor of the FairUnpack. Using values of these parameters, the framework takes care of matching between sub-events in the data stream and user-specified unpackers.

Unpackers, created in the macro, are to be added to the source using FairSource::AddUnpacker(FairUnpack*) member function.

Output

Data will be stored in ROOT tree with branches defined in Register() of an unpacker class:

fRawData = new TClonesArray("R3BLandRawHit");
FairRootManager* fMan = FairRootManager::Instance();
fMan->Register("LandRawHit", "Land", fRawData, kTRUE);

Using the task mechanism of FairRoot, one can perform further data analysis on the fly or in a separate macro. In the Init() member function of an analysis task one should use:

FairRootManager* fMan = FairRootManager::Instance();
fLandRawHit = (TClonesArray*)fMan->GetObject("LandRawHit");

Steering macro

1. Create data source

Reading from a local lmd-file:

FairLmdSource* source = new FairLmdSource();
source->AddFile("filename1.lmd");
source->AddFile("filename2.lmd");
...

Connecting to the remote-event-server:

FairRemoteSource* source = new FairRemoteSource("node_name");

"node_name" - name of the machine with running remote-event-server (mrevserv64)

2. Create unpacker(s) and add them to source

// NeuLAND MBS parameters -------------------------------
Short_t type = 94;
Short_t subType = 9400;
Short_t procId = 10;
Short_t subCrate = 1;
Short_t control = 3;
R3BLandUnpack *unpacker = new R3BLandUnpack("", type, subType,
                                            procId, subCrate, control);
source->AddUnpacker(unpacker);

3. Steering object and run-time database

FairRunOnline* run = new FairRunOnline(source);
run->SetOutputFile("output.root");
run->Init();
FairRuntimeDb* rtdb = run->GetRuntimeDb();
Bool_t kParameterMerged = kTRUE;
FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
parOut->open("params.root");
rtdb->setFirstInput(parOut);
rtdb->saveOutput();
rtdb->print();
Int_t nEvents = 1000;
run->Run(nEvents, 0);

In case a negative value is set in number of events, the event loop will continue until end of file is reached, or until CTRL+C interrupt is detected (e.g. when using remote-event-server as a data source).