Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:28:10

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   }
0130 
0131   std::tie(stripQualityFlags_, stripQualityDebugFlags_) = stripFlags(p);
0132   if (stripQualityFlags_ != 0) {
0133     stripQualityToken_ = c.consumes(edm::ESInputTag("", p.getParameter<std::string>("SiStripQualityLabel")));
0134     if (stripQualityFlags_ & MeasurementTrackerImpl::BadStrips) {
0135       auto makeBadStripCuts = [](edm::ParameterSet const &pset) {
0136         return StMeasurementConditionSet::BadStripCuts(pset.getParameter<uint32_t>("maxBad"),
0137                                                        pset.getParameter<uint32_t>("maxConsecutiveBad"));
0138       };
0139 
0140       auto cutPset = p.getParameter<edm::ParameterSet>("badStripCuts");
0141       badStripCuts_.tib = makeBadStripCuts(cutPset.getParameter<edm::ParameterSet>("TIB"));
0142       badStripCuts_.tob = makeBadStripCuts(cutPset.getParameter<edm::ParameterSet>("TOB"));
0143       badStripCuts_.tid = makeBadStripCuts(cutPset.getParameter<edm::ParameterSet>("TID"));
0144       badStripCuts_.tec = makeBadStripCuts(cutPset.getParameter<edm::ParameterSet>("TEC"));
0145     }
0146   }
0147 
0148   pixelCPEToken_ = c.consumes(edm::ESInputTag("", p.getParameter<std::string>("PixelCPE")));
0149   hitMatcherToken_ = c.consumes(edm::ESInputTag("", p.getParameter<std::string>("HitMatcher")));
0150   trackerTopologyToken_ = c.consumes();
0151   trackerGeomToken_ = c.consumes();
0152   geometricSearchTrackerToken_ = c.consumes();
0153 
0154   //FIXME:: just temporary solution for phase2!
0155   auto phase2 = p.getParameter<std::string>("Phase2StripCPE");
0156   if (not phase2.empty()) {
0157     usePhase2_ = true;
0158     phase2TrackerCPEToken_ = c.consumes(edm::ESInputTag("", phase2));
0159   } else {
0160     stripCPEToken_ = c.consumes(edm::ESInputTag("", p.getParameter<std::string>("StripCPE")));
0161     if (pixelQualityFlags_ != 0) {
0162       pixelCablingToken_ = c.consumes();
0163     }
0164   }
0165 }
0166 
0167 MeasurementTrackerESProducer::~MeasurementTrackerESProducer() {}
0168 
0169 std::unique_ptr<MeasurementTracker> MeasurementTrackerESProducer::produce(const CkfComponentsRecord &iRecord) {
0170   // ========= SiPixelQuality related tasks =============
0171   const SiPixelQuality *ptr_pixelQuality = nullptr;
0172   const SiPixelFedCabling *ptr_pixelCabling = nullptr;
0173 
0174   if (pixelQualityFlags_ != 0) {
0175     ptr_pixelQuality = &iRecord.get(pixelQualityToken_);
0176     if (!usePhase2_) {
0177       ptr_pixelCabling = &iRecord.get(pixelCablingToken_);
0178     }
0179   }
0180 
0181   // ========= SiStripQuality related tasks =============
0182   const SiStripQuality *ptr_stripQuality = nullptr;
0183   if (stripQualityFlags_ != 0) {
0184     ptr_stripQuality = &iRecord.get(stripQualityToken_);
0185   }
0186 
0187   const ClusterParameterEstimator<Phase2TrackerCluster1D> *ptr_phase2TrackerCPE = nullptr;
0188   const StripClusterParameterEstimator *ptr_SiStripTrackerCPE = nullptr;
0189   if (usePhase2_) {
0190     ptr_phase2TrackerCPE = &iRecord.get(phase2TrackerCPEToken_);
0191   } else {
0192     ptr_SiStripTrackerCPE = &iRecord.get(stripCPEToken_);
0193   }
0194   return std::make_unique<MeasurementTrackerImpl>(badStripCuts_,
0195                                                   &iRecord.get(pixelCPEToken_),
0196                                                   ptr_SiStripTrackerCPE,
0197                                                   &iRecord.get(hitMatcherToken_),
0198                                                   &iRecord.get(trackerTopologyToken_),
0199                                                   &iRecord.get(trackerGeomToken_),
0200                                                   &iRecord.get(geometricSearchTrackerToken_),
0201                                                   ptr_stripQuality,
0202                                                   stripQualityFlags_,
0203                                                   stripQualityDebugFlags_,
0204                                                   ptr_pixelQuality,
0205                                                   ptr_pixelCabling,
0206                                                   pixelQualityFlags_,
0207                                                   pixelQualityDebugFlags_,
0208                                                   ptr_phase2TrackerCPE);
0209 }
0210 
0211 void MeasurementTrackerESProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
0212   edm::ParameterSetDescription desc;
0213 
0214   desc.add<std::string>("ComponentName", "");
0215 
0216   desc.add<std::string>("PixelCPE", "PixelCPEGeneric");
0217   desc.add<std::string>("StripCPE", "StripCPEfromTrackAngle");
0218   desc.add<std::string>("HitMatcher", "StandardMatcher");
0219 
0220   desc.add<std::string>("Phase2StripCPE", "")->setComment("empty string used to turn off Phase 2");
0221 
0222   desc.add<std::string>("SiStripQualityLabel", "");
0223   desc.add<bool>("UseStripModuleQualityDB", true);
0224   desc.addUntracked<bool>("DebugStripModuleQualityDB", false)->setComment("Dump out info on module status");
0225   desc.add<bool>("UseStripAPVFiberQualityDB", true)->setComment("Read APV and Fiber status from SiStripQuality");
0226   desc.addUntracked<bool>("DebugStripAPVFiberQualityDB", false)->setComment("Dump out info on module status");
0227   desc.add<bool>("MaskBadAPVFibers", true)
0228       ->setComment(
0229           "if set to true, clusters with barycenter on bad APV and Fibers are ignored. (UseStripAPVFiberQualityDB must "
0230           "also be true for this to work)");
0231 
0232   desc.add<bool>("UseStripStripQualityDB", true)->setComment("read Strip status from SiStripQuality");
0233   desc.addUntracked<bool>("DebugStripStripQualityDB", false)->setComment("dump out info on module status");
0234 
0235   {
0236     //used by MeasurementTrackerImpl
0237     edm::ParameterSetDescription badStripCutsDesc;
0238     badStripCutsDesc.add<uint32_t>("maxBad", 4);
0239     badStripCutsDesc.add<uint32_t>("maxConsecutiveBad", 2);
0240 
0241     edm::ParameterSetDescription mtiDesc;
0242     mtiDesc.add<edm::ParameterSetDescription>("TIB", badStripCutsDesc);
0243     mtiDesc.add<edm::ParameterSetDescription>("TOB", badStripCutsDesc);
0244     mtiDesc.add<edm::ParameterSetDescription>("TID", badStripCutsDesc);
0245     mtiDesc.add<edm::ParameterSetDescription>("TEC", badStripCutsDesc);
0246 
0247     desc.addOptional<edm::ParameterSetDescription>("badStripCuts", mtiDesc);
0248   }
0249 
0250   desc.add<bool>("UsePixelModuleQualityDB", true)->setComment("Use DB info at the module level (that is, detid level)");
0251   desc.addUntracked<bool>("DebugPixelModuleQualityDB", false)->setComment("dump out info on module status");
0252   desc.add<bool>("UsePixelROCQualityDB", true)->setComment("Use DB info at the ROC level");
0253   desc.addUntracked<bool>("DebugPixelROCQualityDB", false)->setComment("dump out info om module status ");
0254 
0255   descriptions.add("_MeasurementTrackerESProducer_default", desc);
0256 }
0257 
0258 DEFINE_FWK_EVENTSETUP_MODULE(MeasurementTrackerESProducer);