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::EventDisFactory.
0004  
0005  \author    Michael Savastio
0006  \date      2011-08-19
0007  \copyright 2011 Brookhaven National Lab
0008  */
0009 
0010 #include "eicsmear/smear/EventDisFactory.h"
0011 
0012 #include <vector>
0013 
0014 #include <TBranch.h>
0015 
0016 #include "eicsmear/erhic/EventDis.h"
0017 #include "eicsmear/erhic/ParticleIdentifier.h"
0018 #include "eicsmear/erhic/VirtualParticle.h"
0019 #include "eicsmear/smear/ParticleMCS.h"
0020 
0021 namespace {
0022 
0023 Smear::ParticleMCS* mcToSmear(const erhic::VirtualParticle& mc) {
0024   Smear::ParticleMCS* p = new Smear::ParticleMCS(mc.Get4Vector(),
0025                                                  mc.Id(), mc.GetStatus());
0026   p->SetStatus(mc.GetStatus());
0027   return p;
0028 }
0029 
0030 }  // anonymous namespace
0031 
0032 namespace Smear {
0033 
0034 EventDisFactory::~EventDisFactory() {
0035 }
0036 
0037 EventDisFactory::EventDisFactory(const Detector& d, TBranch& mcBranch)
0038 : mDetector(d)
0039 , mMcEvent(NULL) {
0040   mcBranch.SetAddress(&mMcEvent);
0041 }
0042 
0043 Event* EventDisFactory::Create() {
0044   Event* event = new Event;
0045   for (unsigned j(0); j < mMcEvent->GetNTracks(); j++) {
0046     const erhic::VirtualParticle* ptr = mMcEvent->GetTrack(j);
0047     if (!ptr) {
0048       continue;
0049     }  // if
0050     // If this is the scattered lepton, record the index.
0051     // Set the index even if the particle turns out to be outside the
0052     // acceptance (in which case it will just point to a NULL anyway).
0053     if (mMcEvent->ScatteredLepton() == ptr) {
0054       ParticleMCS* p = mDetector.Smear(*ptr);
0055       if (p) {
0056         p->SetStatus(ptr->GetStatus());
0057         event->SetScattered(j);
0058       }  // if
0059       event->AddLast(p);
0060       // Only set the index if the scattered electron is detected
0061     } else if (mMcEvent->BeamLepton() == ptr ||
0062            mMcEvent->BeamHadron() == ptr) {
0063       // It's convenient to keep the initial beams, unsmeared, in the
0064       // smeared event record, so copy their properties exactly
0065       event->AddLast(mcToSmear(*ptr));
0066     } else {
0067       ParticleMCS* p = mDetector.Smear(*ptr);
0068       if (p) {
0069         p->SetStatus(ptr->GetStatus());
0070       }  // if
0071       event->AddLast(p);
0072     }  // if
0073   }  // for
0074   // Fill the event-wise kinematic variables.
0075   mDetector.FillEventKinematics(event);
0076   return event;
0077 }
0078 
0079 }  // namespace Smear