Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-06-26 07:05:37

0001 /**
0002  \file
0003  Implementation of class Smear::EventSmear.
0004  
0005  \author    Michael Savastio
0006  \date      2011-10-10
0007  \copyright 2011 Brookhaven National Lab
0008  */
0009 
0010 #include "eicsmear/smear/EventSmear.h"
0011 
0012 #include <iostream>
0013 #include <vector>
0014 
0015 namespace Smear {
0016 
0017 Event::Event()
0018 : nTracks(0)
0019 , mScatteredIndex(-1) {
0020 }
0021 
0022 Event::~Event() {
0023   ClearParticles();
0024 }
0025 
0026 void Event::ClearParticles() {
0027   for (unsigned i(0); i < particles.size(); ++i) {
0028     if (GetTrack(i)) {
0029       delete GetTrack(i);
0030     }  // if
0031   }  // for
0032 }
0033 
0034 void Event::Reset() {
0035   ClearParticles();
0036   *this = Event();
0037 }
0038 
0039 void Event::AddLast(ParticleMCS* track) {
0040   particles.push_back(track);
0041 }
0042 
0043 // The scattered lepton should be the first non-NULL entry in the track list
0044 const ParticleMCS* Event::ScatteredLepton() const {
0045   if (mScatteredIndex > -1 &&
0046       mScatteredIndex < static_cast<int>(GetNTracks())) {
0047     return GetTrack(mScatteredIndex);
0048   }  // if
0049   return NULL;
0050 }
0051 
0052 // Get the particles that belong to the hadronic final state.
0053 // (i.e. including leptons and bosons except for the scattered lepton).
0054 // The stored Particle* are pointers to the original particles in the event
0055 // so don't delete them!
0056 void Event::HadronicFinalState(ParticlePtrList& final) const {
0057   // Skip the first two entries, as these are the incident beams
0058   for (unsigned i(2); i < GetNTracks(); ++i) {
0059     if (!GetTrack(i)) {
0060       continue;
0061     }  // if
0062     if (GetTrack(i) != ScatteredLepton()) {
0063       final.push_back(GetTrack(i));
0064     }  // if
0065   }  // for
0066 }
0067 
0068 std::vector<const erhic::VirtualParticle*> Event::GetTracks() const {
0069   std::vector<const erhic::VirtualParticle*> tracks;
0070   for (unsigned i(0); i < GetNTracks(); ++i) {
0071     tracks.push_back(GetTrack(i));
0072   }  // for
0073   return tracks;
0074 }
0075 
0076 void Event::SetScattered(int index) {
0077   if (index >= 0) {
0078     mScatteredIndex = index;
0079   }  // if
0080 }
0081 void Event::Print(Option_t* /* unused */) const {
0082   std::cout <<
0083   "x:  " << GetX() << std::endl <<
0084   "Q2: " << GetQ2() << std::endl <<
0085   "y:  " << GetY() << std::endl;
0086   for (unsigned i(0); i < GetNTracks(); ++i) {
0087     if (GetTrack(i)) {
0088       GetTrack(i)->Print();
0089     }  // if
0090   }  // for
0091 }
0092 
0093 }  // namespace Smear