AliPhysics  ec707b8 (ec707b8)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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  fClassName(),
38  fIsParticleLevel(kFALSE),
39  fBitMap(0),
40  fMinPt(0.15),
41  fMaxPt(1000.),
42  fMinE(0.),
43  fMaxE(1000.),
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  fRejectionReason(0),
55  fLoadedClass(0)
56 {
57  fVertex[0] = 0;
58  fVertex[1] = 0;
59  fVertex[2] = 0;
60 }
61 
70  TObject(),
71  fName(name),
72  fClArrayName(name),
73  fClassName(),
74  fIsParticleLevel(kFALSE),
75  fBitMap(0),
76  fMinPt(0.15),
77  fMaxPt(1000.),
78  fMinE(0.),
79  fMaxE(1000.),
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  fRejectionReason(0),
91  fLoadedClass(0)
92 {
93  fVertex[0] = 0;
94  fVertex[1] = 0;
95  fVertex[2] = 0;
96 }
97 
103 void AliEmcalContainer::SetArray(AliVEvent *event)
104 {
105 
106  const AliVVertex *vertex = event->GetPrimaryVertex();
107  if (vertex) vertex->GetXYZ(fVertex);
108 
109  if (!fClArrayName.IsNull() && !fClArray) {
110  fClArray = dynamic_cast<TClonesArray*>(event->FindListObject(fClArrayName));
111  if (!fClArray) {
112  AliError(Form("%s: Could not retrieve array with name %s!", GetName(), fClArrayName.Data()));
113  return;
114  }
115  } else {
116  return;
117  }
118 
119  fLoadedClass = fClArray->GetClass();
120 
121  if (!fClassName.IsNull()) {
122  if (!fLoadedClass->InheritsFrom(fClassName)) {
123  AliError(Form("%s: Objects of type %s in %s are not inherited from %s!",
124  GetName(), fLoadedClass->GetName(), fClArrayName.Data(), fClassName.Data()));
125  fClArray = 0;
126  fLoadedClass = 0;
127  }
128  }
129 
130  fLabelMap = dynamic_cast<AliNamedArrayI*>(event->FindListObject(fClArrayName + "_Map"));
131 }
132 
139 {
140  if (fLabelMap) {
141  if (lab < fLabelMap->GetSize()) {
142  return fLabelMap->At(lab);
143  }
144  else {
145  AliDebug(3,Form("%s_AliEmcalContainer::GetIndexFromLabel - Label not found in the map, returning -1...",fClArrayName.Data()));
146  return -1;
147  }
148  }
149  else {
150  AliDebug(3,Form("%s_AliEmcalContainer::GetIndexFromLabel - No index-label map found, returning label...",fClArrayName.Data()));
151  return lab;
152  }
153 }
154 
161 {
162  UInt_t rs = fRejectionReason;
163  UShort_t p = 0;
164  while (rs >>= 1) { p++; }
165  return p;
166 }
167 
175 Bool_t AliEmcalContainer::SamePart(const AliVParticle* part1, const AliVParticle* part2, Double_t dist)
176 {
177  if(!part1) return kFALSE;
178  if(!part2) return kFALSE;
179  Double_t dPhi = TMath::Abs(part1->Phi() - part2->Phi());
180  Double_t dEta = TMath::Abs(part1->Eta() - part2->Eta());
181  Double_t dpT = TMath::Abs(part1->Pt() - part2->Pt());
182  dPhi = TVector2::Phi_mpi_pi(dPhi);
183  if (dPhi > dist) return kFALSE;
184  if (dEta > dist) return kFALSE;
185  if (dpT > dist) return kFALSE;
186  return kTRUE;
187 }
188 
197 Bool_t AliEmcalContainer::ApplyKinematicCuts(const AliTLorentzVector& mom)
198 {
199  if (mom.Pt() < fMinPt || mom.Pt() > fMaxPt) {
201  return kFALSE;
202  }
203 
204  if (mom.E() < fMinE || mom.E() > fMaxE) {
206  return kFALSE;
207  }
208 
209  Double_t eta = mom.Eta();
210  Double_t phi = mom.Phi_0_2pi();
211 
212  if (fMinEta < fMaxEta && (eta < fMinEta || eta > fMaxEta)) {
214  return kFALSE;
215  }
216 
217  if (fMinPhi < fMaxPhi && (phi < fMinPhi || phi > fMaxPhi)) {
219  return kFALSE;
220  }
221 
222  return kTRUE;
223 }
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
Double_t fMinE
cut on particle energy
Double_t fMinPhi
cut on particle eta
Double_t fMaxE
cut on particle pt
virtual Bool_t ApplyKinematicCuts(const AliTLorentzVector &mom)
Int_t GetIndexFromLabel(Int_t lab) const
TString fClassName
name of branch
UShort_t GetRejectionReasonBitPosition() const
virtual void SetArray(AliVEvent *event)
Double_t fMinPt
bitmap mask
TClass * fLoadedClass
!Class of teh objects contained in the TClonesArray
UInt_t fRejectionReason
!reject reason bit map for the last call to an accept object function
Double_t fMaxPhi
cut on particle phi
Base class for container structures within the EMCAL framework.
AliNamedArrayI * fLabelMap
!Label-Index map
Double_t fVertex[3]
!event vertex array
const char * GetName() const
Double_t fMaxPt
cut on particle pt
Double_t fMinEta
cut on particle energy
TString fClArrayName
object name
Double_t fMaxEta
cut on particle eta
TClonesArray * fClArray
if < 0 it will use a PID mass when available
static Bool_t SamePart(const AliVParticle *part1, const AliVParticle *part2, Double_t dist=1.e-4)