1 Char_t *partname[3] = {"pion", "kaon", "proton"};
2 Char_t *chargename[2] = {"positive", "negative"};
3 Char_t *chargename2[2] = {"plus", "minus"};
5 mcSpectra(Char_t *filename)
8 TFile *fin = TFile::Open(filename);
9 TH1D *hspectrumMB[3][2];
10 TH1D *hspectrumCent[3][2][6];
13 TFile *fout = TFile::Open("mcSpectra.root", "RECREATE");
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]));
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));
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]));
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));