14#include <FairRootManager.h>
16#include <FairRuntimeDb.h>
20#include <TClonesArray.h>
23#include <TStopwatch.h>
34using std::setprecision;
44 LOG(info) << GetName() <<
" uses TimeBased mode.";
47 LOG(info) << GetName() <<
" uses Events mode.";
51 FairRootManager* ioman = FairRootManager::Instance();
54 fPointArray =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"FsdPoint"));
56 LOG(error) << GetName() <<
": Error in reading from file! No FsdPoint array.";
59 TString objectName =
fPointArray->GetClass()->GetName();
60 if (0 != objectName.CompareTo(
"CbmFsdPoint")) {
61 LOG(fatal) << GetName() <<
": TClonesArray does not contain data of the expected class CbmFsdPoint";
76 LOG(info) << GetName() <<
": Initialisation successful " << kSUCCESS;
83 LOG(info) << GetName() <<
": Get the digi parameters for FSD";
86 FairRun* ana = FairRun::Instance();
87 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
91 LOG(fatal) << GetName() <<
": parameter container CbmFsdDigiPar not available in current RuntimeDb!!";
98 LOG(fatal) << GetName() <<
": parameter container CbmFsdDigiPar not found!!";
106 LOG(fatal) << GetName() <<
": parameter values for FSD digitization does not meet a sanity check!!";
119 LOG(fatal) << GetName() <<
": parameter values for FSD digitization does not meet a sanity check!!";
147 Int_t photodetId = -1;
151 photodetId = gRandom->Integer(
static_cast<UInt_t
>(
fNumPhotoDets));
158 for (
Int_t iPoint = 0; iPoint < nPoints; iPoint++) {
160 if (!point)
continue;
162 int32_t pointAddress =
static_cast<int32_t
>(point->GetDetectorID());
167 Double_t eloss = point->GetEnergyLoss() + gRandom->Gaus(0.,
fEnergyResolution[unitId]);
170 static_cast<uint32_t
>(unitId),
static_cast<uint32_t
>(modId),
static_cast<uint32_t
>(photodetId)));
177 Double_t timeDiff = std::fabs(time - it->second.first->GetTime());
180 it->second.first->SetEdep(it->second.first->GetEdep() + eloss);
181 if (time < it->second.first->GetTime()) it->second.first->SetTime(time);
183 it->second.second->AddLink(link);
188 new CbmFsdDigi(it->second.first->GetAddress(), it->second.first->GetTime(), it->second.first->GetEdep());
192 delete it->second.second;
197 delete it->second.first;
203 fDigiBuffer.insert(std::make_pair(pointAddress, std::make_pair(digi, match)));
212 fDigiBuffer.insert(std::make_pair(pointAddress, std::make_pair(digi, match)));
222 LOG(info) <<
"+ " << setw(15) << GetName() <<
": Event " << setw(6) << right <<
fCurrentEvent <<
" at " << fixed
223 << setprecision(3) <<
fCurrentEventTime <<
" ns, points: " << nPoints <<
", digis: " << nDigis
224 <<
". Exec time " << setprecision(6) << timer.RealTime() <<
" s.";
238 std::cout << std::endl;
239 LOG(info) <<
"=====================================";
240 LOG(info) << GetName() <<
": Finish run";
242 LOG(info) << GetName() <<
": Run summary";
243 LOG(info) <<
"Events processed : " <<
fNumEvents;
248 LOG(info) <<
"=====================================";
255 if (sendEverything) {
259 new CbmFsdDigi(dp.second.first->GetAddress(), dp.second.first->GetTime(), dp.second.first->GetEdep());
263 delete dp.second.first;
264 delete dp.second.second;
268 delete dp.second.first;
275 std::vector<int32_t> keysSent;
283 new CbmFsdDigi(dp.second.first->GetAddress(), dp.second.first->GetTime(), dp.second.first->GetEdep());
287 delete dp.second.second;
293 keysSent.push_back(dp.first);
298 for (
auto& key : keysSent) {
ClassImp(CbmConverterManager)
Double_t fCurrentEventTime
void SendData(Double_t time, CbmFsdDigi *digi, CbmMatch *match=nullptr)
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.