EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EventRapgap.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EventRapgap.cxx
1 
11 
12 #include <sstream>
13 #include <string>
14 
15 namespace erhic {
16 
17 bool EventRapgap::Parse(const std::string& line) {
18  static std::stringstream ss;
19  ss.str("");
20  ss.clear();
21  ss << line;
22  ss >>
23  number >> number >> // Skip first int in the line
24  genevent >> process >> idir >> idisdif >> cs >> sigma_cs >> s >> q2 >>
25  y >> xgam >> xpr >> Pt_h >> pt2_hat >> sHat >> t >> x_pom >> sHat2 >> z >>
26  x1 >> phi1 >> nTracks;
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.
35  // 3) the parent is track 1 or 2
37  // Look for the lepton beam to get the species.
38  // If we don't get it we can't find the scattered
39  // lepton so return NULL.
40  const VirtualParticle* beam = BeamLepton();
41  if (!beam) {
42  return NULL;
43  } // if
44  const int species = beam->Id().Code();
45  // Get the final state particles and search them for
46  // the scattered lepton.
47  std::vector<const VirtualParticle*> final;
48  FinalState(final);
49  std::vector<const VirtualParticle*>::const_iterator iter;
50  for (iter = final.begin(); iter != final.end(); ++iter) {
51  // We already know the particle is final state, so
52  // check its species and parent index.
53  if ( (*iter)->Id().Code() == species &&
54  ( (*iter)->GetParentIndex() == 1 || (*iter)->GetParentIndex() == 2 )
55  ) {
56  // Found it, cast to required particle type and return.
57  return static_cast<const ParticleMC*>(*iter);
58  } // if
59  } // for
60  // No luck, couldn't find the scattered lepton.
61  return nullptr;
62  }
63 
64 
65  // Look for the exchange boson in the event record.
66  // It would probably be the third track, but we'll go with the first status=21 boson
67  // that has particle 1 or 2 as parent
69  for ( auto particle : EventMC::GetTracks() ){
70  if ( particle->GetStatus() != 21 ) continue;
71  if ( particle->GetParentIndex() != 1 && particle->GetParentIndex() == 2 ) continue;
72  if ( particle->Id().Code() == 22 || particle->Id().Code() == 23 || std::abs(particle->Id().Code()) == 24 ){
73  // Found it, cast to required particle type and return.
74  return static_cast<const ParticleMC*>(particle);
75  }
76  } // for
77  // No luck, couldn't find the exchange boson.
78  return nullptr;
79  }
80 
81 } // namespace erhic