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 100 of file PixelInactiveAreaFinder.h.

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

Definition at line 101 of file PixelInactiveAreaFinder.h.

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

Definition at line 104 of file PixelInactiveAreaFinder.h.

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

Definition at line 102 of file PixelInactiveAreaFinder.h.

Definition at line 103 of file PixelInactiveAreaFinder.h.

Definition at line 42 of file PixelInactiveAreaFinder.h.

Definition at line 93 of file PixelInactiveAreaFinder.h.

Definition at line 25 of file PixelInactiveAreaFinder.h.

Definition at line 94 of file PixelInactiveAreaFinder.h.

Definition at line 95 of file PixelInactiveAreaFinder.h.

Definition at line 24 of file PixelInactiveAreaFinder.h.

using PixelInactiveAreaFinder::Stream = std::stringstream
private

Definition at line 105 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 437 of file PixelInactiveAreaFinder.cc.

References badPixelFEDChannelsTokens_, SoftLeptonByDistance_cfi::distance, Exception, spr::find(), runEdmFileComparison::found, mps_fire::i, inactiveLayers_, inactiveLayerSetIndices_, layerSetIndexInactiveToActive_, LogDebug, LogTrace, HiRegitMuonDetachedTripletStep_cff::seedingLayers, GlobalPosition_Frontier_DevDB_cff::tag, and edm::vector_transform().

439  :
440  debug_(iConfig.getUntrackedParameter<bool>("debug")),
441  createPlottingFiles_(iConfig.getUntrackedParameter<bool>("createPlottingFiles")),
442  ignoreSingleFPixPanelModules_(iConfig.getParameter<bool>("ignoreSingleFPixPanelModules")),
443  inactivePixelDetectorTokens_(edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag> >("inactivePixelDetectorLabels"), [&](const auto& tag) { return iC.consumes<DetIdCollection>(tag); })),
444  badPixelFEDChannelsTokens_(edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag> >("badPixelFEDChannelCollectionLabels"), [&](const auto& tag) { return iC.consumes<PixelFEDChannelCollection>(tag); }))
445 {
446 #ifdef EDM_ML_DEBUG
447  for(const auto& layer: seedingLayers) {
448  LogTrace("PixelInactiveAreaFinder") << "Input layer subdet " << std::get<0>(layer) << " side " << static_cast<unsigned int>(std::get<1>(layer)) << " layer " << std::get<2>(layer);
449  }
450 #endif
451 
452  auto findOrAdd = [&](SeedingLayerId layer) -> unsigned short {
453  auto found = std::find(inactiveLayers_.cbegin(), inactiveLayers_.cend(), layer);
454  if(found == inactiveLayers_.cend()) {
455  auto ret = inactiveLayers_.size();
456  inactiveLayers_.push_back(layer);
457  return ret;
458  }
459  return std::distance(inactiveLayers_.cbegin(), found);
460  };
461 
462  // mapping from active layer pairs to inactive layer pairs
463  const auto activeToInactiveMap = createActiveToInactiveMap();
464 
465  // convert input layer pairs (that are for active layers) to layer
466  // pairs to look for inactive areas
467  LayerSetIndex i=0;
468  for(const auto& layerSet: seedingLayerSetsLooper.makeRange(seedingLayers)) {
469  assert(layerSet.size() == 2);
470  auto found = activeToInactiveMap.find(std::make_pair(layerSet[0], layerSet[1]));
471  if(found == activeToInactiveMap.end()) {
472  throw cms::Exception("Configuration") << "Encountered layer pair " << layerSet[0] << "+" << layerSet[1] << " not found from the internal 'active layer pairs' to 'inactive layer pairs' mapping; either fix the input or the mapping (in PixelInactiveAreaFinder.cc)";
473  }
474 
475  LogTrace("PixelInactiveAreaFinder") << "Input layer set " << layerSet[0] << "+" << layerSet[1];
476  for(const auto& inactiveLayerSet: found->second) {
477  auto innerInd = findOrAdd(inactiveLayerSet.first);
478  auto outerInd = findOrAdd(inactiveLayerSet.second);
479 
480  auto found = std::find(inactiveLayerSetIndices_.cbegin(), inactiveLayerSetIndices_.cend(), std::make_pair(innerInd, outerInd));
481  if(found == inactiveLayerSetIndices_.end()) {
482  inactiveLayerSetIndices_.emplace_back(innerInd, outerInd);
483  layerSetIndexInactiveToActive_.push_back(std::vector<LayerSetIndex>{i});
484  }
485  else {
486  layerSetIndexInactiveToActive_.at(std::distance(inactiveLayerSetIndices_.cbegin(), found)).push_back(i); // TODO: move to operator[] once finished
487  }
488 
489  LogTrace("PixelInactiveAreaFinder") << " inactive layer set " << inactiveLayerSet.first << "+" << inactiveLayerSet.second;
490  }
491 
492  ++i;
493  }
494 
495 
496 #ifdef EDM_ML_DEBUG
497  LogDebug("PixelInactiveAreaFinder") << "All inactive layer sets";
498  for(const auto& idxPair: inactiveLayerSetIndices_) {
499  LogTrace("PixelInactiveAreaFinder") << " " << inactiveLayers_[idxPair.first] << "+" << inactiveLayers_[idxPair.second];
500  }
501 #endif
502 }
#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_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
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 846 of file PixelInactiveAreaFinder.cc.

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

