qaReader_mcpico.cxx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #include <qaReader_mcpico.h>
  2. ClassImp(qaReader_mcpico);
  3. qaReader_mcpico::qaReader_mcpico(/* args */) : is_init(false), fCurrentEvent(-1)
  4. {
  5. }
  6. qaReader_mcpico::~qaReader_mcpico()
  7. {
  8. }
  9. Bool_t qaReader_mcpico::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_mcpico::SetChain(const TString &inputFileName)
  26. {
  27. fChain = (TChain *)qaUtility::GetInstance()->initChain(inputFileName, fChainName);
  28. fChain->SetBranchAddress("bimp", &bimp);
  29. fChain->SetBranchAddress("phi2", &phi2);
  30. fChain->SetBranchAddress("phi3", &phi3);
  31. fChain->SetBranchAddress("ecc2", &ecc2);
  32. fChain->SetBranchAddress("ecc3", &ecc3);
  33. fChain->SetBranchAddress("npart", &npart);
  34. fChain->SetBranchAddress("nh", &nh);
  35. fChain->SetBranchAddress("momx", momx);
  36. fChain->SetBranchAddress("momy", momy);
  37. fChain->SetBranchAddress("momz", momz);
  38. fChain->SetBranchAddress("ene", ene);
  39. fChain->SetBranchAddress("hid", hid);
  40. fChain->SetBranchAddress("pdg", pdg);
  41. fChain->SetBranchAddress("charge", charge);
  42. is_init = kTRUE;
  43. }
  44. qaEvent *qaReader_mcpico::ReadEvent(Long64_t iev)
  45. {
  46. fCurrentEvent = iev;
  47. if (!ChainCheck())
  48. {
  49. return nullptr;
  50. }
  51. qaEvent *event = new qaEvent();
  52. event->SetB(bimp);
  53. event->SetPhiRP(phi2);
  54. event->SetNparticles(nh);
  55. return event;
  56. }
  57. qaParticle *qaReader_mcpico::ReadParticle(Int_t ipart)
  58. {
  59. if (!ChainCheck())
  60. {
  61. return nullptr;
  62. }
  63. if (ipart >= nh)
  64. {
  65. return nullptr;
  66. }
  67. qaParticle *particle = new qaParticle();
  68. particle->SetEnergy(ene[ipart]);
  69. particle->SetPdg(pdg[ipart]);
  70. particle->SetPxPyPz(momx[ipart], momy[ipart], momz[ipart]);
  71. particle->SetTime(0.);
  72. particle->SetXYZ(0., 0., 0.);
  73. particle->SetCharge(qaUtility::GetInstance()->GetCharge(pdg[ipart]));
  74. return particle;
  75. }