00001 #include "RecoMuon/MuonSeedGenerator/src/MuonSeedPtExtractor.h"
00002
00003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00004
00005
00006
00007
00008 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
00009 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00010
00011 #include "TMath.h"
00012
00013 MuonSeedPtExtractor::MuonSeedPtExtractor(const edm::ParameterSet& par){
00014
00015
00016
00017 DT12 = par.getParameter<std::vector<double> >("DT_12");
00018 DT13 = par.getParameter<std::vector<double> >("DT_13");
00019 DT14 = par.getParameter<std::vector<double> >("DT_14");
00020 DT23 = par.getParameter<std::vector<double> >("DT_23");
00021 DT24 = par.getParameter<std::vector<double> >("DT_24");
00022 DT34 = par.getParameter<std::vector<double> >("DT_34");
00023
00024 CSC01 = par.getParameter<std::vector<double> >("CSC_01");
00025 CSC12 = par.getParameter<std::vector<double> >("CSC_12");
00026 CSC02 = par.getParameter<std::vector<double> >("CSC_02");
00027 CSC13 = par.getParameter<std::vector<double> >("CSC_13");
00028 CSC03 = par.getParameter<std::vector<double> >("CSC_03");
00029 CSC14 = par.getParameter<std::vector<double> >("CSC_14");
00030 CSC23 = par.getParameter<std::vector<double> >("CSC_23");
00031 CSC24 = par.getParameter<std::vector<double> >("CSC_24");
00032 CSC34 = par.getParameter<std::vector<double> >("CSC_34");
00033
00034
00035 OL1213 = par.getParameter<std::vector<double> >("OL_1213");
00036 OL1222 = par.getParameter<std::vector<double> >("OL_1222");
00037 OL1232 = par.getParameter<std::vector<double> >("OL_1232");
00038 OL2213 = par.getParameter<std::vector<double> >("OL_2213");
00039 OL2222 = par.getParameter<std::vector<double> >("OL_2222");
00040
00041
00042 SME11 = par.getParameter<std::vector<double> >("SME_11");
00043 SME12 = par.getParameter<std::vector<double> >("SME_12");
00044 SME13 = par.getParameter<std::vector<double> >("SME_13");
00045 SME21 = par.getParameter<std::vector<double> >("SME_21");
00046 SME22 = par.getParameter<std::vector<double> >("SME_22");
00047 SME31 = par.getParameter<std::vector<double> >("SME_31");
00048 SME32 = par.getParameter<std::vector<double> >("SME_32");
00049 SME41 = par.getParameter<std::vector<double> >("SME_41");
00050
00051
00052 SMB10 = par.getParameter<std::vector<double> >("SMB_10");
00053 SMB11 = par.getParameter<std::vector<double> >("SMB_11");
00054 SMB12 = par.getParameter<std::vector<double> >("SMB_12");
00055 SMB20 = par.getParameter<std::vector<double> >("SMB_20");
00056 SMB21 = par.getParameter<std::vector<double> >("SMB_21");
00057 SMB22 = par.getParameter<std::vector<double> >("SMB_22");
00058 SMB30 = par.getParameter<std::vector<double> >("SMB_30");
00059 SMB31 = par.getParameter<std::vector<double> >("SMB_31");
00060 SMB32 = par.getParameter<std::vector<double> >("SMB_32");
00061
00062 }
00063 MuonSeedPtExtractor::~MuonSeedPtExtractor(){
00064 }
00065
00066
00067 std::vector<double> MuonSeedPtExtractor::pT_extract(MuonTransientTrackingRecHit::ConstMuonRecHitPointer firstHit,
00068 MuonTransientTrackingRecHit::ConstMuonRecHitPointer secondHit) const
00069 {
00070
00071
00072 std::map <std::string, std::vector<double> > chamberCombination;
00073
00074
00075 chamberCombination["DT12"] = dt12();
00076 chamberCombination["DT13"] = dt13();
00077 chamberCombination["DT14"] = dt14();
00078 chamberCombination["DT23"] = dt23();
00079 chamberCombination["DT24"] = dt24();
00080 chamberCombination["DT34"] = dt34();
00081
00082
00083 chamberCombination["CSC01"] = csc01();
00084 chamberCombination["CSC12"] = csc12();
00085 chamberCombination["CSC02"] = csc02();
00086 chamberCombination["CSC13"] = csc13();
00087 chamberCombination["CSC03"] = csc03();
00088 chamberCombination["CSC14"] = csc14();
00089 chamberCombination["CSC23"] = csc23();
00090 chamberCombination["CSC24"] = csc24();
00091 chamberCombination["CSC34"] = csc34();
00092
00093
00094 chamberCombination["OL1213"] = ol1213();
00095 chamberCombination["OL1222"] = ol1222();
00096 chamberCombination["OL1232"] = ol1232();
00097 chamberCombination["OL2213"] = ol2213();
00098 chamberCombination["OL2222"] = ol2222();
00099
00100
00101 chamberCombination["SME11"] = sme11();
00102 chamberCombination["SME12"] = sme12();
00103 chamberCombination["SME13"] = sme13();
00104 chamberCombination["SME21"] = sme21();
00105 chamberCombination["SME22"] = sme22();
00106 chamberCombination["SME31"] = sme31();
00107 chamberCombination["SME32"] = sme32();
00108 chamberCombination["SME41"] = sme41();
00109
00110
00111 chamberCombination["SMB10"] = smb10();
00112 chamberCombination["SMB11"] = smb11();
00113 chamberCombination["SMB12"] = smb12();
00114 chamberCombination["SMB20"] = smb20();
00115 chamberCombination["SMB21"] = smb21();
00116 chamberCombination["SMB22"] = smb22();
00117 chamberCombination["SMB30"] = smb30();
00118 chamberCombination["SMB31"] = smb31();
00119 chamberCombination["SMB32"] = smb32();
00120
00121
00122 double phiInner = firstHit->globalPosition().phi();
00123 double phiOuter = secondHit->globalPosition().phi();
00124
00125 double etaInner = firstHit->globalPosition().eta();
00126 double etaOuter = secondHit->globalPosition().eta();
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 double dPhi = phiInner - phiOuter;
00144 if(dPhi < -TMath::Pi()){
00145 dPhi += 2*TMath::Pi();
00146 }
00147 else if(dPhi > TMath::Pi()){
00148 dPhi -= 2*TMath::Pi();
00149 }
00150 int sign = 1;
00151 if ( dPhi< 0.) {
00152 dPhi = -dPhi;
00153 sign = -1;
00154 }
00155
00156 if (dPhi < 1.0e-6){
00157 dPhi = 1.0e-6;
00158 }
00159 double eta = fabs(etaOuter);
00160
00161
00162 std::vector <int> stationCoded(2);
00163 stationCoded[0] = stationCoded[1] = 999;
00164
00165 DetId detId_first = firstHit->hit()->geographicalId();
00166 DetId detId_second = secondHit->hit()->geographicalId();
00167
00168 stationCoded[0] = stationCode(firstHit);
00169 stationCoded[1] = stationCode(secondHit);
00170
00171 std::ostringstream os0 ;
00172 std::ostringstream os1 ;
00173 os0 << abs(stationCoded[0]);
00174 os1 << abs(stationCoded[1]);
00175
00176
00177
00178 std::string combination = "0";
00179 std::string init_combination = combination;
00180 bool singleSegment = false;
00181
00182 if( stationCoded[0] == stationCoded[1]){
00183
00184 singleSegment = true;
00185 GlobalPoint segPos = firstHit->globalPosition();
00186
00187 GlobalVector gv = firstHit->globalDirection();
00188
00189
00190
00191 double cosDpsi = (gv.x()*segPos.x() + gv.y()*segPos.y());
00192 cosDpsi /= sqrt(segPos.x()*segPos.x() + segPos.y()*segPos.y());
00193 cosDpsi /= sqrt(gv.x()*gv.x() + gv.y()*gv.y());
00194
00195 double axb = ( segPos.x()*gv.y() ) - ( segPos.y()*gv.x() ) ;
00196 sign = (axb < 0.) ? 1 : -1;
00197
00198 double dpsi = fabs(acos(cosDpsi)) ;
00199 if ( dpsi > TMath::Pi()/2.) {
00200 dpsi = TMath::Pi() - dpsi;
00201 }
00202 if (fabs(dpsi) < 0.00005) {
00203 dpsi = 0.00005;
00204 }
00205 dPhi = dpsi;
00206 double etaAbs = fabs(eta);
00207 switch(stationCoded[0]){
00208
00209 case -1:
00210
00211 if ( etaAbs < 0.3 ) {
00212 combination = "SMB10";
00213 }
00214
00215 else if(etaAbs >= 0.3 && etaAbs < 0.82){
00216 combination = "SMB11";
00217 }
00218
00219 else if(etaAbs >= 0.82 && etaAbs < 1.2){
00220 combination = "SMB12";
00221 }
00222 else{
00223
00224 }
00225 break;
00226 case 1:
00227
00228 if(etaAbs > 0.92 && etaAbs < 1.16){
00229 combination = "SME13";
00230 }
00231
00232 else if(etaAbs >= 1.16 && etaAbs <= 1.6){
00233 }
00234 else{
00235
00236 }
00237 break;
00238 case 0:
00239
00240 if ( etaAbs > 1.6 && etaAbs < 2.45 ) {
00241 combination = "SME11";
00242 }
00243 break;
00244
00245 case -2:
00246
00247 if ( etaAbs < 0.25 ) {
00248 combination = "SMB20";
00249 }
00250
00251 else if ( etaAbs >= 0.25 && etaAbs < 0.72 ) {
00252 combination = "SMB21";
00253 }
00254
00255 else if ( etaAbs >= 0.72 && etaAbs < 1.04 ) {
00256 combination = "SMB22";
00257 }
00258 else{
00259
00260 combination = "SMB22";
00261 }
00262 break;
00263 case 2:
00264
00265 if ( etaAbs > 0.95 && etaAbs <= 1.6 ) {
00266 combination = "SME22";
00267 }
00268
00269 else if ( etaAbs > 1.6 && etaAbs < 2.45 ) {
00270 combination = "SME21";
00271 }
00272 else{
00273
00274 }
00275 break;
00276
00277 case -3:
00278
00279 if ( fabs(eta) <= 0.22 ) {
00280 combination = "SMB30";
00281 }
00282
00283 if ( fabs(eta) > 0.22 && fabs(eta) <= 0.6 ) {
00284 combination = "SMB31";
00285 }
00286
00287 if ( fabs(eta) > 0.6 && fabs(eta) < 0.95 ) {
00288 combination = "SMB32";
00289 }
00290 else{
00291
00292 }
00293
00294 break;
00295 case 3:
00296
00297 break;
00298 case 4:
00299
00300 break;
00301 default :
00302 break;
00303 }
00304 }
00305 else{
00306 if(stationCoded[0]<0){
00307 if(stationCoded[1]<0){
00308
00309 combination = "DT" + os0.str() + os1.str();
00310 }
00311 else{
00312
00313 eta = fabs(etaInner);
00314 if(-1==stationCoded[0]){
00315 switch (stationCoded[1]){
00316 case 1:
00317 combination = "OL1213";
00318 break;
00319 case 2:
00320 combination = "OL1222";
00321 break;
00322 case 3:
00323 combination = "OL1232";
00324 break;
00325 default:
00326
00327 break;
00328 }
00329 }
00330 else if (-2==stationCoded[0]){
00331 if(1==stationCoded[1]){
00332 combination = "OL2213";
00333 }
00334 else{
00335
00336 combination = "OL2222";
00337 }
00338 }
00339 else{
00340
00341 }
00342 }
00343 }
00344 else{
00345 if(stationCoded[1]<0){
00346
00347
00348 }
00349 else{
00350
00351 combination = "CSC" + os0.str() + os1.str();
00352 if("CSC04" == combination){
00353 combination = "CSC14";
00354 }
00355 }
00356 }
00357 }
00358
00359 std::vector<double> pTestimate(2);
00360
00361 if(init_combination!=combination){
00362
00363 pTestimate = getPt(chamberCombination[combination], eta, dPhi);
00364 if(singleSegment){
00365 pTestimate[0] = fabs(pTestimate[0]);
00366 pTestimate[1] = fabs(pTestimate[1]);
00367 }
00368 pTestimate[0] = pTestimate[0] * double(sign);
00369 }
00370 else{
00371 pTestimate[0] = pTestimate[1] = 100;
00372
00373 }
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384 return pTestimate;
00385 }
00386
00387
00388 int MuonSeedPtExtractor::stationCode(MuonTransientTrackingRecHit::ConstMuonRecHitPointer hit) const
00389 {
00390 DetId detId(hit->hit()->geographicalId());
00391 int result = -999;
00392 if(hit->isDT() ){
00393 DTChamberId dtCh(detId);
00394
00395 switch (dtCh.station()){
00396 case 1:
00397 result = -1;
00398 break;
00399 case 2:
00400 result = -2;
00401 break;
00402 case 3:
00403 result = -3;
00404 break;
00405 case 4:
00406 result = -4;
00407 break;
00408 default:
00409 result = -99;
00410 break;
00411 }
00412 }
00413 else if( hit->isCSC() ){
00414 CSCDetId cscID(detId);
00415
00416 switch ( cscID.station() ){
00417 case 1:
00418 if ( 1 == cscID.ring() || 4 == cscID.ring()){
00419 result = 0;
00420 }
00421 else{
00422 result = 1;
00423 }
00424 break;
00425 case 2:
00426 result = 2;
00427 break;
00428 case 3:
00429 result = 3;
00430 break;
00431 case 4:
00432 result = 4;
00433 break;
00434 default:
00435 result = 99;
00436 break;
00437 }
00438 }
00439 else if(hit->isRPC()){
00440 }
00441 return result;
00442 }
00443
00444
00445 std::vector<double> MuonSeedPtExtractor::getPt(const std::vector<double> & vPara, double eta, double dPhi ) const {
00446
00447 double h = fabs(eta);
00448 double estPt = ( vPara[0] + vPara[1]*h + vPara[2]*h*h ) / dPhi;
00449 double estSPt = ( vPara[3] + vPara[4]*h + vPara[5]*h*h ) * estPt;
00450
00451 std::vector<double> paraPt ;
00452 paraPt.push_back( estPt );
00453 paraPt.push_back( estSPt ) ;
00454 return paraPt ;
00455 }