EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EventDEMP.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EventDEMP.cxx
1 
9 
10 #include <cmath>
11 #include <sstream>
12 #include <string>
13 
14 namespace erhic {
15 
17 : numParticles(NAN)
18 , weight(NAN){
19 }
20 
21 bool EventDEMP::Parse(const std::string& line) {
22  static std::stringstream ss;
23  ss.str("");
24  ss.clear();
25  ss << line;
26  ss >>
27  number >> number >> // Skip first int in the line
29  // Protect against errors in the input file or the stream
30  return !ss.fail();
31 }
32 
33 // Look for the scattered lepton in the event record.
34 // This is the first (only?) particle that matches the following:
35 // 1) pdg code equals that of incident lepton beam.
36 // 2) status code is 1 i.e. it's a stable/final-state particle.
38  // Look for the lepton beam to get the species.
39  // If we don't get it we can't find the scattered
40  // lepton so return NULL.
41  const VirtualParticle* beam = BeamLepton();
42  if (!beam) {
43  return nullptr;
44  } // if
45  const int species = beam->Id().Code();
46  // Get the final state particles and search them for
47  // the scattered lepton.
48  std::vector<const VirtualParticle*> final;
49  FinalState(final);
50  // std::vector<const VirtualParticle*>::const_iterator iter;
51  for (auto & iter : final ) {
52  // We already know the particle is final state
53  // could check for its parent but we don't need to
54  if ( iter->Id().Code() == species) {
55  // Found it, cast to required particle type and return.
56  return static_cast<const ParticleMC*>(iter);
57  }
58  }
59 
60  // No luck, couldn't find the scattered lepton.
61  return nullptr;
62 }
63 
64 } // namespace erhic