Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
dune::FelixRawDecoder Class Reference
Inheritance diagram for dune::FelixRawDecoder:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 FelixRawDecoder (fhicl::ParameterSet const &p)
 
 FelixRawDecoder (FelixRawDecoder const &)=delete
 
 FelixRawDecoder (FelixRawDecoder &&)=delete
 
FelixRawDecoderoperator= (FelixRawDecoder const &)=delete
 
FelixRawDecoderoperator= (FelixRawDecoder &&)=delete
 
void produce (art::Event &e) override
 
void reconfigure (const fhicl::ParameterSet &pset)
 
void beginJob () override
 
void setRootObjects ()
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Types

typedef std::vector< raw::RawDigitRawDigits
 

Private Member Functions

bool _process (const artdaq::Fragment &frag, RawDigits &raw_digits)
 

Private Attributes

std::string _input_label
 
std::string _output_label
 
bool _expect_container_fragments
 
TH1D * _h_nframes
 
std::vector< uint16_t > _buffer
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 34 of file FelixRawDecoder_module.cc.

Member Typedef Documentation

Definition at line 54 of file FelixRawDecoder_module.cc.

Constructor & Destructor Documentation

dune::FelixRawDecoder::FelixRawDecoder ( fhicl::ParameterSet const &  p)
explicit

Definition at line 70 of file FelixRawDecoder_module.cc.

71  : EDProducer{pset}
72 // Initialize member data here.
73 {
75  //fs->registerFileSwitchCallback(this, &FelixRawDecoder::setRootObjects);
77 
78  reconfigure(pset);
79  // Call appropriate produces<>() functions here.
80  //produces< std::vector<raw::RawDigit> > ( _output_label );
81  produces<RawDigits>( _output_label );
82 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
static constexpr double fs
Definition: Units.h:100
void reconfigure(const fhicl::ParameterSet &pset)
dune::FelixRawDecoder::FelixRawDecoder ( FelixRawDecoder const &  )
delete
dune::FelixRawDecoder::FelixRawDecoder ( FelixRawDecoder &&  )
delete

Member Function Documentation

bool dune::FelixRawDecoder::_process ( const artdaq::Fragment &  frag,
RawDigits raw_digits 
)
private

Definition at line 183 of file FelixRawDecoder_module.cc.

187 {
188  // FIXME: Remove hard-coded fragment type
189  //if((unsigned)frag.type() != 2) return false;
190 
191  MF_LOG_INFO("FelixRawDecoder")
192  << " SequenceID = " << frag.sequenceID()
193  << " fragmentID = " << frag.fragmentID()
194  << " fragmentType = " << (unsigned)frag.type()
195  << " Timestamp = " << frag.timestamp();
197  //Load overlay class.
198  dune::FelixFragment felix(frag);
199  //Get detector elemen number
200  uint8_t crate = felix.crate_no(0);
201  uint8_t slot = felix.slot_no(0);
202  uint8_t fiber = felix.fiber_no(0); // two numbers?
203  const unsigned n_frames = felix.total_frames(); // One frame contains 20 ticks.
204  std::cout<<" Nframes = "<<n_frames<<std::endl;
205  _h_nframes->Fill(n_frames);
206  const unsigned n_channels = dune::FelixFrame::num_ch_per_frame;// 256
208  //v_adc.reserve(n_frames*n_channels);
209  // Fill the adc vector.
210  //typedef std::tuple<uint8_t, uint8_t, uint8_t, unsigned> WireInfo_tuple; // unused
211  for(unsigned ch = 0; ch < n_channels; ++ch) {
212  v_adc.clear();
213  std::cout<<"crate:slot:fiber = "<<crate<<", "<<slot<<", "<<fiber<<std::endl;
214  std::vector<dune::adc_t> waveform( felix.get_ADCs_by_channel(ch) );
215  for(unsigned int nframe=0;nframe<waveform.size();nframe++){
216  if(ch==0 && nframe<100) {
217  if(nframe==0) std::cout<<"Print the first 100 ADCs of Channel#1"<<std::endl;
218  std::cout<<waveform.at(nframe)<<" ";
219  if(nframe==99) std::cout<<std::endl;
220  }
221  v_adc.push_back(waveform.at(nframe));
222  }
223  int offlineChannel = -1;
224  offlineChannel = channelMap->GetOfflineNumberFromDetectorElements(crate, slot, fiber, ch,dune::PdspChannelMapService::kFELIX); // FIXME
225  // Push to raw_digits.
226  raw::RawDigit raw_digit(offlineChannel, n_frames, v_adc);
227  raw_digits.push_back(raw_digit);
228  }
229  return true;
230 }
static constexpr size_t num_ch_per_frame
Definition: FelixFormat.hh:298
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:73
unsigned int GetOfflineNumberFromDetectorElements(unsigned int crate, unsigned int slot, unsigned int fiber, unsigned int fembchannel, FelixOrRCE frswitch)
struct dune::tde::crate crate
#define MF_LOG_INFO(category)
QTextStream & endl(QTextStream &s)
void dune::FelixRawDecoder::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 95 of file FelixRawDecoder_module.cc.

95  {
96 }
FelixRawDecoder& dune::FelixRawDecoder::operator= ( FelixRawDecoder const &  )
delete
FelixRawDecoder& dune::FelixRawDecoder::operator= ( FelixRawDecoder &&  )
delete
void dune::FelixRawDecoder::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 98 of file FelixRawDecoder_module.cc.

98  {
99  // TODO Use MF_LOG_DEBUG
100  MF_LOG_INFO("FelixRawDecoder")
101  << "-------------------- FELIX RawDecoder -------------------";
102 
103  RawDigits raw_digits;
104  unsigned int n_felix_frags = 0;
105 
107  art::InputTag itag1(_input_label, "ContainerFELIX");
108  auto cont_frags = evt.getHandle<artdaq::Fragments>(itag1);
109  art::EventNumber_t eventNumber = evt.event();
110  // Check if there is Timing data in this event
111  // Don't crash code if not present, just don't save anything
112  try { cont_frags->size(); }
113  catch(std::exception const&) {
114  std::cout << "WARNING: Container FELIX data not found in event " << eventNumber << std::endl;
115  std::vector<raw::RawDigit> digits;
116  evt.put(std::make_unique<std::vector<raw::RawDigit>>(std::move(digits)), _output_label);
117  return;
118  }
119  //Check that the data is valid
120  if(!cont_frags){
121  MF_LOG_ERROR("FelixRawDecoder")
122  << "Run: " << evt.run()
123  << ", SubRun: " << evt.subRun()
124  << ", Event: " << evt.event()
125  << " Container Fragments is NOT VALID";
126  }
127 
128  for (auto const& cont : *cont_frags)
129  {
130  artdaq::ContainerFragment cont_frag(cont);
131  for (size_t ii = 0; ii < cont_frag.block_count(); ++ii)
132  {
133  //artdaq::Fragment frag;
134  //size_t frag_size = cont_frag.fragSize(ii);
135  //frag.resizeBytes(frag_size);
136  //memcpy(frag.headerAddress(), cont_frag.at(ii), frag_size);
137  //if (_process(frag, raw_digits)) ++n_felix_frags;
138  if (_process(*cont_frag[ii], raw_digits)) ++n_felix_frags;
139  }
140  }
141  }
142  else
143  {
144  art::InputTag itag2(_input_label, "FELIX");
145  auto frags = evt.getHandle<artdaq::Fragments>(itag2);
146  // Check if there is Timing data in this event
147  // Don't crash code if not present, just don't save anything
148  art::EventNumber_t eventNumber = evt.event();
149  try { frags->size(); }
150  catch(std::exception const&) {
151  std::cout << "WARNING: Raw FELIX data not found in event " << eventNumber << std::endl;
152  std::vector<raw::RawDigit> digits;
153  evt.put(std::make_unique<std::vector<raw::RawDigit>>(std::move(digits)), _output_label);
154  return;
155  }
156 
157  //Check that the data is valid
158  if(!frags.isValid()){
159  MF_LOG_ERROR("FelixRawDecoder")
160  << "Run: " << evt.run()
161  << ", SubRun: " << evt.subRun()
162  << ", Event: " << evt.event()
163  << " Fragments is NOT VALID";
164  }
165 
166  for(auto const& frag: *frags)
167  {
168  if (_process(frag, raw_digits)) ++n_felix_frags;
169  }
170  }
171 
172  MF_LOG_INFO("FelixRawDecoder")
173  << " Processed " << n_felix_frags
174  << " FELIX Fragments, "
175  << raw_digits.size()
176  << " RawDigits.";
177 
178  evt.put(std::make_unique<decltype(raw_digits)>(std::move(raw_digits)),
179  _output_label);
180 }
std::vector< raw::RawDigit > RawDigits
unsigned int event
Definition: DataStructs.h:636
unsigned int run
Definition: DataStructs.h:637
#define MF_LOG_ERROR(category)
def move(depos, offset)
Definition: depos.py:107
#define MF_LOG_INFO(category)
bool _process(const artdaq::Fragment &frag, RawDigits &raw_digits)
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:118
unsigned int subRun
Definition: DataStructs.h:638
TCEvent evt
Definition: DataStructs.cxx:7
std::vector< Fragment > Fragments
Definition: HDF5Utils.h:57
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
void dune::FelixRawDecoder::reconfigure ( const fhicl::ParameterSet pset)

