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