Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-09-28 07:02:50

0001 /**
0002  \file Implementation of class erhic::EventSimple. 
0003  \author    Barak Schmookler
0004  \date      2020-03-19
0005  */
0006 
0007 #include "eicsmear/erhic/EventSimple.h"
0008 
0009 #include <cmath>
0010 #include <sstream>
0011 #include <string>
0012 
0013 namespace erhic {
0014 
0015 EventSimple::EventSimple()
0016 : numParticles(NAN){
0017 }
0018 
0019 bool EventSimple::Parse(const std::string& line) {
0020   static std::stringstream ss;
0021   ss.str("");
0022   ss.clear();
0023   ss << line;
0024   ss >>
0025   number >> number >>  // Skip first int in the line
0026     numParticles;
0027   // Protect against errors in the input file or the stream
0028   return !ss.fail();
0029 }
0030 
0031 // Look for the scattered lepton in the event record.
0032 // This is the first (only?) particle that matches the following:
0033 //  1) pdg code equals that of incident lepton beam.
0034 //  2) status code is 1 i.e. it's a stable/final-state particle.
0035 const ParticleMC* EventSimple::ScatteredLepton() const {
0036   // Look for the lepton beam to get the species.
0037   // If we don't get it we can't find the scattered
0038   // lepton so return NULL.
0039   const VirtualParticle* beam = BeamLepton();
0040   if (!beam) {
0041     return nullptr;
0042   }  // if
0043   const int species = beam->Id().Code();
0044   // Get the final state particles and search them for
0045   // the scattered lepton.
0046   std::vector<const VirtualParticle*> final;
0047   FinalState(final);
0048   // std::vector<const VirtualParticle*>::const_iterator iter;
0049   for (auto & iter : final ) {
0050     // We already know the particle is final state
0051     // could check for its parent but we don't need to
0052     if ( iter->Id().Code() == species) {
0053       // Found it, cast to required particle type and return.
0054       return static_cast<const ParticleMC*>(iter);
0055     }
0056   }
0057 
0058   // No luck, couldn't find the scattered lepton.
0059   return nullptr;
0060 }
0061 
0062 }  // namespace erhic