test
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 
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 {
108  if(theTrackerGeom->detsPXB().size()!=0)
109  {if(GeomDetEnumerators::isTrackerPixel(theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsPXB().front()->geographicalId().subdetId())))
111  if(theTrackerGeom->detsPXF().size()!=0)
112  {if(GeomDetEnumerators::isTrackerPixel(theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsPXF().front()->geographicalId().subdetId())))
114  if(theTrackerGeom->detsTIB().size()!=0)
115  {if(GeomDetEnumerators::isTrackerPixel(theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsTIB().front()->geographicalId().subdetId())))
117  if(theTrackerGeom->detsTID().size()!=0)
118  {if(GeomDetEnumerators::isTrackerPixel(theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsTID().front()->geographicalId().subdetId())))
120  if(theTrackerGeom->detsTOB().size()!=0)
121  {if(GeomDetEnumerators::isTrackerPixel(theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsTOB().front()->geographicalId().subdetId())))
123  if(theTrackerGeom->detsTEC().size()!=0)
124  {if(GeomDetEnumerators::isTrackerPixel(theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsTEC().front()->geographicalId().subdetId())))
126 
127  // fist all stripdets
128  sortTKD(theStripDets);
130  for (unsigned int i=0; i!=theStripDets.size(); ++i)
132 
133  // now the glued dets
134  sortTKD(theGluedDets);
135  for (unsigned int i=0; i!=theGluedDets.size(); ++i)
137 
138  // and then the pixels, at last
139  sortTKD(thePixelDets);
141  for (unsigned int i=0; i!=thePixelDets.size(); ++i)
143 
144 }
145 
146 void MeasurementTrackerImpl::initStMeasurementConditionSet(std::vector<TkStripMeasurementDet> & stripDets)
147 {
148  // assume vector is full and ordered!
149  int size = stripDets.size();
150  theStDetConditions.init(size);
151  for (int i=0; i!=size; ++i) {
152  auto & mdet = stripDets[i];
153  mdet.setIndex(i);
154  //intialize the detId !
155  theStDetConditions.id_[i] = mdet.specificGeomDet().geographicalId().rawId();
157  //initalize the total number of strips
158  theStDetConditions.totalStrips_[i] = mdet.specificGeomDet().specificTopology().nstrips();
159  }
160 }
161 
162 void MeasurementTrackerImpl::initPxMeasurementConditionSet(std::vector<TkPixelMeasurementDet> & pixelDets)
163 {
164  // assume vector is full and ordered!
165  int size = pixelDets.size();
166  thePxDetConditions.init(size);
167 
168  for (int i=0; i!=size; ++i) {
169  auto & mdet = pixelDets[i];
170  mdet.setIndex(i);
171  thePxDetConditions.id_[i] = mdet.specificGeomDet().geographicalId().rawId();
172  }
173 }
174 
175 
176 
177 
179 {
180  for (TrackerGeometry::DetContainer::const_iterator gd=dets.begin();
181  gd != dets.end(); gd++) {
182  addPixelDet(*gd);
183  }
184 }
185 
187 {
188  for (TrackerGeometry::DetContainer::const_iterator gd=dets.begin();
189  gd != dets.end(); gd++) {
190 
191  auto gdu = (*gd);
192 
193  // StripSubdetector stripId( (**gd).geographicalId());
194  // bool isDetUnit( gdu != 0);
195  // cout << "StripSubdetector glued? " << stripId.glued()
196  // << " is DetUnit? " << isDetUnit << endl;
197 
198  if (gdu->isLeaf()) {
199  addStripDet(*gd);
200  }
201  else {
202  const GluedGeomDet* gluedDet = dynamic_cast<const GluedGeomDet*>(*gd);
203  if (gluedDet == 0) {
204  throw MeasurementDetException("MeasurementTracker ERROR: GeomDet neither DetUnit nor GluedDet");
205  }
206  addGluedDet(gluedDet);
207  }
208  }
209 }
210 
212 {
213  try {
215  }
216  catch(MeasurementDetException& err){
217  edm::LogError("MeasurementDet") << "Oops, got a MeasurementDetException: " << err.what() ;
218  }
219 }
220 
222 {
223  try {
225  }
226  catch(MeasurementDetException& err){
227  edm::LogError("MeasurementDet") << "Oops, got a MeasurementDetException: " << err.what() ;
228  }
229 }
230 
232 {
234 }
235 
237 {
238  const GluedGeomDet& gd = det.specificGeomDet();
239  const MeasurementDet* monoDet = findDet( gd.monoDet()->geographicalId());
240  const MeasurementDet* stereoDet = findDet( gd.stereoDet()->geographicalId());
241  if (monoDet == 0 || stereoDet == 0) {
242  edm::LogError("MeasurementDet") << "MeasurementTracker ERROR: GluedDet components not found as MeasurementDets ";
243  throw MeasurementDetException("MeasurementTracker ERROR: GluedDet components not found as MeasurementDets");
244  }
245  det.init(monoDet,stereoDet);
246  theDetMap[gd.geographicalId()] = &det;
247 }
248 
249 void MeasurementTrackerImpl::initializeStripStatus(const SiStripQuality *quality, int qualityFlags, int qualityDebugFlags) {
250  edm::ParameterSet cutPset = pset_.getParameter<edm::ParameterSet>("badStripCuts");
251  if (qualityFlags & BadStrips) {
252  typedef StMeasurementConditionSet::BadStripCuts BadStripCuts;
257  }
259 
260 
261  if ((quality != 0) && (qualityFlags != 0)) {
262  edm::LogInfo("MeasurementTracker") << "qualityFlags = " << qualityFlags;
263  unsigned int on = 0, tot = 0;
264  unsigned int foff = 0, ftot = 0, aoff = 0, atot = 0;
265  for (int i=0; i!= theStDetConditions.nDet(); i++) {
266  uint32_t detid = theStDetConditions.id(i);
267  if (qualityFlags & BadModules) {
268  bool isOn = quality->IsModuleUsable(detid);
270  tot++; on += (unsigned int) isOn;
271  if (qualityDebugFlags & BadModules) {
272  edm::LogInfo("MeasurementTracker")<< "MeasurementTrackerImpl::initializeStripStatus : detid " << detid << " is " << (isOn ? "on" : "off");
273  }
274  } else {
276  }
277  // first turn all APVs and fibers ON
279  if (qualityFlags & BadAPVFibers) {
280  short badApvs = quality->getBadApvs(detid);
281  short badFibers = quality->getBadFibers(detid);
282  for (int j = 0; j < 6; j++) {
283  atot++;
284  if (badApvs & (1 << j)) {
286  aoff++;
287  }
288  }
289  for (int j = 0; j < 3; j++) {
290  ftot++;
291  if (badFibers & (1 << j)) {
294  foff++;
295  }
296  }
297  }
298  auto & badStrips = theStDetConditions.getBadStripBlocks(i);
299  badStrips.clear();
300  if (qualityFlags & BadStrips) {
301  SiStripBadStrip::Range range = quality->getRange(detid);
302  for (SiStripBadStrip::ContainerIterator bit = range.first; bit != range.second; ++bit) {
303  badStrips.push_back(quality->decode(*bit));
304  }
305  }
306  }
307  if (qualityDebugFlags & BadModules) {
308  edm::LogInfo("MeasurementTracker StripModuleStatus") <<
309  " Total modules: " << tot << ", active " << on <<", inactive " << (tot - on);
310  }
311  if (qualityDebugFlags & BadAPVFibers) {
312  edm::LogInfo("MeasurementTracker StripAPVStatus") <<
313  " Total APVs: " << atot << ", active " << (atot-aoff) <<", inactive " << (aoff);
314  edm::LogInfo("MeasurementTracker StripFiberStatus") <<
315  " Total Fibers: " << ftot << ", active " << (ftot-foff) <<", inactive " << (foff);
316  }
317  } else {
318  for (int i=0; i!=theStDetConditions.nDet(); i++) {
319  theStDetConditions.setActive(i,true); // module ON
320  theStDetConditions.set128StripStatus(i,true); // all APVs and fibers ON
321  }
322  }
323 
324 }
325 
326 void MeasurementTrackerImpl::initializePixelStatus(const SiPixelQuality *quality, const SiPixelFedCabling *pixelCabling, int qualityFlags, int qualityDebugFlags) {
327  if ((quality != 0) && (qualityFlags != 0)) {
328  edm::LogInfo("MeasurementTracker") << "qualityFlags = " << qualityFlags;
329  unsigned int on = 0, tot = 0, badrocs = 0;
330  for (std::vector<TkPixelMeasurementDet>::iterator i=thePixelDets.begin();
331  i!=thePixelDets.end(); i++) {
332  uint32_t detid = ((*i).geomDet().geographicalId()).rawId();
333  if (qualityFlags & BadModules) {
334  bool isOn = quality->IsModuleUsable(detid);
335  (i)->setActive(isOn);
336  tot++; on += (unsigned int) isOn;
337  if (qualityDebugFlags & BadModules) {
338  edm::LogInfo("MeasurementTracker")<< "MeasurementTrackerImpl::initializePixelStatus : detid " << detid << " is " << (isOn ? "on" : "off");
339  }
340  } else {
341  (i)->setActive(true);
342  }
343  if ((qualityFlags & BadROCs) && (quality->getBadRocs(detid) != 0)) {
344  std::vector<LocalPoint> badROCs = quality->getBadRocPositions(detid, *theTrackerGeom, pixelCabling);
345  badrocs += badROCs.size();
346  (i)->setBadRocPositions(badROCs);
347  } else {
348  (i)->clearBadRocPositions();
349  }
350  }
351  if (qualityDebugFlags & BadModules) {
352  edm::LogInfo("MeasurementTracker PixelModuleStatus") <<
353  " Total modules: " << tot << ", active " << on <<", inactive " << (tot - on);
354  }
355  if (qualityDebugFlags & BadROCs) {
356  edm::LogInfo("MeasurementTracker PixelROCStatus") << " Total of bad ROCs: " << badrocs ;
357  }
358  } else {
359  for (std::vector<TkPixelMeasurementDet>::iterator i=thePixelDets.begin();
360  i!=thePixelDets.end(); i++) {
361  (i)->setActive(true); // module ON
362  }
363  }
364 }
365 
virtual char const * what() const
Definition: Exception.cc:141
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
const GeomDetEnumerators::SubDetector geomDetSubDetector(int subdet) const
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:21
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
bool isTrackerPixel(const GeomDetEnumerators::SubDetector m)
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