CMS 3D CMS Logo

RunInfoTestESProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CondTools/RunInfo
4 // Class: RunInfoTestESProducer
5 //
13 //
14 // Original Author: Christopher Jones
15 // Created: Wed, 02 Oct 2019 17:34:35 GMT
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
27 
30 
31 //
32 // class declaration
33 //
34 
36 public:
38 
39  using ReturnType = std::unique_ptr<RunInfo>;
40 
42 
43  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
44 
45 private:
47  // ----------member data ---------------------------
48  std::vector<RunInfo> runInfos_;
49 };
50 
51 //
52 // constants, enums and typedefs
53 //
54 namespace {
55  bool ri_less(RunInfo const& iLHS, RunInfo const& iRHS) { return iLHS.m_run < iRHS.m_run; }
56 } // namespace
57 
58 //
59 // static data member definitions
60 //
61 
62 //
63 // constructors and destructor
64 //
66  std::vector<edm::ParameterSet> const& runInfos = iConfig.getParameter<std::vector<edm::ParameterSet>>("runInfos");
67  runInfos_.reserve(runInfos.size());
68  for (auto const& pset : runInfos) {
69  runInfos_.emplace_back(makeRunInfo(pset));
70  }
71  std::sort(runInfos_.begin(), runInfos_.end(), ri_less);
72 
73  setWhatProduced(this);
74 }
75 
76 //
77 // member functions
78 //
79 
80 // ------------ method called to produce the data ------------
82  const int run = iRecord.validityInterval().first().eventID().run();
83  RunInfo toFind;
84  toFind.m_run = run;
85  auto itFound = std::lower_bound(runInfos_.begin(), runInfos_.end(), toFind, ri_less);
86  if (itFound == runInfos_.end() or itFound->m_run != run) {
87  return nullptr;
88  }
89  return std::make_unique<RunInfo>(*itFound);
90 }
91 
93  RunInfo retValue;
94  retValue.m_run = pset.getParameter<int>("run");
95  retValue.m_start_time_ll = pset.getParameter<long long>("start_time");
96  retValue.m_start_time_str = pset.getParameter<std::string>("start_time_str");
97  retValue.m_stop_time_ll = pset.getParameter<long long>("stop_time");
98  retValue.m_stop_time_str = pset.getParameter<std::string>("stop_time_str");
99  retValue.m_fed_in = pset.getParameter<std::vector<int>>("fed_in");
100  retValue.m_start_current = pset.getParameter<double>("start_current");
101  retValue.m_stop_current = pset.getParameter<double>("stop_current");
102  retValue.m_avg_current = pset.getParameter<double>("avg_current");
103  retValue.m_min_current = pset.getParameter<double>("min_current");
104  retValue.m_max_current = pset.getParameter<double>("max_current");
105  retValue.m_run_intervall_micros = pset.getParameter<double>("run_intervall_micros");
106 
107  auto convert = [](std::vector<double> const& iIn) {
108  std::vector<float> f;
109  f.reserve(iIn.size());
110  std::copy(iIn.begin(), iIn.end(), std::back_inserter(f));
111  return f;
112  };
113 
114  retValue.m_current = convert(pset.getParameter<std::vector<double>>("current"));
115  retValue.m_times_of_currents = convert(pset.getParameter<std::vector<double>>("times_of_currents"));
116 
117  return retValue;
118 }
119 
121  edm::ParameterSetDescription runInfoDesc;
122  runInfoDesc.add<int>("run");
123  runInfoDesc.add<long long>("start_time", 0);
124  runInfoDesc.add<std::string>("start_time_str", "");
125  runInfoDesc.add<long long>("stop_time", 0);
126  runInfoDesc.add<std::string>("stop_time_str", "");
127  runInfoDesc.add<std::vector<int>>("fed_in", {});
128  runInfoDesc.add<double>("start_current", 0);
129  runInfoDesc.add<double>("stop_current", 0);
130  runInfoDesc.add<double>("avg_current", 0);
131  runInfoDesc.add<double>("min_current", 0);
132  runInfoDesc.add<double>("max_current", 0);
133  runInfoDesc.add<double>("run_intervall_micros", 0);
134  runInfoDesc.add<std::vector<double>>("current", {});
135  runInfoDesc.add<std::vector<double>>("times_of_currents", {});
136 
138  desc.addVPSet("runInfos", runInfoDesc, {});
139 
140  descriptions.addDefault(desc);
141 }
142 
143 //define this as a plug-in
ConfigurationDescriptions.h
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
RunInfoTestESProducer::produce
ReturnType produce(const RunInfoRcd &)
Definition: RunInfoTestESProducer.cc:81
RunSummaryRcd.h
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
RunInfo::m_max_current
float m_max_current
Definition: RunInfo.h:29
RunInfoTestESProducer
Definition: RunInfoTestESProducer.cc:35
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ESProducer.h
edm::ValidityInterval::first
const IOVSyncValue & first() const
Definition: ValidityInterval.h:37
RunInfo::m_fed_in
std::vector< int > m_fed_in
Definition: RunInfo.h:25
RunInfo::m_times_of_currents
std::vector< float > m_times_of_currents
Definition: RunInfo.h:33
RunInfoTestESProducer::makeRunInfo
RunInfo makeRunInfo(edm::ParameterSet const &pset) const
Definition: RunInfoTestESProducer.cc:92
RunInfo::m_stop_current
float m_stop_current
Definition: RunInfo.h:27
RunInfo
Definition: RunInfo.h:18
RunInfoTestESProducer::runInfos_
std::vector< RunInfo > runInfos_
Definition: RunInfoTestESProducer.cc:48
RunInfoTestESProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: RunInfoTestESProducer.cc:120
ParameterSetDescription.h
RunInfo::m_run_intervall_micros
float m_run_intervall_micros
Definition: RunInfo.h:31
cuda_std::lower_bound
__host__ constexpr __device__ RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:27
edm::EventID::run
RunNumber_t run() const
Definition: EventID.h:38
RunInfoRcd
Definition: RunSummaryRcd.h:26
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
RunInfo::m_stop_time_ll
long long m_stop_time_ll
Definition: RunInfo.h:23
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
fileCollector.convert
def convert(infile, ofile)
Definition: fileCollector.py:47
edm::IOVSyncValue::eventID
const EventID & eventID() const
Definition: IOVSyncValue.h:40
edm::ParameterSet
Definition: ParameterSet.h:36
RunInfoTestESProducer::ReturnType
std::unique_ptr< RunInfo > ReturnType
Definition: RunInfoTestESProducer.cc:39
edm::ParameterSetDescription::addVPSet
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
Definition: ParameterSetDescription.h:149
RunInfo::m_start_current
float m_start_current
Definition: RunInfo.h:26
RunInfo::m_current
std::vector< float > m_current
Definition: RunInfo.h:32
RunInfoTestESProducer::RunInfoTestESProducer
RunInfoTestESProducer(const edm::ParameterSet &)
Definition: RunInfoTestESProducer.cc:65
RunInfo::m_start_time_str
std::string m_start_time_str
Definition: RunInfo.h:22
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
RunInfo.h
ModuleFactory.h
writedatasetfile.run
run
Definition: writedatasetfile.py:27
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
RunInfo::m_min_current
float m_min_current
Definition: RunInfo.h:30
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
edm::ESProducer
Definition: ESProducer.h:101
RunInfo::m_avg_current
float m_avg_current
Definition: RunInfo.h:28
edm::eventsetup::EventSetupRecord::validityInterval
ValidityInterval validityInterval() const
Definition: EventSetupRecord.h:93
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
RunInfo::m_run
int m_run
Definition: RunInfo.h:20
RunInfo::m_stop_time_str
std::string m_stop_time_str
Definition: RunInfo.h:24
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
RunInfo::m_start_time_ll
long long m_start_time_ll
Definition: RunInfo.h:21