CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
PixelInactiveAreaFinder Class Reference

#include <PixelInactiveAreaFinder.h>

Classes

struct  DetGroupSpan
 
class  InactiveAreas
 

Public Types

using Area = AreaSeededTrackingRegionsBuilder::Area
 
using DetGroupSpanContainer = std::vector< DetGroupSpan >
 
using LayerSetIndex = SeedingLayerSetsHits::LayerSetIndex
 
using SeedingLayerId = SeedingLayerSetsBuilder::SeedingLayerId
 

Public Member Functions

InactiveAreas inactiveAreas (const edm::Event &iEvent, const edm::EventSetup &iSetup)
 
 PixelInactiveAreaFinder (const edm::ParameterSet &iConfig, const std::vector< SeedingLayerId > &seedingLayers, const SeedingLayerSetsLooper &seedingLayerSetsLooper, edm::ConsumesCollector &&iC)
 
 ~PixelInactiveAreaFinder ()=default
 

Static Public Member Functions

static void fillDescriptions (edm::ParameterSetDescription &desc)
 

Private Types

using det_t = uint32_t
 
using DetContainer = std::vector< uint32_t >
 
using DetectorSet = std::set< uint32_t >
 
using DetGroup = std::vector< uint32_t >
 
using DetGroupContainer = std::vector< DetGroup >
 
using DetGroupSpanContainerPair = std::pair< DetGroupSpanContainer, DetGroupSpanContainer >
 
using OverlapSpans = std::vector< DetGroupSpan >
 
using OverlapSpansContainer = std::vector< OverlapSpans >
 
using Stream = std::stringstream
 

Private Member Functions

DetGroup badAdjecentDetsBarrel (const det_t &det)
 
DetGroup badAdjecentDetsEndcap (const det_t &det)
 
DetGroupContainer badDetGroupsBarrel ()
 
DetGroupContainer badDetGroupsEndcap ()
 
void createPlottingFiles ()
 
DetGroupSpanContainerPair detGroupSpans ()
 
void detInfo (const det_t &det, Stream &ss)
 
bool detWorks (det_t det)
 
void getBadPixelDets (const edm::Event &iEvent, const edm::EventSetup &iSetup)
 
void getPhiSpanBarrel (const DetGroup &detGroup, DetGroupSpan &cspan)
 
void getPhiSpanEndcap (const DetGroup &detGroup, DetGroupSpan &cspan)
 
void getRSpan (const DetGroup &detGroup, DetGroupSpan &cspan)
 
void getSpan (const DetGroup &detGroup, DetGroupSpan &cspan)
 
void getZSpan (const DetGroup &detGroup, DetGroupSpan &cspan)
 
void printBadDetGroups ()
 
void printBadDetGroupSpans ()
 
void printBadPixelDets ()
 
void printPixelDets ()
 
DetGroup reachableDetGroup (const det_t &initDet, DetectorSet &foundDets)
 
void updatePixelDets (const edm::EventSetup &iSetup)
 

Private Attributes

DetContainer badPixelDetsBarrel_
 
DetContainer badPixelDetsEndcap_
 
std::vector< edm::EDGetTokenT< PixelFEDChannelCollection > > badPixelFEDChannelsTokens_
 
const bool createPlottingFiles_
 
const bool debug_
 
edm::ESWatcher< TrackerDigiGeometryRecordgeometryWatcher_
 
const bool ignoreSingleFPixPanelModules_
 
std::vector< SeedingLayerIdinactiveLayers_
 
std::vector< std::pair< unsigned short, unsigned short > > inactiveLayerSetIndices_
 
std::vector< edm::EDGetTokenT< DetIdCollection > > inactivePixelDetectorTokens_
 
std::vector< std::vector< LayerSetIndex > > layerSetIndexInactiveToActive_
 
std::array< unsigned short, 4 > nBPixLadders
 
unsigned short nModulesPerLadder
 
DetContainer pixelDetsBarrel_
 
DetContainer pixelDetsEndcap_
 
const SiPixelQualitypixelQuality_ = 0
 
const TrackerGeometrytrackerGeometry_ = 0
 
const TrackerTopologytrackerTopology_ = 0
 

Detailed Description

Definition at line 21 of file PixelInactiveAreaFinder.h.

Member Typedef Documentation

Definition at line 23 of file PixelInactiveAreaFinder.h.

using PixelInactiveAreaFinder::det_t = uint32_t
private

Definition at line 99 of file PixelInactiveAreaFinder.h.

using PixelInactiveAreaFinder::DetContainer = std::vector<uint32_t>
private

Definition at line 100 of file PixelInactiveAreaFinder.h.

using PixelInactiveAreaFinder::DetectorSet = std::set<uint32_t>
private

Definition at line 103 of file PixelInactiveAreaFinder.h.

using PixelInactiveAreaFinder::DetGroup = std::vector<uint32_t>
private

Definition at line 101 of file PixelInactiveAreaFinder.h.

Definition at line 102 of file PixelInactiveAreaFinder.h.

Definition at line 36 of file PixelInactiveAreaFinder.h.

Definition at line 92 of file PixelInactiveAreaFinder.h.

Definition at line 25 of file PixelInactiveAreaFinder.h.

Definition at line 93 of file PixelInactiveAreaFinder.h.

Definition at line 94 of file PixelInactiveAreaFinder.h.

Definition at line 24 of file PixelInactiveAreaFinder.h.

using PixelInactiveAreaFinder::Stream = std::stringstream
private

Definition at line 104 of file PixelInactiveAreaFinder.h.

Constructor & Destructor Documentation

PixelInactiveAreaFinder::PixelInactiveAreaFinder ( const edm::ParameterSet iConfig,
const std::vector< SeedingLayerId > &  seedingLayers,
const SeedingLayerSetsLooper seedingLayerSetsLooper,
edm::ConsumesCollector &&  iC 
)

Definition at line 462 of file PixelInactiveAreaFinder.cc.

References badPixelFEDChannelsTokens_, HLT_2018_cff::distance, Exception, spr::find(), newFWLiteAna::found, mps_fire::i, inactiveLayers_, inactiveLayerSetIndices_, layerSetIndexInactiveToActive_, LogDebug, LogTrace, runTheMatrix::ret, HLT_2018_cff::seedingLayers, GlobalPosition_Frontier_DevDB_cff::tag, and edm::vector_transform().