Referenced by reachableDetGroup().

846  {
847  using std::remove_if;
848 
849  DetGroup adj;
850  auto const tTopo = trackerTopology_;
851  auto const & detId = DetId(det);
852  unsigned int layer = tTopo->pxbLayer (detId);
853  unsigned int ladder = tTopo->pxbLadder(detId);
854  unsigned int module = tTopo->pxbModule(detId);
855  unsigned int nLads = nBPixLadders[layer];
856  //add detectors from next and previous ladder
857  adj.push_back( tTopo->pxbDetId( layer, ((ladder-1)+1)%nLads+1, module )() );
858  adj.push_back( tTopo->pxbDetId( layer, ((ladder-1)-1+nLads)%nLads+1, module )() );
859  //add adjecent detectors from same ladder
860  if(module == 1) {
861  adj.push_back( tTopo->pxbDetId( layer, ladder, module+1 )() );
862  }
863  else if(module == nModulesPerLadder) {
864  adj.push_back( tTopo->pxbDetId( layer, ladder, module-1 )() );
865  }
866  else {
867  adj.push_back( tTopo->pxbDetId( layer, ladder, module+1 )() );
868  adj.push_back( tTopo->pxbDetId( layer, ladder, module-1 )() );
869  }
870  //remove working detectors from list
871  adj.erase(remove_if(adj.begin(),adj.end(), [&](auto c) {return this->detWorks(c);}), adj.end());
872  return adj;
873 }
std::array< unsigned short, 4 > nBPixLadders
Definition: DetId.h:18
const TrackerTopology * trackerTopology_
Definition: vlib.h:208
PixelInactiveAreaFinder::DetGroup PixelInactiveAreaFinder::badAdjecentDetsEndcap ( const det_t det)
private

Definition at line 874 of file PixelInactiveAreaFinder.cc.

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

Referenced by reachableDetGroup().

874  {
875  // this might be faster if adjecent
876  using std::tie;
877  using std::ignore;
878  DetGroup adj;
879  Span_t phiSpan, phiSpanComp;
880  float z, zComp;
881  unsigned int disk, diskComp;
882  auto const & detSurf = trackerGeometry_->idToDet(DetId(det))->surface();
883  phiSpan = detSurf.phiSpan();
884  tie(z,ignore) = detSurf.zSpan();
885  disk = trackerTopology_->pxfDisk(DetId(det));
886  // add detectors from same disk whose phi ranges overlap to the adjecent list
887  for(auto const & detComp : badPixelDetsEndcap_){
888  auto const & detIdComp = DetId(detComp);
889  auto const & detSurfComp = trackerGeometry_->idToDet(detIdComp)->surface();
890  diskComp = trackerTopology_->pxfDisk(detIdComp);
891  phiSpanComp = detSurfComp.phiSpan();
892  tie(zComp,ignore) = detSurfComp.zSpan();
893  if(det != detComp && disk == diskComp && z*zComp > 0
894  && phiRangesOverlap(phiSpan,phiSpanComp)){
895  adj.push_back(detComp);
896  }
897  }
898  return adj;
899 }
std::pair< float, float > const & phiSpan() const
Definition: Surface.h:123
unsigned int pxfDisk(const DetId &id) const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
const TrackerGeometry * trackerGeometry_
def ignore(seq)
Definition: DetId.h:18
const TrackerTopology * trackerTopology_
const TrackerGeomDet * idToDet(DetId) const override
PixelInactiveAreaFinder::DetGroupContainer PixelInactiveAreaFinder::badDetGroupsBarrel ( )
private

Definition at line 927 of file PixelInactiveAreaFinder.cc.

References badPixelDetsBarrel_, and reachableDetGroup().

Referenced by detGroupSpans(), and printBadDetGroups().

927  {
928  DetGroupContainer detGroups;
929  DetectorSet foundDets;
930  for(auto const & badDet : badPixelDetsBarrel_){
931  if(foundDets.find(badDet) == foundDets.end()){
932  detGroups.push_back(this->reachableDetGroup(badDet,foundDets));
933  }
934  }
935  return detGroups;
936 }
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 937 of file PixelInactiveAreaFinder.cc.

References badPixelDetsEndcap_, ignoreSingleFPixPanelModules_, and reachableDetGroup().

Referenced by detGroupSpans(), and printBadDetGroups().

937  {
938  DetGroupContainer detGroups;
939  DetectorSet foundDets;
940  for(auto const & badDet : badPixelDetsEndcap_){
941  if(foundDets.find(badDet) == foundDets.end()){
942  auto adjacentDets = this->reachableDetGroup(badDet,foundDets);
943  if(ignoreSingleFPixPanelModules_ && adjacentDets.size() == 1) {
944  // size==1 means that only a single panel of a blade was inactive
945  // because of the large overlap with the other panel (i.e.
946  // redundancy in the detectory) ignoring these may help to decrease fakes
947  continue;
948  }
949  detGroups.push_back(adjacentDets);
950  }
951  }
952  return detGroups;
953 }
DetGroup reachableDetGroup(const det_t &initDet, DetectorSet &foundDets)
std::set< uint32_t > DetectorSet
std::vector< DetGroup > DetGroupContainer
void PixelInactiveAreaFinder::createPlottingFiles ( )
private

Definition at line 796 of file PixelInactiveAreaFinder.cc.

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

Referenced by inactiveAreas().

