CMS 3D CMS Logo

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 19 of file MuonDTSeedFromRecHits.h.

Constructor & Destructor Documentation

◆ MuonDTSeedFromRecHits()

MuonDTSeedFromRecHits::MuonDTSeedFromRecHits ( )

Definition at line 25 of file MuonDTSeedFromRecHits.cc.

Member Function Documentation

◆ bestBarrelHit()

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

Definition at line 73 of file MuonDTSeedFromRecHits.cc.

References HLT_2024v13_cff::barrelHits.

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

74  {
75  int alt_npt = 0;
76  int best_npt = 0;
77  int cur_npt = 0;
78  MuonRecHitPointer best = nullptr;
79  MuonRecHitPointer alter = nullptr;
80 
81  for (MuonRecHitContainer::const_iterator iter = barrelHits.begin(); iter != barrelHits.end(); iter++) {
82  bool hasZed = ((*iter)->projectionMatrix()[1][1] == 1);
83 
84  cur_npt = 0;
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();
88  }
89  float radius1 = (*iter)->det()->position().perp();
90 
91  if (hasZed) {
92  if (cur_npt > best_npt) {
93  best = (*iter);
94  best_npt = cur_npt;
95  } else if (best && cur_npt == best_npt) {
96  float radius2 = best->det()->position().perp();
97  if (radius1 < radius2) {
98  best = (*iter);
99  best_npt = cur_npt;
100  }
101  }
102  }
103 
104  if (cur_npt > alt_npt) {
105  alter = (*iter);
106  alt_npt = cur_npt;
107  } else if (alter && cur_npt == alt_npt) {
108  float radius2 = alter->det()->position().perp();
109  if (radius1 < radius2) {
110  alter = (*iter);
111  alt_npt = cur_npt;
112  }
113  }
114  }
115 
116  if (!best)
117  best = alter;
118 
119  return best;
120 }
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer

◆ bestEta()

float MuonDTSeedFromRecHits::bestEta ( ) const
private

Definition at line 122 of file MuonDTSeedFromRecHits.cc.

References HLT_2024v13_cff::eta1, HLT_2024v13_cff::eta2, mps_fire::result, and MuonSeedFromRecHits::theRhits.

Referenced by computePtWithoutVtx(), and computePtWithVtx().

122  {
123  int Maxseg = 0;
124  float Msdeta = 100.;
125  float result = (*theRhits.begin())->globalPosition().eta();
126 
127  for (MuonRecHitContainer::const_iterator iter = theRhits.begin(); iter != theRhits.end(); iter++) {
128  float eta1 = (*iter)->globalPosition().eta();
129 
130  int Nseg = 0;
131  float sdeta = .0;
132 
133  for (MuonRecHitContainer::const_iterator iter2 = theRhits.begin(); iter2 != theRhits.end(); iter2++) {
134  if (iter2 == iter)
135  continue;
136 
137  float eta2 = (*iter2)->globalPosition().eta();
138 
139  if (fabs(eta1 - eta2) > .2)
140  continue;
141 
142  Nseg++;
143  sdeta += fabs(eta1 - eta2);
144 
145  if (Nseg > Maxseg || (Nseg == Maxseg && sdeta < Msdeta)) {
146  Maxseg = Nseg;
147  Msdeta = sdeta;
148  result = eta1;
149  }
150  }
151  } // +v.
152  return result;
153 }
MuonTransientTrackingRecHit::MuonRecHitContainer theRhits

◆ computeBestPt()

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

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

Referenced by seed().

