CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
MuonSeedPtExtractor Class Reference

#include <MuonSeedPtExtractor.h>

Public Member Functions

 MuonSeedPtExtractor (const edm::ParameterSet &)
 Constructor with Parameter set and MuonServiceProxy. More...
 
virtual std::vector< double > pT_extract (MuonTransientTrackingRecHit::ConstMuonRecHitPointer firstHit, MuonTransientTrackingRecHit::ConstMuonRecHitPointer secondHit) const
 
void setBeamSpot (const GlobalVector &gv)
 
virtual ~MuonSeedPtExtractor ()
 Destructor. More...
 

Private Types

typedef std::map< std::string, std::vector< double > > ParametersMap
 
typedef std::map< std::string, std::vector< double > > ScalesMap
 

Private Member Functions

void fillParametersForCombo (const std::string &name, const edm::ParameterSet &pset)
 
void fillScalesForCombo (const std::string &name, const edm::ParameterSet &pset)
 
std::vector< double > getPt (const std::vector< double > &vPara, double eta, double dPhi) const
 
std::vector< double > getPt (const std::vector< double > &vPara, double eta, double dPhi, const std::string &combination, const DTChamberId &outerDetId) const
 
void init (const edm::ParameterSet &par)
 
int stationCode (MuonTransientTrackingRecHit::ConstMuonRecHitPointer hit) const
 

Private Attributes

bool scaleDT_
 
GlobalVector theBeamSpot
 
ParametersMap theParametersForCombo
 
ScalesMap theScalesForCombo
 

Detailed Description

Definition at line 15 of file MuonSeedPtExtractor.h.

Member Typedef Documentation

typedef std::map<std::string, std::vector<double> > MuonSeedPtExtractor::ParametersMap
private

Definition at line 45 of file MuonSeedPtExtractor.h.

typedef std::map<std::string, std::vector<double> > MuonSeedPtExtractor::ScalesMap
private

Definition at line 46 of file MuonSeedPtExtractor.h.

Constructor & Destructor Documentation

MuonSeedPtExtractor::MuonSeedPtExtractor ( const edm::ParameterSet par)

Constructor with Parameter set and MuonServiceProxy.

Definition at line 9 of file MuonSeedPtExtractor.cc.

References init().

10 : theBeamSpot(0.,0.,0.),
11  scaleDT_( par.getParameter<bool>("scaleDT") )
12 {
13  init(par);
14 }
T getParameter(std::string const &) const
void init(const edm::ParameterSet &par)
MuonSeedPtExtractor::~MuonSeedPtExtractor ( )
virtual

Destructor.

Definition at line 113 of file MuonSeedPtExtractor.cc.

113  {
114 }

Member Function Documentation

void MuonSeedPtExtractor::fillParametersForCombo ( const std::string &  name,
const edm::ParameterSet pset 
)
private

Definition at line 117 of file MuonSeedPtExtractor.cc.

References edm::ParameterSet::getParameter(), dataset::name, and theParametersForCombo.

Referenced by init().

118 {
119  theParametersForCombo[name] = pset.getParameter<std::vector<double> >(name);
120 }
T getParameter(std::string const &) const
ParametersMap theParametersForCombo
void MuonSeedPtExtractor::fillScalesForCombo ( const std::string &  name,
const edm::ParameterSet pset 
)
private

Definition at line 123 of file MuonSeedPtExtractor.cc.

References edm::ParameterSet::getParameter(), dataset::name, and theScalesForCombo.

Referenced by init().

124 {
125  theScalesForCombo[name] = pset.getParameter<std::vector<double> >(name);
126 }
T getParameter(std::string const &) const
std::vector< double > MuonSeedPtExtractor::getPt ( const std::vector< double > &  vPara,
double  eta,
double  dPhi 
) const
private

Definition at line 382 of file MuonSeedPtExtractor.cc.

References h.

Referenced by pT_extract().

