File indexing completed on 2024-04-06 12:28:28
0001 #include "FWCore/Framework/interface/ESProducer.h"
0002 #include "FWCore/Framework/interface/ESHandle.h"
0003 #include "FWCore/Framework/interface/ModuleFactory.h"
0004
0005 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008
0009 #include "RecoTracker/PixelLowPtUtilities/interface/ClusterShapeHitFilter.h"
0010
0011 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0012 #include "RecoTracker/Record/interface/CkfComponentsRecord.h"
0013 #include "RecoLocalTracker/SiStripClusterizer/interface/ClusterChargeCut.h"
0014 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0015 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0016
0017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0018
0019 class ClusterShapeHitFilterESProducer : public edm::ESProducer {
0020 public:
0021 ClusterShapeHitFilterESProducer(const edm::ParameterSet&);
0022
0023 typedef std::unique_ptr<ClusterShapeHitFilter> ReturnType;
0024 ReturnType produce(const ClusterShapeHitFilter::Record&);
0025
0026 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0027
0028 private:
0029
0030 edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> fieldToken_;
0031
0032 edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geoToken_;
0033
0034 edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> topolToken_;
0035
0036 edm::ESGetToken<SiPixelLorentzAngle, SiPixelLorentzAngleRcd> pixelToken_;
0037
0038 edm::ESGetToken<SiStripLorentzAngle, SiStripLorentzAngleDepRcd> stripToken_;
0039
0040 const std::string pixelShapeFile;
0041 const std::string pixelShapeFileL1;
0042 const float minGoodPixelCharge_, minGoodStripCharge_;
0043 const bool isPhase2_;
0044 const bool cutOnPixelCharge_, cutOnStripCharge_;
0045 const bool cutOnPixelShape_, cutOnStripShape_;
0046 };
0047
0048
0049 ClusterShapeHitFilterESProducer::ClusterShapeHitFilterESProducer(const edm::ParameterSet& iConfig)
0050 : pixelShapeFile(iConfig.getParameter<std::string>("PixelShapeFile")),
0051 pixelShapeFileL1(iConfig.getParameter<std::string>("PixelShapeFileL1")),
0052 minGoodPixelCharge_(0),
0053 minGoodStripCharge_(clusterChargeCut(iConfig)),
0054 isPhase2_(iConfig.getParameter<bool>("isPhase2")),
0055 cutOnPixelCharge_(false),
0056 cutOnStripCharge_(minGoodStripCharge_ > 0),
0057 cutOnPixelShape_(iConfig.getParameter<bool>("doPixelShapeCut")),
0058 cutOnStripShape_(iConfig.getParameter<bool>("doStripShapeCut")) {
0059 std::string componentName = iConfig.getParameter<std::string>("ComponentName");
0060
0061 edm::LogInfo("ClusterShapeHitFilterESProducer") << " with name: " << componentName;
0062
0063 auto cc = setWhatProduced(this, componentName);
0064 fieldToken_ = cc.consumes();
0065 geoToken_ = cc.consumes();
0066 topolToken_ = cc.consumes();
0067 pixelToken_ = cc.consumes();
0068 if (!isPhase2_) {
0069 stripToken_ = cc.consumes();
0070 }
0071 }
0072
0073
0074 ClusterShapeHitFilterESProducer::ReturnType ClusterShapeHitFilterESProducer::produce(
0075 const ClusterShapeHitFilter::Record& iRecord) {
0076 using namespace edm::es;
0077
0078 const SiStripLorentzAngle* theSiStripLorentzAngle = nullptr;
0079 if (!isPhase2_) {
0080 theSiStripLorentzAngle = &iRecord.get(stripToken_);
0081 }
0082
0083
0084 ClusterShapeHitFilterESProducer::ReturnType aFilter(new ClusterShapeHitFilter(&iRecord.get(geoToken_),
0085 &iRecord.get(topolToken_),
0086 &iRecord.get(fieldToken_),
0087 &iRecord.get(pixelToken_),
0088 theSiStripLorentzAngle,
0089 pixelShapeFile,
0090 pixelShapeFileL1));
0091
0092 aFilter->setShapeCuts(cutOnPixelShape_, cutOnStripShape_);
0093 aFilter->setChargeCuts(cutOnPixelCharge_, minGoodPixelCharge_, cutOnStripCharge_, minGoodStripCharge_);
0094 return aFilter;
0095 }
0096
0097
0098 void ClusterShapeHitFilterESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0099 edm::ParameterSetDescription desc;
0100 desc.add<std::string>("PixelShapeFile", "RecoTracker/PixelLowPtUtilities/data/pixelShapePhase0.par");
0101 desc.add<std::string>("PixelShapeFileL1", "RecoTracker/PixelLowPtUtilities/data/pixelShapePhase0.par");
0102 desc.add<std::string>("ComponentName", "");
0103 desc.add<bool>("isPhase2", false);
0104 desc.add<bool>("doPixelShapeCut", true);
0105 desc.add<bool>("doStripShapeCut", true);
0106 desc.add<edm::ParameterSetDescription>("clusterChargeCut", getConfigurationDescription4CCC(CCC::kNone));
0107 descriptions.addWithDefaultLabel(desc);
0108 }
0109
0110 DEFINE_FWK_EVENTSETUP_MODULE(ClusterShapeHitFilterESProducer);