]> git.uio.no Git - u/mrichter/AliRoot.git/blame - JETAN/AliAnalysisTaskDiJets.cxx
Fix for the problem during PbPb run of Nov 2010 (Indra)
[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),
7bb870ca 35 fUseAODInput(kFALSE),
863dbf3b 36 fFillAOD(kFALSE),
7bb870ca 37 fJetBranch("jets"),
38 fAOD(0),
4f49cbd0 39 fHistList(0),
40 fH1DeltaPt(0),
41 fH1DeltaPhi(0),
42 fH1PhiImbal(0),
43 fH1Asym(0),
44 fH2Pt2vsPt1(0),
45 fH2DifvsSum(0)
bd24e6dc 46{
47 // Default constructor
48}
49
4f49cbd0 50//----------------------------------------------------------------------
bd24e6dc 51AliAnalysisTaskDiJets::AliAnalysisTaskDiJets(const char* name):
52 AliAnalysisTaskSE(name),
53 fDiJets(0),
4f49cbd0 54 fDiJetsIn(0),
7bb870ca 55 fUseAODInput(kFALSE),
863dbf3b 56 fFillAOD(kFALSE),
7bb870ca 57 fJetBranch("jets"),
58 fAOD(0),
4f49cbd0 59 fHistList(0),
60 fH1DeltaPt(0),
61 fH1DeltaPhi(0),
62 fH1PhiImbal(0),
63 fH1Asym(0),
64 fH2Pt2vsPt1(0),
65 fH2DifvsSum(0)
bd24e6dc 66{
67 // Default constructor
4f49cbd0 68 DefineOutput(1, TList::Class());
bd24e6dc 69}
70
4f49cbd0 71//----------------------------------------------------------------------
bd24e6dc 72void AliAnalysisTaskDiJets::UserCreateOutputObjects()
73{
74// Create the output container
75//
7bb870ca 76 if (fDebug) printf("AnalysisTaskDiJets::CreateOutPutData() \n");
bd24e6dc 77 fDiJets = new TClonesArray("AliAODDiJet", 0);
863dbf3b 78 if (fFillAOD){
7bb870ca 79 fDiJets->SetName(Form("dijets_%s",fJetBranch.Data()));
863dbf3b 80 AddAODBranch("TClonesArray", &fDiJets);
81 }
4f49cbd0 82
83 if (!fHistList) fHistList = new TList();
9c6bd749 84 fHistList->SetOwner();
4f49cbd0 85 Float_t pi=TMath::Pi();
86 gStyle->SetPalette(1);
87
88 fH1DeltaPt = new TH1F("DeltaPt","Difference between the jets' Pt;#Deltap_{T} (GeV/c);Entries",150,0.,150.);
89 fH1DeltaPt->SetMarkerSize(0.6);
90 fH1DeltaPt->SetMarkerColor(4);
91 fH1DeltaPt->SetMarkerStyle(21);
92 fH1DeltaPt->SetOption("E");
93
94 fH1DeltaPhi = new TH1F("DeltaPhi","Difference in the azimuthal angle;#Delta#phi;Entries",100,0.,pi);
95 fH1DeltaPhi->SetMarkerSize(0.6);
96 fH1DeltaPhi->SetMarkerColor(4);
97 fH1DeltaPhi->SetMarkerStyle(21);
98 fH1DeltaPhi->SetOption("E");
99
100 fH1PhiImbal = new TH1F("PhiImb","Phi imbalance;#phi;Entries",100,-pi,pi);
101 fH1PhiImbal->SetMarkerSize(0.6);
102 fH1PhiImbal->SetMarkerColor(4);
103 fH1PhiImbal->SetMarkerStyle(21);
104 fH1PhiImbal->SetOption("E");
105
106 fH1Asym = new TH1F("Asym","Pt asymmetry;#Deltap_{T}/(p_{T,1}+p_{T,2});Entries",50,0.,1.);
107 fH1Asym->SetMarkerSize(0.6);
108 fH1Asym->SetMarkerColor(4);
109 fH1Asym->SetMarkerStyle(21);
110 fH1Asym->SetOption("E");
111
112 fH2Pt2vsPt1 = new TH2F("Pt2vsPt1","Pt2 versus Pt1;p_{T,1} (GeV/c);p_{T,2} (GeV/c)",250,0.,250.,250,0.,250.);
113 fH2Pt2vsPt1->SetOption("cont0");
114
115 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.);
116 fH2DifvsSum->SetOption("cont0");
117
118 fHistList->Add(fH1DeltaPt);
119 fHistList->Add(fH1DeltaPhi);
120 fHistList->Add(fH1PhiImbal);
121 fHistList->Add(fH1Asym);
122 fHistList->Add(fH2Pt2vsPt1);
123 fHistList->Add(fH2DifvsSum);
bd24e6dc 124}
125
4f49cbd0 126//----------------------------------------------------------------------
bd24e6dc 127void AliAnalysisTaskDiJets::Init()
128{
129 // Initialization
7bb870ca 130 if (fDebug) printf("AnalysisTaskDiJets::Init() \n");
bd24e6dc 131}
132
4f49cbd0 133//----------------------------------------------------------------------
bd24e6dc 134void AliAnalysisTaskDiJets::UserExec(Option_t */*option*/)
135{
136// Execute analysis for current event
137//
7bb870ca 138 if (fDiJets) fDiJets->Delete();
139
140 if(fUseAODInput){
01c15c67 141 fAOD = dynamic_cast<AliAODEvent*> (InputEvent());
ec365e4a 142 if(!fAOD){
7bb870ca 143 // We do not have an input AOD, look in the output
ec365e4a 144 if (fDebug) printf("%s:%d No AOD event in the input\n",(char*)__FILE__,__LINE__);
7bb870ca 145 return;
146 }
147 } else {
148 fAOD = AODEvent();
ec365e4a 149 if(!fAOD){
150 if (fDebug) printf("%s:%d AODEvent not found in the Output",(char*)__FILE__,__LINE__);
4f49cbd0 151 return;
152 }
6c3180e0 153 }
ec365e4a 154
7bb870ca 155 TClonesArray* jets = (TClonesArray*) fAOD->FindListObject(fJetBranch.Data());
6c3180e0 156 // N.B. if we take the aod from the output this is always
157 // empty and since it is the same as fDiJets
7bb870ca 158 fDiJetsIn = (TClonesArray*) (fAOD->GetList()->FindObject("dijets"));
4f49cbd0 159
bd24e6dc 160 if (fDiJetsIn) {
7bb870ca 161 if (fDebug) printf("Found %d dijets in old list \n", fDiJetsIn->GetEntries());
4f49cbd0 162 AliAODJet* jj1, *jj2;
163 AliAODDiJet* testJ;
164
165 if (fDiJetsIn->GetEntries() > 0) {
166 testJ = (AliAODDiJet*) (fDiJetsIn->At(0));
167 jj1 = testJ->Jet(0);
168 jj1->Print("");
169 jj2 = testJ->Jet(1);
170 jj2->Print("");
171 }
bd24e6dc 172 }
4f49cbd0 173
bd24e6dc 174 Int_t nj = jets->GetEntriesFast();
7bb870ca 175 if (fDebug) printf("There are %5d jets in the event \n", nj);
4f49cbd0 176
b3818fc4 177 if (nj < 2){
178 PostData(1, fHistList);
179 return;
180 }
4f49cbd0 181 AliAODJet* jet1 = (AliAODJet*) (jets->At(0));
182 TLorentzVector v1 = *(jet1->MomentumVector());
183 AliAODJet* jet2 = (AliAODJet*) (jets->At(1));
184 TLorentzVector v2 = *(jet2->MomentumVector());
185 TLorentzVector v = v1 + v2;
dcaaffc0 186 if (fDiJets) {
187 Int_t ndi = fDiJets->GetEntriesFast();
188 TClonesArray &lref = *fDiJets;
189 new(lref[ndi]) AliAODDiJet(v);
190 AliAODDiJet* dijet = (AliAODDiJet*) (fDiJets->At(ndi));
191 dijet->SetJetRefs(jet1, jet2);
192 fH1DeltaPhi->Fill(dijet->DeltaPhi());
193 fH1PhiImbal->Fill(dijet->PhiImbalance());
4f49cbd0 194
dcaaffc0 195 }
196
4f49cbd0 197 fH1DeltaPt->Fill(jet1->Pt()-jet2->Pt());
4f49cbd0 198 fH1Asym->Fill((jet1->Pt()-jet2->Pt())/(jet1->Pt()+jet2->Pt()));
199 fH2Pt2vsPt1->Fill(jet1->Pt(),jet2->Pt());
200 fH2DifvsSum->Fill(jet1->Pt()+jet2->Pt(),jet1->Pt()-jet2->Pt());
201
202 PostData(1, fHistList);
203 return;
bd24e6dc 204}
205
4f49cbd0 206//----------------------------------------------------------------------
bd24e6dc 207void AliAnalysisTaskDiJets::Terminate(Option_t */*option*/)
208{
209// Terminate analysis
210//
7bb870ca 211 if (fDebug) printf("AnalysisDiJets: Terminate() \n");
bd24e6dc 212}
213