CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
DetIdAssociator Class Referenceabstract

#include <DetIdAssociator.h>

Inheritance diagram for DetIdAssociator:
CaloDetIdAssociator MuonDetIdAssociator EcalDetIdAssociator HcalDetIdAssociator HODetIdAssociator PreshowerDetIdAssociator

Classes

struct  MapRange
 

Public Types

typedef std::vector
< GlobalPoint >
::const_iterator 
const_iterator
 
enum  PropagationTarget { Barrel, ForwardEndcap, BackwardEndcap }
 

Public Member Functions

virtual void buildMap ()
 make the look-up map More...
 
 DetIdAssociator (const int nPhi, const int nEta, const double etaBinSize)
 
double etaBinSize () const
 look-up map bin size in eta dimension More...
 
virtual std::vector< DetIdgetCrossedDetIds (const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory) const
 
virtual std::vector< DetIdgetCrossedDetIds (const std::set< DetId > &, const std::vector< SteppingHelixStateInfo > &trajectory, const double toleranceInSigmas=-1) const
 
virtual std::set< DetIdgetDetIdsCloseToAPoint (const GlobalPoint &, const int iN=0) const
 
virtual std::set< DetIdgetDetIdsCloseToAPoint (const GlobalPoint &direction, const unsigned int iNEtaPlus, const unsigned int iNEtaMinus, const unsigned int iNPhiPlus, const unsigned int iNPhiMinus) const
 
virtual std::set< DetIdgetDetIdsCloseToAPoint (const GlobalPoint &direction, const MapRange &mapRange) const
 
virtual std::set< DetIdgetDetIdsCloseToAPoint (const GlobalPoint &point, const double d=0) const
 
virtual std::set< DetIdgetDetIdsCloseToAPoint (const GlobalPoint &point, const double dThetaPlus, const double dThetaMinus, const double dPhiPlus, const double dPhiMinus) const
 
virtual std::set< DetIdgetDetIdsInACone (const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory, const double dR) const
 
virtual const GeomDetgetGeomDet (const DetId &) const =0
 
virtual int iEta (const GlobalPoint &) const
 look-up map eta index More...
 
virtual int iPhi (const GlobalPoint &) const
 look-up map phi index More...
 
virtual const char * name () const =0
 
int nEtaBins () const
 number of bins of the look-up map in eta dimension More...
 
int nPhiBins () const
 number of bins of the look-up map in phi dimension More...
 
virtual void setConditions (const DetIdAssociatorRecord &)
 
virtual void setGeometry (const DetIdAssociatorRecord &)=0
 
const FiducialVolumevolume () const
 get active detector volume More...
 
virtual ~DetIdAssociator ()
 

Protected Member Functions

virtual void check_setup () const
 
virtual bool crossedElement (const GlobalPoint &, const GlobalPoint &, const DetId &, const double toleranceInSigmas=-1, const SteppingHelixStateInfo *=0) const
 
virtual void dumpMapContent (int, int) const
 
virtual void dumpMapContent (int, int, int, int) const
 
void fillSet (std::set< DetId > &set, unsigned int iEta, unsigned int iPhi) const
 
virtual std::pair
< const_iterator,
const_iterator
getDetIdPoints (const DetId &, std::vector< GlobalPoint > &) const =0
 
virtual const unsigned int getNumberOfSubdetectors () const
 
virtual GlobalPoint getPosition (const DetId &) const =0
 
virtual void getValidDetIds (unsigned int subDetectorIndex, std::vector< DetId > &) const =0
 
unsigned int index (unsigned int iEta, unsigned int iPhi) const
 
virtual bool insideElement (const GlobalPoint &, const DetId &) const =0
 
virtual bool nearElement (const GlobalPoint &point, const DetId &id, const double distance) const
 

Protected Attributes

std::vector< DetIdcontainer_
 
const double etaBinSize_
 
std::vector< std::pair
< unsigned int, unsigned int > > 
lookupMap_
 
double maxEta_
 
double minTheta_
 
const int nEta_
 
const int nPhi_
 
bool theMapIsValid_
 
FiducialVolume volume_
 

Detailed Description

\

Description: Abstract base class for 3D point -> std::set<DetId>

Implementation: A look up map of active detector elements in eta-phi space is built to speed up access to the detector element geometry as well as associated hits. The map is uniformly binned in eta and phi dimensions, which can be viewed as a histogram with every bin containing DetId of elements crossed in a given eta-phi window. It is very likely that a single DetId can be found in a few bins if it's geometrical size is bigger than eta-phi bin size.

The map is implemented as a double array. The first one has fixed size and points to the range of array elements in the second one.

Definition at line 46 of file DetIdAssociator.h.

Member Typedef Documentation

Definition at line 55 of file DetIdAssociator.h.

Member Enumeration Documentation

Enumerator
Barrel 
ForwardEndcap 
BackwardEndcap 

