DAQHeaderAna_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: DAQHeaderAna
3 // Module Type: analyzer
4 // File: DAQHeaderAna_module.cc
5 //
6 // Generated at Mon Feb 23 09:39:46 2015 by Jan Zirnstein using artmod
7 // from cetpkgsupport v1_07_01.
8 ////////////////////////////////////////////////////////////////////////
9 
17 #include "fhiclcpp/ParameterSet.h"
19 #include "art_root_io/TFileService.h"
20 
21 #include "TH1.h"
22 #include "TTimeStamp.h"
23 
24 #include <iostream>
25 #include "RawData/DAQHeader.h"
26 
27 namespace novaddt {
28  class DAQHeaderAna;
29 }
30 
32 public:
33  explicit DAQHeaderAna(fhicl::ParameterSet const & p);
34  // The destructor generated by the compiler is fine for classes
35  // without bare pointers or other resource use.
36 
37  // Plugins should not be copied or assigned.
38  DAQHeaderAna(DAQHeaderAna const &) = delete;
39  DAQHeaderAna(DAQHeaderAna &&) = delete;
40  DAQHeaderAna & operator = (DAQHeaderAna const &) = delete;
41  DAQHeaderAna & operator = (DAQHeaderAna &&) = delete;
42 
43  // Required functions.
44  void analyze(art::Event const & e) override;
45 
46  // Optional functions
47  void beginJob() override;
48 
49 private:
50 
51  // Declare member data here.
54  unsigned int _nDCMs;
55  unsigned int _nTargetSlices;
56 
57 };
58 
59 
61  :
62  EDAnalyzer(p)
63  ,_daqHeaderLabel(p.get< std::string >("InputLabel"))
64  ,_nDCMs(p.get< unsigned int >("NDCMs"))
65  ,_nTargetSlices(p.get< unsigned int >("ExpectedSlices"))
66  // More initializers here.
67 {}
68 
70 {
71  // Figure out max of hist axis
72  unsigned int xmax = _nDCMs*(_nTargetSlices+1) + 10;
74  _nMicroSlices= tfs->make<TH1I>("nMicroSlices","Number of Microslices;Microslices;Events",xmax,0,xmax);
75 }
77 {
78  // Implementation of required member function here.
79  // Get the DAQHeader
81  e.getByLabel(_daqHeaderLabel, DAQHeader);
82 
83  // Fill the histogram
84  const int NumMicroSlices = DAQHeader->TotalMicroSlices();
85  _nMicroSlices->Fill(NumMicroSlices);
86 
87  // TimeStamp gymnastics stolen from HeaderDrawer.cxx from the EventDisplay package
88  // Unpack time and date information
89  unsigned int year, month, day;
90  unsigned int hour, minute, second;
91  int nano;
92 
93  unsigned long long int tsval = e.time().value();
94  const unsigned long int mask32 = 0xFFFFFFFFUL;
95  unsigned long int lup = ( tsval >> 32 ) & mask32;
96  unsigned long int llo = tsval & mask32;
97  TTimeStamp ts(lup, (int)llo);
98 
99  ts.GetDate(kTRUE,0,&year,&month,&day);
100  ts.GetTime(kTRUE,0,&hour,&minute,&second);
101  nano = ts.GetNanoSec();
102  char timebuff[256];
103  sprintf(timebuff, "%.2d:%.2d:%2.9f", hour, minute, (float)second+(float)nano/1.0E9);
104  std::string time = timebuff;
105 
106  // Pring information for missing microslices when 2 were expected per DCM
107  int minslices = _nDCMs*_nTargetSlices;
108  int maxslices = _nDCMs*(_nTargetSlices+1);
109  bool missingMicro = (NumMicroSlices < minslices ) ||
110  (NumMicroSlices > minslices && NumMicroSlices < maxslices);
111  if(missingMicro){
112  std::cout<<"There are missing microslices in this event:\n";
113  std::cout<<"Run: " << e.run() << std::endl;
114  std::cout<<"SubRun: " << e.subRun() << std::endl;
115  std::cout<<"Event: " << e.event() << std::endl;
116  std::cout<<"Microslices: " << NumMicroSlices << std::endl;
117  std::cout<<"Status: " << DAQHeader->Status() << std::endl;
118  std::cout<<"Time: " << time << std::endl;
119  }
120 
121 }
122 
DAQHeaderAna & operator=(DAQHeaderAna const &)=delete
EventNumber_t event() const
std::map< std::string, double > xmax
const char * p
Definition: xmltok.h:285
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
DEFINE_ART_MODULE(TestTMapFile)
int TotalMicroSlices() const
Definition: DAQHeader.h:27
constexpr TimeValue_t value() const
Definition: Timestamp.h:23
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:446
Timestamp time() const
SubRunNumber_t subRun() const
unsigned int Status() const
Definition: DAQHeader.h:25
RunNumber_t run() const
OStream cout
Definition: OStream.cxx:6
Float_t e
Definition: plot.C:35
DAQHeaderAna(fhicl::ParameterSet const &p)
void analyze(art::Event const &e) override
static constexpr Double_t year
Definition: Munits.h:185
enum BeamMode string