Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:24:59

0001 #include "FWCore/Framework/interface/ESProducer.h"
0002 #include "FWCore/Framework/interface/ESHandle.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "FWCore/Framework/interface/ModuleFactory.h"
0005 
0006 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0007 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0008 #include "MagneticField/Engine/interface/MagneticField.h"
0009 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0010 #include "CondFormats/DataRecord/interface/SiPhase2OuterTrackerLorentzAngleRcd.h"
0011 
0012 #include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h"
0013 #include "RecoLocalTracker/ClusterParameterEstimator/interface/ClusterParameterEstimator.h"
0014 #include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h"
0015 #include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPEGeometric.h"
0016 
0017 #include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h"
0018 
0019 #include <memory>
0020 #include <map>
0021 
0022 class Phase2StripCPEESProducer : public edm::ESProducer {
0023 public:
0024   Phase2StripCPEESProducer(const edm::ParameterSet&);
0025   std::unique_ptr<ClusterParameterEstimator<Phase2TrackerCluster1D> > produce(const TkPhase2OTCPERecord& iRecord);
0026 
0027 private:
0028   enum CPE_t { DEFAULT, GEOMETRIC };
0029 
0030   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magfieldToken_;
0031   edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> pDDToken_;
0032   edm::ESGetToken<SiPhase2OuterTrackerLorentzAngle, SiPhase2OuterTrackerLorentzAngleRcd> lorentzAngleToken_;
0033   CPE_t cpeNum_;
0034   edm::ParameterSet pset_;
0035 };
0036 
0037 Phase2StripCPEESProducer::Phase2StripCPEESProducer(const edm::ParameterSet& p) {
0038   std::string name = p.getParameter<std::string>("ComponentType");
0039 
0040   std::map<std::string, CPE_t> enumMap;
0041   enumMap[std::string("Phase2StripCPE")] = DEFAULT;
0042   enumMap[std::string("Phase2StripCPEGeometric")] = GEOMETRIC;
0043   if (enumMap.find(name) == enumMap.end())
0044     throw cms::Exception("Unknown StripCPE type") << name;
0045 
0046   cpeNum_ = enumMap[name];
0047   pset_ = p.getParameter<edm::ParameterSet>("parameters");
0048   auto c = setWhatProduced(this, name);
0049   if (cpeNum_ != GEOMETRIC) {
0050     magfieldToken_ = c.consumes();
0051     pDDToken_ = c.consumes();
0052     lorentzAngleToken_ = c.consumes();
0053   }
0054 }
0055 
0056 std::unique_ptr<ClusterParameterEstimator<Phase2TrackerCluster1D> > Phase2StripCPEESProducer::produce(
0057     const TkPhase2OTCPERecord& iRecord) {
0058   std::unique_ptr<ClusterParameterEstimator<Phase2TrackerCluster1D> > cpe_;
0059   switch (cpeNum_) {
0060     case DEFAULT:
0061       cpe_ = std::make_unique<Phase2StripCPE>(
0062           pset_, iRecord.get(magfieldToken_), iRecord.get(pDDToken_), iRecord.get(lorentzAngleToken_));
0063       break;
0064 
0065     case GEOMETRIC:
0066       cpe_ = std::make_unique<Phase2StripCPEGeometric>(pset_);
0067       break;
0068   }
0069   return cpe_;
0070 }
0071 
0072 #include "FWCore/Framework/interface/ModuleFactory.h"
0073 DEFINE_FWK_EVENTSETUP_MODULE(Phase2StripCPEESProducer);