467  : debug_(iConfig.getUntrackedParameter<bool>("debug")),
468  createPlottingFiles_(iConfig.getUntrackedParameter<bool>("createPlottingFiles")),
469  ignoreSingleFPixPanelModules_(iConfig.getParameter<bool>("ignoreSingleFPixPanelModules")),
471  edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag>>("inactivePixelDetectorLabels"),
472  [&](const auto& tag) { return iC.consumes<DetIdCollection>(tag); })),
474  edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag>>("badPixelFEDChannelCollectionLabels"),
475  [&](const auto& tag) { return iC.consumes<PixelFEDChannelCollection>(tag); })) {
476 #ifdef EDM_ML_DEBUG
477  for (const auto& layer : seedingLayers) {
478  LogTrace("PixelInactiveAreaFinder") << "Input layer subdet " << std::get<0>(layer) << " side "
479  << static_cast<unsigned int>(std::get<1>(layer)) << " layer "
480  << std::get<2>(layer);
481  }
482 #endif
483 
484  auto findOrAdd = [&](SeedingLayerId layer) -> unsigned short {
485  auto found = std::find(inactiveLayers_.cbegin(), inactiveLayers_.cend(), layer);
486  if (found == inactiveLayers_.cend()) {
487  auto ret = inactiveLayers_.size();
488  inactiveLayers_.push_back(layer);
489  return ret;
490  }
491  return std::distance(inactiveLayers_.cbegin(), found);
492  };
493 
494  // mapping from active layer pairs to inactive layer pairs
495  const auto activeToInactiveMap = createActiveToInactiveMap();
496 
497  // convert input layer pairs (that are for active layers) to layer
498  // pairs to look for inactive areas
499  LayerSetIndex i = 0;
500  for (const auto& layerSet : seedingLayerSetsLooper.makeRange(seedingLayers)) {
501  assert(layerSet.size() == 2);
502  auto found = activeToInactiveMap.find(std::make_pair(layerSet[0], layerSet[1]));
503  if (found == activeToInactiveMap.end()) {
504  throw cms::Exception("Configuration")
505  << "Encountered layer pair " << layerSet[0] << "+" << layerSet[1]
506  << " not found from the internal 'active layer pairs' to 'inactive layer pairs' mapping; either fix the "
507  "input or the mapping (in PixelInactiveAreaFinder.cc)";
508  }
509 
510  LogTrace("PixelInactiveAreaFinder") << "Input layer set " << layerSet[0] << "+" << layerSet[1];
511  for (const auto& inactiveLayerSet : found->second) {
512  auto innerInd = findOrAdd(inactiveLayerSet.first);
513  auto outerInd = findOrAdd(inactiveLayerSet.second);
514 
515  auto found = std::find(
516  inactiveLayerSetIndices_.cbegin(), inactiveLayerSetIndices_.cend(), std::make_pair(innerInd, outerInd));
517  if (found == inactiveLayerSetIndices_.end()) {
518  inactiveLayerSetIndices_.emplace_back(innerInd, outerInd);
519  layerSetIndexInactiveToActive_.push_back(std::vector<LayerSetIndex>{i});
520  } else {
522  .push_back(i); // TODO: move to operator[] once finished
523  }
524 
525  LogTrace("PixelInactiveAreaFinder")
526  << " inactive layer set " << inactiveLayerSet.first << "+" << inactiveLayerSet.second;
527  }
528 
529  ++i;
530  }
531 
532 #ifdef EDM_ML_DEBUG
533  LogDebug("PixelInactiveAreaFinder") << "All inactive layer sets";
534  for (const auto& idxPair : inactiveLayerSetIndices_) {
535  LogTrace("PixelInactiveAreaFinder") << " " << inactiveLayers_[idxPair.first] << "+"
536  << inactiveLayers_[idxPair.second];
537  }
538 #endif
539 }
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
SeedingLayerSetsBuilder::SeedingLayerId SeedingLayerId
std::vector< edm::EDGetTokenT< DetIdCollection > > inactivePixelDetectorTokens_
ret
prodAgent to be discontinued
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< std::pair< unsigned short, unsigned short > > inactiveLayerSetIndices_
#define LogTrace(id)
std::vector< edm::EDGetTokenT< PixelFEDChannelCollection > > badPixelFEDChannelsTokens_
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
LayerSetRange< T > makeRange(const T &container) const
std::vector< std::vector< LayerSetIndex > > layerSetIndexInactiveToActive_
std::vector< SeedingLayerId > inactiveLayers_
SeedingLayerSetsHits::LayerSetIndex LayerSetIndex
PixelInactiveAreaFinder::~PixelInactiveAreaFinder ( )
default

Member Function Documentation

PixelInactiveAreaFinder::DetGroup PixelInactiveAreaFinder::badAdjecentDetsBarrel ( const det_t det)
private

Definition at line 898 of file PixelInactiveAreaFinder.cc.

References HltBtagPostValidation_cff::c, detWorks(), PVValHelper::ladder, nBPixLadders, nModulesPerLadder, and trackerTopology_.

Referenced by reachableDetGroup().

898  {
899  using std::remove_if;
900 
901  DetGroup adj;
902  auto const tTopo = trackerTopology_;
903  auto const& detId = DetId(det);
904  unsigned int layer = tTopo->pxbLayer(detId);
905  unsigned int ladder = tTopo->pxbLadder(detId);
906  unsigned int module = tTopo->pxbModule(detId);
907  unsigned int nLads = nBPixLadders[layer];
908  //add detectors from next and previous ladder
909  adj.push_back(tTopo->pxbDetId(layer, ((ladder - 1) + 1) % nLads + 1, module)());
910  adj.push_back(tTopo->pxbDetId(layer, ((ladder - 1) - 1 + nLads) % nLads + 1, module)());
911  //add adjecent detectors from same ladder
912  if (module == 1) {
913  adj.push_back(tTopo->pxbDetId(layer, ladder, module + 1)());
914  } else if (module == nModulesPerLadder) {
915  adj.push_back(tTopo->pxbDetId(layer, ladder, module - 1)());
916  } else {
917  adj.push_back(tTopo->pxbDetId(layer, ladder, module + 1)());
918  adj.push_back(tTopo->pxbDetId(layer, ladder, module - 1)());
919  }
920  //remove working detectors from list
921  adj.erase(remove_if(adj.begin(), adj.end(), [&](auto c) { return this->detWorks(c); }), adj.end());
922  return adj;
923 }
std::array< unsigned short, 4 > nBPixLadders
Definition: DetId.h:17
const TrackerTopology * trackerTopology_
Definition: vlib.h:198
PixelInactiveAreaFinder::DetGroup PixelInactiveAreaFinder::badAdjecentDetsEndcap ( const det_t det)
private

Definition at line 924 of file PixelInactiveAreaFinder.cc.

References badPixelDetsEndcap_, TrackerGeometry::idToDet(), SequenceTypes::ignore(), Surface::phiSpan(), TrackerTopology::pxfDisk(), GeomDet::surface(), trackerGeometry_, trackerTopology_, and z.

Referenced by reachableDetGroup().

924  {
925  // this might be faster if adjecent
926  using std::ignore;
927  using std::tie;
928  DetGroup adj;
929  Span_t phiSpan, phiSpanComp;
930  float z, zComp;
931  unsigned int disk, diskComp;
932  auto const& detSurf = trackerGeometry_->idToDet(DetId(det))->surface();
933  phiSpan = detSurf.phiSpan();
934  tie(z, ignore) = detSurf.zSpan();
935  disk = trackerTopology_->pxfDisk(DetId(det));
936  // add detectors from same disk whose phi ranges overlap to the adjecent list
937  for (auto const& detComp : badPixelDetsEndcap_) {
938  auto const& detIdComp = DetId(detComp);
939  auto const& detSurfComp = trackerGeometry_->idToDet(detIdComp)->surface();
940  diskComp = trackerTopology_->pxfDisk(detIdComp);
941  phiSpanComp = detSurfComp.phiSpan();
942  tie(zComp, ignore) = detSurfComp.zSpan();
943  if (det != detComp && disk == diskComp && z * zComp > 0 && phiRangesOverlap(phiSpan, phiSpanComp)) {
944  adj.push_back(detComp);
945  }
946  }
947  return adj;
948 }
unsigned int pxfDisk(const DetId &id) const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
std::pair< float, float > const & phiSpan() const
Definition: Surface.h:92
const TrackerGeometry * trackerGeometry_
def ignore(seq)
Definition: DetId.h:17
const TrackerTopology * trackerTopology_
const TrackerGeomDet * idToDet(DetId) const override
PixelInactiveAreaFinder::DetGroupContainer PixelInactiveAreaFinder::badDetGroupsBarrel ( )
private

