Pythia ProcessID getting code (it might be not correct)
Updated on Tue, 2024-10-22 15:44. Originally created by slee5 on 2024-10-22 15:44.
/**!
* Example macro for running an event generator in standalone mode.
*
* Usage:
*
* ln -s starsim.reader.C reader.C
*
* root4star
* .L reader.C
* int nevents=100;
* reader( nevents )
*
* or
*
* root4star -q -b reader.C
*
*/
class St_geant_Maker;
St_geant_Maker *geant_maker = 0;
class StarGenEvent;
StarGenEvent *event = 0;
class StarGenPPEvent;
StarGenPPEvent* eventPP = 0;
class StarPrimaryMaker;
StarPrimaryMaker *_primary = 0;
class StarGenEventReader;
StarGenEventReader *eventreader = 0;
#include "TFile.h"
#include "TTree.h"
#include "TClonesArray.h"
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void readForStarSim( Int_t nevents=1, UInt_t rngSeed = 12345 )
{
gROOT->ProcessLine(".L bfc.C");
{
TString simple = "tables nodefault";
bfc(0, simple );
}
gSystem->Load( "libVMC.so");
gSystem->Load( "St_g2t.so" );
gSystem->Load( "St_geant_Maker.so" );
gSystem->Load( "StarGeneratorUtil.so" );
gSystem->Load( "StarGeneratorEvent.so" );
gSystem->Load( "StarGeneratorBase.so" );
gSystem->Load( "Pythia8_3_03.so" );
gSystem->Load( "libMathMore.so" );
gSystem->Load( "libStarGenEventReader.so" );
eventreader = new StarGenEventReader();
eventreader -> SetInputFile("pythia8.root","genevents","Pythia8");
chain -> SetDebug();
chain->Init();
// ============================= process ID getting methode 1 (based on example macros) =============================
for(int i=0; i<10; i++){
chain->Clear();
chain->Make(i);
cout << i << endl;
StarGenPPEvent* event = (StarGenPPEvent*)eventreader->Event();
// for genevents.primaryEvent branch
// std::cout << "GENERATOR ID = " << event->GetGeneratorId() << std::endl;
// std::cout << "PROCESS ID = " << event->GetProcessId() << std::endl;
// std::cout << "RUN NUMBER = " << event->GetRunNumber() << std::endl;
// std::cout << "EVENT NUMBER = " << event->GetEventNumber() << std::endl;
// std::cout << "NUM PARTICLES = " << event->GetNumberOfParticles() << std::endl;
// Note) genvents.Pyrthia8.process branch has correct ProcessID
std::cout << "PROCESS ID = " << event->process << std::endl;
}
// ============================= process ID getting methode 2 =============================
TFile* file = new TFile("pythia8.root","read");
TTree* tree = (TTree*)file -> Get("genevents");
TClonesArray* genEventArr = new TClonesArray("StarGenPPEvent");
tree -> SetBranchAddress("Pythia8", &genEventArr);
// It can not addressed !!
int eventNum = tree -> GetEntries();
cout << eventNum << endl;
for(int i=0; i<eventNum; i++){
tree -> GetEntry(i);
cout << i << endl;
StarGenPPEvent* event = (StarGenPPEvent*)genEventArr -> At(i);
cout << event -> process << endl;
}
}
// ----------------------------------------------------------------------------
»
- slee5's blog
- Login or register to post comments