24 template <
class T>
T sqr(
T t) {
return t*
t;}
32 std::stringstream& ss,
33 std::vector<Quad>& quadV)
40 if ( phits.
size() < 2)
return 0;
41 if ( mhits.
size() < 2)
return 0;
50 std::cout <<
" --------------------------------------------------------------------------" <<
"\n";
51 std::cout <<
" Starting a hit quad fast reco " <<
"\n";
52 std::cout <<
" --------------------------------------------------------------------------" <<
"\n";
63 vHit[0]=ptth2->globalPosition();
64 vHit[1]=ptth1->globalPosition();
65 vHit[2]=mtth1->globalPosition();
66 vHit[3]=mtth2->globalPosition();
80 TVector3 vPhotVertex(vgPhotVertex.
x(), vgPhotVertex.
y(), vgPhotVertex.
z());
82 TVector3 h1(vHit[0].
x(),vHit[0].
y(),vHit[0].
z());
83 TVector3 h2(vHit[1].
x(),vHit[1].
y(),vHit[1].
z());
84 TVector3 h3(vHit[2].
x(),vHit[2].
y(),vHit[2].
z());
85 TVector3 h4(vHit[3].
x(),vHit[3].
y(),vHit[3].
z());
93 double candPtPlus, candPtMinus;
98 if ( ! (nite &&
abs(nite) < 25 && nite != -1000 && nite != -2000) )
return 0;
103 #ifdef mydebug_sguazz
104 std::cout <<
" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" <<
"\n";
105 std::cout <<
" >>>>>>>>>>> Conv Cand: " <<
" Vertex X: " << candVtx.X() <<
" [cm] Y: " << candVtx.Y() <<
" [cm] pt+: " << candPtPlus<<
" [GeV] pt-: " << candPtMinus <<
" [GeV]; #its: " << nite <<
"\n";
111 double quadPhotCotTheta = 0.;
113 simpleGetSlope(ptth2, ptth1, mtth1, mtth2, region, quadPhotCotTheta, quadZ0);
116 double quadPhotPhi = (candVtx-vPhotVertex).
Phi();
118 TVector3 fittedPrimaryVertex(vgPhotVertex.
x(), vgPhotVertex.
y(),quadZ0);
120 candVtx.SetZ(candVtx.Perp()*quadPhotCotTheta+quadZ0);
121 GlobalPoint convVtxGlobalPoint(candVtx.X(),candVtx.Y(),candVtx.Z());
128 thisQuad.
x = candVtx.X();
129 thisQuad.y = candVtx.Y();
130 thisQuad.z = candVtx.Z();
131 thisQuad.ptPlus = candPtPlus;
132 thisQuad.ptMinus = candPtMinus;
133 thisQuad.cot = quadPhotCotTheta;
139 FastHelix helixPlus(ptth2->globalPosition(), ptth1->globalPosition(), convVtxGlobalPoint, es, convVtxGlobalPoint);
142 GlobalVector(candPtPlus*
cos(quadPhotPhi),candPtPlus*
sin(quadPhotPhi),candPtPlus*quadPhotCotTheta),
144 & kinePlus.magneticField()
149 FastHelix helixMinus(mtth2->globalPosition(), mtth1->globalPosition(), convVtxGlobalPoint, es, convVtxGlobalPoint);
152 GlobalVector(candPtMinus*
cos(quadPhotPhi),candPtMinus*
sin(quadPhotPhi),candPtMinus*quadPhotCotTheta),
154 & kineMinus.magneticField()
157 float sinThetaPlus =
sin(kinePlus.momentum().theta());
158 float sinThetaMinus =
sin(kineMinus.momentum().theta());
174 if ( vError > 15. ) vError = 1.;
176 << vgPhotVertex.
x() <<
" " << vgPhotVertex.
y() <<
" " << vgPhotVertex.
z() <<
" " << vError <<
" "
181 << candVtx.X() <<
" " << candVtx.Y() <<
" " << candVtx.Z() <<
" "
182 << fittedPrimaryVertex.X() <<
" " << fittedPrimaryVertex.Y() <<
" " << fittedPrimaryVertex.Z() <<
" "
183 << candPtPlus <<
" " << rPlus <<
" " << plusCenter.X() <<
" " << plusCenter.Y() <<
" "
184 << candPtMinus <<
" " << rMinus <<
" " << minusCenter.X() <<
" " << minusCenter.Y() <<
" "
185 << nite <<
" " << chi2 <<
"\n";
187 #ifdef mydebug_sguazz
188 std::cout <<
" >>>>> Hit quad fast reco done >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" <<
"\n";
190 std::cout <<
"[SeedForPhotonConversionFromQuadruplets]\n ptth1 " ;
191 detid=ptth1->geographicalId().rawId();
193 std::cout <<
" \t " << detid <<
" " << ptth1->localPosition() <<
" " << ptth1->globalPosition() ;
194 detid=ptth2->geographicalId().rawId();
197 std::cout <<
" \t " << detid <<
" " << ptth2->localPosition() <<
" " << ptth2->globalPosition()
198 <<
"\nhelix momentum " << kinePlus.momentum() <<
" pt " << kinePlus.momentum().perp() <<
" radius " << 1/kinePlus.transverseCurvature() <<
" q " << kinePlus.charge();
200 detid=mtth1->geographicalId().rawId();
201 std::cout <<
" \t " << detid <<
" " << mtth1->localPosition() <<
" " << mtth1->globalPosition() ;
203 detid=mtth2->geographicalId().rawId();
205 std::cout <<
" \t " << detid <<
" " << mtth2->localPosition() <<
" " << mtth2->globalPosition()
206 <<
"\nhelix momentum " << kineMinus.momentum() <<
" pt " << kineMinus.momentum().perp() <<
" radius " << 1/kineMinus.transverseCurvature() <<
" q " << kineMinus.charge();
207 std::cout <<
"\n <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" <<
"\n";
210 buildSeed(seedCollection,phits,ftsPlus,es);
211 return buildSeed(seedCollection,mhits,ftsMinus,es);
220 const float cotTheta)
const
228 FastHelix helix(tth2->globalPosition(), tth1->globalPosition(), vertexPos, es, vertexPos);
229 kine = helix.stateAtVertex().parameters();
234 GlobalVector(kine.momentum().x(),kine.momentum().y(),kine.momentum().perp()*cotTheta),
236 & kine.magneticField()
247 (*pss) <<
"[SeedForPhotonConversionFromQuadruplets] initialKinematic tth1 " ;
248 detid=tth1->geographicalId().rawId();
250 (*pss) <<
" \t " << detid <<
" " << tth1->localPosition() <<
" " << tth1->globalPosition() ;
251 detid= tth2->geographicalId().rawId();
252 (*pss) <<
" \n\t tth2 ";
254 (*pss) <<
" \t " << detid <<
" " << tth2->localPosition() <<
" " << tth2->globalPosition()
276 float sinTheta)
const
281 sqr(vertexBounds.
y()), 0, 0,
282 sqr(vertexBounds.
z())
291 float sin2th =
sqr(sinTheta);
294 float zErr = vertexErr.
czz();
295 float transverseErr = vertexErr.
cxx();
296 C[3][3] = transverseErr;
297 C[4][4] = zErr*sin2th + transverseErr*(1-sin2th);
326 for (
unsigned int iHit = 0; iHit < hits.
size() && iHit<1; iHit++) {
327 hit = hits[iHit]->hit();
331 if (!state.
isValid())
return 0;
338 if (!
checkHit(state,newtth,es))
return 0;
340 updatedState = updator.
update(state, *newtth);
341 if (!updatedState.
isValid())
return 0;
343 seedHits.
push_back(newtth->hit()->clone());
346 (*pss) <<
"\n[SeedForPhotonConversionFromQuadruplets] hit " << iHit;
349 <<
" tth " << tth->localPosition() <<
" newtth " << newtth->localPosition() <<
" state " << state.
globalMomentum().
perp();
358 return &seedCollection.back();
372 return hit->clone(state);
381 (*pss) <<
"\n" << s <<
"\t";
382 for(
size_t i=0;
i<2;++
i)
383 (*
pss) << std::setw (60) << d[
i] << std::setw(1) <<
" | ";
388 (*pss) <<
"\n" << s <<
"\t";
389 for(
size_t i=0;
i<2;++
i)
390 (*
pss) << std::setw (60) << d[
i] << std::setw(1) <<
" | ";
395 (*pss) <<
"\n" << s <<
"\t";
396 for(
size_t i=0;
i<2;++
i)
397 (*
pss) << std::setw(20) << d[
i] <<
" r " << d[
i].
perp() <<
" phi " << d[
i].
phi() <<
" | ";
402 (*pss) <<
"\n" << s <<
"\n";
404 (*
pss) << std::setw(20) << d[
i] <<
" r " << d[
i].
perp() <<
" phi " << d[
i].
phi() <<
"\n";
417 for (
int i = 0;
i < n -
j;
i++) {
436 for (
int i = 0;
i < n -
j;
i++) {
451 double x[5],
y[5], e2y[5];
456 x[0] = ohit->globalPosition().perp();
457 y[0] = ohit->globalPosition().z();
460 x[1] = nohit->globalPosition().perp();
461 y[1] = nohit->globalPosition().z();
464 x[2] = nihit->globalPosition().perp();
465 y[2] = nihit->globalPosition().z();
468 x[3] = ihit->globalPosition().perp();
469 y[3] = ihit->globalPosition().z();
476 if ( vError > 15. ) vError = 1.;
477 e2y[4] =
sqr(vError);
480 double chi2 =
verySimpleFit(5, x, y, e2y, z0, e2z0, cotTheta);
498 double sqrProjFactor =
sqr((hit->globalPosition().z()-region.
origin().
z())/(hit->globalPosition().perp()-region.
origin().
perp()));
499 return (hit->globalPositionError().czz()+sqrProjFactor*hit->globalPositionError().rerr(hit->globalPosition()));
505 BOOST_FOREACH(
Quad quad, quadV )
507 double dx = thisQuad.
x-quad.
x;
508 double dy = thisQuad.
y-quad.
y;
509 double dz =
abs(thisQuad.
z-quad.
z);
510 if (
sqrt(dx*dx+dy*dy)<1. &&
518 quadV.push_back(thisQuad);
TVector3 GetMinusCenter(double &)
static const int cotTheta_Max
virtual CurvilinearTrajectoryError initialError(const GlobalVector &vertexBounds, float ptMin, float sinTheta) const
std::pair< ALIstring, ALIstring > pss
virtual float ptMin() const =0
minimal pt of interest
virtual GlobalPoint origin() const =0
void stupidPrint(std::string s, float *d)
void bubbleReverseSortVsPhi(GlobalPoint arr[], int n, GlobalPoint vtx)
Sin< T >::type sin(const T &t)
Geom::Phi< T > phi() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
void bubbleSortVsPhi(GlobalPoint arr[], int n, GlobalPoint vtx)
uint32_t rawId() const
get the raw id
float transverseCurvature() const
double getSqrEffectiveErrorOnZ(const TransientTrackingRecHit::ConstRecHitPointer &hit, const TrackingRegion ®ion)
virtual GlobalTrajectoryParameters initialKinematic(const SeedingHitSet &hits, const GlobalPoint &vertexPos, const edm::EventSetup &es, const float cotTheta) const
double verySimpleFit(int size, double *ax, double *ay, double *e2y, double &p0, double &e2p0, double &p1)
std::vector< TrajectorySeed > TrajectorySeedCollection
const T & max(const T &a, const T &b)
GlobalVector momentum() const
Cos< T >::type cos(const T &t)
void print(std::stringstream &ss, const SiStripCluster &clus)
virtual TransientTrackingRecHit::RecHitPointer refitHit(const TransientTrackingRecHit::ConstRecHitPointer &hit, const TrajectoryStateOnSurface &state) const
virtual bool checkHit(const TrajectoryStateOnSurface &, const TransientTrackingRecHit::ConstRecHitPointer &hit, const edm::EventSetup &es) const
GlobalPoint position() const
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
double simpleGetSlope(const TransientTrackingRecHit::ConstRecHitPointer &ohit, const TransientTrackingRecHit::ConstRecHitPointer &nohit, const TransientTrackingRecHit::ConstRecHitPointer &ihit, const TransientTrackingRecHit::ConstRecHitPointer &nihit, const TrackingRegion ®ion, double &cotTheta, double &z0)
double deltaPhi(double phi1, double phi2)
Vector3DBase unit() const
int ConversionCandidate(TVector3 &, double &, double &)
virtual float originRBound() const =0
bounds the particle vertex in the transverse plane
virtual const TrajectorySeed * trajectorySeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &phits, const SeedingHitSet &mhits, const TrackingRegion ®ion, const edm::EventSetup &es, std::stringstream &ss, std::vector< Quad > &quadV)
std::vector< std::vector< double > > tmp
GlobalVector globalMomentum() const
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TransientTrackingRecHit &) const
virtual float originZBound() const =0
bounds the particle vertex in the longitudinal plane
Square< F >::type sqr(const F &f)
bool similarQuadExist(Quad &thisQuad, std::vector< Quad > &quadV)
std::string thePropagatorLabel
unsigned int size() const
const MagneticField & magneticField() const
TVector3 GetPlusCenter(double &)
DetId geographicalId() const
TrackCharge charge() const
virtual LocalPoint localPosition() const =0
virtual const TrajectorySeed * buildSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits, const FreeTrajectoryState &fts, const edm::EventSetup &es) const
tuple size
Write out results.
Global3DVector GlobalVector
void SetMaxNumberOfIterations(int val)