CMS 3D CMS Logo

CompositeTECWedge.cc
Go to the documentation of this file.
1 #include "CompositeTECWedge.h"
2 
4 
6 #include "LayerCrossingSide.h"
7 #include "DetGroupMerger.h"
9 
11 
15 
16 #include "TkDetUtil.h"
18 #include <boost/function.hpp>
19 
20 using namespace std;
21 
23 
24 // --------- Temporary solution. DetSorting.h has to be used.
25 namespace {
26  class DetPhiLess {
27  public:
28  bool operator()(const GeomDet* a, const GeomDet* b) { return Geom::phiLess(a->surface(), b->surface()); }
29  };
30 } // namespace
31 // ---------------------
32 
33 CompositeTECWedge::CompositeTECWedge(vector<const GeomDet*>& innerDets, vector<const GeomDet*>& outerDets)
34  : theFrontDets(innerDets.begin(), innerDets.end()), theBackDets(outerDets.begin(), outerDets.end()) {
35  theDets.assign(theFrontDets.begin(), theFrontDets.end());
36  theDets.insert(theDets.end(), theBackDets.begin(), theBackDets.end());
37 
38  //
39  std::sort(theFrontDets.begin(), theFrontDets.end(), DetPhiLess());
40  std::sort(theBackDets.begin(), theBackDets.end(), DetPhiLess());
41 
45 
46  //--------- DEBUG INFO --------------
47  LogDebug("TkDetLayers") << "DEBUG INFO for CompositeTECWedge"
48  << "\n"
49  << "TECWedge z, perp,innerRadius,outerR: " << this->position().z() << " , "
50  << this->position().perp() << " , " << theDiskSector->innerRadius() << " , "
51  << theDiskSector->outerRadius();
52 
53  for (vector<const GeomDet*>::const_iterator it = theFrontDets.begin(); it != theFrontDets.end(); it++) {
54  LogDebug("TkDetLayers") << "frontDet phi,z,r: " << (*it)->surface().position().phi() << " , "
55  << (*it)->surface().position().z() << " , " << (*it)->surface().position().perp();
56  }
57 
58  for (vector<const GeomDet*>::const_iterator it = theBackDets.begin(); it != theBackDets.end(); it++) {
59  LogDebug("TkDetLayers") << "backDet phi,z,r: " << (*it)->surface().phi() << " , " << (*it)->surface().position().z()
60  << " , " << (*it)->surface().position().perp();
61  }
62  //-----------------------------------
63 }
64 
66 
67 const vector<const GeometricSearchDet*>& CompositeTECWedge::components() const {
68  throw DetLayerException("CompositeTECWedge doesn't have GeometricSearchDet components");
69 }
70 
71 pair<bool, TrajectoryStateOnSurface> CompositeTECWedge::compatible(const TrajectoryStateOnSurface& ts,
72  const Propagator&,
73  const MeasurementEstimator&) const {
74  edm::LogError("TkDetLayers") << "temporary dummy implementation of CompositeTECWedge::compatible()!!";
75  return pair<bool, TrajectoryStateOnSurface>();
76 }
77 
79  const Propagator& prop,
80  const MeasurementEstimator& est,
81  std::vector<DetGroup>& result) const {
83  if (!crossings.isValid())
84  return;
85 
86  std::vector<DetGroup> closestResult;
87  addClosest(tsos, prop, est, crossings.closest(), closestResult);
88 
89  LogDebug("TkDetLayers") << "in CompositeTECWedge::groupedCompatibleDets,closestResult.size(): "
90  << closestResult.size();
91 
92  if (closestResult.empty())
93  return;
94 
95  DetGroupElement closestGel(closestResult.front().front());
96  auto window = tkDetUtil::computeWindowSize(closestGel.det(), closestGel.trajectoryState(), est);
97 
98  searchNeighbors(tsos, prop, est, crossings.closest(), window, closestResult, false);
99 
100  std::vector<DetGroup> nextResult;
101  searchNeighbors(tsos, prop, est, crossings.other(), window, nextResult, true);
102 
103  int crossingSide = LayerCrossingSide().endcapSide(closestGel.trajectoryState(), prop);
105  std::move(closestResult), std::move(nextResult), result, crossings.closestIndex(), crossingSide);
106 }
107 
108 // private methods for the implementation of groupedCompatibleDets()
109 
111  PropagationDirection propDir) const {
112  HelixPlaneCrossing::PositionType startPos(startingState.globalPosition());
113  HelixPlaneCrossing::DirectionType startDir(startingState.globalMomentum());
114 
115  auto rho = startingState.transverseCurvature();
116 
117  HelixForwardPlaneCrossing crossing(startPos, startDir, rho, propDir);
118 
119  pair<bool, double> frontPath = crossing.pathLength(*theFrontSector);
120  if (!frontPath.first)
121  return SubLayerCrossings();
122 
123  pair<bool, double> backPath = crossing.pathLength(*theBackSector);
124  if (!backPath.first)
125  return SubLayerCrossings();
126 
127  GlobalPoint gFrontPoint(crossing.position(frontPath.second));
128  GlobalPoint gBackPoint(crossing.position(backPath.second));
129 
130  LogDebug("TkDetLayers") << "in TECWedge,front crossing r,z,phi: (" << gFrontPoint.perp() << "," << gFrontPoint.z()
131  << "," << gFrontPoint.phi() << ")";
132 
133  LogDebug("TkDetLayers") << "in TECWedge,back crossing r,z,phi: (" << gBackPoint.perp() << "," << gBackPoint.z() << ","
134  << gBackPoint.phi() << ")" << endl;
135 
136  int frontIndex = findClosestDet(gFrontPoint, 0);
137  SubLayerCrossing frontSLC(0, frontIndex, gFrontPoint);
138 
139  int backIndex = findClosestDet(gBackPoint, 1);
140  SubLayerCrossing backSLC(1, backIndex, gBackPoint);
141 
142  auto frontDist = std::abs(Geom::deltaPhi(gFrontPoint.barePhi(), theFrontDets[frontIndex]->surface().phi()));
143  /*
144  float frontDist = theFrontDets[frontIndex]->surface().phi() - gFrontPoint.phi();
145  frontDist *= Geom::phiLess( theFrontDets[frontIndex]->surface().phi(),gFrontPoint.barePhi()) ? -1. : 1.;
146  if (frontDist < 0.) { frontDist += 2.*Geom::pi();}
147  */
148  auto backDist = std::abs(Geom::deltaPhi(gBackPoint.barePhi(), theBackDets[backIndex]->surface().phi()));
149  /*
150  float backDist = theBackDets[backIndex]->surface().phi() - gBackPoint.phi();
151  backDist *= Geom::phiLess( theBackDets[backIndex]->surface().phi(),gBackPoint.barePhi()) ? -1. : 1.;
152  if ( backDist < 0.) { backDist += 2.*Geom::pi();}
153  */
154 
155  if (frontDist < backDist) {
156  return SubLayerCrossings(frontSLC, backSLC, 0);
157  } else {
158  return SubLayerCrossings(backSLC, frontSLC, 1);
159  }
160 }
161 
163  const Propagator& prop,
164  const MeasurementEstimator& est,
165  const SubLayerCrossing& crossing,
166  vector<DetGroup>& result) const {
167  const vector<const GeomDet*>& sWedge(subWedge(crossing.subLayerIndex()));
168 
169  LogDebug("TkDetLayers") << "in CompositeTECWedge,adding GeomDet at r,z,phi: ("
170  << sWedge[crossing.closestDetIndex()]->position().perp() << ","
171  << sWedge[crossing.closestDetIndex()]->position().z() << ","
172  << sWedge[crossing.closestDetIndex()]->position().phi() << ")";
173 
174  return CompatibleDetToGroupAdder().add(*sWedge[crossing.closestDetIndex()], tsos, prop, est, result);
175 }
176 
178  const Propagator& prop,
179  const MeasurementEstimator& est,
180  const SubLayerCrossing& crossing,
181  float window,
182  vector<DetGroup>& result,
183  bool checkClosest) const {
184  const GlobalPoint& gCrossingPos = crossing.position();
185 
186  const vector<const GeomDet*>& sWedge(subWedge(crossing.subLayerIndex()));
187 
188  int closestIndex = crossing.closestDetIndex();
189  int negStartIndex = closestIndex - 1;
190  int posStartIndex = closestIndex + 1;
191 
192  if (checkClosest) { // must decide if the closest is on the neg or pos side
193  if (Geom::phiLess(gCrossingPos.barePhi(), sWedge[closestIndex]->surface().phi())) {
194  posStartIndex = closestIndex;
195  } else {
196  negStartIndex = closestIndex;
197  }
198  }
199 
200  typedef CompatibleDetToGroupAdder Adder;
201  for (int idet = negStartIndex; idet >= 0; idet--) {
202  //if(idet <0 || idet>=sWedge.size()) {edm::LogInfo(TkDetLayers) << "==== warning! gone out vector bounds.idet: " << idet ;break;}
203  if (!tkDetUtil::overlapInPhi(gCrossingPos, *sWedge[idet], window))
204  break;
205  if (!Adder::add(*sWedge[idet], tsos, prop, est, result))
206  break;
207  }
208  for (int idet = posStartIndex; idet < static_cast<int>(sWedge.size()); idet++) {
209  //if(idet <0 || idet>=sWedge.size()) {edm::LogInfo(TkDetLayers) << "==== warning! gone out vector bounds.idet: " << idet ;break;}
210  if (!tkDetUtil::overlapInPhi(gCrossingPos, *sWedge[idet], window))
211  break;
212  if (!Adder::add(*sWedge[idet], tsos, prop, est, result))
213  break;
214  }
215 }
216 
217 int CompositeTECWedge::findClosestDet(const GlobalPoint& startPos, int sectorId) const {
218  vector<const GeomDet*> const& myDets = sectorId == 0 ? theFrontDets : theBackDets;
219 
220  int close = 0;
221  auto closeDist = std::abs((myDets.front()->toLocal(startPos)).x());
222  for (unsigned int i = 1; i < myDets.size(); i++) {
223  auto dist = std::abs((myDets[i]->toLocal(startPos)).x());
224  if (dist < closeDist) {
225  close = i;
226  closeDist = dist;
227  }
228  }
229  return close;
230 }
SubLayerCrossing::position
const GlobalPoint & position() const
Definition: SubLayerCrossings.h:14
MeasurementEstimator
Definition: MeasurementEstimator.h:19
tkDetUtil::computeWindowSize
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
Definition: TkDetUtil.cc:10
SubLayerCrossings::isValid
bool isValid()
Definition: SubLayerCrossings.h:28
CompositeTECWedge::components
const std::vector< const GeometricSearchDet * > & components() const override __attribute__((cold))
Returns basic components, if any.
Definition: CompositeTECWedge.cc:67
CompositeTECWedge::~CompositeTECWedge
~CompositeTECWedge() override __attribute__((cold))
Definition: CompositeTECWedge.cc:65
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
CompositeTECWedge::searchNeighbors
void searchNeighbors(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, float window, std::vector< DetGroup > &result, bool checkClosest) const __attribute__((hot))
Definition: CompositeTECWedge.cc:177
GeomDet
Definition: GeomDet.h:27
LayerCrossingSide
Definition: LayerCrossingSide.h:15
LayerCrossingSide.h
SubLayerCrossings::closestIndex
int closestIndex() const
Definition: SubLayerCrossings.h:31
CompositeTECWedge::compatible
std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &ts, const Propagator &, const MeasurementEstimator &) const override __attribute__((cold))
Definition: CompositeTECWedge.cc:71
VectorUtil.h
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
CompositeTECWedge::findClosestDet
int findClosestDet(const GlobalPoint &startPos, int sectorId) const
Definition: CompositeTECWedge.cc:217
svgfig.window
def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100, xlogbase=None, ylogbase=None, minusInfinity=-1000, flipx=False, flipy=True)
Definition: svgfig.py:643
CompositeTECWedge::computeCrossings
SubLayerCrossings computeCrossings(const TrajectoryStateOnSurface &tsos, PropagationDirection propDir) const __attribute__((hot))
Definition: CompositeTECWedge.cc:110
TrajectoryStateOnSurface::transverseCurvature
double transverseCurvature() const
Definition: TrajectoryStateOnSurface.h:70
DDAxes::x
GeometricSearchDet::position
virtual const Surface::PositionType & position() const
Returns position of the surface.
Definition: GeometricSearchDet.h:31
CompositeTECWedge::theDets
std::vector< const GeomDet * > theDets
Definition: CompositeTECWedge.h:60
end
#define end
Definition: vmac.h:39
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
Propagator
Definition: Propagator.h:44
ForwardDiskSectorBuilderFromDet
Definition: ForwardDiskSectorBuilderFromDet.h:17
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
DetLayerException.h
LayerCrossingSide::endcapSide
static int endcapSide(const TrajectoryStateOnSurface &startingState, const Propagator &prop)
Definition: LayerCrossingSide.h:31
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
MeasurementEstimator.h
Propagator::propagationDirection
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
CompositeTECWedge::subWedge
const std::vector< const GeomDet * > & subWedge(int ind) const
Definition: CompositeTECWedge.h:55
DetGroupMerger.h
Point3DBase< float, GlobalTag >
b
double b
Definition: hdecay.h:118
CompositeTECWedge::theBackDets
std::vector< const GeomDet * > theBackDets
Definition: CompositeTECWedge.h:59
DDAxes::rho
DetGroupMerger::orderAndMergeTwoLevels
static void orderAndMergeTwoLevels(std::vector< DetGroup > &&one, std::vector< DetGroup > &&two, std::vector< DetGroup > &result, int firstIndex, int firstCrossed)
Definition: DetGroupMerger.cc:6
TkDetUtil.h
CompatibleDetToGroupAdder::add
static bool add(const GeometricSearchDet &det, const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) __attribute__((hot))
Definition: CompatibleDetToGroupAdder.cc:7
SubLayerCrossings::closest
const SubLayerCrossing & closest() const
Definition: SubLayerCrossings.h:29
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::LogError
Definition: MessageLogger.h:183
Geom::phiLess
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:18
a
double a
Definition: hdecay.h:119
PV3DBase::barePhi
T barePhi() const
Definition: PV3DBase.h:65
CompositeTECWedge::theBackSector
ReferenceCountingPointer< BoundDiskSector > theBackSector
Definition: CompositeTECWedge.h:63
CompositeTECWedge::groupedCompatibleDetsV
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const override __attribute__((hot))
Definition: CompositeTECWedge.cc:78
PVValHelper::add
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
Definition: PVValidationHelpers.cc:12
SubLayerCrossing::closestDetIndex
int closestDetIndex() const
Definition: SubLayerCrossings.h:13
DetGroupElement
Definition: DetGroup.h:10
CompositeTECWedge::addClosest
bool addClosest(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, std::vector< DetGroup > &result) const __attribute__((hot))
Definition: CompositeTECWedge.cc:162
TECWedge::theDiskSector
ReferenceCountingPointer< BoundDiskSector > theDiskSector
Definition: TECWedge.h:24
GeometricSearchDet::DetWithState
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
Definition: GeometricSearchDet.h:19
tkDetUtil::overlapInPhi
bool overlapInPhi(float phi, const GeomDet &det, float phiWindow)
Definition: TkDetUtil.h:18
CompatibleDetToGroupAdder.h
HelixForwardPlaneCrossing::position
PositionType position(double s) const override
Definition: HelixForwardPlaneCrossing.cc:38
CompositeTECWedge::CompositeTECWedge
CompositeTECWedge(std::vector< const GeomDet * > &innerDets, std::vector< const GeomDet * > &outerDets) __attribute__((cold))
Definition: CompositeTECWedge.cc:33
DetLayerException
Common base class.
Definition: DetLayerException.h:15
TrajectoryStateOnSurface::globalMomentum
GlobalVector globalMomentum() const
Definition: TrajectoryStateOnSurface.h:66
ForwardDiskSectorBuilderFromDet.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
HelixForwardPlaneCrossing::pathLength
std::pair< bool, double > pathLength(const Plane &plane) override
Definition: HelixForwardPlaneCrossing.h:27
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
CompatibleDetToGroupAdder
Definition: CompatibleDetToGroupAdder.h:13
toLocal
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
Definition: ConversionProducer.h:192
SubLayerCrossings::other
const SubLayerCrossing & other() const
Definition: SubLayerCrossings.h:30
DetWithState
GeometricSearchDet::DetWithState DetWithState
Definition: CompositeTECWedge.cc:22
CompositeTECWedge.h
SubLayerCrossing
Definition: SubLayerCrossings.h:7
SubLayerCrossing::subLayerIndex
int subLayerIndex() const
Definition: SubLayerCrossings.h:12
mps_fire.result
result
Definition: mps_fire.py:303
HelixForwardPlaneCrossing
Definition: HelixForwardPlaneCrossing.h:13
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
rangesIntersect.h
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
begin
#define begin
Definition: vmac.h:32
Basic3DVector< float >
HelixForwardPlaneCrossing.h
SubLayerCrossings
Definition: SubLayerCrossings.h:22
CompositeTECWedge::theFrontSector
ReferenceCountingPointer< BoundDiskSector > theFrontSector
Definition: CompositeTECWedge.h:62
CompositeTECWedge::theFrontDets
std::vector< const GeomDet * > theFrontDets
Definition: CompositeTECWedge.h:58