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 if( not theComponents) {
96 std::unique_ptr<std::vector<const GeometricSearchDet*>>
temp(
new std::vector<const GeometricSearchDet*>() );
98 for (
auto c: theComps) temp->push_back(
c);
99 std::vector<const GeometricSearchDet*>* expected =
nullptr;
100 if(theComponents.compare_exchange_strong(expected,temp.get())) {
106 return *theComponents;
113 float ringMinZ =
std::abs( ringDisk.position().z()) - ringDisk.bounds().thickness()/2.;
114 float ringMaxZ =
std::abs( ringDisk.position().z()) + ringDisk.bounds().thickness()/2.;
115 ringPars[
i].thetaRingMin = ringDisk.innerRadius()/ ringMaxZ;
116 ringPars[
i].thetaRingMax = ringDisk.outerRadius()/ ringMinZ;
117 ringPars[
i].theRingR=( ringDisk.innerRadius() +
118 ringDisk.outerRadius())/2.;
125 theComponents{
nullptr}
130 if ( rings.size() != 3)
throw DetLayerException(
"Number of rings in TID layer is not equal to 3 !!");
131 setSurface( computeDisk( rings ) );
133 for(
int i=0;
i!=3; ++
i) {
134 theComps[
i]=rings[
i];
136 theBasicComps.insert(theBasicComps.end(),
137 (*rings[
i]).basicComponents().begin(),
138 (*rings[
i]).basicComponents().end());
142 LogDebug(
"TkDetLayers") <<
"==== DEBUG TIDLayer =====" ;
143 LogDebug(
"TkDetLayers") <<
"r,zed pos , thickness, innerR, outerR: "
146 << this->specificSurface().bounds().thickness() <<
" , "
147 << this->specificSurface().innerRadius() <<
" , "
148 << this->specificSurface().outerRadius() ;
155 float theRmin = rings.front()->specificSurface().innerRadius();
156 float theRmax = rings.front()->specificSurface().outerRadius();
157 float theZmin = rings.front()->position().z() -
158 rings.front()->surface().bounds().thickness()/2;
159 float theZmax = rings.front()->position().z() +
160 rings.front()->surface().bounds().thickness()/2;
162 for (vector<const TIDRing*>::const_iterator
i = rings.begin();
i != rings.end();
i++) {
163 float rmin = (**i).specificSurface().innerRadius();
164 float rmax = (**i).specificSurface().outerRadius();
165 float zmin = (**i).position().z() - (**i).surface().bounds().thickness()/2.;
166 float zmax = (**i).position().z() + (**i).surface().bounds().thickness()/2.;
167 theRmin =
min( theRmin, rmin);
168 theRmax =
max( theRmax, rmax);
169 theZmin =
min( theZmin, zmin);
170 theZmax =
max( theZmax, zmax);
173 float zPos = (theZmax+theZmin)/2.;
178 theZmin-zPos, theZmax-zPos));
195 std::vector<DetGroup> &
result)
const
198 if ( ringIndices[0]==-1 ) {
199 edm::LogError(
"TkDetLayers") <<
"TkRingedForwardLayer::groupedCompatibleDets : error in CrossingProximity";
203 std::array<vector<DetGroup>,3> groupsAtRingLevel;
207 auto index = [&ringIndices,& ringOrder](
int i) {
return ringOrder[ringIndices[
i]];};
209 auto & closestResult = groupsAtRingLevel[
index(0)];
211 if ( closestResult.empty() ){
217 float rWindow =
computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
219 if(!
overlapInR(closestGel.trajectoryState(),ringIndices[1],rWindow)) {
220 result.swap(closestResult);
225 auto & nextResult = groupsAtRingLevel[
index(1)];
227 if(nextResult.empty()) {
228 result.swap(closestResult);
232 if(!
overlapInR(closestGel.trajectoryState(),ringIndices[2],rWindow) ) {
234 orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,
result);
238 auto & nextNextResult = groupsAtRingLevel[
index(2)];
240 if(nextNextResult.empty()) {
242 orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,
result);
247 orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,
result);
266 Crossing myXing( startPos, startDir,
rho, propDir );
271 for (
int i = 0;
i < 3 ;
i++ ) {
273 pair<bool,double> pathlen = myXing.pathLength( theRing);
274 if ( pathlen.first ) {
275 ringCrossings[
i] =
GlobalPoint( myXing.position(pathlen.second ));
287 if ( closestIndex<0 || nextIndex<0 )
return std::array<int,3>{{-1,-1,-1}};
288 int nextNextIndex = -1;
289 for(
int i=0;
i<3 ;
i++){
290 if(
i!= closestIndex &&
i!=nextIndex) {
296 std::array<int,3> indices{{closestIndex,nextIndex,nextNextIndex}};
311 return maxDistance.
y();
320 float rDiff =
std::abs( ringCrossing[0].
perp() - initialR);
321 for (
int i = 1;
i < 3 ;
i++){
324 if ( testDiff<rDiff ) {
336 int firstIndexToCheck = (closest != 0)? 0 : 1;
338 float rDiff =
std::abs( ringCrossing[firstIndexToCheck].
perp() - initialR);
339 int theBin = firstIndexToCheck;
340 for (
int i = firstIndexToCheck+1;
i < 3 ;
i++){
344 if ( testDiff<rDiff ) {
TkRotation< Scalar > RotationType
virtual const std::vector< const GeometricSearchDet * > & components() const __attribute__((cold))
virtual PropagationDirection propagationDirection() const
Global3DPoint GlobalPoint
std::array< int, 3 > ringIndicesByCrossingProximity(const TrajectoryStateOnSurface &startingState, const Propagator &prop) const
GlobalPoint globalPosition() const
Vector2DBase< float, LocalTag > Local2DVector
const Plane & surface() const
The nominal surface of the GeomDet.
Point3DBase< Scalar, GlobalTag > PositionType
TIDLayer(std::vector< const TIDRing * > &rings) __attribute__((cold))
~TIDLayer() __attribute__((cold))
Abs< T >::type abs(const T &t)
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
virtual const BoundSurface & surface() const
The surface of the GeometricSearchDet.
std::atomic< std::vector< const GeometricSearchDet * > * > theComponents
void fillRingPars(int i) __attribute__((cold))
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const
bool overlapInR(const TrajectoryStateOnSurface &tsos, int i, double ymax) const __attribute__((hot))
std::vector< std::vector< double > > tmp
T perp() const
Magnitude of transverse component.
GlobalVector globalMomentum() const
static int position[264][3]
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const __attribute__((hot))
BoundDisk * computeDisk(const std::vector< const TIDRing * > &rings) const __attribute__((cold))
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
const TIDRing * theComps[3]
int findClosest(const GlobalPoint[3]) const __attribute__((hot))
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const __attribute__((hot))
int findNextIndex(const GlobalPoint[3], int) const __attribute__((hot))
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const __attribute__((hot))
double transverseCurvature() const