CMS 3D CMS Logo

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 MapRange &mapRange) 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 &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 bool selectAllInACone (const double dR) const
 helper to see if getDetIdsInACone is useful More...
 
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 *=nullptr) 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_iteratorgetDetIdPoints (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 45 of file DetIdAssociator.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 54 of file DetIdAssociator.h.

Member Enumeration Documentation

◆ PropagationTarget

Enumerator
Barrel 
ForwardEndcap 
BackwardEndcap 

Definition at line 47 of file DetIdAssociator.h.

Constructor & Destructor Documentation

◆ DetIdAssociator()

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

Definition at line 24 of file DetIdAssociator.cc.

25  : nPhi_(nPhi),
26  nEta_(nEta),
27  lookupMap_(nPhi_ * nEta_, std::pair<unsigned int, unsigned int>(0, 0)),
28  theMapIsValid_(false),
30  if (nEta_ <= 0 || nPhi_ <= 0)
31  throw cms::Exception("FatalError") << "incorrect look-up map size. Cannot initialize such a map.";
32  maxEta_ = etaBinSize_ * nEta_ / 2;
33  minTheta_ = 2 * atan(exp(-maxEta_));
34 }

References etaBinSize_, Exception, JetChargeProducer_cfi::exp, maxEta_, minTheta_, nEta_, and nPhi_.

◆ ~DetIdAssociator()

virtual DetIdAssociator::~DetIdAssociator ( )
inlinevirtual

Definition at line 57 of file DetIdAssociator.h.

57 {}

Member Function Documentation

◆ buildMap()

void DetIdAssociator::buildMap ( )
virtual

make the look-up map

Definition at line 138 of file DetIdAssociator.cc.

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

References funct::abs(), FiducialVolume::addActivePoint(), cms::cuda::assert(), newFWLiteAna::bin, check_setup(), container_, FiducialVolume::determinInnerDimensions(), etaBinSize_, ALCARECOTkAlBeamHalo_cff::etaMax, ALCARECOTkAlBeamHalo_cff::etaMin, Exception, getDetIdPoints(), getNumberOfSubdetectors(), getPosition(), getValidDetIds(), LEDCalibrationChannels::ieta, iEta(), index(), DetIdInfo::info(), LEDCalibrationChannels::iphi, iPhi(), edm::isNotFinite(), LogTrace, lookupMap_, FiducialVolume::maxR(), FiducialVolume::maxZ(), FiducialVolume::minR(), FiducialVolume::minZ(), eostools::move(), name(), nEta_, nPhi_, AlignmentTrackSelector_cfi::phiMax, AlignmentTrackSelector_cfi::phiMin, HLT_2018_cff::points, theMapIsValid_, and volume_.

◆ check_setup()

void DetIdAssociator::check_setup ( ) const
protectedvirtual

Reimplemented in MuonDetIdAssociator, and CaloDetIdAssociator.

Definition at line 371 of file DetIdAssociator.cc.

371  {
372  if (nEta_ == 0)
373  throw cms::Exception("FatalError") << "Number of eta bins is not set.\n";
374  if (nPhi_ == 0)
375  throw cms::Exception("FatalError") << "Number of phi bins is not set.\n";
376  // if (ivProp_==0) throw cms::Exception("FatalError") << "Track propagator is not defined\n";
377  if (etaBinSize_ == 0)
378  throw cms::Exception("FatalError") << "Eta bin size is not set.\n";
379 }

References etaBinSize_, Exception, nEta_, and nPhi_.

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

◆ crossedElement()

virtual bool DetIdAssociator::crossedElement ( const GlobalPoint ,
const GlobalPoint ,
const DetId ,
const double  toleranceInSigmas = -1,
const SteppingHelixStateInfo = nullptr 
) const
inlineprotectedvirtual

Reimplemented in CaloDetIdAssociator.

Definition at line 130 of file DetIdAssociator.h.

134  {
135  return false;
136  }

Referenced by getCrossedDetIds().

◆ dumpMapContent() [1/2]

void DetIdAssociator::dumpMapContent ( int  ieta,
int  iphi 
) const
protectedvirtual

Definition at line 327 of file DetIdAssociator.cc.

