Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-20 22:34:34

0001 #include <memory>
0002 #include <string>
0003 
0004 #include "CondFormats/DataRecord/interface/SiPixelGenErrorDBObjectRcd.h"
0005 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0006 #include "FWCore/Framework/interface/ESHandle.h"
0007 #include "FWCore/Framework/interface/ESProducer.h"
0008 #include "FWCore/Framework/interface/EventSetup.h"
0009 #include "FWCore/Framework/interface/ModuleFactory.h"
0010 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0011 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0012 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0013 #include "MagneticField/Engine/interface/MagneticField.h"
0014 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0015 #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h"
0016 #include "RecoLocalTracker/Records/interface/TkPixelCPERecord.h"
0017 #include "RecoLocalTracker/SiPixelRecHits/interface/PixelCPEFast.h"
0018 
0019 class PixelCPEFastESProducer : public edm::ESProducer {
0020 public:
0021   PixelCPEFastESProducer(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<SiPixelLorentzAngle, SiPixelLorentzAngleRcd> lorentzAngleWidthToken_;
0031   edm::ESGetToken<SiPixelGenErrorDBObject, SiPixelGenErrorDBObjectRcd> genErrorDBObjectToken_;
0032 
0033   edm::ParameterSet pset_;
0034   bool useErrorsFromTemplates_;
0035 };
0036 
0037 using namespace edm;
0038 
0039 PixelCPEFastESProducer::PixelCPEFastESProducer(const edm::ParameterSet& p) : pset_(p) {
0040   auto const& myname = p.getParameter<std::string>("ComponentName");
0041   auto const& magname = p.getParameter<edm::ESInputTag>("MagneticFieldRecord");
0042   useErrorsFromTemplates_ = p.getParameter<bool>("UseErrorsFromTemplates");
0043 
0044   auto cc = setWhatProduced(this, myname);
0045   magfieldToken_ = cc.consumes(magname);
0046   pDDToken_ = cc.consumes();
0047   hTTToken_ = cc.consumes();
0048   lorentzAngleToken_ = cc.consumes(edm::ESInputTag(""));
0049   lorentzAngleWidthToken_ = cc.consumes(edm::ESInputTag("", "forWidth"));
0050   if (useErrorsFromTemplates_) {
0051     genErrorDBObjectToken_ = cc.consumes();
0052   }
0053 }
0054 
0055 std::unique_ptr<PixelClusterParameterEstimator> PixelCPEFastESProducer::produce(const TkPixelCPERecord& iRecord) {
0056   // add the new la width object
0057   const SiPixelLorentzAngle* lorentzAngleWidthProduct = nullptr;
0058   lorentzAngleWidthProduct = &iRecord.get(lorentzAngleWidthToken_);
0059 
0060   const SiPixelGenErrorDBObject* genErrorDBObjectProduct = nullptr;
0061 
0062   // Errors take only from new GenError
0063   if (useErrorsFromTemplates_) {  // do only when generrors are needed
0064     genErrorDBObjectProduct = &iRecord.get(genErrorDBObjectToken_);
0065     //} else {
0066     //std::cout<<" pass an empty GenError pointer"<<std::endl;
0067   }
0068   return std::make_unique<PixelCPEFast>(pset_,
0069                                         &iRecord.get(magfieldToken_),
0070                                         iRecord.get(pDDToken_),
0071                                         iRecord.get(hTTToken_),
0072                                         &iRecord.get(lorentzAngleToken_),
0073                                         genErrorDBObjectProduct,
0074                                         lorentzAngleWidthProduct);
0075 }
0076 
0077 void PixelCPEFastESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0078   edm::ParameterSetDescription desc;
0079 
0080   // from PixelCPEBase
0081   PixelCPEBase::fillPSetDescription(desc);
0082 
0083   // from PixelCPEFast
0084   PixelCPEFast::fillPSetDescription(desc);
0085 
0086   // used by PixelCPEFast
0087   desc.add<double>("EdgeClusterErrorX", 50.0);
0088   desc.add<double>("EdgeClusterErrorY", 85.0);
0089   desc.add<bool>("UseErrorsFromTemplates", true);
0090   desc.add<bool>("TruncatePixelCharge", true);
0091 
0092   // specific to PixelCPEFastESProducer
0093   desc.add<std::string>("ComponentName", "PixelCPEFast");
0094   desc.add<edm::ESInputTag>("MagneticFieldRecord", edm::ESInputTag());
0095 
0096   descriptions.add("PixelCPEFastESProducer", desc);
0097 }
0098 
0099 DEFINE_FWK_EVENTSETUP_MODULE(PixelCPEFastESProducer);