Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
daq2raw::OnlineUnpack Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-28/DAQ2RawDigit/OnlineUnpack.h"

Public Member Functions

 OnlineUnpack (TH1F *pulseHeightVals, TH1F *timeStampVals, TH1F *triggerVals, const std::string *file_name=nullptr)
 Constructor. More...
 
 ~OnlineUnpack ()
 Destructor. More...
 
bool ProcessRawEvent (void *rawevent_buffer, std::vector< rawdata::RawDigit > *, rawdata::RawTrigger *, rawdata::RawSumDropMB *, rawdata::RawSumDCM *, rawdata::FlatDAQData *, rawdata::DAQHeader *)
 Unpack the RawEvent. More...
 
bool ProcessRawEvent (rawfileparser::RawFileParser &parser, std::vector< rawdata::RawDigit > *, rawdata::RawTrigger *, rawdata::RawSumDropMB *, rawdata::RawSumDCM *, rawdata::FlatDAQData *, rawdata::DAQHeader *)
 
uint32_t getRunNumber () const
 
uint32_t getSubrunNumber () const
 
unsigned long long getEventNumber () const
 
int getDetId () const
 
uint32_t getNumberOfNonemptyMicroblocks () const
 

Public Attributes

bool fFilterCorruptedNanoslices
 Do we need to filter out Corrupted NanoSlices? More...
 

Private Member Functions

bool ProcessRawEvent_ (std::vector< rawdata::RawDigit > *, rawdata::RawTrigger *, rawdata::RawSumDropMB *, rawdata::RawSumDCM *, rawdata::FlatDAQData *, rawdata::DAQHeader *)
 
bool getDetIDFromFileName (const std::string *)
 Try to get Detector ID from the file name. More...
 

Private Attributes

int fDetId
 Detector ID reading from Microblocks. More...
 
uint32_t fNumberOfNonemptyMicroblocks
 
daqdataformats::RawEvent fRawEvent
 Flat DAQ RawEvent. More...
 
rawdata::RawDigit fDigit
 Instance of RawDigit class. More...
 
UnpackedEvent fUnpackedEventParameters
 
TH1F * fPulseHeight_values
 
TH1F * fTimeStamp_values
 
TH1F * fTrigger_values
 
TH1F * fTDC_values
 
uint32_t fHitNumber
 
const std::stringfCurrentFileName
 Current file name. More...
 

Detailed Description

Definition at line 67 of file OnlineUnpack.h.

Constructor & Destructor Documentation

daq2raw::OnlineUnpack::OnlineUnpack ( TH1F *  pulseHeightVals,
TH1F *  timeStampVals,
TH1F *  triggerVals,
const std::string file_name = nullptr 
)

Constructor.

Definition at line 41 of file OnlineUnpack.cxx.

41  :
45  ,fPulseHeight_values (pulseHeightVals)
46  ,fTimeStamp_values (timeStampVals)
47  ,fTrigger_values (triggerVals)
48  ,fTDC_values (nullptr)
49  ,fHitNumber (0)
51 {
52 }
uint32_t fNumberOfNonemptyMicroblocks
Definition: OnlineUnpack.h:101
bool fFilterCorruptedNanoslices
Do we need to filter out Corrupted NanoSlices?
Definition: OnlineUnpack.h:96
int fDetId
Detector ID reading from Microblocks.
Definition: OnlineUnpack.h:100
const std::string * fCurrentFileName
Current file name.
Definition: OnlineUnpack.h:116
daq2raw::OnlineUnpack::~OnlineUnpack ( )

Destructor.

Definition at line 56 of file OnlineUnpack.cxx.

57 {
58 }

Member Function Documentation

int daq2raw::OnlineUnpack::getDetId ( ) const
inline

Definition at line 82 of file OnlineUnpack.h.

Referenced by daq2raw::NOvARawInputDriver::readNext(), daq2raw::NOvASocketInputDriver::readNext(), and daq2raw::TestBeamRawInputDriver::readNext().

82 { return fDetId; }
int fDetId
Detector ID reading from Microblocks.
Definition: OnlineUnpack.h:100
bool daq2raw::OnlineUnpack::getDetIDFromFileName ( const std::string file_name)
private

Try to get Detector ID from the file name.

Definition at line 435 of file OnlineUnpack.cxx.

References fDetId, novadaq::cnv::kFARDET, novadaq::cnv::kNDOS, novadaq::cnv::kNEARDET, and novadaq::cnv::kTESTBEAM.

Referenced by ProcessRawEvent_().

435  {
436 
437  if(!file_name) return false;
438 
439  if (boost::find_first(*file_name, "ndos") || boost::find_first(*file_name, "NDOS")){
441  }
442  else if(boost::find_first(*file_name, "fardet") || boost::find_first(*file_name, "FarDet")){
444  }
445  else if(boost::find_first(*file_name, "neardet") || boost::find_first(*file_name, "NearDet")){
447  }
448  else if(boost::find_first(*file_name, "testbeam") || boost::find_first(*file_name, "TestBeam")){
450  }
451  // If file_name exists but no matching detector string found, return false.
452  else return false;
453 
454  return true;
455 }
int fDetId
Detector ID reading from Microblocks.
Definition: OnlineUnpack.h:100
Far Detector at Ash River, MN.
Prototype Near Detector on the surface at FNAL.
Near Detector in the NuMI cavern.
unsigned long long daq2raw::OnlineUnpack::getEventNumber ( ) const
inline

