Added the Jetfinder classes
[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
16/*
17
18$Log$
19Revision 1.1.1.1 2003/05/29 18:56:53 horner
20Initial import - Mark
21
22
23*/
24
25//_________________________________________________________________________
26// Output object for jetfinder
27//
28//*-- Author: Renan Cabrera (LBL)
29// Mark Horner (LBL/UCT)
30//
31
32
33
34#include <stdio.h>
35#include <TClonesArray.h>
36#include <TParticle.h>
37#include <TTree.h>
38
39//.....................
40#include "AliEMCALJet.h"
41#include "AliEMCALParton.h"
42#include "AliEMCALJetFinderOutput.h"
43#include "AliEMCALJetFinderInput.h"
44
45ClassImp(AliEMCALJetFinderOutput)
46
47//________________________________________________________________________
48AliEMCALJetFinderOutput::AliEMCALJetFinderOutput()
49{
50if (fDebug>0) Info("AliEMCALJetFinderOutput","Beginning Constructor");
51
52 fNMaxJets=10;
53 fNMaxParticles=2000;
54 fNMaxPartons=4;
55 fInitialised = kFALSE;
56 InitArrays();
57}
58void AliEMCALJetFinderOutput::InitArrays()
59{
60
61if (fDebug>1) Info("AliEMCALJetFinderOutput","Beginning InitArrays");
62
63 fJetsArray = new TClonesArray("AliEMCALJet",fNMaxJets);
64 fNJets = 0;
65 fPartonsArray = new TClonesArray("AliEMCALParton",fNMaxPartons);
66 fNPartons = 0;
67 fParticlesArray = new TClonesArray("TParticle",fNMaxParticles);
68 fNParticles =0;
69 fInitialised = kTRUE;
70
71}
72
73//_______________________________________________________________________
74AliEMCALJetFinderOutput::~AliEMCALJetFinderOutput()
75{
76if (fDebug>0) Info("~AliEMCALJetFinderOutput","Beginning Destructor");
77if (fInitialised)
78{
79 fJetsArray->Delete();
80 fPartonsArray->Delete();
81 fParticlesArray->Delete();
82
83 delete fJetsArray;
84 delete fPartonsArray;
85 delete fParticlesArray;
86}
87}
88
89//_______________________________________________________________________
90void AliEMCALJetFinderOutput::Reset(AliEMCALJetFinderResetType_t resettype)
91{
92if (fDebug>1) Info("Reset","Beginning Reset");
93if (!fInitialised) InitArrays();
94 if ( resettype == kResetAll ||
95 resettype == kResetJets||
96 resettype == kResetData ){
97 fJetsArray->Delete();
98 fNJets = 0;
99 }
100 if ( resettype == kResetAll ||
101 resettype == kResetPartons||
102 resettype == kResetData ){
103 fPartonsArray->Delete();
104 fNPartons = 0;
105 }
106 if ( resettype == kResetAll ||
107 resettype == kResetParticles||
108 resettype == kResetData ){
109 fParticlesArray->Delete();
110 fNParticles = 0;
111 }
112}
113//________________________________________________________________________
114void AliEMCALJetFinderOutput::AddJet(AliEMCALJet* jet)
115{
116if (fDebug>1) Info("AddJet","Beginning AddJet");
117if (!fInitialised) InitArrays();
118
119 if (fNJets < fNMaxJets){
120 new( (*fJetsArray)[fNJets] ) AliEMCALJet( *jet );
121 fNJets++;
122 }else
123 {
124 Error("AddJet","Cannot AddJet - maximum exceeded");
125 }
126}
127
128
129//_______________________________________________________________________
130void AliEMCALJetFinderOutput::AddParton(AliEMCALParton* parton)
131{
132if (fDebug>1) Info("AddParton","Beginning AddParton");
133if (!fInitialised) InitArrays();
134
135 if (fNPartons < fNMaxPartons){
136 new( (*fPartonsArray)[fNPartons] ) AliEMCALParton( *parton );
137 fNPartons++;
138 }else
139 {
140 Error("AddParton","Cannot AddParton - maximum exceeded");
141 }
142
143}
144
145//_______________________________________________________________________
146void AliEMCALJetFinderOutput::AddParticle(TParticle* particle)
147{
148if (fDebug>1) Info("AddParticle","Beginning AddParticle");
149if (!fInitialised) InitArrays();
150
151 if (fNParticles < fNMaxParticles){
152 new( (*fParticlesArray)[fNParticles] ) TParticle( *particle );
153 fNParticles++;
154 }else
155 {
156 Error("AddParticle","Cannot AddParticle - maximum exceeded");
157 }
158
159}
160
161//______________________________________________________________________
162AliEMCALJet* AliEMCALJetFinderOutput::GetJet(Int_t jetID)
163{
164if (fDebug>1) Info("GetJet","Beginning GetJet");
165
166 if (jetID >= fNJets) return 0;
167 return (AliEMCALJet*)((*fJetsArray)[jetID]);
168
169
170}
171
172//______________________________________________________________________
173AliEMCALParton* AliEMCALJetFinderOutput::GetParton(Int_t partonID)
174{
175if (fDebug>1) Info("GetParton","Beginning GetParton");
176
177 if (partonID >= fNPartons) return 0;
178 return (AliEMCALParton*)((*fPartonsArray)[partonID]);
179
180
181}
182
183//______________________________________________________________________
184TParticle* AliEMCALJetFinderOutput::GetParticle(Int_t particleID)
185{
186if (fDebug>1) Info("GetParticle","Beginning GetParticle");
187
188 if (particleID >= fNParticles) return 0;
189 return (TParticle*)((*fParticlesArray)[particleID]);
190
191
192}
193