Skip to content

Commit

Permalink
Merge pull request cms-sw#292 from guitargeek/guitargeek-patch-1
Browse files Browse the repository at this point in the history
Don't leave nCuts in VIDNestedWPBitmapProducer uninitialized
  • Loading branch information
peruzzim committed Feb 8, 2019
2 parents 1b19348 + 40685b4 commit 18e2b78
Showing 1 changed file with 18 additions and 35 deletions.
53 changes: 18 additions & 35 deletions PhysicsTools/NanoAOD/plugins/VIDNestedWPBitmapProducer.cc
Expand Up @@ -2,7 +2,7 @@
//
// Package: PhysicsTools/NanoAOD
// Class: VIDNestedWPBitmapProducer
//
//
/**\class VIDNestedWPBitmapProducer VIDNestedWPBitmapProducer.cc PhysicsTools/NanoAOD/plugins/VIDNestedWPBitmapProducer.cc
Description: [one line class summary]
Expand Down Expand Up @@ -41,32 +41,27 @@

template <typename T>
class VIDNestedWPBitmapProducer : public edm::stream::EDProducer<> {
public:

public:

explicit VIDNestedWPBitmapProducer(const edm::ParameterSet &iConfig):
src_(consumes<edm::View<T>>(iConfig.getParameter<edm::InputTag>("src"))),
isInit_(false)
{
auto vwp = iConfig.getParameter<std::vector<std::string>>("WorkingPoints");
for (auto wp : vwp) {
auto const& vwp = iConfig.getParameter<std::vector<std::string>>("WorkingPoints");
for (auto const& wp : vwp) {
src_bitmaps_.push_back(consumes<edm::ValueMap<unsigned int> >(edm::InputTag(wp+std::string("Bitmap"))));
src_cutflows_.push_back(consumes<edm::ValueMap<vid::CutFlowResult> >(edm::InputTag(wp)));
}
nWP = src_bitmaps_.size();
produces<edm::ValueMap<int>>();
}
~VIDNestedWPBitmapProducer() override {}

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
void beginStream(edm::StreamID) override {};
void produce(edm::Event&, const edm::EventSetup&) override;
void endStream() override {};
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

//virtual void beginRun(edm::Run const&, edm::EventSetup const&) override;
//virtual void endRun(edm::Run const&, edm::EventSetup const&) override;
//virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
//virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
private:

void produce(edm::Event&, const edm::EventSetup&) override;

// ----------member data ---------------------------

Expand All @@ -76,22 +71,14 @@ class VIDNestedWPBitmapProducer : public edm::stream::EDProducer<> {

unsigned int nWP;
unsigned int nBits;
unsigned int nCuts;
unsigned int nCuts = 0;
std::vector<unsigned int> res_;
bool isInit_;

void initNCuts(unsigned int);

};

//
// constants, enums and typedefs
//


//
// static data member definitions
//

template <typename T>
void
Expand All @@ -107,20 +94,18 @@ VIDNestedWPBitmapProducer<T>::produce(edm::Event& iEvent, const edm::EventSetup&

std::vector<unsigned int> res;

auto npho = src->size();
for (unsigned int i=0; i<npho; i++){
auto obj = src->ptrAt(i);
for (auto const& obj : src->ptrs()) {
for (unsigned int j=0; j<nWP; j++){
auto cutflow = (*(src_cutflows[j]))[obj];
if (!isInit_) initNCuts(cutflow.cutFlowSize());
if (cutflow.cutFlowSize()!=nCuts) throw cms::Exception("Configuration","Trying to compress VID bitmaps for cutflows of different size");
auto bitmap = (*(src_bitmaps[j]))[obj];
for (unsigned int k=0; k<nCuts; k++){
if (j==0) res_[k] = 0;
if (bitmap>>k & 1) {
if (res_[k]!=j) throw cms::Exception("Configuration","Trying to compress VID bitmaps which are not nested in the correct order for all cuts");
res_[k]++;
}
if (j==0) res_[k] = 0;
if (bitmap>>k & 1) {
if (res_[k]!=j) throw cms::Exception("Configuration","Trying to compress VID bitmaps which are not nested in the correct order for all cuts");
res_[k]++;
}
}
}

Expand All @@ -129,8 +114,7 @@ VIDNestedWPBitmapProducer<T>::produce(edm::Event& iEvent, const edm::EventSetup&
res.push_back(out);
}


std::unique_ptr<edm::ValueMap<int>> resV(new edm::ValueMap<int>());
auto resV = std::make_unique<edm::ValueMap<int>>();
edm::ValueMap<int>::Filler filler(*resV);
filler.insert(src,res.begin(),res.end());
filler.fill();
Expand Down Expand Up @@ -170,4 +154,3 @@ typedef VIDNestedWPBitmapProducer<pat::Photon> PhoVIDNestedWPBitmapProducer;
//define this as a plug-in
DEFINE_FWK_MODULE(EleVIDNestedWPBitmapProducer);
DEFINE_FWK_MODULE(PhoVIDNestedWPBitmapProducer);

0 comments on commit 18e2b78

Please sign in to comment.