3 // Copy tags from particle level constituent to detector level
7 #include "AliJetConstituentTagCopier.h"
9 #include <TClonesArray.h>
11 #include <TLorentzVector.h>
13 #include "AliNamedArrayI.h"
14 #include "AliVCluster.h"
15 #include "AliVParticle.h"
16 #include "AliParticleContainer.h"
17 #include "AliClusterContainer.h"
20 ClassImp(AliJetConstituentTagCopier)
22 //________________________________________________________________________
23 AliJetConstituentTagCopier::AliJetConstituentTagCopier() :
24 AliAnalysisTaskEmcal("AliJetConstituentTagCopier", kFALSE),
25 fCleanBeforeCopy(kFALSE),
27 fMCParticleContainer(0)
29 // Default constructor.
32 //________________________________________________________________________
33 AliJetConstituentTagCopier::AliJetConstituentTagCopier(const char *name) :
34 AliAnalysisTaskEmcal(name, kFALSE),
35 fCleanBeforeCopy(kFALSE),
37 fMCParticleContainer(0)
39 // Standard constructor.
42 //________________________________________________________________________
43 AliJetConstituentTagCopier::~AliJetConstituentTagCopier()
48 //________________________________________________________________________
49 Bool_t AliJetConstituentTagCopier::Run()
51 for (Int_t i = 0; i < fParticleCollArray.GetEntriesFast(); i++) {
52 AliParticleContainer *cont = static_cast<AliParticleContainer*>(fParticleCollArray.At(i));
54 if (cont == fMCParticleContainer) continue;
58 for (Int_t i = 0; i < fClusterCollArray.GetEntriesFast(); i++) {
59 AliClusterContainer *cont = static_cast<AliClusterContainer*>(fClusterCollArray.At(i));
67 //________________________________________________________________________
68 void AliJetConstituentTagCopier::DoClusterLoop(AliClusterContainer *cont)
70 AliVCluster *cluster = 0;
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);
80 if (!fMCParticleContainer) return;
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;
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);
97 AliError(Form("%s: Could not get MC particle %d", GetName(), index));
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);
107 AliDebug(2, Form("Total energy of MC clusters = %f", totalEnergy));
110 //________________________________________________________________________
111 void AliJetConstituentTagCopier::DoParticleLoop(AliParticleContainer *cont)
113 AliVParticle *track = 0;
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);
123 if (!fMCParticleContainer) return;
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;
130 Int_t index = fMCParticleContainer->GetIndexFromLabel(mcLabel);
131 if (index < 0) continue;
132 AliVParticle *part = fMCParticleContainer->GetParticle(index);
134 AliError(Form("%s: Could not get MC particle %d", GetName(), index));
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);