Definition at line 48 of file DetIdAssociator.h.

Constructor & Destructor Documentation

DetIdAssociator::DetIdAssociator ( const int  nPhi,
const int  nEta,
const double  etaBinSize 
)

Definition at line 25 of file DetIdAssociator.cc.

References etaBinSize_, edm::hlt::Exception, create_public_lumi_plots::exp, maxEta_, minTheta_, nEta_, and nPhi_.

26  :nPhi_(nPhi),nEta_(nEta),
27  lookupMap_(nPhi_*nEta_,std::pair<unsigned int, unsigned int>(0,0)),
29 {
30  if (nEta_ <= 0 || nPhi_ <= 0) throw cms::Exception("FatalError") << "incorrect look-up map size. Cannot initialize such a map.";
31  maxEta_ = etaBinSize_*nEta_/2;
32  minTheta_ = 2*atan(exp(-maxEta_));
33 }
std::vector< std::pair< unsigned int, unsigned int > > lookupMap_
double etaBinSize() const
look-up map bin size in eta dimension
const double etaBinSize_
virtual DetIdAssociator::~DetIdAssociator ( )
inlinevirtual

Definition at line 58 of file DetIdAssociator.h.

58 {}

Member Function Documentation

void DetIdAssociator::buildMap ( )
virtual

make the look-up map

Definition at line 142 of file DetIdAssociator.cc.

References funct::abs(), FiducialVolume::addActivePoint(), assert(), newFWLiteAna::bin, check_setup(), container_, FiducialVolume::determinInnerDimensions(), etaBinSize_, HLT_25ns14e33_v1_cff::etaMax, HLT_25ns14e33_v1_cff::etaMin, edm::hlt::Exception, getDetIdPoints(), getNumberOfSubdetectors(), getPosition(), getValidDetIds(), iEta(), index(), DetIdInfo::info(), iPhi(), edm::isNotFinite(), LogTrace, lookupMap_, FiducialVolume::maxR(), FiducialVolume::maxZ(), FiducialVolume::minR(), FiducialVolume::minZ(), name(), nEta_, nPhi_, relval_parameters_module::step, theMapIsValid_, and volume_.

