18 #include "TMinuitMinimizer.h"
23 thePtMin(ps.getParameter<double>(
"PtMin")),
24 thePeakFindThresh(ps.getParameter<unsigned int>(
"PeakFindThreshold")),
25 thePeakFindMaxZ(ps.getParameter<double>(
"PeakFindMaxZ")),
26 thePeakFindBinning(ps.getParameter<int>(
"PeakFindBinsPerCm")),
27 theFitThreshold(ps.getParameter<int>(
"FitThreshold")),
28 theFitMaxZ(ps.getParameter<double>(
"FitMaxZ")),
29 theFitBinning(ps.getParameter<int>(
"FitBinsPerCm")) {
30 produces<reco::VertexCollection>();
34 TMinuitMinimizer::UseStaticMinuit(
false);
45 std::vector<const reco::Track*>
tracks;
46 for (
unsigned int i = 0;
i < tracks_.size();
i++) {
47 if (tracks_[
i].
pt() <
thePtMin && std::fabs(tracks_[
i].vz()) < 100000.)
50 tracks.push_back(&(*recTrack));
53 LogTrace(
"MinBiasTracking") <<
" [VertexProducer] selected tracks: " << tracks.size() <<
" (out of " << tracks_.size()
57 auto vertices = std::make_unique<reco::VertexCollection>();
70 if (tracks.size() % 2 == 0)
71 med = (tracks[tracks.size() / 2 - 1]->vz() + tracks[tracks.size() / 2]->vz()) / 2;
73 med = tracks[tracks.size() / 2]->vz();
75 LogTrace(
"MinBiasTracking") <<
" [vertex position] median = " << med <<
" cm";
82 for (std::vector<const reco::Track*>::const_iterator
track = tracks.begin();
track != tracks.end();
track++)
83 if (fabs((*track)->vz()) < thePeakFindMaxZ)
84 hmax.Fill((*track)->vz());
86 int maxBin = hmax.GetMaximumBin();
88 LogTrace(
"MinBiasTracking") <<
" [vertex position] most prob = " << hmax.GetBinCenter(maxBin) <<
" cm";
92 for (
int i = -1;
i <= 1;
i++) {
93 num += hmax.GetBinContent(maxBin +
i) * hmax.GetBinCenter(maxBin +
i);
94 denom += hmax.GetBinContent(maxBin +
i);
99 err(2, 2) = 0.1 * 0.1;
106 float nBinAvg = num /
denom;
111 LogTrace(
"MinBiasTracking") <<
" [vertex position] 3-bin weighted average = " << nBinAvg <<
" cm";
118 for (std::vector<const reco::Track*>::const_iterator
track = tracks.begin();
track != tracks.end();
track++)
119 if (fabs((*track)->vz() - med) < theFitMaxZ)
120 histo.Fill((*track)->vz() - med);
122 LogTrace(
"MinBiasTracking") <<
" [vertex position] most prob for fit = "
123 << med + histo.GetBinCenter(histo.GetMaximumBin()) <<
" cm";
128 <<
" entries in fit histogram. Returning median.";
131 err(2, 2) = 0.1 * 0.1;
139 TF1
f1(
"f1",
"[0]*exp(-0.5 * ((x-[1])/[2])^2) + [3]");
140 f1.SetParameters(10., 0., 0.02, 0.002 * tracks.size());
141 f1.SetParLimits(1, -0.1, 0.1);
142 f1.SetParLimits(2, 0.001, 0.05);
143 f1.SetParLimits(3, 0.0, 0.005 * tracks.size());
145 histo.Fit(&f1,
"QN SERIAL");
147 LogTrace(
"MinBiasTracking") <<
" [vertex position] fitted = " << med + f1.GetParameter(1) <<
" +- "
148 << f1.GetParError(1) <<
" cm";
151 err(2, 2) = f1.GetParError(1) * f1.GetParError(1);
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
constexpr unsigned int maxBin
std::vector< Track > TrackCollection
collection of Tracks
math::Error< dimension >::type Error
covariance error matrix (3x3)
auto const & tracks
cannot be loose
math::XYZPoint Point
point in the space
T const * product() const