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 // Authors: jgcn@mda.cinvestav.mx
20 // andreas.morsch@cern.ch
21 //---------------------------------------------------------------------
23 #include <Riostream.h>
25 #include "AliJetFinder.h"
27 #include "AliJetReader.h"
28 #include "AliJetReaderHeader.h"
29 #include "AliJetControlPlots.h"
30 #include "AliLeading.h"
32 ClassImp(AliJetFinder)
34 AliJetFinder::AliJetFinder():
46 fGenJets = new AliJet();
47 fLeading = new AliLeading();
50 ////////////////////////////////////////////////////////////////////////
52 AliJetFinder::~AliJetFinder()
55 // here reset and delete jets
58 fGenJets->ClearJets();
66 // reset and delete control plots
67 if (fPlots) delete fPlots;
70 ////////////////////////////////////////////////////////////////////////
72 void AliJetFinder::SetOutputFile(const char *name)
75 fOut = new TFile(name,"recreate");
78 ////////////////////////////////////////////////////////////////////////
80 void AliJetFinder::PrintJets()
82 // Print jet information
83 cout << " Jets found with jet algorithm:" << endl;
85 cout << " Jets found by pythia:" << endl;
86 fGenJets->PrintJets();
89 ////////////////////////////////////////////////////////////////////////
91 void AliJetFinder::SetPlotMode(Bool_t b)
93 // Sets the plotting mode
95 if (b && !fPlots) fPlots = new AliJetControlPlots();
98 ////////////////////////////////////////////////////////////////////////
100 void AliJetFinder::WriteJetsToFile(Int_t i)
102 // Writes the jets to file
105 sprintf(hname,"TreeJ%d",i);
106 TTree* jetT = new TTree(hname,"AliJet");
107 jetT->Branch("FoundJet",&fJets,1000);
108 jetT->Branch("GenJet",&fGenJets,1000);
109 jetT->Branch("LeadingPart",&fLeading,1000);
115 ////////////////////////////////////////////////////////////////////////
117 void AliJetFinder::WriteRHeaderToFile()
119 // write reader header
121 AliJetReaderHeader *rh = fReader->GetReaderHeader();
125 ////////////////////////////////////////////////////////////////////////
128 void AliJetFinder::Run()
130 // Do some initialization
133 fReader->OpenInputFiles();
139 nFirst = fReader->GetReaderHeader()->GetFirstEvent();
140 nLast = fReader->GetReaderHeader()->GetLastEvent();
142 for (Int_t i=nFirst;i<nLast;i++) {
143 fReader->FillMomentumArray(i);
144 fLeading->FindLeading(fReader);
145 fReader->GetGenJets(fGenJets);
147 if (fOut) WriteJetsToFile(i);
148 if (fPlots) fPlots->FillHistos(fJets);
150 fGenJets->ClearJets();
156 fPlots->PlotHistos();
167 // The following methods have been added to allow for event steering from the outside
170 void AliJetFinder::ConnectTree(TTree* tree)
172 // Connect the input file
173 fReader->ConnectTree(tree);
176 void AliJetFinder::WriteHeaders()
181 WriteRHeaderToFile();
182 WriteJHeaderToFile();
187 Bool_t AliJetFinder::ProcessEvent(Long64_t entry)
192 printf("<<<<< Processing Event %5d >>>>> \n", (Int_t) entry);
193 Bool_t ok = fReader->FillMomentumArray(entry);
194 if (!ok) return kFALSE;
195 fLeading->FindLeading(fReader);
197 if (fOut) WriteJetsToFile(entry);
198 if (fPlots) fPlots->FillHistos(fJets);
200 fGenJets->ClearJets();
205 void AliJetFinder::FinishRun()
210 fPlots->PlotHistos();