143 {
144  // the map is built in two steps to create a clean memory footprint
145  // 0) determine how many elements each bin has
146  // 1) fill the container map
147  check_setup();
148  LogTrace("TrackAssociator")<<"building map for " << name() << "\n";
149  // clear the map
150  if (nEta_ <= 0 || nPhi_ <= 0) throw cms::Exception("FatalError") << "incorrect look-up map size. Cannot build such a map.";
151  std::vector<GlobalPoint> pointBuffer;
152  std::vector<DetId> detIdBuffer;
153  unsigned int numberOfSubDetectors = getNumberOfSubdetectors();
154  unsigned totalNumberOfElementsInTheContainer(0);
155  for ( unsigned int step = 0; step < 2; ++step){
156  unsigned int numberOfDetIdsOutsideEtaRange = 0;
157  unsigned int numberOfDetIdsActive = 0;
158  LogTrace("TrackAssociator")<< "Step: " << step;
159  for ( unsigned int subDetectorIndex = 0; subDetectorIndex < numberOfSubDetectors; ++subDetectorIndex ){
160  getValidDetIds(subDetectorIndex, detIdBuffer);
161  // This std::move prevents modification
162  std::vector<DetId> const& validIds = std::move(detIdBuffer);
163  LogTrace("TrackAssociator")<< "Number of valid DetIds for subdetector: " << subDetectorIndex << " is " << validIds.size();
164  for (std::vector<DetId>::const_iterator id_itr = validIds.begin(); id_itr!=validIds.end(); id_itr++) {
165  std::pair<const_iterator,const_iterator> points = getDetIdPoints(*id_itr, pointBuffer);
166  LogTrace("TrackAssociatorVerbose")<< "Found " << points.second-points.first << " global points to describe geometry of DetId: "
167  << id_itr->rawId();
168  int etaMax(-1);
169  int etaMin(-1);
170  int phiMax(-1);
171  int phiMin(-1);
172  // this is a bit overkill, but it should be 100% proof (when debugged :)
173  for(std::vector<GlobalPoint>::const_iterator iter = points.first; iter != points.second; iter++)
174  {
175  LogTrace("TrackAssociatorVerbose")<< "\tpoint (rho,phi,z): " << iter->perp() << ", " <<
176  iter->phi() << ", " << iter->z();
177  // FIX ME: this should be a fatal error
178  if(edm::isNotFinite(iter->mag())||iter->mag()>1e5) { //Detector parts cannot be 1 km away or be NaN
179  edm::LogWarning("TrackAssociator") << "Critical error! Bad detector unit geometry:\n\tDetId:"
180  << id_itr->rawId() << "\t mag(): " << iter->mag() << "\n" << DetIdInfo::info( *id_itr,0 )
181  << "\nSkipped the element";
182  continue;
183  }
184  volume_.addActivePoint(*iter);
185  int ieta = iEta(*iter);
186  int iphi = iPhi(*iter);
187  if (ieta<0 || ieta>=nEta_) {
188  LogTrace("TrackAssociator")<<"Out of range: DetId:" << id_itr->rawId() << "\t (ieta,iphi): "
189  << ieta << "," << iphi << "\n" << "Point: " << *iter << "\t(eta,phi): " << (*iter).eta()
190  << "," << (*iter).phi() << "\n center: " << getPosition(*id_itr);
191  continue;
192  }
193  if ( phiMin<0 ) {
194  // first element
195  etaMin = ieta;
196  etaMax = ieta;
197  phiMin = iphi;
198  phiMax = iphi;
199  }else{
200  // check for discontinuity in phi
201  int deltaMin = abs(phiMin -iphi);
202  int deltaMax = abs(phiMax -iphi);
203  // assume that no single detector element has more than 3.1416 coverage in phi
204  if ( deltaMin > nPhi_/2 && phiMin < nPhi_/2 ) phiMin+= nPhi_;
205  if ( deltaMax > nPhi_/2 ) {
206  if (phiMax < nPhi_/2 )
207  phiMax+= nPhi_;
208  else
209  iphi += nPhi_;
210  }
211  assert (iphi>=0);
212  if ( etaMin > ieta) etaMin = ieta;
213  if ( etaMax < ieta) etaMax = ieta;
214  if ( phiMin > iphi) phiMin = iphi;
215  if ( phiMax < iphi) phiMax = iphi;
216  }
217  }
218  if (etaMax<0||phiMax<0||etaMin>=nEta_||phiMin>=nPhi_) {
219  LogTrace("TrackAssociatorVerbose")<<"Out of range or no geometry: DetId:" << id_itr->rawId() <<
220  "\n\teta (min,max): " << etaMin << "," << etaMax <<
221  "\n\tphi (min,max): " << phiMin << "," << phiMax <<
222  "\nTower id: " << id_itr->rawId() << "\n";
223  numberOfDetIdsOutsideEtaRange++;
224  continue;
225  }
226  numberOfDetIdsActive++;
227 
228  LogTrace("TrackAssociatorVerbose") << "DetId (ieta_min,ieta_max,iphi_min,iphi_max): " << id_itr->rawId() <<
229  ", " << etaMin << ", " << etaMax << ", " << phiMin << ", " << phiMax;
230  for(int ieta = etaMin; ieta <= etaMax; ieta++)
231  for(int iphi = phiMin; iphi <= phiMax; iphi++)
232  if ( step == 0 ){
233  lookupMap_.at(index(ieta,iphi%nPhi_)).second++;
234  totalNumberOfElementsInTheContainer++;
235  } else {
236  container_.at(lookupMap_.at(index(ieta,iphi%nPhi_)).first) = *id_itr;
237  lookupMap_.at(index(ieta,iphi%nPhi_)).first--;
238  totalNumberOfElementsInTheContainer--;
239  }
240  }
241  }
242  LogTrace("TrackAssociator") << "Number of elements outside the allowed range ( |eta|>"<<
243  nEta_/2*etaBinSize_ << "): " << numberOfDetIdsOutsideEtaRange << "\n";
244  LogTrace("TrackAssociator") << "Number of active DetId's mapped: " <<
245  numberOfDetIdsActive << "\n";
246  if ( step == 0 ){
247  // allocate
248  container_.resize(totalNumberOfElementsInTheContainer);
249  // fill the range index in the lookup map to point to the last element in the range
250  unsigned int index(0);
251  for ( std::vector<std::pair<unsigned int,unsigned int> >::iterator bin = lookupMap_.begin();
252  bin != lookupMap_.end(); ++bin )
253  {
254  if (bin->second==0) continue;
255  index += bin->second;
256  bin->first = index-1;
257  }
258  }
259  }
260  if ( totalNumberOfElementsInTheContainer != 0 )
261  throw cms::Exception("FatalError") << "Look-up map filled incorrectly. Structural problem. Get in touch with the developer.";
263  edm::LogVerbatim("TrackAssociator") << "Fiducial volume for " << name() << " (minR, maxR, minZ, maxZ): " <<
264  volume_.minR() << ", " << volume_.maxR() << ", " << volume_.minZ() << ", " << volume_.maxZ();
265  theMapIsValid_ = true;
266 }
void determinInnerDimensions()
virtual void getValidDetIds(unsigned int subDetectorIndex, std::vector< DetId > &) const =0
double maxZ(bool withTolerance=true) const
FiducialVolume volume_
assert(m_qm.get())
unsigned int index(unsigned int iEta, unsigned int iPhi) const
virtual int iEta(const GlobalPoint &) const
look-up map eta index
std::vector< std::pair< unsigned int, unsigned int > > lookupMap_
double minZ(bool withTolerance=true) const
std::vector< DetId > container_
const double etaBinSize_
virtual int iPhi(const GlobalPoint &) const
look-up map phi index
void addActivePoint(const GlobalPoint &point)
add a point that belongs to the active volume
virtual const unsigned int getNumberOfSubdetectors() const
bool isNotFinite(T x)
Definition: isFinite.h:10
virtual const char * name() const =0
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual void check_setup() const
#define LogTrace(id)
double minR(bool withTolerance=true) const
static std::string info(const DetId &, const TrackerTopology *tTopo)
Definition: DetIdInfo.cc:29
virtual GlobalPoint getPosition(const DetId &) const =0
virtual std::pair< const_iterator, const_iterator > getDetIdPoints(const DetId &, std::vector< GlobalPoint > &) const =0
double maxR(bool withTolerance=true) const
void DetIdAssociator::check_setup ( ) const
protectedvirtual

