testSystematics.C
Go to the documentation of this file.
1 #include "../dataProducts/Constants.h"
2 #include "../dataProducts/StaticFuncs.h"
3 
5 
6  // only interested in MC. Set the selection and interaction channel here
7  std::string det = "Far";
8  std::string per = "1";
9  std::string bType = "FHC";
10  std::string sType = "NuMuSelQ1";
11  std::string iType = "NuMuCC";
12 
13  std::string treeName = "list/full/MC"+det+"Period"+per+bType+"Beam"+sType+iType;
14 
15  std::cout << "Looking at systematics for " << treeName << std::endl;
16 
17  TTree* t = (TTree*)_file0->Get(treeName.c_str());
18 
19  std::vector<int>* systVarKeys = nullptr;
20  std::vector<float>* systVarMinus2Wgts = nullptr;
21  std::vector<float>* systVarMinus1Wgts = nullptr;
22  std::vector<float>* systVarPlus1Wgts = nullptr;
23  std::vector<float>* systVarPlus2Wgts = nullptr;
24 
25  t->SetBranchAddress("systVarKeys" , &systVarKeys );
26  t->SetBranchAddress("systVarMinus2Wgts", &systVarMinus2Wgts );
27  t->SetBranchAddress("systVarMinus1Wgts", &systVarMinus1Wgts );
28  t->SetBranchAddress("systVarPlus1Wgts" , &systVarPlus1Wgts );
29  t->SetBranchAddress("systVarPlus2Wgts" , &systVarPlus2Wgts );
30 
31  t->GetEntry(0);
32 
33  // setup histograms
34  std::vector<TH1D*> hists;
35  for (int i = 0; i < systVarKeys->size(); ++i){
36  std::string systName = cmf::KeyToVarName(systVarKeys->at(i));
37  hists.push_back(new TH1D(systName.c_str(),
38  std::string(systName+";weight;").c_str(),
39  100, 0.8, 1.2));
40  }
41 
42  for (int i = 0; i < t->GetEntries(); ++i){
43  t->GetEntry(i);
44  for (int is = 0; is < systVarKeys->size(); ++is){
45  if (systVarPlus1Wgts->at(is) != 1)
46  hists.at(is)->Fill(systVarPlus1Wgts->at(is));
47  }
48  }
49 
50 
51  TCanvas *c1 = new TCanvas("c1", "c1", 500, 500);
52  for (int ih = 0; ih < hists.size(); ++ih){
53  hists.at(ih)->Draw("hist");
54  c1->SaveAs((std::string(hists.at(ih)->GetName())+".png").c_str());
55  }
56 }
void testSystematics()
TString hists[nhists]
Definition: bdt_com.C:3
OStream cout
Definition: OStream.cxx:6
c1
Definition: demo5.py:24
static std::string KeyToVarName(uint8_t const &key)
Definition: StaticFuncs.h:654
enum BeamMode string