Skip to content

Commit

Permalink
Merge pull request #29328 from Dr15Jones/threadEfficientGeneratorInte…
Browse files Browse the repository at this point in the history
…rfaceCore

Use global::EDAnalyzers in GeneratorInterface/Core
  • Loading branch information
cmsbuild authored Mar 28, 2020
2 parents 507fd6c + 6f9e7ea commit d5d1a36
Show file tree
Hide file tree
Showing 7 changed files with 290 additions and 287 deletions.
45 changes: 0 additions & 45 deletions GeneratorInterface/Core/interface/GenFilterEfficiencyAnalyzer.h

This file was deleted.

117 changes: 0 additions & 117 deletions GeneratorInterface/Core/interface/GenXSecAnalyzer.h

This file was deleted.

27 changes: 0 additions & 27 deletions GeneratorInterface/Core/interface/GeneratorSmearedProducer.h

This file was deleted.

68 changes: 64 additions & 4 deletions GeneratorInterface/Core/plugins/GenFilterEfficiencyAnalyzer.cc
Original file line number Diff line number Diff line change
@@ -1,17 +1,72 @@
#include "GeneratorInterface/Core/interface/GenFilterEfficiencyAnalyzer.h"
// F. Cossutti
// $Revision://

// analyzer of a summary information product on filter efficiency for a user specified path
// meant for the generator filter efficiency calculation

// system include files
#include <memory>
#include <iostream>

// user include files

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/global/EDAnalyzer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Run.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/LuminosityBlock.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "SimDataFormats/GeneratorProducts/interface/GenFilterInfo.h"
//
// class declaration
//

namespace gfea {
struct Empty {};
}; // namespace gfea

class GenFilterEfficiencyAnalyzer : public edm::global::EDAnalyzer<edm::LuminosityBlockCache<gfea::Empty>> {
public:
explicit GenFilterEfficiencyAnalyzer(const edm::ParameterSet&);
~GenFilterEfficiencyAnalyzer() final;

private:
void analyze(edm::StreamID, const edm::Event&, const edm::EventSetup&) const final;
std::shared_ptr<gfea::Empty> globalBeginLuminosityBlock(edm::LuminosityBlock const&,
edm::EventSetup const&) const final;
void globalEndLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) const final;
void endJob() final;

edm::EDGetTokenT<GenFilterInfo> genFilterInfoToken_;
mutable std::mutex mutex_;
CMS_THREAD_GUARD(mutex_) mutable GenFilterInfo totalGenFilterInfo_;

// ----------member data ---------------------------
};

GenFilterEfficiencyAnalyzer::GenFilterEfficiencyAnalyzer(const edm::ParameterSet& pset)
: genFilterInfoToken_(consumes<GenFilterInfo, edm::InLumi>(pset.getParameter<edm::InputTag>("genFilterInfoTag"))),
totalGenFilterInfo_(0, 0, 0, 0, 0., 0., 0., 0.) {}

GenFilterEfficiencyAnalyzer::~GenFilterEfficiencyAnalyzer() {}

void GenFilterEfficiencyAnalyzer::analyze(const edm::Event&, const edm::EventSetup&) {}
void GenFilterEfficiencyAnalyzer::analyze(edm::StreamID, const edm::Event&, const edm::EventSetup&) const {}

std::shared_ptr<gfea::Empty> GenFilterEfficiencyAnalyzer::globalBeginLuminosityBlock(edm::LuminosityBlock const& iLumi,
edm::EventSetup const&) const {
return std::shared_ptr<gfea::Empty>();
}

// ------------ method called once each job just after ending the event loop ------------

void GenFilterEfficiencyAnalyzer::endLuminosityBlock(edm::LuminosityBlock const& iLumi, edm::EventSetup const&) {
void GenFilterEfficiencyAnalyzer::globalEndLuminosityBlock(edm::LuminosityBlock const& iLumi,
edm::EventSetup const&) const {
edm::Handle<GenFilterInfo> genFilter;
iLumi.getByToken(genFilterInfoToken_, genFilter);

Expand All @@ -21,7 +76,10 @@ void GenFilterEfficiencyAnalyzer::endLuminosityBlock(edm::LuminosityBlock const&
<< " N failed = " << genFilter->sumFailWeights() << std::endl;
std::cout << "Generator filter efficiency = " << genFilter->filterEfficiency(-1) << " +- "
<< genFilter->filterEfficiencyError(-1) << std::endl;
totalGenFilterInfo_.mergeProduct(*genFilter);
{
std::lock_guard<std::mutex> guard(mutex_);
totalGenFilterInfo_.mergeProduct(*genFilter);
}
}

void GenFilterEfficiencyAnalyzer::endJob() {
Expand All @@ -30,3 +88,5 @@ void GenFilterEfficiencyAnalyzer::endJob() {
std::cout << "Filter efficiency = " << totalGenFilterInfo_.filterEfficiency(-1) << " +- "
<< totalGenFilterInfo_.filterEfficiencyError(-1) << std::endl;
}

DEFINE_FWK_MODULE(GenFilterEfficiencyAnalyzer);
Loading

0 comments on commit d5d1a36

Please sign in to comment.