CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
PixelUnpackingRegions Class Reference

#include <PixelUnpackingRegions.h>

Classes

struct  Module
 
struct  Region
 

Public Member Functions

bool mayUnpackFED (unsigned int fed_n) const
 check whether a FED has to be unpacked More...
 
bool mayUnpackModule (unsigned int id) const
 check whether a module has to be unpacked More...
 
const std::set< unsigned int > * modulesToUnpack () const
 full set of module ids to unpack More...
 
unsigned int nBarrelModules () const
 
unsigned int nFEDs () const
 various informational accessors: More...
 
unsigned int nForwardModules () const
 
unsigned int nModules () const
 
unsigned int nRegions () const
 
 PixelUnpackingRegions (const edm::ParameterSet &, edm::ConsumesCollector &&iC)
 
void run (const edm::Event &e, const edm::EventSetup &es)
 has to be run during each event More...
 
 ~PixelUnpackingRegions ()
 

Private Member Functions

void addRegion (Region &r)
 
void addRegionLocal (Region &r, std::vector< Module > &container, const Module &lo, const Module &hi)
 
void gatherFromRange (Region &r, std::vector< Module >::const_iterator, std::vector< Module >::const_iterator)
 
void initialize (const edm::EventSetup &es)
 run by the run method: (re)initialize the cabling data when it's necessary More...
 

Private Attributes

math::XYZPoint beamSpot_
 
edm::InputTag beamSpotTag_
 
std::unique_ptr< SiPixelFedCablingTreecabling_
 
std::vector< double > dPhi_
 
std::set< unsigned int > feds_
 
std::vector< edm::InputTaginputs_
 
std::vector< double > maxZ_
 
std::set< unsigned int > modules_
 
unsigned int nreg_
 
std::vector< ModulephiBPIX_
 
std::vector< ModulephiFPIXm_
 
std::vector< ModulephiFPIXp_
 
edm::EDGetTokenT< reco::BeamSpottBeamSpot
 
std::vector< edm::EDGetTokenT< reco::CandidateView > > tCandidateView
 
edm::ESWatcher< SiPixelFedCablingMapRcdwatcherSiPixelFedCablingMap_
 

Detailed Description

Input: One or several collections of Candidate-based seeds with their objects defining the directions of unpacking regions; separate deltaPhi and maxZ tolerances could be given to each input collection. Output: FED ids and module detIds that need to be unpacked

Definition at line 29 of file PixelUnpackingRegions.h.

Constructor & Destructor Documentation

◆ PixelUnpackingRegions()

PixelUnpackingRegions::PixelUnpackingRegions ( const edm::ParameterSet conf,
edm::ConsumesCollector &&  iC 
)

Definition at line 30 of file PixelUnpackingRegions.cc.

30  {
31  edm::ParameterSet regPSet = conf.getParameter<edm::ParameterSet>("Regions");
32  beamSpotTag_ = regPSet.getParameter<edm::InputTag>("beamSpot");
33  inputs_ = regPSet.getParameter<std::vector<edm::InputTag> >("inputs");
34  dPhi_ = regPSet.getParameter<std::vector<double> >("deltaPhi");
35  maxZ_ = regPSet.getParameter<std::vector<double> >("maxZ");
36 
38  for (unsigned int t = 0; t < inputs_.size(); t++)
40 
41  if (inputs_.size() != dPhi_.size() || dPhi_.size() != maxZ_.size()) {
42  edm::LogError("PixelUnpackingRegions")
43  << "Not the same size of config parameters vectors!\n"
44  << " inputs " << inputs_.size() << " deltaPhi " << dPhi_.size() << " maxZ " << maxZ_.size();
45  }
46 }

References beamSpotTag_, dPhi_, edm::ParameterSet::getParameter(), inputs_, maxZ_, OrderedSet::t, tBeamSpot, and tCandidateView.

◆ ~PixelUnpackingRegions()

PixelUnpackingRegions::~PixelUnpackingRegions ( )
inline

Definition at line 48 of file PixelUnpackingRegions.h.

48 {}

Member Function Documentation

◆ addRegion()

void PixelUnpackingRegions::addRegion ( Region r)
private

Definition at line 141 of file PixelUnpackingRegions.cc.

141  {
142  ++nreg_;
143 
144  float phi = r.v.phi();
145 
146  Module lo(phi - r.dPhi);
147  Module hi(phi + r.dPhi);
148 
149  addRegionLocal(r, phiBPIX_, lo, hi);
150  if (r.v.eta() > 1.) {
151  addRegionLocal(r, phiFPIXp_, lo, hi);
152  }
153  if (r.v.eta() < -1.) {
154  addRegionLocal(r, phiFPIXm_, lo, hi);
155  }
156 }

