CMS 3D CMS Logo

MeasurementTrackerImpl.cc
Go to the documentation of this file.
2 
5 
12 
14 
16 
22 
24 
29 
32 #include "TkStripMeasurementDet.h"
33 #include "TkPixelMeasurementDet.h"
35 #include "TkGluedMeasurementDet.h"
36 #include "TkStackMeasurementDet.h"
38 
41 
42 #include <iostream>
43 #include <typeinfo>
44 #include <map>
45 #include <algorithm>
46 
47 //
48 
49 using namespace std;
50 
51 namespace {
52 
53  class StrictWeakOrdering {
54  public:
55  bool operator()(uint32_t p, const uint32_t& i) const { return p < i; }
56  };
57 
58  struct CmpTKD {
59  bool operator()(MeasurementDet const* rh, MeasurementDet const* lh) {
60  return rh->fastGeomDet().geographicalId().rawId() < lh->fastGeomDet().geographicalId().rawId();
61  }
62  bool operator()(MeasurementDet const& rh, MeasurementDet const& lh) {
63  return rh.fastGeomDet().geographicalId().rawId() < lh.fastGeomDet().geographicalId().rawId();
64  }
65  };
66 
67  template <typename TKD>
68  void sortTKD(std::vector<TKD*>& det) {
69  std::sort(det.begin(), det.end(), CmpTKD());
70  }
71  template <typename TKD>
72  void sortTKD(std::vector<TKD>& det) {
73  std::sort(det.begin(), det.end(), CmpTKD());
74  }
75 
76 } // namespace
77 
80  const StripClusterParameterEstimator* stripCPE,
81  const SiStripRecHitMatcher* hitMatcher,
82  const TrackerTopology* trackerTopology,
83  const TrackerGeometry* trackerGeom,
84  const GeometricSearchTracker* geometricSearchTracker,
85  const SiStripQuality* stripQuality,
86  int stripQualityFlags,
87  int stripQualityDebugFlags,
88  const SiPixelQuality* pixelQuality,
89  const SiPixelFedCabling* pixelCabling,
90  int pixelQualityFlags,
91  int pixelQualityDebugFlags,
93  : MeasurementTracker(trackerGeom, geometricSearchTracker),
94  theStDetConditions(hitMatcher, stripCPE),
95  thePxDetConditions(pixelCPE),
96  thePhase2DetConditions(phase2OTCPE) {
97  this->initialize(trackerTopology);
98  this->initializeStripStatus(badStripCuts, stripQuality, stripQualityFlags, stripQualityDebugFlags);
99  this->initializePixelStatus(pixelQuality, pixelCabling, pixelQualityFlags, pixelQualityDebugFlags);
100 }
101 
103 
105  bool subIsPixel = false;
106  //FIXME:just temporary solution for phase2 :
107  //the OT is defined as PixelSubDetector!
108  bool subIsOT = false;
109 
110  //if the TkGeometry has the subDet vector filled, the theDetMap is filled, otherwise nothing should happen
111  if (!theTrackerGeom->detsPXB().empty()) {
113  theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsPXB().front()->geographicalId().subdetId()));
114  addDets(theTrackerGeom->detsPXB(), subIsPixel, subIsOT);
115  }
116 
117  if (!theTrackerGeom->detsPXF().empty()) {
119  theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsPXF().front()->geographicalId().subdetId()));
120  addDets(theTrackerGeom->detsPXF(), subIsPixel, subIsOT);
121  }
122 
123  subIsOT = true;
124 
125  if (!theTrackerGeom->detsTIB().empty()) {
127  theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsTIB().front()->geographicalId().subdetId()));
128  addDets(theTrackerGeom->detsTIB(), subIsPixel, subIsOT);
129  }
130 
131  if (!theTrackerGeom->detsTID().empty()) {
133  theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsTID().front()->geographicalId().subdetId()));
134  addDets(theTrackerGeom->detsTID(), subIsPixel, subIsOT);
135  }
136 
137  if (!theTrackerGeom->detsTOB().empty()) {
139  theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsTOB().front()->geographicalId().subdetId()));
140  addDets(theTrackerGeom->detsTOB(), subIsPixel, subIsOT);
141  }
142 
143  if (!theTrackerGeom->detsTEC().empty()) {
145  theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsTEC().front()->geographicalId().subdetId()));
146  addDets(theTrackerGeom->detsTEC(), subIsPixel, subIsOT);
147  }
148 
149  // fist all stripdets
150  sortTKD(theStripDets);
152  for (unsigned int i = 0; i != theStripDets.size(); ++i)
154 
155  // now the glued dets
156  sortTKD(theGluedDets);
157  for (unsigned int i = 0; i != theGluedDets.size(); ++i)
158  initGluedDet(theGluedDets[i], trackerTopology);
159 
160  // then the pixels
161  sortTKD(thePixelDets);
163  for (unsigned int i = 0; i != thePixelDets.size(); ++i)
165 
166  // then the phase2 dets
167  sortTKD(thePhase2Dets);
169  for (unsigned int i = 0; i != thePhase2Dets.size(); ++i)
171 
172  // and then the stack dets, at last
173  sortTKD(theStackDets);
174  for (unsigned int i = 0; i != theStackDets.size(); ++i)
176 
177  // and then the double sensor dets
178  sortTKD(theDoubleSensGeomDets);
179  for (unsigned int i = 0; i != theDoubleSensGeomDets.size(); ++i)
181 
182  if (!checkDets())
183  throw MeasurementDetException("Number of dets in MeasurementTracker not consistent with TrackerGeometry!");
184 }
185 
186 void MeasurementTrackerImpl::initStMeasurementConditionSet(std::vector<TkStripMeasurementDet>& stripDets) {
187  // assume vector is full and ordered!
188  int size = stripDets.size();
190  for (int i = 0; i != size; ++i) {
191  auto& mdet = stripDets[i];
192  mdet.setIndex(i);
193  //intialize the detId !
194  theStDetConditions.id_[i] = mdet.specificGeomDet().geographicalId().rawId();
196  //initalize the total number of strips
197  theStDetConditions.totalStrips_[i] = mdet.specificGeomDet().specificTopology().nstrips();
198  }
199 }
200 
201 void MeasurementTrackerImpl::initPxMeasurementConditionSet(std::vector<TkPixelMeasurementDet>& pixelDets) {
202  // assume vector is full and ordered!
203  int size = pixelDets.size();
205 
206  for (int i = 0; i != size; ++i) {
207  auto& mdet = pixelDets[i];
208  mdet.setIndex(i);
209  thePxDetConditions.id_[i] = mdet.specificGeomDet().geographicalId().rawId();
210  }
211 }
212 
213 void MeasurementTrackerImpl::initPhase2OTMeasurementConditionSet(std::vector<TkPhase2OTMeasurementDet>& phase2Dets) {
214  // assume vector is full and ordered!
215  int size = phase2Dets.size();
217 
218  for (int i = 0; i != size; ++i) {
219  auto& mdet = phase2Dets[i];
220  mdet.setIndex(i);
221  thePhase2DetConditions.id_[i] = mdet.specificGeomDet().geographicalId().rawId();
222  }
223 }
224 
225 void MeasurementTrackerImpl::addDets(const TrackingGeometry::DetContainer& dets, bool subIsPixel, bool subIsOT) {
226  //in phase2, we can have composed subDetector made by Pixel or Strip
227  for (TrackerGeometry::DetContainer::const_iterator gd = dets.begin(); gd != dets.end(); gd++) {
228  const GeomDetUnit* gdu = dynamic_cast<const GeomDetUnit*>(*gd);
229 
230  //Pixel or Strip GeomDetUnit
231  if (gdu->isLeaf()) {
232  if (subIsPixel) {
233  if (!subIsOT) {
234  addPixelDet(*gd);
235  } else {
236  addPhase2Det(*gd);
237  }
238  } else {
239  addStripDet(*gd);
240  }
241  } else {
242  //Glued or Stack GeomDet
243  const GluedGeomDet* gluedDet = dynamic_cast<const GluedGeomDet*>(*gd);
244  const StackGeomDet* stackDet = dynamic_cast<const StackGeomDet*>(*gd);
245  const DoubleSensGeomDet* doubleSensGeomDet = dynamic_cast<const DoubleSensGeomDet*>(*gd);
246 
247  if ((gluedDet == nullptr && stackDet == nullptr && doubleSensGeomDet == nullptr) ||
248  (gluedDet != nullptr && stackDet != nullptr && doubleSensGeomDet != nullptr)) {
250  "MeasurementTracker ERROR: GeomDet neither DetUnit nor GluedDet nor StackDet nor DoubleSensGeomDet");
251  }
252  if (gluedDet != nullptr)
253  addGluedDet(gluedDet);
254  else if (stackDet != nullptr)
255  addStackDet(stackDet);
256  else
257  addDoubleSensGeomDet(doubleSensGeomDet);
258  }
259  }
260 }
261 
263  if (theTrackerGeom->dets().size() == theDetMap.size())
264  return true;
265  return false;
266 }
267 
269  try {
271  } catch (MeasurementDetException& err) {
272  edm::LogError("MeasurementDet") << "Oops, got a MeasurementDetException: " << err.what();
273  }
274 }
275 
277  try {
279  } catch (MeasurementDetException& err) {
280  edm::LogError("MeasurementDet") << "Oops, got a MeasurementDetException: " << err.what();
281  }
282 }
283 
285  try {
287  } catch (MeasurementDetException& err) {
288  edm::LogError("MeasurementDet") << "Oops, got a MeasurementDetException: " << err.what();
289  }
290 }
291 
294 }
295 
297  //since the Stack will be composed by PS or 2S,
298  //both cluster parameter estimators are needed? - right now just the thePixelCPE is used.
300 }
301 
304 }
305 
307  const GluedGeomDet& gd = det.specificGeomDet();
308  const MeasurementDet* monoDet = findDet(gd.monoDet()->geographicalId());
309  const MeasurementDet* stereoDet = findDet(gd.stereoDet()->geographicalId());
310  if (monoDet == nullptr || stereoDet == nullptr) {
311  edm::LogError("MeasurementDet") << "MeasurementTracker ERROR: GluedDet components not found as MeasurementDets ";
312  throw MeasurementDetException("MeasurementTracker ERROR: GluedDet components not found as MeasurementDets");
313  }
314  det.init(monoDet, stereoDet, trackerTopology);
315  theDetMap[gd.geographicalId()] = &det;
316 }
317 
319  const StackGeomDet& gd = det.specificGeomDet();
320  const MeasurementDet* lowerDet = findDet(gd.lowerDet()->geographicalId());
321  const MeasurementDet* upperDet = findDet(gd.upperDet()->geographicalId());
322  if (lowerDet == nullptr || upperDet == nullptr) {
323  edm::LogError("MeasurementDet") << "MeasurementTracker ERROR: StackDet components not found as MeasurementDets ";
324  throw MeasurementDetException("MeasurementTracker ERROR: StackDet components not found as MeasurementDets");
325  }
326  det.init(lowerDet, upperDet);
327  theDetMap[gd.geographicalId()] = &det;
328 }
329 
331  const DoubleSensGeomDet& gd = det.specificGeomDet();
332  const MeasurementDet* firstDet = findDet(gd.firstDet()->geographicalId());
333  const MeasurementDet* secondDet = findDet(gd.secondDet()->geographicalId());
334  if (firstDet == nullptr || secondDet == nullptr) {
335  edm::LogError("MeasurementDet")
336  << "MeasurementTracker ERROR: DoubleSensDet components not found as MeasurementDets ";
337  throw MeasurementDetException("MeasurementTracker ERROR: DoubleSensDet components not found as MeasurementDets");
338  }
339  det.init(firstDet, secondDet);
340  theDetMap[gd.geographicalId()] = &det;
341 }
342 
344  const SiStripQuality* quality,
345  int qualityFlags,
346  int qualityDebugFlags) {
347  if (qualityFlags & BadStrips) {
352  }
354 
355  if ((quality != nullptr) && (qualityFlags != 0)) {
356  edm::LogInfo("MeasurementTracker") << "qualityFlags = " << qualityFlags;
357  unsigned int on = 0, tot = 0;
358  unsigned int foff = 0, ftot = 0, aoff = 0, atot = 0;
359  for (int i = 0; i != theStDetConditions.nDet(); i++) {
360  uint32_t detid = theStDetConditions.id(i);
361  if (qualityFlags & BadModules) {
362  bool isOn = quality->IsModuleUsable(detid);
364  tot++;
365  on += (unsigned int)isOn;
366  if (qualityDebugFlags & BadModules) {
367  edm::LogInfo("MeasurementTracker")
368  << "MeasurementTrackerImpl::initializeStripStatus : detid " << detid << " is " << (isOn ? "on" : "off");
369  }
370  } else {
372  }
373  // first turn all APVs and fibers ON
375  if (qualityFlags & BadAPVFibers) {
376  short badApvs = quality->getBadApvs(detid);
377  short badFibers = quality->getBadFibers(detid);
378  for (int j = 0; j < 6; j++) {
379  atot++;
380  if (badApvs & (1 << j)) {
382  aoff++;
383  }
384  }
385  for (int j = 0; j < 3; j++) {
386  ftot++;
387  if (badFibers & (1 << j)) {
389  theStDetConditions.set128StripStatus(i, false, 2 * j + 1);
390  foff++;
391  }
392  }
393  }
394  auto& badStrips = theStDetConditions.getBadStripBlocks(i);
395  badStrips.clear();
396  if (qualityFlags & BadStrips) {
397  SiStripBadStrip::Range range = quality->getRange(detid);
398  for (SiStripBadStrip::ContainerIterator bit = range.first; bit != range.second; ++bit) {
399  badStrips.push_back(quality->decode(*bit));
400  }
401  }
402  }
403  if (qualityDebugFlags & BadModules) {
404  edm::LogInfo("MeasurementTracker StripModuleStatus")
405  << " Total modules: " << tot << ", active " << on << ", inactive " << (tot - on);
406  }
407  if (qualityDebugFlags & BadAPVFibers) {
408  edm::LogInfo("MeasurementTracker StripAPVStatus")
409  << " Total APVs: " << atot << ", active " << (atot - aoff) << ", inactive " << (aoff);
410  edm::LogInfo("MeasurementTracker StripFiberStatus")
411  << " Total Fibers: " << ftot << ", active " << (ftot - foff) << ", inactive " << (foff);
412  }
413  } else {
414  for (int i = 0; i != theStDetConditions.nDet(); i++) {
415  theStDetConditions.setActive(i, true); // module ON
416  theStDetConditions.set128StripStatus(i, true); // all APVs and fibers ON
417  }
418  }
419 }
420 
422  const SiPixelFedCabling* pixelCabling,
423  int qualityFlags,
424  int qualityDebugFlags) {
425  if ((quality != nullptr) && (qualityFlags != 0)) {
426  edm::LogInfo("MeasurementTracker") << "qualityFlags = " << qualityFlags;
427  unsigned int on = 0, tot = 0, badrocs = 0;
428  for (std::vector<TkPixelMeasurementDet>::iterator i = thePixelDets.begin(); i != thePixelDets.end(); i++) {
429  uint32_t detid = ((*i).geomDet().geographicalId()).rawId();
430  if (qualityFlags & BadModules) {
431  bool isOn = quality->IsModuleUsable(detid);
432  (i)->setActive(isOn);
433  tot++;
434  on += (unsigned int)isOn;
435  if (qualityDebugFlags & BadModules) {
436  edm::LogInfo("MeasurementTracker")
437  << "MeasurementTrackerImpl::initializePixelStatus : detid " << detid << " is " << (isOn ? "on" : "off");
438  }
439  } else {
440  (i)->setActive(true);
441  }
442  if ((qualityFlags & BadROCs) && (quality->getBadRocs(detid) != 0)) {
443  std::vector<LocalPoint> badROCs = quality->getBadRocPositions(detid, *theTrackerGeom, pixelCabling);
444  badrocs += badROCs.size();
445  (i)->setBadRocPositions(badROCs);
446  } else {
447  (i)->clearBadRocPositions();
448  }
449  }
450  if (qualityDebugFlags & BadModules) {
451  edm::LogInfo("MeasurementTracker PixelModuleStatus")
452  << " Total modules: " << tot << ", active " << on << ", inactive " << (tot - on);
453  }
454  if (qualityDebugFlags & BadROCs) {
455  edm::LogInfo("MeasurementTracker PixelROCStatus") << " Total of bad ROCs: " << badrocs;
456  }
457  } else {
458  for (std::vector<TkPixelMeasurementDet>::iterator i = thePixelDets.begin(); i != thePixelDets.end(); i++) {
459  (i)->setActive(true); // module ON
460  }
461  }
462 }
size
Write out results.
const DetContainer & detsTIB() const
const GeomDetUnit * secondDet() const
void initDoubleSensDet(TkDoubleSensMeasurementDet &det)
virtual bool isLeaf() const
is a Unit
Definition: GeomDet.h:70
void addStripDet(const GeomDet *gd)
void addStackDet(const StackGeomDet *gd)
const GeomDetUnit * lowerDet() const
Definition: StackGeomDet.h:19
const GeomDetUnit * firstDet() const
std::vector< TkStripMeasurementDet > theStripDets
const DetContainer & detsPXB() const
std::vector< TkStackMeasurementDet > theStackDets
void init(const MeasurementDet *firstDet, const MeasurementDet *secondDet)
StMeasurementConditionSet theStDetConditions
static constexpr auto TID
Definition: SiStripDetId.h:38
const GeomDetUnit * upperDet() const
Definition: StackGeomDet.h:20
unsigned int id(int i) const
void addDoubleSensGeomDet(const DoubleSensGeomDet *gd)
std::vector< unsigned int >::const_iterator ContainerIterator
void addDets(const TrackingGeometry::DetContainer &dets, bool subIsPixel, bool subIsOT)
const TrackerGeometry * theTrackerGeom
const DetContainer & detsPXF() const
const StripClusterParameterEstimator * stripCPE() const
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
const GluedGeomDet & specificGeomDet() const
bool int lh
Definition: SIMDVec.h:20
std::vector< TkPhase2OTMeasurementDet > thePhase2Dets
Log< level::Error, false > LogError
void addPixelDet(const GeomDet *gd)
const SiStripRecHitMatcher * matcher() const
std::vector< const GeomDet * > DetContainer
string quality
void init(const MeasurementDet *lowerDet, const MeasurementDet *upperDet)
std::vector< unsigned char > subId_
unsigned int id(int i) const
void initGluedDet(TkGluedMeasurementDet &det, const TrackerTopology *trackerTopology)
const DetContainer & detsTOB() const
std::vector< TkPixelMeasurementDet > thePixelDets
void initializePixelStatus(const SiPixelQuality *stripQuality, const SiPixelFedCabling *pixelCabling, int qualityFlags, int qualityDebugFlags)
void initPhase2OTMeasurementConditionSet(std::vector< TkPhase2OTMeasurementDet > &phase2Dets)
void setActive(int i, bool active)
Turn on/off the module for reconstruction, for the full run or lumi (using info from DB...
std::vector< BadStripBlock > & getBadStripBlocks(int i)
MeasurementTrackerImpl(const BadStripCutsDet &badStripCuts, const PixelClusterParameterEstimator *pixelCPE, const StripClusterParameterEstimator *stripCPE, const SiStripRecHitMatcher *hitMatcher, const TrackerTopology *trackerTopology, const TrackerGeometry *trackerGeom, const GeometricSearchTracker *geometricSearchTracker, const SiStripQuality *stripQuality, int stripQualityFlags, int stripQualityDebugFlags, const SiPixelQuality *pixelQuality, const SiPixelFedCabling *pixelCabling, int pixelQualityFlags, int pixelQualityDebugFlags, const ClusterParameterEstimator< Phase2TrackerCluster1D > *phase2OTCPE=nullptr)
void initialize(const TrackerTopology *trackerTopology)
void initStMeasurementConditionSet(std::vector< TkStripMeasurementDet > &stripDets)
unsigned int id(int i) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
std::vector< TkDoubleSensMeasurementDet > theDoubleSensGeomDets
std::vector< unsigned int > id_
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
static constexpr auto TOB
Definition: SiStripDetId.h:39
std::vector< int > totalStrips_
void initializeStripStatus(const BadStripCutsDet &badStripCuts, const SiStripQuality *stripQuality, int qualityFlags, int qualityDebugFlags)
const std::vector< TkStripMeasurementDet > & stripDets() const
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:19
void addPhase2Det(const GeomDet *gd)
Log< level::Info, false > LogInfo
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
void setMaskBad128StripBlocks(bool maskThem)
std::vector< unsigned int > id_
void addGluedDet(const GluedGeomDet *gd)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::vector< unsigned int > id_
const GeomDet & fastGeomDet() const
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:20
std::vector< TkGluedMeasurementDet > theGluedDets
static constexpr auto TIB
Definition: SiStripDetId.h:37
void init(const MeasurementDet *monoDet, const MeasurementDet *stereoDet, const TrackerTopology *tTopo)
PxMeasurementConditionSet thePxDetConditions
Phase2OTMeasurementConditionSet thePhase2DetConditions
const MeasurementDet * findDet(const DetId &id) const
const GeomDetEnumerators::SubDetector geomDetSubDetector(int subdet) const
std::pair< ContainerIterator, ContainerIterator > Range
const std::vector< TkPixelMeasurementDet > & pixelDets() const
const DetContainer & detsTEC() const
const StackGeomDet & specificGeomDet() const
void initPxMeasurementConditionSet(std::vector< TkPixelMeasurementDet > &pixelDets)
const DoubleSensGeomDet & specificGeomDet() const
void set128StripStatus(int i, bool good, int idx=-1)
const PixelClusterParameterEstimator * pixelCPE() const
void initStackDet(TkStackMeasurementDet &det)
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
static constexpr auto TEC
Definition: SiStripDetId.h:40
const DetContainer & detsTID() const