Reimplemented in MuonDetIdAssociator, and CaloDetIdAssociator.

Definition at line 377 of file DetIdAssociator.cc.

References etaBinSize_, edm::hlt::Exception, nEta_, and nPhi_.

Referenced by buildMap(), CaloDetIdAssociator::check_setup(), MuonDetIdAssociator::check_setup(), getCrossedDetIds(), getDetIdsCloseToAPoint(), and getDetIdsInACone().

378 {
379  if (nEta_==0) throw cms::Exception("FatalError") << "Number of eta bins is not set.\n";
380  if (nPhi_==0) throw cms::Exception("FatalError") << "Number of phi bins is not set.\n";
381  // if (ivProp_==0) throw cms::Exception("FatalError") << "Track propagator is not defined\n";
382  if (etaBinSize_==0) throw cms::Exception("FatalError") << "Eta bin size is not set.\n";
383 }
const double etaBinSize_
virtual bool DetIdAssociator::crossedElement ( const GlobalPoint ,
const GlobalPoint ,
const DetId ,
const double  toleranceInSigmas = -1,
const SteppingHelixStateInfo = 0 
) const
inlineprotectedvirtual

Reimplemented in CaloDetIdAssociator.

Definition at line 134 of file DetIdAssociator.h.

Referenced by getCrossedDetIds().

138  { return false; }
void DetIdAssociator::dumpMapContent ( int  ieta,
int  iphi 
) const
protectedvirtual

Definition at line 324 of file DetIdAssociator.cc.

References fillSet(), getDetIdPoints(), LogTrace, nPhi_, and point.

Referenced by dumpMapContent().

325 {
326  if (! (ieta>=0 && ieta<nEta_ && iphi>=0) )
327  {
328  edm::LogWarning("TrackAssociator") << "ieta or iphi is out of range. Skipped.";
329  return;
330  }
331 
332  std::vector<GlobalPoint> pointBuffer;
333  std::set<DetId> set;
334  fillSet(set,ieta,iphi%nPhi_);
335  LogTrace("TrackAssociator") << "Map content for cell (ieta,iphi): " << ieta << ", " << iphi%nPhi_;
336  for(std::set<DetId>::const_iterator itr = set.begin(); itr!=set.end(); itr++)
337  {
338  LogTrace("TrackAssociator") << "\tDetId " << itr->rawId() << ", geometry (x,y,z,rho,eta,phi):";
339  std::pair<const_iterator,const_iterator> points = getDetIdPoints(*itr, pointBuffer);
340  for(std::vector<GlobalPoint>::const_iterator point = points.first; point != points.second; point++)
341  LogTrace("TrackAssociator") << "\t\t" << point->x() << ", " << point->y() << ", " << point->z() << ", "
342  << point->perp() << ", " << point->eta() << ", " << point->phi();
343  }
344 }
void fillSet(std::set< DetId > &set, unsigned int iEta, unsigned int iPhi) const
#define LogTrace(id)
virtual std::pair< const_iterator, const_iterator > getDetIdPoints(const DetId &, std::vector< GlobalPoint > &) const =0
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
void DetIdAssociator::dumpMapContent ( int  ieta_min,
int  ieta_max,
int  iphi_min,
int  iphi_max 
) const
protectedvirtual

Definition at line 346 of file DetIdAssociator.cc.

References dumpMapContent(), i, and j.

347 {
348  for(int i=ieta_min;i<=ieta_max;i++)
349  for(int j=iphi_min;j<=iphi_max;j++)
350  dumpMapContent(i,j);
351 }
int i
Definition: DBlmapReader.cc:9
virtual void dumpMapContent(int, int) const
int j
Definition: DBlmapReader.cc:9
double DetIdAssociator::etaBinSize ( ) const
inline

look-up map bin size in eta dimension

Definition at line 109 of file DetIdAssociator.h.

References etaBinSize_.

