Alternatively, you can compile this to a program and then generate 1000 events with
(/etc/root/system.rootrc or ~/.rootrc).
Runtime load paths set on the executable (Using GNU ld,
specified with flag `-rpath').
Dynamic loader search path as specified in the loaders
configuration file (On GNU/Linux this file is
etc/ld.so.conf).
For Un*x: Any directory mentioned in LD_LIBRARY_PATH
For Windows: Any directory mentioned in PATH
Namespace for new ROOT classes and functions.
#include <cstdlib>
using namespace std;
#define FILENAME "pythia.root"
#define TREENAME "tree"
#define BRANCHNAME "particles"
#define HISTNAME "ptSpectra"
#define PDGNUMBER 211
void loadLibraries()
{
#ifdef R__MACOSX
#endif
}
int makeEventSample(
Int_t nEvents)
{
loadLibraries();
Error(
"makeEventSample",
"Couldn;t open file %s", FILENAME);
return 1;
}
tree->Branch(BRANCHNAME, &particles);
for (
Int_t i = 0; i < nEvents; i++) {
if (i % 100 == 0)
cout << "Event # " << i << endl;
}
TH1D* hist =
new TH1D(HISTNAME,
"p_{#perp} spectrum for #pi^{+}",
100, 0, 3);
char expression[64];
sprintf(expression,"sqrt(pow(%s.fPx,2)+pow(%s.fPy,2))>>%s",
BRANCHNAME, BRANCHNAME, HISTNAME);
char selection[64];
sprintf(selection,"%s.fKF==%d", BRANCHNAME, PDGNUMBER);
tree->Draw(expression,selection);
hist->
Fit(
"expo",
"QO+",
"", .25, 1.75);
return 0;
}
int showEventSample()
{
loadLibraries();
Error(
"showEventSample",
"Couldn;t open file %s", FILENAME);
return 1;
}
Error(
"showEventSample",
"couldn't get TTree %s", TREENAME);
return 2;
}
if (!hist) {
Error(
"showEventSample",
"couldn't get TH1D %s", HISTNAME);
return 4;
}
char expression[64];
sprintf(expression,
"T #approx %5.1f", -1000 / func->
GetParameter(1));
return 0;
}
void pythiaExample(
Int_t n=1000) {
showEventSample();
}
#ifndef __CINT__
int main(
int argc,
char** argv)
{
if (argc > 1)
n = strtol(argv[1], NULL, 0);
int retVal = 0;
retVal = makeEventSample(
n);
else {
retVal = showEventSample();
app.Run();
}
return retVal;
}
#endif
void Error(const char *location, const char *msgfmt,...)
R__EXTERN TStyle * gStyle
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
An array of clone (identical) objects.
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 Double_t GetParameter(Int_t ipar) const
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose, Int_t netopt=0)
Create / open a file.
virtual TObjArray * GetListOfParticles() const
1-D histogram with a double per channel (see TH1 documentation)}
virtual void SetXTitle(const char *title)
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 Double_t Integral(Option_t *option="") const
Return integral of bin contents.
virtual TF1 * GetFunction(const char *name) const
Return pointer to function with name.
virtual void Draw(Option_t *option="")
Draw this histogram with options.
virtual void SetYTitle(const char *title)
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
To draw Mathematical Formula.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
virtual void SetLogy(Int_t value=1)
Set Lin/Log scale for Y.
TPythia is an interface class to F77 version of Pythia 6.2
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.
void GenerateEvent()
generate event and copy the information from /HEPEVT/ to fPrimaries
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
A TTree represents a columnar dataset.
int main(int argc, char **argv)