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::EventSartre. 
0003  \author    Barak Schmookler
0004  \date      2020-04-08
0005  */
0006 
0007 #include "eicsmear/erhic/EventSartre.h"
0008 
0009 #include <cmath>
0010 #include <sstream>
0011 #include <string>
0012 
0013 namespace erhic {
0014 
0015 EventSartre::EventSartre()
0016 : genevent(-1)
0017 , trueT(NAN)
0018 , trueQ2(NAN)
0019 , trueX(NAN)
0020 , trueY(NAN)
0021 , trueW2(NAN)
0022 , trueNu(NAN)
0023 , trueXpom(NAN)
0024 , s_cm(NAN)
0025 , pol(-1)
0026 , dmode(-1)
0027 , bup(-1){
0028 }
0029 
0030 bool EventSartre::Parse(const std::string& line) {
0031   static std::stringstream ss;
0032   ss.str("");
0033   ss.clear();
0034   ss << line;
0035   ss >>
0036   number >> number >>  // Skip first int in the line
0037   genevent >>
0038   trueT >> trueQ2 >> trueX >> trueY >> trueW2 >> trueNu >>
0039   trueXpom >> s_cm >> pol >> dmode >> bup;
0040   // Protect against errors in the input file or the stream
0041   return !ss.fail();
0042 }
0043 
0044   // Look for the scattered lepton in the event record.
0045   // This is the first (only?) particle that matches the following:
0046   //  1) pdg code equals that of incident lepton beam.
0047   //  2) status code is 1 i.e. it's a stable/final-state particle.
0048   //  3) the parent is track 1 or 2
0049   const ParticleMC* EventSartre::ScatteredLepton() const {
0050     // Look for the lepton beam to get the species.
0051     // If we don't get it we can't find the scattered
0052     // lepton so return NULL.
0053     const VirtualParticle* beam = BeamLepton();
0054     if (!beam) {
0055       return NULL;
0056     }  // if
0057     const int species = beam->Id().Code();
0058     // Get the final state particles and search them for
0059     // the scattered lepton.
0060     std::vector<const VirtualParticle*> final;
0061     FinalState(final);
0062     std::vector<const VirtualParticle*>::const_iterator iter;
0063     for (iter = final.begin(); iter != final.end(); ++iter) {
0064       // We already know the particle is final state, so
0065       // check its species and parent index.
0066       if ( (*iter)->Id().Code() == species && 
0067        ( (*iter)->GetParentIndex() == 1 || (*iter)->GetParentIndex() == 2 )
0068        ) {
0069     // Found it, cast to required particle type and return.
0070     return static_cast<const ParticleMC*>(*iter);
0071       }  // if
0072     }  // for
0073     // No luck, couldn't find the scattered lepton.
0074     return nullptr;
0075   }
0076 
0077 
0078   // Look for the exchange boson in the event record.
0079   // It would probably be the third track, but we'll go with the first status=21 boson
0080   //    that has particle 1 or 2 as parent
0081   const ParticleMC* EventSartre::ExchangeBoson() const {
0082     for ( auto particle : EventMC::GetTracks() ){
0083       if ( particle->GetStatus() != 21 ) continue;
0084       if ( particle->GetParentIndex() != 1 &&  particle->GetParentIndex() == 2 ) continue;
0085       if ( particle->Id().Code() == 22 ||  particle->Id().Code() == 23 ||  std::abs(particle->Id().Code()) == 24 ){
0086     // Found it, cast to required particle type and return.
0087     return static_cast<const ParticleMC*>(particle);
0088       }
0089     }  // for
0090     // No luck, couldn't find the exchange boson.
0091     return nullptr;
0092   }
0093 
0094 }  // namespace erhic
0095 
0096 
0097