CbmRoot
CbmDigitizationSource Class Reference

Source class for the input to digitization in CBM. More...

#include <CbmDigitizationSource.h>

Inheritance diagram for CbmDigitizationSource:
[legend]
Collaboration diagram for CbmDigitizationSource:
[legend]

Public Member Functions

 CbmDigitizationSource ()
 Constructor. More...
 
virtual ~CbmDigitizationSource ()
 Destructor. More...
 
virtual Bool_t ActivateObject (TObject **object, const char *branchName)
 Activate a branch and set its address. More...
 
void AddInput (UInt_t inputId, TChain *chain, Double_t rate, ECbmTreeAccess mode=ECbmTreeAccess::kRegular)
 Add a transport input. More...
 
virtual Int_t CheckMaxEventNo (Int_t lastEntry=0)
 Maximal entry number the source can run to. More...
 
virtual void Close ()
 Abstract in base class. No implementation here. More...
 
void EmbedInput (UInt_t inputId, TChain *chain, UInt_t targetInputId, ECbmTreeAccess mode=ECbmTreeAccess::kRegular)
 Embed a transport input. More...
 
virtual void FillEventHeader (FairEventHeader *event)
 Fill the output event header. More...
 
const std::set< TString > & GetBranchList () const
 List of branch names @value Reference to set of branch names. More...
 
CbmMCInputGetFirstInput ()
 First input from the first input set @value Pointer to first input. More...
 
virtual Source_Type GetSourceType ()
 Source type is kFILE. More...
 
virtual Bool_t Init ()
 Abstract in base class. No implementation here. More...
 
virtual Bool_t InitUnpackers ()
 Abstract in base class. No implementation here. More...
 
virtual Int_t ReadEvent (UInt_t event=0)
 Provide one tree entry. More...
 
virtual Bool_t ReInitUnpackers ()
 Abstract in base class. No implementation here. More...
 
virtual void Reset ()
 Abstract in base class. No implementation here. More...
 
void SetEventMode (Bool_t choice=kTRUE)
 Set event-by-event mode @value choice kTRUE if event-by-event mode. More...
 
virtual void SetParUnpackers ()
 Abstract in base class. No implementation here. More...
 
void SetTimeStart (Double_t time)
 Set the offset for the first event time. More...
 

Private Member Functions

Bool_t CheckBranchList (CbmMCInputSet *input)
 Compare an input set branch list with the reference list. More...
 
Int_t ReadEventByEvent (UInt_t event)
 Get next entry in event-by-event mode. More...
 
void ReadRunId ()
 Read run ID from the first entry in the first input. More...
 
 ClassDef (CbmDigitizationSource, 1)
 

Private Attributes

std::vector< CbmMCInputSet * > fInputSets
 
std::map< UInt_t, CbmMCInputSet * > fInputMap
 
std::map< Double_t, CbmMCInputSet * > fNextEvent
 input ID -> inputSet More...
 
FairMCEventHeader * fMCEventHeader
 time -> inputSet More...
 
TObjArray * fListOfFolders
 
std::set< TString > fBranches
 
Double_t fTimeStart
 
Double_t fCurrentTime
 
Int_t fCurrentEntryId
 
Int_t fCurrentInputId
 
Int_t fCurrentRunId
 
Bool_t fFirstCall
 
Bool_t fEventMode
 
CbmMCInputSetfCurrentInputSet
 
Bool_t fSwitchInputSet
 

Detailed Description

Source class for the input to digitization in CBM.

Author
Volker Friese v.fri.nosp@m.ese@.nosp@m.gsi.d.nosp@m.e
Date
9 November 2018

This class serves as input source for CBM digitization runs. It allows to mix an arbitrary number of different inputs (results of transport simulations) with different event rates. For each input chain, a sequence of event times is calculated. The respective next event is delivered to FairRootManager.

The API is the method AddInput, specifying a TChain with an event rate. The source object has to be registered to the run. The large number of non-API public methods is due to the implementation of the base class FairSource.

The class is based on FairMixedSource by M. Al-Turany, stripping unneeded functionality and introducing a different concept of input mixing.

Definition at line 42 of file CbmDigitizationSource.h.

