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 **************************************************************************/
18 //________________________________________________________________________
19 // Initial JetFinder input object
21 //*-- Author: Mark Horner (LBL/UCT)
23 #include "AliEMCALJetFinderInput.h"
24 #include "AliEMCALDigit.h"
25 #include "AliEMCALParton.h"
26 #include "TClonesArray.h"
29 ClassImp(AliEMCALJetFinderInput)
31 AliEMCALJetFinderInput::AliEMCALJetFinderInput()
33 // Default constructor
34 // Defines all TClonesArrays
35 // Creates full array of Digits - all other arrays will have objects created as necessary
37 if (fDebug>0) Info("AliEMCALJetFinderInput","Beginning Constructor");
39 fInitialised = kFALSE;
43 void AliEMCALJetFinderInput::InitArrays()
45 if (fDebug>0) Info("AliEMCALJetFinderInput","Beginning InitArrays");
46 fNDigits = 96*144; // This is the number of digits
47 fNMaxDigits = fNDigits;
49 fNMaxParticles = 2000;
51 fDigitsArray = new TClonesArray ("AliEMCALDigit",fNDigits); // This is the digits array for the EMCAL
52 for (Int_t i = 0; i < 96*144; i++)
54 new((*fDigitsArray)[i]) AliEMCALDigit(0,0,i+1,0,1.0,-1);
55 ((AliEMCALDigit*)(*fDigitsArray)[i])->SetAmp(0); // Default digit amplitude is zero
57 fTracksArray = new TClonesArray("TParticle",fNMaxTracks);
59 fPartonsArray = new TClonesArray("AliEMCALParton",fNMaxPartons);
61 fParticlesArray = new TClonesArray ("TParticle",fNMaxParticles);
67 AliEMCALJetFinderInput::~AliEMCALJetFinderInput()
70 // Deletes all memory allocated in TClonesArrays
72 if (fDebug>0) Info("~AliEMCALJetFinderInput","Beginning Destructor");
75 fDigitsArray->Delete();
76 fTracksArray->Delete();
77 fPartonsArray->Delete();
78 fParticlesArray->Delete();
82 delete fParticlesArray;
86 void AliEMCALJetFinderInput::Reset(AliEMCALJetFinderResetType_t resettype)
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");
92 if (!fInitialised) InitArrays();
94 if ( resettype == kResetData ||
95 resettype == kResetDigits ||
96 resettype == kResetAll ){
97 fDigitsArray->Delete();
98 for (Int_t i = 0; i < 96*144; i++)
100 new((*fDigitsArray)[i]) AliEMCALDigit(0,0,i+1,0,1.0);
101 ((AliEMCALDigit*)(*fDigitsArray)[i])->SetAmp(0); // Default digit amplitude is zero
104 if ( resettype == kResetData ||
105 resettype == kResetTracks ||
106 resettype == kResetAll ){
107 fTracksArray->Delete();
110 if ( resettype == kResetData ||
111 resettype == kResetPartons ||
112 resettype == kResetAll ){
113 fPartonsArray->Delete();
116 if ( resettype == kResetData ||
117 resettype == kResetParticles ||
118 resettype == kResetAll ){
119 fParticlesArray->Delete();
124 void AliEMCALJetFinderInput::AddEnergyToDigit(Int_t digitID,Int_t denergy)
126 // Adds energy to the digit specified - Note these are tower IDs and
129 if (fDebug>5) Info("AddEnergyToDigit","Beginning AddEnergyToDigit");
130 if (!fInitialised) InitArrays();
133 AliEMCALDigit *mydigit = (AliEMCALDigit*)((*fDigitsArray)[digitID]);
134 amp = mydigit->GetAmp();
135 mydigit->SetAmp(amp+denergy);
138 void AliEMCALJetFinderInput::AddTrack(TParticle track)
140 // Adds a TParticle to the track array
142 if (fDebug>5) Info("AddTrack","Beginning AddTrack");
144 if (!fInitialised) InitArrays();
145 if (fNTracks < fNMaxTracks){
146 new((*fTracksArray)[fNTracks]) TParticle(track);
150 Error("AddTracks","Cannot AddTrack - maximum exceeded");
154 void AliEMCALJetFinderInput::AddParton(AliEMCALParton *parton)
156 // Adds an AliEMCALParton to the parton array
158 if (fDebug>5) Info("AddParton","Beginning AddParton");
160 if (!fInitialised) InitArrays();
161 if (fNPartons < fNMaxPartons){
162 new((*fPartonsArray)[fNPartons]) AliEMCALParton(*parton);
166 Error("AddParton","Cannot AddParton - maximum exceeded");
170 void AliEMCALJetFinderInput::AddParticle(TParticle *particle)
172 // Adds a TParticle to the particle array
174 if (fDebug>5) Info("AddParticle","Beginning AddParticle");
176 if (!fInitialised) InitArrays();
177 if (fNParticles < fNMaxParticles){
178 new((*fParticlesArray)[fNParticles]) TParticle(*particle);
182 Error("AddParticle","Cannot AddParticle - maximum exceeded");
188 AliEMCALDigit* AliEMCALJetFinderInput::GetDigit(Int_t digitID)
190 // Returns a pointer to an AliEMCALDigit with the given ID
192 if (fDebug>5) Info("GetDigit","Beginning GetDigit");
194 if (digitID >= fNDigits) return 0;
195 return (AliEMCALDigit*)((*fDigitsArray)[digitID]);
198 TParticle* AliEMCALJetFinderInput::GetTrack(Int_t trackID)
200 // Returns a pointer to a TParticle specified by the ID
202 if (fDebug>5) Info("GetTrack","Beginning GetTrack with trackID %i",trackID);
204 if (trackID >= fNTracks) return 0;
205 return (TParticle*)((*fTracksArray)[trackID]);
208 AliEMCALParton* AliEMCALJetFinderInput::GetParton(Int_t partonID)
210 // Returns a pointer to an AliEMCALParton specified by the ID
212 if (fDebug>5) Info("GetParton","Beginning GetParton");
214 if (partonID >= fNPartons) return 0;
215 return (AliEMCALParton*)((*fPartonsArray)[partonID]);
218 TParticle* AliEMCALJetFinderInput::GetParticle(Int_t particleID)
220 // Returns a pointer to a TParticle specified by the ID
222 if (fDebug>5) Info("GetParticle","Beginning GetParticle");
224 if (particleID >= fNParticles) return 0;
225 return (TParticle*)((*fParticlesArray)[particleID]);