/* * CbmMuchNewReadoutBuffer.cxx * * Created on: 11.05.2016 * Author: vikas@vecc.gov.in */ #include "CbmMuchNewReadoutBuffer.h" // ----- Initialisation of static variables ------------------------------ CbmMuchNewReadoutBuffer* CbmMuchNewReadoutBuffer::fgInstance = NULL; // --------------------------------------------------------------------------- //This Modify Function will be called from CbmReadoutBuffer::Fill(). //2 CbmMuchSignal has to be merged and create one, as both hit on the same Detector or Pad within detector deadtime window. //SignalStart time and SignalEnd time is already modified. //ADC has to be summed up //Matches of two also be joined. Int_t CbmMuchNewReadoutBuffer::Modify(CbmMuchNewSignal* oldData1, CbmMuchNewSignal* oldData2, std::vector& newDataList) { LOG(INFO) << "Modify called " << ++fCounter << " times." << FairLogger::endl; //std::cout << "Modify: old data 1 at t = " << oldData1->GetTimeStart() // << " to " << oldData1->GetTimeStop() << FairLogger::endl; //std::cout << "Modify: old data 2 at t = " << oldData2->GetTimeStart() // << " to " << oldData2->GetTimeStop() << FairLogger::endl; LOG(INFO) << "Modify: old data 1 at t = " << oldData1->GetTimeStart() << " to " << oldData1->GetTimeStop() << FairLogger::endl; LOG(INFO) << "Modify: old data 2 at t = " << oldData2->GetTimeStart() << " to " << oldData2->GetTimeStop() << FairLogger::endl; CbmMuchNewSignal* firstData = oldData1; CbmMuchNewSignal* secondData = oldData2; if ( oldData1->GetTimeStart() > oldData2->GetTimeStart() ) { firstData = oldData2; secondData = oldData1; } /* Create a new signal from the first signal and then correspondingly modify the Match of that signal. * For this add secondData information to the newdata */ // Create new signal object same as firstData CbmMuchNewSignal* newData = new CbmMuchNewSignal(firstData->GetAddress()); newData->SetTimeStart(firstData->GetTimeStart()); newData->SetTimeStop(firstData->GetTimeStop()); // StartTime = Time of the first digi, // StopTime = Max stop time of both digis. // Add the new pair of time and charge to the map. newData->MergeSignal(secondData); Double_t stopTime = std::max(oldData1->GetTimeStop(), oldData2->GetTimeStop() ); newData->SetTimeStop(stopTime); //Merge matches of both data, created signal is new therefore contain nothing in the fMatch variable. //adding links of firstData->Match to NewMatch (newData->GetMatch())->AddLinks(*(secondData->GetMatch())); //adding links of SecondData->Match to NewMatch (newData->GetMatch())->AddLinks(*(secondData->GetMatch())); LOG(DEBUG4) << "Modify: new data at t = " << newData->GetTimeStart() << " to " << newData->GetTimeStop() << FairLogger::endl; //Add new data object to the result list newDataList.push_back(newData); return 1; // Number of return data objects } // ----- Instance -------------------------------------------------------- CbmMuchNewReadoutBuffer* CbmMuchNewReadoutBuffer::Instance() { if ( ! fgInstance ) fgInstance = new CbmMuchNewReadoutBuffer(); return fgInstance; } // --------------------------------------------------------------------------- ClassImp(CbmMuchNewReadoutBuffer)