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