Definition at line 81 of file OnlineUnpack.h.

Referenced by daq2raw::NOvARawInputDriver::readNext(), daq2raw::NOvASocketInputDriver::readNext(), and daq2raw::TestBeamRawInputDriver::readNext().

81 { return fRawEvent.getEventNumber(); }
daqdataformats::RawEvent fRawEvent
Flat DAQ RawEvent.
Definition: OnlineUnpack.h:103
uint32_t daq2raw::OnlineUnpack::getNumberOfNonemptyMicroblocks ( ) const
inline

Definition at line 83 of file OnlineUnpack.h.

References string.

uint32_t fNumberOfNonemptyMicroblocks
Definition: OnlineUnpack.h:101
uint32_t daq2raw::OnlineUnpack::getRunNumber ( ) const
inline

Definition at line 79 of file OnlineUnpack.h.

Referenced by daq2raw::NOvARawInputDriver::readNext(), daq2raw::NOvASocketInputDriver::readNext(), and daq2raw::TestBeamRawInputDriver::readNext().

79 { return fRawEvent.getRunNumber(); }
daqdataformats::RawEvent fRawEvent
Flat DAQ RawEvent.
Definition: OnlineUnpack.h:103
uint32_t daq2raw::OnlineUnpack::getSubrunNumber ( ) const
inline

Definition at line 80 of file OnlineUnpack.h.

Referenced by daq2raw::NOvARawInputDriver::readNext(), daq2raw::NOvASocketInputDriver::readNext(), and daq2raw::TestBeamRawInputDriver::readNext().

80 { return fRawEvent.getSubrun(); }
daqdataformats::RawEvent fRawEvent
Flat DAQ RawEvent.
Definition: OnlineUnpack.h:103
bool daq2raw::OnlineUnpack::ProcessRawEvent ( void rawevent_buffer,
std::vector< rawdata::RawDigit > *  digits,
rawdata::RawTrigger raw_trigger,
rawdata::RawSumDropMB raw_sumDropMB,
rawdata::RawSumDCM raw_sumDCM,
rawdata::FlatDAQData flat_daq_data,
rawdata::DAQHeader daq_header 
)

Unpack the RawEvent.

Definition at line 61 of file OnlineUnpack.cxx.

References fRawEvent, and ProcessRawEvent_().

Referenced by daq2raw::NOvARawInputDriver::readNext(), daq2raw::NOvASocketInputDriver::readNext(), and daq2raw::TestBeamRawInputDriver::readNext().

67  {
68 
69  // First set the pointer to the raw Buffer.
70  fRawEvent.setBufferSource(buffer);
71 
72  return ProcessRawEvent_(digits, raw_trigger, raw_sumDropMB, raw_sumDCM, flat_daq_data, daq_header);
73 }
::xsd::cxx::tree::buffer< char > buffer
Definition: Database.h:179
daqdataformats::RawEvent fRawEvent
Flat DAQ RawEvent.
Definition: OnlineUnpack.h:103
bool ProcessRawEvent_(std::vector< rawdata::RawDigit > *, rawdata::RawTrigger *, rawdata::RawSumDropMB *, rawdata::RawSumDCM *, rawdata::FlatDAQData *, rawdata::DAQHeader *)
bool daq2raw::OnlineUnpack::ProcessRawEvent ( rawfileparser::RawFileParser parser,
std::vector< rawdata::RawDigit > *  digits,
rawdata::RawTrigger raw_trigger,
rawdata::RawSumDropMB raw_sumDropMB,
rawdata::RawSumDCM raw_sumDCM,
rawdata::FlatDAQData flat_daq_data,
rawdata::DAQHeader daq_header 
)

Definition at line 76 of file OnlineUnpack.cxx.

References errno, art::errors::FileReadError, fRawEvent, rawfileparser::RawFileParser::getEvent(), ProcessRawEvent_(), and fillBadChanDBTables::result.

82  {
83  errno = 0; // Currently our only way of distinguishing EOF from read failure.
84  const bool result = parser.getEvent(fRawEvent);
85  if (errno) {
87  << "Read error attempting to obtain next raw event:"
88  << strerror(errno) << ".\n";
89  }
90  return result?ProcessRawEvent_(digits, raw_trigger, raw_sumDropMB, raw_sumDCM, flat_daq_data, daq_header):false;
91 }
daqdataformats::RawEvent fRawEvent
Flat DAQ RawEvent.
Definition: OnlineUnpack.h:103
bool ProcessRawEvent_(std::vector< rawdata::RawDigit > *, rawdata::RawTrigger *, rawdata::RawSumDropMB *, rawdata::RawSumDCM *, rawdata::FlatDAQData *, rawdata::DAQHeader *)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
int getEvent(daqdataformats::RawEvent &theEvent)
Retrieve the next event from the file.
int errno
Definition: errno.cpp:12
bool daq2raw::OnlineUnpack::ProcessRawEvent_ ( std::vector< rawdata::RawDigit > *  digits,
rawdata::RawTrigger raw_trigger,
rawdata::RawSumDropMB raw_sumDropMB,
rawdata::RawSumDCM raw_sumDCM,
rawdata::FlatDAQData flat_daq_data,
rawdata::DAQHeader daq_header 
)
private

