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
00080
00081
00082
00083
00084
00085
00086
00087
00088 double myEffEta=0. , myEffPhi=0. , myEffPt=0. , myCorrection=1. , myEff;
00089
00090
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
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
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.;
00111 if (pt>173.) myEffPt = 0.991 - pt*3.46562e-05;
00112
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.;
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
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 myEff = myEffEta*myEffPhi*myEffPt*myCorrection;
00159 double prob = random->flatShoot();
00160 return (myEff > prob) ;
00161
00162 }
00163