CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TIDRing.cc
Go to the documentation of this file.
1 #include "TIDRing.h"
2 
4 
12 
13 #include "LayerCrossingSide.h"
14 #include "DetGroupMerger.h"
16 
17 #include "TkDetUtil.h"
19 #include <boost/function.hpp>
20 
21 using namespace std;
22 
24 
25 TIDRing::TIDRing(std::vector<const GeomDet*>& innerDets,
26  std::vector<const GeomDet*>& outerDets):
28  theFrontDets(innerDets.begin(),innerDets.end()),
29  theBackDets(outerDets.begin(),outerDets.end())
30 {
31  theDets.assign(theFrontDets.begin(),theFrontDets.end());
32  theDets.insert(theDets.end(),theBackDets.begin(),theBackDets.end());
33 
34 
35  // the dets should be already phi-ordered. TO BE CHECKED
36  //sort( theFrontDets.begin(), theFrontDets.end(), DetLessPhi() );
37  //sort( theBackDets.begin(), theBackDets.end(), DetLessPhi() );
38 
40 
43 
44  theFrontBinFinder = BinFinderType( theFrontDets.front()->surface().position().phi(),
45  theFrontDets.size());
46  theBackBinFinder = BinFinderType( theBackDets.front()->surface().position().phi(),
47  theBackDets.size());
48 
49 
50 
51  LogDebug("TkDetLayers") << "DEBUG INFO for TIDRing" ;
52  for(vector<const GeomDet*>::const_iterator it=theFrontDets.begin();
53  it!=theFrontDets.end(); it++){
54  LogDebug("TkDetLayers") << "frontDet phi,z,r: "
55  << (*it)->surface().position().phi() << " , "
56  << (*it)->surface().position().z() << " , "
57  << (*it)->surface().position().perp() ;
58  }
59 
60  for(vector<const GeomDet*>::const_iterator it=theBackDets.begin();
61  it!=theBackDets.end(); it++){
62  LogDebug("TkDetLayers") << "backDet phi,z,r: "
63  << (*it)->surface().position().phi() << " , "
64  << (*it)->surface().position().z() << " , "
65  << (*it)->surface().position().perp() ;
66  }
67 
68 
69 }
70 
72 
73 }
74 
75 const vector<const GeometricSearchDet*>&
77 {
78  throw DetLayerException("TIDRing doesn't have GeometricSearchDet components");
79 }
80 
81 
82 pair<bool, TrajectoryStateOnSurface>
84  const MeasurementEstimator&) const{
85  edm::LogError("TkDetLayers") << "temporary dummy implementation of TIDRing::compatible()!!" ;
86  return pair<bool,TrajectoryStateOnSurface>();
87 }
88 
89 
90 
91 void
93  const Propagator& prop,
94  const MeasurementEstimator& est,
95  std::vector<DetGroup>& result) const
96 {
97  SubLayerCrossings crossings;
98  crossings = computeCrossings( tsos, prop.propagationDirection());
99  if(! crossings.isValid()) return;
100 
101  std::vector<DetGroup> closestResult;
102  addClosest( tsos, prop, est, crossings.closest(), closestResult);
103  if (closestResult.empty()) return;
104 
105  DetGroupElement closestGel( closestResult.front().front());
106  float phiWindow = tkDetUtil::computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
107  searchNeighbors( tsos, prop, est, crossings.closest(), phiWindow,
108  closestResult, false);
109 
110  vector<DetGroup> nextResult;
111  searchNeighbors( tsos, prop, est, crossings.other(), phiWindow,
112  nextResult, true);
113 
114  int crossingSide = LayerCrossingSide().endcapSide( closestGel.trajectoryState(), prop);
115  DetGroupMerger::orderAndMergeTwoLevels( std::move(closestResult), std::move(nextResult), result,
116  crossings.closestIndex(), crossingSide);
117 }
118 
119 // indentical in CompositeTECWedge
122  PropagationDirection propDir) const
123 {
124 
125  HelixPlaneCrossing::PositionType startPos( startingState.globalPosition() );
126  HelixPlaneCrossing::DirectionType startDir( startingState.globalMomentum() );
127 
128  auto rho = startingState.transverseCurvature();
129 
130  HelixForwardPlaneCrossing crossing(startPos,startDir,rho,propDir);
131 
132  pair<bool,double> frontPath = crossing.pathLength( *theFrontDisk);
133  if (!frontPath.first) return SubLayerCrossings();
134 
135  pair<bool,double> backPath = crossing.pathLength( *theBackDisk);
136  if (!backPath.first) return SubLayerCrossings();
137 
138  GlobalPoint gFrontPoint(crossing.position(frontPath.second));
139  GlobalPoint gBackPoint( crossing.position(backPath.second));
140 
141  int frontIndex = theFrontBinFinder.binIndex(gFrontPoint.barePhi());
142  SubLayerCrossing frontSLC( 0, frontIndex, gFrontPoint);
143 
144  int backIndex = theBackBinFinder.binIndex(gBackPoint.barePhi());
145  SubLayerCrossing backSLC( 1, backIndex, gBackPoint);
146 
147 
148  // 0ss: frontDisk has index=0, backDisk has index=1
149  float frontDist = std::abs(Geom::deltaPhi( gFrontPoint.barePhi(),
150  theFrontDets[frontIndex]->surface().phi()));
151  float backDist = std::abs(Geom::deltaPhi( gBackPoint.barePhi(),
152  theBackDets[backIndex]->surface().phi()));
153 
154 
155  if (frontDist < backDist) {
156  return SubLayerCrossings( frontSLC, backSLC, 0);
157  }
158  else {
159  return SubLayerCrossings( backSLC, frontSLC, 1);
160  }
161 }
162 
164  const Propagator& prop,
165  const MeasurementEstimator& est,
166  const SubLayerCrossing& crossing,
167  vector<DetGroup>& result) const
168 {
169  const vector<const GeomDet*>& sub( subLayer( crossing.subLayerIndex()));
170  const GeomDet* det(sub[crossing.closestDetIndex()]);
171  return CompatibleDetToGroupAdder::add( *det, tsos, prop, est, result);
172 }
173 
174 
175 
177  const Propagator& prop,
178  const MeasurementEstimator& est,
179  const SubLayerCrossing& crossing,
180  float window,
181  vector<DetGroup>& result,
182  bool checkClosest) const
183 {
184  GlobalPoint gCrossingPos = crossing.position();
185 
186  const vector<const GeomDet*>& sLayer( subLayer( crossing.subLayerIndex()));
187 
188  int closestIndex = crossing.closestDetIndex();
189  int negStartIndex = closestIndex-1;
190  int posStartIndex = closestIndex+1;
191 
192  if (checkClosest) { // must decide if the closest is on the neg or pos side
193  if ( Geom::phiLess( gCrossingPos.barePhi(), sLayer[closestIndex]->surface().phi())) {
194  posStartIndex = closestIndex;
195  }
196  else {
197  negStartIndex = closestIndex;
198  }
199  }
200 
201  const BinFinderType& binFinder = (crossing.subLayerIndex()==0 ? theFrontBinFinder : theBackBinFinder);
202 
203  typedef CompatibleDetToGroupAdder Adder;
204  int half = sLayer.size()/2; // to check if dets are called twice....
205  for (int idet=negStartIndex; idet >= negStartIndex - half; idet--) {
206  const GeomDet & neighborDet = *sLayer[binFinder.binIndex(idet)];
207  if (!tkDetUtil::overlapInPhi( gCrossingPos, neighborDet, window)) break;
208  if (!Adder::add( neighborDet, tsos, prop, est, result)) break;
209  // maybe also add shallow crossing angle test here???
210  }
211  for (int idet=posStartIndex; idet < posStartIndex + half; idet++) {
212  const GeomDet & neighborDet = *sLayer[binFinder.binIndex(idet)];
213  if (!tkDetUtil::overlapInPhi( gCrossingPos, neighborDet, window)) break;
214  if (!Adder::add( neighborDet, tsos, prop, est, result)) break;
215  // maybe also add shallow crossing angle test here???
216  }
217 }
#define LogDebug(id)
PeriodicBinFinderInPhi< float > BinFinderType
Definition: TIDRing.h:75
Common base class.
void searchNeighbors(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, float window, std::vector< DetGroup > &result, bool checkClosest) const __attribute__((hot))
Definition: TIDRing.cc:176
std::vector< const GeomDet * > theDets
Definition: TIDRing.h:67
def window
Definition: svgfig.py:642
SubLayerCrossings computeCrossings(const TrajectoryStateOnSurface &tsos, PropagationDirection propDir) const __attribute__((hot))
Definition: TIDRing.cc:121
virtual PositionType position(double s) const
int closestIndex() const
int closestDetIndex() const
virtual std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &, const Propagator &, const MeasurementEstimator &) const
Definition: TIDRing.cc:83
GlobalPoint globalPosition() const
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:151
PropagationDirection
BinFinderType theFrontBinFinder
Definition: TIDRing.h:77
bool overlapInPhi(float phi, const GeomDet &det, float phiWindow)
Definition: TkDetUtil.h:19
virtual int binIndex(T phi) const
returns an index in the valid range for the bin that contains phi
bool addClosest(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, std::vector< DetGroup > &result) const __attribute__((hot))
Definition: TIDRing.cc:163
tuple result
Definition: mps_fire.py:84
const GlobalPoint & position() const
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
Definition: TkDetUtil.cc:9
T barePhi() const
Definition: PV3DBase.h:68
virtual const std::vector< const GeometricSearchDet * > & components() const __attribute__((cold))
Returns basic components, if any.
Definition: TIDRing.cc:76
std::vector< const GeomDet * > theFrontDets
Definition: TIDRing.h:68
int subLayerIndex() const
def move
Definition: eostools.py:510
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static int endcapSide(const TrajectoryStateOnSurface &startingState, const Propagator &prop)
ReferenceCountingPointer< BoundDisk > theBackDisk
Definition: TIDRing.h:73
#define end
Definition: vmac.h:37
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:23
const SubLayerCrossing & other() const
static bool add(const GeometricSearchDet &det, const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) __attribute__((hot))
ReferenceCountingPointer< BoundDisk > theFrontDisk
Definition: TIDRing.h:72
ReferenceCountingPointer< BoundDisk > theDisk
Definition: TIDRing.h:71
BinFinderType theBackBinFinder
Definition: TIDRing.h:78
const SubLayerCrossing & closest() const
#define begin
Definition: vmac.h:30
GlobalVector globalMomentum() const
virtual std::pair< bool, double > pathLength(const Plane &plane)
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
static void orderAndMergeTwoLevels(std::vector< DetGroup > &&one, std::vector< DetGroup > &&two, std::vector< DetGroup > &result, int firstIndex, int firstCrossed)
const std::vector< const GeomDet * > & subLayer(int ind) const
Definition: TIDRing.h:61
~TIDRing()
Definition: TIDRing.cc:71
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const __attribute__((hot))
Definition: TIDRing.cc:92
TIDRing(std::vector< const GeomDet * > &innerDets, std::vector< const GeomDet * > &outerDets)
Definition: TIDRing.cc:25
std::vector< const GeomDet * > theBackDets
Definition: TIDRing.h:69