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();
138 Int_t nFirst, nLast, option, debug, arrayInitialised;
139 nFirst = fReader->GetReaderHeader()->GetFirstEvent();
140 nLast = fReader->GetReaderHeader()->GetLastEvent();
142 option = fReader->GetReaderHeader()->GetDetector();
143 debug = fReader->GetReaderHeader()->GetDebug();
144 arrayInitialised = fReader->GetArrayInitialised();
147 for (Int_t i=nFirst;i<nLast;i++) {
148 fReader->FillMomentumArray(i);
149 fLeading->FindLeading(fReader);
150 fReader->GetGenJets(fGenJets);
152 if (option == 0) { // TPC with fMomentumArray
154 printf("In FindJetsTPC() routine: find jets with fMomentumArray !!!\n");
157 if(debug > 1) printf("In FindJets() routine: find jets with fUnitArray !!!\n");
160 if (fOut) WriteJetsToFile(i);
161 if (fPlots) fPlots->FillHistos(fJets);
163 fGenJets->ClearJets();
170 fPlots->PlotHistos();
181 // The following methods have been added to allow for event steering from the outside
184 void AliJetFinder::ConnectTree(TTree* tree)
186 // Connect the input file
187 fReader->ConnectTree(tree);
190 void AliJetFinder::WriteHeaders()
195 WriteRHeaderToFile();
196 WriteJHeaderToFile();
201 Bool_t AliJetFinder::ProcessEvent(Long64_t entry)
206 printf("<<<<< Processing Event %5d >>>>> \n", (Int_t) entry);
207 Bool_t ok = fReader->FillMomentumArray(entry);
208 if (!ok) return kFALSE;
209 fLeading->FindLeading(fReader);
211 if (fOut) WriteJetsToFile(entry);
212 if (fPlots) fPlots->FillHistos(fJets);
214 fGenJets->ClearJets();
219 void AliJetFinder::FinishRun()
224 fPlots->PlotHistos();
231 if (fOut) fOut->Close();