CosmicExposureInfo_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \brief Sum up livetimes from individual cosmic triggers
3 /// \author Christopher Backhouse - bckhouse@caltech.edu
4 ////////////////////////////////////////////////////////////////////////
5 
6 // NOvASoft includes
7 #include "DAQDataFormats/TriggerDefines.h"
8 #include "RawData/RawTrigger.h"
10 
11 // Framework includes
17 #include "fhiclcpp/ParameterSet.h"
18 
19 namespace cosmic
20 {
21  /// \brief Sum up livetimes from individual cosmic triggers
23  {
24  public:
25  explicit CosmicExposureInfo(const fhicl::ParameterSet& pset);
26  virtual ~CosmicExposureInfo();
27 
28  void produce(art::Event& evt);
29 
30  void beginSubRun(art::SubRun& sr);
31  void endSubRun(art::SubRun& sr);
32 
33  protected:
35 
36  double fExposure; //< Livetime so far this subrun in seconds
37  };
38 
39  //......................................................................
41  : EDProducer(pset)
42  , fTriggerToken(consumes<std::vector<rawdata::RawTrigger>>("daq")),
43  fExposure(0)
44  {
45  produces<sumdata::CosmicExposure, art::InSubRun>();
46  }
47 
48  //......................................................................
50  {
51  }
52 
53  //......................................................................
55  {
56  fExposure = 0;
57  }
58 
59  //......................................................................
61  {
62  if(fExposure >= 0){
63  std::unique_ptr<sumdata::CosmicExposure> ce(new sumdata::CosmicExposure);
64  ce->totlivetime = fExposure;
65  sr.put(std::move(ce));
66  }
67  }
68 
69  //......................................................................
71  {
73  evt.getByToken(fTriggerToken, trigs);
74 
75  for(unsigned int n = 0; n < trigs->size(); ++n){
76  const rawdata::RawTrigger& trig = (*trigs)[n];
77 
78  // No: beam spills are just as valid cosmic live time
79 // // Should be a cosmic trigger
80 // const uint8_t trigtype = trig.fTriggerMask_TriggerType;
81 // assert(trigtype & daqdataformats::TRIGBIT_ID_CAL_PER ||
82 // trigtype & daqdataformats::TRIGBIT_ID_CAL_RND);
83 
84  // Units of trigger field are 500ns
86  }
87  }
88 
90 
91 } // end namespace
bool getByToken(ProductToken< PROD > const &, Handle< PROD > &result) const
Definition: DataViewImpl.h:462
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
CosmicExposureInfo(const fhicl::ParameterSet &pset)
Definition of connection map class.
Definition: CMap.h:19
DEFINE_ART_MODULE(TestTMapFile)
const art::ProductToken< std::vector< rawdata::RawTrigger > > fTriggerToken
Sum up livetimes from individual cosmic triggers.
std::void_t< T > n
int evt
caf::StandardRecord * sr
ProductToken< T > consumes(InputTag const &)
Definition: ModuleBase.h:55
uint32_t fTriggerRange_TriggerLength
Definition: RawTrigger.h:40
Sum up livetimes from individual cosmic triggers.
Float_t e
Definition: plot.C:35
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:730