- fixes to changes in previous commit
[u/mrichter/AliRoot.git] / JETAN / AliAnalysisTaskDiJets.cxx
CommitLineData
bd24e6dc 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18#include "AliAnalysisTaskDiJets.h"
19#include "AliAODEvent.h"
20#include "AliAODJet.h"
21#include "AliAODDiJet.h"
22#include <TClonesArray.h>
23#include <TLorentzVector.h>
4f49cbd0 24#include <TStyle.h>
bd24e6dc 25
26
27ClassImp(AliAnalysisTaskDiJets)
28
29////////////////////////////////////////////////////////////////////////
30
31AliAnalysisTaskDiJets::AliAnalysisTaskDiJets():
32 AliAnalysisTaskSE(),
33 fDiJets(0),
4f49cbd0 34 fDiJetsIn(0),
35 fHistList(0),
36 fH1DeltaPt(0),
37 fH1DeltaPhi(0),
38 fH1PhiImbal(0),
39 fH1Asym(0),
40 fH2Pt2vsPt1(0),
41 fH2DifvsSum(0)
bd24e6dc 42{
43 // Default constructor
44}
45
4f49cbd0 46//----------------------------------------------------------------------
bd24e6dc 47AliAnalysisTaskDiJets::AliAnalysisTaskDiJets(const char* name):
48 AliAnalysisTaskSE(name),
49 fDiJets(0),
4f49cbd0 50 fDiJetsIn(0),
51 fHistList(0),
52 fH1DeltaPt(0),
53 fH1DeltaPhi(0),
54 fH1PhiImbal(0),
55 fH1Asym(0),
56 fH2Pt2vsPt1(0),
57 fH2DifvsSum(0)
bd24e6dc 58{
59 // Default constructor
4f49cbd0 60 DefineOutput(1, TList::Class());
bd24e6dc 61}
62
4f49cbd0 63//----------------------------------------------------------------------
bd24e6dc 64void AliAnalysisTaskDiJets::UserCreateOutputObjects()
65{
66// Create the output container
67//
68 if (fDebug > 1) printf("AnalysisTaskDiJets::CreateOutPutData() \n");
69 fDiJets = new TClonesArray("AliAODDiJet", 0);
4f49cbd0 70 fDiJets->SetName("dijets");
341bfe06 71 AddAODBranch("TClonesArray", &fDiJets);
4f49cbd0 72
73 if (!fHistList) fHistList = new TList();
74 Float_t pi=TMath::Pi();
75 gStyle->SetPalette(1);
76
77 fH1DeltaPt = new TH1F("DeltaPt","Difference between the jets' Pt;#Deltap_{T} (GeV/c);Entries",150,0.,150.);
78 fH1DeltaPt->SetMarkerSize(0.6);
79 fH1DeltaPt->SetMarkerColor(4);
80 fH1DeltaPt->SetMarkerStyle(21);
81 fH1DeltaPt->SetOption("E");
82
83 fH1DeltaPhi = new TH1F("DeltaPhi","Difference in the azimuthal angle;#Delta#phi;Entries",100,0.,pi);
84 fH1DeltaPhi->SetMarkerSize(0.6);
85 fH1DeltaPhi->SetMarkerColor(4);
86 fH1DeltaPhi->SetMarkerStyle(21);
87 fH1DeltaPhi->SetOption("E");
88
89 fH1PhiImbal = new TH1F("PhiImb","Phi imbalance;#phi;Entries",100,-pi,pi);
90 fH1PhiImbal->SetMarkerSize(0.6);
91 fH1PhiImbal->SetMarkerColor(4);
92 fH1PhiImbal->SetMarkerStyle(21);
93 fH1PhiImbal->SetOption("E");
94
95 fH1Asym = new TH1F("Asym","Pt asymmetry;#Deltap_{T}/(p_{T,1}+p_{T,2});Entries",50,0.,1.);
96 fH1Asym->SetMarkerSize(0.6);
97 fH1Asym->SetMarkerColor(4);
98 fH1Asym->SetMarkerStyle(21);
99 fH1Asym->SetOption("E");
100
101 fH2Pt2vsPt1 = new TH2F("Pt2vsPt1","Pt2 versus Pt1;p_{T,1} (GeV/c);p_{T,2} (GeV/c)",250,0.,250.,250,0.,250.);
102 fH2Pt2vsPt1->SetOption("cont0");
103
104 fH2DifvsSum = new TH2F("DifvsSum","Pt difference vs Pt sum;p_{T,1}+p_{T,2} (GeV/c);#Deltap_{T} (GeV/c)",400,0.,400.,150,0.,150.);
105 fH2DifvsSum->SetOption("cont0");
106
107 fHistList->Add(fH1DeltaPt);
108 fHistList->Add(fH1DeltaPhi);
109 fHistList->Add(fH1PhiImbal);
110 fHistList->Add(fH1Asym);
111 fHistList->Add(fH2Pt2vsPt1);
112 fHistList->Add(fH2DifvsSum);
bd24e6dc 113}
114
4f49cbd0 115//----------------------------------------------------------------------
bd24e6dc 116void AliAnalysisTaskDiJets::Init()
117{
118 // Initialization
119 if (fDebug > 1) printf("AnalysisTaskDiJets::Init() \n");
120}
121
4f49cbd0 122//----------------------------------------------------------------------
bd24e6dc 123void AliAnalysisTaskDiJets::UserExec(Option_t */*option*/)
124{
125// Execute analysis for current event
126//
127 fDiJets->Delete();
128 AliAODEvent* aod = dynamic_cast<AliAODEvent*> (InputEvent());
6c3180e0 129
130 if(!aod){
131 // We do not have an input AOD, look in the output
132 aod = AODEvent();
133 if(!aod){
4f49cbd0 134 if (fDebug >1) printf("%s:%d AODEvent not found in the Output",(char*)__FILE__,__LINE__);
135 return;
136 }
6c3180e0 137 }
138
bd24e6dc 139 TClonesArray* jets = aod->GetJets();
6c3180e0 140
141 // N.B. if we take the aod from the output this is always
142 // empty and since it is the same as fDiJets
4f49cbd0 143 fDiJetsIn = (TClonesArray*) (aod->GetList()->FindObject("dijets"));
144
bd24e6dc 145 if (fDiJetsIn) {
4f49cbd0 146 if (fDebug >1) printf("Found %d dijets in old list \n", fDiJetsIn->GetEntries());
147 AliAODJet* jj1, *jj2;
148 AliAODDiJet* testJ;
149
150 if (fDiJetsIn->GetEntries() > 0) {
151 testJ = (AliAODDiJet*) (fDiJetsIn->At(0));
152 jj1 = testJ->Jet(0);
153 jj1->Print("");
154 jj2 = testJ->Jet(1);
155 jj2->Print("");
156 }
bd24e6dc 157 }
4f49cbd0 158
bd24e6dc 159 Int_t nj = jets->GetEntriesFast();
4f49cbd0 160 if (fDebug >1) printf("There are %5d jets in the event \n", nj);
161
b3818fc4 162 if (nj < 2){
163 PostData(1, fHistList);
164 return;
165 }
4f49cbd0 166 AliAODJet* jet1 = (AliAODJet*) (jets->At(0));
167 TLorentzVector v1 = *(jet1->MomentumVector());
168 AliAODJet* jet2 = (AliAODJet*) (jets->At(1));
169 TLorentzVector v2 = *(jet2->MomentumVector());
170 TLorentzVector v = v1 + v2;
171 Int_t ndi = fDiJets->GetEntriesFast();
172 TClonesArray &lref = *fDiJets;
173 new(lref[ndi]) AliAODDiJet(v);
174 AliAODDiJet* dijet = (AliAODDiJet*) (fDiJets->At(ndi));
175 dijet->SetJetRefs(jet1, jet2);
176
177 fH1DeltaPt->Fill(jet1->Pt()-jet2->Pt());
178 fH1DeltaPhi->Fill(dijet->DeltaPhi());
179 fH1PhiImbal->Fill(dijet->PhiImbalance());
180 fH1Asym->Fill((jet1->Pt()-jet2->Pt())/(jet1->Pt()+jet2->Pt()));
181 fH2Pt2vsPt1->Fill(jet1->Pt(),jet2->Pt());
182 fH2DifvsSum->Fill(jet1->Pt()+jet2->Pt(),jet1->Pt()-jet2->Pt());
183
184 PostData(1, fHistList);
185 return;
bd24e6dc 186}
187
4f49cbd0 188//----------------------------------------------------------------------
bd24e6dc 189void AliAnalysisTaskDiJets::Terminate(Option_t */*option*/)
190{
191// Terminate analysis
192//
193 if (fDebug > 1) printf("AnalysisDiJets: Terminate() \n");
194}
195