CMS 3D CMS Logo

MkFitEventOfHitsProducer.cc
Go to the documentation of this file.
2 
6 
9 
12 
17 
20 
26 
27 // mkFit includes
31 
33 public:
34  explicit MkFitEventOfHitsProducer(edm::ParameterSet const& iConfig);
35  ~MkFitEventOfHitsProducer() override = default;
36 
37  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
38 
39 private:
40  void produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
41 
42  void fill(const std::vector<const TrackingRecHit*>& hits,
44  const MkFitGeometry& mkFitGeom) const;
45 
56  const bool usePixelQualityDB_;
58 };
59 
61  : beamSpotToken_{consumes(iConfig.getParameter<edm::InputTag>("beamSpot"))},
62  pixelHitsToken_{consumes(iConfig.getParameter<edm::InputTag>("pixelHits"))},
63  stripHitsToken_{consumes(iConfig.getParameter<edm::InputTag>("stripHits"))},
64  pixelClusterIndexToHitToken_{consumes(iConfig.getParameter<edm::InputTag>("pixelHits"))},
65  stripClusterIndexToHitToken_{consumes(iConfig.getParameter<edm::InputTag>("stripHits"))},
66  mkFitGeomToken_{esConsumes()},
67  putToken_{produces<MkFitEventOfHits>()},
68  usePixelQualityDB_{iConfig.getParameter<bool>("usePixelQualityDB")},
69  useStripStripQualityDB_{iConfig.getParameter<bool>("useStripStripQualityDB")} {
70  if (useStripStripQualityDB_ || usePixelQualityDB_)
71  geomToken_ = esConsumes();
72  if (usePixelQualityDB_) {
73  pixelQualityToken_ = esConsumes();
74  }
75  if (useStripStripQualityDB_) {
76  stripQualityToken_ = esConsumes();
77  }
78 }
79 
82 
83  desc.add("beamSpot", edm::InputTag{"offlineBeamSpot"});
84  desc.add("pixelHits", edm::InputTag{"mkFitSiPixelHits"});
85  desc.add("stripHits", edm::InputTag{"mkFitSiStripHits"});
86  desc.add("usePixelQualityDB", true)->setComment("Use SiPixelQuality DB information");
87  desc.add("useStripStripQualityDB", true)->setComment("Use SiStrip quality DB information");
88 
89  descriptions.addWithDefaultLabel(desc);
90 }
91 
93  const auto& pixelHits = iEvent.get(pixelHitsToken_);
94  const auto& stripHits = iEvent.get(stripHitsToken_);
95  const auto& mkFitGeom = iSetup.getData(mkFitGeomToken_);
96 
97  auto eventOfHits = std::make_unique<mkfit::EventOfHits>(mkFitGeom.trackerInfo());
99 
101  std::vector<mkfit::DeadVec> deadvectors(mkFitGeom.layerNumberConverter().nLayers());
102  const auto& trackerGeom = iSetup.getData(geomToken_);
103 
104  if (usePixelQualityDB_) {
105  const auto& pixelQuality = iSetup.getData(pixelQualityToken_);
106  const auto& badPixels = pixelQuality.getBadComponentList();
107  for (const auto& bp : badPixels) {
108  const DetId detid(bp.DetID);
109  const auto& surf = trackerGeom.idToDet(detid)->surface();
110  bool isBarrel = (mkFitGeom.topology()->side(detid) == static_cast<unsigned>(TrackerDetSide::Barrel));
111  const auto ilay = mkFitGeom.mkFitLayerNumber(detid);
112  const auto q1 = isBarrel ? surf.zSpan().first : surf.rSpan().first;
113  const auto q2 = isBarrel ? surf.zSpan().second : surf.rSpan().second;
114  if (bp.errorType == 0)
115  deadvectors[ilay].push_back({surf.phiSpan().first, surf.phiSpan().second, q1, q2});
116  }
117  }
118  // For Phase-2, disable (momentarily?) SiStrip quality check
120  const auto& siStripQuality = iSetup.getData(stripQualityToken_);
121  const auto& badStrips = siStripQuality.getBadComponentList();
122  for (const auto& bs : badStrips) {
123  const DetId detid(bs.detid);
124  const auto& surf = trackerGeom.idToDet(detid)->surface();
125  bool isBarrel = (mkFitGeom.topology()->side(detid) == static_cast<unsigned>(TrackerDetSide::Barrel));
126  const auto ilay = mkFitGeom.mkFitLayerNumber(detid);
127  const auto q1 = isBarrel ? surf.zSpan().first : surf.rSpan().first;
128  const auto q2 = isBarrel ? surf.zSpan().second : surf.rSpan().second;
129  if (bs.BadModule)
130  deadvectors[ilay].push_back({surf.phiSpan().first, surf.phiSpan().second, q1, q2});
131  else { //assume that BadApvs are filled in sync with BadFibers
132  auto const& topo = dynamic_cast<const StripTopology&>(trackerGeom.idToDet(detid)->topology());
133  int firstApv = -1;
134  int lastApv = -1;
135 
136  auto addRangeAPV = [&topo, &surf, &q1, &q2](int first, int last, mkfit::DeadVec& dv) {
137  auto const firstPoint = surf.toGlobal(topo.localPosition(first * sistrip::STRIPS_PER_APV));
138  auto const lastPoint = surf.toGlobal(topo.localPosition((last + 1) * sistrip::STRIPS_PER_APV));
139  float phi1 = firstPoint.phi();
140  float phi2 = lastPoint.phi();
141  if (reco::deltaPhi(phi1, phi2) > 0)
142  std::swap(phi1, phi2);
143  LogTrace("SiStripBadComponents")
144  << "insert bad range " << first << " to " << last << " " << phi1 << " " << phi2;
145  dv.push_back({phi1, phi2, q1, q2});
146  };
147 
148  const int nApvs = topo.nstrips() / sistrip::STRIPS_PER_APV;
149  for (int apv = 0; apv < nApvs; ++apv) {
150  const bool isBad = bs.BadApvs & (1 << apv);
151  if (isBad) {
152  LogTrace("SiStripBadComponents") << "bad apv " << apv << " on " << bs.detid;
153  if (lastApv == -1) {
154  firstApv = apv;
155  lastApv = apv;
156  } else if (lastApv + 1 == apv)
157  lastApv++;
158 
159  if (apv + 1 == nApvs)
160  addRangeAPV(firstApv, lastApv, deadvectors[ilay]);
161  } else if (firstApv != -1) {
162  addRangeAPV(firstApv, lastApv, deadvectors[ilay]);
163  //and reset
164  firstApv = -1;
165  lastApv = -1;
166  }
167  }
168  }
169  }
170  }
172  }
173 
174  fill(iEvent.get(pixelClusterIndexToHitToken_).hits(), *eventOfHits, mkFitGeom);
175  fill(iEvent.get(stripClusterIndexToHitToken_).hits(), *eventOfHits, mkFitGeom);
176 
178 
179  auto const bs = iEvent.get(beamSpotToken_);
180  eventOfHits->setBeamSpot(
181  mkfit::BeamSpot(bs.x0(), bs.y0(), bs.z0(), bs.sigmaZ(), bs.BeamWidthX(), bs.BeamWidthY(), bs.dxdz(), bs.dydz()));
182 
184 }
185 
186 void MkFitEventOfHitsProducer::fill(const std::vector<const TrackingRecHit*>& hits,
188  const MkFitGeometry& mkFitGeom) const {
189  for (unsigned int i = 0, end = hits.size(); i < end; ++i) {
190  const auto* hit = hits[i];
191  if (hit != nullptr) {
192  const auto ilay = mkFitGeom.mkFitLayerNumber(hit->geographicalId());
193  eventOfHits[ilay].registerHit(i);
194  }
195  }
196 }
197 
std::vector< DeadVec > deadvectors
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
MkFitEventOfHitsProducer(edm::ParameterSet const &iConfig)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
~MkFitEventOfHitsProducer() override=default
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
void cmssw_LoadHits_End(EventOfHits &eoh)
Definition: MkStdSeqs.cc:45
const edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
void cmssw_LoadHits_Begin(EventOfHits &eoh, const std::vector< const HitVec *> &orig_hitvectors)
Definition: MkStdSeqs.cc:29
#define LogTrace(id)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDPutTokenT< MkFitEventOfHits > putToken_
int iEvent
Definition: GenABIO.cc:224
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::ESGetToken< SiPixelQuality, SiPixelQualityRcd > pixelQualityToken_
void loadDeads(EventOfHits &eoh, const std::vector< DeadVec > &deadvectors)
Definition: MkStdSeqs.cc:19
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::EDGetTokenT< MkFitHitWrapper > stripHitsToken_
Definition: DetId.h:17
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
const edm::EDGetTokenT< MkFitClusterIndexToHit > pixelClusterIndexToHitToken_
const edm::ESGetToken< MkFitGeometry, TrackerRecoGeometryRecord > mkFitGeomToken_
const edm::EDGetTokenT< MkFitClusterIndexToHit > stripClusterIndexToHitToken_
Constants and enumerated types for FED/FEC systems.
const edm::EDGetTokenT< MkFitHitWrapper > pixelHitsToken_
std::vector< DeadRegion > DeadVec
Definition: DeadRegion.h:11
int mkFitLayerNumber(DetId detId) const
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > stripQualityToken_
static const uint16_t STRIPS_PER_APV
void fill(const std::vector< const TrackingRecHit *> &hits, mkfit::EventOfHits &eventOfHits, const MkFitGeometry &mkFitGeom) const
def move(src, dest)
Definition: eostools.py:511