Public Member Functions | Private Member Functions | Private Attributes | List of all members
lris::RawData311InputDriver Class Reference

#include <RawData311InputDriver.h>

Public Member Functions

 RawData311InputDriver (fhicl::ParameterSet const &pset, art::ProductRegistryHelper &helper, art::SourceHelper const &pm)
 
void closeCurrentFile ()
 
void readFile (std::string const &name, art::FileBlock *&fb)
 
bool readNext (art::RunPrincipal *const &inR, art::SubRunPrincipal *const &inSR, art::RunPrincipal *&outR, art::SubRunPrincipal *&outSR, art::EventPrincipal *&outE)
 

Private Member Functions

void process_Event311 (std::vector< raw::RawDigit > &digitList, dlardaq::evheader_t &event_head, uint16_t evt_num)
 
double GetPedMean (size_t LAr_chan, std::vector< std::pair< double, double > > *fPedMap)
 
double GetPedRMS (size_t LAr_chan, std::vector< std::pair< double, double > > *fPedMap)
 

Private Attributes

art::SourceHelper const & fSourceHelper
 
art::SubRunID fCurrentSubRunID
 
uint16_t fEventCounter
 
uint16_t fNEvents
 
std::string filename
 
short nchannels = 1280
 
short nsamples = 1667
 
dlardaq::EventDecoder DataDecode
 
dlardaq::runheader_t file_head
 
dlardaq::footer_t file_foot
 
std::vector< std::pair< double, double > > fPedMap
 
std::string fPedestalFile
 

Detailed Description

Definition at line 32 of file RawData311InputDriver.h.

Constructor & Destructor Documentation

lris::RawData311InputDriver::RawData311InputDriver ( fhicl::ParameterSet const &  pset,
art::ProductRegistryHelper helper,
art::SourceHelper const &  pm 
)

Definition at line 154 of file RawData311InputDriver_service.cc.

157  :
158  fSourceHelper(pm),
160  fEventCounter(0),
162  {
163  fPedestalFile = p.get<std::string>("PedestalFile");
164  helper.reconstitutes<std::vector<raw::RawDigit>, art::InEvent>("daq");
165  }
std::string string
Definition: nybbler.cc:12
dlardaq::EventDecoder DataDecode
art::SourceHelper const & fSourceHelper
TypeLabel const & reconstitutes(std::string const &modLabel, std::string const &instanceName={})
p
Definition: test.py:223

Member Function Documentation

void lris::RawData311InputDriver::closeCurrentFile ( )

Definition at line 169 of file RawData311InputDriver_service.cc.

