diff --git a/sim/detectors/mvd/CbmMvdDigitizer.cxx b/sim/detectors/mvd/CbmMvdDigitizer.cxx index 05fe019b8f671de9ac10a3cbd93dd9c77b5fe070..5586853e296893fbc1df10d8e37e8eee6a07f274 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(); }