CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions
MuonDTSeedFromRecHits Class Reference

#include <MuonDTSeedFromRecHits.h>

Inheritance diagram for MuonDTSeedFromRecHits:
MuonSeedFromRecHits

Public Member Functions

ConstMuonRecHitPointer bestBarrelHit (const MuonRecHitContainer &barrelHits) const
 
 MuonDTSeedFromRecHits ()
 
virtual TrajectorySeed seed () const
 
- Public Member Functions inherited from MuonSeedFromRecHits
void add (MuonTransientTrackingRecHit::MuonRecHitPointer hit)
 
void clear ()
 
TrajectorySeed createSeed (float ptmean, float sptmean, MuonTransientTrackingRecHit::ConstMuonRecHitPointer last) const
 
MuonTransientTrackingRecHit::ConstMuonRecHitPointer firstRecHit () const
 
 MuonSeedFromRecHits ()
 
unsigned int nrhit () const
 
void setBField (const MagneticField *field)
 
void setPtExtractor (const MuonSeedPtExtractor *extractor)
 
virtual ~MuonSeedFromRecHits ()
 

Private Member Functions

float bestEta () const
 
void computeBestPt (double *pt, double *spt, float &ptmean, float &sptmean) const
 
void computeMean (const double *pt, const double *weights, int sz, bool tossOutlyers, float &ptmean, float &sptmean) const
 
void computePtWithoutVtx (double *pt, double *spt) const
 
void computePtWithVtx (double *pt, double *spt) const
 

Additional Inherited Members

- Protected Types inherited from MuonSeedFromRecHits
typedef
MuonTransientTrackingRecHit::ConstMuonRecHitPointer 
ConstMuonRecHitPointer
 
typedef
MuonTransientTrackingRecHit::MuonRecHitContainer 
MuonRecHitContainer
 
typedef
MuonTransientTrackingRecHit::MuonRecHitPointer 
MuonRecHitPointer
 
- Protected Attributes inherited from MuonSeedFromRecHits
const MagneticFieldtheField
 
const MuonSeedPtExtractorthePtExtractor
 
MuonTransientTrackingRecHit::MuonRecHitContainer theRhits
 

Detailed Description

Author
A. Vitelli - INFN Torino
porting R.Bellan - INFN Torino

Generate a seed starting from a list of RecHits make use of TrajectorySeed from CommonDet

Definition at line 20 of file MuonDTSeedFromRecHits.h.

Constructor & Destructor Documentation

MuonDTSeedFromRecHits::MuonDTSeedFromRecHits ( )

Definition at line 29 of file MuonDTSeedFromRecHits.cc.

31 {
32 }

Member Function Documentation

MuonDTSeedFromRecHits::ConstMuonRecHitPointer MuonDTSeedFromRecHits::bestBarrelHit ( const MuonRecHitContainer barrelHits) const

Definition at line 82 of file MuonDTSeedFromRecHits.cc.

Referenced by MuonOverlapSeedFromRecHits::bestHit(), and seed().

82  {
83 
84  int alt_npt = 0;
85  int best_npt = 0;
86  int cur_npt = 0;
87  MuonRecHitPointer best = 0;
88  MuonRecHitPointer alter=0;
89 
90  for (MuonRecHitContainer::const_iterator iter=barrelHits.begin();
91  iter!=barrelHits.end(); iter++ ) {
92 
93  bool hasZed = ((*iter)->projectionMatrix()[1][1]==1);
94 
95  cur_npt = 0;
96  vector<TrackingRecHit*> slrhs=(*iter)->recHits();
97  for (vector<TrackingRecHit*>::const_iterator slrh=slrhs.begin(); slrh!=slrhs.end(); ++slrh ) {
98  cur_npt+=(*slrh)->recHits().size();
99  }
100  float radius1 = (*iter)->det()->position().perp();
101 
102  if (hasZed) {
103  if ( cur_npt > best_npt ) {
104  best = (*iter);
105  best_npt = cur_npt;
106  }
107  else if ( best && cur_npt == best_npt ) {
108  float radius2 = best->det()->position().perp();
109  if (radius1 < radius2) {
110  best = (*iter);
111  best_npt = cur_npt;
112  }
113  }
114  }
115 
116  if ( cur_npt > alt_npt ) {
117  alter = (*iter);
118  alt_npt = cur_npt;
119  }
120  else if ( alter && cur_npt == alt_npt ) {
121  float radius2 = alter->det()->position().perp();
122  if (radius1 < radius2) {
123  alter = (*iter);
124  alt_npt = cur_npt;
125  }
126  }
127  }
128 
129  if ( !best ) best = alter;
130 
131  return best;
132 }
float MuonDTSeedFromRecHits::bestEta ( ) const
private

