Skip to content

Commit

Permalink
Improve FairRunOnline. Cleanup of run managers.
Browse files Browse the repository at this point in the history
1. Allow to use parameters in FairUnpackers.

Added SetParContainers() method to FairUnpack.
Separated method FairMbsSource::InitUnpackers().
Added source identification method.
Generate RunID if it was not set.

2. Unify data members of different run classes.

Use only one data member of FairEventHeader in the base class FairRun with needed getters and setters.
All derrived classes use this data member.

3. Create new class for online sources.

The last implementation assumed that all sources which need parameter containers in the unpackers are derrived
from FairMbsSource. This is not the case for many of the Sources used by CBM. Therefore an new class for online
sources was created which contain all the needed functionality. FairMbsSource is derrived from FairOnlineSource,
as well as the CBM specific source classes.

4. Avoid reading the first event in case of online source.

In case of online sources like lmd files or other raw data files the input file or input stream doesn't contain
an event header, so it doesn't make any sense to read the first event and try to extract one. The event header is
needed in case of ROOT files to extract the runID. The RunId for online files should be defined from the macro or
generated on the fly.
  • Loading branch information
kresan authored and fuhlig1 committed Apr 11, 2016
1 parent 1439e50 commit b9155f5
Show file tree
Hide file tree
Showing 20 changed files with 168 additions and 80 deletions.
1 change: 1 addition & 0 deletions base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ field/FairRKPropagator.cxx
source/FairSource.cxx
source/FairFileSource.cxx
source/FairMixedSource.cxx
source/FairOnlineSource.cxx
)

If(BUILD_MBS)
Expand Down
1 change: 1 addition & 0 deletions base/FairLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#pragma link C++ class FairSource;
#pragma link C++ class FairFileSource;
#pragma link C++ class FairMixedSource;
#pragma link C++ class FairOnlineSource;
#ifdef BUILD_MBS
#pragma link C++ class FairMbsSource;
#pragma link C++ class FairRemoteSource;
Expand Down
2 changes: 2 additions & 0 deletions base/source/FairFileSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class FairFileSource : public FairSource
void Close();
void Reset();

virtual Source_Type GetSourceType() { return kFILE; }

/**Check the maximum event number we can run to*/
virtual Int_t CheckMaxEventNo(Int_t EvtEnd=0);
/**Read the tree entry on one branch**/
Expand Down
4 changes: 0 additions & 4 deletions base/source/FairLmdSource.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ void FairLmdSource::AddPath(TString dir, TString wildCard)

