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