EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EventDisFactory.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EventDisFactory.cxx
1 
11 
12 #include <vector>
13 
14 #include <TBranch.h>
15 
20 
21 namespace {
22 
23 Smear::ParticleMCS* mcToSmear(const erhic::VirtualParticle& mc) {
25  mc.Id(), mc.GetStatus());
26  p->SetStatus(mc.GetStatus());
27  return p;
28 }
29 
30 } // anonymous namespace
31 
32 namespace Smear {
33 
35 }
36 
37 EventDisFactory::EventDisFactory(const Detector& d, TBranch& mcBranch)
38 : mDetector(d)
39 , mMcEvent(NULL) {
40  mcBranch.SetAddress(&mMcEvent);
41 }
42 
44  Event* event = new Event;
45  for (unsigned j(0); j < mMcEvent->GetNTracks(); j++) {
46  const erhic::VirtualParticle* ptr = mMcEvent->GetTrack(j);
47  if (!ptr) {
48  continue;
49  } // if
50  // If this is the scattered lepton, record the index.
51  // Set the index even if the particle turns out to be outside the
52  // acceptance (in which case it will just point to a NULL anyway).
53  if (mMcEvent->ScatteredLepton() == ptr) {
54  ParticleMCS* p = mDetector.Smear(*ptr);
55  if (p) {
56  p->SetStatus(ptr->GetStatus());
57  event->SetScattered(j);
58  } // if
59  event->AddLast(p);
60  // Only set the index if the scattered electron is detected
61  } else if (mMcEvent->BeamLepton() == ptr ||
62  mMcEvent->BeamHadron() == ptr) {
63  // It's convenient to keep the initial beams, unsmeared, in the
64  // smeared event record, so copy their properties exactly
65  event->AddLast(mcToSmear(*ptr));
66  } else {
67  ParticleMCS* p = mDetector.Smear(*ptr);
68  if (p) {
69  p->SetStatus(ptr->GetStatus());
70  } // if
71  event->AddLast(p);
72  } // if
73  } // for
74  // Fill the event-wise kinematic variables.
76  return event;
77 }
78 
79 } // namespace Smear