CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 nBarrelFEDs () const
 
unsigned int nBarrelModules () const
 
unsigned int nFEDs () const
 various informational accessors: More...
 
unsigned int nForwardFEDs () const
 
unsigned int nForwardModules () const
 
unsigned int nModules () const
 
unsigned int nRegions () const
 
 PixelUnpackingRegions (const edm::ParameterSet &)
 
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, Module lo, 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_
 
boost::scoped_ptr
< SiPixelFedCabling
cabling_
 
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::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 27 of file PixelUnpackingRegions.h.

Constructor & Destructor Documentation

PixelUnpackingRegions::PixelUnpackingRegions ( const edm::ParameterSet conf)

Definition at line 41 of file PixelUnpackingRegions.cc.

References beamSpotTag_, dPhi_, edm::ParameterSet::getParameter(), inputs_, and maxZ_.

42 {
43  edm::ParameterSet regPSet = conf.getParameter<edm::ParameterSet>("Regions");
44  beamSpotTag_ = regPSet.getParameter<edm::InputTag>("beamSpot");
45  inputs_ = regPSet.getParameter<std::vector<edm::InputTag> >("inputs");
46  dPhi_ = regPSet.getParameter<std::vector<double> >("deltaPhi");
47  maxZ_ = regPSet.getParameter<std::vector<double> >("maxZ");
48 
49  if (inputs_.size() != dPhi_.size() || dPhi_.size() != maxZ_.size() )
50  {
51  edm::LogError("PixelUnpackingRegions")<<"Not the same size of config parameters vectors!\n"
52  <<" inputs "<<inputs_.size()<<" deltaPhi "<<dPhi_.size() <<" maxZ "<< maxZ_.size();
53  }
54 }
T getParameter(std::string const &) const
std::vector< edm::InputTag > inputs_
std::vector< double > dPhi_
std::vector< double > maxZ_
PixelUnpackingRegions::~PixelUnpackingRegions ( )
inline

Definition at line 52 of file PixelUnpackingRegions.h.

52 {}

Member Function Documentation

void PixelUnpackingRegions::addRegion ( Region r)
private

Definition at line 151 of file PixelUnpackingRegions.cc.

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

Referenced by run().

152 {
153  ++nreg_;
154 
155  float phi = normalizedPhi(r.v.phi()); // ensure [-pi,+pi]
156 
157  Module lo(phi - r.dPhi);
158  Module hi(phi + r.dPhi);
159 
160  addRegionLocal(r, phiBPIX_, lo, hi);
161  if (r.v.eta() > 1.)
162  {
163  addRegionLocal(r, phiFPIXp_, lo, hi);
164  }
165  if (r.v.eta() < -1.)
166  {
167  addRegionLocal(r, phiFPIXm_, lo, hi);
168  }
169 }
#define Module(md)
Definition: vmac.h:202
std::vector< Module > phiFPIXm_
void addRegionLocal(Region &r, std::vector< Module > &container, Module lo, Module hi)
std::vector< Module > phiFPIXp_
std::vector< Module > phiBPIX_
double normalizedPhi(double phi)
Definition: normalizedPhi.cc:5
Definition: DDAxes.h:10
void PixelUnpackingRegions::addRegionLocal ( Region r,
std::vector< Module > &  container,
Module  lo,
Module  hi 
)
private

Definition at line 172 of file PixelUnpackingRegions.cc.

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

Referenced by addRegion().

173 {
174  Module pi_m(-M_PI);
175  Module pi_p( M_PI);
176 
177  std::vector<Module>::const_iterator a, b;
178 
179  if (lo.phi >= -M_PI && hi.phi <= M_PI) // interval doesn't cross the +-pi overlap
180  {
181  a = lower_bound(container.begin(), container.end(), lo);
182  b = upper_bound(container.begin(), container.end(), hi);
183  gatherFromRange(r, a, b);
184  }
185  else // interval is torn by the +-pi overlap
186  {
187  if (hi.phi > M_PI) hi.phi -= 2.*M_PI;
188  a = lower_bound(container.begin(), container.end(), pi_m);
189  b = upper_bound(container.begin(), container.end(), hi);
190  gatherFromRange(r, a, b);
191 
192  if (lo.phi < -M_PI) lo.phi += 2.*M_PI;
193  a = lower_bound(container.begin(), container.end(), lo);
194  b = upper_bound(container.begin(), container.end(), pi_p);
195  gatherFromRange(r, a, b);
196  }
197 }
void gatherFromRange(Region &r, std::vector< Module >::const_iterator, std::vector< Module >::const_iterator)
#define Module(md)
Definition: vmac.h:202
#define M_PI
Definition: BFit3D.cc:3
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 200 of file PixelUnpackingRegions.cc.

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

