qaReader_mcini.cxx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include <qaReader_mcini.h>
  2. ClassImp(qaReader_mcini);
  3. qaReader_mcini::qaReader_mcini(/* args */) : is_init(false), fCurrentEvent(-1), fEvent(nullptr), fParticle(nullptr)
  4. {
  5. }
  6. qaReader_mcini::~qaReader_mcini()
  7. {
  8. }
  9. Bool_t qaReader_mcini::ChainCheck()
  10. {
  11. if (!is_init)
  12. {
  13. return false;
  14. }
  15. if (fCurrentEvent == -1)
  16. {
  17. return false;
  18. }
  19. if (!fChain->GetEntry(fCurrentEvent))
  20. {
  21. return false;
  22. }
  23. return true;
  24. }
  25. void qaReader_mcini::SetChain(const TString &inputFileName)
  26. {
  27. fChain = (TChain *)qaUtility::GetInstance()->initChain(inputFileName, fChainName);
  28. fChain->SetBranchAddress("event", &fEvent);
  29. is_init = kTRUE;
  30. }
  31. qaEvent *qaReader_mcini::ReadEvent(Long64_t iev)
  32. {
  33. fCurrentEvent = iev;
  34. if (!ChainCheck())
  35. {
  36. return nullptr;
  37. }
  38. qaEvent *event = new qaEvent();
  39. event->SetB(fEvent->GetB());
  40. event->SetPhiRP(fEvent->GetPhi());
  41. event->SetNparticles(fEvent->GetNpa());
  42. return event;
  43. }
  44. qaParticle *qaReader_mcini::ReadParticle(Int_t ipart)
  45. {
  46. if (!ChainCheck())
  47. {
  48. return nullptr;
  49. }
  50. if (ipart >= fEvent->GetNpa())
  51. {
  52. return nullptr;
  53. }
  54. fParticle = fEvent->GetParticle(ipart);
  55. fMomentum = fParticle->GetMomentum();
  56. qaParticle *particle = new qaParticle();
  57. particle->SetEnergy(fMomentum.E());
  58. particle->SetPdg(fParticle->GetPdg());
  59. particle->SetPxPyPz(fMomentum.Px(), fMomentum.Py(), fMomentum.Pz());
  60. particle->SetTime(0.);
  61. particle->SetXYZ(0., 0., 0.);
  62. particle->SetCharge(qaUtility::GetInstance()->GetCharge(fParticle->GetPdg()));
  63. return particle;
  64. }