]>
Commit | Line | Data |
---|---|---|
22d1b439 | 1 | ////////////////////////////////////////////////////////////////////////////////////// |
2 | // CompareMagnetPolarities.C // | |
3 | // computes and draws the ratio of pions from runs with different magnet polarities // | |
4 | // written by John Groh // | |
5 | ////////////////////////////////////////////////////////////////////////////////////// | |
6 | ||
7 | const Int_t nCharge = 2; | |
8 | TString Sign[nCharge] = {"Plus","Minus"}; | |
9 | const Int_t nRuns = 2; | |
10 | const Int_t Runs[nRuns] = {138275, 139465}; | |
11 | TString Names[nCharge] = {"#pi^{+}","#pi^{-}"}; | |
12 | ||
13 | ||
14 | void CompareMagnetPolarities() | |
15 | { | |
16 | // get pion spectra histos for run 138275 | |
17 | TH1F * hSpectra138275[nCharge]; | |
18 | TFile * fin138275 = TFile::Open("results/SeeIfPionsVaryWithMagnetPolarity/Res_OutputAODSpectraTask_Data_Cent30to40_QVec0.0to100.0_Eta-0.8to0.8_3.0SigmaPID_TrBit1024_SeeIfPionsVaryWithMagnetPolarity_Run138275.root"); | |
19 | TCanvas * cSpectra138275 = (TCanvas*)fin138275->Get("cSpectra"); | |
20 | for (Int_t icharge=0; icharge<nCharge; icharge++) | |
21 | { | |
22 | hSpectra138275[icharge] = (TH1F*)cSpectra138275->FindObject(Form("Spectra_Pion%s",Sign[icharge].Data())); | |
23 | } | |
24 | fin138275->Close(); | |
25 | ||
26 | // repeat for run 139465 | |
27 | TH1F * hSpectra139465[nCharge]; | |
28 | TFile * fin139465 = TFile::Open("results/SeeIfPionsVaryWithMagnetPolarity/Res_OutputAODSpectraTask_Data_Cent30to40_QVec0.0to100.0_Eta-0.8to0.8_3.0SigmaPID_TrBit1024_SeeIfPionsVaryWithMagnetPolarity_Run139465.root"); | |
29 | TCanvas * cSpectra139465 = (TCanvas*)fin139465->Get("cSpectra"); | |
30 | for (Int_t icharge=0; icharge<nCharge; icharge++) | |
31 | { | |
32 | hSpectra139465[icharge] = (TH1F*)cSpectra139465->FindObject(Form("Spectra_Pion%s",Sign[icharge].Data())); | |
33 | } | |
34 | fin139465->Close(); | |
35 | ||
36 | // repeat for run 138364 | |
37 | TH1F * hSpectra138364[nCharge]; | |
38 | TFile * fin138364 = TFile::Open("results/SeeIfPionsVaryWithMagnetPolarity/Res_OutputAODSpectraTask_Data_Cent30to40_QVec0.0to100.0_Eta-0.8to0.8_3.0SigmaPID_TrBit1024_SeeIfPionsVaryWithMagnetPolarity_Run138364.root"); | |
39 | TCanvas * cSpectra138364 = (TCanvas*)fin138364->Get("cSpectra"); | |
40 | for (Int_t icharge=0; icharge<nCharge; icharge++) | |
41 | { | |
42 | hSpectra138364[icharge] = (TH1F*)cSpectra138364->FindObject(Form("Spectra_Pion%s",Sign[icharge].Data())); | |
43 | } | |
44 | fin138364->Close(); | |
45 | ||
46 | // ratio 1 - (late negative) / (late positive) | |
47 | TCanvas * cRatioPions_1 = new TCanvas("cRatioPions_1","cRatioPions_1"); | |
48 | TLegend * lRatioPions_1 = new TLegend(.79,.79,.99,.99); | |
49 | TH1F * hRatio[nCharge]; | |
50 | for (Int_t icharge=0; icharge<nCharge; icharge++) | |
51 | { | |
52 | hRatio[icharge] = (TH1F*)hSpectra138275[icharge]->Clone(); | |
53 | hRatio[icharge]->Divide(hSpectra139465[icharge]); | |
54 | hRatio[icharge]->SetTitle(Form("Ratio of Spectra: #frac{Run %i}{Run %i};p_{T} (GeV/c);",Runs[0],Runs[1])); | |
55 | hRatio[icharge]->SetLineStyle(icharge+1); | |
56 | hRatio[icharge]->GetYaxis()->SetRangeUser(.7,1.3); | |
57 | if (icharge == 0) hRatio[icharge]->DrawCopy("hist]["); | |
58 | else hRatio[icharge]->DrawCopy("hist][same"); | |
59 | lRatioPions_1->AddEntry(hRatio[icharge],Names[icharge].Data(),"l"); | |
60 | } | |
61 | lRatioPions_1->DrawClone(); | |
62 | ||
63 | // another ratio - (early positive) / (late positive) | |
64 | TCanvas * cRatioPions_2 = new TCanvas("cRatioPions_2","cRatioPions_2"); | |
65 | TLegend * lRatioPions_2 = new TLegend(.79,.79,.99,.99); | |
66 | TH1F * hRatio[nCharge]; | |
67 | for (Int_t icharge=0; icharge<nCharge; icharge++) | |
68 | { | |
69 | hRatio[icharge] = (TH1F*)hSpectra138364[icharge]->Clone(); | |
70 | hRatio[icharge]->Divide(hSpectra139465[icharge]); | |
71 | hRatio[icharge]->SetTitle(Form("Ratio of Spectra: #frac{Run %i}{Run %i};p_{T} (GeV/c);",Runs[0],Runs[1])); | |
72 | hRatio[icharge]->SetLineStyle(icharge+1); | |
73 | hRatio[icharge]->GetYaxis()->SetRangeUser(.7,1.3); | |
74 | if (icharge == 0) hRatio[icharge]->DrawCopy("hist]["); | |
75 | else hRatio[icharge]->DrawCopy("hist][same"); | |
76 | lRatioPions_2->AddEntry(hRatio[icharge],Names[icharge].Data(),"l"); | |
77 | } | |
78 | lRatioPions_2->DrawClone(); | |
79 | ||
80 | ||
81 | } |