]>
Commit | Line | Data |
---|---|---|
9239b066 | 1 | // $Id$ |
8afc7c8d | 2 | // |
3 | // Copy tags from particle level constituent to detector level | |
4 | // | |
5 | // Author: S. Aiola | |
6 | ||
7 | #include "AliJetConstituentTagCopier.h" | |
8 | ||
9 | #include <TClonesArray.h> | |
5ce8ae64 | 10 | #include <TMath.h> |
4358e58a | 11 | #include <TLorentzVector.h> |
8afc7c8d | 12 | |
5be3857d | 13 | #include "AliNamedArrayI.h" |
8afc7c8d | 14 | #include "AliVCluster.h" |
15 | #include "AliVParticle.h" | |
7cd832c7 | 16 | #include "AliParticleContainer.h" |
17 | #include "AliClusterContainer.h" | |
8afc7c8d | 18 | #include "AliLog.h" |
19 | ||
20 | ClassImp(AliJetConstituentTagCopier) | |
21 | ||
22 | //________________________________________________________________________ | |
23 | AliJetConstituentTagCopier::AliJetConstituentTagCopier() : | |
9239b066 | 24 | AliAnalysisTaskEmcal("AliJetConstituentTagCopier", kFALSE), |
f0c10df2 | 25 | fCleanBeforeCopy(kFALSE), |
a7477843 | 26 | fMCLabelShift(0), |
7cd832c7 | 27 | fMCParticleContainer(0) |
8afc7c8d | 28 | { |
29 | // Default constructor. | |
30 | } | |
31 | ||
32 | //________________________________________________________________________ | |
33 | AliJetConstituentTagCopier::AliJetConstituentTagCopier(const char *name) : | |
9239b066 | 34 | AliAnalysisTaskEmcal(name, kFALSE), |
f0c10df2 | 35 | fCleanBeforeCopy(kFALSE), |
a7477843 | 36 | fMCLabelShift(0), |
7cd832c7 | 37 | fMCParticleContainer(0) |
8afc7c8d | 38 | { |
39 | // Standard constructor. | |
40 | } | |
41 | ||
42 | //________________________________________________________________________ | |
43 | AliJetConstituentTagCopier::~AliJetConstituentTagCopier() | |
44 | { | |
45 | // Destructor | |
46 | } | |
47 | ||
8afc7c8d | 48 | //________________________________________________________________________ |
49 | Bool_t AliJetConstituentTagCopier::Run() | |
50 | { | |
7cd832c7 | 51 | for (Int_t i = 0; i < fParticleCollArray.GetEntriesFast(); i++) { |
52 | AliParticleContainer *cont = static_cast<AliParticleContainer*>(fParticleCollArray.At(i)); | |
53 | if (!cont) continue; | |
54 | if (cont == fMCParticleContainer) continue; | |
55 | DoParticleLoop(cont); | |
8afc7c8d | 56 | } |
57 | ||
7cd832c7 | 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); | |
8afc7c8d | 62 | } |
63 | ||
64 | return kTRUE; | |
65 | } | |
66 | ||
67 | //________________________________________________________________________ | |
7cd832c7 | 68 | void AliJetConstituentTagCopier::DoClusterLoop(AliClusterContainer *cont) |
8afc7c8d | 69 | { |
7cd832c7 | 70 | AliVCluster *cluster = 0; |
71 | ||
f0c10df2 | 72 | if (fCleanBeforeCopy) { |
7cd832c7 | 73 | cont->ResetCurrentID(); |
74 | while ((cluster = static_cast<AliVCluster*>(cont->GetNextAcceptCluster()))) { | |
f0c10df2 | 75 | Int_t mcLabel = cluster->GetLabel(); |
7cd832c7 | 76 | if (mcLabel > 0) cluster->SetBit(TObject::kBitMask, kFALSE); |
f0c10df2 | 77 | } |
78 | } | |
79 | ||
7cd832c7 | 80 | if (!fMCParticleContainer) return; |
f0c10df2 | 81 | |
4358e58a | 82 | Double_t totalEnergy = 0; |
7cd832c7 | 83 | cont->ResetCurrentID(); |
84 | while ((cluster = static_cast<AliVCluster*>(cont->GetNextAcceptCluster()))) { | |
8afc7c8d | 85 | Int_t mcLabel = cluster->GetLabel(); |
7cd832c7 | 86 | if (mcLabel > fMCLabelShift) mcLabel -= fMCLabelShift; |
8afc7c8d | 87 | if (mcLabel > 0) { |
4358e58a | 88 | TLorentzVector vect; |
89 | cluster->GetMomentum(vect, fVertex); | |
90 | AliDebug(2, Form("Cluster %d, pt = %f, eta = %f, phi = %f, label = %d", | |
7cd832c7 | 91 | cont->GetCurrentID(), cluster->E(), vect.Eta(), vect.Phi(), mcLabel)); |
4358e58a | 92 | totalEnergy += cluster->E(); |
7cd832c7 | 93 | Int_t index = fMCParticleContainer->GetIndexFromLabel(mcLabel); |
94 | if (index < 0) continue; | |
95 | AliVParticle *part = fMCParticleContainer->GetParticle(index); | |
8afc7c8d | 96 | if (!part) { |
97 | AliError(Form("%s: Could not get MC particle %d", GetName(), index)); | |
98 | continue; | |
4358e58a | 99 | } |
100 | AliDebug(2, Form("Matched with particle %d, pt = %f, eta = %f, phi = %f", | |
101 | index, part->E(), part->Eta(), part->Phi())); | |
8afc7c8d | 102 | UInt_t bits = (UInt_t)part->TestBits(TObject::kBitMask); |
103 | cluster->SetBit(bits); | |
104 | } | |
105 | } | |
4358e58a | 106 | |
7cd832c7 | 107 | AliDebug(2, Form("Total energy of MC clusters = %f", totalEnergy)); |
8afc7c8d | 108 | } |
109 | ||
110 | //________________________________________________________________________ | |
7cd832c7 | 111 | void AliJetConstituentTagCopier::DoParticleLoop(AliParticleContainer *cont) |
8afc7c8d | 112 | { |
7cd832c7 | 113 | AliVParticle *track = 0; |
114 | ||
f0c10df2 | 115 | if (fCleanBeforeCopy) { |
7cd832c7 | 116 | cont->ResetCurrentID(); |
117 | while ((track = static_cast<AliVParticle*>(cont->GetNextAcceptParticle()))) { | |
f0c10df2 | 118 | Int_t mcLabel = TMath::Abs(track->GetLabel()); |
7cd832c7 | 119 | if (mcLabel > 0) track->SetBit(TObject::kBitMask, kFALSE); |
f0c10df2 | 120 | } |
121 | } | |
122 | ||
7cd832c7 | 123 | if (!fMCParticleContainer) return; |
f0c10df2 | 124 | |
7cd832c7 | 125 | cont->ResetCurrentID(); |
126 | while ((track = static_cast<AliVParticle*>(cont->GetNextAcceptParticle()))) { | |
5ce8ae64 | 127 | Int_t mcLabel = TMath::Abs(track->GetLabel()); |
7cd832c7 | 128 | if (mcLabel > fMCLabelShift) mcLabel -= fMCLabelShift; |
a7477843 | 129 | if (mcLabel > 0) { |
7cd832c7 | 130 | Int_t index = fMCParticleContainer->GetIndexFromLabel(mcLabel); |
131 | if (index < 0) continue; | |
132 | AliVParticle *part = fMCParticleContainer->GetParticle(index); | |
8afc7c8d | 133 | if (!part) { |
134 | AliError(Form("%s: Could not get MC particle %d", GetName(), index)); | |
135 | continue; | |
136 | } | |
4358e58a | 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", |
7cd832c7 | 138 | cont->GetCurrentID(), track->Pt(), track->Eta(), track->Phi(), mcLabel, index, part->Pt(), part->Eta(), part->Phi())); |
8afc7c8d | 139 | UInt_t bits = (UInt_t)part->TestBits(TObject::kBitMask); |
140 | track->SetBit(bits); | |
141 | } | |
142 | } | |
143 | } |