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

Fake CPE #24175

Merged
merged 15 commits into from Aug 11, 2018
67 changes: 67 additions & 0 deletions RecoLocalTracker/ClusterParameterEstimator/interface/FakeCPE.h
@@ -0,0 +1,67 @@
#ifndef RecoLocalTracker_Cluster_Parameter_Estimator_Fake_H
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use an include guard matching the full file name subsystem_package_fileName_h

Copy link
Contributor Author

Choose a reason for hiding this comment

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

consistent with base class

head -n 1 RecoLocalTracker/ClusterParameterEstimator/interface/ClusterParameterEstimator.h 
#ifndef RecoLocalTracker_Cluster_Parameter_Estimator_H

#define RecoLocalTracker_Cluster_Parameter_Estimator_Fake_H

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

#include "Geometry/CommonDetUnit/interface/GeomDet.h"

#include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"


#include <cstdint>
#include <unordered_map>

#include "FWCore/MessageLogger/interface/MessageLogger.h"

class FakeCPE {
public:

using LocalValues = std::pair<LocalPoint,LocalError>;

// store position and error for each cluster...
class Map {
public:
using LocalValues = std::pair<LocalPoint,LocalError>;
void clear() {m_map.clear();}
void error(const GeomDetUnit& gd) const {edm::LogError("FakeCPE") << "hit not found in det " << gd.geographicalId().rawId(); }
template<typename Cluster>
void add(const Cluster& cluster, const GeomDetUnit& gd,LocalValues const & lv) { m_map[encode(cluster,gd)] = lv; }

template<typename Cluster>
LocalValues const & get(const Cluster& cluster, const GeomDetUnit& gd) const {
auto p = m_map.find(encode(cluster,gd));
if (p!=m_map.end()) { return (*p).second; }
error(gd);
return dummy;
}

static uint64_t encode(const SiPixelCluster& cluster, const GeomDetUnit& det) {
uint64_t u1 = det.geographicalId().rawId();
uint64_t u2 = cluster.minPixelRow();
uint64_t u3 = cluster.minPixelCol();
return (u1<<32) | (u2<<16) | u3;
}
static uint64_t encode(const SiStripCluster& cluster, const GeomDetUnit& det) {
uint64_t u1 = det.geographicalId().rawId();
uint64_t u2 = cluster.firstStrip();
return (u1<<32) | u2;
}

private:
std::unordered_map<uint64_t,LocalValues> m_map;
LocalValues dummy;
};


Map & map() { return m_map;}
Map const & map() const { return m_map;}

private:

Map m_map;

};

#endif
@@ -0,0 +1,53 @@
#ifndef RecoLocalTracker_Fake_PixelCluster_Parameter_Estimator_H
#define RecoLocalTracker_Fake_PixelCluster_Parameter_Estimator_H

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

#include "Geometry/CommonDetUnit/interface/GeomDet.h"
#include "DataFormats/TrajectoryState/interface/LocalTrajectoryParameters.h"
#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"

#include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitQuality.h"
#include<tuple>


#include "RecoLocalTracker/ClusterParameterEstimator/interface/FakeCPE.h"
#include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h"

class PixelFakeCPE final : public PixelClusterParameterEstimator {
public:

PixelFakeCPE() = default;
~PixelFakeCPE() = default;

typedef std::pair<LocalPoint,LocalError> LocalValues;
typedef std::vector<LocalValues> VLocalValues;

using ReturnType = std::tuple<LocalPoint,LocalError,SiPixelRecHitQuality::QualWordType>;

// here just to implement it in the clients;
// to be properly implemented in the sub-classes in order to make them thread-safe

ReturnType getParameters(const SiPixelCluster & cl,
const GeomDetUnit & det) const override {
auto const & lv = fakeCPE().map().get(cl,det);
return {lv.first,lv.second,0};
}

ReturnType getParameters(const SiPixelCluster & cl,
const GeomDetUnit & det,
const LocalTrajectoryParameters &) const override{
return getParameters(cl,det);
}

void setFakeCPE(FakeCPE * iFakeCPE) { m_fakeCPE = iFakeCPE;}
FakeCPE const & fakeCPE() const { return *m_fakeCPE; }

private:
FakeCPE const * m_fakeCPE=nullptr;

};

#endif
@@ -0,0 +1,55 @@
#ifndef RecoLocalTracker_Fake_StripCluster_Parameter_Estimator_H
#define RecoLocalTracker_Fake_StripCluster_Parameter_Estimator_H
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use an include guard matching the full file name subsystem_package_fileName_h

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just copied for base class

head -n 1

RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h
#ifndef RecoLocalTracker_PixelCluster_Parameter_Estimator_H


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

#include "Geometry/CommonDetUnit/interface/GeomDet.h"
#include "DataFormats/TrajectoryState/interface/LocalTrajectoryParameters.h"
#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"

