test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Phase2OTEndcapRing.cc
Go to the documentation of this file.
1 #include "Phase2OTEndcapRing.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 Phase2OTEndcapRing::Phase2OTEndcapRing(vector<const GeomDet*>& innerDets,
26  vector<const GeomDet*>& outerDets,
27  vector<const GeomDet*>& innerDetBrothers,
28  vector<const GeomDet*>& outerDetBrothers):
30  theFrontDets(innerDets.begin(),innerDets.end()),
31  theBackDets(outerDets.begin(),outerDets.end()),
32  theFrontDetBrothers(innerDetBrothers.begin(),innerDetBrothers.end()),
33  theBackDetBrothers(outerDetBrothers.begin(),outerDetBrothers.end())
34 {
35  theDets.assign(theFrontDets.begin(),theFrontDets.end());
36  theDets.insert(theDets.end(),theBackDets.begin(),theBackDets.end());
37  theDets.insert(theDets.end(),theFrontDetBrothers.begin(),theFrontDetBrothers.end());
38  theDets.insert(theDets.end(),theBackDetBrothers.begin(),theBackDetBrothers.end());
39 
40 
41  // the dets should be already phi-ordered. TO BE CHECKED
42  //sort( theFrontDets.begin(), theFrontDets.end(), DetLessPhi() );
43  //sort( theBackDets.begin(), theBackDets.end(), DetLessPhi() );
44 
46 
49 
50  theFrontBinFinder = BinFinderType( theFrontDets.front()->surface().position().phi(),
51  theFrontDets.size());
52  theBackBinFinder = BinFinderType( theBackDets.front()->surface().position().phi(),
53  theBackDets.size());
54 
55 
56 
57  LogDebug("TkDetLayers") << "DEBUG INFO for Phase2OTEndcapRing" ;
58  for(vector<const GeomDet*>::const_iterator it=theFrontDets.begin();
59  it!=theFrontDets.end(); it++){
60  LogDebug("TkDetLayers") << "frontDet phi,z,r: "
61  << (*it)->surface().position().phi() << " , "
62  << (*it)->surface().position().z() << " , "
63  << (*it)->surface().position().perp() ;
64  }
65 
66  for(vector<const GeomDet*>::const_iterator it=theBackDets.begin();
67  it!=theBackDets.end(); it++){
68  LogDebug("TkDetLayers") << "backDet phi,z,r: "
69  << (*it)->surface().position().phi() << " , "
70  << (*it)->surface().position().z() << " , "
71  << (*it)->surface().position().perp() ;
72  }
73 
74 
75 }
76 
78 
79 }
80 
81 const vector<const GeometricSearchDet*>&
83 {
84  throw DetLayerException("Phase2OTEndcapRing doesn't have GeometricSearchDet components");
85 }
86 
87 
88 pair<bool, TrajectoryStateOnSurface>
90  const MeasurementEstimator&) const{
91  edm::LogError("TkDetLayers") << "temporary dummy implementation of Phase2OTEndcapRing::compatible()!!" ;
92  return pair<bool,TrajectoryStateOnSurface>();
93 }
94 
95 
96 
97 void
99  const Propagator& prop,
100  const MeasurementEstimator& est,
101  std::vector<DetGroup>& result) const
102 {
103  SubLayerCrossings crossings;
104  crossings = computeCrossings( tsos, prop.propagationDirection());
105  if(! crossings.isValid()) return;
106 
107 
108  std::vector<DetGroup> closestResult;
109  std::vector<DetGroup> closestBrotherResult;
110  addClosest( tsos, prop, est, crossings.closest(), closestResult,closestBrotherResult);
111  if (closestResult.empty()) return;
112 
113  DetGroupElement closestGel( closestResult.front().front());
114  int crossingSide = LayerCrossingSide().endcapSide( closestGel.trajectoryState(), prop);
115  float phiWindow = tkDetUtil::computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
116  searchNeighbors( tsos, prop, est, crossings.closest(), phiWindow,
117  closestResult, closestBrotherResult, false);
118 
119  vector<DetGroup> closestCompleteResult;
120  DetGroupMerger::orderAndMergeTwoLevels(std::move(closestResult),std::move(closestBrotherResult),closestCompleteResult,
121  0, crossingSide);
122 
123  vector<DetGroup> nextResult;
124  vector<DetGroup> nextBrotherResult;
125  searchNeighbors( tsos, prop, est, crossings.other(), phiWindow,
126  nextResult, nextBrotherResult, true);
127 
128  vector<DetGroup> nextCompleteResult;
129  DetGroupMerger::orderAndMergeTwoLevels(std::move(nextResult),std::move(nextBrotherResult),nextCompleteResult,
130  0, crossingSide);
131 
132  DetGroupMerger::orderAndMergeTwoLevels( std::move(closestCompleteResult), std::move(nextCompleteResult), result,
133  crossings.closestIndex(), crossingSide);
134 }
135 
136 
139  PropagationDirection propDir) const
140 {
141  auto rho = startingState.transverseCurvature();
142 
143  HelixPlaneCrossing::PositionType startPos( startingState.globalPosition() );
144  HelixPlaneCrossing::DirectionType startDir( startingState.globalMomentum() );
145  HelixForwardPlaneCrossing crossing(startPos,startDir,rho,propDir);
146 
147  pair<bool,double> frontPath = crossing.pathLength( *theFrontDisk);
148  if (!frontPath.first) return SubLayerCrossings();
149 
150  pair<bool,double> backPath = crossing.pathLength( *theBackDisk);
151  if (!backPath.first) return SubLayerCrossings();
152 
153  GlobalPoint gFrontPoint(crossing.position(frontPath.second));
154  GlobalPoint gBackPoint( crossing.position(backPath.second));
155 
156  int frontIndex = theFrontBinFinder.binIndex(gFrontPoint.barePhi());
157  SubLayerCrossing frontSLC( 0, frontIndex, gFrontPoint);
158 
159  int backIndex = theBackBinFinder.binIndex(gBackPoint.barePhi());
160  SubLayerCrossing backSLC( 1, backIndex, gBackPoint);
161 
162 
163  // 0ss: frontDisk has index=0, backDisk has index=1
164  float frontDist = std::abs(Geom::deltaPhi( gFrontPoint.barePhi(),
165  theFrontDets[frontIndex]->surface().phi()));
166  float backDist = std::abs(Geom::deltaPhi( gBackPoint.barePhi(),
167  theBackDets[backIndex]->surface().phi()));
168 
169 
170  if (frontDist < backDist) {
171  return SubLayerCrossings( frontSLC, backSLC, 0);
172  }
173  else {
174  return SubLayerCrossings( backSLC, frontSLC, 1);
175  }
176 }
177 
179  const Propagator& prop,
180  const MeasurementEstimator& est,
181  const SubLayerCrossing& crossing,
182  vector<DetGroup>& result,
183  vector<DetGroup>& brotherresult) const
184 {
185  const vector<const GeomDet*>& sub( subLayer( crossing.subLayerIndex()));
186  const GeomDet* det(sub[crossing.closestDetIndex()]);
187  bool firstgroup = CompatibleDetToGroupAdder::add( *det, tsos, prop, est, result);
188  // it assumes that the closestDetIndex is ok also for the brother detectors: the crossing is NOT recomputed
189  const vector<const GeomDet*>& subBrothers( subLayerBrothers( crossing.subLayerIndex()));
190  const GeomDet* detBrother(subBrothers[crossing.closestDetIndex()]);
191  bool brothergroup = CompatibleDetToGroupAdder::add( *detBrother, tsos, prop, est, brotherresult);
192  return firstgroup || brothergroup;
193 }
194 
195 
196 
198  const Propagator& prop,
199  const MeasurementEstimator& est,
200  const SubLayerCrossing& crossing,
201  float window,
202  vector<DetGroup>& result,
203  vector<DetGroup>& brotherresult,
204  bool checkClosest) const
205 {
206  GlobalPoint gCrossingPos = crossing.position();
207 
208  const vector<const GeomDet*>& sLayer( subLayer( crossing.subLayerIndex()));
209  // It assumes that what is ok for the front modules in the pt modules is ok also for the back module
210  const vector<const GeomDet*>& sBrotherLayer( subLayerBrothers( crossing.subLayerIndex()));
211 
212  int closestIndex = crossing.closestDetIndex();
213  int negStartIndex = closestIndex-1;
214  int posStartIndex = closestIndex+1;
215 
216  if (checkClosest) { // must decide if the closest is on the neg or pos side
217  if ( Geom::phiLess( gCrossingPos.barePhi(), sLayer[closestIndex]->surface().phi())) {
218  posStartIndex = closestIndex;
219  }
220  else {
221  negStartIndex = closestIndex;
222  }
223  }
224 
225  const BinFinderType& binFinder = (crossing.subLayerIndex()==0 ? theFrontBinFinder : theBackBinFinder);
226 
227  typedef CompatibleDetToGroupAdder Adder;
228  int half = sLayer.size()/2; // to check if dets are called twice....
229  for (int idet=negStartIndex; idet >= negStartIndex - half; idet--) {
230  const GeomDet & neighborDet = *sLayer[binFinder.binIndex(idet)];
231  if (!tkDetUtil::overlapInPhi( gCrossingPos, neighborDet, window)) break;
232  if (!Adder::add( neighborDet, tsos, prop, est, result)) break;
233  // If the two above checks are passed also the brother module will be added with no further checks
234  const GeomDet & neighborBrotherDet = *sBrotherLayer[binFinder.binIndex(idet)];
235  Adder::add( neighborBrotherDet, tsos, prop, est, brotherresult);
236  // maybe also add shallow crossing angle test here???
237  }
238  for (int idet=posStartIndex; idet < posStartIndex + half; idet++) {
239  const GeomDet & neighborDet = *sLayer[binFinder.binIndex(idet)];
240  if (!tkDetUtil::overlapInPhi( gCrossingPos, neighborDet, window)) break;
241  if (!Adder::add( neighborDet, tsos, prop, est, result)) break;
242  // If the two above checks are passed also the brother module will be added with no further checks
243  const GeomDet & neighborBrotherDet = *sBrotherLayer[binFinder.binIndex(idet)];
244  Adder::add( neighborBrotherDet, tsos, prop, est, brotherresult);
245  // maybe also add shallow crossing angle test here???
246  }
247 }
#define LogDebug(id)
Common base class.
def window
Definition: svgfig.py:642
virtual const std::vector< const GeometricSearchDet * > & components() const __attribute__((cold))
Returns basic components, if any.
int closestIndex() const
int closestDetIndex() const
std::vector< const GeomDet * > theFrontDetBrothers
GlobalPoint globalPosition() const
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
std::vector< const GeomDet * > theBackDetBrothers
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:151
bool addClosest(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, std::vector< DetGroup > &result, std::vector< DetGroup > &brotherresult) const __attribute__((hot))
PropagationDirection
bool overlapInPhi(float phi, const GeomDet &det, float phiWindow)
Definition: TkDetUtil.h:19
virtual int binIndex(T phi) const
returns an index in the valid range for the bin that contains phi
void searchNeighbors(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, float window, std::vector< DetGroup > &result, std::vector< DetGroup > &brotherresult, bool checkClosest) const __attribute__((hot))
tuple result
Definition: mps_fire.py:84
const GlobalPoint & position() const
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
Definition: TkDetUtil.cc:9
T barePhi() const
Definition: PV3DBase.h:68
ReferenceCountingPointer< BoundDisk > theDisk
const std::vector< const GeomDet * > & subLayer(int ind) const
std::vector< const GeomDet * > theDets
std::vector< const GeomDet * > theBackDets
int subLayerIndex() const
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)
Phase2OTEndcapRing(std::vector< const GeomDet * > &innerDets, std::vector< const GeomDet * > &outerDets, std::vector< const GeomDet * > &innerDetBrothers, std::vector< const GeomDet * > &outerDetBrothers)
#define end
Definition: vmac.h:37
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
const std::vector< const GeomDet * > & subLayerBrothers(int ind) const
BinFinderType theBackBinFinder
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))
std::vector< const GeomDet * > theFrontDets
BinFinderType theFrontBinFinder
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)
virtual std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &, const Propagator &, const MeasurementEstimator &) const
ReferenceCountingPointer< BoundDisk > theBackDisk
PeriodicBinFinderInPhi< float > BinFinderType
SubLayerCrossings computeCrossings(const TrajectoryStateOnSurface &tsos, PropagationDirection propDir) const __attribute__((hot))
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const __attribute__((hot))
ReferenceCountingPointer< BoundDisk > theFrontDisk