CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
HDetIdAssociator Class Referenceabstract

#include <DetIdAssociator.h>

Inheritance diagram for HDetIdAssociator:
HCaloDetIdAssociator HEcalDetIdAssociator HHcalDetIdAssociator

Public Member Functions

virtual std::set< DetIdgetCrossedDetIds (const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory)
 
virtual std::set< DetIdgetDetIdsCloseToAPoint (const GlobalPoint &, const int idR=0)
 
virtual std::set< DetIdgetDetIdsCloseToAPoint (const GlobalPoint &point, const double dR=0)
 
virtual std::set< DetIdgetDetIdsInACone (const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory, const double)
 
virtual std::set< DetIdgetMaxEDetId (const std::set< DetId > &, edm::Handle< CaloTowerCollection > caloTowers)
 
virtual std::set< DetIdgetMaxEDetId (const std::set< DetId > &, edm::Handle< HBHERecHitCollection > recHits)
 
virtual std::vector< GlobalPointgetTrajectory (const FreeTrajectoryState &, const std::vector< GlobalPoint > &)
 
 HDetIdAssociator ()
 
 HDetIdAssociator (const int nPhi, const int nEta, const double etaBinSize)
 
virtual int iEta (const GlobalPoint &)
 
virtual int iPhi (const GlobalPoint &)
 
virtual void setPropagator (Propagator *ptr)
 
virtual ~HDetIdAssociator ()
 

Protected Member Functions

virtual void buildMap ()
 
virtual void check_setup ()
 
virtual std::set< DetIdgetASetOfValidDetIds ()=0
 
virtual std::vector< GlobalPointgetDetIdPoints (const DetId &)=0
 
virtual GlobalPoint getPosition (const DetId &)=0
 
virtual bool insideElement (const GlobalPoint &, const DetId &)=0
 
virtual bool nearElement (const GlobalPoint &point, const DetId &id, const double distance)
 

Protected Attributes

const double etaBinSize_
 
PropagatorivProp_
 
const int nEta_
 
const int nPhi_
 
std::vector< std::vector< std::set< DetId > > > * theMap_
 

Detailed Description

Definition at line 32 of file DetIdAssociator.h.

Constructor & Destructor Documentation

◆ HDetIdAssociator() [1/2]

HDetIdAssociator::HDetIdAssociator ( )
inline

Definition at line 34 of file DetIdAssociator.h.

34 : theMap_(nullptr), nPhi_(0), nEta_(0), etaBinSize_(0), ivProp_(nullptr){};
const double etaBinSize_
std::vector< std::vector< std::set< DetId > > > * theMap_
Propagator * ivProp_

◆ HDetIdAssociator() [2/2]

HDetIdAssociator::HDetIdAssociator ( const int  nPhi,
const int  nEta,
const double  etaBinSize 
)
inline

Definition at line 35 of file DetIdAssociator.h.

36  : theMap_(nullptr), nPhi_(nPhi), nEta_(nEta), etaBinSize_(etaBinSize), ivProp_(nullptr){};
const double etaBinSize_
std::vector< std::vector< std::set< DetId > > > * theMap_
Propagator * ivProp_

◆ ~HDetIdAssociator()

virtual HDetIdAssociator::~HDetIdAssociator ( )
inlinevirtual

Definition at line 38 of file DetIdAssociator.h.

38 {};

Member Function Documentation

◆ buildMap()

void HDetIdAssociator::buildMap ( )
protectedvirtual

Definition at line 278 of file DetIdAssociator.cc.

References cms::cuda::assert(), check_setup(), etaBinSize_, ALCARECOTkAlBeamHalo_cff::etaMax, ALCARECOTkAlBeamHalo_cff::etaMin, getASetOfValidDetIds(), getPosition(), hcalRecHitTable_cff::ieta, iEta(), hcalRecHitTable_cff::iphi, iPhi(), LogTrace, nEta_, nPhi_, AlignmentTrackSelector_cfi::phiMax, AlignmentTrackSelector_cfi::phiMin, point, std::swap(), and theMap_.

Referenced by getDetIdsCloseToAPoint().

