CMS 3D CMS Logo

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 <cmath>
12 
13 using namespace std;
14 
16  string filename = fileName();
17  TFile theFile(filename.c_str(), "READ");
18  if (not theFile.IsZombie()) {
19  theData.reset(dynamic_cast<TH2F*>(theFile.GetKey("h100")->ReadObj()));
20  theData->SetDirectory(nullptr);
21  }
22  if (!theData) {
23  throw cms::Exception("Data not found")
24  << " ** MultipleScatteringX0Data ** file: " << filename << " <-- no data found!!!";
25  }
26 }
27 
29 
31  string defName = "RecoTracker/TkMSParametrization/data/MultipleScatteringX0Data.root";
32  edm::FileInPath f(defName);
33  return f.fullPath();
34 }
35 
37  if (theData)
38  return theData->GetNbinsX();
39  else
40  return 0;
41 }
42 
44  if (theData)
45  return theData->GetXaxis()->GetXmin();
46  else
47  return 0;
48 }
49 
51  if (theData)
52  return theData->GetXaxis()->GetXmax();
53  else
54  return 0;
55 }
56 
57 float MultipleScatteringX0Data::sumX0atEta(float eta, float r) const {
58  if (!theData)
59  return 0.;
60  eta = fabs(eta);
61 
62  int ieta = theData->GetXaxis()->FindBin(eta);
63  int irad = theData->GetYaxis()->FindBin(r);
64 
65  if (irad < theData->GetNbinsY()) {
66  return theData->GetBinContent(ieta, irad);
67  } else {
68  float sumX0 = 0;
69  for (int ir = theData->GetNbinsY(); ir > 0; ir--) {
70  float val = theData->GetBinContent(ieta, ir);
71  if (val > sumX0)
72  sumX0 = val;
73  }
74  return sumX0;
75  }
76 }
float sumX0atEta(float eta, float r) const override
double f[11][100]
std::unique_ptr< TH2F > theData