diff --git a/src/cmd/src/ProcBlockManager.cc b/src/cmd/src/ProcBlockManager.cc index b5da6d2f..f507ad6e 100644 --- a/src/cmd/src/ProcBlockManager.cc +++ b/src/cmd/src/ProcBlockManager.cc @@ -27,6 +27,7 @@ #include #include #include +#include namespace RAT { @@ -89,6 +90,7 @@ ProcBlockManager::ProcBlockManager(ProcBlock *theMainBlock) { AppendProcessor(); AppendProcessor(); AppendProcessor(); + AppendProcessor(); // Misc AppendProcessor(); AppendProcessor(); diff --git a/src/daq/CMakeLists.txt b/src/daq/CMakeLists.txt index 2df9753e..3b01b79b 100644 --- a/src/daq/CMakeLists.txt +++ b/src/daq/CMakeLists.txt @@ -17,6 +17,7 @@ add_library(daq OBJECT src/SplitEVDAQProc.cc src/TrueDAQProc.cc src/WaveformAnalysis.cc + src/RENETestDAQProc.cc ) # Set our include directories diff --git a/src/daq/include/RAT/RENETestDAQProc.hh b/src/daq/include/RAT/RENETestDAQProc.hh new file mode 100644 index 00000000..348e32ab --- /dev/null +++ b/src/daq/include/RAT/RENETestDAQProc.hh @@ -0,0 +1,46 @@ +#ifndef __RAT_RENETestDAQProc__ +#define __RAT_RENETestDAQProc__ + +#include +#include +#include +#include +#include + +namespace RAT { + +class RENETestDAQProc : public Processor { + public: + RENETestDAQProc(); + virtual ~RENETestDAQProc(){}; + virtual Processor::Result DSEvent(DS::Root *ds); + void SetD(std::string param, double value); + void SetI(std::string param, int value); + + void BeginOfRun(DS::Run *run); + + protected: + int fEventCounter; + double fPulseWidth; + double fTriggerThreshold; + double fTriggerWindow; + double fPmtLockout; + double fTriggerLockout; + double fTriggerResolution; + double fLookback; + double fMaxHitTime; + bool fDigitize; + bool fAnalyze; + + int fTriggerOnNoise; + DBLinkPtr ldaq; + + Digitizer *fDigitizer; + std::string fDigitizerType; + + WaveformAnalysis *fWaveformAnalysis; +}; + +} // namespace RAT + +#endif diff --git a/src/daq/src/RENETestDAQProc.cc b/src/daq/src/RENETestDAQProc.cc new file mode 100644 index 00000000..6114d865 --- /dev/null +++ b/src/daq/src/RENETestDAQProc.cc @@ -0,0 +1,349 @@ +/* SplitEVDAQ is an extension of the SimpleDAQ that converts hits into multiple + * triggers, and places those in new events (not subevents) to better simulate + * data and produce combined datasets. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +namespace RAT { + +RENETestDAQProc::RENETestDAQProc() : Processor("renetestdaq") { + // Trigger Specifications +std::cout<<"YUN1---------------------------------------------------------hhhhhhhhhhh"<GetLink("DAQ", "SplitEVDAQ"); + fEventCounter = 0; + fPulseWidth = ldaq->GetD("pulse_width"); + fTriggerThreshold = ldaq->GetD("trigger_threshold"); + fTriggerWindow = ldaq->GetD("trigger_window"); + fPmtLockout = ldaq->GetD("pmt_lockout"); + fTriggerLockout = ldaq->GetD("trigger_lockout"); + fTriggerResolution = ldaq->GetD("trigger_resolution"); + fLookback = ldaq->GetD("lookback"); + fMaxHitTime = ldaq->GetD("max_hit_time"); + fTriggerOnNoise = ldaq->GetI("trigger_on_noise"); + fDigitizerType = ldaq->GetS("digitizer_name"); + fDigitize = ldaq->GetZ("digitize"); + fAnalyze = ldaq->GetZ("analyze"); + + fDigitizer = new Digitizer(fDigitizerType); + fWaveformAnalysis = new WaveformAnalysis(); +} + +void RENETestDAQProc::BeginOfRun(DS::Run *run) { +std::cout<<"YUN2---------------------------------------------------------hhhhhhhhhh"<GetPMTInfo(); + const size_t numModels = pmtinfo->GetModelCount(); + for (size_t i = 0; i < numModels; i++) { + const std::string modelName = pmtinfo->GetModelName(i); + fDigitizer->AddWaveformGenerator(modelName); + } + } +} + +Processor::Result RENETestDAQProc::DSEvent(DS::Root *ds) { +std::cout<<"YUN3---------------------------------------------------------hhhhhhhhhh"<GetMC(); + DS::Run *run = DS::RunStore::Get()->GetRun(ds); + DS::PMTInfo *pmtinfo = run->GetPMTInfo(); + // Prune the previous EV branchs if one exists + if (ds->ExistEV()) ds->PruneEV(); + +///////////////////////////////////////////////////////////////////////////////////////////////////// +// declare several std::vectors + std::vector iArray, iArraySort; // index + std::vector tArray, tArraySort; // front end time + std::vector qArray, qArraySort; // charge + std::vector idArray, idArraySort; // PMT ID + std::vector phArray, phArraySort; // photon count ...we are not using this... + std::vector htArray, htArraySort; // hit time ...we are not using this either... +/////////////////////////////////////////////////////////////////////////////// +std::vector QArrayV; +std::vector QArrayRawV; +std::vector fNPEArrayV; + + +int numSub = 0; + + std::vector subIndex; + std::vector clusterTime; + std::vector triggerTime; + + std::vector startIndex; + + std::vector WaveV; + + double timeWindow = 500.0; //ns +double voltageThreshold = 500.; //mV + double samplingTime = 2.; //ns + double delayTime = -50.; //ns + + double maxFrontEndTime = 0.; + for (int imcpmt = 0; imcpmt < mc->GetMCPMTCount(); imcpmt++) { + DS::MCPMT *mcpmt0 = mc->GetMCPMT(imcpmt); + if (mcpmt0->GetMCPhotonCount() > 0) { + for (int i = 0; i < mcpmt0->GetMCPhotonCount(); i++) { + if((mcpmt0->GetMCPhoton(i)->GetFrontEndTime()) > maxFrontEndTime){ + maxFrontEndTime = (mcpmt0->GetMCPhoton(i)->GetFrontEndTime()); + } + } + } + } + int sizeOfQAV = TMath::Floor(maxFrontEndTime/samplingTime)+1+25; + std::cout<<"sizeOfQAV "<GetMCPMTCount(); imcpmt++) { + std::cout<<"--------------------------------mc->GetMCPMTCount() "<GetMCPMTCount() <GetMCPMT(imcpmt); + + if (mcpmt->GetMCPhotonCount() > 0) { + for (int i = 0; i < mcpmt->GetMCPhotonCount(); i++) { + tArray.push_back(mcpmt->GetMCPhoton(i)->GetFrontEndTime()); + tArraySort.push_back(mcpmt->GetMCPhoton(i)->GetFrontEndTime()); + qArray.push_back(mcpmt->GetMCPhoton(i)->GetCharge()); + idArray.push_back(mcpmt->GetID()); + iArray.push_back(i); + phArray.push_back(mcpmt->GetMCPhotonCount()); + htArray.push_back(mcpmt->GetMCPhoton(i)->GetHitTime()); + } + } + std::cout<<"--------------------------------tArray.size() "< 0) { + // group these events and get bunch of subevents. the cluster time will be + // the earliest time among the PMTs. + +/////////////////////////////////////////////////////////////////////////////////////////// + + + +QArrayV.clear(); +fNPEArrayV.clear(); +QArrayRawV.clear(); + +QArrayV.resize(sizeOfQAV, 0.); +fNPEArrayV.resize(sizeOfQAV, 0); +QArrayRawV.resize(sizeOfQAV, 0.); +std::cout<<"sizeOfQAV "<= voltageThreshold && triggerKey == 0 ){ + triggerKey = 1; + timeNow = a*samplingTime; + timeStart = a*samplingTime+delayTime; + if(timeStart < 0) timeStart = 0; + subIndex.push_back(numSub); + clusterTime.push_back(timeStart); + triggerTime.push_back(timeNow); + startIndex.push_back(TMath::Floor(timeStart/2)); + std::cout<<"--------------------------------timeStart "< timeWindow)){ + triggerKey = 0; + } +} +/////////////////////////////////////////////////////////////////////////////////////////////// + + std::cout<<"--------------------------------numSub "<GetMCPMTCount()<AddNewEV(); + DS::PMT *pmt; + fEventCounter += 1; + + if (b > 0) { + ev->SetDeltaT(clusterTime[b] - clusterTime[b - 1]); + } else { + ev->SetDeltaT(clusterTime[0]); + } + ev->SetCalibratedTriggerTime(clusterTime[b]); + ev->SetID(subIndex[b]); + // std::cout<<"--------------------------------ev->SetID(subIndex[b]); b "<GetID(); + WaveV.clear(); + pmt = ev->AddNewPMT(); + pmt->SetID(pmtID); + pmt->SetTime(startIndex[b]*2); + pmt->SetTriggerTime(triggerTime[b]); + std::cout<=QArrayV.size()){ + WaveV.push_back(QArrayV[QArrayV.size()-1]*50/samplingTime); + qSum += QArrayV[QArrayV.size()-1]; + }else{ + WaveV.push_back(QArrayV[startIndex[b]+getEVi]*50/samplingTime); + qSum += QArrayV[startIndex[b]+getEVi]; + } + //std::cout<<"-----------------C5 QQArrayV[startIndex[b]+getEVi]*50/samplingTime "<SetWaveVector(WaveV); + + + /////////////////////////////////////////////////////////////////////////////////////////////////// + pmt->SetCharge(qSum); + std::cout<<"--------------------------------C4 QArrayV.size() "<< QArrayV.size()<DigitizePMT(mcpmt, pmtID, startIndex[b]*2, pmtinfo); + if (fAnalyze) { + DS::DigitPMT *digitpmt = ev->AddNewDigitPMT(); + digitpmt->SetID(pmtID); + fWaveformAnalysis->RunAnalysis(digitpmt, pmtID, fDigitizer); + } + } + + + if (fDigitize) { + fDigitizer->DigitizeSum(ev); + } + +//std::cout<<"--------------------------------fDigitize9"<SetTotalCharge(qSum); + } + } +return Processor::OK; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////////////// + + +void RENETestDAQProc::SetD(std::string param, double value) { +std::cout<<"YUN4---------------------------------------------------------hhhhhhhhhhhhhh"<peak = _peak; } virtual Double_t GetPeakVoltage() { return peak; } + + virtual void SetTriggerTime(double _triggerTime) { this->triggerTime = _triggerTime; } + virtual double GetTriggerTime() { return triggerTime; } + + virtual void SetWaveVector(const std::vector& _WaveVector) { this->WaveVector = _WaveVector; } + virtual const std::vector& GetWaveVector() const { return WaveVector; } ClassDef(PMT, 4); @@ -76,6 +82,10 @@ class PMT : public TObject { Double_t timeOverThresh; Double_t pedestal; Double_t peak; + + double triggerTime; + + std::vector WaveVector; }; } // namespace DS