CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TECLayer.cc
Go to the documentation of this file.
1 #include "TECLayer.h"
2 
4 
6 #include "DetGroupMerger.h"
7 #include "LayerCrossingSide.h"
8 
14 #include "TkDetUtil.h"
15 
16 
17 using namespace std;
18 
20 
21 TECLayer::TECLayer(vector<const TECPetal*>& innerPetals,
22  vector<const TECPetal*>& outerPetals) :
23  theFrontComps(innerPetals.begin(),innerPetals.end()),
24  theBackComps(outerPetals.begin(),outerPetals.end())
25 {
26  theComps.assign(theFrontComps.begin(),theFrontComps.end());
27  theComps.insert(theComps.end(),theBackComps.begin(),theBackComps.end());
28 
29  for(vector<const GeometricSearchDet*>::const_iterator it=theComps.begin();
30  it!=theComps.end();it++){
31  theBasicComps.insert(theBasicComps.end(),
32  (**it).basicComponents().begin(),
33  (**it).basicComponents().end());
34  }
35 
36 
37  //This should be no necessary. TO BE CHECKED
38  //sort(theFrontPetals.begin(), theFrontPetals.end(), PetalLessPhi());
39  //sort(theBackPetals.begin(), theBackPetals.end(), PetalLessPhi());
40 
41  // building disk for front and back petals
45 
46  // set up the bin finders
47  theFrontBinFinder = BinFinderPhi(theFrontComps.front()->position().phi(),
48  theFrontComps.size());
49  theBackBinFinder = BinFinderPhi(theBackComps.front()->position().phi(),
50  theBackComps.size());
51 
52  //--------- DEBUG INFO --------------
53  LogDebug("TkDetLayers") << "DEBUG INFO for TECLayer" << "\n"
54  << "TECLayer z,perp, innerRadius, outerR: "
55  << this->position().z() << " , "
56  << this->position().perp() << " , "
57  << this->specificSurface().innerRadius() << " , "
58  << this->specificSurface().outerRadius() ;
59 
60 
61  for(vector<const GeometricSearchDet*>::const_iterator it=theFrontComps.begin();
62  it!=theFrontComps.end(); it++){
63  LogDebug("TkDetLayers") << "frontPetal phi,z,r: "
64  << (*it)->surface().position().phi() << " , "
65  << (*it)->surface().position().z() << " , "
66  << (*it)->surface().position().perp() ;
67  }
68 
69  for(vector<const GeometricSearchDet*>::const_iterator it=theBackComps.begin();
70  it!=theBackComps.end(); it++){
71  LogDebug("TkDetLayers") << "backPetal phi,z,r: "
72  << (*it)->surface().position().phi() << " , "
73  << (*it)->surface().position().z() << " , "
74  << (*it)->surface().position().perp() ;
75  }
76  //-----------------------------------
77 
78 
79 }
80 
81 
82 
84  vector<const GeometricSearchDet*>::const_iterator i;
85  for (i=theComps.begin(); i!=theComps.end(); i++) {
86  delete *i;
87  }
88 }
89 
90 
91 void
93  const Propagator& prop,
94  const MeasurementEstimator& est,
95  std::vector<DetGroup> & result) const {
96  SubLayerCrossings crossings;
97  crossings = computeCrossings( tsos, prop.propagationDirection());
98  if(! crossings.isValid()) return;
99 
100  vector<DetGroup> closestResult;
101  addClosest( tsos, prop, est, crossings.closest(), closestResult);
102  LogDebug("TkDetLayers") << "in TECLayer, closestResult.size(): " << closestResult.size();
103 
104  // this differs from other groupedCompatibleDets logic, which DON'T check next in such cases!!!
105  if(closestResult.empty()){
106  vector<DetGroup> nextResult;
107  addClosest( tsos, prop, est, crossings.other(), nextResult);
108  LogDebug("TkDetLayers") << "in TECLayer, nextResult.size(): " << nextResult.size();
109  if(nextResult.empty()) return;
110 
111 
112  DetGroupElement nextGel( nextResult.front().front());
113  int crossingSide = LayerCrossingSide().endcapSide( nextGel.trajectoryState(), prop);
114  DetGroupMerger::orderAndMergeTwoLevels( std::move(closestResult), std::move(nextResult), result,
115  crossings.closestIndex(), crossingSide);
116  }
117  else {
118  DetGroupElement closestGel( closestResult.front().front());
119  float phiWindow = tkDetUtil::computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
120  searchNeighbors( tsos, prop, est, crossings.closest(), phiWindow,
121  closestResult, false);
122  vector<DetGroup> nextResult;
123  searchNeighbors( tsos, prop, est, crossings.other(), phiWindow,
124  nextResult, true);
125 
126  int crossingSide = LayerCrossingSide().endcapSide( closestGel.trajectoryState(), prop);
127  DetGroupMerger::orderAndMergeTwoLevels( std::move(closestResult), std::move(nextResult), result,
128  crossings.closestIndex(), crossingSide);
129  }
130 }
131 
133  PropagationDirection propDir) const
134 {
135  double rho( startingState.transverseCurvature());
136 
137  HelixPlaneCrossing::PositionType startPos( startingState.globalPosition() );
138  HelixPlaneCrossing::DirectionType startDir( startingState.globalMomentum() );
139  HelixForwardPlaneCrossing crossing(startPos,startDir,rho,propDir);
140 
141  pair<bool,double> frontPath = crossing.pathLength( *theFrontDisk);
142  if (!frontPath.first) SubLayerCrossings();
143 
144 
145  GlobalPoint gFrontPoint(crossing.position(frontPath.second));
146  LogDebug("TkDetLayers")
147  << "in TECLayer,front crossing point: r,z,phi: ("
148  << gFrontPoint.perp() << ","
149  << gFrontPoint.z() << ","
150  << gFrontPoint.phi() << ")" << endl;
151 
152 
153  int frontIndex = theFrontBinFinder.binIndex(gFrontPoint.barePhi());
154  SubLayerCrossing frontSLC( 0, frontIndex, gFrontPoint);
155 
156 
157 
158  pair<bool,double> backPath = crossing.pathLength( *theBackDisk);
159  if (!backPath.first) SubLayerCrossings();
160 
161 
162  GlobalPoint gBackPoint( crossing.position(backPath.second));
163  LogDebug("TkDetLayers")
164  << "in TECLayer,back crossing point: r,z,phi: ("
165  << gBackPoint.perp() << ","
166  << gFrontPoint.z() << ","
167  << gBackPoint.phi() << ")" << endl;
168 
169 
170  int backIndex = theBackBinFinder.binIndex(gBackPoint.barePhi());
171  SubLayerCrossing backSLC( 1, backIndex, gBackPoint);
172 
173 
174  // 0ss: frontDisk has index=0, backDisk has index=1
175  float frontDist = std::abs(Geom::deltaPhi( double(gFrontPoint.barePhi()),
176  double(theFrontComps[frontIndex]->surface().phi())));
177  float backDist = std::abs(Geom::deltaPhi( double(gBackPoint.barePhi()),
178  double(theBackComps[backIndex]->surface().phi())));
179 
180 
181  if (frontDist < backDist) {
182  return SubLayerCrossings( frontSLC, backSLC, 0);
183  }
184  else {
185  return SubLayerCrossings( backSLC, frontSLC, 1);
186  }
187 }
188 
190  const Propagator& prop,
191  const MeasurementEstimator& est,
192  const SubLayerCrossing& crossing,
193  vector<DetGroup>& result) const
194 {
195  const vector<const GeometricSearchDet*>& sub( subLayer( crossing.subLayerIndex()));
196  const GeometricSearchDet* det(sub[crossing.closestDetIndex()]);
197 
198  LogDebug("TkDetLayers")
199  << "in TECLayer, adding petal at r,z,phi: ("
200  << det->position().perp() << ","
201  << det->position().z() << ","
202  << det->position().phi() << ")" << endl;
203 
204  return CompatibleDetToGroupAdder().add( *det, tsos, prop, est, result);
205 }
206 
208  const Propagator& prop,
209  const MeasurementEstimator& est,
210  const SubLayerCrossing& crossing,
211  float window,
212  vector<DetGroup>& result,
213  bool checkClosest) const
214 {
215  GlobalPoint gCrossingPos = crossing.position();
216 
217  const vector<const GeometricSearchDet*>& sLayer( subLayer( crossing.subLayerIndex()));
218 
219  int closestIndex = crossing.closestDetIndex();
220  int negStartIndex = closestIndex-1;
221  int posStartIndex = closestIndex+1;
222 
223  if (checkClosest) { // must decide if the closest is on the neg or pos side
224  if ( PhiLess()( gCrossingPos.phi(), sLayer[closestIndex]->position().phi())) {
225  posStartIndex = closestIndex;
226  }
227  else {
228  negStartIndex = closestIndex;
229  }
230  }
231 
232  const BinFinderPhi& binFinder = (crossing.subLayerIndex()==0 ? theFrontBinFinder : theBackBinFinder);
233 
234  typedef CompatibleDetToGroupAdder Adder;
235  int half = sLayer.size()/2; // to check if dets are called twice....
236  for (int idet=negStartIndex; idet >= negStartIndex - half; idet--) {
237  const GeometricSearchDet & neighborPetal = *sLayer[binFinder.binIndex(idet)];
238  if (!overlap( gCrossingPos, neighborPetal, window)) break;
239  if (!Adder::add( neighborPetal, tsos, prop, est, result)) break;
240  // maybe also add shallow crossing angle test here???
241  }
242  for (int idet=posStartIndex; idet < posStartIndex + half; idet++) {
243  const GeometricSearchDet & neighborPetal = *sLayer[binFinder.binIndex(idet)];
244  if (!overlap( gCrossingPos, neighborPetal, window)) break;
245  if (!Adder::add( neighborPetal, tsos, prop, est, result)) break;
246  // maybe also add shallow crossing angle test here???
247  }
248 }
249 
250 bool TECLayer::overlap( const GlobalPoint& gpos, const GeometricSearchDet& gsdet, float phiWin) const
251 {
252  float phi = gpos.barePhi();
253  const BoundDiskSector& diskSector = static_cast<const BoundDiskSector&>(gsdet.surface());
254  pair<float,float> phiRange(phi-phiWin,phi+phiWin);
255  pair<float,float> petalPhiRange(diskSector.phi() - 0.5*diskSector.phiExtension(),
256  diskSector.phi() + 0.5*diskSector.phiExtension());
257 
258 
259  return rangesIntersect(phiRange, petalPhiRange, PhiLess());
260 }
261 
262 
263 
264 BoundDisk*
265 TECLayer::computeDisk( vector<const GeometricSearchDet*>& petals) const
266 {
267  // Attention: it is assumed that the petals do belong to one layer, and are all
268  // of the same rmin/rmax extension !!
269 
270  const BoundDiskSector& diskSector = static_cast<const BoundDiskSector&>(petals.front()->surface());
271 
272  float rmin = diskSector.innerRadius();
273  float rmax = diskSector.outerRadius();
274 
275  float theZmax(petals.front()->position().z());
276  float theZmin(theZmax);
277  for ( vector<const GeometricSearchDet*>::const_iterator i = petals.begin(); i != petals.end(); i++ ) {
278  float zmin = (**i).position().z() - (**i).surface().bounds().thickness()/2.;
279  float zmax = (**i).position().z() + (**i).surface().bounds().thickness()/2.;
280  theZmax = max( theZmax, zmax);
281  theZmin = min( theZmin, zmin);
282  }
283 
284  float zPos = (theZmax+theZmin)/2.;
285  PositionType pos(0.,0.,zPos);
287 
288  return new BoundDisk( pos, rot, new SimpleDiskBounds(rmin, rmax,
289  theZmin-zPos, theZmax-zPos));
290 }
291 
#define LogDebug(id)
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
int i
Definition: DBlmapReader.cc:9
def window
Definition: svgfig.py:642
T perp() const
Definition: PV3DBase.h:72
std::vector< const GeomDet * > theBasicComps
Definition: TECLayer.h:71
int closestIndex() const
int closestDetIndex() const
double deltaPhi(float phi1, float phi2)
Definition: VectorUtil.h:30
double zPos
void searchNeighbors(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, float window, std::vector< DetGroup > &result, bool checkClosest) const
Definition: TECLayer.cc:207
void setSurface(BoundDisk *cp)
Definition: DDAxes.h:10
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
float rmin() const
GlobalPoint globalPosition() const
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
~TECLayer()
Definition: TECLayer.cc:83
ReferenceCountingPointer< BoundDisk > theFrontDisk
Definition: TECLayer.h:74
PropagationDirection
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const
Definition: TECLayer.cc:92
float zmin() const
virtual PropagationDirection propagationDirection() const GCC11_FINAL
Definition: Propagator.h:145
virtual int binIndex(T phi) const
returns an index in the valid range for the bin that contains phi
const GlobalPoint & position() const
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
Definition: TkDetUtil.cc:31
T barePhi() const
Definition: PV3DBase.h:68
int endcapSide(const TrajectoryStateOnSurface &startingState, const Propagator &prop) const
bool addClosest(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, std::vector< DetGroup > &result) const
Definition: TECLayer.cc:189
std::vector< const GeometricSearchDet * > theComps
Definition: TECLayer.h:68
ReferenceCountingPointer< BoundDisk > theBackDisk
Definition: TECLayer.h:75
const T & max(const T &a, const T &b)
std::vector< const GeometricSearchDet * > theFrontComps
Definition: TECLayer.h:69
virtual const BoundSurface & surface() const GCC11_FINAL
The surface of the GeometricSearchDet.
bool rangesIntersect(const Range &a, const Range &b)
int subLayerIndex() const
T phi() const
Definition: Phi.h:41
T z() const
Definition: PV3DBase.h:64
std::vector< const GeometricSearchDet * > theBackComps
Definition: TECLayer.h:70
tuple result
Definition: query.py:137
BinFinderPhi theBackBinFinder
Definition: TECLayer.h:80
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PeriodicBinFinderInPhi< double > BinFinderPhi
Definition: TECLayer.h:77
#define end
Definition: vmac.h:37
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
const std::vector< const GeometricSearchDet * > & subLayer(int ind) const
Definition: TECLayer.h:60
const SubLayerCrossing & other() const
SubLayerCrossings computeCrossings(const TrajectoryStateOnSurface &startingState, PropagationDirection propDir) const
Definition: TECLayer.cc:132
float zmax() const
virtual const Surface::PositionType & position() const
Returns position of the surface.
BinFinderPhi theFrontBinFinder
Definition: TECLayer.h:79
virtual BoundDisk * computeDisk(std::vector< const GeometricSearchDet * > &petals) const
Definition: TECLayer.cc:265
Disk BoundDisk
Definition: BoundDisk.h:62
static bool add(const GeometricSearchDet &det, const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result)
virtual const BoundDisk & specificSurface() const GCC11_FINAL
const SubLayerCrossing & closest() const
#define begin
Definition: vmac.h:30
GlobalVector globalMomentum() const
bool overlap(const GlobalPoint &gpos, const GeometricSearchDet &petal, float window) const
Definition: TECLayer.cc:250
float rmax() 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)
TECLayer(std::vector< const TECPetal * > &innerPetals, std::vector< const TECPetal * > &outerPetals)
Definition: TECLayer.cc:21
Definition: DDAxes.h:10