22 theTrackCollection(ps.getParameter<edm::InputTag>(
"TrackCollection")),
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"))
31 produces<reco::VertexCollection>();
40 ev.
getByLabel(theTrackCollection, trackCollection);
44 std::vector<const reco::Track *>
tracks;
45 for (
unsigned int i=0;
i<tracks_.size();
i++) {
46 if (tracks_[
i].
pt() < thePtMin && std::fabs(tracks_[
i].vz()) < 100000.)
continue;
48 tracks.push_back( &(*recTrack));
52 <<
" [VertexProducer] selected tracks: "
53 << tracks.size() <<
" (out of " << tracks_.size()
54 <<
") above pt = " << thePtMin;
60 if(tracks.size() == 0) {
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();
76 <<
" [vertex position] median = " << med <<
" cm";
79 if(tracks.size() > thePeakFindThresh) {
82 TH1F hmax(
"hmax",
"hmax",thePeakFindBinning*2.0*thePeakFindMaxZ,-1.0*thePeakFindMaxZ,thePeakFindMaxZ);
84 for(std::vector<const reco::Track *>::const_iterator
85 track = tracks.begin(); track!= tracks.end(); track++)
86 if(fabs((*track)->vz()) < thePeakFindMaxZ)
87 hmax.Fill((*track)->vz());
89 int maxBin = hmax.GetMaximumBin();
92 <<
" [vertex position] most prob = "
93 << hmax.GetBinCenter(maxBin) <<
" cm";
96 float num=0.0, denom=0.0;
97 for(
int i=-1;
i<=1;
i++) {
98 num += hmax.GetBinContent(maxBin+
i)*hmax.GetBinCenter(maxBin+
i);
99 denom += hmax.GetBinContent(maxBin+
i);
105 err(2,2) = 0.1 * 0.1;
108 vertices->push_back(ver);
113 float nBinAvg = num/denom;
119 <<
" [vertex position] 3-bin weighted average = "
124 TH1F
histo(
"histo",
"histo", theFitBinning*2.0*theFitMaxZ,-1.0*theFitMaxZ,theFitMaxZ);
127 for(std::vector<const reco::Track *>::const_iterator
128 track = tracks.begin(); track!= tracks.end(); track++)
129 if(fabs((*track)->vz() - med) < theFitMaxZ)
130 histo.Fill((*track)->vz() - med);
133 <<
" [vertex position] most prob for fit = "
134 << med + histo.GetBinCenter(histo.GetMaximumBin()) <<
" cm";
137 if(histo.GetEntries() <= theFitThreshold) {
140 <<
" [vertex position] Fewer than" << theFitThreshold
141 <<
" entries in fit histogram. Returning median.";
144 err(2,2) = 0.1 * 0.1;
147 vertices->push_back(ver);
153 TF1
f1(
"f1",
"[0]*exp(-0.5 * ((x-[1])/[2])^2) + [3]");
154 f1.SetParameters(10.,0.,0.02,0.002*tracks.size());
155 f1.SetParLimits(1,-0.1,0.1);
156 f1.SetParLimits(2,0.001,0.05);
157 f1.SetParLimits(3,0.0,0.005*tracks.size());
159 histo.Fit(
"f1",
"QN");
162 <<
" [vertex position] fitted = "
163 << med + f1.GetParameter(1) <<
" +- " << f1.GetParError(1) <<
" cm";
166 err(2,2) = f1.GetParError(1) * f1.GetParError(1);
169 vertices->push_back(ver);
const std::vector< reco::PFCandidatePtr > & tracks_
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
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
T const * product() const