245  {
246  const std::string metname = "Muon|RecoMuon|MuonDTSeedFromRecHits";
247 
248  int nTotal = 8;
249  int igood = -1;
250  for (int i = 0; i <= 7; i++) {
251  if (pt[i] == 0) {
252  spt[i] = 0.;
253  nTotal--;
254  } else {
255  igood = i;
256  }
257  }
258 
259  if (nTotal == 1) {
261  ptmean = pt[igood];
262  sptmean = 1 / sqrt(spt[igood]);
263  } else if (nTotal == 0) {
264  // No estimate (e.g. only one rechit!)
265  ptmean = 50;
266  sptmean = 30;
267  } else {
269  // calculate pt with vertex
270  float ptvtx = 0.0;
271  float sptvtx = 0.0;
272  computeMean(pt, spt, 2, false, ptvtx, sptvtx);
273  LogTrace(metname) << " GSL: Pt w vtx :" << ptvtx << "+/-" << sptvtx << endl;
274 
275  // FIXME: temp hack
276  if (ptvtx != 0.) {
277  ptmean = ptvtx;
278  sptmean = sptvtx;
279  return;
280  //
281  }
282  // calculate pt w/o vertex
283  float ptMB = 0.0;
284  float sptMB = 0.0;
285  computeMean(pt + 2, spt + 2, 6, false, ptMB, sptMB);
286  LogTrace(metname) << " GSL: Pt w/o vtx :" << ptMB << "+/-" << sptMB << endl;
287 
288  // decide wheter the muon comes or not from vertex
289  float ptpool = 0.0;
290  if ((ptvtx + ptMB) != 0.0)
291  ptpool = (ptvtx - ptMB) / (ptvtx + ptMB);
292  bool fromvtx = true;
293  if (fabs(ptpool) > 0.2)
294  fromvtx = false;
295  LogTrace(metname) << "From vtx? " << fromvtx << " ptpool " << ptpool << endl;
296 
297  // now choose the "right" pt => weighted mean
298  computeMean(pt, spt, 8, true, ptmean, sptmean);
299  LogTrace(metname) << " GSL Pt :" << ptmean << "+/-" << sptmean << endl;
300  }
301 }
const std::string metname
#define LogTrace(id)
T sqrt(T t)
Definition: SSEVec.h:19
void computeMean(const double *pt, const double *weights, int sz, bool tossOutlyers, float &ptmean, float &sptmean) const

◆ computeMean()

void MuonDTSeedFromRecHits::computeMean ( const double *  pt,
const double *  weights,
int  sz,
bool  tossOutlyers,
float &  ptmean,
float &  sptmean 
) const
private

Definition at line 303 of file MuonDTSeedFromRecHits.cc.

References cms::cuda::assert(), mps_fire::i, dqmiodumpmetadata::n, DiDispStaMuonMonitor_cfi::pt, mathSSE::sqrt(), and hltDeepSecondaryVertexTagInfosPFPuppi_cfi::weights.

Referenced by computeBestPt().

304  {
305  int n = 0;
306  double ptTmp[8];
307  double wtTmp[8];
308  assert(sz <= 8);
309 
310  for (int i = 0; i < 8; ++i) {
311  ptTmp[i] = 0.;
312  wtTmp[i] = 0;
313  if (i < sz && pt[i] != 0) {
314  ptTmp[n] = pt[i];
315  wtTmp[n] = weights[i];
316  ++n;
317  }
318  }
319  if (n != 0) {
320  if (n == 1) {
321  ptmean = ptTmp[0];
322  sptmean = 1 / sqrt(wtTmp[0]);
323  } else {
324  ptmean = gsl_stats_wmean(wtTmp, 1, ptTmp, 1, n);
325  sptmean = sqrt(gsl_stats_wvariance_m(wtTmp, 1, ptTmp, 1, n, ptmean));
326  }
327 
328  if (tossOutlyers) {
329  // Recompute mean with a cut at 3 sigma
330  for (int nm = 0; nm < 8; nm++) {
331  if (ptTmp[nm] != 0 && fabs(ptTmp[nm] - ptmean) > 3 * (sptmean)) {
332  wtTmp[nm] = 0.;
333  }
334  }
335  ptmean = gsl_stats_wmean(wtTmp, 1, ptTmp, 1, n);
336  sptmean = sqrt(gsl_stats_wvariance_m(wtTmp, 1, ptTmp, 1, n, ptmean));
337  }
338  }
339 }
assert(be >=bs)
T sqrt(T t)
Definition: SSEVec.h:19

◆ computePtWithoutVtx()

void MuonDTSeedFromRecHits::computePtWithoutVtx ( double *  pt,
double *  spt 
) const
private

Definition at line 187 of file MuonDTSeedFromRecHits.cc.

References bestEta(), HLT_2024v13_cff::eta1, HLT_2024v13_cff::eta2, DiDispStaMuonMonitor_cfi::pt, MuonSeedPtExtractor::pT_extract(), relativeConstraints::station, MuonSeedFromRecHits::thePtExtractor, MuonSeedFromRecHits::theRhits, and createJobs::tmp.

Referenced by seed().

