7 void RunGammaFitterDemo(
const char* filelist =
"/star/u/sdhamija/StGammaMaker/StRoot/StGammaMaker/macros/photon_9_11.list")
10 gROOT->Macro(
"$STAR/StRoot/StGammaMaker/macros/loadGammaLibs.C");
13 TChain* chain =
new TChain(
"gammas");
14 ifstream in(filelist);
16 while (getline(in, line)) chain->AddFile(line.c_str());
21 chain->SetBranchAddress(
"GammaEvent", &event);
24 TH2* hResidualYield =
new TH2F(
"hResidualYield",
"#gamma events from pp#rightarrow#gamma+jet+X;Fit Residual Sum (R_{0,u}+R_{0,v}) [MeV];Fitted Peak Integral [MeV]", 40, 0, 200, 40, 0, 600);
25 TH1* hVertexZ =
new TH1F(
"hVertexZ",
";z_{vertex} [cm]", 100, -200, 200);
26 TH2* hVertexXY =
new TH2F(
"hVertexXY",
";x_{vertex} [cm];y_{vertex} [cm]", 40, -0.2, 0.2, 40, -0.45, -0.2);
27 TH1* hClusterEnergy =
new TH1F(
"hClusterEnergy",
";Cluster E [GeV]", 100, 0, 60);
28 TH1* hClusterPt =
new TH1F(
"hClusterPt",
";Cluster p_{T} [GeV]", 100, 0, 20);
29 TH2* hClusterXY =
new TH2F(
"hClusterXY",
";Cluster x [cm];Cluster y [cm]", 40, -250, 250, 40, -250, 250);
30 TH2* hClusterEtaPhi =
new TH2F(
"hClusterEtaPhi",
";Cluster #eta;Cluster #phi [radians]", 40, 1, 2, 40, -TMath::Pi(), TMath::Pi());
31 TH2* hSmdPointXY =
new TH2F(
"hSmdPointXY",
";SMD x [cm]; SMD y [cm]", 40, -250, 250, 40, -250, 250);
32 TH1* hYieldU =
new TH1F(
"hYieldU",
";Fitted Peak Integral [MeV]", 100, 0, 400);
33 TH1* hYieldV =
new TH1F(
"hYieldV",
";Fitted Peak Integral [MeV]", 100, 0, 400);
34 TH1* hResidualU =
new TH1F(
"hResidualU",
";Fit Residual [MeV]", 100, -40, 120);
35 TH1* hResidualV =
new TH1F(
"hResidualV",
";Fit Residual [MeV]", 100, -40, 120);
36 TH1* hChi2PerNdfU =
new TH1F(
"hChi2PerNdfU",
";#chi^{2}/ndf", 100, 0, 10);
37 TH1* hChi2PerNdfV =
new TH1F(
"hChi2PerNdfV",
";#chi^{2}/ndf", 100, 0, 10);
38 TH1* hMeanU =
new TH1F(
"hMeanU",
";Mean #mu", 100, 0, 288);
39 TH1* hMeanV =
new TH1F(
"hMeanV",
";Mean #mu", 100, 0, 288);
40 TH1* hSigmaU =
new TH1F(
"hSigmaU",
";RMS #sigma", 100, 0, 10);
41 TH1* hSigmaV =
new TH1F(
"hSigmaV",
";RMS #sigma", 100, 0, 10);
42 TH1* hNhitsU =
new TH1F(
"hNhitsU",
";Number of SMD hits", 50, 0, 50);
43 TH1* hNhitsV =
new TH1F(
"hNhitsV",
";Number of SMD hits", 50, 0, 50);
46 TF1* fResidualCut =
new TF1(
"fResidualCut",
"pol2", 0, 200);
47 fResidualCut->SetParameters(100, 0, 0.05);
50 int nevents = chain->GetEntries();
51 cout <<
"nevents = " << nevents << endl;
55 for (
int iEvent = 0; iEvent < nevents; ++iEvent) {
56 chain->GetEvent(iEvent);
57 if (iEvent % 1000 == 0) cout <<
"iEvent = " << iEvent << endl;
59 if (event->vertex() == TVector3(0,0,0))
continue;
61 for (
int i = 0; i <
event->numberOfCandidates(); ++i) {
65 if (candidate->detectorId() == StGammaCandidate::kEEmc) {
72 int sector, subsector, etabin;
74 TVector3& position = EEmcSmdGeom::instance()->
getIntersection(sector, u.mean, v.mean);
75 if (position.z() != -999) {
76 float residual = u.residual+v.residual;
77 float yield = u.yield+v.yield;
78 if (residual > 0 && yield > 0) {
81 hResidualYield->Fill(residual, yield);
82 hVertexZ->Fill(event->vertex().z());
83 hVertexXY->Fill(event->vertex().x(),
event->vertex().y());
84 hClusterEnergy->Fill(candidate->energy());
85 hClusterPt->Fill(candidate->momentum().Pt());
86 hClusterXY->Fill(candidate->position().x(), candidate->position().y());
87 hClusterEtaPhi->Fill(candidate->position().Eta(), candidate->position().Phi());
88 hSmdPointXY->Fill(position.x(), position.y());
89 hYieldU->Fill(u.yield);
90 hYieldV->Fill(v.yield);
91 hResidualU->Fill(u.residual);
92 hResidualV->Fill(v.residual);
93 if (u.ndf > 0) hChi2PerNdfU->Fill(u.chiSquare / u.ndf);
94 if (v.ndf > 0) hChi2PerNdfV->Fill(v.chiSquare / v.ndf);
99 hNhitsU->Fill(candidate->numberOfSmdu());
100 hNhitsV->Fill(candidate->numberOfSmdv());
107 cout <<
"ncandidates = " << ncandidates << endl;
110 TCanvas* c1 =
new TCanvas(
"c1",
"c1", 1200, 800);
112 gStyle->SetPalette(1);
113 gStyle->SetOptStat(11);
117 hResidualYield->Draw(
"colz");
118 fResidualCut->SetLineColor(kRed);
119 fResidualCut->Draw(
"same");
120 gPad->Print(
"hResidualYield.png");
124 hVertexZ->Fit(
"gaus");
125 hVertexZ->GetFunction(
"gaus")->SetLineColor(kRed);
126 gPad->Print(
"hVertexZ.png");
129 hVertexXY->Draw(
"colz");
130 gPad->Print(
"hVertexXY.png");
133 hClusterEnergy->Draw();
134 gPad->Print(
"hClusterEnergy.png");
138 gPad->Print(
"hClusterPt.png");
141 hClusterXY->Draw(
"colz");
142 gPad->Print(
"hClusterXY.png");
145 hClusterEtaPhi->Draw(
"colz");
146 gPad->Print(
"hClusterEtaPhi.png");
149 hSmdPointXY->Draw(
"colz");
150 gPad->Print(
"hSmdPointXY.png");
153 hYieldU->SetLineColor(kRed);
154 hYieldV->SetLineColor(kBlue);
155 hYieldU->SetLineWidth(2);
156 hYieldV->SetLineWidth(2);
158 hYieldV->Draw(
"same");
159 TLegend* leg1 =
new TLegend(0.60, 0.60, 0.85, 0.80);
160 leg1->AddEntry(hYieldU,
"SMD-u",
"L");
161 leg1->AddEntry(hYieldV,
"SMD-v",
"L");
163 gPad->Print(
"hYield.png");
166 hResidualU->SetLineColor(kRed);
167 hResidualV->SetLineColor(kBlue);
168 hResidualU->SetLineWidth(2);
169 hResidualV->SetLineWidth(2);
171 hResidualV->Draw(
"same");
172 TLegend* leg2 =
new TLegend(0.60, 0.60, 0.85, 0.80);
173 leg2->AddEntry(hResidualU,
"SMD-u",
"L");
174 leg2->AddEntry(hResidualV,
"SMD-v",
"L");
176 gPad->Print(
"hResidual.png");
179 hChi2PerNdfU->SetLineColor(kRed);
180 hChi2PerNdfV->SetLineColor(kBlue);
181 hChi2PerNdfU->SetLineWidth(2);
182 hChi2PerNdfV->SetLineWidth(2);
183 hChi2PerNdfU->Draw();
184 hChi2PerNdfV->Draw(
"same");
185 TLegend* leg3 =
new TLegend(0.60, 0.60, 0.85, 0.80);
186 leg3->AddEntry(hChi2PerNdfU,
"SMD-u",
"L");
187 leg3->AddEntry(hChi2PerNdfV,
"SMD-v",
"L");
189 gPad->Print(
"hChi2PerNdf.png");
192 hMeanU->SetLineColor(kRed);
193 hMeanV->SetLineColor(kBlue);
194 hMeanU->SetLineWidth(2);
195 hMeanV->SetLineWidth(2);
197 hMeanV->Draw(
"same");
198 TLegend* leg4 =
new TLegend(0.60, 0.60, 0.85, 0.80);
199 leg4->AddEntry(hMeanU,
"SMD-u",
"L");
200 leg4->AddEntry(hMeanV,
"SMD-v",
"L");
202 gPad->Print(
"hMean.png");
205 hSigmaU->SetLineColor(kRed);
206 hSigmaV->SetLineColor(kBlue);
207 hSigmaU->SetLineWidth(2);
208 hSigmaV->SetLineWidth(2);
210 hSigmaV->Draw(
"same");
211 TLegend* leg5 =
new TLegend(0.60, 0.60, 0.85, 0.80);
212 leg5->AddEntry(hSigmaU,
"SMD-u",
"L");
213 leg5->AddEntry(hSigmaV,
"SMD-v",
"L");
215 gPad->Print(
"hSigma.png");
218 hNhitsU->SetLineColor(kRed);
219 hNhitsV->SetLineColor(kBlue);
220 hNhitsU->SetLineWidth(2);
221 hNhitsV->SetLineWidth(2);
223 hNhitsV->Draw(
"same");
224 TLegend* leg6 =
new TLegend(0.60, 0.60, 0.85, 0.80);
225 leg6->AddEntry(hNhitsU,
"SMD-u",
"L");
226 leg6->AddEntry(hNhitsV,
"SMD-v",
"L");
228 gPad->Print(
"hNhits.png");
static EEmcGeomSimple & Instance()
returns a reference to a static instance of EEmcGeomSimple
static StGammaFitter * instance()
Access to single instance of this singleton class.
int fit(StGammaCandidate *candidate, StGammaFitterResult *fits, Int_t plane=0)
Fit transverse SMD profile to predetermined peak in u- and v-plane.
TVector3 getIntersection(Int_t iSec, Int_t iUStrip, Int_t iVStrip, const TVector3 &vertex) const
bool getTower(const TVector3 &r, int &sec, int &sub, int &etabin, Float_t &dphi, Float_t &deta) const
StGammaCandidate * candidate(Int_t i) const
Return ith strip.