796  {
797  // All detectors to file DETECTORS
798  Stream ss;
799  std::ofstream fsDet("DETECTORS.txt");
800  for(auto const & det : pixelDetsBarrel_){
801  detInfo(det,ss);
802  ss << std::endl;
803  }
804  edm::LogPrint("PixelInactiveAreaFinder") << "Endcap detectors;";
805  for(auto const & det : pixelDetsEndcap_){
806  detInfo(det,ss);
807  ss << std::endl;
808  }
809  fsDet << ss.rdbuf();
810  ss.str(std::string());
811  // Bad detectors
812  std::ofstream fsBadDet("BADDETECTORS.txt");
813  for(auto const & det : badPixelDetsBarrel_){
814  detInfo(det,ss);
815  ss<<std::endl;
816  }
817  for(auto const & det : badPixelDetsEndcap_){
818  detInfo(det,ss);
819  ss<<std::endl;
820  }
821  fsBadDet << ss.rdbuf();
822  ss.str(std::string());
823  // detgroupspans
824  std::ofstream fsSpans("DETGROUPSPANS.txt");
826  for(auto const & cspan : cspans.first){
827  detGroupSpanInfo(cspan,ss);ss<<std::endl;
828  }
829  for(auto const & cspan : cspans.second){
830  detGroupSpanInfo(cspan,ss);ss<<std::endl;
831  }
832  fsSpans << ss.rdbuf();
833  ss.str(std::string());
834 
835 }
std::pair< DetGroupSpanContainer, DetGroupSpanContainer > DetGroupSpanContainerPair
void detInfo(const det_t &det, Stream &ss)
DetGroupSpanContainerPair detGroupSpans()
PixelInactiveAreaFinder::DetGroupSpanContainerPair PixelInactiveAreaFinder::detGroupSpans ( )
private

Definition at line 1098 of file PixelInactiveAreaFinder.cc.

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

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

1098  {
1099  DetGroupSpanContainer cspansBarrel;
1100  DetGroupSpanContainer cspansEndcap;
1101  DetGroupContainer badDetGroupsBar = badDetGroupsBarrel();
1102  DetGroupContainer badDetGroupsEnd = badDetGroupsEndcap();
1103  for(auto const & detGroup : badDetGroupsBar){
1104  DetGroupSpan cspan;
1105  getSpan(detGroup,cspan);
1106  cspansBarrel.push_back(cspan);
1107  }
1108  for(auto const & detGroup : badDetGroupsEnd){
1109  DetGroupSpan cspan;
1110  getSpan(detGroup,cspan);
1111  cspansEndcap.push_back(cspan);
1112  }
1113  return DetGroupSpanContainerPair(cspansBarrel,cspansEndcap);
1114 }
std::pair< DetGroupSpanContainer, DetGroupSpanContainer > DetGroupSpanContainerPair
DetGroupContainer badDetGroupsEndcap()
DetGroupContainer badDetGroupsBarrel()
std::vector< DetGroup > DetGroupContainer
std::vector< DetGroupSpan > DetGroupSpanContainer
void getSpan(const DetGroup &detGroup, DetGroupSpan &cspan)
void PixelInactiveAreaFinder::detInfo ( const det_t det,
Stream ss 
)
private

Definition at line 684 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().

684  {
685  using std::tie;
686  using std::setw;
687  using std::showpos;
688  using std::noshowpos;
689  using std::fixed;
690  using std::right;
691  using std::left;
692  using std::setprecision;
693  using std::setfill;
694  std::string deli = "; ";
695  ss << "id:[" << det << "]" <<deli;
696  ss << "subdetid:[" << DetId(det).subdetId() << "]" << deli;
697  if(DetId(det).subdetId()==PixelSubdetector::PixelBarrel){
698  unsigned int layer = trackerTopology_->pxbLayer (DetId(det));
699  unsigned int ladder = trackerTopology_->pxbLadder(DetId(det));
700  unsigned int module = trackerTopology_->pxbModule(DetId(det));
701  ss << "layer:[" << layer << "]" << deli
702  << "ladder:[" << right << setw(2) << ladder << "]" << deli
703  << "module:[" << module << "]" << deli;
704  }else if(DetId(det).subdetId()==PixelSubdetector::PixelEndcap){
705  unsigned int disk = trackerTopology_->pxfDisk (DetId(det));
706  unsigned int blade = trackerTopology_->pxfBlade(DetId(det));
707  unsigned int panel = trackerTopology_->pxfPanel(DetId(det));
708  ss << left << setw(6) << "disk:" << "[" << right << disk << "]" << deli
709  << left << setw(7) << "blade:" << "[" << setw(2) << right << blade << "]" << deli
710  << left << setw(7) << "panel:" << "[" << right << panel << "]" << deli;
711  }
712  float phiA,phiB,zA,zB,rA,rB;
713  auto detSurface = trackerGeometry_->idToDet(DetId(det))->surface();
714  tie(phiA,phiB) = detSurface.phiSpan();
715  tie(zA,zB) = detSurface.zSpan();
716  tie(rA,rB) = detSurface.rSpan();
717  ss
718  << setprecision(16)
719  << fixed
720  << showpos
721  << setfill(' ')
722  << "phi:[" << right << setw(12) << phiA << "," << left << setw(12) << phiB << "]" << deli
723  << "z:[" << right << setw(7) << zA << "," << left << setw(7) << zB << "]" << deli << noshowpos
724  << "r:[" << right << setw(10) << rA << "," << left << setw(10) << rB << "]" << deli;
725 
726 }
std::pair< float, float > const & phiSpan() const
Definition: Surface.h:123
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:42
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
const TrackerGeometry * trackerGeometry_
unsigned int pxbLayer(const DetId &id) const
Definition: DetId.h:18
const TrackerTopology * trackerTopology_
const TrackerGeomDet * idToDet(DetId) const override
Definition: vlib.h:208
unsigned int pxfPanel(const DetId &id) const
unsigned int pxfBlade(const DetId &id) const
bool PixelInactiveAreaFinder::detWorks ( det_t  det)
private

