DAS  3.0
Das Analysis System
Correction

Description

Functor to apply the PU profile correction.

#include <PUcorrection.h>

Public Member Functions

 Correction (TFile *fMC, TFile *fData, std::function< const char *(const char *, bool)> hname, float maxWeight=std::numeric_limits< float >::max())
 
float operator() (float pu, char v='0') const
 
void Write (TDirectory *d, bool reset)
 

Public Attributes

TH1 * nominal
 
TH1 * upper
 
TH1 * lower
 

Constructor & Destructor Documentation

◆ Correction()

Correction ( TFile *  fMC,
TFile *  fData,
std::function< const char *(const char *, bool)>  hname,
float  maxWeight = std::numeric_limits<float>::max() 
)
inline

Constructor.

26  :
27  nominal(fData->Get<TH1>(hname("nominal", false))),
28  upper (fData->Get<TH1>(hname(("PU" + SysUp).c_str(), false))),
29  lower (fData->Get<TH1>(hname(("PU" + SysDown).c_str(), false)))
30  {
31  namespace DE = Darwin::Exceptions;
32  for (TH1 * h: {nominal, upper, lower}) {
33  if (h == nullptr)
34  BOOST_THROW_EXCEPTION( DE::BadInput("No profile found in input", *fData) );
35  h->SetDirectory(0);
36  auto integral = h->Integral();
37  if (integral == 0)
38  BOOST_THROW_EXCEPTION( DE::BadInput("Empty profile", *h) );
39  h->Scale(1./integral);
40  }
41 
42  auto n = hname("nominal", true);
43  std::cout << "Fetching " << n << std::endl;
44  auto sim = dynamic_cast<TH1*>(fMC->Get(n));
45  if (sim == nullptr)
46  BOOST_THROW_EXCEPTION( DE::BadInput("No profile found in input", *fMC) );
47  auto integral = sim->Integral();
48  if (integral == 0)
49  BOOST_THROW_EXCEPTION( DE::BadInput("Empty profile", *sim) );
50  sim->Scale(1./integral);
51  for (TH1 * h: {nominal, upper, lower})
52  h->Divide(sim);
53 
54  for (TH1 *h: {nominal, upper, lower}) {
55  for (int i = 0; i <= h->GetNbinsX()+1; ++i) {
56  if (h->GetBinContent(i) < maxWeight) continue;
57  h->SetBinContent(i, maxWeight);
58  }
59  }
60  }

Member Function Documentation

◆ operator()()

float operator() ( float  pu,
char  v = '0' 
) const
inline

Overloading of operator()

Returns the weight as a function of the value of the in-time pileup, for a given variation (of the MB cross section).

68  {
69  namespace DE = Darwin::Exceptions;
70  TH1 * h = nullptr;
71  switch (v) {
72  case '0': h = nominal; break;
73  case '+': h = upper ; break;
74  case '-': h = lower ; break;
75  default:
76  BOOST_THROW_EXCEPTION( std::runtime_error("Unknown variation") );
77  }
78  if (h == nullptr)
79  BOOST_THROW_EXCEPTION( DE::BadInput("No correction found for this variation input", *h) );
80  int ibin = h->FindBin(pu);
81  return h->GetBinContent(ibin);
82  }

◆ Write()

void Write ( TDirectory *  d,
bool  reset 
)
inline

Write output to given directory.

87  {
88  d->cd();
89  for (TH1 * h: {nominal, upper, lower}) {
90  h->SetDirectory(d);
91  if (reset) h->Reset();
92  }
93  nominal->Write("nominal");
94  upper->Write("upper");
95  lower->Write("lower");
96  }

Member Data Documentation

◆ lower

TH1 * lower

◆ nominal

TH1* nominal

◆ upper

TH1 * upper

The documentation for this struct was generated from the following file:
DAS::PUprofile::Correction::lower
TH1 * lower
Definition: PUcorrection.h:19
DAS::PUprofile::Correction::upper
TH1 * upper
Definition: PUcorrection.h:19
DAS::SysUp
const std::string SysUp
Suffix used for "up" uncertainties. Follows the Combine convention.
Definition: Format.h:8
DAS::Normalisation::reset
void reset(Weights &wgts, const double v=0)
Definition: applyDataNormalisation.h:28
Darwin::Exceptions
Handling of exceptions.
Definition: darwin.h:35
DAS::PUprofile::Correction::nominal
TH1 * nominal
Definition: PUcorrection.h:19
DAS::SysDown
const std::string SysDown
Suffix used for "down" uncertainties. Follows the Combine convention.
Definition: Format.h:10
Darwin::Exceptions::BadInput
Generic exception for ill-defined input (before the event loop).
Definition: exceptions.h:68