CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 30 of file DetIdAssociator.h.

Constructor & Destructor Documentation

HDetIdAssociator::HDetIdAssociator ( )
inline

Definition at line 32 of file DetIdAssociator.h.

32 :theMap_(0),nPhi_(0),nEta_(0),etaBinSize_(0),ivProp_(0){};
const double etaBinSize_
std::vector< std::vector< std::set< DetId > > > * theMap_
Propagator * ivProp_
HDetIdAssociator::HDetIdAssociator ( const int  nPhi,
const int  nEta,
const double  etaBinSize 
)
inline

Definition at line 33 of file DetIdAssociator.h.

34  :theMap_(0),nPhi_(nPhi),nEta_(nEta),etaBinSize_(etaBinSize),ivProp_(0){};
const double etaBinSize_
std::vector< std::vector< std::set< DetId > > > * theMap_
Propagator * ivProp_
virtual HDetIdAssociator::~HDetIdAssociator ( )
inlinevirtual

Definition at line 36 of file DetIdAssociator.h.

36 {};

Member Function Documentation

void HDetIdAssociator::buildMap ( )
protectedvirtual

Definition at line 250 of file DetIdAssociator.cc.

References check_setup(), PV3DBase< T, PVType, FrameType >::eta(), etaBinSize_, jptDQMConfig_cff::etaMax, jptDQMConfig_cff::etaMin, getASetOfValidDetIds(), getPosition(), iEta(), iPhi(), LogTrace, nEta_, nPhi_, jptDQMConfig_cff::phiMax, jptDQMConfig_cff::phiMin, point, std::swap(), and theMap_.

Referenced by getDetIdsCloseToAPoint().

251 {
252 // modified version: take only detector central position
253  check_setup();
254  LogTrace("HDetIdAssociator")<<"building map" << "\n";
255  if(theMap_) delete theMap_;
256  theMap_ = new std::vector<std::vector<std::set<DetId> > >(nEta_,std::vector<std::set<DetId> >(nPhi_));
257  int numberOfDetIdsOutsideEtaRange = 0;
258  int numberOfDetIdsActive = 0;
259  std::set<DetId> validIds = getASetOfValidDetIds();
260  for (std::set<DetId>::const_iterator id_itr = validIds.begin(); id_itr!=validIds.end(); id_itr++) {
261 // std::vector<GlobalPoint> points = getDetIdPoints(*id_itr);
262  GlobalPoint point = getPosition(*id_itr);
263 // reject fake DetIds (eta=0 - what are they anyway???)
264  if(point.eta()==0)continue;
265 
266  int ieta = iEta(point);
267  int iphi = iPhi(point);
268  int etaMax(-1);
269  int etaMin(nEta_);
270  int phiMax(-1);
271  int phiMin(nPhi_);
272  if ( iphi >= nPhi_ ) iphi = iphi % nPhi_;
273  assert (iphi>=0);
274  if ( etaMin > ieta) etaMin = ieta;
275  if ( etaMax < ieta) etaMax = ieta;
276  if ( phiMin > iphi) phiMin = iphi;
277  if ( phiMax < iphi) phiMax = iphi;
278 // for abs(eta)>1.8 one tower covers two phi segments
279  if ((ieta>54||ieta<15) && iphi%2==0) phiMax++;
280  if ((ieta>54||ieta<15) && iphi%2==1) phiMin--;
281 
282  if (etaMax<0||phiMax<0||etaMin>=nEta_||phiMin>=nPhi_) {
283  LogTrace("HDetIdAssociator")<<"Out of range: DetId:" << id_itr->rawId() <<
284  "\n\teta (min,max): " << etaMin << "," << etaMax <<
285  "\n\tphi (min,max): " << phiMin << "," << phiMax <<
286  "\nTower id: " << id_itr->rawId() << "\n";
287  numberOfDetIdsOutsideEtaRange++;
288  continue;
289  }
290 
292  phiMin += nPhi_;
294  }
295  for(int ieta = etaMin; ieta <= etaMax; ieta++)
296  for(int iphi = phiMin; iphi <= phiMax; iphi++)
297  (*theMap_)[ieta][iphi%nPhi_].insert(*id_itr);
298  numberOfDetIdsActive++;
299  }
300  LogTrace("HDetIdAssociator") << "Number of elements outside the allowed range ( |eta|>"<<
301  nEta_/2*etaBinSize_ << "): " << numberOfDetIdsOutsideEtaRange << "\n";
302  LogTrace("HDetIdAssociator") << "Number of active DetId's mapped: " <<
303  numberOfDetIdsActive << "\n";
304 }
virtual void check_setup()
const double etaBinSize_
virtual GlobalPoint getPosition(const DetId &)=0
std::vector< std::vector< std::set< DetId > > > * theMap_
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
virtual int iPhi(const GlobalPoint &)
virtual std::set< DetId > getASetOfValidDetIds()=0
#define LogTrace(id)
virtual int iEta(const GlobalPoint &)
T eta() const
Definition: PV3DBase.h:76
*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
virtual void HDetIdAssociator::check_setup ( )
inlineprotectedvirtual

