22 using namespace ctfseeding;
29 struct LayerRZPredictions {
36 static const double nSigmaRZ = 3.4641016151377544;
40 : thePairGenerator(0),
42 useFixedPreFiltering(cfg.getParameter<bool>(
"useFixedPreFiltering")),
43 extraHitRZtolerance(cfg.getParameter<double>(
"extraHitRZtolerance")),
44 extraHitRPhitolerance(cfg.getParameter<double>(
"extraHitRPhitolerance")),
45 useMScat(cfg.getParameter<bool>(
"useMultScattering")),
46 useBend(cfg.getParameter<bool>(
"useBending"))
54 const std::vector<SeedingLayer> &layers,
LayerCacheType *layerCache)
63 if (range.first >= second.max() || range.second <= second.min())
65 if (range.first < second.min())
66 range.first = second.min();
67 if (range.second > second.max())
68 range.second = second.max();
69 return range.first < range.second;
89 map<const DetLayer*, LayerRZPredictions> mapPred;
91 for(
int il = 0; il <
size; il++) {
92 thirdHitMap[il] = &(*theLayerCache)(&
theLayers[il], region, ev, es);
93 const DetLayer *layer = theLayers[il].detLayer();
94 LayerRZPredictions &predRZ = mapPred[layer];
95 predRZ.line.initLayer(layer);
96 predRZ.helix1.initLayer(layer);
97 predRZ.helix2.initLayer(layer);
106 for(OrderedHitPairs::const_iterator ip = pairs.begin();
107 ip != pairs.end(); ++ip) {
120 for(
int il = 0; il <
size; il++) {
129 LayerRZPredictions &predRZ = mapPred.find(layer)->second;
130 predRZ.line.initPropagator(&line);
154 Range z3s = predRZ.line.detRange();
155 double z3 = z3s.first < 0 ?
max(z3s.first, z3s.second)
156 :
min(z3s.first, z3s.second);
158 gp1.
z(), gp2.
z(), z3);
163 helix =
HelixRZ(&predictionRPhi, gp1.
z(), gp2.
z(), curvature.first);
164 HelixRZ helix2(&predictionRPhi, gp1.
z(), gp2.
z(), curvature.second);
166 predRZ.helix1.initPropagator(&helix);
167 predRZ.helix2.initPropagator(&helix2);
169 Range rzRanges[2] = { predRZ.helix1(), predRZ.helix2() };
170 rzRange.first =
min(rzRanges[0].
first, rzRanges[1].first);
171 rzRange.second =
max(rzRanges[0].
second, rzRanges[1].second);
175 if (curvature.first * curvature.second < 0.0) {
176 Range rzLineRange = predRZ.line();
177 rzRange.first =
min(rzRange.first, rzLineRange.first);
178 rzRange.second =
max(rzRange.second, rzLineRange.second);
181 rzRange = predRZ.line();
183 if (rzRange.first >= rzRange.second)
186 correction.correctRZRange(rzRange);
190 float phi0 = ip->outer()->globalPosition().phi();
196 radius = predRZ.line.detRange();
197 if (!
intersect(rzRange, predRZ.line.detSize()))
201 if (!
intersect(radius, predRZ.line.detSize()))
205 Range rPhi1 = predictionRPhi(curvature, radius.first);
206 Range rPhi2 = predictionRPhi(curvature, radius.second);
207 correction.correctRPhiRange(rPhi1);
208 correction.correctRPhiRange(rPhi2);
209 rPhi1.first /= radius.first;
210 rPhi1.second /= radius.first;
211 rPhi2.first /= radius.second;
212 rPhi2.second /= radius.second;
217 vector<Hit> thirdHits = thirdHitMap[il]->
hits(phiRange.min(), phiRange.max());
222 typedef vector<Hit>::const_iterator IH;
223 for (IH th=thirdHits.begin(), eh=thirdHits.end(); th < eh; ++th) {
225 double p3_r = p3.
perp();
226 double p3_z = p3.
z();
227 double p3_phi = p3.
phi();
229 Range rangeRPhi = predictionRPhi(curvature, p3_r);
230 correction.correctRPhiRange(rangeRPhi);
232 double phiErr =
nSigmaPhi *
sqrt((*th)->globalPositionError().phierr(p3));
233 if (!
checkPhiInRange(p3_phi, rangeRPhi.first/p3_r - phiErr, rangeRPhi.second/p3_r + phiErr))
239 double curv_ = predictionRPhi.curvature(thc);
240 double p2_r = point2.
r(), p2_z = point2.z();
242 l2rzFixup(predictionRPhi, curv_, *ip->outer(), p2_r, p2_z);
243 l3rzFixup(predictionRPhi, curv_, **th, p3_r, p3_z);
247 HelixRZ updatedHelix(&predictionRPhi, gp1.
z(), p2_z, curv_);
248 rangeRZ = predRZ.helix1(barrelLayer ? p3_r : p3_z, updatedHelix);
250 float tIP = predictionRPhi.transverseIP(thc);
253 rangeRZ = predRZ.line(barrelLayer ? p3_r : p3_z, line);
255 correction.correctRZRange(rangeRZ);
258 ? hit->globalPositionError().czz()
259 : hit->globalPositionError().rerr(p3));
260 rangeRZ.first -= err, rangeRZ.second += err;
262 if (!rangeRZ.inside(barrelLayer ? p3_z : p3_r))
266 edm::LogError(
"TooManyTriplets")<<
" number of triples exceed maximum. no triplets produced.";
267 delete[] thirdHitMap;
274 delete[] thirdHitMap;
279 while (phi > phi2) phi -= 2. *
M_PI;
280 while (phi < phi1) phi += 2. *
M_PI;
285 const std::pair<float, float> &r1,
const std::pair<float, float> &r2)
const
287 float r2Min = r2.first;
288 float r2Max = r2.second;
289 while (r1.first - r2Min > +
M_PI) r2Min += 2. *
M_PI, r2Max += 2. *
M_PI;
290 while (r1.first - r2Min < -
M_PI) r2Min -= 2. *
M_PI, r2Max -= 2. *
M_PI;
291 return std::make_pair(
min(r1.first, r2Min),
max(r1.second, r2Max));
T getParameter(std::string const &) const
virtual HitPairGenerator * clone() const =0
virtual float ptMin() const =0
minimal pt of interest
virtual Location location() const =0
Which part of the detector (barrel, endcap)
ThirdHitPredictionFromCircle::HelixRZ HelixRZ
static const double nSigmaPhi
std::vector< Hit > hits(float phiMin, float phiMax) const
Geom::Phi< T > phi() const
T r() const
Radius, same as mag()
bool useFixedPreFiltering
LayerCacheType * theLayerCache
float extraHitRPhitolerance
U second(std::pair< T, U > const &p)
bool checkPhiInRange(float phi, float phi1, float phi2) const
T curvature(T InversePt, const edm::EventSetup &iSetup)
const T & max(const T &a, const T &b)
virtual void hitPairs(const TrackingRegion ®, OrderedHitPairs &prs, const edm::EventSetup &es)
unsigned int theMaxElement
virtual void hitTriplets(const TrackingRegion ®ion, OrderedHitTriplets &trs, const edm::Event &ev, const edm::EventSetup &es)
static const double nSigmaRZ
std::pair< float, float > mergePhiRanges(const std::pair< float, float > &r1, const std::pair< float, float > &r2) const
float extraHitRZtolerance
HitPairGenerator * thePairGenerator
PixelRecoRange< float > Range
static double maxCurvature(const ThirdHitPredictionFromCircle *circle, double z1, double z2, double z3)
std::vector< ctfseeding::SeedingLayer > theLayers
virtual float originRBound() const =0
bounds the particle vertex in the transverse plane
static bool intersect(Range &range, const Range &second)
PixelTripletLargeTipGenerator(const edm::ParameterSet &cfg)
TransientTrackingRecHit::ConstRecHitPointer Hit
virtual void init(const HitPairGenerator &pairs, const std::vector< ctfseeding::SeedingLayer > &layers, LayerCacheType *layerCache)
virtual unsigned int size() const
tuple size
Write out results.