Definition at line 135 of file MuonDTSeedFromRecHits.cc.

References query::result, and MuonSeedFromRecHits::theRhits.

Referenced by computePtWithoutVtx(), and computePtWithVtx().

135  {
136 
137  int Maxseg = 0;
138  float Msdeta = 100.;
139  float result = (*theRhits.begin())->globalPosition().eta();
140 
141  for (MuonRecHitContainer::const_iterator iter=theRhits.begin(); iter!=theRhits.end(); iter++ ) {
142 
143  float eta1= (*iter)->globalPosition().eta();
144 
145  int Nseg = 0;
146  float sdeta = .0;
147 
148  for (MuonRecHitContainer::const_iterator iter2=theRhits.begin(); iter2!=theRhits.end(); iter2++ ) {
149 
150  if ( iter2 == iter ) continue;
151 
152  float eta2 = (*iter2)->globalPosition().eta();
153 
154  if ( fabs (eta1-eta2) > .2 ) continue;
155 
156  Nseg++;
157  sdeta += fabs (eta1-eta2);
158 
159  if ( Nseg > Maxseg || (Nseg == Maxseg && sdeta < Msdeta) ) {
160  Maxseg = Nseg;
161  Msdeta = sdeta;
162  result = eta1;
163  }
164 
165  }
166  } // +v.
167  return result;
168 }
MuonTransientTrackingRecHit::MuonRecHitContainer theRhits
tuple result
Definition: query.py:137
void MuonDTSeedFromRecHits::computeBestPt ( double *  pt,
double *  spt,
float &  ptmean,
float &  sptmean 
) const
private

just one pt estimate: use it.

more than a pt estimate, do all the job.

Definition at line 260 of file MuonDTSeedFromRecHits.cc.

References computeMean(), i, LogTrace, metname, and mathSSE::sqrt().

Referenced by seed().

263  {
264 
265  const std::string metname = "Muon|RecoMuon|MuonDTSeedFromRecHits";
266 
267  int nTotal=8;
268  int igood=-1;
269  for (int i=0;i<=7;i++) {
270  if(pt[i]==0) {
271  spt[i]=0.;
272  nTotal--;
273  } else {
274  igood=i;
275  }
276  }
277 
278  if (nTotal==1) {
280  ptmean=pt[igood];
281  sptmean=1/sqrt(spt[igood]);
282  } else if (nTotal==0) {
283  // No estimate (e.g. only one rechit!)
284  ptmean=50;
285  sptmean=30;
286  } else {
288  // calculate pt with vertex
289  float ptvtx=0.0;
290  float sptvtx=0.0;
291  computeMean(pt, spt, 2, false, ptvtx, sptvtx);
292  LogTrace(metname) << " GSL: Pt w vtx :" << ptvtx << "+/-" <<
293  sptvtx << endl;
294 
295  // FIXME: temp hack
296  if(ptvtx != 0.) {
297  ptmean = ptvtx;
298  sptmean = sptvtx;
299  return;
300  //
301  }
302  // calculate pt w/o vertex
303  float ptMB=0.0;
304  float sptMB=0.0;
305  computeMean(pt+2, spt+2, 6, false, ptMB, sptMB);
306  LogTrace(metname) << " GSL: Pt w/o vtx :" << ptMB << "+/-" <<
307  sptMB << endl;
308 
309  // decide wheter the muon comes or not from vertex
310  float ptpool=0.0;
311  if((ptvtx+ptMB)!=0.0) ptpool=(ptvtx-ptMB)/(ptvtx+ptMB);
312  bool fromvtx=true;
313  if(fabs(ptpool)>0.2) fromvtx=false;
314  LogTrace(metname) << "From vtx? " <<fromvtx << " ptpool "<< ptpool << endl;
315 
316  // now choose the "right" pt => weighted mean
317  computeMean(pt, spt, 8, true, ptmean, sptmean);
318  LogTrace(metname) << " GSL Pt :" << ptmean << "+/-" << sptmean << endl;
319 
320  }
321 }
int i
Definition: DBlmapReader.cc:9
const std::string metname
T sqrt(T t)
Definition: SSEVec.h:46
void computeMean(const double *pt, const double *weights, int sz, bool tossOutlyers, float &ptmean, float &sptmean) const
#define LogTrace(id)
void MuonDTSeedFromRecHits::computeMean ( const double *  pt,
const double *  weights,
int  sz,
bool  tossOutlyers,
float &  ptmean,
float &  sptmean 
) const
private

Definition at line 324 of file MuonDTSeedFromRecHits.cc.

References i, n, and mathSSE::sqrt().

