CMS 3D CMS Logo

MuonSeedPtExtractor.cc

Go to the documentation of this file.
00001 #include "RecoMuon/MuonSeedGenerator/src/MuonSeedPtExtractor.h"
00002 
00003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00004 
00005 //#include "TrackingTools/DetLayers/interface/DetLayer.h"
00006 //#include "Geometry/CommonDetUnit/interface/GeomDet.h"
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   // load pT seed parameters
00016   // DT combinations
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   // CSC combinations
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   // Overlap combinations
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   // Single segments (CSC)
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   // Single segments (DT)
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   //std::vector<double> vPara;
00071   
00072   std::map <std::string, std::vector<double> > chamberCombination;
00073 
00074   // DT station-station
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   // CSC station-station (O is ME11)
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   // DT-CSC overlap 
00094   chamberCombination["OL1213"] = ol1213();
00095   chamberCombination["OL1222"] = ol1222();
00096   chamberCombination["OL1232"] = ol1232();
00097   chamberCombination["OL2213"] = ol2213();
00098   chamberCombination["OL2222"] = ol2222();
00099 
00100   // CSC single (ststion/ring)
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   // DT single (?)
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   //std::cout<<" first pos = "<<firstHit->globalPosition()<<std::endl;
00128   //std::cout<<" scond pos = "<<secondHit->globalPosition()<<std::endl;
00129   //double thetaInner = firstHit->globalPosition().theta();
00130   // if some of the segments is missing r-phi measurement then we should
00131   // use only the 4D phi estimate (also use 4D eta estimate only)
00132   // the direction is not so important (it will be corrected) 
00133   /*
00134     bool firstOK = (4==allValidSets[iSet][firstMeasurement]->hit->dimension());
00135     bool lastOK = (4==allValidSets[iSet][lastMeasurement]->hit->dimension());
00136     if(!(firstOK * lastOK)){
00137     if(!firstOK){
00138     }
00139     if(!firstOK){
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);// what if it is 2D segment? use inner?
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   //  std::cout<<" st1 = "<<stationCoded[0]<<" st2 = "<<stationCoded[1]<<std::endl;
00177   //std::cout<<" detId_first = "<<detId_first.rawId()<<"  detId_second = "<< detId_second.rawId()<<std::endl;
00178   std::string  combination = "0";
00179   std::string init_combination = combination;
00180   bool singleSegment = false;
00181   //if(detId_first == detId_second){
00182   if( stationCoded[0] == stationCoded[1]){
00183     // single segment - DT or CSC
00184     singleSegment = true;
00185     GlobalPoint segPos = firstHit->globalPosition();
00186     //eta = segPos.eta();
00187     GlobalVector gv = firstHit->globalDirection();
00188 
00189     // Psi is angle between the segment origin and segment direction
00190     // Use dot product between two vectors to get Psi in global x-y plane
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       // the 1st layer
00209     case -1:
00210      // MB10
00211     if ( etaAbs < 0.3 ) {
00212       combination = "SMB10";
00213     }
00214      // MB11
00215     else if(etaAbs >= 0.3 && etaAbs < 0.82){
00216       combination = "SMB11";
00217     }
00218     // MB12
00219     else if(etaAbs >= 0.82 && etaAbs < 1.2){
00220       combination = "SMB12";
00221     }
00222     else{
00223       // can not be
00224     }
00225       break;
00226     case 1:
00227     // ME13
00228       if(etaAbs > 0.92 && etaAbs < 1.16){
00229         combination = "SME13";
00230       }
00231       // ME12
00232       else if(etaAbs >= 1.16 && etaAbs <= 1.6){
00233       }
00234       else{
00235         // can not be 
00236       }
00237       break;
00238     case 0:
00239       // ME11
00240       if ( etaAbs > 1.6 && etaAbs < 2.45 ) {
00241         combination = "SME11";
00242       }
00243       break;
00244       // the 2nd layer
00245     case -2:
00246       // MB20
00247       if ( etaAbs < 0.25 ) {
00248         combination = "SMB20";
00249       }
00250       // MB21
00251       else if ( etaAbs >= 0.25 && etaAbs < 0.72 ) {
00252         combination = "SMB21";
00253       }
00254       // MB22
00255       else if ( etaAbs >= 0.72 && etaAbs < 1.04 ) {
00256         combination = "SMB22";
00257       }
00258       else{
00259         // can not be 
00260         combination = "SMB22"; // in case
00261       }
00262       break;
00263     case 2:
00264      // ME22
00265      if ( etaAbs > 0.95 && etaAbs <= 1.6 ) {
00266        combination = "SME22";
00267      }
00268      // ME21
00269      else if ( etaAbs > 1.6 && etaAbs < 2.45 ) {
00270        combination = "SME21";
00271      }
00272      else{
00273        // can not be
00274      }
00275       break;
00276       // the 3rd layer
00277     case -3:
00278       // MB30
00279      if ( fabs(eta) <= 0.22 ) {
00280        combination = "SMB30";
00281      }
00282      // MB31
00283      if ( fabs(eta) > 0.22 && fabs(eta) <= 0.6 ) {
00284        combination = "SMB31";
00285      }
00286      // MB32
00287      if ( fabs(eta) > 0.6 && fabs(eta) < 0.95 ) {
00288        combination = "SMB32";
00289      }
00290      else{
00291        // can not be
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         // DT-DT
00309         combination = "DT" + os0.str() + os1.str();
00310       }
00311       else{
00312         // DT-CSC
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             // can not be 
00327             break;
00328           }
00329         }
00330         else if (-2==stationCoded[0]){
00331           if(1==stationCoded[1]){
00332             combination = "OL2213";
00333           }
00334           else{
00335             // can not be (not coded?)
00336             combination = "OL2222";// in case
00337           }
00338         }
00339         else{
00340           // can not be
00341         }
00342       }
00343     }
00344     else{
00345       if(stationCoded[1]<0){
00346         // CSC-DT
00347         // can not be
00348       }
00349       else{
00350         // CSC-CSC
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   //  std::cout<<" combination = "<<combination<<std::endl;
00361   if(init_combination!=combination){
00362     //    std::cout<<" combination = "<<combination<<" eta = "<<eta<<" dPhi = "<<dPhi<<std::endl;
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     // hmm
00373   }
00374   // std::cout<<" pTestimate[0] = "<<pTestimate[0]<<" pTestimate[1] = "<<pTestimate[1]<<std::endl;
00375   /*
00376                               MuonRecHitContainer_clusters[cluster][iHit+1]->isDT());
00377           if(specialCase){
00378             DTChamberId dtCh(detId);
00379             DTChamberId dtCh_2(detId_2);
00380             specialCase =  (dtCh.station() == dtCh_2.station());
00381           }
00382   */
00383   //return vPara;
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     //std::cout<<"first (DT) St/W/S = "<<dtCh.station()<<"/"<<dtCh.wheel()<<"/"<<dtCh.sector()<<"/"<<std::endl;
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     //std::cout<<"first (CSC) E/S/R/C = "<<cscID.endcap()<<"/"<<cscID.station()<<"/"<<cscID.ring()<<"/"<<cscID.chamber()<<std::endl;
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 // it is a copy from the Seed code - call it from there?
00445 std::vector<double> MuonSeedPtExtractor::getPt(const std::vector<double> & vPara, double eta, double dPhi ) const {
00446   // std::cout<<" eta = "<<eta<<" dPhi = "<<dPhi<<" vPara[0] = "<<vPara[0]<<" vPara[1] = "<<vPara[1]<<" vPara[2] = "<<vPara[2]<<std::endl;
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   // std::cout<<"estPt = "<<estPt<<std::endl;
00451   std::vector<double> paraPt ;
00452   paraPt.push_back( estPt );
00453   paraPt.push_back( estSPt ) ;
00454   return paraPt ;
00455 }

Generated on Tue Jun 9 17:44:29 2009 for CMSSW by  doxygen 1.5.4