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);
45 ev.
getByToken(theTrackCollection, trackCollection);
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()
59 <<
") above pt = " << thePtMin;
65 if(tracks.size() == 0) {
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";
84 if(tracks.size() > thePeakFindThresh) {
87 TH1F hmax(
"hmax",
"hmax",thePeakFindBinning*2.0*thePeakFindMaxZ,-1.0*thePeakFindMaxZ,thePeakFindMaxZ);
89 for(std::vector<const reco::Track *>::const_iterator
90 track = tracks.begin(); track!= tracks.end(); track++)
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;
113 vertices->push_back(ver);
118 float nBinAvg = num/denom;
124 <<
" [vertex position] 3-bin weighted average = "
129 TH1F
histo(
"histo",
"histo", theFitBinning*2.0*theFitMaxZ,-1.0*theFitMaxZ,theFitMaxZ);
132 for(std::vector<const reco::Track *>::const_iterator
133 track = tracks.begin(); track!= tracks.end(); track++)
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";
142 if(histo.GetEntries() <= theFitThreshold) {
145 <<
" [vertex position] Fewer than" << theFitThreshold
146 <<
" entries in fit histogram. Returning median.";
149 err(2,2) = 0.1 * 0.1;
152 vertices->push_back(ver);
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);
174 vertices->push_back(ver);
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)
std::vector< Vertex > VertexCollection
collection of Vertex objects
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
math::XYZPoint Point
point in the space
T const * product() const