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
Make ClusterMultiplicityFilter multithread safe #12024
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,23 +4,26 @@ | |
#include <string> | ||
|
||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/EDFilter.h" | ||
#include "FWCore/Framework/interface/stream/EDFilter.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" | ||
#include "DataFormats/Common/interface/DetSetVectorNew.h" | ||
|
||
|
||
class ClusterMultiplicityFilter : public edm::EDFilter { | ||
class ClusterMultiplicityFilter : public edm::stream::EDFilter<> { | ||
public: | ||
explicit ClusterMultiplicityFilter(const edm::ParameterSet&); | ||
~ClusterMultiplicityFilter(); | ||
|
||
private: | ||
virtual void beginJob() ; | ||
|
||
virtual bool filter(edm::Event&, const edm::EventSetup&); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add |
||
virtual void endJob() ; | ||
|
||
unsigned int maxNumberOfClusters_; | ||
std::string clusterCollectionLabel_; | ||
const unsigned int maxNumberOfClusters_; | ||
const std::string clusterCollectionLabel_; | ||
|
||
edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> > clusters_; | ||
|
||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,19 +15,15 @@ | |
#include <memory> | ||
|
||
#include "RecoLocalTracker/SubCollectionProducers/interface/ClusterMultiplicityFilter.h" | ||
|
||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
|
||
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" | ||
#include "DataFormats/Common/interface/DetSetVector.h" | ||
|
||
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" | ||
|
||
|
||
ClusterMultiplicityFilter::ClusterMultiplicityFilter(const edm::ParameterSet& iConfig) | ||
ClusterMultiplicityFilter::ClusterMultiplicityFilter(const edm::ParameterSet& iConfig) : | ||
maxNumberOfClusters_(iConfig.getUntrackedParameter<unsigned int>("MaxNumberOfClusters")), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. both config parameters affect the result of the code, so, they should be made tracked (remove "Untracked") |
||
clusterCollectionLabel_(iConfig.getUntrackedParameter<std::string>("ClusterCollectionLabel")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use InputTag directly in the configuration: conversions from string input parameter to InputTag should be avoinded |
||
{ | ||
maxNumberOfClusters_ = iConfig.getUntrackedParameter<unsigned int>("MaxNumberOfClusters"); | ||
clusterCollectionLabel_ = iConfig.getUntrackedParameter<std::string>("ClusterCollectionLabel"); | ||
clusters_ = consumes<edmNew::DetSetVector<SiStripCluster> >(edm::InputTag(clusterCollectionLabel_)); | ||
} | ||
|
||
|
||
|
@@ -40,22 +36,22 @@ bool ClusterMultiplicityFilter::filter(edm::Event& iEvent, const edm::EventSetup | |
|
||
bool result = true; | ||
|
||
const edm::DetSetVector<SiStripCluster> *clusters = 0; | ||
edm::Handle<edm::DetSetVector<SiStripCluster> > clusterHandle; | ||
iEvent.getByLabel(clusterCollectionLabel_,clusterHandle); | ||
const edmNew::DetSetVector<SiStripCluster> *clusters = 0; | ||
edm::Handle<edmNew::DetSetVector<SiStripCluster> > clusterHandle; | ||
iEvent.getByToken(clusters_,clusterHandle); | ||
if( !clusterHandle.isValid() ) { | ||
throw cms::Exception("CorruptData") | ||
<< "ClusterMultiplicityFilter requires collection <edm::DetSetVector<SiStripCluster> with label " << clusterCollectionLabel_ << std::endl; | ||
} | ||
|
||
clusters = clusterHandle.product(); | ||
const edm::DetSetVector<SiStripCluster>& input = *clusters; | ||
const edmNew::DetSetVector<SiStripCluster>& input = *clusters; | ||
|
||
unsigned int totalClusters = 0; | ||
|
||
//loop over detectors | ||
for (edm::DetSetVector<SiStripCluster>::const_iterator DSViter=input.begin(); DSViter!=input.end();DSViter++ ) { | ||
totalClusters+=DSViter->data.size(); | ||
for (edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter=input.begin(); DSViter!=input.end();DSViter++ ) { | ||
totalClusters+=DSViter->size(); | ||
} | ||
|
||
|
||
|
@@ -66,13 +62,3 @@ bool ClusterMultiplicityFilter::filter(edm::Event& iEvent, const edm::EventSetup | |
|
||
return result; | ||
} | ||
|
||
|
||
void ClusterMultiplicityFilter::beginJob() { | ||
} | ||
|
||
|
||
// ------------ method called once each job just after ending the event loop ------------ | ||
void ClusterMultiplicityFilter::endJob() { | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could easily be converted to a
edm::global::EDFilter<>
which would safe memory and be faster for the framework.