Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
raw::VDColdboxTDERawInput Class Reference

#include <VDColdboxTDERawInput.h>

Classes

struct  eveinfo_t
 
struct  fragment_t
 
struct  triginfo_t
 

Public Member Functions

 VDColdboxTDERawInput (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 Types

enum  { evinfoSz = 44 }
 
typedef struct raw::VDColdboxTDERawInput::triginfo_t triginfo_t
 
typedef struct raw::VDColdboxTDERawInput::eveinfo_t eveinfo_t
 
typedef struct raw::VDColdboxTDERawInput::fragment_t fragment_t
 

Private Member Functions

void __close ()
 
void __readChunk (std::vector< BYTE > &bytes, size_t sz)
 
bool __unpackEvent (std::vector< BYTE > &buf, DaqEvent &event)
 
std::string __getProducerLabel (std::string &lbl)
 
unsigned __unpack_evtable ()
 
unsigned __unpack_eve_info (const char *buf, eveinfo_t &ei)
 
unsigned __get_file_seqno (std::string s)
 

Private Attributes

art::SourceHelper const & __sourceHelper
 
art::SubRunID __currentSubRunID
 
int __logLevel
 
std::string __outlbl_digits
 
std::string __outlbl_status
 
std::string __outlbl_rdtime
 
std::string __prodlbl_digits
 
std::string __prodlbl_status
 
std::string __prodlbl_rdtime
 
uint32_t __eventCtr
 
uint32_t __eventNum
 
int __maxEvents
 
size_t __nsacro
 
size_t __start_tde_cru
 
std::vector< unsigned > __daqch
 
std::vector< bool__keepch
 
std::vector< unsigned > __invped
 
std::vector< std::streampos > __events
 
std::vector< uint32_t > __evsz
 
size_t __filesz
 
std::ifstream __file
 
unsigned __file_seqno
 

Detailed Description

Definition at line 76 of file VDColdboxTDERawInput.h.

Member Typedef Documentation

Member Enumeration Documentation

anonymous enum
private
Enumerator
evinfoSz 

Definition at line 143 of file VDColdboxTDERawInput.h.

Constructor & Destructor Documentation

raw::VDColdboxTDERawInput::VDColdboxTDERawInput ( fhicl::ParameterSet const &  pset,
art::ProductRegistryHelper helper,
art::SourceHelper const &  pm 
)

Definition at line 140 of file VDColdboxTDERawInput_source.cc.

142  :
143  __sourceHelper( pm ),
145  __eventCtr( 0 ),
146  __eventNum( 0 )
147  {
148  const std::string myname = "VDColdboxTDERawInput::ctor: ";
149 
150  __logLevel = pset.get<int>("LogLevel", 0);
151  __nsacro = pset.get<size_t>("SamplesPerChannel", 10000);
152  __start_tde_cru = pset.get<size_t>("StartTDEChCRU", 0);
153  __outlbl_digits = pset.get<std::string>("OutputLabelRawDigits", "daq");
154  __outlbl_rdtime = pset.get<std::string>("OutputLabelRDTime", "daq");
155  __outlbl_status = pset.get<std::string>("OutputLabelRDStatus", "daq");
156  __maxEvents = pset.get<int>("maxEvents", -1);
157  auto vecped_crps = pset.get<std::vector<UIntVec>>("InvertBaseline", std::vector<UIntVec>());
158  auto select_crps = pset.get<std::vector<unsigned>>("SelectCRPs", std::vector<unsigned>());
159 
160  std::map<unsigned, unsigned> invped_crps;
161  if( !vecped_crps.empty() ){
162  for( auto &v : vecped_crps ){
163  if( v.size() != 2 ){
164  if( __logLevel >= 1 )
165  mf::LogError(__FUNCTION__)<<"Bad vector size for pedestal inversion parameters";
166  continue;
167  }
168  // CRP ID = Pedestal inversion
169  invped_crps[ v[0] ] = v[1];
170  }
171  }
172 
173  if( __logLevel >= 1 )
174  {
175  std::cout << myname << " Configuration : " << std::endl;
176  std::cout << myname << " LogLevel : " << __logLevel << std::endl;
177  std::cout << myname << " SamplesPerChannel : " << __nsacro << std::endl;
178  std::cout << myname << " maxEvents : " << __maxEvents << std::endl;
179  std::cout << myname << " StartTDEChCRU : " << __start_tde_cru << std::endl;
180  std::cout << myname << " OutputLabelRawDigits : " << __outlbl_digits << std::endl;
181  std::cout << myname << " OutputLabelRDStatus : " << __outlbl_status << std::endl;
182  std::cout << myname << " OutputLabelRDtime : " << __outlbl_rdtime << std::endl;
183  std::cout << myname << " SelectCRPs : ";
184  if( select_crps.empty() ) std::cout<<"all"<<std::endl;
185  else
186  {
187  std::ostringstream vstr;
188  std::copy(select_crps.begin(), select_crps.end()-1,
189  std::ostream_iterator<unsigned>(vstr, ", "));
190  vstr << select_crps.back();
191  std::cout << vstr.str() << std::endl;
192  }
193  std::cout << myname << " InvertBaseline : ";
194  if( invped_crps.empty() ) std::cout<<"None"<<std::endl;
195  else {
196  for( auto const &m : invped_crps )
197  std::cout<< "[ "<<m.first<<", "<<m.second<<" ] ";
198  std::cout<<std::endl;
199  }
200  }
201 
205 
206 
207 
208  //
209  helper.reconstitutes<std::vector<raw::RawDigit>, art::InEvent>(__outlbl_digits,
211  helper.reconstitutes<std::vector<raw::RDStatus>, art::InEvent>(__outlbl_status,
213  helper.reconstitutes<std::vector<raw::RDTimeStamp>, art::InEvent>(__outlbl_rdtime,
215 
216  //
217  // channel map order by CRP View
219 
220  // we grab all CRPs
221  auto crpidx = channelMap->get_crpidx();
222  for( auto c: crpidx )
223  {
224  // we take all channels in this CRP sorted by view and view channel
225  std::vector<dune::tde::ChannelId> chidx = channelMap->find_by_crp( c, true );
226 
227  // check if we want to keep only specific CRPs
228  bool keep = true;
229  if( !select_crps.empty() )
230  {
231  if( std::find( select_crps.begin(), select_crps.end(), c ) == select_crps.end() )
232  {
233  keep = false;
234  }
235  }
236  if( __logLevel >= 2 )
237  std::cout<<myname<<" CRP "<<c<<" selected "<<keep<<std::endl;
238 
239  // check if we need to invert baseline for the group of CRP channels
240  unsigned invped = 0;
241  if( !invped_crps.empty() ){
242  auto it = invped_crps.find( c );
243  if( it != invped_crps.end() ){
244  invped = it->second;
245  }
246  }
247  if( __logLevel >= 2 )
248  std::cout<<myname<<" CRP "<<c<<" baseline "<<invped<<std::endl;
249 
250 
251  //std::cout<<chidx.size()<<std::endl;
252  for( auto id: chidx )
253  {
254  // drop channels not connected to CRP
255  if( !id.exists() ) continue;
256  __daqch.push_back( id.seqn() );
257  __keepch.push_back( keep );
258  __invped.push_back( invped );
259  }
260  }
261 
262  if( __logLevel >= 1 ){
263  std::cout << myname << " Readout info : " << std::endl;
264  std::cout<<myname << " Number of CRPs from chmap : " << channelMap->ncrps() << std::endl;
265  std::cout<<myname << " Total channels expected : " << __daqch.size() << std::endl;
266  }
267  }
std::string string
Definition: nybbler.cc:12
std::vector< unsigned > __invped
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
bool exists(std::string path)
TypeLabel const & reconstitutes(std::string const &modLabel, std::string const &instanceName={})
art::SourceHelper const & __sourceHelper
std::vector< unsigned > __daqch
T copy(T const &v)
QTextStream & endl(QTextStream &s)
std::string __getProducerLabel(std::string &lbl)

Member Function Documentation

void raw::VDColdboxTDERawInput::__close ( )
private

Definition at line 464 of file VDColdboxTDERawInput_source.cc.

465  {
466  if(__file.is_open())
467  __file.close();
468 
469  __filesz = 0;
470  }
unsigned raw::VDColdboxTDERawInput::__get_file_seqno ( std::string  s)
private

Definition at line 729 of file VDColdboxTDERawInput_source.cc.

730  {
731  unsigned rval = 0;
732 
733  //std::cout << "input " << s << std::endl;
734  std::regex r("[[:digit:]]+_([[:digit:]]+)_[[:alnum:]]+\\.[[:alnum:]]+");
735  std::smatch m;
736 
737  if( !regex_search( s, m, r ) )
738  {
739  mf::LogWarning(__FUNCTION__) << "Unable to extract seqno from file name "<< s;
740  return rval;
741  }
742 
743  //
744  try
745  {
746  // str() is the entire match
747  rval = std::stoi( m.str(1) );
748  }
749  catch (const std::invalid_argument& ia)
750  {
751  rval = 0;
752  mf::LogWarning(__FUNCTION__) << "This should never happen";
753  }
754 
755  return rval;
756  }
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
static QCString * s
Definition: config.cpp:1042
std::string raw::VDColdboxTDERawInput::__getProducerLabel ( std::string lbl)
private

Definition at line 448 of file VDColdboxTDERawInput_source.cc.

449  {
450  std::string res = "";
451  size_t ipos = lbl.find(":");
452  if ( ipos != std::string::npos ) {
453  res = lbl.substr(ipos + 1);
454  lbl = lbl.substr(0, ipos);
455  }
456 
457  return res;
458  }
std::string string
Definition: nybbler.cc:12
void raw::VDColdboxTDERawInput::__readChunk ( std::vector< BYTE > &  bytes,
size_t  sz 
)
private

Definition at line 474 of file VDColdboxTDERawInput_source.cc.

475  {
476  bytes.resize( sz );
477  __file.read( &bytes[0], sz );
478  if( !__file )
479  {
480  ssize_t nb = __file.gcount();
481  //mf::LogWarning(__FUNCTION__)
482  //<<"Could not read "<<sz<" bytes "<<" only "<<nb<<" were available"<<endl;
483  bytes.resize( nb );
484  // reset stream state from errors
485  __file.clear();
486  }
487  }
static constexpr double nb
Definition: Units.h:81
unsigned raw::VDColdboxTDERawInput::__unpack_eve_info ( const char *  buf,
eveinfo_t ei 
)
private

Definition at line 568 of file VDColdboxTDERawInput_source.cc.

569  {
570  //
571  unsigned rval = 0;
572 
573  //
574  //memset(&ei, 0, sizeof(ei));
575  try
576  {
577  // check for delimiting words
578  BYTE k0 = buf[0];
579  BYTE k1 = buf[1];
580  static const unsigned evskey = 0xFF;
581  if( !( ((k0 & 0xFF) == evskey) && ((k1 & 0xFF) == evskey) ) )
582  {
583  mf::LogError(__FUNCTION__)<<"Event delimiting word could not be detected";
584  throw fex;
585  }
586  rval += 2;
587 
588  // decode run number
589  ei.runnum = ConvertToValue<uint32_t>( buf+rval );
590  rval += sizeof( ei.runnum );
591 
592  // run flags
593  ei.runflags = (uint8_t)buf[rval++];
594 
595  // this is actually written in host byte order
596  ei.ti = ConvertToValue<triginfo_t>( buf+rval );
597  rval += sizeof(ei.ti);
598 
599  // data quality flags
600  ei.evflag = (uint8_t)buf[rval++];
601 
602  // event number 4 bytes
603  ei.evnum = ConvertToValue<uint32_t>( buf+rval );
604  rval += sizeof( ei.evnum );
605 
606  // size of the lro data segment
607  ei.evszlro = ConvertToValue<uint32_t>( buf+rval );
608  rval += sizeof( ei.evszlro );
609 
610  // size of the cro data segment
611  ei.evszcro = ConvertToValue<uint32_t>( buf+rval );
612  rval += sizeof( ei.evszcro );
613  }
614  catch(std::exception &e)
615  {
616  rval = 0;
617  }
618 
619  return rval;
620  }
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
const double e
char BYTE
Definition: dlardaq.h:39
static formatexception fex
Definition: dlardaq.h:52
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
unsigned raw::VDColdboxTDERawInput::__unpack_evtable ( )
private

Definition at line 491 of file VDColdboxTDERawInput_source.cc.

492  {
493  unsigned rval = 0;
494  //__eventNum = 0;
495 
496  std::vector<BYTE> buf;
497  size_t msz = 2*sizeof(uint32_t);
498  __readChunk( buf, msz);
499  if( buf.size() != msz )
500  {
501  mf::LogError(__FUNCTION__)<<"Could not read number of events";
502  return 0;
503  }
504 
505 
506  // number of events in the file
507  __eventNum = ConvertToValue<uint32_t>(&buf[4]);
508  rval += buf.size();
509 
510  // file
511  if( __eventNum == 0 )
512  {
513  mf::LogError(__FUNCTION__)<<"File does not contain any events";
514  return 0;
515  }
516 
517  mf::LogInfo(__FUNCTION__)<<"Number of events in this file "<<__eventNum;
518 
519  size_t evtsz = __eventNum * 4 * sizeof(uint32_t);
520  if( evtsz + rval >= __filesz )
521  {
522  mf::LogError(__FUNCTION__)<<"Cannot find event table";
523  return 0;
524  }
525 
526  // read next chunk with event table info
527  __readChunk( buf, evtsz );
528  rval += buf.size();
529 
530  // unpack sizes of events in sequence
531  // we are only interested in the size here
532  __evsz.clear();
533  for( unsigned i=0;i<buf.size();i+=16 )
534  {
535  unsigned o = 0;
536  //uint32_t sn = ConvertToValue<uint32_t>(&buf[i+o]);
537 
538  o = 4;
539  uint32_t sz = ConvertToValue<uint32_t>(&buf[i+o]);
540  __evsz.push_back( sz );
541  }
542 
543  // generate table of positions of events in a file
544  __events.clear();
545 
546  // first event is at the current position
547  __events.push_back( __file.tellg() );
548  for(size_t i=0; i < __evsz.size()-1; i++)
549  {
550  __file.seekg( __evsz[i], std::ios::cur );
551  if( !__file )
552  {
553  mf::LogError(__FUNCTION__)<<"Event table does not match file size";
554  __file.clear();
555  __evsz.resize( __events.size() );
556  __eventNum = __events.size();
557  break;
558  }
559  __events.push_back( __file.tellg() );
560  }
561 
562  // return the number of bytes unpacked
563  return rval;
564  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::vector< uint32_t > __evsz
void __readChunk(std::vector< BYTE > &bytes, size_t sz)
std::vector< std::streampos > __events
bool raw::VDColdboxTDERawInput::__unpackEvent ( std::vector< BYTE > &  buf,
DaqEvent &  event 
)
private

Definition at line 624 of file VDColdboxTDERawInput_source.cc.

625  {
626  // fragments from each L1 builder
627  std::vector<fragment_t> frags;
628 
629  unsigned idx = 0;
630  for(;;)
631  {
632  fragment_t afrag;
633  if( idx >= buf.size() ) break;
634  unsigned rval = __unpack_eve_info( &buf[idx], afrag.ei );
635  if( rval == 0 ) return false;
636  idx += rval;
637  // set point to the binary data
638  afrag.bytes = &buf[idx];
639  size_t dsz = afrag.ei.evszcro + afrag.ei.evszlro;
640  idx += dsz;
641  idx += 1; // "Bruno byte"
642 
643  // some basic checks
644  if( frags.size() >= 1 )
645  {
646  if( frags[0].ei.runnum != afrag.ei.runnum )
647  {
648  mf::LogError(__FUNCTION__)<<"run numbers do not match among event fragments";
649  continue;
650  }
651  if( frags[0].ei.evnum != afrag.ei.evnum )
652  {
653  mf::LogError(__FUNCTION__)<<"event numbers do not match among event fragments";
654  mf::LogDebug(__FUNCTION__)<<"event number "<< frags[0].ei.evnum;
655  mf::LogDebug(__FUNCTION__)<<"event number "<< afrag.ei.evnum;
656  continue;
657  }
658  // check also timestamps???
659  }
660 
661  frags.push_back( afrag );
662  }
663 
664  //mf::LogDebug(__FUNCTION__)<<"number of fragments "<<frags.size()<<"\n";
665  //
666  std::mutex iomutex;
667  std::vector<std::thread> threads(frags.size() - 1);
668  unsigned nsa = __nsacro;
669  //unsigned invped = __invped;
670  for (unsigned i = 1; i<frags.size(); ++i)
671  {
672  auto afrag = frags.begin() + i;
673  threads[i-1] = std::thread([&iomutex, i, nsa, afrag] {
674  {
675  std::lock_guard<std::mutex> iolock(iomutex);
676  // make it look like we're using i so clang doesn't complain. This had been commented out
677  //msg_info << "Unpack thread #" << i << " is running\n";
678  if (i==100000) std::cout << "Unpack thread #" << i << " is running\n";
679  }
680  unpackData( afrag->bytes + afrag->ei.evszlro, afrag->ei.evszcro,
681  GETDCFLAG(afrag->ei.runflags), nsa, afrag->crodata);
682  });
683  }
684 
685  // unpack first fragment in the main thread
686  auto f0 = frags.begin();
687  event.good = EVDQFLAG( f0->ei.evflag );
688  event.runnum = f0->ei.runnum;
689  event.runflags = f0->ei.runflags;
690  //
691  event.evnum = f0->ei.evnum;
692  event.evflags.push_back( f0->ei.evflag );
693  //
694  event.trigtype = f0->ei.ti.type;
695  event.trignum = f0->ei.ti.num;
696  event.trigstamp = f0->ei.ti.ts;
697 
698  unpackData( f0->bytes + f0->ei.evszlro, f0->ei.evszcro, GETDCFLAG(f0->ei.runflags),
699  nsa, event.crodata );
700 
701  event.compression = raw::kNone;
702  // the compression should be set for all L1 event builders,
703  // since this depends on loaded AMC firmware
704  if( GETDCFLAG(f0->ei.runflags) )
705  event.compression = raw::kHuffman;
706 
707  // wait for other threads to complete
708  for (auto& t : threads) t.join();
709 
710  // merge with other fragments
711  for (auto it = frags.begin() + 1; it != frags.end(); ++it )
712  {
713  event.good = ( event.good && EVDQFLAG( it->ei.evflag ) );
714  event.evflags.push_back( it->ei.evflag );
715 
716  //
717  event.crodata.reserve(event.crodata.size() + it->crodata.size() );
718  std::move( std::begin( it->crodata ), std::end( it->crodata ),
719  std::back_inserter( event.crodata ));
720  it->crodata.clear();
721  }
722 
723  return true;
724  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
Huffman Encoding.
Definition: RawTypes.h:10
struct raw::VDColdboxTDERawInput::fragment_t fragment_t
unsigned __unpack_eve_info(const char *buf, eveinfo_t &ei)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
no compression
Definition: RawTypes.h:9
#define EVDQFLAG(info)
def move(depos, offset)
Definition: depos.py:107
#define GETDCFLAG(info)
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
Event finding and building.
void raw::VDColdboxTDERawInput::closeCurrentFile ( )

Definition at line 270 of file VDColdboxTDERawInput_source.cc.

271  {
272  __close();
273  }
void raw::VDColdboxTDERawInput::readFile ( std::string const &  name,
art::FileBlock *&  fb 
)

Definition at line 276 of file VDColdboxTDERawInput_source.cc.

278  {
279  __close();
280 
281  __eventCtr = 0;
282  __eventNum = 0;
283 
284  fb = new art::FileBlock(art::FileFormatVersion(1, "DPPD RawInput 2019"), name);
285 
286  //
287  __file.open( name.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
288 
289  if( !__file.is_open() )
290  {
292  << "Error opening binary file " << name << std::endl;
293  }
294 
295  // get file size
296  __filesz = __file.tellg();
297 
298  // move to beginning
299  __file.seekg(0, std::ios::beg);
300 
301  // unpack event table
302  if( __unpack_evtable() == 0 )
303  {
304  __close();
306  << "File " << name << " does not have any events"<< std::endl;
307  }
308 
311  }
static QCString name
Definition: declinfo.cpp:673
unsigned __get_file_seqno(std::string s)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
QTextStream & endl(QTextStream &s)
bool raw::VDColdboxTDERawInput::readNext ( art::RunPrincipal *const &  inR,
art::SubRunPrincipal *const &  inSR,
art::RunPrincipal *&  outR,
art::SubRunPrincipal *&  outSR,
art::EventPrincipal *&  outE 
)

Definition at line 315 of file VDColdboxTDERawInput_source.cc.

320  {
321  mf::LogInfo(__FUNCTION__)<<"Processing "<<__eventCtr<<" event record";
322  if( __eventCtr == __eventNum )
323  {
324  //ok we finished
325  mf::LogDebug(__FUNCTION__)<<"Finished reading "<<__eventNum<<" events";
326  return false;
327  }
328  if( (__maxEvents > 0 ) && ( (int)__eventCtr >= __maxEvents) ){
329  return false;
330  }
331 
332  // move to the next file position
333  if( __events[ __eventCtr ] != __file.tellg() )
334  __file.seekg( __events[ __eventCtr ], std::ios::beg );
335  size_t bsz = __evsz[ __eventCtr ];
336 
337  std::vector<BYTE> buf;
338  __readChunk( buf, bsz );
339 
340  // increment our event counter
341  __eventCtr++;
342 
343  DaqEvent event;
344  //bool ok =
345  __unpackEvent( buf, event );
346  // not sure what art wants me to do here if this was not ok ???
347 
348  art::RunNumber_t rn = event.runnum;
349  art::SubRunNumber_t srn = __file_seqno; // seq no from file name
350 
351  uint64_t sec = event.trigstamp.tv_sec;
352  uint64_t nsec = event.trigstamp.tv_nsec;
353 
354  // first 4 bytes are seconds and last four bytes are nsec
355  uint64_t tval = (sec << 32) + nsec;
356 
357  // here we are using event timestamp
358  // what happens if events in the future in same sub-run
359  // (different L2 builder) event have a lower timestamp
360  art::Timestamp tstamp( tval );
361 
362  bool doupdate;
363  if( (doupdate = (rn != __currentSubRunID.run())) )
364  {
365  outR = __sourceHelper.makeRunPrincipal(rn, tstamp);
366  doupdate = true;
367  }
368  if( (doupdate = (srn != __currentSubRunID.subRun())) )
369  {
370  outSR = __sourceHelper.makeSubRunPrincipal(rn, srn, tstamp);
371  }
372 
373  if( doupdate )
374  __currentSubRunID = art::SubRunID( rn, srn );
375 
376 
379  event.evnum, tstamp );
380 
381 
382  std::unique_ptr< std::vector<raw::RawDigit> > data ( new std::vector<raw::RawDigit> );
383  std::unique_ptr< std::vector<raw::RDTimeStamp> > rdtm ( new std::vector<raw::RDTimeStamp> );
384  std::unique_ptr< std::vector<raw::RDStatus> > stat ( new std::vector<raw::RDStatus> );
385 
386  // move data
387  data->reserve( event.crodata.size() );
388 
389  //
391  unsigned cru_ch = __start_tde_cru; // TDE channels should start at 0
392  for( size_t i=0;i<event.crodata.size();i++ )
393  {
394  if( i >= __daqch.size() ){ //skip not connected channels
395  continue;
396  }
397  unsigned daqch = __daqch[i];
398  raw::ChannelID_t ch = cru_ch;
399  cru_ch++;
400 
401  // raw digit
402 
403  if( __keepch[i] ){
404  unsigned invped = __invped[i];
405  if( invped > 0 ){
406  for( auto &e : event.crodata[daqch] ){
407  float v = (float)invped - e;
408  e = (short)(v);
409  }
410  }
411 
412  float median = 0., sigma = 0.;
413  getMedianSigma(event.crodata[daqch], median, sigma);
414  data->push_back( raw::RawDigit(ch, __nsacro,
415  std::move( event.crodata[daqch] ),
416  event.compression) );
417  data->back().SetPedestal( median, sigma );
418  }
419  else {
420  data->push_back( raw::RawDigit(ch, 0, dummy, event.compression) );
421  }
422  }
423  unsigned int statword = 0;
424  bool discarded = false;
425  bool kept = false;
426  if( !event.good ) // data missing from some units
427  {
428  discarded = false;
429  kept = true;
430  }
431  if( discarded ) statword |= 1;
432  if( kept ) statword |= 2;
433  stat->emplace_back( discarded, kept, statword );
434 
435  // assign some trigger flag ... see DataPrepModule
436  uint16_t rdtsflags = 0xd; // CRT for now
437  rdtm->emplace_back( raw::RDTimeStamp( tval, rdtsflags ) );
438 
442 
443  return true;
444  }
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary const &subRunAux) const
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:73
std::vector< unsigned > __invped
RunPrincipal * makeRunPrincipal(RunAuxiliary const &runAux) const
Definition: SourceHelper.cc:92
std::vector< uint32_t > __evsz
const double e
def move(depos, offset)
Definition: depos.py:107
RunNumber_t run() const
Definition: SubRunID.h:85
art::SourceHelper const & __sourceHelper
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:119
bool __unpackEvent(std::vector< BYTE > &buf, DaqEvent &event)
void __readChunk(std::vector< BYTE > &bytes, size_t sz)
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={})
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
std::vector< std::streampos > __events
std::vector< unsigned > __daqch
cet::LibraryManager dummy("noplugin")
EventPrincipal * makeEventPrincipal(EventAuxiliary const &eventAux, std::unique_ptr< History > &&history) const
SubRunNumber_t subRun() const
Definition: SubRunID.h:91
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
double median(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:26
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:120

Member Data Documentation

art::SubRunID raw::VDColdboxTDERawInput::__currentSubRunID
private

Definition at line 96 of file VDColdboxTDERawInput.h.

std::vector<unsigned> raw::VDColdboxTDERawInput::__daqch
private

Definition at line 128 of file VDColdboxTDERawInput.h.

uint32_t raw::VDColdboxTDERawInput::__eventCtr
private

Definition at line 106 of file VDColdboxTDERawInput.h.

uint32_t raw::VDColdboxTDERawInput::__eventNum
private

Definition at line 107 of file VDColdboxTDERawInput.h.

std::vector<std::streampos> raw::VDColdboxTDERawInput::__events
private

Definition at line 134 of file VDColdboxTDERawInput.h.

std::vector<uint32_t> raw::VDColdboxTDERawInput::__evsz
private

Definition at line 135 of file VDColdboxTDERawInput.h.

std::ifstream raw::VDColdboxTDERawInput::__file
private

Definition at line 139 of file VDColdboxTDERawInput.h.

unsigned raw::VDColdboxTDERawInput::__file_seqno
private

Definition at line 140 of file VDColdboxTDERawInput.h.

size_t raw::VDColdboxTDERawInput::__filesz
private

Definition at line 138 of file VDColdboxTDERawInput.h.

std::vector<unsigned> raw::VDColdboxTDERawInput::__invped
private

Definition at line 131 of file VDColdboxTDERawInput.h.

std::vector<bool> raw::VDColdboxTDERawInput::__keepch
private

Definition at line 129 of file VDColdboxTDERawInput.h.

int raw::VDColdboxTDERawInput::__logLevel
private

Definition at line 98 of file VDColdboxTDERawInput.h.

int raw::VDColdboxTDERawInput::__maxEvents
private

Definition at line 109 of file VDColdboxTDERawInput.h.

size_t raw::VDColdboxTDERawInput::__nsacro
private

Definition at line 112 of file VDColdboxTDERawInput.h.

std::string raw::VDColdboxTDERawInput::__outlbl_digits
private

Definition at line 99 of file VDColdboxTDERawInput.h.

std::string raw::VDColdboxTDERawInput::__outlbl_rdtime
private

Definition at line 101 of file VDColdboxTDERawInput.h.

std::string raw::VDColdboxTDERawInput::__outlbl_status
private

Definition at line 100 of file VDColdboxTDERawInput.h.

std::string raw::VDColdboxTDERawInput::__prodlbl_digits
private

Definition at line 102 of file VDColdboxTDERawInput.h.

std::string raw::VDColdboxTDERawInput::__prodlbl_rdtime
private

Definition at line 104 of file VDColdboxTDERawInput.h.

std::string raw::VDColdboxTDERawInput::__prodlbl_status
private

Definition at line 103 of file VDColdboxTDERawInput.h.

art::SourceHelper const& raw::VDColdboxTDERawInput::__sourceHelper
private

Definition at line 95 of file VDColdboxTDERawInput.h.

size_t raw::VDColdboxTDERawInput::__start_tde_cru
private

Definition at line 113 of file VDColdboxTDERawInput.h.


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