]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - PWGJE/EMCALJetTasks/AliJetConstituentTagCopier.cxx
bookkeep pt hard info when generating on-the-fly pythia events
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / AliJetConstituentTagCopier.cxx
... / ...
CommitLineData
1// $Id$
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>
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
20ClassImp(AliJetConstituentTagCopier)
21
22//________________________________________________________________________
23AliJetConstituentTagCopier::AliJetConstituentTagCopier() :
24 AliAnalysisTaskEmcal("AliJetConstituentTagCopier", kFALSE),
25 fCleanBeforeCopy(kFALSE),
26 fMCLabelShift(0),
27 fMCParticleContainer(0)
28{
29 // Default constructor.
30}
31
32//________________________________________________________________________
33AliJetConstituentTagCopier::AliJetConstituentTagCopier(const char *name) :
34 AliAnalysisTaskEmcal(name, kFALSE),
35 fCleanBeforeCopy(kFALSE),
36 fMCLabelShift(0),
37 fMCParticleContainer(0)
38{
39 // Standard constructor.
40}
41
42//________________________________________________________________________
43AliJetConstituentTagCopier::~AliJetConstituentTagCopier()
44{
45 // Destructor
46}
47
48//________________________________________________________________________
49Bool_t AliJetConstituentTagCopier::Run()
50{
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);
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//________________________________________________________________________
68void AliJetConstituentTagCopier::DoClusterLoop(AliClusterContainer *cont)
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//________________________________________________________________________
111void AliJetConstituentTagCopier::DoParticleLoop(AliParticleContainer *cont)
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}