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 **************************************************************************/
16 //---------------------------------------------------------------------
17 // Jet finder base class
18 // manages the search for jets
19 // Author: jgcn@mda.cinvestav.mx
20 //---------------------------------------------------------------------
22 #include <Riostream.h>
24 #include "AliGenPythiaEventHeader.h"
25 #include "AliJetFinder.h"
27 #include "AliJetReader.h"
28 #include "AliJetReaderHeader.h"
29 #include "AliJetControlPlots.h"
30 #include "AliLeading.h"
31 #include "AliHeader.h"
33 ClassImp(AliJetFinder)
36 AliJetFinder::AliJetFinder():
49 fGenJets = new AliJet();
50 fLeading = new AliLeading();
53 //SetPlotMode(kFALSE);
56 ////////////////////////////////////////////////////////////////////////
58 AliJetFinder::~AliJetFinder()
61 // here reset and delete jets
64 fGenJets->ClearJets();
72 // reset and delete control plots
73 if (fPlots) delete fPlots;
76 ////////////////////////////////////////////////////////////////////////
78 void AliJetFinder::SetOutputFile(const char *name)
81 fOut = new TFile(name,"recreate");
84 ////////////////////////////////////////////////////////////////////////
86 void AliJetFinder::PrintJets()
88 // Print jet information
89 cout << " Jets found with jet algorithm:" << endl;
91 cout << " Jets found by pythia:" << endl;
92 fGenJets->PrintJets();
95 ////////////////////////////////////////////////////////////////////////
97 void AliJetFinder::SetPlotMode(Bool_t b)
99 // Sets the plotting mode
101 if (b && !fPlots) fPlots = new AliJetControlPlots();
104 ////////////////////////////////////////////////////////////////////////
106 void AliJetFinder::WriteJetsToFile(Int_t i)
108 // Writes the jets to file
111 sprintf(hname,"TreeJ%d",i);
112 TTree* jetT = new TTree(hname,"AliJet");
113 jetT->Branch("FoundJet",&fJets,1000);
114 jetT->Branch("GenJet",&fGenJets,1000);
115 jetT->Branch("LeadingPart",&fLeading,1000);
121 ////////////////////////////////////////////////////////////////////////
123 void AliJetFinder::WriteRHeaderToFile()
125 // write reader header
127 AliJetReaderHeader *rh = fReader->GetReaderHeader();
131 ////////////////////////////////////////////////////////////////////////
133 void AliJetFinder::GetGenJets()
135 // Get the generated jet information from mc header
136 AliHeader* alih = fReader->GetAliHeader();
137 if (alih == 0) return;
138 AliGenEventHeader * genh = alih->GenEventHeader();
139 if (genh == 0) return;
140 Int_t nj =((AliGenPythiaEventHeader*)genh)->NTriggerJets();
141 Int_t* m = new Int_t[nj];
142 Int_t* k = new Int_t[nj];
143 for (Int_t i=0; i< nj; i++) {
145 ((AliGenPythiaEventHeader*)genh)->TriggerJet(i,p);
146 fGenJets->AddJet(p[0],p[1],p[2],p[3]);
150 fGenJets->SetNinput(nj);
151 fGenJets->SetMultiplicities(m);
152 fGenJets->SetInJet(k);
155 ////////////////////////////////////////////////////////////////////////
157 void AliJetFinder::Run()
159 // do some initialization
163 fReader->OpenInputFiles();
168 WriteRHeaderToFile();
169 WriteJHeaderToFile();
173 nFirst = fReader->GetReaderHeader()->GetFirstEvent();
174 nLast = fReader->GetReaderHeader()->GetLastEvent();
176 for (Int_t i=nFirst;i<nLast;i++) {
177 fReader->FillMomentumArray(i);
178 fLeading->FindLeading(fReader);
181 if (fOut) WriteJetsToFile(i);
182 if (fPlots) fPlots->FillHistos(fJets);
184 fGenJets->ClearJets();
190 fPlots->PlotHistos();