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