Definition at line 837 of file PixelInactiveAreaFinder.cc.

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

Referenced by badAdjecentDetsBarrel().

837  {
838  return
840  == badPixelDetsBarrel_.end()
841  &&
843  == badPixelDetsEndcap_.end()
844  ;
845 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
void PixelInactiveAreaFinder::fillDescriptions ( edm::ParameterSetDescription desc)
static

Definition at line 504 of file PixelInactiveAreaFinder.cc.

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

Referenced by PixelInactiveAreaTrackingRegionsSeedingLayersProducer::fillDescriptions().

504  {
505  desc.add<std::vector<edm::InputTag>>("inactivePixelDetectorLabels", std::vector<edm::InputTag>{{edm::InputTag("siPixelDigis")}})->setComment("One or more DetIdCollections of modules to mask on the fly for a given event");
506  desc.add<std::vector<edm::InputTag>>("badPixelFEDChannelCollectionLabels", std::vector<edm::InputTag>{{edm::InputTag("siPixelDigis")}})->setComment("One or more PixelFEDChannelCollections of modules+ROCs to mask on the fly for a given event");
507  desc.add<bool>("ignoreSingleFPixPanelModules", false);
508 
509  desc.addUntracked<bool>("debug", false);
510  desc.addUntracked<bool>("createPlottingFiles", false);
511 }
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 638 of file PixelInactiveAreaFinder.cc.

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

Referenced by inactiveAreas().

638  {
639  auto addDetId = [&](const auto id) {
640  const auto detid = DetId(id);
641  const auto subdet = detid.subdetId();
642  if(subdet == PixelSubdetector::PixelBarrel) {
643  badPixelDetsBarrel_.push_back(detid.rawId());
644  }
645  else if(subdet == PixelSubdetector::PixelEndcap) {
646  badPixelDetsEndcap_.push_back(detid.rawId());
647  }
648  };
649 
650  // SiPixelQuality
651  edm::ESHandle<SiPixelQuality> pixelQuality;
652  iSetup.get<SiPixelQualityRcd>().get(pixelQuality);
653 
654  for(auto const & disabledModule : pixelQuality->getBadComponentList() ){
655  addDetId(disabledModule.DetID);
656  }
657 
658  // dynamic bad modules
659  for(const auto& token: inactivePixelDetectorTokens_) {
661  iEvent.getByToken(token, detIds);
662  for(const auto& id: *detIds) {
663  addDetId(id);
664  }
665  }
666 
667  // dynamic bad ROCs ("Fed25")
668  // TODO: consider moving to finer-grained areas for inactive ROCs
669  for(const auto& token: badPixelFEDChannelsTokens_) {
670  edm::Handle<PixelFEDChannelCollection> pixelFEDChannelCollectionHandle;
671  iEvent.getByToken(token, pixelFEDChannelCollectionHandle);
672  for(const auto& disabledChannels: *pixelFEDChannelCollectionHandle) {
673  addDetId(disabledChannels.detId());
674  }
675  }
676 
677  // remove duplicates
678  std::sort(badPixelDetsBarrel_.begin(),badPixelDetsBarrel_.end());
679  std::sort(badPixelDetsEndcap_.begin(),badPixelDetsEndcap_.end());
682 }
std::vector< edm::EDGetTokenT< DetIdCollection > > inactivePixelDetectorTokens_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
def unique(seq, keepstr=True)
Definition: tier0.py:25
const std::vector< disabledModuleType > getBadComponentList() const
std::vector< edm::EDGetTokenT< PixelFEDChannelCollection > > badPixelFEDChannelsTokens_
Definition: DetId.h:18
T get() const
Definition: EventSetup.h:71
void PixelInactiveAreaFinder::getPhiSpanBarrel ( const DetGroup detGroup,
DetGroupSpan cspan 
)
private

Definition at line 955 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().

955  {
956  // find phiSpan using ordered vector of unique ladders in detGroup
957  if(detGroup.empty()){
958  cspan = DetGroupSpan();
959  return;
960  } else{
961  cspan.layer = trackerTopology_->pxbLayer(DetId(detGroup[0]));
962  cspan.disk = 0;
963  }
964  using uint = unsigned int;
965  using LadderSet = std::set<uint>;
966  using LadVec = std::vector<uint>;
967  LadderSet lads;
968  for(auto const & det : detGroup){
969  lads.insert(trackerTopology_->pxbLadder(DetId(det)));
970  }
971  LadVec ladv(lads.begin(),lads.end());
972  uint nLadders = nBPixLadders[cspan.layer];
973  // find start ladder of detGroup
974  uint i = 0;
975  uint currentLadder = ladv[0];
976  uint previousLadder = ladv[ (ladv.size()+i-1) % ladv.size() ];
977  // loop until discontinuity is found from vector
978  while ( (nLadders+currentLadder-1)%nLadders == previousLadder ){
979  ++i;
980  currentLadder = ladv[i%ladv.size()];
981  previousLadder = ladv[ (ladv.size()+i-1)%ladv.size() ];
982  if(i == ladv.size()){
983  cspan.phiSpan.first = std::numeric_limits<float>::epsilon();
984  cspan.phiSpan.second = -std::numeric_limits<float>::epsilon();
985  return;
986  }
987  }
988  uint startLadder = currentLadder;
989  uint endLadder = previousLadder;
990  auto detStart = trackerTopology_->pxbDetId(cspan.layer,startLadder,1);
991  auto detEnd = trackerTopology_->pxbDetId(cspan.layer,endLadder,1);
992  cspan.phiSpan.first = trackerGeometry_->idToDet(detStart)->surface().phiSpan().first;
993  cspan.phiSpan.second = trackerGeometry_->idToDet(detEnd)->surface().phiSpan().second;
994 }
std::pair< float, float > const & phiSpan() const
Definition: Surface.h:123
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:42
const TrackerGeometry * trackerGeometry_
unsigned int pxbLayer(const DetId &id) const
Definition: DetId.h:18
const TrackerTopology * trackerTopology_
def uint(string)
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 995 of file PixelInactiveAreaFinder.cc.

References counter, geometryDiff::epsilon, runEdmFileComparison::found, PixelInactiveAreaFinder::DetGroupSpan::phiSpan, and trackerGeometry_.

Referenced by getSpan(), and printBadDetGroups().

995  {
996  // this is quite naive/bruteforce method
997  // 1) it starts by taking one detector from detGroup and starts to compare it to others
998  // 2) when it finds overlapping detector in clockwise direction it starts comparing
999  // found detector to others
1000  // 3) search stops until no overlapping detectors in clockwise detector or all detectors
1001  // have been work detector
1002  Stream ss;
1003  bool found = false;
1004  auto const tGeom = trackerGeometry_;
1005  DetGroup::const_iterator startDetIter = detGroup.begin();
1006  Span_t phiSpan,phiSpanComp;
1007  unsigned int counter = 0;
1008  while(!found){
1009  phiSpan = tGeom->idToDet(DetId(*startDetIter))->surface().phiSpan();
1010  for(DetGroup::const_iterator compDetIter=detGroup.begin();compDetIter!=detGroup.end();++compDetIter){
1011  phiSpanComp = tGeom->idToDet(DetId(*compDetIter))->surface().phiSpan();
1012  if(phiRangesOverlap(phiSpan,phiSpanComp)
1013  && phiMoreClockwise(phiSpanComp.first,phiSpan.first)
1014  && startDetIter != compDetIter)
1015  {
1016  ++counter;
1017  if(counter > detGroup.size()){
1018  cspan.phiSpan.first = std::numeric_limits<float>::epsilon();
1019  cspan.phiSpan.second = -std::numeric_limits<float>::epsilon();
1020  return;
1021  }
1022  startDetIter = compDetIter;break;
1023  } else if (compDetIter == detGroup.end()-1){
1024  found = true;
1025  }
1026  }
1027  }
1028  cspan.phiSpan.first = phiSpan.first;
1029  // second with same method}
1030  found = false;
1031  DetGroup::const_iterator endDetIter = detGroup.begin();
1032  counter = 0;
1033  while(!found){
1034  phiSpan = tGeom->idToDet(DetId(*endDetIter))->surface().phiSpan();
1035  for(DetGroup::const_iterator compDetIter=detGroup.begin();compDetIter!=detGroup.end();++compDetIter){
1036  phiSpanComp = tGeom->idToDet(DetId(*compDetIter))->surface().phiSpan();
1037  if(phiRangesOverlap(phiSpan,phiSpanComp)
1038  && phiMoreCounterclockwise(phiSpanComp.second,phiSpan.second)
1039  && endDetIter != compDetIter)
1040  {
1041  ++counter;
1042  if(counter > detGroup.size()){
1043  cspan.phiSpan.first = std::numeric_limits<float>::epsilon();
1044  cspan.phiSpan.second = -std::numeric_limits<float>::epsilon();
1045  return;
1046  }
1047  endDetIter = compDetIter;break;
1048  } else if (compDetIter == detGroup.end()-1){
1049  found = true;
1050  }
1051  }
1052  }
1053  cspan.phiSpan.second = phiSpan.second;
1054 }
const TrackerGeometry * trackerGeometry_
Definition: DetId.h:18
static std::atomic< unsigned int > counter
void PixelInactiveAreaFinder::getRSpan ( const DetGroup detGroup,
DetGroupSpan cspan 
)
private

Definition at line 1068 of file PixelInactiveAreaFinder.cc.

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

Referenced by getSpan(), and printBadDetGroups().

1068  {
1069  auto cmpFun = [this] (det_t detA, det_t detB){
1070  return
1071  trackerGeometry_->idToDet(DetId(detA))->surface().rSpan().first
1072  <
1073  trackerGeometry_->idToDet(DetId(detB))->surface().rSpan().first
1074  ;
1075  };
1076 
1077  auto minmaxIters = std::minmax_element(detGroup.begin(),detGroup.end(),cmpFun);
1078  cspan.rSpan.first = trackerGeometry_->idToDet(DetId(*(minmaxIters.first)))->surface().rSpan().first;
1079  cspan.rSpan.second = trackerGeometry_->idToDet(DetId(*(minmaxIters.second)))->surface().rSpan().second;
1080 }
std::pair< float, float > const & rSpan() const
Definition: Surface.h:125
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
const TrackerGeometry * trackerGeometry_
Definition: DetId.h:18
const TrackerGeomDet * idToDet(DetId) const override
void PixelInactiveAreaFinder::getSpan ( const DetGroup detGroup,
DetGroupSpan cspan 
)
private

Definition at line 1081 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().

1081  {
1082  auto firstDetIt = detGroup.begin();
1083  if(firstDetIt != detGroup.end()){
1084  cspan.subdetId = DetId(*firstDetIt).subdetId();
1085  if(cspan.subdetId == 1){
1086  cspan.layer = trackerTopology_->pxbLayer(DetId(*firstDetIt));
1087  cspan.disk = 0;
1088  getPhiSpanBarrel(detGroup,cspan);
1089  }else if(cspan.subdetId == 2){
1090  cspan.disk = trackerTopology_->pxfDisk(DetId(*firstDetIt));
1091  cspan.layer = 0;
1092  getPhiSpanEndcap(detGroup,cspan);
1093  }
1094  getZSpan(detGroup,cspan);
1095  getRSpan(detGroup,cspan);
1096  }
1097 }
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:41
unsigned int pxbLayer(const DetId &id) const
Definition: DetId.h:18
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 1055 of file PixelInactiveAreaFinder.cc.

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

Referenced by getSpan(), and printBadDetGroups().

1055  {
1056  auto cmpFun = [this] (det_t detA, det_t detB){
1057  return
1058  trackerGeometry_->idToDet(DetId(detA))->surface().zSpan().first
1059  <
1060  trackerGeometry_->idToDet(DetId(detB))->surface().zSpan().first
1061  ;
1062  };
1063 
1064  auto minmaxIters = std::minmax_element(detGroup.begin(),detGroup.end(),cmpFun);
1065  cspan.zSpan.first = trackerGeometry_->idToDet(DetId(*(minmaxIters.first)))->surface().zSpan().first;
1066  cspan.zSpan.second = trackerGeometry_->idToDet(DetId(*(minmaxIters.second)))->surface().zSpan().second;
1067 }
std::pair< float, float > const & zSpan() const
Definition: Surface.h:124
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
const TrackerGeometry * trackerGeometry_
Definition: DetId.h:18
const TrackerGeomDet * idToDet(DetId) const override
PixelInactiveAreaFinder::InactiveAreas PixelInactiveAreaFinder::inactiveAreas ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 515 of file PixelInactiveAreaFinder.cc.

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

Referenced by PixelInactiveAreaTrackingRegionsSeedingLayersProducer::produce().

515  {
516  // Set data to handles
517  {
518  edm::ESHandle<TrackerGeometry> trackerGeometry;
519  iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometry);
520  trackerGeometry_ = trackerGeometry.product();
521 
522  edm::ESHandle<TrackerTopology> trackerTopology;
523  iSetup.get<TrackerTopologyRcd>().get(trackerTopology);
524  trackerTopology_ = trackerTopology.product();
525  }
526 
527  // assign data to instance variables
528  updatePixelDets(iSetup);
529  getBadPixelDets(iEvent, iSetup);
530 
531  //write files for plotting
534  }
535 
536  // find detGroupSpans ie phi,r,z limits for detector detGroups that are not working
537  // returns pair where first is barrel spans and second endcap spans
539 
540  // map spans to a vector with consistent indexing with inactiveLayers_ and inactiveLayerSetIndices_
541  // TODO: try to move the inner logic towards this direction as well
542  std::vector<DetGroupSpanContainer> spans(inactiveLayers_.size());
543 
544  auto doWork = [&](const DetGroupSpanContainer& container) {
545  for(const auto& span: container) {
547  const auto side = (subdet == GeomDetEnumerators::PixelBarrel ? TrackerDetSide::Barrel :
548  (span.zSpan.first < 0 ? TrackerDetSide::NegEndcap : TrackerDetSide::PosEndcap));
549  const auto layer = subdet == GeomDetEnumerators::PixelBarrel ? span.layer : span.disk;
550  auto found = std::find(inactiveLayers_.begin(), inactiveLayers_.end(), SeedingLayerId(subdet, side, layer));
551  if(found != inactiveLayers_.end()) { // it is possible that this layer is ignored by the configuration
552  spans[std::distance(inactiveLayers_.begin(), found)].push_back(span);
553  }
554  }
555  };
556  doWork(cspans.first);
557  doWork(cspans.second);
558 
559  auto ret = InactiveAreas(&inactiveLayers_,
560  std::move(spans),
563 
564  if(debug_) {
565  printOverlapSpans(ret);
566  }
567 
568  return ret;
569 }
std::pair< DetGroupSpanContainer, DetGroupSpanContainer > DetGroupSpanContainerPair
SeedingLayerSetsBuilder::SeedingLayerId SeedingLayerId
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
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:71
DetGroupSpanContainerPair detGroupSpans()
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 753 of file PixelInactiveAreaFinder.cc.

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