382  {
383  //std::cout<<" eta = "<<eta<<" dPhi = "<<dPhi<<" vPara[0] = "<<vPara[0]<<" vPara[1] = "<<vPara[1]<<" vPara[2] = "<<vPara[2]<<std::endl;
384  double h = fabs(eta);
385  double estPt = ( vPara[0] + vPara[1]*h + vPara[2]*h*h ) / dPhi;
386  double estSPt = ( vPara[3] + vPara[4]*h + vPara[5]*h*h ) / dPhi;
387  // std::cout<<"estPt = "<<estPt<<std::endl;
388  std::vector<double> paraPt ;
389  paraPt.push_back( estPt );
390  paraPt.push_back( estSPt ) ;
391  return paraPt ;
392 }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::vector< double > MuonSeedPtExtractor::getPt ( const std::vector< double > &  vPara,
double  eta,
double  dPhi,
const std::string &  combination,
const DTChamberId outerDetId 
) const
private

Definition at line 395 of file MuonSeedPtExtractor.cc.

References funct::abs(), h, JetEnergyShift_cfi::scaleFactor, theScalesForCombo, DTChamberId::wheel(), and makeMuonMisalignmentScenario::wheel.

396  {
397  double h = fabs(eta);
398  double estPt = ( vPara[0] + vPara[1]*h + vPara[2]*h*h ) / dPhi;
399  // changed by S.C.
400  double estSPt = ( vPara[3] + vPara[4]*h + vPara[5]*h*h ) / dPhi;
401 
402  // scale the pt and spt , changed by S.C.
403  int wheel = 0;
404  if(combination[0] == 'D') {
405  wheel = abs(outerDetId.wheel());
406  }
407 
408  std::ostringstream os;
409  os << combination << "_" << wheel << "_scale";
410 
411  ScalesMap::const_iterator scalesItr = theScalesForCombo.find(os.str());
412  if ( scalesItr != theScalesForCombo.end()) {
413  double t1 = scalesItr->second[0];
414  double scaleFactor = 1./( 1. + t1/( estPt + 10. ) ) ;
415 
416  estSPt = estSPt * scaleFactor ;
417  estPt = estPt * scaleFactor ;
418  }
419 
420  // std::cout<<"estPt = "<<estPt<<std::endl;
421  std::vector<double> paraPt ;
422  paraPt.push_back( estPt );
423  paraPt.push_back( estSPt ) ;
424  return paraPt ;
425 }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
void MuonSeedPtExtractor::init ( const edm::ParameterSet par)
private

Definition at line 17 of file MuonSeedPtExtractor.cc.

References fillParametersForCombo(), and fillScalesForCombo().

Referenced by MuonSeedPtExtractor().

