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(), f, geometryDiff::file, dqmdumpme::first, dqmdumpme::last, writedatasetfile::run, and runs.

25  assert(first < last);
26 
27  assert(fs::exists(file));
28 
29  ifstream f(file);
30  int run;
31  while (f >> run >> runs[run])
32  ;
33  f.close();
34 }
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 36 of file Trend.cc.

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

38 {
39  float sum = 0.;
40  for (auto& run : runs) {
41  if (run.first < run1)
42  continue;
43  if (run.first >= run2)
44  break;
45  sum += run.second;
46  }
47  return sum / convertUnit; // conversion from e.g. /pb to /fb
48 }
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 50 of file Trend.cc.

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

Referenced by operator()().

50 { return operator()(firstRun, run); }
float operator()() const
Sums luminosity for [firstRun, lastRun[.
Definition: Trend.cc:52
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 52 of file Trend.cc.

References firstRun, and lastRun.

Referenced by operator()().

52 { 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:52
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 68 of file Trend.cc.

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

68  {
69  assert(gIn != nullptr);
70 
71  vector<float> x, y, ex, ey;
72  int n = gIn->GetN();
73  for (int i = 0; i < n - 1; ++i) {
74  int currentRun = gIn->GetPointX(i);
75  if (currentRun < firstRun)
76  continue;
77  if (currentRun >= lastRun)
78  break;
79 
80  int nextRun = gIn->GetPointX(i + 1);
81 
82  auto lumi_edge = operator()(firstRun, currentRun), lumi_width = operator()(currentRun, nextRun);
83  x.push_back(lumi_edge + lumi_width / 2);
84  ex.push_back(lumi_width / 2);
85 
86  auto point = gIn->GetPointY(i), error = gIn->GetErrorY(i);
87  y.push_back(point);
88  ey.push_back(error);
89  }
90 
91  auto N = x.size();
92  assert(N == y.size() && N == ex.size() && N == ey.size());
93  TGraph* gOut = new TGraphErrors(N, x.data(), y.data(), ex.data(), ey.data());
94  gOut->SetTitle(gIn->GetTitle());
95  CopyStyle(gIn, gOut);
96  return gOut;
97 }
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:52
#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:55
*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 99 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.

99  {
100  vector<float> edges, contents, errors;
101  edges.push_back(0);
102  int N = hIn->GetNbinsX();
103  for (int i = 1; i <= N; ++i) {
104  auto nextRun = hIn->GetBinLowEdge(i + 1);
105  if (nextRun < firstRun)
106  continue;
107  if (nextRun >= lastRun)
108  break;
109 
110  edges.push_back(operator()(nextRun));
111 
112  auto content = hIn->GetBinContent(i), error = hIn->GetBinError(i);
113  contents.push_back(content);
114  errors.push_back(error);
115  }
116 
117  N = edges.size() - 1;
118  TString name = hIn->GetName();
119  name += "_byLumi";
120  TH1* hOut = new TH1F(name, hIn->GetTitle(), N, edges.data());
121  for (int i = 1; i <= N; ++i) {
122  hOut->SetBinContent(i, contents[i - 1]);
123  hOut->SetBinError(i, errors[i - 1]);
124  }
125  CopyStyle(hIn, hOut);
126  return hOut;
127 }
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:55

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().