17 #include <boost/function.hpp>
18 #include <boost/bind.hpp>
35 float operator()(
float a,
float b)
const {
40 void fillBoundaries(std::vector<const TECWedge*>
const & dets,
41 std::vector<float> & boundaries) {
42 boundaries.resize(dets.size());
46 std::adjacent_difference(boundaries.begin(),boundaries.end(), boundaries.begin(),
Mean());
50 int findBin(std::vector<float>
const & boundaries,
float r) {
52 std::lower_bound(boundaries.begin()+1,boundaries.end(),
r)
53 -boundaries.begin()-1;
57 void fillPars(std::vector<const TECWedge*>
const & dets, std::vector<CompositeTECPetal::WedgePar> & pars) {
59 for (
auto gsdet : dets) {
60 const BoundDiskSector& wedgeSector =
static_cast<const BoundDiskSector&
>( gsdet->surface());
61 float wedgeMinZ =
std::abs( wedgeSector.position().z()) - 0.5*wedgeSector.bounds().thickness();
62 float wedgeMaxZ =
std::abs( wedgeSector.position().z()) + 0.5*wedgeSector.bounds().thickness();
63 float thetaWedgeMin = wedgeSector.innerRadius()/ wedgeMaxZ;
64 float thetaWedgeMax = wedgeSector.outerRadius()/ wedgeMinZ;
65 CompositeTECPetal::WedgePar apar = {gsdet->position().perp(),thetaWedgeMin,thetaWedgeMax};
77 auto tsRadius = gpos.
perp();
80 auto rmax = (tsRadius +
ymax);
86 return !( (rmin >
zmax*wpar.thetaMax) | (
zmin*wpar.thetaMin > rmax) );
94 CompositeTECPetal::CompositeTECPetal(vector<const TECWedge*>& innerWedges,
95 vector<const TECWedge*>& outerWedges) :
97 theFrontComps(innerWedges),
98 theBackComps(outerWedges)
100 theComps.assign(theFrontComps.begin(),theFrontComps.end());
101 theComps.insert(theComps.end(),theBackComps.begin(),theBackComps.end());
103 details::fillBoundaries( theFrontComps, theFrontBoundaries);
104 details::fillBoundaries( theBackComps, theBackBoundaries);
105 details::fillPars(theFrontComps, theFrontPars);
106 details::fillPars(theBackComps, theBackPars);
108 for(vector<const GeometricSearchDet*>::const_iterator it=theComps.begin();
109 it!=theComps.end();it++){
110 theBasicComps.insert(theBasicComps.end(),
111 (**it).basicComponents().begin(),
112 (**it).basicComponents().end());
120 vector<const TECWedge*> allWedges;
121 allWedges.assign(innerWedges.begin(),innerWedges.end());
122 allWedges.insert(allWedges.end(),outerWedges.begin(),outerWedges.end());
129 LogDebug(
"TkDetLayers") <<
"DEBUG INFO for CompositeTECPetal" ;
131 for(
auto it=theFrontComps.begin();
132 it!=theFrontComps.end(); it++){
133 LogDebug(
"TkDetLayers") <<
"frontWedge phi,z,r: "
134 << (*it)->surface().position().phi() <<
" , "
135 << (*it)->surface().position().z() <<
" , "
136 << (*it)->surface().position().perp() ;
139 for(
auto it=theBackComps.begin();
140 it!=theBackComps.end(); it++){
141 LogDebug(
"TkDetLayers") <<
"backWedge phi,z,r: "
142 << (*it)->surface().position().phi() <<
" , "
143 << (*it)->surface().position().z() <<
" , "
144 << (*it)->surface().position().perp() ;
152 CompositeTECPetal::~CompositeTECPetal(){
153 vector<const GeometricSearchDet*>::const_iterator
i;
154 for (i=theComps.begin(); i!=theComps.end(); i++) {
160 pair<bool, TrajectoryStateOnSurface>
163 edm::LogError(
"TkDetLayers") <<
"temporary dummy implementation of CompositeTECPetal::compatible()!!" ;
164 return pair<bool,TrajectoryStateOnSurface>();
172 std::vector<DetGroup> &
result)
const {
174 vector<DetGroup> closestResult;
177 if(! crossings.
isValid())
return;
179 addClosest( tsos, prop, est, crossings.
closest(), closestResult);
180 LogDebug(
"TkDetLayers") <<
"in TECPetal, closestResult.size(): "<< closestResult.size();
182 if (closestResult.empty()){
183 vector<DetGroup> nextResult;
184 addClosest( tsos, prop, est, crossings.
other(), nextResult);
185 LogDebug(
"TkDetLayers") <<
"in TECPetal, nextResult.size(): "<< nextResult.size() ;
186 if(nextResult.empty())
return;
197 searchNeighbors( tsos, prop, est, crossings.
closest(),
window,
198 closestResult,
false);
200 vector<DetGroup> nextResult;
201 searchNeighbors( tsos, prop, est, crossings.
other(),
window,
220 HelixForwardPlaneCrossing crossing(startPos,startDir,rho,propDir);
222 pair<bool,double> frontPath = crossing.pathLength( *theFrontSector);
225 pair<bool,double> backPath = crossing.pathLength(*theBackSector);
228 GlobalPoint gFrontPoint(crossing.position(frontPath.second));
229 GlobalPoint gBackPoint( crossing.position(backPath.second));
233 <<
"in TECPetal,front crossing : r,z,phi: ("
234 << gFrontPoint.perp() <<
","
235 << gFrontPoint.z() <<
","
236 << gFrontPoint.phi() <<
")";
239 <<
"in TECPetal,back crossing r,z,phi: ("
240 << gBackPoint.perp() <<
","
241 << gBackPoint.z() <<
","
242 << gBackPoint.phi() <<
")" ;
246 int frontIndex = findBin(gFrontPoint.perp(),0);
249 int backIndex = findBin(gBackPoint.perp(),1);
252 auto frontDist =
std::abs( theFrontPars[frontIndex].theR - gFrontPoint.perp());
253 auto backDist =
std::abs( theBackPars[backIndex].theR - gBackPoint.perp());
258 if (frontDist < backDist) {
270 vector<DetGroup>& result)
const
276 <<
"in TECPetal, adding Wedge at r,z,phi: ("
277 << det->position().perp() <<
","
278 << det->position().z() <<
","
279 << det->position().phi() <<
")" ;
281 <<
"wedge comps size: "
282 << det->basicComponents().size();
295 vector<DetGroup>& result,
296 bool checkClosest)
const
302 int negStartIndex = closestIndex-1;
303 int posStartIndex = closestIndex+1;
305 float detR = findPar(closestIndex,crossing.
subLayerIndex()).theR;
308 if ( gCrossingPos.
perp2() < detR*detR ) {
309 posStartIndex = closestIndex;
312 negStartIndex = closestIndex;
316 const std::vector<const TECWedge*>& sLayer = subLayer(crossing.
subLayerIndex() );
319 int theSize = crossing.
subLayerIndex()==0 ? theFrontComps.size() : theBackComps.size();
322 for (
int idet=negStartIndex; idet >= 0; idet--) {
325 WedgePar
const & wpar = findPar(idet, crossing.
subLayerIndex());
327 if (!
Adder::add( neighborWedge, tsos, prop, est, result))
break;
330 for (
int idet=posStartIndex; idet <theSize; idet++) {
333 WedgePar
const & wpar = findPar(idet, crossing.
subLayerIndex());
335 if (!
Adder::add( neighborWedge, tsos, prop, est, result))
break;
353 int CompositeTECPetal::findBin(
float R,
int diskSectorType)
const
355 return details::findBin(diskSectorType==0 ? theFrontBoundaries : theBackBoundaries,R);
int closestDetIndex() const
GlobalPoint globalPosition() const
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
const Plane & surface() const
The nominal surface of the GeomDet.
virtual PropagationDirection propagationDirection() const GCC11_FINAL
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
const GlobalPoint & position() const
const T & max(const T &a, const T &b)
int subLayerIndex() const
Abs< T >::type abs(const T &t)
static int endcapSide(const TrajectoryStateOnSurface &startingState, const Propagator &prop)
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
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))
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const
virtual const Surface::PositionType & position() const
Returns position of the surface.
const SubLayerCrossing & closest() const
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