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

Public Member Functions

 TimeOffset (fhicl::ParameterSet const &p)
 
 TimeOffset (TimeOffset const &)=delete
 
 TimeOffset (TimeOffset &&)=delete
 
TimeOffsetoperator= (TimeOffset const &)=delete
 
TimeOffsetoperator= (TimeOffset &&)=delete
 
void analyze (art::Event const &e) override
 
- 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 (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::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 &)
 
fhicl::ParameterSetID selectorConfig () 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 onFileClose ()
 

Private Attributes

const art::InputTag fCRTLabel
 
const art::InputTag fTimestampLabel
 
const int fNIntervalBins
 
const double fIntervalMin
 
const double fIntervalMax
 
TH1D * fTimestampMinusCRT
 
TH1D * fEarliestDeltaT
 
TH1D * fCRTDeltaT
 
TH1D * fMinDeltaT
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- 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 71 of file TimeOffset_module.cc.

Constructor & Destructor Documentation

CRT::TimeOffset::TimeOffset ( fhicl::ParameterSet const &  p)
explicit

Definition at line 123 of file TimeOffset_module.cc.

124  :
125  EDAnalyzer(p),
126  fCRTLabel(p.get<art::InputTag>("CRTLabel", "crt")),
127  fTimestampLabel(p.get<art::InputTag>("TimestampLabel")),
128  fNIntervalBins(500),
129  fIntervalMin(0),
130  fIntervalMax(125000)
131 {
132  // Tell "scheduler" which data products this module needs as input
133  consumes<std::vector<CRT::Trigger>>(fCRTLabel);
134  consumes<std::vector<raw::RDTimeStamp>>(fTimestampLabel);
135 
136  // Set up file change callback
138  tfs->registerFileSwitchCallback(this, &CRT::TimeOffset::onFileClose);
139  onFileClose(); // Setting up the callback above doesn't actually call
140  // it for the first file. So, call it now to create
141  // initial histograms.
142 }
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
const double fIntervalMin
const double fIntervalMax
p
Definition: test.py:223
const art::InputTag fTimestampLabel
const art::InputTag fCRTLabel
CRT::TimeOffset::TimeOffset ( TimeOffset const &  )
delete
CRT::TimeOffset::TimeOffset ( TimeOffset &&  )
delete

Member Function Documentation

void CRT::TimeOffset::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 158 of file TimeOffset_module.cc.

159 {
160  // Get the CRT::Triggers and RDTimeStamps that we will compare.
161  // If we fail to get either data product, skip this event without
162  // killing the job. Propagate an error message to the user about
163  // which data product wasn't found first.
164  try
165  {
166  const auto& crtHandle = e.getValidHandle<std::vector<CRT::Trigger>>(fCRTLabel);
167  const auto& timeHandle = e.getValidHandle<std::vector<raw::RDTimeStamp>>(fTimestampLabel);
168 
169  using timestamp_t = int64_t; //Make sure timestamp differences are signed
170  ::limits<timestamp_t> crtLimits, rawLimits;
171  timestamp_t minAbsDeltaT = std::numeric_limits<timestamp_t>::max();
172  for(const auto& trigger: *crtHandle)
173  {
174  //Fill plots for all combinations of a CRT::Trigger and an RDTimeStamp
175  const timestamp_t& crtTime = trigger.Timestamp();
176  for(const auto& time: *timeHandle)
177  {
178  const timestamp_t& rawTime = time.GetTimeStamp();
179  const auto deltaT = rawTime - crtTime;
180  fTimestampMinusCRT->Fill(deltaT);
181  rawLimits(rawTime);
182  if(labs(deltaT) < labs(minAbsDeltaT)) minAbsDeltaT = deltaT;
183  } //For each RDTimeStamp from fTimestampLabel
184 
185  // Fill plots for this CRT::Trigger
186  crtLimits(crtTime);
187  } //For each CRT::Trigger from fCRTLabel
188 
189  fEarliestDeltaT->Fill(rawLimits.min()-crtLimits.min());
190  fCRTDeltaT->Fill(crtLimits.range());
191  fMinDeltaT->Fill(minAbsDeltaT);
192  }
193  catch(const cet::exception& e) //Don't crash the whole job if this module doesn't find the data products it needs.
194  {
195  mf::LogWarning("Product not found") << "Failed to find one of the data products that "
196  << "CRT::TimeOffset needs to make timing plots. "
197  << "This module needs CRT::Triggers and raw::RDTimeStamps.\n"
198  << e.what() << "\n";
199  }
200 }
const double e
struct ptb::content::word::timestamp_t timestamp_t
static int max(int a, int b)
const art::InputTag fTimestampLabel
const art::InputTag fCRTLabel
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void CRT::TimeOffset::onFileClose ( )
private

Definition at line 144 of file TimeOffset_module.cc.

145 {
146  std::stringstream ss;
147  ss << fTimestampLabel;
148 
150  fTimestampMinusCRT = tfs->make<TH1D>("TimestampMinusCRT", (std::string("Time Difference Between CRT and ")+ss.str()+";Time [ticks];").c_str(),
152  fEarliestDeltaT = tfs->make<TH1D>("EarliestDeltaT", "Time Difference Between Earliest CRT::Trigger and Earliest RDTimestamp;Time [ticks];",
154  fCRTDeltaT = tfs->make<TH1D>("CRTDeltaT", "Range of CRT Timestamps;Time [ticks];Events", fNIntervalBins, fIntervalMin, fIntervalMax);
155  fMinDeltaT = tfs->make<TH1D>("MinDeltaT", "Minimum Time Difference Between a CRT::Trigger and any RDTimestamp;Time [ticks];", 601, -100, 500);
156 }
std::string string
Definition: nybbler.cc:12
const double fIntervalMin
const double fIntervalMax
const art::InputTag fTimestampLabel
TimeOffset& CRT::TimeOffset::operator= ( TimeOffset const &  )
delete
TimeOffset& CRT::TimeOffset::operator= ( TimeOffset &&  )
delete

Member Data Documentation

TH1D* CRT::TimeOffset::fCRTDeltaT
private

Definition at line 118 of file TimeOffset_module.cc.

const art::InputTag CRT::TimeOffset::fCRTLabel
private

Definition at line 101 of file TimeOffset_module.cc.

TH1D* CRT::TimeOffset::fEarliestDeltaT
private

Definition at line 116 of file TimeOffset_module.cc.

const double CRT::TimeOffset::fIntervalMax
private

Definition at line 108 of file TimeOffset_module.cc.

const double CRT::TimeOffset::fIntervalMin
private

Definition at line 107 of file TimeOffset_module.cc.

TH1D* CRT::TimeOffset::fMinDeltaT
private

Definition at line 120 of file TimeOffset_module.cc.

const int CRT::TimeOffset::fNIntervalBins
private

Definition at line 106 of file TimeOffset_module.cc.

const art::InputTag CRT::TimeOffset::fTimestampLabel
private

Definition at line 102 of file TimeOffset_module.cc.

TH1D* CRT::TimeOffset::fTimestampMinusCRT
private

Definition at line 114 of file TimeOffset_module.cc.


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