170  {
171  mf::LogInfo(__FUNCTION__)<<"File boundary: processed " <<fEventCounter <<" events out of " <<fNEvents <<"\n";
172  DataDecode.m_file.close();
173  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
dlardaq::EventDecoder DataDecode
std::ifstream m_file
Definition: EventDecoder.h:64
double lris::RawData311InputDriver::GetPedMean ( size_t  LAr_chan,
std::vector< std::pair< double, double > > *  fPedMap 
)
inlineprivate

Definition at line 73 of file RawData311InputDriver.h.

73 { return fPedMap->at(LAr_chan).first; }
double lris::RawData311InputDriver::GetPedRMS ( size_t  LAr_chan,
std::vector< std::pair< double, double > > *  fPedMap 
)
inlineprivate

Definition at line 75 of file RawData311InputDriver.h.

75 { return fPedMap->at(LAr_chan).second; }
void lris::RawData311InputDriver::process_Event311 ( std::vector< raw::RawDigit > &  digitList,
dlardaq::evheader_t event_head,
uint16_t  evt_num 
)
private

Definition at line 118 of file RawData311InputDriver_service.cc.

121  {
122  // one digit for every wire on each plane
123  digitList.clear();
124  digitList.resize(nchannels);
125  // Get the data.
126  std::vector<dlardaq::adc16_t> ADCvec311;
127  DataDecode.GetEvent(evt_num, event_head, ADCvec311);
128  std::vector<dlardaq::adc16_t> *ADCvec311Pointer = &ADCvec311;
129  // fill the wires
130  std::vector<short> adclist;
131 
132  for(size_t LAr_chan = 0; LAr_chan < (size_t)nchannels; LAr_chan++)
133  {
134  adclist.clear();
135  size_t Chan311 = Get311Chan(LAr_chan);
136  SplitAdc(ADCvec311Pointer, Chan311, nsamples, adclist);
137  short unsigned int nTickReadout = nsamples;
138  raw::ChannelID_t channel = LAr_chan;
140  raw::RawDigit rd(channel, nTickReadout, adclist, comp);
141 
142  double pedval = RawData311InputDriver::GetPedMean(Chan311, &fPedMap);
143  //std::cout << "Pedval: " << pedval << "\n";
144  double pedrms = RawData311InputDriver::GetPedRMS(Chan311, &fPedMap);
145  rd.SetPedestal(pedval, pedrms);
146 
147  digitList[LAr_chan] = rd;
148  }
149  }// process_Event311
enum raw::_compress Compress_t
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
double GetPedRMS(size_t LAr_chan, std::vector< std::pair< double, double > > *fPedMap)
uint8_t channel
Definition: CRTFragment.hh:201
dlardaq::EventDecoder DataDecode
no compression
Definition: RawTypes.h:9
std::vector< std::pair< double, double > > fPedMap
double GetPedMean(size_t LAr_chan, std::vector< std::pair< double, double > > *fPedMap)
size_t Get311Chan(size_t LAr_chan)
ssize_t GetEvent(size_t evnum, dlardaq::evheader_t &eh, std::vector< adc16_t > &adc)
void SplitAdc(const std::vector< dlardaq::adc16_t > *adc, size_t channel, uint32_t num_samples, std::vector< short > &adclist)
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void lris::RawData311InputDriver::readFile ( std::string const &  name,
art::FileBlock *&  fb 
)

Definition at line 177 of file RawData311InputDriver_service.cc.

179  {
180  // Read in the pedestal file
182 
183  filename = name;
184  // Fill and return a new Fileblock
185  fb = new art::FileBlock(art::FileFormatVersion(1, "311 RawInput 2017"), name);
186 
187  // Prepare the EventDecoder
188  //short nchannels_Vplane = 320;
189  //short nchannels_Zplane = 960;
190  //short nchannels = nchannels_Vplane + nchannels_Zplane;
191  //uint32_t nsamples = 1667;
192  //DataDecode(nchannels, nsamples);
193 
194  DataDecode.m_file.open(name.c_str(), std::ios_base::in | std::ios_base::binary);
195  if( !DataDecode.m_file.is_open() )
196  {
198  << "failed to open input file " << name << "\n";
199  }
200 
201  // Read in the file header.
202  std::vector<dlardaq::BYTE> head_buf;
203  head_buf.resize(dlardaq::RunHeadSz);
204 
205  DataDecode.m_file.read(&head_buf[0], head_buf.size());
206  dlardaq::decode_runhead(&head_buf[0], file_head);
207 
208  // Define start of event data.
209  std::streampos data_start = DataDecode.m_file.tellg();
210 
211  // Read in the file footer.
212  std::vector<dlardaq::BYTE> foot_buf;
213  foot_buf.resize(dlardaq::FileFootSz);
214 
216  DataDecode.m_file.read(&foot_buf[0], foot_buf.size());
217  dlardaq::decode_filefoot(&foot_buf[0], file_foot);
218  DataDecode.m_file.seekg(data_start);
219 
221  if(fNEvents > 0 && fNEvents < 1000) //There should be 335 events at most in one file.
222  {
223  mf::LogInfo("")<<"Opened file " <<name <<" with " << fNEvents <<" events." <<"\n";
224  } else
225  {
227  <<"File " <<name <<" seems to have too many events: " <<fNEvents <<"\n";
228  }
229  }
static QCString name
Definition: declinfo.cpp:673
static const size_t FileFootSz
Definition: dlardaq.h:60
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
dlardaq::EventDecoder DataDecode
ssize_t decode_runhead(const char *buf, runheader_t &rh)
void ReadPedestalFile(std::string PedestalFileName, std::vector< std::pair< double, double > > &PedMap)
static const size_t RunHeadSz
Definition: dlardaq.h:56
std::vector< std::pair< double, double > > fPedMap
std::ifstream m_file
Definition: EventDecoder.h:64
ssize_t decode_filefoot(const char *buf, footer_t &rf)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
uint16_t num_events
Definition: dlardaq.h:92
bool lris::RawData311InputDriver::readNext ( art::RunPrincipal *const &  inR,
art::SubRunPrincipal *const &  inSR,
art::RunPrincipal *&  outR,
art::SubRunPrincipal *&  outSR,
art::EventPrincipal *&  outE 
)

Definition at line 233 of file RawData311InputDriver_service.cc.

238  {
239  if(fEventCounter == fNEvents)
240  {
241  mf::LogInfo(__FUNCTION__)<<"All the files have been read in. Checking end of file..." <<"\n";
242  std::streampos current_position = DataDecode.m_file.tellg();
243  DataDecode.m_file.seekg(0, std::ios::end);
244  std::streampos file_length = DataDecode.m_file.tellg();
245  if( ((uint8_t)file_length - (uint8_t)current_position) > (uint8_t)100 )
246  {
248  <<"Processed " <<fEventCounter <<" events out of " <<fNEvents <<" but there are still "
249  <<(file_length - current_position) <<" bits left." <<"\n";
250  }
251  mf::LogInfo(__FUNCTION__)<<"Completed reading file and closing output file." <<"\n";
252  return false; //Tells readNext that all events have been read.
253  }
254 
255  mf::LogInfo(__FUNCTION__)<<"Reading event " << fEventCounter << " from " << fNEvents <<"\n";
256 
257  // Create empty result, then fill it from current file
258  dlardaq::evheader_t event_head;
259  std::unique_ptr< std::vector<raw::RawDigit> > tpc_raw_digits( new std::vector<raw::RawDigit> );
260  process_Event311(*tpc_raw_digits, event_head, fEventCounter++);
261 
262 
263 
264  // Prepare some stuff
265  art::RunNumber_t rn;
266  rn = file_head.run_num;
267 
268  std::uint64_t tthi = event_head.trig_info.ts.tv_sec;
269  std::uint64_t thilo = (tthi << 32) + event_head.trig_info.ts.tv_nsec;
270  art::Timestamp tstamp(thilo);
271 
272  size_t pos = filename.find("-");
273  size_t end = filename.find(".");
274  std::string str_subrn = filename.substr(pos+1, end-1);
275  int int_subrn = std::stoi(str_subrn);
276  art::SubRunNumber_t subrn = int_subrn;
277  art::SubRunID newID(rn, subrn);
278  if( fCurrentSubRunID.runID() != newID.runID() )
279  {
280  outR = fSourceHelper.makeRunPrincipal(rn, tstamp);
281  }
282  if( fCurrentSubRunID != newID )
283  {
284  outSR = fSourceHelper.makeSubRunPrincipal(rn, subrn, tstamp);
285  fCurrentSubRunID = newID;
286  }
287 
289  fEventCounter - 1, tstamp);
290 
291  // Put products in the event.
292  art::put_product_in_principal(std::move(tpc_raw_digits), *outE, "daq");
293 
294  return true;
295  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
trigger_t trig_info
Definition: dlardaq.h:83
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary const &subRunAux) const
dlardaq::EventDecoder DataDecode
RunPrincipal * makeRunPrincipal(RunAuxiliary const &runAux) const
Definition: SourceHelper.cc:92
art::SourceHelper const & fSourceHelper
RunID const & runID() const
Definition: SubRunID.h:79
std::ifstream m_file
Definition: EventDecoder.h:64
def move(depos, offset)
Definition: depos.py:107
RunNumber_t run() const
Definition: SubRunID.h:85
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:119
void process_Event311(std::vector< raw::RawDigit > &digitList, dlardaq::evheader_t &event_head, uint16_t evt_num)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::enable_if_t<!detail::range_sets_supported(P::branch_type)> put_product_in_principal(std::unique_ptr< T > &&product, P &principal, std::string const &module_label, std::string const &instance_name={})
EventPrincipal * makeEventPrincipal(EventAuxiliary const &eventAux, std::unique_ptr< History > &&history) const
SubRunNumber_t subRun() const
Definition: SubRunID.h:91
struct timespec ts
Definition: dlardaq.h:70
uint32_t run_num
Definition: dlardaq.h:76
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:120

