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_
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
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_
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 detWorks(), PVValHelper::ladder, nBPixLadders, nModulesPerLadder, and trackerTopology_.

Referenced by reachableDetGroup().

846  {
847  using std::remove_if;
848  using std::bind1st;
849  using std::mem_fun;
850 
851  DetGroup adj;
852  auto const tTopo = trackerTopology_;
853  auto const & detId = DetId(det);
854  unsigned int layer = tTopo->pxbLayer (detId);
855  unsigned int ladder = tTopo->pxbLadder(detId);
856  unsigned int module = tTopo->pxbModule(detId);
857  unsigned int nLads = nBPixLadders[layer];
858  //add detectors from next and previous ladder
859  adj.push_back( tTopo->pxbDetId( layer, ((ladder-1)+1)%nLads+1, module )() );
860  adj.push_back( tTopo->pxbDetId( layer, ((ladder-1)-1+nLads)%nLads+1, module )() );
861  //add adjecent detectors from same ladder
862  if(module == 1) {
863  adj.push_back( tTopo->pxbDetId( layer, ladder, module+1 )() );
864  }
865  else if(module == nModulesPerLadder) {
866  adj.push_back( tTopo->pxbDetId( layer, ladder, module-1 )() );
867  }
868  else {
869  adj.push_back( tTopo->pxbDetId( layer, ladder, module+1 )() );
870  adj.push_back( tTopo->pxbDetId( layer, ladder, module-1 )() );
871  }
872  //remove working detectors from list
873  adj.erase(remove_if(adj.begin(),adj.end(),bind1st(
874  mem_fun(&PixelInactiveAreaFinder::detWorks),this)),adj.end());
875  return adj;
876 }
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 877 of file PixelInactiveAreaFinder.cc.

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

Referenced by reachableDetGroup().

877  {
878  // this might be faster if adjecent
879  using std::tie;
880  using std::ignore;
881  DetGroup adj;
882  Span_t phiSpan, phiSpanComp;
883  float z, zComp;
884  unsigned int disk, diskComp;
885  auto const & detSurf = trackerGeometry_->idToDet(DetId(det))->surface();
886  phiSpan = detSurf.phiSpan();
887  tie(z,ignore) = detSurf.zSpan();
888  disk = trackerTopology_->pxfDisk(DetId(det));
889  // add detectors from same disk whose phi ranges overlap to the adjecent list
890  for(auto const & detComp : badPixelDetsEndcap_){
891  auto const & detIdComp = DetId(detComp);
892  auto const & detSurfComp = trackerGeometry_->idToDet(detIdComp)->surface();
893  diskComp = trackerTopology_->pxfDisk(detIdComp);
894  phiSpanComp = detSurfComp.phiSpan();
895  tie(zComp,ignore) = detSurfComp.zSpan();
896  if(det != detComp && disk == diskComp && z*zComp > 0
897  && phiRangesOverlap(phiSpan,phiSpanComp)){
898  adj.push_back(detComp);
899  }
900  }
901  return adj;
902 }
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 930 of file PixelInactiveAreaFinder.cc.

References badPixelDetsBarrel_, and reachableDetGroup().

Referenced by detGroupSpans(), and printBadDetGroups().

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

References badPixelDetsEndcap_, ignoreSingleFPixPanelModules_, and reachableDetGroup().

Referenced by detGroupSpans(), and printBadDetGroups().

940  {
941  DetGroupContainer detGroups;
942  DetectorSet foundDets;
943  for(auto const & badDet : badPixelDetsEndcap_){
944  if(foundDets.find(badDet) == foundDets.end()){
945  auto adjacentDets = this->reachableDetGroup(badDet,foundDets);
946  if(ignoreSingleFPixPanelModules_ && adjacentDets.size() == 1) {
947  // size==1 means that only a single panel of a blade was inactive
948  // because of the large overlap with the other panel (i.e.
949  // redundancy in the detectory) ignoring these may help to decrease fakes
950  continue;
951  }
952  detGroups.push_back(adjacentDets);
953  }
954  }
955  return detGroups;
956 }
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 1101 of file PixelInactiveAreaFinder.cc.

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

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

1101  {
1102  DetGroupSpanContainer cspansBarrel;
1103  DetGroupSpanContainer cspansEndcap;
1104  DetGroupContainer badDetGroupsBar = badDetGroupsBarrel();
1105  DetGroupContainer badDetGroupsEnd = badDetGroupsEndcap();
1106  for(auto const & detGroup : badDetGroupsBar){
1107  DetGroupSpan cspan;
1108  getSpan(detGroup,cspan);
1109  cspansBarrel.push_back(cspan);
1110  }
1111  for(auto const & detGroup : badDetGroupsEnd){
1112  DetGroupSpan cspan;
1113  getSpan(detGroup,cspan);
1114  cspansEndcap.push_back(cspan);
1115  }
1116  return DetGroupSpanContainerPair(cspansBarrel,cspansEndcap);
1117 }
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
const TrackerGeometry * trackerGeometry_
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:38
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(), edm::ParameterSetDescription::addUntracked(), and edm::ParameterDescriptionNode::setComment().

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>())->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 }
void setComment(std::string const &value)
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:519
def unique(seq, keepstr=True)
Definition: tier0.py:24
const std::vector< disabledModuleType > getBadComponentList() const
std::vector< edm::EDGetTokenT< PixelFEDChannelCollection > > badPixelFEDChannelsTokens_
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:59
void PixelInactiveAreaFinder::getPhiSpanBarrel ( const DetGroup detGroup,
DetGroupSpan cspan 
)
private

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

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

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

