POTSummary_plugin.cc
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////
2 /// \brief Module to create a summary of total POT seen in a job
3 /// \author brebel@fnal.gov
4 ///////////////////////////////////////////////////////////////////////
5 #include <cmath>
6 #include <string>
7 #include <vector>
8 
9 // Framework includes
16 #include "fhiclcpp/ParameterSet.h"
18 
19 // NOvA includes
22 #include "SummaryData/SpillData.h"
23 #include "SummaryData/POTSum.h"
24 
25 
26 namespace skim {
28  public:
29  explicit POTSummary(fhicl::ParameterSet const& pset);
30  virtual ~POTSummary();
31 
32  void event (art::Event const& e);
33  void readResults (art::Results const& r);
34  void writeResults(art::Results & r);
35  void reconfigure (fhicl::ParameterSet const & p);
36  void clear();
37 
38  private:
39 
40  std::string fSpillDataLabel; ///< label of module storing spill info
41  skim::SpillEvaluator fSpillEval; ///< tool to check the quality of a spill
42  std::map<std::string, sumdata::POTSum> fEpochToPOTSum; ///< POT summary for each epoch
44 
45  };
46 
47  //......................................................................
49  : fSpillEval(pset.get<fhicl::ParameterSet>("SpillEvaluation"))
50  {
51  this->reconfigure(pset);
52  produces< std::map<std::string, sumdata::POTSum> >();
53 
54  return;
55  }
56 
57  //......................................................................
59  {
60  }
61 
62  //......................................................................
64  {
65  fSpillDataLabel = pset.get<std::string>("SpillDataLabel");
66 
67  return;
68  }
69 
70  //......................................................................
72  {
74 
75 
76  if( !spillData.failedToGet() ){
77 
78  fEpochToPOTSum[fRH->GetDataEpoch().name].totpot += spillData->spillpot;
79  fEpochToPOTSum[fRH->GetDataEpoch().name].totspills += 1;
80 
81  if( fSpillEval.EvaluateSpill(*spillData) ){
82  fEpochToPOTSum[fRH->GetDataEpoch().name].totgoodpot += spillData->spillpot;
83  fEpochToPOTSum[fRH->GetDataEpoch().name].goodspills += 1;
84  }
85 
86  }// end we found a SpillData object
87 
88  return;
89  }
90 
91 
92  //......................................................................
93  // Method to clear out the collections of data products after the
94  // writeResults method is called.
96  {
97  fEpochToPOTSum.clear();
98  return;
99  }
100 
101  //......................................................................
103  {
104 
105  return;
106  }
107 
108  //......................................................................
110  {
111  std::unique_ptr< std::map<std::string, sumdata::POTSum> > pot(&fEpochToPOTSum);
112 
113  for(auto itr : fEpochToPOTSum)
114  LOG_VERBATIM("POTSummary")
115  << "Epoch "
116  << itr.first
117  << " contains "
118  << itr.second.totgoodpot
119  << " POT";
120 
121  r.put(std::move(pot));
122  } // end writeResults
123 
124 } // end fnex namespace
125 
126 namespace skim{
127 
129 
130 }
131 
void writeResults(art::Results &r)
std::map< std::string, sumdata::POTSum > fEpochToPOTSum
POT summary for each epoch.
std::string fSpillDataLabel
label of module storing spill info
const char * p
Definition: xmltok.h:285
art::ProductID put(std::unique_ptr< PROD > &&product)
Definition: Results.h:78
art::ServiceHandle< nova::dbi::RunHistoryService > fRH
RunHistory service.
Module to create a summary of total POT seen in a job.
Definition: Evaluator.h:27
skim::SpillEvaluator fSpillEval
tool to check the quality of a spill
T get(std::string const &key) const
Definition: ParameterSet.h:231
#define pot
std::string name
Definition: RunHistory.h:59
void readResults(art::Results const &r)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
bool EvaluateSpill(sumdata::SpillData const &spillData)
DEFINE_ART_RESULTS_PLUGIN(POTSummary)
TRandom3 r(0)
POTSummary(fhicl::ParameterSet const &pset)
#define LOG_VERBATIM(category)
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
DataEpoch GetDataEpoch()
Definition: RunHistory.h:484
Float_t e
Definition: plot.C:35
void event(art::Event const &e)
void reconfigure(fhicl::ParameterSet const &p)