Definition at line 978 of file PixelInactiveAreaFinder.cc.

References badPixelDetsBarrel_, and reachableDetGroup().

Referenced by detGroupSpans(), and printBadDetGroups().

978  {
979  DetGroupContainer detGroups;
980  DetectorSet foundDets;
981  for (auto const& badDet : badPixelDetsBarrel_) {
982  if (foundDets.find(badDet) == foundDets.end()) {
983  detGroups.push_back(this->reachableDetGroup(badDet, foundDets));
984  }
985  }
986  return detGroups;
987 }
DetGroup reachableDetGroup(const det_t &initDet, DetectorSet &foundDets)
std::set< uint32_t > DetectorSet
std::vector< DetGroup > DetGroupContainer
PixelInactiveAreaFinder::DetGroupContainer PixelInactiveAreaFinder::badDetGroupsEndcap ( )
private

Definition at line 988 of file PixelInactiveAreaFinder.cc.

References badPixelDetsEndcap_, ignoreSingleFPixPanelModules_, and reachableDetGroup().

Referenced by detGroupSpans(), and printBadDetGroups().

988  {
989  DetGroupContainer detGroups;
990  DetectorSet foundDets;
991  for (auto const& badDet : badPixelDetsEndcap_) {
992  if (foundDets.find(badDet) == foundDets.end()) {
993  auto adjacentDets = this->reachableDetGroup(badDet, foundDets);
994  if (ignoreSingleFPixPanelModules_ && adjacentDets.size() == 1) {
995  // size==1 means that only a single panel of a blade was inactive
996  // because of the large overlap with the other panel (i.e.
997  // redundancy in the detectory) ignoring these may help to decrease fakes
998  continue;
999  }
1000  detGroups.push_back(adjacentDets);
1001  }
1002  }
1003  return detGroups;
1004 }
DetGroup reachableDetGroup(const det_t &initDet, DetectorSet &foundDets)
std::set< uint32_t > DetectorSet
std::vector< DetGroup > DetGroupContainer
void PixelInactiveAreaFinder::createPlottingFiles ( )
private

Definition at line 852 of file PixelInactiveAreaFinder.cc.

References badPixelDetsBarrel_, badPixelDetsEndcap_, detGroupSpans(), detInfo(), pixelDetsBarrel_, pixelDetsEndcap_, contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by inactiveAreas().

852  {
853  // All detectors to file DETECTORS
854  Stream ss;
855  std::ofstream fsDet("DETECTORS.txt");
856  for (auto const& det : pixelDetsBarrel_) {
857  detInfo(det, ss);
858  ss << std::endl;
859  }
860  edm::LogPrint("PixelInactiveAreaFinder") << "Endcap detectors;";
861  for (auto const& det : pixelDetsEndcap_) {
862  detInfo(det, ss);
863  ss << std::endl;
864  }
865  fsDet << ss.rdbuf();
866  ss.str(std::string());
867  // Bad detectors
868  std::ofstream fsBadDet("BADDETECTORS.txt");
869  for (auto const& det : badPixelDetsBarrel_) {
870  detInfo(det, ss);
871  ss << std::endl;
872  }
873  for (auto const& det : badPixelDetsEndcap_) {
874  detInfo(det, ss);
875  ss << std::endl;
876  }
877  fsBadDet << ss.rdbuf();
878  ss.str(std::string());
879  // detgroupspans
880  std::ofstream fsSpans("DETGROUPSPANS.txt");
882  for (auto const& cspan : cspans.first) {
883  detGroupSpanInfo(cspan, ss);
884  ss << std::endl;
885  }
886  for (auto const& cspan : cspans.second) {
887  detGroupSpanInfo(cspan, ss);
888  ss << std::endl;
889  }
890  fsSpans << ss.rdbuf();
891  ss.str(std::string());
892 }
void detInfo(const det_t &det, Stream &ss)
DetGroupSpanContainerPair detGroupSpans()
std::pair< DetGroupSpanContainer, DetGroupSpanContainer > DetGroupSpanContainerPair
PixelInactiveAreaFinder::DetGroupSpanContainerPair PixelInactiveAreaFinder::detGroupSpans ( )
private

Definition at line 1141 of file PixelInactiveAreaFinder.cc.

References badDetGroupsBarrel(), badDetGroupsEndcap(), and getSpan().

Referenced by createPlottingFiles(), inactiveAreas(), and printBadDetGroupSpans().

1141  {
1142  DetGroupSpanContainer cspansBarrel;
1143  DetGroupSpanContainer cspansEndcap;
1144  DetGroupContainer badDetGroupsBar = badDetGroupsBarrel();
1145  DetGroupContainer badDetGroupsEnd = badDetGroupsEndcap();
1146  for (auto const& detGroup : badDetGroupsBar) {
1147  DetGroupSpan cspan;
1148  getSpan(detGroup, cspan);
1149  cspansBarrel.push_back(cspan);
1150  }
1151  for (auto const& detGroup : badDetGroupsEnd) {
1152  DetGroupSpan cspan;
1153  getSpan(detGroup, cspan);
1154  cspansEndcap.push_back(cspan);
1155  }
1156  return DetGroupSpanContainerPair(cspansBarrel, cspansEndcap);
1157 }
DetGroupContainer badDetGroupsEndcap()
DetGroupContainer badDetGroupsBarrel()
std::vector< DetGroup > DetGroupContainer
std::vector< DetGroupSpan > DetGroupSpanContainer
void getSpan(const DetGroup &detGroup, DetGroupSpan &cspan)
std::pair< DetGroupSpanContainer, DetGroupSpanContainer > DetGroupSpanContainerPair
void PixelInactiveAreaFinder::detInfo ( const det_t det,
Stream ss 
)
private

Definition at line 738 of file PixelInactiveAreaFinder.cc.