109 { return etaBinSize_;};
const double etaBinSize_
void DetIdAssociator::fillSet ( std::set< DetId > &  set,
unsigned int  iEta,
unsigned int  iPhi 
) const
protected

Definition at line 385 of file DetIdAssociator.cc.

References container_, i, index(), lookupMap_, and findQualityFiles::size.

Referenced by dumpMapContent(), and getDetIdsCloseToAPoint().

386 {
387  unsigned int i = index(iEta,iPhi);
388  unsigned int i0 = lookupMap_.at(i).first;
389  unsigned int size = lookupMap_.at(i).second;
390  for ( i = i0; i < i0+size; ++i )
391  set.insert(container_.at(i));
392 }
int i
Definition: DBlmapReader.cc:9
unsigned int index(unsigned int iEta, unsigned int iPhi) const
virtual int iEta(const GlobalPoint &) const
look-up map eta index
std::vector< std::pair< unsigned int, unsigned int > > lookupMap_
std::vector< DetId > container_
virtual int iPhi(const GlobalPoint &) const
look-up map phi index
tuple size
Write out results.
std::vector< DetId > DetIdAssociator::getCrossedDetIds ( const std::set< DetId > &  inset,
const std::vector< GlobalPoint > &  trajectory 
) const
virtual
  • DetIds crossed by the track tolerance is the radius of the trajectory used for matching -1 is default and represent the case with no uncertainty on the trajectory direction. It's the fastest option
  • DetIds crossed by the track, ordered according to the order that they were crossed by the track flying outside the detector

Definition at line 284 of file DetIdAssociator.cc.

References check_setup(), crossedElement(), i, and convertSQLitetoXML_cfg::output.

286 {
287  check_setup();
288  std::vector<DetId> output;
289  std::set<DetId> ids(inset);
290  for ( unsigned int i=0; i+1 < trajectory.size(); ++i ) {
291  std::set<DetId>::const_iterator id_iter = ids.begin();
292  while ( id_iter != ids.end() ) {
293  if ( crossedElement(trajectory[i],trajectory[i+1],*id_iter) ){
294  output.push_back(*id_iter);
295  ids.erase(id_iter++);
296  }else
297  id_iter++;
298  }
299  }
300  return output;
301 }
int i
Definition: DBlmapReader.cc:9
virtual bool crossedElement(const GlobalPoint &, const GlobalPoint &, const DetId &, const double toleranceInSigmas=-1, const SteppingHelixStateInfo *=0) const
virtual void check_setup() const
std::vector< DetId > DetIdAssociator::getCrossedDetIds ( const std::set< DetId > &  inset,
const std::vector< SteppingHelixStateInfo > &  trajectory,
const double  toleranceInSigmas = -1 
) const
virtual

Definition at line 303 of file DetIdAssociator.cc.

References check_setup(), crossedElement(), i, convertSQLitetoXML_cfg::output, and position.

306 {
307  check_setup();
308  std::vector<DetId> output;
309  std::set<DetId> ids(inset);
310  for ( unsigned int i=0; i+1 < trajectory.size(); ++i ) {
311  std::set<DetId>::const_iterator id_iter = ids.begin();
312  while ( id_iter != ids.end() ) {
313  if ( crossedElement(trajectory[i].position(),trajectory[i+1].position(),*id_iter,tolerance,&trajectory[i]) ){
314  output.push_back(*id_iter);
315  ids.erase(id_iter++);
316  }else
317  id_iter++;
318  }
319  }
320  return output;
321 }
int i
Definition: DBlmapReader.cc:9
virtual bool crossedElement(const GlobalPoint &, const GlobalPoint &, const DetId &, const double toleranceInSigmas=-1, const SteppingHelixStateInfo *=0) const
virtual void check_setup() const
static int position[264][3]
Definition: ReadPGInfo.cc:509
virtual std::pair<const_iterator, const_iterator> DetIdAssociator::getDetIdPoints ( const DetId ,
std::vector< GlobalPoint > &   
) const
protectedpure virtual

Implemented in MuonDetIdAssociator, and CaloDetIdAssociator.

Referenced by buildMap(), and dumpMapContent().

std::set< DetId > DetIdAssociator::getDetIdsCloseToAPoint ( const GlobalPoint direction,
const int  iN = 0 
) const
virtual

Preselect DetIds close to a point on the inner surface of the detector. "iN" is a number of the adjacent bins of the map to retrieve

Definition at line 35 of file DetIdAssociator.cc.

References gen::n.

Referenced by getDetIdsCloseToAPoint().

37 {
38  unsigned int n = 0;
39  if (iN>0) n = iN;
40  return getDetIdsCloseToAPoint(direction,n,n,n,n);
41 }
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
std::set< DetId > DetIdAssociator::getDetIdsCloseToAPoint ( const GlobalPoint direction,
const unsigned int  iNEtaPlus,
const unsigned int  iNEtaMinus,
const unsigned int  iNPhiPlus,
const unsigned int  iNPhiMinus 
) const
virtual

