StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StUeEvent.cxx
1 // -*- mode: c++ -*-
2 
3 //
4 // Grant Webb <gdwebb@bnl.gov>
5 // Brookhaven National Laboratory
6 // 30 July 2015
7 //
8 #include "TClonesArray.h"
9 #include "TVector3.h"
10 #include "TLorentzVector.h"
11 #include "StJetEventTypes.h"
12 
13 ClassImp(StUeEvent);
14 
15 StUeEvent::StUeEvent()
16  : mRunId(0)
17  , mEventId(0)
18  , mVertices(new TClonesArray("StJetVertex",10))
19  , mTracks(new TClonesArray("StJetTrack",50))
20  , mTowers(new TClonesArray("StJetTower",50))
21  , mParticles(new TClonesArray("StJetParticle",50))
22 {
23 }
24 
25 StUeEvent::~StUeEvent()
26 {
27  mVertices->Delete(); delete mVertices; mVertices = 0;
28  mTracks->Delete(); delete mTracks; mTracks = 0;
29  mTowers->Delete(); delete mTowers; mTowers = 0;
30  mParticles->Delete(); delete mParticles; mParticles = 0;
31 }
32 void StUeEvent::Clear(Option_t* option)
33 {
34  mVertices->Clear(option);
35  mTracks->Clear(option);
36  mTowers->Clear(option);
37  mParticles->Clear(option);
38 }
39 
40 int StUeEvent::numberOfVertices () const { return mVertices->GetEntriesFast(); }
41 int StUeEvent::numberOfTracks () const { return mTracks->GetEntriesFast(); }
42 int StUeEvent::numberOfTowers () const { return mTowers->GetEntriesFast(); }
43 int StUeEvent::numberOfParticles() const { return mParticles->GetEntriesFast(); }
44 
45 StJetVertex* StUeEvent::vertex (int i) const { return (StJetVertex*)mVertices->At(i); }
46 StJetTrack* StUeEvent::track (int i) const { return (StJetTrack*)mTracks->At(i); }
47 StJetTower* StUeEvent::tower (int i) const { return (StJetTower*)mTowers->At(i); }
48 StJetParticle* StUeEvent::particle(int i) const { return (StJetParticle*)mParticles->At(i); }
49 
50 StJetVertex* StUeEvent::newVertex() { return new ((*mVertices)[mVertices->GetEntriesFast()]) StJetVertex; }
51 StJetTrack* StUeEvent::newTrack() { return new ((*mTracks)[mTracks->GetEntriesFast()]) StJetTrack; }
52 StJetTower* StUeEvent::newTower() { return new ((*mTowers)[mTowers->GetEntriesFast()]) StJetTower; }
53 StJetParticle* StUeEvent::newParticle() { return new ((*mParticles)[mParticles->GetEntriesFast()]) StJetParticle; }
54 
55 float StUeEvent::sumTrackPt() const
56 {
57  float s = 0;
58  for (int i = 0; i < numberOfTracks(); ++i) s += track(i)->pt();
59  return s;
60 }
61 
62 float StUeEvent::sumTowerPt() const
63 {
64  float s = 0;
65  for (int i = 0; i < numberOfTowers(); ++i) s += tower(i)->pt();
66  return s;
67 }
68 
69 float StUeEvent::sumParticlePt() const
70 {
71  float s = 0;
72  for (int i = 0; i < numberOfParticles(); ++i) s += particle(i)->pt();
73  return s;
74 }