CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/FastSimulation/ParamL3MuonProducer/src/FMGLfromL3TKEfficiencyHandler.cc

Go to the documentation of this file.
00001 #include <fstream>
00002 
00003 #include "FastSimulation/ParamL3MuonProducer/interface/FMGLfromL3TKEfficiencyHandler.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 FMGLfromL3TKEfficiencyHandler::FMGLfromL3TKEfficiencyHandler(const RandomEngine * engine)
00012   : random(engine) {
00013 
00014   std::string fname = "FastSimulation/ParamL3MuonProducer/data/efficiencyGL_L3TK.data";
00015   std::string path(getenv("CMSSW_SEARCH_PATH"));
00016   FileInPath f1(path,fname);
00017   
00018   if ( f1() == 0) {
00019     std::cout << "File " << fname << " not found in " << path << std::endl;
00020     throw Genexception(" efficiency list not found for FMGLfromL3TKEfficiencyHandler.");
00021   } else {
00022     // The following should be on LogInfo
00023     //std::cout << "Reading " << f1.name() << std::endl;
00024   }
00025   std::ifstream & listfile = *f1();
00026   
00027   double eff=0.;
00028   int nent;
00029   listfile >> nent;
00030   if (nent != nEtaBins) { 
00031     std::cout << " *** ERROR -> FMGLfromL3TKEfficiencyHandler : nEta bins " 
00032               << nent << " instead of " << nEtaBins << std::endl;
00033   }
00034   for (int i=0; i<nEtaBins; i++) {
00035     listfile >> eff;
00036     Effic_Eta[i]=eff;
00037   }
00038 
00039 }
00040 
00041 FMGLfromL3TKEfficiencyHandler::~FMGLfromL3TKEfficiencyHandler(){
00042   delete Effic_Eta;
00043 }
00044 
00045 bool FMGLfromL3TKEfficiencyHandler::kill(const SimTrack & aTrack) {
00046 
00047   // At least eight hit in the tracker : To be tuned !!!
00048   //if ( aTrack.recHits().size() < 8 ) return false;
00049 
00050   // At least zero reconstructed  Pixel hits : To be tuned !!!
00051   //int seed = 0;
00052   //for ( unsigned i=1; i<6; ++i ) 
00053   //  if ( aTrack.isARecHit(i) ) ++seed;
00054   //if ( seed < 0 ) return false;
00055 
00056   double myEffEta=0. , myCorrection=1. , myEff;
00057 
00058   // Eta dependence : 
00059   double eta = fabs(aTrack.momentum().eta());
00060   if (eta < 2.40) {
00061     int iEtaBin = (int) ( (eta/2.40) * nEtaBins);
00062     myEffEta = Effic_Eta[iEtaBin];
00063   } else return false;
00064 
00065   if (eta<1.04) myCorrection = 1.0296;
00066 
00067   /*
00068   double pt = std::sqrt(aTrack.momentum().perp2());
00069   if (eta<1.04) {
00070     if (pt>40.) myEffPt = 0.9583 - pt*5.82726e-05;
00071     else if (pt>4.10) myEffPt = 0.952*(1.-exp(-(pt-4.072)));
00072     myCorrection = 1.115;
00073   }
00074   else if (eta<2.07) {
00075     if (pt>173.) myEffPt = 0.991 - pt*3.46562e-05;
00076     else if (pt>3.10) myEffPt = 0.985*(1.-exp(-(pt-3.061)));
00077     myCorrection = 1.034;
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.157;
00083   }
00084   else return false;
00085   */
00086 
00087   //  myEff = myEffEta*myEffPt*myCorrection;
00088   myEff = myEffEta * myCorrection;
00089   double prob = random->flatShoot();
00090   return (myEff > prob) ;
00091 
00092 }
00093 
00094 
00095