]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/EMCALJetTasks/AliJetRandomizerTask.cxx
including task for user mconnors
[u/mrichter/AliRoot.git] / PWGGA / EMCALJetTasks / AliJetRandomizerTask.cxx
1 // $Id$
2 //
3 // Jet randomizer task.
4 //
5 // Author: S.Aiola, C.Loizides
6
7 #include <TClonesArray.h>
8 #include <TLorentzVector.h>
9 #include <TRandom3.h>
10
11 #include "AliAnalysisManager.h"
12 #include "AliVEvent.h"
13 #include "AliVCluster.h"
14 #include "AliEMCALDigit.h"
15 #include "AliEMCALRecPoint.h"
16 #include "AliPicoTrack.h"
17 #include "AliEMCALGeometry.h"
18 #include "AliLog.h"
19
20 #include "AliJetRandomizerTask.h"
21
22 ClassImp(AliJetRandomizerTask)
23
24 //________________________________________________________________________
25 AliJetRandomizerTask::AliJetRandomizerTask() : 
26   AliJetModelBaseTask("AliJetRandomizerTask")
27 {
28   // Default constructor.
29
30   SetSuffix("Randomized");
31 }
32
33 //________________________________________________________________________
34 AliJetRandomizerTask::AliJetRandomizerTask(const char *name) : 
35   AliJetModelBaseTask(name)
36 {
37   // Standard constructor.
38
39   SetSuffix("Randomized");
40 }
41
42 //________________________________________________________________________
43 AliJetRandomizerTask::~AliJetRandomizerTask()
44 {
45   // Destructor
46 }
47
48 //________________________________________________________________________
49 void AliJetRandomizerTask::UserExec(Option_t *) 
50 {
51   // Execute per event.
52
53   if (!fCopyArray) {
54     AliWarning("fCopyArray == kFALSE not allowed for AliJetRandomizerTask, will set kTRUE");
55     fCopyArray = kTRUE;
56   }
57
58   if (!fIsInit) { 
59     ExecOnce();
60     fIsInit = 1;
61   }
62
63   Run();
64 }
65
66 //________________________________________________________________________
67 void AliJetRandomizerTask::Run() 
68 {
69   // Randomize particles.
70
71   if (fNClusters > 0 && fOutClusters) {
72     const Int_t nClusters = fClusters->GetEntriesFast();
73     for (Int_t i = 0; i < nClusters; ++i) {
74       AliVCluster *cluster = dynamic_cast<AliVCluster*>(fClusters->At(i));
75       if (!cluster)
76         continue;
77       if (!cluster->IsEMCAL())
78         continue;
79
80       Float_t pos[3];
81       cluster->GetPosition(pos);
82       TVector3 clusVec(pos);
83
84       AddCluster(cluster->E(), clusVec.Eta());
85     }
86   }
87  
88   if (fNTracks > 0 && fOutTracks) {
89     const Int_t nTracks = fTracks->GetEntriesFast();
90     for (Int_t i = 0; i < nTracks; ++i) {
91       AliPicoTrack *track = dynamic_cast<AliPicoTrack*>(fTracks->At(i));
92       if (!track)
93         continue;
94
95       AddTrack(track->Pt(), track->Eta());
96     }
97   }
98 }