CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/FastSimulation/ParamL3MuonProducer/src/FML3EfficiencyHandler.cc

Go to the documentation of this file.
00001 #include <fstream>
00002 
00003 #include "FastSimulation/ParamL3MuonProducer/interface/FML3EfficiencyHandler.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 FML3EfficiencyHandler::FML3EfficiencyHandler(const RandomEngine * engine)
00012   : random(engine) {
00013 
00014    std::string fname = "FastSimulation/ParamL3MuonProducer/data/efficiencyL3.data";
00015    std::string path(getenv("CMSSW_SEARCH_PATH"));
00016    FileInPath f1(path,fname);
00017    if ( f1() == 0) {
00018      std::cout << "File " << fname << " not found in " << path << std::endl;
00019      throw Genexception(" efficiency list not found for FML3EfficiencyHandler.");
00020    } else {
00021      std::cout << "Reading " << f1.name() << std::endl;
00022    }
00023    std::ifstream & listfile = *f1();
00024  
00025    double eff=0.;
00026    int nent;
00027    listfile >> nent;
00028    if (nent != nEtaBins) { 
00029      std::cout << " *** ERROR -> FML3EfficiencyHandler : nEta bins " 
00030           << 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    int iStart=nEtaBins;
00037    listfile >> nent;
00038    if (nent != nPhiBins) { 
00039      std::cout << " *** ERROR -> FML3EfficiencyHandler : nPhi bins "
00040                << nent << " instead of " << nPhiBins << std::endl;
00041    }
00042    for (int i=iStart; i<iStart+nPhiBins; i++) {
00043      listfile >> eff;
00044      Effic_Phi_Barrel[i-iStart]=eff;
00045    }
00046    iStart += nPhiBins;
00047    listfile >> nent;
00048    if (nent != nPhiBins) { 
00049      std::cout << " *** ERROR -> FML3EfficiencyHandler : nPhi bins "
00050                << nent << " instead of " << nPhiBins << std::endl;
00051    }
00052    for (int i=iStart; i<iStart+nPhiBins; i++) {
00053      listfile >> eff;
00054      Effic_Phi_Endcap[i-iStart]=eff;
00055    }
00056    iStart += nPhiBins;
00057    listfile >> nent;
00058    if (nent != nPhiBins) { 
00059      std::cout << " *** ERROR -> FML3EfficiencyHandler : nPhi bins "
00060           << nent << " instead of " << nPhiBins << std::endl;
00061    }
00062    for (int i=iStart; i<iStart+nPhiBins; i++) {
00063      listfile >> eff;
00064      Effic_Phi_Extern[i-iStart]=eff;
00065    }
00066 
00067 }
00068 
00069 FML3EfficiencyHandler::~FML3EfficiencyHandler(){
00070   delete Effic_Eta;
00071   delete Effic_Phi_Barrel;
00072   delete Effic_Phi_Endcap;
00073   delete Effic_Phi_Extern;
00074 }
00075 
00076 bool FML3EfficiencyHandler::kill(const SimTrack & aTrack) {
00077 
00078   
00079   // At least eight hit in the tracker : To be tuned !!!
00080   //  if ( aTrack.recHits().size() < 8 ) return false;
00081 
00082   // At least zero reconstructed  Pixel hits : To be tuned !!!
00083   //  int seed = 0;
00084   //  for ( unsigned i=1; i<6; ++i ) 
00085   //    if ( aTrack.isARecHit(i) ) ++seed;
00086   //  if ( seed < 0 ) return false;
00087 
00088   double myEffEta=0. , myEffPhi=0. , myEffPt=0. , myCorrection=1. , myEff;
00089 
00090   // Eta dependence :
00091   double eta = fabs(aTrack.momentum().eta());
00092   if (eta < 2.40) {
00093     int iEtaBin = (int) ( (eta/2.40) * nEtaBins);
00094     myEffEta = Effic_Eta[iEtaBin];
00095   } else return false;
00096 
00097   // Phi and Pt dependence:
00098   double pt = std::sqrt(aTrack.momentum().perp2());
00099   double phi = aTrack.momentum().phi();
00100   if (phi < 0.) {phi = 2* M_PI + phi; }
00101   int iPhiBin = (int) ((phi/(2*M_PI)) * nPhiBins);
00102   if (eta<1.04) {
00103     myEffPhi = Effic_Phi_Barrel[iPhiBin];
00104     if (pt>40.) myEffPt = 0.9583 - pt*5.82726e-05;
00105     //    else if (pt>4.10) myEffPt = 0.952*(1.-exp(-(pt-4.072)));
00106     else if (pt>4.0) myEffPt = 0.952*(1.-sqrt(exp(-(pt-3.3))));
00107     myCorrection = 1.124;
00108   }
00109   else if (eta<2.07) {
00110     myEffPhi = 1.;  // no visible residual phi structure in the endcaps
00111     if (pt>173.) myEffPt = 0.991 - pt*3.46562e-05;
00112     //    else if (pt>3.10) myEffPt = 0.985*(1.-exp(-(pt-3.061)));
00113     else if (pt>3.0) myEffPt = 0.985*(1.-sqrt(exp(-(pt-2.4))));
00114     myCorrection = 1.028;
00115   }
00116   else if (eta<2.40) {
00117     myEffPhi = 1.; // no visible residual phi structure in the endcaps
00118     if (pt>26.) myEffPt = 0.9221 - pt*7.75139e-05;
00119     else if (pt>3.00) myEffPt = 0.927*(1.-exp(-sqrt(pt-1.617)));
00120     myCorrection = 1.133;
00121   }
00122   else return false;
00123 
00124   /*
00125   // Special high Pt muons treatment :
00126   if (pt>400.) {
00127     double myEffHighPt=1.;
00128     double pttev = pt/1000.;
00129     if (eta < 0.3) {
00130       //      myEffHighPt = 0.952 - 0.033*pttev;
00131       myEffHighPt = 0.945 - 0.028*pttev;  // fit up to 3.0 TeV
00132     } else if ( eta < 0.6) {
00133       //      myEffHighPt = 0.973 - 0.033*pttev;
00134       myEffHighPt = 0.974 - 0.033*pttev;  // fit up to 3.0 TeV
00135     } else if ( eta < 0.9) {
00136       //      myEffHighPt = 0.969 - 0.045*pttev;  
00137       myEffHighPt = 0.966 - 0.041*pttev;  // fit up to 2.7 TeV
00138     } else if ( eta < 1.2) {
00139       //      myEffHighPt = 0.968 - 0.058*pttev;
00140       myEffHighPt = 0.957 - 0.044*pttev;  // fit up to 2.7 TeV
00141     } else if ( eta < 1.5) {
00142       //      myEffHighPt = 0.966 - 0.074*pttev;
00143       myEffHighPt = 0.944 - 0.045*pttev;  // fit up to 2.4 TeV
00144     } else if ( eta < 1.8) {
00145       //      myEffHighPt = 0.955 - 0.11*pttev;
00146       myEffHighPt = 0.939 - 0.086*pttev;  // fit up to 1.8 TeV
00147     } else if ( eta < 2.1) {
00148       //      myEffHighPt = 0.982 - 0.11*pttev;
00149       myEffHighPt = 0.989 - 0.122*pttev;  // fit up to 1.5 TeV
00150     } else {
00151       //     myEffHighPt = 0.958 - 0.14*pttev;
00152       myEffHighPt = 0.934 - 0.088*pttev;  // fit up to 1.2 TeV
00153     }
00154     myEffPt = (myEffPt>myEffHighPt? myEffHighPt : myEffPt);
00155   }
00156   */
00157 
00158   myEff = myEffEta*myEffPhi*myEffPt*myCorrection;
00159   double prob = random->flatShoot();
00160   return (myEff > prob) ;
00161 
00162 }
00163