21 #include "gsl/gsl_statistics.h"
28 double pt[16] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
31 double spt[8] = {1 / 0.048, 1 / 0.075, 1 / 0.226, 1 / 0.132, 1 / 0.106, 1 / 0.175, 1 / 0.125, 1 / 0.185};
43 <<
" Pt MB2 @vtx: " <<
pt[1] <<
" w: " << spt[1] << endl;
46 <<
" Pt MB3-MB1 " <<
pt[3] <<
" w: " << spt[3] <<
"\n"
47 <<
" Pt MB3-MB2 " <<
pt[4] <<
" w: " << spt[4] <<
"\n"
48 <<
" Pt MB4-MB1 " <<
pt[5] <<
" w: " << spt[5] <<
"\n"
49 <<
" Pt MB4-MB2 " <<
pt[6] <<
" w: " << spt[6] <<
"\n"
50 <<
" Pt MB4-MB3 " <<
pt[7] <<
" w: " << spt[7] << endl;
60 for (
int i = 0;
i < 8; ++
i)
64 sptmean =
sqrt(sptmean * sptmean + 0.09 * ptmean * ptmean /
npoints);
67 LogTrace(
metname) <<
" Seed Pt: " << ptmean <<
" +/- " << sptmean << endl;
81 for (MuonRecHitContainer::const_iterator iter =
barrelHits.begin(); iter !=
barrelHits.end(); iter++) {
82 bool hasZed = ((*iter)->projectionMatrix()[1][1] == 1);
85 vector<TrackingRecHit*> slrhs = (*iter)->recHits();
86 for (vector<TrackingRecHit*>::const_iterator slrh = slrhs.begin(); slrh != slrhs.end(); ++slrh) {
87 cur_npt += (*slrh)->recHits().size();
89 float radius1 = (*iter)->det()->position().perp();
92 if (cur_npt > best_npt) {
95 }
else if (best && cur_npt == best_npt) {
96 float radius2 = best->det()->position().perp();
97 if (radius1 < radius2) {
104 if (cur_npt > alt_npt) {
107 }
else if (alter && cur_npt == alt_npt) {
108 float radius2 = alter->det()->position().perp();
109 if (radius1 < radius2) {
127 for (MuonRecHitContainer::const_iterator iter =
theRhits.begin(); iter !=
theRhits.end(); iter++) {
128 float eta1 = (*iter)->globalPosition().eta();
133 for (MuonRecHitContainer::const_iterator iter2 =
theRhits.begin(); iter2 !=
theRhits.end(); iter2++) {
137 float eta2 = (*iter2)->globalPosition().eta();
145 if (Nseg > Maxseg || (Nseg == Maxseg && sdeta < Msdeta)) {
158 for (MuonRecHitContainer::const_iterator iter =
theRhits.begin(); iter !=
theRhits.end(); iter++) {
161 float eta1 = (*iter)->globalPosition().eta();
162 if (fabs(
eta1 - eta0) > .2)
190 for (MuonRecHitContainer::const_iterator iter =
theRhits.begin(); iter !=
theRhits.end(); iter++) {
192 float eta1 = (*iter)->globalPosition().eta();
193 if (fabs(
eta1 - eta0) > .2)
196 for (MuonRecHitContainer::const_iterator iter2 =
theRhits.begin(); iter2 != iter; iter2++) {
198 float eta2 = (*iter2)->globalPosition().eta();
199 if (fabs(
eta2 - eta0) > .2)
210 unsigned int st = stat1 * 10 + stat2;
250 for (
int i = 0;
i <= 7;
i++) {
262 sptmean = 1 /
sqrt(spt[igood]);
263 }
else if (nTotal == 0) {
273 LogTrace(
metname) <<
" GSL: Pt w vtx :" << ptvtx <<
"+/-" << sptvtx << endl;
286 LogTrace(
metname) <<
" GSL: Pt w/o vtx :" << ptMB <<
"+/-" << sptMB << endl;
290 if ((ptvtx + ptMB) != 0.0)
291 ptpool = (ptvtx - ptMB) / (ptvtx + ptMB);
293 if (fabs(ptpool) > 0.2)
295 LogTrace(
metname) <<
"From vtx? " << fromvtx <<
" ptpool " << ptpool << endl;
299 LogTrace(
metname) <<
" GSL Pt :" << ptmean <<
"+/-" << sptmean << endl;
304 const double*
pt,
const double*
weights,
int sz,
bool tossOutlyers,
float& ptmean,
float& sptmean)
const {
310 for (
int i = 0;
i < 8; ++
i) {
313 if (
i < sz &&
pt[
i] != 0) {
322 sptmean = 1 /
sqrt(wtTmp[0]);
324 ptmean = gsl_stats_wmean(wtTmp, 1, ptTmp, 1,
n);
325 sptmean =
sqrt(gsl_stats_wvariance_m(wtTmp, 1, ptTmp, 1,
n, ptmean));
330 for (
int nm = 0; nm < 8; nm++) {
331 if (ptTmp[nm] != 0 && fabs(ptTmp[nm] - ptmean) > 3 * (sptmean)) {
335 ptmean = gsl_stats_wmean(wtTmp, 1, ptTmp, 1,
n);
336 sptmean =
sqrt(gsl_stats_wvariance_m(wtTmp, 1, ptTmp, 1,
n, ptmean));