Pythia8 simulation test code
Updated on Tue, 2024-10-22 14:57. Originally created by slee5 on 2024-10-22 14:57.
class St_geant_Maker;
St_geant_Maker *geant_maker = 0;
class StarGenEvent;
StarGenEvent *event = 0;
class StarPrimaryMaker;
StarPrimaryMaker *_primary = 0;
class RHICfFilter;
RHICfFilter *filter = 0;
class StarPythia8;
StarPythia8* _pythia8;
// ----------------------------------------------------------------------------
void geometry( TString tag, Bool_t agml=true )
{
TString cmd = "DETP GEOM "; cmd += tag;
if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
geant_maker -> LoadGeometry(cmd);
// if ( agml ) command("gexec $STAR_LIB/libxgeometry.so");
}
// ----------------------------------------------------------------------------
void command( TString cmd )
{
if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
geant_maker -> Do( cmd );
}
// ----------------------------------------------------------------------------
// trig() -- generates one event
// trig(n) -- generates n+1 events.
//
// NOTE: last event generated will be corrupt in the FZD file
//
void trig( Int_t n=1 )
{
chain->EventLoop(n);
_primary->event()->Print();
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void Pythia8()
{
//
// Create the pythia 8 event generator and add it to
// the primary generator
//
StarPythia8 *pythia8 = new StarPythia8();
_pythia8 = pythia8;
pythia8->SetFrame("CMS", 510.0);
pythia8->SetBlue("proton");
pythia8->SetYell("proton");
pythia8->Set("SoftQCD:all = on");
_primary -> AddGenerator( pythia8 );
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Note) !!! RHICf Pi0 event must generate the number of pythia event 10000 per pi0 events,
// !!! total events 200 will be limited
void genStarSim(const Char_t *jobID = "woZDC", Int_t nevents=500)
{
gROOT->ProcessLine(".L bfc.C");
{
TString simpleMC = "DbV20230620 y2017a geant gstar usexgeom agml misalign FieldOn huge tables ";
TString simpleFull = "Simu y2017a geant gstar usexgeom agml misalign FieldOn ReverseField MakeEvent huge tables cmudst McEvOut EvOut bbcSim btofSim vpdSim sti ittf tpcDb TpcFastSim MiniMcMk IdTruth";
TString fileID = jobID;
TString fileName = Form("StarSimPythia8_%s", fileID.Data());
bfc(0, simpleFull, 0,fileName);
}
gSystem->Load( "libVMC.so");
gSystem->Load( "StarGeneratorUtil.so");
gSystem->Load( "StarGeneratorEvent.so");
gSystem->Load( "StarGeneratorBase.so" );
gSystem->Load( "StarGeneratorDecay.so" );
gSystem->Load( "Pythia8_3_03.so" );
gSystem->Load( "libMathMore.so" );
gSystem->Load("libKinematics.so");
gSystem->Load("libHepMC2_06_09.so");
gSystem->Load("libPhotos3_61.so");
gSystem->Load("libTauola1_1_5.so");
gSystem->Load("libEvtGen1_06_00.so");
// Force loading of xgeometry
gSystem->Load( "xgeometry.so" );
gSystem->Load( "/star/u/slee5/.sl73_gcc485/lib/StarGeneratorFilt.so" ); // for local run
// gSystem->Load( "StarGeneratorFilt.so" ); // for job run
// Setup RNG seed and map all ROOT TRandom here
StarRandom::seed( 0 );
StarRandom::capture();
_primary = new StarPrimaryMaker();
_primary -> SetFileName(Form("pythia8_%s.root", fileID.Data()));
_primary -> SetVertex( 0.0, 0.0, 0.0 );
_primary -> SetSigma ( 0.6, 0.6, 20.0 );
chain -> AddBefore( "geant", _primary );
//
// Setup an event generator
//
Pythia8();
command("call gstar_part");
// filter = new RHICfFilter();
// filter -> SetRHICfRunType(0); // [0=TS, 1=TL, 2=TOP]
// _primary -> AddFilter( filter );
// If set to 1, tracks will be saved in the tree on events which were
// rejected. If the tree size is too big (because the filter is too
// powerful) you may want to set this equal to zero. In which case
// only header information is saved for the event.
_primary->SetAttr("FilterKeepAll", int(1));
_primary->SetVertex( 0., 0., 0. );
_primary->SetSigma( 0.1, 0.1, 30.0 );
_primary -> Init();
command("gkine -4 0");
// command(Form("gfile o STARSim_pythia8_%s.fzd", fileID.Data()));
_pythia8->Set("111:onMode=1"); // pi0
_pythia8->Set("221:onMode=1"); // eta
_pythia8->Set("310:onMode=1"); // K short
_pythia8->Set("130:onMode=1"); // K long
_pythia8->Set("3122:onMode=1"); // Lambda 0
_pythia8->Set("3212:onMode=1"); // Sigma 0
_pythia8->Set("3322:onMode=1"); // Xi 0
//
// Trigger on nevents
//
trig( nevents );
//
// Finish the chain
//
chain->Finish();
//
// EXIT starsim
//
command("call agexit"); // Make sure that STARSIM exits properly
}
// ----------------------------------------------------------------------------
»
- slee5's blog
- Login or register to post comments