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

Run3-sim129 Use token rather than label for accessing collections in FastSimulation/ForwardDetectors #39666

Merged
merged 7 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 6 additions & 10 deletions FastSimulation/ForwardDetectors/plugins/FastSimDataFilter.cc
Expand Up @@ -3,38 +3,35 @@
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/PluginManager/interface/ModuleDef.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
#include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"

using namespace std;
namespace cms {

FastSimDataFilter::FastSimDataFilter(const edm::ParameterSet& conf) {
towercut = conf.getUntrackedParameter<double>("towercut", 1.4);
}

FastSimDataFilter::~FastSimDataFilter() {}
FastSimDataFilter::FastSimDataFilter(const edm::ParameterSet& conf)
: tokTowers_(consumes<CaloTowerCollection>(edm::InputTag("towerMaker"))),
towercut(conf.getUntrackedParameter<double>("towercut", 1.4)) {}

void FastSimDataFilter::beginJob() {
ntotal = 0;
npassed = 0;
}
void FastSimDataFilter::endJob() {
cout << " FastSimDataFilter: accepted " << npassed << " out of total " << ntotal << endl;
edm::LogVerbatim("FastSim") << " FastSimDataFilter: accepted " << npassed << " out of total " << ntotal;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing the name of the class, instead of a generic "FastSim" can help in case of using these messages for debug:

Suggested change
edm::LogVerbatim("FastSim") << " FastSimDataFilter: accepted " << npassed << " out of total " << ntotal;
edm::LogVerbatim("FastSimDataFilter") << " FastSimDataFilter: accepted " << npassed << " out of total " << ntotal;

}

bool FastSimDataFilter::filter(edm::Event& event, const edm::EventSetup& setup) {
ntotal++;
bool result = false;

edm::Handle<CaloTowerCollection> towers;
event.getByLabel("towerMaker", towers);
const edm::Handle<CaloTowerCollection>& towers = event.getHandle(tokTowers_);
CaloTowerCollection::const_iterator cal;

int nplusP = 0;
Expand Down Expand Up @@ -83,7 +80,6 @@ namespace cms {
} // towers cycle

if ((nplusP * nminusP >= 1) || (nplusR * nminusR >= 1) || (nplusP * nminusR >= 1) || (nplusR * nminusP >= 1)) {
// std::cout << "... passed" << std::endl;
result = true;
npassed++;
}
Expand Down
7 changes: 4 additions & 3 deletions FastSimulation/ForwardDetectors/plugins/FastSimDataFilter.h
Expand Up @@ -3,6 +3,7 @@

#include "FWCore/Framework/interface/stream/EDFilter.h"
#include "DataFormats/Math/interface/Vector3D.h"
#include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"

#include <vector>
#include <utility>
Expand All @@ -22,17 +23,17 @@ namespace cms {
class FastSimDataFilter : public edm::stream::EDFilter<> {
public:
FastSimDataFilter(const edm::ParameterSet& pset);

~FastSimDataFilter() override;
~FastSimDataFilter() override = default;

bool filter(edm::Event&, const edm::EventSetup&) override;
virtual void beginJob();
virtual void endJob();

private:
typedef math::RhoEtaPhiVector Vector;
const edm::EDGetTokenT<CaloTowerCollection> tokTowers_;

double towercut;
const double towercut;
int ntotal, npassed;
};
} // namespace cms
Expand Down