CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #include <fstream>
00002 
00003 #include "FastSimulation/ParamL3MuonProducer/interface/FMGLfromL3EfficiencyHandler.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 FMGLfromL3EfficiencyHandler::FMGLfromL3EfficiencyHandler(const RandomEngine * engine)
00012   : random(engine) {
00013 
00014   std::string fname = "FastSimulation/ParamL3MuonProducer/data/efficiencyGL_L3.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 FMGLfromL3EfficiencyHandler.");
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 -> FMGLfromL3EfficiencyHandler : 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 FMGLfromL3EfficiencyHandler::~FMGLfromL3EfficiencyHandler(){
00042   delete Effic_Eta;
00043 }
00044 
00045 bool FMGLfromL3EfficiencyHandler::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. ,  myEff;
00057   // double myCorrection=1.;
00058 
00059   // Eta dependence : 
00060   double eta = fabs(aTrack.momentum().eta());
00061   if (eta < 2.40) {
00062     int iEtaBin = (int) ( (eta/2.40) * nEtaBins);
00063     myEffEta = Effic_Eta[iEtaBin];
00064   } else return false;
00065 
00066   /*
00067   double pt = aTrack.momentum().pt();
00068   if (eta<1.04) {
00069     if (pt>40.) myEffPt = 0.9583 - pt*5.82726e-05;
00070     else if (pt>4.10) myEffPt = 0.952*(1.-exp(-(pt-4.072)));
00071     myCorrection = 1.115;
00072   }
00073   else if (eta<2.07) {
00074     if (pt>173.) myEffPt = 0.991 - pt*3.46562e-05;
00075     else if (pt>3.10) myEffPt = 0.985*(1.-exp(-(pt-3.061)));
00076     myCorrection = 1.034;
00077   }
00078   else if (eta<2.40) {
00079     if (pt>26.) myEffPt = 0.9221 - pt*7.75139e-05;
00080     else if (pt>3.00) myEffPt = 0.927*(1.-exp(-sqrt(pt-1.617)));
00081     myCorrection = 1.157;
00082   }
00083   else return false;
00084   */
00085 
00086   //  myEff = myEffEta*myEffPt*myCorrection;
00087   myEff = myEffEta;
00088   double prob = random->flatShoot();
00089   return (myEff > prob) ;
00090 
00091 }