CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AcceptanceTableHelper.cc
Go to the documentation of this file.
1 /****************************************************************************
2  * File AcceptanceTableHelper.cc
3  *
4  * Access to acceptance tables stored in root histograms
5  *
6  * Author: Dmitry Zaborov
7  *
8  * Version: $Id: AcceptanceTableHelper.cc,v 1.3 2007/12/31 10:02:46 elmer Exp $
9  ***************************************************************************/
10 
12 
13 #include <iostream>
14 #include <math.h>
15 
18 void AcceptanceTableHelper::Init(TFile& f, const std::string basename)
19 {
20  // ... read table for low t
21  TH3F *h = (TH3F*)f.Get(basename.c_str());
22 
23  if (h != NULL)
24  {
25  h_log10t_log10Xi_Phi = (TH3F*)h->Clone();
26  std::cout << "Read ";
27  h_log10t_log10Xi_Phi->SetDirectory(0); // secure it from deleting if the file is eventually closed
28  h_log10t_log10Xi_Phi->Print();
29  } else {
30  std::cout << "Warning: could not get acceptance table " << basename << std::endl;
31  }
32 
33  // ... read table for high t
34  std::string name2 = basename+"_hight";
35  h = (TH3F*)f.Get(name2.c_str());
36 
37  if (h != NULL)
38  {
39  h_t_log10Xi_Phi = (TH3F*)h->Clone();
40  h_t_log10Xi_Phi->SetDirectory(0); // secure it from deleting if the file is eventually closed
41  std::cout << "Read ";
42  h_t_log10Xi_Phi->Print();
43  } else {
44  std::cout << "Warning: could not get acceptance table " << name2 << std::endl;
45  }
46 }
47 
50 float AcceptanceTableHelper::GetAcceptance(float t, float xi, float phi) {
51 
52  float log10t = log10(-t);
53  float log10Xi = log10(xi);
54 
55  float acc = 0;
56 
57  if ((h_log10t_log10Xi_Phi != NULL) // if table exists
58  && (log10t < h_log10t_log10Xi_Phi->GetXaxis()->GetXmax())) // and t within table range
59  {
60 
61  float log10tMin = h_log10t_log10Xi_Phi->GetXaxis()->GetXmin();
62  if (log10t < log10tMin) log10t = log10tMin; // very small t should go to the lowest t bin
63 
64  acc = h_log10t_log10Xi_Phi->GetBinContent(h_log10t_log10Xi_Phi->FindBin(log10t, log10Xi, phi));
65 
66  } else if (h_t_log10Xi_Phi != NULL) { // if table exists for high t
67 
68  acc = h_t_log10Xi_Phi->GetBinContent(h_t_log10Xi_Phi->FindBin(-t, log10Xi, phi));
69  }
70 
71  return acc;
72 }
void Init(TFile &, const std::string)
Get acceptance tables from root file.
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
#define NULL
Definition: scimark2.h:8
TH3F * h_log10t_log10Xi_Phi
Table for low t: acceptance as a function of log10(t), log10(Xi) and Phi.
double f[11][100]
TH3F * h_t_log10Xi_Phi
Table for high t: acceptance as a function of -t, log10(Xi) and Phi.
Geom::Phi< T > phi() const
tuple cout
Definition: gather_cfg.py:145
float GetAcceptance(float, float, float)
Acceptance as a function of t, xi and phi.