Definition at line 43 of file DetIdAssociator.cc.

References check_setup(), PV3DBase< T, PVType, FrameType >::eta(), edm::hlt::Exception, fillSet(), i, iEta(), iPhi(), j, LogTrace, nEta_, nPhi_, PV3DBase< T, PVType, FrameType >::phi(), and theMapIsValid_.

48 {
49  std::set<DetId> set;
50  check_setup();
51  if (! theMapIsValid_ ) throw cms::Exception("FatalError") << "map is not valid.";
52  LogTrace("TrackAssociator") << "(iNEtaPlus, iNEtaMinus, iNPhiPlus, iNPhiMinus): " <<
53  iNEtaPlus << ", " << iNEtaMinus << ", " << iNPhiPlus << ", " << iNPhiMinus;
54  LogTrace("TrackAssociator") << "point (eta,phi): " << direction.eta() << "," << direction.phi();
55  int ieta = iEta(direction);
56  int iphi = iPhi(direction);
57  LogTrace("TrackAssociator") << "(ieta,iphi): " << ieta << "," << iphi << "\n";
58  if (ieta>=0 && ieta<nEta_ && iphi>=0 && iphi<nPhi_){
59  fillSet(set,ieta,iphi);
60  // dumpMapContent(ieta,iphi);
61  // check if any neighbor bin is requested
62  if (iNEtaPlus + iNEtaMinus + iNPhiPlus + iNPhiMinus >0 ){
63  LogTrace("TrackAssociator") << "Add neighbors (ieta,iphi): " << ieta << "," << iphi;
64  // eta
65  int maxIEta = ieta+iNEtaPlus;
66  int minIEta = ieta-iNEtaMinus;
67  if (maxIEta>=nEta_) maxIEta = nEta_-1;
68  if (minIEta<0) minIEta = 0;
69  // phi
70  int maxIPhi = iphi+iNPhiPlus;
71  int minIPhi = iphi-iNPhiMinus;
72  if (maxIPhi-minIPhi>=nPhi_){ // all elements in phi
73  minIPhi = 0;
74  maxIPhi = nPhi_-1;
75  }
76  if(minIPhi<0) {
77  minIPhi+=nPhi_;
78  maxIPhi+=nPhi_;
79  }
80  LogTrace("TrackAssociator") << "\tieta (min,max): " << minIEta << "," << maxIEta;
81  LogTrace("TrackAssociator") << "\tiphi (min,max): " << minIPhi << "," << maxIPhi<< "\n";
82  // dumpMapContent(minIEta,maxIEta,minIPhi,maxIPhi);
83  for (int i=minIEta;i<=maxIEta;i++)
84  for (int j=minIPhi;j<=maxIPhi;j++) {
85  if( i==ieta && j==iphi) continue; // already in the set
86  fillSet(set,i,j%nPhi_);
87  }
88  }
89 
90  }
91  return set;
92 }
int i
Definition: DBlmapReader.cc:9
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
virtual int iEta(const GlobalPoint &) const
look-up map eta index
virtual int iPhi(const GlobalPoint &) const
look-up map phi index
void fillSet(std::set< DetId > &set, unsigned int iEta, unsigned int iPhi) const
int j
Definition: DBlmapReader.cc:9
virtual void check_setup() const
#define LogTrace(id)
T eta() const
Definition: PV3DBase.h:76
std::set< DetId > DetIdAssociator::getDetIdsCloseToAPoint ( const GlobalPoint direction,
const MapRange mapRange 
) const
virtual

Definition at line 359 of file DetIdAssociator.cc.

References DetIdAssociator::MapRange::dPhiMinus, DetIdAssociator::MapRange::dPhiPlus, DetIdAssociator::MapRange::dThetaMinus, DetIdAssociator::MapRange::dThetaPlus, and getDetIdsCloseToAPoint().

361 {
362  return getDetIdsCloseToAPoint(direction, mapRange.dThetaPlus, mapRange.dThetaMinus,
363  mapRange.dPhiPlus, mapRange.dPhiMinus);
364 
365 }
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
std::set< DetId > DetIdAssociator::getDetIdsCloseToAPoint ( const GlobalPoint point,
const double  d = 0 
) const
virtual

Preselect DetIds close to a point on the inner surface of the detector. "d" defines the allowed range in theta-phi space:

  • theta is in [point.theta()-d, point.theta()+d]
  • phi is in [point.phi()-d, point.phi()+d]

Definition at line 94 of file DetIdAssociator.cc.

References getDetIdsCloseToAPoint().

