scripts/DrawXsection.C

Go to the documentation of this file.
00001 //____________________________________________________________________
00002 //
00003 // Script to draw a X-section, LOSS, or range made with MakeXsection
00004 //
00013 void
00014 DrawXsection(Bool_t scale=kFALSE, 
00015              const char* filename="xsec.root", 
00016              const char* var="LOSS", 
00017              const char* medName="FMD_Si$", 
00018              Double_t thick=.03,
00019              const char* pdgName="pi+")
00020 {
00021   TFile*   file = TFile::Open(filename, "READ");
00022   TTree*   tree = static_cast<TTree*>(file->Get(Form("%s_%s",medName,
00023                                                      pdgName)));
00024   TLeaf* tb   = tree->GetLeaf("T");
00025   TLeaf* vb   = tree->GetLeaf(var);
00026   if (!vb) {
00027     std::cerr << "Leaf " << var << " not found" << std::endl;
00028     return;
00029   }
00030   Float_t tkine, value;
00031   tb->SetAddress(&tkine);
00032   vb->SetAddress(&value);
00033   Int_t n = tree->GetEntries();
00034 
00035   Float_t xscale = 1;
00036   Float_t yscale = 1;
00037   if (scale) {
00038     TDatabasePDG* pdgDb = TDatabasePDG::Instance();
00039     TParticlePDG* pdgP  = pdgDb->GetParticle(pdgName);
00040     if (!pdgP) {
00041       std::cerr << "Couldn't find particle " << pdgName << std::endl;
00042       return;
00043     }
00044     Double_t m = pdgP->Mass();
00045     Double_t q = pdgP->Charge() / 3;
00046     if (m == 0 || q == 0) {
00047       std::cerr  << "Mass is 0" << std::endl;
00048       return;
00049     }
00050     xscale = 1 / m;
00051     yscale = 1 / (q * q);
00052   }
00053   
00054   TGraphErrors* graph = new TGraphErrors(n);
00055   for (Int_t i = 0; i < n; i++) {
00056     tree->GetEntry(i);
00057     Double_t x = tkine*xscale;
00058     Double_t y = value*yscale;
00059     graph->SetPoint(i, x, y); 
00060     // 5 sigma
00061     graph->SetPointError(i, 0, 5 * .1 * y);
00062   }
00063   graph->SetLineWidth(2);
00064   graph->SetFillStyle(3001);
00065   graph->SetFillColor(6);
00066   graph->Draw("L3 same");
00067 }
00068 
00069 //____________________________________________________________________
00070 //
00071 // EOF
00072 //

Generated on Fri Mar 24 17:11:21 2006 for ALICE FMD Off-line by  doxygen 1.4.6