CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TBPLayer.cc
Go to the documentation of this file.
1 #include "TBPLayer.h"
2 
4 
5 #include "LayerCrossingSide.h"
6 #include "DetGroupMerger.h"
8 #include "BarrelUtil.h"
9 
10 
16 
17 
18 using namespace std;
19 
21 
22 
23 void TBPLayer::construct() {
24  theComps.assign(theInnerComps.begin(),theInnerComps.end());
25  theComps.insert(theComps.end(),theOuterComps.begin(),theOuterComps.end());
26 
27  for(vector<const GeometricSearchDet*>::const_iterator it=theComps.begin();
28  it!=theComps.end();it++){
29  theBasicComps.insert(theBasicComps.end(),
30  (**it).basicComponents().begin(),
31  (**it).basicComponents().end());
32  }
33 
34  theInnerCylinder = cylinder( theInnerComps);
35  theOuterCylinder = cylinder( theOuterComps);
36 
37  if (theInnerComps.size())
38  theInnerBinFinder = BinFinderType(theInnerComps.front()->position().phi(),
39  theInnerComps.size());
40 
41  if (theOuterComps.size())
42  theOuterBinFinder = BinFinderType(theOuterComps.front()->position().phi(),
43  theOuterComps.size());
44 
46 
47  //--------- DEBUG INFO --------------
48  LogDebug("TkDetLayers") << "==== DEBUG TBPLayer =====" ;
49  LogDebug("TkDetLayers") << "innerCyl radius, thickness, lenght: "
50  << theInnerCylinder->radius() << " , "
51  << theInnerCylinder->bounds().thickness() << " , "
52  << theInnerCylinder->bounds().length() ;
53 
54  LogDebug("TkDetLayers") << "outerCyl radius, thickness, lenght: "
55  << theOuterCylinder->radius() << " , "
56  << theOuterCylinder->bounds().thickness() << " , "
57  << theOuterCylinder->bounds().length() ;
58 
59  LogDebug("TkDetLayers") << "Cyl radius, thickness, lenght: "
60  << specificSurface().radius() << " , "
61  << specificSurface().bounds().thickness() << " , "
62  << specificSurface().bounds().length() ;
63 
64  for (vector<const GeometricSearchDet*>::const_iterator i=theInnerComps.begin();
65  i != theInnerComps.end(); i++){
66  LogDebug("TkDetLayers") << "inner Rod pos z,perp,eta,phi: "
67  << (**i).position().z() << " , "
68  << (**i).position().perp() << " , "
69  << (**i).position().eta() << " , "
70  << (**i).position().phi() ;
71  }
72 
73  for (vector<const GeometricSearchDet*>::const_iterator i=theOuterComps.begin();
74  i != theOuterComps.end(); i++){
75  LogDebug("TkDetLayers") << "outer Rod pos z,perp,eta,phi: "
76  << (**i).position().z() << " , "
77  << (**i).position().perp() << " , "
78  << (**i).position().eta() << " , "
79  << (**i).position().phi() ;
80  }
81  LogDebug("TkDetLayers") << "==== end DEBUG TBPLayer =====" ;
82 }
83 
84 
85 TBPLayer::~TBPLayer(){}
86 
87 BoundCylinder* TBPLayer::cylinder( const vector<const GeometricSearchDet*>& rods) const
88 {
89  vector<const GeomDet*> tmp;
90  for (vector<const GeometricSearchDet*>::const_iterator it=rods.begin(); it!=rods.end(); it++) {
91  tmp.insert(tmp.end(),(*it)->basicComponents().begin(),(*it)->basicComponents().end());
92  }
93  return CylinderBuilderFromDet()( tmp.begin(), tmp.end());
94 }
95 
96 
97 // private methods for the implementation of groupedCompatibleDets()
98 
99 std::tuple<bool,int,int> TBPLayer::computeIndexes(GlobalPoint gInnerPoint, GlobalPoint gOuterPoint) const {
100  int innerIndex = theInnerBinFinder.binIndex(gInnerPoint.barePhi());
101  float innerDist = theInnerBinFinder.binPosition(innerIndex) - gInnerPoint.barePhi();
102 
103  int outerIndex = theOuterBinFinder.binIndex(gOuterPoint.barePhi());
104  float outerDist = theOuterBinFinder.binPosition(outerIndex) - gOuterPoint.barePhi() ;
105 
106 
107  innerDist *= PhiLess()( theInnerBinFinder.binPosition(innerIndex),gInnerPoint.barePhi()) ? -1.f : 1.f;
108  outerDist *= PhiLess()( theOuterBinFinder.binPosition(outerIndex),gOuterPoint.barePhi()) ? -1.f : 1.f;
109  if (innerDist < 0.f) { innerDist += Geom::ftwoPi();}
110  if (outerDist < 0.f) { outerDist += Geom::ftwoPi();}
111 
112  return std::make_tuple(innerDist < outerDist,innerIndex, outerIndex);
113 }
114 
115 
116 
117 float TBPLayer::computeWindowSize( const GeomDet* det,
118  const TrajectoryStateOnSurface& tsos,
119  const MeasurementEstimator& est) const
120 {
121 
122  return barrelUtil::computeWindowSize(det,tsos,est);
123 }
124 
125 
126 void TBPLayer::searchNeighbors( const TrajectoryStateOnSurface& tsos,
127  const Propagator& prop,
128  const MeasurementEstimator& est,
129  const SubLayerCrossing& crossing,
130  float window,
131  vector<DetGroup>& result,
132  bool checkClosest) const {
133  using barrelUtil::overlap;
134 
135  GlobalPoint gCrossingPos = crossing.position();
136  auto gphi = gCrossingPos.barePhi();
137 
138  const vector<const GeometricSearchDet*>& sLayer( subLayer( crossing.subLayerIndex()));
139 
140  int closestIndex = crossing.closestDetIndex();
141  int negStartIndex = closestIndex-1;
142  int posStartIndex = closestIndex+1;
143 
144  if (checkClosest) { // must decide if the closest is on the neg or pos side
145  if ( PhiLess()( gphi, sLayer[closestIndex]->surface().phi())) {
146  posStartIndex = closestIndex;
147  }
148  else {
149  negStartIndex = closestIndex;
150  }
151  }
152 
153  const BinFinderType& binFinder = (crossing.subLayerIndex()==0 ? theInnerBinFinder : theOuterBinFinder);
154 
155  typedef CompatibleDetToGroupAdder Adder;
156  int quarter = sLayer.size()/4;
157  for (int idet=negStartIndex; idet >= negStartIndex - quarter; idet--) {
158  const GeometricSearchDet & neighborRod = *sLayer[binFinder.binIndex(idet)];
159  if (!overlap( gphi, neighborRod, window)) break;
160  if (!Adder::add( neighborRod, tsos, prop, est, result)) break;
161  // maybe also add shallow crossing angle test here???
162  }
163  for (int idet=posStartIndex; idet < posStartIndex + quarter; idet++) {
164  const GeometricSearchDet & neighborRod = *sLayer[binFinder.binIndex(idet)];
165  if (!overlap( gphi, neighborRod, window)) break;
166  if (!Adder::add( neighborRod, tsos, prop, est, result)) break;
167  // maybe also add shallow crossing angle test here???
168  }
169 }
170 
171 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
def window
Definition: svgfig.py:642
virtual void initialize()
int closestDetIndex() const
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
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
T barePhi() const
Definition: PV3DBase.h:68
int subLayerIndex() const
tuple result
Definition: query.py:137
double f[11][100]
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
bool overlap(float phi, const GeometricSearchDet &gsdet, float phiWin)
Definition: BarrelUtil.h:46
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
Definition: BarrelUtil.h:35
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
float ftwoPi()
Definition: Pi.h:36
Definition: DDAxes.h:10