123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #include <mciReader_mcini.h>
- ClassImp(mciReader_mcini);
- mciReader_mcini::mciReader_mcini(/* args */) : is_init(false), fCurrentEvent(-1), fEvent(nullptr), fParticle(nullptr)
- {
- }
- mciReader_mcini::~mciReader_mcini()
- {
- }
- Bool_t mciReader_mcini::ChainCheck()
- {
- if (!is_init)
- {
- return false;
- }
- if (fCurrentEvent == -1)
- {
- return false;
- }
- if (!fChain->GetEntry(fCurrentEvent))
- {
- return false;
- }
- return true;
- }
- void mciReader_mcini::SetChain(const TString &inputFileName)
- {
- fChain = (TChain *)mciUtility::GetInstance()->initChain(inputFileName, fChainName);
- fChain->SetBranchAddress("event", &fEvent);
- is_init = kTRUE;
- }
- mciEvent *mciReader_mcini::ReadEvent(Long64_t iev)
- {
- mciEvent *event = new mciEvent();
- fCurrentEvent = iev;
- if (!ChainCheck())
- {
- return event;
- }
- event->SetB(fEvent->GetB());
- event->SetPhiRP(fEvent->GetPhi());
- event->SetNparticles(fEvent->GetNpa());
- return event;
- }
- mciParticle *mciReader_mcini::ReadParticle(Int_t ipart)
- {
- mciParticle *particle = new mciParticle();
- if (!ChainCheck())
- {
- return particle;
- }
- if (ipart >= fEvent->GetNpa())
- {
- return particle;
- }
- fParticle = fEvent->GetParticle(ipart);
- fMomentum = fParticle->GetMomentum();
- particle->SetEnergy(fMomentum.E());
- particle->SetPdg(fParticle->GetPdg());
- particle->SetPxPyPz(fMomentum.Px(), fMomentum.Py(), fMomentum.Pz());
- particle->SetTime(0.);
- particle->SetXYZ(0., 0., 0.);
- particle->SetCharge(mciUtility::GetInstance()->GetCharge(fParticle->GetPdg()));
- return particle;
- }
|