]> git.uio.no Git - u/mrichter/AliRoot.git/blame - JETAN/AliAnalysisTaskDiJets.cxx
Adding new macro, loadFromOCDB.C, for loading magnetic field, mapping and
[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>
24
25
26ClassImp(AliAnalysisTaskDiJets)
27
28////////////////////////////////////////////////////////////////////////
29
30AliAnalysisTaskDiJets::AliAnalysisTaskDiJets():
31 AliAnalysisTaskSE(),
32 fDiJets(0),
33 fDiJetsIn(0)
34{
35 // Default constructor
36}
37
38AliAnalysisTaskDiJets::AliAnalysisTaskDiJets(const char* name):
39 AliAnalysisTaskSE(name),
40 fDiJets(0),
41 fDiJetsIn(0)
42{
43 // Default constructor
44}
45
46void AliAnalysisTaskDiJets::UserCreateOutputObjects()
47{
48// Create the output container
49//
50 if (fDebug > 1) printf("AnalysisTaskDiJets::CreateOutPutData() \n");
51 fDiJets = new TClonesArray("AliAODDiJet", 0);
52 fDiJets->SetName("Dijets");
341bfe06 53 AddAODBranch("TClonesArray", &fDiJets);
bd24e6dc 54}
55
56void AliAnalysisTaskDiJets::Init()
57{
58 // Initialization
59 if (fDebug > 1) printf("AnalysisTaskDiJets::Init() \n");
60}
61
62void AliAnalysisTaskDiJets::UserExec(Option_t */*option*/)
63{
64// Execute analysis for current event
65//
66 fDiJets->Delete();
67 AliAODEvent* aod = dynamic_cast<AliAODEvent*> (InputEvent());
6c3180e0 68
69 if(!aod){
70 // We do not have an input AOD, look in the output
71 aod = AODEvent();
72 if(!aod){
73 Printf("%s:%d AODEvent not found in the Output",(char*)__FILE__,__LINE__);
74 return;
75 }
76 }
77
bd24e6dc 78 TClonesArray* jets = aod->GetJets();
6c3180e0 79
80 // N.B. if we take the aod from the output this is always
81 // empty and since it is the same as fDiJets
bd24e6dc 82 fDiJetsIn = (TClonesArray*) (aod->GetList()->FindObject("Dijets"));
83
84 if (fDiJetsIn) {
85 printf("Found %d dijets in old list \n", fDiJetsIn->GetEntries());
86 AliAODJet* jj1, *jj2;
87 AliAODDiJet* testJ;
88
89 if (fDiJetsIn->GetEntries() > 0) {
90 testJ = (AliAODDiJet*) (fDiJetsIn->At(0));
91 jj1 = testJ->Jet(0);
92 jj1->Print("");
93 jj2 = testJ->Jet(1);
94 jj2->Print("");
95 }
96 }
97
98
99 Int_t nj = jets->GetEntriesFast();
100 printf("There are %5d jets in the event \n", nj);
101 if (nj > 1) {
6eea9f7c 102 for (Int_t iJet1=0; iJet1<nj; iJet1++){
103 AliAODJet* jet1 = (AliAODJet*) (jets->At(iJet1));
104 TLorentzVector v1 = *(jet1->MomentumVector());
105 for (Int_t iJet2=iJet1+1; iJet2<nj; iJet2++){
106 AliAODJet* jet2 = (AliAODJet*) (jets->At(iJet2));
107 TLorentzVector v2 = *(jet2->MomentumVector());
108 TLorentzVector v = v1 + v2;
109 Int_t ndi = fDiJets->GetEntriesFast();
110 TClonesArray &lref = *fDiJets;
111 new(lref[ndi]) AliAODDiJet(v);;
112 AliAODDiJet* dijet = (AliAODDiJet*) (fDiJets->At(ndi));
113 dijet->SetJetRefs(jet1, jet2);
114 }
115 }
bd24e6dc 116 }
117
118}
119
120void AliAnalysisTaskDiJets::Terminate(Option_t */*option*/)
121{
122// Terminate analysis
123//
124 if (fDebug > 1) printf("AnalysisDiJets: Terminate() \n");
125}
126