Changed arrays
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALJetFinderOutput.cxx
CommitLineData
f7d5860b 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
ee6b678f 16/* $Id$ */
f7d5860b 17
18//_________________________________________________________________________
19// Output object for jetfinder
20//
21//*-- Author: Renan Cabrera (LBL)
22// Mark Horner (LBL/UCT)
23//
24
25
26
27#include <stdio.h>
28#include <TClonesArray.h>
29#include <TParticle.h>
30#include <TTree.h>
31
32//.....................
33#include "AliEMCALJet.h"
34#include "AliEMCALParton.h"
35#include "AliEMCALJetFinderOutput.h"
36#include "AliEMCALJetFinderInput.h"
37
38ClassImp(AliEMCALJetFinderOutput)
39
40//________________________________________________________________________
41AliEMCALJetFinderOutput::AliEMCALJetFinderOutput()
42{
43if (fDebug>0) Info("AliEMCALJetFinderOutput","Beginning Constructor");
44
45 fNMaxJets=10;
46 fNMaxParticles=2000;
47 fNMaxPartons=4;
48 fInitialised = kFALSE;
49 InitArrays();
50}
51void AliEMCALJetFinderOutput::InitArrays()
52{
53
54if (fDebug>1) Info("AliEMCALJetFinderOutput","Beginning InitArrays");
55
56 fJetsArray = new TClonesArray("AliEMCALJet",fNMaxJets);
57 fNJets = 0;
58 fPartonsArray = new TClonesArray("AliEMCALParton",fNMaxPartons);
59 fNPartons = 0;
60 fParticlesArray = new TClonesArray("TParticle",fNMaxParticles);
61 fNParticles =0;
62 fInitialised = kTRUE;
63
64}
65
66//_______________________________________________________________________
67AliEMCALJetFinderOutput::~AliEMCALJetFinderOutput()
68{
69if (fDebug>0) Info("~AliEMCALJetFinderOutput","Beginning Destructor");
70if (fInitialised)
71{
72 fJetsArray->Delete();
73 fPartonsArray->Delete();
74 fParticlesArray->Delete();
75
76 delete fJetsArray;
77 delete fPartonsArray;
78 delete fParticlesArray;
79}
80}
81
82//_______________________________________________________________________
83void AliEMCALJetFinderOutput::Reset(AliEMCALJetFinderResetType_t resettype)
84{
85if (fDebug>1) Info("Reset","Beginning Reset");
86if (!fInitialised) InitArrays();
87 if ( resettype == kResetAll ||
88 resettype == kResetJets||
89 resettype == kResetData ){
90 fJetsArray->Delete();
91 fNJets = 0;
92 }
93 if ( resettype == kResetAll ||
94 resettype == kResetPartons||
95 resettype == kResetData ){
96 fPartonsArray->Delete();
97 fNPartons = 0;
98 }
99 if ( resettype == kResetAll ||
100 resettype == kResetParticles||
101 resettype == kResetData ){
102 fParticlesArray->Delete();
103 fNParticles = 0;
104 }
105}
106//________________________________________________________________________
107void AliEMCALJetFinderOutput::AddJet(AliEMCALJet* jet)
108{
109if (fDebug>1) Info("AddJet","Beginning AddJet");
110if (!fInitialised) InitArrays();
111
112 if (fNJets < fNMaxJets){
113 new( (*fJetsArray)[fNJets] ) AliEMCALJet( *jet );
114 fNJets++;
115 }else
116 {
117 Error("AddJet","Cannot AddJet - maximum exceeded");
118 }
119}
120
121
122//_______________________________________________________________________
123void AliEMCALJetFinderOutput::AddParton(AliEMCALParton* parton)
124{
125if (fDebug>1) Info("AddParton","Beginning AddParton");
126if (!fInitialised) InitArrays();
127
128 if (fNPartons < fNMaxPartons){
129 new( (*fPartonsArray)[fNPartons] ) AliEMCALParton( *parton );
130 fNPartons++;
131 }else
132 {
133 Error("AddParton","Cannot AddParton - maximum exceeded");
134 }
135
136}
137
138//_______________________________________________________________________
139void AliEMCALJetFinderOutput::AddParticle(TParticle* particle)
140{
141if (fDebug>1) Info("AddParticle","Beginning AddParticle");
142if (!fInitialised) InitArrays();
143
144 if (fNParticles < fNMaxParticles){
145 new( (*fParticlesArray)[fNParticles] ) TParticle( *particle );
146 fNParticles++;
147 }else
148 {
149 Error("AddParticle","Cannot AddParticle - maximum exceeded");
150 }
151
152}
153
154//______________________________________________________________________
155AliEMCALJet* AliEMCALJetFinderOutput::GetJet(Int_t jetID)
156{
157if (fDebug>1) Info("GetJet","Beginning GetJet");
158
159 if (jetID >= fNJets) return 0;
160 return (AliEMCALJet*)((*fJetsArray)[jetID]);
161
162
163}
164
165//______________________________________________________________________
166AliEMCALParton* AliEMCALJetFinderOutput::GetParton(Int_t partonID)
167{
168if (fDebug>1) Info("GetParton","Beginning GetParton");
169
170 if (partonID >= fNPartons) return 0;
171 return (AliEMCALParton*)((*fPartonsArray)[partonID]);
172
173
174}
175
176//______________________________________________________________________
177TParticle* AliEMCALJetFinderOutput::GetParticle(Int_t particleID)
178{
179if (fDebug>1) Info("GetParticle","Beginning GetParticle");
180
181 if (particleID >= fNParticles) return 0;
182 return (TParticle*)((*fParticlesArray)[particleID]);
183
184
185}
186