327  {
328  if (!(ieta >= 0 && ieta < nEta_ && iphi >= 0)) {
329  edm::LogWarning("TrackAssociator") << "ieta or iphi is out of range. Skipped.";
330  return;
331  }
332 
333  std::vector<GlobalPoint> pointBuffer;
334  std::set<DetId> set;
335  fillSet(set, ieta, iphi % nPhi_);
336  LogTrace("TrackAssociator") << "Map content for cell (ieta,iphi): " << ieta << ", " << iphi % nPhi_;
337  for (std::set<DetId>::const_iterator itr = set.begin(); itr != set.end(); itr++) {
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 }

References fillSet(), getDetIdPoints(), LEDCalibrationChannels::ieta, LEDCalibrationChannels::iphi, LogTrace, nPhi_, point, and HLT_2018_cff::points.

Referenced by dumpMapContent().

◆ dumpMapContent() [2/2]

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.

346  {
347  for (int i = ieta_min; i <= ieta_max; i++)
348  for (int j = iphi_min; j <= iphi_max; j++)
349  dumpMapContent(i, j);
350 }

References dumpMapContent(), mps_fire::i, and dqmiolumiharvest::j.

◆ etaBinSize()

double DetIdAssociator::etaBinSize ( ) const
inline

look-up map bin size in eta dimension

Definition at line 108 of file DetIdAssociator.h.

108 { return etaBinSize_; };

References etaBinSize_.

◆ fillSet()

void DetIdAssociator::fillSet ( std::set< DetId > &  set,
unsigned int  iEta,
unsigned int  iPhi 
) const
protected

Definition at line 381 of file DetIdAssociator.cc.

381  {
382  unsigned int i = index(iEta, iPhi);
383  unsigned int i0 = lookupMap_.at(i).first;
384  unsigned int size = lookupMap_.at(i).second;
385  for (i = i0; i < i0 + size; ++i)
386  set.insert(container_.at(i));
387 }

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

Referenced by dumpMapContent(), and getDetIdsCloseToAPoint().

◆ getCrossedDetIds() [1/2]

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 290 of file DetIdAssociator.cc.

291  {
292  check_setup();
293  std::vector<DetId> output;
294  std::set<DetId> ids(inset);
295  for (unsigned int i = 0; i + 1 < trajectory.size(); ++i) {
296  std::set<DetId>::const_iterator id_iter = ids.begin();
297  while (id_iter != ids.end()) {
298  if (crossedElement(trajectory[i], trajectory[i + 1], *id_iter)) {
299  output.push_back(*id_iter);
300  ids.erase(id_iter++);
301  } else
302  id_iter++;
303  }
304  }
305  return output;
306 }

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

◆ getCrossedDetIds() [2/2]

std::vector< DetId > DetIdAssociator::getCrossedDetIds ( const std::set< DetId > &  inset,
const std::vector< SteppingHelixStateInfo > &  trajectory,
const double  toleranceInSigmas = -1 
) const
virtual

Definition at line 308 of file DetIdAssociator.cc.

310  {
311  check_setup();
312  std::vector<DetId> output;
313  std::set<DetId> ids(inset);
314  for (unsigned int i = 0; i + 1 < trajectory.size(); ++i) {
315  std::set<DetId>::const_iterator id_iter = ids.begin();
316  while (id_iter != ids.end()) {
317  if (crossedElement(trajectory[i].position(), trajectory[i + 1].position(), *id_iter, tolerance, &trajectory[i])) {
318  output.push_back(*id_iter);
319  ids.erase(id_iter++);
320  } else
321  id_iter++;
322  }
323  }
324  return output;
325 }

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

◆ getDetIdPoints()

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().

◆ getDetIdsCloseToAPoint() [1/5]

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 36 of file DetIdAssociator.cc.

36  {
37  unsigned int n = 0;
38  if (iN > 0)
39  n = iN;
40  return getDetIdsCloseToAPoint(direction, n, n, n, n);
41 }

References dqmiodumpmetadata::n.

Referenced by getDetIdsCloseToAPoint().

◆ getDetIdsCloseToAPoint() [2/5]

std::set< DetId > DetIdAssociator::getDetIdsCloseToAPoint ( const GlobalPoint direction,
const MapRange mapRange 
) const
virtual

Definition at line 358 of file DetIdAssociator.cc.

358  {
359  return getDetIdsCloseToAPoint(
360  direction, mapRange.dThetaPlus, mapRange.dThetaMinus, mapRange.dPhiPlus, mapRange.dPhiMinus);
361 }

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

◆ getDetIdsCloseToAPoint() [3/5]

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.

47  {
48  std::set<DetId> set;
49  check_setup();
50  if (!theMapIsValid_)
51  throw cms::Exception("FatalError") << "map is not valid.";
52  LogTrace("TrackAssociator") << "(iNEtaPlus, iNEtaMinus, iNPhiPlus, iNPhiMinus): " << iNEtaPlus << ", " << iNEtaMinus
53  << ", " << 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_)
68  maxIEta = nEta_ - 1;
69  if (minIEta < 0)
70  minIEta = 0;
71  // phi
72  int maxIPhi = iphi + iNPhiPlus;
73  int minIPhi = iphi - iNPhiMinus;
74  if (maxIPhi - minIPhi >= nPhi_) { // all elements in phi
75  minIPhi = 0;
76  maxIPhi = nPhi_ - 1;
77  }
78  if (minIPhi < 0) {
79  minIPhi += nPhi_;
80  maxIPhi += nPhi_;
81  }
82  LogTrace("TrackAssociator") << "\tieta (min,max): " << minIEta << "," << maxIEta;
83  LogTrace("TrackAssociator") << "\tiphi (min,max): " << minIPhi << "," << maxIPhi << "\n";
84  // dumpMapContent(minIEta,maxIEta,minIPhi,maxIPhi);
85  for (int i = minIEta; i <= maxIEta; i++)
86  for (int j = minIPhi; j <= maxIPhi; j++) {
87  if (i == ieta && j == iphi)
88  continue; // already in the set
89  fillSet(set, i, j % nPhi_);
90  }
91  }
92  }
93  return set;
94 }

