CMS 3D CMS Logo

BunchSpacingProducer.cc
Go to the documentation of this file.
9 #include <iostream>
10 
11 namespace edm {
12  class EventSetup;
13 }
14 
15 //
16 // class declaration
17 //
19 public:
20  explicit BunchSpacingProducer(const edm::ParameterSet&);
21 
22  ~BunchSpacingProducer() override;
23 
24  void produce(edm::Event&, const edm::EventSetup&) final;
25 
27 
28 private:
30  unsigned int bunchSpacingOverride_;
31  bool overRide_;
32 };
33 
34 //
35 // constructors and destructor
36 //
37 
38 BunchSpacingProducer::BunchSpacingProducer::BunchSpacingProducer(const edm::ParameterSet& iConfig) {
39  // register your products
40  produces<unsigned int>();
41  bunchSpacing_ = consumes<int>(edm::InputTag("addPileupInfo", "bunchSpacing"));
42  overRide_ = false;
43  if (iConfig.exists("overrideBunchSpacing")) {
44  overRide_ = iConfig.getParameter<bool>("overrideBunchSpacing");
45  if (overRide_) {
46  bunchSpacingOverride_ = iConfig.getParameter<unsigned int>("bunchSpacingOverride");
47  }
48  }
49 }
50 
52 
53 //
54 // member functions
55 //
57  if (overRide_) {
58  e.put(std::make_unique<unsigned int>(bunchSpacingOverride_));
59  return;
60  }
61 
62  unsigned int bunchSpacing = 50;
63  unsigned int run = e.run();
64 
65  if (e.isRealData()) {
66  if ((run > 252126 && run != 254833) || run == 178003 || run == 178004 || run == 209089 || run == 209106 ||
67  run == 209109 || run == 209146 || run == 209148 || run == 209151) {
68  bunchSpacing = 25;
69  }
70  } else {
71  edm::Handle<int> bunchSpacingH;
72  e.getByToken(bunchSpacing_, bunchSpacingH);
73  bunchSpacing = *bunchSpacingH;
74  }
75 
76  e.put(std::make_unique<unsigned int>(bunchSpacing));
77  return;
78 }
79 
82  desc.add<bool>("overrideBunchSpacing", false); // true for prompt reco
83  desc.add<unsigned int>("bunchSpacingOverride", 25); // override value
84 
85  descriptions.add("bunchSpacingProducer", desc);
86 }
87 
static void fillDescriptions(edm::ConfigurationDescriptions &)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
unsigned int bunchSpacingOverride_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< int > bunchSpacing_
BunchSpacingProducer(const edm::ParameterSet &)
void produce(edm::Event &, const edm::EventSetup &) final
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.