00001 #include <fstream> 00002 00003 #include "FastSimulation/ParamL3MuonProducer/interface/FMGLfromTKEfficiencyHandler.h" 00004 #include "SimDataFormats/Track/interface/SimTrack.h" 00005 00006 #include "Utilities/General/interface/FileInPath.h" 00007 #include "Utilities/General/interface/CMSexception.h" 00008 00009 #include "FastSimulation/Utilities/interface/RandomEngine.h" 00010 00011 FMGLfromTKEfficiencyHandler::FMGLfromTKEfficiencyHandler(const RandomEngine * engine) 00012 : random(engine) {; 00013 00014 std::string fname = "FastSimulation/ParamL3MuonProducer/data/efficiencyGL_TK.data"; 00015 std::string path(getenv("CMSSW_SEARCH_PATH")); 00016 FileInPath f1(path,fname); 00017 00018 if ( f1() == 0) { 00019 std::cout << "File efficiencyGL_TK.data not found in " << path << std::endl; 00020 throw Genexception(" efficiency list not found for FMGLfromTKEfficiencyHandler."); 00021 } else { 00022 std::cout << "Reading " << f1.name() << std::endl; 00023 } 00024 std::ifstream & listfile = *f1(); 00025 00026 double eff=0.; 00027 int nent; 00028 listfile >> nent; 00029 if (nent != nEtaBins) { 00030 std::cout << " *** ERROR -> FMGLfromTKEfficiencyHandler : nEta bins " << nent << " instead of " << nEtaBins << std::endl; 00031 } 00032 for (int i=0; i<nEtaBins; i++) { 00033 listfile >> eff; 00034 Effic_Eta[i]=eff; 00035 } 00036 00037 } 00038 00039 FMGLfromTKEfficiencyHandler::~FMGLfromTKEfficiencyHandler(){ 00040 delete Effic_Eta; 00041 } 00042 00043 bool FMGLfromTKEfficiencyHandler::kill(const SimTrack & aTrack) { 00044 00045 // At least eight hit in the tracker : To be tuned !!! 00046 //if ( aTrack.recHits().size() < 8 ) return false; 00047 00048 // At least zero reconstructed Pixel hits : To be tuned !!! 00049 //int seed = 0; 00050 //for ( unsigned i=1; i<6; ++i ) 00051 // if ( aTrack.isARecHit(i) ) ++seed; 00052 //if ( seed < 0 ) return false; 00053 00054 double myEffEta=0. , myEffPt=0. , myCorrection=1. , myEff; 00055 00056 // Eta dependence : 00057 double eta = fabs(aTrack.momentum().eta()); 00058 if (eta < 2.40) { 00059 int iEtaBin = (int) ( (eta/2.40) * nEtaBins); 00060 myEffEta = Effic_Eta[iEtaBin]; 00061 } else return false; 00062 00063 // Pt dependence (same as L3 muons for "track-only" Global Muons): 00064 double pt = std::sqrt(aTrack.momentum().perp2()); 00065 if (eta<1.04) { 00066 if (pt>40.) myEffPt = 0.9583 - pt*5.82726e-05; 00067 // else if (pt>4.10) myEffPt = 0.952*(1.-exp(-(pt-4.072))); 00068 else if (pt>4.0) myEffPt = 0.952*(1.-sqrt(exp(-(pt-3.2)))); 00069 // myCorrection = 1.045; 00070 myCorrection = 1.077; 00071 } 00072 else if (eta<2.07) { 00073 if (pt>173.) myEffPt = 0.991 - pt*3.46562e-05; 00074 // else if (pt>3.10) myEffPt = 0.985*(1.-exp(-(pt-3.061))); 00075 else if (pt>3.0) myEffPt = 0.985*(1.-sqrt(exp(-(pt-2.4)))); 00076 // myCorrection = 1.027; 00077 myCorrection = 1.028; 00078 } 00079 else if (eta<2.40) { 00080 if (pt>26.) myEffPt = 0.9221 - pt*7.75139e-05; 00081 else if (pt>3.00) myEffPt = 0.927*(1.-exp(-sqrt(pt-1.617))); 00082 // myCorrection = 1.061; 00083 myCorrection = 1.133; 00084 } 00085 else return false; 00086 00087 /* 00088 // Special high Pt muons treatment : 00089 if (pt>400.) { 00090 float myEffHighPt=1.; 00091 float pttev = pt/1000.; 00092 if (eta < 0.3) { 00093 myEffHighPt = 0.952 - 0.033*pttev; 00094 } else if ( eta < 0.6) { 00095 myEffHighPt = 0.973 - 0.033*pttev; 00096 } else if ( eta < 0.9) { 00097 myEffHighPt = 0.969 - 0.045*pttev; 00098 } else if ( eta < 1.2) { 00099 myEffHighPt = 0.968 - 0.058*pttev; 00100 } else if ( eta < 1.5) { 00101 myEffHighPt = 0.966 - 0.074*pttev; 00102 } else if ( eta < 1.8) { 00103 myEffHighPt = 0.955 - 0.11*pttev; 00104 } else if ( eta < 2.1) { 00105 myEffHighPt = 0.982 - 0.11*pttev; 00106 } else { 00107 myEffHighPt = 0.958 - 0.14*pttev; 00108 } 00109 myEffPt = (myEffPt>myEffHighPt? myEffHighPt : myEffPt); 00110 } 00111 */ 00112 /* 00113 if (eta<1.04) { 00114 if (pt>40.) myEffPt = 0.9583 - pt*5.82726e-05; 00115 else if (pt>4.10) myEffPt = 0.952*(1.-exp(-(pt-4.072))); 00116 myCorrection = 1.115; 00117 } 00118 else if (eta<2.07) { 00119 if (pt>173.) myEffPt = 0.991 - pt*3.46562e-05; 00120 else if (pt>3.10) myEffPt = 0.985*(1.-exp(-(pt-3.061))); 00121 myCorrection = 1.034; 00122 } 00123 else if (eta<2.40) { 00124 if (pt>26.) myEffPt = 0.9221 - pt*7.75139e-05; 00125 else if (pt>3.00) myEffPt = 0.927*(1.-exp(-sqrt(pt-1.617))); 00126 myCorrection = 1.157; 00127 } 00128 else return false; 00129 */ 00130 00131 myEff = myEffEta*myEffPt*myCorrection; 00132 00133 double prob = random->flatShoot(); 00134 return (myEff > prob) ; 00135 00136 } 00137 00138 00139