Referenced by addRegionLocal().

201 {
202  for(; a != b; ++a)
203  {
204  // projection in r's direction onto beam's z
205  float zmodule = a->z - ( (a->x - beamSpot_.x())*r.cosphi + (a->y - beamSpot_.y())*r.sinphi ) * r.atantheta;
206 
207  // do not include modules that project too far in z
208  if ( std::abs(zmodule) > r.maxZ ) continue;
209 
210  feds_.insert(a->fed);
211  modules_.insert(a->id);
212  }
213 }
#define abs(x)
Definition: mlp_lapack.h:159
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 89 of file PixelUnpackingRegions.cc.

References cabling_, edm::ESWatcher< T >::check(), PixelUnpackingRegions::Module::fed, relativeConstraints::geom, edm::EventSetup::get(), PixelUnpackingRegions::Module::id, m, normalizedPhi(), PixelUnpackingRegions::Module::phi, phiBPIX_, phiFPIXm_, phiFPIXp_, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, python.multivaluedict::sort(), watcherSiPixelFedCablingMap_, PixelUnpackingRegions::Module::x, PixelUnpackingRegions::Module::y, and PixelUnpackingRegions::Module::z.

Referenced by run().

90 {
91  // initialize cabling map or update it if necessary
92  // and re-cache modules information
94  {
96  es.get<SiPixelFedCablingMapRcd>().get( cablingMap );
97  cabling_.reset((SiPixelFedCabling*)cablingMap->cablingTree());
98 
100  // get the TrackerGeom
101  es.get<TrackerDigiGeometryRecord>().get( geom );
102 
103  phiBPIX_.clear();
104  phiFPIXp_.clear();
105  phiFPIXm_.clear();
106 
107  phiBPIX_.reserve(1024);
108  phiFPIXp_.reserve(512);
109  phiFPIXm_.reserve(512);
110 
111  std::vector<GeomDet*>::const_iterator it = geom->dets().begin();
112  for ( ; it != geom->dets().end(); ++it)
113  {
114  int subdet = (*it)->geographicalId().subdetId();
115  if (! (subdet == PixelSubdetector::PixelBarrel ||
116  subdet == PixelSubdetector::PixelEndcap) ) continue;
117 
118  Module m;
119 
120  m.x = (*it)->position().x();
121  m.y = (*it)->position().y();
122  m.z = (*it)->position().z();
123 
124  m.phi = normalizedPhi( (*it)->position().phi() ); // ensure [-pi,+pi]
125 
126  m.id = (*it)->geographicalId().rawId();
127  const std::vector<sipixelobjects::CablingPathToDetUnit> path2det = cabling_->pathToDetUnit(m.id);
128 
129  m.fed = path2det[0].fed;
130  assert(m.fed<40);
131 
132  if (subdet == PixelSubdetector::PixelBarrel)
133  {
134  phiBPIX_.push_back(m);
135  }
136  else if (subdet == PixelSubdetector::PixelEndcap)
137  {
138  if (m.z > 0.) phiFPIXp_.push_back(m);
139  else phiFPIXm_.push_back(m);
140  }
141  }
142 
143  // pre-sort by phi
144  std::sort(phiBPIX_.begin(), phiBPIX_.end());
145  std::sort(phiFPIXp_.begin(), phiFPIXp_.end());
146  std::sort(phiFPIXm_.begin(), phiFPIXm_.end());
147  }
148 }
#define Module(md)
Definition: vmac.h:202
boost::scoped_ptr< SiPixelFedCabling > cabling_
std::vector< Module > phiFPIXm_
edm::ESWatcher< SiPixelFedCablingMapRcd > watcherSiPixelFedCablingMap_
std::vector< Module > phiFPIXp_
const T & get() const
Definition: EventSetup.h:55
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:59
std::vector< Module > phiBPIX_
double normalizedPhi(double phi)
Definition: normalizedPhi.cc:5
bool PixelUnpackingRegions::mayUnpackFED ( unsigned int  fed_n) const

check whether a FED has to be unpacked

Definition at line 216 of file PixelUnpackingRegions.cc.

References feds_.

Referenced by SiPixelRawToDigi::produce().

217 {
218  if (feds_.count(fed_n)) return true;
219  return false;
220 }
std::set< unsigned int > feds_
bool PixelUnpackingRegions::mayUnpackModule ( unsigned int  id) const

check whether a module has to be unpacked

Definition at line 233 of file PixelUnpackingRegions.cc.