References alignBH_cfg::fixed, TrackerGeometry::idToDet(), PVValHelper::ladder, Surface::phiSpan(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, TrackerTopology::pxbLadder(), TrackerTopology::pxbLayer(), TrackerTopology::pxbModule(), TrackerTopology::pxfBlade(), TrackerTopology::pxfDisk(), TrackerTopology::pxfPanel(), AlCaHLTBitMon_QueryRunRegistry::string, DetId::subdetId(), GeomDet::surface(), trackerGeometry_, and trackerTopology_.

Referenced by createPlottingFiles(), printBadDetGroups(), printBadPixelDets(), and printPixelDets().

738  {
739  using std::fixed;
740  using std::left;
741  using std::noshowpos;
742  using std::right;
743  using std::setfill;
744  using std::setprecision;
745  using std::setw;
746  using std::showpos;
747  using std::tie;
748  std::string deli = "; ";
749  ss << "id:[" << det << "]" << deli;
750  ss << "subdetid:[" << DetId(det).subdetId() << "]" << deli;
751  if (DetId(det).subdetId() == PixelSubdetector::PixelBarrel) {
752  unsigned int layer = trackerTopology_->pxbLayer(DetId(det));
753  unsigned int ladder = trackerTopology_->pxbLadder(DetId(det));
754  unsigned int module = trackerTopology_->pxbModule(DetId(det));
755  ss << "layer:[" << layer << "]" << deli << "ladder:[" << right << setw(2) << ladder << "]" << deli << "module:["
756  << module << "]" << deli;
757  } else if (DetId(det).subdetId() == PixelSubdetector::PixelEndcap) {
758  unsigned int disk = trackerTopology_->pxfDisk(DetId(det));
759  unsigned int blade = trackerTopology_->pxfBlade(DetId(det));
760  unsigned int panel = trackerTopology_->pxfPanel(DetId(det));
761  ss << left << setw(6) << "disk:"
762  << "[" << right << disk << "]" << deli << left << setw(7) << "blade:"
763  << "[" << setw(2) << right << blade << "]" << deli << left << setw(7) << "panel:"
764  << "[" << right << panel << "]" << deli;
765  }
766  float phiA, phiB, zA, zB, rA, rB;
767  auto detSurface = trackerGeometry_->idToDet(DetId(det))->surface();
768  tie(phiA, phiB) = detSurface.phiSpan();
769  tie(zA, zB) = detSurface.zSpan();
770  tie(rA, rB) = detSurface.rSpan();
771  ss << setprecision(16) << fixed << showpos << setfill(' ') << "phi:[" << right << setw(12) << phiA << "," << left
772  << setw(12) << phiB << "]" << deli << "z:[" << right << setw(7) << zA << "," << left << setw(7) << zB << "]"
773  << deli << noshowpos << "r:[" << right << setw(10) << rA << "," << left << setw(10) << rB << "]" << deli;
774 }
unsigned int pxfDisk(const DetId &id) const
unsigned int pxbLadder(const DetId &id) const
unsigned int pxbModule(const DetId &id) const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
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::pair< float, float > const & phiSpan() const
Definition: Surface.h:92
const TrackerGeometry * trackerGeometry_
unsigned int pxbLayer(const DetId &id) const
Definition: DetId.h:17
const TrackerTopology * trackerTopology_
const TrackerGeomDet * idToDet(DetId) const override
Definition: vlib.h:198
unsigned int pxfPanel(const DetId &id) const
unsigned int pxfBlade(const DetId &id) const
bool PixelInactiveAreaFinder::detWorks ( det_t  det)
private

Definition at line 894 of file PixelInactiveAreaFinder.cc.

References badPixelDetsBarrel_, badPixelDetsEndcap_, and spr::find().

Referenced by badAdjecentDetsBarrel().

894  {
895  return std::find(badPixelDetsBarrel_.begin(), badPixelDetsBarrel_.end(), det) == badPixelDetsBarrel_.end() &&
897 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void PixelInactiveAreaFinder::fillDescriptions ( edm::ParameterSetDescription desc)
static

Definition at line 541 of file PixelInactiveAreaFinder.cc.

References edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), and HLT_2018_cff::InputTag.

Referenced by PixelInactiveAreaTrackingRegionsSeedingLayersProducer::fillDescriptions().

541  {
542  desc.add<std::vector<edm::InputTag>>("inactivePixelDetectorLabels",
543  std::vector<edm::InputTag>{{edm::InputTag("siPixelDigis")}})
544  ->setComment("One or more DetIdCollections of modules to mask on the fly for a given event");
545  desc.add<std::vector<edm::InputTag>>("badPixelFEDChannelCollectionLabels",
546  std::vector<edm::InputTag>{{edm::InputTag("siPixelDigis")}})
547  ->setComment("One or more PixelFEDChannelCollections of modules+ROCs to mask on the fly for a given event");
548  desc.add<bool>("ignoreSingleFPixPanelModules", false);
549 
550  desc.addUntracked<bool>("debug", false);
551  desc.addUntracked<bool>("createPlottingFiles", false);
552 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void PixelInactiveAreaFinder::getBadPixelDets ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
private

Definition at line 691 of file PixelInactiveAreaFinder.cc.

References badPixelDetsBarrel_, badPixelDetsEndcap_, badPixelFEDChannelsTokens_, edm::EventSetup::get(), SiPixelQuality::getBadComponentList(), edm::Event::getByToken(), triggerObjects_cff::id, inactivePixelDetectorTokens_, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, unpackBuffers-CaloStage2::token, and tier0::unique().

Referenced by inactiveAreas().

691  {
692  auto addDetId = [&](const auto id) {
693  const auto detid = DetId(id);
694  const auto subdet = detid.subdetId();
695  if (subdet == PixelSubdetector::PixelBarrel) {
696  badPixelDetsBarrel_.push_back(detid.rawId());
697  } else if (subdet == PixelSubdetector::PixelEndcap) {
698  badPixelDetsEndcap_.push_back(detid.rawId());
699  }
700  };
701 
702  // SiPixelQuality
703  edm::ESHandle<SiPixelQuality> pixelQuality;
704  iSetup.get<SiPixelQualityRcd>().get(pixelQuality);
705 
706  for (auto const& disabledModule : pixelQuality->getBadComponentList()) {
707  addDetId(disabledModule.DetID);
708  }
709 
710  // dynamic bad modules
711  for (const auto& token : inactivePixelDetectorTokens_) {
713  iEvent.getByToken(token, detIds);
714  for (const auto& id : *detIds) {
715  addDetId(id);
716  }
717  }
718 
719  // dynamic bad ROCs ("Fed25")
720  // TODO: consider moving to finer-grained areas for inactive ROCs
721  for (const auto& token : badPixelFEDChannelsTokens_) {
722  edm::Handle<PixelFEDChannelCollection> pixelFEDChannelCollectionHandle;
723  iEvent.getByToken(token, pixelFEDChannelCollectionHandle);
724  for (const auto& disabledChannels : *pixelFEDChannelCollectionHandle) {
725  addDetId(disabledChannels.detId());
726  }
727  }
728 
729  // remove duplicates
730  std::sort(badPixelDetsBarrel_.begin(), badPixelDetsBarrel_.end());
731  std::sort(badPixelDetsEndcap_.begin(), badPixelDetsEndcap_.end());
733  badPixelDetsBarrel_.end());
735  badPixelDetsEndcap_.end());
736 }
std::vector< edm::EDGetTokenT< DetIdCollection > > inactivePixelDetectorTokens_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
def unique(seq, keepstr=True)
Definition: tier0.py:24
const std::vector< disabledModuleType > getBadComponentList() const
std::vector< edm::EDGetTokenT< PixelFEDChannelCollection > > badPixelFEDChannelsTokens_
Definition: DetId.h:17
T get() const
Definition: EventSetup.h:73
void PixelInactiveAreaFinder::getPhiSpanBarrel ( const DetGroup detGroup,
DetGroupSpan cspan 
)
private

Definition at line 1006 of file PixelInactiveAreaFinder.cc.

References PixelInactiveAreaFinder::DetGroupSpan::disk, geometryDiff::epsilon, mps_fire::i, TrackerGeometry::idToDet(), createfilelist::int, PixelInactiveAreaFinder::DetGroupSpan::layer, nBPixLadders, PixelInactiveAreaFinder::DetGroupSpan::phiSpan, Surface::phiSpan(), TrackerTopology::pxbDetId(), TrackerTopology::pxbLadder(), TrackerTopology::pxbLayer(), GeomDet::surface(), trackerGeometry_, trackerTopology_, and parallelization::uint.

Referenced by getSpan(), and printBadDetGroups().

