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);
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);
198 Error(
"showEventSample",
"couldn't get TTree %s", TREENAME);
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.
R__EXTERN TStyle * gStyle
virtual Int_t Fill()
Fill all branches.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
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.
virtual Bool_t IsOpen() const
Returns kTRUE in case file is open and kFALSE if file is not open.
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.
virtual Int_t Write(const char *name=0, Int_t opt=0, Int_t bufsiz=0)
Write memory objects to this file.
tomato 1-D histogram with a double per channel (see TH1 documentation)}
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
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
virtual Double_t GetParameter(Int_t ipar) const
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...
THist< 1, double, THistStatContent, THistStatUncertainty > TH1D
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.
int main(int argc, char **argv)
virtual void Close(Option_t *option="")
Close a file.
virtual void SetLogy(Int_t value=1)
Set Lin/Log scale for Y.