CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MultipleScatteringX0Data.cc
Go to the documentation of this file.
4 
5 #include "TH2.h"
6 #include "TFile.h"
7 #include "TKey.h"
8 
9 #include <iostream>
10 #include <string>
11 #include <math.h>
12 
13 using namespace std;
14 
15 
17  : theFile(0), theData(0)
18 {
19  string filename = fileName();
20  theFile = new TFile(filename.c_str(),"READ");
21  if (theFile) {
22  theData = dynamic_cast<TH2F*> (theFile->GetKey("h100")->ReadObj());
23  }
24  if (!theData) {
25  throw cms::Exception("Data not found")
26  << " ** MultipleScatteringX0Data ** file: "
27  << filename
28  <<" <-- no data found!!!";
29  }
30 }
31 
33 {
34  if(theFile) {
35  theFile->Close();
36  delete theFile;
37  }
38 }
39 
41 {
42  string defName="RecoTracker/TkMSParametrization/data/MultipleScatteringX0Data.root";
43  edm::FileInPath f(defName);
44  return f.fullPath();
45 }
46 
48 {
49  if (theData) return theData->GetNbinsX();
50  else return 0;
51 }
52 
54 {
55  if (theData) return theData->GetXaxis()->GetXmin();
56  else return 0;
57 }
58 
60 {
61  if (theData) return theData->GetXaxis()->GetXmax();
62  else return 0;
63 }
64 
65 float MultipleScatteringX0Data::sumX0atEta(float eta, float r) const
66 {
67  if(!theData) return 0.;
68  eta = fabs(eta);
69 
70  int ieta = theData->GetXaxis()->FindBin(eta);
71  int irad = theData->GetYaxis()->FindBin(r);
72 
73  if (irad < theData->GetNbinsY()) {
74  return theData->GetBinContent(ieta,irad);
75  }
76  else {
77  float sumX0 = 0;
78  for(int ir = theData->GetNbinsY(); ir > 0; ir--) {
79  float val = theData->GetBinContent(ieta, ir);
80  if (val > sumX0) sumX0 = val;
81  }
82  return sumX0;
83  }
84 }
T eta() const
double f[11][100]
tuple filename
Definition: lut2db_cfg.py:20
virtual float sumX0atEta(float eta, float r) const
std::string fullPath() const
Definition: FileInPath.cc:171