Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-20 23:14:36

0001 #include "MeasurementTrackerImpl.h"
0002 
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/Framework/interface/ESHandle.h"
0005 #include "FWCore/Framework/interface/ModuleFactory.h"
0006 #include "FWCore/Framework/interface/ESProducer.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 
0009 #include "RecoLocalTracker/ClusterParameterEstimator/interface/StripClusterParameterEstimator.h"
0010 #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h"
0011 #include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h"
0012 #include "RecoLocalTracker/SiStripRecHitConverter/interface/SiStripRecHitMatcher.h"
0013 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0014 #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h"
0015 #include "RecoTracker/Record/interface/CkfComponentsRecord.h"
0016 #include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h"
0017 
0018 #include "RecoLocalTracker/Records/interface/TrackerCPERecord.h"
0019 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0020 #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
0021 
0022 #include "CondFormats/DataRecord/interface/SiStripNoisesRcd.h"
0023 #include "CondFormats/SiStripObjects/interface/SiStripNoises.h"
0024 
0025 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
0026 #include "CalibTracker/Records/interface/SiStripQualityRcd.h"
0027 #include "CondFormats/DataRecord/interface/SiPixelQualityRcd.h"
0028 #include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h"
0029 
0030 #include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h"
0031 #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
0032 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h"
0033 
0034 #include <string>
0035 #include <memory>
0036 
0037 class dso_hidden MeasurementTrackerESProducer : public edm::ESProducer {
0038 public:
0039   MeasurementTrackerESProducer(const edm::ParameterSet &p);
0040   ~MeasurementTrackerESProducer() override;
0041   std::unique_ptr<MeasurementTracker> produce(const CkfComponentsRecord &);
0042 
0043   static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
0044 
0045 private:
0046   edm::ESGetToken<SiPixelQuality, SiPixelQualityRcd> pixelQualityToken_;
0047   edm::ESGetToken<SiPixelFedCablingMap, SiPixelFedCablingMapRcd> pixelCablingToken_;
0048   edm::ESGetToken<SiStripQuality, SiStripQualityRcd> stripQualityToken_;
0049 
0050   edm::ESGetToken<PixelClusterParameterEstimator, TkPixelCPERecord> pixelCPEToken_;
0051   edm::ESGetToken<StripClusterParameterEstimator, TkStripCPERecord> stripCPEToken_;
0052   edm::ESGetToken<SiStripRecHitMatcher, TkStripCPERecord> hitMatcherToken_;
0053   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> trackerTopologyToken_;
0054   edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeomToken_;
0055   edm::ESGetToken<GeometricSearchTracker, TrackerRecoGeometryRecord> geometricSearchTrackerToken_;
0056   edm::ESGetToken<ClusterParameterEstimator<Phase2TrackerCluster1D>, TkPhase2OTCPERecord> phase2TrackerCPEToken_;
0057 
0058   MeasurementTrackerImpl::BadStripCutsDet badStripCuts_;
0059 
0060   int pixelQualityFlags_;
0061   int pixelQualityDebugFlags_;
0062 
0063   int stripQualityFlags_;
0064   int stripQualityDebugFlags_;
0065 
0066   bool usePhase2_ = false;
0067 };
0068 
0069 using namespace edm;
0070 
0071 namespace {
0072   std::pair<int, int> stripFlags(const edm::ParameterSet &pset) {
0073     int stripQualityFlags = 0;
0074     int stripQualityDebugFlags = 0;
0075 
0076     if (pset.getParameter<bool>("UseStripModuleQualityDB")) {
0077       stripQualityFlags += MeasurementTracker::BadModules;
0078       if (pset.getUntrackedParameter<bool>("DebugStripModuleQualityDB", false)) {
0079         stripQualityDebugFlags += MeasurementTracker::BadModules;
0080       }
0081     }
0082     if (pset.getParameter<bool>("UseStripAPVFiberQualityDB")) {
0083       stripQualityFlags += MeasurementTracker::BadAPVFibers;
0084       if (pset.getUntrackedParameter<bool>("DebugStripAPVFiberQualityDB", false)) {
0085         stripQualityDebugFlags += MeasurementTracker::BadAPVFibers;
0086       }
0087       if (pset.getParameter<bool>("MaskBadAPVFibers")) {
0088         stripQualityFlags += MeasurementTracker::MaskBad128StripBlocks;
0089       }
0090     }
0091     if (pset.getParameter<bool>("UseStripStripQualityDB")) {
0092       stripQualityFlags += MeasurementTracker::BadStrips;
0093       if (pset.getUntrackedParameter<bool>("DebugStripStripQualityDB", false)) {
0094         stripQualityDebugFlags += MeasurementTracker::BadStrips;
0095       }
0096     }
0097     return std::make_pair(stripQualityFlags, stripQualityDebugFlags);
0098   }
0099 
0100   std::pair<int, int> pixelFlags(const edm::ParameterSet &pset) {
0101     int pixelQualityFlags = 0;
0102     int pixelQualityDebugFlags = 0;
0103 
0104     if (pset.getParameter<bool>("UsePixelModuleQualityDB")) {
0105       pixelQualityFlags += MeasurementTracker::BadModules;
0106       if (pset.getUntrackedParameter<bool>("DebugPixelModuleQualityDB", false)) {
0107         pixelQualityDebugFlags += MeasurementTracker::BadModules;
0108       }
0109     }
0110     if (pset.getParameter<bool>("UsePixelROCQualityDB")) {
0111       pixelQualityFlags += MeasurementTracker::BadROCs;
0112       if (pset.getUntrackedParameter<bool>("DebugPixelROCQualityDB", false)) {
0113         pixelQualityDebugFlags += MeasurementTracker::BadROCs;
0114       }
0115     }
0116 
0117     return std::make_pair(pixelQualityFlags, pixelQualityDebugFlags);
0118   }
0119 }  // namespace
0120 
0121 MeasurementTrackerESProducer::MeasurementTrackerESProducer(const edm::ParameterSet &p) {
0122   std::string myname = p.getParameter<std::string>("ComponentName");
0123 
0124   auto c = setWhatProduced(this, myname);
0125 
0126   std::tie(pixelQualityFlags_, pixelQualityDebugFlags_) = pixelFlags(p);
0127   if (pixelQualityFlags_ != 0) {
0128     pixelQualityToken_ = c.consumes();
0129     pixelCablingToken_ = c.consumes();
0130   }
0131 
0132   std::tie(stripQualityFlags_, stripQualityDebugFlags_) = stripFlags(p);
0133   if (stripQualityFlags_ != 0) {
0134     stripQualityToken_ = c.consumes(edm::ESInputTag("", p.getParameter<std::string>("SiStripQualityLabel")));
0135     if (stripQualityFlags_ & MeasurementTrackerImpl::BadStrips) {
0136       auto makeBadStripCuts = [](edm::ParameterSet const &pset) {
0137         return StMeasurementConditionSet::BadStripCuts(pset.getParameter<uint32_t>("maxBad"),
0138                                                        pset.getParameter<uint32_t>("maxConsecutiveBad"));
0139       };
0140 
0141       auto cutPset = p.getParameter<edm::ParameterSet>("badStripCuts");
0142       badStripCuts_.tib = makeBadStripCuts(cutPset.getParameter<edm::ParameterSet>("TIB"));
0143       badStripCuts_.tob = makeBadStripCuts(cutPset.getParameter<edm::ParameterSet>("TOB"));
0144       badStripCuts_.tid = makeBadStripCuts(cutPset.getParameter<edm::ParameterSet>("TID"));
0145       badStripCuts_.tec = makeBadStripCuts(cutPset.getParameter<edm::ParameterSet>("TEC"));
0146     }
0147   }
0148 
0149   pixelCPEToken_ = c.consumes(edm::ESInputTag("", p.getParameter<std::string>("PixelCPE")));
0150   hitMatcherToken_ = c.consumes(edm::ESInputTag("", p.getParameter<std::string>("HitMatcher")));
0151   trackerTopologyToken_ = c.consumes();
0152   trackerGeomToken_ = c.consumes();
0153   geometricSearchTrackerToken_ = c.consumes();
0154 
0155   //FIXME:: just temporary solution for phase2!
0156   auto phase2 = p.getParameter<std::string>("Phase2StripCPE");
0157   if (not phase2.empty()) {
0158     usePhase2_ = true;
0159     phase2TrackerCPEToken_ = c.consumes(edm::ESInputTag("", phase2));
0160   } else {
0161     stripCPEToken_ = c.consumes(edm::ESInputTag("", p.getParameter<std::string>("StripCPE")));
0162   }
0163 }
0164 
0165 MeasurementTrackerESProducer::~MeasurementTrackerESProducer() {}
0166 
0167 std::unique_ptr<MeasurementTracker> MeasurementTrackerESProducer::produce(const CkfComponentsRecord &iRecord) {
0168   // ========= SiPixelQuality related tasks =============
0169   const SiPixelQuality *ptr_pixelQuality = nullptr;
0170   const SiPixelFedCabling *ptr_pixelCabling = nullptr;
0171 
0172   if (pixelQualityFlags_ != 0) {
0173     ptr_pixelQuality = &iRecord.get(pixelQualityToken_);
0174     ptr_pixelCabling = &iRecord.get(pixelCablingToken_);
0175   }
0176 
0177   // ========= SiStripQuality related tasks =============
0178   const SiStripQuality *ptr_stripQuality = nullptr;
0179   if (stripQualityFlags_ != 0) {
0180     ptr_stripQuality = &iRecord.get(stripQualityToken_);
0181   }
0182 
0183   const ClusterParameterEstimator<Phase2TrackerCluster1D> *ptr_phase2TrackerCPE = nullptr;
0184   const StripClusterParameterEstimator *ptr_SiStripTrackerCPE = nullptr;
0185   if (usePhase2_) {
0186     ptr_phase2TrackerCPE = &iRecord.get(phase2TrackerCPEToken_);
0187   } else {
0188     ptr_SiStripTrackerCPE = &iRecord.get(stripCPEToken_);
0189   }
0190   return std::make_unique<MeasurementTrackerImpl>(badStripCuts_,
0191                                                   &iRecord.get(pixelCPEToken_),
0192                                                   ptr_SiStripTrackerCPE,
0193                                                   &iRecord.get(hitMatcherToken_),
0194                                                   &iRecord.get(trackerTopologyToken_),
0195                                                   &iRecord.get(trackerGeomToken_),
0196                                                   &iRecord.get(geometricSearchTrackerToken_),
0197                                                   ptr_stripQuality,
0198                                                   stripQualityFlags_,
0199                                                   stripQualityDebugFlags_,
0200                                                   ptr_pixelQuality,
0201                                                   ptr_pixelCabling,
0202                                                   pixelQualityFlags_,
0203                                                   pixelQualityDebugFlags_,
0204                                                   ptr_phase2TrackerCPE);
0205 }
0206 
0207 void MeasurementTrackerESProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
0208   edm::ParameterSetDescription desc;
0209 
0210   desc.add<std::string>("ComponentName", "");
0211 
0212   desc.add<std::string>("PixelCPE", "PixelCPEGeneric");
0213   desc.add<std::string>("StripCPE", "StripCPEfromTrackAngle");
0214   desc.add<std::string>("HitMatcher", "StandardMatcher");
0215 
0216   desc.add<std::string>("Phase2StripCPE", "")->setComment("empty string used to turn off Phase 2");
0217 
0218   desc.add<std::string>("SiStripQualityLabel", "");
0219   desc.add<bool>("UseStripModuleQualityDB", true);
0220   desc.addUntracked<bool>("DebugStripModuleQualityDB", false)->setComment("Dump out info on module status");
0221   desc.add<bool>("UseStripAPVFiberQualityDB", true)->setComment("Read APV and Fiber status from SiStripQuality");
0222   desc.addUntracked<bool>("DebugStripAPVFiberQualityDB", false)->setComment("Dump out info on module status");
0223   desc.add<bool>("MaskBadAPVFibers", true)
0224       ->setComment(
0225           "if set to true, clusters with barycenter on bad APV and Fibers are ignored. (UseStripAPVFiberQualityDB must "
0226           "also be true for this to work)");
0227 
0228   desc.add<bool>("UseStripStripQualityDB", true)->setComment("read Strip status from SiStripQuality");
0229   desc.addUntracked<bool>("DebugStripStripQualityDB", false)->setComment("dump out info on module status");
0230 
0231   {
0232     //used by MeasurementTrackerImpl
0233     edm::ParameterSetDescription badStripCutsDesc;
0234     badStripCutsDesc.add<uint32_t>("maxBad", 4);
0235     badStripCutsDesc.add<uint32_t>("maxConsecutiveBad", 2);
0236 
0237     edm::ParameterSetDescription mtiDesc;
0238     mtiDesc.add<edm::ParameterSetDescription>("TIB", badStripCutsDesc);
0239     mtiDesc.add<edm::ParameterSetDescription>("TOB", badStripCutsDesc);
0240     mtiDesc.add<edm::ParameterSetDescription>("TID", badStripCutsDesc);
0241     mtiDesc.add<edm::ParameterSetDescription>("TEC", badStripCutsDesc);
0242 
0243     desc.addOptional<edm::ParameterSetDescription>("badStripCuts", mtiDesc);
0244   }
0245 
0246   desc.add<bool>("UsePixelModuleQualityDB", true)->setComment("Use DB info at the module level (that is, detid level)");
0247   desc.addUntracked<bool>("DebugPixelModuleQualityDB", false)->setComment("dump out info on module status");
0248   desc.add<bool>("UsePixelROCQualityDB", true)->setComment("Use DB info at the ROC level");
0249   desc.addUntracked<bool>("DebugPixelROCQualityDB", false)->setComment("dump out info om module status ");
0250 
0251   descriptions.add("_MeasurementTrackerESProducer_default", desc);
0252 }
0253 
0254 DEFINE_FWK_EVENTSETUP_MODULE(MeasurementTrackerESProducer);