-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Central bunch spacing producer #11544
Changes from all commits
88bae49
37ec63c
922eefb
8914b53
f3e377a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#include "FWCore/Framework/interface/stream/EDProducer.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/LuminosityBlock.h" | ||
#include "FWCore/Framework/interface/Run.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
#include <iostream> | ||
|
||
namespace edm { | ||
class EventSetup; | ||
} | ||
|
||
// | ||
// class declaration | ||
// | ||
class BunchSpacingProducer : public edm::stream::EDProducer<> { | ||
|
||
public: | ||
|
||
explicit BunchSpacingProducer(const edm::ParameterSet&); | ||
|
||
~BunchSpacingProducer(); | ||
|
||
virtual void produce(edm::Event&, const edm::EventSetup&) override final; | ||
|
||
static void fillDescriptions( edm::ConfigurationDescriptions & ) ; | ||
|
||
private: | ||
|
||
edm::EDGetTokenT<int> bunchSpacing_; | ||
unsigned int bunchSpacingOverride_; | ||
bool overRide_; | ||
}; | ||
|
||
// | ||
// constructors and destructor | ||
// | ||
|
||
|
||
BunchSpacingProducer:: | ||
BunchSpacingProducer::BunchSpacingProducer(const edm::ParameterSet& iConfig) | ||
{ | ||
// register your products | ||
produces<unsigned int>(); | ||
bunchSpacing_ = consumes<int>(edm::InputTag("addPileupInfo","bunchSpacing")); | ||
overRide_=false; | ||
if ( iConfig.exists("overrideBunchSpacing") ) { | ||
std::cout << "ok parameter eixsts\n"; | ||
overRide_= iConfig.getParameter<bool>("overrideBunchSpacing"); | ||
if ( overRide_) { | ||
std::cout << "and its true\n"; | ||
bunchSpacingOverride_=iConfig.getParameter<unsigned int>("bunchSpacingOverride"); | ||
} | ||
} | ||
} | ||
|
||
BunchSpacingProducer::~BunchSpacingProducer(){ | ||
} | ||
|
||
// | ||
// member functions | ||
// | ||
void BunchSpacingProducer::produce(edm::Event& e, const edm::EventSetup& iSetup) | ||
{ | ||
if ( overRide_ ) { | ||
std::auto_ptr<unsigned int> pOut1(new unsigned int); | ||
*pOut1=bunchSpacingOverride_; | ||
e.put(pOut1); | ||
std::cout << "Derived from override " << bunchSpacingOverride_ << std::endl; | ||
return; | ||
} | ||
|
||
unsigned int bunchSpacing=50; | ||
unsigned int run=e.run(); | ||
|
||
if ( e.isRealData()) { | ||
if ( ( run > 252126 && run != 254833 )|| | ||
run == 178003 || | ||
run == 178004 || | ||
run == 209089 || | ||
run == 209106 || | ||
run == 209109 || | ||
run == 209146 || | ||
run == 209148 || | ||
run == 209151) { | ||
bunchSpacing = 25; | ||
} | ||
} | ||
else{ | ||
edm::Handle<int> bunchSpacingH; | ||
e.getByToken(bunchSpacing_,bunchSpacingH); | ||
bunchSpacing = *bunchSpacingH; | ||
} | ||
|
||
std::cout << "Derived from run number " << bunchSpacing << std::endl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cout, really? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. debug printout… whoops
|
||
std::auto_ptr<unsigned int> pOut1(new unsigned int); | ||
*pOut1=bunchSpacing; | ||
e.put(pOut1); | ||
return; | ||
} | ||
|
||
void BunchSpacingProducer::fillDescriptions( edm::ConfigurationDescriptions & descriptions ) | ||
{ | ||
edm::ParameterSetDescription desc ; | ||
desc.add<bool>("overrideBunchSpacing",false); // true for prompt reco | ||
desc.add<unsigned int>("bunchSpacingOverride",25); // override value | ||
|
||
descriptions.add("bunchSpacingProducer",desc) ; | ||
} | ||
|
||
|
||
|
||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
DEFINE_FWK_MODULE(BunchSpacingProducer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that'll do just fine too. Thanks.