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

Constructor & Destructor Documentation

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

Definition at line 30 of file PixelUnpackingRegions.cc.

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

31 {
32  edm::ParameterSet regPSet = conf.getParameter<edm::ParameterSet>("Regions");
33  beamSpotTag_ = regPSet.getParameter<edm::InputTag>("beamSpot");
34  inputs_ = regPSet.getParameter<std::vector<edm::InputTag> >("inputs");
35  dPhi_ = regPSet.getParameter<std::vector<double> >("deltaPhi");
36  maxZ_ = regPSet.getParameter<std::vector<double> >("maxZ");
37 
39  for (unsigned int t=0; t<inputs_.size(); t++ ) tCandidateView.push_back(iC.consumes< reco::CandidateView >(inputs_[t]));
40 
41  if (inputs_.size() != dPhi_.size() || dPhi_.size() != maxZ_.size() )
42  {
43  edm::LogError("PixelUnpackingRegions")<<"Not the same size of config parameters vectors!\n"
44  <<" inputs "<<inputs_.size()<<" deltaPhi "<<dPhi_.size() <<" maxZ "<< maxZ_.size();
45  }
46 
47 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
std::vector< edm::EDGetTokenT< reco::CandidateView > > tCandidateView
std::vector< edm::InputTag > inputs_
std::vector< double > dPhi_
std::vector< double > maxZ_
edm::EDGetTokenT< reco::BeamSpot > tBeamSpot
PixelUnpackingRegions::~PixelUnpackingRegions ( )
inline

Definition at line 55 of file PixelUnpackingRegions.h.

References MillePedeFileConverter_cfg::e, mayUnpackFED(), mayUnpackModule(), and run().

55 {}

Member Function Documentation

void PixelUnpackingRegions::addRegion ( Region r)
private

Definition at line 154 of file PixelUnpackingRegions.cc.

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

Referenced by run().

155 {
156  ++nreg_;
157 
158  float phi = r.v.phi();
159 
160  Module lo(phi - r.dPhi);
161  Module hi(phi + r.dPhi);
162 
163  addRegionLocal(r, phiBPIX_, lo, hi);
164  if (r.v.eta() > 1.)
165  {
166  addRegionLocal(r, phiFPIXp_, lo, hi);
167  }
168  if (r.v.eta() < -1.)
169  {
170  addRegionLocal(r, phiFPIXm_, lo, hi);
171  }
172 }
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 175 of file PixelUnpackingRegions.cc.

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

Referenced by addRegion().

176 {
177  Module lo = _lo;
178  Module hi = _hi;
179  Module pi_m(-M_PI);
180  Module pi_p( M_PI);
181 
182  std::vector<Module>::const_iterator a, b;
183 
184  if (lo.phi >= -M_PI && hi.phi <= M_PI) // interval doesn't cross the +-pi overlap
185  {
186  a = lower_bound(container.begin(), container.end(), lo);
187  b = upper_bound(container.begin(), container.end(), hi);
188  gatherFromRange(r, a, b);
189  }
190  else // interval is torn by the +-pi overlap
191  {
192  if (hi.phi > M_PI) hi.phi -= 2.*M_PI;
193  a = lower_bound(container.begin(), container.end(), pi_m);
194  b = upper_bound(container.begin(), container.end(), hi);
195  gatherFromRange(r, a, b);
196 
197  if (lo.phi < -M_PI) lo.phi += 2.*M_PI;
198  a = lower_bound(container.begin(), container.end(), lo);
199  b = upper_bound(container.begin(), container.end(), pi_p);
200  gatherFromRange(r, a, b);
201  }
202 }
void gatherFromRange(Region &r, std::vector< Module >::const_iterator, std::vector< Module >::const_iterator)
#define M_PI
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
void PixelUnpackingRegions::gatherFromRange ( Region r,
std::vector< Module >::const_iterator  a,
std::vector< Module >::const_iterator  b 
)
private

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

206 {
207  for(; a != b; ++a)
208  {
209  // projection in r's direction onto beam's z
210  float zmodule = a->z - ( (a->x - beamSpot_.x())*r.cosphi + (a->y - beamSpot_.y())*r.sinphi ) * r.atantheta;
211 
212  // do not include modules that project too far in z
213  if ( std::abs(zmodule) > r.maxZ ) continue;
214 
215  feds_.insert(a->fed);
216  modules_.insert(a->id);
217  }
218 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
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 82 of file PixelUnpackingRegions.cc.

References cabling_, SiPixelFedCablingMap::cablingTree(), edm::ESWatcher< T >::check(), TrackerGeometry::dets(), PixelUnpackingRegions::Module::fed, relativeConstraints::geom, edm::EventSetup::get(), PixelUnpackingRegions::Module::id, TrackerGeometry::isThere(), funct::m, FEDNumbering::MAXSiPixelFEDID, FEDNumbering::MAXSiPixeluTCAFEDID, FEDNumbering::MINSiPixelFEDID, FEDNumbering::MINSiPixeluTCAFEDID, GeomDetEnumerators::P1PXB, GeomDetEnumerators::P1PXEC, PixelUnpackingRegions::Module::phi, phiBPIX_, phiFPIXm_, phiFPIXp_, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, watcherSiPixelFedCablingMap_, PixelUnpackingRegions::Module::x, PixelUnpackingRegions::Module::y, and PixelUnpackingRegions::Module::z.

Referenced by run().

83 {
84  // initialize cabling map or update it if necessary
85  // and re-cache modules information
87  {
89  es.get<SiPixelFedCablingMapRcd>().get( cablingMap );
90  cabling_ = cablingMap->cablingTree();
91 
93  // get the TrackerGeom
94  es.get<TrackerDigiGeometryRecord>().get( geom );
95 
96  // switch on the phase1
97  unsigned int fedMin = FEDNumbering::MINSiPixelFEDID; // phase0
98  unsigned int fedMax = FEDNumbering::MAXSiPixelFEDID;
99  if( (geom->isThere(GeomDetEnumerators::P1PXB)) &&
101  fedMin = FEDNumbering::MINSiPixeluTCAFEDID; // phase1
103  }
104 
105 
106  phiBPIX_.clear();
107  phiFPIXp_.clear();
108  phiFPIXm_.clear();
109 
110  phiBPIX_.reserve(1024);
111  phiFPIXp_.reserve(512);
112  phiFPIXm_.reserve(512);
113 
114  auto it = geom->dets().begin();
115  for ( ; it != geom->dets().end(); ++it)
116  {
117  int subdet = (*it)->geographicalId().subdetId();
118  if (! (subdet == PixelSubdetector::PixelBarrel ||
119  subdet == PixelSubdetector::PixelEndcap) ) continue;
120 
121  Module m;
122 
123  m.x = (*it)->position().x();
124  m.y = (*it)->position().y();
125  m.z = (*it)->position().z();
126 
127  m.phi = (*it)->position().phi();
128 
129  m.id = (*it)->geographicalId().rawId();
130  const std::vector<sipixelobjects::CablingPathToDetUnit> path2det = cabling_->pathToDetUnit(m.id);
131 
132  m.fed = path2det[0].fed;
133  assert( (m.fed<=fedMax) && (m.fed>=fedMin) );
134 
135  if (subdet == PixelSubdetector::PixelBarrel)
136  {
137  phiBPIX_.push_back(m);
138  }
139  else if (subdet == PixelSubdetector::PixelEndcap)
140  {
141  if (m.z > 0.) phiFPIXp_.push_back(m);
142  else phiFPIXm_.push_back(m);
143  }
144  }
145 
146  // pre-sort by phi
147  std::sort(phiBPIX_.begin(), phiBPIX_.end());
148  std::sort(phiFPIXp_.begin(), phiFPIXp_.end());
149  std::sort(phiFPIXm_.begin(), phiFPIXm_.end());
150  }
151 }
std::vector< Module > phiFPIXm_
bool isThere(GeomDetEnumerators::SubDetector subdet) const
std::unique_ptr< SiPixelFedCablingTree > cabling_
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
edm::ESWatcher< SiPixelFedCablingMapRcd > watcherSiPixelFedCablingMap_
std::unique_ptr< SiPixelFedCablingTree > cablingTree() const
std::vector< Module > phiFPIXp_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
T get() const
Definition: EventSetup.h:71
std::vector< Module > phiBPIX_
bool PixelUnpackingRegions::mayUnpackFED ( unsigned int  fed_n) const

check whether a FED has to be unpacked

Definition at line 221 of file PixelUnpackingRegions.cc.

References feds_.

Referenced by SiPixelRawToDigi::produce(), and ~PixelUnpackingRegions().

222 {
223  if (feds_.count(fed_n)) return true;
224  return false;
225 }
std::set< unsigned int > feds_
bool PixelUnpackingRegions::mayUnpackModule ( unsigned int  id) const

check whether a module has to be unpacked

Definition at line 228 of file PixelUnpackingRegions.cc.

References modules_.

Referenced by ~PixelUnpackingRegions().

229 {
230  if (modules_.count(id)) return true;
231  return false;
232 }
std::set< unsigned int > modules_
const std::set<unsigned int>* PixelUnpackingRegions::modulesToUnpack ( ) const
inline

full set of module ids to unpack

Definition at line 67 of file PixelUnpackingRegions.h.

References modules_.

Referenced by SiPixelRawToDigi::produce().

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

Definition at line 234 of file PixelUnpackingRegions.cc.

References modules_.

Referenced by nModules(), and SiPixelRawToDigi::produce().

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

various informational accessors:

Definition at line 70 of file PixelUnpackingRegions.h.

References feds_.

Referenced by SiPixelRawToDigi::produce().

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

Definition at line 239 of file PixelUnpackingRegions.cc.

References modules_.

Referenced by nModules(), and SiPixelRawToDigi::produce().

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

Definition at line 71 of file PixelUnpackingRegions.h.

References modules_, nBarrelModules(), and nForwardModules().

Referenced by SiPixelRawToDigi::produce().

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

Definition at line 74 of file PixelUnpackingRegions.h.

References nreg_.

74 { return nreg_; }
void PixelUnpackingRegions::run ( const edm::Event e,
const edm::EventSetup es 
)

has to be run during each event

Definition at line 50 of file PixelUnpackingRegions.cc.

References addRegion(), ecalDrivenElectronSeedsParameters_cff::beamSpot, beamSpot_, EnergyCorrector::c, dPhi_, feds_, edm::Event::getByToken(), h, mps_fire::i, initialize(), input, inputs_, maxZ_, modules_, reco::Candidate::momentum(), gen::n, nreg_, reco::BeamSpot::position(), alignCSCRings::r, edm::View< T >::size(), tBeamSpot, and tCandidateView.

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

51 {
52  feds_.clear();
53  modules_.clear();
54  nreg_ = 0;
55 
56  initialize(es);
57 
59  e.getByToken(tBeamSpot, beamSpot);
60  beamSpot_ = beamSpot->position();
61  //beamSpot_ = math::XYZPoint(0.,0.,0.);
62 
63  size_t ninputs = inputs_.size();
64  for(size_t input = 0; input < ninputs; ++input)
65  {
68 
69  size_t n = h->size();
70  for(size_t i = 0; i < n; ++i )
71  {
72  const reco::Candidate & c = (*h)[i];
73 
74  // different input collections can have different dPhi and maxZ
76  addRegion(r);
77  }
78  }
79 }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< edm::EDGetTokenT< reco::CandidateView > > tCandidateView
size_type size() const
static std::string const input
Definition: EdmProvDump.cc:48
std::vector< edm::InputTag > inputs_
virtual Vector momentum() const =0
spatial momentum vector
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
const Point & position() const
position
Definition: BeamSpot.h:62
std::vector< double > maxZ_
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 127 of file PixelUnpackingRegions.h.

Referenced by gatherFromRange(), and run().

edm::InputTag PixelUnpackingRegions::beamSpotTag_
private

Definition at line 100 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions().

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

Definition at line 126 of file PixelUnpackingRegions.h.

Referenced by initialize().

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

Definition at line 98 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

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

Definition at line 105 of file PixelUnpackingRegions.h.

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

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

Definition at line 97 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

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

Definition at line 99 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

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

Definition at line 107 of file PixelUnpackingRegions.h.

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

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

Definition at line 122 of file PixelUnpackingRegions.h.

Referenced by addRegion(), and initialize().

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

Definition at line 124 of file PixelUnpackingRegions.h.

Referenced by addRegion(), and initialize().

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

Definition at line 123 of file PixelUnpackingRegions.h.

Referenced by addRegion(), and initialize().

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

Definition at line 102 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

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

Definition at line 103 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

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

Definition at line 129 of file PixelUnpackingRegions.h.

Referenced by initialize().