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());
49 int findBin(std::vector<float>
const & boundaries,
float r) {
51 std::lower_bound(boundaries.begin()+1,boundaries.end(),
r)
52 -boundaries.begin()-1;
56 void fillPars(std::vector<const TECWedge*>
const & dets, std::vector<CompositeTECPetal::WedgePar> & pars) {
58 for (
auto gsdet : dets) {
59 const BoundDiskSector& wedgeSector =
static_cast<const BoundDiskSector&
>( gsdet->surface());
60 float wedgeMinZ = fabs( wedgeSector.position().z()) - 0.5*wedgeSector.bounds().thickness();
61 float wedgeMaxZ = fabs( wedgeSector.position().z()) + 0.5*wedgeSector.bounds().thickness();
62 float thetaWedgeMin = wedgeSector.innerRadius()/ wedgeMaxZ;
63 float thetaWedgeMax = wedgeSector.outerRadius()/ wedgeMinZ;
64 CompositeTECPetal::WedgePar apar = {gsdet->position().perp(),thetaWedgeMin,thetaWedgeMax};
76 float tsRadius = gpos.
perp();
77 float thetamin =
std::max(0.
f,tsRadius-ymax)/(fabs(gpos.
z())+10.
f);
78 float thetamax = ( tsRadius +
ymax)/(fabs(gpos.
z())-10.
f);
83 return !( thetamin > wpar.thetaMax || wpar.thetaMin > thetamax);
91 CompositeTECPetal::CompositeTECPetal(vector<const TECWedge*>& innerWedges,
92 vector<const TECWedge*>& outerWedges) :
93 theFrontComps(innerWedges),
94 theBackComps(outerWedges)
96 theComps.assign(theFrontComps.begin(),theFrontComps.end());
97 theComps.insert(theComps.end(),theBackComps.begin(),theBackComps.end());
99 details::fillBoundaries( theFrontComps, theFrontBoundaries);
100 details::fillBoundaries( theBackComps, theBackBoundaries);
101 details::fillPars(theFrontComps, theFrontPars);
102 details::fillPars(theBackComps, theBackPars);
104 for(vector<const GeometricSearchDet*>::const_iterator it=theComps.begin();
105 it!=theComps.end();it++){
106 theBasicComps.insert(theBasicComps.end(),
107 (**it).basicComponents().begin(),
108 (**it).basicComponents().end());
116 vector<const TECWedge*> allWedges;
117 allWedges.assign(innerWedges.begin(),innerWedges.end());
118 allWedges.insert(allWedges.end(),outerWedges.begin(),outerWedges.end());
125 LogDebug(
"TkDetLayers") <<
"DEBUG INFO for CompositeTECPetal" ;
127 for(
auto it=theFrontComps.begin();
128 it!=theFrontComps.end(); it++){
129 LogDebug(
"TkDetLayers") <<
"frontWedge phi,z,r: "
130 << (*it)->surface().position().phi() <<
" , "
131 << (*it)->surface().position().z() <<
" , "
132 << (*it)->surface().position().perp() ;
135 for(
auto it=theBackComps.begin();
136 it!=theBackComps.end(); it++){
137 LogDebug(
"TkDetLayers") <<
"backWedge phi,z,r: "
138 << (*it)->surface().position().phi() <<
" , "
139 << (*it)->surface().position().z() <<
" , "
140 << (*it)->surface().position().perp() ;
148 CompositeTECPetal::~CompositeTECPetal(){
149 vector<const GeometricSearchDet*>::const_iterator
i;
150 for (i=theComps.begin(); i!=theComps.end(); i++) {
156 pair<bool, TrajectoryStateOnSurface>
159 edm::LogError(
"TkDetLayers") <<
"temporary dummy implementation of CompositeTECPetal::compatible()!!" ;
160 return pair<bool,TrajectoryStateOnSurface>();
168 std::vector<DetGroup> &
result)
const {
170 vector<DetGroup> closestResult;
173 if(! crossings.
isValid())
return;
175 addClosest( tsos, prop, est, crossings.
closest(), closestResult);
176 LogDebug(
"TkDetLayers") <<
"in TECPetal, closestResult.size(): "<< closestResult.size();
178 if (closestResult.empty()){
179 vector<DetGroup> nextResult;
180 addClosest( tsos, prop, est, crossings.
other(), nextResult);
181 LogDebug(
"TkDetLayers") <<
"in TECPetal, nextResult.size(): "<< nextResult.size() ;
182 if(nextResult.empty())
return;
193 searchNeighbors( tsos, prop, est, crossings.
closest(),
window,
194 closestResult,
false);
196 vector<DetGroup> nextResult;
197 searchNeighbors( tsos, prop, est, crossings.
other(),
window,
214 HelixForwardPlaneCrossing crossing(startPos,startDir,
rho,propDir);
215 pair<bool,double> frontPath = crossing.pathLength( *theFrontSector);
219 GlobalPoint gFrontPoint(crossing.position(frontPath.second));
221 <<
"in TECPetal,front crossing : r,z,phi: ("
222 << gFrontPoint.perp() <<
","
223 << gFrontPoint.z() <<
","
224 << gFrontPoint.phi() <<
")";
227 int frontIndex = findBin(gFrontPoint.perp(),0);
228 float frontDist = fabs( theFrontPars[frontIndex].theR - gFrontPoint.perp());
233 pair<bool,double> backPath = crossing.pathLength( *theBackSector);
238 GlobalPoint gBackPoint( crossing.position(backPath.second));
240 <<
"in TECPetal,back crossing r,z,phi: ("
241 << gBackPoint.perp() <<
","
242 << gBackPoint.z() <<
","
243 << gBackPoint.phi() <<
")" ;
245 int backIndex = findBin(gBackPoint.perp(),1);
246 float backDist = fabs( theBackPars[backIndex].theR - gBackPoint.perp());
252 if (frontDist < backDist) {
264 vector<DetGroup>& result)
const
270 <<
"in TECPetal, adding Wedge at r,z,phi: ("
271 << det->position().perp() <<
","
272 << det->position().z() <<
","
273 << det->position().phi() <<
")" ;
275 <<
"wedge comps size: "
276 << det->basicComponents().size();
289 vector<DetGroup>& result,
290 bool checkClosest)
const
296 int negStartIndex = closestIndex-1;
297 int posStartIndex = closestIndex+1;
299 float detR = findPar(closestIndex,crossing.
subLayerIndex()).theR;
302 if ( gCrossingPos.
perp2() < detR*detR ) {
303 posStartIndex = closestIndex;
306 negStartIndex = closestIndex;
310 const std::vector<const TECWedge*>& sLayer = subLayer(crossing.
subLayerIndex() );
313 int theSize = crossing.
subLayerIndex()==0 ? theFrontComps.size() : theBackComps.size();
316 for (
int idet=negStartIndex; idet >= 0; idet--) {
319 WedgePar
const & wpar = findPar(idet, crossing.
subLayerIndex());
321 if (!
Adder::add( neighborWedge, tsos, prop, est, result))
break;
324 for (
int idet=posStartIndex; idet <theSize; idet++) {
327 WedgePar
const & wpar = findPar(idet, crossing.
subLayerIndex());
329 if (!
Adder::add( neighborWedge, tsos, prop, est, result))
break;
347 int CompositeTECPetal::findBin(
float R,
int diskSectorType)
const
349 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
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
int endcapSide(const TrajectoryStateOnSurface &startingState, const Propagator &prop) const
const T & max(const T &a, const T &b)
int subLayerIndex() const
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
const SubLayerCrossing & other() const
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const
virtual const Surface::PositionType & position() const
Returns position of the surface.
static bool add(const GeometricSearchDet &det, const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result)
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