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  : fTriggerToken(consumes<std::vector<rawdata::RawTrigger>>("daq")),
42  fExposure(0)
43  {
44  produces<sumdata::CosmicExposure, art::InSubRun>();
45  }
46 
47  //......................................................................
49  {
50  }
51 
52  //......................................................................
54  {
55  fExposure = 0;
56  }
57 
58  //......................................................................
60  {
61  if(fExposure >= 0){
62  std::unique_ptr<sumdata::CosmicExposure> ce(new sumdata::CosmicExposure);
63  ce->totlivetime = fExposure;
64  sr.put(std::move(ce));
65  }
66  }
67 
68  //......................................................................
70  {
72  evt.getByToken(fTriggerToken, trigs);
73 
74  for(unsigned int n = 0; n < trigs->size(); ++n){
75  const rawdata::RawTrigger& trig = (*trigs)[n];
76 
77  // No: beam spills are just as valid cosmic live time
78 // // Should be a cosmic trigger
79 // const uint8_t trigtype = trig.fTriggerMask_TriggerType;
80 // assert(trigtype & daqdataformats::TRIGBIT_ID_CAL_PER ||
81 // trigtype & daqdataformats::TRIGBIT_ID_CAL_RND);
82 
83  // Units of trigger field are 500ns
85  }
86  }
87 
89 
90 } // end namespace
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.
ProductID put(std::unique_ptr< PROD > &&)
uint32_t fTriggerRange_TriggerLength
Definition: RawTrigger.h:40
Sum up livetimes from individual cosmic triggers.
bool getByToken(ProductToken< PROD > const &token, Handle< PROD > &result) const
Definition: DataViewImpl.h:387
Float_t e
Definition: plot.C:35
ProductToken< T > consumes(InputTag const &)
static constexpr Double_t sr
Definition: Munits.h:164