CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Attributes
Run2Lumi Struct Reference

#include <Trend.h>

Public Member Functions

float operator() (int run1, int run2) const
 Sums luminosity for [run1, run2[ and returns it in /fb. More...
 
float operator() (int run) const
 Sums luminosity for [firstRun, run[. More...
 
float operator() () const
 Sums luminosity for [firstRun, lastRun[. More...
 
TGraph * operator() (TGraph *gIn) const
 
TH1 * operator() (TH1 *hIn) const
 
 Run2Lumi (boost::filesystem::path file, int first, int last, float convertUnit)
 

Public Attributes

const float convertUnit
 
const int firstRun
 first run, starting at lumi = 0 on the x-axis of the trend More...
 
const int lastRun
 last run (excluded!), starting at the max lumi on the x-axis of the trend More...
 

Private Attributes

std::map< int, float > runs
 couples of run and corresponding luminosity More...
 

Detailed Description

Functor to obtain delivered luminosity corresponding to a given range.

The constructor extracts the luminosity from an 2-column file (see constructor), and the operator() returns the accumulated luminosity for any subrange.

Another overload of the operator() allows the conversion of a TGraphErrors as a function of the run number to another TGraphErrors as a function of the luminosity.

Definition at line 22 of file Trend.h.

Constructor & Destructor Documentation

◆ Run2Lumi()

Run2Lumi::Run2Lumi ( boost::filesystem::path  file,
int  first,
int  last,
float  convertUnit 
)

Constructor, takes as input a 2-column file that will populate the map runs as well as the global range.

(Note: in principle, the global range could be extracted from the 2-column file, but the choice here is to have one standard lumi file, leaving as only freedom to the user the possibility to change the global range depending on the analysis.)

Parameters
filepath to a 2-column file with 6-digit run number and lumi in /pb
first6-digit run number (included)
last6-digit run number (excluded)
convertUnitdefault is from pb to fb

Definition at line 23 of file Trend.cc.

References cms::cuda::assert(), gather_cfg::cout, f, geometryDiff::file, first, dqmdumpme::last, writedatasetfile::run, and runs.

25  cout << __func__ << endl;
26  assert(first < last);
27 
28  cout << file << endl;
29  assert(fs::exists(file));
30 
31  ifstream f(file);
32  int run;
33  while (f >> run >> runs[run])
34  ;
35  f.close();
36 }
assert(be >=bs)
const int lastRun
last run (excluded!), starting at the max lumi on the x-axis of the trend
Definition: Trend.h:23
std::map< int, float > runs
couples of run and corresponding luminosity
Definition: Trend.h:28
double f[11][100]
const int firstRun
first run, starting at lumi = 0 on the x-axis of the trend
Definition: Trend.h:23
const float convertUnit
Definition: Trend.h:25

Member Function Documentation

◆ operator()() [1/5]

float Run2Lumi::operator() ( int  run1,
int  run2 
) const

Sums luminosity for [run1, run2[ and returns it in /fb.

Definition at line 38 of file Trend.cc.

References convertUnit, writedatasetfile::run, ntuplemaker::run1, compare_using_db::run2, and runs.

40 {
41  float sum = 0.;
42  for (auto& run : runs) {
43  if (run.first < run1)
44  continue;
45  if (run.first >= run2)
46  break;
47  sum += run.second;
48  }
49  return sum / convertUnit; // conversion from e.g. /pb to /fb
50 }
std::map< int, float > runs
couples of run and corresponding luminosity
Definition: Trend.h:28
const float convertUnit
Definition: Trend.h:25

◆ operator()() [2/5]

float Run2Lumi::operator() ( int  run) const

Sums luminosity for [firstRun, run[.

Definition at line 52 of file Trend.cc.

References firstRun, operator()(), and writedatasetfile::run.

52 { return operator()(firstRun, run); }
float operator()() const
Sums luminosity for [firstRun, lastRun[.
Definition: Trend.cc:54
const int firstRun
first run, starting at lumi = 0 on the x-axis of the trend
Definition: Trend.h:23

◆ operator()() [3/5]

float Run2Lumi::operator() ( ) const

Sums luminosity for [firstRun, lastRun[.

Definition at line 54 of file Trend.cc.

References firstRun, lastRun, and operator()().

Referenced by operator()().

54 { return operator()(firstRun, lastRun); }
const int lastRun
last run (excluded!), starting at the max lumi on the x-axis of the trend
Definition: Trend.h:23
float operator()() const
Sums luminosity for [firstRun, lastRun[.
Definition: Trend.cc:54
const int firstRun
first run, starting at lumi = 0 on the x-axis of the trend
Definition: Trend.h:23

◆ operator()() [4/5]

TGraph * Run2Lumi::operator() ( TGraph *  gIn) const

Converts a TGraph given as a function of the run number to another TGraph as a function of the luminosity in the global subrange.

Definition at line 70 of file Trend.cc.

References cms::cuda::assert(), CopyStyle(), relativeConstraints::error, firstRun, mps_fire::i, lastRun, N, dqmiodumpmetadata::n, operator()(), point, x, and y.

70  {
71  assert(gIn != nullptr);
72 
73  vector<float> x, y, ex, ey;
74  int n = gIn->GetN();
75  for (int i = 0; i < n - 1; ++i) {
76  int currentRun = gIn->GetPointX(i);
77  if (currentRun < firstRun)
78  continue;
79  if (currentRun >= lastRun)
80  break;
81 
82  int nextRun = gIn->GetPointX(i + 1);
83 
84  auto lumi_edge = operator()(firstRun, currentRun), lumi_width = operator()(currentRun, nextRun);
85  x.push_back(lumi_edge + lumi_width / 2);
86  ex.push_back(lumi_width / 2);
87 
88  auto point = gIn->GetPointY(i), error = gIn->GetErrorY(i);
89  y.push_back(point);
90  ey.push_back(error);
91  }
92 
93  auto N = x.size();
94  assert(N == y.size() && N == ex.size() && N == ey.size());
95  TGraph* gOut = new TGraphErrors(N, x.data(), y.data(), ex.data(), ey.data());
96  gOut->SetTitle(gIn->GetTitle());
97  CopyStyle(gIn, gOut);
98  return gOut;
99 }
assert(be >=bs)
const int lastRun
last run (excluded!), starting at the max lumi on the x-axis of the trend
Definition: Trend.h:23
float operator()() const
Sums luminosity for [firstRun, lastRun[.
Definition: Trend.cc:54
#define N
Definition: blowfish.cc:9
const int firstRun
first run, starting at lumi = 0 on the x-axis of the trend
Definition: Trend.h:23
void CopyStyle(T *objIn, T *objOut)
Definition: Trend.cc:57
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5

◆ operator()() [5/5]

TH1 * Run2Lumi::operator() ( TH1 *  hIn) const

Converts a TH1 given as a function of the run number to another TH1 as a function of the luminosity in the global subrange.

Note: the run is expected to be on the low edge of each bin

Definition at line 101 of file Trend.cc.

References Skims_PA_cff::content, relmon_rootfiles_spy::contents, CopyStyle(), SelectiveReadoutTask_cfi::edges, relativeConstraints::error, debug_messages_cfi::errors, firstRun, mps_fire::i, lastRun, N, and Skims_PA_cff::name.

101  {
102  vector<float> edges, contents, errors;
103  edges.push_back(0);
104  int N = hIn->GetNbinsX();
105  for (int i = 1; i <= N; ++i) {
106  auto nextRun = hIn->GetBinLowEdge(i + 1);
107  if (nextRun < firstRun)
108  continue;
109  if (nextRun >= lastRun)
110  break;
111 
112  edges.push_back(operator()(nextRun));
113 
114  auto content = hIn->GetBinContent(i), error = hIn->GetBinError(i);
115  contents.push_back(content);
116  errors.push_back(error);
117  }
118 
119  N = edges.size() - 1;
120  TString name = hIn->GetName();
121  name += "_byLumi";
122  TH1* hOut = new TH1F(name, hIn->GetTitle(), N, edges.data());
123  for (int i = 1; i <= N; ++i) {
124  hOut->SetBinContent(i, contents[i - 1]);
125  hOut->SetBinError(i, errors[i - 1]);
126  }
127  CopyStyle(hIn, hOut);
128  return hOut;
129 }
const int lastRun
last run (excluded!), starting at the max lumi on the x-axis of the trend
Definition: Trend.h:23
#define N
Definition: blowfish.cc:9
const int firstRun
first run, starting at lumi = 0 on the x-axis of the trend
Definition: Trend.h:23
Definition: errors.py:1
void CopyStyle(T *objIn, T *objOut)
Definition: Trend.cc:57

Member Data Documentation

◆ convertUnit

const float Run2Lumi::convertUnit

Definition at line 25 of file Trend.h.

Referenced by operator()().

◆ firstRun

const int Run2Lumi::firstRun

first run, starting at lumi = 0 on the x-axis of the trend

Definition at line 23 of file Trend.h.

Referenced by operator()().

◆ lastRun

const int Run2Lumi::lastRun

last run (excluded!), starting at the max lumi on the x-axis of the trend

Definition at line 23 of file Trend.h.

Referenced by operator()().

◆ runs

std::map<int, float> Run2Lumi::runs
private

couples of run and corresponding luminosity

Definition at line 28 of file Trend.h.

Referenced by operator()(), and Run2Lumi().