]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALJetFinderInput.cxx
G3 specific configuration removed.
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALJetFinderInput.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/* $Log$
17 Revision 1.1.1.1 2003/05/29 18:56:35 horner
18 Initial import - Mark
19*/
20
21//________________________________________________________________________
22// Initial JetFinder input object
23//
24//*-- Author: Mark Horner (LBL/UCT)
25
26#include "AliEMCALJetFinderInput.h"
27#include "AliEMCALDigit.h"
28#include "AliEMCALParton.h"
29#include "TClonesArray.h"
30
31
32ClassImp(AliEMCALJetFinderInput)
33
34AliEMCALJetFinderInput::AliEMCALJetFinderInput()
35{
36// Default constructor
37// Defines all TClonesArrays
38// Creates full array of Digits - all other arrays will have objects created as necessary
39
40if (fDebug>0) Info("AliEMCALJetFinderInput","Beginning Constructor");
41
42fInitialised = kFALSE;
43
44}
45
46void AliEMCALJetFinderInput::InitArrays()
47{
48if (fDebug>0) Info("AliEMCALJetFinderInput","Beginning InitArrays");
49fNDigits = 96*144; // This is the number of digits
50fNMaxDigits = fNDigits;
51fNMaxTracks = 3000;
52fNMaxParticles = 2000;
53fNMaxPartons = 4;
54fDigitsArray = new TClonesArray ("AliEMCALDigit",fNDigits); // This is the digits array for the EMCAL
55for (Int_t i = 0; i < 96*144; i++)
56{
57 new((*fDigitsArray)[i]) AliEMCALDigit(0,0,i+1,0,1.0,-1);
58 ((AliEMCALDigit*)(*fDigitsArray)[i])->SetAmp(0); // Default digit amplitude is zero
59}
60fTracksArray = new TClonesArray("TParticle",fNMaxTracks);
61fNTracks = 0;
62fPartonsArray = new TClonesArray("AliEMCALParton",fNMaxPartons);
63fNPartons = 0;
64fParticlesArray = new TClonesArray ("TParticle",fNMaxParticles);
65fNParticles = 0;
66fInitialised = kTRUE;
67}
68
69
70AliEMCALJetFinderInput::~AliEMCALJetFinderInput()
71{
72// Destructor -
73// Deletes all memory allocated in TClonesArrays
74
75if (fDebug>0) Info("~AliEMCALJetFinderInput","Beginning Destructor");
76if (fInitialised)
77{
78 fDigitsArray->Delete();
79 fTracksArray->Delete();
80 fPartonsArray->Delete();
81 fParticlesArray->Delete();
82 delete fDigitsArray;
83 delete fTracksArray;
84 delete fPartonsArray;
85 delete fParticlesArray;
86}
87}
88
89void AliEMCALJetFinderInput::Reset(AliEMCALJetFinderResetType_t resettype)
90{
91// Clears the contents of all the arrays and returns to the state we were in
92// after the constructor
93if (fDebug>1) Info("Reset","Beginning Reset");
94
95 if (!fInitialised) InitArrays();
96
97 if ( resettype == kResetData ||
98 resettype == kResetDigits ||
99 resettype == kResetAll ){
100 fDigitsArray->Delete();
101 for (Int_t i = 0; i < 96*144; i++)
102 {
103 new((*fDigitsArray)[i]) AliEMCALDigit(0,0,i+1,0,1.0);
104 ((AliEMCALDigit*)(*fDigitsArray)[i])->SetAmp(0); // Default digit amplitude is zero
105 }
106 }
107 if ( resettype == kResetData ||
108 resettype == kResetTracks ||
109 resettype == kResetAll ){
110 fTracksArray->Delete();
111 fNTracks = 0;
112 }
113 if ( resettype == kResetData ||
114 resettype == kResetPartons ||
115 resettype == kResetAll ){
116 fPartonsArray->Delete();
117 fNPartons=0;
118 }
119 if ( resettype == kResetData ||
120 resettype == kResetParticles ||
121 resettype == kResetAll ){
122 fParticlesArray->Delete();
123 fNParticles = 0;
124 }
125
126}
127void AliEMCALJetFinderInput::AddEnergyToDigit(Int_t digitID,Int_t denergy)
128{
129// Adds energy to the digit specified - Note these are tower IDs and
130// so start at 1!
131
132if (fDebug>5) Info("AddEnergyToDigit","Beginning AddEnergyToDigit");
133 if (!fInitialised) InitArrays();
134
135 Int_t amp = 0;
136 AliEMCALDigit *mydigit = (AliEMCALDigit*)((*fDigitsArray)[digitID]);
137 amp = mydigit->GetAmp();
138 mydigit->SetAmp(amp+denergy);
139}
140
141void AliEMCALJetFinderInput::AddTrack(TParticle track)
142{
143// Adds a TParticle to the track array
144
145if (fDebug>5) Info("AddTrack","Beginning AddTrack");
146
147 if (!fInitialised) InitArrays();
148 if (fNTracks < fNMaxTracks){
149 new((*fTracksArray)[fNTracks]) TParticle(track);
150 fNTracks++;
151 }else
152 {
153 Error("AddTracks","Cannot AddTrack - maximum exceeded");
154 }
155
156}
157void AliEMCALJetFinderInput::AddParton(AliEMCALParton *parton)
158{
159// Adds an AliEMCALParton to the parton array
160
161if (fDebug>5) Info("AddParton","Beginning AddParton");
162
163 if (!fInitialised) InitArrays();
164 if (fNPartons < fNMaxPartons){
165 new((*fPartonsArray)[fNPartons]) AliEMCALParton(*parton);
166 fNPartons++;
167 }else
168 {
169 Error("AddParton","Cannot AddParton - maximum exceeded");
170 }
171}
172
173void AliEMCALJetFinderInput::AddParticle(TParticle *particle)
174{
175// Adds a TParticle to the particle array
176
177if (fDebug>5) Info("AddParticle","Beginning AddParticle");
178
179 if (!fInitialised) InitArrays();
180 if (fNParticles < fNMaxParticles){
181 new((*fParticlesArray)[fNParticles]) TParticle(*particle);
182 fNParticles++;
183 }else
184 {
185 Error("AddParticle","Cannot AddParticle - maximum exceeded");
186 }
187
188}
189
190
191AliEMCALDigit* AliEMCALJetFinderInput::GetDigit(Int_t digitID)
192{
193// Returns a pointer to an AliEMCALDigit with the given ID
194
195if (fDebug>5) Info("GetDigit","Beginning GetDigit");
196
197 if (digitID >= fNDigits) return 0;
198 return (AliEMCALDigit*)((*fDigitsArray)[digitID]);
199}
200
201TParticle* AliEMCALJetFinderInput::GetTrack(Int_t trackID)
202{
203// Returns a pointer to a TParticle specified by the ID
204
205if (fDebug>5) Info("GetTrack","Beginning GetTrack with trackID %i",trackID);
206
207 if (trackID >= fNTracks) return 0;
208 return (TParticle*)((*fTracksArray)[trackID]);
209}
210
211AliEMCALParton* AliEMCALJetFinderInput::GetParton(Int_t partonID)
212{
213// Returns a pointer to an AliEMCALParton specified by the ID
214
215if (fDebug>5) Info("GetParton","Beginning GetParton");
216
217 if (partonID >= fNPartons) return 0;
218 return (AliEMCALParton*)((*fPartonsArray)[partonID]);
219}
220
221TParticle* AliEMCALJetFinderInput::GetParticle(Int_t particleID)
222{
223// Returns a pointer to a TParticle specified by the ID
224
225if (fDebug>5) Info("GetParticle","Beginning GetParticle");
226
227 if (particleID >= fNParticles) return 0;
228 return (TParticle*)((*fParticlesArray)[particleID]);
229}
230
231
232