5 #include "TTreeFormula.h" 19 TTree *inTree = fDefaultTree;
21 if (fInTrees.size() != 0)
22 inTree = fInTrees[index];
24 if (fYields.size() == 0) {
26 std::vector<TTreeFormula*> formulae;
27 TTreeFormula *tempFormula;
28 std::set<TString> needed;
30 for (
auto& cut : fCuts) {
34 inTree->SetBranchStatus(
"*", 0);
35 for (
auto need : needed) {
36 Message(eDebug,
"Enabling %s", need.Data());
37 inTree->SetBranchStatus(need, 1);
40 for (UInt_t iCut = 0; iCut != fCuts.size(); ++iCut) {
41 tempFormula =
new TTreeFormula(fCutNames[iCut], fCuts[iCut], inTree);
42 tempFormula->SetQuickLoad(
true);
43 formulae.push_back(tempFormula);
47 Int_t numEntries = inTree->GetEntriesFast();
49 for (Int_t iEntry = 0; iEntry != numEntries; ++iEntry) {
51 inTree->GetEntry(iEntry);
53 for (UInt_t iCut = 0; iCut != formulae.size(); ++iCut) {
56 formulae[iCut]->GetNdata();
58 if (formulae[iCut]->EvalInstance() == 0)
66 for (UInt_t iFormula = 0; iFormula != formulae.size(); ++iFormula)
67 delete formulae[iFormula];
76 std::cout << std::endl;
78 auto max_length = std::max_element(
fCuts.begin(),
fCuts.end(),
79 [] (
const TString& str1,
const TString& str2)
80 {
return str1.Length() < str2.Length();})->Length();
82 for (UInt_t iCut = 0; iCut !=
fCuts.size(); ++iCut) {
86 std::cout << std::setw(max_length + 2);
96 std::cout << std::setw(15);
101 std::cout << std::endl;
104 std::cout << std::endl;
112 std::vector<TH1D*> theHists;
114 for (UInt_t iTree = 0; iTree !=
fInTrees.size(); ++iTree) {
118 TH1D* theHist =
new TH1D(TString::Format(
"cutflow_%d", iTree),
";;Number of Events",
121 for (UInt_t iCut = 0; iCut !=
fCuts.size(); ++iCut) {
123 theHist->GetXaxis()->SetBinLabel(iCut+1,
fCutNames[iCut]);
126 theHist->SetBinContent(iCut+1,
fYields[iCut]);
131 theHist->SetBinContent(iCut+1,
float(
fYields[iCut])/
fInTrees[iTree]->GetEntriesFast());
133 theHist->SetBinContent(iCut+1,
float(
fYields[iCut])/
fYields[iCut - 1]);
138 theHists.push_back(theHist);
145 for (UInt_t iHist = 0; iHist != theHists.size(); ++iHist)
146 delete theHists[iHist];