23 bool operator()(
const pair<vector<DetGroup>
const *,
int> &
a,
const pair<vector<DetGroup>
const *,
int> &
b)
const {
24 if(
a.second==2) {
return true;}
25 else if(
a.second==0) {
26 if(
b.second==2)
return false;
27 if(
b.second==1)
return true;
34 TIDLayer::TIDLayer(vector<const TIDRing*>&
rings):
39 setSurface( computeDisk( rings ) );
41 if ( theComps.size() != 3)
throw DetLayerException(
"Number of rings in TID layer is not equal to 3 !!");
43 for(vector<const GeometricSearchDet*>::const_iterator it=theComps.begin();
44 it!=theComps.end();it++){
45 theBasicComps.insert(theBasicComps.end(),
46 (**it).basicComponents().begin(),
47 (**it).basicComponents().end());
51 LogDebug(
"TkDetLayers") <<
"==== DEBUG TIDLayer =====" ;
52 LogDebug(
"TkDetLayers") <<
"r,zed pos , thickness, innerR, outerR: "
55 << this->specificSurface().bounds().thickness() <<
" , "
56 << this->specificSurface().innerRadius() <<
" , "
57 << this->specificSurface().outerRadius() ;
62 TIDLayer::computeDisk(
const vector<const TIDRing*>& rings)
const
64 float theRmin = rings.front()->specificSurface().
innerRadius();
65 float theRmax = rings.front()->specificSurface().outerRadius();
66 float theZmin = rings.front()->position().z() -
67 rings.front()->surface().bounds().thickness()/2;
68 float theZmax = rings.front()->position().z() +
69 rings.front()->surface().bounds().thickness()/2;
71 for (vector<const TIDRing*>::const_iterator
i = rings.begin();
i != rings.end();
i++) {
72 float rmin = (**i).specificSurface().innerRadius();
73 float rmax = (**i).specificSurface().outerRadius();
74 float zmin = (**i).position().z() - (**i).surface().bounds().thickness()/2.;
75 float zmax = (**i).position().z() + (**i).surface().bounds().thickness()/2.;
76 theRmin =
min( theRmin, rmin);
77 theRmax =
max( theRmax, rmax);
78 theZmin =
min( theZmin, zmin);
79 theZmax =
max( theZmax, zmax);
82 float zPos = (theZmax+theZmin)/2.;
87 theZmin-zPos, theZmax-zPos));
92 TIDLayer::~TIDLayer(){
93 vector<const GeometricSearchDet*>::const_iterator
i;
94 for (i=theComps.begin(); i!=theComps.end(); i++) {
106 std::vector<DetGroup> &
result)
const
108 vector<int> ringIndices = ringIndicesByCrossingProximity(startingState,prop);
109 if ( ringIndices.size()!=3 ) {
110 edm::LogError(
"TkDetLayers") <<
"TkRingedForwardLayer::groupedCompatibleDets : ringIndices.size() = "
111 << ringIndices.size() <<
" and not =3!!" ;
115 vector<DetGroup> closestResult;
116 vector<DetGroup> nextResult;
117 vector<DetGroup> nextNextResult;
118 vector<vector<DetGroup> > groupsAtRingLevel;
120 theComps[ringIndices[0]]->groupedCompatibleDetsV( startingState, prop, est, closestResult);
121 if ( closestResult.empty() ){
122 theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, result);
126 groupsAtRingLevel.push_back(closestResult);
129 float rWindow =
computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
130 if(!overlapInR(closestGel.trajectoryState(),ringIndices[1],rWindow)) {
131 result.swap(closestResult);
136 theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, nextResult);
137 if(nextResult.empty()) {
138 result.swap(closestResult);
141 groupsAtRingLevel.push_back(nextResult);
143 if(!overlapInR(closestGel.trajectoryState(),ringIndices[2],rWindow) ) {
145 orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,ringIndices,
result);
149 theComps[ringIndices[2]]->groupedCompatibleDetsV( startingState, prop, est, nextNextResult);
150 if(nextNextResult.empty()) {
152 orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,ringIndices,
result);
156 groupsAtRingLevel.push_back(nextNextResult);
158 orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,ringIndices,
result);
177 Crossing myXing( startPos, startDir,
rho, propDir );
182 for (
int i = 0; i < 3 ; i++ ) {
184 pair<bool,double> pathlen = myXing.pathLength( theRing);
185 if ( pathlen.first ) {
186 ringCrossings[
i] =
GlobalPoint( myXing.position(pathlen.second ));
196 int closestIndex = findClosest(ringCrossings);
197 int nextIndex = findNextIndex(ringCrossings,closestIndex);
198 if ( closestIndex<0 || nextIndex<0 )
return vector<int>();
199 int nextNextIndex = -1;
200 for(
int i=0; i<3 ; i++){
201 if(i!= closestIndex && i!=nextIndex) {
208 indices.push_back(closestIndex);
209 indices.push_back(nextIndex);
210 indices.push_back(nextNextIndex);
225 return maxDistance.
y();
229 void mergeOutward(vector< pair<vector<DetGroup>
const *,
int> >
const & groupPlusIndex,
230 std::vector<DetGroup> & result ) {
232 Merger::orderAndMergeTwoLevels(*groupPlusIndex[0].
first,
233 *groupPlusIndex[1].first,result,1,1);
234 int size = groupPlusIndex.size();
236 std::vector<DetGroup>
tmp;
238 Merger::orderAndMergeTwoLevels(tmp,*groupPlusIndex[2].
first,result,1,1);
243 void mergeInward(vector< pair<vector<DetGroup>
const *,
int> >
const & groupPlusIndex,
244 std::vector<DetGroup> & result ) {
246 int size = groupPlusIndex.size();
249 Merger::orderAndMergeTwoLevels(*groupPlusIndex[1].
first,
250 *groupPlusIndex[0].first,result,1,1);
252 std::vector<DetGroup>
tmp;
253 Merger::orderAndMergeTwoLevels(*groupPlusIndex[2].
first,
254 *groupPlusIndex[1].first,tmp,1,1);
255 Merger::orderAndMergeTwoLevels(tmp,*groupPlusIndex[0].
first,result,1,1);
263 const vector<vector<DetGroup> > & groups,
264 const vector<int> & indices,
265 std::vector<DetGroup> & result )
267 vector< pair<vector<DetGroup>
const *,
int> > groupPlusIndex;
269 for(
unsigned int i=0;i<groups.size();i++){
270 groupPlusIndex.push_back(pair<vector<DetGroup>
const *,
int>(&groups[i],indices[i]) );
279 mergeOutward(groupPlusIndex,result);
281 mergeInward(groupPlusIndex,result);
285 mergeOutward(groupPlusIndex,result);
287 mergeInward(groupPlusIndex,result);
293 TIDLayer::findClosest(
const GlobalPoint ringCrossing[3] )
const
296 const BoundDisk & theFrontRing =
static_cast<const BoundDisk &
>(theComps[0]->surface());
297 float initialR = 0.5*( theFrontRing.
innerRadius() +
299 float rDiff = fabs( ringCrossing[0].
perp() - initialR);
300 for (
int i = 1; i < 3 ; i++){
304 float testDiff = fabs( ringCrossing[i].
perp() - ringR);
305 if ( testDiff<rDiff ) {
314 TIDLayer::findNextIndex(
const GlobalPoint ringCrossing[3],
int closest )
const
317 int firstIndexToCheck = (closest != 0)? 0 : 1;
318 const BoundDisk & theFrontRing =
static_cast<const BoundDisk &
>(theComps[firstIndexToCheck]->surface());
322 float rDiff = fabs( ringCrossing[0].
perp() - initialR);
323 int theBin = firstIndexToCheck;
324 for (
int i = firstIndexToCheck+1; i < 3 ; i++){
329 float testDiff = fabs( ringCrossing[i].
perp() - ringR);
330 if ( testDiff<rDiff ) {
347 float thetamax = ( tsRadius + ymax)/(fabs(tsos.
globalPosition().
z())-10.);
352 float thetaRingMin = ringDisk.
innerRadius()/ ringMaxZ;
353 float thetaRingMax = ringDisk.
outerRadius()/ ringMinZ;
357 return !( thetamin > thetaRingMax || thetaRingMin > thetamax);
TkRotation< Scalar > RotationType
virtual PropagationDirection propagationDirection() const
Global3DPoint GlobalPoint
GlobalPoint globalPosition() const
Vector2DBase< float, LocalTag > Local2DVector
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const BoundPlane &plane) const
static int position[TOTALCHAMBERS][3]
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
Point3DBase< Scalar, GlobalTag > PositionType
virtual float thickness() const =0
const T & max(const T &a, const T &b)
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
bool operator()(const pair< vector< DetGroup > const *, int > &a, const pair< vector< DetGroup >const *, int > &b) const
const Bounds & bounds() const
std::vector< std::vector< double > > tmp
T perp() const
Magnitude of transverse component.
GlobalVector globalMomentum() const
const BoundPlane & surface() const
The nominal surface of the GeomDet.
float outerRadius() const
The outer radius of the disk.
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
float innerRadius() const
The inner radius of the disk.
const PositionType & position() const
tuple size
Write out results.
double transverseCurvature() const