eic-smear  1.0.3
A collection of ROOT classes for Monte Carlo events and a fast-smearing code simulating detector effects for the Electron-Ion Collider task force
EventDisFactory.cxx
Go to the documentation of this file.
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.
75  mDetector.FillEventKinematics(event);
76  return event;
77 }
78 
79 } // namespace Smear
EventDisFactory(const Detector &, TBranch &)
ParticleMCS * Smear(const erhic::VirtualParticle &) const
Definition: Detector.cxx:132
virtual UShort_t GetStatus() const =0
virtual UInt_t GetNTracks() const =0
virtual const VirtualParticle * GetTrack(UInt_t) const =0
virtual const VirtualParticle * BeamLepton() const =0
void FillEventKinematics(Event *event)
Definition: Detector.cxx:82
virtual const VirtualParticle * ScatteredLepton() const =0
virtual TLorentzVector Get4Vector() const =0
virtual Pid Id() const =0
virtual Event * Create()
virtual const VirtualParticle * BeamHadron() const =0
Abstract base class for a general particle.