]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALJetFinderInput.cxx
Jet Finder - hard coded geom parameters removed
[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 "AliEMCALParton.h"
32 class TClonesArray;
33
34
35 ClassImp(AliEMCALJetFinderInput)
36
37 AliEMCALJetFinderInput::AliEMCALJetFinderInput()
38 {
39 // Default constructor
40 // Defines all TClonesArrays  
41 // Creates full array of Digits - all other arrays will have objects created as necessary 
42
43 if (fDebug>0) Info("AliEMCALJetFinderInput","Beginning Constructor");   
44
45 fInitialised = kFALSE;
46 fNDigits = 96*144;     // This is the number of digits
47 fNMaxDigits = fNDigits;
48 fNMaxTracks = 3000;
49 fNMaxParticles = 2000;
50 fNMaxPartons = 4;
51 fNTracks        = 0;
52 fNPartons       = 0;
53 fNParticles     = 0;
54
55 }
56
57 void AliEMCALJetFinderInput::InitArrays()
58 {
59 if (fDebug>0) Info("AliEMCALJetFinderInput","Beginning InitArrays");
60 fNDigits = 96*144;     // This is the number of digits
61 fNMaxDigits = fNDigits;
62 fNMaxTracks = 3000;
63 fNMaxParticles = 2000;
64 fNMaxPartons = 4;
65 for (Int_t i = 0; i < 96*144; i++)
66 {
67         AliEMCALDigit tempdigit(0,0,i+1,0,1.0,-1);
68         tempdigit.SetAmp(0);
69 //       AliEMCALDigit(0,0,i+1,0,1.0,-1)
70         new(&fDigitsArray[i]) AliEMCALDigit(tempdigit); // Default digit amplitude is zero
71 }
72 fNTracks        = 0;
73 fNPartons       = 0;
74 fNParticles     = 0;
75 fInitialised = kTRUE;
76 }
77
78
79 AliEMCALJetFinderInput::~AliEMCALJetFinderInput()
80 {
81 // Destructor -
82
83 if (fDebug>0) Info("~AliEMCALJetFinderInput","Beginning Destructor");   
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           for (Int_t i = 0; i < 96*144; i++)
98                   {
99                         AliEMCALDigit tempdigit(0,0,i+1,0,1.0,-1);
100                         tempdigit.SetAmp(0);
101                         new(&fDigitsArray[i]) AliEMCALDigit(tempdigit); // Default digit amplitude is zero
102                   }
103   }
104   if (  resettype == kResetData   ||    
105         resettype == kResetTracks ||
106         resettype == kResetAll   ){
107           fNTracks = 0;
108   }
109  if (  resettype == kResetData    ||
110        resettype == kResetPartons ||
111        resettype == kResetAll   ){
112          fNPartons=0;
113  }
114  if (  resettype == kResetData      ||
115        resettype == kResetParticles ||
116        resettype == kResetAll   ){
117          fNParticles = 0;
118  }
119
120 }
121 void AliEMCALJetFinderInput::AddEnergyToDigit(Int_t digitID,Int_t denergy)
122 {
123 // Adds energy to the digit specified - Note these are tower IDs and
124 // so start at 1!
125                 
126 if (fDebug>15) Info("AddEnergyToDigit","Beginning AddEnergyToDigit");
127  if (!fInitialised) InitArrays();       
128
129  Int_t amp = 0;
130  AliEMCALDigit *mydigit = &fDigitsArray[digitID];
131  amp = mydigit->GetAmp();
132  mydigit->SetAmp(amp+denergy);
133 }       
134
135 void AliEMCALJetFinderInput::AddTrack(TParticle track)
136 {
137 // Adds a TParticle to the track array
138                 
139 if (fDebug>5) Info("AddTrack","Beginning AddTrack");
140  
141         if (!fInitialised) InitArrays();        
142         if (fNTracks < fNMaxTracks){  
143                 new(&fTracksArray[fNTracks]) TParticle(track);
144                 fNTracks++;
145                 if (fDebug>5) Info("AddTracks","Added Tracks %i",fNTracks);     
146         }else
147         {
148                 Error("AddTracks","Cannot AddTrack - maximum exceeded");
149         }
150
151 }
152 void AliEMCALJetFinderInput::AddParton(AliEMCALParton *parton)
153 {
154 // Adds an AliEMCALParton to the parton array 
155         
156 if (fDebug>5) Info("AddParton","Beginning AddParton");
157
158         if (!fInitialised) InitArrays();        
159         if (fNPartons < fNMaxPartons){  
160                 new(&fPartonsArray[fNPartons]) AliEMCALParton(*parton);
161                 fNPartons++;
162                 if (fDebug>5) Info("AddParton","Added Parton %i",fNPartons);    
163         }else
164         {
165                 Error("AddParton","Cannot AddParton - maximum exceeded");
166         }
167 }
168
169 void AliEMCALJetFinderInput::AddParticle(TParticle *particle)
170 {
171 // Adds a TParticle to the particle array
172         
173 if (fDebug>5) Info("AddParticle","Beginning AddParticle");      
174
175         if (!fInitialised) InitArrays();        
176         if (fNParticles < fNMaxParticles){  
177                 new(&fParticlesArray[fNParticles]) TParticle(*particle);
178                 fNParticles++;
179                 if (fDebug>5) Info("AddParticle","Added Particle %i",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>15) 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>15) 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>15) 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>15) Info("GetParticle","Beginning GetParticle");
223
224     if (particleID >= fNParticles) return 0;
225     return (TParticle*)(&fParticlesArray[particleID]);
226 }
227
228
229