AliPhysics  31210d0 (31210d0)
AliJetConstituentTagCopier.cxx
Go to the documentation of this file.
1 // $Id$
2 //
3 // Copy tags from particle level constituent to detector level
4 //
5 // Author: S. Aiola
6 
8 
9 #include <TClonesArray.h>
10 #include <TMath.h>
11 #include <TLorentzVector.h>
12 
13 #include "AliNamedArrayI.h"
14 #include "AliVCluster.h"
15 #include "AliVParticle.h"
16 #include "AliParticleContainer.h"
17 #include "AliClusterContainer.h"
18 #include "AliLog.h"
19 
21 
22 //________________________________________________________________________
25  fCleanBeforeCopy(kFALSE),
26  fMCLabelShift(0),
27  fMCParticleContainer(0)
28 {
29  // Default constructor.
30 }
31 
32 //________________________________________________________________________
34  AliAnalysisTaskEmcal(name, kFALSE),
35  fCleanBeforeCopy(kFALSE),
36  fMCLabelShift(0),
37  fMCParticleContainer(0)
38 {
39  // Standard constructor.
40 }
41 
42 //________________________________________________________________________
44 {
45  // Destructor
46 }
47 
48 //________________________________________________________________________
50 {
51  for (Int_t i = 0; i < fParticleCollArray.GetEntriesFast(); i++) {
53  if (!cont) continue;
54  if (cont == fMCParticleContainer) continue;
55  DoParticleLoop(cont);
56  }
57 
58  for (Int_t i = 0; i < fClusterCollArray.GetEntriesFast(); i++) {
59  AliClusterContainer *cont = static_cast<AliClusterContainer*>(fClusterCollArray.At(i));
60  if (!cont) continue;
61  DoClusterLoop(cont);
62  }
63 
64  return kTRUE;
65 }
66 
67 //________________________________________________________________________
69 {
70  AliVCluster *cluster = 0;
71 
72  if (fCleanBeforeCopy) {
73  cont->ResetCurrentID();
74  while ((cluster = static_cast<AliVCluster*>(cont->GetNextAcceptCluster()))) {
75  Int_t mcLabel = cluster->GetLabel();
76  if (mcLabel > 0) cluster->SetBit(TObject::kBitMask, kFALSE);
77  }
78  }
79 
80  if (!fMCParticleContainer) return;
81 
82  Double_t totalEnergy = 0;
83  cont->ResetCurrentID();
84  while ((cluster = static_cast<AliVCluster*>(cont->GetNextAcceptCluster()))) {
85  Int_t mcLabel = cluster->GetLabel();
86  if (mcLabel > fMCLabelShift) mcLabel -= fMCLabelShift;
87  if (mcLabel > 0) {
88  TLorentzVector vect;
89  cluster->GetMomentum(vect, fVertex);
90  AliDebug(2, Form("Cluster %d, pt = %f, eta = %f, phi = %f, label = %d",
91  cont->GetCurrentID(), cluster->E(), vect.Eta(), vect.Phi(), mcLabel));
92  totalEnergy += cluster->E();
93  Int_t index = fMCParticleContainer->GetIndexFromLabel(mcLabel);
94  if (index < 0) continue;
95  AliVParticle *part = fMCParticleContainer->GetParticle(index);
96  if (!part) {
97  AliError(Form("%s: Could not get MC particle %d", GetName(), index));
98  continue;
99  }
100  AliDebug(2, Form("Matched with particle %d, pt = %f, eta = %f, phi = %f",
101  index, part->E(), part->Eta(), part->Phi()));
102  UInt_t bits = (UInt_t)part->TestBits(TObject::kBitMask);
103  cluster->SetBit(bits);
104  }
105  }
106 
107  AliDebug(2, Form("Total energy of MC clusters = %f", totalEnergy));
108 }
109 
110 //________________________________________________________________________
112 {
113  AliVParticle *track = 0;
114 
115  if (fCleanBeforeCopy) {
116  cont->ResetCurrentID();
117  while ((track = static_cast<AliVParticle*>(cont->GetNextAcceptParticle()))) {
118  Int_t mcLabel = TMath::Abs(track->GetLabel());
119  if (mcLabel > 0) track->SetBit(TObject::kBitMask, kFALSE);
120  }
121  }
122 
123  if (!fMCParticleContainer) return;
124 
125  cont->ResetCurrentID();
126  while ((track = static_cast<AliVParticle*>(cont->GetNextAcceptParticle()))) {
127  Int_t mcLabel = TMath::Abs(track->GetLabel());
128  if (mcLabel > fMCLabelShift) mcLabel -= fMCLabelShift;
129  if (mcLabel > 0) {
130  Int_t index = fMCParticleContainer->GetIndexFromLabel(mcLabel);
131  if (index < 0) continue;
132  AliVParticle *part = fMCParticleContainer->GetParticle(index);
133  if (!part) {
134  AliError(Form("%s: Could not get MC particle %d", GetName(), index));
135  continue;
136  }
137  AliDebug(3, Form("Track %d, pt = %f, eta = %f, phi = %f, label = %d is matched with particle %d, pt = %f, eta = %f, phi = %f",
138  cont->GetCurrentID(), track->Pt(), track->Eta(), track->Phi(), mcLabel, index, part->Pt(), part->Eta(), part->Phi()));
139  UInt_t bits = (UInt_t)part->TestBits(TObject::kBitMask);
140  track->SetBit(bits);
141  }
142  }
143 }
void DoClusterLoop(AliClusterContainer *cont)
TObjArray fClusterCollArray
cluster collection array
virtual AliVParticle * GetNextAcceptParticle()
double Double_t
Definition: External.C:58
Base task in the EMCAL framework.
void DoParticleLoop(AliParticleContainer *cont)
Container for particles within the EMCAL framework.
TObjArray fParticleCollArray
particle/track collection array
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
virtual AliVParticle * GetParticle(Int_t i=-1) const
Double_t fVertex[3]
!event vertex
Bool_t Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
bool Bool_t
Definition: External.C:53
AliParticleContainer * fMCParticleContainer
Container structure for EMCAL clusters.
AliVCluster * GetNextAcceptCluster()