25 PixelForwardLayerPhase1::PixelForwardLayerPhase1(vector<const PixelBlade*>& blades):
26 theComps(blades.
begin(),blades.
end())
28 for(vector<const GeometricSearchDet*>::const_iterator it=theComps.begin();
29 it!=theComps.end();it++){
30 theBasicComps.insert(theBasicComps.end(),
31 (**it).basicComponents().begin(),
32 (**it).basicComponents().end());
37 setSurface( computeSurface() );
47 float theRmin = (*(theComps.begin()))->surface().position().perp();
48 float theRmax = theRmin;
49 for(vector<const GeometricSearchDet*>::const_iterator it=theComps.begin();
50 it!=theComps.end(); it++){
51 theRmin =
std::min( theRmin, (*it)->surface().position().perp());
52 theRmax =
std::max( theRmax, (*it)->surface().position().perp());
54 float split_inner_outer_radius = 0.5 * (theRmin + theRmax);
56 for(vector<const GeometricSearchDet*>::const_iterator it=theComps.begin();
57 it!=theComps.end();it++){
58 if((**it).surface().position().perp() <= split_inner_outer_radius) ++_num_innerpanels;
60 _num_outerpanels = theComps.size() - _num_innerpanels;
65 theBinFinder_inner = BinFinderType( theComps.front()->surface().position().phi(),
67 theBinFinder_outer = BinFinderType( theComps[_num_innerpanels]->surface().
position().
phi(),
72 PixelForwardLayerPhase1::~PixelForwardLayerPhase1(){
73 vector<const GeometricSearchDet*>::const_iterator
i;
74 for (i=theComps.begin(); i!=theComps.end(); i++) {
83 std::vector<DetGroup> &
result)
const {
84 vector<DetGroup> closestResult_inner;
85 vector<DetGroup> closestResult_outer;
86 vector<DetGroup> nextResult_inner;
87 vector<DetGroup> nextResult_outer;
88 vector<DetGroup> result_inner;
89 vector<DetGroup> result_outer;
90 int frontindex_inner = 0;
91 int frontindex_outer = 0;
92 SubTurbineCrossings crossings_inner;
93 SubTurbineCrossings crossings_outer;
97 if (!crossings_inner.isValid){
101 if (!crossings_outer.isValid){
107 Adder::add( *theComps[theBinFinder_inner.binIndex(crossings_inner.closestIndex)],
108 tsos, prop, est, closestResult_inner);
110 if(closestResult_inner.empty()){
111 Adder::add( *theComps[theBinFinder_inner.binIndex(crossings_inner.nextIndex)],
112 tsos, prop, est, result_inner);
113 frontindex_inner = crossings_inner.nextIndex;
115 if (
Adder::add( *theComps[theBinFinder_inner.binIndex(crossings_inner.nextIndex)],
116 tsos, prop, est, nextResult_inner)) {
118 int theHelicity = computeHelicity(theComps[theBinFinder_inner.binIndex(crossings_inner.closestIndex)],
119 theComps[theBinFinder_inner.binIndex(crossings_inner.nextIndex)] );
121 theHelicity, crossingSide);
122 if (theHelicity == crossingSide) frontindex_inner = crossings_inner.closestIndex;
123 else frontindex_inner = crossings_inner.nextIndex;
125 result_inner.swap(closestResult_inner);
126 frontindex_inner = crossings_inner.closestIndex;
129 if(!closestResult_inner.empty()){
132 searchNeighbors( tsos, prop, est, crossings_inner, window, result_inner,
true);
140 Adder::add( *theComps[(theBinFinder_outer.binIndex(crossings_outer.closestIndex)) + _num_innerpanels],
141 tsos, prop, est, closestResult_outer);
143 if(closestResult_outer.empty()){
144 Adder::add( *theComps[theBinFinder_outer.binIndex(crossings_outer.nextIndex) + _num_innerpanels],
145 tsos, prop, est, result_outer);
146 frontindex_outer = crossings_outer.nextIndex;
148 if (
Adder::add( *theComps[theBinFinder_outer.binIndex(crossings_outer.nextIndex) + _num_innerpanels],
149 tsos, prop, est, nextResult_outer)) {
151 int theHelicity = computeHelicity(theComps[theBinFinder_outer.binIndex(crossings_outer.closestIndex) + _num_innerpanels],
152 theComps[theBinFinder_outer.binIndex(crossings_outer.nextIndex) + _num_innerpanels] );
154 theHelicity, crossingSide);
155 if (theHelicity == crossingSide) frontindex_outer = crossings_outer.closestIndex;
156 else frontindex_outer = crossings_outer.nextIndex;
158 result_outer.swap(closestResult_outer);
159 frontindex_outer = crossings_outer.closestIndex;
162 if(!closestResult_outer.empty()){
164 float window =
computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
165 searchNeighbors( tsos, prop, est, crossings_inner, window, result_outer,
false);
168 if(result_inner.empty() && result_outer.empty() )
return;
169 if(result_inner.empty()) result.swap(result_outer);
170 else if(result_outer.empty()) result.swap(result_inner);
173 int theHelicity = computeHelicity(theComps[theBinFinder_inner.binIndex(frontindex_inner)],
174 theComps[theBinFinder_outer.binIndex(frontindex_outer) + _num_innerpanels] );
176 theHelicity, crossingSide);
186 const SubTurbineCrossings& crossings,
188 vector<DetGroup>& result,
189 bool innerDisk)
const
195 int negStart =
min( crossings.closestIndex, crossings.nextIndex) - 1;
196 int posStart =
max( crossings.closestIndex, crossings.nextIndex) + 1;
198 int quarter = theComps.size()/4;
199 if(innerDisk) quarter = _num_innerpanels/4;
200 else quarter = _num_outerpanels/4;
202 vector<DetGroup>
tmp;
203 vector<DetGroup> newResult;
204 for (
int idet=negStart; idet >= negStart - quarter+1; idet--) {
211 if (!
Adder::add( *neighbor, tsos, prop, est, tmp))
break;
212 int theHelicity = computeHelicity(theComps[theBinFinder_inner.binIndex(idet)],
213 theComps[theBinFinder_inner.binIndex(idet+1)] );
214 Merger::orderAndMergeTwoLevels( std::move(tmp), std::move(result), newResult, theHelicity, crossingSide);
216 const GeometricSearchDet* neighbor = theComps[(theBinFinder_outer.binIndex(idet)) + _num_innerpanels];
219 if (!
Adder::add( *neighbor, tsos, prop, est, tmp))
break;
220 int theHelicity = computeHelicity(theComps[(theBinFinder_outer.binIndex(idet)) + _num_innerpanels],
221 theComps[(theBinFinder_outer.binIndex(idet+1)) + _num_innerpanels] );
222 Merger::orderAndMergeTwoLevels( std::move(tmp), std::move(result), newResult, theHelicity, crossingSide);
224 result.swap(newResult);
226 for (
int idet=posStart; idet < posStart + quarter-1; idet++) {
233 if (!
Adder::add( *neighbor, tsos, prop, est, tmp))
break;
234 int theHelicity = computeHelicity(theComps[theBinFinder_inner.binIndex(idet-1)],
235 theComps[theBinFinder_inner.binIndex(idet)] );
236 Merger::orderAndMergeTwoLevels( std::move(result), std::move(tmp), newResult, theHelicity, crossingSide);
238 const GeometricSearchDet* neighbor = theComps[(theBinFinder_outer.binIndex(idet)) + _num_innerpanels];
241 if (!
Adder::add( *neighbor, tsos, prop, est, tmp))
break;
242 int theHelicity = computeHelicity(theComps[(theBinFinder_outer.binIndex(idet-1)) + _num_innerpanels],
243 theComps[(theBinFinder_outer.binIndex(idet)) + _num_innerpanels] );
244 Merger::orderAndMergeTwoLevels( std::move(result), std::move(tmp), newResult, theHelicity, crossingSide);
246 result.swap(newResult);
257 PixelForwardLayerPhase1::SubTurbineCrossings
267 HelixArbitraryPlaneCrossing turbineCrossing( startPos, startDir,
rho,
270 pair<bool,double> thePath = turbineCrossing.pathLength( specificSurface() );
272 if (!thePath.first) {
274 return SubTurbineCrossings();
279 int closestIndex = 0;
281 closestIndex = theBinFinder_inner.binIndex(turbinePoint.phi());
283 closestIndex = theBinFinder_outer.binIndex(turbinePoint.phi());
285 HelixArbitraryPlaneCrossing2Order theBladeCrossing(turbinePoint, turbineDir,
rho);
287 float closestDist = 0;
290 const Plane& closestPlane( static_cast<const Plane&>(
291 theComps[closestIndex]->surface()));
293 pair<bool,double> theClosestBladePath = theBladeCrossing.pathLength( closestPlane );
294 LocalPoint closestPos = closestPlane.toLocal(
GlobalPoint(theBladeCrossing.position(theClosestBladePath.second)) );
296 closestDist = closestPos.
x();
298 nextIndex =
PhiLess()( closestPlane.position().phi(), turbinePoint.phi()) ?
299 closestIndex+1 : closestIndex-1;
301 const Plane& closestPlane( static_cast<const Plane&>(
302 theComps[closestIndex + _num_innerpanels]->surface()));
304 pair<bool,double> theClosestBladePath = theBladeCrossing.pathLength( closestPlane );
305 LocalPoint closestPos = closestPlane.toLocal(
GlobalPoint(theBladeCrossing.position(theClosestBladePath.second)) );
307 closestDist = closestPos.
x();
309 nextIndex =
PhiLess()( closestPlane.position().phi(), turbinePoint.phi()) ?
310 closestIndex+1 : closestIndex-1;
315 const Plane& nextPlane( static_cast<const Plane&>(
316 theComps[ theBinFinder_inner.binIndex(nextIndex)]->surface()));
317 pair<bool,double> theNextBladePath = theBladeCrossing.pathLength( nextPlane );
318 LocalPoint nextPos = nextPlane.toLocal(
GlobalPoint(theBladeCrossing.position(theNextBladePath.second)) );
319 nextDist = nextPos.
x();
321 const Plane& nextPlane( static_cast<const Plane&>(
322 theComps[ theBinFinder_outer.binIndex(nextIndex) + _num_innerpanels]->surface()));
323 pair<bool,double> theNextBladePath = theBladeCrossing.pathLength( nextPlane );
324 LocalPoint nextPos = nextPlane.toLocal(
GlobalPoint(theBladeCrossing.position(theNextBladePath.second)) );
325 nextDist = nextPos.
x();
328 if (fabs(closestDist) < fabs(nextDist)) {
329 return SubTurbineCrossings( closestIndex, nextIndex, nextDist);
332 return SubTurbineCrossings( nextIndex, closestIndex, closestDist);
Global3DPoint GlobalPoint
GlobalPoint globalPosition() const
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
Vector2DBase< float, LocalTag > Local2DVector
const Plane & surface() const
The nominal surface of the GeomDet.
static int position[TOTALCHAMBERS][3]
virtual PropagationDirection propagationDirection() const GCC11_FINAL
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
int endcapSide(const TrajectoryStateOnSurface &startingState, const Propagator &prop) const
const T & max(const T &a, const T &b)
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const
virtual const Surface::PositionType & position() const
Returns position of the surface.
std::vector< std::vector< double > > tmp
GlobalVector globalMomentum() const
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)
double transverseCurvature() const