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