AliPhysics  8bb951a (8bb951a)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalContainer.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 #include <TClonesArray.h>
16 #include "AliVEvent.h"
17 #include "AliLog.h"
18 #include "AliNamedArrayI.h"
19 #include "AliVParticle.h"
20 #include "AliTLorentzVector.h"
21 
22 #include "AliEmcalContainer.h"
23 
27 
34  TObject(),
35  fName(),
36  fClArrayName(),
37  fBaseClassName(),
38  fIsParticleLevel(kFALSE),
39  fBitMap(0),
40  fMinPt(0.15),
41  fMaxPt(1000.),
42  fMaxE(1000.),
43  fMinE(0.),
44  fMinEta(-0.9),
45  fMaxEta(0.9),
46  fMinPhi(-10),
47  fMaxPhi(10),
48  fMinMCLabel(-1),
49  fMaxMCLabel(-1),
50  fMassHypothesis(-1),
51  fClArray(0),
52  fCurrentID(0),
53  fLabelMap(0),
54  fLoadedClass(0),
55  fClassName()
56 {
57  fVertex[0] = 0;
58  fVertex[1] = 0;
59  fVertex[2] = 0;
60 }
61 
70  TObject(),
71  fName(name),
72  fClArrayName(name),
73  fBaseClassName(),
74  fIsParticleLevel(kFALSE),
75  fBitMap(0),
76  fMinPt(0.15),
77  fMaxPt(1000.),
78  fMaxE(1000.),
79  fMinE(0.),
80  fMinEta(-0.9),
81  fMaxEta(0.9),
82  fMinPhi(-10),
83  fMaxPhi(10),
84  fMinMCLabel(-1),
85  fMaxMCLabel(-1),
86  fMassHypothesis(-1),
87  fClArray(0),
88  fCurrentID(0),
89  fLabelMap(0),
90  fLoadedClass(0),
91  fClassName()
92 {
93  fVertex[0] = 0;
94  fVertex[1] = 0;
95  fVertex[2] = 0;
96 }
97 
104 TObject *AliEmcalContainer::operator[](int index) const {
105  if(index >= 0 && index < GetNEntries()) return fClArray->At(index);
106  return NULL;
107 }
108 
113 void AliEmcalContainer::SetClassName(const char *clname)
114 {
115  TClass cls(clname);
116  if (cls.InheritsFrom(fBaseClassName)) {
117  fClassName = clname;
118  }
119  else {
120  AliError(Form("Unable to set class name %s for this container, it must inherits from %s!",clname,fBaseClassName.Data()));
121  }
122 }
123 
129 void AliEmcalContainer::SetArray(AliVEvent *event)
130 {
131  const AliVVertex *vertex = event->GetPrimaryVertex();
132  if (vertex) vertex->GetXYZ(fVertex);
133 
134  if (!fClArrayName.IsNull() && !fClArray) {
135  fClArray = dynamic_cast<TClonesArray*>(event->FindListObject(fClArrayName));
136  if (!fClArray) {
137  AliError(Form("%s: Could not retrieve array with name %s!", GetName(), fClArrayName.Data()));
138  return;
139  }
140  } else {
141  return;
142  }
143 
144  fLoadedClass = fClArray->GetClass();
145 
146  if (!fClassName.IsNull()) {
147  if (!fLoadedClass->InheritsFrom(fClassName)) {
148  AliError(Form("%s: Objects of type %s in %s are not inherited from %s!",
149  GetName(), fLoadedClass->GetName(), fClArrayName.Data(), fClassName.Data()));
150  fClArray = 0;
151  fLoadedClass = 0;
152  }
153  }
154 
155  fLabelMap = dynamic_cast<AliNamedArrayI*>(event->FindListObject(fClArrayName + "_Map"));
156 }
157 
163  Int_t result = 0;
164  for(int index = 0; index < GetNEntries(); index++){
165  UInt_t rejectionReason = 0;
166  if(AcceptObject(index, rejectionReason)) result++;
167  }
168  return result;
169 }
170 
177 {
178  if (fLabelMap) {
179  if (lab < fLabelMap->GetSize()) {
180  return fLabelMap->At(lab);
181  }
182  else {
183  AliDebug(3,Form("%s_AliEmcalContainer::GetIndexFromLabel - Label not found in the map, returning -1...",fClArrayName.Data()));
184  return -1;
185  }
186  }
187  else {
188  AliDebug(3,Form("%s_AliEmcalContainer::GetIndexFromLabel - No index-label map found, returning label...",fClArrayName.Data()));
189  return lab;
190  }
191 }
192 
198 UShort_t AliEmcalContainer::GetRejectionReasonBitPosition(UInt_t rejectionReason) const
199 {
200  UInt_t rs = rejectionReason;
201  UShort_t p = 0;
202  while (rs >>= 1) { p++; }
203  return p;
204 }
205 
213 Bool_t AliEmcalContainer::SamePart(const AliVParticle* part1, const AliVParticle* part2, Double_t dist)
214 {
215  if(!part1) return kFALSE;
216  if(!part2) return kFALSE;
217  Double_t dPhi = TMath::Abs(part1->Phi() - part2->Phi());
218  Double_t dEta = TMath::Abs(part1->Eta() - part2->Eta());
219  Double_t dpT = TMath::Abs(part1->Pt() - part2->Pt());
220  dPhi = TVector2::Phi_mpi_pi(dPhi);
221  if (dPhi > dist) return kFALSE;
222  if (dEta > dist) return kFALSE;
223  if (dpT > dist) return kFALSE;
224  return kTRUE;
225 }
226 
236 Bool_t AliEmcalContainer::ApplyKinematicCuts(const AliTLorentzVector& mom, UInt_t &rejectionReason) const
237 {
238  if (mom.Pt() < fMinPt || mom.Pt() > fMaxPt) {
239  rejectionReason |= kPtCut;
240  return kFALSE;
241  }
242 
243  if (mom.E() < fMinE || mom.E() > fMaxE) {
244  rejectionReason |= kPtCut;
245  return kFALSE;
246  }
247 
248  Double_t eta = mom.Eta();
249  Double_t phi = mom.Phi_0_2pi();
250 
251  if (fMinEta < fMaxEta && (eta < fMinEta || eta > fMaxEta)) {
252  rejectionReason |= kAcceptanceCut;
253  return kFALSE;
254  }
255 
256  if (fMinPhi < fMaxPhi && (phi < fMinPhi || phi > fMaxPhi)) {
257  rejectionReason |= kAcceptanceCut;
258  return kFALSE;
259  }
260 
261  return kTRUE;
262 }
263 
270  return AliEmcalIterableContainer(this, false);
271 }
272 
279  return AliEmcalIterableContainer(this, true);
280 }
particle not in acceptance in and/or
virtual Bool_t ApplyKinematicCuts(const AliTLorentzVector &mom, UInt_t &rejectionReason) const
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
const AliEmcalIterableContainer all() const
Int_t GetNAcceptEntries() const
Double_t fMinE
Max. cut on particle energy.
Double_t fMinPhi
Min. cut on particle .
TObject * operator[](int index) const
Double_t fMaxE
Min. cut on particle energy.
Int_t GetIndexFromLabel(Int_t lab) const
TString fClassName
name of the class in the TClonesArray
virtual void SetArray(AliVEvent *event)
Double_t fMinPt
Min. cut on particle .
TClass * fLoadedClass
! Class of the objects contained in the TClonesArray
virtual Bool_t AcceptObject(Int_t i, UInt_t &rejectionReason) const =0
UShort_t GetRejectionReasonBitPosition(UInt_t rejectionReason) const
Double_t fMaxPhi
Max. cut on particle .
Base class for container structures within the EMCAL framework.
Container implementing iterable functionality of the EMCAL containers.
AliNamedArrayI * fLabelMap
! Label-Index map
void SetClassName(const char *clname)
Double_t fVertex[3]
! event vertex array
const char * GetName() const
Double_t fMaxPt
Max. cut on particle .
static Bool_t SamePart(const AliVParticle *part1, const AliVParticle *part2, Double_t dist=1.e-4)
Double_t fMinEta
Min. cut on particle .
TString fBaseClassName
name of the base class that this container can handle
TString fClArrayName
name of branch
Double_t fMaxEta
Max. cut on particle .
const AliEmcalIterableContainer accepted() const
TClonesArray * fClArray
! Pointer to array in input event
Int_t GetNEntries() const