]>
Commit | Line | Data |
---|---|---|
59e49925 | 1 | Char_t *partname[3] = {"pion", "kaon", "proton"}; |
2 | Char_t *chargename[2] = {"positive", "negative"}; | |
3 | Char_t *chargename2[2] = {"plus", "minus"}; | |
4 | ||
5 | mcSpectra(Char_t *filename) | |
6 | { | |
7 | ||
8 | TFile *fin = TFile::Open(filename); | |
9 | TH1D *hspectrumMB[3][2]; | |
10 | TH1D *hspectrumCent[3][2][6]; | |
11 | TH1 *h; | |
12 | THnSparseF *hsparse; | |
13 | TFile *fout = TFile::Open("mcSpectra.root", "RECREATE"); | |
14 | ||
15 | for (Int_t ipart = 0; ipart < 3; ipart++) | |
16 | for (Int_t icharge = 0; icharge < 2; icharge++) { | |
17 | hsparse = (THnSparseF *)fin->Get(Form("hHisto_hPrimaryTracks_%s_%s", partname[ipart], chargename[icharge])); | |
18 | h = hsparse->Projection(1); | |
19 | h->SetName(Form("mb_%s_%s", partname[ipart], chargename2[icharge])); | |
20 | h->Sumw2(); | |
21 | for (Int_t ipt = 0; ipt < h->GetNbinsX(); ipt++) { | |
22 | h->SetBinContent(ipt + 1, h->GetBinContent(ipt + 1) / h->GetBinWidth(ipt + 1)); | |
23 | h->SetBinError(ipt + 1, h->GetBinError(ipt + 1) / h->GetBinWidth(ipt + 1)); | |
24 | } | |
25 | fout->cd(); | |
26 | h->Write(); | |
27 | for (Int_t icent = 0; icent < 6; icent++) { | |
28 | hsparse->GetAxis(0)->SetRange(icent + 1, icent + 1); | |
29 | h = hsparse->Projection(1); | |
30 | h->SetName(Form("cent%d_%s_%s", icent, partname[ipart], chargename2[icharge])); | |
31 | h->Sumw2(); | |
32 | for (Int_t ipt = 0; ipt < h->GetNbinsX(); ipt++) { | |
33 | h->SetBinContent(ipt + 1, h->GetBinContent(ipt + 1) / h->GetBinWidth(ipt + 1)); | |
34 | h->SetBinError(ipt + 1, h->GetBinError(ipt + 1) / h->GetBinWidth(ipt + 1)); | |
35 | } | |
36 | fout->cd(); | |
37 | h->Write(); | |
38 | } | |
39 | } | |
40 | ||
41 | } |