19 #include "TMinuitMinimizer.h" 24 thePtMin(ps.getParameter<double>(
"PtMin")),
25 thePeakFindThresh(ps.getParameter<unsigned
int>(
"PeakFindThreshold")),
26 thePeakFindMaxZ(ps.getParameter<double>(
"PeakFindMaxZ")),
27 thePeakFindBinning(ps.getParameter<
int>(
"PeakFindBinsPerCm")),
28 theFitThreshold(ps.getParameter<
int>(
"FitThreshold")),
29 theFitMaxZ(ps.getParameter<double>(
"FitMaxZ")),
30 theFitBinning(ps.getParameter<
int>(
"FitBinsPerCm"))
32 produces<reco::VertexCollection>();
36 TMinuitMinimizer::UseStaticMinuit(
false);
49 std::vector<const reco::Track *>
tracks;
50 for (
unsigned int i=0;
i<tracks_.size();
i++) {
51 if (tracks_[
i].
pt() <
thePtMin && std::fabs(tracks_[
i].vz()) < 100000.)
continue;
53 tracks.push_back( &(*recTrack));
57 <<
" [VertexProducer] selected tracks: " 58 << tracks.size() <<
" (out of " << tracks_.size()
62 auto vertices = std::make_unique<reco::VertexCollection>();
75 if(tracks.size() % 2 == 0)
76 med = (tracks[tracks.size()/2-1]->vz() + tracks[tracks.size()/2]->vz())/2;
78 med = tracks[tracks.size()/2 ]->vz();
81 <<
" [vertex position] median = " << med <<
" cm";
89 for(std::vector<const reco::Track *>::const_iterator
91 if(fabs((*track)->vz()) < thePeakFindMaxZ)
92 hmax.Fill((*track)->vz());
94 int maxBin = hmax.GetMaximumBin();
97 <<
" [vertex position] most prob = " 98 << hmax.GetBinCenter(maxBin) <<
" cm";
101 float num=0.0, denom=0.0;
102 for(
int i=-1;
i<=1;
i++) {
103 num += hmax.GetBinContent(maxBin+
i)*hmax.GetBinCenter(maxBin+
i);
104 denom += hmax.GetBinContent(maxBin+
i);
110 err(2,2) = 0.1 * 0.1;
118 float nBinAvg = num/denom;
124 <<
" [vertex position] 3-bin weighted average = " 132 for(std::vector<const reco::Track *>::const_iterator
134 if(fabs((*track)->vz() - med) < theFitMaxZ)
135 histo.Fill((*track)->vz() - med);
138 <<
" [vertex position] most prob for fit = " 139 << med + histo.GetBinCenter(histo.GetMaximumBin()) <<
" cm";
146 <<
" entries in fit histogram. Returning median.";
149 err(2,2) = 0.1 * 0.1;
158 TF1
f1(
"f1",
"[0]*exp(-0.5 * ((x-[1])/[2])^2) + [3]");
159 f1.SetParameters(10.,0.,0.02,0.002*tracks.size());
160 f1.SetParLimits(1,-0.1,0.1);
161 f1.SetParLimits(2,0.001,0.05);
162 f1.SetParLimits(3,0.0,0.005*tracks.size());
167 <<
" [vertex position] fitted = " 168 << med + f1.GetParameter(1) <<
" +- " << f1.GetParError(1) <<
" cm";
171 err(2,2) = f1.GetParError(1) * f1.GetParError(1);
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const std::vector< reco::PFCandidatePtr > & tracks_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< Track > TrackCollection
collection of Tracks
math::Error< dimension >::type Error
covariance error matrix (3x3)
math::XYZPoint Point
point in the space
T const * product() const