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 //---------------------------------------------------------------------
19 // Jet finder base class
20 // manages the search for jets
21 // Authors: jgcn@mda.cinvestav.mx
22 // andreas.morsch@cern.ch
23 //---------------------------------------------------------------------
25 #include <Riostream.h>
27 #include <TClonesArray.h>
29 #include "AliJetFinder.h"
31 #include "AliAODJet.h"
32 #include "AliJetReader.h"
33 #include "AliJetReaderHeader.h"
34 #include "AliJetControlPlots.h"
35 #include "AliLeading.h"
36 #include "AliAODEvent.h"
38 ClassImp(AliJetFinder)
40 AliJetFinder::AliJetFinder():
56 fGenJets = new AliJet();
57 fLeading = new AliLeading();
61 ////////////////////////////////////////////////////////////////////////
63 AliJetFinder::~AliJetFinder()
66 // here reset and delete jets
69 fGenJets->ClearJets();
77 // reset and delete control plots
78 if (fPlots) delete fPlots;
81 ////////////////////////////////////////////////////////////////////////
83 void AliJetFinder::SetOutputFile(const char */*name*/)
86 // fOut = new TFile(name,"recreate");
89 ////////////////////////////////////////////////////////////////////////
91 void AliJetFinder::PrintJets()
93 // Print jet information
94 cout << " Jets found with jet algorithm:" << endl;
96 cout << " Jets found by pythia:" << endl;
97 fGenJets->PrintJets();
100 ////////////////////////////////////////////////////////////////////////
102 void AliJetFinder::SetPlotMode(Bool_t b)
104 // Sets the plotting mode
106 if (b && !fPlots) fPlots = new AliJetControlPlots();
109 ////////////////////////////////////////////////////////////////////////
110 TTree* AliJetFinder::MakeTreeJ(char* name)
112 // Create the tree for reconstructed jets
113 fTreeJ = new TTree(name, "AliJet");
114 fTreeJ->Branch("FoundJet", &fJets, 1000);
115 fTreeJ->Branch("GenJet", &fGenJets,1000);
116 fTreeJ->Branch("LeadingPart",&fLeading,1000);
120 ////////////////////////////////////////////////////////////////////////
122 void AliJetFinder::WriteRHeaderToFile()
124 // write reader header
125 AliJetReaderHeader *rh = fReader->GetReaderHeader();
129 ////////////////////////////////////////////////////////////////////////
132 void AliJetFinder::Run()
134 // Do some initialization
137 fReader->OpenInputFiles();
142 Int_t nFirst, nLast, option, debug, arrayInitialised;
143 nFirst = fReader->GetReaderHeader()->GetFirstEvent();
144 nLast = fReader->GetReaderHeader()->GetLastEvent();
146 option = fReader->GetReaderHeader()->GetDetector();
147 debug = fReader->GetReaderHeader()->GetDebug();
148 arrayInitialised = fReader->GetArrayInitialised();
151 for (Int_t i=nFirst;i<nLast;i++) {
152 fReader->FillMomentumArray();
153 fLeading->FindLeading(fReader);
154 fReader->GetGenJets(fGenJets);
156 if (option == 0) { // TPC with fMomentumArray
158 printf("In FindJetsTPC() routine: find jets with fMomentumArray !!!\n");
161 if(debug > 1) printf("In FindJets() routine: find jets with fUnitArray !!!\n");
168 if (fPlots) fPlots->FillHistos(fJets);
170 fGenJets->ClearJets();
177 fPlots->PlotHistos();
188 // The following methods have been added to allow for event steering from the outside
191 void AliJetFinder::ConnectTree(TTree* tree, TObject* data)
193 // Connect the input file
194 fReader->ConnectTree(tree, data);
197 void AliJetFinder::WriteHeaders()
200 TFile* f = new TFile("jets_local.root", "recreate");
201 WriteRHeaderToFile();
202 WriteJHeaderToFile();
207 Bool_t AliJetFinder::ProcessEvent()
212 Bool_t ok = fReader->FillMomentumArray();
213 if (!ok) return kFALSE;
216 fLeading->FindLeading(fReader);
220 if (fPlots) fPlots->FillHistos(fJets);
222 fGenJets->ClearJets();
227 void AliJetFinder::FinishRun()
232 fPlots->PlotHistos();
244 void AliJetFinder::AddJet(AliAODJet p)
246 // Add new jet to the list
247 new ((*fAODjets)[fNAODjets++]) AliAODJet(p);
250 void AliJetFinder::ConnectAOD(AliAODEvent* aod)
252 // Connect to the AOD
253 fAODjets = aod->GetJets();