1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 Revision 1.1.1.1 2003/05/29 18:56:35 horner
21 //________________________________________________________________________
22 // Initial JetFinder input object
24 //*-- Author: Mark Horner (LBL/UCT)
26 #include "AliEMCALJetFinderInput.h"
27 #include "AliEMCALDigit.h"
28 #include "AliEMCALParton.h"
29 #include "TClonesArray.h"
32 ClassImp(AliEMCALJetFinderInput)
34 AliEMCALJetFinderInput::AliEMCALJetFinderInput()
36 // Default constructor
37 // Defines all TClonesArrays
38 // Creates full array of Digits - all other arrays will have objects created as necessary
40 if (fDebug>0) Info("AliEMCALJetFinderInput","Beginning Constructor");
42 fInitialised = kFALSE;
46 void AliEMCALJetFinderInput::InitArrays()
48 if (fDebug>0) Info("AliEMCALJetFinderInput","Beginning InitArrays");
49 fNDigits = 96*144; // This is the number of digits
50 fNMaxDigits = fNDigits;
52 fNMaxParticles = 2000;
54 fDigitsArray = new TClonesArray ("AliEMCALDigit",fNDigits); // This is the digits array for the EMCAL
55 for (Int_t i = 0; i < 96*144; i++)
57 new((*fDigitsArray)[i]) AliEMCALDigit(0,0,i+1,0,1.0,-1);
58 ((AliEMCALDigit*)(*fDigitsArray)[i])->SetAmp(0); // Default digit amplitude is zero
60 fTracksArray = new TClonesArray("TParticle",fNMaxTracks);
62 fPartonsArray = new TClonesArray("AliEMCALParton",fNMaxPartons);
64 fParticlesArray = new TClonesArray ("TParticle",fNMaxParticles);
70 AliEMCALJetFinderInput::~AliEMCALJetFinderInput()
73 // Deletes all memory allocated in TClonesArrays
75 if (fDebug>0) Info("~AliEMCALJetFinderInput","Beginning Destructor");
78 fDigitsArray->Delete();
79 fTracksArray->Delete();
80 fPartonsArray->Delete();
81 fParticlesArray->Delete();
85 delete fParticlesArray;
89 void AliEMCALJetFinderInput::Reset(AliEMCALJetFinderResetType_t resettype)
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");
95 if (!fInitialised) InitArrays();
97 if ( resettype == kResetData ||
98 resettype == kResetDigits ||
99 resettype == kResetAll ){
100 fDigitsArray->Delete();
101 for (Int_t i = 0; i < 96*144; i++)
103 new((*fDigitsArray)[i]) AliEMCALDigit(0,0,i+1,0,1.0);
104 ((AliEMCALDigit*)(*fDigitsArray)[i])->SetAmp(0); // Default digit amplitude is zero
107 if ( resettype == kResetData ||
108 resettype == kResetTracks ||
109 resettype == kResetAll ){
110 fTracksArray->Delete();
113 if ( resettype == kResetData ||
114 resettype == kResetPartons ||
115 resettype == kResetAll ){
116 fPartonsArray->Delete();
119 if ( resettype == kResetData ||
120 resettype == kResetParticles ||
121 resettype == kResetAll ){
122 fParticlesArray->Delete();
127 void AliEMCALJetFinderInput::AddEnergyToDigit(Int_t digitID,Int_t denergy)
129 // Adds energy to the digit specified - Note these are tower IDs and
132 if (fDebug>5) Info("AddEnergyToDigit","Beginning AddEnergyToDigit");
133 if (!fInitialised) InitArrays();
136 AliEMCALDigit *mydigit = (AliEMCALDigit*)((*fDigitsArray)[digitID]);
137 amp = mydigit->GetAmp();
138 mydigit->SetAmp(amp+denergy);
141 void AliEMCALJetFinderInput::AddTrack(TParticle track)
143 // Adds a TParticle to the track array
145 if (fDebug>5) Info("AddTrack","Beginning AddTrack");
147 if (!fInitialised) InitArrays();
148 if (fNTracks < fNMaxTracks){
149 new((*fTracksArray)[fNTracks]) TParticle(track);
153 Error("AddTracks","Cannot AddTrack - maximum exceeded");
157 void AliEMCALJetFinderInput::AddParton(AliEMCALParton *parton)
159 // Adds an AliEMCALParton to the parton array
161 if (fDebug>5) Info("AddParton","Beginning AddParton");
163 if (!fInitialised) InitArrays();
164 if (fNPartons < fNMaxPartons){
165 new((*fPartonsArray)[fNPartons]) AliEMCALParton(*parton);
169 Error("AddParton","Cannot AddParton - maximum exceeded");
173 void AliEMCALJetFinderInput::AddParticle(TParticle *particle)
175 // Adds a TParticle to the particle array
177 if (fDebug>5) Info("AddParticle","Beginning AddParticle");
179 if (!fInitialised) InitArrays();
180 if (fNParticles < fNMaxParticles){
181 new((*fParticlesArray)[fNParticles]) TParticle(*particle);
185 Error("AddParticle","Cannot AddParticle - maximum exceeded");
191 AliEMCALDigit* AliEMCALJetFinderInput::GetDigit(Int_t digitID)
193 // Returns a pointer to an AliEMCALDigit with the given ID
195 if (fDebug>5) Info("GetDigit","Beginning GetDigit");
197 if (digitID >= fNDigits) return 0;
198 return (AliEMCALDigit*)((*fDigitsArray)[digitID]);
201 TParticle* AliEMCALJetFinderInput::GetTrack(Int_t trackID)
203 // Returns a pointer to a TParticle specified by the ID
205 if (fDebug>5) Info("GetTrack","Beginning GetTrack with trackID %i",trackID);
207 if (trackID >= fNTracks) return 0;
208 return (TParticle*)((*fTracksArray)[trackID]);
211 AliEMCALParton* AliEMCALJetFinderInput::GetParton(Int_t partonID)
213 // Returns a pointer to an AliEMCALParton specified by the ID
215 if (fDebug>5) Info("GetParton","Beginning GetParton");
217 if (partonID >= fNPartons) return 0;
218 return (AliEMCALParton*)((*fPartonsArray)[partonID]);
221 TParticle* AliEMCALJetFinderInput::GetParticle(Int_t particleID)
223 // Returns a pointer to a TParticle specified by the ID
225 if (fDebug>5) Info("GetParticle","Beginning GetParticle");
227 if (particleID >= fNParticles) return 0;
228 return (TParticle*)((*fParticlesArray)[particleID]);