Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:29

0001 #include "FWCore/Framework/interface/ESProducer.h"
0002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0003 #include "FWCore/Framework/interface/ModuleFactory.h"
0004 #include "FWCore/Framework/interface/ESHandle.h"
0005 #include "RecoLocalTracker/Records/interface/TkStripCPERecord.h"
0006 #include "RecoLocalTracker/ClusterParameterEstimator/interface/StripClusterParameterEstimator.h"
0007 
0008 #include "CalibTracker/Records/interface/SiStripDependentRecords.h"
0009 
0010 #include "RecoLocalTracker/SiStripRecHitConverter/interface/StripCPE.h"
0011 #include "RecoLocalTracker/SiStripRecHitConverter/interface/StripCPEfromTrackAngle.h"
0012 #include "RecoLocalTracker/SiStripRecHitConverter/interface/StripCPEgeometric.h"
0013 #include "RecoLocalTracker/ClusterParameterEstimator/interface/StripFakeCPE.h"
0014 
0015 #include "CondFormats/SiStripObjects/interface/SiStripBackPlaneCorrection.h"
0016 #include "CondFormats/SiStripObjects/interface/SiStripConfObject.h"
0017 #include "CondFormats/SiStripObjects/interface/SiStripLatency.h"
0018 
0019 class StripCPEESProducer : public edm::ESProducer {
0020 public:
0021   StripCPEESProducer(const edm::ParameterSet&);
0022   std::unique_ptr<StripClusterParameterEstimator> produce(const TkStripCPERecord&);
0023 
0024 private:
0025   enum CPE_t { SIMPLE, TRACKANGLE, GEOMETRIC, FAKE };
0026 
0027   CPE_t cpeNum;
0028   edm::ParameterSet parametersPSet;
0029 
0030   edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> pDDToken_;
0031   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magfieldToken_;
0032   edm::ESGetToken<SiStripLorentzAngle, SiStripLorentzAngleDepRcd> lorentzAngleToken_;
0033   edm::ESGetToken<SiStripBackPlaneCorrection, SiStripBackPlaneCorrectionDepRcd> backPlaneCorrectionToken_;
0034   edm::ESGetToken<SiStripConfObject, SiStripConfObjectRcd> confObjToken_;
0035   edm::ESGetToken<SiStripLatency, SiStripLatencyRcd> latencyToken_;
0036 };
0037 
0038 StripCPEESProducer::StripCPEESProducer(const edm::ParameterSet& p) {
0039   std::string name = p.getParameter<std::string>("ComponentName");
0040   std::string type = name;
0041   if (!p.exists("ComponentType"))
0042     edm::LogWarning("StripCPEESProducer") << " the CPE producer should contain a ComponentType, probably identical to "
0043                                              "ComponentName in the first step of migration. Falling back to:"
0044                                           << type;
0045   else
0046     type = p.getParameter<std::string>("ComponentType");
0047 
0048   std::map<std::string, CPE_t> enumMap;
0049   enumMap[std::string("SimpleStripCPE")] = SIMPLE;
0050   enumMap[std::string("StripCPEfromTrackAngle")] = TRACKANGLE;
0051   enumMap[std::string("StripCPEgeometric")] = GEOMETRIC;
0052   enumMap[std::string("FakeStripCPE")] = FAKE;
0053   if (enumMap.find(type) == enumMap.end())
0054     throw cms::Exception("Unknown StripCPE type") << type;
0055 
0056   cpeNum = enumMap[type];
0057   parametersPSet = (p.exists("parameters") ? p.getParameter<edm::ParameterSet>("parameters") : p);
0058   auto cc = setWhatProduced(this, name);
0059   pDDToken_ = cc.consumes();
0060   magfieldToken_ = cc.consumes();
0061   lorentzAngleToken_ = cc.consumes();
0062   backPlaneCorrectionToken_ = cc.consumes();
0063   confObjToken_ = cc.consumes();
0064   latencyToken_ = cc.consumes();
0065 }
0066 
0067 std::unique_ptr<StripClusterParameterEstimator> StripCPEESProducer::produce(const TkStripCPERecord& iRecord) {
0068   TrackerGeometry const& pDD = iRecord.get(pDDToken_);
0069   MagneticField const& magfield = iRecord.get(magfieldToken_);
0070   SiStripLorentzAngle const& lorentzAngle = iRecord.get(lorentzAngleToken_);
0071   SiStripBackPlaneCorrection const& backPlaneCorrection = iRecord.get(backPlaneCorrectionToken_);
0072   SiStripConfObject const& confObj = iRecord.get(confObjToken_);
0073   SiStripLatency const& latency = iRecord.get(latencyToken_);
0074 
0075   std::unique_ptr<StripClusterParameterEstimator> cpe;
0076 
0077   switch (cpeNum) {
0078     case SIMPLE:
0079       cpe = std::make_unique<StripCPE>(
0080           parametersPSet, magfield, pDD, lorentzAngle, backPlaneCorrection, confObj, latency);
0081       break;
0082 
0083     case TRACKANGLE:
0084       cpe = std::make_unique<StripCPEfromTrackAngle>(
0085           parametersPSet, magfield, pDD, lorentzAngle, backPlaneCorrection, confObj, latency);
0086       break;
0087 
0088     case GEOMETRIC:
0089       cpe = std::make_unique<StripCPEgeometric>(
0090           parametersPSet, magfield, pDD, lorentzAngle, backPlaneCorrection, confObj, latency);
0091       break;
0092 
0093     case FAKE:
0094       cpe = std::make_unique<StripFakeCPE>();
0095       break;
0096   }
0097 
0098   return cpe;
0099 }
0100 
0101 DEFINE_FWK_EVENTSETUP_MODULE(StripCPEESProducer);