References addRegionLocal(), nreg_, phi, phiBPIX_, phiFPIXm_, phiFPIXp_, and alignCSCRings::r.

Referenced by run().

◆ addRegionLocal()

void PixelUnpackingRegions::addRegionLocal ( Region r,
std::vector< Module > &  container,
const Module lo,
const Module hi 
)
private

Definition at line 158 of file PixelUnpackingRegions.cc.

161  {
162  Module lo = _lo;
163  Module hi = _hi;
164  Module pi_m(-M_PI);
165  Module pi_p(M_PI);
166 
167  std::vector<Module>::const_iterator a, b;
168 
169  if (lo.phi >= -M_PI && hi.phi <= M_PI) // interval doesn't cross the +-pi overlap
170  {
171  a = lower_bound(container.begin(), container.end(), lo);
172  b = upper_bound(container.begin(), container.end(), hi);
173  gatherFromRange(r, a, b);
174  } else // interval is torn by the +-pi overlap
175  {
176  if (hi.phi > M_PI)
177  hi.phi -= 2. * M_PI;
178  a = lower_bound(container.begin(), container.end(), pi_m);
179  b = upper_bound(container.begin(), container.end(), hi);
180  gatherFromRange(r, a, b);
181 
182  if (lo.phi < -M_PI)
183  lo.phi += 2. * M_PI;
184  a = lower_bound(container.begin(), container.end(), lo);
185  b = upper_bound(container.begin(), container.end(), pi_p);
186  gatherFromRange(r, a, b);
187  }
188 }

References a, b, gatherFromRange(), cuda_std::lower_bound(), M_PI, PixelUnpackingRegions::Module::phi, alignCSCRings::r, and cuda_std::upper_bound().

Referenced by addRegion().

◆ gatherFromRange()

void PixelUnpackingRegions::gatherFromRange ( Region r,
std::vector< Module >::const_iterator  a,
std::vector< Module >::const_iterator  b 
)
private

Definition at line 190 of file PixelUnpackingRegions.cc.

192  {
193  for (; a != b; ++a) {
194  // projection in r's direction onto beam's z
195  float zmodule = a->z - ((a->x - beamSpot_.x()) * r.cosphi + (a->y - beamSpot_.y()) * r.sinphi) * r.atantheta;
196 
197  // do not include modules that project too far in z
198  if (std::abs(zmodule) > r.maxZ)
199  continue;
200 
201  feds_.insert(a->fed);
202  modules_.insert(a->id);
203  }
204 }

References a, funct::abs(), b, beamSpot_, feds_, modules_, and alignCSCRings::r.

Referenced by addRegionLocal().

◆ initialize()

void PixelUnpackingRegions::initialize ( const edm::EventSetup es)
private

run by the run method: (re)initialize the cabling data when it's necessary

Definition at line 76 of file PixelUnpackingRegions.cc.

76  {
77  // initialize cabling map or update it if necessary
78  // and re-cache modules information
81  es.get<SiPixelFedCablingMapRcd>().get(cablingMap);
82  cabling_ = cablingMap->cablingTree();
83 
85  // get the TrackerGeom
87 
88  // switch on the phase1
89  unsigned int fedMin = FEDNumbering::MINSiPixelFEDID; // phase0
90  unsigned int fedMax = FEDNumbering::MAXSiPixelFEDID;
91  if ((geom->isThere(GeomDetEnumerators::P1PXB)) && (geom->isThere(GeomDetEnumerators::P1PXEC))) {
92  fedMin = FEDNumbering::MINSiPixeluTCAFEDID; // phase1
94  }
95 
96  phiBPIX_.clear();
97  phiFPIXp_.clear();
98  phiFPIXm_.clear();
99 
100  phiBPIX_.reserve(1024);
101  phiFPIXp_.reserve(512);
102  phiFPIXm_.reserve(512);
103 
104  auto it = geom->dets().begin();
105  for (; it != geom->dets().end(); ++it) {
106  int subdet = (*it)->geographicalId().subdetId();
107  if (!(subdet == PixelSubdetector::PixelBarrel || subdet == PixelSubdetector::PixelEndcap))
108  continue;
109 
110  Module m;
111 
112  m.x = (*it)->position().x();
113  m.y = (*it)->position().y();
114  m.z = (*it)->position().z();
115 
116  m.phi = (*it)->position().phi();
117 
118  m.id = (*it)->geographicalId().rawId();
119  const std::vector<sipixelobjects::CablingPathToDetUnit> path2det = cabling_->pathToDetUnit(m.id);
120 
121  m.fed = path2det[0].fed;
122  assert((m.fed <= fedMax) && (m.fed >= fedMin));
123 
124  if (subdet == PixelSubdetector::PixelBarrel) {
125  phiBPIX_.push_back(m);
126  } else if (subdet == PixelSubdetector::PixelEndcap) {
127  if (m.z > 0.)
128  phiFPIXp_.push_back(m);
129  else
130  phiFPIXm_.push_back(m);
131  }
132  }
133 
134  // pre-sort by phi
135  std::sort(phiBPIX_.begin(), phiBPIX_.end());
136  std::sort(phiFPIXp_.begin(), phiFPIXp_.end());
137  std::sort(phiFPIXm_.begin(), phiFPIXm_.end());
138  }
139 }

