15 const char* filename=
"xsec.root",
16 const char* var=
"LOSS",
17 const char* medName=
"FMD_Si$",
19 const char* pdgName=
"pi+")
22 TTree*
tree =
static_cast<TTree*
>(file->Get(Form(
"%s_%s",medName,
24 TLeaf* tb = tree->GetLeaf(
"T");
25 TLeaf* vb = tree->GetLeaf(var);
27 std::cerr <<
"Leaf " << var <<
" not found" << std::endl;
31 tb->SetAddress(&tkine);
32 vb->SetAddress(&value);
33 Int_t n = tree->GetEntries();
38 TDatabasePDG* pdgDb = TDatabasePDG::Instance();
39 TParticlePDG* pdgP = pdgDb->GetParticle(pdgName);
41 std::cerr <<
"Couldn't find particle " << pdgName << std::endl;
44 Double_t m = pdgP->Mass();
45 Double_t q = pdgP->Charge() / 3;
46 if (m == 0 || q == 0) {
47 std::cerr <<
"Mass is 0" << std::endl;
54 TGraphErrors* graph =
new TGraphErrors(n);
55 for (Int_t i = 0; i < n; i++) {
57 Double_t x = tkine*xscale;
58 Double_t y = value*yscale;
59 graph->SetPoint(i, x, y);
61 graph->SetPointError(i, 0, 5 * .1 * y);
63 TCanvas* c =
new TCanvas(
"c",
"c");
66 graph->SetLineWidth(2);
67 graph->SetFillStyle(3001);
68 graph->SetFillColor(6);
70 graph->DrawClone(
"AL3");
TFile * Open(const char *filename, Long64_t &nevents)
void DrawXsection(Bool_t scale=kFALSE, const char *filename="xsec.root", const char *var="LOSS", const char *medName="FMD_Si$", Double_t thick=.03, const char *pdgName="pi+")