* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
-
-
+
+/* $Id$ */
+
//---------------------------------------------------------------------
// Jet finder base class
// manages the search for jets
-// Author: jgcn@mda.cinvestav.mx
+// Authors: jgcn@mda.cinvestav.mx
+// andreas.morsch@cern.ch
+// magali.estienne@subatech.in2p3.fr
+// alexandre.shabetai@cern.ch
//---------------------------------------------------------------------
-#include <Riostream.h>
#include <TFile.h>
-#include "AliGenPythiaEventHeader.h"
-#include "AliJetFinder.h"
-#include "AliJet.h"
-#include "AliJetReader.h"
-#include "AliJetReaderHeader.h"
-#include "AliJetControlPlots.h"
-#include "AliLeading.h"
-#include "AliHeader.h"
+#include "AliJetFinder.h"
+#include "AliUA1JetHeaderV1.h"
+#include "AliAODJetEventBackground.h"
+#include "AliAODJet.h"
+#include "AliAODEvent.h"
ClassImp(AliJetFinder)
-////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////
-AliJetFinder::AliJetFinder()
+AliJetFinder::AliJetFinder():
+ fHeader(0x0),
+ fAODjets(0x0),
+ fNAODjets(0),
+ fAODEvBkg(0),
+ fDebug(0),
+ fCalTrkEvent(0x0)
{
- //
// Constructor
- //
- fOut = 0x0;
- fJets = new AliJet();
- fGenJets = new AliJet();
- fLeading = new AliLeading();
- fReader = 0x0;
- fPlots = 0x0;
- SetPlotMode(kFALSE);
}
-
-////////////////////////////////////////////////////////////////////////
-
+//-----------------------------------------------------------------------
AliJetFinder::~AliJetFinder()
{
- //
- // destructor
- //
-
- // here reset and delete jets
- fJets->ClearJets();
- delete fJets;
- fGenJets->ClearJets();
- delete fGenJets;
- // close file
- if (fOut) {
- fOut->Close();
- fOut->Delete();
- }
- delete fOut;
- // reset and delete control plots
- if (fPlots) delete fPlots;
- // delete fLeading;
+ // Destructor
}
-
-////////////////////////////////////////////////////////////////////////
-
-void AliJetFinder::SetOutputFile(const char *name)
+//-----------------------------------------------------------------------
+void AliJetFinder::WriteHeader()
{
- // opens output file
- fOut = new TFile(name,"recreate");
+ // Write the Headers
+ TFile* f = new TFile("jets_local.root", "recreate");
+ WriteHeaderToFile();
+ f->Close();
+
}
+//-----------------------------------------------------------------------
+void AliJetFinder::WriteHeaderToFile()
+{
+ // write reader header
+ AliJetHeader *rh = GetJetHeader();
+ rh->Write();
-////////////////////////////////////////////////////////////////////////
+}
-void AliJetFinder::PrintJets()
+//-----------------------------------------------------------------------
+Bool_t AliJetFinder::ProcessEvent()
{
-//
-// Print jet information
- cout << " Jets found with jet algorithm:" << endl;
- fJets->PrintJets();
- cout << " Jets found by pythia:" << endl;
- fGenJets->PrintJets();
-}
+ // Process one event
+ // Find jets
+ FindJets();
-////////////////////////////////////////////////////////////////////////
+ Reset();
+ return kTRUE;
-void AliJetFinder::SetPlotMode(Bool_t b)
-{
-// Sets the plotting mode
- fPlotMode=b;
- if (b && !fPlots) fPlots = new AliJetControlPlots();
}
-////////////////////////////////////////////////////////////////////////
-
-void AliJetFinder::WriteJetsToFile(Int_t i)
+//-----------------------------------------------------------------------
+void AliJetFinder::AddJet(AliAODJet p)
{
-// Writes the jets to file
- fOut->cd();
- char hname[30];
- sprintf(hname,"TreeJ%d",i);
- TTree* jetT = new TTree(hname,"AliJet");
- jetT->Branch("FoundJet",&fJets,1000);
- jetT->Branch("GenJet",&fGenJets,1000);
- jetT->Branch("LeadingPart",&fLeading,1000);
- jetT->Fill();
- jetT->Write(hname);
- delete jetT;
-}
+ // Add new jet to the list
+ if (fAODjets) { new ((*fAODjets)[fNAODjets++]) AliAODJet(p);}
+ else { Warning("AliJetFinder::AddJet(AliAODJet p)","fAODjets is null!");}
-////////////////////////////////////////////////////////////////////////
-
-void AliJetFinder::WriteRHeaderToFile()
-{
- // write reader header
- fOut->cd();
- AliJetReaderHeader *rh = fReader->GetReaderHeader();
- rh->Write();
}
-
-////////////////////////////////////////////////////////////////////////
-
-void AliJetFinder::GetGenJets()
+//-----------------------------------------------------------------------
+void AliJetFinder::ConnectAOD(const AliAODEvent* aod)
{
-// Get the generated jet information from mc header
- AliHeader* alih = fReader->GetAliHeader();
- if (alih == 0) return;
- AliGenEventHeader * genh = alih->GenEventHeader();
- if (genh == 0) return;
- Int_t nj =((AliGenPythiaEventHeader*)genh)->NTriggerJets();
- Int_t* m = new Int_t[nj];
- Int_t* k = new Int_t[nj];
- for (Int_t i=0; i< nj; i++) {
- Float_t p[4];
- ((AliGenPythiaEventHeader*)genh)->TriggerJet(i,p);
- fGenJets->AddJet(p[0],p[1],p[2],p[3]);
- m[i]=1;
- k[i]=i;
- }
- fGenJets->SetNinput(nj);
- fGenJets->SetMultiplicities(m);
- fGenJets->SetInJet(k);
-}
+ // Connect to the AOD
+ fAODjets = aod->GetJets();
+ fAODEvBkg = (AliAODJetEventBackground*)(aod->FindListObject(AliAODJetEventBackground::StdBranchName()));
-////////////////////////////////////////////////////////////////////////
+}
-void AliJetFinder::Run()
+//-----------------------------------------------------------------------
+void AliJetFinder::ConnectAODNonStd(AliAODEvent* aod,const char *bname)
{
- // do some initialization
- Init();
-
- // connect files
- fReader->OpenInputFiles();
-
- // write headers
- if (fOut) {
- fOut->cd();
- WriteRHeaderToFile();
- WriteJHeaderToFile();
- }
-
- // loop over events
- Int_t nFirst,nLast;
- nFirst = fReader->GetReaderHeader()->GetFirstEvent();
- nLast = fReader->GetReaderHeader()->GetLastEvent();
- // loop over events
- for (Int_t i=nFirst;i<nLast;i++) {
- fReader->FillMomentumArray(i);
- fLeading->FindLeading(fReader);
- GetGenJets();
- FindJets();
- if (fOut) WriteJetsToFile(i);
- if (fPlots) fPlots->FillHistos(fJets,fReader);
- fLeading->Reset();
- fGenJets->ClearJets();
- Reset();
- }
- // write out
- if (fPlots) {
- fPlots->Normalize();
- fPlots->PlotHistos();
- }
- if (fOut) {
- fOut->cd();
- fPlots->Write();
- fOut->Close();
- }
+ // Connect non standard AOD jet and jet background branches
+ fAODjets = dynamic_cast<TClonesArray*>(aod->FindListObject(bname));
+ fAODEvBkg = (AliAODJetEventBackground*)(aod->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),bname)));
+ // how is this is reset? Cleared? -> by the UserExec!!
+
}