Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-16 09:02:06

0001 /**
0002  \file Declaration of smearing claases for hadronic events.
0003  
0004  \author    Thomas Burton
0005  \date      2012-05-03
0006  \copyright 2012 Brookhaven National Lab
0007  */
0008 
0009 #ifndef INCLUDE_EICSMEAR_HADRONIC_EVENTSMEAR_H_
0010 #define INCLUDE_EICSMEAR_HADRONIC_EVENTSMEAR_H_
0011 
0012 #include <vector>
0013 
0014 #include <Rtypes.h>  // For ClassDef macro
0015 #include <TBranch.h>
0016 
0017 #include "eicsmear/erhic/VirtualEvent.h"
0018 #include "eicsmear/hadronic/EventMC.h"
0019 #include "eicsmear/smear/EventFactory.h"
0020 #include "eicsmear/smear/ParticleMCS.h"
0021 
0022 namespace erhic {
0023 namespace hadronic {
0024 
0025 /**
0026  Realisation of hadronic::EventMC as an event with detector smearing.
0027  */
0028 class EventSmear : public VirtualEvent {
0029  public:
0030   /**
0031    Destructor.
0032    */
0033   virtual ~EventSmear();
0034 
0035   /**
0036    Constructor.
0037    */
0038   EventSmear();
0039 
0040   /**
0041    Returns the numbered track for the event.
0042    */
0043   virtual const Smear::ParticleMCS* GetTrack(UInt_t) const;
0044 
0045   /**
0046    \overload
0047    */
0048   virtual Smear::ParticleMCS* GetTrack(UInt_t);
0049 
0050   /**
0051    Returns the number of tracks in the event.
0052    */
0053   virtual UInt_t GetNTracks() const;
0054 
0055   /**
0056    Add a particle to the end of the list.
0057    */
0058   virtual void AddLast(Smear::ParticleMCS*);
0059 
0060  protected:
0061   std::vector<Smear::ParticleMCS*> particles;
0062 
0063   ClassDef(erhic::hadronic::EventSmear, 1)
0064 };
0065 
0066 }  // namespace hadronic
0067 }  // namespace erhic
0068 
0069 namespace Smear {
0070 
0071 /**
0072  Factory class for smeared hadronic events.
0073  */
0074 class HadronicEventBuilder : public EventFactory<erhic::hadronic::EventSmear> {
0075  public:
0076   /**
0077    Destructor.
0078    */
0079   virtual ~HadronicEventBuilder() { }
0080 
0081   /**
0082    Constructor.
0083    Initialise with the Detector performing particle smearing and
0084    the tree branch providing DIS Monte Carlo events.
0085    */
0086   HadronicEventBuilder(const Detector& d, TBranch& mcBranch)
0087   : mDetector(d)
0088   , mMcEvent(NULL) {
0089     mcBranch.SetAddress(&mMcEvent);
0090   }
0091 
0092   /**
0093    Create a smeared event corresponding to the current DIS Monte Carlo
0094    event in the input branch passed to the constructor.
0095    The user should call TTree::GetEntry() themselves between calls to
0096    Create().
0097    */
0098   virtual EventType* Create() {
0099     EventType* event = new EventType;
0100     for (unsigned j(0); j < mMcEvent->GetNTracks(); j++) {
0101       const erhic::VirtualParticle* ptr = mMcEvent->GetTrack(j);
0102       if (ptr) {
0103         event->AddLast(mDetector.Smear(*ptr));
0104       }  // if
0105     }  // for
0106     return event;
0107   }
0108 
0109  protected:
0110   Detector mDetector;
0111   erhic::hadronic::EventMC* mMcEvent;
0112 };
0113 
0114 }  // namespace Smear
0115 
0116 #endif  // INCLUDE_EICSMEAR_HADRONIC_EVENTSMEAR_H_