91 #define FILENAME "pythia.root" 92 #define TREENAME "tree" 93 #define BRANCHNAME "particles" 94 #define HISTNAME "ptSpectra" 124 if (!file || !file->IsOpen()) {
125 Error(
"makeEventSample",
"Couldn;t open file %s", FILENAME);
130 TTree*
tree =
new TTree(TREENAME,
"Pythia 6 tree");
135 tree->Branch(BRANCHNAME, &particles);
141 cout <<
"Event # " << i << endl;
158 TH1D* hist =
new TH1D(HISTNAME,
"p_{#perp} spectrum for #pi^{+}",
163 sprintf(expression,
"sqrt(pow(%s.fPx,2)+pow(%s.fPy,2))>>%s",
164 BRANCHNAME, BRANCHNAME, HISTNAME);
166 sprintf(selection,
"%s.fKF==%d", BRANCHNAME, PDGNUMBER);
167 tree->Draw(expression,selection);
172 hist->
Fit(
"expo",
"QO+",
"", .25, 1.75);
183 int showEventSample()
190 if (!file || !file->IsOpen()) {
191 Error(
"showEventSample",
"Couldn;t open file %s", FILENAME);
196 TTree* tree = (TTree*)file->Get(TREENAME);
198 Error(
"showEventSample",
"couldn't get TTree %s", TREENAME);
206 TH1D* hist = (
TH1D*)file->Get(HISTNAME);
208 Error(
"showEventSample",
"couldn't get TH1D %s", HISTNAME);
220 sprintf(expression,
"T #approx %5.1f", -1000 / func->
GetParameter(1));
222 latex->SetTextSize(.1);
223 latex->SetTextColor(4);
229 void pythiaExample(
Int_t n=1000) {
235 int main(
int argc,
char** argv)
241 n = strtol(argv[1],
NULL, 0);
245 retVal = makeEventSample(n);
247 retVal = showEventSample();
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
virtual void SetParNames(const char *name0="p0", const char *name1="p1", const char *name2="p2", const char *name3="p3", const char *name4="p4", const char *name5="p5", const char *name6="p6", const char *name7="p7", const char *name8="p8", const char *name9="p9", const char *name10="p10")
Set up to 10 parameter names.
virtual TF1 * GetFunction(const char *name) const
Return pointer to function with name.
R__EXTERN TStyle * gStyle
virtual Double_t Integral(Option_t *option="") const
Return integral of bin contents.
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.
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,...)
R__EXTERN TSystem * gSystem
virtual void Draw(Option_t *option="")
Draw this histogram with options.
tomato 1-D histogram with a double per channel (see TH1 documentation)}
double func(double *x, double *p)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
An array of clone (identical) objects.
virtual void SetXTitle(const char *title)
virtual Double_t GetParameter(Int_t ipar) const
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...
THist< 1, double, THistStatContent, THistStatUncertainty > TH1D
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 TObjArray * GetListOfParticles() const
int main(int argc, char **argv)
virtual void SetLogy(Int_t value=1)
Set Lin/Log scale for Y.