Made more robust
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALJetFinderOutput.cxx
CommitLineData
f7d5860b 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
42460d75 16
ee6b678f 17/* $Id$ */
f7d5860b 18
19//_________________________________________________________________________
20// Output object for jetfinder
44f59d68 21// --
f7d5860b 22//*-- Author: Renan Cabrera (LBL)
23// Mark Horner (LBL/UCT)
44f59d68 24// --
f7d5860b 25
26
f7d5860b 27#include <stdio.h>
f7d5860b 28#include <TParticle.h>
29#include <TTree.h>
30
31//.....................
32#include "AliEMCALJet.h"
33#include "AliEMCALParton.h"
34#include "AliEMCALJetFinderOutput.h"
35#include "AliEMCALJetFinderInput.h"
36
37ClassImp(AliEMCALJetFinderOutput)
38
39//________________________________________________________________________
42460d75 40AliEMCALJetFinderOutput::AliEMCALJetFinderOutput(){
880c5eb1 41 // Default constructor
42
42460d75 43 fNMaxJets=10;
44 fNMaxParticles=2000;
45 fNMaxPartons=4;
46 fInitialised=kFALSE;
47 fNPartons=0;
48 fNJets=0;
49 fNParticles=0;
50
51
f7d5860b 52if (fDebug>0) Info("AliEMCALJetFinderOutput","Beginning Constructor");
53
42460d75 54} //________________________________________________________________________
f7d5860b 55void AliEMCALJetFinderOutput::InitArrays()
56{
880c5eb1 57 // Initialise arrays - legacy from TClones days
f7d5860b 58if (fDebug>1) Info("AliEMCALJetFinderOutput","Beginning InitArrays");
59
f7d5860b 60}
61
62//_______________________________________________________________________
63AliEMCALJetFinderOutput::~AliEMCALJetFinderOutput()
64{
880c5eb1 65 // Default destrucotr
f7d5860b 66if (fDebug>0) Info("~AliEMCALJetFinderOutput","Beginning Destructor");
f7d5860b 67}
68
69//_______________________________________________________________________
70void AliEMCALJetFinderOutput::Reset(AliEMCALJetFinderResetType_t resettype)
71{
880c5eb1 72// Reset stored data
73
f7d5860b 74if (fDebug>1) Info("Reset","Beginning Reset");
75if (!fInitialised) InitArrays();
76 if ( resettype == kResetAll ||
77 resettype == kResetJets||
78 resettype == kResetData ){
f7d5860b 79 fNJets = 0;
80 }
81 if ( resettype == kResetAll ||
82 resettype == kResetPartons||
83 resettype == kResetData ){
f7d5860b 84 fNPartons = 0;
85 }
86 if ( resettype == kResetAll ||
87 resettype == kResetParticles||
88 resettype == kResetData ){
f7d5860b 89 fNParticles = 0;
90 }
91}
92//________________________________________________________________________
93void AliEMCALJetFinderOutput::AddJet(AliEMCALJet* jet)
94{
880c5eb1 95// Add a jet to the array
96
f7d5860b 97if (fDebug>1) Info("AddJet","Beginning AddJet");
98if (!fInitialised) InitArrays();
99
42460d75 100
101 if (fNJets < fNMaxJets){
102 new( &fJetsArray[fNJets]) AliEMCALJet( *jet );
f7d5860b 103 fNJets++;
104 }else
105 {
106 Error("AddJet","Cannot AddJet - maximum exceeded");
42460d75 107 }
108
f7d5860b 109}
110
111
112//_______________________________________________________________________
113void AliEMCALJetFinderOutput::AddParton(AliEMCALParton* parton)
114{
880c5eb1 115//Add a parton to the array
116
f7d5860b 117if (fDebug>1) Info("AddParton","Beginning AddParton");
118if (!fInitialised) InitArrays();
119
120 if (fNPartons < fNMaxPartons){
42460d75 121 new( &fPartonsArray[fNPartons] ) AliEMCALParton( *parton );
f7d5860b 122 fNPartons++;
123 }else
124 {
125 Error("AddParton","Cannot AddParton - maximum exceeded");
126 }
42460d75 127
f7d5860b 128}
129
130//_______________________________________________________________________
131void AliEMCALJetFinderOutput::AddParticle(TParticle* particle)
132{
880c5eb1 133//Add a particle tot he array
134
f7d5860b 135if (fDebug>1) Info("AddParticle","Beginning AddParticle");
136if (!fInitialised) InitArrays();
137
138 if (fNParticles < fNMaxParticles){
42460d75 139 new( &fParticlesArray[fNParticles] ) TParticle( *particle );
f7d5860b 140 fNParticles++;
141 }else
142 {
143 Error("AddParticle","Cannot AddParticle - maximum exceeded");
42460d75 144 }
f7d5860b 145}
146
147//______________________________________________________________________
148AliEMCALJet* AliEMCALJetFinderOutput::GetJet(Int_t jetID)
149{
880c5eb1 150 // return a jet
f7d5860b 151if (fDebug>1) Info("GetJet","Beginning GetJet");
152
153 if (jetID >= fNJets) return 0;
42460d75 154 return &(fJetsArray[jetID]);
f7d5860b 155
f7d5860b 156}
157
158//______________________________________________________________________
159AliEMCALParton* AliEMCALJetFinderOutput::GetParton(Int_t partonID)
160{
880c5eb1 161 //return a parton
f7d5860b 162if (fDebug>1) Info("GetParton","Beginning GetParton");
163
164 if (partonID >= fNPartons) return 0;
42460d75 165 return &(fPartonsArray[partonID]);
f7d5860b 166}
167
168//______________________________________________________________________
169TParticle* AliEMCALJetFinderOutput::GetParticle(Int_t particleID)
170{
880c5eb1 171//return a particle
172
f7d5860b 173if (fDebug>1) Info("GetParticle","Beginning GetParticle");
174
175 if (particleID >= fNParticles) return 0;
42460d75 176return &(fParticlesArray[particleID]);
f7d5860b 177
178}
179