SpillTime_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \brief Print the time of each NuMI spill, or another specified
3 /// trigger type. This is intended for use by EliminateBeamSpills.
4 ///
5 /// The time printed is the NOvA timestamp, which is a monotonically
6 /// increasing integer free of leap seconds. The only leap second
7 /// trouble is that since Accelerator Division systems don't handle leap
8 /// seconds well, we might be taking triggers that are 1s (or other
9 /// amounts) off of the physical spills near leap seconds.
10 ///
11 /// This method of getting timestamps relies on the spill server having
12 /// been up and running at the time the data being processed was taken.
13 /// It is possible that we have taken some data with other triggers
14 /// while the beam was running, but the spill server was down, in which
15 /// case we do not learn the spill times from this method.
16 ///
17 /// \author M. Strait <mstrait@fnal.gov>
18 ////////////////////////////////////////////////////////////////////////
19 
22 
23 #include "RawData/RawTrigger.h"
24 #include "DAQDataFormats/TriggerDefines.h"
25 
26 class spilltime : public art::EDAnalyzer {
27  public:
28  explicit spilltime(fhicl::ParameterSet const& pset):
29  EDAnalyzer(pset), trigger2spill(pset.get<double>("trigger2spill")),
30  trigid(pset.get<int>("trigid")) { }
31  virtual ~spilltime() { } // compiles, but does not run, without this
32  void analyze(const art::Event& evt);
33 
34  private:
35  double trigger2spill;
36  int trigid;
37 };
38 
40 {
42  evt.getByLabel("daq", rawtrigger);
43  if(rawtrigger.failedToGet()){
44  fprintf(stderr, "Unexpected lack of 'daq' product!\n");
45  return;
46  }
47  if(rawtrigger->empty()) return;
48 
49  if(((*rawtrigger)[0].fTriggerMask_TriggerType)+1 != trigid) return;
50 
51  const double tdc_per_second = 64e6;
52  const uint64_t trigger2spills_tdc = uint64_t(trigger2spill * tdc_per_second);
53 
54  // This is a monotonically increasing timestamp with no worries about leap
55  // seconds.
56  const uint64_t triggertime = (*rawtrigger)[0].fTriggerTimingMarker_TimeStart;
57 
58  const uint64_t spilltime = triggertime + trigger2spills_tdc;
59 
60  printf("Spilltime: %lu\n", spilltime);
61 }
62 
double trigger2spill
DEFINE_ART_MODULE(TestTMapFile)
virtual ~spilltime()
int evt
printf("%d Experimental points found\n", nlines)
Print the time of each NuMI spill, or another specified trigger type. This is intended for use by Eli...
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
void analyze(const art::Event &evt)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
spilltime(fhicl::ParameterSet const &pset)
bool failedToGet() const
Definition: Handle.h:196