18 {
19  // load pT seed parameters
20  // DT combinations
21  fillParametersForCombo("DT_12", par);
22  fillParametersForCombo("DT_13", par);
23  fillParametersForCombo("DT_14", par);
24  fillParametersForCombo("DT_23", par);
25  fillParametersForCombo("DT_24", par);
26  fillParametersForCombo("DT_34", par);
27  // CSC combinations
28  fillParametersForCombo("CSC_01", par);
29  fillParametersForCombo("CSC_12", par);
30  fillParametersForCombo("CSC_02", par);
31  fillParametersForCombo("CSC_13", par);
32  fillParametersForCombo("CSC_03", par);
33  fillParametersForCombo("CSC_14", par);
34  fillParametersForCombo("CSC_23", par);
35  fillParametersForCombo("CSC_24", par);
36  fillParametersForCombo("CSC_34", par);
37 
38  // Overlap combinations
39  fillParametersForCombo("OL_1213", par);
40  fillParametersForCombo("OL_1222", par);
41  fillParametersForCombo("OL_1232", par);
42  fillParametersForCombo("OL_2213", par);
43  fillParametersForCombo("OL_2222", par);
44 
45  // Single segments (CSC)
46  fillParametersForCombo("SME_11", par);
47  fillParametersForCombo("SME_12", par);
48  fillParametersForCombo("SME_13", par);
49  fillParametersForCombo("SME_21", par);
50  fillParametersForCombo("SME_22", par);
51  fillParametersForCombo("SME_31", par);
52  fillParametersForCombo("SME_32", par);
53  fillParametersForCombo("SME_41", par);
54  fillParametersForCombo("SME_42", par);
55 
56  // Single segments (DT)
57  fillParametersForCombo("SMB_10", par);
58  fillParametersForCombo("SMB_11", par);
59  fillParametersForCombo("SMB_12", par);
60  fillParametersForCombo("SMB_20", par);
61  fillParametersForCombo("SMB_21", par);
62  fillParametersForCombo("SMB_22", par);
63  fillParametersForCombo("SMB_30", par);
64  fillParametersForCombo("SMB_31", par);
65  fillParametersForCombo("SMB_32", par);
66 
67  fillScalesForCombo("CSC_01_1_scale", par);
68  fillScalesForCombo("CSC_12_1_scale", par);
69  fillScalesForCombo("CSC_12_2_scale", par);
70  fillScalesForCombo("CSC_12_3_scale", par);
71  fillScalesForCombo("CSC_13_2_scale", par);
72  fillScalesForCombo("CSC_13_3_scale", par);
73  fillScalesForCombo("CSC_14_3_scale", par);
74  fillScalesForCombo("CSC_23_1_scale", par);
75  fillScalesForCombo("CSC_23_2_scale", par);
76  fillScalesForCombo("CSC_24_1_scale", par);
77  fillScalesForCombo("CSC_34_1_scale", par);
78  fillScalesForCombo("DT_12_1_scale", par);
79  fillScalesForCombo("DT_12_2_scale", par);
80  fillScalesForCombo("DT_13_1_scale", par);
81  fillScalesForCombo("DT_13_2_scale", par);
82  fillScalesForCombo("DT_14_1_scale", par);
83  fillScalesForCombo("DT_14_2_scale", par);
84  fillScalesForCombo("DT_23_1_scale", par);
85  fillScalesForCombo("DT_23_2_scale", par);
86  fillScalesForCombo("DT_24_1_scale", par);
87  fillScalesForCombo("DT_24_2_scale", par);
88  fillScalesForCombo("DT_34_1_scale", par);
89  fillScalesForCombo("DT_34_2_scale", par);
90  fillScalesForCombo("OL_1213_0_scale", par);
91  fillScalesForCombo("OL_1222_0_scale", par);
92  fillScalesForCombo("OL_1232_0_scale", par);
93  fillScalesForCombo("OL_2213_0_scale", par);
94  fillScalesForCombo("OL_2222_0_scale", par);
95  fillScalesForCombo("SMB_10_0_scale", par);
96  fillScalesForCombo("SMB_11_0_scale", par);
97  fillScalesForCombo("SMB_12_0_scale", par);
98  fillScalesForCombo("SMB_20_0_scale", par);
99  fillScalesForCombo("SMB_21_0_scale", par);
100  fillScalesForCombo("SMB_22_0_scale", par);
101  fillScalesForCombo("SMB_30_0_scale", par);
102  fillScalesForCombo("SMB_31_0_scale", par);
103  fillScalesForCombo("SMB_32_0_scale", par);
104  fillScalesForCombo("SME_11_0_scale", par);
105  fillScalesForCombo("SME_12_0_scale", par);
106  fillScalesForCombo("SME_13_0_scale", par);
107  fillScalesForCombo("SME_21_0_scale", par);
108  fillScalesForCombo("SME_22_0_scale", par);
109 
110 }
void fillParametersForCombo(const std::string &name, const edm::ParameterSet &pset)
void fillScalesForCombo(const std::string &name, const edm::ParameterSet &pset)
std::vector< double > MuonSeedPtExtractor::pT_extract ( MuonTransientTrackingRecHit::ConstMuonRecHitPointer  firstHit,
MuonTransientTrackingRecHit::ConstMuonRecHitPointer  secondHit 
) const
virtual

If firstHit and secondHit are the same, it calculates the pT from the phi bend of the single segment

Definition at line 129 of file MuonSeedPtExtractor.cc.