1006  {
1007  // find phiSpan using ordered vector of unique ladders in detGroup
1008  if (detGroup.empty()) {
1009  cspan = DetGroupSpan();
1010  return;
1011  } else {
1012  cspan.layer = trackerTopology_->pxbLayer(DetId(detGroup[0]));
1013  cspan.disk = 0;
1014  }
1015  using uint = unsigned int;
1016  using LadderSet = std::set<uint>;
1017  using LadVec = std::vector<uint>;
1018  LadderSet lads;
1019  for (auto const& det : detGroup) {
1020  lads.insert(trackerTopology_->pxbLadder(DetId(det)));
1021  }
1022  LadVec ladv(lads.begin(), lads.end());
1023  uint nLadders = nBPixLadders[cspan.layer];
1024  // find start ladder of detGroup
1025  uint i = 0;
1026  uint currentLadder = ladv[0];
1027  uint previousLadder = ladv[(ladv.size() + i - 1) % ladv.size()];
1028  // loop until discontinuity is found from vector
1029  while ((nLadders + currentLadder - 1) % nLadders == previousLadder) {
1030  ++i;
1031  currentLadder = ladv[i % ladv.size()];
1032  previousLadder = ladv[(ladv.size() + i - 1) % ladv.size()];
1033  if (i == ladv.size()) {
1034  cspan.phiSpan.first = std::numeric_limits<float>::epsilon();
1035  cspan.phiSpan.second = -std::numeric_limits<float>::epsilon();
1036  return;
1037  }
1038  }
1039  uint startLadder = currentLadder;
1040  uint endLadder = previousLadder;
1041  auto detStart = trackerTopology_->pxbDetId(cspan.layer, startLadder, 1);
1042  auto detEnd = trackerTopology_->pxbDetId(cspan.layer, endLadder, 1);
1043  cspan.phiSpan.first = trackerGeometry_->idToDet(detStart)->surface().phiSpan().first;
1044  cspan.phiSpan.second = trackerGeometry_->idToDet(detEnd)->surface().phiSpan().second;
1045 }
std::array< unsigned short, 4 > nBPixLadders
unsigned int pxbLadder(const DetId &id) const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
std::pair< float, float > const & phiSpan() const
Definition: Surface.h:92
const TrackerGeometry * trackerGeometry_
unsigned int pxbLayer(const DetId &id) const
Definition: DetId.h:17
const TrackerTopology * trackerTopology_
const TrackerGeomDet * idToDet(DetId) const override
DetId pxbDetId(uint32_t layer, uint32_t ladder, uint32_t module) const
void PixelInactiveAreaFinder::getPhiSpanEndcap ( const DetGroup detGroup,
DetGroupSpan cspan 
)
private

Definition at line 1046 of file PixelInactiveAreaFinder.cc.

References counter, geometryDiff::epsilon, newFWLiteAna::found, PixelInactiveAreaFinder::DetGroupSpan::phiSpan, contentValuesCheck::ss, and trackerGeometry_.

Referenced by getSpan(), and printBadDetGroups().

1046  {
1047  // this is quite naive/bruteforce method
1048  // 1) it starts by taking one detector from detGroup and starts to compare it to others
1049  // 2) when it finds overlapping detector in clockwise direction it starts comparing
1050  // found detector to others
1051  // 3) search stops until no overlapping detectors in clockwise detector or all detectors
1052  // have been work detector
1053  Stream ss;
1054  bool found = false;
1055  auto const tGeom = trackerGeometry_;
1056  DetGroup::const_iterator startDetIter = detGroup.begin();
1057  Span_t phiSpan, phiSpanComp;
1058  unsigned int counter = 0;
1059  while (!found) {
1060  phiSpan = tGeom->idToDet(DetId(*startDetIter))->surface().phiSpan();
1061  for (DetGroup::const_iterator compDetIter = detGroup.begin(); compDetIter != detGroup.end(); ++compDetIter) {
1062  phiSpanComp = tGeom->idToDet(DetId(*compDetIter))->surface().phiSpan();
1063  if (phiRangesOverlap(phiSpan, phiSpanComp) && phiMoreClockwise(phiSpanComp.first, phiSpan.first) &&
1064  startDetIter != compDetIter) {
1065  ++counter;
1066  if (counter > detGroup.size()) {
1067  cspan.phiSpan.first = std::numeric_limits<float>::epsilon();
1068  cspan.phiSpan.second = -std::numeric_limits<float>::epsilon();
1069  return;
1070  }
1071  startDetIter = compDetIter;
1072  break;
1073  } else if (compDetIter == detGroup.end() - 1) {
1074  found = true;
1075  }
1076  }
1077  }
1078  cspan.phiSpan.first = phiSpan.first;
1079  // second with same method}
1080  found = false;
1081  DetGroup::const_iterator endDetIter = detGroup.begin();
1082  counter = 0;
1083  while (!found) {
1084  phiSpan = tGeom->idToDet(DetId(*endDetIter))->surface().phiSpan();
1085  for (DetGroup::const_iterator compDetIter = detGroup.begin(); compDetIter != detGroup.end(); ++compDetIter) {
1086  phiSpanComp = tGeom->idToDet(DetId(*compDetIter))->surface().phiSpan();
1087  if (phiRangesOverlap(phiSpan, phiSpanComp) && phiMoreCounterclockwise(phiSpanComp.second, phiSpan.second) &&
1088  endDetIter != compDetIter) {
1089  ++counter;
1090  if (counter > detGroup.size()) {
1091  cspan.phiSpan.first = std::numeric_limits<float>::epsilon();
1092  cspan.phiSpan.second = -std::numeric_limits<float>::epsilon();
1093  return;
1094  }
1095  endDetIter = compDetIter;
1096  break;
1097  } else if (compDetIter == detGroup.end() - 1) {
1098  found = true;
1099  }
1100  }
1101  }
1102  cspan.phiSpan.second = phiSpan.second;
1103 }
const TrackerGeometry * trackerGeometry_
Definition: DetId.h:17
static std::atomic< unsigned int > counter
void PixelInactiveAreaFinder::getRSpan ( const DetGroup detGroup,
DetGroupSpan cspan 
)
private

Definition at line 1114 of file PixelInactiveAreaFinder.cc.

References TrackerGeometry::idToDet(), PixelInactiveAreaFinder::DetGroupSpan::rSpan, Surface::rSpan(), GeomDet::surface(), and trackerGeometry_.

Referenced by getSpan(), and printBadDetGroups().

1114  {
1115  auto cmpFun = [this](det_t detA, det_t detB) {
1116  return trackerGeometry_->idToDet(DetId(detA))->surface().rSpan().first <
1117  trackerGeometry_->idToDet(DetId(detB))->surface().rSpan().first;
1118  };
1119 
1120  auto minmaxIters = std::minmax_element(detGroup.begin(), detGroup.end(), cmpFun);
1121  cspan.rSpan.first = trackerGeometry_->idToDet(DetId(*(minmaxIters.first)))->surface().rSpan().first;
1122  cspan.rSpan.second = trackerGeometry_->idToDet(DetId(*(minmaxIters.second)))->surface().rSpan().second;
1123 }
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
std::pair< float, float > const & rSpan() const
Definition: Surface.h:94
const TrackerGeometry * trackerGeometry_
Definition: DetId.h:17
const TrackerGeomDet * idToDet(DetId) const override
void PixelInactiveAreaFinder::getSpan ( const DetGroup detGroup,
DetGroupSpan cspan 
)
private

Definition at line 1124 of file PixelInactiveAreaFinder.cc.

