123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- #include <qaReader_hsd_root.h>
- ClassImp(qaReader_hsd_root);
- qaReader_hsd_root::qaReader_hsd_root(/* args */) : is_init(false), fCurrentEvent(-1), fEvent(nullptr), fParticle(nullptr)
- {
- }
- qaReader_hsd_root::~qaReader_hsd_root()
- {
- }
- Bool_t qaReader_hsd_root::ChainCheck()
- {
- if (!is_init)
- {
- return false;
- }
- if (fCurrentEvent == -1)
- {
- return false;
- }
- if (!fChainPHSD->GetEntry(fCurrentEvent))
- {
- return false;
- }
- if (!fChainFrag->GetEntry(fCurrentEvent))
- {
- return false;
- }
- return true;
- }
- void qaReader_hsd_root::SetChain(const TString &inputFileName)
- {
- fChainPHSD = (TChain *)qaUtility::GetInstance()->initChain(inputFileName, fChainPHSDName);
- fChainPHSD->SetBranchAddress("event", &fEvent);
- fChainFrag = (TChain *)qaUtility::GetInstance()->initChain(inputFileName, fChainFragName);
- fChainFrag->SetBranchAddress("eventFrag", &fEventFrag);
- is_init = kTRUE;
- }
- qaEvent *qaReader_hsd_root::ReadEvent(Long64_t iev)
- {
- fCurrentEvent = iev;
- if (!ChainCheck())
- {
- return nullptr;
- }
- qaEvent *event = new qaEvent();
- event->SetB(fEvent->GetB());
- event->SetPhiRP(0.); // in PHQMD axis orientation is rotated by 180 deg. In HSD/PHSD it's ok.
- //event->SetPhiRP(TMath::Pi()); // in PHQMD axis orientation is rotated by 180 deg. In HSD/PHSD it's ok.
- event->SetNparticles(fEvent->GetNpart() + fEventFrag->GetNfragMST()); // number of particles from PHSD and number of MST fragments
- return event;
- }
- qaParticle *qaReader_hsd_root::ReadParticle(Int_t ipart)
- {
- if (!ChainCheck())
- {
- return nullptr;
- }
- if (ipart >= fEvent->GetNpart() + fEventFrag->GetNfragMST())
- {
- return nullptr;
- }
- if (ipart < 0)
- {
- return nullptr;
- }
- bool is_particle = false;
- bool is_fragment = false;
- if (ipart < fEvent->GetNpart())
- {
- is_particle = true;
- }
- if (ipart >= fEvent->GetNpart())
- {
- is_fragment = true;
- }
- if (!is_particle && !is_fragment)
- {
- return nullptr;
- }
- if (is_particle && is_fragment)
- {
- return nullptr;
- }
- qaParticle *particle = new qaParticle();
- if (is_particle)
- {
- fParticle = fEvent->GetParticle(ipart);
- if (fParticle->IsInMST()) // Check whether the particle from PHSD was used to create MST fragment
- {
- return nullptr;
- }
- particle->SetEnergy(fParticle->E());
- particle->SetPdg(fParticle->GetPdg());
- particle->SetPxPyPz(fParticle->Px(), fParticle->Py(), fParticle->Pz());
- particle->SetTime(0.);
- particle->SetXYZ(0., 0., 0.);
- particle->SetCharge(fParticle->GetCharge());
- }
- if (is_fragment)
- {
- fFragmentMST = fEventFrag->GetFragmentMST(ipart - fEvent->GetNpart());
- particle->SetEnergy(fFragmentMST->E());
- particle->SetPdg(fFragmentMST->GetPdg());
- particle->SetPxPyPz(fFragmentMST->Px(), fFragmentMST->Py(), fFragmentMST->Pz());
- particle->SetTime(0.);
- particle->SetXYZ(0., 0., 0.);
- particle->SetCharge(fFragmentMST->GetZ());
- }
- return particle;
- }
|