Reimplemented in HCaloDetIdAssociator.

Definition at line 70 of file DetIdAssociator.h.

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

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

71  {
72  if (nEta_==0) throw cms::Exception("FatalError") << "Number of eta bins is not set.\n";
73  if (nPhi_==0) throw cms::Exception("FatalError") << "Number of phi bins is not set.\n";
74  if (ivProp_==0) throw cms::Exception("FatalError") << "Track propagator is not defined\n";
75  if (etaBinSize_==0) throw cms::Exception("FatalError") << "Eta bin size is not set.\n";
76  }
const double etaBinSize_
Propagator * ivProp_
virtual std::set<DetId> HDetIdAssociator::getASetOfValidDetIds ( )
protectedpure virtual
std::set< DetId > HDetIdAssociator::getCrossedDetIds ( const std::set< DetId > &  inset,
const std::vector< GlobalPoint > &  trajectory 
)
virtual

Definition at line 352 of file DetIdAssociator.cc.

References check_setup(), and insideElement().

354 {
355  check_setup();
356  std::set<DetId> outset;
357  for(std::set<DetId>::const_iterator id_iter = inset.begin(); id_iter != inset.end(); id_iter++)
358  for(std::vector<GlobalPoint>::const_iterator point_iter = trajectory.begin(); point_iter != trajectory.end(); point_iter++)
359  if (insideElement(*point_iter, *id_iter)) outset.insert(*id_iter);
360  return outset;
361 }
virtual void check_setup()
virtual bool insideElement(const GlobalPoint &, const DetId &)=0
virtual std::vector<GlobalPoint> HDetIdAssociator::getDetIdPoints ( const DetId )
protectedpure virtual

Implemented in HCaloDetIdAssociator.

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

Definition at line 144 of file DetIdAssociator.cc.

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

Referenced by getDetIdsCloseToAPoint().

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

Definition at line 44 of file DetIdAssociator.h.

References PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, etaBinSize_, getDetIdsCloseToAPoint(), and nPhi_.

46  {
47  int etaIdR = int(dR/etaBinSize_);
48  int phiIdR = int(dR/(2*3.1416)*nPhi_);
49  if (etaIdR>phiIdR)
50  return getDetIdsCloseToAPoint(point, 1+etaIdR);
51  else
52  return getDetIdsCloseToAPoint(point, 1+phiIdR);
53  }
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int idR=0)
const double etaBinSize_
std::set< DetId > HDetIdAssociator::getDetIdsInACone ( const std::set< DetId > &  inset,
const std::vector< GlobalPoint > &  trajectory,
const double  dR 
)
virtual

Definition at line 307 of file DetIdAssociator.cc.

