CbmRoot
Loading...
Searching...
No Matches
CbmDigitizeBase.cxx
Go to the documentation of this file.
1/* Copyright (C) 2018-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer] */
4
9#include "CbmDigitizeBase.h"
10
11#include <FairEventHeader.h> // for FairEventHeader
12#include <FairRootManager.h> // for FairRootManager
13#include <FairRunAna.h> // for FairRunAna
14#include <FairTask.h> // for FairTask
15
16#include <TGenericClassInfo.h> // for TGenericClassInfo
17
18#include <cassert> // for assert
19#include <cstdio>
20
21// ----- Default constructor --------------------------------------------
23 : FairTask("Digitizer")
24 , fEventMode(kFALSE)
25 , fProduceNoise(kTRUE)
26 , fCreateMatches(kTRUE)
27 , fCurrentInput(-1)
28 , fCurrentEvent(-1)
29 , fCurrentMCEntry(-1)
30 , fCurrentEventTime(0.)
31{
32}
33// --------------------------------------------------------------------------
34
35
36// ----- Default constructor --------------------------------------------
38 : FairTask(name)
39 , fEventMode(kFALSE)
40 , fProduceNoise(kTRUE)
41 , fCreateMatches(kTRUE)
42 , fCurrentInput(-1)
43 , fCurrentEvent(-1)
44 , fCurrentMCEntry(-1)
45 , fCurrentEventTime(0.)
46{
47}
48// --------------------------------------------------------------------------
49
50
51// ----- Destructor -----------------------------------------------------
53// --------------------------------------------------------------------------
54
55
56// ----- Get event information ------------------------------------------
58{
59
60 // --- The event number is taken from the FairRootManager
61 fCurrentEvent = FairRootManager::Instance()->GetEntryNr();
62
63 if (FairRunAna::Instance()) {
64 FairEventHeader* event = FairRunAna::Instance()->GetEventHeader();
65 assert(event);
66 fCurrentInput = event->GetInputFileId();
67 fCurrentMCEntry = event->GetMCEntryNumber();
68 fCurrentEventTime = event->GetEventTime();
69 } //? FairRunAna
70 else { // no FairRunAna
71 fCurrentInput = -1;
72 fCurrentMCEntry = -1;
74 } //? not FairRunAna
75}
76// --------------------------------------------------------------------------
77
78
79// ----- Read list of inactive channels ---------------------------------
81{
82
83 if (fInactiveChannelFileName.IsNull()) return std::make_pair(0, true);
84
85 FILE* channelFile = fopen(fInactiveChannelFileName.Data(), "r");
86 if (channelFile == nullptr) return std::make_pair(0, false);
87
88 size_t nLines = 0;
89 uint32_t channel = 0;
90 while (fscanf(channelFile, "%u", &channel) == 1) {
91 fInactiveChannels.insert(channel);
92 nLines++;
93 }
94 bool success = feof(channelFile);
95
96 fclose(channelFile);
97 return std::make_pair(nLines, success);
98}
99// --------------------------------------------------------------------------
100
101
ClassImp(CbmConverterManager)
Int_t fCurrentMCEntry
Abstract base class for CBM digitisation tasks.
virtual std::pair< size_t, bool > ReadInactiveChannels()
Set of inactive channels, indicated by CbmAddress.
Int_t fCurrentEvent
Number of current input.
TString fInactiveChannelFileName
Time of current MC event [ns].
std::set< uint32_t > fInactiveChannels
Name of file with inactive channels.
virtual ~CbmDigitizeBase()
Destructor.
CbmDigitizeBase()
Constructor.
void GetEventInfo()
Get event information.
Int_t fCurrentInput
Start time of run [ns].
Double_t fCurrentEventTime
Number of current MC entry.
Int_t fCurrentMCEntry
Number of current MC event.