7 TH1F* hPullMomentum =
new TH1F(
"hPullMomentum",
"hPullMomentum", 300, -1, 1);
8 hPullMomentum->SetLineWidth(2);
9 hPullMomentum->SetLineColor(kBlack);
11 TH2F* hMomemtumTruevsReco =
new TH2F(
"hMomemtumTruevsReco",
"hMomemtumTruevsReco", 100, 0, 5, 100, 0, 5);
13 TH1F* hPullAngle =
new TH1F(
"hPullAngle",
"hPullAngle", 100, -1, 1);
14 hPullAngle->SetLineWidth(2);
15 hPullAngle->SetLineColor(kBlack);
17 TH2F* hAngleTruevsReco =
new TH2F(
"hAngleTruevsReco",
"hAngleTruevsReco", 100, -1, 1, 100, -1, 1);
19 TH1F* hPullNeutrons =
new TH1F(
"hPullNeutrons",
"hPullNeutrons", 100, -1, 1);
20 hPullNeutrons->SetLineWidth(2);
21 hPullNeutrons->SetLineColor(kBlack);
25 const char *dirname=
"/pnfs/dune/persistent/users/ND_GAr/2020_06_21/neutrino/";
27 const char *ext=
".root";
28 std::vector<const char*> lista;
31 TChain *chain =
new TChain(
"caf");
33 TSystemDirectory
dir(dirname, dirname);
34 TList *
files = dir.GetListOfFiles();
40 while ((file = (TSystemFile*)next())) {
41 fname = file->GetName();
42 if (file->IsDirectory() && fname.EndsWith(ext))
continue;
45 strcpy(result,dirname);
46 strcat(result,fname.Data());
48 lista.push_back(result);
57 TFile *
tf =
new TFile ( Form(
"%s",a.c_str() ) );
58 chain->Add( Form(
"%s/caf", a.c_str()) );
63 std::vector<float> *truep = 0;
64 std::vector<float> *preco = 0;
65 std::vector<int> *truepdg = 0;
66 std::vector<int> *recopid = 0;
67 std::vector<float> *angle = 0;
68 std::vector<float> *anglereco = 0;
69 std::vector<float> *erecon = 0;
71 chain->SetBranchAddress(
"truep", &truep);
72 chain->SetBranchAddress(
"preco", &preco);
73 chain->SetBranchAddress(
"truepdg", &truepdg);
74 chain->SetBranchAddress(
"recopid", &recopid);
75 chain->SetBranchAddress(
"angle", &angle);
76 chain->SetBranchAddress(
"anglereco", &anglereco);
77 chain->SetBranchAddress(
"erecon", &erecon);
80 for(
int itree = 0; itree < chain->GetEntries(); itree++)
82 chain->GetEntry(itree);
84 for(
int i = 0; i < truep->size(); i++)
88 hPullMomentum->Fill( (truep->at(i) - preco->at(i)) / truep->at(i) );
89 hMomemtumTruevsReco->Fill(truep->at(i), preco->at(i));
90 hPullAngle->Fill( (angle->at(i) - anglereco->at(i)) / angle->at(i) );
91 hAngleTruevsReco->Fill(angle->at(i), anglereco->at(i));
97 gStyle->SetOptStat(1110);
99 hPullMomentum->Scale(1./hPullMomentum->Integral());
101 hPullMomentum->SetStats(kTRUE);
102 hPullMomentum->Fit(
"gaus",
"EMR+",
"", -0.8, 0.8);
103 TCanvas *
c1 =
new TCanvas(
"c1",
"Pull p", 800, 600);
104 hPullMomentum->GetXaxis()->SetTitle(
"(p_{true} - p_{reco}) / p_{true}" );
105 hPullMomentum->GetYaxis()->SetTitle(
"Normalized Events" );
106 hPullMomentum->Draw(
"hist");
107 hPullMomentum->GetFunction(
"gaus")->SetLineColor(kRed);
108 hPullMomentum->GetFunction(
"gaus")->SetLineStyle(2);
109 hPullMomentum->GetFunction(
"gaus")->Draw(
"same");
110 c1->SaveAs(
"PullMomentumMuons.pdf");
112 TCanvas *c2 =
new TCanvas(
"c2",
"Mom truth vs reco", 800, 600);
113 gPad->SetRightMargin(0.12);
114 hMomemtumTruevsReco->GetXaxis()->SetTitle(
"p_{true} [GeV]" );
115 hMomemtumTruevsReco->GetYaxis()->SetTitle(
"p_{reco} [GeV]" );
116 hMomemtumTruevsReco->Draw(
"COLZ");
117 c2->SaveAs(
"MomentumMuons_TruevsReco.pdf");
119 hPullAngle->Scale(1./hPullAngle->Integral());
120 hPullAngle->SetStats(kTRUE);
122 TCanvas *c3 =
new TCanvas(
"c3",
"Pull angle", 800, 600);
123 hPullAngle->GetXaxis()->SetTitle(
"(angle_{true} - angle_{reco}) / angle_{true}" );
124 hPullAngle->GetYaxis()->SetTitle(
"Normalized Events" );
125 hPullAngle->Draw(
"hist");
126 c3->SaveAs(
"PullAngleMuons.pdf");
128 TCanvas *c4 =
new TCanvas(
"c4",
"Angle truth vs reco", 800, 600);
129 gPad->SetRightMargin(0.12);
130 hAngleTruevsReco->GetXaxis()->SetTitle(
"angle_{true} [GeV]" );
131 hAngleTruevsReco->GetYaxis()->SetTitle(
"angle_{reco} [GeV]" );
132 hAngleTruevsReco->Draw(
"COLZ");
133 c4->SaveAs(
"AngleMuons_TruevsReco.pdf");
QTextStream & endl(QTextStream &s)