References cms::cuda::assert(), cabling_, SiPixelFedCablingMap::cablingTree(), edm::ESWatcher< T >::check(), relativeConstraints::geom, edm::EventSetup::get(), get, visualization-live-secondInstance_cfg::m, FEDNumbering::MAXSiPixelFEDID, FEDNumbering::MAXSiPixeluTCAFEDID, FEDNumbering::MINSiPixelFEDID, FEDNumbering::MINSiPixeluTCAFEDID, GeomDetEnumerators::P1PXB, GeomDetEnumerators::P1PXEC, phiBPIX_, phiFPIXm_, phiFPIXp_, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, and watcherSiPixelFedCablingMap_.

Referenced by run().

◆ mayUnpackFED()

bool PixelUnpackingRegions::mayUnpackFED ( unsigned int  fed_n) const

check whether a FED has to be unpacked

Definition at line 206 of file PixelUnpackingRegions.cc.

206  {
207  if (feds_.count(fed_n))
208  return true;
209  return false;
210 }

References feds_.

Referenced by SiPixelRawToDigi::produce().

◆ mayUnpackModule()

bool PixelUnpackingRegions::mayUnpackModule ( unsigned int  id) const

check whether a module has to be unpacked

Definition at line 212 of file PixelUnpackingRegions.cc.

212  {
213  if (modules_.count(id))
214  return true;
215  return false;
216 }

References modules_.

◆ modulesToUnpack()

const std::set<unsigned int>* PixelUnpackingRegions::modulesToUnpack ( ) const
inline

full set of module ids to unpack

Definition at line 60 of file PixelUnpackingRegions.h.

60 { return &modules_; }

References modules_.

Referenced by SiPixelRawToDigi::produce().

◆ nBarrelModules()

unsigned int PixelUnpackingRegions::nBarrelModules ( ) const

Definition at line 218 of file PixelUnpackingRegions.cc.

218  {
219  return std::count_if(modules_.begin(), modules_.end(), isBPIXModule);
220 }

References modules_.

Referenced by SiPixelRawToDigi::produce().

◆ nFEDs()

unsigned int PixelUnpackingRegions::nFEDs ( ) const
inline

various informational accessors:

Definition at line 63 of file PixelUnpackingRegions.h.

63 { return feds_.size(); }

References feds_.

Referenced by SiPixelRawToDigi::produce().

◆ nForwardModules()

unsigned int PixelUnpackingRegions::nForwardModules ( ) const

Definition at line 222 of file PixelUnpackingRegions.cc.

222  {
223  return std::count_if(modules_.begin(), modules_.end(), isFPIXModule);
224 }

References modules_.

Referenced by SiPixelRawToDigi::produce().

◆ nModules()

unsigned int PixelUnpackingRegions::nModules ( ) const
inline

Definition at line 64 of file PixelUnpackingRegions.h.

64 { return modules_.size(); }

References modules_.

Referenced by SiPixelRawToDigi::produce().

◆ nRegions()

unsigned int PixelUnpackingRegions::nRegions ( ) const
inline

Definition at line 67 of file PixelUnpackingRegions.h.

67 { return nreg_; }

References nreg_.

◆ run()

void PixelUnpackingRegions::run ( const edm::Event e,
const edm::EventSetup es 
)

has to be run during each event

Definition at line 48 of file PixelUnpackingRegions.cc.

