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():
50 fGenJets = new AliJet();
51 fLeading = new AliLeading();
54 ////////////////////////////////////////////////////////////////////////
56 AliJetFinder::~AliJetFinder()
59 // here reset and delete jets
62 fGenJets->ClearJets();
70 // reset and delete control plots
71 if (fPlots) delete fPlots;
74 ////////////////////////////////////////////////////////////////////////
76 void AliJetFinder::SetOutputFile(const char *name)
79 fOut = new TFile(name,"recreate");
82 ////////////////////////////////////////////////////////////////////////
84 void AliJetFinder::PrintJets()
86 // Print jet information
87 cout << " Jets found with jet algorithm:" << endl;
89 cout << " Jets found by pythia:" << endl;
90 fGenJets->PrintJets();
93 ////////////////////////////////////////////////////////////////////////
95 void AliJetFinder::SetPlotMode(Bool_t b)
97 // Sets the plotting mode
99 if (b && !fPlots) fPlots = new AliJetControlPlots();
102 ////////////////////////////////////////////////////////////////////////
104 void AliJetFinder::WriteJetsToFile(Int_t i)
106 // Writes the jets to file
109 sprintf(hname,"TreeJ%d",i);
110 fJetT = new TTree(hname,"AliJet");
111 fJetT->Branch("FoundJet",&fJets,1000);
112 fJetT->Branch("GenJet",&fGenJets,1000);
113 fJetT->Branch("LeadingPart",&fLeading,1000);
119 ////////////////////////////////////////////////////////////////////////
121 void AliJetFinder::WriteRHeaderToFile()
123 // write reader header
125 AliJetReaderHeader *rh = fReader->GetReaderHeader();
129 ////////////////////////////////////////////////////////////////////////
132 void AliJetFinder::Run()
134 // Do some initialization
137 fReader->OpenInputFiles();
142 Int_t nFirst, nLast, option, debug, arrayInitialised;
143 nFirst = fReader->GetReaderHeader()->GetFirstEvent();
144 nLast = fReader->GetReaderHeader()->GetLastEvent();
146 option = fReader->GetReaderHeader()->GetDetector();
147 debug = fReader->GetReaderHeader()->GetDebug();
148 arrayInitialised = fReader->GetArrayInitialised();
151 for (Int_t i=nFirst;i<nLast;i++) {
152 fReader->FillMomentumArray(i);
153 fLeading->FindLeading(fReader);
154 fReader->GetGenJets(fGenJets);
156 if (option == 0) { // TPC with fMomentumArray
158 printf("In FindJetsTPC() routine: find jets with fMomentumArray !!!\n");
161 if(debug > 1) printf("In FindJets() routine: find jets with fUnitArray !!!\n");
164 if (fOut) WriteJetsToFile(i);
165 if (fPlots) fPlots->FillHistos(fJets);
167 fGenJets->ClearJets();
174 fPlots->PlotHistos();
185 // The following methods have been added to allow for event steering from the outside
188 void AliJetFinder::ConnectTree(TTree* tree)
190 // Connect the input file
191 fReader->ConnectTree(tree);
194 void AliJetFinder::WriteHeaders()
199 WriteRHeaderToFile();
200 WriteJHeaderToFile();
205 Bool_t AliJetFinder::ProcessEvent(Long64_t entry)
210 printf("<<<<< Processing Event %5d >>>>> \n", (Int_t) entry);
211 Bool_t ok = fReader->FillMomentumArray(entry);
212 if (!ok) return kFALSE;
213 fLeading->FindLeading(fReader);
215 if (fOut) WriteJetsToFile(entry);
216 if (fPlots) fPlots->FillHistos(fJets);
218 fGenJets->ClearJets();
223 void AliJetFinder::FinishRun()
228 fPlots->PlotHistos();
235 if (fOut) fOut->Close();