StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjMCParticleListReader.cxx
1 // $Id: StjMCParticleListReader.cxx,v 1.2 2008/08/22 18:36:32 tai Exp $
2 #include "StjMCParticleListReader.h"
3 
4 #include <TTree.h>
5 
6 #include <iostream>
7 
9 
10 using namespace std;
11 
12 void StjMCParticleListReader::SetBranchAddress(TTree *tree)
13 {
14  tree->SetBranchAddress("eventId" , &_eventId );
15  tree->SetBranchAddress("nMCParticles" , &_nMCParticles );
16  tree->SetBranchAddress("mcparticleId" , _mcparticleId );
17  tree->SetBranchAddress("status" , _status );
18  tree->SetBranchAddress("pdg" , _pdg );
19  tree->SetBranchAddress("pt" , _pt );
20  tree->SetBranchAddress("eta" , _eta );
21  tree->SetBranchAddress("phi" , _phi );
22  tree->SetBranchAddress("m" , _m );
23  tree->SetBranchAddress("e" , _e );
24  tree->SetBranchAddress("firstMotherId" , _firstMotherId );
25  tree->SetBranchAddress("lastMotherId" , _lastMotherId );
26  tree->SetBranchAddress("firstDaughterId" , _firstDaughterId );
27  tree->SetBranchAddress("lastDaughterId" , _lastDaughterId );
28  tree->SetBranchAddress("vertexZ" , &_vertexZ );
29  tree->SetBranchAddress("runNumber" , &_runNumber );
30 }
31 
32 void StjMCParticleListReader::clearEntry()
33 {
34  _list.clear();
35 }
36 
37 void StjMCParticleListReader::readEntry()
38 {
39  clearEntry();
40 
41  for(int i = 0; i < _nMCParticles; ++i) {
42 
43  StjMCParticle mcparticle;
44 
45  mcparticle.runNumber = _runNumber;
46  mcparticle.eventId = _eventId;
47  mcparticle.mcparticleId = _mcparticleId[i];
48  mcparticle.pdg = _pdg[i];
49  mcparticle.firstMotherId = _firstMotherId[i];
50  mcparticle.lastMotherId = _lastMotherId[i];
51  mcparticle.firstDaughterId = _firstDaughterId[i];
52  mcparticle.lastDaughterId = _lastDaughterId[i];
53  mcparticle.pt = _pt[i];
54  mcparticle.eta = _eta[i];
55  mcparticle.phi = _phi[i];
56  mcparticle.m = _m[i];
57  mcparticle.e = _e[i];
58  mcparticle.status = _status[i];
59  mcparticle.vertexZ = _vertexZ;
60 
61  _list.push_back(mcparticle);
62  }
63 }