Variable that is saying whether there was at least one Microblock We are getting detector ID from microblocks. If there is none, we'll take it from Configuration Block

Resizing the size of the FlatDAQData buffer to the size of the event fRawEvent.sizeofdata() returns the size in words, so we need to multiply by 4

Now, fill FlatDAQData object with the event

Checking for the markers

Trigger pointer

Checking Trigger markers

Filling Trigger stuff

Loop over DataBlocks

Counter for total number of microslices in the event

Checking DataBlock markers

Loop over the MicroBlocks

Set the microblock

Doing various checks

  1. Cannot be less than 8
  2. Has to be dividable by 4 if nanoslice is version 0
  3. Cannot be empty

Increment the total number of valid microslices in the event

Inform everyone of the detector ID.

Increment fNumberOfNonemptyMicroblocks

Diblock number

DCM number in the diblock

Loop over NanoSlices

Set the nanoslice

See if we need to filter the nanoslice

NanoSlice has to have DataPresent Flag

NanoSlice version 0 has to have Reserved field set to 0xCAFE

DCM link number for the FEB

Pixel number

Get the daq channel for the hit

get local channel from the DAQ channel

Event time

Push Raw Digit

Advance the hit number

Bug in Datalogger that has detector ID in Configuration block different than in Microblocks Try to figure out the detector from the file name

Now filling DAQHeader

Definition at line 94 of file OnlineUnpack.cxx.

References rawdata::RawSumDCM::_points, ana::assert(), om::cout, daqdataformats::CURRENT_FIELDS_SUB_NAMESPACE::DataBlock_Marker, febshutoff_auto::dcm, fillBadChanDBTables::det, geo2elec::diblock, daqchannelmap::DAQChannelMap::encodeDChan(), daqchannelmap::DAQChannelMap::encodeLChan(), allTimeWatchdog::endl, fCurrentFileName, rawdata::RawDigit::fDataPresent, rawdata::RawDigit::fDebugMode, fDetId, fDigit, rawdata::RawDigit::fFEBStatus, fFilterCorruptedNanoslices, rawdata::RawDigit::fFrameSequenceNumber, fHitNumber, rawdata::RawDigit::fLinkStatus, daq2raw::UnpackedEvent::fNumberOfDigits, fNumberOfNonemptyMicroblocks, fPulseHeight_values, rawdata::FlatDAQData::fRawBuffer, fRawEvent, rawdata::RawDigit::fReserved, rawdata::RawSumDropMB::fSumTrig_BuffId, rawdata::RawSumDCMPoint::fSumTrig_DCM_dcm, rawdata::RawSumDCMPoint::fSumTrig_DCM_det, rawdata::RawSumDCMPoint::fSumTrig_DCM_dib, rawdata::RawSumDCMPoint::fSumTrig_DCM_TimeStampHigh, rawdata::RawSumDCMPoint::fSumTrig_DCM_TimeStampLow, rawdata::RawSumDCMPoint::fSumTrig_DCM_Type, rawdata::RawSumDropMB::fSumTrig_NumDroppedMicroblocks, rawdata::RawSumDropMB::fSumTrig_TimeStamp, rawdata::RawSumDropMB::fSumTrig_TimeStampHigh, rawdata::RawSumDropMB::fSumTrig_TimeStampLow, fTDC_values, fTimeStamp_values, fTrigger_values, rawdata::RawTrigger::fTriggerHeader_MasterTriggerNumber, daq2raw::UnpackedEvent::fTriggerHeader_MasterTriggerNumber, rawdata::RawTrigger::fTriggerHeader_Source, daq2raw::UnpackedEvent::fTriggerHeader_Source, rawdata::RawTrigger::fTriggerHeader_SourceID, daq2raw::UnpackedEvent::fTriggerHeader_SourceID, rawdata::RawTrigger::fTriggerHeader_SourceSubID, daq2raw::UnpackedEvent::fTriggerHeader_SourceSubID, rawdata::RawTrigger::fTriggerHeader_TriggerNumber, daq2raw::UnpackedEvent::fTriggerHeader_TriggerNumber, rawdata::RawTrigger::fTriggerMask_MCBit, daq2raw::UnpackedEvent::fTriggerMask_MCBit, rawdata::RawTrigger::fTriggerMask_Prescale, daq2raw::UnpackedEvent::fTriggerMask_Prescale, rawdata::RawTrigger::fTriggerMask_TMod, daq2raw::UnpackedEvent::fTriggerMask_TMod, rawdata::RawTrigger::fTriggerMask_TriggerType, daq2raw::UnpackedEvent::fTriggerMask_TriggerTypesHigh, daq2raw::UnpackedEvent::fTriggerMask_TriggerTypesHigh2, daq2raw::UnpackedEvent::fTriggerMask_TriggerTypesLow, rawdata::RawTrigger::fTriggerRange_TriggerLength, daq2raw::UnpackedEvent::fTriggerRange_TriggerLength, rawdata::RawTrigger::fTriggerTime_ClockSource, daq2raw::UnpackedEvent::fTriggerTime_ClockSource, rawdata::RawTrigger::fTriggerTime_GenTime, daq2raw::UnpackedEvent::fTriggerTime_GenTime, rawdata::RawTrigger::fTriggerTimingMarker_ExtractionStart, daq2raw::UnpackedEvent::fTriggerTimingMarker_ExtractionStart, rawdata::RawTrigger::fTriggerTimingMarker_TimeStart, daq2raw::UnpackedEvent::fTriggerTimingMarker_TimeStart, fUnpackedEventParameters, rawdata::RawDigit::fVersion, daqchannelmap::DAQChannelMap::getDCM(), daqchannelmap::DAQChannelMap::getDetector(), getDetIDFromFileName(), daqchannelmap::DAQChannelMap::getDiBlock(), daqchannelmap::DAQChannelMap::getFEB(), daqdataformats::RawMicroSlice::getFloatingNanoSlice(), daqdataformats::RawNanoSlice::getHeader(), daqdataformats::RawMicroSlice::getHeader(), daqchannelmap::DAQChannelMap::getInstance(), novadaq::cnv::DetInfo::GetName(), daqdataformats::RawMicroSlice::getNumNanoSlices(), daqchannelmap::DAQChannelMap::getPixel(), rawdata::FlatDAQData::getRawBufferPointer(), daqchannelmap::DAQChannelMap::getView(), MECModelEnuComparisons::i, makeTrainCVSamples::int, daqdataformats::CURRENT_FIELDS_SUB_NAMESPACE::Marker_value, rawdata::RawDigit::SetADC(), rawdata::RawDigit::SetChannel(), rawdata::RawDigit::SetDaqChannel(), ds::DetectorService::SetDetector(), rawdata::DAQHeader::SetDetId(), daqdataformats::RawMicroSlice::setFloatingNanoSlice(), rawdata::RawDigit::SetTDC(), rawdata::DAQHeader::SetTotalMicroSlices(), daqdataformats::CURRENT_FIELDS_SUB_NAMESPACE::SummaryBlock_Marker, rawdata::RawTrigger::TDCT0(), and daqdataformats::CURRENT_FIELDS_SUB_NAMESPACE::TriggerHeaderDelimiter.

