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 **************************************************************************/
18 //---------------------------------------------------------------------
19 // Jet finder base class
20 // manages the search for jets
21 // Authors: jgcn@mda.cinvestav.mx
22 // andreas.morsch@cern.ch
23 //---------------------------------------------------------------------
25 #include <Riostream.h>
27 #include "AliJetFinder.h"
29 #include "AliJetReader.h"
30 #include "AliJetReaderHeader.h"
31 #include "AliJetControlPlots.h"
32 #include "AliLeading.h"
34 ClassImp(AliJetFinder)
36 AliJetFinder::AliJetFinder():
48 fGenJets = new AliJet();
49 fLeading = new AliLeading();
52 ////////////////////////////////////////////////////////////////////////
54 AliJetFinder::~AliJetFinder()
57 // here reset and delete jets
60 fGenJets->ClearJets();
68 // reset and delete control plots
69 if (fPlots) delete fPlots;
72 ////////////////////////////////////////////////////////////////////////
74 void AliJetFinder::SetOutputFile(const char *name)
77 fOut = new TFile(name,"recreate");
80 ////////////////////////////////////////////////////////////////////////
82 void AliJetFinder::PrintJets()
84 // Print jet information
85 cout << " Jets found with jet algorithm:" << endl;
87 cout << " Jets found by pythia:" << endl;
88 fGenJets->PrintJets();
91 ////////////////////////////////////////////////////////////////////////
93 void AliJetFinder::SetPlotMode(Bool_t b)
95 // Sets the plotting mode
97 if (b && !fPlots) fPlots = new AliJetControlPlots();
100 ////////////////////////////////////////////////////////////////////////
102 void AliJetFinder::WriteJetsToFile(Int_t i)
104 // Writes the jets to file
107 sprintf(hname,"TreeJ%d",i);
108 TTree* jetT = new TTree(hname,"AliJet");
109 jetT->Branch("FoundJet",&fJets,1000);
110 jetT->Branch("GenJet",&fGenJets,1000);
111 jetT->Branch("LeadingPart",&fLeading,1000);
117 ////////////////////////////////////////////////////////////////////////
119 void AliJetFinder::WriteRHeaderToFile()
121 // write reader header
123 AliJetReaderHeader *rh = fReader->GetReaderHeader();
127 ////////////////////////////////////////////////////////////////////////
130 void AliJetFinder::Run()
132 // Do some initialization
135 fReader->OpenInputFiles();
140 Int_t nFirst, nLast, option, debug, arrayInitialised;
141 nFirst = fReader->GetReaderHeader()->GetFirstEvent();
142 nLast = fReader->GetReaderHeader()->GetLastEvent();
144 option = fReader->GetReaderHeader()->GetDetector();
145 debug = fReader->GetReaderHeader()->GetDebug();
146 arrayInitialised = fReader->GetArrayInitialised();
149 for (Int_t i=nFirst;i<nLast;i++) {
150 fReader->FillMomentumArray(i);
151 fLeading->FindLeading(fReader);
152 fReader->GetGenJets(fGenJets);
154 if (option == 0) { // TPC with fMomentumArray
156 printf("In FindJetsTPC() routine: find jets with fMomentumArray !!!\n");
159 if(debug > 1) printf("In FindJets() routine: find jets with fUnitArray !!!\n");
162 if (fOut) WriteJetsToFile(i);
163 if (fPlots) fPlots->FillHistos(fJets);
165 fGenJets->ClearJets();
172 fPlots->PlotHistos();
183 // The following methods have been added to allow for event steering from the outside
186 void AliJetFinder::ConnectTree(TTree* tree)
188 // Connect the input file
189 fReader->ConnectTree(tree);
192 void AliJetFinder::WriteHeaders()
197 WriteRHeaderToFile();
198 WriteJHeaderToFile();
203 Bool_t AliJetFinder::ProcessEvent(Long64_t entry)
208 printf("<<<<< Processing Event %5d >>>>> \n", (Int_t) entry);
209 Bool_t ok = fReader->FillMomentumArray(entry);
210 if (!ok) return kFALSE;
211 fLeading->FindLeading(fReader);
213 if (fOut) WriteJetsToFile(entry);
214 if (fPlots) fPlots->FillHistos(fJets);
216 fGenJets->ClearJets();
221 void AliJetFinder::FinishRun()
226 fPlots->PlotHistos();
233 if (fOut) fOut->Close();