00001 #include <fstream> 00002 00003 #include "FastSimulation/Muons/interface/FML1EfficiencyHandler.h" 00004 #include "FastSimDataFormats/L1GlobalMuonTrigger/interface/SimpleL1MuGMTCand.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 using namespace std; 00012 00013 FML1EfficiencyHandler::FML1EfficiencyHandler(const RandomEngine * engine) 00014 : random(engine){ 00015 00016 string fname = "FastSimulation/Muons/data/efficiencyL1.data"; 00017 // std::string path(std::getenv("CMSSW_SEARCH__PATH")); 00018 std::string path(getenv("CMSSW_SEARCH_PATH")); 00019 FileInPath f1(path,fname); 00020 if ( f1() == 0) { 00021 std::cout << "File " << fname << " not found in " << path << std::endl; 00022 throw Genexception(" efficiency list not found for FML1EfficiencyHandler."); 00023 } else { 00024 std::cout << "Reading " << f1.name() << std::endl; 00025 } 00026 std::ifstream & listfile = *f1(); 00027 00028 double eff=0.; 00029 for (int i=0; i<nEtaBins; i++) { 00030 listfile >> eff; 00031 Effic_Eta[i]=eff; 00032 } 00033 int iStart=nEtaBins; 00034 for (int i=iStart; i<iStart+nPhiBins; i++) { 00035 listfile >> eff; 00036 Effic_Phi_Barrel[i-iStart]=eff; 00037 } 00038 iStart += nPhiBins; 00039 for (int i=iStart; i<iStart+nPhiBins; i++) { 00040 listfile >> eff; 00041 Effic_Phi_Endcap[i-iStart]=eff; 00042 } 00043 iStart += nPhiBins; 00044 for (int i=iStart; i<iStart+nPhiBins; i++) { 00045 listfile >> eff; 00046 Effic_Phi_Extern[i-iStart]=eff; 00047 } 00048 00049 } 00050 00051 FML1EfficiencyHandler::~FML1EfficiencyHandler() {} 00052 00053 00054 bool FML1EfficiencyHandler::kill(const SimpleL1MuGMTCand * aMuon) { 00055 00056 double myEffEta=0. , myEffPhi=0. , myEff; 00057 double AbsEta = fabs(aMuon->getMomentum().eta()); 00058 double Phi = aMuon->getMomentum().phi(); 00059 double Pt = std::sqrt(aMuon->getMomentum().perp2()); 00060 00061 // efficiency as a function of |eta| 00062 00063 if (AbsEta < 2.40) { 00064 int iEtaBin = (int) ( (AbsEta/2.40) * nEtaBins); 00065 myEffEta = Effic_Eta[iEtaBin]; 00066 } else { myEffEta = 0.0; } 00067 00068 // efficiency as a function of phi and combined efficiency: 00069 00070 if (Phi < 0.) {Phi = 2* M_PI + Phi; } 00071 int iPhiBin = (int) ((Phi/(2*M_PI)) * nPhiBins); 00072 00073 int ieta = 0; 00074 if (AbsEta < 1.04) { 00075 myEffPhi = Effic_Phi_Barrel[iPhiBin]; 00076 myEff = myEffEta * myEffPhi * tuningfactor(0); 00077 ieta = 0; 00078 } else if (AbsEta < 2.07) { 00079 myEffPhi = Effic_Phi_Endcap[iPhiBin]; 00080 myEff = myEffEta * myEffPhi * tuningfactor(1); 00081 ieta = 1; 00082 } else if (AbsEta < 2.40) { 00083 myEffPhi = Effic_Phi_Extern[iPhiBin]; 00084 myEff = myEffEta * myEffPhi * tuningfactor(2); 00085 ieta = 2; 00086 } else { myEff = 0. ; } 00087 00088 // Drop of efficiency at the lowest Pt's: 00089 if (Pt<6) myEff *= dumpingfactor(ieta,Pt); 00090 00091 double prob = random->flatShoot(); 00092 00093 return (myEff > prob); 00094 }