Constructor & Destructor Documentation

◆ CbmDigitizationSource()

CbmDigitizationSource::CbmDigitizationSource ( )

Constructor.

Definition at line 21 of file CbmDigitizationSource.cxx.

◆ ~CbmDigitizationSource()

CbmDigitizationSource::~CbmDigitizationSource ( )
virtual

Destructor.

Definition at line 42 of file CbmDigitizationSource.cxx.

References fBranches, and fInputSets.

Member Function Documentation

◆ ActivateObject()

Bool_t CbmDigitizationSource::ActivateObject ( TObject **  object,
const char *  branchName 
)
virtual

Activate a branch and set its address.

Parameters
objectPointer to pointer to branch class
branchNameName of branch

Inherited from FairSource. This method will be called from FairRootManager::ActivateBranch(branchName) when an input branch is demanded by a task.

All input trees have to be connected to the argument object.

Definition at line 51 of file CbmDigitizationSource.cxx.

References fInputSets.

Referenced by Init().

◆ AddInput()

void CbmDigitizationSource::AddInput ( UInt_t  inputId,
TChain *  chain,
Double_t  rate,
ECbmTreeAccess  mode = ECbmTreeAccess::kRegular 
)

Add a transport input.

Parameters
inputIdInput number (identifier)
chainPointer to input chain
modeTree access mode (kRegular / kRepeat / kRandom)

Definition at line 64 of file CbmDigitizationSource.cxx.

References CbmMCInputSet::AddInput(), CheckBranchList(), fBranches, fInputMap, fInputSets, CbmMCInputSet::GetBranchList(), kRegular, and kRepeat.

Referenced by CbmDigitization::AddInput().

◆ CheckBranchList()

Bool_t CbmDigitizationSource::CheckBranchList ( CbmMCInputSet input)
private

Compare an input set branch list with the reference list.

Parameters
inputPointer to CbmMCInputSet @value kTRUE if the branch list of the input set is compatible

The branch list of the input set is considered compatible if all branches of the reference list are present in the input set. Additional branches in the input set are not considered harmful. The reference branch list is defined by the first input set.

Definition at line 107 of file CbmDigitizationSource.cxx.

References fBranches, and CbmMCInputSet::GetBranchList().

Referenced by AddInput().

◆ CheckMaxEventNo()

Int_t CbmDigitizationSource::CheckMaxEventNo ( Int_t  lastEntry = 0)
virtual

Maximal entry number the source can run to.

Parameters
lastEntryLast entry as specified by FairRunAna. Ignored. @value Last entry possible with this source

Inherited from FairSource. Since there can be several inputs being randomly mixed together, a maximal entry number cannot be specified. Thus, a practically infinite value is returned. The run is then terminated by ReadEvent() returning non-zero. If lastEntry is specified by FairRunAna (i.e., by the user), this is the return value.

Definition at line 141 of file CbmDigitizationSource.cxx.

References fInputSets.

◆ ClassDef()

CbmDigitizationSource::ClassDef ( CbmDigitizationSource  ,
 
)
private

◆ Close()

virtual void CbmDigitizationSource::Close ( )
inlinevirtual

Abstract in base class. No implementation here.

Is actually not called at all from FairRunAna.

Definition at line 95 of file CbmDigitizationSource.h.

◆ EmbedInput()

void CbmDigitizationSource::EmbedInput ( UInt_t  inputId,
TChain *  chain,
UInt_t  targetInputId,
ECbmTreeAccess  mode = ECbmTreeAccess::kRegular 
)

Embed a transport input.

Parameters
inputIdInput number (identifier)
chainPointer to input chain
targetInputIdID of the input to be embedded into
modeTree access mode (kRegular / kRepeat / kRandom)

Definition at line 161 of file CbmDigitizationSource.cxx.

References fInputMap, kRegular, and kRepeat.

Referenced by CbmDigitization::EmbedInput().

◆ FillEventHeader()

void CbmDigitizationSource::FillEventHeader ( FairEventHeader *  event)
virtual

Fill the output event header.

Parameters
eventPointer to event header

Fills run ID, input ID, entry ID and event time.

Definition at line 194 of file CbmDigitizationSource.cxx.