753  {
754  DetGroupContainer badDetGroupsBar = badDetGroupsBarrel();
755  DetGroupContainer badDetGroupsEnd = badDetGroupsEndcap();
756  Stream ss;
757  for(auto const & detGroup : badDetGroupsBar){
758  ss << std::setfill(' ') << std::left << std::setw(16) << "DetGroup:";
759  DetGroupSpan cspan;
760  getPhiSpanBarrel(detGroup,cspan);
761  getZSpan(detGroup,cspan);
762  getRSpan(detGroup,cspan);
763  detGroupSpanInfo(cspan,ss);
764  ss<<std::endl;
765  for(auto const & det : detGroup){
766  detInfo(det,ss);ss<<std::endl;
767  }
768  ss<<std::endl;
769  }
770  for(auto const & detGroup : badDetGroupsEnd){
771  ss << std::setfill(' ') << std::left << std::setw(16) << "DetGroup:";
772  DetGroupSpan cspan;
773  getPhiSpanEndcap(detGroup,cspan);
774  getZSpan(detGroup,cspan);
775  getRSpan(detGroup,cspan);
776  detGroupSpanInfo(cspan,ss);
777  ss << std::endl;
778  for(auto const & det : detGroup){
779  detInfo(det,ss);ss<<std::endl;
780  }
781  ss << std::endl;
782  }
783  edm::LogPrint("PixelInactiveAreaFinder")<<ss.str();
784 }
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 785 of file PixelInactiveAreaFinder.cc.

