FEBShutoff_module.cc
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////
2 // \file FEBShutoff_module.cc
3 // \brief Analyzer module that pulls out FEB Statuses to track shutoffs.
4 // \author lackey32@fnal.gov
5 ////////////////////////////////////////////////////////////////////////
6 
7 // C/C++ includes
8 #include <string>
9 
10 // ROOT includes
11 #include "TTree.h"
12 
13 // Framework includes
24 #include "fhiclcpp/ParameterSet.h"
26 
27 // Novasoft includes
29 #include "Geometry/LiveGeometry.h"
30 #include "NovaTimingUtilities/TimingUtilities.h"
31 #include "RawData/RawDigit.h"
32 #include "RawData/RawTrigger.h"
33 
34 namespace febstat {
35 
36  class FEBShutoff : public art::EDAnalyzer {
37  public:
38  explicit FEBShutoff(fhicl::ParameterSet const& pset);
39  ~FEBShutoff();
40  void analyze(const art::Event& evt);
41  void reconfigure(const fhicl::ParameterSet& pset);
42  void beginJob();
43 
44  private:
45 
47 
48  std::vector<uint32_t> dcm, feb, pixel;
49  std::vector<uint8_t> febStatus;
50  std::vector<Double_t> hitTime;
51  Double_t evtTime;
52 
53  TTree *febshutoff;
54 
55  };
56 
57  //......................................................................
58 
60  : EDAnalyzer(pset)
61  {
62  reconfigure(pset);
63  }
64 
65  //......................................................................
66 
68  {
69  }
70 
71  //......................................................................
72 
74  {
75  fRawDataLabel = pset.get<std::string>("RawDataLabel");
76  }
77 
78  //......................................................................
79 
81  {
83  febshutoff = tfs->make<TTree>("evts","");
84  febshutoff->Branch("dcm",&dcm);
85  febshutoff->Branch("feb",&feb);
86  febshutoff->Branch("pixel",&pixel);
87  febshutoff->Branch("febStatus",&febStatus);
88  febshutoff->Branch("evtTime",&evtTime,"evtTime/D");
89  febshutoff->Branch("hitTime",&hitTime);
90  }
91 
92  //......................................................................
93 
95  {
96  // Load services
98 
99  // Get trigger time
101  evt.getByLabel(fRawDataLabel, trigs);
102  const rawdata::RawTrigger trig = trigs->at(0);
103 
104  struct timespec unixTime;
106 
107  unsigned long int unixTimeSec = unixTime.tv_sec;
108  unsigned long int unixTimeNanoSec = unixTime.tv_nsec;
109  evtTime = unixTimeSec + (1e-9)*unixTimeNanoSec;
110 
111  // Get Raw Digits (for feb # and status)
113  evt.getByLabel(fRawDataLabel, digitcol);
114  //art::Ptr<rawdata::RawDigit> digitlist;
115  for (unsigned int dig=0; dig<digitcol->size(); ++dig) {
116  // get dchan to get dcm and feb
117  uint32_t dchan = digitcol->at(dig).DaqChannel();
118  dcm.push_back(cmap->Map()->getDCM(dchan));
119  feb.push_back(cmap->Map()->getFEB(dchan));
120  pixel.push_back(cmap->Map()->getPixel(dchan));
121  febStatus.push_back(digitcol->at(dig).fFEBStatus);
122  int32_t tdc = digitcol->at(dig).TDC();
123  hitTime.push_back(evtTime + tdc*15.625e-9);
124  //std::cout<<"dcm-5-01-0"<<dcm<<":"<<feb<<" status: "<<+febStatus<<" time: "<<hitTime<<std::endl;
125  }
126 
127  febshutoff->Fill();
128 
129  // Cleanup vectors
130  dcm.clear();
131  feb.clear();
132  pixel.clear();
133  febStatus.clear();
134  hitTime.clear();
135 
136  } // end analyze
137 
138  //......................................................................
140 } // end namespace febstat
void reconfigure(const fhicl::ParameterSet &pset)
std::vector< uint32_t > pixel
void analyze(const art::Event &evt)
std::vector< uint32_t > dcm
const daqchannelmap::DAQChannelMap * Map() const
Definition: CMap.h:57
DEFINE_ART_MODULE(TestTMapFile)
bool convertNovaTimeToUnixTime(uint64_t const &inputNovaTime, struct timespec &outputUnixTime)
std::vector< uint32_t > feb
std::vector< Double_t > hitTime
T get(std::string const &key) const
Definition: ParameterSet.h:231
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
pixel_t getPixel(dchan daqchan) const
Decode the pixel id from a dchan.
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
T * make(ARGS...args) const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
unsigned long long fTriggerTimingMarker_TimeStart
Definition: RawTrigger.h:38
std::vector< uint8_t > febStatus
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
Float_t e
Definition: plot.C:35
uint32_t dchan
< DAQ Channel Map Package
FEBShutoff(fhicl::ParameterSet const &pset)
feb_t getFEB(dchan daqchan) const
Decode the feb id from a dchan.