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 **************************************************************************/
17 //---------------------------------------------------------------------
18 // Jet finder base class
19 // manages the search for jets
20 // Author: jgcn@mda.cinvestav.mx
21 //---------------------------------------------------------------------
23 #include <Riostream.h>
25 #include "AliGenPythiaEventHeader.h"
26 #include "AliJetFinder.h"
28 #include "AliJetReader.h"
29 #include "AliJetReaderHeader.h"
30 #include "AliJetControlPlots.h"
31 #include "AliLeading.h"
32 #include "AliHeader.h"
35 ClassImp(AliJetFinder)
37 ////////////////////////////////////////////////////////////////////////
39 AliJetFinder::AliJetFinder()
46 fGenJets = new AliJet();
47 fLeading = new AliLeading();
54 ////////////////////////////////////////////////////////////////////////
56 AliJetFinder::~AliJetFinder()
62 // here reset and delete jets
65 fGenJets->ClearJets();
73 // reset and delete control plots
74 if (fPlots) delete fPlots;
79 ////////////////////////////////////////////////////////////////////////
81 void AliJetFinder::SetOutputFile(const char *name)
84 fOut = new TFile(name,"recreate");
88 ////////////////////////////////////////////////////////////////////////
90 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();
101 ////////////////////////////////////////////////////////////////////////
103 void AliJetFinder::SetPlotMode(Bool_t b)
105 // Sets the plotting mode
107 if (b && !fPlots) fPlots = new AliJetControlPlots();
110 ////////////////////////////////////////////////////////////////////////
112 void AliJetFinder::WriteJetsToFile(Int_t i)
114 // Writes the jets to file
117 sprintf(hname,"TreeJ%d",i);
118 TTree* jetT = new TTree(hname,"AliJet");
119 jetT->Branch("FoundJet",&fJets,1000);
120 jetT->Branch("GenJet",&fGenJets,1000);
121 jetT->Branch("LeadingPart",&fLeading,1000);
127 ////////////////////////////////////////////////////////////////////////
129 void AliJetFinder::WriteRHeaderToFile()
131 // write reader header
133 AliJetReaderHeader *rh = fReader->GetReaderHeader();
138 ////////////////////////////////////////////////////////////////////////
140 void AliJetFinder::GetGenJets()
142 // Get the generated jet information from mc header
143 AliHeader* alih = fReader->GetAliHeader();
144 if (alih == 0) return;
145 AliGenEventHeader * genh = alih->GenEventHeader();
146 if (genh == 0) return;
147 Int_t nj =((AliGenPythiaEventHeader*)genh)->NTriggerJets();
148 Int_t* m = new Int_t[nj];
149 Int_t* k = new Int_t[nj];
150 for (Int_t i=0; i< nj; i++) {
152 ((AliGenPythiaEventHeader*)genh)->TriggerJet(i,p);
153 fGenJets->AddJet(p[0],p[1],p[2],p[3]);
157 fGenJets->SetNinput(nj);
158 fGenJets->SetMultiplicities(m);
159 fGenJets->SetInJet(k);
162 ////////////////////////////////////////////////////////////////////////
164 void AliJetFinder::Run()
166 // do some initialization
170 fReader->OpenInputFiles();
175 WriteRHeaderToFile();
176 WriteJHeaderToFile();
181 nFirst = fReader->GetReaderHeader()->GetFirstEvent();
182 nLast = fReader->GetReaderHeader()->GetLastEvent();
184 for (Int_t i=nFirst;i<nLast;i++) {
185 fReader->FillMomentumArray(i);
186 fLeading->FindLeading(fReader);
189 if (fOut) WriteJetsToFile(i);
190 if (fPlots) fPlots->FillHistos(fJets,fReader);
192 fGenJets->ClearJets();
198 fPlots->PlotHistos();