Definition at line 84 of file FelixRawDecoder_module.cc.

84  {
85 
86  _input_label = pset.get<std::string>("RawDataLabel");
87  _output_label = pset.get<std::string>("OutputDataLabel");
88  _expect_container_fragments = pset.get<bool>("ExpectContainerFragments", true);
89 }
std::string string
Definition: nybbler.cc:12
T get(std::string const &key) const
Definition: ParameterSet.h:271
void dune::FelixRawDecoder::setRootObjects ( )

Definition at line 91 of file FelixRawDecoder_module.cc.

91  {
93  _h_nframes = file_srv->make<TH1D>("felix_NFrames","FELIX: Number of frames", 1000, 0, 1000);
94 }

Member Data Documentation

std::vector<uint16_t> dune::FelixRawDecoder::_buffer
private

Definition at line 66 of file FelixRawDecoder_module.cc.

bool dune::FelixRawDecoder::_expect_container_fragments
private

Definition at line 63 of file FelixRawDecoder_module.cc.

TH1D* dune::FelixRawDecoder::_h_nframes
private

Definition at line 64 of file FelixRawDecoder_module.cc.

std::string dune::FelixRawDecoder::_input_label
private

Definition at line 61 of file FelixRawDecoder_module.cc.

std::string dune::FelixRawDecoder::_output_label
private

Definition at line 62 of file FelixRawDecoder_module.cc.


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