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