1 //____________________________________________________________________
3 // Script to draw a X-section, LOSS, or range made with MakeXsection
6 DrawXsection(Bool_t scale=kFALSE,
7 const char* filename="xsec.root",
8 const char* var="LOSS",
9 const char* medName="FMD_Si$",
11 const char* pdgName="pi+")
13 TFile* file = TFile::Open(filename, "READ");
14 TTree* tree = static_cast<TTree*>(file->Get(Form("%s_%s",medName,
16 TLeaf* tb = tree->GetLeaf("T");
17 TLeaf* vb = tree->GetLeaf(var);
19 std::cerr << "Leaf " << var << " not found" << std::endl;
23 tb->SetAddress(&tkine);
24 vb->SetAddress(&value);
25 Int_t n = tree->GetEntries();
30 TDatabasePDG* pdgDb = TDatabasePDG::Instance();
31 TParticlePDG* pdgP = pdgDb->GetParticle(pdgName);
33 std::cerr << "Couldn't find particle " << pdgName << std::endl;
36 Double_t m = pdgP->Mass();
37 Double_t q = pdgP->Charge() / 3;
38 if (m == 0 || q == 0) {
39 std::cerr << "Mass is 0" << std::endl;
46 TGraphErrors* graph = new TGraphErrors(n);
47 for (Int_t i = 0; i < n; i++) {
49 Double_t x = tkine*xscale;
50 Double_t y = value*yscale;
51 graph->SetPoint(i, x, y);
53 graph->SetPointError(i, 0, 5 * .1 * y);
55 graph->SetLineWidth(2);
56 graph->SetFillStyle(3001);
57 graph->SetFillColor(6);
58 graph->Draw("L3 same");
61 //____________________________________________________________________