References PixelInactiveAreaFinder::DetGroupSpan::disk, getPhiSpanBarrel(), getPhiSpanEndcap(), getRSpan(), getZSpan(), PixelInactiveAreaFinder::DetGroupSpan::layer, TrackerTopology::pxbLayer(), TrackerTopology::pxfDisk(), PixelInactiveAreaFinder::DetGroupSpan::subdetId, DetId::subdetId(), and trackerTopology_.

Referenced by detGroupSpans().

1124  {
1125  auto firstDetIt = detGroup.begin();
1126  if (firstDetIt != detGroup.end()) {
1127  cspan.subdetId = DetId(*firstDetIt).subdetId();
1128  if (cspan.subdetId == 1) {
1129  cspan.layer = trackerTopology_->pxbLayer(DetId(*firstDetIt));
1130  cspan.disk = 0;
1131  getPhiSpanBarrel(detGroup, cspan);
1132  } else if (cspan.subdetId == 2) {
1133  cspan.disk = trackerTopology_->pxfDisk(DetId(*firstDetIt));
1134  cspan.layer = 0;
1135  getPhiSpanEndcap(detGroup, cspan);
1136  }
1137  getZSpan(detGroup, cspan);
1138  getRSpan(detGroup, cspan);
1139  }
1140 }
unsigned int pxfDisk(const DetId &id) const
void getRSpan(const DetGroup &detGroup, DetGroupSpan &cspan)
void getPhiSpanBarrel(const DetGroup &detGroup, DetGroupSpan &cspan)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
unsigned int pxbLayer(const DetId &id) const
Definition: DetId.h:17
const TrackerTopology * trackerTopology_
void getPhiSpanEndcap(const DetGroup &detGroup, DetGroupSpan &cspan)
void getZSpan(const DetGroup &detGroup, DetGroupSpan &cspan)
void PixelInactiveAreaFinder::getZSpan ( const DetGroup detGroup,
DetGroupSpan cspan 
)
private

Definition at line 1104 of file PixelInactiveAreaFinder.cc.

References TrackerGeometry::idToDet(), GeomDet::surface(), trackerGeometry_, PixelInactiveAreaFinder::DetGroupSpan::zSpan, and Surface::zSpan().

Referenced by getSpan(), and printBadDetGroups().

1104  {
1105  auto cmpFun = [this](det_t detA, det_t detB) {
1106  return trackerGeometry_->idToDet(DetId(detA))->surface().zSpan().first <
1107  trackerGeometry_->idToDet(DetId(detB))->surface().zSpan().first;
1108  };
1109 
1110  auto minmaxIters = std::minmax_element(detGroup.begin(), detGroup.end(), cmpFun);
1111  cspan.zSpan.first = trackerGeometry_->idToDet(DetId(*(minmaxIters.first)))->surface().zSpan().first;
1112  cspan.zSpan.second = trackerGeometry_->idToDet(DetId(*(minmaxIters.second)))->surface().zSpan().second;
1113 }
std::pair< float, float > const & zSpan() const
Definition: Surface.h:93
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
const TrackerGeometry * trackerGeometry_
Definition: DetId.h:17
const TrackerGeomDet * idToDet(DetId) const override
PixelInactiveAreaFinder::InactiveAreas PixelInactiveAreaFinder::inactiveAreas ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 554 of file PixelInactiveAreaFinder.cc.

References Barrel, createPlottingFiles(), createPlottingFiles_, debug_, detGroupSpans(), HLT_2018_cff::distance, spr::find(), newFWLiteAna::found, edm::EventSetup::get(), getBadPixelDets(), inactiveLayers_, inactiveLayerSetIndices_, layerSetIndexInactiveToActive_, eostools::move(), NegEndcap, PixelSubdetector::PixelBarrel, GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, PosEndcap, edm::ESHandle< T >::product(), runTheMatrix::ret, trackerGeometry_, trackerTopology_, and updatePixelDets().

Referenced by PixelInactiveAreaTrackingRegionsSeedingLayersProducer::produce().

555  {
556  // Set data to handles
557  {
558  edm::ESHandle<TrackerGeometry> trackerGeometry;
559  iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometry);
560  trackerGeometry_ = trackerGeometry.product();
561 
562  edm::ESHandle<TrackerTopology> trackerTopology;
563  iSetup.get<TrackerTopologyRcd>().get(trackerTopology);
564  trackerTopology_ = trackerTopology.product();
565  }
566 
567  // assign data to instance variables
568  updatePixelDets(iSetup);
569  getBadPixelDets(iEvent, iSetup);
570 
571  //write files for plotting
572  if (createPlottingFiles_) {
574  }
575 
576  // find detGroupSpans ie phi,r,z limits for detector detGroups that are not working
577  // returns pair where first is barrel spans and second endcap spans
579 
580  // map spans to a vector with consistent indexing with inactiveLayers_ and inactiveLayerSetIndices_
581  // TODO: try to move the inner logic towards this direction as well
582  std::vector<DetGroupSpanContainer> spans(inactiveLayers_.size());
583 
584  auto doWork = [&](const DetGroupSpanContainer& container) {
585  for (const auto& span : container) {
586  const auto subdet = span.subdetId == PixelSubdetector::PixelBarrel ? GeomDetEnumerators::PixelBarrel
588  const auto side = (subdet == GeomDetEnumerators::PixelBarrel
590  : (span.zSpan.first < 0 ? TrackerDetSide::NegEndcap : TrackerDetSide::PosEndcap));
591  const auto layer = subdet == GeomDetEnumerators::PixelBarrel ? span.layer : span.disk;
592  auto found = std::find(inactiveLayers_.begin(), inactiveLayers_.end(), SeedingLayerId(subdet, side, layer));
593  if (found != inactiveLayers_.end()) { // it is possible that this layer is ignored by the configuration
594  spans[std::distance(inactiveLayers_.begin(), found)].push_back(span);
595  }
596  }
597  };
598  doWork(cspans.first);
599  doWork(cspans.second);
600 
601  auto ret =
603 
604  if (debug_) {
605  printOverlapSpans(ret);
606  }
607 
608  return ret;
609 }
SeedingLayerSetsBuilder::SeedingLayerId SeedingLayerId
ret
prodAgent to be discontinued
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void updatePixelDets(const edm::EventSetup &iSetup)
std::vector< std::pair< unsigned short, unsigned short > > inactiveLayerSetIndices_
const TrackerGeometry * trackerGeometry_
void getBadPixelDets(const edm::Event &iEvent, const edm::EventSetup &iSetup)
const TrackerTopology * trackerTopology_
std::vector< DetGroupSpan > DetGroupSpanContainer
T get() const
Definition: EventSetup.h:73
DetGroupSpanContainerPair detGroupSpans()
std::pair< DetGroupSpanContainer, DetGroupSpanContainer > DetGroupSpanContainerPair
T const * product() const
Definition: ESHandle.h:86
std::vector< std::vector< LayerSetIndex > > layerSetIndexInactiveToActive_
def move(src, dest)
Definition: eostools.py:511
std::vector< SeedingLayerId > inactiveLayers_
void PixelInactiveAreaFinder::printBadDetGroups ( )
private

Definition at line 805 of file PixelInactiveAreaFinder.cc.

References badDetGroupsBarrel(), badDetGroupsEndcap(), detInfo(), getPhiSpanBarrel(), getPhiSpanEndcap(), getRSpan(), getZSpan(), and contentValuesCheck::ss.