278  {
279  // modified version: take only detector central position
280  check_setup();
281  LogTrace("HDetIdAssociator") << "building map"
282  << "\n";
283  if (theMap_)
284  delete theMap_;
285  theMap_ = new std::vector<std::vector<std::set<DetId> > >(nEta_, std::vector<std::set<DetId> >(nPhi_));
286  int numberOfDetIdsOutsideEtaRange = 0;
287  int numberOfDetIdsActive = 0;
288  std::set<DetId> validIds = getASetOfValidDetIds();
289  for (std::set<DetId>::const_iterator id_itr = validIds.begin(); id_itr != validIds.end(); id_itr++) {
290  // std::vector<GlobalPoint> points = getDetIdPoints(*id_itr);
291  GlobalPoint point = getPosition(*id_itr);
292  // reject fake DetIds (eta=0 - what are they anyway???)
293  if (point.eta() == 0)
294  continue;
295 
296  int ieta = iEta(point);
297  int iphi = iPhi(point);
298  int etaMax(-1);
299  int etaMin(nEta_);
300  int phiMax(-1);
301  int phiMin(nPhi_);
302  if (iphi >= nPhi_)
303  iphi = iphi % nPhi_;
304  assert(iphi >= 0);
305  if (etaMin > ieta)
306  etaMin = ieta;
307  if (etaMax < ieta)
308  etaMax = ieta;
309  if (phiMin > iphi)
310  phiMin = iphi;
311  if (phiMax < iphi)
312  phiMax = iphi;
313  // for abs(eta)>1.8 one tower covers two phi segments
314  if ((ieta > 54 || ieta < 15) && iphi % 2 == 0)
315  phiMax++;
316  if ((ieta > 54 || ieta < 15) && iphi % 2 == 1)
317  phiMin--;
318 
319  if (etaMax < 0 || phiMax < 0 || etaMin >= nEta_ || phiMin >= nPhi_) {
320  LogTrace("HDetIdAssociator") << "Out of range: DetId:" << id_itr->rawId() << "\n\teta (min,max): " << etaMin
321  << "," << etaMax << "\n\tphi (min,max): " << phiMin << "," << phiMax
322  << "\nTower id: " << id_itr->rawId() << "\n";
323  numberOfDetIdsOutsideEtaRange++;
324  continue;
325  }
326 
327  if (phiMax - phiMin > phiMin + nPhi_ - phiMax) {
328  phiMin += nPhi_;
330  }
331  for (int ieta = etaMin; ieta <= etaMax; ieta++)
332  for (int iphi = phiMin; iphi <= phiMax; iphi++)
333  (*theMap_)[ieta][iphi % nPhi_].insert(*id_itr);
334  numberOfDetIdsActive++;
335  }
336  LogTrace("HDetIdAssociator") << "Number of elements outside the allowed range ( |eta|>" << nEta_ / 2 * etaBinSize_
337  << "): " << numberOfDetIdsOutsideEtaRange << "\n";
338  LogTrace("HDetIdAssociator") << "Number of active DetId's mapped: " << numberOfDetIdsActive << "\n";
339 }
virtual void check_setup()
const double etaBinSize_
virtual GlobalPoint getPosition(const DetId &)=0
std::vector< std::vector< std::set< DetId > > > * theMap_
assert(be >=bs)
#define LogTrace(id)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
virtual int iPhi(const GlobalPoint &)
virtual std::set< DetId > getASetOfValidDetIds()=0
virtual int iEta(const GlobalPoint &)
*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

◆ check_setup()

virtual void HDetIdAssociator::check_setup ( )
inlineprotectedvirtual

Reimplemented in HCaloDetIdAssociator.

Definition at line 65 of file DetIdAssociator.h.

References etaBinSize_, Exception, ivProp_, nEta_, and nPhi_.

Referenced by buildMap(), HCaloDetIdAssociator::check_setup(), getCrossedDetIds(), getDetIdsCloseToAPoint(), getDetIdsInACone(), getMaxEDetId(), and getTrajectory().

65  {
66  if (nEta_ == 0)
67  throw cms::Exception("FatalError") << "Number of eta bins is not set.\n";
68  if (nPhi_ == 0)
69  throw cms::Exception("FatalError") << "Number of phi bins is not set.\n";
70  if (ivProp_ == nullptr)
71  throw cms::Exception("FatalError") << "Track propagator is not defined\n";
72  if (etaBinSize_ == 0)
73  throw cms::Exception("FatalError") << "Eta bin size is not set.\n";
74  }
const double etaBinSize_
Propagator * ivProp_

◆ getASetOfValidDetIds()

virtual std::set<DetId> HDetIdAssociator::getASetOfValidDetIds ( )
protectedpure virtual