#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
#include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/MeasurementPoint.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/MeasurementError.h"

#include "CommonTools/Utils/interface/DynArray.h"
#include "FWCore/Utilities/interface/Exception.h"


#include "RecoLocalTracker/ClusterParameterEstimator/interface/FakeCPE.h"
#include "RecoLocalTracker/ClusterParameterEstimator/interface/StripClusterParameterEstimator.h"

class StripFakeCPE final : public StripClusterParameterEstimator
{
public:

StripFakeCPE() = default;
~StripFakeCPE() override = default;

using LocalValues = std::pair<LocalPoint,LocalError>;

LocalValues localParameters( const SiStripCluster& cl , const GeomDetUnit& gd) const override {
return fakeCPE().map().get(cl,gd);
}

// used by Validation....
LocalVector driftDirection(const StripGeomDetUnit* ) const override { return LocalVector();}

void setFakeCPE(FakeCPE * iFakeCPE) { m_fakeCPE = iFakeCPE;}
FakeCPE const & fakeCPE() const { return *m_fakeCPE; }


private:

FakeCPE const * m_fakeCPE=nullptr;


};


#endif




52 changes: 52 additions & 0 deletions RecoLocalTracker/SiPixelRecHits/plugins/FakePixelCPEESProducer.cc
@@ -0,0 +1,52 @@
#include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelFakeCPE.h"

#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/ESProducer.h"



#include <string>
#include <memory>


#include "FWCore/Framework/interface/ESProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "RecoLocalTracker/Records/interface/TkPixelCPERecord.h"

namespace {

class FakePixelCPEESProducer final : public edm::ESProducer{
public:

FakePixelCPEESProducer(const edm::ParameterSet & p) {
std::string myname = p.getParameter<std::string>("ComponentName");
setWhatProduced(this,myname);
}

~FakePixelCPEESProducer() = default;

std::unique_ptr<PixelClusterParameterEstimator> produce(const TkPixelCPERecord &) {
return std::make_unique<PixelFakeCPE>();
}

private:

};

}

#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Utilities/interface/typelookup.h"
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"

DEFINE_FWK_EVENTSETUP_MODULE(FakePixelCPEESProducer);

Expand Up @@ -2,6 +2,8 @@
#include "RecoLocalTracker/SiStripRecHitConverter/interface/StripCPE.h"
#include "RecoLocalTracker/SiStripRecHitConverter/interface/StripCPEfromTrackAngle.h"
#include "RecoLocalTracker/SiStripRecHitConverter/interface/StripCPEgeometric.h"
#include "RecoLocalTracker/ClusterParameterEstimator/interface/StripFakeCPE.h"

#include "CondFormats/SiStripObjects/interface/SiStripBackPlaneCorrection.h"
#include "CondFormats/SiStripObjects/interface/SiStripConfObject.h"
#include "CondFormats/SiStripObjects/interface/SiStripLatency.h"
Expand All @@ -22,6 +24,7 @@ StripCPEESProducer::StripCPEESProducer(const edm::ParameterSet & p)
enumMap[std::string("SimpleStripCPE")]=SIMPLE;
enumMap[std::string("StripCPEfromTrackAngle")]=TRACKANGLE;
enumMap[std::string("StripCPEgeometric")]=GEOMETRIC;
enumMap[std::string("FakeStripCPE")]=FAKE;
if(enumMap.find(type)==enumMap.end())
throw cms::Exception("Unknown StripCPE type") << type;

Expand Down Expand Up @@ -59,6 +62,10 @@ produce(const TkStripCPERecord & iRecord)
cpe = std::make_unique<StripCPEgeometric>(parametersPSet, *magfield, *pDD, *lorentzAngle, *backPlaneCorrection, *confObj, *latency );
break;

case FAKE:
cpe = std::make_unique<StripFakeCPE>();
break;

}

return cpe;
Expand Down
Expand Up @@ -20,7 +20,7 @@ class StripCPEESProducer: public edm::ESProducer {

private:

enum CPE_t { SIMPLE, TRACKANGLE, GEOMETRIC };
enum CPE_t { SIMPLE, TRACKANGLE, GEOMETRIC, FAKE };
std::map<std::string,CPE_t> enumMap;

CPE_t cpeNum;
Expand Down
5 changes: 5 additions & 0 deletions RecoTracker/TrackProducer/test/BuildFile.xml
Expand Up @@ -42,3 +42,8 @@
<use name="TrackingTools/GsfTracking"/>
<flags EDM_PLUGIN="1"/>
</library>
<library file="FakeCPEFiller.cc" name="FakeCPEFiller">
<use name="SimTracker/TrackerHitAssociation"/>
<flags EDM_PLUGIN="1"/>
</library>