CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
< SiPixelFedCablingTree
cabling_
 
edm::ESGetToken
< SiPixelFedCablingMap,
SiPixelFedCablingMapRcd
cablingMapToken_
 
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::ESGetToken
< TrackerGeometry,
TrackerDigiGeometryRecord
trackerGeomToken_
 
edm::ESWatcher
< SiPixelFedCablingMapRcd
watcherSiPixelFedCablingMap_
 

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 32 of file PixelUnpackingRegions.h.

Constructor & Destructor Documentation

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

Definition at line 28 of file PixelUnpackingRegions.cc.

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

28  {
29  edm::ParameterSet regPSet = conf.getParameter<edm::ParameterSet>("Regions");
30  beamSpotTag_ = regPSet.getParameter<edm::InputTag>("beamSpot");
31  inputs_ = regPSet.getParameter<std::vector<edm::InputTag> >("inputs");
32  dPhi_ = regPSet.getParameter<std::vector<double> >("deltaPhi");
33  maxZ_ = regPSet.getParameter<std::vector<double> >("maxZ");
36 
38  for (unsigned int t = 0; t < inputs_.size(); t++)
39  tCandidateView.push_back(iC.consumes<reco::CandidateView>(inputs_[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 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< edm::EDGetTokenT< reco::CandidateView > > tCandidateView
Log< level::Error, false > LogError
edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcd > cablingMapToken_
std::vector< edm::InputTag > inputs_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< double > dPhi_
std::vector< double > maxZ_
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeomToken_
edm::EDGetTokenT< reco::BeamSpot > tBeamSpot
PixelUnpackingRegions::~PixelUnpackingRegions ( )
inline

Definition at line 51 of file PixelUnpackingRegions.h.

51 {}

Member Function Documentation

void PixelUnpackingRegions::addRegion ( Region r)
private

Definition at line 139 of file PixelUnpackingRegions.cc.

References addRegionLocal(), PixelUnpackingRegions::Region::dPhi, nreg_, phi, phiBPIX_, phiFPIXm_, phiFPIXp_, and PixelUnpackingRegions::Region::v.

Referenced by run().

139  {
140  ++nreg_;
141 
142  float phi = r.v.phi();
143 
144  Module lo(phi - r.dPhi);
145  Module hi(phi + r.dPhi);
146 
147  addRegionLocal(r, phiBPIX_, lo, hi);
148  if (r.v.eta() > 1.) {
149  addRegionLocal(r, phiFPIXp_, lo, hi);
150  }
151  if (r.v.eta() < -1.) {
152  addRegionLocal(r, phiFPIXm_, lo, hi);
153  }
154 }
void addRegionLocal(Region &r, std::vector< Module > &container, const Module &lo, const Module &hi)
std::vector< Module > phiFPIXm_
std::vector< Module > phiFPIXp_
std::vector< Module > phiBPIX_
void PixelUnpackingRegions::addRegionLocal ( Region r,
std::vector< Module > &  container,
const Module lo,
const Module hi 
)
private

Definition at line 156 of file PixelUnpackingRegions.cc.

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

Referenced by addRegion().

159  {
160  Module lo = _lo;
161  Module hi = _hi;
162  Module pi_m(-M_PI);
163  Module pi_p(M_PI);
164 
165  std::vector<Module>::const_iterator a, b;
166 
167  if (lo.phi >= -M_PI && hi.phi <= M_PI) // interval doesn't cross the +-pi overlap
168  {
169  a = lower_bound(container.begin(), container.end(), lo);
170  b = upper_bound(container.begin(), container.end(), hi);
171  gatherFromRange(r, a, b);
172  } else // interval is torn by the +-pi overlap
173  {
174  if (hi.phi > M_PI)
175  hi.phi -= 2. * M_PI;
176  a = lower_bound(container.begin(), container.end(), pi_m);
177  b = upper_bound(container.begin(), container.end(), hi);
178  gatherFromRange(r, a, b);
179 
180  if (lo.phi < -M_PI)
181  lo.phi += 2. * M_PI;
182  a = lower_bound(container.begin(), container.end(), lo);
183  b = upper_bound(container.begin(), container.end(), pi_p);
184  gatherFromRange(r, a, b);
185  }
186 }
__host__ __device__ constexpr RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
void gatherFromRange(Region &r, std::vector< Module >::const_iterator, std::vector< Module >::const_iterator)
#define M_PI
double b
Definition: hdecay.h:118
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
double a
Definition: hdecay.h:119
void PixelUnpackingRegions::gatherFromRange ( Region r,
std::vector< Module >::const_iterator  a,
std::vector< Module >::const_iterator  b 
)
private

Definition at line 188 of file PixelUnpackingRegions.cc.

References a, funct::abs(), PixelUnpackingRegions::Region::atantheta, b, beamSpot_, PixelUnpackingRegions::Region::cosphi, feds_, PixelUnpackingRegions::Region::maxZ, modules_, and PixelUnpackingRegions::Region::sinphi.

Referenced by addRegionLocal().

190  {
191  for (; a != b; ++a) {
192  // projection in r's direction onto beam's z
193  float zmodule = a->z - ((a->x - beamSpot_.x()) * r.cosphi + (a->y - beamSpot_.y()) * r.sinphi) * r.atantheta;
194 
195  // do not include modules that project too far in z
196  if (std::abs(zmodule) > r.maxZ)
197  continue;
198 
199  feds_.insert(a->fed);
200  modules_.insert(a->id);
201  }
202 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
std::set< unsigned int > feds_
std::set< unsigned int > modules_
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.

References cms::cuda::assert(), cabling_, cablingMapToken_, edm::ESWatcher< T >::check(), PixelUnpackingRegions::Module::fed, relativeConstraints::geom, edm::EventSetup::getHandle(), PixelUnpackingRegions::Module::id, visualization-live-secondInstance_cfg::m, FEDNumbering::MAXSiPixelFEDID, FEDNumbering::MAXSiPixeluTCAFEDID, FEDNumbering::MINSiPixelFEDID, FEDNumbering::MINSiPixeluTCAFEDID, GeomDetEnumerators::P1PXB, GeomDetEnumerators::P1PXEC, PixelUnpackingRegions::Module::phi, phiBPIX_, phiFPIXm_, phiFPIXp_, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, trackerGeomToken_, watcherSiPixelFedCablingMap_, PixelUnpackingRegions::Module::x, PixelUnpackingRegions::Module::y, and PixelUnpackingRegions::Module::z.

Referenced by run().

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

check whether a FED has to be unpacked

Definition at line 204 of file PixelUnpackingRegions.cc.

References feds_.

Referenced by SiPixelRawToDigi::produce().

204  {
205  if (feds_.count(fed_n))
206  return true;
207  return false;
208 }
std::set< unsigned int > feds_
bool PixelUnpackingRegions::mayUnpackModule ( unsigned int  id) const

check whether a module has to be unpacked

Definition at line 210 of file PixelUnpackingRegions.cc.

References modules_.

210  {
211  if (modules_.count(id))
212  return true;
213  return false;
214 }
std::set< unsigned int > modules_
const std::set<unsigned int>* PixelUnpackingRegions::modulesToUnpack ( ) const
inline

full set of module ids to unpack

Definition at line 63 of file PixelUnpackingRegions.h.

References modules_.

Referenced by SiPixelRawToDigi::produce().

63 { return &modules_; }
std::set< unsigned int > modules_
unsigned int PixelUnpackingRegions::nBarrelModules ( ) const

Definition at line 216 of file PixelUnpackingRegions.cc.

References modules_.

Referenced by SiPixelRawToDigi::produce().

216  {
217  return std::count_if(modules_.begin(), modules_.end(), isBPIXModule);
218 }
std::set< unsigned int > modules_
unsigned int PixelUnpackingRegions::nFEDs ( ) const
inline

various informational accessors:

Definition at line 66 of file PixelUnpackingRegions.h.

References feds_.

Referenced by SiPixelRawToDigi::produce().

66 { return feds_.size(); }
std::set< unsigned int > feds_
unsigned int PixelUnpackingRegions::nForwardModules ( ) const

Definition at line 220 of file PixelUnpackingRegions.cc.

References modules_.

Referenced by SiPixelRawToDigi::produce().

220  {
221  return std::count_if(modules_.begin(), modules_.end(), isFPIXModule);
222 }
std::set< unsigned int > modules_
unsigned int PixelUnpackingRegions::nModules ( ) const
inline

Definition at line 67 of file PixelUnpackingRegions.h.

References modules_.

Referenced by SiPixelRawToDigi::produce().

67 { return modules_.size(); }
std::set< unsigned int > modules_
unsigned int PixelUnpackingRegions::nRegions ( ) const
inline

Definition at line 70 of file PixelUnpackingRegions.h.

References nreg_.

70 { return nreg_; }
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.

References addRegion(), beam_dqm_sourceclient-live_cfg::beamSpot, beamSpot_, c, dPhi_, feds_, edm::Event::getByToken(), h, mps_fire::i, initialize(), input, inputs_, maxZ_, modules_, reco::Candidate::momentum(), dqmiodumpmetadata::n, nreg_, alignCSCRings::r, tBeamSpot, and tCandidateView.

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

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) {
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 }
const edm::EventSetup & c
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::vector< edm::EDGetTokenT< reco::CandidateView > > tCandidateView
static std::string const input
Definition: EdmProvDump.cc:47
virtual Vector momentum() const =0
spatial momentum vector
std::vector< edm::InputTag > inputs_
std::vector< double > dPhi_
void initialize(const edm::EventSetup &es)
run by the run method: (re)initialize the cabling data when it&#39;s necessary
std::vector< double > maxZ_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
edm::EDGetTokenT< reco::BeamSpot > tBeamSpot
std::set< unsigned int > feds_
std::set< unsigned int > modules_

Member Data Documentation

math::XYZPoint PixelUnpackingRegions::beamSpot_
private

Definition at line 122 of file PixelUnpackingRegions.h.

Referenced by gatherFromRange(), and run().

edm::InputTag PixelUnpackingRegions::beamSpotTag_
private

Definition at line 95 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions().

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

Definition at line 121 of file PixelUnpackingRegions.h.

Referenced by initialize().

edm::ESGetToken<SiPixelFedCablingMap, SiPixelFedCablingMapRcd> PixelUnpackingRegions::cablingMapToken_
private

Definition at line 126 of file PixelUnpackingRegions.h.

Referenced by initialize(), and PixelUnpackingRegions().

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

Definition at line 93 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

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

Definition at line 100 of file PixelUnpackingRegions.h.

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

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

Definition at line 92 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

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

Definition at line 94 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

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

Definition at line 102 of file PixelUnpackingRegions.h.

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

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

Definition at line 117 of file PixelUnpackingRegions.h.

Referenced by addRegion(), and initialize().

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

Definition at line 119 of file PixelUnpackingRegions.h.

Referenced by addRegion(), and initialize().

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

Definition at line 118 of file PixelUnpackingRegions.h.

Referenced by addRegion(), and initialize().

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

Definition at line 97 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

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

Definition at line 98 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> PixelUnpackingRegions::trackerGeomToken_
private

Definition at line 125 of file PixelUnpackingRegions.h.

Referenced by initialize(), and PixelUnpackingRegions().

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

Definition at line 124 of file PixelUnpackingRegions.h.

Referenced by initialize().