48  {
49  feds_.clear();
50  modules_.clear();
51  nreg_ = 0;
52 
53  initialize(es);
54 
56  e.getByToken(tBeamSpot, beamSpot);
57  beamSpot_ = beamSpot->position();
58  //beamSpot_ = math::XYZPoint(0.,0.,0.);
59 
60  size_t ninputs = inputs_.size();
61  for (size_t input = 0; input < ninputs; ++input) {
63  e.getByToken(tCandidateView[input], h);
64 
65  size_t n = h->size();
66  for (size_t i = 0; i < n; ++i) {
67  const reco::Candidate& c = (*h)[i];
68 
69  // different input collections can have different dPhi and maxZ
70  Region r(c.momentum(), dPhi_[input], maxZ_[input]);
71  addRegion(r);
72  }
73  }
74 }

References addRegion(), pwdgSkimBPark_cfi::beamSpot, beamSpot_, HltBtagPostValidation_cff::c, dPhi_, MillePedeFileConverter_cfg::e, feds_, h, mps_fire::i, initialize(), input, inputs_, maxZ_, modules_, dqmiodumpmetadata::n, nreg_, alignCSCRings::r, tBeamSpot, and tCandidateView.

Referenced by Types.EventID::cppID(), Types.LuminosityBlockID::cppID(), and SiPixelRawToDigi::produce().

Member Data Documentation

◆ beamSpot_

math::XYZPoint PixelUnpackingRegions::beamSpot_
private

Definition at line 119 of file PixelUnpackingRegions.h.

Referenced by gatherFromRange(), and run().

◆ beamSpotTag_

edm::InputTag PixelUnpackingRegions::beamSpotTag_
private

Definition at line 92 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions().

◆ cabling_

std::unique_ptr<SiPixelFedCablingTree> PixelUnpackingRegions::cabling_
private

Definition at line 118 of file PixelUnpackingRegions.h.

Referenced by initialize().

◆ dPhi_

std::vector<double> PixelUnpackingRegions::dPhi_
private

Definition at line 90 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

◆ feds_

std::set<unsigned int> PixelUnpackingRegions::feds_
private

Definition at line 97 of file PixelUnpackingRegions.h.

Referenced by gatherFromRange(), mayUnpackFED(), nFEDs(), and run().

◆ inputs_

std::vector<edm::InputTag> PixelUnpackingRegions::inputs_
private

Definition at line 89 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

◆ maxZ_

std::vector<double> PixelUnpackingRegions::maxZ_
private

Definition at line 91 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

◆ modules_

std::set<unsigned int> PixelUnpackingRegions::modules_
private

◆ nreg_

unsigned int PixelUnpackingRegions::nreg_
private

Definition at line 99 of file PixelUnpackingRegions.h.

Referenced by addRegion(), nRegions(), and run().

◆ phiBPIX_

std::vector<Module> PixelUnpackingRegions::phiBPIX_
private

Definition at line 114 of file PixelUnpackingRegions.h.

Referenced by addRegion(), and initialize().

◆ phiFPIXm_

std::vector<Module> PixelUnpackingRegions::phiFPIXm_
private

Definition at line 116 of file PixelUnpackingRegions.h.

Referenced by addRegion(), and initialize().

◆ phiFPIXp_

std::vector<Module> PixelUnpackingRegions::phiFPIXp_
private

Definition at line 115 of file PixelUnpackingRegions.h.

Referenced by addRegion(), and initialize().

◆ tBeamSpot

edm::EDGetTokenT<reco::BeamSpot> PixelUnpackingRegions::tBeamSpot
private

Definition at line 94 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

◆ tCandidateView

std::vector<edm::EDGetTokenT<reco::CandidateView> > PixelUnpackingRegions::tCandidateView
private

Definition at line 95 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

◆ watcherSiPixelFedCablingMap_

edm::ESWatcher<SiPixelFedCablingMapRcd> PixelUnpackingRegions::watcherSiPixelFedCablingMap_
private

Definition at line 121 of file PixelUnpackingRegions.h.

Referenced by initialize().

edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
PixelUnpackingRegions::beamSpotTag_
edm::InputTag beamSpotTag_
Definition: PixelUnpackingRegions.h:92
PixelUnpackingRegions::tBeamSpot
edm::EDGetTokenT< reco::BeamSpot > tBeamSpot
Definition: PixelUnpackingRegions.h:94
PixelUnpackingRegions::tCandidateView
std::vector< edm::EDGetTokenT< reco::CandidateView > > tCandidateView
Definition: PixelUnpackingRegions.h:95
mps_fire.i
i
Definition: mps_fire.py:355
PixelUnpackingRegions::beamSpot_
math::XYZPoint beamSpot_
Definition: PixelUnpackingRegions.h:119
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
input
static const std::string input
Definition: EdmProvDump.cc:48
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
PixelUnpackingRegions::modules_
std::set< unsigned int > modules_
Definition: PixelUnpackingRegions.h:98
PixelUnpackingRegions::dPhi_
std::vector< double > dPhi_
Definition: PixelUnpackingRegions.h:90
Module
#define Module(md)
Definition: vmac.h:203
PixelUnpackingRegions::cabling_
std::unique_ptr< SiPixelFedCablingTree > cabling_
Definition: PixelUnpackingRegions.h:118
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
cms::cuda::assert
assert(be >=bs)
edm::Handle< reco::BeamSpot >
PixelUnpackingRegions::maxZ_
std::vector< double > maxZ_
Definition: PixelUnpackingRegions.h:91
PixelUnpackingRegions::gatherFromRange
void gatherFromRange(Region &r, std::vector< Module >::const_iterator, std::vector< Module >::const_iterator)
Definition: PixelUnpackingRegions.cc:190
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
FEDNumbering::MAXSiPixelFEDID
Definition: FEDNumbering.h:28
cuda_std::upper_bound
__host__ constexpr __device__ RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:45
GeomDetEnumerators::P1PXEC
Definition: GeomDetEnumerators.h:26
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
reco::BeamSpot
Definition: BeamSpot.h:21
edm::ESHandle< TrackerGeometry >
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:49
PixelUnpackingRegions::phiBPIX_
std::vector< Module > phiBPIX_
Definition: PixelUnpackingRegions.h:114
h
PixelUnpackingRegions::phiFPIXm_
std::vector< Module > phiFPIXm_
Definition: PixelUnpackingRegions.h:116
OrderedSet.t
t
Definition: OrderedSet.py:90
b
double b
Definition: hdecay.h:118
cuda_std::lower_bound
__host__ constexpr __device__ RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:27
SiPixelFedCablingMap::cablingTree
std::unique_ptr< SiPixelFedCablingTree > cablingTree() const
Definition: SiPixelFedCablingMap.cc:103
PixelUnpackingRegions::nreg_
unsigned int nreg_
Definition: PixelUnpackingRegions.h:99
edm::View
Definition: CaloClusterFwd.h:14
GeomDetEnumerators::P1PXB
Definition: GeomDetEnumerators.h:25
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
a
double a
Definition: hdecay.h:119
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
g4SimHits_cfi.Region
Region
Definition: g4SimHits_cfi.py:143
PixelUnpackingRegions::addRegionLocal
void addRegionLocal(Region &r, std::vector< Module > &container, const Module &lo, const Module &hi)
Definition: PixelUnpackingRegions.cc:158
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
get
#define get
FEDNumbering::MAXSiPixeluTCAFEDID
Definition: FEDNumbering.h:106
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
FEDNumbering::MINSiPixelFEDID
Definition: FEDNumbering.h:27
reco::Candidate
Definition: Candidate.h:27
alignCSCRings.r
r
Definition: alignCSCRings.py:93
DDAxes::phi
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
hi
Definition: HiEvtPlaneList.h:38
PixelUnpackingRegions::initialize
void initialize(const edm::EventSetup &es)
run by the run method: (re)initialize the cabling data when it's necessary
Definition: PixelUnpackingRegions.cc:76
FEDNumbering::MINSiPixeluTCAFEDID
Definition: FEDNumbering.h:105
PixelUnpackingRegions::feds_
std::set< unsigned int > feds_
Definition: PixelUnpackingRegions.h:97
PixelUnpackingRegions::watcherSiPixelFedCablingMap_
edm::ESWatcher< SiPixelFedCablingMapRcd > watcherSiPixelFedCablingMap_
Definition: PixelUnpackingRegions.h:121
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
SiPixelFedCablingMapRcd
Definition: SiPixelFedCablingMapRcd.h:5
PixelUnpackingRegions::addRegion
void addRegion(Region &r)
Definition: PixelUnpackingRegions.cc:141
edm::InputTag
Definition: InputTag.h:15
PixelUnpackingRegions::phiFPIXp_
std::vector< Module > phiFPIXp_
Definition: PixelUnpackingRegions.h:115
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
PixelUnpackingRegions::inputs_
std::vector< edm::InputTag > inputs_
Definition: PixelUnpackingRegions.h:89