1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliAnalysisTaskDiJets.h"
19 #include "AliAODEvent.h"
20 #include "AliAODJet.h"
21 #include "AliAODDiJet.h"
22 #include <TClonesArray.h>
23 #include <TLorentzVector.h>
26 ClassImp(AliAnalysisTaskDiJets)
28 ////////////////////////////////////////////////////////////////////////
30 AliAnalysisTaskDiJets::AliAnalysisTaskDiJets():
35 // Default constructor
38 AliAnalysisTaskDiJets::AliAnalysisTaskDiJets(const char* name):
39 AliAnalysisTaskSE(name),
43 // Default constructor
46 void AliAnalysisTaskDiJets::UserCreateOutputObjects()
48 // Create the output container
50 if (fDebug > 1) printf("AnalysisTaskDiJets::CreateOutPutData() \n");
51 fDiJets = new TClonesArray("AliAODDiJet", 0);
52 fDiJets->SetName("Dijets");
53 AddAODBranch("TClonesArray", &fDiJets);
56 void AliAnalysisTaskDiJets::Init()
59 if (fDebug > 1) printf("AnalysisTaskDiJets::Init() \n");
62 void AliAnalysisTaskDiJets::UserExec(Option_t */*option*/)
64 // Execute analysis for current event
67 AliAODEvent* aod = dynamic_cast<AliAODEvent*> (InputEvent());
70 // We do not have an input AOD, look in the output
73 Printf("%s:%d AODEvent not found in the Output",(char*)__FILE__,__LINE__);
78 TClonesArray* jets = aod->GetJets();
80 // N.B. if we take the aod from the output this is always
81 // empty and since it is the same as fDiJets
82 fDiJetsIn = (TClonesArray*) (aod->GetList()->FindObject("Dijets"));
85 printf("Found %d dijets in old list \n", fDiJetsIn->GetEntries());
89 if (fDiJetsIn->GetEntries() > 0) {
90 testJ = (AliAODDiJet*) (fDiJetsIn->At(0));
99 Int_t nj = jets->GetEntriesFast();
100 printf("There are %5d jets in the event \n", nj);
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);
120 void AliAnalysisTaskDiJets::Terminate(Option_t */*option*/)
122 // Terminate analysis
124 if (fDebug > 1) printf("AnalysisDiJets: Terminate() \n");