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_ = iConfig.getParameter<bool>("overrideBunchSpacing");
43  bunchSpacingOverride_ = iConfig.getParameter<unsigned int>("bunchSpacingOverride");
44 }
45 
47 
48 //
49 // member functions
50 //
52  if (overRide_) {
53  e.put(std::make_unique<unsigned int>(bunchSpacingOverride_));
54  return;
55  }
56 
57  unsigned int bunchSpacing = 50;
58  unsigned int run = e.run();
59 
60  if (e.isRealData()) {
61  if ((run > 252126 && run != 254833) || run == 178003 || run == 178004 || run == 209089 || run == 209106 ||
62  run == 209109 || run == 209146 || run == 209148 || run == 209151) {
63  bunchSpacing = 25;
64  }
65  } else {
66  edm::Handle<int> bunchSpacingH;
67  e.getByToken(bunchSpacing_, bunchSpacingH);
68  bunchSpacing = *bunchSpacingH;
69  }
70 
71  e.put(std::make_unique<unsigned int>(bunchSpacing));
72  return;
73 }
74 
77  desc.add<bool>("overrideBunchSpacing", false); // true for prompt reco
78  desc.add<unsigned int>("bunchSpacingOverride", 25); // override value
79 
80  descriptions.add("BunchSpacingProducer", desc);
81 }
82 
static void fillDescriptions(edm::ConfigurationDescriptions &)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
unsigned int bunchSpacingOverride_
edm::EDGetTokenT< int > bunchSpacing_
BunchSpacingProducer(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void produce(edm::Event &, const edm::EventSetup &) final
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.