StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StProtoJet.cxx
1 // $Id: StProtoJet.cxx,v 1.15 2016/01/06 22:00:17 gdwebb Exp $
2 
3 #include "StProtoJet.h"
4 
5 using namespace std;
6 
7 StProtoJet::StProtoJet()
8  : mPx(0), mPy(0), mPz(0), mE(0)
9  , mArea(-1.)
10  , mAreaError(-1.)
11  , _charge(0)
12 {
13 
14 }
15 
16 StProtoJet::StProtoJet(const AbstractFourVec* particle)
17  : mPx(particle->px()), mPy(particle->py()), mPz(particle->pz()), mE(particle->e())
18  , mArea(-1.), mAreaError(-1.)
19  , _charge(particle->charge())
20 {
21  _particleList.push_back(particle);
22 }
23 
24 StProtoJet::~StProtoJet()
25 {
26 }
27 
28 void StProtoJet::update()
29 {
30  mPx = mPy = mPz = mE = _charge = 0.;
31  // add 4-momenta
32  for (FourVecList::const_iterator particle = _particleList.begin(); particle != _particleList.end(); ++particle) {
33  mPx += (*particle)->px();
34  mPy += (*particle)->py();
35  mPz += (*particle)->pz();
36  mE += (*particle)->e();
37  _charge += (*particle)->charge();
38  }
39 }
40 
41 void StProtoJet::add(const StProtoJet& protoJet)
42 {
43  mPx += protoJet.mPx;
44  mPy += protoJet.mPy;
45  mPz += protoJet.mPz;
46  mE += protoJet.mE;
47  _charge += protoJet._charge;
48  for (FourVecList::const_iterator particle = protoJet._particleList.begin(); particle != protoJet._particleList.end(); ++particle) {
49  _particleList.push_back(*particle);
50  }
51 }
52 
53 void StProtoJet::add(const AbstractFourVec& particle)
54 {
55  mPx += particle.px();
56  mPy += particle.py();
57  mPz += particle.pz();
58  mE += particle.e();
59  _charge += particle.charge();
60 }
61 
62 void StProtoJet::merge(const StProtoJet& protoJet)
63 {
64  for (FourVecList::const_iterator particle = protoJet._particleList.begin(); particle != protoJet._particleList.end(); ++particle) {
65  _particleList.push_back(*particle);
66  mPx += (*particle)->px();
67  mPy += (*particle)->py();
68  mPz += (*particle)->pz();
69  mE += (*particle)->e();
70  _charge += (*particle)->charge();
71  }
72 }
73 
74 void StProtoJet::clear()
75 {
76  _particleList.clear();
77  mPx = mPy = mPz = mE = _charge = 0;
78 }