Crombie Tools
TwoScaleFactorCorrector.cc
Go to the documentation of this file.
1 /**
2  @file TwoScaleFactorCorrector.cc
3  Describes the TwoScaleFactorCorrector class.
4  @author Daniel Abercrombie <dabercro@mit.edu>
5 */
6 
8 
10 
11 //--------------------------------------------------------------------
13  Corrector* Leg1Loose, Corrector* Leg1Tight,
14  Corrector* Leg2Loose, Corrector* Leg2Tight)
15 : Corrector(name),
16  fCorrectors {Leg1Loose, Leg1Tight, Leg2Loose, Leg2Tight}
17 {}
18 
19 //--------------------------------------------------------------------
21 {
22  for (auto iCorr : fCorrectors)
23  delete iCorr;
24 }
25 
26 //--------------------------------------------------------------------
28 {
30  for (auto iCorr : fCorrectors)
31  iCorr->SetInTree(tree);
32 }
33 
34 //--------------------------------------------------------------------
35 
36 /**
37  @returns value of correction histogram using the expressions added
38  through AddInExpression(), unless the event does not pass the cut
39  set by SetInCut(). In that case, a default value is returned (1.0).
40 */
41 
43 {
44  // Evaluate each tight inner corrector.
45  auto leg1_tight = fCorrectors[1]->EvaluateWithFlag();
46  auto leg2_tight = fCorrectors[3]->EvaluateWithFlag();
47 
48  auto leg1_loose = fCorrectors[0]->Evaluate();
49  auto leg2_loose = fCorrectors[2]->Evaluate();
50 
51  // If only one is tight, use the other's loose, and multiply
52  if ((bool) leg1_tight.first != (bool) leg2_tight.first) {
53  if (leg1_tight.first)
54  return leg1_tight.second * leg2_loose;
55 
56  return leg2_tight.second * leg1_loose;
57  }
58 
59  // If both tight are non-unity, then do the combination equation
60  if (leg1_tight.first)
61  return (leg1_tight.second * leg1_tight.second * leg1_loose + leg2_tight.second * leg2_tight.second * leg2_loose) /
62  (leg1_tight.second + leg2_tight.second);
63 
64  return leg1_loose * leg2_loose;
65 }
66 
67 //--------------------------------------------------------------------
69 {
71  *newTwoScaleFactorCorrector = *this;
72  newTwoScaleFactorCorrector->fIsCopy = true;
73  for (int iCorr = 0; iCorr < TSFCORRECTOR_NCORRECTORS; iCorr++)
74  newTwoScaleFactorCorrector->fCorrectors[iCorr] = fCorrectors[iCorr]->Copy();
75 
77 }
78 
79 std::vector<TString> TwoScaleFactorCorrector::GetFormulas() {
80  std::vector<TString> all_formulas;
81  for (auto i_corr : fCorrectors) {
82  auto formulas = i_corr->GetFormulas();
83  all_formulas.insert(all_formulas.end(), formulas.begin(), formulas.end());
84  }
85  return all_formulas;
86 }