18 m_mass[0] = Widget::mpion;
19 m_mass[1] = Widget::mkaon;
20 m_mass[2] = Widget::mproton;
21 m_mass[3] = Widget::mmuon;
22 m_mass[4] = Widget::melectron;
23 for(
int i = 0; i < 5; ++i ){
24 m_upperp[i] = bgmax[i]*m_mass[i];
25 m_lowerp[i] = bgmin[i]*m_mass[i];
32 std::cout <<
"Making histograms..." << std::endl;
35 std::string overwrite;
37 if( stat (outfilename.Data(), &buffer) == 0 ){
38 TFile* testfile =
new TFile(outfilename);
39 if( testfile && testfile->GetListOfKeys()->IsEmpty() ==
false ){
40 std::cout << outfilename <<
" exists. Are you sure you want to overwrite it (y/n)? ";
41 std::cin >> overwrite;
42 if( overwrite ==
"n" )
return;
48 TFile* outfile =
new TFile(outfilename,
"RECREATE");
50 std::cout <<
"Making histograms..." << std::endl;
53 for(
int i = 0; i < filenames.size(); ++i ){
54 TFile* infile =
new TFile(filenames[i]);
55 TTree* intree = (TTree*)infile->Get(
"track");
58 TString cuts = TString::Format(
"dedxsat>0&&costh==costh");
61 cuts += TString::Format(
"&&numGoodHits>=0&&numGoodHits<=100");
63 cuts += TString::Format(
"&&lNHitsUsed>=0&&lNHitsUsed<=100");
69 cuts +=
"&&eopst<0.75";
73 cuts +=
"&&dedx>=0.4/TMath::Abs(pF)";
77 cuts +=
"&&dedx>0&&dedx<100&&dedx>0.85/TMath::Abs(pF)";
79 else if( i == 3 ) name =
"muon";
80 else if( i == 4 ) name =
"electron";
83 intree->Project(TString::Format(
"hp(100,0,%f)",m_upperp[i]),
"abs(pF)",cuts);
84 TH1F* hp = (TH1F*)infile->Get(
"hp");
85 hp->SetName(name+
"_hp");
86 hp->SetTitle(
""); hp->SetStats(0);
87 hp->SetXTitle(
"p [GeV/c]"); hp->SetYTitle(
"Events");
90 intree->Project(
"hcosth(100,-1,1)",
"costh",cuts);
91 TH1F* hcosth = (TH1F*)infile->Get(
"hcosth");
92 hcosth->SetName(name+
"_hcosth");
93 hcosth->SetTitle(
""); hcosth->SetStats(0);
94 hcosth->SetXTitle(
"cos(#theta)"); hcosth->SetYTitle(
"Events");
97 if( i == 1 || i == 2 ) intree->Project(TString::Format(
"dedx_p(100,0,%f,100,0,10)",m_upperp[i]+(m_upperp[i]-m_lowerp[i])*0.1),
"dedx:abs(pF)",cuts);
98 else intree->Project(TString::Format(
"dedx_p(100,0,%f,100,0,3)",m_upperp[i]+(m_upperp[i]-m_lowerp[i])*0.1),
"dedx:abs(pF)",cuts);
99 TH2F* dedx_p = (TH2F*)infile->Get(
"dedx_p");
100 dedx_p->SetName(name+
"_dedx_p");
101 dedx_p->SetTitle(
""); dedx_p->SetStats(0);
102 dedx_p->SetXTitle(
"p [GeV/c]"); dedx_p->SetYTitle(
"dE/dx");
105 intree->Project(TString::Format(
"p_costh(100,-1,1,100,0,%f)",m_upperp[i]+(m_upperp[i]-m_lowerp[i])*0.1),
"abs(pF):costh",cuts);
106 TH2F* p_costh = (TH2F*)infile->Get(
"p_costh");
107 p_costh->SetName(name+
"_p_costh");
108 p_costh->SetTitle(
""); p_costh->SetStats(0);
109 p_costh->SetYTitle(
"p [GeV/c]"); p_costh->SetXTitle(
"cos(#theta)");
113 intree->Project(
"nhit_pt(100,0,2.0,60,0,60)",
"lNHitsUsed:abs(pF)*sqrt(1-costh*costh)",cuts);
116 intree->Project(
"nhit_pt(100,0,2.0,60,0,60)",
"numGoodHits:abs(pF)*sqrt(1-costh*costh)",cuts);
118 TH2F* nhit_pt = (TH2F*)infile->Get(
"nhit_pt");
119 nhit_pt->SetName(name+
"_nhit_pt");
120 nhit_pt->SetTitle(
""); nhit_pt->SetStats(0);
121 nhit_pt->SetXTitle(
"p_t [GeV/c]"); nhit_pt->SetYTitle(
"Number of Hits");
140 std::cout <<
"Plotting histograms..." << std::endl;
142 TFile*
f =
new TFile(filename);
147 varname[1] =
"_hcosth";
148 varname[2] =
"_dedx_p";
149 varname[3] =
"_p_costh";
150 varname[4] =
"_nhit_pt";
152 TCanvas* can =
new TCanvas(
"can",
"Quality plots",800,800);
153 for(
int i = 0; i < 5; ++i ){
156 if( i == 0 ) name =
"pion";
157 else if( i == 1 ) name =
"kaon";
158 else if( i == 2 ) name =
"proton";
159 else if( i == 3 ) name =
"muon";
160 else if( i == 4 ) name =
"electron";
163 for(
int j = 0; j < 5; ++j ){
164 TString histname = name+varname[j];
165 TH1F* h1 = (TH1F*)
f->Get(histname);
166 if(j<2) h1->DrawCopy(
"e");
167 else h1->DrawCopy(
"colz");
170 double max = 3.0;
if( i == 1 || i == 2 )
max = 10.0;
171 TLine* upper =
new TLine(m_upperp[i],0,m_upperp[i],
max);
172 TLine* lower =
new TLine(m_lowerp[i],0,m_lowerp[i],
max);
173 upper->SetLineColor(kRed); upper->SetLineStyle(kDashed);
174 lower->SetLineColor(kRed); lower->SetLineStyle(kDashed);
175 upper->DrawClone(
"same");
176 lower->DrawClone(
"same");
180 can->SaveAs(
"plots/"+histname+
".eps");