]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG/EMCAL/AliEmcalContainer.cxx
Merge branch 'feature-movesplit'
[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),
6504c17f 24 fLabelMap(0),
25 fRejectionReason(0)
e58333e0 26{
27 // Default constructor.
28
6421eeb0 29 fVertex[0] = 0;
30 fVertex[1] = 0;
31 fVertex[2] = 0;
e58333e0 32}
33
34//________________________________________________________________________
35AliEmcalContainer::AliEmcalContainer(const char *name):
36 TNamed(name,name),
b6f970ad 37 fClArrayName(),
38 fClassName(),
ef46ebe5 39 fIsParticleLevel(kFALSE),
40 fClArray(0),
41 fCurrentID(0),
6504c17f 42 fLabelMap(0),
43 fRejectionReason(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}
68e03fc3 100
101//________________________________________________________________________
102UShort_t AliEmcalContainer::GetRejectionReasonBitPosition() const
103{
104 // Returns the highest bit in the rejection map.
105
106 UInt_t rs = fRejectionReason;
107 UShort_t p = 0;
108 while (rs >>= 1) { p++; }
109 return p;
110}