References begin, check_setup(), end, getPosition(), i, iEta(), iPhi(), j, nearElement(), nEta_, nPhi_, point, findQualityFiles::size, and theMap_.

310 {
311 // modified version: if dR<0, returns 3x3 towers around the input one (Michal)
312  check_setup();
313  std::set<DetId> outset;
314 
315  if(dR>=0) {
316  for(std::set<DetId>::const_iterator id_iter = inset.begin(); id_iter != inset.end(); id_iter++)
317  for(std::vector<GlobalPoint>::const_iterator point_iter = trajectory.begin(); point_iter != trajectory.end(); point_iter++)
318  if (nearElement(*point_iter,*id_iter,dR)) outset.insert(*id_iter);
319  }
320  else {
321  if (inset.size()!=1) return outset;
322  std::set<DetId>::const_iterator id_inp = inset.begin();
323  int ieta;
324  int iphi;
325  GlobalPoint point = getPosition(*id_inp);
326  ieta = iEta(point);
327  iphi = iPhi(point);
328  for (int i=ieta-1;i<=ieta+1;i++) {
329  for (int j=iphi-1;j<=iphi+1;j++) {
330 // if( i==ieta && j==iphi) continue;
331  if( i<0 || i>=nEta_) continue;
332  int j2fill = j%nPhi_;
333  if(j2fill<0) j2fill+=nPhi_;
334  if((*theMap_)[i][j2fill].size()==0)continue;
335  outset.insert((*theMap_)[i][j2fill].begin(),(*theMap_)[i][j2fill].end());
336  }
337  }
338  }
339 
340 // if (outset.size() > 0) {
341 // std::cout<<" RRRA: DetIds in cone:"<<std::endl;
342 // for( std::set<DetId>::const_iterator itr=outset.begin(); itr!=outset.end(); itr++) {
343 // GlobalPoint point = getPosition(*itr);
344 // std::cout << "DetId: " <<itr->rawId() <<" (eta,phi): " << point.eta() << "," << point.phi()<<std::endl;
345 // }
346 // }
347 
348  return outset;
349 }
virtual void check_setup()
int i
Definition: DBlmapReader.cc:9
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 &)
int j
Definition: DBlmapReader.cc:9
#define end
Definition: vmac.h:38
virtual int iEta(const GlobalPoint &)
#define begin
Definition: vmac.h:31
tuple size
Write out results.
*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
std::set< DetId > HDetIdAssociator::getMaxEDetId ( const std::set< DetId > &  inset,
edm::Handle< CaloTowerCollection caloTowers 
)
virtual

Definition at line 364 of file DetIdAssociator.cc.

References check_setup().

366 {
367 // returns the most energetic tower in the NxN box (Michal)
368  check_setup();
369  std::set<DetId> outset;
370  std::set<DetId>::const_iterator id_max = inset.begin();
371  double Ehadmax=0;
372 
373  for(std::set<DetId>::const_iterator id_iter = inset.begin(); id_iter != inset.end(); id_iter++) {
374  DetId id(*id_iter);
375 // GlobalPoint point = getPosition(*id_iter);
376 // int ieta = iEta(point);
377 // int iphi = iPhi(point);
378  CaloTowerCollection::const_iterator tower = (*caloTowers).find(id);
379  if(tower != (*caloTowers).end() && tower->hadEnergy()>Ehadmax) {
380  id_max = id_iter;
381  Ehadmax = tower->hadEnergy();
382  }
383  }
384 
385  if (Ehadmax > 0) outset.insert(*id_max);
386 
387 // if (outset.size() > 0) {
388 // std::cout<<" RRRA: Most energetic DetId:"<<std::endl;
389 // for( std::set<DetId>::const_iterator itr=outset.begin(); itr!=outset.end(); itr++) {
390 // GlobalPoint point = getPosition(*itr);
391 // std::cout << "DetId: " <<itr->rawId() <<" (eta,phi): " << point.eta() << "," << point.phi()<<std::endl;
392 // }
393 // }
394 
395  return outset;
396 }
virtual void check_setup()
std::vector< CaloTower >::const_iterator const_iterator
Definition: DetId.h:20
std::set< DetId > HDetIdAssociator::getMaxEDetId ( const std::set< DetId > &  inset,
edm::Handle< HBHERecHitCollection recHits 
)
virtual

