14 <input>../GenericB_GENSIMRECtoDST.dst.root</input>
15 <output>Pi0_Validation.root</output>
16 <contact>Mario Merola (mario.merola@na.infn.it), Andrea Selce (selce@infn.it)</contact>
18 Check the calibration of the ECL in the MC by determining the measured pi0 invariant mass.
25 from modularAnalysis
import cutAndCopyList, inputMdst, matchMCTruth
26 from stdPi0s
import stdPi0s
27 from validation_tools.metadata
import create_validation_histograms
28 from validation_tools.metadata
import validation_metadata_update
29 from variables
import variables
as vm
31 INPUT_FILENAME =
"../GenericB_GENSIMRECtoDST.dst.root"
32 OUTPUT_FILENAME =
"Pi0_Validation.root"
35 inputMdst(INPUT_FILENAME, path=main)
38 matchMCTruth(
'pi0:all', path=main)
40 cutAndCopyList(
'pi0:rec',
'pi0:all',
'daughter(0, E)>0.05 and daughter(1, E)>0.05', path=main)
41 cutAndCopyList(
'pi0:mc',
'pi0:all',
'mcErrors<1', path=main)
43 vm.addAlias(
'Mreco',
'M')
46 create_validation_histograms(
47 main, OUTPUT_FILENAME,
"pi0:rec",
50 "Mreco", 40, 0.08, 0.18,
51 "#pi^{0} reconstructed candidates, invariant mass",
52 "Andrea Selce <selce@infn.it>",
53 r"The $\pi^{0}$ invariant mass distribution with $E_{\gamma}>0.05\, \text{GeV}$",
54 r"Distribution should be peaking at the nominal $\pi^{0}$ mass.",
55 "M(#pi^{0}) [GeV/c^{2}]",
"Candidates",
"shifter"
58 description=
r"$\pi^0$ reconstructed mass distribution",
62 vm.addAlias(
'Mmc',
'M')
64 create_validation_histograms(
65 main, OUTPUT_FILENAME,
"pi0:mc",
68 "Mmc", 40, 0.08, 0.18,
69 "#pi^{0} MC candidates, invariant mass",
70 "Andrea Selce <selce@infn.it>",
71 r"The $\pi^{0}$ invariant mass distribution for truth matched candidates",
72 r"Distribution should be peaking at the nominal $\pi^{0}$ mass.",
73 "M(#pi^{0}) [GeV/c^{2}]",
"Candidates",
"shifter"
76 description=
r"$\pi^0$ MC mass distribution",
79 main.add_module(
'Progress')
81 print(basf2.statistics)
84 f = ROOT.TFile(OUTPUT_FILENAME)
85 Mrecohist = f.Get(
'Mreco')
86 Mmchist = f.Get(
'Mmc')
89 mass = ROOT.RooRealVar(
"recomass",
"m_{#gamma#gamma} [GeV/c^{2}]", 0.11, 0.15)
91 h_pi0_reco = ROOT.RooDataHist(
"h_pi0_reco",
"h_pi0_reco", ROOT.RooArgList(mass), Mrecohist)
92 h_pi0_mc = ROOT.RooDataHist(
"h_pi0_mc",
"h_pi0_mc", ROOT.RooArgList(mass), Mmchist)
96 mean = ROOT.RooRealVar(
"mean",
"mean", 0.14, 0.11, 0.15)
97 sig1 = ROOT.RooRealVar(
"#sigma",
"sig", 0.05, 0.002, 0.1)
98 gau1 = ROOT.RooGaussian(
"gau1",
"gau1", mass, mean, sig1)
100 alphacb = ROOT.RooRealVar(
"alphacb",
"alpha", 1.5, 0.1, 1.9)
101 ncb = ROOT.RooRealVar(
"ncb",
"n", 8)
102 sigcb = ROOT.RooCBShape(
"sigcb",
"sigcb", mass, mean, sig1, alphacb, ncb)
105 b1 = ROOT.RooRealVar(
"b1",
"b1", -3.0021e-01, -0.8, 0.8)
106 a1 = ROOT.RooRealVar(
"a1",
"a1", -3.0021e-01, -0.8, 0.8)
107 bList = ROOT.RooArgList(a1, b1)
108 bkg = ROOT.RooChebychev(
"bkg",
"bkg", mass, bList)
111 nsig = ROOT.RooRealVar(
"nsig",
"nsig", 1000, 0, 1000000)
112 nbkg = ROOT.RooRealVar(
"nbkg",
"nbkg", 1000, 0, 1000000)
115 totalPdf = ROOT.RooAddPdf(
"totalpdf",
"", ROOT.RooArgList(sigcb, bkg), ROOT.RooArgList(nsig, nbkg))
118 output = ROOT.TFile(
"Pi0_Validation_ntuple.root",
"recreate")
121 outputNtuple = ROOT.TNtuple(
123 "Pi0 mass fit results",
124 "mean:meanerror:width:widtherror")
127 ROOT.gROOT.SetBatch(
True)
128 canvas = ROOT.TCanvas(
"canvas",
"pi0 mass fit", 1000, 600)
133 totalPdf.fitTo(h_pi0_reco, ROOT.RooFit.Extended(
True), ROOT.RooFit.Minos(1), ROOT.RooFit.Range(0.11, 0.15))
134 frame1 = ROOT.RooPlot
135 frame1 = mass.frame()
136 h_pi0_reco.plotOn(frame1, ROOT.RooFit.Name(
"Hist"))
137 frame1.SetMaximum(frame1.GetMaximum())
138 totalPdf.plotOn(frame1, ROOT.RooFit.Name(
"curve"))
139 totalPdf.plotOn(frame1, ROOT.RooFit.Components(
"sigcb"), ROOT.RooFit.LineStyle(ROOT.kDashed), ROOT.RooFit.LineColor(ROOT.kRed))
140 totalPdf.plotOn(frame1, ROOT.RooFit.Components(
"bkg"), ROOT.RooFit.LineStyle(3), ROOT.RooFit.LineColor(ROOT.kBlue))
143 frame1.SetMaximum(Mrecohist.GetMaximum() * 1.5)
144 frame1.GetXaxis().SetTitleOffset(1.4)
145 frame1.GetYaxis().SetTitleOffset(1.5)
146 meanval = mean.getVal()
147 meanerror = mean.getError()
148 width = sig1.getVal()
149 widtherror = sig1.getError()
152 outputNtuple.Fill(meanval, meanerror, width, widtherror)
166 b1.setRange(-0.5, 0.5)
167 a1.setRange(-0.5, 0.5)
168 b1.setVal(-3.0021e-01)
169 a1.setVal(-3.0021e-01)
173 totalPdf.fitTo(h_pi0_mc, ROOT.RooFit.Extended(
True), ROOT.RooFit.Minos(1), ROOT.RooFit.Range(0.11, 0.15))
174 frame2 = ROOT.RooPlot
175 frame2 = mass.frame()
176 h_pi0_mc.plotOn(frame2, ROOT.RooFit.Name(
"Hist"))
177 frame2.SetMaximum(frame2.GetMaximum())
178 totalPdf.plotOn(frame2, ROOT.RooFit.Name(
"curve"))
179 totalPdf.plotOn(frame2, ROOT.RooFit.Components(
"sigcb"), ROOT.RooFit.LineStyle(ROOT.kDashed), ROOT.RooFit.LineColor(ROOT.kRed))
180 totalPdf.plotOn(frame2, ROOT.RooFit.Components(
"bkg"), ROOT.RooFit.LineStyle(3), ROOT.RooFit.LineColor(ROOT.kBlue))
183 frame2.SetMaximum(Mmchist.GetMaximum() * 1.5)
184 frame2.GetXaxis().SetTitleOffset(1.4)
185 frame2.GetYaxis().SetTitleOffset(1.5)
186 meanval_mc = mean.getVal()
187 meanerror_mc = mean.getError()
188 width_mc = sig1.getVal()
189 widtherror_mc = sig1.getError()
194 outputNtuple.Fill(meanval_mc, meanerror_mc, width_mc, widtherror_mc)
198 validation_metadata_update(
201 title=
"Pi0 mass fit results",
202 contact=
"selce@infn.it",
203 description=
"Fit to the invariant mass of the reconstructed and truth matched pi0s",
204 check=
"Consistent numerical fit results. Stable mean and width.",
205 metaoptions=
"shifter")