805  {
806  DetGroupContainer badDetGroupsBar = badDetGroupsBarrel();
807  DetGroupContainer badDetGroupsEnd = badDetGroupsEndcap();
808  Stream ss;
809  for (auto const& detGroup : badDetGroupsBar) {
810  ss << std::setfill(' ') << std::left << std::setw(16) << "DetGroup:";
811  DetGroupSpan cspan;
812  getPhiSpanBarrel(detGroup, cspan);
813  getZSpan(detGroup, cspan);
814  getRSpan(detGroup, cspan);
815  detGroupSpanInfo(cspan, ss);
816  ss << std::endl;
817  for (auto const& det : detGroup) {
818  detInfo(det, ss);
819  ss << std::endl;
820  }
821  ss << std::endl;
822  }
823  for (auto const& detGroup : badDetGroupsEnd) {
824  ss << std::setfill(' ') << std::left << std::setw(16) << "DetGroup:";
825  DetGroupSpan cspan;
826  getPhiSpanEndcap(detGroup, cspan);
827  getZSpan(detGroup, cspan);
828  getRSpan(detGroup, cspan);
829  detGroupSpanInfo(cspan, ss);
830  ss << std::endl;
831  for (auto const& det : detGroup) {
832  detInfo(det, ss);
833  ss << std::endl;
834  }
835  ss << std::endl;
836  }
837  edm::LogPrint("PixelInactiveAreaFinder") << ss.str();
838 }
void getRSpan(const DetGroup &detGroup, DetGroupSpan &cspan)
DetGroupContainer badDetGroupsEndcap()
void getPhiSpanBarrel(const DetGroup &detGroup, DetGroupSpan &cspan)
void detInfo(const det_t &det, Stream &ss)
DetGroupContainer badDetGroupsBarrel()
std::vector< DetGroup > DetGroupContainer
void getPhiSpanEndcap(const DetGroup &detGroup, DetGroupSpan &cspan)
void getZSpan(const DetGroup &detGroup, DetGroupSpan &cspan)
void PixelInactiveAreaFinder::printBadDetGroupSpans ( )
private

Definition at line 839 of file PixelInactiveAreaFinder.cc.

References detGroupSpans(), and contentValuesCheck::ss.

839  {
841  Stream ss;
842  for (auto const& cspan : cspans.first) {
843  detGroupSpanInfo(cspan, ss);
844  ss << std::endl;
845  }
846  for (auto const& cspan : cspans.second) {
847  detGroupSpanInfo(cspan, ss);
848  ss << std::endl;
849  }
850  edm::LogPrint("PixelInactiveAreaFinder") << ss.str();
851 }
DetGroupSpanContainerPair detGroupSpans()
std::pair< DetGroupSpanContainer, DetGroupSpanContainer > DetGroupSpanContainerPair
void PixelInactiveAreaFinder::printBadPixelDets ( )
private

Definition at line 790 of file PixelInactiveAreaFinder.cc.

References badPixelDetsBarrel_, badPixelDetsEndcap_, detInfo(), contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

790  {
791  edm::LogPrint("PixelInactiveAreaFinder") << "Bad barrel detectors:";
792  Stream ss;
793  for (auto const& det : badPixelDetsBarrel_) {
794  detInfo(det, ss);
795  edm::LogPrint("PixelInactiveAreaFinder") << ss.str();
796  ss.str(std::string());
797  }
798  edm::LogPrint("PixelInactiveAreaFinder") << "Endcap detectors;";
799  for (auto const& det : badPixelDetsEndcap_) {
800  detInfo(det, ss);
801  edm::LogPrint("PixelInactiveAreaFinder") << ss.str();
802  ss.str(std::string());
803  }
804 }
void detInfo(const det_t &det, Stream &ss)
void PixelInactiveAreaFinder::printPixelDets ( )
private

Definition at line 775 of file PixelInactiveAreaFinder.cc.

References detInfo(), pixelDetsBarrel_, pixelDetsEndcap_, contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

775  {
776  edm::LogPrint("PixelInactiveAreaFinder") << "Barrel detectors:";
777  Stream ss;
778  for (auto const& det : pixelDetsBarrel_) {
779  detInfo(det, ss);
780  edm::LogPrint("PixelInactiveAreaFinder") << ss.str();
781  ss.str(std::string());
782  }
783  edm::LogPrint("PixelInactiveAreaFinder") << "Endcap detectors;";
784  for (auto const& det : pixelDetsEndcap_) {
785  detInfo(det, ss);
786  edm::LogPrint("PixelInactiveAreaFinder") << ss.str();
787  ss.str(std::string());
788  }
789 }
void detInfo(const det_t &det, Stream &ss)
PixelInactiveAreaFinder::DetGroup PixelInactiveAreaFinder::reachableDetGroup ( const det_t initDet,
DetectorSet foundDets 
)
private

Definition at line 949 of file PixelInactiveAreaFinder.cc.

References badAdjecentDetsBarrel(), badAdjecentDetsEndcap(), PixelSubdetector::PixelBarrel, and PixelSubdetector::PixelEndcap.

Referenced by badDetGroupsBarrel(), and badDetGroupsEndcap().

950  {
952  std::queue<det_t> workQueue;
953  det_t workDet;
954  DetGroup badAdjDets;
955  foundDets.insert(initDet);
956  workQueue.push(initDet);
957  reachableDetGroup.push_back(initDet);
958  while (!workQueue.empty()) {
959  workDet = workQueue.front();
960  workQueue.pop();
961  if (DetId(workDet).subdetId() == PixelSubdetector::PixelBarrel) {
962  badAdjDets = this->badAdjecentDetsBarrel(workDet);
963  } else if (DetId(workDet).subdetId() == PixelSubdetector::PixelEndcap) {
964  badAdjDets = this->badAdjecentDetsEndcap(workDet);
965  } else {
966  badAdjDets = {};
967  }
968  for (auto const& badDet : badAdjDets) {
969  if (foundDets.find(badDet) == foundDets.end()) {
970  reachableDetGroup.push_back(badDet);
971  foundDets.insert(badDet);
972  workQueue.push(badDet);
973  }
974  }
975  }
976  return reachableDetGroup;
977 }
DetGroup reachableDetGroup(const det_t &initDet, DetectorSet &foundDets)
DetGroup badAdjecentDetsBarrel(const det_t &det)
Definition: DetId.h:17
DetGroup badAdjecentDetsEndcap(const det_t &det)
void PixelInactiveAreaFinder::updatePixelDets ( const edm::EventSetup iSetup)
private

Definition at line 612 of file PixelInactiveAreaFinder.cc.

References begin, edm::ESWatcher< T >::check(), dqmiodumpmetadata::counts, createPlottingFiles_, TrackerGeometry::detsPXB(), TrackerGeometry::detsPXF(), end, Exception, geometryWatcher_, PVValHelper::ladder, TrackerTopology::layer(), LogDebug, LogTrace, nBPixLadders, nModulesPerLadder, TrackerGeometry::numberOfLayers(), PixelSubdetector::PixelBarrel, pixelDetsBarrel_, pixelDetsEndcap_, PixelSubdetector::PixelEndcap, TrackerTopology::pxbLadder(), trackerGeometry_, trackerTopology_, and heppy_batch::val.

Referenced by inactiveAreas().

