Public Member Functions | Private Member Functions | Private Attributes | List of all members
DAQToOffline::SSPTriggerAna Class Reference
Inheritance diagram for DAQToOffline::SSPTriggerAna:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 SSPTriggerAna (fhicl::ParameterSet const &pset)
 
void analyze (art::Event const &evt) override
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void printParameterSet ()
 
 SSPTriggerAna (SSPTriggerAna const &)=delete
 
 SSPTriggerAna (SSPTriggerAna &&)=delete
 
SSPTriggerAnaoperator= (SSPTriggerAna const &)=delete
 
SSPTriggerAnaoperator= (SSPTriggerAna &&)=delete
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob ()
 
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::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
- 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 Member Functions

void beginJob () override
 
void endJob () override
 
void beginRun (art::Run const &run) override
 
void endRun (art::Run const &run) override
 

Private Attributes

std::string fFragType
 
std::string fRawDataLabel
 
std::string fOutputDataLabel
 
SSPReformatterAlgs sspReform
 
unsigned long int firstTime
 
unsigned long int lastTime
 
std::map< int, long int > triggerCount
 
std::map< int, long int > triggerCountHeaders
 
std::map< int, long int > triggerCountWaveforms
 
TH1D * fTriggerRateHist
 
TH1D * fTriggerRateHistHeaders
 
TH1D * fTriggerRateHistWaveforms
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &paths, fhicl::ParameterSet const &config)
 
detail::ProcessAndEventSelectorsprocessAndEventSelectors ()
 
- 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 54 of file SSPTriggerAna_module.cc.

Constructor & Destructor Documentation

DAQToOffline::SSPTriggerAna::SSPTriggerAna ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 98 of file SSPTriggerAna_module.cc.

99  : art::EDAnalyzer(pset),
100  sspReform(pset.get<fhicl::ParameterSet>("SSPReformatter"))
101 {
102 
103  this->reconfigure(pset);
104 
105  //first_FirstSample = -1;
106  //first_TimeStamp = -1;
107 }
void reconfigure(fhicl::ParameterSet const &pset)
DAQToOffline::SSPTriggerAna::SSPTriggerAna ( SSPTriggerAna const &  )
delete
DAQToOffline::SSPTriggerAna::SSPTriggerAna ( SSPTriggerAna &&  )
delete

Member Function Documentation

void DAQToOffline::SSPTriggerAna::analyze ( art::Event const &  evt)
overridevirtual

< Derived Optical channel

< first sample time in ticks

Implements art::EDAnalyzer.

Definition at line 219 of file SSPTriggerAna_module.cc.

