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