References check_setup(), PV3DBase< T, PVType, FrameType >::eta(), Exception, fillSet(), mps_fire::i, LEDCalibrationChannels::ieta, iEta(), LEDCalibrationChannels::iphi, iPhi(), dqmiolumiharvest::j, LogTrace, nEta_, nPhi_, PV3DBase< T, PVType, FrameType >::phi(), and theMapIsValid_.

◆ getDetIdsCloseToAPoint() [4/5]

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:

Definition at line 96 of file DetIdAssociator.cc.

96  {
97  return getDetIdsCloseToAPoint(point, d, d, d, d);
98 }

References ztail::d, getDetIdsCloseToAPoint(), and point.

◆ getDetIdsCloseToAPoint() [5/5]

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.

104  {
105  LogTrace("TrackAssociator") << "(dThetaPlus,dThetaMinus,dPhiPlus,dPhiMinus): " << dThetaPlus << ", " << dThetaMinus
106  << ", " << dPhiPlus << ", " << dPhiMinus;
107  unsigned int n = 0;
108  if (dThetaPlus < 0 || dThetaMinus < 0 || dPhiPlus < 0 || dPhiMinus < 0)
109  return getDetIdsCloseToAPoint(point, n, n, n, n);
110  // check that region of interest overlaps with the look-up map
111  double maxTheta = point.theta() + dThetaPlus;
112  if (maxTheta > M_PI - minTheta_)
113  maxTheta = M_PI - minTheta_;
114  double minTheta = point.theta() - dThetaMinus;
115  if (minTheta < minTheta_)
116  minTheta = minTheta_;
117  if (maxTheta < minTheta_ || minTheta > M_PI - minTheta_)
118  return std::set<DetId>();
119 
120  // take into account non-linear dependence of eta from
121  // theta in regions with large |eta|
122  double minEta = -log(tan(maxTheta / 2));
123  double maxEta = -log(tan(minTheta / 2));
124  unsigned int iNEtaPlus = abs(int((maxEta - point.eta()) / etaBinSize_));
125  unsigned int iNEtaMinus = abs(int((point.eta() - minEta) / etaBinSize_));
126  unsigned int iNPhiPlus = abs(int(dPhiPlus / (2 * M_PI) * nPhi_));
127  unsigned int iNPhiMinus = abs(int(dPhiMinus / (2 * M_PI) * nPhi_));
128  // add one more bin in each direction to guaranty that we don't miss anything
129  return getDetIdsCloseToAPoint(point, iNEtaPlus + 1, iNEtaMinus + 1, iNPhiPlus + 1, iNPhiMinus + 1);
130 }