220 {
221 
222  // std::cout<<"Event: "<<evt.event()<<"Run: "<<evt.run()<<std::endl;
223 
224  art::Handle<artdaq::Fragments> rawFragments;
225  evt.getByLabel(fRawDataLabel, fFragType, rawFragments);
226 
227  // Check if there is SSP data in this event
228  // Don't crash code if not present, just don't save anything
229  try { rawFragments->size(); }
230  catch(std::exception const&) {
231  mf::LogWarning("SSPTriggerAna") << "WARNING: Raw SSP data not found in event " << evt.event();
232  return;
233  }
234 
235  // Check that the data is valid
236  if(!rawFragments.isValid()){
237  mf::LogError("SSPTriggerAna") << "Run: " << evt.run()
238  << ", SubRun: " << evt.subRun()
239  << ", Event: " << evt.event()
240  << " is NOT VALID";
241  throw cet::exception("raw NOT VALID");
242  return;
243  }
244 
245 
246 
247  unsigned int numFragments = rawFragments->size();
248 
249  for (size_t idx = 0; idx < numFragments; ++idx) {
250  const auto& frag((*rawFragments)[idx]);
251  lbne::SSPFragment sspf(frag);
252 
253  unsigned int nTriggers = sspReform.CheckAndGetNTriggers(frag, sspf);
254 
255  const unsigned int* dataPointer = sspf.dataBegin();
256 
257 
258  for (unsigned int triggersProcessed = 0;
259  (nTriggers==0 || triggersProcessed < nTriggers) && dataPointer < sspf.dataEnd();
260  ++triggersProcessed) {
261 
262  //
263  // The elements of the OpDet Pulse
264  //
265  unsigned short OpChannel = -1; ///< Derived Optical channel
266  unsigned long FirstSample = 0; ///< first sample time in ticks
267 
268 
269  // Load the event header, advance the pointer
270  auto daqHeader = sspReform.GetHeaderAndAdvance(dataPointer);
271  //const SSPDAQ::EventHeader* daqHeader=reinterpret_cast<const SSPDAQ::EventHeader*>(dataPointer);
272  //dataPointer += sizeof(SSPDAQ::EventHeader)/sizeof(unsigned int);
273 
274  // Get ADC Count, create pointer to adcs
275  unsigned int nADC = sspReform.GetWaveformLength(daqHeader);
276 
277  //get the information from the header
278  try {
279  OpChannel = sspReform.GetOpChannel(daqHeader);
280 
281  FirstSample = sspReform.GetGlobalFirstSample(daqHeader);
282  //TimeStamp = ((double)FirstSample)/fNOvAClockFrequency;
283 
284  if (FirstSample < 1e16) {
285  sspReform.PrintHeaderInfo(daqHeader);
286  mf::LogInfo("SSPTriggerAna") << "Problem timestamp at " << FirstSample << std::endl;
287  continue;
288  }
289  }
290  catch (cet::exception const&) {
291  continue;
292  }
293 
294  firstTime = std::min(firstTime, FirstSample);
295  lastTime = std::max(lastTime, FirstSample);
296 
297  triggerCount[OpChannel]++;
298  fTriggerRateHist->Fill(OpChannel);
299 
300  if (nADC == 0) {
301  // Header only
302  triggerCountHeaders[OpChannel]++;
303  fTriggerRateHistHeaders->Fill(OpChannel);
304  }
305  else {
306  // Waveform to skip
307  triggerCountWaveforms[OpChannel]++;
308  fTriggerRateHistWaveforms->Fill(OpChannel);
309 
310  // Advance the dataPointer to the next header
311  dataPointer+=nADC/2;
312  }
313 
314 
315  } // End of loop over triggers
316  } // End of loop over fragments (rawFragments)
317 
318 
319 }
unsigned int event
Definition: DataStructs.h:574
std::map< int, long int > triggerCountWaveforms
unsigned int run
Definition: DataStructs.h:575
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
unsigned int CheckAndGetNTriggers(const artdaq::Fragment &frag, const lbne::SSPFragment sspf)
Load the milislice.
std::map< int, long int > triggerCountHeaders
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
unsigned int GetWaveformLength(const SSPDAQ::EventHeader *daqHeader)
const SSPDAQ::EventHeader * GetHeaderAndAdvance(const unsigned int *&dataPointer)
Load the header.
bool isValid() const
Definition: Handle.h:183
unsigned long GetGlobalFirstSample(const SSPDAQ::EventHeader *daqHeader)
std::map< int, long int > triggerCount
static int max(int a, int b)
unsigned short GetOpChannel(const SSPDAQ::EventHeader *daqHeader)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
unsigned int subRun
Definition: DataStructs.h:576
TCEvent evt
Definition: DataStructs.cxx:7
void PrintHeaderInfo(const SSPDAQ::EventHeader *daqHeader)
Print out header information.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
void DAQToOffline::SSPTriggerAna::beginJob ( )
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 132 of file SSPTriggerAna_module.cc.