Referenced by computeBestPt().

326 {
327  int n=0;
328  double ptTmp[8];
329  double wtTmp[8];
330  assert(sz<=8);
331 
332  for (int i=0; i<sz; ++i) {
333  ptTmp[i] = 0.;
334  wtTmp[i] = 0;
335  if (pt[i]!=0) {
336  ptTmp[n]=pt[i];
337  wtTmp[n]=weights[i];
338  ++n;
339  }
340  }
341  if(n != 0)
342  {
343  if (n==1) {
344  ptmean=ptTmp[0];
345  sptmean=1/sqrt(wtTmp[0]);
346  } else {
347  ptmean = gsl_stats_wmean(wtTmp, 1, ptTmp, 1, n);
348  sptmean = sqrt( gsl_stats_wvariance_m (wtTmp, 1, ptTmp, 1, n, ptmean) );
349  }
350 
351  if(tossOutlyers)
352  {
353  // Recompute mean with a cut at 3 sigma
354  for ( int nm =0; nm<8; nm++ ){
355  if ( ptTmp[nm]!=0 && fabs(ptTmp[nm]-ptmean)>3*(sptmean) ) {
356  wtTmp[nm]=0.;
357  }
358  }
359  ptmean = gsl_stats_wmean(wtTmp, 1, ptTmp, 1, n);
360  sptmean = sqrt( gsl_stats_wvariance_m (wtTmp, 1, ptTmp, 1, n, ptmean) );
361  }
362  }
363 
364 }
int i
Definition: DBlmapReader.cc:9
T sqrt(T t)
Definition: SSEVec.h:46
void MuonDTSeedFromRecHits::computePtWithoutVtx ( double *  pt,
double *  spt 
) const
private

Definition at line 202 of file MuonDTSeedFromRecHits.cc.

References bestEta(), DTChamberId, MuonSeedPtExtractor::pT_extract(), relativeConstraints::station, MuonSeedFromRecHits::thePtExtractor, MuonSeedFromRecHits::theRhits, and tmp.

Referenced by seed().

202  {
203  float eta0 = bestEta();
204 
205  for (MuonRecHitContainer::const_iterator iter=theRhits.begin();
206  iter!=theRhits.end(); iter++ ) {
207  //+vvp !:
208  float eta1= (*iter)->globalPosition().eta();
209  if ( fabs (eta1-eta0) > .2 ) continue; // !!! +vvp
210 
211  for (MuonRecHitContainer::const_iterator iter2=theRhits.begin();
212  iter2!=iter; iter2++ ) {
213  //+vvp !:
214  float eta2= (*iter2)->globalPosition().eta();
215  if ( fabs (eta2-eta0) > .2 ) continue; // !!! +vvp
216 
217  unsigned int stat1 = DTChamberId((*iter)->geographicalId()).station();
218  unsigned int stat2 = DTChamberId((*iter2)->geographicalId()).station();
219 
220  if ( stat1>stat2) {
221  int tmp = stat1;
222  stat1 = stat2;
223  stat2 = tmp;
224  }
225  unsigned int st = stat1*10+stat2;
226  double thispt = thePtExtractor->pT_extract(*iter, *iter2)[0];
227  switch (st) {
228  case 12 : {//MB1-MB2
229  pt[2] = thispt;
230  break;
231  }
232  case 13 : {//MB1-MB3
233  pt[3] = thispt;
234  break;
235  }
236  case 14 : {//MB1-MB4
237  pt[5] = thispt;
238  break;
239  }
240  case 23 : {//MB2-MB3
241  pt[4] = thispt;
242  break;
243  }
244  case 24 : {//MB2-MB4
245  pt[6] = thispt;
246  break;
247  }
248  case 34 : {//MB3-MB4
249  pt[7] = thispt;
250  break;
251  }
252  default: {
253  break;
254  }
255  }
256  }
257  }
258 }
MuonTransientTrackingRecHit::MuonRecHitContainer theRhits
const MuonSeedPtExtractor * thePtExtractor
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
virtual std::vector< double > pT_extract(MuonTransientTrackingRecHit::ConstMuonRecHitPointer firstHit, MuonTransientTrackingRecHit::ConstMuonRecHitPointer secondHit) const
void MuonDTSeedFromRecHits::computePtWithVtx ( double *  pt,
double *  spt 
) const
private

Definition at line 171 of file MuonDTSeedFromRecHits.cc.

References bestEta(), DTChamberId, MuonSeedPtExtractor::pT_extract(), relativeConstraints::station, MuonSeedFromRecHits::thePtExtractor, and MuonSeedFromRecHits::theRhits.

Referenced by seed().