96 {
97  return getDetIdsCloseToAPoint(point,d,d,d,d);
98 }
tuple d
Definition: ztail.py:151
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
std::set< DetId > DetIdAssociator::getDetIdsCloseToAPoint ( const GlobalPoint point,
const double  dThetaPlus,
const double  dThetaMinus,
const double  dPhiPlus,
const double  dPhiMinus 
) const
virtual
  • theta is in [point.theta()-dThetaMinus, point.theta()+dThetaPlus]
  • phi is in [point.phi()-dPhiMinus, point.phi()+dPhiPlus]

Definition at line 100 of file DetIdAssociator.cc.

References funct::abs(), PV3DBase< T, PVType, FrameType >::eta(), etaBinSize_, getDetIdsCloseToAPoint(), create_public_lumi_plots::log, LogTrace, M_PI, maxEta, benchmark_cfg::minEta, minTheta_, gen::n, nPhi_, funct::tan(), and PV3DBase< T, PVType, FrameType >::theta().

105 {
106  LogTrace("TrackAssociator") << "(dThetaPlus,dThetaMinus,dPhiPlus,dPhiMinus): " <<
107  dThetaPlus << ", " << dThetaMinus << ", " << dPhiPlus << ", " << dPhiMinus;
108  unsigned int n = 0;
109  if ( dThetaPlus<0 || dThetaMinus<0 || dPhiPlus<0 || dPhiMinus<0)
110  return getDetIdsCloseToAPoint(point,n,n,n,n);
111  // check that region of interest overlaps with the look-up map
112  double maxTheta = point.theta()+dThetaPlus;
113  if (maxTheta > M_PI-minTheta_) maxTheta = M_PI-minTheta_;
114  double minTheta = point.theta()-dThetaMinus;
115  if (minTheta < minTheta_) minTheta = minTheta_;
116  if ( maxTheta < minTheta_ || minTheta > M_PI-minTheta_) return std::set<DetId>();
117 
118  // take into account non-linear dependence of eta from
119  // theta in regions with large |eta|
120  double minEta = -log(tan(maxTheta/2));
121  double maxEta = -log(tan(minTheta/2));
122  unsigned int iNEtaPlus = abs(int( ( maxEta-point.eta() )/etaBinSize_));
123  unsigned int iNEtaMinus = abs(int( ( point.eta() - minEta )/etaBinSize_));
124  unsigned int iNPhiPlus = abs(int( dPhiPlus/(2*M_PI)*nPhi_ ));
125  unsigned int iNPhiMinus = abs(int( dPhiMinus/(2*M_PI)*nPhi_ ));
126  // add one more bin in each direction to guaranty that we don't miss anything
127  return getDetIdsCloseToAPoint(point, iNEtaPlus+1, iNEtaMinus+1, iNPhiPlus+1, iNPhiMinus+1);
128 }
double maxEta
const double etaBinSize_
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define LogTrace(id)
#define M_PI
T eta() const
Definition: PV3DBase.h:76
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
std::set< DetId > DetIdAssociator::getDetIdsInACone ( const std::set< DetId > &  inset,
const std::vector< GlobalPoint > &  trajectory,
const double  dR 
) const
virtual

Find DetIds that satisfy given requirements

  • inside eta-phi cone of radius dR

Definition at line 268 of file DetIdAssociator.cc.

References check_setup(), M_PI, maxEta_, and nearElement().

271 {
272  if ( dR > 2*M_PI && dR > maxEta_ ) return inset;
273  check_setup();
274  std::set<DetId> outset;
275  for(std::set<DetId>::const_iterator id_iter = inset.begin(); id_iter != inset.end(); id_iter++)
276  for(std::vector<GlobalPoint>::const_iterator point_iter = trajectory.begin(); point_iter != trajectory.end(); point_iter++)
277  if (nearElement(*point_iter,*id_iter,dR)) {
278  outset.insert(*id_iter);
279  break;
280  }
281  return outset;
282 }
virtual bool nearElement(const GlobalPoint &point, const DetId &id, const double distance) const
virtual void check_setup() const
#define M_PI
virtual const GeomDet* DetIdAssociator::getGeomDet ( const DetId ) const
pure virtual
virtual const unsigned int DetIdAssociator::getNumberOfSubdetectors ( ) const
inlineprotectedvirtual

Reimplemented in EcalDetIdAssociator, and HcalDetIdAssociator.

Definition at line 129 of file DetIdAssociator.h.

Referenced by buildMap().

129 { return 1;}
virtual GlobalPoint DetIdAssociator::getPosition ( const DetId ) const
protectedpure virtual

Implemented in MuonDetIdAssociator, and CaloDetIdAssociator.

Referenced by buildMap(), and nearElement().

virtual void DetIdAssociator::getValidDetIds ( unsigned int  subDetectorIndex,
std::vector< DetId > &   
) const
protectedpure virtual
int DetIdAssociator::iEta ( const GlobalPoint point) const
virtual

look-up map eta index

Definition at line 131 of file DetIdAssociator.cc.