References detGroupSpans().

785  {
787  Stream ss;
788  for(auto const & cspan : cspans.first){
789  detGroupSpanInfo(cspan,ss);ss<<std::endl;
790  }
791  for(auto const & cspan : cspans.second){
792  detGroupSpanInfo(cspan,ss);ss<<std::endl;
793  }
794  edm::LogPrint("PixelInactiveAreaFinder") << ss.str();
795 }
std::pair< DetGroupSpanContainer, DetGroupSpanContainer > DetGroupSpanContainerPair
DetGroupSpanContainerPair detGroupSpans()
void PixelInactiveAreaFinder::printBadPixelDets ( )
private

Definition at line 740 of file PixelInactiveAreaFinder.cc.

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

740  {
741  edm::LogPrint("PixelInactiveAreaFinder") << "Bad barrel detectors:";
742  Stream ss;
743  for(auto const & det : badPixelDetsBarrel_){
744  detInfo(det,ss);
745  edm::LogPrint("PixelInactiveAreaFinder") << ss.str();ss.str(std::string());
746  }
747  edm::LogPrint("PixelInactiveAreaFinder") << "Endcap detectors;";
748  for(auto const & det : badPixelDetsEndcap_){
749  detInfo(det,ss);
750  edm::LogPrint("PixelInactiveAreaFinder") << ss.str();ss.str(std::string());
751  }
752 }
void detInfo(const det_t &det, Stream &ss)
void PixelInactiveAreaFinder::printPixelDets ( )
private

