CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
20 public:
21 
22  explicit BunchSpacingProducer(const edm::ParameterSet&);
23 
25 
26  virtual void produce(edm::Event&, const edm::EventSetup&) override final;
27 
29 
30 private:
31 
33  unsigned int bunchSpacingOverride_;
34  bool overRide_;
35 };
36 
37 //
38 // constructors and destructor
39 //
40 
41 
42 BunchSpacingProducer::
43 BunchSpacingProducer::BunchSpacingProducer(const edm::ParameterSet& iConfig)
44 {
45  // register your products
46  produces<unsigned int>();
47  bunchSpacing_ = consumes<int>(edm::InputTag("addPileupInfo","bunchSpacing"));
48  overRide_=false;
49  if ( iConfig.exists("overrideBunchSpacing") ) {
50  overRide_= iConfig.getParameter<bool>("overrideBunchSpacing");
51  if ( overRide_) {
52  bunchSpacingOverride_=iConfig.getParameter<unsigned int>("bunchSpacingOverride");
53  }
54  }
55 }
56 
58 }
59 
60 //
61 // member functions
62 //
64 {
65  if ( overRide_ ) {
66  std::auto_ptr<unsigned int> pOut1(new unsigned int);
67  *pOut1=bunchSpacingOverride_;
68  e.put(pOut1);
69  return;
70  }
71 
72  unsigned int bunchSpacing=50;
73  unsigned int run=e.run();
74 
75  if ( e.isRealData()) {
76  if ( ( run > 252126 && run != 254833 )||
77  run == 178003 ||
78  run == 178004 ||
79  run == 209089 ||
80  run == 209106 ||
81  run == 209109 ||
82  run == 209146 ||
83  run == 209148 ||
84  run == 209151) {
85  bunchSpacing = 25;
86  }
87  }
88  else{
89  edm::Handle<int> bunchSpacingH;
90  e.getByToken(bunchSpacing_,bunchSpacingH);
91  bunchSpacing = *bunchSpacingH;
92  }
93 
94  std::auto_ptr<unsigned int> pOut1(new unsigned int);
95  *pOut1=bunchSpacing;
96  e.put(pOut1);
97  return;
98 }
99 
101 {
103  desc.add<bool>("overrideBunchSpacing",false); // true for prompt reco
104  desc.add<unsigned int>("bunchSpacingOverride",25); // override value
105 
106  descriptions.add("bunchSpacingProducer",desc) ;
107 }
108 
109 
110 
static void fillDescriptions(edm::ConfigurationDescriptions &)
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &) overridefinal
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
unsigned int bunchSpacingOverride_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool exists(std::string const &parameterName) const
checks if a parameter exists
bool isRealData() const
Definition: EventBase.h:64
edm::EDGetTokenT< int > bunchSpacing_
BunchSpacingProducer(const edm::ParameterSet &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
RunNumber_t run() const
Definition: Event.h:92
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)