◆ getCrossedDetIds()

std::set< DetId > HDetIdAssociator::getCrossedDetIds ( const std::set< DetId > &  inset,
const std::vector< GlobalPoint > &  trajectory 
)
virtual

Definition at line 391 of file DetIdAssociator.cc.

References check_setup(), and insideElement().

392  {
393  check_setup();
394  std::set<DetId> outset;
395  for (std::set<DetId>::const_iterator id_iter = inset.begin(); id_iter != inset.end(); id_iter++)
396  for (std::vector<GlobalPoint>::const_iterator point_iter = trajectory.begin(); point_iter != trajectory.end();
397  point_iter++)
398  if (insideElement(*point_iter, *id_iter))
399  outset.insert(*id_iter);
400  return outset;
401 }
virtual void check_setup()
virtual bool insideElement(const GlobalPoint &, const DetId &)=0

◆ getDetIdPoints()

virtual std::vector<GlobalPoint> HDetIdAssociator::getDetIdPoints ( const DetId )
protectedpure virtual

Implemented in HCaloDetIdAssociator.

◆ getDetIdsCloseToAPoint() [1/2]

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

Definition at line 138 of file DetIdAssociator.cc.

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

Referenced by getDetIdsCloseToAPoint().

138  {
139  std::set<DetId> set;
140  check_setup();
141  if (!theMap_)
142  buildMap();
143  LogTrace("MatchPoint") << "point (eta,phi): " << direction.eta() << "," << direction.phi() << "\n";
144  int ieta = iEta(direction);
145  int iphi = iPhi(direction);
146 
147  LogTrace("MatchPoint") << "(ieta,iphi): " << ieta << "," << iphi << "\n";
148 
149  if (ieta >= 0 && ieta < nEta_ && iphi >= 0 && iphi < nPhi_) {
150  set = (*theMap_)[ieta][iphi];
151  if (idR > 0) {
152  LogTrace("MatchPoint") << "Add neighbors (ieta,iphi): " << ieta << "," << iphi << "\n";
153  //add neighbors
154  int maxIEta = ieta + idR;
155  int minIEta = ieta - idR;
156  if (maxIEta >= nEta_)
157  maxIEta = nEta_ - 1;
158  if (minIEta < 0)
159  minIEta = 0;
160  int maxIPhi = iphi + idR;
161  int minIPhi = iphi - idR;
162  if (minIPhi < 0) {
163  minIPhi += nPhi_;
164  maxIPhi += nPhi_;
165  }
166  LogTrace("MatchPoint") << "\tieta (min,max): " << minIEta << "," << maxIEta << "\n";
167  LogTrace("MatchPoint") << "\tiphi (min,max): " << minIPhi << "," << maxIPhi << "\n";
168  for (int i = minIEta; i <= maxIEta; i++)
169  for (int j = minIPhi; j <= maxIPhi; j++) {
170  if (i == ieta && j == iphi)
171  continue; // already in the set
172  set.insert((*theMap_)[i][j % nPhi_].begin(), (*theMap_)[i][j % nPhi_].end());
173  }
174  }
175  }
176  // if(set.size() > 0) {
177  // if (ieta+idR<55 && ieta-idR>14 && set.size() != (2*idR+1)*(2*idR+1)){
178  // std::cout<<" RRRA: "<<set.size()<<" DetIds in region "<<ieta<<" "<<iphi<<std::endl;
179  // for( std::set<DetId>::const_iterator itr=set.begin(); itr!=set.end(); itr++) {
180  // GlobalPoint point = getPosition(*itr);
181  // std::cout << "DetId: " <<itr->rawId() <<" (eta,phi): " << point.eta() << "," << point.phi()<<" "<<iEta(point)<<" "<<iPhi(point)<<std::endl;
182  // }
183  // }
184  // else {
185  // std::cout <<" HDetIdAssociator::getDetIdsCloseToAPoint::There are strange days "<<std::endl;
186  // }
187  return set;
188 }
virtual void check_setup()
virtual void buildMap()
std::vector< std::vector< std::set< DetId > > > * theMap_
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T eta() const
Definition: PV3DBase.h:73
#define LogTrace(id)
virtual int iPhi(const GlobalPoint &)
virtual int iEta(const GlobalPoint &)

◆ getDetIdsCloseToAPoint() [2/2]

virtual std::set<DetId> HDetIdAssociator::getDetIdsCloseToAPoint ( const GlobalPoint point,
const double  dR = 0 
)
inlinevirtual

