AliPhysics  v5-06-40-01 (42bb456)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliEmcalContainer.cxx
Go to the documentation of this file.
1 //
2 // Emcal Container Base class
3 //
4 // Author: M. Verweij
5 
6 
7 #include <TClonesArray.h>
8 #include "AliVEvent.h"
9 #include "AliLog.h"
10 #include "AliNamedArrayI.h"
11 
12 #include "AliEmcalContainer.h"
13 
15 
16 //________________________________________________________________________
18  TNamed("AliEmcalContainer","AliEmcalContainer"),
19  fClArrayName(),
20  fClassName(),
21  fIsParticleLevel(kFALSE),
22  fClArray(0),
23  fCurrentID(0),
24  fLabelMap(0),
25  fRejectionReason(0)
26 {
27  // Default constructor.
28 
29  fVertex[0] = 0;
30  fVertex[1] = 0;
31  fVertex[2] = 0;
32 }
33 
34 //________________________________________________________________________
36  TNamed(name,name),
37  fClArrayName(),
38  fClassName(),
39  fIsParticleLevel(kFALSE),
40  fClArray(0),
41  fCurrentID(0),
42  fLabelMap(0),
43  fRejectionReason(0)
44 {
45  // Standard constructor.
46 
47  fVertex[0] = 0;
48  fVertex[1] = 0;
49  fVertex[2] = 0;
50 }
51 
52 //________________________________________________________________________
53 void AliEmcalContainer::SetArray(AliVEvent *event)
54 {
55  // Get array from event.
56 
57  const AliVVertex *vertex = event->GetPrimaryVertex();
58  if (vertex) vertex->GetXYZ(fVertex);
59 
60  if (!fClArrayName.IsNull() && !fClArray) {
61  fClArray = dynamic_cast<TClonesArray*>(event->FindListObject(fClArrayName));
62  if (!fClArray) {
63  AliError(Form("%s: Could not retrieve array with name %s!", GetName(), fClArrayName.Data()));
64  return;
65  }
66  } else {
67  return;
68  }
69 
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  }
78  }
79 
80  fLabelMap = dynamic_cast<AliNamedArrayI*>(event->FindListObject(fClArrayName + "_Map"));
81 }
82 
83 //________________________________________________________________________
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  }
99 }
100 
101 //________________________________________________________________________
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 }
Int_t GetIndexFromLabel(Int_t lab) const
UShort_t GetRejectionReasonBitPosition() const
virtual void SetArray(AliVEvent *event)
UInt_t fRejectionReason
event vertex array
AliNamedArrayI * fLabelMap
current ID for automatic loops
Double_t fVertex[3]
Label-Index map.
TClonesArray * fClArray
ClassImp(AliEmcalContainer) AliEmcalContainer