CbmRoot
Loading...
Searching...
No Matches
CbmBmonDigitize.cxx
Go to the documentation of this file.
1/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer] */
4
10#include "CbmBmonDigitize.h"
11
12#include "CbmMatch.h"
13
14#include <Logger.h>
15
16#include <TRandom.h>
17#include <TStopwatch.h>
18
19#include <iomanip>
20#include <iostream>
21
22using std::fixed;
23using std::left;
24using std::setprecision;
25using std::setw;
26
27
28// ----- Standard constructor ------------------------------------------
29CbmBmonDigitize::CbmBmonDigitize(double sigma) : CbmDigitize<CbmBmonDigi>("BmonDigitize"), fResolution(sigma) {}
30// -------------------------------------------------------------------------
31
32
33// ----- Destructor ----------------------------------------------------
35// -------------------------------------------------------------------------
36
37
38// ----- Task execution ------------------------------------------------
39void CbmBmonDigitize::Exec(Option_t*)
40{
41
42 // --- Start timer and reset counters
43 TStopwatch timer;
44 timer.Start();
45
46 // --- Get MC event information
48
49 // --- Create digi and send it to DAQ
50 double digiTime = fCurrentEventTime + gRandom->Gaus(0., fResolution);
51 double charge = 1.; // Placeholder
53 if (fCreateMatches) {
54 CbmMatch* digiMatch = new CbmMatch();
55 digiMatch->AddLink(1., -1, fCurrentMCEntry, fCurrentInput);
56 SendData(digiTime, digi, digiMatch);
57 }
58 else
59 SendData(digiTime, digi);
60
61 // --- Event log
62 LOG(info) << left << setw(15) << GetName() << "[" << fixed << setprecision(3) << timer.RealTime() << " s]"
63 << " event time: " << fCurrentEventTime << " ns, measurement time " << digiTime << " ns";
64
65 // --- Monitor
66 timer.Stop();
67 fNofEvents++;
68 fTimeTot += timer.RealTime();
69}
70// -------------------------------------------------------------------------
71
72
73// ----- Finish run ---------------------------------------------------
75{
76 std::cout << std::endl;
77 LOG(info) << "=====================================";
78 LOG(info) << GetName() << ": Run summary";
79 LOG(info) << "Events processed : " << fNofEvents;
80 LOG(info) << "Real time per event : " << fTimeTot / Double_t(fNofEvents) << " s";
81 LOG(info) << "=====================================";
82}
83// -------------------------------------------------------------------------
84
85
86// ----- Initialisation -----------------------------------------------
88{
89 std::cout << std::endl;
90 LOG(info) << "==========================================================";
91 LOG(info) << GetName() << ": Initialisation";
92 LOG(info) << "Time resolution is " << fResolution << " [ns]";
93
95
96 // --- Read list of inactive channels
97 if (!fInactiveChannelFileName.IsNull()) {
98 LOG(info) << GetName() << ": Reading inactive channels from " << fInactiveChannelFileName;
99 auto result = ReadInactiveChannels();
100 if (!result.second) {
101 LOG(error) << GetName() << ": Error in reading from file! Task will be inactive.";
102 return kFATAL;
103 }
104 LOG(info) << GetName() << ": " << std::get<0>(result) << " lines read from file, " << fInactiveChannels.size()
105 << " channels set inactive";
106 }
107
108 LOG(info) << GetName() << ": Initialisation successful";
109 LOG(info) << "==========================================================";
110 std::cout << std::endl;
111 return kSUCCESS;
112}
113// -------------------------------------------------------------------------
114
115
116// ----- Private method ReInit -----------------------------------------
117InitStatus CbmBmonDigitize::ReInit() { return kSUCCESS; }
118// -------------------------------------------------------------------------
119
120
ClassImp(CbmConverterManager)
XPU_D constexpr auto ToIntegralType(T enumerator) -> typename std::underlying_type< T >::type
Definition CbmDefs.h:29
Data class for a signal in the t-zero detector.
Definition CbmBmonDigi.h:30
Task class for simulating the detector response of the t-zero detector.
Double_t fTimeTot
Total execution time.
virtual void Finish()
CbmBmonDigitize(double resolution=0.025)
virtual InitStatus ReInit()
virtual InitStatus Init()
virtual void Exec(Option_t *opt)
size_t fNofEvents
Total number of procesed events.
virtual ~CbmBmonDigitize()
double fResolution
Time resolution [ns].
virtual std::pair< size_t, bool > ReadInactiveChannels()
Set of inactive channels, indicated by CbmAddress.
TString fInactiveChannelFileName
Time of current MC event [ns].
std::set< uint32_t > fInactiveChannels
Name of file with inactive channels.
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.
Bool_t fCreateMatches
Flag for production of inter-event noise.
Base class template for CBM digitisation tasks.
Definition CbmDigitize.h:44
void SendData(Double_t time, CbmBmonDigi *digi, CbmMatch *match=nullptr)
void AddLink(const CbmLink &newLink)
Definition CbmMatch.cxx:47