133 {
134  //art::ServiceHandle<art::TFileService> tfs;
135  //adc_values_ = tfs->make<TH1D>("adc_values","adc_values",4096,-0.5,4095.5);
136 
138  fTriggerRateHist = tfs->make<TH1D>("triggerratehist",";Trigger Rate vs OpChannel;Rate (Hz)",116,-10,106);
139  fTriggerRateHistHeaders = tfs->make<TH1D>("triggerratehist_headers",";Trigger Rate vs OpChannel;Rate (Hz)",116,-10,106);
140  fTriggerRateHistWaveforms = tfs->make<TH1D>("triggerratehist_waveforms",";Trigger Rate vs OpChannel;Rate (Hz)",116,-10,106);
141 
142  firstTime = (((unsigned long int)1)<<63);
143  lastTime = 0;
144 }
void DAQToOffline::SSPTriggerAna::beginRun ( art::Run const &  run)
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 148 of file SSPTriggerAna_module.cc.

void DAQToOffline::SSPTriggerAna::endJob ( )
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 176 of file SSPTriggerAna_module.cc.

177 {
178  //delete adc_values_;
179  delete fTriggerRateHist;
182 
183  long int deltaT = lastTime-firstTime;
184  double deltaTus = ((double)deltaT)/sspReform.ClockFrequency();
185 
186 
187  mf::LogVerbatim("SSPTriggerAna") << "!! Trigger Rate Report." << std::endl;
188  mf::LogVerbatim("SSPTriggerAna") << "!! Time: " << deltaTus / 60.e6 << " minutes." << std::endl;
189 
190  for (auto itr = triggerCount.begin(); itr != triggerCount.end(); itr++) {
191  double freq = ((double)itr->second) / deltaTus * 1e6;
192  mf::LogVerbatim("SSPTriggerAna") << "!! Channel " << itr->first << ": " << std::setiosflags(std::ios::fixed) << std::setprecision(2) << std::setw(7) << freq << " Hz" << std::endl;
193  }
194 
195  for (auto itr = triggerCountHeaders.begin(); itr != triggerCountHeaders.end(); itr++) {
196  double freq = ((double)itr->second) / deltaTus * 1e6;
197  mf::LogVerbatim("SSPTriggerAna") << "!! H Channel " << itr->first << ": " << std::setiosflags(std::ios::fixed) << std::setprecision(2) << std::setw(7) << freq << " Hz" << std::endl;
198  }
199 
200  for (auto itr = triggerCountWaveforms.begin(); itr != triggerCountWaveforms.end(); itr++) {
201  double freq = ((double)itr->second) / deltaTus * 1e6;
202  mf::LogVerbatim("SSPTriggerAna") << "!! W Channel " << itr->first << ": " << std::setiosflags(std::ios::fixed) << std::setprecision(2) << std::setw(7) << freq << " Hz" << std::endl;
203  }
204 
205 
206  /*
207  mf::LogInfo("SSPTriggerAna") << "firstSample: " << firstTime << " samples\n"
208  << "lastSample: " << lastTime << " samples\n"
209  << "totalSamples: " << deltaT << " samples\n"
210  << "totalTime: " << deltaTus << " us\n"
211  << "# Channels: " << channels.size() << "\n"
212  << "# Triggers: " << triggerCount << "\n"
213  << "Frequency: " << freq << "kHz\n";
214  */
215 }
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
std::map< int, long int > triggerCountWaveforms
std::map< int, long int > triggerCountHeaders
Q_EXPORT QTSManip setprecision(int p)
Definition: qtextstream.h:343
std::map< int, long int > triggerCount
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
double ClockFrequency()
Return the NOvAClockFrequency.
QTextStream & endl(QTextStream &s)
void DAQToOffline::SSPTriggerAna::endRun ( art::Run const &  run)
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 155 of file SSPTriggerAna_module.cc.

