Skip to content

Commit

Permalink
8_0_X backport of #15049
Browse files Browse the repository at this point in the history
  • Loading branch information
forthommel committed Nov 14, 2016
1 parent 202e444 commit e6343e1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
9 changes: 6 additions & 3 deletions PhysicsTools/Utilities/interface/LumiReWeighting.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <string>
#include <boost/shared_ptr.hpp>
#include <vector>
#include "FWCore/Utilities/interface/InputTag.h"

namespace reweight{

Expand Down Expand Up @@ -220,10 +221,11 @@ namespace edm {
public:
LumiReWeighting( std::string generatedFile,
std::string dataFile,
std::string GenHistName,
std::string DataHistName);
std::string GenHistName = "pileup",
std::string DataHistName = "pileup",
const edm::InputTag& PileupSumInfoInputTag = edm::InputTag( "addPileupInfo" ) );

LumiReWeighting( const std::vector< float >& MC_distr, const std::vector< float >& Lumi_distr);
LumiReWeighting( const std::vector< float >& MC_distr, const std::vector< float >& Lumi_distr, const edm::InputTag& PileupSumInfoInputTag = edm::InputTag( "addPileupInfo" ) );

LumiReWeighting ( ) { } ;

Expand All @@ -241,6 +243,7 @@ namespace edm {
std::string dataFileName_;
std::string GenHistName_;
std::string DataHistName_;
edm::InputTag pileupSumInfoTag_;
boost::shared_ptr<TFile> generatedFile_;
boost::shared_ptr<TFile> dataFile_;
boost::shared_ptr<TH1> weights_;
Expand Down
18 changes: 11 additions & 7 deletions PhysicsTools/Utilities/src/LumiReWeighting.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ using namespace edm;

LumiReWeighting::LumiReWeighting( std::string generatedFile,
std::string dataFile,
std::string GenHistName = "pileup",
std::string DataHistName = "pileup" ) :
std::string GenHistName,
std::string DataHistName,
const edm::InputTag& PileupSumInfoInputTag ) :
generatedFileName_( generatedFile),
dataFileName_ ( dataFile ),
GenHistName_ ( GenHistName ),
DataHistName_ ( DataHistName )
GenHistName_ ( GenHistName ),
DataHistName_ ( DataHistName ),
pileupSumInfoTag_ ( PileupSumInfoInputTag )
{
generatedFile_ = boost::shared_ptr<TFile>( new TFile(generatedFileName_.c_str()) ); //MC distribution
dataFile_ = boost::shared_ptr<TFile>( new TFile(dataFileName_.c_str()) ); //Data distribution
Expand Down Expand Up @@ -81,7 +83,9 @@ LumiReWeighting::LumiReWeighting( std::string generatedFile,
OldLumiSection_ = -1;
}

LumiReWeighting::LumiReWeighting(const std::vector< float >& MC_distr,const std::vector< float >& Lumi_distr) {
LumiReWeighting::LumiReWeighting(const std::vector< float >& MC_distr,const std::vector< float >& Lumi_distr, const edm::InputTag& PileupSumInfoInputTag ) :
pileupSumInfoTag_ ( PileupSumInfoInputTag )
{
// no histograms for input: use vectors

// now, make histograms out of them:
Expand Down Expand Up @@ -173,7 +177,7 @@ double LumiReWeighting::weight( const edm::EventBase &e ) {
// get pileup summary information

Handle<std::vector< PileupSummaryInfo > > PupInfo;
e.getByLabel(edm::InputTag("addPileupInfo"), PupInfo);
e.getByLabel(pileupSumInfoTag_, PupInfo);

std::vector<PileupSummaryInfo>::const_iterator PVI;

Expand Down Expand Up @@ -224,7 +228,7 @@ double LumiReWeighting::weightOOT( const edm::EventBase &e ) {
// find the pileup summary information

Handle<std::vector< PileupSummaryInfo > > PupInfo;
e.getByLabel(edm::InputTag("addPileupInfo"), PupInfo);
e.getByLabel(pileupSumInfoTag_, PupInfo);

std::vector<PileupSummaryInfo>::const_iterator PVI;

Expand Down

0 comments on commit e6343e1

Please sign in to comment.