612  {
613  if (!geometryWatcher_.check(iSetup))
614  return;
615 
616  // deduce the number of ladders per layer and the number of modules per ladder
617  {
618  // sanity checks
620  throw cms::Exception("NotImplemented")
621  << "This module supports only a detector with 4 pixel barrel layers, the current geometry has "
623  }
625  throw cms::Exception("NotImplemented")
626  << "This module supports only a detector with 3 pixel forward disks, the current geometry has "
628  }
629 
630  std::array<std::array<unsigned short, 100>, 4> counts = {}; // assume at most 100 ladders per layer
631  for (const auto& det : trackerGeometry_->detsPXB()) {
632  const auto layer = trackerTopology_->layer(det->geographicalId());
633  const auto ladder = trackerTopology_->pxbLadder(det->geographicalId());
634  if (ladder >= 100) {
635  throw cms::Exception("LogicError")
636  << "Got a ladder with number " << ladder
637  << " while the expected maximum was 100; either something is wrong or the maximum has to be increased.";
638  }
639  counts[layer - 1][ladder - 1] += 1; // numbering of layer and ladder starts at 1
640  }
641 
642  // take number of modules per ladder from the first ladder of the first layer (such better exist)
643  // other ladders better have the same number
644  nModulesPerLadder = counts[0][0];
645  if (nModulesPerLadder == 0) {
646  throw cms::Exception("LogicError") << "Ladder 1 of layer 1 has 0 modules, something fishy is going on.";
647  }
648 
649  LogDebug("PixelInactiveAreaFinder") << "Number of modules per ladder " << nModulesPerLadder
650  << "; below are number of ladders per layer";
651 
652  // number of ladders
653  for (unsigned layer = 0; layer < 4; ++layer) {
654  nBPixLadders[layer] =
655  std::count_if(counts[layer].begin(), counts[layer].end(), [](unsigned short val) { return val > 0; });
656  LogTrace("PixelInactiveAreaFinder")
657  << "BPix layer " << (layer + 1) << " has " << nBPixLadders[layer] << " ladders";
658 
659  auto fail = std::count_if(counts[layer].begin(), counts[layer].end(), [&](unsigned short val) {
660  return val != nModulesPerLadder && val > 0;
661  });
662  if (fail != 0) {
663  throw cms::Exception("LogicError")
664  << "Layer " << (layer + 1) << " had " << fail
665  << " ladders whose number of modules/ladder differed from the ladder 1 of layer 1 (" << nModulesPerLadder
666  << "). Something fishy is going on.";
667  }
668  }
669  }
670 
671  // don't bother with the rest if not needed
673  return;
674 
675  pixelDetsBarrel_.clear();
676  pixelDetsEndcap_.clear();
677 
678  for (auto const& geomDetPtr : trackerGeometry_->detsPXB()) {
679  if (geomDetPtr->geographicalId().subdetId() == PixelSubdetector::PixelBarrel) {
680  pixelDetsBarrel_.push_back(geomDetPtr->geographicalId().rawId());
681  }
682  }
683  for (auto const& geomDetPtr : trackerGeometry_->detsPXF()) {
684  if (geomDetPtr->geographicalId().subdetId() == PixelSubdetector::PixelEndcap) {
685  pixelDetsEndcap_.push_back(geomDetPtr->geographicalId().rawId());
686  }
687  }
688  std::sort(pixelDetsBarrel_.begin(), pixelDetsBarrel_.end());
689  std::sort(pixelDetsEndcap_.begin(), pixelDetsEndcap_.end());
690 }
#define LogDebug(id)
std::array< unsigned short, 4 > nBPixLadders
unsigned int pxbLadder(const DetId &id) const
unsigned int numberOfLayers(int subdet) const
const DetContainer & detsPXB() const
#define end
Definition: vmac.h:39
const TrackerGeometry * trackerGeometry_
#define LogTrace(id)
const TrackerTopology * trackerTopology_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
unsigned int layer(const DetId &id) const
#define begin
Definition: vmac.h:32
const DetContainer & detsPXF() const
edm::ESWatcher< TrackerDigiGeometryRecord > geometryWatcher_

Member Data Documentation

DetContainer PixelInactiveAreaFinder::badPixelDetsBarrel_
private
DetContainer PixelInactiveAreaFinder::badPixelDetsEndcap_
private
std::vector<edm::EDGetTokenT<PixelFEDChannelCollection> > PixelInactiveAreaFinder::badPixelFEDChannelsTokens_
private

Definition at line 89 of file PixelInactiveAreaFinder.h.

Referenced by getBadPixelDets(), and PixelInactiveAreaFinder().

const bool PixelInactiveAreaFinder::createPlottingFiles_
private

Definition at line 80 of file PixelInactiveAreaFinder.h.

Referenced by inactiveAreas(), and updatePixelDets().

const bool PixelInactiveAreaFinder::debug_
private

Definition at line 79 of file PixelInactiveAreaFinder.h.

Referenced by inactiveAreas().

edm::ESWatcher<TrackerDigiGeometryRecord> PixelInactiveAreaFinder::geometryWatcher_
private

Definition at line 106 of file PixelInactiveAreaFinder.h.

Referenced by updatePixelDets().

const bool PixelInactiveAreaFinder::ignoreSingleFPixPanelModules_
private

Definition at line 81 of file PixelInactiveAreaFinder.h.

Referenced by badDetGroupsEndcap().

std::vector<SeedingLayerId> PixelInactiveAreaFinder::inactiveLayers_
private

Definition at line 83 of file PixelInactiveAreaFinder.h.

Referenced by inactiveAreas(), and PixelInactiveAreaFinder().

std::vector<std::pair<unsigned short, unsigned short> > PixelInactiveAreaFinder::inactiveLayerSetIndices_
private

Definition at line 84 of file PixelInactiveAreaFinder.h.

Referenced by inactiveAreas(), and PixelInactiveAreaFinder().

std::vector<edm::EDGetTokenT<DetIdCollection> > PixelInactiveAreaFinder::inactivePixelDetectorTokens_
private

Definition at line 88 of file PixelInactiveAreaFinder.h.

Referenced by getBadPixelDets().

std::vector<std::vector<LayerSetIndex> > PixelInactiveAreaFinder::layerSetIndexInactiveToActive_
private

Definition at line 86 of file PixelInactiveAreaFinder.h.

Referenced by inactiveAreas(), and PixelInactiveAreaFinder().

std::array<unsigned short, 4> PixelInactiveAreaFinder::nBPixLadders
private
unsigned short PixelInactiveAreaFinder::nModulesPerLadder
private

Definition at line 97 of file PixelInactiveAreaFinder.h.

Referenced by badAdjecentDetsBarrel(), and updatePixelDets().

DetContainer PixelInactiveAreaFinder::pixelDetsBarrel_
private

Definition at line 112 of file PixelInactiveAreaFinder.h.

Referenced by createPlottingFiles(), printPixelDets(), and updatePixelDets().

DetContainer PixelInactiveAreaFinder::pixelDetsEndcap_
private

Definition at line 113 of file PixelInactiveAreaFinder.h.

Referenced by createPlottingFiles(), printPixelDets(), and updatePixelDets().

const SiPixelQuality* PixelInactiveAreaFinder::pixelQuality_ = 0
private

Definition at line 108 of file PixelInactiveAreaFinder.h.

const TrackerGeometry* PixelInactiveAreaFinder::trackerGeometry_ = 0
private
const TrackerTopology* PixelInactiveAreaFinder::trackerTopology_ = 0
private