171  {
172 
173  float eta0 = bestEta();
174 
175  for (MuonRecHitContainer::const_iterator iter=theRhits.begin(); iter!=theRhits.end(); iter++ ) {
176 
177  //+vvp !:
178 
179  float eta1= (*iter)->globalPosition().eta();
180  if ( fabs (eta1-eta0) > .2 ) continue; // !!! +vvp
181 
182  // assign Pt from MB1 & vtx
183  unsigned int stat = DTChamberId((**iter).geographicalId()).station();
184  if(stat > 2) continue;
185 
186  double thispt = thePtExtractor->pT_extract(*iter, *iter)[0];
187  float ptmax = 2000.;
188  if(thispt > ptmax) thispt = ptmax;
189  if(thispt < -ptmax) thispt = -ptmax;
190 
191  if( stat==1 ) {
192  pt[0] = thispt;
193  }
194  // assign Pt from MB2 & vtx
195  if( stat==2 ) {
196  pt[1] = thispt;
197  }
198  }
199 }
MuonTransientTrackingRecHit::MuonRecHitContainer theRhits
const MuonSeedPtExtractor * thePtExtractor
virtual std::vector< double > pT_extract(MuonTransientTrackingRecHit::ConstMuonRecHitPointer firstHit, MuonTransientTrackingRecHit::ConstMuonRecHitPointer secondHit) const
TrajectorySeed MuonDTSeedFromRecHits::seed ( ) const
virtual

compute pts with vertex constraint

now w/o vertex constrain

now combine all pt estimate

Definition at line 35 of file MuonDTSeedFromRecHits.cc.

References bestBarrelHit(), computeBestPt(), computePtWithoutVtx(), computePtWithVtx(), MuonSeedFromRecHits::createSeed(), i, prof2calltree::last, LogTrace, metname, mathSSE::sqrt(), and MuonSeedFromRecHits::theRhits.

Referenced by MuonSeedFinder::seeds().

35  {
36  double pt[16] = { 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. };
37  // these weights are supposed to be 1/sigma^2(pt), but they're so small.
38  // Instead of the 0.2-0.5 GeV here, we'll add something extra in quadrature later
39  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 };
40 
41  const std::string metname = "Muon|RecoMuon|MuonDTSeedFromRecHits";
42 
44  computePtWithVtx(pt, spt);
45 
47  computePtWithoutVtx(pt, spt);
48 
49  // some dump...
50  LogTrace(metname) << " Pt MB1 @vtx: " << pt[0] << " w: " << spt[0] << "\n"
51  << " Pt MB2 @vtx: " << pt[1] << " w: " << spt[1]<< endl ;
52 
53  LogTrace(metname) << " Pt MB2-MB1 " << pt[2] << " w: " << spt[2]<< "\n"
54  << " Pt MB3-MB1 " << pt[3] << " w: " << spt[3]<< "\n"
55  << " Pt MB3-MB2 " << pt[4] << " w: " << spt[4]<< "\n"
56  << " Pt MB4-MB1 " << pt[5] << " w: " << spt[5]<< "\n"
57  << " Pt MB4-MB2 " << pt[6] << " w: " << spt[6]<< "\n"
58  << " Pt MB4-MB3 " << pt[7] << " w: " << spt[7]<< endl ;
59 
61  float ptmean=0.;
62  float sptmean=0.;
63  //@@ Use Shih-Chuan's
64  computeBestPt(pt, spt, ptmean, sptmean);
65 
66  // add an extra term to the error in quadrature, 30% of pT per point
67  int npoints = 0;
68  for(int i = 0; i < 8; ++i)
69  if(pt[i] != 0) ++npoints;
70  if(npoints != 0) {
71  sptmean = sqrt(sptmean*sptmean + 0.09*ptmean*ptmean/npoints);
72  }
73 
74  LogTrace(metname) << " Seed Pt: " << ptmean << " +/- " << sptmean << endl;
75  // take the best candidate
77  return createSeed(ptmean, sptmean,last);
78 }
int i
Definition: DBlmapReader.cc:9
ConstMuonRecHitPointer bestBarrelHit(const MuonRecHitContainer &barrelHits) const
void computePtWithVtx(double *pt, double *spt) const
void computeBestPt(double *pt, double *spt, float &ptmean, float &sptmean) const
const std::string metname
MuonTransientTrackingRecHit::MuonRecHitContainer theRhits
T sqrt(T t)
Definition: SSEVec.h:46
#define LogTrace(id)
void computePtWithoutVtx(double *pt, double *spt) const
TrajectorySeed createSeed(float ptmean, float sptmean, MuonTransientTrackingRecHit::ConstMuonRecHitPointer last) const