Definition at line 44 of file DetIdAssociator.h.

References HGC3DClusterGenMatchSelector_cfi::dR, etaBinSize_, getDetIdsCloseToAPoint(), createfilelist::int, nPhi_, and point.

44  {
45  int etaIdR = int(dR / etaBinSize_);
46  int phiIdR = int(dR / (2 * 3.1416) * nPhi_);
47  if (etaIdR > phiIdR)
48  return getDetIdsCloseToAPoint(point, 1 + etaIdR);
49  else
50  return getDetIdsCloseToAPoint(point, 1 + phiIdR);
51  }
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int idR=0)
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

◆ getDetIdsInACone()

std::set< DetId > HDetIdAssociator::getDetIdsInACone ( const std::set< DetId > &  inset,
const std::vector< GlobalPoint > &  trajectory,
const double  dR 
)
virtual

Definition at line 342 of file DetIdAssociator.cc.

References check_setup(), HGC3DClusterGenMatchSelector_cfi::dR, relativeConstraints::empty, mps_fire::end, getPosition(), mps_fire::i, hcalRecHitTable_cff::ieta, iEta(), hcalRecHitTable_cff::iphi, iPhi(), dqmiolumiharvest::j, nearElement(), nEta_, nPhi_, point, and theMap_.

344  {
345  // modified version: if dR<0, returns 3x3 towers around the input one (Michal)
346  check_setup();
347  std::set<DetId> outset;
348 
349  if (dR >= 0) {
350  for (std::set<DetId>::const_iterator id_iter = inset.begin(); id_iter != inset.end(); id_iter++)
351  for (std::vector<GlobalPoint>::const_iterator point_iter = trajectory.begin(); point_iter != trajectory.end();
352  point_iter++)
353  if (nearElement(*point_iter, *id_iter, dR))
354  outset.insert(*id_iter);
355  } else {
356  if (inset.size() != 1)
357  return outset;
358  std::set<DetId>::const_iterator id_inp = inset.begin();
359  int ieta;
360  int iphi;
361  GlobalPoint point = getPosition(*id_inp);
362  ieta = iEta(point);
363  iphi = iPhi(point);
364  for (int i = ieta - 1; i <= ieta + 1; i++) {
365  for (int j = iphi - 1; j <= iphi + 1; j++) {
366  // if( i==ieta && j==iphi) continue;
367  if (i < 0 || i >= nEta_)
368  continue;
369  int j2fill = j % nPhi_;
370  if (j2fill < 0)
371  j2fill += nPhi_;
372  if ((*theMap_)[i][j2fill].empty())
373  continue;
374  outset.insert((*theMap_)[i][j2fill].begin(), (*theMap_)[i][j2fill].end());
375  }
376  }
377  }
378 
379  // if (outset.size() > 0) {
380  // std::cout<<" RRRA: DetIds in cone:"<<std::endl;
381  // for( std::set<DetId>::const_iterator itr=outset.begin(); itr!=outset.end(); itr++) {
382  // GlobalPoint point = getPosition(*itr);
383  // std::cout << "DetId: " <<itr->rawId() <<" (eta,phi): " << point.eta() << "," << point.phi()<<std::endl;
384  // }
385  // }
386 
387  return outset;
388 }
virtual void check_setup()
virtual GlobalPoint getPosition(const DetId &)=0
std::vector< std::vector< std::set< DetId > > > * theMap_
virtual bool nearElement(const GlobalPoint &point, const DetId &id, const double distance)
virtual int iPhi(const GlobalPoint &)
virtual int iEta(const GlobalPoint &)
*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

◆ getMaxEDetId() [1/2]

std::set< DetId > HDetIdAssociator::getMaxEDetId ( const std::set< DetId > &  inset,
edm::Handle< CaloTowerCollection caloTowers 
)
virtual

Definition at line 404 of file DetIdAssociator.cc.

References check_setup(), l1ctLayer2EG_cff::id, and l1tHGCalTowerProducer_cfi::tower.

