Skip to content

Commit

Permalink
Merge pull request #1585 from vkuznet/ThreadSafe2_FastSimulation_Trac…
Browse files Browse the repository at this point in the history
…kingRecHitProducer

Multithreading fixes -- FastSimulation/TrackingRecHitProducer
  • Loading branch information
ktf committed Nov 26, 2013
2 parents caeec85 + 3154a6d commit be55364
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 19 deletions.
8 changes: 7 additions & 1 deletion FastSimulation/TrackingRecHitProducer/src/FastPixelCPE.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <iostream>
#include <map>
#include <memory>
using namespace std;

//-----------------------------------------------------------------------------
Expand All @@ -30,6 +31,11 @@ PixelClusterParameterEstimator::LocalValues FastPixelCPE::localParameters(const
throw cms::Exception("FastPixelCPE") << "Cluster not filled.";
}

void FastPixelCPE::enterLocalParameters(unsigned int id, std::pair<int,int> &row_col, const std::pair<LocalPoint,LocalError>& pos_err_info) const {
void FastPixelCPE::enterLocalParameters(unsigned int id, std::pair<int,int> &row_col, const std::pair<LocalPoint,LocalError>& pos_err_info) {
pos_err_map.insert(std::make_pair(std::make_pair(id,row_col), pos_err_info));
}

std::unique_ptr<ClusterParameterEstimator<SiPixelCluster>>
FastPixelCPE::clone() const {
return std::unique_ptr<ClusterParameterEstimator<SiPixelCluster>>(new ClusterParameterEstimator<SiPixelCluster>(*this));
}
9 changes: 5 additions & 4 deletions FastSimulation/TrackingRecHitProducer/src/FastPixelCPE.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
#define FastSimulation_TrackingRecHitProducer_FastPixelCPE_H

//Header files
#include "RecoLocalTracker/ClusterParameterEstimator/interface/ClusterParameterEstimator.h"
#include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h"
#include "FastSimDataFormats/External/interface/FastTrackerCluster.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include <map>

#if 0
#endif
#include <memory>

class FastPixelCPE : public PixelClusterParameterEstimator
{
Expand All @@ -22,12 +21,14 @@ class FastPixelCPE : public PixelClusterParameterEstimator
const GeomDetUnit & det) const;

//Put information into the map.
void enterLocalParameters(unsigned int id, std::pair<int,int> &row_col, const std::pair<LocalPoint,LocalError>& pos_err_info) const;
void enterLocalParameters(unsigned int id, std::pair<int,int> &row_col, const std::pair<LocalPoint,LocalError>& pos_err_info);

//Clear the map.
void clearParameters() const {
pos_err_map.clear();
}

std::unique_ptr<ClusterParameterEstimator<SiPixelCluster>> clone() const;

private:
//Map used to store clusters distinctly.
Expand Down
8 changes: 6 additions & 2 deletions FastSimulation/TrackingRecHitProducer/src/FastStripCPE.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include <algorithm>
#include<cmath>
#include<map>
#include <memory>


void FastStripCPE::enterLocalParameters(uint32_t id, uint16_t firstStrip, const std::pair<LocalPoint, LocalError>& pos_err_info ) const {
void FastStripCPE::enterLocalParameters(uint32_t id, uint16_t firstStrip, const std::pair<LocalPoint, LocalError>& pos_err_info ) {
//Filling the map.
pos_err_map.insert(std::make_pair(std::make_pair(id, firstStrip), pos_err_info));
}
Expand All @@ -21,6 +21,10 @@ StripClusterParameterEstimator::LocalValues FastStripCPE::localParameters( const
throw cms::Exception("FastStripCPE") << "Cluster not filled.";
}

std::unique_ptr<ClusterParameterEstimator<SiStripCluster>>
FastStripCPE::clone() const {
return std::unique_ptr<ClusterParameterEstimator<SiStripCluster>>(new ClusterParameterEstimator<SiStripCluster>(*this));
}

LocalVector FastStripCPE::driftDirection(const StripGeomDetUnit* det) const {
throw cms::Exception("FastStripCPE") << "Should Not Be Called.";
Expand Down
7 changes: 5 additions & 2 deletions FastSimulation/TrackingRecHitProducer/src/FastStripCPE.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

#include "DataFormats/GeometryVector/interface/LocalPoint.h"
#include "DataFormats/GeometrySurface/interface/LocalError.h"
#include "RecoLocalTracker/ClusterParameterEstimator/interface/ClusterParameterEstimator.h"
#include "RecoLocalTracker/ClusterParameterEstimator/interface/StripClusterParameterEstimator.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include <ext/hash_map>
#include <map>

#include <memory>

class FastStripCPE : public StripClusterParameterEstimator
{
Expand All @@ -23,13 +24,15 @@ class FastStripCPE : public StripClusterParameterEstimator
StripClusterParameterEstimator::LocalValues localParameters( const SiStripCluster & cl)const;

//Put information into the map.
void enterLocalParameters(uint32_t id, uint16_t firstStrip, const std::pair<LocalPoint,LocalError>& pos_err_info) const;
void enterLocalParameters(uint32_t id, uint16_t firstStrip, const std::pair<LocalPoint,LocalError>& pos_err_info);

//Clear the map.
void clearParameters() const {
pos_err_map.clear();
}

std::unique_ptr<ClusterParameterEstimator<SiStripCluster>> clone() const;

LocalVector driftDirection(const StripGeomDetUnit* det)const;

private:
Expand Down
13 changes: 7 additions & 6 deletions FastSimulation/TrackingRecHitProducer/src/SiClusterTranslator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ SiClusterTranslator::produce(edm::Event& e, const edm::EventSetup& es)

edm::ESHandle<PixelClusterParameterEstimator> pixelCPE;
es.get<TkPixelCPERecord>().get("FastPixelCPE",pixelCPE);
const PixelClusterParameterEstimator &pixelcpe(*pixelCPE);
auto pixelcpe = pixelCPE->clone();
pixelcpe->clearParameters();

edm::ESHandle<StripClusterParameterEstimator> stripCPE;
es.get<TkStripCPERecord>().get("FastStripCPE", stripCPE);
const StripClusterParameterEstimator &stripcpe(*stripCPE);
auto stripcpe = stripCPE->clone();

edm::Handle<CrossingFrame<PSimHit> > cf_simhit;
std::vector<const CrossingFrame<PSimHit> *> cf_simhitvec;
Expand All @@ -118,8 +119,8 @@ SiClusterTranslator::produce(edm::Event& e, const edm::EventSetup& es)
std::map< DetId, std::vector<SiStripCluster> > temporaryStripClusters;

//Clearing CPE maps from previous event.
stripcpe.clearParameters();
pixelcpe.clearParameters();
stripcpe->clearParameters();
pixelcpe->clearParameters();

int ClusterNum = 0;

Expand Down Expand Up @@ -166,7 +167,7 @@ SiClusterTranslator::produce(edm::Event& e, const edm::EventSetup& es)

//Filling Pixel CPE with information.
std::pair<int,int> row_col((int)pixelPos_out.first,(int)pixelPos_out.second);
pixelcpe.enterLocalParameters((unsigned int) det.rawId() , row_col, std::make_pair(position,error));
pixelcpe->enterLocalParameters((unsigned int) det.rawId() , row_col, std::make_pair(position,error));

unsigned int ch = PixelChannelIdentifier::pixelToChannel((int)pixelPos_out.first, (int)pixelPos_out.second);

Expand Down Expand Up @@ -220,7 +221,7 @@ SiClusterTranslator::produce(edm::Event& e, const edm::EventSetup& es)
}

//Filling Strip CPE with info.
stripcpe.enterLocalParameters(det.rawId(), strip_num, std::make_pair(position,error));
stripcpe->enterLocalParameters(det.rawId(), strip_num, std::make_pair(position,error));

//Creating a new strip cluster
SiStripCluster temporaryStripCluster(det.rawId(), strip_num, digi_vec.begin(), digi_vec.end());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef RecoLocalTracker_Cluster_Parameter_Estimator_H
#define RecoLocalTracker_Cluster_Parameter_Estimator_H

#include <memory>

#include "DataFormats/GeometrySurface/interface/LocalError.h"
#include "DataFormats/GeometryVector/interface/LocalPoint.h"

Expand All @@ -14,7 +16,9 @@ class ClusterParameterEstimator {
public:
typedef std::pair<LocalPoint,LocalError> LocalValues;
typedef std::vector<LocalValues> VLocalValues;
virtual LocalValues localParameters( const T&,const GeomDetUnit&) const = 0;
virtual LocalValues localParameters( const T&,const GeomDetUnit&) const {
return std::make_pair(LocalPoint(), LocalError());
}
virtual LocalValues localParameters( const T& cluster, const GeomDetUnit& gd, const LocalTrajectoryParameters&) const {
return localParameters(cluster,gd);
}
Expand All @@ -36,10 +40,13 @@ class ClusterParameterEstimator {

//methods needed by FastSim
virtual void enterLocalParameters(unsigned int id, std::pair<int,int>
&row_col, LocalValues pos_err_info) const {}
&row_col, LocalValues pos_err_info) {}
virtual void enterLocalParameters(uint32_t id, uint16_t firstStrip,
LocalValues pos_err_info) const {}
virtual void clearParameters() const {}
LocalValues pos_err_info) {}
virtual void clearParameters() {}
virtual std::unique_ptr<ClusterParameterEstimator<T>> clone() const {
return std::unique_ptr<ClusterParameterEstimator<T>>(new ClusterParameterEstimator<T>(*this));
}

};

Expand Down

0 comments on commit be55364

Please sign in to comment.