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

Private Member Functions

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

Private Attributes

std::vector< CbmMCInputSet * > fInputSets
 
std::map< UInt_t, CbmMCInputSet * > fInputMap
 
std::multimap< Double_t, CbmMCInputSet * > fNextEvent
 input ID -> inputSet
 
FairMCEventHeader * fMCEventHeader
 time -> inputSet
 
TObjArray * fListOfFolders
 
std::set< TString > fBranches
 
Double_t fTimeStart
 
Double_t fCurrentTime
 
Int_t fCurrentEntryId
 
Int_t fCurrentInputId
 
Int_t fCurrentRunId
 
Bool_t fFirstCall
 
cbm::sim::Mode fMode
 
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 49 of file CbmDigitizationSource.h.

Constructor & Destructor Documentation

◆ CbmDigitizationSource()

CbmDigitizationSource::CbmDigitizationSource ( )

Constructor.

Definition at line 30 of file CbmDigitizationSource.cxx.

◆ ~CbmDigitizationSource()

CbmDigitizationSource::~CbmDigitizationSource ( )
virtual

Destructor.

Definition at line 53 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 63 of file CbmDigitizationSource.cxx.

References fInputSets.

Referenced by Init().

◆ AddInput()

void CbmDigitizationSource::AddInput ( UInt_t inputId,
TChain * chain,
cbm::sim::TimeDist dist,
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 76 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 111 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 145 of file CbmDigitizationSource.cxx.

References fInputSets.

◆ ClassDef()

CbmDigitizationSource::ClassDef ( CbmDigitizationSource ,
1  )
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 100 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 165 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 192 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 123 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 206 of file CbmDigitizationSource.cxx.

References fInputMap.

Referenced by CbmDigitization::CheckInput().

◆ GetSourceType()

virtual Source_Type CbmDigitizationSource::GetSourceType ( )
inlinevirtual

Source type is kFILE.

Definition at line 133 of file CbmDigitizationSource.h.

◆ GetStartTime()

Double_t CbmDigitizationSource::GetStartTime ( )
inline

Run start time.

Definition at line 141 of file CbmDigitizationSource.h.

References fTimeStart.

Referenced by CbmDigitization::Run().

◆ 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 152 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, fFirstCall, fMode, fNextEvent, fSwitchInputSet, CbmMCInputSet::GetDeltaT(), CbmMCInputSet::GetNextEntry(), ReadEventByEvent(), and ReadRunId().

Referenced by SpecifyRunId().

◆ 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 329 of file CbmDigitizationSource.cxx.

References fCurrentEntryId, fCurrentInputId, fCurrentTime, fInputSets, fTimeStart, 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 364 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 172 of file CbmDigitizationSource.h.

◆ Reset()

virtual void CbmDigitizationSource::Reset ( )
inlinevirtual

Abstract in base class. No implementation here.

Definition at line 176 of file CbmDigitizationSource.h.

◆ SetMode()

void CbmDigitizationSource::SetMode ( cbm::sim::Mode mode)
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 197 of file CbmDigitizationSource.h.

References fMode.

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 204 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 217 of file CbmDigitizationSource.h.

References fTimeStart.

Referenced by CbmDigitization::SetStartTime().

◆ SpecifyRunId()

virtual Bool_t CbmDigitizationSource::SpecifyRunId ( )
inlinevirtual

Implement abstract function from base class.

Read the first event from input file to fill the event header and get the RunID

Definition at line 184 of file CbmDigitizationSource.h.

References ReadEvent().

Member Data Documentation

◆ fBranches

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

◆ fCurrentEntryId

Int_t CbmDigitizationSource::fCurrentEntryId
private

Definition at line 229 of file CbmDigitizationSource.h.

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

◆ fCurrentInputId

Int_t CbmDigitizationSource::fCurrentInputId
private

Definition at line 230 of file CbmDigitizationSource.h.

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

◆ fCurrentInputSet

CbmMCInputSet* CbmDigitizationSource::fCurrentInputSet
private

Definition at line 234 of file CbmDigitizationSource.h.

Referenced by Init(), and ReadEvent().

◆ fCurrentRunId

Int_t CbmDigitizationSource::fCurrentRunId
private

Definition at line 231 of file CbmDigitizationSource.h.

Referenced by FillEventHeader(), and ReadRunId().

◆ fCurrentTime

Double_t CbmDigitizationSource::fCurrentTime
private

Definition at line 228 of file CbmDigitizationSource.h.

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

◆ fFirstCall

Bool_t CbmDigitizationSource::fFirstCall
private

Definition at line 232 of file CbmDigitizationSource.h.

Referenced by ReadEvent(), and ReadRunId().

◆ fInputMap

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

Definition at line 222 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 225 of file CbmDigitizationSource.h.

Referenced by Init().

◆ fMCEventHeader

FairMCEventHeader* CbmDigitizationSource::fMCEventHeader
private

time -> inputSet

Definition at line 224 of file CbmDigitizationSource.h.

Referenced by Init(), and ReadRunId().

◆ fMode

cbm::sim::Mode CbmDigitizationSource::fMode
private

Definition at line 233 of file CbmDigitizationSource.h.

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

◆ fNextEvent

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

input ID -> inputSet

Definition at line 223 of file CbmDigitizationSource.h.

Referenced by Init(), and ReadEvent().

◆ fSwitchInputSet

Bool_t CbmDigitizationSource::fSwitchInputSet
private

Definition at line 235 of file CbmDigitizationSource.h.

Referenced by ReadEvent().

◆ fTimeStart

Double_t CbmDigitizationSource::fTimeStart
private

Definition at line 227 of file CbmDigitizationSource.h.

Referenced by GetStartTime(), Init(), ReadEventByEvent(), and SetTimeStart().


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