#include <Riostream.h>
#include <TFile.h>
+#include <TClonesArray.h>
+
#include "AliJetFinder.h"
#include "AliJet.h"
+#include "AliAODJet.h"
#include "AliJetReader.h"
#include "AliJetReaderHeader.h"
#include "AliJetControlPlots.h"
#include "AliLeading.h"
+#include "AliAODEvent.h"
ClassImp(AliJetFinder)
AliJetFinder::AliJetFinder():
- fJetT(0),
+ fTreeJ(0),
fPlotMode(kFALSE),
fJets(0),
fGenJets(0),
fLeading(0),
fReader(0x0),
fHeader(0x0),
+ fAODjets(0x0),
+ fNAODjets(0),
fPlots(0x0),
fOut(0x0)
fJets = new AliJet();
fGenJets = new AliJet();
fLeading = new AliLeading();
+ fAODjets = 0;
}
////////////////////////////////////////////////////////////////////////
delete fOut;
// reset and delete control plots
if (fPlots) delete fPlots;
+ if ( fLeading )
+ delete fLeading;
+ fLeading = NULL;
}
////////////////////////////////////////////////////////////////////////
-void AliJetFinder::SetOutputFile(const char *name)
+void AliJetFinder::SetOutputFile(const char */*name*/)
{
- // opens output file
- fOut = new TFile(name,"recreate");
+ // opens output file
+ // fOut = new TFile(name,"recreate");
}
////////////////////////////////////////////////////////////////////////
}
////////////////////////////////////////////////////////////////////////
-
-void AliJetFinder::WriteJetsToFile(Int_t i)
+TTree* AliJetFinder::MakeTreeJ(char* name)
{
- // Writes the jets to file
- fOut->cd();
- char hname[30];
- sprintf(hname,"TreeJ%d",i);
- fJetT = new TTree(hname,"AliJet");
- fJetT->Branch("FoundJet",&fJets,1000);
- fJetT->Branch("GenJet",&fGenJets,1000);
- fJetT->Branch("LeadingPart",&fLeading,1000);
- fJetT->Fill();
- fJetT->Write(hname);
- delete fJetT;
+ // Create the tree for reconstructed jets
+ fTreeJ = new TTree(name, "AliJet");
+ fTreeJ->Branch("FoundJet", &fJets, 1000);
+ fTreeJ->Branch("GenJet", &fGenJets,1000);
+ fTreeJ->Branch("LeadingPart",&fLeading,1000);
+ return fTreeJ;
}
////////////////////////////////////////////////////////////////////////
void AliJetFinder::WriteRHeaderToFile()
{
// write reader header
- fOut->cd();
- AliJetReaderHeader *rh = fReader->GetReaderHeader();
- rh->Write();
+ AliJetReaderHeader *rh = fReader->GetReaderHeader();
+ rh->Write();
}
////////////////////////////////////////////////////////////////////////
// loop over events
for (Int_t i=nFirst;i<nLast;i++) {
- fReader->FillMomentumArray(i);
+ fReader->FillMomentumArray();
fLeading->FindLeading(fReader);
fReader->GetGenJets(fGenJets);
if(debug > 1) printf("In FindJets() routine: find jets with fUnitArray !!!\n");
FindJets();
}
- if (fOut) WriteJetsToFile(i);
+ if (fOut) {
+ fOut->cd();
+ }
+
if (fPlots) fPlots->FillHistos(fJets);
fLeading->Reset();
fGenJets->ClearJets();
// The following methods have been added to allow for event steering from the outside
//
-void AliJetFinder::ConnectTree(TTree* tree)
+void AliJetFinder::ConnectTree(TTree* tree, TObject* data)
{
// Connect the input file
- fReader->ConnectTree(tree);
+ fReader->ConnectTree(tree, data);
}
void AliJetFinder::WriteHeaders()
{
// Write the Headers
- if (fOut) {
- fOut->cd();
- WriteRHeaderToFile();
- WriteJHeaderToFile();
- }
+ TFile* f = new TFile("jets_local.root", "recreate");
+ WriteRHeaderToFile();
+ WriteJHeaderToFile();
+ f->Close();
}
-Bool_t AliJetFinder::ProcessEvent(Long64_t entry)
+Bool_t AliJetFinder::ProcessEvent()
{
//
// Process one event
//
- printf("<<<<< Processing Event %5d >>>>> \n", (Int_t) entry);
- Bool_t ok = fReader->FillMomentumArray(entry);
+ Bool_t ok = fReader->FillMomentumArray();
if (!ok) return kFALSE;
+
+ // Leading particles
fLeading->FindLeading(fReader);
+ // Jets
FindJets();
- if (fOut) WriteJetsToFile(entry);
+
if (fPlots) fPlots->FillHistos(fJets);
fLeading->Reset();
fGenJets->ClearJets();
void AliJetFinder::FinishRun()
{
// Finish a run
- if (fPlots) {
- fPlots->Normalize();
- fPlots->PlotHistos();
- if (fOut) {
- fOut->cd();
- fPlots->Write();
- fOut->Close();
- }
- } else {
- if (fOut) fOut->Close();
- }
+ if (fPlots) {
+ fPlots->Normalize();
+ fPlots->PlotHistos();
+ }
+
+ if (fOut) {
+ fOut->cd();
+ if (fPlots) {
+ fPlots->Write();
+ }
+ fOut->Close();
+ }
+}
+
+void AliJetFinder::AddJet(AliAODJet p)
+{
+ // Add new jet to the list
+ new ((*fAODjets)[fNAODjets++]) AliAODJet(p);
+}
+
+void AliJetFinder::ConnectAOD(AliAODEvent* aod)
+{
+// Connect to the AOD
+ fAODjets = aod->GetJets();
}
+void AliJetFinder::ConnectAODNonStd(AliAODEvent* aod,const char *bname)
+{
+
+ fAODjets = dynamic_cast<TClonesArray*>(aod->FindListObject(bname));
+ // how is this is reset? Cleared?
+}