Member Data Documentation

dlardaq::EventDecoder lris::RawData311InputDriver::DataDecode
private

Definition at line 61 of file RawData311InputDriver.h.

art::SubRunID lris::RawData311InputDriver::fCurrentSubRunID
private

Definition at line 53 of file RawData311InputDriver.h.

uint16_t lris::RawData311InputDriver::fEventCounter
private

Definition at line 55 of file RawData311InputDriver.h.

dlardaq::footer_t lris::RawData311InputDriver::file_foot
private

Definition at line 64 of file RawData311InputDriver.h.

dlardaq::runheader_t lris::RawData311InputDriver::file_head
private

Definition at line 63 of file RawData311InputDriver.h.

std::string lris::RawData311InputDriver::filename
private

Definition at line 57 of file RawData311InputDriver.h.

uint16_t lris::RawData311InputDriver::fNEvents
private

Definition at line 56 of file RawData311InputDriver.h.

std::string lris::RawData311InputDriver::fPedestalFile
private

Definition at line 67 of file RawData311InputDriver.h.

std::vector< std::pair<double, double> > lris::RawData311InputDriver::fPedMap
private

Definition at line 66 of file RawData311InputDriver.h.

art::SourceHelper const& lris::RawData311InputDriver::fSourceHelper
private

Definition at line 52 of file RawData311InputDriver.h.

short lris::RawData311InputDriver::nchannels = 1280
private

Definition at line 59 of file RawData311InputDriver.h.

short lris::RawData311InputDriver::nsamples = 1667
private

Definition at line 60 of file RawData311InputDriver.h.


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