References funct::abs(), etaBinSize_, getDetIdsCloseToAPoint(), dqm-mbProfile::log, LogTrace, M_PI, maxEta, CombinatorialSeedGeneratorForBeamHalo_cfi::maxTheta, EgHLTOffEleSelection_cfi::minEta, minTheta_, dqmiodumpmetadata::n, nPhi_, point, and funct::tan().

◆ getDetIdsInACone()

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 273 of file DetIdAssociator.cc.

275  {
276  if (selectAllInACone(dR))
277  return inset;
278  check_setup();
279  std::set<DetId> outset;
280  for (std::set<DetId>::const_iterator id_iter = inset.begin(); id_iter != inset.end(); id_iter++)
281  for (std::vector<GlobalPoint>::const_iterator point_iter = trajectory.begin(); point_iter != trajectory.end();
282  point_iter++)
283  if (nearElement(*point_iter, *id_iter, dR)) {
284  outset.insert(*id_iter);
285  break;
286  }
287  return outset;
288 }

References check_setup(), HGC3DClusterGenMatchSelector_cfi::dR, nearElement(), and selectAllInACone().

◆ getGeomDet()

virtual const GeomDet* DetIdAssociator::getGeomDet ( const DetId ) const
pure virtual

◆ getNumberOfSubdetectors()

virtual const unsigned int DetIdAssociator::getNumberOfSubdetectors ( ) const
inlineprotectedvirtual

Reimplemented in HcalDetIdAssociator, and EcalDetIdAssociator.

Definition at line 125 of file DetIdAssociator.h.

125 { return 1; }

Referenced by buildMap().

◆ getPosition()

virtual GlobalPoint DetIdAssociator::getPosition ( const DetId ) const
protectedpure virtual

Implemented in MuonDetIdAssociator, and CaloDetIdAssociator.

Referenced by buildMap(), and nearElement().

◆ getValidDetIds()

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

◆ iEta()

int DetIdAssociator::iEta ( const GlobalPoint point) const
virtual

look-up map eta index

Definition at line 132 of file DetIdAssociator.cc.

132 { return int(point.eta() / etaBinSize_ + nEta_ / 2); }

References etaBinSize_, createfilelist::int, nEta_, and point.

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

◆ index()

unsigned int DetIdAssociator::index ( unsigned int  iEta,
unsigned int  iPhi 
) const
inlineprotected

Definition at line 139 of file DetIdAssociator.h.

139 { return iEta * nPhi_ + iPhi; }

References iEta(), iPhi(), and nPhi_.

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

◆ insideElement()

virtual bool DetIdAssociator::insideElement ( const GlobalPoint ,
const DetId  
) const
protectedpure virtual

◆ iPhi()

int DetIdAssociator::iPhi ( const GlobalPoint point) const
virtual

look-up map phi index

Definition at line 134 of file DetIdAssociator.cc.

134  {
135  return int((double(point.phi()) + M_PI) / (2 * M_PI) * nPhi_);
136 }

References createfilelist::int, M_PI, nPhi_, and point.

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

◆ name()

virtual const char* DetIdAssociator::name ( ) const
pure virtual

◆ nearElement()

bool DetIdAssociator::nearElement ( const GlobalPoint point,
const DetId id,
const double  distance 
) const
protectedvirtual

Definition at line 363 of file DetIdAssociator.cc.

363  {
364  GlobalPoint center = getPosition(id);
365  double deltaPhi(fabs(point.phi() - center.phi()));
366  if (deltaPhi > M_PI)
367  deltaPhi = fabs(deltaPhi - M_PI * 2.);
368  return (point.eta() - center.eta()) * (point.eta() - center.eta()) + deltaPhi * deltaPhi < distance * distance;
369 }

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

Referenced by getDetIdsInACone().

◆ nEtaBins()

int DetIdAssociator::nEtaBins ( ) const
inline

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

Definition at line 106 of file DetIdAssociator.h.

106 { return nEta_; }

References nEta_.

◆ nPhiBins()

int DetIdAssociator::nPhiBins ( ) const
inline

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