References modules_.

234 {
235  if (modules_.count(id)) return true;
236  return false;
237 }
std::set< unsigned int > modules_
const std::set<unsigned int>* PixelUnpackingRegions::modulesToUnpack ( ) const
inline

full set of module ids to unpack

Definition at line 64 of file PixelUnpackingRegions.h.

References modules_.

Referenced by SiPixelRawToDigi::produce().

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

Definition at line 222 of file PixelUnpackingRegions.cc.

References feds_.

Referenced by SiPixelRawToDigi::produce().

223 {
224  return std::count_if(feds_.begin(), feds_.end(), isBPIXFED );
225 }
std::set< unsigned int > feds_
unsigned int PixelUnpackingRegions::nBarrelModules ( ) const

Definition at line 239 of file PixelUnpackingRegions.cc.

References modules_.

Referenced by SiPixelRawToDigi::produce().

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

various informational accessors:

Definition at line 67 of file PixelUnpackingRegions.h.

References feds_.

Referenced by SiPixelRawToDigi::produce().

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

Definition at line 227 of file PixelUnpackingRegions.cc.

References feds_.

Referenced by SiPixelRawToDigi::produce().

228 {
229  return std::count_if(feds_.begin(), feds_.end(), isFPIXFED );
230 }
std::set< unsigned int > feds_
unsigned int PixelUnpackingRegions::nForwardModules ( ) const

Definition at line 244 of file PixelUnpackingRegions.cc.

References modules_.

Referenced by SiPixelRawToDigi::produce().

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

Definition at line 70 of file PixelUnpackingRegions.h.

References modules_.

Referenced by SiPixelRawToDigi::produce().

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

Definition at line 73 of file PixelUnpackingRegions.h.

References nreg_.

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

has to be run during each event

Definition at line 57 of file PixelUnpackingRegions.cc.

References addRegion(), SiPixelRawToDigiRegional_cfi::beamSpot, beamSpot_, beamSpotTag_, trackerHits::c, dPhi_, feds_, edm::Event::getByLabel(), h, i, initialize(), LaserDQM_cfg::input, inputs_, maxZ_, modules_, reco::Candidate::momentum(), n, nreg_, and alignCSCRings::r.

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

58 {
59  feds_.clear();
60  modules_.clear();
61  nreg_ = 0;
62 
63  initialize(es);
64 
66  e.getByLabel(beamSpotTag_, beamSpot);
67  beamSpot_ = beamSpot->position();
68  //beamSpot_ = math::XYZPoint(0.,0.,0.);
69 
70  size_t ninputs = inputs_.size();
71  for(size_t input = 0; input < ninputs; ++input)
72  {
74  e.getByLabel(inputs_[input], h);
75 
76  size_t n = h->size();
77  for(size_t i = 0; i < n; ++i )
78  {
79  const reco::Candidate & c = (*h)[i];
80 
81  // different input collections can have different dPhi and maxZ
83  addRegion(r);
84  }
85  }
86 }
int i
Definition: DBlmapReader.cc:9
virtual Vector momentum() const =0
spatial momentum vector
Region
Definition: Region.h:7
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::vector< edm::InputTag > inputs_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
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_
std::set< unsigned int > feds_
std::set< unsigned int > modules_

Member Data Documentation

math::XYZPoint PixelUnpackingRegions::beamSpot_
private

Definition at line 123 of file PixelUnpackingRegions.h.

Referenced by gatherFromRange(), and run().

edm::InputTag PixelUnpackingRegions::beamSpotTag_
private

Definition at line 99 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

boost::scoped_ptr<SiPixelFedCabling> PixelUnpackingRegions::cabling_
private

Definition at line 122 of file PixelUnpackingRegions.h.

Referenced by initialize().

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

Definition at line 97 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

std::set<unsigned int> PixelUnpackingRegions::feds_
private
std::vector<edm::InputTag> PixelUnpackingRegions::inputs_
private

Definition at line 96 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

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

Definition at line 98 of file PixelUnpackingRegions.h.

Referenced by PixelUnpackingRegions(), and run().

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

Definition at line 103 of file PixelUnpackingRegions.h.

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

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

Definition at line 118 of file PixelUnpackingRegions.h.

Referenced by addRegion(), and initialize().

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

Definition at line 120 of file PixelUnpackingRegions.h.

Referenced by addRegion(), and initialize().

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

Definition at line 119 of file PixelUnpackingRegions.h.

Referenced by addRegion(), and initialize().

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

Definition at line 125 of file PixelUnpackingRegions.h.

Referenced by initialize().