41 void mergeOutward(std::array<vector<DetGroup>,3> & groups,
42 std::vector<DetGroup> &
result ) {
44 Merger::orderAndMergeTwoLevels(std::move(groups[0]),
45 std::move(groups[1]),result,1,1);
46 if(!groups[2].
empty()) {
47 std::vector<DetGroup>
tmp;
49 Merger::orderAndMergeTwoLevels(std::move(tmp),std::move(groups[2]),result,1,1);
55 void mergeInward(std::array<vector<DetGroup>,3> & groups,
56 std::vector<DetGroup> & result ) {
58 Merger::orderAndMergeTwoLevels(std::move(groups[2]),
59 std::move(groups[1]),result,1,1);
60 if(!groups[0].
empty()) {
61 std::vector<DetGroup>
tmp;
63 Merger::orderAndMergeTwoLevels(std::move(tmp),std::move(groups[0]),result,1,1);
72 std::array<vector<DetGroup>,3> & groups,
73 std::vector<DetGroup> & result ) {
78 mergeOutward(groups,result);
80 mergeInward(groups,result);
84 mergeOutward(groups,result);
86 mergeInward(groups,result);
95 static std::vector<const GeometricSearchDet*> crap;
96 for (
auto c: theComps) crap.push_back(
c);
102 TIDLayer::fillRingPars(
int i) {
104 float ringMinZ = fabs( ringDisk.position().z()) - ringDisk.bounds().thickness()/2.;
105 float ringMaxZ = fabs( ringDisk.position().z()) + ringDisk.bounds().thickness()/2.;
106 ringPars[
i].thetaRingMin = ringDisk.innerRadius()/ ringMaxZ;
107 ringPars[
i].thetaRingMax = ringDisk.outerRadius()/ ringMinZ;
108 ringPars[
i].theRingR=( ringDisk.innerRadius() +
109 ringDisk.outerRadius())/2.;
114 TIDLayer::TIDLayer(vector<const TIDRing*>& rings) {
118 if ( rings.size() != 3)
throw DetLayerException(
"Number of rings in TID layer is not equal to 3 !!");
119 setSurface( computeDisk( rings ) );
121 for(
int i=0; i!=3; ++
i) {
122 theComps[
i]=rings[
i];
124 theBasicComps.insert(theBasicComps.end(),
125 (*rings[
i]).basicComponents().begin(),
126 (*rings[
i]).basicComponents().end());
130 LogDebug(
"TkDetLayers") <<
"==== DEBUG TIDLayer =====" ;
131 LogDebug(
"TkDetLayers") <<
"r,zed pos , thickness, innerR, outerR: "
134 << this->specificSurface().bounds().thickness() <<
" , "
135 << this->specificSurface().innerRadius() <<
" , "
136 << this->specificSurface().outerRadius() ;
141 TIDLayer::computeDisk(
const vector<const TIDRing*>& rings)
const
143 float theRmin = rings.front()->specificSurface().innerRadius();
144 float theRmax = rings.front()->specificSurface().outerRadius();
145 float theZmin = rings.front()->position().z() -
146 rings.front()->surface().bounds().thickness()/2;
147 float theZmax = rings.front()->position().z() +
148 rings.front()->surface().bounds().thickness()/2;
150 for (vector<const TIDRing*>::const_iterator i = rings.begin(); i != rings.end(); i++) {
151 float rmin = (**i).specificSurface().innerRadius();
152 float rmax = (**i).specificSurface().outerRadius();
153 float zmin = (**i).position().z() - (**i).surface().bounds().thickness()/2.;
154 float zmax = (**i).position().z() + (**i).surface().bounds().thickness()/2.;
155 theRmin =
min( theRmin, rmin);
156 theRmax =
max( theRmax, rmax);
157 theZmin =
min( theZmin, zmin);
158 theZmax =
max( theZmax, zmax);
161 float zPos = (theZmax+theZmin)/2.;
166 theZmin-zPos, theZmax-zPos));
171 TIDLayer::~TIDLayer(){
172 for (
auto c : theComps)
delete c;
181 std::vector<DetGroup> &
result)
const
183 std::array<int,3>
const & ringIndices = ringIndicesByCrossingProximity(startingState,prop);
184 if ( ringIndices[0]==-1 ) {
185 edm::LogError(
"TkDetLayers") <<
"TkRingedForwardLayer::groupedCompatibleDets : error in CrossingProximity";
189 std::array<vector<DetGroup>,3> groupsAtRingLevel;
193 auto index = [&ringIndices,& ringOrder](
int i) {
return ringOrder[ringIndices[
i]];};
195 auto & closestResult = groupsAtRingLevel[
index(0)];
196 theComps[ringIndices[0]]->groupedCompatibleDetsV( startingState, prop, est, closestResult);
197 if ( closestResult.empty() ){
198 theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, result);
203 float rWindow =
computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
205 if(!overlapInR(closestGel.trajectoryState(),ringIndices[1],rWindow)) {
206 result.swap(closestResult);
211 auto & nextResult = groupsAtRingLevel[
index(1)];
212 theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, nextResult);
213 if(nextResult.empty()) {
214 result.swap(closestResult);
218 if(!overlapInR(closestGel.trajectoryState(),ringIndices[2],rWindow) ) {
220 orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,
result);
224 auto & nextNextResult = groupsAtRingLevel[
index(2)];
225 theComps[ringIndices[2]]->groupedCompatibleDetsV( startingState, prop, est, nextNextResult);
226 if(nextNextResult.empty()) {
228 orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,
result);
233 orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,
result);
241 typedef HelixForwardPlaneCrossing Crossing;
252 Crossing myXing( startPos, startDir,
rho, propDir );
257 for (
int i = 0; i < 3 ; i++ ) {
259 pair<bool,double> pathlen = myXing.pathLength( theRing);
260 if ( pathlen.first ) {
261 ringCrossings[
i] =
GlobalPoint( myXing.position(pathlen.second ));
271 int closestIndex = findClosest(ringCrossings);
272 int nextIndex = findNextIndex(ringCrossings,closestIndex);
273 if ( closestIndex<0 || nextIndex<0 )
return std::array<int,3>{{-1,-1,-1}};
274 int nextNextIndex = -1;
275 for(
int i=0; i<3 ; i++){
276 if(i!= closestIndex && i!=nextIndex) {
282 std::array<int,3> indices{{closestIndex,nextIndex,nextNextIndex}};
297 return maxDistance.
y();
302 TIDLayer::findClosest(
const GlobalPoint ringCrossing[3] )
const
305 float initialR = ringPars[0].theRingR;
306 float rDiff = fabs( ringCrossing[0].
perp() - initialR);
307 for (
int i = 1; i < 3 ; i++){
308 float ringR = ringPars[
i].theRingR;
309 float testDiff = fabs( ringCrossing[i].
perp() - ringR);
310 if ( testDiff<rDiff ) {
319 TIDLayer::findNextIndex(
const GlobalPoint ringCrossing[3],
int closest )
const
322 int firstIndexToCheck = (closest != 0)? 0 : 1;
323 float initialR = ringPars[firstIndexToCheck].theRingR;
324 float rDiff = fabs( ringCrossing[0].
perp() - initialR);
325 int theBin = firstIndexToCheck;
326 for (
int i = firstIndexToCheck+1; i < 3 ; i++){
328 float ringR = ringPars[
i].theRingR;
329 float testDiff = fabs( ringCrossing[i].
perp() - ringR);
330 if ( testDiff<rDiff ) {
351 return !( thetamin > ringPars[
index].thetaRingMax || ringPars[
index].thetaRingMin > thetamax);
TkRotation< Scalar > RotationType
Global3DPoint GlobalPoint
GlobalPoint globalPosition() const
Vector2DBase< float, LocalTag > Local2DVector
const Plane & surface() const
The nominal surface of the GeomDet.
static int position[TOTALCHAMBERS][3]
virtual PropagationDirection propagationDirection() const GCC11_FINAL
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
Point3DBase< Scalar, GlobalTag > PositionType
const T & max(const T &a, const T &b)
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const
std::vector< std::vector< double > > tmp
T perp() const
Magnitude of transverse component.
GlobalVector globalMomentum() const
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
double transverseCurvature() const