References PV3DBase< T, PVType, FrameType >::eta(), etaBinSize_, and nEta_.

Referenced by buildMap(), and getDetIdsCloseToAPoint().

132 {
133  return int(point.eta()/etaBinSize_ + nEta_/2);
134 }
const double etaBinSize_
T eta() const
Definition: PV3DBase.h:76
unsigned int DetIdAssociator::index ( unsigned int  iEta,
unsigned int  iPhi 
) const
inlineprotected

Definition at line 143 of file DetIdAssociator.h.

References iPhi(), and nPhi_.

Referenced by BeautifulSoup.PageElement::_invert(), buildMap(), and fillSet().

143  {
144  return iEta*nPhi_+iPhi;
145  }
virtual int iEta(const GlobalPoint &) const
look-up map eta index
virtual int iPhi(const GlobalPoint &) const
look-up map phi index
virtual bool DetIdAssociator::insideElement ( const GlobalPoint ,
const DetId  
) const
protectedpure virtual
int DetIdAssociator::iPhi ( const GlobalPoint point) const
virtual

look-up map phi index

Definition at line 136 of file DetIdAssociator.cc.

References M_PI, nPhi_, and PV3DBase< T, PVType, FrameType >::phi().

Referenced by buildMap(), getDetIdsCloseToAPoint(), and index().

137 {
138  return int((double(point.phi())+M_PI)/(2*M_PI)*nPhi_);
139 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
#define M_PI
virtual const char* DetIdAssociator::name ( ) const
pure virtual
bool DetIdAssociator::nearElement ( const GlobalPoint point,
const DetId id,
const double  distance 
) const
protectedvirtual

Definition at line 367 of file DetIdAssociator.cc.

References SiPixelRawToDigiRegional_cfi::deltaPhi, PV3DBase< T, PVType, FrameType >::eta(), getPosition(), M_PI, and PV3DBase< T, PVType, FrameType >::phi().

Referenced by getDetIdsInACone().

370 {
371  GlobalPoint center = getPosition(id);
372  double deltaPhi(fabs(point.phi()-center.phi()));
373  if(deltaPhi>M_PI) deltaPhi = fabs(deltaPhi-M_PI*2.);
374  return (point.eta()-center.eta())*(point.eta()-center.eta()) + deltaPhi*deltaPhi < distance*distance;
375 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
#define M_PI
T eta() const
Definition: PV3DBase.h:76
virtual GlobalPoint getPosition(const DetId &) const =0
int DetIdAssociator::nEtaBins ( ) const
inline

number of bins of the look-up map in eta dimension

Definition at line 107 of file DetIdAssociator.h.

References nEta_.

107 { return nEta_;}
int DetIdAssociator::nPhiBins ( ) const
inline

number of bins of the look-up map in phi dimension

Definition at line 105 of file DetIdAssociator.h.

References nPhi_.

105 { return nPhi_;}
virtual void DetIdAssociator::setConditions ( const DetIdAssociatorRecord )
inlinevirtual

Reimplemented in MuonDetIdAssociator.

Definition at line 118 of file DetIdAssociator.h.

118 {};
virtual void DetIdAssociator::setGeometry ( const DetIdAssociatorRecord )
pure virtual
const FiducialVolume & DetIdAssociator::volume ( void  ) const

get active detector volume

Definition at line 353 of file DetIdAssociator.cc.

References edm::hlt::Exception, theMapIsValid_, and volume_.

Referenced by BetaCalculatorECAL::calcEcalDeposit().

354 {
355  if (! theMapIsValid_ ) throw cms::Exception("FatalError") << "map is not valid.";
356  return volume_;
357 }
FiducialVolume volume_

Member Data Documentation

std::vector<DetId> DetIdAssociator::container_
protected

Definition at line 155 of file DetIdAssociator.h.

Referenced by buildMap(), and fillSet().

const double DetIdAssociator::etaBinSize_
protected
std::vector<std::pair<unsigned int,unsigned int> > DetIdAssociator::lookupMap_
protected

Definition at line 154 of file DetIdAssociator.h.

Referenced by buildMap(), and fillSet().

double DetIdAssociator::maxEta_
protected

Definition at line 158 of file DetIdAssociator.h.

Referenced by DetIdAssociator(), and getDetIdsInACone().

double DetIdAssociator::minTheta_
protected

Definition at line 159 of file DetIdAssociator.h.

Referenced by DetIdAssociator(), and getDetIdsCloseToAPoint().

const int DetIdAssociator::nEta_
protected
const int DetIdAssociator::nPhi_
protected
bool DetIdAssociator::theMapIsValid_
protected

Definition at line 156 of file DetIdAssociator.h.

Referenced by buildMap(), getDetIdsCloseToAPoint(), and volume().

FiducialVolume DetIdAssociator::volume_
protected

Definition at line 164 of file DetIdAssociator.h.

Referenced by buildMap(), and volume().