CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MeasurementTrackerImpl.cc
Go to the documentation of this file.
2 
5 
11 
13 
15 
21 
23 
28 
31 #include "TkStripMeasurementDet.h"
32 #include "TkPixelMeasurementDet.h"
33 #include "TkGluedMeasurementDet.h"
34 
37 
38 #include <iostream>
39 #include <typeinfo>
40 #include <map>
41 #include <algorithm>
42 
43 
44 //
45 
46 using namespace std;
47 
48 namespace {
49 
50  class StrictWeakOrdering{
51  public:
52  bool operator() ( uint32_t p,const uint32_t& i) const {return p < i;}
53  };
54 
55 
56  struct CmpTKD {
57  bool operator()(MeasurementDet const* rh, MeasurementDet const * lh) {
58  return rh->fastGeomDet().geographicalId().rawId() < lh->fastGeomDet().geographicalId().rawId();
59  }
60  bool operator()(MeasurementDet const & rh, MeasurementDet const & lh) {
62  }
63  };
64 
65  template<typename TKD>
66  void sortTKD( std::vector<TKD*> & det) {
67  std::sort(det.begin(),det.end(),CmpTKD());
68  }
69  template<typename TKD>
70  void sortTKD( std::vector<TKD> & det) {
71  std::sort(det.begin(),det.end(),CmpTKD());
72  }
73 
74 }
75 
76 
78  const PixelClusterParameterEstimator* pixelCPE,
79  const StripClusterParameterEstimator* stripCPE,
80  const SiStripRecHitMatcher* hitMatcher,
81  const TrackerGeometry* trackerGeom,
82  const GeometricSearchTracker* geometricSearchTracker,
83  const SiStripQuality *stripQuality,
84  int stripQualityFlags,
85  int stripQualityDebugFlags,
86  const SiPixelQuality *pixelQuality,
87  const SiPixelFedCabling *pixelCabling,
88  int pixelQualityFlags,
89  int pixelQualityDebugFlags) :
90  MeasurementTracker(trackerGeom,geometricSearchTracker),
91  pset_(conf),
92  name_(conf.getParameter<std::string>("ComponentName")),
93  theStDetConditions(hitMatcher,stripCPE),
94  thePxDetConditions(pixelCPE)
95 {
96  this->initialize();
97  this->initializeStripStatus(stripQuality, stripQualityFlags, stripQualityDebugFlags);
98  this->initializePixelStatus(pixelQuality, pixelCabling, pixelQualityFlags, pixelQualityDebugFlags);
99 }
100 
102 {
103 }
104 
105 
107 {
110 
115 
116  // fist all stripdets
117  sortTKD(theStripDets);
119  for (unsigned int i=0; i!=theStripDets.size(); ++i)
121 
122  // now the glued dets
123  sortTKD(theGluedDets);
124  for (unsigned int i=0; i!=theGluedDets.size(); ++i)
126 
127  // and then the pixels, at last
128  sortTKD(thePixelDets);
130  for (unsigned int i=0; i!=thePixelDets.size(); ++i)
132 
133 }
134 
135 void MeasurementTrackerImpl::initStMeasurementConditionSet(std::vector<TkStripMeasurementDet> & stripDets)
136 {
137  // assume vector is full and ordered!
138  int size = stripDets.size();
139  theStDetConditions.init(size);
140  for (int i=0; i!=size; ++i) {
141  auto & mdet = stripDets[i];
142  mdet.setIndex(i);
143  //intialize the detId !
144  theStDetConditions.id_[i] = mdet.specificGeomDet().geographicalId().rawId();
146  //initalize the total number of strips
147  theStDetConditions.totalStrips_[i] = mdet.specificGeomDet().specificTopology().nstrips();
148  }
149 }
150 
151 void MeasurementTrackerImpl::initPxMeasurementConditionSet(std::vector<TkPixelMeasurementDet> & pixelDets)
152 {
153  // assume vector is full and ordered!
154  int size = pixelDets.size();
155  thePxDetConditions.init(size);
156 
157  for (int i=0; i!=size; ++i) {
158  auto & mdet = pixelDets[i];
159  mdet.setIndex(i);
160  thePxDetConditions.id_[i] = mdet.specificGeomDet().geographicalId().rawId();
161  }
162 }
163 
164 
165 
166 
168 {
169  for (TrackerGeometry::DetContainer::const_iterator gd=dets.begin();
170  gd != dets.end(); gd++) {
171  addPixelDet(*gd);
172  }
173 }
174 
176 {
177  for (TrackerGeometry::DetContainer::const_iterator gd=dets.begin();
178  gd != dets.end(); gd++) {
179 
180  auto gdu = (*gd);
181 
182  // StripSubdetector stripId( (**gd).geographicalId());
183  // bool isDetUnit( gdu != 0);
184  // cout << "StripSubdetector glued? " << stripId.glued()
185  // << " is DetUnit? " << isDetUnit << endl;
186 
187  if (gdu->isLeaf()) {
188  addStripDet(*gd);
189  }
190  else {
191  const GluedGeomDet* gluedDet = dynamic_cast<const GluedGeomDet*>(*gd);
192  if (gluedDet == 0) {
193  throw MeasurementDetException("MeasurementTracker ERROR: GeomDet neither DetUnit nor GluedDet");
194  }
195  addGluedDet(gluedDet);
196  }
197  }
198 }
199 
201 {
202  try {
204  }
205  catch(MeasurementDetException& err){
206  edm::LogError("MeasurementDet") << "Oops, got a MeasurementDetException: " << err.what() ;
207  }
208 }
209 
211 {
212  try {
214  }
215  catch(MeasurementDetException& err){
216  edm::LogError("MeasurementDet") << "Oops, got a MeasurementDetException: " << err.what() ;
217  }
218 }
219 
221 {
223 }
224 
226 {
227  const GluedGeomDet& gd = det.specificGeomDet();
228  const MeasurementDet* monoDet = findDet( gd.monoDet()->geographicalId());
229  const MeasurementDet* stereoDet = findDet( gd.stereoDet()->geographicalId());
230  if (monoDet == 0 || stereoDet == 0) {
231  edm::LogError("MeasurementDet") << "MeasurementTracker ERROR: GluedDet components not found as MeasurementDets ";
232  throw MeasurementDetException("MeasurementTracker ERROR: GluedDet components not found as MeasurementDets");
233  }
234  det.init(monoDet,stereoDet);
235  theDetMap[gd.geographicalId()] = &det;
236 }
237 
238 void MeasurementTrackerImpl::initializeStripStatus(const SiStripQuality *quality, int qualityFlags, int qualityDebugFlags) {
239  edm::ParameterSet cutPset = pset_.getParameter<edm::ParameterSet>("badStripCuts");
240  if (qualityFlags & BadStrips) {
241  typedef StMeasurementConditionSet::BadStripCuts BadStripCuts;
246  }
248 
249 
250  if ((quality != 0) && (qualityFlags != 0)) {
251  edm::LogInfo("MeasurementTracker") << "qualityFlags = " << qualityFlags;
252  unsigned int on = 0, tot = 0;
253  unsigned int foff = 0, ftot = 0, aoff = 0, atot = 0;
254  for (int i=0; i!= theStDetConditions.nDet(); i++) {
255  uint32_t detid = theStDetConditions.id(i);
256  if (qualityFlags & BadModules) {
257  bool isOn = quality->IsModuleUsable(detid);
259  tot++; on += (unsigned int) isOn;
260  if (qualityDebugFlags & BadModules) {
261  edm::LogInfo("MeasurementTracker")<< "MeasurementTrackerImpl::initializeStripStatus : detid " << detid << " is " << (isOn ? "on" : "off");
262  }
263  } else {
265  }
266  // first turn all APVs and fibers ON
268  if (qualityFlags & BadAPVFibers) {
269  short badApvs = quality->getBadApvs(detid);
270  short badFibers = quality->getBadFibers(detid);
271  for (int j = 0; j < 6; j++) {
272  atot++;
273  if (badApvs & (1 << j)) {
275  aoff++;
276  }
277  }
278  for (int j = 0; j < 3; j++) {
279  ftot++;
280  if (badFibers & (1 << j)) {
283  foff++;
284  }
285  }
286  }
287  auto & badStrips = theStDetConditions.getBadStripBlocks(i);
288  badStrips.clear();
289  if (qualityFlags & BadStrips) {
290  SiStripBadStrip::Range range = quality->getRange(detid);
291  for (SiStripBadStrip::ContainerIterator bit = range.first; bit != range.second; ++bit) {
292  badStrips.push_back(quality->decode(*bit));
293  }
294  }
295  }
296  if (qualityDebugFlags & BadModules) {
297  edm::LogInfo("MeasurementTracker StripModuleStatus") <<
298  " Total modules: " << tot << ", active " << on <<", inactive " << (tot - on);
299  }
300  if (qualityDebugFlags & BadAPVFibers) {
301  edm::LogInfo("MeasurementTracker StripAPVStatus") <<
302  " Total APVs: " << atot << ", active " << (atot-aoff) <<", inactive " << (aoff);
303  edm::LogInfo("MeasurementTracker StripFiberStatus") <<
304  " Total Fibers: " << ftot << ", active " << (ftot-foff) <<", inactive " << (foff);
305  }
306  } else {
307  for (int i=0; i!=theStDetConditions.nDet(); i++) {
308  theStDetConditions.setActive(i,true); // module ON
309  theStDetConditions.set128StripStatus(i,true); // all APVs and fibers ON
310  }
311  }
312 
313 }
314 
315 void MeasurementTrackerImpl::initializePixelStatus(const SiPixelQuality *quality, const SiPixelFedCabling *pixelCabling, int qualityFlags, int qualityDebugFlags) {
316  if ((quality != 0) && (qualityFlags != 0)) {
317  edm::LogInfo("MeasurementTracker") << "qualityFlags = " << qualityFlags;
318  unsigned int on = 0, tot = 0, badrocs = 0;
319  for (std::vector<TkPixelMeasurementDet>::iterator i=thePixelDets.begin();
320  i!=thePixelDets.end(); i++) {
321  uint32_t detid = ((*i).geomDet().geographicalId()).rawId();
322  if (qualityFlags & BadModules) {
323  bool isOn = quality->IsModuleUsable(detid);
324  (i)->setActive(isOn);
325  tot++; on += (unsigned int) isOn;
326  if (qualityDebugFlags & BadModules) {
327  edm::LogInfo("MeasurementTracker")<< "MeasurementTrackerImpl::initializePixelStatus : detid " << detid << " is " << (isOn ? "on" : "off");
328  }
329  } else {
330  (i)->setActive(true);
331  }
332  if ((qualityFlags & BadROCs) && (quality->getBadRocs(detid) != 0)) {
333  std::vector<LocalPoint> badROCs = quality->getBadRocPositions(detid, *theTrackerGeom, pixelCabling);
334  badrocs += badROCs.size();
335  (i)->setBadRocPositions(badROCs);
336  } else {
337  (i)->clearBadRocPositions();
338  }
339  }
340  if (qualityDebugFlags & BadModules) {
341  edm::LogInfo("MeasurementTracker PixelModuleStatus") <<
342  " Total modules: " << tot << ", active " << on <<", inactive " << (tot - on);
343  }
344  if (qualityDebugFlags & BadROCs) {
345  edm::LogInfo("MeasurementTracker PixelROCStatus") << " Total of bad ROCs: " << badrocs ;
346  }
347  } else {
348  for (std::vector<TkPixelMeasurementDet>::iterator i=thePixelDets.begin();
349  i!=thePixelDets.end(); i++) {
350  (i)->setActive(true); // module ON
351  }
352  }
353 }
354 
virtual char const * what() const
Definition: Exception.cc:141
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
short getBadFibers(const uint32_t &detid) const
void init(const MeasurementDet *monoDet, const MeasurementDet *stereoDet)
void addStripDet(const GeomDet *gd)
unsigned int id(int i) const
std::vector< TkStripMeasurementDet > theStripDets
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:20
const MeasurementDet * findDet(const DetId &id) const
StMeasurementConditionSet theStDetConditions
std::vector< unsigned int >::const_iterator ContainerIterator
void initializeStripStatus(const SiStripQuality *stripQuality, int qualityFlags, int qualityDebugFlags)
const TrackerGeometry * theTrackerGeom
void initGluedDet(TkGluedMeasurementDet &det)
bool int lh
Definition: SIMDVec.h:19
void addPixelDets(const TrackingGeometry::DetContainer &dets)
void addPixelDet(const GeomDet *gd)
void addStripDets(const TrackingGeometry::DetContainer &dets)
const GeomDet & fastGeomDet() const
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::vector< unsigned char > subId_
unsigned int id(int i) const
const SiStripRecHitMatcher * matcher() const
const DetContainer & detsTEC() const
short getBadApvs(const uint32_t &detid) const
bool IsModuleUsable(const uint32_t &detid) const
std::vector< TkPixelMeasurementDet > thePixelDets
void initializePixelStatus(const SiPixelQuality *stripQuality, const SiPixelFedCabling *pixelCabling, int qualityFlags, int qualityDebugFlags)
const std::vector< LocalPoint > getBadRocPositions(const uint32_t &detid, const TrackerGeometry &theTracker, const SiPixelFedCabling *map) const
void setActive(int i, bool active)
Turn on/off the module for reconstruction, for the full run or lumi (using info from DB...
const GluedGeomDet & specificGeomDet() const
std::vector< BadStripBlock > & getBadStripBlocks(int i)
void initStMeasurementConditionSet(std::vector< TkStripMeasurementDet > &stripDets)
const DetContainer & detsPXB() const
int j
Definition: DBlmapReader.cc:9
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:77
const StripClusterParameterEstimator * stripCPE() const
const edm::ParameterSet & pset_
bool IsModuleUsable(const uint32_t &detid) const
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
std::vector< int > totalStrips_
tuple conf
Definition: dbtoconf.py:185
const DetContainer & detsTIB() const
MeasurementTrackerImpl(const edm::ParameterSet &conf, const PixelClusterParameterEstimator *pixelCPE, const StripClusterParameterEstimator *stripCPE, const SiStripRecHitMatcher *hitMatcher, const TrackerGeometry *trackerGeom, const GeometricSearchTracker *geometricSearchTracker, const SiStripQuality *stripQuality, int stripQualityFlags, int stripQualityDebugFlags, const SiPixelQuality *pixelQuality, const SiPixelFedCabling *pixelCabling, int pixelQualityFlags, int pixelQualityDebugFlags)
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
void setMaskBad128StripBlocks(bool maskThem)
std::vector< unsigned int > id_
void addGluedDet(const GluedGeomDet *gd)
std::vector< unsigned int > id_
std::vector< TkGluedMeasurementDet > theGluedDets
short getBadRocs(const uint32_t &detid) const
PxMeasurementConditionSet thePxDetConditions
const Range getRange(const uint32_t detID) const
std::pair< ContainerIterator, ContainerIterator > Range
const DetContainer & detsPXF() const
const DetContainer & detsTOB() const
void initPxMeasurementConditionSet(std::vector< TkPixelMeasurementDet > &pixelDets)
void set128StripStatus(int i, bool good, int idx=-1)
std::vector< GeomDet const * > DetContainer
tuple size
Write out results.
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
data decode(const unsigned int &value) const
const DetContainer & detsTID() const