Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 10:00:38

0001 #include "RecoLocalTracker/SiPixelRecHits/interface/PixelCPETemplateReco.h"
0002 #include "RecoLocalTracker/Records/interface/TkPixelCPERecord.h"
0003 #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h"
0004 #include "MagneticField/Engine/interface/MagneticField.h"
0005 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0006 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0007 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0008 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0009 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0010 
0011 #include "FWCore/Framework/interface/EventSetup.h"
0012 #include "FWCore/Framework/interface/ESHandle.h"
0013 #include "FWCore/Framework/interface/ModuleFactory.h"
0014 #include "FWCore/Framework/interface/ESProducer.h"
0015 
0016 #include <string>
0017 #include <memory>
0018 
0019 class PixelCPETemplateRecoESProducer : public edm::ESProducer {
0020 public:
0021   PixelCPETemplateRecoESProducer(const edm::ParameterSet& p);
0022   std::unique_ptr<PixelClusterParameterEstimator> produce(const TkPixelCPERecord&);
0023   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0024 
0025 private:
0026   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magfieldToken_;
0027   edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> pDDToken_;
0028   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> hTTToken_;
0029   edm::ESGetToken<SiPixelLorentzAngle, SiPixelLorentzAngleRcd> lorentzAngleToken_;
0030   edm::ESGetToken<SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcd> templateDBobjectToken_;
0031   edm::ESGetToken<std::vector<SiPixelTemplateStore>, SiPixelTemplateDBObjectESProducerRcd> templateStoreToken_;
0032 
0033   edm::ParameterSet pset_;
0034   bool doLorentzFromAlignment_;
0035   bool useLAFromDB_;
0036 };
0037 
0038 using namespace edm;
0039 
0040 PixelCPETemplateRecoESProducer::PixelCPETemplateRecoESProducer(const edm::ParameterSet& p) {
0041   std::string myname = p.getParameter<std::string>("ComponentName");
0042 
0043   useLAFromDB_ = p.getParameter<bool>("useLAFromDB");
0044   doLorentzFromAlignment_ = p.getParameter<bool>("doLorentzFromAlignment");
0045 
0046   pset_ = p;
0047   auto c = setWhatProduced(this, myname);
0048   magfieldToken_ = c.consumes();
0049   pDDToken_ = c.consumes();
0050   hTTToken_ = c.consumes();
0051   templateDBobjectToken_ = c.consumes();
0052   templateStoreToken_ = c.consumes();
0053   if (useLAFromDB_ || doLorentzFromAlignment_) {
0054     char const* laLabel = doLorentzFromAlignment_ ? "fromAlignment" : "";
0055     lorentzAngleToken_ = c.consumes(edm::ESInputTag("", laLabel));
0056   }
0057 }
0058 
0059 std::unique_ptr<PixelClusterParameterEstimator> PixelCPETemplateRecoESProducer::produce(
0060     const TkPixelCPERecord& iRecord) {
0061   // Normal, default LA is used in case of template failure, load it unless
0062   // turned off
0063   // if turned off, null is ok, becomes zero
0064   const SiPixelLorentzAngle* lorentzAngleProduct = nullptr;
0065   if (useLAFromDB_ || doLorentzFromAlignment_) {
0066     lorentzAngleProduct = &iRecord.get(lorentzAngleToken_);
0067   }
0068 
0069   return std::make_unique<PixelCPETemplateReco>(pset_,
0070                                                 &iRecord.get(magfieldToken_),
0071                                                 iRecord.get(pDDToken_),
0072                                                 iRecord.get(hTTToken_),
0073                                                 lorentzAngleProduct,
0074                                                 &iRecord.get(templateStoreToken_),
0075                                                 &iRecord.get(templateDBobjectToken_));
0076 }
0077 
0078 void PixelCPETemplateRecoESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0079   edm::ParameterSetDescription desc;
0080 
0081   // from PixelCPEBase
0082   PixelCPEBase::fillPSetDescription(desc);
0083 
0084   // from PixelCPETemplateReco
0085   PixelCPETemplateReco::fillPSetDescription(desc);
0086 
0087   // specific to PixelCPETemplateRecoESProducer
0088   desc.add<std::string>("ComponentName", "PixelCPETemplateReco");
0089   descriptions.add("_templates_default", desc);
0090 }
0091 
0092 DEFINE_FWK_EVENTSETUP_MODULE(PixelCPETemplateRecoESProducer);