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 =
std::abs( ringDisk.position().z()) - ringDisk.bounds().thickness()/2.;
105 float ringMaxZ =
std::abs( 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) :
119 if ( rings.size() != 3)
throw DetLayerException(
"Number of rings in TID layer is not equal to 3 !!");
120 setSurface( computeDisk( rings ) );
122 for(
int i=0; i!=3; ++
i) {
123 theComps[
i]=rings[
i];
125 theBasicComps.insert(theBasicComps.end(),
126 (*rings[
i]).basicComponents().begin(),
127 (*rings[
i]).basicComponents().end());
131 LogDebug(
"TkDetLayers") <<
"==== DEBUG TIDLayer =====" ;
132 LogDebug(
"TkDetLayers") <<
"r,zed pos , thickness, innerR, outerR: "
135 << this->specificSurface().bounds().thickness() <<
" , "
136 << this->specificSurface().innerRadius() <<
" , "
137 << this->specificSurface().outerRadius() ;
142 TIDLayer::computeDisk(
const vector<const TIDRing*>& rings)
const
144 float theRmin = rings.front()->specificSurface().innerRadius();
145 float theRmax = rings.front()->specificSurface().outerRadius();
146 float theZmin = rings.front()->position().z() -
147 rings.front()->surface().bounds().thickness()/2;
148 float theZmax = rings.front()->position().z() +
149 rings.front()->surface().bounds().thickness()/2;
151 for (vector<const TIDRing*>::const_iterator i = rings.begin(); i != rings.end(); i++) {
152 float rmin = (**i).specificSurface().innerRadius();
153 float rmax = (**i).specificSurface().outerRadius();
154 float zmin = (**i).position().z() - (**i).surface().bounds().thickness()/2.;
155 float zmax = (**i).position().z() + (**i).surface().bounds().thickness()/2.;
156 theRmin =
min( theRmin, rmin);
157 theRmax =
max( theRmax, rmax);
158 theZmin =
min( theZmin, zmin);
159 theZmax =
max( theZmax, zmax);
162 float zPos = (theZmax+theZmin)/2.;
167 theZmin-zPos, theZmax-zPos));
172 TIDLayer::~TIDLayer(){
173 for (
auto c : theComps)
delete c;
182 std::vector<DetGroup> &
result)
const
184 std::array<int,3>
const & ringIndices = ringIndicesByCrossingProximity(startingState,prop);
185 if ( ringIndices[0]==-1 ) {
186 edm::LogError(
"TkDetLayers") <<
"TkRingedForwardLayer::groupedCompatibleDets : error in CrossingProximity";
190 std::array<vector<DetGroup>,3> groupsAtRingLevel;
194 auto index = [&ringIndices,& ringOrder](
int i) {
return ringOrder[ringIndices[
i]];};
196 auto & closestResult = groupsAtRingLevel[
index(0)];
197 theComps[ringIndices[0]]->groupedCompatibleDetsV( startingState, prop, est, closestResult);
198 if ( closestResult.empty() ){
199 theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, result);
204 float rWindow =
computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
206 if(!overlapInR(closestGel.trajectoryState(),ringIndices[1],rWindow)) {
207 result.swap(closestResult);
212 auto & nextResult = groupsAtRingLevel[
index(1)];
213 theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, nextResult);
214 if(nextResult.empty()) {
215 result.swap(closestResult);
219 if(!overlapInR(closestGel.trajectoryState(),ringIndices[2],rWindow) ) {
221 orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,
result);
225 auto & nextNextResult = groupsAtRingLevel[
index(2)];
226 theComps[ringIndices[2]]->groupedCompatibleDetsV( startingState, prop, est, nextNextResult);
227 if(nextNextResult.empty()) {
229 orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,
result);
234 orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,
result);
242 typedef HelixForwardPlaneCrossing Crossing;
253 Crossing myXing( startPos, startDir,
rho, propDir );
258 for (
int i = 0; i < 3 ; i++ ) {
260 pair<bool,double> pathlen = myXing.pathLength( theRing);
261 if ( pathlen.first ) {
262 ringCrossings[
i] =
GlobalPoint( myXing.position(pathlen.second ));
272 int closestIndex = findClosest(ringCrossings);
273 int nextIndex = findNextIndex(ringCrossings,closestIndex);
274 if ( closestIndex<0 || nextIndex<0 )
return std::array<int,3>{{-1,-1,-1}};
275 int nextNextIndex = -1;
276 for(
int i=0; i<3 ; i++){
277 if(i!= closestIndex && i!=nextIndex) {
283 std::array<int,3> indices{{closestIndex,nextIndex,nextNextIndex}};
298 return maxDistance.
y();
303 TIDLayer::findClosest(
const GlobalPoint ringCrossing[3] )
const
306 float initialR = ringPars[0].theRingR;
307 float rDiff =
std::abs( ringCrossing[0].
perp() - initialR);
308 for (
int i = 1; i < 3 ; i++){
309 float ringR = ringPars[
i].theRingR;
310 float testDiff =
std::abs( ringCrossing[i].
perp() - ringR);
311 if ( testDiff<rDiff ) {
320 TIDLayer::findNextIndex(
const GlobalPoint ringCrossing[3],
int closest )
const
323 int firstIndexToCheck = (closest != 0)? 0 : 1;
324 float initialR = ringPars[firstIndexToCheck].theRingR;
325 float rDiff =
std::abs( ringCrossing[firstIndexToCheck].
perp() - initialR);
326 int theBin = firstIndexToCheck;
327 for (
int i = firstIndexToCheck+1; i < 3 ; i++){
329 float ringR = ringPars[
i].theRingR;
330 float testDiff =
std::abs( ringCrossing[i].
perp() - ringR);
331 if ( testDiff<rDiff ) {
352 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
Point3DBase< Scalar, GlobalTag > PositionType
const T & max(const T &a, const T &b)
Abs< T >::type abs(const T &t)
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
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