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  struct CmpTKD {
51  bool operator()(MeasurementDet const* rh, MeasurementDet const * lh) {
52  return rh->fastGeomDet().geographicalId().rawId() < lh->fastGeomDet().geographicalId().rawId();
53  }
54  bool operator()(MeasurementDet const & rh, MeasurementDet const & lh) {
56  }
57  };
58 
59  template<typename TKD>
60  void sortTKD( std::vector<TKD*> & det) {
61  std::sort(det.begin(),det.end(),CmpTKD());
62  }
63  template<typename TKD>
64  void sortTKD( std::vector<TKD> & det) {
65  std::sort(det.begin(),det.end(),CmpTKD());
66  }
67 
68 }
69 
70 
72  const PixelClusterParameterEstimator* pixelCPE,
73  const StripClusterParameterEstimator* stripCPE,
74  const SiStripRecHitMatcher* hitMatcher,
75  const TrackerGeometry* trackerGeom,
76  const GeometricSearchTracker* geometricSearchTracker,
77  const SiStripQuality *stripQuality,
78  int stripQualityFlags,
79  int stripQualityDebugFlags,
80  const SiPixelQuality *pixelQuality,
81  const SiPixelFedCabling *pixelCabling,
82  int pixelQualityFlags,
83  int pixelQualityDebugFlags) :
84  MeasurementTracker(trackerGeom,geometricSearchTracker),
85  pset_(conf),
86  name_(conf.getParameter<std::string>("ComponentName")),
87  theStDetConditions(hitMatcher,stripCPE),
88  thePxDetConditions(pixelCPE)
89 {
90  this->initialize();
91  this->initializeStripStatus(stripQuality, stripQualityFlags, stripQualityDebugFlags);
92  this->initializePixelStatus(pixelQuality, pixelCabling, pixelQualityFlags, pixelQualityDebugFlags);
93 }
94 
96 {
97 }
98 
99 
101 {
104 
109 
110  // fist all stripdets
111  sortTKD(theStripDets);
113  for (unsigned int i=0; i!=theStripDets.size(); ++i)
115 
116  // now the glued dets
117  sortTKD(theGluedDets);
118  for (unsigned int i=0; i!=theGluedDets.size(); ++i)
120 
121  // and then the pixels, at last
122  sortTKD(thePixelDets);
124  for (unsigned int i=0; i!=thePixelDets.size(); ++i)
126 
127 }
128 
129 void MeasurementTrackerImpl::initStMeasurementConditionSet(std::vector<TkStripMeasurementDet> & stripDets)
130 {
131  // assume vector is full and ordered!
132  int size = stripDets.size();
133  theStDetConditions.init(size);
134  for (int i=0; i!=size; ++i) {
135  auto & mdet = stripDets[i];
136  mdet.setIndex(i);
137  //intialize the detId !
138  theStDetConditions.id_[i] = mdet.specificGeomDet().geographicalId().rawId();
140  //initalize the total number of strips
141  theStDetConditions.totalStrips_[i] = mdet.specificGeomDet().specificTopology().nstrips();
142  }
143 }
144 
145 void MeasurementTrackerImpl::initPxMeasurementConditionSet(std::vector<TkPixelMeasurementDet> & pixelDets)
146 {
147  // assume vector is full and ordered!
148  int size = pixelDets.size();
149  thePxDetConditions.init(size);
150 
151  for (int i=0; i!=size; ++i) {
152  auto & mdet = pixelDets[i];
153  mdet.setIndex(i);
154  thePxDetConditions.id_[i] = mdet.specificGeomDet().geographicalId().rawId();
155  }
156 }
157 
158 
159 
160 
162 {
163  for (TrackerGeometry::DetContainer::const_iterator gd=dets.begin();
164  gd != dets.end(); gd++) {
165  addPixelDet(*gd);
166  }
167 }
168 
170 {
171  for (TrackerGeometry::DetContainer::const_iterator gd=dets.begin();
172  gd != dets.end(); gd++) {
173 
174  const GeomDetUnit* gdu = dynamic_cast<const GeomDetUnit*>(*gd);
175 
176  // StripSubdetector stripId( (**gd).geographicalId());
177  // bool isDetUnit( gdu != 0);
178  // cout << "StripSubdetector glued? " << stripId.glued()
179  // << " is DetUnit? " << isDetUnit << endl;
180 
181  if (gdu != 0) {
182  addStripDet(*gd);
183  }
184  else {
185  const GluedGeomDet* gluedDet = dynamic_cast<const GluedGeomDet*>(*gd);
186  if (gluedDet == 0) {
187  throw MeasurementDetException("MeasurementTracker ERROR: GeomDet neither DetUnit nor GluedDet");
188  }
189  addGluedDet(gluedDet);
190  }
191  }
192 }
193 
195 {
196  try {
198  }
199  catch(MeasurementDetException& err){
200  edm::LogError("MeasurementDet") << "Oops, got a MeasurementDetException: " << err.what() ;
201  }
202 }
203 
205 {
206  try {
208  }
209  catch(MeasurementDetException& err){
210  edm::LogError("MeasurementDet") << "Oops, got a MeasurementDetException: " << err.what() ;
211  }
212 }
213 
215 {
217 }
218 
220 {
221  const GluedGeomDet& gd = det.specificGeomDet();
222  const MeasurementDet* monoDet = findDet( gd.monoDet()->geographicalId());
223  const MeasurementDet* stereoDet = findDet( gd.stereoDet()->geographicalId());
224  if (monoDet == 0 || stereoDet == 0) {
225  edm::LogError("MeasurementDet") << "MeasurementTracker ERROR: GluedDet components not found as MeasurementDets ";
226  throw MeasurementDetException("MeasurementTracker ERROR: GluedDet components not found as MeasurementDets");
227  }
228  det.init(monoDet,stereoDet);
229  theDetMap[gd.geographicalId()] = &det;
230 }
231 
232 void MeasurementTrackerImpl::initializeStripStatus(const SiStripQuality *quality, int qualityFlags, int qualityDebugFlags) {
233  edm::ParameterSet cutPset = pset_.getParameter<edm::ParameterSet>("badStripCuts");
234  if (qualityFlags & BadStrips) {
235  typedef StMeasurementConditionSet::BadStripCuts BadStripCuts;
240  }
242 
243 
244  if ((quality != 0) && (qualityFlags != 0)) {
245  edm::LogInfo("MeasurementTracker") << "qualityFlags = " << qualityFlags;
246  unsigned int on = 0, tot = 0;
247  unsigned int foff = 0, ftot = 0, aoff = 0, atot = 0;
248  for (int i=0; i!= theStDetConditions.nDet(); i++) {
249  uint32_t detid = theStDetConditions.id(i);
250  if (qualityFlags & BadModules) {
251  bool isOn = quality->IsModuleUsable(detid);
253  tot++; on += (unsigned int) isOn;
254  if (qualityDebugFlags & BadModules) {
255  edm::LogInfo("MeasurementTracker")<< "MeasurementTrackerImpl::initializeStripStatus : detid " << detid << " is " << (isOn ? "on" : "off");
256  }
257  } else {
259  }
260  // first turn all APVs and fibers ON
262  if (qualityFlags & BadAPVFibers) {
263  short badApvs = quality->getBadApvs(detid);
264  short badFibers = quality->getBadFibers(detid);
265  for (int j = 0; j < 6; j++) {
266  atot++;
267  if (badApvs & (1 << j)) {
269  aoff++;
270  }
271  }
272  for (int j = 0; j < 3; j++) {
273  ftot++;
274  if (badFibers & (1 << j)) {
277  foff++;
278  }
279  }
280  }
281  auto & badStrips = theStDetConditions.getBadStripBlocks(i);
282  badStrips.clear();
283  if (qualityFlags & BadStrips) {
284  SiStripBadStrip::Range range = quality->getRange(detid);
285  for (SiStripBadStrip::ContainerIterator bit = range.first; bit != range.second; ++bit) {
286  badStrips.push_back(quality->decode(*bit));
287  }
288  }
289  }
290  if (qualityDebugFlags & BadModules) {
291  edm::LogInfo("MeasurementTracker StripModuleStatus") <<
292  " Total modules: " << tot << ", active " << on <<", inactive " << (tot - on);
293  }
294  if (qualityDebugFlags & BadAPVFibers) {
295  edm::LogInfo("MeasurementTracker StripAPVStatus") <<
296  " Total APVs: " << atot << ", active " << (atot-aoff) <<", inactive " << (aoff);
297  edm::LogInfo("MeasurementTracker StripFiberStatus") <<
298  " Total Fibers: " << ftot << ", active " << (ftot-foff) <<", inactive " << (foff);
299  }
300  } else {
301  for (int i=0; i!=theStDetConditions.nDet(); i++) {
302  theStDetConditions.setActive(i,true); // module ON
303  theStDetConditions.set128StripStatus(i,true); // all APVs and fibers ON
304  }
305  }
306 
307 }
308 
309 void MeasurementTrackerImpl::initializePixelStatus(const SiPixelQuality *quality, const SiPixelFedCabling *pixelCabling, int qualityFlags, int qualityDebugFlags) {
310  if ((quality != 0) && (qualityFlags != 0)) {
311  edm::LogInfo("MeasurementTracker") << "qualityFlags = " << qualityFlags;
312  unsigned int on = 0, tot = 0, badrocs = 0;
313  for (std::vector<TkPixelMeasurementDet>::iterator i=thePixelDets.begin();
314  i!=thePixelDets.end(); i++) {
315  uint32_t detid = ((*i).geomDet().geographicalId()).rawId();
316  if (qualityFlags & BadModules) {
317  bool isOn = quality->IsModuleUsable(detid);
318  (i)->setActive(isOn);
319  tot++; on += (unsigned int) isOn;
320  if (qualityDebugFlags & BadModules) {
321  edm::LogInfo("MeasurementTracker")<< "MeasurementTrackerImpl::initializePixelStatus : detid " << detid << " is " << (isOn ? "on" : "off");
322  }
323  } else {
324  (i)->setActive(true);
325  }
326  if ((qualityFlags & BadROCs) && (quality->getBadRocs(detid) != 0)) {
327  std::vector<LocalPoint> badROCs = quality->getBadRocPositions(detid, *theTrackerGeom, pixelCabling);
328  badrocs += badROCs.size();
329  (i)->setBadRocPositions(badROCs);
330  } else {
331  (i)->clearBadRocPositions();
332  }
333  }
334  if (qualityDebugFlags & BadModules) {
335  edm::LogInfo("MeasurementTracker PixelModuleStatus") <<
336  " Total modules: " << tot << ", active " << on <<", inactive " << (tot - on);
337  }
338  if (qualityDebugFlags & BadROCs) {
339  edm::LogInfo("MeasurementTracker PixelROCStatus") << " Total of bad ROCs: " << badrocs ;
340  }
341  } else {
342  for (std::vector<TkPixelMeasurementDet>::iterator i=thePixelDets.begin();
343  i!=thePixelDets.end(); i++) {
344  (i)->setActive(true); // module ON
345  }
346  }
347 }
348 
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:72
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