Referenced by getSpan(), and printBadDetGroups().

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

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

Referenced by getSpan(), and printBadDetGroups().

1071  {
1072  auto cmpFun = [this] (det_t detA, det_t detB){
1073  return
1074  trackerGeometry_->idToDet(DetId(detA))->surface().rSpan().first
1075  <
1076  trackerGeometry_->idToDet(DetId(detB))->surface().rSpan().first
1077  ;
1078  };
1079 
1080  auto minmaxIters = std::minmax_element(detGroup.begin(),detGroup.end(),cmpFun);
1081  cspan.rSpan.first = trackerGeometry_->idToDet(DetId(*(minmaxIters.first)))->surface().rSpan().first;
1082  cspan.rSpan.second = trackerGeometry_->idToDet(DetId(*(minmaxIters.second)))->surface().rSpan().second;
1083 }
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 1084 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().

1084  {
1085  auto firstDetIt = detGroup.begin();
1086  if(firstDetIt != detGroup.end()){
1087  cspan.subdetId = DetId(*firstDetIt).subdetId();
1088  if(cspan.subdetId == 1){
1089  cspan.layer = trackerTopology_->pxbLayer(DetId(*firstDetIt));
1090  cspan.disk = 0;
1091  getPhiSpanBarrel(detGroup,cspan);
1092  }else if(cspan.subdetId == 2){
1093  cspan.disk = trackerTopology_->pxfDisk(DetId(*firstDetIt));
1094  cspan.layer = 0;
1095  getPhiSpanEndcap(detGroup,cspan);
1096  }
1097  getZSpan(detGroup,cspan);
1098  getRSpan(detGroup,cspan);
1099  }
1100 }
unsigned int pxfDisk(const DetId &id) const
void getRSpan(const DetGroup &detGroup, DetGroupSpan &cspan)
void getPhiSpanBarrel(const DetGroup &detGroup, DetGroupSpan &cspan)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:38
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 1058 of file PixelInactiveAreaFinder.cc.

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

Referenced by getSpan(), and printBadDetGroups().

1058  {
1059  auto cmpFun = [this] (det_t detA, det_t detB){
1060  return
1061  trackerGeometry_->idToDet(DetId(detA))->surface().zSpan().first
1062  <
1063  trackerGeometry_->idToDet(DetId(detB))->surface().zSpan().first
1064  ;
1065  };
1066 
1067  auto minmaxIters = std::minmax_element(detGroup.begin(),detGroup.end(),cmpFun);
1068  cspan.zSpan.first = trackerGeometry_->idToDet(DetId(*(minmaxIters.first)))->surface().zSpan().first;
1069  cspan.zSpan.second = trackerGeometry_->idToDet(DetId(*(minmaxIters.second)))->surface().zSpan().second;
1070 }
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
const T & get() const
Definition: EventSetup.h:59
DetGroupSpanContainerPair detGroupSpans()
T const * product() const
Definition: ESHandle.h:86
std::vector< std::vector< LayerSetIndex > > layerSetIndexInactiveToActive_
def move(src, dest)
Definition: eostools.py:510
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 903 of file PixelInactiveAreaFinder.cc.

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

Referenced by badDetGroupsBarrel(), and badDetGroupsEndcap().

903  {
905  std::queue<det_t> workQueue;
906  det_t workDet;
907  DetGroup badAdjDets;
908  foundDets.insert(initDet);
909  workQueue.push(initDet);
910  reachableDetGroup.push_back(initDet);
911  while(!workQueue.empty()){
912  workDet = workQueue.front();workQueue.pop();
913  if(DetId(workDet).subdetId() == PixelSubdetector::PixelBarrel){
914  badAdjDets = this->badAdjecentDetsBarrel(workDet);
915  }else if(DetId(workDet).subdetId() == PixelSubdetector::PixelEndcap){
916  badAdjDets = this->badAdjecentDetsEndcap(workDet);
917  }else {
918  badAdjDets = {};
919  }
920  for(auto const & badDet : badAdjDets){
921  if(foundDets.find(badDet) == foundDets.end()){
922  reachableDetGroup.push_back(badDet);
923  foundDets.insert(badDet);
924  workQueue.push(badDet);
925  }
926  }
927  }
928  return reachableDetGroup;
929 }
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:57
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