CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PixelForwardLayer.cc
Go to the documentation of this file.
2 
4 
7 
13 
14 
18 
19 using namespace std;
20 
22 
23 PixelForwardLayer::PixelForwardLayer(vector<const PixelBlade*>& blades):
24  theComps(blades.begin(),blades.end())
25 {
26  for(vector<const GeometricSearchDet*>::const_iterator it=theComps.begin();
27  it!=theComps.end();it++){
28  theBasicComps.insert(theBasicComps.end(),
29  (**it).basicComponents().begin(),
30  (**it).basicComponents().end());
31  }
32 
33  //They should be already phi-ordered. TO BE CHECKED!!
34  //sort( theBlades.begin(), theBlades.end(), PhiLess());
36 
37  //Is a "periodic" binFinderInPhi enough?. TO BE CHECKED!!
38  theBinFinder = BinFinderType( theComps.front()->surface().position().phi(),
39  theComps.size());
40 
41  //--------- DEBUG INFO --------------
42  LogDebug("TkDetLayers") << "DEBUG INFO for PixelForwardLayer" << "\n"
43  << "PixelForwardLayer.surfcace.phi(): "
44  << this->surface().position().phi() << "\n"
45  << "PixelForwardLayer.surfcace.z(): "
46  << this->surface().position().z() << "\n"
47  << "PixelForwardLayer.surfcace.innerR(): "
48  << this->specificSurface().innerRadius() << "\n"
49  << "PixelForwardLayer.surfcace.outerR(): "
50  << this->specificSurface().outerRadius() ;
51 
52  for(vector<const GeometricSearchDet*>::const_iterator it=theComps.begin();
53  it!=theComps.end(); it++){
54  LogDebug("TkDetLayers") << "blades phi,z,r: "
55  << (*it)->surface().position().phi() << " , "
56  << (*it)->surface().position().z() << " , "
57  << (*it)->surface().position().perp();
58  }
59  //-----------------------------------
60 
61 
62 }
63 
65  vector<const GeometricSearchDet*>::const_iterator i;
66  for (i=theComps.begin(); i!=theComps.end(); i++) {
67  delete *i;
68  }
69 }
70 
71 void
73  const Propagator& prop,
74  const MeasurementEstimator& est,
75  std::vector<DetGroup> & result) const {
76  vector<DetGroup> closestResult;
77  SubTurbineCrossings crossings;
78 
79  crossings = computeCrossings( tsos, prop.propagationDirection());
80  if (!crossings.isValid){
81  //edm::LogInfo("TkDetLayers") << "computeCrossings returns invalid in PixelForwardLayer::groupedCompatibleDets:";
82  return;
83  }
84 
85  typedef CompatibleDetToGroupAdder Adder;
87  tsos, prop, est, closestResult);
88 
89  if(closestResult.empty()){
91  tsos, prop, est, result);
92  return;
93  }
94 
95  DetGroupElement closestGel( closestResult.front().front());
96  float window = computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
97 
98  //float detWidth = closestGel.det()->surface().bounds().width();
99  //if (crossings.nextDistance < detWidth + window) {
100  vector<DetGroup> nextResult;
102  tsos, prop, est, nextResult)) {
103  int crossingSide = LayerCrossingSide().endcapSide( tsos, prop);
104  int theHelicity = computeHelicity(theComps[theBinFinder.binIndex(crossings.closestIndex)],
105  theComps[theBinFinder.binIndex(crossings.nextIndex)] );
106  DetGroupMerger::orderAndMergeTwoLevels( closestResult, nextResult, result,
107  theHelicity, crossingSide);
108  }
109  else {
110  result.swap(closestResult);
111  }
112 
113  /*
114  }
115  else {
116  result.swap(closestResult);
117  }
118  */
119 
120  // --- THIS lines may speed up the reconstruction. But it reduces slightly the efficiency.
121  // only loop over neighbors (other than closest and next) if window is BIG
122  //if (window > 0.5*detWidth) {
123  searchNeighbors( tsos, prop, est, crossings, window, result);
124  //}
125 }
126 
127 
128 
129 void
131  const Propagator& prop,
132  const MeasurementEstimator& est,
133  const SubTurbineCrossings& crossings,
134  float window,
135  vector<DetGroup>& result) const
136 {
137  typedef CompatibleDetToGroupAdder Adder;
138  int crossingSide = LayerCrossingSide().endcapSide( tsos, prop);
139  typedef DetGroupMerger Merger;
140 
141  int negStart = min( crossings.closestIndex, crossings.nextIndex) - 1;
142  int posStart = max( crossings.closestIndex, crossings.nextIndex) + 1;
143 
144  int quarter = theComps.size()/4;
145 
146  vector<DetGroup> tmp;
147  vector<DetGroup> newResult;
148  for (int idet=negStart; idet >= negStart - quarter+1; idet--) {
149  tmp.clear();
150  newResult.clear();
151  const GeometricSearchDet* neighbor = theComps[theBinFinder.binIndex(idet)];
152  // if (!overlap( gCrossingPos, *neighbor, window)) break; // mybe not needed?
153  // maybe also add shallow crossing angle test here???
154  if (!Adder::add( *neighbor, tsos, prop, est, tmp)) break;
155  int theHelicity = computeHelicity(theComps[theBinFinder.binIndex(idet)],
156  theComps[theBinFinder.binIndex(idet+1)] );
157  Merger::orderAndMergeTwoLevels( tmp, result, newResult, theHelicity, crossingSide);
158  result.swap(newResult);
159  }
160  for (int idet=posStart; idet < posStart + quarter-1; idet++) {
161  tmp.clear();
162  newResult.clear();
163  const GeometricSearchDet* neighbor = theComps[theBinFinder.binIndex(idet)];
164  // if (!overlap( gCrossingPos, *neighbor, window)) break; // mybe not needed?
165  // maybe also add shallow crossing angle test here???
166  if (!Adder::add( *neighbor, tsos, prop, est, tmp)) break;
167  int theHelicity = computeHelicity(theComps[theBinFinder.binIndex(idet-1)],
168  theComps[theBinFinder.binIndex(idet)] );
169  Merger::orderAndMergeTwoLevels( result, tmp, newResult, theHelicity, crossingSide);
170  result.swap(newResult);
171  }
172 }
173 
174 int
176 {
177  if( fabs(firstBlade->position().z()) < fabs(secondBlade->position().z()) ) return 0;
178  return 1;
179 }
180 
183  PropagationDirection propDir) const
184 {
186 
187  HelixPlaneCrossing::PositionType startPos( startingState.globalPosition());
188  HelixPlaneCrossing::DirectionType startDir( startingState.globalMomentum());
189  float rho( startingState.transverseCurvature());
190 
191  HelixArbitraryPlaneCrossing turbineCrossing( startPos, startDir, rho,
192  propDir);
193 
194  pair<bool,double> thePath = turbineCrossing.pathLength( specificSurface() );
195 
196  if (!thePath.first) {
197  //edm::LogInfo("TkDetLayers") << "ERROR in PixelForwardLayer: disk not crossed by track" ;
198  return SubTurbineCrossings();
199  }
200 
201  HelixPlaneCrossing::PositionType turbinePoint( turbineCrossing.position(thePath.second));
202  HelixPlaneCrossing::DirectionType turbineDir( turbineCrossing.direction(thePath.second));
203  int closestIndex = theBinFinder.binIndex(turbinePoint.phi());
204 
205  const BoundPlane& closestPlane( static_cast<const BoundPlane&>(
206  theComps[closestIndex]->surface()));
207 
208 
209  HelixArbitraryPlaneCrossing2Order theBladeCrossing(turbinePoint, turbineDir, rho);
210 
211  pair<bool,double> theClosestBladePath = theBladeCrossing.pathLength( closestPlane );
212  LocalPoint closestPos = closestPlane.toLocal(GlobalPoint(theBladeCrossing.position(theClosestBladePath.second)) );
213 
214  float closestDist = closestPos.x(); // use fact that local X perp to global Y
215 
216  //int next = turbinePoint.phi() - closestPlane.position().phi() > 0 ? closest+1 : closest-1;
217  int nextIndex = PhiLess()( closestPlane.position().phi(), turbinePoint.phi()) ?
218  closestIndex+1 : closestIndex-1;
219 
220  const BoundPlane& nextPlane( static_cast<const BoundPlane&>(
221  theComps[ theBinFinder.binIndex(nextIndex)]->surface()));
222 
223  pair<bool,double> theNextBladePath = theBladeCrossing.pathLength( nextPlane );
224  LocalPoint nextPos = nextPlane.toLocal(GlobalPoint(theBladeCrossing.position(theNextBladePath.second)) );
225 
226  float nextDist = nextPos.x();
227 
228  if (fabs(closestDist) < fabs(nextDist)) {
229  return SubTurbineCrossings( closestIndex, nextIndex, nextDist);
230  }
231  else {
232  return SubTurbineCrossings( nextIndex, closestIndex, closestDist);
233  }
234 }
235 
236 float
238  const TrajectoryStateOnSurface& tsos,
239  const MeasurementEstimator& est) const
240 {
241  return est.maximalLocalDisplacement(tsos, det->surface()).x();
242 }
243 
244 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
static void orderAndMergeTwoLevels(const std::vector< DetGroup > &one, const std::vector< DetGroup > &two, std::vector< DetGroup > &result, int firstIndex, int firstCrossed)
def window
Definition: svgfig.py:642
virtual BoundDisk * computeSurface()
virtual PropagationDirection propagationDirection() const
Definition: Propagator.h:143
virtual const BoundSurface & surface() const
The surface of the GeometricSearchDet.
void setSurface(BoundDisk *cp)
Definition: DDAxes.h:10
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
virtual std::pair< bool, double > pathLength(const Plane &)
GlobalPoint globalPosition() const
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
#define min(a, b)
Definition: mlp_lapack.h:161
Vector2DBase< float, LocalTag > Local2DVector
PropagationDirection
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const BoundPlane &plane) const
PixelForwardLayer(std::vector< const PixelBlade * > &blades)
virtual int binIndex(T phi) const
returns an index in the valid range for the bin that contains phi
int endcapSide(const TrajectoryStateOnSurface &startingState, const Propagator &prop) const
const T & max(const T &a, const T &b)
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:58
tuple result
Definition: query.py:137
virtual const BoundDisk & specificSurface() const
std::vector< const GeometricSearchDet * > theComps
#define end
Definition: vmac.h:38
virtual PositionType position(double s) const
virtual const Surface::PositionType & position() const
Returns position of the surface.
PeriodicBinFinderInPhi< double > BinFinderType
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
#define begin
Definition: vmac.h:31
GlobalVector globalMomentum() const
float outerRadius() const
The outer radius of the disk.
Definition: BoundDisk.cc:10
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
float innerRadius() const
The inner radius of the disk.
Definition: BoundDisk.cc:6
SubTurbineCrossings computeCrossings(const TrajectoryStateOnSurface &startingState, PropagationDirection propDir) const
void searchNeighbors(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubTurbineCrossings &crossings, float window, std::vector< DetGroup > &result) const
BinFinderType theBinFinder
T x() const
Definition: PV3DBase.h:56
const PositionType & position() const
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
std::vector< const GeomDet * > theBasicComps
int computeHelicity(const GeometricSearchDet *firstBlade, const GeometricSearchDet *secondBlade) const