Definition at line 399 of file DetIdAssociator.cc.

References check_setup().

401 {
402 // returns the most energetic tower in the NxN box - from RecHits (Michal)
403  check_setup();
404  std::set<DetId> outset;
405  std::set<DetId>::const_iterator id_max = inset.begin();
406  double Ehadmax=0;
407 
408  for(std::set<DetId>::const_iterator id_iter = inset.begin(); id_iter != inset.end(); id_iter++) {
409  DetId id(*id_iter);
410 // GlobalPoint point = getPosition(*id_iter);
411 // int ieta = iEta(point);
412 // int iphi = iPhi(point);
413  HBHERecHitCollection::const_iterator hit = (*recHits).find(id);
414  if(hit != (*recHits).end() && hit->energy()>Ehadmax) {
415  id_max = id_iter;
416  Ehadmax = hit->energy();
417  }
418  }
419 
420  if (Ehadmax > 0) outset.insert(*id_max);
421 
422 // if (outset.size() > 0) {
423 // std::cout<<" RRRA: Most energetic DetId:"<<std::endl;
424 // for( std::set<DetId>::const_iterator itr=outset.begin(); itr!=outset.end(); itr++) {
425 // GlobalPoint point = getPosition(*itr);
426 // std::cout << "DetId: " <<itr->rawId() <<" (eta,phi): " << point.eta() << "," << point.phi()<<std::endl;
427 // }
428 // }
429 
430  return outset;
431 }
virtual void check_setup()
std::vector< T >::const_iterator const_iterator
Definition: DetId.h:20
virtual GlobalPoint HDetIdAssociator::getPosition ( const DetId )
protectedpure virtual

Implemented in HCaloDetIdAssociator.

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

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

Definition at line 26 of file DetIdAssociator.cc.

References abs, check_setup(), 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().

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

Definition at line 198 of file DetIdAssociator.cc.

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

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