References funct::abs(), MillePedeFileConverter_cfg::e, stringResolutionProvider_cfi::eta, PV3DBase< T, PVType, FrameType >::eta(), Exception, getPt(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), Pi, relativeConstraints::ring, CSCDetId::ring(), scaleDT_, Validation_hcalonly_cfi::sign, mathSSE::sqrt(), DTChamberId::station(), CSCDetId::station(), stationCode(), AlCaHLTBitMon_QueryRunRegistry::string, theBeamSpot, theParametersForCombo, DTChamberId::wheel(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by MuonDTSeedFromRecHits::computePtWithoutVtx(), MuonDTSeedFromRecHits::computePtWithVtx(), MuonCSCSeedFromRecHits::createDefaultEndcapSeed(), SETSeedFinder::estimateMomentum(), MuonOverlapSeedFromRecHits::makeSeed(), and MuonCSCSeedFromRecHits::makeSeed().

131 {
132  GlobalPoint innerPoint = firstHit->globalPosition() - theBeamSpot;
133  GlobalPoint outerPoint = secondHit->globalPosition() - theBeamSpot;
136 
137  // ways in which the hits could be in the wrong order
138  if( (outerHit->isDT() && innerHit->isCSC())
139  || (outerHit->isDT() && innerHit->isDT() && (innerPoint.perp() > outerPoint.perp()))
140  || (outerHit->isCSC() && innerHit->isCSC() && (fabs(innerPoint.z()) > fabs(outerPoint.z()))) )
141  {
142  innerHit = secondHit;
143  outerHit = firstHit;
144  innerPoint = innerHit->globalPosition() - theBeamSpot;
145  outerPoint = outerHit->globalPosition() - theBeamSpot;
146  }
147 
148  double phiInner = innerPoint.phi();
149  double phiOuter = outerPoint.phi();
150 
151  double etaInner = innerPoint.eta();
152  double etaOuter = outerPoint.eta();
153  //std::cout<<" inner pos = "<< innerPoint << " phi eta " << phiInner << " " << etaInner << std::endl;
154  //std::cout<<" outer pos = "<< outerPoint << " phi eta " << phiOuter << " " << etaOuter << std::endl;
155  //double thetaInner = firstHit->globalPosition().theta();
156  // if some of the segments is missing r-phi measurement then we should
157  // use only the 4D phi estimate (also use 4D eta estimate only)
158  // the direction is not so important (it will be corrected)
159  /*
160  bool firstOK = (4==allValidSets[iSet][firstMeasurement]->hit->dimension());
161  bool lastOK = (4==allValidSets[iSet][lastMeasurement]->hit->dimension());
162  if(!(firstOK * lastOK)){
163  if(!firstOK){
164  }
165  if(!firstOK){
166  }
167  }
168  */
169  double dPhi = phiInner - phiOuter;
170  if(dPhi < -TMath::Pi()){
171  dPhi += 2*TMath::Pi();
172  }
173  else if(dPhi > TMath::Pi()){
174  dPhi -= 2*TMath::Pi();
175  }
176  int sign = 1;
177  if ( dPhi< 0.) {
178  dPhi = -dPhi;
179  sign = -1;
180  }
181 
182  if (dPhi < 1.0e-6){
183  dPhi = 1.0e-6;
184  }
185  double eta = fabs(etaOuter);// what if it is 2D segment? use inner?
186 
187 
188  std::vector <int> stationCoded(2);
189  stationCoded[0] = stationCoded[1] = 999;
190 
191  DetId detId_inner = innerHit->hit()->geographicalId();
192  DetId detId_outer = outerHit->hit()->geographicalId();
193 
194  stationCoded[0] = stationCode(innerHit);
195  stationCoded[1] = stationCode(outerHit);
196 
197  std::ostringstream os0 ;
198  std::ostringstream os1 ;
199  os0 << abs(stationCoded[0]);
200  os1 << abs(stationCoded[1]);
201 
202  //std::cout<<" st1 = "<<stationCoded[0]<<" st2 = "<<stationCoded[1]<<std::endl;
203  //std::cout<<" detId_inner = "<<detId_inner.rawId()<<" detId_outer = "<< detId_outer.rawId()<<std::endl;
204  std::string combination = "0";
205  std::string init_combination = combination;
206  bool singleSegment = false;
207  //if(detId_first == detId_second){
208  if( stationCoded[0] == stationCoded[1]){
209  // single segment - DT or CSC
210  singleSegment = true;
211  //eta = innerPoint.eta();
212  GlobalVector gv = innerHit->globalDirection();
213  double gvPerpPos = gv.x()*gv.x() + gv.y()*gv.y();
214  if (gvPerpPos < 1e-32) gvPerpPos = 1e-32;
215  gvPerpPos=sqrt(gvPerpPos);
216  // Psi is angle between the segment origin and segment direction
217  // Use dot product between two vectors to get Psi in global x-y plane
218  double cosDpsi = (gv.x()*innerPoint.x() + gv.y()*innerPoint.y());
219  if (cosDpsi!=0){
220  cosDpsi /= sqrt(innerPoint.x()*innerPoint.x() + innerPoint.y()*innerPoint.y());
221  cosDpsi /= gvPerpPos;
222  cosDpsi = cosDpsi > 1 ? 1 : cosDpsi;
223  cosDpsi = cosDpsi < -1 ? -1 : cosDpsi;
224  }
225 
226  double axb = ( innerPoint.x()*gv.y() ) - ( innerPoint.y()*gv.x() ) ;
227  sign = (axb < 0.) ? 1 : -1;
228 
229  double dpsi = fabs(acos(cosDpsi)) ;
230  if ( dpsi > TMath::Pi()/2.) {
231  dpsi = TMath::Pi() - dpsi;
232  }
233  if (fabs(dpsi) < 0.00005) {
234  dpsi = 0.00005;
235  }
236  dPhi = dpsi;
237 
238  if(innerHit->isDT())
239  {
240  DTChamberId dtCh(detId_inner);
241  std::ostringstream os;
242  os << dtCh.station() << abs(dtCh.wheel());
243  combination = "SMB_"+os.str();
244  }
245  else if(innerHit->isCSC())
246  {
247  CSCDetId cscId(detId_inner);
248  std::ostringstream os;
249  int ring = cscId.ring();
250  if(ring == 4) ring = 1;
251  os << cscId.station() << ring;
252  combination = "SME_"+os.str();
253  }
254  else
255  {
256  throw cms::Exception("MuonSeedPtExtractor") << "Bad hit DetId";
257  }
258  }
259  else{
260  if(stationCoded[0]<0){
261  if(stationCoded[1]<0){
262  // DT-DT
263  combination = "DT_" + os0.str() + os1.str();
264  }
265  else{
266  // DT-CSC
267  eta = fabs(etaInner);
268  if(-1==stationCoded[0]){
269  switch (stationCoded[1]){
270  case 1:
271  combination = "OL_1213";
272  break;
273  case 2:
274  combination = "OL_1222";
275  break;
276  case 3:
277  combination = "OL_1232";
278  break;
279  default:
280  // can not be
281  break;
282  }
283  }
284  else if (-2==stationCoded[0]){
285  if(1==stationCoded[1]){
286  combination = "OL_2213";
287  }
288  else{
289  // can not be (not coded?)
290  combination = "OL_2222";// in case
291  }
292  }
293  else{
294  // can not be
295  }
296  }
297  }
298  else{
299  if(stationCoded[1]<0){
300  // CSC-DT
301  // can not be
302  }
303  else{
304  // CSC-CSC
305  combination = "CSC_" + os0.str() + os1.str();
306  if("CSC_04" == combination){
307  combination = "CSC_14";
308  }
309  }
310  }
311  }
312 
313  std::vector<double> pTestimate(2);//
314  //std::cout<<" combination = "<<combination<<std::endl;
315  if(init_combination!=combination){
316  //std::cout<<" combination = "<<combination<<" eta = "<<eta<<" dPhi = "<<dPhi<<std::endl;
317  ParametersMap::const_iterator parametersItr = theParametersForCombo.find(combination);
318  if(parametersItr == theParametersForCombo.end()) {
319  // edm::LogWarning("RecoMuon|MuonSeedGenerator|MuonSeedPtExtractor") << "Cannot find parameters for combo " << combination;
320  edm::LogWarning("BadSegmentCombination") << "Cannot find parameters for combo " << combination;
321  pTestimate[0] = pTestimate[1] = 100;
322  // throw cms::Exception("MuonSeedPtEstimator") << "Cannot find parameters for combo " << combination;
323  } else {
324 
325  if(scaleDT_ && outerHit->isDT() )
326  {
327  pTestimate = getPt(parametersItr->second, eta, dPhi, combination, detId_outer);
328  }
329  else
330  {
331  pTestimate = getPt(parametersItr->second, eta, dPhi);
332  }
333 
334  if(singleSegment){
335  pTestimate[0] = fabs(pTestimate[0]);
336  pTestimate[1] = fabs(pTestimate[1]);
337  }
338  pTestimate[0] *= double(sign);
339  }
340  }
341  else{
342  // often a MB3 - ME1/3 seed
343  pTestimate[0] = pTestimate[1] = 100;
344  // hmm
345  }
346  // std::cout<<" pTestimate[0] = "<<pTestimate[0]<<" pTestimate[1] = "<<pTestimate[1]<<std::endl;
347  /*
348  MuonRecHitContainer_clusters[cluster][iHit+1]->isDT());
349  if(specialCase){
350  DTChamberId dtCh(detId);
351  DTChamberId dtCh_2(detId_2);
352  specialCase = (dtCh.station() == dtCh_2.station());
353  }
354  */
355  //return vPara;
356  return pTestimate;
357 }
const double Pi
T perp() const
Definition: PV3DBase.h:72
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
int stationCode(MuonTransientTrackingRecHit::ConstMuonRecHitPointer hit) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParametersMap theParametersForCombo
Definition: DetId.h:18
T eta() const
Definition: PV3DBase.h:76
std::shared_ptr< MuonTransientTrackingRecHit const > ConstMuonRecHitPointer
T x() const
Definition: PV3DBase.h:62
std::vector< double > getPt(const std::vector< double > &vPara, double eta, double dPhi) const
void MuonSeedPtExtractor::setBeamSpot ( const GlobalVector gv)
inline
int MuonSeedPtExtractor::stationCode ( MuonTransientTrackingRecHit::ConstMuonRecHitPointer  hit) const
private

Definition at line 360 of file MuonSeedPtExtractor.cc.

References mps_fire::result, CSCDetId::ring(), DTChamberId::station(), and CSCDetId::station().

Referenced by pT_extract().

361 {
362  DetId detId(hit->hit()->geographicalId());
363  int result = -999;
364  if(hit->isDT() ){
365  DTChamberId dtCh(detId);
366  //std::cout<<"first (DT) St/W/S = "<<dtCh.station()<<"/"<<dtCh.wheel()<<"/"<<dtCh.sector()<<"/"<<std::endl;
367  result = -1 * dtCh.station();
368  }
369  else if( hit->isCSC() ){
370  CSCDetId cscID(detId);
371  //std::cout<<"first (CSC) E/S/R/C = "<<cscID.endcap()<<"/"<<cscID.station()<<"/"<<cscID.ring()<<"/"<<cscID.chamber()<<std::endl;
372  result = cscID.station();
373  if(result == 1 && (1 == cscID.ring() || 4 == cscID.ring()) )
374  result = 0;
375  }
376  else if(hit->isRPC()){
377  }
378  return result;
379 }
Definition: DetId.h:18

Member Data Documentation

bool MuonSeedPtExtractor::scaleDT_
private

Definition at line 50 of file MuonSeedPtExtractor.h.

Referenced by pT_extract().

GlobalVector MuonSeedPtExtractor::theBeamSpot
private

Definition at line 49 of file MuonSeedPtExtractor.h.

Referenced by pT_extract().

ParametersMap MuonSeedPtExtractor::theParametersForCombo
private

Definition at line 47 of file MuonSeedPtExtractor.h.

Referenced by fillParametersForCombo(), and pT_extract().

ScalesMap MuonSeedPtExtractor::theScalesForCombo
private

Definition at line 48 of file MuonSeedPtExtractor.h.

Referenced by fillScalesForCombo(), and getPt().