StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjJetListReader.cxx
1 // $Id: StjJetListReader.cxx,v 1.1 2008/09/15 05:50:04 tai Exp $
2 // Copyright (C) 2008 Tai Sakuma <sakuma@bnl.gov>
3 #include "StjJetListReader.h"
4 
5 #include <TTree.h>
6 
7 #include <map>
8 #include <iostream>
9 
10 ClassImp(StjJetListReader)
11 
12 using namespace std;
13 
14 void StjJetListReader::SetBranchAddress(TTree *jettree, TTree *fourtree)
15 {
16  jettree->SetBranchAddress("eventId" , &_jet_eventId );
17  jettree->SetBranchAddress("nJets" , &_jet_nJets );
18  jettree->SetBranchAddress("jetId" , _jet_jetId );
19  jettree->SetBranchAddress("pt" , _jet_pt );
20  jettree->SetBranchAddress("eta" , _jet_eta );
21  jettree->SetBranchAddress("detectorEta", _jet_detectorEta );
22  jettree->SetBranchAddress("phi" , _jet_phi );
23  jettree->SetBranchAddress("m" , _jet_m );
24  jettree->SetBranchAddress("neuRt" , _jet_neuRt );
25  jettree->SetBranchAddress("vertexZ" , &_jet_vertexZ );
26  jettree->SetBranchAddress("runNumber" , &_jet_runNumber );
27 
28  fourtree->SetBranchAddress("eventId" , &_four_eventId );
29  fourtree->SetBranchAddress("nFourVecs" , &_four_nFourVecs );
30  fourtree->SetBranchAddress("jetId" , _four_jetId );
31  fourtree->SetBranchAddress("pt" , _four_pt );
32  fourtree->SetBranchAddress("eta" , _four_eta );
33  fourtree->SetBranchAddress("phi" , _four_phi );
34  fourtree->SetBranchAddress("towerId" , _four_towerId );
35  fourtree->SetBranchAddress("trackId" , _four_trackId );
36  fourtree->SetBranchAddress("mcparticleId", _four_mcparticleId );
37  fourtree->SetBranchAddress("m" , _four_m );
38  fourtree->SetBranchAddress("type" , _four_type );
39  fourtree->SetBranchAddress("detectorId" , _four_detectorId );
40  fourtree->SetBranchAddress("fourvecId" , _four_fourvecId );
41  fourtree->SetBranchAddress("runNumber" , &_four_runNumber );
42  fourtree->SetBranchAddress("vertexZ" , &_four_vertexZ );
43 }
44 
45 void StjJetListReader::clearEntry()
46 {
47  _list.clear();
48 }
49 
50 void StjJetListReader::readEntry()
51 {
52  clearEntry();
53  for(int i = 0; i < _jet_nJets; ++i) {
54  StjJet jet;
55  jet.runNumber = _jet_runNumber;
56  jet.eventId = _jet_eventId;
57  jet.jetId = _jet_jetId[i];
58  jet.pt = _jet_pt[i];
59  jet.eta = _jet_eta[i];
60  jet.phi = _jet_phi[i];
61  jet.m = _jet_m[i];
62  jet.neuRt = _jet_neuRt[i];
63  jet.vertexZ = _jet_vertexZ;
64  jet.detectorEta = _jet_detectorEta[i];
65 
66  for(int j = 0; j < _four_nFourVecs; ++j) {
67  if(_four_jetId[j] != jet.jetId) continue;
68  StjFourVec four;
69  four.runNumber = _four_runNumber;
70  four.eventId = _four_eventId;
71  four.vertexZ = _four_vertexZ;
72  four.fourvecId = _four_fourvecId[j];
73  four.type = _four_type[j];
74  four.detectorId = _four_detectorId[j];
75  four.trackId = _four_trackId[j];
76  four.towerId = _four_towerId[j];
77  four.mcparticleId = _four_mcparticleId[j];
78  four.pt = _four_pt[j];
79  four.eta = _four_eta[j];
80  four.phi = _four_phi[j];
81  four.m = _four_m[j];
82  jet.fourVecList.push_back(four);
83  }
84  _list.push_back(jet);
85  }
86 }