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

Public Member Functions

 TimingRawDecoder (fhicl::ParameterSet const &p)
 
 TimingRawDecoder (TimingRawDecoder const &)=delete
 
 TimingRawDecoder (TimingRawDecoder &&)=delete
 
TimingRawDecoderoperator= (TimingRawDecoder const &)=delete
 
TimingRawDecoderoperator= (TimingRawDecoder &&)=delete
 
void produce (art::Event &e) override
 
void reconfigure (const fhicl::ParameterSet &pset)
 
void printParameterSet ()
 
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 Attributes

std::string fRawDataLabel
 
std::string fOutputDataLabel
 
bool fUseChannelMap
 
bool fDebug
 
bool fMakeTree
 
bool fMakeEventTimeFile = false
 
TH1I * fHTimestamp
 
TH1I * fHTrigType
 
TH1I * fHTimestampDelta
 
ULong64_t fPrevTimestamp
 

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 47 of file TimingRawDecoder_module.cc.

Constructor & Destructor Documentation

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

Definition at line 85 of file TimingRawDecoder_module.cc.

86  : EDProducer{pset}
87 // Initialize member data here.
88 {
90  //fs->registerFileSwitchCallback(this, &TimingRawDecoder::setRootObjects);
92 
93  reconfigure(pset);
94  // Call appropriate produces<>() functions here.
95  produces< std::vector<raw::RDTimeStamp> > (fOutputDataLabel);
96  produces< std::vector<dune::ProtoDUNETimeStamp> > (fOutputDataLabel);
97 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
static constexpr double fs
Definition: Units.h:100
void reconfigure(const fhicl::ParameterSet &pset)
dune::TimingRawDecoder::TimingRawDecoder ( TimingRawDecoder const &  )
delete
dune::TimingRawDecoder::TimingRawDecoder ( TimingRawDecoder &&  )
delete

Member Function Documentation

void dune::TimingRawDecoder::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 144 of file TimingRawDecoder_module.cc.

144  {
145 }
TimingRawDecoder& dune::TimingRawDecoder::operator= ( TimingRawDecoder const &  )
delete
TimingRawDecoder& dune::TimingRawDecoder::operator= ( TimingRawDecoder &&  )
delete
void dune::TimingRawDecoder::printParameterSet ( )

Definition at line 112 of file TimingRawDecoder_module.cc.

112  {
113 
114  for(int i=0;i<20;i++) std::cout << "=";
115  std::cout << std::endl;
116  std::cout << "Parameter Set" << std::endl;
117  for(int i=0;i<20;i++) std::cout << "=";
118  std::cout << std::endl;
119 
120  std::cout << "fRawDataLabel: " << fRawDataLabel << std::endl;
121  std::cout << "fOutputDataLabel: " << fOutputDataLabel << std::endl;
122  std::cout << "fDebug: ";
123  if(fDebug) std::cout << "true" << std::endl;
124  else std::cout << "false" << std::endl;
125 
126  for(int i=0;i<20;i++) std::cout << "=";
127  std::cout << std::endl;
128 }
QTextStream & endl(QTextStream &s)
void dune::TimingRawDecoder::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 147 of file TimingRawDecoder_module.cc.

147  {
148  //std::cout<<"-------------------- Timing RawDecoder -------------------"<<std::endl;
149  // Implementation of required member function here.
150  art::InputTag itag1(fRawDataLabel, "TIMING");
151  auto rawFragments = evt.getHandle<artdaq::Fragments>(itag1);
152 
153  art::EventNumber_t eventNumber = evt.event();
154  art::RunNumber_t runNumber = evt.run();
155 
156  std::vector<raw::RDTimeStamp> rdtimestamps;
157  std::vector<dune::ProtoDUNETimeStamp> pdtimestamps;
158 
159  if(rawFragments.isValid()){
160 
161  ULong64_t evtTimestamp = 0;
162  for(auto const& rawFrag : *rawFragments){
163  dune::TimingFragment frag(rawFrag);
164  // Try to determine the version of the fragment. This is
165  // complicated because early versions of the fragment didn't
166  // have a metadata object with the version, so for those, we
167  // have to look at the size of the fragment (actually the size
168  // of the payload, which excludes the header and metadata)
169  int fragmentVersion=0;
170  if(rawFrag.hasMetadata()){
172  fragmentVersion=metadata->fragment_version;
173  }
174  else{
175  size_t dataSizeBytes=rawFrag.dataSizeBytes();
176  // The first version of the fragment had 6 uint32_t words
177  if(dataSizeBytes==6*sizeof(uint32_t)){
178  fragmentVersion=1;
179  }
180  // The second version of the fragment had 12 uint32_t words,
181  // as the last spill start/end and last run start timestamps
182  // were added
183  else if(dataSizeBytes==12*sizeof(uint32_t)){
184  fragmentVersion=2;
185  }
186  else{
187  throw cet::exception("TimingRawDecoder::produce") << "Fragment had no metadata and unexpected size " << dataSizeBytes << " bytes. Can't determined timing fragment version";
188  }
189  }
190 
191  //std::cout << " Run " << runNumber << ", event " << eventNumber << ": ArtDaq Fragment Timestamp: " << std::dec << rawFrag.timestamp() << std::endl;
192  ULong64_t currentTimestamp=frag.get_tstamp();
193  uint16_t scmd = (frag.get_scmd() & 0xFFFF); // mask this just to make sure. Though scmd only has four relevant bits, the method is declared uint32_t.
194  rdtimestamps.emplace_back(currentTimestamp,scmd);
195 
197  pdts.setCookie(frag.get_cookie());
198  pdts.setTriggerType((dune::ProtoDUNETimingCommand)frag.get_scmd());
199  pdts.setReservedBits(frag.get_tcmd());
200  pdts.setTimeStamp(frag.get_tstamp());
201  pdts.setEventCounter(frag.get_evtctr());
202  // TODO: Checksum isn't set by the board reader yet
203  pdts.setChecksumGood(true);
204  pdts.setVersion(fragmentVersion);
205  // The additional timestamps were not added until version 2 of the timing fragment
206  if(fragmentVersion>=2){
207  pdts.setLastRunStart(frag.get_last_runstart_timestamp());
208  pdts.setLastSpillStart(frag.get_last_spillstart_timestamp());
209  pdts.setLastSpillEnd(frag.get_last_spillend_timestamp());
210  }
211  else{
212  // Set to 0xfff... if not present
213  pdts.setLastRunStart(~0ul);
214  pdts.setLastSpillStart(~0ul);
215  pdts.setLastSpillEnd(~0ul);
216  }
217 
218  pdtimestamps.push_back(pdts);
219 
220  fHTimestamp->Fill(currentTimestamp/1e6);
221  fHTrigType->Fill(frag.get_scmd());
222 
223  if(fPrevTimestamp!=0) fHTimestampDelta->Fill((currentTimestamp-fPrevTimestamp)/1e6);
224 
225  fPrevTimestamp=currentTimestamp;
226  // fHTimestamp->Fill(rawFrag.timestamp());
227 
228  if ( fMakeEventTimeFile ) {
229  if ( evtTimestamp == 0 ) {
230  evtTimestamp = rawFrag.timestamp();
231  string foutName = "artdaqTimestamp-Run" + std::to_string(runNumber);
232  int subrun = evt.subRun();
233  if ( subrun != 1 ) {
234  cout << "TimingRawDecoder::produce: WARNING: Unexpected subrun number: " << subrun << endl;
235  foutName += "-Sub" + std::to_string(subrun);
236  }
237  foutName += "-Event" + std::to_string(eventNumber) + ".dat";
238  ofstream fout(foutName);
239  fout << evtTimestamp << endl;
240  }
241  else
242  {
243  if ( rawFrag.timestamp() != evtTimestamp ) {
244  cout << "TimingRawDecoder::produce: WARNING: Fragments have inconsistent timestamps." << endl;
245  }
246  }
247  }
248  }
249  }
250  evt.put(std::make_unique<decltype(rdtimestamps)>(std::move(rdtimestamps)), fOutputDataLabel);
251  evt.put(std::make_unique<decltype(pdtimestamps)>(std::move(pdtimestamps)), fOutputDataLabel);
252 }
unsigned int event
Definition: DataStructs.h:636
void setLastSpillEnd(ULong64_t arg)
unsigned int run
Definition: DataStructs.h:637
void setLastSpillStart(ULong64_t arg)
void setTimeStamp(ULong64_t arg)
void setEventCounter(UInt_t arg)
void setTriggerType(dune::ProtoDUNETimingCommand arg)
void setLastRunStart(ULong64_t arg)
void setReservedBits(UInt_t arg)
def move(depos, offset)
Definition: depos.py:107
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:118
unsigned int subRun
Definition: DataStructs.h:638
TCEvent evt
Definition: DataStructs.cxx:7
ProtoDUNETimingCommand
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
std::vector< Fragment > Fragments
Definition: HDF5Utils.h:57
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:120
void dune::TimingRawDecoder::reconfigure ( const fhicl::ParameterSet pset)

Definition at line 99 of file TimingRawDecoder_module.cc.

99  {
100 
101  fRawDataLabel = pset.get<std::string>("RawDataLabel");
102  fOutputDataLabel = pset.get<std::string>("OutputDataLabel");
103  fUseChannelMap = pset.get<bool>("UseChannelMap");
104  fDebug = pset.get<bool>("Debug");
105  fMakeTree = pset.get<bool>("MakeTree");
106  pset.get_if_present<bool>("MakeEventTimeFile", fMakeEventTimeFile);
107  fPrevTimestamp=0;
108  if(fDebug) printParameterSet();
109 
110 }
std::string string
Definition: nybbler.cc:12
T get(std::string const &key) const
Definition: ParameterSet.h:271
std::optional< T > get_if_present(std::string const &key) const
Definition: ParameterSet.h:224
void dune::TimingRawDecoder::setRootObjects ( )

Definition at line 130 of file TimingRawDecoder_module.cc.

130  {
132 
133  fHTimestamp = tFileService->make<TH1I>("Timestamp","Timing Timestamp", 1e3, 0, 1e9);
134  fHTimestamp->GetXaxis()->SetTitle("Timestamp (ms)");
135 
136  fHTimestampDelta = tFileService->make<TH1I>("TimestampDelta","Timing Timestamp Delta", 100, 0, 1e3);
137  fHTimestampDelta->GetXaxis()->SetTitle("Delta Timestamp (ms)");
138 
139  fHTrigType = tFileService->make<TH1I>("TrigType","Timing trigger type", 20, -0.5, 19.5);
140  fHTrigType->GetXaxis()->SetTitle("Trigger type");
141 
142 
143 }

Member Data Documentation

bool dune::TimingRawDecoder::fDebug
private

Definition at line 73 of file TimingRawDecoder_module.cc.

TH1I* dune::TimingRawDecoder::fHTimestamp
private

Definition at line 77 of file TimingRawDecoder_module.cc.

TH1I* dune::TimingRawDecoder::fHTimestampDelta
private

Definition at line 79 of file TimingRawDecoder_module.cc.

TH1I* dune::TimingRawDecoder::fHTrigType
private

Definition at line 78 of file TimingRawDecoder_module.cc.

bool dune::TimingRawDecoder::fMakeEventTimeFile = false
private

Definition at line 75 of file TimingRawDecoder_module.cc.

bool dune::TimingRawDecoder::fMakeTree
private

Definition at line 74 of file TimingRawDecoder_module.cc.

std::string dune::TimingRawDecoder::fOutputDataLabel
private

Definition at line 71 of file TimingRawDecoder_module.cc.

ULong64_t dune::TimingRawDecoder::fPrevTimestamp
private

Definition at line 81 of file TimingRawDecoder_module.cc.

std::string dune::TimingRawDecoder::fRawDataLabel
private

Definition at line 70 of file TimingRawDecoder_module.cc.

bool dune::TimingRawDecoder::fUseChannelMap
private

Definition at line 72 of file TimingRawDecoder_module.cc.


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