Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /**
0002  \file
0003  Implementation of class erhic::EventRapgap.
0004 
0005  \author    Thomas Burton
0006  \date      2011-07-07
0007  \copyright 2011 Brookhaven National Lab
0008  */
0009 
0010 #include "eicsmear/erhic/EventRapgap.h"
0011 
0012 #include <sstream>
0013 #include <string>
0014 
0015 namespace erhic {
0016 
0017 bool EventRapgap::Parse(const std::string& line) {
0018   static std::stringstream ss;
0019   ss.str("");
0020   ss.clear();
0021   ss << line;
0022   ss >>
0023   number >> number >>  // Skip first int in the line
0024   genevent >> process >> idir >> idisdif >> cs >> sigma_cs >> s >> q2 >>
0025   y >> xgam >> xpr >> Pt_h >> pt2_hat >> sHat >> t >> x_pom >> sHat2 >> z >>
0026   x1 >> phi1 >> nTracks;
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   //  3) the parent is track 1 or 2
0036   const ParticleMC* EventRapgap::ScatteredLepton() const {
0037     // Look for the lepton beam to get the species.
0038     // If we don't get it we can't find the scattered
0039     // lepton so return NULL.
0040     const VirtualParticle* beam = BeamLepton();
0041     if (!beam) {
0042       return NULL;
0043     }  // if
0044     const int species = beam->Id().Code();
0045     // Get the final state particles and search them for
0046     // the scattered lepton.
0047     std::vector<const VirtualParticle*> final;
0048     FinalState(final);
0049     std::vector<const VirtualParticle*>::const_iterator iter;
0050     for (iter = final.begin(); iter != final.end(); ++iter) {
0051       // We already know the particle is final state, so
0052       // check its species and parent index.
0053       if ( (*iter)->Id().Code() == species && 
0054        ( (*iter)->GetParentIndex() == 1 || (*iter)->GetParentIndex() == 2 )
0055        ) {
0056     // Found it, cast to required particle type and return.
0057     return static_cast<const ParticleMC*>(*iter);
0058       }  // if
0059     }  // for
0060     // No luck, couldn't find the scattered lepton.
0061     return nullptr;
0062   }
0063 
0064 
0065   // Look for the exchange boson in the event record.
0066   // It would probably be the third track, but we'll go with the first status=21 boson
0067   //    that has particle 1 or 2 as parent
0068   const ParticleMC* EventRapgap::ExchangeBoson() const {
0069     for ( auto particle : EventMC::GetTracks() ){
0070       if ( particle->GetStatus() != 21 ) continue;
0071       if ( particle->GetParentIndex() != 1 &&  particle->GetParentIndex() == 2 ) continue;
0072       if ( particle->Id().Code() == 22 ||  particle->Id().Code() == 23 ||  std::abs(particle->Id().Code()) == 24 ){
0073     // Found it, cast to required particle type and return.
0074     return static_cast<const ParticleMC*>(particle);
0075       }
0076     }  // for
0077     // No luck, couldn't find the exchange boson.
0078     return nullptr;
0079   }
0080 
0081 }  // namespace erhic