15 #include <dataharvester/Writer.h> 21 void sortTracksByPt(std::vector<reco::TransientTrack>&
cont) {
26 for (
auto const& tk :
cont) {
28 pt2[
i++] = tk.impactPointState().globalMomentum().perp2();
32 std::sort(ind, ind +
s, [p_pt2](
int i,
int j) {
return p_pt2[
i] > p_pt2[
j]; });
33 std::vector<reco::TransientTrack>
tmp;
35 for (
auto i = 0
U;
i <
s; ++
i)
45 const float initialError = 10000;
47 ret(0, 0) = initialError;
48 ret(1, 1) = initialError;
49 ret(2, 2) = initialError;
66 GlobalError const linPointError = initLinePointError();
68 void sortByDistanceToRefPoint(std::vector<RefCountedVertexTrack>&
cont,
const GlobalPoint ref) {
73 for (
auto const& tk :
cont) {
75 d2[
i++] = (tk->linearizedTrack()->track().initialFreeState().position() - ref).
mag2();
79 std::sort(ind, ind +
s, [p_d2](
int i,
int j) {
return p_d2[
i] < p_d2[
j]; });
80 std::vector<RefCountedVertexTrack>
tmp;
82 for (
auto i = 0
U;
i <
s; ++
i)
89 map<RefCountedLinearizedTrackState, int> ids;
92 int getId(
const RefCountedLinearizedTrackState& r) {
94 if (ids.count(r) == 0) {
109 theLinP(linP.
clone()),
111 theSmoother(smoother.
clone()),
112 theAssProbComputer(ann.
clone()),
113 theComp(crit.
clone()),
114 theLinTrkFactory(ltsf.
clone()),
115 gsfIntermediarySmoothing_(
false) {
122 : theMaxShift(
o.theMaxShift),
123 theMaxLPShift(
o.theMaxLPShift),
124 theMaxStep(
o.theMaxStep),
125 theWeightThreshold(
o.theWeightThreshold),
127 theLinP(
o.theLinP->
clone()),
128 theUpdator(
o.theUpdator->
clone()),
129 theSmoother(
o.theSmoother->
clone()),
130 theAssProbComputer(
o.theAssProbComputer->
clone()),
131 theComp(
o.theComp->
clone()),
132 theLinTrkFactory(
o.theLinTrkFactory->
clone()),
133 gsfIntermediarySmoothing_(
o.gsfIntermediarySmoothing_) {}
153 s.getParameter<
double>(
"maxlpshift"),
154 s.getParameter<
int>(
"maxstep"),
155 s.getParameter<
double>(
"weightthreshold"));
159 if (unstracks.size() < 2) {
160 LogError(
"RecoVertex|AdaptiveVertexFitter") <<
"Supplied fewer than two tracks. Vertex is invalid.";
163 vector<reco::TransientTrack>
tracks = unstracks;
172 return fit(vtContainer,
seed,
false);
177 LogError(
"RecoVertex|AdaptiveVertexFitter") <<
"Supplied fewer than two tracks. Vertex is invalid.";
189 LogError(
"RecoVertex|AdaptiveVertexFitter") <<
"Supplied no tracks. Vertex is invalid.";
202 LogError(
"RecoVertex|AdaptiveVertexFitter") <<
"Supplied fewer than two tracks. Vertex is invalid.";
209 return fit(vtContainer, fitseed,
false);
218 if (unstracks.empty()) {
219 LogError(
"RecoVertex|AdaptiveVertexFitter") <<
"Supplied no tracks. Vertex is invalid.";
224 vector<RefCountedVertexTrack> vtContainer;
226 vector<reco::TransientTrack>
tracks = unstracks;
239 return fit(vtContainer, beamSpotState,
true);
253 LogError(
"RecoVertex|AdaptiveVertexFitter") <<
"Supplied no tracks. Vertex is invalid.";
258 return fit(vtContainer,
seed,
true);
269 LogError(
"RecoVertex|AdaptiveVertexFitter") <<
"Supplied no tracks. Vertex is invalid.";
286 vector<RefCountedLinearizedTrackState> lTracks;
287 for (vector<reco::TransientTrack>::const_iterator
i =
tracks.begin();
i !=
tracks.end(); ++
i) {
290 lTracks.push_back(lTrData);
292 LogInfo(
"RecoVertex/AdaptiveVertexFitter") <<
"Exception " <<
e.what() <<
" in ::linearizeTracks." 293 <<
"Your future vertex has just lost a track.";
308 vector<RefCountedLinearizedTrackState> lTracks;
309 for (vector<RefCountedVertexTrack>::const_iterator
i =
tracks.begin();
i !=
tracks.end();
i++) {
317 lTracks.push_back(lTrData);
319 LogInfo(
"RecoVertex/AdaptiveVertexFitter") <<
"Exception " <<
e.what() <<
" in ::relinearizeTracks. " 320 <<
"Will not relinearize this track.";
321 lTracks.push_back((**i).linearizedTrack());
333 LogInfo(
"RecoVertex/AdaptiveVertexFitter") <<
"Weight " <<
weight <<
" > 1.0!";
351 vector<RefCountedVertexTrack> finalTracks;
356 for (vector<RefCountedLinearizedTrackState>::const_iterator
i = lTracks.begin();
i != lTracks.end();
i++) {
359 pair<bool, double> chi2Res(
false, 0.);
365 if (!chi2Res.first) {
367 LogInfo(
"AdaptiveVertexFitter") <<
"When reweighting, chi2<0. Will add this track with w=0.";
376 map<string, dataharvester::MultiType>
m;
381 m[
"pos"] =
"reweight";
386 finalTracks.push_back(vTrData);
394 const vector<RefCountedLinearizedTrackState>& lTracks,
const VertexState&
seed)
const {
401 vector<RefCountedVertexTrack> finalTracks;
406 for (vector<RefCountedLinearizedTrackState>::const_iterator
i = lTracks.begin();
i != lTracks.end();
i++) {
409 if (!chi2Res.first) {
411 LogInfo(
"AdaptiveVertexFitter") <<
"When weighting a track, chi2 calculation failed;" 412 <<
" will add with w=0.";
418 map<string, dataharvester::MultiType>
m;
427 finalTracks.push_back(vTrData);
439 vector<RefCountedLinearizedTrackState> lTracks;
440 for (vector<RefCountedVertexTrack>::const_iterator
i =
tracks.begin();
i !=
tracks.end();
i++) {
441 lTracks.push_back((**i).linearizedTrack());
453 bool withPrior)
const {
457 vector<RefCountedVertexTrack> initialTracks;
461 CachingVertex<5> returnVertex(priorVertexPosition, priorVertexError, initialTracks, 0);
464 priorVertexPosition, priorVertexError, priorVertexPosition, priorVertexError, initialTracks, 0);
467 std::vector<RefCountedVertexTrack> globalVTracks =
tracks;
469 sortByDistanceToRefPoint(globalVTracks, priorSeed.
position());
493 if ((previousPosition - newPosition).transverse() >
theMaxLPShift) {
510 for (vector<RefCountedVertexTrack>::const_iterator
i = globalVTracks.begin();
i != globalVTracks.end();
i++) {
511 if ((**i).weight() > 0.)
519 if (fabs(
nVertex.position().z()) > 10000. ||
nVertex.position().perp() > 120.) {
521 LogInfo(
"AdaptiveVertexFitter")
522 <<
"Vertex candidate just took off to " <<
nVertex.position() <<
"! Will discard this update!";
534 LogInfo(
"RecoVertex/AdaptiveVertexFitter")
535 <<
"The updator returned an invalid vertex when adding track " <<
i - globalVTracks.begin()
536 <<
".\n Your vertex might just have lost one good track.";
539 previousPosition = newPosition;
541 returnVertex = fVertex;
555 <<
" Fitted vertex is invalid.";
560 map<string, dataharvester::MultiType>
m;
virtual bool isAnnealed() const =0
AdaptiveVertexFitter * clone() const override
virtual RefCountedLinearizedTrackState linearizedTrackState(const GlobalPoint &linP, const reco::TransientTrack &track) const =0
LinearizationPointFinder * theLinP
ret
prodAgent to be discontinued
VertexUpdator< 5 > * theUpdator
CachingVertex< 5 > fit(const std::vector< RefCountedVertexTrack > &tracks, const VertexState &priorSeed, bool withPrior) const
VertexState const & vertexState() const
Log< level::Error, false > LogError
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &) const override
void setWeightThreshold(float w)
virtual CachingVertex< N > add(const CachingVertex< N > &v, const typename CachingVertex< N >::RefCountedVertexTrack t) const =0
GlobalError error() const
VertexSmoother< 5 > * theSmoother
AnnealingSchedule * theAssProbComputer
Log< level::Info, false > LogInfo
virtual double currentTemp() const =0
std::vector< RefCountedVertexTrack > reWeightTracks(const std::vector< RefCountedLinearizedTrackState > &, const CachingVertex< 5 > &seed) const
double getWeight(float chi2) const
std::vector< RefCountedVertexTrack > reLinearizeTracks(const std::vector< RefCountedVertexTrack > &tracks, const CachingVertex< 5 > &vertex) const
void setParameters(double maxshift=0.0001, double maxlpshift=0.1, unsigned maxstep=30, double weightthreshold=.001)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
AdaptiveVertexFitter(const AnnealingSchedule &ann=GeometricAnnealing(), const LinearizationPointFinder &linP=DefaultLinearizationPointFinder(), const VertexUpdator< 5 > &updator=KalmanVertexUpdator< 5 >(), const VertexTrackCompatibilityEstimator< 5 > &estor=KalmanVertexTrackCompatibilityEstimator< 5 >(), const VertexSmoother< 5 > &smoother=DummyVertexSmoother< 5 >(), const AbstractLTSFactory< 5 > <sf=LinearizedTrackStateFactory())
static unsigned int getId()
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
virtual CachingVertex< N > smooth(const CachingVertex< N > &vertex) const =0
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
virtual GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const =0
std::vector< RefCountedVertexTrack > linearizeTracks(const std::vector< reco::TransientTrack > &, const VertexState &) const
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
virtual void resetAnnealing()=0
double theWeightThreshold
~AdaptiveVertexFitter() override
GlobalPoint position() const
virtual double weight(double chi2) const =0
std::vector< RefCountedVertexTrack > weightTracks(const std::vector< RefCountedLinearizedTrackState > &, const VertexState &seed) const
cont
load Luminosity info ##
const AbstractLTSFactory< 5 > * theLinTrkFactory
VertexTrackCompatibilityEstimator< 5 > * theComp
GlobalPoint position() const
bool gsfIntermediarySmoothing_