405  {
406  // returns the most energetic tower in the NxN box (Michal)
407  check_setup();
408  std::set<DetId> outset;
409  std::set<DetId>::const_iterator id_max = inset.begin();
410  double Ehadmax = 0;
411 
412  for (std::set<DetId>::const_iterator id_iter = inset.begin(); id_iter != inset.end(); id_iter++) {
413  DetId id(*id_iter);
414  // GlobalPoint point = getPosition(*id_iter);
415  // int ieta = iEta(point);
416  // int iphi = iPhi(point);
417  CaloTowerCollection::const_iterator tower = (*caloTowers).find(id);
418  if (tower != (*caloTowers).end() && tower->hadEnergy() > Ehadmax) {
419  id_max = id_iter;
420  Ehadmax = tower->hadEnergy();
421  }
422  }
423 
424  if (Ehadmax > 0)
425  outset.insert(*id_max);
426 
427  // if (outset.size() > 0) {
428  // std::cout<<" RRRA: Most energetic DetId:"<<std::endl;
429  // for( std::set<DetId>::const_iterator itr=outset.begin(); itr!=outset.end(); itr++) {
430  // GlobalPoint point = getPosition(*itr);
431  // std::cout << "DetId: " <<itr->rawId() <<" (eta,phi): " << point.eta() << "," << point.phi()<<std::endl;
432  // }
433  // }
434 
435  return outset;
436 }
virtual void check_setup()
std::vector< CaloTower >::const_iterator const_iterator
Definition: DetId.h:17

◆ getMaxEDetId() [2/2]

std::set< DetId > HDetIdAssociator::getMaxEDetId ( const std::set< DetId > &  inset,
edm::Handle< HBHERecHitCollection recHits 
)
virtual

Definition at line 439 of file DetIdAssociator.cc.

References check_setup(), and l1ctLayer2EG_cff::id.

440  {
441  // returns the most energetic tower in the NxN box - from RecHits (Michal)
442  check_setup();
443  std::set<DetId> outset;
444  std::set<DetId>::const_iterator id_max = inset.begin();
445  double Ehadmax = 0;
446 
447  for (std::set<DetId>::const_iterator id_iter = inset.begin(); id_iter != inset.end(); id_iter++) {
448  DetId id(*id_iter);
449  // GlobalPoint point = getPosition(*id_iter);
450  // int ieta = iEta(point);
451  // int iphi = iPhi(point);
452  HBHERecHitCollection::const_iterator hit = (*recHits).find(id);
453  if (hit != (*recHits).end() && hit->energy() > Ehadmax) {
454  id_max = id_iter;
455  Ehadmax = hit->energy();
456  }
457  }
458 
459  if (Ehadmax > 0)
460  outset.insert(*id_max);
461 
462  // if (outset.size() > 0) {
463  // std::cout<<" RRRA: Most energetic DetId:"<<std::endl;
464  // for( std::set<DetId>::const_iterator itr=outset.begin(); itr!=outset.end(); itr++) {
465  // GlobalPoint point = getPosition(*itr);
466  // std::cout << "DetId: " <<itr->rawId() <<" (eta,phi): " << point.eta() << "," << point.phi()<<std::endl;
467  // }
468  // }
469 
470  return outset;
471 }
virtual void check_setup()
std::vector< T >::const_iterator const_iterator
Definition: DetId.h:17

◆ getPosition()

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

Implemented in HCaloDetIdAssociator.

Referenced by buildMap(), getDetIdsInACone(), and nearElement().

◆ getTrajectory()

std::vector< GlobalPoint > HDetIdAssociator::getTrajectory ( const FreeTrajectoryState ftsStart,
const std::vector< GlobalPoint > &  surfaces 
)
virtual

Definition at line 25 of file DetIdAssociator.cc.