199 {
200 // unequal bin sizes for endcap, following HCAL geometry
201  int iEta1 = int(point.eta()/etaBinSize_ + nEta_/2);
202  if (point.eta()>1.827 && point.eta()<=1.830) return iEta1-1;
203  else if (point.eta()>1.914 && point.eta()<=1.930) return iEta1-1;
204  else if (point.eta()>2.001 && point.eta()<=2.043) return iEta1-1;
205  else if (point.eta()>2.088 && point.eta()<=2.172) return iEta1-1;
206  else if (point.eta()>2.175 && point.eta()<=2.262) return iEta1-1;
207  else if (point.eta()>2.262 && point.eta()<=2.332) return iEta1-2;
208  else if (point.eta()>2.332 && point.eta()<=2.349) return iEta1-1;
209  else if (point.eta()>2.349 && point.eta()<=2.436) return iEta1-2;
210  else if (point.eta()>2.436 && point.eta()<=2.500) return iEta1-3;
211  else if (point.eta()>2.500 && point.eta()<=2.523) return iEta1-2;
212  else if (point.eta()>2.523 && point.eta()<=2.610) return iEta1-3;
213  else if (point.eta()>2.610 && point.eta()<=2.650) return iEta1-4;
214  else if (point.eta()>2.650 && point.eta()<=2.697) return iEta1-3;
215  else if (point.eta()>2.697 && point.eta()<=2.784) return iEta1-4;
216  else if (point.eta()>2.784 && point.eta()<=2.868) return iEta1-5;
217  else if (point.eta()>2.868 && point.eta()<=2.871) return iEta1-4;
218  else if (point.eta()>2.871 && point.eta()<=2.958) return iEta1-5;
219  else if (point.eta()>2.958) return iEta1-6;
220  else if (point.eta()<-1.827 && point.eta()>=-1.830) return iEta1+1;
221  else if (point.eta()<-1.914 && point.eta()>=-1.930) return iEta1+1;
222  else if (point.eta()<-2.001 && point.eta()>=-2.043) return iEta1+1;
223  else if (point.eta()<-2.088 && point.eta()>=-2.172) return iEta1+1;
224  else if (point.eta()<-2.175 && point.eta()>=-2.262) return iEta1+1;
225  else if (point.eta()<-2.262 && point.eta()>=-2.332) return iEta1+2;
226  else if (point.eta()<-2.332 && point.eta()>=-2.349) return iEta1+1;
227  else if (point.eta()<-2.349 && point.eta()>=-2.436) return iEta1+2;
228  else if (point.eta()<-2.436 && point.eta()>=-2.500) return iEta1+3;
229  else if (point.eta()<-2.500 && point.eta()>=-2.523) return iEta1+2;
230  else if (point.eta()<-2.523 && point.eta()>=-2.610) return iEta1+3;
231  else if (point.eta()<-2.610 && point.eta()>=-2.650) return iEta1+4;
232  else if (point.eta()<-2.650 && point.eta()>=-2.697) return iEta1+3;
233  else if (point.eta()<-2.697 && point.eta()>=-2.784) return iEta1+4;
234  else if (point.eta()<-2.784 && point.eta()>=-2.868) return iEta1+5;
235  else if (point.eta()<-2.868 && point.eta()>=-2.871) return iEta1+4;
236  else if (point.eta()<-2.871 && point.eta()>=-2.958) return iEta1+5;
237  else if (point.eta()<-2.349) return iEta1+6;
238  else return iEta1;
239 }
const double etaBinSize_
T eta() const
Definition: PV3DBase.h:76
virtual bool HDetIdAssociator::insideElement ( const GlobalPoint ,
const DetId  
)
protectedpure virtual

Implemented in HCaloDetIdAssociator.

Referenced by getCrossedDetIds().

int HDetIdAssociator::iPhi ( const GlobalPoint point)
virtual

Definition at line 242 of file DetIdAssociator.cc.

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

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

243 {
244  double pi=4*atan(1.);
245  int iPhi1 = int((double(point.phi())+pi)/(2*pi)*nPhi_);
246  return iPhi1;
247 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
double pi
virtual bool HDetIdAssociator::nearElement ( const GlobalPoint point,
const DetId id,
const double  distance 
)
inlineprotectedvirtual

Definition at line 84 of file DetIdAssociator.h.

References PV3DBase< T, PVType, FrameType >::eta(), getPosition(), PV3DBase< T, PVType, FrameType >::phi(), funct::pow(), and mathSSE::sqrt().

Referenced by getDetIdsInACone().

85  {
86  GlobalPoint center = getPosition(id);
87  return sqrt(pow(point.eta()-center.eta(),2)+pow(point.phi()-center.phi(),2)) < distance;
88  };
virtual GlobalPoint getPosition(const DetId &)=0
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T sqrt(T t)
Definition: SSEVec.h:48
T eta() const
Definition: PV3DBase.h:76
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
virtual void HDetIdAssociator::setPropagator ( Propagator ptr)
inlinevirtual

Definition at line 67 of file DetIdAssociator.h.

References ivProp_.

67 { ivProp_ = ptr; };
Propagator * ivProp_

Member Data Documentation

const double HDetIdAssociator::etaBinSize_
protected

Definition at line 93 of file DetIdAssociator.h.

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

Propagator* HDetIdAssociator::ivProp_
protected

Definition at line 94 of file DetIdAssociator.h.

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

const int HDetIdAssociator::nEta_
protected
const int HDetIdAssociator::nPhi_
protected
std::vector<std::vector<std::set<DetId> > >* HDetIdAssociator::theMap_
protected

Definition at line 88 of file DetIdAssociator.h.

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