HI rooters,
I wrote a short and simple script ,the script is just a test,i want to know how to use TClonesArray,and the difference between TObjArray and TClonesArray. So this is my code:
[color=brown]{ TFile *f=new TFile(“particleinfo.root”,“recreate”);
TClonesArray *particleinfo = new TClonesArray();
//TObjArray *particleinfo =new TObjArray();
TParticle *particle1 = new TParticle();
particle1->SetMomentum(300,300,200,700);
TParticle *particle2 =new TParticle ();
particle2->SetMomentum(100,100,100,400);
TParticle *particle3 =new TParticle ();
particle3->SetMomentum(-90,-80,100,300);
particleinfo->Add(particle1);
particleinfo->Add(particle2);
particleinfo->Add(particle3);
particleinfo->Write();
f->Close();
}[/color]
When i use the TObjArray ,there is no problem;
But when use TClonesArray ,the warning infomation is:
[color=red]Warning in TClonesArray::AddLast: may not use this method
Warning in TClonesArray::AddLast: may not use this method
Warning in TClonesArray::AddLast: may not use this method[/color]
SO ,what’s the problem??? When and How to use TClonesArray is better ??
Tanks a lot!