Definition at line 104 of file DetIdAssociator.h.

104 { return nPhi_; }

References nPhi_.

◆ selectAllInACone()

virtual bool DetIdAssociator::selectAllInACone ( const double  dR) const
inlinevirtual

helper to see if getDetIdsInACone is useful

Definition at line 82 of file DetIdAssociator.h.

82 { return dR > 2 * M_PI && dR > maxEta_; }

References HGC3DClusterGenMatchSelector_cfi::dR, M_PI, and maxEta_.

Referenced by getDetIdsInACone().

◆ volume()

const FiducialVolume & DetIdAssociator::volume ( void  ) const

get active detector volume

Definition at line 352 of file DetIdAssociator.cc.

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

References Exception, theMapIsValid_, and volume_.

Referenced by TrackExtrapolator::produce().

Member Data Documentation

◆ container_

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

Definition at line 149 of file DetIdAssociator.h.

Referenced by buildMap(), and fillSet().

◆ etaBinSize_

const double DetIdAssociator::etaBinSize_
protected

◆ lookupMap_

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

Definition at line 148 of file DetIdAssociator.h.

Referenced by buildMap(), and fillSet().

◆ maxEta_

double DetIdAssociator::maxEta_
protected

Definition at line 152 of file DetIdAssociator.h.

Referenced by DetIdAssociator(), and selectAllInACone().

◆ minTheta_

double DetIdAssociator::minTheta_
protected

Definition at line 153 of file DetIdAssociator.h.

Referenced by DetIdAssociator(), and getDetIdsCloseToAPoint().

◆ nEta_

const int DetIdAssociator::nEta_
protected

◆ nPhi_

const int DetIdAssociator::nPhi_
protected

◆ theMapIsValid_

bool DetIdAssociator::theMapIsValid_
protected

Definition at line 150 of file DetIdAssociator.h.

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

◆ volume_

FiducialVolume DetIdAssociator::volume_
protected

Definition at line 158 of file DetIdAssociator.h.

Referenced by buildMap(), and volume().