References fCurrentEntryId, fCurrentInputId, fCurrentRunId, and fCurrentTime.

◆ GetBranchList()

const std::set<TString>& CbmDigitizationSource::GetBranchList ( ) const
inline

List of branch names @value Reference to set of branch names.

Definition at line 121 of file CbmDigitizationSource.h.

References fBranches.

Referenced by CbmDigitization::CheckInput().

◆ GetFirstInput()

CbmMCInput * CbmDigitizationSource::GetFirstInput ( )

First input from the first input set @value Pointer to first input.

Definition at line 208 of file CbmDigitizationSource.cxx.

References fInputMap.

Referenced by CbmDigitization::CheckInput().

◆ GetSourceType()

virtual Source_Type CbmDigitizationSource::GetSourceType ( )
inlinevirtual

Source type is kFILE.

Definition at line 131 of file CbmDigitizationSource.h.

◆ Init()

Bool_t CbmDigitizationSource::Init ( )
virtual

◆ InitUnpackers()

virtual Bool_t CbmDigitizationSource::InitUnpackers ( )
inlinevirtual

Abstract in base class. No implementation here.

Is actually not called at all from FairRunAna.

Definition at line 146 of file CbmDigitizationSource.h.

◆ ReadEvent()

Int_t CbmDigitizationSource::ReadEvent ( UInt_t  event = 0)
virtual

Provide one tree entry.

Parameters
eventEvent number. Has no effect here. @value 0 for success, 1 is end of tree is reached.

The input with the smallest next event time is chosen. From each input, the entries are provided consecutively. If the end of the respective input tree is reached, such that no more entries can be read, 1 is returned, causing FairRunAna to stop the run.

Definition at line 271 of file CbmDigitizationSource.cxx.

References fCurrentEntryId, fCurrentInputId, fCurrentInputSet, fCurrentTime, fEventMode, fFirstCall, fNextEvent, fSwitchInputSet, CbmMCInputSet::GetDeltaT(), CbmMCInputSet::GetNextEntry(), ReadEventByEvent(), and ReadRunId().

◆ ReadEventByEvent()

Int_t CbmDigitizationSource::ReadEventByEvent ( UInt_t  event)
private

Get next entry in event-by-event mode.

Parameters
eventEntry number @value 0 if successful, 1 if requested entry does not exist

In the event-by-event mode, only the first input set is used. The event time is zero for all events.

Definition at line 330 of file CbmDigitizationSource.cxx.

References fCurrentEntryId, fCurrentInputId, fCurrentTime, fInputSets, CbmMCInput::GetChain(), CbmMCInput::GetMode(), CbmMCInput::GetNextEntry(), CbmMCInput::GetNofEntries(), and kRegular.

Referenced by ReadEvent().

◆ ReadRunId()

void CbmDigitizationSource::ReadRunId ( )
private

Read run ID from the first entry in the first input.

This is used for the first call to ReadEvent, which happens from FairRunAna::Init() to get the run ID. The run ID is read from FairMCEventHeader and copied to the FairEventHeader by FillEventHeader, which is also called from FairRunAna.

Definition at line 367 of file CbmDigitizationSource.cxx.

References fCurrentEntryId, fCurrentInputId, fCurrentRunId, fFirstCall, fInputSets, fMCEventHeader, and CbmMCInput::GetChain().

Referenced by ReadEvent().

◆ ReInitUnpackers()

virtual Bool_t CbmDigitizationSource::ReInitUnpackers ( )
inlinevirtual

Abstract in base class. No implementation here.

Is actually not called at all from FairRunAna.

Definition at line 166 of file CbmDigitizationSource.h.

◆ Reset()

virtual void CbmDigitizationSource::Reset ( )
inlinevirtual

Abstract in base class. No implementation here.

Definition at line 170 of file CbmDigitizationSource.h.

◆ SetEventMode()

void CbmDigitizationSource::SetEventMode ( Bool_t  choice = kTRUE)
inline

Set event-by-event mode @value choice kTRUE if event-by-event mode.

In the event-by-event mode, only the first input is processed. No event start time is generated; the event time is always zero.

