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 27 of file MuonDTSeedFromRecHits.cc.

29 {
30 }

Member Function Documentation

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

Definition at line 80 of file MuonDTSeedFromRecHits.cc.

References TrackingRecHit::det(), PV3DBase< T, PVType, FrameType >::perp(), GeomDet::position(), and GenericTransientTrackingRecHit::recHits().

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

80  {
81 
82  int alt_npt = 0;
83  int best_npt = 0;
84  int cur_npt = 0;
85  MuonRecHitPointer best = 0;
86  MuonRecHitPointer alter=0;
87 
88  for (MuonRecHitContainer::const_iterator iter=barrelHits.begin();
89  iter!=barrelHits.end(); iter++ ) {
90 
91  bool hasZed = ((*iter)->projectionMatrix()[1][1]==1);
92 
93  cur_npt = 0;
94  vector<TrackingRecHit*> slrhs=(*iter)->recHits();
95  for (vector<TrackingRecHit*>::const_iterator slrh=slrhs.begin(); slrh!=slrhs.end(); ++slrh ) {
96  cur_npt+=(*slrh)->recHits().size();
97  }
98  float radius1 = (*iter)->det()->position().perp();
99 
100  if (hasZed) {
101  if ( cur_npt > best_npt ) {
102  best = (*iter);
103  best_npt = cur_npt;
104  }
105  else if ( best && cur_npt == best_npt ) {
106  float radius2 = best->det()->position().perp();
107  if (radius1 < radius2) {
108  best = (*iter);
109  best_npt = cur_npt;
110  }
111  }
112  }
113 
114  if ( cur_npt > alt_npt ) {
115  alter = (*iter);
116  alt_npt = cur_npt;
117  }
118  else if ( alter && cur_npt == alt_npt ) {
119  float radius2 = alter->det()->position().perp();
120  if (radius1 < radius2) {
121  alter = (*iter);
122  alt_npt = cur_npt;
123  }
124  }
125  }
126 
127  if ( !best ) best = alter;
128 
129  return best;
130 }
T perp() const
Definition: PV3DBase.h:72
virtual std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:46
const GeomDet * det() const
float MuonDTSeedFromRecHits::bestEta ( ) const
private

Definition at line 133 of file MuonDTSeedFromRecHits.cc.

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

Referenced by computePtWithoutVtx(), and computePtWithVtx().

133  {
134 
135  int Maxseg = 0;
136  float Msdeta = 100.;
137  float result = (*theRhits.begin())->globalPosition().eta();
138 
139  for (MuonRecHitContainer::const_iterator iter=theRhits.begin(); iter!=theRhits.end(); iter++ ) {
140 
141  float eta1= (*iter)->globalPosition().eta();
142 
143  int Nseg = 0;
144  float sdeta = .0;
145 
146  for (MuonRecHitContainer::const_iterator iter2=theRhits.begin(); iter2!=theRhits.end(); iter2++ ) {
147 
148  if ( iter2 == iter ) continue;
149 
150  float eta2 = (*iter2)->globalPosition().eta();
151 
152  if ( fabs (eta1-eta2) > .2 ) continue;
153 
154  Nseg++;
155  sdeta += fabs (eta1-eta2);
156 
157  if ( Nseg > Maxseg || (Nseg == Maxseg && sdeta < Msdeta) ) {
158  Maxseg = Nseg;
159  Msdeta = sdeta;
160  result = eta1;
161  }
162 
163  }
164  } // +v.
165  return result;
166 }
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 258 of file MuonDTSeedFromRecHits.cc.

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

Referenced by seed().

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

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

Referenced by computeBestPt().

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

Definition at line 200 of file MuonDTSeedFromRecHits.cc.

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

Referenced by seed().

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

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

Referenced by seed().

169  {
170 
171  float eta0 = bestEta();
172 
173  for (MuonRecHitContainer::const_iterator iter=theRhits.begin(); iter!=theRhits.end(); iter++ ) {
174 
175  //+vvp !:
176 
177  float eta1= (*iter)->globalPosition().eta();
178  if ( fabs (eta1-eta0) > .2 ) continue; // !!! +vvp
179 
180  // assign Pt from MB1 & vtx
181  unsigned int stat = DTChamberId((**iter).geographicalId()).station();
182  if(stat > 2) continue;
183 
184  double thispt = thePtExtractor->pT_extract(*iter, *iter)[0];
185  float ptmax = 2000.;
186  if(thispt > ptmax) thispt = ptmax;
187  if(thispt < -ptmax) thispt = -ptmax;
188 
189  if( stat==1 ) {
190  pt[0] = thispt;
191  }
192  // assign Pt from MB2 & vtx
193  if( stat==2 ) {
194  pt[1] = thispt;
195  }
196  }
197 }
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 33 of file MuonDTSeedFromRecHits.cc.

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

Referenced by MuonSeedFinder::seeds().

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