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