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 
ConfigurationDescriptions.h
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
edm::EDGetTokenT< int >
LuminosityBlock.h
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDProducer.h
BunchSpacingProducer::~BunchSpacingProducer
~BunchSpacingProducer() override
Definition: BunchSpacingProducer.cc:51
edm::Handle< int >
BunchSpacingProducer::bunchSpacing_
edm::EDGetTokenT< int > bunchSpacing_
Definition: BunchSpacingProducer.cc:29
BunchSpacingProducer::overRide_
bool overRide_
Definition: BunchSpacingProducer.cc:31
BunchSpacingProducer
Definition: BunchSpacingProducer.cc:18
BunchSpacingProducer::BunchSpacingProducer
BunchSpacingProducer(const edm::ParameterSet &)
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
Run.h
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:674
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
BunchSpacingProducer::produce
void produce(edm::Event &, const edm::EventSetup &) final
Definition: BunchSpacingProducer.cc:56
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
writedatasetfile.run
run
Definition: writedatasetfile.py:27
EventSetup.h
BunchSpacingProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Definition: BunchSpacingProducer.cc:80
EventSetup
ParameterSet.h
edm::Event
Definition: Event.h:73
BunchSpacingProducer::bunchSpacingOverride_
unsigned int bunchSpacingOverride_
Definition: BunchSpacingProducer.cc:30
edm::InputTag
Definition: InputTag.h:15
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37