10 #include "DAQDataFormats/RawTrigger.h" 11 #include "DAQDataFormats/RawTriggerHeader.h" 12 #include "DAQDataFormats/RawTriggerTime.h" 13 #include "DAQDataFormats/RawTriggerMask.h" 14 #include "DAQDataFormats/RawTriggerTimingMarker.h" 15 #include "DAQDataFormats/RawDataBlock.h" 16 #include "DAQDataFormats/RawMicroBlock.h" 17 #include "RawFileParser/RawFileParser.h" 18 #include "DAQChannelMap/DAQChannelMap.h" 25 #include "NovaDAQConventions/DAQConventions.h" 32 #include <boost/algorithm/string.hpp> 42 fFilterCorruptedNanoslices (false)
44 ,fNumberOfNonemptyMicroblocks(0)
45 ,fPulseHeight_values (pulseHeightVals)
46 ,fTimeStamp_values (timeStampVals)
47 ,fTrigger_values (triggerVals)
48 ,fTDC_values (nullptr)
50 ,fCurrentFileName (file_name)
62 std::vector<rawdata::RawDigit>* digits,
72 return ProcessRawEvent_(digits, raw_trigger, raw_sumDropMB, raw_sumDCM, flat_daq_data, daq_header);
77 std::vector<rawdata::RawDigit>* digits,
87 <<
"Read error attempting to obtain next raw event:" 88 << strerror(
errno) <<
".\n";
90 return result?
ProcessRawEvent_(digits, raw_trigger, raw_sumDropMB, raw_sumDCM, flat_daq_data, daq_header):
false;
120 std::cout<<
"Event Header markers are wrong\n";
129 #ifdef DAQDATAFORMATS_VERSIONING_IS_IMPLEMENTED 135 std::cout<<
"Trigger Header markers are wrong\n";
179 const uint32_t n_datablocks =
fRawEvent.getDataBlockNumber();
181 bool isSummaryEvent =
false;
184 uint32_t total_microslices=0;
186 for(uint32_t idatablock = 0; idatablock < n_datablocks; ++idatablock){
189 fRawEvent.setFloatingDataBlock(idatablock);
193 #ifdef DAQDATAFORMATS_VERSIONING_IS_IMPLEMENTED 196 if(datablock->getHeader()->checkMarker()) {
197 isSummaryEvent =
true;
204 std::cout<<
"DataBlock Header markers are wrong\n";
212 rsdm->getNumDroppedMicroblocks();
221 for(uint32_t ient = 0; ient < summaryDCMData->getHeader()->getNumEntries(); ++ient) {
222 thePoint = summaryDCMData->getDataPoint(ient);
223 if(!thePoint)
continue;
225 uint8_t dib = thePoint->getDCMID();
226 uint8_t
dcm = (thePoint->getDCMID() >> 8) & 0x1F;
227 uint8_t
det = (thePoint->getDCMID() >> 13);
237 raw_sumDCM->
_points.push_back(aPoint);
243 const uint32_t n_microblocks = datablock->getNumMicroBlocks();
245 for(uint32_t imicro = 0; imicro < n_microblocks; ++imicro){
248 datablock->setFloatingMicroBlock(imicro);
255 if(microslice->
getHeader()->getByteCount() < 8)
return false;
257 #ifndef DAQDATAFORMATS_VERSIONING_IS_IMPLEMENTED 259 if(microslice->
getHeader()->getByteCount() % 4)
return false;
262 if(!microslice->
getHeader()->getDataPresent() && microslice->
getHeader()->getByteCount()!= 8)
return false;
268 fDetId = (
int)microblock->getHeader()->getDetId();
278 const uint32_t
diblock = microblock->getHeader()->getDiblockId();
280 const uint32_t dcmid = microblock->getHeader()->getDCMId();
286 for(uint32_t inano = 0; inano < n_nanoslices; ++inano){
294 #ifdef DAQDATAFORMATS_VERSIONING_IS_IMPLEMENTED 295 const uint32_t nanoslice_version = nanoslice_header->getVersion();
297 const uint32_t nanoslice_version = 0;
303 if(!nanoslice_header->getDataPresent())
continue;
305 if(nanoslice_version == 0 && !nanoslice->checkReservedForCafe())
continue;
310 const uint32_t dcm_link = nanoslice_header->getFEBId();
312 const uint32_t pixel = nanoslice_header->getPixelAddr();
326 cmap->
getDCM(daq_channel);
327 cmap->
getFEB(daq_channel);
332 mf::LogError(
"BadDAQChannel") <<
"we have a bad DAQChannel " << daq_channel
333 <<
" don't make a digit from it";
338 const uint32_t local_channel = cmap->
encodeLChan(daq_channel);
341 #ifdef SUBTRACT_EVENT_TIME_FROM_HIT 342 const Long64_t nanoslice_time = nanoslice->getTimeStamp();
343 const Long64_t tdc_time = raw_trigger->
TDCT0();
344 const Long64_t time_difference = nanoslice_time - tdc_time;
345 const int32_t TDC = time_difference;
347 const uint32_t TDC = nanoslice->getTimeStamp();
366 if (nanoslice_version == 0){
367 const int32_t ADC = nanoslice->getPulseHeight();
372 #ifdef DAQDATAFORMATS_VERSIONING_IS_IMPLEMENTED 373 else if(nanoslice_version >= 1){
375 const int nsamples = nanoslice->getNSamples();
378 mf::LogError(
"NSamples") <<
"NSamples cannot be zero\n";
382 const uint32_t sample0 = nanoslice->getValue(0);
387 for(
int i=1;
i<nsamples; ++
i){
397 mf::LogError(
"Version") <<
"Unknown nanoslice version" << nanoslice_version<<
"\n";
403 digits->push_back(
fDigit);
417 std::cout<<
"From "<<__PRETTY_FUNCTION__<<
":"<<__LINE__;
418 std::cout<<
" Warning!!! Could not get the detector ID.";
437 if(!file_name)
return false;
439 if (boost::find_first(*file_name,
"ndos") || boost::find_first(*file_name,
"NDOS")){
442 else if(boost::find_first(*file_name,
"fardet") || boost::find_first(*file_name,
"FarDet")){
445 else if(boost::find_first(*file_name,
"neardet") || boost::find_first(*file_name,
"NearDet")){
448 else if(boost::find_first(*file_name,
"testbeam") || boost::find_first(*file_name,
"TestBeam")){
int fNumberOfDigits
! Detector type
static std::string GetName(int id)
uint32_t fTriggerMask_TriggerTypesHigh2
int getDetector(uint32_t anychan) const
uint32_t fTriggerMask_Prescale
void SetDetector(novadaq::cnv::DetId det)
Call this if you have definitive special knowledge (ie you're the Geometry service) ...
diblock
print "ROW IS " print row
uint32_t fTriggerHeader_SourceID
! Trigger source (see DAQDataFormats/TriggerDefines.h)
RawSumDCMType fSumTrig_DCM_Type
void SetTDC(int32_t iTDC)
uint32_t fNumberOfNonemptyMicroblocks
uint32_t fTriggerHeader_SourceSubID
virtual DetView_TYPE getView(dchan daqchan) const =0
Which view (X or Y) does this daq channel readout?
uint8_t fTriggerHeader_Source
uint32_t fSumTrig_NumDroppedMicroblocks
uint16_t fReserved
Should be 0xCAFE.
~OnlineUnpack()
Destructor.
void SetChannel(uint32_t iChan)
bool fFilterCorruptedNanoslices
Do we need to filter out Corrupted NanoSlices?
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
void * getRawBufferPointer() const
uint32_t fSumTrig_DCM_TimeStampLow
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
std::vector< RawSumDCMPoint > _points
::xsd::cxx::tree::buffer< char > buffer
uint8_t fTriggerTime_ClockSource
int fDetId
Detector ID reading from Microblocks.
uint8_t fTriggerMask_TriggerType
TH1F * fPulseHeight_values
uint32_t fTriggerMask_TriggerTypesLow
void SetADC(uint32_t i, int16_t iADC)
uint8_t fTriggerMask_TMod
unsigned long long fTriggerHeader_MasterTriggerNumber
Far Detector at Ash River, MN.
unsigned long long fTriggerTimingMarker_ExtractionStart
const std::string * fCurrentFileName
Current file name.
uint32_t fTriggerHeader_Source
uint8_t fVersion
NanoSlice version.
daqdataformats::RawEvent fRawEvent
Flat DAQ RawEvent.
uint32_t fTriggerTime_ClockSource
uint32_t fTriggerRange_TriggerLength
static DAQChannelMap * getInstance(int detID)
uint8_t fFrameSequenceNumber
bool ProcessRawEvent_(std::vector< rawdata::RawDigit > *, rawdata::RawTrigger *, rawdata::RawSumDropMB *, rawdata::RawSumDCM *, rawdata::FlatDAQData *, rawdata::DAQHeader *)
uint32_t fTriggerMask_MCBit
Prototype Near Detector on the surface at FNAL.
unsigned long long fTriggerTimingMarker_TimeStart
Near Detector in the NuMI cavern.
unsigned long long fTriggerTime_GenTime
void SetDaqChannel(uint32_t iChan)
rawdata::RawDigit fDigit
Instance of RawDigit class.
unsigned long long fTriggerTime_GenTime
uint32_t fTriggerMask_Prescale
A module to produce rawdata::RawDigits from NOvADDT DAQHits.
uint16_t fTriggerHeader_SourceID
A very simple service to remember what detector we're working in.
uint32_t fTriggerMask_TMod
uint64_t fSumTrig_TimeStamp
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
pixel_t getPixel(dchan daqchan) const
Decode the pixel id from a dchan.
uint32_t fTriggerMask_TriggerTypesHigh
uint32_t fSumTrig_TimeStampLow
unsigned long long fTriggerHeader_TriggerNumber
unsigned long long fTriggerTimingMarker_TimeStart
bool getDetIDFromFileName(const std::string *)
Try to get Detector ID from the file name.
unsigned long long fTriggerTimingMarker_ExtractionStart
assert(nhit_max >=nhit_nbins)
unsigned long long fTriggerHeader_TriggerNumber
! Identifier of the subsystem or channel on source device
cmap::CMap class source code
uint32_t fTriggerRange_TriggerLength
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
int getEvent(daqdataformats::RawEvent &theEvent)
Retrieve the next event from the file.
dchan encodeDChan(int detID, diblock_t diblock, dcm_id_t dcm, feb_t feb, pixel_t pixel) const
uint32_t fSumTrig_DCM_TimeStampHigh
uint32_t dchan
< DAQ Channel Map Package
unsigned long long TDCT0() const
Return just the lower 32 bits of the timing marker. This is the reference "t0" for the RawDigit TDC c...
std::vector< char > fRawBuffer
Flat event data.
uint32_t fSumTrig_TimeStampHigh
bool ProcessRawEvent(void *rawevent_buffer, std::vector< rawdata::RawDigit > *, rawdata::RawTrigger *, rawdata::RawSumDropMB *, rawdata::RawSumDCM *, rawdata::FlatDAQData *, rawdata::DAQHeader *)
Unpack the RawEvent.
UnpackedEvent fUnpackedEventParameters
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
unsigned long long fTriggerHeader_MasterTriggerNumber
! Universal trigger number
uint32_t fTriggerHeader_SourceSubID
! Identifier of the source system
feb_t getFEB(dchan daqchan) const
Decode the feb id from a dchan.
OnlineUnpack(TH1F *pulseHeightVals, TH1F *timeStampVals, TH1F *triggerVals, const std::string *file_name=nullptr)
Constructor.