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

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

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 }
const double etaBinSize_
std::vector< std::pair< unsigned int, unsigned int > > lookupMap_
double etaBinSize() const
look-up map bin size in eta dimension

◆ ~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.

References funct::abs(), FiducialVolume::addActivePoint(), cms::cuda::assert(), newFWLiteAna::bin, check_setup(), container_, FiducialVolume::determinInnerDimensions(), TrackValidation_cff::e5, etaBinSize_, ALCARECOTkAlBeamHalo_cff::etaMax, ALCARECOTkAlBeamHalo_cff::etaMin, Exception, getDetIdPoints(), getNumberOfSubdetectors(), getPosition(), getValidDetIds(), hcalRecHitTable_cff::ieta, iEta(), index(), DetIdInfo::info(), hcalRecHitTable_cff::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, hiPixelPairStep_cff::points, theMapIsValid_, trackerHitRTTI::vector, and volume_.

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 }
Log< level::Info, true > LogVerbatim
void determinInnerDimensions()
unsigned int index(unsigned int iEta, unsigned int iPhi) const
virtual void getValidDetIds(unsigned int subDetectorIndex, std::vector< DetId > &) const =0
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
FiducialVolume volume_
double maxZ(bool withTolerance=true) const
assert(be >=bs)
std::vector< DetId > container_
#define LogTrace(id)
const double etaBinSize_
void addActivePoint(const GlobalPoint &point)
add a point that belongs to the active volume
virtual const char * name() const =0
virtual int iEta(const GlobalPoint &) const
look-up map eta index
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< std::pair< unsigned int, unsigned int > > lookupMap_
virtual int iPhi(const GlobalPoint &) const
look-up map phi index
static std::string info(const DetId &, const TrackerTopology *tTopo)
Definition: DetIdInfo.cc:25
virtual GlobalPoint getPosition(const DetId &) const =0
double minR(bool withTolerance=true) const
step
Definition: StallMonitor.cc:83
Log< level::Warning, false > LogWarning
virtual std::pair< const_iterator, const_iterator > getDetIdPoints(const DetId &, std::vector< GlobalPoint > &) const =0
double maxR(bool withTolerance=true) const
virtual const unsigned int getNumberOfSubdetectors() const
def move(src, dest)
Definition: eostools.py:511
double minZ(bool withTolerance=true) const
virtual void check_setup() const

◆ check_setup()

void DetIdAssociator::check_setup ( ) const
protectedvirtual

Reimplemented in MuonDetIdAssociator, and CaloDetIdAssociator.

Definition at line 371 of file DetIdAssociator.cc.

References etaBinSize_, Exception, nEta_, and nPhi_.

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

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 }
const double etaBinSize_

◆ 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.

Referenced by getCrossedDetIds().

134  {
135  return false;
136  }

◆ dumpMapContent() [1/2]

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

Definition at line 327 of file DetIdAssociator.cc.

References fillSet(), getDetIdPoints(), hcalRecHitTable_cff::ieta, hcalRecHitTable_cff::iphi, LogTrace, nPhi_, point, and hiPixelPairStep_cff::points.

Referenced by dumpMapContent().

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 }
#define LogTrace(id)
void fillSet(std::set< DetId > &set, unsigned int iEta, unsigned int iPhi) const
Log< level::Warning, false > LogWarning
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

◆ 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.

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

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 }
virtual void dumpMapContent(int, int) const

◆ etaBinSize()

double DetIdAssociator::etaBinSize ( ) const
inline

look-up map bin size in eta dimension

Definition at line 108 of file DetIdAssociator.h.

References etaBinSize_.

108 { return etaBinSize_; };
const double 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.

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

Referenced by dumpMapContent(), and getDetIdsCloseToAPoint().

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 }
size
Write out results.
unsigned int index(unsigned int iEta, unsigned int iPhi) const
std::vector< DetId > container_
virtual int iEta(const GlobalPoint &) const
look-up map eta index
std::vector< std::pair< unsigned int, unsigned int > > lookupMap_
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:50
virtual int iPhi(const GlobalPoint &) const
look-up map phi index

◆ 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.

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

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 }
virtual bool crossedElement(const GlobalPoint &, const GlobalPoint &, const DetId &, const double toleranceInSigmas=-1, const SteppingHelixStateInfo *=nullptr) const
Definition: output.py:1
virtual void check_setup() const

◆ 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.

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

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 }
virtual bool crossedElement(const GlobalPoint &, const GlobalPoint &, const DetId &, const double toleranceInSigmas=-1, const SteppingHelixStateInfo *=nullptr) const
const double tolerance
static int position[264][3]
Definition: ReadPGInfo.cc:289
Definition: output.py:1
virtual void check_setup() const

◆ 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.

References dqmiodumpmetadata::n.

Referenced by getDetIdsCloseToAPoint().

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

◆ getDetIdsCloseToAPoint() [2/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.

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

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 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T eta() const
Definition: PV3DBase.h:73
#define LogTrace(id)
void fillSet(std::set< DetId > &set, unsigned int iEta, unsigned int iPhi) const
virtual int iEta(const GlobalPoint &) const
look-up map eta index
virtual int iPhi(const GlobalPoint &) const
look-up map phi index
virtual void check_setup() const

◆ getDetIdsCloseToAPoint() [3/5]

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

Definition at line 358 of file DetIdAssociator.cc.

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

358  {
359  return getDetIdsCloseToAPoint(
360  direction, mapRange.dThetaPlus, mapRange.dThetaMinus, mapRange.dPhiPlus, mapRange.dPhiMinus);
361 }
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const

◆ 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.

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

96  {
97  return getDetIdsCloseToAPoint(point, d, d, d, d);
98 }
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
d
Definition: ztail.py:151
*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

◆ 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.

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

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 }
#define LogTrace(id)
const double etaBinSize_
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define M_PI
*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

◆ 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.

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

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 }
virtual bool selectAllInACone(const double dR) const
helper to see if getDetIdsInACone is useful
virtual bool nearElement(const GlobalPoint &point, const DetId &id, const double distance) const
virtual void check_setup() const

◆ 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.

Referenced by buildMap().

125 { return 1; }

◆ 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.

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

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

132 { return int(point.eta() / etaBinSize_ + nEta_ / 2); }
const double etaBinSize_
*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

◆ index()

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

Definition at line 139 of file DetIdAssociator.h.

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

Referenced by buildMap(), and fillSet().

139 { return iEta * nPhi_ + iPhi; }
virtual int iEta(const GlobalPoint &) const
look-up map eta index
virtual int iPhi(const GlobalPoint &) const
look-up map phi index

◆ 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.

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

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

134  {
135  return int((double(point.phi()) + M_PI) / (2 * M_PI) * nPhi_);
136 }
#define M_PI
*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

◆ 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.

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

Referenced by getDetIdsInACone().

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 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T eta() const
Definition: PV3DBase.h:73
#define M_PI
virtual GlobalPoint getPosition(const DetId &) 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

◆ 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.

References nEta_.

106 { return 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.

References nPhi_.

104 { return 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.

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.

References Exception, theMapIsValid_, and volume_.

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

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