CMS 3D CMS Logo

PPSAssociationCutsESSource.cc
Go to the documentation of this file.
1 /****************************************************************************
2  * Authors:
3  * Jan Kašpar
4  * Grzegorz Sroka
5  ****************************************************************************/
6 
10 
18 
21 #include <vector>
22 
23 using namespace std;
24 
26 public:
28 
29  ~PPSAssociationCutsESSource() override = default;
30 
31  std::shared_ptr<PPSAssociationCuts> produce(const PPSAssociationCutsRcd &);
32 
34 
35 protected:
36  void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &,
37  const edm::IOVSyncValue &,
38  edm::ValidityInterval &) override;
39 
40 private:
41  static edm::ParameterSetDescription getIOVDefaultParameters();
44  std::vector<std::shared_ptr<PPSAssociationCuts>> ppsAssociationCuts_;
45  std::vector<edm::EventRange> validityRanges_;
46 };
47 
48 //----------------------------------------------------------------------------------------------------
49 
51  for (const auto &interval : iConfig.getParameter<std::vector<edm::ParameterSet>>("configuration")) {
52  ppsAssociationCuts_.push_back(make_shared<PPSAssociationCuts>(interval));
53  validityRanges_.push_back(interval.getParameter<edm::EventRange>("validityRange"));
54  }
55 
56  setWhatProduced(this);
57  findingRecord<PPSAssociationCutsRcd>();
58 }
59 
60 //----------------------------------------------------------------------------------------------------
61 
63  const edm::IOVSyncValue &iosv,
64  edm::ValidityInterval &oValidity) {
65  for (unsigned int idx = 0; idx < ppsAssociationCuts_.size(); ++idx) {
66  // is within an entry ?
67  if (edm::contains(validityRanges_[idx], iosv.eventID())) {
68  currentAssociationCutValid_ = true;
69  currentAssociationCutIdx_ = idx;
70  oValidity = edm::ValidityInterval(edm::IOVSyncValue(validityRanges_[idx].startEventID()),
71  edm::IOVSyncValue(validityRanges_[idx].endEventID()));
72  return;
73  }
74  }
75 
76  currentAssociationCutValid_ = false;
77  currentAssociationCutIdx_ = 0;
78 
79  edm::LogInfo("PPSAssociationCutsESSource")
80  << ">> PPSAssociationCutsESSource::setIntervalFor(" << key.name() << ")\n"
81  << " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event();
82 
83  const edm::EventID start(iosv.eventID().run(), iosv.eventID().luminosityBlock(), iosv.eventID().event());
84  const edm::EventID end(iosv.eventID().run(), iosv.eventID().luminosityBlock(), iosv.eventID().event());
86 }
87 
88 //----------------------------------------------------------------------------------------------------
89 
90 std::shared_ptr<PPSAssociationCuts> PPSAssociationCutsESSource::produce(const PPSAssociationCutsRcd &) {
91  auto output = std::make_shared<PPSAssociationCuts>();
92 
93  if (currentAssociationCutValid_) {
94  const auto &associationCut = ppsAssociationCuts_[currentAssociationCutIdx_];
95  output = associationCut;
96  }
97 
98  return output;
99 }
100 
101 //----------------------------------------------------------------------------------------------------
102 
105  desc.add<std::string>("ppsAssociationCutsLabel", "");
106 
108 
109  std::vector<edm::ParameterSet> vDefaults;
110  desc.addVPSet("configuration", validator, vDefaults);
111 
112  descriptions.add("ppsAssociationCutsESSource", desc);
113 }
114 
117  desc.add<edm::EventRange>("validityRange", edm::EventRange())->setComment("interval of validity");
118 
119  for (auto &sector : {"45", "56"}) {
120  desc.add<edm::ParameterSetDescription>("association_cuts_" + std::string(sector),
122  ->setComment("track-association cuts for sector " + std::string(sector));
123  }
124 
125  return desc;
126 }
127 
128 //----------------------------------------------------------------------------------------------------
129 
Definition: start.py:1
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
static void fillDescriptions(edm::ConfigurationDescriptions &)
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:37
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
std::shared_ptr< PPSAssociationCuts > produce(const PPSAssociationCutsRcd &)
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
std::vector< std::shared_ptr< PPSAssociationCuts > > ppsAssociationCuts_
Log< level::Info, false > LogInfo
RunNumber_t run() const
Definition: EventID.h:38
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:92
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const EventID & eventID() const
Definition: IOVSyncValue.h:40
static edm::ParameterSetDescription getDefaultParameters()
Definition: output.py:1
static edm::ParameterSetDescription getIOVDefaultParameters()
std::vector< edm::EventRange > validityRanges_
EventNumber_t event() const
Definition: EventID.h:40
PPSAssociationCutsESSource(const edm::ParameterSet &)