AliPhysics  f2694b8 (f2694b8)
 All Classes Namespaces Files Functions Variables Typedefs 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 #include "AliVParticle.h"
12 
13 #include "AliEmcalContainer.h"
14 
16 
17 //________________________________________________________________________
19  TObject(),
20  fName(),
21  fClArrayName(),
22  fClassName(),
23  fIsParticleLevel(kFALSE),
24  fBitMap(0),
25  fClArray(0),
26  fCurrentID(0),
27  fLabelMap(0),
28  fRejectionReason(0),
29  fLoadedClass(0)
30 {
31  // Default constructor.
32 
33  fVertex[0] = 0;
34  fVertex[1] = 0;
35  fVertex[2] = 0;
36 }
37 
38 //________________________________________________________________________
40  TObject(),
41  fName(name),
42  fClArrayName(name),
43  fClassName(),
44  fIsParticleLevel(kFALSE),
45  fBitMap(0),
46  fClArray(0),
47  fCurrentID(0),
48  fLabelMap(0),
49  fRejectionReason(0),
50  fLoadedClass(0)
51 {
52  // Standard constructor.
53 
54  fVertex[0] = 0;
55  fVertex[1] = 0;
56  fVertex[2] = 0;
57 }
58 
59 //________________________________________________________________________
60 void AliEmcalContainer::SetArray(AliVEvent *event)
61 {
62  // Get array from event.
63 
64  const AliVVertex *vertex = event->GetPrimaryVertex();
65  if (vertex) vertex->GetXYZ(fVertex);
66 
67  if (!fClArrayName.IsNull() && !fClArray) {
68  fClArray = dynamic_cast<TClonesArray*>(event->FindListObject(fClArrayName));
69  if (!fClArray) {
70  AliError(Form("%s: Could not retrieve array with name %s!", GetName(), fClArrayName.Data()));
71  return;
72  }
73  } else {
74  return;
75  }
76 
77  fLoadedClass = fClArray->GetClass();
78 
79  if (!fClassName.IsNull()) {
80  if (!fLoadedClass->InheritsFrom(fClassName)) {
81  AliError(Form("%s: Objects of type %s in %s are not inherited from %s!",
82  GetName(), fLoadedClass->GetName(), fClArrayName.Data(), fClassName.Data()));
83  fClArray = 0;
84  fLoadedClass = 0;
85  }
86  }
87 
88  fLabelMap = dynamic_cast<AliNamedArrayI*>(event->FindListObject(fClArrayName + "_Map"));
89 }
90 
91 //________________________________________________________________________
93 {
94  if (fLabelMap) {
95  if (lab < fLabelMap->GetSize()) {
96  return fLabelMap->At(lab);
97  }
98  else {
99  AliDebug(3,Form("%s_AliEmcalContainer::GetIndexFromLabel - Label not found in the map, returning -1...",fClArrayName.Data()));
100  return -1;
101  }
102  }
103  else {
104  AliDebug(3,Form("%s_AliEmcalContainer::GetIndexFromLabel - No index-label map found, returning label...",fClArrayName.Data()));
105  return lab;
106  }
107 }
108 
109 //________________________________________________________________________
111 {
112  // Returns the highest bit in the rejection map.
113 
114  UInt_t rs = fRejectionReason;
115  UShort_t p = 0;
116  while (rs >>= 1) { p++; }
117  return p;
118 }
119 
120 
121 //__________________________________________________________________________________________________
122 Bool_t AliEmcalContainer::SamePart(const AliVParticle* part1, const AliVParticle* part2, Double_t dist)
123 {
124  // Helper function to calculate the distance between two jets or a jet and a particle
125  if(!part1) return kFALSE;
126  if(!part2) return kFALSE;
127  Double_t dPhi = TMath::Abs(part1->Phi() - part2->Phi());
128  Double_t dEta = TMath::Abs(part1->Eta() - part2->Eta());
129  Double_t dpT = TMath::Abs(part1->Pt() - part2->Pt());
130  dPhi = TVector2::Phi_mpi_pi(dPhi);
131  if (dPhi > dist) return kFALSE;
132  if (dEta > dist) return kFALSE;
133  if (dpT > dist) return kFALSE;
134  return kTRUE;
135 }
Int_t GetIndexFromLabel(Int_t lab) const
UShort_t GetRejectionReasonBitPosition() const
virtual void SetArray(AliVEvent *event)
TClass * fLoadedClass
reject reason bit map for the last call to an accept object function
UInt_t fRejectionReason
event vertex array
AliNamedArrayI * fLabelMap
current ID for automatic loops
Double_t fVertex[3]
Label-Index map.
const char * GetName() const
static Bool_t SamePart(const AliVParticle *part1, const AliVParticle *part2, Double_t dist=1.e-4)
TClonesArray * fClArray
ClassImp(AliEmcalContainer) AliEmcalContainer