Definition at line 727 of file PixelInactiveAreaFinder.cc.

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

727  {
728  edm::LogPrint("PixelInactiveAreaFinder") << "Barrel detectors:";
729  Stream ss;
730  for(auto const & det : pixelDetsBarrel_){
731  detInfo(det,ss);
732  edm::LogPrint("PixelInactiveAreaFinder") << ss.str();ss.str(std::string());
733  }
734  edm::LogPrint("PixelInactiveAreaFinder") << "Endcap detectors;";
735  for(auto const & det : pixelDetsEndcap_){
736  detInfo(det,ss);
737  edm::LogPrint("PixelInactiveAreaFinder") << ss.str();ss.str(std::string());
738  }
739 }
void detInfo(const det_t &det, Stream &ss)
PixelInactiveAreaFinder::DetGroup PixelInactiveAreaFinder::reachableDetGroup ( const det_t initDet,
DetectorSet foundDets 
)
private

Definition at line 900 of file PixelInactiveAreaFinder.cc.

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

Referenced by badDetGroupsBarrel(), and badDetGroupsEndcap().

900  {
902  std::queue<det_t> workQueue;
903  det_t workDet;
904  DetGroup badAdjDets;
905  foundDets.insert(initDet);
906  workQueue.push(initDet);
907  reachableDetGroup.push_back(initDet);
908  while(!workQueue.empty()){
909  workDet = workQueue.front();workQueue.pop();
910  if(DetId(workDet).subdetId() == PixelSubdetector::PixelBarrel){
911  badAdjDets = this->badAdjecentDetsBarrel(workDet);
912  }else if(DetId(workDet).subdetId() == PixelSubdetector::PixelEndcap){
913  badAdjDets = this->badAdjecentDetsEndcap(workDet);
914  }else {
915  badAdjDets = {};
916  }
917  for(auto const & badDet : badAdjDets){
918  if(foundDets.find(badDet) == foundDets.end()){
919  reachableDetGroup.push_back(badDet);
920  foundDets.insert(badDet);
921  workQueue.push(badDet);
922  }
923  }
924  }
925  return reachableDetGroup;
926 }
DetGroup reachableDetGroup(const det_t &initDet, DetectorSet &foundDets)
DetGroup badAdjecentDetsBarrel(const det_t &det)
Definition: DetId.h:18
DetGroup badAdjecentDetsEndcap(const det_t &det)
void PixelInactiveAreaFinder::updatePixelDets ( const edm::EventSetup iSetup)
private

Definition at line 572 of file PixelInactiveAreaFinder.cc.

References begin, edm::ESWatcher< T >::check(), createPlottingFiles_, TrackerGeometry::detsPXB(), TrackerGeometry::detsPXF(), end, Exception, cmsPerfPublish::fail(), 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().

