Skip to content
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

Use global::EDAnalyzers in GeneratorInterface/Core #29328

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
@@ -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);