]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG/EMCAL/AliEmcalContainer.cxx
Transition to new base class (Salvatore/Marta).
[u/mrichter/AliRoot.git] / PWG / EMCAL / AliEmcalContainer.cxx
CommitLineData
e58333e0 1//
2// Emcal Container Base class
3//
4// Author: M. Verweij
5
e58333e0 6
e58333e0 7#include <TClonesArray.h>
6421eeb0 8
e58333e0 9#include "AliEmcalJet.h"
10#include "AliVEvent.h"
11#include "AliLog.h"
ef46ebe5 12#include "AliNamedArrayI.h"
e58333e0 13
14#include "AliEmcalContainer.h"
15
16ClassImp(AliEmcalContainer)
17
18//________________________________________________________________________
19AliEmcalContainer::AliEmcalContainer():
20 TNamed("AliEmcalContainer","AliEmcalContainer"),
b6f970ad 21 fClArrayName(),
22 fClassName(),
ef46ebe5 23 fIsParticleLevel(kFALSE),
24 fClArray(0),
25 fCurrentID(0),
26 fLabelMap(0)
e58333e0 27{
28 // Default constructor.
29
6421eeb0 30 fVertex[0] = 0;
31 fVertex[1] = 0;
32 fVertex[2] = 0;
e58333e0 33}
34
35//________________________________________________________________________
36AliEmcalContainer::AliEmcalContainer(const char *name):
37 TNamed(name,name),
b6f970ad 38 fClArrayName(),
39 fClassName(),
ef46ebe5 40 fIsParticleLevel(kFALSE),
41 fClArray(0),
42 fCurrentID(0),
43 fLabelMap(0)
e58333e0 44{
45 // Standard constructor.
46
6421eeb0 47 fVertex[0] = 0;
48 fVertex[1] = 0;
49 fVertex[2] = 0;
e58333e0 50}
51
52//________________________________________________________________________
b6f970ad 53void AliEmcalContainer::SetArray(AliVEvent *event)
54{
e58333e0 55 // Get array from event.
56
6421eeb0 57 const AliVVertex *vertex = event->GetPrimaryVertex();
58 if (vertex) vertex->GetXYZ(fVertex);
59
e58333e0 60 if (!fClArrayName.IsNull() && !fClArray) {
61 fClArray = dynamic_cast<TClonesArray*>(event->FindListObject(fClArrayName));
62 if (!fClArray) {
b6f970ad 63 AliError(Form("%s: Could not retrieve array with name %s!", GetName(), fClArrayName.Data()));
e58333e0 64 return;
65 }
66 } else {
67 return;
68 }
69
b6f970ad 70 if (!fClassName.IsNull()) {
71 TString objname(fClArray->GetClass()->GetName());
72 TClass cls(objname);
73 if (!cls.InheritsFrom(fClassName)) {
74 AliError(Form("%s: Objects of type %s in %s are not inherited from %s!",
75 GetName(), cls.GetName(), fClArrayName.Data(), fClassName.Data()));
76 fClArray = 0;
77 }
e58333e0 78 }
ef46ebe5 79
80 fLabelMap = dynamic_cast<AliNamedArrayI*>(event->FindListObject(fClArrayName + "_Map"));
81}
82
83//________________________________________________________________________
84Int_t AliEmcalContainer::GetIndexFromLabel(Int_t lab) const
85{
86 if (fLabelMap) {
87 if (lab < fLabelMap->GetSize()) {
88 return fLabelMap->At(lab);
89 }
90 else {
91 AliDebug(3,Form("%s_AliEmcalContainer::GetIndexFromLabel - Label not found in the map, returning -1...",fClArrayName.Data()));
92 return -1;
93 }
94 }
95 else {
96 AliDebug(3,Form("%s_AliEmcalContainer::GetIndexFromLabel - No index-label map found, returning label...",fClArrayName.Data()));
97 return lab;
98 }
e58333e0 99}