572  {
573  if(!geometryWatcher_.check(iSetup))
574  return;
575 
576  // deduce the number of ladders per layer and the number of modules per ladder
577  {
578  // sanity checks
580  throw cms::Exception("NotImplemented") << "This module supports only a detector with 4 pixel barrel layers, the current geometry has " << trackerGeometry_->numberOfLayers(PixelSubdetector::PixelBarrel);
581  }
583  throw cms::Exception("NotImplemented") << "This module supports only a detector with 3 pixel forward disks, the current geometry has " << trackerGeometry_->numberOfLayers(PixelSubdetector::PixelEndcap);
584  }
585 
586  std::array<std::array<unsigned short, 100>, 4> counts = {}; // assume at most 100 ladders per layer
587  for(const auto& det: trackerGeometry_->detsPXB()) {
588  const auto layer = trackerTopology_->layer(det->geographicalId());
589  const auto ladder = trackerTopology_->pxbLadder(det->geographicalId());
590  if(ladder >= 100) {
591  throw cms::Exception("LogicError") << "Got a ladder with number " << ladder << " while the expected maximum was 100; either something is wrong or the maximum has to be increased.";
592  }
593  counts[layer-1][ladder-1] += 1; // numbering of layer and ladder starts at 1
594  }
595 
596  // take number of modules per ladder from the first ladder of the first layer (such better exist)
597  // other ladders better have the same number
598  nModulesPerLadder = counts[0][0];
599  if(nModulesPerLadder == 0) {
600  throw cms::Exception("LogicError") << "Ladder 1 of layer 1 has 0 modules, something fishy is going on.";
601  }
602 
603  LogDebug("PixelInactiveAreaFinder") << "Number of modules per ladder " << nModulesPerLadder << "; below are number of ladders per layer";
604 
605  // number of ladders
606  for(unsigned layer=0; layer<4; ++layer) {
607  nBPixLadders[layer] = std::count_if(counts[layer].begin(), counts[layer].end(), [](unsigned short val) { return val > 0; });
608  LogTrace("PixelInactiveAreaFinder") << "BPix layer " << (layer+1) << " has " << nBPixLadders[layer] << " ladders";
609 
610  auto fail = std::count_if(counts[layer].begin(), counts[layer].end(), [&](unsigned short val) { return val != nModulesPerLadder && val > 0; });
611  if(fail != 0) {
612  throw cms::Exception("LogicError") << "Layer " << (layer+1) << " had " << fail << " ladders whose number of modules/ladder differed from the ladder 1 of layer 1 (" << nModulesPerLadder << "). Something fishy is going on.";
613  }
614  }
615  }
616 
617 
618  // don't bother with the rest if not needed
620  return;
621 
622  pixelDetsBarrel_.clear();
623  pixelDetsEndcap_.clear();
624 
625  for(auto const & geomDetPtr : trackerGeometry_->detsPXB() ) {
626  if(geomDetPtr->geographicalId().subdetId() == PixelSubdetector::PixelBarrel){
627  pixelDetsBarrel_.push_back(geomDetPtr->geographicalId().rawId());
628  }
629  }
630  for(auto const & geomDetPtr : trackerGeometry_->detsPXF() ) {
631  if(geomDetPtr->geographicalId().subdetId() == PixelSubdetector::PixelEndcap){
632  pixelDetsEndcap_.push_back(geomDetPtr->geographicalId().rawId());
633  }
634  }
635  std::sort(pixelDetsBarrel_.begin(),pixelDetsBarrel_.end());
636  std::sort(pixelDetsEndcap_.begin(),pixelDetsEndcap_.end());
637 }
#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
def fail(errstr="")
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 90 of file PixelInactiveAreaFinder.h.

Referenced by getBadPixelDets(), and PixelInactiveAreaFinder().

const bool PixelInactiveAreaFinder::createPlottingFiles_
private

Definition at line 81 of file PixelInactiveAreaFinder.h.

Referenced by inactiveAreas(), and updatePixelDets().

const bool PixelInactiveAreaFinder::debug_
private

Definition at line 80 of file PixelInactiveAreaFinder.h.

Referenced by inactiveAreas().

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

Definition at line 107 of file PixelInactiveAreaFinder.h.

Referenced by updatePixelDets().

const bool PixelInactiveAreaFinder::ignoreSingleFPixPanelModules_
private

Definition at line 82 of file PixelInactiveAreaFinder.h.

Referenced by badDetGroupsEndcap().

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

Definition at line 84 of file PixelInactiveAreaFinder.h.

Referenced by inactiveAreas(), and PixelInactiveAreaFinder().

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

Definition at line 85 of file PixelInactiveAreaFinder.h.

Referenced by inactiveAreas(), and PixelInactiveAreaFinder().

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

Definition at line 89 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 98 of file PixelInactiveAreaFinder.h.

Referenced by badAdjecentDetsBarrel(), and updatePixelDets().

DetContainer PixelInactiveAreaFinder::pixelDetsBarrel_
private

Definition at line 113 of file PixelInactiveAreaFinder.h.

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

DetContainer PixelInactiveAreaFinder::pixelDetsEndcap_
private

Definition at line 114 of file PixelInactiveAreaFinder.h.

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

const SiPixelQuality* PixelInactiveAreaFinder::pixelQuality_ = 0
private

Definition at line 109 of file PixelInactiveAreaFinder.h.

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