187  {
188  float eta0 = bestEta();
189 
190  for (MuonRecHitContainer::const_iterator iter = theRhits.begin(); iter != theRhits.end(); iter++) {
191  //+vvp !:
192  float eta1 = (*iter)->globalPosition().eta();
193  if (fabs(eta1 - eta0) > .2)
194  continue; // !!! +vvp
195 
196  for (MuonRecHitContainer::const_iterator iter2 = theRhits.begin(); iter2 != iter; iter2++) {
197  //+vvp !:
198  float eta2 = (*iter2)->globalPosition().eta();
199  if (fabs(eta2 - eta0) > .2)
200  continue; // !!! +vvp
201 
202  unsigned int stat1 = DTChamberId((*iter)->geographicalId()).station();
203  unsigned int stat2 = DTChamberId((*iter2)->geographicalId()).station();
204 
205  if (stat1 > stat2) {
206  int tmp = stat1;
207  stat1 = stat2;
208  stat2 = tmp;
209  }
210  unsigned int st = stat1 * 10 + stat2;
211  double thispt = thePtExtractor->pT_extract(*iter, *iter2)[0];
212  switch (st) {
213  case 12: { //MB1-MB2
214  pt[2] = thispt;
215  break;
216  }
217  case 13: { //MB1-MB3
218  pt[3] = thispt;
219  break;
220  }
221  case 14: { //MB1-MB4
222  pt[5] = thispt;
223  break;
224  }
225  case 23: { //MB2-MB3
226  pt[4] = thispt;
227  break;
228  }
229  case 24: { //MB2-MB4
230  pt[6] = thispt;
231  break;
232  }
233  case 34: { //MB3-MB4
234  pt[7] = thispt;
235  break;
236  }
237  default: {
238  break;
239  }
240  }
241  }
242  }
243 }
MuonTransientTrackingRecHit::MuonRecHitContainer theRhits
const MuonSeedPtExtractor * thePtExtractor
virtual std::vector< double > pT_extract(MuonTransientTrackingRecHit::ConstMuonRecHitPointer firstHit, MuonTransientTrackingRecHit::ConstMuonRecHitPointer secondHit) const
tmp
align.sh
Definition: createJobs.py:716

◆ computePtWithVtx()

void MuonDTSeedFromRecHits::computePtWithVtx ( double *  pt,
double *  spt 
) const
private

Definition at line 155 of file MuonDTSeedFromRecHits.cc.

References bestEta(), HLT_2024v13_cff::eta1, DiDispStaMuonMonitor_cfi::pt, MuonSeedPtExtractor::pT_extract(), muonTiming_cfi::ptmax, relativeConstraints::station, MuonSeedFromRecHits::thePtExtractor, and MuonSeedFromRecHits::theRhits.

Referenced by seed().

155  {
156  float eta0 = bestEta();
157 
158  for (MuonRecHitContainer::const_iterator iter = theRhits.begin(); iter != theRhits.end(); iter++) {
159  //+vvp !:
160 
161  float eta1 = (*iter)->globalPosition().eta();
162  if (fabs(eta1 - eta0) > .2)
163  continue; // !!! +vvp
164 
165  // assign Pt from MB1 & vtx
166  unsigned int stat = DTChamberId((**iter).geographicalId()).station();
167  if (stat > 2)
168  continue;
169 
170  double thispt = thePtExtractor->pT_extract(*iter, *iter)[0];
171  float ptmax = 2000.;
172  if (thispt > ptmax)
173  thispt = ptmax;
174  if (thispt < -ptmax)
175  thispt = -ptmax;
176 
177  if (stat == 1) {
178  pt[0] = thispt;
179  }
180  // assign Pt from MB2 & vtx
181  if (stat == 2) {
182  pt[1] = thispt;
183  }
184  }
185 }
MuonTransientTrackingRecHit::MuonRecHitContainer theRhits
const MuonSeedPtExtractor * thePtExtractor
virtual std::vector< double > pT_extract(MuonTransientTrackingRecHit::ConstMuonRecHitPointer firstHit, MuonTransientTrackingRecHit::ConstMuonRecHitPointer secondHit) const

◆ seed()

TrajectorySeed MuonDTSeedFromRecHits::seed ( ) const
virtual

compute pts with vertex constraint

now w/o vertex constrain

now combine all pt estimate

Definition at line 27 of file MuonDTSeedFromRecHits.cc.

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

Referenced by MuonSeedFinder::seeds().

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