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()
41 fGenJets = new AliJet();
42 fLeading = new AliLeading();
48 ////////////////////////////////////////////////////////////////////////
50 AliJetFinder::~AliJetFinder()
53 // here reset and delete jets
56 fGenJets->ClearJets();
64 // reset and delete control plots
65 if (fPlots) delete fPlots;
68 ////////////////////////////////////////////////////////////////////////
70 void AliJetFinder::SetOutputFile(const char *name)
73 fOut = new TFile(name,"recreate");
76 ////////////////////////////////////////////////////////////////////////
78 void AliJetFinder::PrintJets()
80 // Print jet information
81 cout << " Jets found with jet algorithm:" << endl;
83 cout << " Jets found by pythia:" << endl;
84 fGenJets->PrintJets();
87 ////////////////////////////////////////////////////////////////////////
89 void AliJetFinder::SetPlotMode(Bool_t b)
91 // Sets the plotting mode
93 if (b && !fPlots) fPlots = new AliJetControlPlots();
96 ////////////////////////////////////////////////////////////////////////
98 void AliJetFinder::WriteJetsToFile(Int_t i)
100 // Writes the jets to file
103 sprintf(hname,"TreeJ%d",i);
104 TTree* jetT = new TTree(hname,"AliJet");
105 jetT->Branch("FoundJet",&fJets,1000);
106 jetT->Branch("GenJet",&fGenJets,1000);
107 jetT->Branch("LeadingPart",&fLeading,1000);
113 ////////////////////////////////////////////////////////////////////////
115 void AliJetFinder::WriteRHeaderToFile()
117 // write reader header
119 AliJetReaderHeader *rh = fReader->GetReaderHeader();
123 ////////////////////////////////////////////////////////////////////////
125 void AliJetFinder::GetGenJets()
127 // Get the generated jet information from mc header
128 AliHeader* alih = fReader->GetAliHeader();
129 if (alih == 0) return;
130 AliGenEventHeader * genh = alih->GenEventHeader();
131 if (genh == 0) return;
132 Int_t nj =((AliGenPythiaEventHeader*)genh)->NTriggerJets();
133 Int_t* m = new Int_t[nj];
134 Int_t* k = new Int_t[nj];
135 for (Int_t i=0; i< nj; i++) {
137 ((AliGenPythiaEventHeader*)genh)->TriggerJet(i,p);
138 fGenJets->AddJet(p[0],p[1],p[2],p[3]);
142 fGenJets->SetNinput(nj);
143 fGenJets->SetMultiplicities(m);
144 fGenJets->SetInJet(k);
147 ////////////////////////////////////////////////////////////////////////
149 void AliJetFinder::Run()
151 // do some initialization
155 fReader->OpenInputFiles();
160 WriteRHeaderToFile();
161 WriteJHeaderToFile();
165 nFirst = fReader->GetReaderHeader()->GetFirstEvent();
166 nLast = fReader->GetReaderHeader()->GetLastEvent();
168 for (Int_t i=nFirst;i<nLast;i++) {
169 fReader->FillMomentumArray(i);
170 fLeading->FindLeading(fReader);
173 if (fOut) WriteJetsToFile(i);
174 if (fPlots) fPlots->FillHistos(fJets);
176 fGenJets->ClearJets();
182 fPlots->PlotHistos();