X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=JETAN%2FAliJetFinder.cxx;h=799613863449acda187f66566fde4d9f1237098d;hb=e8f0a920a93fe1a5eeede1802653686d806d87a4;hp=7a4d5f56a0ac1c0572300c1b607bb2c75b42132a;hpb=97047b83ddd56d8eda1271cbb257795353f26b77;p=u%2Fmrichter%2FAliRoot.git diff --git a/JETAN/AliJetFinder.cxx b/JETAN/AliJetFinder.cxx index 7a4d5f56a0a..79961386344 100644 --- a/JETAN/AliJetFinder.cxx +++ b/JETAN/AliJetFinder.cxx @@ -13,222 +13,103 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ +/* $Id$ */ + //--------------------------------------------------------------------- // Jet finder base class // manages the search for jets // Authors: jgcn@mda.cinvestav.mx // andreas.morsch@cern.ch +// magali.estienne@subatech.in2p3.fr +// alexandre.shabetai@cern.ch //--------------------------------------------------------------------- -#include #include + #include "AliJetFinder.h" -#include "AliJet.h" -#include "AliJetReader.h" -#include "AliJetReaderHeader.h" -#include "AliJetControlPlots.h" -#include "AliLeading.h" +#include "AliUA1JetHeaderV1.h" +#include "AliAODJetEventBackground.h" +#include "AliAODJet.h" +#include "AliAODEvent.h" ClassImp(AliJetFinder) +/////////////////////////////////////////////////////////////////////// + AliJetFinder::AliJetFinder(): - fPlotMode(kFALSE), - fJets(0), - fGenJets(0), - fLeading(0), - fReader(0x0), - fPlots(0x0), - fOut(0x0) - + fHeader(0x0), + fAODjets(0x0), + fNAODjets(0), + fAODEvBkg(0), + fDebug(0), + fCalTrkEvent(0x0) { // Constructor - fJets = new AliJet(); - fGenJets = new AliJet(); - fLeading = new AliLeading(); } -//////////////////////////////////////////////////////////////////////// - +//----------------------------------------------------------------------- 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; + // Destructor } -//////////////////////////////////////////////////////////////////////// - -void AliJetFinder::SetOutputFile(const char *name) -{ - // opens output file - fOut = new TFile(name,"recreate"); -} - -//////////////////////////////////////////////////////////////////////// - -void AliJetFinder::PrintJets() -{ - // Print jet information - cout << " Jets found with jet algorithm:" << endl; - fJets->PrintJets(); - cout << " Jets found by pythia:" << endl; - fGenJets->PrintJets(); -} - -//////////////////////////////////////////////////////////////////////// - -void AliJetFinder::SetPlotMode(Bool_t b) +//----------------------------------------------------------------------- +void AliJetFinder::WriteHeader() { - // Sets the plotting mode - fPlotMode=b; - if (b && !fPlots) fPlots = new AliJetControlPlots(); -} - -//////////////////////////////////////////////////////////////////////// + // Write the Headers + TFile* f = new TFile("jets_local.root", "recreate"); + WriteHeaderToFile(); + f->Close(); -void AliJetFinder::WriteJetsToFile(Int_t i) -{ - // 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; } -//////////////////////////////////////////////////////////////////////// - -void AliJetFinder::WriteRHeaderToFile() +//----------------------------------------------------------------------- +void AliJetFinder::WriteHeaderToFile() { // write reader header - fOut->cd(); - AliJetReaderHeader *rh = fReader->GetReaderHeader(); + AliJetHeader *rh = GetJetHeader(); rh->Write(); -} - -//////////////////////////////////////////////////////////////////////// +} -void AliJetFinder::Run() +//----------------------------------------------------------------------- +Bool_t AliJetFinder::ProcessEvent() { - // Do some initialization - Init(); - // connect files - fReader->OpenInputFiles(); - - // write headers - WriteHeaders(); - // loop over events - Int_t nFirst, nLast, option, debug, arrayInitialised; - nFirst = fReader->GetReaderHeader()->GetFirstEvent(); - nLast = fReader->GetReaderHeader()->GetLastEvent(); - - option = fReader->GetReaderHeader()->GetDetector(); - debug = fReader->GetReaderHeader()->GetDebug(); - arrayInitialised = fReader->GetArrayInitialised(); - - // loop over events - for (Int_t i=nFirst;iFillMomentumArray(i); - fLeading->FindLeading(fReader); - fReader->GetGenJets(fGenJets); - - if (option == 0) { // TPC with fMomentumArray - if(debug > 1) - printf("In FindJetsTPC() routine: find jets with fMomentumArray !!!\n"); - FindJetsTPC(); - } else { - if(debug > 1) printf("In FindJets() routine: find jets with fUnitArray !!!\n"); - FindJets(); - } - if (fOut) WriteJetsToFile(i); - if (fPlots) fPlots->FillHistos(fJets); - fLeading->Reset(); - fGenJets->ClearJets(); - Reset(); - } - - // write out - if (fPlots) { - fPlots->Normalize(); - fPlots->PlotHistos(); - } - if (fOut) { - fOut->cd(); - fPlots->Write(); - fOut->Close(); - } -} + // Process one event + // Find jets + FindJets(); -// -// The following methods have been added to allow for event steering from the outside -// + Reset(); + return kTRUE; -void AliJetFinder::ConnectTree(TTree* tree) -{ - // Connect the input file - fReader->ConnectTree(tree); } -void AliJetFinder::WriteHeaders() +//----------------------------------------------------------------------- +void AliJetFinder::AddJet(AliAODJet p) { - // Write the Headers - if (fOut) { - fOut->cd(); - WriteRHeaderToFile(); - WriteJHeaderToFile(); - } -} + // Add new jet to the list + if (fAODjets) { new ((*fAODjets)[fNAODjets++]) AliAODJet(p);} + else { Warning("AliJetFinder::AddJet(AliAODJet p)","fAODjets is null!");} +} -Bool_t AliJetFinder::ProcessEvent(Long64_t entry) +//----------------------------------------------------------------------- +void AliJetFinder::ConnectAOD(const AliAODEvent* aod) { -// -// Process one event -// - printf("<<<<< Processing Event %5d >>>>> \n", (Int_t) entry); - Bool_t ok = fReader->FillMomentumArray(entry); - if (!ok) return kFALSE; - fLeading->FindLeading(fReader); - FindJets(); - if (fOut) WriteJetsToFile(entry); - if (fPlots) fPlots->FillHistos(fJets); - fLeading->Reset(); - fGenJets->ClearJets(); - Reset(); - return kTRUE; + // Connect to the AOD + fAODjets = aod->GetJets(); + fAODEvBkg = (AliAODJetEventBackground*)(aod->FindListObject(AliAODJetEventBackground::StdBranchName())); + } -void AliJetFinder::FinishRun() +//----------------------------------------------------------------------- +void AliJetFinder::ConnectAODNonStd(AliAODEvent* aod,const char *bname) { - // Finish a run - if (fPlots) { - fPlots->Normalize(); - fPlots->PlotHistos(); - if (fOut) { - fOut->cd(); - fPlots->Write(); - fOut->Close(); - } - } else { - if (fOut) fOut->Close(); - } + // Connect non standard AOD jet and jet background branches + fAODjets = dynamic_cast(aod->FindListObject(bname)); + fAODEvBkg = (AliAODJetEventBackground*)(aod->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),bname))); + // how is this is reset? Cleared? -> by the UserExec!! + }