Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-05 07:05:39

0001 #include "RecoLocalTracker/SiPixelRecHits/interface/PixelCPEGeneric.h"
0002 #include "RecoLocalTracker/SiPixelRecHits/interface/PixelCPEGenericForBricked.h"
0003 #include "MagneticField/Engine/interface/MagneticField.h"
0004 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0005 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0006 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0007 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0008 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0009 #include "RecoLocalTracker/Records/interface/TkPixelCPERecord.h"
0010 #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h"
0011 
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/Framework/interface/ESHandle.h"
0014 #include "FWCore/Framework/interface/ModuleFactory.h"
0015 #include "FWCore/Framework/interface/ESProducer.h"
0016 
0017 // new record
0018 #include "CondFormats/DataRecord/interface/SiPixelGenErrorDBObjectRcd.h"
0019 
0020 #include <string>
0021 #include <memory>
0022 
0023 class PixelCPEGenericESProducer : public edm::ESProducer {
0024 public:
0025   PixelCPEGenericESProducer(const edm::ParameterSet& p);
0026   std::unique_ptr<PixelClusterParameterEstimator> produce(const TkPixelCPERecord&);
0027   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0028 
0029 private:
0030   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magfieldToken_;
0031   edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> pDDToken_;
0032   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> hTTToken_;
0033   edm::ESGetToken<SiPixelLorentzAngle, SiPixelLorentzAngleRcd> lorentzAngleToken_;
0034   edm::ESGetToken<SiPixelLorentzAngle, SiPixelLorentzAngleRcd> lorentzAngleWidthToken_;
0035   edm::ESGetToken<SiPixelGenErrorDBObject, SiPixelGenErrorDBObjectRcd> genErrorDBObjectToken_;
0036 
0037   edm::ParameterSet pset_;
0038   bool useLAWidthFromDB_;
0039   bool UseErrorsFromTemplates_;
0040   std::string CPEgenericMode_;  // user's choice of CPE generic
0041 };
0042 
0043 using namespace edm;
0044 
0045 PixelCPEGenericESProducer::PixelCPEGenericESProducer(const edm::ParameterSet& p) {
0046   CPEgenericMode_ = p.getParameter<std::string>("ComponentName");
0047   // Use LA-width from DB. If both (upper and this) are false LA-width is calcuated from LA-offset
0048   useLAWidthFromDB_ = p.getParameter<bool>("useLAWidthFromDB");
0049   // Use Alignment LA-offset
0050   const bool doLorentzFromAlignment = p.getParameter<bool>("doLorentzFromAlignment");
0051   char const* laLabel = "";  // standard LA, from calibration, label=""
0052   if (doLorentzFromAlignment) {
0053     laLabel = "fromAlignment";
0054   }
0055 
0056   auto magname = p.getParameter<edm::ESInputTag>("MagneticFieldRecord");
0057   UseErrorsFromTemplates_ = p.getParameter<bool>("UseErrorsFromTemplates");
0058 
0059   pset_ = p;
0060   auto c = setWhatProduced(this, CPEgenericMode_);
0061   magfieldToken_ = c.consumes(magname);
0062   pDDToken_ = c.consumes();
0063   hTTToken_ = c.consumes();
0064   lorentzAngleToken_ = c.consumes(edm::ESInputTag("", laLabel));
0065   if (useLAWidthFromDB_) {
0066     lorentzAngleWidthToken_ = c.consumes(edm::ESInputTag("", "forWidth"));
0067   }
0068   if (UseErrorsFromTemplates_) {
0069     genErrorDBObjectToken_ = c.consumes();
0070   }
0071 }
0072 
0073 std::unique_ptr<PixelClusterParameterEstimator> PixelCPEGenericESProducer::produce(const TkPixelCPERecord& iRecord) {
0074   // add the new la width object
0075   const SiPixelLorentzAngle* lorentzAngleWidthProduct = nullptr;
0076   if (useLAWidthFromDB_) {  // use the width LA
0077     lorentzAngleWidthProduct = &iRecord.get(lorentzAngleWidthToken_);
0078   }
0079   //std::cout<<" la width "<<lorentzAngleWidthProduct<<std::endl; //dk
0080 
0081   const SiPixelGenErrorDBObject* genErrorDBObjectProduct = nullptr;
0082 
0083   // Errors take only from new GenError
0084   if (UseErrorsFromTemplates_) {  // do only when generrors are needed
0085     genErrorDBObjectProduct = &iRecord.get(genErrorDBObjectToken_);
0086     //} else {
0087     //std::cout<<" pass an empty GenError pointer"<<std::endl;
0088   }
0089 
0090   return (CPEgenericMode_ == "PixelCPEGenericForBricked")
0091              ? std::make_unique<PixelCPEGenericForBricked>(pset_,
0092                                                            &iRecord.get(magfieldToken_),
0093                                                            iRecord.get(pDDToken_),
0094                                                            iRecord.get(hTTToken_),
0095                                                            &iRecord.get(lorentzAngleToken_),
0096                                                            genErrorDBObjectProduct,
0097                                                            lorentzAngleWidthProduct)
0098              : std::make_unique<PixelCPEGeneric>(pset_,
0099                                                  &iRecord.get(magfieldToken_),
0100                                                  iRecord.get(pDDToken_),
0101                                                  iRecord.get(hTTToken_),
0102                                                  &iRecord.get(lorentzAngleToken_),
0103                                                  genErrorDBObjectProduct,
0104                                                  lorentzAngleWidthProduct);
0105 }
0106 
0107 void PixelCPEGenericESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0108   edm::ParameterSetDescription desc;
0109 
0110   // from PixelCPEBase
0111   PixelCPEBase::fillPSetDescription(desc);
0112 
0113   // from PixelCPEGeneric
0114   PixelCPEGeneric::fillPSetDescription(desc);
0115 
0116   // specific to PixelCPEGenericESProducer
0117   desc.add<std::string>("ComponentName", "PixelCPEGeneric");
0118   desc.add<edm::ESInputTag>("MagneticFieldRecord", edm::ESInputTag(""));
0119   descriptions.add("_generic_default", desc);
0120 }
0121 
0122 DEFINE_FWK_EVENTSETUP_MODULE(PixelCPEGenericESProducer);