From 4cb4d139d9103a57ce10900b105f7cd6847c3d47 Mon Sep 17 00:00:00 2001 From: Florian Uhlig <f.uhlig@gsi.de> Date: Wed, 29 Nov 2023 11:32:53 +0100 Subject: [PATCH] Fix mvd digitization Receice at the end of the run all data which is still in the buffers of the mvd sensors, create digis and send them to the DAQ. --- sim/detectors/mvd/CbmMvdDigitizer.cxx | 39 ++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/sim/detectors/mvd/CbmMvdDigitizer.cxx b/sim/detectors/mvd/CbmMvdDigitizer.cxx index 05fe019b8f..5586853e29 100644 --- a/sim/detectors/mvd/CbmMvdDigitizer.cxx +++ b/sim/detectors/mvd/CbmMvdDigitizer.cxx @@ -141,8 +141,6 @@ void CbmMvdDigitizer::Exec(Option_t* /*opt*/) Int_t nPoints = fInputPoints->GetEntriesFast(); Int_t nDigis = 0; CbmMvdPoint* point = 0; - fTmpDigi->Clear(); - fTmpMatch->Clear(); cout << fName << "Debug: 1" << endl; if (fInputPoints->GetEntriesFast() > 0) { @@ -204,6 +202,7 @@ void CbmMvdDigitizer::Exec(Option_t* /*opt*/) // cout << fName <<"Debug: 7" << endl; } + // TODO: (VF) There seem to be no entries in the match array, nor matches // attached to the digi object LOG(debug) << fName << ": Sent " << nDigis << " digis to DAQ"; @@ -219,6 +218,11 @@ void CbmMvdDigitizer::Exec(Option_t* /*opt*/) // << fixed << setprecision(6) << fTimer.RealTime() << " s"; } + // Clear the arrays after being used. Every digi and match was already + // copied and send to the DAQ + fTmpDigi->Clear(); + fTmpMatch->Clear(); + // --- Event log fTimer.Stop(); LOG(info) << "+ " << setw(15) << GetName() << ": Event " << setw(6) << right << fCurrentEvent << " at " << fixed @@ -340,8 +344,9 @@ InitStatus CbmMvdDigitizer::ReInit() { return kSUCCESS; } // ----- Virtual method Finish ----------------------------------------- void CbmMvdDigitizer::Finish() { - Int_t i = DetectPlugin(100); - LOG(debug) << "CbmMvdDigitizer::Finish() Autodetect: " << i << " Manual Detect " << fDigiPluginNr; + + Int_t nTargetPlugin = DetectPlugin(100); + LOG(debug) << "CbmMvdDigitizer::Finish() Autodetect: " << nTargetPlugin << " Manual Detect " << fDigiPluginNr; LOG(debug) << "finishing"; LOG(debug) << "Trying to show Histograms: " << fShowDebugHistos; @@ -353,7 +358,33 @@ void CbmMvdDigitizer::Finish() LOG(debug) << "Histograms completed"; + // Get the digis which are still in the sensor buffers fDetector->Finish(); + fDetector->GetOutputArray(nTargetPlugin, fTmpDigi); + fDetector->GetMatchArray(nTargetPlugin, fTmpMatch); + + // Send the remaining digis to the DAQ + Int_t nEntries = fTmpDigi->GetEntriesFast(); + LOG(info) << GetName() << " Finalising buffers with " << nEntries << " digis"; + for (Int_t index = 0; index < nEntries; index++) { + + CbmMvdDigi* digi = dynamic_cast<CbmMvdDigi*>(fTmpDigi->At(index)); + CbmMvdDigi* digi1 = new CbmMvdDigi(*digi); + assert(digi1); + fDigiVect.push_back(digi1); + + if (fCreateMatches) { + CbmMatch* match = dynamic_cast<CbmMatch*>(fTmpMatch->At(index)); + CbmMatch* match1 = new CbmMatch(*match); + fMatchVect.push_back(match1); + SendData(digi1->GetTime(), digi1, match1); + } + else { + SendData(digi1->GetTime(), digi1); + } + + } + PrintParameters(); } -- GitLab