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 69 of file Trend.cc.

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

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

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

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