test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CompositeTECWedge.cc
Go to the documentation of this file.
1 #include "CompositeTECWedge.h"
2 
4 
6 #include "LayerCrossingSide.h"
7 #include "DetGroupMerger.h"
9 
11 
15 
16 #include "TkDetUtil.h"
18 #include <boost/function.hpp>
19 
20 using namespace std;
21 
23 
24 // --------- Temporary solution. DetSorting.h has to be used.
25 namespace {
26  class DetPhiLess {
27  public:
28  bool operator()(const GeomDet* a,const GeomDet* b)
29  {
30  return Geom::phiLess(a->surface(), b->surface());
31  }
32  };
33 }
34 // ---------------------
35 
36 CompositeTECWedge::CompositeTECWedge(vector<const GeomDet*>& innerDets,
37  vector<const GeomDet*>& outerDets):
38  theFrontDets(innerDets.begin(),innerDets.end()), theBackDets(outerDets.begin(),outerDets.end())
39 {
40  theDets.assign(theFrontDets.begin(),theFrontDets.end());
41  theDets.insert(theDets.end(),theBackDets.begin(),theBackDets.end());
42 
43 
44  //
45  std::sort( theFrontDets.begin(), theFrontDets.end(), DetPhiLess() );
46  std::sort( theBackDets.begin(), theBackDets.end(), DetPhiLess() );
47 
51 
52  //--------- DEBUG INFO --------------
53  LogDebug("TkDetLayers") << "DEBUG INFO for CompositeTECWedge" << "\n"
54  << "TECWedge z, perp,innerRadius,outerR: "
55  << this->position().z() << " , "
56  << this->position().perp() << " , "
57  << theDiskSector->innerRadius() << " , "
58  << theDiskSector->outerRadius() ;
59 
60 
61  for(vector<const GeomDet*>::const_iterator it=theFrontDets.begin();
62  it!=theFrontDets.end(); it++){
63  LogDebug("TkDetLayers") << "frontDet phi,z,r: "
64  << (*it)->surface().position().phi() << " , "
65  << (*it)->surface().position().z() << " , "
66  << (*it)->surface().position().perp();
67  }
68 
69  for(vector<const GeomDet*>::const_iterator it=theBackDets.begin();
70  it!=theBackDets.end(); it++){
71  LogDebug("TkDetLayers") << "backDet phi,z,r: "
72  << (*it)->surface().phi() << " , "
73  << (*it)->surface().position().z() << " , "
74  << (*it)->surface().position().perp() ;
75  }
76  //-----------------------------------
77 
78 
79 }
80 
82 
83 }
84 
85 
86 const vector<const GeometricSearchDet*>&
88  throw DetLayerException("CompositeTECWedge doesn't have GeometricSearchDet components");
89 }
90 
91 
92 pair<bool, TrajectoryStateOnSurface>
94  const MeasurementEstimator&) const{
95  edm::LogError("TkDetLayers") << "temporary dummy implementation of CompositeTECWedge::compatible()!!" ;
96  return pair<bool,TrajectoryStateOnSurface>();
97 }
98 
99 
100 void
102  const Propagator& prop,
103  const MeasurementEstimator& est,
104  std::vector<DetGroup> & result) const{
105 
106  SubLayerCrossings crossings = computeCrossings( tsos, prop.propagationDirection());
107  if(! crossings.isValid()) return;
108 
109  std::vector<DetGroup> closestResult;
110  addClosest( tsos, prop, est, crossings.closest(), closestResult);
111 
112  LogDebug("TkDetLayers")
113  << "in CompositeTECWedge::groupedCompatibleDets,closestResult.size(): "
114  << closestResult.size() ;
115 
116  if (closestResult.empty()) return;
117 
118  DetGroupElement closestGel( closestResult.front().front());
119  auto window = tkDetUtil::computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
120 
121  searchNeighbors( tsos, prop, est, crossings.closest(), window,
122  closestResult, false);
123 
124  std::vector<DetGroup> nextResult;
125  searchNeighbors( tsos, prop, est, crossings.other(), window,
126  nextResult, true);
127 
128  int crossingSide = LayerCrossingSide().endcapSide( closestGel.trajectoryState(), prop);
129  DetGroupMerger::orderAndMergeTwoLevels( std::move(closestResult), std::move(nextResult), result,
130  crossings.closestIndex(), crossingSide);
131 }
132 
133 
134 
135 // private methods for the implementation of groupedCompatibleDets()
136 
137 
138 
141  PropagationDirection propDir) const
142 {
143  HelixPlaneCrossing::PositionType startPos( startingState.globalPosition() );
144  HelixPlaneCrossing::DirectionType startDir( startingState.globalMomentum() );
145 
146  auto rho = startingState.transverseCurvature();
147 
148  HelixForwardPlaneCrossing crossing( startPos, startDir, rho, propDir);
149 
150  pair<bool,double> frontPath = crossing.pathLength( *theFrontSector);
151  if (!frontPath.first) return SubLayerCrossings();
152 
153  pair<bool,double> backPath = crossing.pathLength( *theBackSector);
154  if (!backPath.first) return SubLayerCrossings();
155 
156  GlobalPoint gFrontPoint( crossing.position(frontPath.second));
157  GlobalPoint gBackPoint( crossing.position(backPath.second));
158 
159 
160  LogDebug("TkDetLayers")
161  << "in TECWedge,front crossing r,z,phi: ("
162  << gFrontPoint.perp() << ","
163  << gFrontPoint.z() << ","
164  << gFrontPoint.phi() << ")" ;
165 
166  LogDebug("TkDetLayers")
167  << "in TECWedge,back crossing r,z,phi: ("
168  << gBackPoint.perp() << ","
169  << gBackPoint.z() << ","
170  << gBackPoint.phi() << ")" << endl;
171 
172 
173  int frontIndex = findClosestDet(gFrontPoint,0);
174  SubLayerCrossing frontSLC( 0, frontIndex, gFrontPoint);
175 
176  int backIndex = findClosestDet(gBackPoint,1);
177  SubLayerCrossing backSLC( 1, backIndex, gBackPoint);
178 
179 
180  auto frontDist = std::abs(Geom::deltaPhi( gFrontPoint.barePhi(),
181  theFrontDets[frontIndex]->surface().phi()));
182  /*
183  float frontDist = theFrontDets[frontIndex]->surface().phi() - gFrontPoint.phi();
184  frontDist *= Geom::phiLess( theFrontDets[frontIndex]->surface().phi(),gFrontPoint.barePhi()) ? -1. : 1.;
185  if (frontDist < 0.) { frontDist += 2.*Geom::pi();}
186  */
187  auto backDist = std::abs(Geom::deltaPhi( gBackPoint.barePhi(),
188  theBackDets[backIndex]->surface().phi()) );
189  /*
190  float backDist = theBackDets[backIndex]->surface().phi() - gBackPoint.phi();
191  backDist *= Geom::phiLess( theBackDets[backIndex]->surface().phi(),gBackPoint.barePhi()) ? -1. : 1.;
192  if ( backDist < 0.) { backDist += 2.*Geom::pi();}
193  */
194 
195  if (frontDist < backDist) {
196  return SubLayerCrossings( frontSLC, backSLC, 0);
197  }
198  else {
199  return SubLayerCrossings( backSLC, frontSLC, 1);
200  }
201 }
202 
203 
205  const Propagator& prop,
206  const MeasurementEstimator& est,
207  const SubLayerCrossing& crossing,
208  vector<DetGroup>& result) const
209 {
210  const vector<const GeomDet*>& sWedge( subWedge( crossing.subLayerIndex()));
211 
212  LogDebug("TkDetLayers")
213  << "in CompositeTECWedge,adding GeomDet at r,z,phi: ("
214  << sWedge[crossing.closestDetIndex()]->position().perp() << ","
215  << sWedge[crossing.closestDetIndex()]->position().z() << ","
216  << sWedge[crossing.closestDetIndex()]->position().phi() << ")" ;
217 
218  return CompatibleDetToGroupAdder().add( *sWedge[crossing.closestDetIndex()],
219  tsos, prop, est, result);
220 }
221 
222 
224  const Propagator& prop,
225  const MeasurementEstimator& est,
226  const SubLayerCrossing& crossing,
227  float window,
228  vector<DetGroup>& result,
229  bool checkClosest) const
230 {
231  GlobalPoint gCrossingPos = crossing.position();
232 
233  const vector<const GeomDet*>& sWedge( subWedge( crossing.subLayerIndex()));
234 
235  int closestIndex = crossing.closestDetIndex();
236  int negStartIndex = closestIndex-1;
237  int posStartIndex = closestIndex+1;
238 
239  if (checkClosest) { // must decide if the closest is on the neg or pos side
240  if ( Geom::phiLess(gCrossingPos.barePhi(), sWedge[closestIndex]->surface().phi()) ) {
241  posStartIndex = closestIndex;
242  }
243  else {
244  negStartIndex = closestIndex;
245  }
246  }
247 
248  typedef CompatibleDetToGroupAdder Adder;
249  for (int idet=negStartIndex; idet >= 0; idet--) {
250  //if(idet <0 || idet>=sWedge.size()) {edm::LogInfo(TkDetLayers) << "==== warning! gone out vector bounds.idet: " << idet ;break;}
251  if (!tkDetUtil::overlapInPhi( gCrossingPos, *sWedge[idet], window)) break;
252  if (!Adder::add( *sWedge[idet], tsos, prop, est, result)) break;
253  }
254  for (int idet=posStartIndex; idet < static_cast<int>(sWedge.size()); idet++) {
255  //if(idet <0 || idet>=sWedge.size()) {edm::LogInfo(TkDetLayers) << "==== warning! gone out vector bounds.idet: " << idet ;break;}
256  if (!tkDetUtil::overlapInPhi( gCrossingPos, *sWedge[idet], window)) break;
257  if (!Adder::add( *sWedge[idet], tsos, prop, est, result)) break;
258  }
259 }
260 
261 
262 
263 int
264 CompositeTECWedge::findClosestDet( const GlobalPoint& startPos,int sectorId) const
265 {
266  vector<const GeomDet*> const & myDets = sectorId==0 ? theFrontDets : theBackDets;
267 
268  int close = 0;
269  auto closeDist = std::abs( (myDets.front()->toLocal(startPos)).x());
270  for (unsigned int i = 1; i < myDets.size(); i++ ) {
271  auto dist = std::abs((myDets[i]->toLocal(startPos)).x());
272  if ( dist < closeDist ) {
273  close = i;
274  closeDist = dist;
275  }
276  }
277  return close;
278 }
#define LogDebug(id)
Common base class.
int i
Definition: DBlmapReader.cc:9
def window
Definition: svgfig.py:642
virtual const std::vector< const GeometricSearchDet * > & components() const __attribute__((cold))
Returns basic components, if any.
CompositeTECWedge(std::vector< const GeomDet * > &innerDets, std::vector< const GeomDet * > &outerDets) __attribute__((cold))
T perp() const
Definition: PV3DBase.h:72
virtual PositionType position(double s) const
std::vector< const GeomDet * > theDets
int closestIndex() const
int closestDetIndex() const
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
SubLayerCrossings computeCrossings(const TrajectoryStateOnSurface &tsos, PropagationDirection propDir) const __attribute__((hot))
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
bool overlapInPhi(float phi, const GeomDet &det, float phiWindow)
Definition: TkDetUtil.h:19
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
ReferenceCountingPointer< BoundDiskSector > theDiskSector
Definition: TECWedge.h:28
virtual std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &ts, const Propagator &, const MeasurementEstimator &) const __attribute__((cold))
tuple result
Definition: mps_fire.py:84
const GlobalPoint & position() const
std::vector< const GeomDet * > theFrontDets
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
Definition: TkDetUtil.cc:9
T barePhi() const
Definition: PV3DBase.h:68
int findClosestDet(const GlobalPoint &startPos, int sectorId) const
const std::vector< const GeomDet * > & subWedge(int ind) const
std::vector< const GeomDet * > theBackDets
int subLayerIndex() const
T z() const
Definition: PV3DBase.h:64
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)
#define end
Definition: vmac.h:37
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
~CompositeTECWedge() __attribute__((cold))
ReferenceCountingPointer< BoundDiskSector > theBackSector
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))
virtual void groupedCompatibleDetsV(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const __attribute__((hot))
virtual const Surface::PositionType & position() const
Returns position of the surface.
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))
double b
Definition: hdecay.h:120
const SubLayerCrossing & closest() const
#define begin
Definition: vmac.h:30
GlobalVector globalMomentum() const
bool addClosest(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, std::vector< DetGroup > &result) const __attribute__((hot))
double a
Definition: hdecay.h:121
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)
ReferenceCountingPointer< BoundDiskSector > theFrontSector