156 {
157  long int deltaT = lastTime-firstTime;
158  double deltaTus = ((double)deltaT)/sspReform.ClockFrequency();
159 
160  fTriggerRateHist->Scale(1.e6/deltaTus);
161  fTriggerRateHistHeaders->Scale(1.e6/deltaTus);
162  fTriggerRateHistWaveforms->Scale(1.e6/deltaTus);
163 
164  fTriggerRateHist->SetTitle(Form("Run %i Trigger Rate",run.run()));
165  fTriggerRateHistHeaders->SetTitle(Form("Run %i Header Trigger Rate",run.run()));
166  fTriggerRateHistWaveforms->SetTitle(Form("Run %i Wavefrom Trigger Rate",run.run()));
167 
168  fTriggerRateHist->Write(Form("run_%i_trigger_rate",run.run()));
169  fTriggerRateHistHeaders->Write(Form("run_%i_trigger_rate_headers",run.run()));
170  fTriggerRateHistWaveforms->Write(Form("run_%i_trigger_rate_waveforms",run.run()));
171 
172 }
double ClockFrequency()
Return the NOvAClockFrequency.
unsigned int run
SSPTriggerAna& DAQToOffline::SSPTriggerAna::operator= ( SSPTriggerAna const &  )
delete
SSPTriggerAna& DAQToOffline::SSPTriggerAna::operator= ( SSPTriggerAna &&  )
delete
void DAQToOffline::SSPTriggerAna::printParameterSet ( )

Definition at line 122 of file SSPTriggerAna_module.cc.

122  {
123 
124  mf::LogDebug("SSPTriggerAna") << "====================================" << "\n"
125  << "Parameter Set" << "\n"
126  << "====================================" << "\n"
127  << "fFragType: " << fFragType << "\n"
128  << "fRawDataLabel: " << fRawDataLabel << "\n"
129  << "====================================" << "\n";
130 }
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
void DAQToOffline::SSPTriggerAna::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 109 of file SSPTriggerAna_module.cc.

109  {
110 
111  fFragType = pset.get<std::string>("FragType");
112  fRawDataLabel = pset.get<std::string>("RawDataLabel");
113 
114  //fDebug = pset.get<bool>("Debug");
115  //fZeroThreshold=0;
116  //fCompression=raw::kNone;
117 
119 
120 }
std::string string
Definition: nybbler.cc:12

Member Data Documentation

std::string DAQToOffline::SSPTriggerAna::fFragType
private

Definition at line 79 of file SSPTriggerAna_module.cc.

unsigned long int DAQToOffline::SSPTriggerAna::firstTime
private

Definition at line 85 of file SSPTriggerAna_module.cc.

std::string DAQToOffline::SSPTriggerAna::fOutputDataLabel
private

Definition at line 81 of file SSPTriggerAna_module.cc.

std::string DAQToOffline::SSPTriggerAna::fRawDataLabel
private

Definition at line 80 of file SSPTriggerAna_module.cc.

TH1D* DAQToOffline::SSPTriggerAna::fTriggerRateHist
private

Definition at line 91 of file SSPTriggerAna_module.cc.

TH1D* DAQToOffline::SSPTriggerAna::fTriggerRateHistHeaders
private

Definition at line 92 of file SSPTriggerAna_module.cc.

TH1D* DAQToOffline::SSPTriggerAna::fTriggerRateHistWaveforms
private

Definition at line 93 of file SSPTriggerAna_module.cc.

unsigned long int DAQToOffline::SSPTriggerAna::lastTime
private

Definition at line 86 of file SSPTriggerAna_module.cc.

SSPReformatterAlgs DAQToOffline::SSPTriggerAna::sspReform
private

Definition at line 83 of file SSPTriggerAna_module.cc.

std::map<int, long int> DAQToOffline::SSPTriggerAna::triggerCount
private

Definition at line 87 of file SSPTriggerAna_module.cc.

std::map<int, long int> DAQToOffline::SSPTriggerAna::triggerCountHeaders
private

Definition at line 88 of file SSPTriggerAna_module.cc.

std::map<int, long int> DAQToOffline::SSPTriggerAna::triggerCountWaveforms
private

Definition at line 89 of file SSPTriggerAna_module.cc.


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