14#include <FairRootManager.h>
16#include <FairRuntimeDb.h>
20#include <TClonesArray.h>
23#include <TStopwatch.h>
34using std::setprecision;
43 if (!
fEventMode) { LOG(info) << GetName() <<
" uses TimeBased mode."; }
45 LOG(info) << GetName() <<
" uses Events mode.";
49 FairRootManager* ioman = FairRootManager::Instance();
52 fPointArray =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"FsdPoint"));
54 LOG(error) << GetName() <<
": Error in reading from file! No FsdPoint array.";
57 TString objectName =
fPointArray->GetClass()->GetName();
58 if (0 != objectName.CompareTo(
"CbmFsdPoint")) {
59 LOG(fatal) << GetName() <<
": TClonesArray does not contain data of the expected class CbmFsdPoint";
74 LOG(info) << GetName() <<
": Initialisation successful " << kSUCCESS;
81 LOG(info) << GetName() <<
": Get the digi parameters for FSD";
84 FairRun* ana = FairRun::Instance();
85 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
89 LOG(fatal) << GetName() <<
": parameter container CbmFsdDigiPar not available in current RuntimeDb!!";
95 if (!
fDigiPar) { LOG(fatal) << GetName() <<
": parameter container CbmFsdDigiPar not found!!"; }
102 LOG(fatal) << GetName() <<
": parameter values for FSD digitization does not meet a sanity check!!";
109 for (Int_t iu = 0; iu <
fNumUnits; iu++) {
115 LOG(fatal) << GetName() <<
": parameter values for FSD digitization does not meet a sanity check!!";
143 Int_t photodetId = -1;
147 photodetId = gRandom->Integer(
static_cast<UInt_t
>(
fNumPhotoDets));
154 for (Int_t iPoint = 0; iPoint < nPoints; iPoint++) {
156 if (!point)
continue;
158 int32_t pointAddress =
static_cast<int32_t
>(point->GetDetectorID());
163 Double_t eloss = point->GetEnergyLoss() + gRandom->Gaus(0.,
fEnergyResolution[unitId]);
166 static_cast<uint32_t
>(unitId),
static_cast<uint32_t
>(modId),
static_cast<uint32_t
>(photodetId)));
173 Double_t timeDiff = std::fabs(time - it->second.first->GetTime());
176 it->second.first->SetEdep(it->second.first->GetEdep() + eloss);
177 if (time < it->second.first->GetTime()) it->second.first->SetTime(time);
179 it->second.second->AddLink(link);
184 new CbmFsdDigi(it->second.first->GetAddress(), it->second.first->GetTime(), it->second.first->GetEdep());
194 fDigiBuffer.insert(std::make_pair(pointAddress, std::make_pair(digi, match)));
203 fDigiBuffer.insert(std::make_pair(pointAddress, std::make_pair(digi, match)));
213 LOG(info) <<
"+ " << setw(15) << GetName() <<
": Event " << setw(6) << right <<
fCurrentEvent <<
" at " << fixed
214 << setprecision(3) <<
fCurrentEventTime <<
" ns, points: " << nPoints <<
", digis: " << nDigis
215 <<
". Exec time " << setprecision(6) << timer.RealTime() <<
" s.";
229 std::cout << std::endl;
230 LOG(info) <<
"=====================================";
231 LOG(info) << GetName() <<
": Finish run";
233 LOG(info) << GetName() <<
": Run summary";
234 LOG(info) <<
"Events processed : " <<
fNumEvents;
239 LOG(info) <<
"=====================================";
246 if (sendEverything) {
250 new CbmFsdDigi(dp.second.first->GetAddress(), dp.second.first->GetTime(), dp.second.first->GetEdep());
260 std::vector<int32_t> keysSent;
268 new CbmFsdDigi(dp.second.first->GetAddress(), dp.second.first->GetTime(), dp.second.first->GetEdep());
275 keysSent.push_back(dp.first);
280 for (
auto& key : keysSent) {
ClassImp(CbmConverterManager)
Int_t fCurrentEvent
Number of current input.
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.
void SendData(Double_t time, CbmFsdDigi *digi, CbmMatch *match=nullptr)
Double_t GetTimeResolution(Int_t iUnitId) const
Int_t GetNumPhotoDets() const
Double_t GetEnergyResolution(Int_t iUnitId) const
Double_t GetDeadTime(Int_t iUnitId) const
Int_t GetNumUnits() const
Data class for FSD digital information.
double GetTime() const
Time.
Class for the digitization of the CBM-FSD.
virtual void Finish()
End-of-run action.
void InitParams()
Initialise the parameters.
TClonesArray * fPointArray
TArrayD fEnergyResolution
std::map< int32_t, std::pair< CbmFsdDigi *, CbmMatch * > > fDigiBuffer
virtual void SetParContainers()
Inherited from FairTask.
virtual InitStatus Init()
Inherited from FairTask.
virtual void Exec(Option_t *opt)
void ReleaseBuffer(Bool_t sendEverything)
release digi from local buffer to CbmDaq TIME BASED
Interception of MC track with the plane representing the FSD.
void AddLink(const CbmLink &newLink)
int32_t GetAddress(uint32_t Unit=0, uint32_t Module=0, uint32_t PhotoDet=0, uint32_t Version=kCurrentVersion)
Construct address.
uint32_t GetElementId(int32_t address, int32_t level)
Get the index of an element.