CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FML1EfficiencyHandler.cc
Go to the documentation of this file.
1 #include <fstream>
2 
5 
8 
10 
11 using namespace std;
12 
14  : random(engine){
15 
16  string fname = "FastSimulation/Muons/data/efficiencyL1.data";
17  // std::string path(std::getenv("CMSSW_SEARCH__PATH"));
18  std::string path(getenv("CMSSW_SEARCH_PATH"));
19  FileInPath f1(path,fname);
20  if ( f1() == 0) {
21  std::cout << "File " << fname << " not found in " << path << std::endl;
22  throw Genexception(" efficiency list not found for FML1EfficiencyHandler.");
23  } else {
24  // The following should be on LogDebug
25  //std::cout << "Reading " << f1.name() << std::endl;
26  }
27  std::ifstream & listfile = *f1();
28 
29  double eff=0.;
30  for (int i=0; i<nEtaBins; i++) {
31  listfile >> eff;
32  Effic_Eta[i]=eff;
33  }
34  int iStart=nEtaBins;
35  for (int i=iStart; i<iStart+nPhiBins; i++) {
36  listfile >> eff;
37  Effic_Phi_Barrel[i-iStart]=eff;
38  }
39  iStart += nPhiBins;
40  for (int i=iStart; i<iStart+nPhiBins; i++) {
41  listfile >> eff;
42  Effic_Phi_Endcap[i-iStart]=eff;
43  }
44  iStart += nPhiBins;
45  for (int i=iStart; i<iStart+nPhiBins; i++) {
46  listfile >> eff;
47  Effic_Phi_Extern[i-iStart]=eff;
48  }
49 
50 }
51 
53 
54 
56 
57  double myEffEta=0. , myEffPhi=0. , myEff;
58  double AbsEta = fabs(aMuon->getMomentum().eta());
59  double Phi = aMuon->getMomentum().phi();
60  double Pt = std::sqrt(aMuon->getMomentum().perp2());
61 
62 // efficiency as a function of |eta|
63 
64  if (AbsEta < 2.40) {
65  int iEtaBin = (int) ( (AbsEta/2.40) * nEtaBins);
66  myEffEta = Effic_Eta[iEtaBin];
67  } else { myEffEta = 0.0; }
68 
69 // efficiency as a function of phi and combined efficiency:
70 
71  if (Phi < 0.) {Phi = 2* M_PI + Phi; }
72  int iPhiBin = (int) ((Phi/(2*M_PI)) * nPhiBins);
73 
74  int ieta = 0;
75  if (AbsEta < 1.04) {
76  myEffPhi = Effic_Phi_Barrel[iPhiBin];
77  myEff = myEffEta * myEffPhi * tuningfactor(0);
78  ieta = 0;
79  } else if (AbsEta < 2.07) {
80  myEffPhi = Effic_Phi_Endcap[iPhiBin];
81  myEff = myEffEta * myEffPhi * tuningfactor(1);
82  ieta = 1;
83  } else if (AbsEta < 2.40) {
84  myEffPhi = Effic_Phi_Extern[iPhiBin];
85  myEff = myEffEta * myEffPhi * tuningfactor(2);
86  ieta = 2;
87  } else { myEff = 0. ; }
88 
89 // Drop of efficiency at the lowest Pt's:
90  if (Pt<6) myEff *= dumpingfactor(ieta,Pt);
91 
92  double prob = random->flatShoot();
93 
94  return (myEff > prob);
95 }
double Effic_Phi_Extern[nPhiBins]
int i
Definition: DBlmapReader.cc:9
double Effic_Phi_Barrel[nPhiBins]
~FML1EfficiencyHandler()
Destructor.
TRandom random
Definition: MVATrainer.cc:138
double tuningfactor(int ieta)
int path() const
Definition: HLTadd.h:3
bool kill(const SimpleL1MuGMTCand *)
reject tracks according to parametrized algorithmic efficiency
T sqrt(T t)
Definition: SSEVec.h:28
FML1EfficiencyHandler(const RandomEngine *engine)
Constructor (read in the parametrizations from a data file)
double Effic_Phi_Endcap[nPhiBins]
#define M_PI
Definition: BFit3D.cc:3
const RandomEngine * random
const LorentzVector getMomentum() const
double flatShoot(double xmin=0.0, double xmax=1.0) const
Definition: RandomEngine.h:30
string fname
main script
tuple cout
Definition: gather_cfg.py:41
double dumpingfactor(int ieta, float pt)