Definition at line 179 of file CbmDigitizationSource.h.

References fEventMode.

Referenced by CbmDigitization::Run().

◆ SetParUnpackers()

virtual void CbmDigitizationSource::SetParUnpackers ( )
inlinevirtual

Abstract in base class. No implementation here.

Is actually not called at all from FairRunAna.

Definition at line 186 of file CbmDigitizationSource.h.

◆ SetTimeStart()

void CbmDigitizationSource::SetTimeStart ( Double_t  time)
inline

Set the offset for the first event time.

Parameters
timeTime offset for first event

If the event times start with or close to zero, negative digi times can occur because of the finite time resolution of the detectors. However, the first time slice always start from zero. To avoid conflicts or loss of data, a time offset is introduced, preventing negative digi times. The default value of this offset is set in the constructor. It can be changed by this method.

Definition at line 199 of file CbmDigitizationSource.h.

References fTimeStart.

Referenced by CbmDigitization::SetStartTime().

Member Data Documentation

◆ fBranches

std::set<TString> CbmDigitizationSource::fBranches
private

◆ fCurrentEntryId

Int_t CbmDigitizationSource::fCurrentEntryId
private

Definition at line 211 of file CbmDigitizationSource.h.

Referenced by FillEventHeader(), ReadEvent(), ReadEventByEvent(), and ReadRunId().

◆ fCurrentInputId

Int_t CbmDigitizationSource::fCurrentInputId
private

Definition at line 212 of file CbmDigitizationSource.h.

Referenced by FillEventHeader(), ReadEvent(), ReadEventByEvent(), and ReadRunId().

◆ fCurrentInputSet

CbmMCInputSet* CbmDigitizationSource::fCurrentInputSet
private

Definition at line 216 of file CbmDigitizationSource.h.

Referenced by Init(), and ReadEvent().

◆ fCurrentRunId

Int_t CbmDigitizationSource::fCurrentRunId
private

Definition at line 213 of file CbmDigitizationSource.h.

Referenced by FillEventHeader(), and ReadRunId().

◆ fCurrentTime

Double_t CbmDigitizationSource::fCurrentTime
private

Definition at line 210 of file CbmDigitizationSource.h.

Referenced by FillEventHeader(), Init(), ReadEvent(), and ReadEventByEvent().

◆ fEventMode

Bool_t CbmDigitizationSource::fEventMode
private

Definition at line 215 of file CbmDigitizationSource.h.

Referenced by Init(), ReadEvent(), and SetEventMode().

◆ fFirstCall

Bool_t CbmDigitizationSource::fFirstCall
private

Definition at line 214 of file CbmDigitizationSource.h.

Referenced by ReadEvent(), and ReadRunId().

◆ fInputMap

std::map<UInt_t, CbmMCInputSet*> CbmDigitizationSource::fInputMap
private

Definition at line 204 of file CbmDigitizationSource.h.

Referenced by AddInput(), EmbedInput(), GetFirstInput(), and Init().

◆ fInputSets

std::vector<CbmMCInputSet*> CbmDigitizationSource::fInputSets
private

◆ fListOfFolders

TObjArray* CbmDigitizationSource::fListOfFolders
private

Definition at line 207 of file CbmDigitizationSource.h.

Referenced by Init().

◆ fMCEventHeader

FairMCEventHeader* CbmDigitizationSource::fMCEventHeader
private

time -> inputSet

Definition at line 206 of file CbmDigitizationSource.h.

Referenced by Init(), and ReadRunId().

◆ fNextEvent

std::map<Double_t, CbmMCInputSet*> CbmDigitizationSource::fNextEvent
private

input ID -> inputSet

Definition at line 205 of file CbmDigitizationSource.h.

Referenced by Init(), and ReadEvent().

◆ fSwitchInputSet

Bool_t CbmDigitizationSource::fSwitchInputSet
private

Definition at line 217 of file CbmDigitizationSource.h.

Referenced by ReadEvent().

◆ fTimeStart

Double_t CbmDigitizationSource::fTimeStart
private

Definition at line 209 of file CbmDigitizationSource.h.

Referenced by Init(), and SetTimeStart().


The documentation for this class was generated from the following files: