92 #define FILENAME "pythia.root"
93 #define TREENAME "tree"
94 #define BRANCHNAME "particles"
95 #define HISTNAME "ptSpectra"
112 int makeEventSample(
Int_t nEvents)
125 if (!file || !file->IsOpen()) {
126 Error(
"makeEventSample",
"Couldn;t open file %s", FILENAME);
131 TTree* tree =
new TTree(TREENAME,
"Pythia 6 tree");
136 tree->
Branch(BRANCHNAME, &particles);
142 cout <<
"Event # " << i << endl;
159 TH1D* hist =
new TH1D(HISTNAME,
"p_{#perp} spectrum for #pi^{+}",
164 sprintf(expression,
"sqrt(pow(%s.fPx,2)+pow(%s.fPy,2))>>%s",
165 BRANCHNAME, BRANCHNAME, HISTNAME);
167 sprintf(selection,
"%s.fKF==%d", BRANCHNAME, PDGNUMBER);
168 tree->
Draw(expression,selection);
173 hist->
Fit(
"expo",
"QO+",
"", .25, 1.75);
175 func->SetParNames(
"A",
"- 1 / T");
184 int showEventSample()
191 if (!file || !file->IsOpen()) {
192 Error(
"showEventSample",
"Couldn;t open file %s", FILENAME);
199 Error(
"showEventSample",
"couldn't get TTree %s", TREENAME);
207 TH1D* hist = (
TH1D*)file->Get(HISTNAME);
209 Error(
"showEventSample",
"couldn't get TH1D %s", HISTNAME);
215 TCanvas* canvas =
new TCanvas(
"canvas",
"canvas");
221 sprintf(expression,
"T #approx %5.1f", -1000 / func->GetParameter(1));
223 latex->SetTextSize(.1);
224 latex->SetTextColor(4);
230 void pythiaExample(
Int_t n=1000) {
236 int main(
int argc,
char** argv)
242 n = strtol(argv[1],
NULL, 0);
246 retVal = makeEventSample(n);
248 retVal = showEventSample();
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
R__EXTERN TStyle * gStyle
virtual Int_t Fill()
Fill all branches.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
virtual void SetYTitle(const char *title)
void GenerateEvent()
generate event and copy the information from /HEPEVT/ to fPrimaries
TPythia is an interface class to F77 version of Pythia 6.2.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
virtual void StartViewer()
Start the TTreeViewer on this tree.
virtual void Print(Option_t *option="") const
Print a summary of the tree contents.
void Initialize(const char *frame, const char *beam, const char *target, float win)
Calls PyInit with the same parameters after performing some checking, sets correct title...
To draw Mathematical Formula.
void Error(const char *location, const char *msgfmt,...)
virtual Double_t Integral(Option_t *option="") const
Return integral of bin contents.
R__EXTERN TSystem * gSystem
virtual void Draw(Option_t *option="")
Draw this histogram with options.
1-D histogram with a double per channel (see TH1 documentation)}
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Create one branch for each element in the collection.
An array of clone (identical) objects.
virtual void SetXTitle(const char *title)
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
virtual TObjArray * GetListOfParticles() const
A TTree object has a header with a name and a title.
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
Fit histogram with function fname.
virtual TF1 * GetFunction(const char *name) const
Return pointer to function with name.