Hello ROOTers…
I have a question about TMCParticle and TPythia6.
Pythia6 with p+p->pi0+X(200GeVcms).
This is my macro.
#define nEvent 1.0e+03//nEvent is number of pp collisions.
void test3()
{
gSystem->Load("libEG");
TPythia6 *pythia = new TPythia6();
//Pythia setttings
pythia->SetMSEL(0);
pythia->SetMSUB(11,1);
pythia->SetMSUB(12,1);
pythia->SetMSUB(13,1);
pythia->SetMSUB(28,1);
pythia->SetMSUB(53,1);
pythia->SetMSUB(68,1);
pythia->SetCKIN(3,10.);
pythia->SetCKIN(4,20.);
pythia->Initialize("cms", "p", "p", 200);
Int_t event;
TFile *f = new TFile("test3.root","recreate");
TTree *t = new TTree("tree","test");
//TClonesArray *particle = (TClonesArray*)pythia->GetListOfParticles();
TMCParticle *particle = (TMCParticle*)pythia->GetListOfParticles();
t->Branch("tree",&particle);
t->Branch("event",&event,"event/I");
for(Int_t i=0;i<nEvent;i++){
event = i+1;
if(i%100 == 0) cout <<"Event # "<<i<<endl;
pythia->GenerateEvent();//Generate event
for(Int_t j=0;j<pythia->GetNumberOfParticles();j++){
if(pythia->GetK(j,2)!=111){//Are particles pi0?
continue;
}
}
t->Fill();
}
f->Write();
t->Print();
}
This macro create root file with TTree.And a Branch have TMCParticle object(t->Branch(“tree”,&particle);).
The particles was selected(Only pi0).
In this macro,branch was filled event by event.So ,This tree or branch have all infomations about pi0s that have created in just one pp collision?
For example,100 Pi0s created just one collision.This tree have all infomations about 100 created Pi0s?
brun
April 1, 2010, 1:22pm
2
No, you store all particles.
I hope to have time to post a corrected script before I leave.
Rene
brun
April 1, 2010, 1:49pm
3
Try the following script:
[code]void test3()
{
const Int_t nEvent = 1000;
gSystem->Load("$PYTHIA6/libPythia6");
gSystem->Load(“libEGPythia6”);
TPythia6 *pythia = new TPythia6();
//Pythia setttings
pythia->SetMSEL(0);
pythia->SetMSUB(11,1);
pythia->SetMSUB(12,1);
pythia->SetMSUB(13,1);
pythia->SetMSUB(28,1);
pythia->SetMSUB(53,1);
pythia->SetMSUB(68,1);
pythia->SetCKIN(3,10.);
pythia->SetCKIN(4,20.);
pythia->Initialize(“cms”, “p”, “p”, 200);
Int_t event;
TFile *f = new TFile(“test3.root”,“recreate”);
TTree *t = new TTree(“tree”,“test”);
TClonesArray particles = (TClonesArray )pythia->GetListOfParticles();
t->Branch(“tree”,&particles);
t->Branch(“event”,&event,“event/I”);
for(Int_t i=0;i<nEvent;i++){
event = i+1;
if(i%100 == 0) cout <<"Event # "<<i<<endl;
pythia->GenerateEvent();//Generate event
for(Int_t j=0;jGetNumberOfParticles();j++){
if(pythia->GetK(j,2)!=111) particles->RemoveAt(j); //Are particles pi0?
}
particles->Compress();
t->Fill();
}
f->Write();
t->Print();
}
[/code]
Rene
Hi
Thanks for that.
TMCParticle don’t have “RemoveAt()”.TClonesArray?
For example…
TClonesArray *particle = (TClonesArray*)pythia->GetListOfParticles();
t->Branch("tree",&particle);
for(Int_t j=0;j<pythia->GetNumberOfParticles();j++){
if(pythia->GetK(j,2)!=111) particle->RemoveAt(j);
}
Kimiaki
brun
April 2, 2010, 5:05am
6
Read carefully the code that I posted above.
I named the TClonesArray *particles (not particle).
RemopveAt is a function of TClonesArray , not TMCParticle that does not appear in my code.
Rene
Hi
I tried and got following result.
・Created ROOT file include not only pi0 but another particles,pi-,pi+,n,gamma…
Dose this code mean remove non pi0 particles(pi+,pi-…) from array?