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

Make ClusterMultiplicityFilter multithread safe #12024

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Expand Up @@ -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<> {
Copy link
Contributor

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.

public:
explicit ClusterMultiplicityFilter(const edm::ParameterSet&);
~ClusterMultiplicityFilter();

private:
virtual void beginJob() ;

virtual bool filter(edm::Event&, const edm::EventSetup&);
Copy link
Contributor

Choose a reason for hiding this comment

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

please add override: filter(edm::Event&, const edm::EventSetup&) override;

virtual void endJob() ;

unsigned int maxNumberOfClusters_;
std::string clusterCollectionLabel_;
const unsigned int maxNumberOfClusters_;
const std::string clusterCollectionLabel_;

edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> > clusters_;

};

Expand Down
Expand Up @@ -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")),
Copy link
Contributor

Choose a reason for hiding this comment

The 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")
[not sure if this would trigger changes in large number of places: let's discuss if it does, given that list]

clusterCollectionLabel_(iConfig.getUntrackedParameter<std::string>("ClusterCollectionLabel"))
Copy link
Contributor

Choose a reason for hiding this comment

The 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_));
}


Expand All @@ -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();
}


Expand All @@ -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() {
}