Bool_t FairLmdSource::Init()
{
if(! FairMbsSource::Init()) {
return kFALSE;
}

if(fFileNames->GetSize() == 0) {
return kFALSE;
}
Expand Down
21 changes: 2 additions & 19 deletions base/source/FairMbsSource.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,12 @@
#include "FairMbsSource.h"
#include "FairLogger.h"

FairMbsSource::FairMbsSource() : FairSource(), fUnpackers(new TObjArray()) {}
FairMbsSource::FairMbsSource() : FairOnlineSource() {}

FairMbsSource::FairMbsSource(const FairMbsSource &source)
: FairSource(source), fUnpackers(new TObjArray(*(source.GetUnpackers()))) {}
: FairOnlineSource(source) {}

FairMbsSource::~FairMbsSource() {
fUnpackers->Delete();
delete fUnpackers;
}

Bool_t FairMbsSource::Init() {
for (Int_t i = 0; i < fUnpackers->GetEntriesFast(); i++) {
if (!((FairUnpack *)fUnpackers->At(i))->Init()) {
return kFALSE;
}
}
return kTRUE;
}

void FairMbsSource::Reset() {
for (Int_t i = 0; i < fUnpackers->GetEntriesFast(); i++) {
((FairUnpack *)fUnpackers->At(i))->Reset();
}
}

Bool_t FairMbsSource::Unpack(Int_t *data, Int_t size, Short_t type,
Expand Down
14 changes: 3 additions & 11 deletions base/source/FairMbsSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,28 @@
#ifndef FAIRMBSSOURCE_H
#define FAIRMBSSOURCE_H

#include "FairSource.h"
#include "FairOnlineSource.h"
#include "TObjArray.h"

#include "FairUnpack.h"


class FairMbsSource : public FairSource
class FairMbsSource : public FairOnlineSource
{
public:
FairMbsSource();
FairMbsSource(const FairMbsSource& source);
virtual ~FairMbsSource();

inline void AddUnpacker(FairUnpack* unpacker) { fUnpackers->Add(unpacker); }
inline const TObjArray* GetUnpackers() const { return fUnpackers; }

virtual Bool_t Init();
virtual Bool_t Init() = 0;
virtual Int_t ReadEvent(UInt_t=0) = 0;
virtual void Close() = 0;

void Reset();

protected:
Bool_t Unpack(Int_t* data, Int_t size,
Short_t type, Short_t subType,
Short_t procId, Short_t subCrate, Short_t control);

private:
TObjArray* fUnpackers;

ClassDef(FairMbsSource, 0)
};

Expand Down
4 changes: 0 additions & 4 deletions base/source/FairMbsStreamSource.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ FairMbsStreamSource::~FairMbsStreamSource()

Bool_t FairMbsStreamSource::Init()
{
if(! FairMbsSource::Init()) {
return kFALSE;
}

if(! ConnectToServer()) {
return kFALSE;
}
Expand Down
2 changes: 2 additions & 0 deletions base/source/FairMixedSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class FairMixedSource : public FairSource
void Close();
void Reset();

virtual Source_Type GetSourceType() { return kFILE; }

/**Check the maximum event number we can run to*/
virtual Int_t CheckMaxEventNo(Int_t EvtEnd=0);
/**Read the tree entry on one branch**/
Expand Down
52 changes: 52 additions & 0 deletions base/source/FairOnlineSource.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/********************************************************************************
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
// -----------------------------------------------------------------------------
// ----- -----
// ----- FairOnlineSource -----
// ----- Created 12.04.2013 by D.Kresan -----
// ----- Copied from FairSource 01.11.2013 by F.Uhlig -----
// ----- -----
// -----------------------------------------------------------------------------

#include <iostream>

#include "FairOnlineSource.h"
#include "FairLogger.h"

FairOnlineSource::FairOnlineSource() : FairSource(), fUnpackers(new TObjArray()) {}

FairOnlineSource::FairOnlineSource(const FairOnlineSource &source)
: FairSource(source), fUnpackers(new TObjArray(*(source.GetUnpackers()))) {}

FairOnlineSource::~FairOnlineSource() {
fUnpackers->Delete();
delete fUnpackers;
}

Bool_t FairOnlineSource::InitUnpackers() {
for (Int_t i = 0; i < fUnpackers->GetEntriesFast(); i++) {
if (!((FairUnpack *)fUnpackers->At(i))->Init()) {
return kFALSE;
}
}
return kTRUE;
}

void FairOnlineSource::SetParUnpackers() {
for (Int_t i = 0; i < fUnpackers->GetEntriesFast(); i++) {
((FairUnpack *)fUnpackers->At(i))->SetParContainers();
}
}

void FairOnlineSource::Reset() {
for (Int_t i = 0; i < fUnpackers->GetEntriesFast(); i++) {
((FairUnpack *)fUnpackers->At(i))->Reset();
}
}

ClassImp(FairOnlineSource)
55 changes: 55 additions & 0 deletions base/source/FairOnlineSource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/********************************************************************************
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
// -----------------------------------------------------------------------------
// ----- -----
// ----- FairMbsSource -----
// ----- Created 12.04.2013 by D.Kresan -----
// ----- Copied from FairSource 01.11.2013 by F.Uhlig -----
// ----- -----
// -----------------------------------------------------------------------------

#ifndef FAIRONLINESOURCE_H
#define FAIRONLINESOURCE_H

#include "FairSource.h"
#include "TObjArray.h"

#include "FairUnpack.h"


class FairOnlineSource : public FairSource
{
public:
FairOnlineSource();
FairOnlineSource(const FairOnlineSource& source);
virtual ~FairOnlineSource();

inline void AddUnpacker(FairUnpack* unpacker) { fUnpackers->Add(unpacker); }
inline const TObjArray* GetUnpackers() const { return fUnpackers; }

virtual Bool_t Init() = 0;
virtual Int_t ReadEvent(UInt_t=0) = 0;
virtual void Close() = 0;

void SetParUnpackers();

Bool_t InitUnpackers();

void Reset();

virtual Source_Type GetSourceType() { return kONLINE; }

protected:
TObjArray* fUnpackers;

private:
ClassDef(FairOnlineSource, 0)
};


#endif
4 changes: 0 additions & 4 deletions base/source/FairRemoteSource.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ FairRemoteSource::~FairRemoteSource()

Bool_t FairRemoteSource::Init()
{
if(! FairMbsSource::Init()) {
return kFALSE;
}

fBuffer->RevStatus(0);
fSocket = fBuffer->RevOpen(fNode, 6003, 0);
fBuffer->RevStatus(0);
Expand Down
6 changes: 5 additions & 1 deletion base/source/FairSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

class FairEventHeader;

enum Source_Type {kONLINE, kFILE};

class FairSource : public TObject
{
public:
Expand All @@ -33,7 +35,9 @@ class FairSource : public TObject
virtual void Close() = 0;

virtual void Reset() = 0;


virtual Source_Type GetSourceType() = 0;

virtual Bool_t ActivateObject(TObject** obj, const char* ObjType) { return kFALSE; }

/**Check the maximum event number we can run to*/
Expand Down
1 change: 1 addition & 0 deletions base/source/FairUnpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class FairUnpack : public TObject
virtual Bool_t Init() = 0;
virtual Bool_t DoUnpack(Int_t* data, Int_t size) = 0;
virtual void Reset() = 0;
virtual void SetParContainers() { };

inline Short_t GetType() const { return fType; }
inline Short_t GetSubType() const { return fSubType; }
Expand Down
12 changes: 6 additions & 6 deletions base/steer/FairRun.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ FairRun::FairRun(Bool_t isMaster)
fOutFile(0),
fRunId(0),
fAna(kFALSE),
fEvHead(NULL),
fEvtHeader(NULL),
fFileHeader(new FairFileHeader()),
fGenerateRunInfo(kFALSE),
fIsMaster(isMaster)
Expand Down Expand Up @@ -75,8 +75,8 @@ FairRun::~FairRun()
delete fRootManager; // who is responsible
fRootManager=0;
}
if (fEvHead) {
delete fEvHead;
if (fEvtHeader) {
delete fEvtHeader;
}
LOG(DEBUG) << "Leave Destructor of FairRun" << FairLogger::endl;
}
Expand Down Expand Up @@ -132,10 +132,10 @@ FairTask* FairRun::GetTask(const char* taskName)
//_____________________________________________________________________________
FairEventHeader* FairRun::GetEventHeader()
{
if ( NULL == fEvHead ) {
fEvHead = new FairEventHeader();
if ( NULL == fEvtHeader ) {
fEvtHeader = new FairEventHeader();
}
return fEvHead;
return fEvtHeader;
}

void FairRun::SetUseFairLinks(Bool_t val)
Expand Down
6 changes: 3 additions & 3 deletions base/steer/FairRun.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class FairRun : public TNamed
* for each run
*/
void SetEventHeader(FairEventHeader* EvHeader) {
fEvHead=EvHeader;
fEvtHeader=EvHeader;
}
/**
* return a pointer to the RuntimeDB
Expand Down Expand Up @@ -180,14 +180,14 @@ class FairRun : public TNamed
/** true for Anaylsis session*/
Bool_t fAna; //!
/** MC Event Header */
FairEventHeader* fEvHead; //!
FairEventHeader* fEvtHeader; //!
/** File Header */
FairFileHeader* fFileHeader;
/** true if RunInfo file should be written*/
Bool_t fGenerateRunInfo; //!
/** true if on master*/
Bool_t fIsMaster; //!

ClassDef(FairRun ,2)
ClassDef(FairRun ,3)
};
#endif //FAIRRUN_H
4 changes: 2 additions & 2 deletions base/steer/FairRunAna.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ FairRunAna::FairRunAna()
fIsInitialized(kFALSE),
fInputGeoFile(0),
fLoadGeo( kFALSE),
fEvtHeader(0),
fStatic(kFALSE),
fField(0),
fTimeStamps(kFALSE),
Expand Down Expand Up @@ -228,7 +227,8 @@ void FairRunAna::Init()
LOG(INFO) << "Parameter and input file are available, Assure that basic info is there for the run!" << FairLogger::endl;
fRootManager->ReadEvent(0);

fEvtHeader = GetEventHeader();
// fEvtHeader = GetEventHeader();
GetEventHeader();

fRootManager->FillEventHeader(fEvtHeader);

Expand Down
4 changes: 1 addition & 3 deletions base/steer/FairRunAna.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "Rtypes.h" // for Bool_t, Double_t, UInt_t, etc
#include "TString.h" // for TString

class FairEventHeader;
class FairField;
class TF1;
class TFile;
Expand Down Expand Up @@ -181,7 +180,6 @@ class FairRunAna : public FairRun
TFile* fInputGeoFile;
static FairRunAna* fgRinstance;
Bool_t fLoadGeo;
FairEventHeader* fEvtHeader;//!
/** true for static initialisation of parameters */
Bool_t fStatic;//!
FairField* fField;
Expand All @@ -205,7 +203,7 @@ class FairRunAna : public FairRun
/** Temporary member to preserve old functionality without setting source in macro */
FairMixedSource* fMixedSource; //!

ClassDef(FairRunAna ,5)
ClassDef(FairRunAna ,6)

};

Expand Down
Loading

0 comments on commit b9155f5

Please sign in to comment.