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  bool isRegional) :
85  MeasurementTracker(trackerGeom,geometricSearchTracker),
86  pset_(conf),
87  name_(conf.getParameter<std::string>("ComponentName")),
88  theStDetConditions(hitMatcher,stripCPE,isRegional),
89  thePxDetConditions(pixelCPE)
90 {
91  this->initialize();
92  this->initializeStripStatus(stripQuality, stripQualityFlags, stripQualityDebugFlags);
93  this->initializePixelStatus(pixelQuality, pixelCabling, pixelQualityFlags, pixelQualityDebugFlags);
94 }
95 
97 {
98 }
99 
100 
102 {
105 
110 
111  // fist all stripdets
112  sortTKD(theStripDets);
114  for (unsigned int i=0; i!=theStripDets.size(); ++i)
116 
117  // now the glued dets
118  sortTKD(theGluedDets);
119  for (unsigned int i=0; i!=theGluedDets.size(); ++i)
121 
122  // and then the pixels, at last
123  sortTKD(thePixelDets);
125  for (unsigned int i=0; i!=thePixelDets.size(); ++i)
127 
128 }
129 
130 void MeasurementTrackerImpl::initStMeasurementConditionSet(std::vector<TkStripMeasurementDet> & stripDets)
131 {
132  // assume vector is full and ordered!
133  int size = stripDets.size();
134  theStDetConditions.init(size);
135  for (int i=0; i!=size; ++i) {
136  auto & mdet = stripDets[i];
137  mdet.setIndex(i);
138  //intialize the detId !
139  theStDetConditions.id_[i] = mdet.specificGeomDet().geographicalId().rawId();
141  //initalize the total number of strips
142  theStDetConditions.totalStrips_[i] = mdet.specificGeomDet().specificTopology().nstrips();
143  }
144 }
145 
146 void MeasurementTrackerImpl::initPxMeasurementConditionSet(std::vector<TkPixelMeasurementDet> & pixelDets)
147 {
148  // assume vector is full and ordered!
149  int size = pixelDets.size();
150  thePxDetConditions.init(size);
151 
152  for (int i=0; i!=size; ++i) {
153  auto & mdet = pixelDets[i];
154  mdet.setIndex(i);
155  thePxDetConditions.id_[i] = mdet.specificGeomDet().geographicalId().rawId();
156  }
157 }
158 
159 
160 
161 
163 {
164  for (TrackerGeometry::DetContainer::const_iterator gd=dets.begin();
165  gd != dets.end(); gd++) {
166  addPixelDet(*gd);
167  }
168 }
169 
171 {
172  for (TrackerGeometry::DetContainer::const_iterator gd=dets.begin();
173  gd != dets.end(); gd++) {
174 
175  const GeomDetUnit* gdu = dynamic_cast<const GeomDetUnit*>(*gd);
176 
177  // StripSubdetector stripId( (**gd).geographicalId());
178  // bool isDetUnit( gdu != 0);
179  // cout << "StripSubdetector glued? " << stripId.glued()
180  // << " is DetUnit? " << isDetUnit << endl;
181 
182  if (gdu != 0) {
183  addStripDet(*gd);
184  }
185  else {
186  const GluedGeomDet* gluedDet = dynamic_cast<const GluedGeomDet*>(*gd);
187  if (gluedDet == 0) {
188  throw MeasurementDetException("MeasurementTracker ERROR: GeomDet neither DetUnit nor GluedDet");
189  }
190  addGluedDet(gluedDet);
191  }
192  }
193 }
194 
196 {
197  try {
198  theStripDets.push_back(TkStripMeasurementDet( gd, theStDetConditions ));
199  }
200  catch(MeasurementDetException& err){
201  edm::LogError("MeasurementDet") << "Oops, got a MeasurementDetException: " << err.what() ;
202  }
203 }
204 
206 {
207  try {
209  }
210  catch(MeasurementDetException& err){
211  edm::LogError("MeasurementDet") << "Oops, got a MeasurementDetException: " << err.what() ;
212  }
213 }
214 
216 {
217  theGluedDets.push_back(TkGluedMeasurementDet( gd, theStDetConditions.matcher(), theStDetConditions.stripCPE() ));
218 }
219 
220 void MeasurementTrackerImpl::initGluedDet( TkGluedMeasurementDet & det)
221 {
222  const GluedGeomDet& gd = det.specificGeomDet();
223  const MeasurementDet* monoDet = findDet( gd.monoDet()->geographicalId());
224  const MeasurementDet* stereoDet = findDet( gd.stereoDet()->geographicalId());
225  if (monoDet == 0 || stereoDet == 0) {
226  edm::LogError("MeasurementDet") << "MeasurementTracker ERROR: GluedDet components not found as MeasurementDets ";
227  throw MeasurementDetException("MeasurementTracker ERROR: GluedDet components not found as MeasurementDets");
228  }
229  det.init(monoDet,stereoDet);
230  theDetMap[gd.geographicalId()] = &det;
231 }
232 
233 void MeasurementTrackerImpl::initializeStripStatus(const SiStripQuality *quality, int qualityFlags, int qualityDebugFlags) {
234  edm::ParameterSet cutPset = pset_.getParameter<edm::ParameterSet>("badStripCuts");
235  if (qualityFlags & BadStrips) {
236  typedef StMeasurementConditionSet::BadStripCuts BadStripCuts;
241  }
243 
244 
245  if ((quality != 0) && (qualityFlags != 0)) {
246  edm::LogInfo("MeasurementTracker") << "qualityFlags = " << qualityFlags;
247  unsigned int on = 0, tot = 0;
248  unsigned int foff = 0, ftot = 0, aoff = 0, atot = 0;
249  for (int i=0; i!= theStDetConditions.nDet(); i++) {
250  uint32_t detid = theStDetConditions.id(i);
251  if (qualityFlags & BadModules) {
252  bool isOn = quality->IsModuleUsable(detid);
254  tot++; on += (unsigned int) isOn;
255  if (qualityDebugFlags & BadModules) {
256  edm::LogInfo("MeasurementTracker")<< "MeasurementTrackerImpl::initializeStripStatus : detid " << detid << " is " << (isOn ? "on" : "off");
257  }
258  } else {
260  }
261  // first turn all APVs and fibers ON
263  if (qualityFlags & BadAPVFibers) {
264  short badApvs = quality->getBadApvs(detid);
265  short badFibers = quality->getBadFibers(detid);
266  for (int j = 0; j < 6; j++) {
267  atot++;
268  if (badApvs & (1 << j)) {
270  aoff++;
271  }
272  }
273  for (int j = 0; j < 3; j++) {
274  ftot++;
275  if (badFibers & (1 << j)) {
278  foff++;
279  }
280  }
281  }
282  auto & badStrips = theStDetConditions.getBadStripBlocks(i);
283  badStrips.clear();
284  if (qualityFlags & BadStrips) {
285  SiStripBadStrip::Range range = quality->getRange(detid);
286  for (SiStripBadStrip::ContainerIterator bit = range.first; bit != range.second; ++bit) {
287  badStrips.push_back(quality->decode(*bit));
288  }
289  }
290  }
291  if (qualityDebugFlags & BadModules) {
292  edm::LogInfo("MeasurementTracker StripModuleStatus") <<
293  " Total modules: " << tot << ", active " << on <<", inactive " << (tot - on);
294  }
295  if (qualityDebugFlags & BadAPVFibers) {
296  edm::LogInfo("MeasurementTracker StripAPVStatus") <<
297  " Total APVs: " << atot << ", active " << (atot-aoff) <<", inactive " << (aoff);
298  edm::LogInfo("MeasurementTracker StripFiberStatus") <<
299  " Total Fibers: " << ftot << ", active " << (ftot-foff) <<", inactive " << (foff);
300  }
301  } else {
302  for (int i=0; i!=theStDetConditions.nDet(); i++) {
303  theStDetConditions.setActive(i,true); // module ON
304  theStDetConditions.set128StripStatus(i,true); // all APVs and fibers ON
305  }
306  }
307 
308 }
309 
310 void MeasurementTrackerImpl::initializePixelStatus(const SiPixelQuality *quality, const SiPixelFedCabling *pixelCabling, int qualityFlags, int qualityDebugFlags) {
311  if ((quality != 0) && (qualityFlags != 0)) {
312  edm::LogInfo("MeasurementTracker") << "qualityFlags = " << qualityFlags;
313  unsigned int on = 0, tot = 0, badrocs = 0;
314  for (std::vector<TkPixelMeasurementDet>::iterator i=thePixelDets.begin();
315  i!=thePixelDets.end(); i++) {
316  uint32_t detid = ((*i).geomDet().geographicalId()).rawId();
317  if (qualityFlags & BadModules) {
318  bool isOn = quality->IsModuleUsable(detid);
319  (i)->setActive(isOn);
320  tot++; on += (unsigned int) isOn;
321  if (qualityDebugFlags & BadModules) {
322  edm::LogInfo("MeasurementTracker")<< "MeasurementTrackerImpl::initializePixelStatus : detid " << detid << " is " << (isOn ? "on" : "off");
323  }
324  } else {
325  (i)->setActive(true);
326  }
327  if ((qualityFlags & BadROCs) && (quality->getBadRocs(detid) != 0)) {
328  std::vector<LocalPoint> badROCs = quality->getBadRocPositions(detid, *theTrackerGeom, pixelCabling);
329  badrocs += badROCs.size();
330  (i)->setBadRocPositions(badROCs);
331  } else {
332  (i)->clearBadRocPositions();
333  }
334  }
335  if (qualityDebugFlags & BadModules) {
336  edm::LogInfo("MeasurementTracker PixelModuleStatus") <<
337  " Total modules: " << tot << ", active " << on <<", inactive " << (tot - on);
338  }
339  if (qualityDebugFlags & BadROCs) {
340  edm::LogInfo("MeasurementTracker PixelROCStatus") << " Total of bad ROCs: " << badrocs ;
341  }
342  } else {
343  for (std::vector<TkPixelMeasurementDet>::iterator i=thePixelDets.begin();
344  i!=thePixelDets.end(); i++) {
345  (i)->setActive(true); // module ON
346  }
347  }
348 }
349 
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 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
std::vector< GeomDet * > DetContainer
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
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, bool isRegional=false)
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...
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
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_
const Range getRange(const uint32_t &detID) const
std::vector< TkGluedMeasurementDet > theGluedDets
short getBadRocs(const uint32_t &detid) const
PxMeasurementConditionSet thePxDetConditions
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)
tuple size
Write out results.
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
data decode(const unsigned int &value) const
const DetContainer & detsTID() const