HLT_2018_cff.points
points
Definition: HLT_2018_cff.py:20125
FiducialVolume::addActivePoint
void addActivePoint(const GlobalPoint &point)
add a point that belongs to the active volume
Definition: FiducialVolume.cc:21
ALCARECOTkAlBeamHalo_cff.etaMin
etaMin
GeV.
Definition: ALCARECOTkAlBeamHalo_cff.py:32
mps_fire.i
i
Definition: mps_fire.py:355
CombinatorialSeedGeneratorForBeamHalo_cfi.maxTheta
maxTheta
Definition: CombinatorialSeedGeneratorForBeamHalo_cfi.py:77
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
DetIdAssociator::getNumberOfSubdetectors
virtual const unsigned int getNumberOfSubdetectors() const
Definition: DetIdAssociator.h:125
step
step
Definition: StallMonitor.cc:94
DetIdAssociator::iPhi
virtual int iPhi(const GlobalPoint &) const
look-up map phi index
Definition: DetIdAssociator.cc:134
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
DetIdAssociator::Barrel
Definition: DetIdAssociator.h:47
FiducialVolume::minR
double minR(bool withTolerance=true) const
Definition: FiducialVolume.h:37
DetIdAssociator::selectAllInACone
virtual bool selectAllInACone(const double dR) const
helper to see if getDetIdsInACone is useful
Definition: DetIdAssociator.h:82
cms::cuda::assert
assert(be >=bs)
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
DetIdAssociator::lookupMap_
std::vector< std::pair< unsigned int, unsigned int > > lookupMap_
Definition: DetIdAssociator.h:148
DetIdAssociator::getPosition
virtual GlobalPoint getPosition(const DetId &) const =0
DetIdAssociator::dumpMapContent
virtual void dumpMapContent(int, int) const
Definition: DetIdAssociator.cc:327
DetIdAssociator::maxEta_
double maxEta_
Definition: DetIdAssociator.h:152
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
DetIdAssociator::etaBinSize_
const double etaBinSize_
Definition: DetIdAssociator.h:151
DetIdAssociator::index
unsigned int index(unsigned int iEta, unsigned int iPhi) const
Definition: DetIdAssociator.h:139
DetIdAssociator::getDetIdPoints
virtual std::pair< const_iterator, const_iterator > getDetIdPoints(const DetId &, std::vector< GlobalPoint > &) const =0
DetIdInfo::info
static std::string info(const DetId &, const TrackerTopology *tTopo)
Definition: DetIdInfo.cc:25
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
DetIdAssociator::etaBinSize
double etaBinSize() const
look-up map bin size in eta dimension
Definition: DetIdAssociator.h:108
DetIdAssociator::getValidDetIds
virtual void getValidDetIds(unsigned int subDetectorIndex, std::vector< DetId > &) const =0
FiducialVolume::maxR
double maxR(bool withTolerance=true) const
Definition: FiducialVolume.h:43
AlignmentTrackSelector_cfi.phiMin
phiMin
Definition: AlignmentTrackSelector_cfi.py:18
maxEta
double maxEta
Definition: PFJetBenchmarkAnalyzer.cc:76
AlignmentTrackSelector_cfi.phiMax
phiMax
Definition: AlignmentTrackSelector_cfi.py:17
DetIdAssociator::nPhi_
const int nPhi_
Definition: DetIdAssociator.h:143
Point3DBase< float, GlobalTag >
DetIdAssociator::minTheta_
double minTheta_
Definition: DetIdAssociator.h:153
DetIdAssociator::container_
std::vector< DetId > container_
Definition: DetIdAssociator.h:149
edm::LogWarning
Definition: MessageLogger.h:141
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
FiducialVolume::minZ
double minZ(bool withTolerance=true) const
Definition: FiducialVolume.h:49
DetIdAssociator::crossedElement
virtual bool crossedElement(const GlobalPoint &, const GlobalPoint &, const DetId &, const double toleranceInSigmas=-1, const SteppingHelixStateInfo *=nullptr) const
Definition: DetIdAssociator.h:130
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
createfilelist.int
int
Definition: createfilelist.py:10
DetIdAssociator::nEta_
const int nEta_
Definition: DetIdAssociator.h:144
tolerance
const double tolerance
Definition: HGCalGeomParameters.cc:27
DetIdAssociator::getDetIdsCloseToAPoint
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
Definition: DetIdAssociator.cc:36
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
edm::LogVerbatim
Definition: MessageLogger.h:297
FiducialVolume::determinInnerDimensions
void determinInnerDimensions()
Definition: FiducialVolume.cc:39
HLT_2018_cff.nEta
nEta
Definition: HLT_2018_cff.py:5271
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:28
DetIdAssociator::ForwardEndcap
Definition: DetIdAssociator.h:47
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
FiducialVolume::maxZ
double maxZ(bool withTolerance=true) const
Definition: FiducialVolume.h:55
DetIdAssociator::volume_
FiducialVolume volume_
Definition: DetIdAssociator.h:158
DetIdAssociator::fillSet
void fillSet(std::set< DetId > &set, unsigned int iEta, unsigned int iPhi) const
Definition: DetIdAssociator.cc:381
eostools.move
def move(src, dest)
Definition: eostools.py:511
DetIdAssociator::theMapIsValid_
bool theMapIsValid_
Definition: DetIdAssociator.h:150
Exception
Definition: hltDiff.cc:246
ALCARECOTkAlBeamHalo_cff.etaMax
etaMax
Definition: ALCARECOTkAlBeamHalo_cff.py:33
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
DetIdAssociator::BackwardEndcap
Definition: DetIdAssociator.h:47
ztail.d
d
Definition: ztail.py:151
HLT_2018_cff.nPhi
nPhi
Definition: HLT_2018_cff.py:5272
DetIdAssociator::check_setup
virtual void check_setup() const
Definition: DetIdAssociator.cc:371
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
DetIdAssociator::iEta
virtual int iEta(const GlobalPoint &) const
look-up map eta index
Definition: DetIdAssociator.cc:132
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
point
*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
DetIdAssociator::name
virtual const char * name() const =0
EgHLTOffEleSelection_cfi.minEta
minEta
Definition: EgHLTOffEleSelection_cfi.py:11
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
DetIdAssociator::nearElement
virtual bool nearElement(const GlobalPoint &point, const DetId &id, const double distance) const
Definition: DetIdAssociator.cc:363
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443