References funct::abs(), check_setup(), TCMET_cfi::corner, PV3DBase< T, PVType, FrameType >::eta(), TrajectoryStateOnSurface::freeState(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), ivProp_, LogTrace, PV3DBase< T, PVType, FrameType >::mag(), FreeTrajectoryState::momentum(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), point, FreeTrajectoryState::position(), Propagator::propagate(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

26  {
27  check_setup();
28  std::vector<GlobalPoint> trajectory;
29  TrajectoryStateOnSurface tSOSDest;
30  FreeTrajectoryState ftsCurrent = ftsStart;
31 
32  for (std::vector<GlobalPoint>::const_iterator surface_iter = surfaces.begin(); surface_iter != surfaces.end();
33  surface_iter++) {
34  // this stuff is some weird pointer, which destroy itself
35  std::unique_ptr<Cylinder> cylinder =
36  std::make_unique<Cylinder>(surface_iter->perp(), Surface::PositionType(0, 0, 0), Surface::RotationType());
37  std::unique_ptr<Plane> forwardEndcap =
38  std::make_unique<Plane>(Surface::PositionType(0, 0, surface_iter->z()), Surface::RotationType());
39  std::unique_ptr<Plane> backwardEndcap =
40  std::make_unique<Plane>(Surface::PositionType(0, 0, -surface_iter->z()), Surface::RotationType());
41 
42  LogTrace("StartingPoint") << "Propagate from "
43  << "\n"
44  << "\tx: " << ftsStart.position().x() << "\n"
45  << "\ty: " << ftsStart.position().y() << "\n"
46  << "\tz: " << ftsStart.position().z() << "\n"
47  << "\tmomentum eta: " << ftsStart.momentum().eta() << "\n"
48  << "\tmomentum phi: " << ftsStart.momentum().phi() << "\n"
49  << "\tmomentum: " << ftsStart.momentum().mag() << "\n";
50 
51  float tanTheta = ftsCurrent.momentum().perp() / ftsCurrent.momentum().z();
52  float corner = surface_iter->perp() / surface_iter->z();
53  /*
54  std::cout<<"Propagate from "<< "\n"
55  << "\tx: " << ftsCurrent.position().x()<< "\n"
56  << "\ty: " << ftsCurrent.position().y()<< "\n"
57  << "\tz: " << ftsCurrent.position().z()<< "\n"
58  << "\tz: " << ftsCurrent.position().perp()<< "\n"
59  << "\tz: " << tanTheta<<" "<< corner <<"\n"
60  << "\tmomentum eta: " << ftsCurrent.momentum().eta()<< "\n"
61  << "\tmomentum phi: " << ftsCurrent.momentum().phi()<< "\n"
62  << "\tmomentum: " << ftsCurrent.momentum().mag()<<std::endl;
63 */
64  // First propage the track to the cylinder if |eta|<1, othewise to the encap
65  // and correct depending on the result
66  int ibar = 0;
67  if (fabs(tanTheta) > corner) {
68  tSOSDest = ivProp_->propagate(ftsCurrent, *cylinder);
69  // std::cout<<" Propagate to cylinder "<<std::endl;
70  } else if (tanTheta > 0.) {
71  tSOSDest = ivProp_->propagate(ftsCurrent, *forwardEndcap);
72  ibar = 1;
73  } else {
74  tSOSDest = ivProp_->propagate(ftsCurrent, *backwardEndcap);
75  ibar = -1;
76  }
77 
78  // std::cout<<" Trajectory valid? "<<tSOSDest.isValid()<<" First propagation in "<<ibar<<std::endl;
79 
80  if (!tSOSDest.isValid()) {
81  // barrel
82  if (ibar == 0) {
83  if (tanTheta < 0)
84  tSOSDest = ivProp_->propagate(ftsCurrent, *forwardEndcap);
85  if (tanTheta >= 0)
86  tSOSDest = ivProp_->propagate(ftsCurrent, *backwardEndcap);
87  } else {
88  tSOSDest = ivProp_->propagate(ftsCurrent, *cylinder);
89  }
90  } else {
91  // missed target
92  if (abs(ibar) > 0) {
93  if (tSOSDest.globalPosition().perp() > surface_iter->perp()) {
94  tSOSDest = ivProp_->propagate(ftsCurrent, *cylinder);
95  }
96  } else {
97  if (tanTheta < 0)
98  tSOSDest = ivProp_->propagate(ftsCurrent, *forwardEndcap);
99  if (tanTheta >= 0)
100  tSOSDest = ivProp_->propagate(ftsCurrent, *backwardEndcap);
101  }
102  }
103 
104  // If missed the target, propagate to again
105  // if ((!tSOSDest.isValid()) && point.perp() > surface_iter->perp())
106  // {tSOSDest = ivProp_->propagate(ftsCurrent, *cylinder);std::cout<<" Propagate again 1 "<<std::endl;}
107  // std::cout<<" Track is ok after repropagation to cylinder or not? "<<tSOSDest.isValid()<<std::endl;
108  // if ((!tSOSDest.isValid()) && ftsStart.momentum().eta()>0. && fabs(ftsStart.momentum().eta())>1.)
109  // {tSOSDest = ivProp_->propagate(ftsStart, *forwardEndcap);std::cout<<" Propagate again 2 "<<std::endl;}
110  // std::cout<<" Track is ok after repropagation forward or not? "<<tSOSDest.isValid()<<std::endl;
111  // if ((!tSOSDest.isValid()) && ftsStart.momentum().eta()<0.&&fabs(ftsStart.momentum().eta())>1.)
112  // {tSOSDest = ivProp_->propagate(ftsStart, *backwardEndcap);std::cout<<" Propagate again 3 "<<std::endl;}
113  // std::cout<<" Track is after repropagation backward ok or not? "<<tSOSDest.isValid()<<std::endl;
114 
115  if (!tSOSDest.isValid())
116  return trajectory;
117 
118  // std::cout<<" Propagate reach something"<<std::endl;
119  LogTrace("SuccessfullPropagation") << "Great, I reached something."
120  << "\n"
121  << "\tx: " << tSOSDest.freeState()->position().x() << "\n"
122  << "\ty: " << tSOSDest.freeState()->position().y() << "\n"
123  << "\tz: " << tSOSDest.freeState()->position().z() << "\n"
124  << "\teta: " << tSOSDest.freeState()->position().eta() << "\n"
125  << "\tphi: " << tSOSDest.freeState()->position().phi() << "\n";
126 
127  // std::cout<<" The position of trajectory "<<tSOSDest.freeState()->position().perp()<<" "<<tSOSDest.freeState()->position().z()<<std::endl;
128 
129  GlobalPoint point = tSOSDest.freeState()->position();
130  point = tSOSDest.freeState()->position();
131  ftsCurrent = *tSOSDest.freeState();
132  trajectory.push_back(point);
133  }
134  return trajectory;
135 }
virtual void check_setup()
T perp() const
Definition: PV3DBase.h:69
T z() const
Definition: PV3DBase.h:61
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T eta() const
Definition: PV3DBase.h:73
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
#define LogTrace(id)
GlobalPoint position() const
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
GlobalPoint globalPosition() const
T mag() const
Definition: PV3DBase.h:64
GlobalVector momentum() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Point3DBase< float, GlobalTag > PositionType
Propagator * ivProp_
TkRotation< float > RotationType
FreeTrajectoryState const * freeState(bool withErrors=true) const
*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

◆ iEta()

int HDetIdAssociator::iEta ( const GlobalPoint point)
virtual

Definition at line 191 of file DetIdAssociator.cc.

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

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

191  {
192  // unequal bin sizes for endcap, following HCAL geometry
193  int iEta1 = int(point.eta() / etaBinSize_ + nEta_ / 2);
194  if (point.eta() > 1.827 && point.eta() <= 1.830)
195  return iEta1 - 1;
196  else if (point.eta() > 1.914 && point.eta() <= 1.930)
197  return iEta1 - 1;
198  else if (point.eta() > 2.001 && point.eta() <= 2.043)
199  return iEta1 - 1;
200  else if (point.eta() > 2.088 && point.eta() <= 2.172)
201  return iEta1 - 1;
202  else if (point.eta() > 2.175 && point.eta() <= 2.262)
203  return iEta1 - 1;
204  else if (point.eta() > 2.262 && point.eta() <= 2.332)
205  return iEta1 - 2;
206  else if (point.eta() > 2.332 && point.eta() <= 2.349)
207  return iEta1 - 1;
208  else if (point.eta() > 2.349 && point.eta() <= 2.436)
209  return iEta1 - 2;
210  else if (point.eta() > 2.436 && point.eta() <= 2.500)
211  return iEta1 - 3;
212  else if (point.eta() > 2.500 && point.eta() <= 2.523)
213  return iEta1 - 2;
214  else if (point.eta() > 2.523 && point.eta() <= 2.610)
215  return iEta1 - 3;
216  else if (point.eta() > 2.610 && point.eta() <= 2.650)
217  return iEta1 - 4;
218  else if (point.eta() > 2.650 && point.eta() <= 2.697)
219  return iEta1 - 3;
220  else if (point.eta() > 2.697 && point.eta() <= 2.784)
221  return iEta1 - 4;
222  else if (point.eta() > 2.784 && point.eta() <= 2.868)
223  return iEta1 - 5;
224  else if (point.eta() > 2.868 && point.eta() <= 2.871)
225  return iEta1 - 4;
226  else if (point.eta() > 2.871 && point.eta() <= 2.958)
227  return iEta1 - 5;
228  else if (point.eta() > 2.958)
229  return iEta1 - 6;
230  else if (point.eta() < -1.827 && point.eta() >= -1.830)
231  return iEta1 + 1;
232  else if (point.eta() < -1.914 && point.eta() >= -1.930)
233  return iEta1 + 1;
234  else if (point.eta() < -2.001 && point.eta() >= -2.043)
235  return iEta1 + 1;
236  else if (point.eta() < -2.088 && point.eta() >= -2.172)
237  return iEta1 + 1;
238  else if (point.eta() < -2.175 && point.eta() >= -2.262)
239  return iEta1 + 1;
240  else if (point.eta() < -2.262 && point.eta() >= -2.332)
241  return iEta1 + 2;
242  else if (point.eta() < -2.332 && point.eta() >= -2.349)
243  return iEta1 + 1;
244  else if (point.eta() < -2.349 && point.eta() >= -2.436)
245  return iEta1 + 2;
246  else if (point.eta() < -2.436 && point.eta() >= -2.500)
247  return iEta1 + 3;
248  else if (point.eta() < -2.500 && point.eta() >= -2.523)
249  return iEta1 + 2;
250  else if (point.eta() < -2.523 && point.eta() >= -2.610)
251  return iEta1 + 3;
252  else if (point.eta() < -2.610 && point.eta() >= -2.650)
253  return iEta1 + 4;
254  else if (point.eta() < -2.650 && point.eta() >= -2.697)
255  return iEta1 + 3;
256  else if (point.eta() < -2.697 && point.eta() >= -2.784)
257  return iEta1 + 4;
258  else if (point.eta() < -2.784 && point.eta() >= -2.868)
259  return iEta1 + 5;
260  else if (point.eta() < -2.868 && point.eta() >= -2.871)
261  return iEta1 + 4;
262  else if (point.eta() < -2.871 && point.eta() >= -2.958)
263  return iEta1 + 5;
264  else if (point.eta() < -2.349)
265  return iEta1 + 6;
266  else
267  return iEta1;
268 }
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

◆ insideElement()

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

Implemented in HCaloDetIdAssociator.

Referenced by getCrossedDetIds().

◆ iPhi()

int HDetIdAssociator::iPhi ( const GlobalPoint point)
virtual

Definition at line 271 of file DetIdAssociator.cc.

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

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

271  {
272  double pi = 4 * atan(1.);
273  int iPhi1 = int((double(point.phi()) + pi) / (2 * pi) * nPhi_);
274  return iPhi1;
275 }
const Double_t 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

◆ nearElement()

virtual bool HDetIdAssociator::nearElement ( const GlobalPoint point,
const DetId id,
const double  distance 
)
inlineprotectedvirtual

Definition at line 82 of file DetIdAssociator.h.

References HLT_2023v12_cff::distance, PV3DBase< T, PVType, FrameType >::eta(), getPosition(), PV3DBase< T, PVType, FrameType >::phi(), point, conifer::pow(), and mathSSE::sqrt().

Referenced by getDetIdsInACone().

82  {
83  GlobalPoint center = getPosition(id);
84  return sqrt(pow(point.eta() - center.eta(), 2) + pow(point.phi() - center.phi(), 2)) < distance;
85  };
virtual GlobalPoint getPosition(const DetId &)=0
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T eta() const
Definition: PV3DBase.h:73
constexpr int pow(int x)
Definition: conifer.h:24
T sqrt(T t)
Definition: SSEVec.h:19
*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

◆ setPropagator()

virtual void HDetIdAssociator::setPropagator ( Propagator ptr)
inlinevirtual

Definition at line 62 of file DetIdAssociator.h.

References ivProp_.

62 { ivProp_ = ptr; };
Propagator * ivProp_

Member Data Documentation

◆ etaBinSize_

const double HDetIdAssociator::etaBinSize_
protected

Definition at line 90 of file DetIdAssociator.h.

Referenced by buildMap(), check_setup(), getDetIdsCloseToAPoint(), and iEta().

◆ ivProp_

Propagator* HDetIdAssociator::ivProp_
protected

Definition at line 91 of file DetIdAssociator.h.

Referenced by check_setup(), getTrajectory(), and setPropagator().

◆ nEta_

const int HDetIdAssociator::nEta_
protected

◆ nPhi_

const int HDetIdAssociator::nPhi_
protected

◆ theMap_

std::vector<std::vector<std::set<DetId> > >* HDetIdAssociator::theMap_
protected

Definition at line 85 of file DetIdAssociator.h.

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