Referenced by ProcessRawEvent().

99  {
100 
101 
102  /// Variable that is saying whether there was at least one Microblock
103  /// We are getting detector ID from microblocks. If there is none, we'll take it from Configuration Block
105  /// Resizing the size of the FlatDAQData buffer to the size of the event
106  /// fRawEvent.sizeofdata() returns the size in words, so we need to multiply by 4
107  flat_daq_data->fRawBuffer.resize(fRawEvent.sizeofdata() * 4);
108 
109  /// Now, fill FlatDAQData object with the event
110  fRawEvent.writeData(flat_daq_data->getRawBufferPointer());
111 
112 #ifdef RUNCHECKS
113  std::cout << "Checks = " <<
114  qc.checkEvent(fRawEvent) << std::endl;
115 #endif
116 
117  /// Checking for the markers
118  if ( fRawEvent.getHeaderMarkerLeft() != daqdataformats::raweventhdr::Marker_value[0]
119  || fRawEvent.getHeaderMarkerRight() != daqdataformats::raweventhdr::Marker_value[1]){
120  std::cout<<"Event Header markers are wrong\n";
121 
122  return false;
123  }
124 
125  /// Trigger pointer
126  daqdataformats::RawTrigger* trigger = fRawEvent.getTrigger();
127 
128  /// Checking Trigger markers
129 #ifdef DAQDATAFORMATS_VERSIONING_IS_IMPLEMENTED
130  if ( trigger->getTriggerHeader()->getDelimiter() != daqdataformats::triggerheader::TriggerHeaderDelimiter ){
131 #else
132  if ( trigger->getTriggerHeader()->getDelimiter() != daqdataformats::TriggerHeaderDelimiter ){
133 #endif
134 
135  std::cout<<"Trigger Header markers are wrong\n";
136  return false;
137  }
138  // Now the unpacking...
139 
140  /// Filling Trigger stuff
141  fUnpackedEventParameters.fTriggerHeader_Source = trigger->getTriggerHeader()->getSource();
142  fUnpackedEventParameters.fTriggerHeader_SourceID = trigger->getTriggerHeader()->getSourceID();
143  fUnpackedEventParameters.fTriggerHeader_SourceSubID = trigger->getTriggerHeader()->getSourceSubID();
144  fUnpackedEventParameters.fTriggerHeader_TriggerNumber = trigger->getTriggerHeader()->getTriggerNumber();
145  fUnpackedEventParameters.fTriggerHeader_MasterTriggerNumber = trigger->getTriggerHeader()->getMasterTriggerNumber();
146  fUnpackedEventParameters.fTriggerTime_GenTime = trigger->getTriggerTime()->getTriggerTimeStamp();
147  fUnpackedEventParameters.fTriggerTime_ClockSource = trigger->getTriggerTime()->getClockSource();
148  fUnpackedEventParameters.fTriggerTimingMarker_TimeStart = trigger->getTriggerTimingMarker()->getTriggerStart_baseClock();
149  fUnpackedEventParameters.fTriggerTimingMarker_ExtractionStart = trigger->getTriggerTimingMarker()->getTriggerStart_833kHz();
150  fUnpackedEventParameters.fTriggerRange_TriggerLength = trigger->getTriggerRange()->getTriggerLength();
151  fUnpackedEventParameters.fTriggerMask_MCBit = trigger->getTriggerMask()->getMonteCarloFlag();
152  fUnpackedEventParameters.fTriggerMask_TMod = trigger->getTriggerMask()->getTrigMod();
153  fUnpackedEventParameters.fTriggerMask_TriggerTypesLow = trigger->getTriggerMask()->getTrigMask_Low();
154  fUnpackedEventParameters.fTriggerMask_TriggerTypesHigh = trigger->getTriggerMask()->getTrigMask_High();
155  fUnpackedEventParameters.fTriggerMask_TriggerTypesHigh2 = trigger->getTriggerMask()->getTrigMask_High2();
156  fUnpackedEventParameters.fTriggerMask_Prescale = trigger->getTriggerMask()->getPrescale();
157 
169  raw_trigger->fTriggerMask_TriggerType = trigger->getTriggerMask()->getTriggerMask();
172  else raw_trigger->fTriggerMask_MCBit = false;
173 
175 
177 
178  /// Loop over DataBlocks
179  const uint32_t n_datablocks = fRawEvent.getDataBlockNumber();
180 
181  bool isSummaryEvent = false;
182 
183  /// Counter for total number of microslices in the event
184  uint32_t total_microslices=0;
185 
186  for(uint32_t idatablock = 0; idatablock < n_datablocks; ++idatablock){
187 
188  // Set the datablock
189  fRawEvent.setFloatingDataBlock(idatablock);
190  daqdataformats::RawDataBlock* datablock = fRawEvent.getFloatingDataBlock();
191 
192  /// Checking DataBlock markers
193 #ifdef DAQDATAFORMATS_VERSIONING_IS_IMPLEMENTED
194  if ( datablock->getHeader()->getMarker() == daqdataformats::datablockheader::SummaryBlock_Marker ){
195 
196  if(datablock->getHeader()->checkMarker()) {
197  isSummaryEvent = true;
198  }
199  }
200  else if ( datablock->getHeader()->getMarker() != daqdataformats::datablockheader::DataBlock_Marker ){
201 #else
202  if ( datablock->getHeader()->getMarker() != daqdataformats::datablock::DataBlock_Marker ){
203 #endif
204  std::cout<<"DataBlock Header markers are wrong\n";
205  return false;
206  }// end of checking DataBlock markers
207 
208  if(isSummaryEvent) {
210 
211  raw_sumDropMB->fSumTrig_NumDroppedMicroblocks =
212  rsdm->getNumDroppedMicroblocks();
213  raw_sumDropMB->fSumTrig_TimeStamp = rsdm->getTimeStamp();
214  raw_sumDropMB->fSumTrig_TimeStampLow = rsdm->getTimeStampLow();
215  raw_sumDropMB->fSumTrig_TimeStampHigh = rsdm->getTimeStampHigh();
216  raw_sumDropMB->fSumTrig_BuffId = datablock->getBuffId();
217 
218  daqdataformats::RawSummaryDCMData* summaryDCMData = (daqdataformats::RawSummaryDCMData*)datablock->getDCMData();
220 
221  for(uint32_t ient = 0; ient < summaryDCMData->getHeader()->getNumEntries(); ++ient) {
222  thePoint = summaryDCMData->getDataPoint(ient);
223  if(!thePoint) continue;
224 
225  uint8_t dib = thePoint->getDCMID();
226  uint8_t dcm = (thePoint->getDCMID() >> 8) & 0x1F;
227  uint8_t det = (thePoint->getDCMID() >> 13);
228 
230  aPoint.fSumTrig_DCM_dib = dib;
231  aPoint.fSumTrig_DCM_dcm = dcm;
232  aPoint.fSumTrig_DCM_det = det;
233  aPoint.fSumTrig_DCM_Type = (rawdata::RawSumDCMType)thePoint->getDataType();
234  aPoint.fSumTrig_DCM_TimeStampLow = thePoint->getTimeStampLow();
235  aPoint.fSumTrig_DCM_TimeStampHigh = thePoint->getTimeStampHigh();
236 
237  raw_sumDCM->_points.push_back(aPoint);
238  }
239  continue;
240  }
241 
242  /// Loop over the MicroBlocks
243  const uint32_t n_microblocks = datablock->getNumMicroBlocks();
244 
245  for(uint32_t imicro = 0; imicro < n_microblocks; ++imicro){
246 
247  /// Set the microblock
248  datablock->setFloatingMicroBlock(imicro);
249 
250  daqdataformats::RawMicroBlock* microblock = (daqdataformats::RawMicroBlock*)datablock->getFloatingMicroBlock();
251  daqdataformats::RawMicroSlice* microslice = (daqdataformats::RawMicroSlice*)microblock->getMicroSlice();
252 
253  /// Doing various checks
254  /// 1. Cannot be less than 8
255  if(microslice->getHeader()->getByteCount() < 8) return false;
256 
257 #ifndef DAQDATAFORMATS_VERSIONING_IS_IMPLEMENTED
258  /// 2. Has to be dividable by 4 if nanoslice is version 0
259  if(microslice->getHeader()->getByteCount() % 4) return false;
260 #endif
261  /// 3. Cannot be empty
262  if(!microslice->getHeader()->getDataPresent() && microslice->getHeader()->getByteCount()!= 8) return false;
263 
264  /// Increment the total number of valid microslices in the event
265  total_microslices++;
266 
267  /// Inform everyone of the detector ID.
268  fDetId = (int)microblock->getHeader()->getDetId();
271 
273 
274  /// Increment fNumberOfNonemptyMicroblocks
276 
277  /// Diblock number
278  const uint32_t diblock = microblock->getHeader()->getDiblockId();
279  /// DCM number in the diblock
280  const uint32_t dcmid = microblock->getHeader()->getDCMId();
281 
283 
284  /// Loop over NanoSlices
285  const uint32_t n_nanoslices = microslice->getNumNanoSlices();
286  for(uint32_t inano = 0; inano < n_nanoslices; ++inano){
287 
288  /// Set the nanoslice
289  microslice->setFloatingNanoSlice(inano);
290 
293 
294 #ifdef DAQDATAFORMATS_VERSIONING_IS_IMPLEMENTED
295  const uint32_t nanoslice_version = nanoslice_header->getVersion();
296 #else
297  const uint32_t nanoslice_version = 0;
298 #endif
299 
300  /// See if we need to filter the nanoslice
302  /// NanoSlice has to have DataPresent Flag
303  if(!nanoslice_header->getDataPresent()) continue;
304  /// NanoSlice version 0 has to have Reserved field set to 0xCAFE
305  if(nanoslice_version == 0 && !nanoslice->checkReservedForCafe()) continue;
306  }// end of filtering
307 
308 
309  /// DCM link number for the FEB
310  const uint32_t dcm_link = nanoslice_header->getFEBId();
311  /// Pixel number
312  const uint32_t pixel = nanoslice_header->getPixelAddr();
313  /// Get the daq channel for the hit
314  const daqchannelmap::dchan daq_channel = cmap->encodeDChan(fDetId,
315  diblock,
316  dcmid,
317  dcm_link,
318  pixel);
319 
320  try{
321  // DAQChannelMap is fixed to correctly map DAQ to the Offline, at least
322  // for the first 4 blocks of any detector!! A further fix is being done
323  // for the AA DiBlock interfaces that are present beyond this.
324  cmap->getDetector(daq_channel);
325  cmap->getDiBlock(daq_channel);
326  cmap->getDCM(daq_channel);
327  cmap->getFEB(daq_channel);
328  cmap->getPixel(daq_channel);
329  cmap->getView(daq_channel);
330  }
331  catch(...){
332  mf::LogError("BadDAQChannel") << "we have a bad DAQChannel " << daq_channel
333  << " don't make a digit from it";
334  continue;
335  }
336 
337  /// get local channel from the DAQ channel
338  const uint32_t local_channel = cmap->encodeLChan(daq_channel);
339 
340  /// Event time
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;
346 #else
347  const uint32_t TDC = nanoslice->getTimeStamp();
348 #endif
349 
350 
351  if(fTDC_values) fTDC_values->Fill(TDC);
352  if(fTimeStamp_values)fTimeStamp_values->Fill(nanoslice->getTimeStamp());
353 
354  fDigit.SetDaqChannel(daq_channel);
355  fDigit.SetChannel(local_channel);
356  fDigit.SetTDC(TDC);
357 
358  fDigit.fFrameSequenceNumber = (uint8_t)nanoslice_header->getSequence();
359  fDigit.fFEBStatus = nanoslice_header->getFEBStatus();
360  fDigit.fDebugMode = nanoslice_header->getDebugMode();
361  fDigit.fDataPresent = nanoslice_header->getDataPresent();
362  fDigit.fLinkStatus = nanoslice_header->getLinkStatus();
363 
364  fDigit.fVersion = (uint8_t)nanoslice_version;
365 
366  if (nanoslice_version == 0){
367  const int32_t ADC = nanoslice->getPulseHeight();
369  fDigit.SetADC(0, ADC);
370  fDigit.fReserved = nanoslice->getReserved();
371  }
372 #ifdef DAQDATAFORMATS_VERSIONING_IS_IMPLEMENTED
373  else if(nanoslice_version >= 1){
374 
375  const int nsamples = nanoslice->getNSamples();
376 
377  if(nsamples == 0){
378  mf::LogError("NSamples") << "NSamples cannot be zero\n";
379  assert(false);
380  }
381 
382  const uint32_t sample0 = nanoslice->getValue(0);
383  if(fPulseHeight_values) fPulseHeight_values->Fill(sample0);
384  fDigit.SetADC(0, sample0);
385 
386 
387  for(int i=1; i<nsamples; ++i){
388  fDigit.SetADC(i, nanoslice->getValue(i));
389  //std::cout<<" ADC"<<i<<":"<<nanoslice->getValue(i);
390  }
391 
392  //nanoslice->print();
393 
394 
395  }// end of cases for nanoslice_version
396  else{
397  mf::LogError("Version") << "Unknown nanoslice version" << nanoslice_version<<"\n";
398  assert(false);
399  }
400 #endif
401 
402  /// Push Raw Digit
403  digits->push_back(fDigit);
404 
405  /// Advance the hit number
406  ++fHitNumber;
407  }// end of loop over nanoslices
408 
409  //std::cout<<"end micro "<<imicro<<"\n";
410  }// end of loop over microblocks
411  }// end of loop over datablocks
412 
413  /// Bug in Datalogger that has detector ID in Configuration block different than in Microblocks
414  /// Try to figure out the detector from the file name
417  std::cout<<"From "<<__PRETTY_FUNCTION__<<":"<<__LINE__;
418  std::cout<<" Warning!!! Could not get the detector ID.";
419  std::cout<<" The empty event "<<fRawEvent.getEventNumber();
420  std::cout<<" will be marked to have DetectorID="<<fDetId;
421  std::cout<<"("<<novadaq::cnv::DetInfo::GetName(fDetId)<<")\n";
422  }
423  }// end of trying to figure out the detector
424 
425  /// Now filling DAQHeader
426  daq_header->SetDetId(fDetId);
427  daq_header->SetTotalMicroSlices(total_microslices);
428 
429  return true;
430 }// end of ProcessRawEvent_
int fNumberOfDigits
! Detector type
Definition: OnlineUnpack.h:62
static std::string GetName(int id)
uint32_t fTriggerMask_TriggerTypesHigh2
Definition: OnlineUnpack.h:58
int getDetector(uint32_t anychan) const
uint32_t fTriggerMask_Prescale
Definition: RawTrigger.h:44
void SetDetId(int i)
Definition: DAQHeader.h:30
void SetDetector(novadaq::cnv::DetId det)
Call this if you have definitive special knowledge (ie you&#39;re the Geometry service) ...
diblock
print "ROW IS " print row
Definition: geo2elec.py:31
uint32_t fTriggerHeader_SourceID
! Trigger source (see DAQDataFormats/TriggerDefines.h)
Definition: OnlineUnpack.h:44
IMPLEMENT_MAIN_STANDARD IMPLEMENT_MAIN_setBufferSource daqdataformats::RawNanoSliceHeader * getHeader() const
Get the NanoSlice header pointer.
Definition: RawNanoSlice.h:57
RawSumDCMType fSumTrig_DCM_Type
Definition: RawSumDCM.h:41
void SetTDC(int32_t iTDC)
Definition: RawDigit.cxx:116
uint32_t fNumberOfNonemptyMicroblocks
Definition: OnlineUnpack.h:101
uint32_t fTriggerHeader_SourceSubID
Definition: RawTrigger.h:33
virtual DetView_TYPE getView(dchan daqchan) const =0
Which view (X or Y) does this daq channel readout?
uint8_t fTriggerHeader_Source
Definition: RawTrigger.h:31
uint32_t fSumTrig_NumDroppedMicroblocks
Definition: RawSumDropMB.h:25
uint32_t getNumNanoSlices() const
Get current Hit Probability (for a microslice generation)
uint16_t fReserved
Should be 0xCAFE.
Definition: RawDigit.h:47
void SetChannel(uint32_t iChan)
Definition: RawDigit.h:99
bool fFilterCorruptedNanoslices
Do we need to filter out Corrupted NanoSlices?
Definition: OnlineUnpack.h:96
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
void * getRawBufferPointer() const
Definition: FlatDAQData.h:21
uint32_t fSumTrig_DCM_TimeStampLow
Definition: RawSumDCM.h:42
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
std::vector< RawSumDCMPoint > _points
Definition: RawSumDCM.h:27
Class to hold the data from the global trigger in the correct format.
Definition: RawTrigger.h:40
uint8_t fTriggerTime_ClockSource
Definition: RawTrigger.h:37
int fDetId
Detector ID reading from Microblocks.
Definition: OnlineUnpack.h:100
uint8_t fTriggerMask_TriggerType
Definition: RawTrigger.h:43
uint32_t fTriggerMask_TriggerTypesLow
Definition: OnlineUnpack.h:56
void SetADC(uint32_t i, int16_t iADC)
Definition: RawDigit.cxx:108
uint8_t fTriggerMask_TMod
Definition: RawTrigger.h:42
unsigned long long fTriggerHeader_MasterTriggerNumber
Definition: RawTrigger.h:35
bool setFloatingNanoSlice(const uint32_t inano) const
Set the SIM flag.
unsigned long long fTriggerTimingMarker_ExtractionStart
Definition: RawTrigger.h:39
const std::string * fCurrentFileName
Current file name.
Definition: OnlineUnpack.h:116
uint32_t fTriggerHeader_Source
Definition: OnlineUnpack.h:43
uint8_t fVersion
NanoSlice version.
Definition: RawDigit.h:52
daqdataformats::RawEvent fRawEvent
Flat DAQ RawEvent.
Definition: OnlineUnpack.h:103
uint32_t fTriggerTime_ClockSource
Definition: OnlineUnpack.h:49
uint32_t fTriggerRange_TriggerLength
Definition: OnlineUnpack.h:53
static DAQChannelMap * getInstance(int detID)
uint8_t fFrameSequenceNumber
Definition: RawDigit.h:39
daqdataformats::RawMicroSliceHeader * getHeader() const
unsigned long long fTriggerTimingMarker_TimeStart
Definition: OnlineUnpack.h:50
unsigned long long fTriggerTime_GenTime
Definition: OnlineUnpack.h:48
void SetDaqChannel(uint32_t iChan)
Definition: RawDigit.h:100
rawdata::RawDigit fDigit
Instance of RawDigit class.
Definition: OnlineUnpack.h:105
unsigned long long fTriggerTime_GenTime
Definition: RawTrigger.h:36
uint32_t fTriggerMask_Prescale
Definition: OnlineUnpack.h:59
uint16_t fTriggerHeader_SourceID
Definition: RawTrigger.h:32
A very simple service to remember what detector we&#39;re working in.
OStream cout
Definition: OStream.cxx:6
uint64_t fSumTrig_TimeStamp
Definition: RawSumDropMB.h:26
pixel_t getPixel(dchan daqchan) const
Decode the pixel id from a dchan.
uint32_t fTriggerMask_TriggerTypesHigh
Definition: OnlineUnpack.h:57
Class to hold the MicroSlice data.
Definition: RawMicroSlice.h:48
uint32_t fSumTrig_TimeStampLow
Definition: RawSumDropMB.h:27
RawSumDCMType
Definition: RawSumDCM.h:13
unsigned long long fTriggerHeader_TriggerNumber
Definition: RawTrigger.h:34
unsigned long long fTriggerTimingMarker_TimeStart
Definition: RawTrigger.h:38
bool getDetIDFromFileName(const std::string *)
Try to get Detector ID from the file name.
unsigned long long fTriggerTimingMarker_ExtractionStart
Definition: OnlineUnpack.h:51
assert(nhit_max >=nhit_nbins)
unsigned long long fTriggerHeader_TriggerNumber
! Identifier of the subsystem or channel on source device
Definition: OnlineUnpack.h:46
cmap::CMap class source code
Definition: CMap.cxx:17
uint32_t fTriggerRange_TriggerLength
Definition: RawTrigger.h:40
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
void SetTotalMicroSlices(int i)
Definition: DAQHeader.h:31
dchan encodeDChan(int detID, diblock_t diblock, dcm_id_t dcm, feb_t feb, pixel_t pixel) const
uint32_t fSumTrig_DCM_TimeStampHigh
Definition: RawSumDCM.h:43
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...
Definition: RawTrigger.cxx:44
std::vector< char > fRawBuffer
Flat event data.
Definition: FlatDAQData.h:23
uint32_t fSumTrig_TimeStampHigh
Definition: RawSumDropMB.h:28
UnpackedEvent fUnpackedEventParameters
Definition: OnlineUnpack.h:107
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
unsigned long long fTriggerHeader_MasterTriggerNumber
! Universal trigger number
Definition: OnlineUnpack.h:47
uint32_t fTriggerHeader_SourceSubID
! Identifier of the source system
Definition: OnlineUnpack.h:45
feb_t getFEB(dchan daqchan) const
Decode the feb id from a dchan.
uint8_t fFEBStatus
Definition: RawDigit.h:43
daqdataformats::RawNanoSlice * getFloatingNanoSlice() const
Get the MicroSlice Timing Marker.

Member Data Documentation

const std::string* daq2raw::OnlineUnpack::fCurrentFileName
private

Current file name.

Definition at line 116 of file OnlineUnpack.h.

Referenced by ProcessRawEvent_().

int daq2raw::OnlineUnpack::fDetId
private

Detector ID reading from Microblocks.

Definition at line 100 of file OnlineUnpack.h.

Referenced by getDetIDFromFileName(), and ProcessRawEvent_().

rawdata::RawDigit daq2raw::OnlineUnpack::fDigit
private

Instance of RawDigit class.

Definition at line 105 of file OnlineUnpack.h.

Referenced by ProcessRawEvent_().

bool daq2raw::OnlineUnpack::fFilterCorruptedNanoslices
uint32_t daq2raw::OnlineUnpack::fHitNumber
private

Definition at line 114 of file OnlineUnpack.h.

Referenced by ProcessRawEvent_().

uint32_t daq2raw::OnlineUnpack::fNumberOfNonemptyMicroblocks
private

Definition at line 101 of file OnlineUnpack.h.

Referenced by ProcessRawEvent_().

TH1F* daq2raw::OnlineUnpack::fPulseHeight_values
private

Definition at line 110 of file OnlineUnpack.h.

Referenced by ProcessRawEvent_().

daqdataformats::RawEvent daq2raw::OnlineUnpack::fRawEvent
private

Flat DAQ RawEvent.

Definition at line 103 of file OnlineUnpack.h.

Referenced by ProcessRawEvent(), and ProcessRawEvent_().

TH1F* daq2raw::OnlineUnpack::fTDC_values
private

Definition at line 113 of file OnlineUnpack.h.

Referenced by ProcessRawEvent_().

TH1F* daq2raw::OnlineUnpack::fTimeStamp_values
private

Definition at line 111 of file OnlineUnpack.h.

Referenced by ProcessRawEvent_().

TH1F* daq2raw::OnlineUnpack::fTrigger_values
private

Definition at line 112 of file OnlineUnpack.h.

Referenced by ProcessRawEvent_().

UnpackedEvent daq2raw::OnlineUnpack::fUnpackedEventParameters
private

Definition at line 107 of file OnlineUnpack.h.

Referenced by ProcessRawEvent_().


The documentation for this class was generated from the following files: