From d89b82292bfd4a6a0daafd362d087df4da469b45 Mon Sep 17 00:00:00 2001 From: kleinb Date: Tue, 24 Jan 2012 20:06:42 +0000 Subject: [PATCH] adding JETAN and FASTJETAN development libs for new i/o of tracks/particles for the reader (A. Shabetai) --- JETAN/CMakeLists.txt | 10 + JETAN/CMakelibFASTJETANdev.pkg | 42 + JETAN/CMakelibJETANdev.pkg | 49 + JETAN/DEV/AliAnalysisTaskDiJets.cxx | 218 +++ JETAN/DEV/AliAnalysisTaskDiJets.h | 55 + JETAN/DEV/AliAnalysisTaskFastEmbedding.cxx | 1196 +++++++++++++ JETAN/DEV/AliAnalysisTaskFastEmbedding.h | 197 +++ .../AliAnalysisTaskJetBackgroundSubtract.cxx | 727 ++++++++ .../AliAnalysisTaskJetBackgroundSubtract.h | 106 ++ JETAN/DEV/AliAnalysisTaskJetCluster.cxx | 1490 +++++++++++++++++ JETAN/DEV/AliAnalysisTaskJetCluster.h | 252 +++ JETAN/DEV/AliAnalysisTaskJetsFinder.cxx | 308 ++++ JETAN/DEV/AliAnalysisTaskJetsFinder.h | 67 + JETAN/DEV/AliAnalysisTaskJetsReader.cxx | 151 ++ JETAN/DEV/AliAnalysisTaskJetsReader.h | 50 + JETAN/DEV/AliAnalysisTaskKMeans.cxx | 559 +++++++ JETAN/DEV/AliAnalysisTaskKMeans.h | 87 + JETAN/DEV/AliCdfJetFinder.cxx | 903 ++++++++++ JETAN/DEV/AliCdfJetFinder.h | 75 + JETAN/DEV/AliCdfJetHeader.cxx | 48 + JETAN/DEV/AliCdfJetHeader.h | 49 + JETAN/DEV/AliDAJetFinder.cxx | 546 ++++++ JETAN/DEV/AliDAJetFinder.h | 56 + JETAN/DEV/AliDAJetHeader.cxx | 56 + JETAN/DEV/AliDAJetHeader.h | 62 + JETAN/DEV/AliEventShape.cxx | 311 ++++ JETAN/DEV/AliEventShape.h | 33 + JETAN/DEV/AliFastJetBkg.cxx | 553 ++++++ JETAN/DEV/AliFastJetBkg.h | 55 + JETAN/DEV/AliFastJetFinder.cxx | 369 ++++ JETAN/DEV/AliFastJetFinder.h | 54 + JETAN/DEV/AliFastJetHeaderV1.cxx | 89 + JETAN/DEV/AliFastJetHeaderV1.h | 102 ++ JETAN/DEV/AliFastJetInput.cxx | 132 ++ JETAN/DEV/AliFastJetInput.h | 53 + JETAN/DEV/AliJetBkg.cxx | 564 +++++++ JETAN/DEV/AliJetBkg.h | 75 + JETAN/DEV/AliJetCalTrk.cxx | 312 ++++ JETAN/DEV/AliJetCalTrk.h | 129 ++ JETAN/DEV/AliJetFillCalTrkEvent.cxx | 104 ++ JETAN/DEV/AliJetFillCalTrkEvent.h | 67 + JETAN/DEV/AliJetFillCalTrkTrack.cxx | 230 +++ JETAN/DEV/AliJetFillCalTrkTrack.h | 55 + JETAN/DEV/AliJetFillCalTrkTrackMC.cxx | 322 ++++ JETAN/DEV/AliJetFillCalTrkTrackMC.h | 63 + JETAN/DEV/AliJetFinder.cxx | 115 ++ JETAN/DEV/AliJetFinder.h | 68 + JETAN/DEV/AliJetHeader.cxx | 60 + JETAN/DEV/AliJetHeader.h | 63 + JETAN/DEV/AliJetHistos.cxx | 122 ++ JETAN/DEV/AliJetHistos.h | 46 + JETAN/DEV/AliJetKineReaderHeader.cxx | 38 + JETAN/DEV/AliJetKineReaderHeader.h | 42 + JETAN/DEV/AliJetReader.cxx | 199 +++ JETAN/DEV/AliJetReader.h | 62 + JETAN/DEV/AliJetReaderHeader.cxx | 120 ++ JETAN/DEV/AliJetReaderHeader.h | 108 ++ JETAN/DEV/AliKMeansClustering.cxx | 570 +++++++ JETAN/DEV/AliKMeansClustering.h | 67 + JETAN/DEV/AliSISConeJetFinder.cxx | 314 ++++ JETAN/DEV/AliSISConeJetFinder.h | 48 + JETAN/DEV/AliSISConeJetHeader.cxx | 98 ++ JETAN/DEV/AliSISConeJetHeader.h | 122 ++ JETAN/DEV/AliUA1JetFinder.cxx | 538 ++++++ JETAN/DEV/AliUA1JetFinder.h | 55 + JETAN/DEV/AliUA1JetHeaderV1.cxx | 74 + JETAN/DEV/AliUA1JetHeaderV1.h | 90 + JETAN/FASTJETANdevLinkDef.h | 15 + JETAN/JETANdevLinkDef.h | 34 + JETAN/Makefile | 24 +- JETAN/PROOF-INF.FASTJETANdev/BUILD.sh | 3 + JETAN/PROOF-INF.FASTJETANdev/SETUP.C | 11 + JETAN/PROOF-INF.JETANdev/BUILD.sh | 3 + JETAN/PROOF-INF.JETANdev/SETUP.C | 12 + PWG4/Makefile | 10 +- PWG4/macros/AnalysisTrainPWG4Jets.C | 98 +- 76 files changed, 14250 insertions(+), 10 deletions(-) create mode 100644 JETAN/CMakeLists.txt create mode 100644 JETAN/CMakelibFASTJETANdev.pkg create mode 100644 JETAN/CMakelibJETANdev.pkg create mode 100644 JETAN/DEV/AliAnalysisTaskDiJets.cxx create mode 100644 JETAN/DEV/AliAnalysisTaskDiJets.h create mode 100644 JETAN/DEV/AliAnalysisTaskFastEmbedding.cxx create mode 100644 JETAN/DEV/AliAnalysisTaskFastEmbedding.h create mode 100644 JETAN/DEV/AliAnalysisTaskJetBackgroundSubtract.cxx create mode 100644 JETAN/DEV/AliAnalysisTaskJetBackgroundSubtract.h create mode 100644 JETAN/DEV/AliAnalysisTaskJetCluster.cxx create mode 100644 JETAN/DEV/AliAnalysisTaskJetCluster.h create mode 100644 JETAN/DEV/AliAnalysisTaskJetsFinder.cxx create mode 100644 JETAN/DEV/AliAnalysisTaskJetsFinder.h create mode 100644 JETAN/DEV/AliAnalysisTaskJetsReader.cxx create mode 100644 JETAN/DEV/AliAnalysisTaskJetsReader.h create mode 100644 JETAN/DEV/AliAnalysisTaskKMeans.cxx create mode 100644 JETAN/DEV/AliAnalysisTaskKMeans.h create mode 100644 JETAN/DEV/AliCdfJetFinder.cxx create mode 100644 JETAN/DEV/AliCdfJetFinder.h create mode 100644 JETAN/DEV/AliCdfJetHeader.cxx create mode 100644 JETAN/DEV/AliCdfJetHeader.h create mode 100644 JETAN/DEV/AliDAJetFinder.cxx create mode 100644 JETAN/DEV/AliDAJetFinder.h create mode 100644 JETAN/DEV/AliDAJetHeader.cxx create mode 100644 JETAN/DEV/AliDAJetHeader.h create mode 100644 JETAN/DEV/AliEventShape.cxx create mode 100644 JETAN/DEV/AliEventShape.h create mode 100644 JETAN/DEV/AliFastJetBkg.cxx create mode 100644 JETAN/DEV/AliFastJetBkg.h create mode 100644 JETAN/DEV/AliFastJetFinder.cxx create mode 100644 JETAN/DEV/AliFastJetFinder.h create mode 100644 JETAN/DEV/AliFastJetHeaderV1.cxx create mode 100644 JETAN/DEV/AliFastJetHeaderV1.h create mode 100644 JETAN/DEV/AliFastJetInput.cxx create mode 100644 JETAN/DEV/AliFastJetInput.h create mode 100644 JETAN/DEV/AliJetBkg.cxx create mode 100644 JETAN/DEV/AliJetBkg.h create mode 100644 JETAN/DEV/AliJetCalTrk.cxx create mode 100644 JETAN/DEV/AliJetCalTrk.h create mode 100644 JETAN/DEV/AliJetFillCalTrkEvent.cxx create mode 100644 JETAN/DEV/AliJetFillCalTrkEvent.h create mode 100644 JETAN/DEV/AliJetFillCalTrkTrack.cxx create mode 100644 JETAN/DEV/AliJetFillCalTrkTrack.h create mode 100644 JETAN/DEV/AliJetFillCalTrkTrackMC.cxx create mode 100644 JETAN/DEV/AliJetFillCalTrkTrackMC.h create mode 100644 JETAN/DEV/AliJetFinder.cxx create mode 100644 JETAN/DEV/AliJetFinder.h create mode 100644 JETAN/DEV/AliJetHeader.cxx create mode 100644 JETAN/DEV/AliJetHeader.h create mode 100644 JETAN/DEV/AliJetHistos.cxx create mode 100644 JETAN/DEV/AliJetHistos.h create mode 100644 JETAN/DEV/AliJetKineReaderHeader.cxx create mode 100644 JETAN/DEV/AliJetKineReaderHeader.h create mode 100644 JETAN/DEV/AliJetReader.cxx create mode 100644 JETAN/DEV/AliJetReader.h create mode 100644 JETAN/DEV/AliJetReaderHeader.cxx create mode 100644 JETAN/DEV/AliJetReaderHeader.h create mode 100644 JETAN/DEV/AliKMeansClustering.cxx create mode 100644 JETAN/DEV/AliKMeansClustering.h create mode 100644 JETAN/DEV/AliSISConeJetFinder.cxx create mode 100644 JETAN/DEV/AliSISConeJetFinder.h create mode 100644 JETAN/DEV/AliSISConeJetHeader.cxx create mode 100644 JETAN/DEV/AliSISConeJetHeader.h create mode 100644 JETAN/DEV/AliUA1JetFinder.cxx create mode 100644 JETAN/DEV/AliUA1JetFinder.h create mode 100644 JETAN/DEV/AliUA1JetHeaderV1.cxx create mode 100644 JETAN/DEV/AliUA1JetHeaderV1.h create mode 100644 JETAN/FASTJETANdevLinkDef.h create mode 100644 JETAN/JETANdevLinkDef.h create mode 100644 JETAN/PROOF-INF.FASTJETANdev/BUILD.sh create mode 100644 JETAN/PROOF-INF.FASTJETANdev/SETUP.C create mode 100644 JETAN/PROOF-INF.JETANdev/BUILD.sh create mode 100644 JETAN/PROOF-INF.JETANdev/SETUP.C diff --git a/JETAN/CMakeLists.txt b/JETAN/CMakeLists.txt new file mode 100644 index 00000000000..90347d6f7a2 --- /dev/null +++ b/JETAN/CMakeLists.txt @@ -0,0 +1,10 @@ +# AliRoot Build System CMakeLists for JETAN +# +# Author: Johny Jose m(johny.jose@cern.ch) +# Port of previous Makefile build to cmake + +cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR) + +file(GLOB PACKAGES CMake*.pkg) + +ALICE_BuildModule() diff --git a/JETAN/CMakelibFASTJETANdev.pkg b/JETAN/CMakelibFASTJETANdev.pkg new file mode 100644 index 00000000000..4a099b4bfda --- /dev/null +++ b/JETAN/CMakelibFASTJETANdev.pkg @@ -0,0 +1,42 @@ +#--------------------------------------------------------------------------------# +# Package File for JETAN # +# Author : Johny Jose (johny.jose@cern.ch) # +# Variables Defined : # +# # +# SRCS - C++ source files # +# HDRS - C++ header files # +# DHDR - ROOT Dictionary Linkdef header file # +# CSRCS - C source files # +# CHDRS - C header files # +# EINCLUDE - Include directories # +# EDEFINE - Compiler definitions # +# ELIBS - Extra libraries to link # +# ELIBSDIR - Extra library directories # +# PACKFFLAGS - Fortran compiler flags for package # +# PACKCXXFLAGS - C++ compiler flags for package # +# PACKCFLAGS - C compiler flags for package # +# PACKSOFLAGS - Shared library linking flags # +# PACKLDFLAGS - Module linker flags # +# PACKBLIBS - Libraries to link (Executables only) # +# EXPORT - Header files to be exported # +# CINTHDRS - Dictionary header files # +# CINTAUTOLINK - Set automatic dictionary generation # +# ARLIBS - Archive Libraries and objects for linking (Executables only) # +# SHLIBS - Shared Libraries and objects for linking (Executables only) # +#--------------------------------------------------------------------------------# + +set ( SRCS DEV/AliFastJetFinder.cxx DEV/AliFastJetHeaderV1.cxx DEV/AliFastJetInput.cxx DEV/AliFastJetBkg.cxx DEV/AliSISConeJetFinder.cxx DEV/AliSISConeJetHeader.cxx DEV/AliAnalysisTaskJetCluster.cxx DEV/AliAnalysisTaskJetBackgroundSubtract.cxx) + +set(FASTJET_ROOT $ENV{FASTJET_ROOT}) + +if(FASTJET_ROOT) + set ( EDEFINE -isystem${FASTJET_ROOT}/include ) +else() + set ( EDEFINE -isystem${ALICE_ROOT}/JETAN/fastjet) +endif(FASTJET_ROOT) + +string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" ) + +set ( DHDR FASTJETANdevLinkDef.h) + +set ( EINCLUDE JETAN/DEV JETAN/fastjet ANALYSIS STEER/AOD STEER/STEERBase ) diff --git a/JETAN/CMakelibJETANdev.pkg b/JETAN/CMakelibJETANdev.pkg new file mode 100644 index 00000000000..96d56448b1a --- /dev/null +++ b/JETAN/CMakelibJETANdev.pkg @@ -0,0 +1,49 @@ +#--------------------------------------------------------------------------------# +# Package File for JETAN # +# Author : Johny Jose (johny.jose@cern.ch) # +# Variables Defined : # +# # +# SRCS - C++ source files # +# HDRS - C++ header files # +# DHDR - ROOT Dictionary Linkdef header file # +# CSRCS - C source files # +# CHDRS - C header files # +# EINCLUDE - Include directories # +# EDEFINE - Compiler definitions # +# ELIBS - Extra libraries to link # +# ELIBSDIR - Extra library directories # +# PACKFFLAGS - Fortran compiler flags for package # +# PACKCXXFLAGS - C++ compiler flags for package # +# PACKCFLAGS - C compiler flags for package # +# PACKSOFLAGS - Shared library linking flags # +# PACKLDFLAGS - Module linker flags # +# PACKBLIBS - Libraries to link (Executables only) # +# EXPORT - Header files to be exported # +# CINTHDRS - Dictionary header files # +# CINTAUTOLINK - Set automatic dictionary generation # +# ARLIBS - Archive Libraries and objects for linking (Executables only) # +# SHLIBS - Shared Libraries and objects for linking (Executables only) # +#--------------------------------------------------------------------------------# + +set ( SRCS DEV/AliJetHeader.cxx DEV/AliJetFinder.cxx DEV/AliJetReaderHeader.cxx DEV/AliJetReader.cxx DEV/AliUA1JetHeaderV1.cxx DEV/AliUA1JetFinder.cxx DEV/AliCdfJetFinder.cxx DEV/AliCdfJetHeader.cxx DEV/AliAnalysisTaskJetsReader.cxx DEV/AliAnalysisTaskJetsFinder.cxx DEV/AliDAJetFinder.cxx DEV/AliDAJetHeader.cxx DEV/AliJetKineReaderHeader.cxx DEV/AliJetHistos.cxx DEV/AliAnalysisTaskDiJets.cxx DEV/AliEventShape.cxx DEV/AliKMeansClustering.cxx DEV/AliAnalysisTaskKMeans.cxx DEV/AliAnalysisTaskFastEmbedding.cxx DEV/AliJetBkg.cxx DEV/AliJetCalTrk.cxx DEV/AliJetFillCalTrkTrack.cxx DEV/AliJetFillCalTrkTrackMC.cxx DEV/AliJetFillCalTrkEvent.cxx ) + +string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" ) + +set ( DHDR JETANdevLinkDef.h) + +set(FASTJET_ROOT $ENV{FASTJET_ROOT}) + +if(FASTJET_ROOT) + set ( EDEFINE -isystem${FASTJET_ROOT}/include) +else() + set ( EDEFINE -isystem${ALICE_ROOT}/JETAN/fastjet) +endif(FASTJET_ROOT) + +set ( EINCLUDE ANALYSIS OADB) + +if( ALICE_TARGET STREQUAL "win32gcc") + + set ( PACKSOFLAGS ${SOFLAGS} -L${ALICE_ROOT}/lib/tgt_${ALICE_TARGET} -lSTEERBase -lESD -lAOD -lANALYSIS -lANALYSISalice -L${ROOTLIBDIR} -lEG -lGeom) + +endif( ALICE_TARGET STREQUAL "win32gcc") + diff --git a/JETAN/DEV/AliAnalysisTaskDiJets.cxx b/JETAN/DEV/AliAnalysisTaskDiJets.cxx new file mode 100644 index 00000000000..f1df281af29 --- /dev/null +++ b/JETAN/DEV/AliAnalysisTaskDiJets.cxx @@ -0,0 +1,218 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ +/* + Analysis Task + for Dijet Analysis + based on AOD +*/ + +#include "AliAnalysisTaskDiJets.h" +#include "AliAODEvent.h" +#include "AliAODJet.h" +#include "AliAODDiJet.h" +#include +#include +#include + + +ClassImp(AliAnalysisTaskDiJets) + +//////////////////////////////////////////////////////////////////////// + +AliAnalysisTaskDiJets::AliAnalysisTaskDiJets(): + AliAnalysisTaskSE(), + fDiJets(0), + fDiJetsIn(0), + fUseAODInput(kFALSE), + fFillAOD(kFALSE), + fJetBranch("jets"), + fAOD(0), + fHistList(0), + fH1DeltaPt(0), + fH1DeltaPhi(0), + fH1PhiImbal(0), + fH1Asym(0), + fH2Pt2vsPt1(0), + fH2DifvsSum(0) +{ + // Default constructor +} + +//---------------------------------------------------------------------- +AliAnalysisTaskDiJets::AliAnalysisTaskDiJets(const char* name): + AliAnalysisTaskSE(name), + fDiJets(0), + fDiJetsIn(0), + fUseAODInput(kFALSE), + fFillAOD(kFALSE), + fJetBranch("jets"), + fAOD(0), + fHistList(0), + fH1DeltaPt(0), + fH1DeltaPhi(0), + fH1PhiImbal(0), + fH1Asym(0), + fH2Pt2vsPt1(0), + fH2DifvsSum(0) +{ + // Default constructor + DefineOutput(1, TList::Class()); +} + +//---------------------------------------------------------------------- +void AliAnalysisTaskDiJets::UserCreateOutputObjects() +{ +// Create the output container +// + if (fDebug) printf("AnalysisTaskDiJets::CreateOutPutData() \n"); + fDiJets = new TClonesArray("AliAODDiJet", 0); + if (fFillAOD){ + fDiJets->SetName(Form("dijets_%s",fJetBranch.Data())); + AddAODBranch("TClonesArray", &fDiJets); + } + + if (!fHistList) fHistList = new TList(); + fHistList->SetOwner(); + Float_t pi=TMath::Pi(); + gStyle->SetPalette(1); + + fH1DeltaPt = new TH1F("DeltaPt","Difference between the jets' Pt;#Deltap_{T} (GeV/c);Entries",150,0.,150.); + fH1DeltaPt->SetMarkerSize(0.6); + fH1DeltaPt->SetMarkerColor(4); + fH1DeltaPt->SetMarkerStyle(21); + fH1DeltaPt->SetOption("E"); + + fH1DeltaPhi = new TH1F("DeltaPhi","Difference in the azimuthal angle;#Delta#phi;Entries",100,0.,pi); + fH1DeltaPhi->SetMarkerSize(0.6); + fH1DeltaPhi->SetMarkerColor(4); + fH1DeltaPhi->SetMarkerStyle(21); + fH1DeltaPhi->SetOption("E"); + + fH1PhiImbal = new TH1F("PhiImb","Phi imbalance;#phi;Entries",100,-pi,pi); + fH1PhiImbal->SetMarkerSize(0.6); + fH1PhiImbal->SetMarkerColor(4); + fH1PhiImbal->SetMarkerStyle(21); + fH1PhiImbal->SetOption("E"); + + fH1Asym = new TH1F("Asym","Pt asymmetry;#Deltap_{T}/(p_{T,1}+p_{T,2});Entries",50,0.,1.); + fH1Asym->SetMarkerSize(0.6); + fH1Asym->SetMarkerColor(4); + fH1Asym->SetMarkerStyle(21); + fH1Asym->SetOption("E"); + + fH2Pt2vsPt1 = new TH2F("Pt2vsPt1","Pt2 versus Pt1;p_{T,1} (GeV/c);p_{T,2} (GeV/c)",250,0.,250.,250,0.,250.); + fH2Pt2vsPt1->SetOption("cont0"); + + fH2DifvsSum = new TH2F("DifvsSum","Pt difference vs Pt sum;p_{T,1}+p_{T,2} (GeV/c);#Deltap_{T} (GeV/c)",400,0.,400.,150,0.,150.); + fH2DifvsSum->SetOption("cont0"); + + fHistList->Add(fH1DeltaPt); + fHistList->Add(fH1DeltaPhi); + fHistList->Add(fH1PhiImbal); + fHistList->Add(fH1Asym); + fHistList->Add(fH2Pt2vsPt1); + fHistList->Add(fH2DifvsSum); +} + +//---------------------------------------------------------------------- +void AliAnalysisTaskDiJets::Init() +{ + // Initialization + if (fDebug) printf("AnalysisTaskDiJets::Init() \n"); +} + +//---------------------------------------------------------------------- +void AliAnalysisTaskDiJets::UserExec(Option_t */*option*/) +{ +// Execute analysis for current event +// + if (fDiJets) fDiJets->Delete(); + + if(fUseAODInput){ + fAOD = dynamic_cast (InputEvent()); + if(!fAOD){ + // We do not have an input AOD, look in the output + if (fDebug) printf("%s:%d No AOD event in the input\n",(char*)__FILE__,__LINE__); + return; + } + } else { + fAOD = AODEvent(); + if(!fAOD){ + if (fDebug) printf("%s:%d AODEvent not found in the Output",(char*)__FILE__,__LINE__); + return; + } + } + + TClonesArray* jets = (TClonesArray*) fAOD->FindListObject(fJetBranch.Data()); + // N.B. if we take the aod from the output this is always + // empty and since it is the same as fDiJets + fDiJetsIn = (TClonesArray*) (fAOD->GetList()->FindObject("dijets")); + + if (fDiJetsIn) { + if (fDebug) printf("Found %d dijets in old list \n", fDiJetsIn->GetEntries()); + AliAODJet* jj1, *jj2; + AliAODDiJet* testJ; + + if (fDiJetsIn->GetEntries() > 0) { + testJ = (AliAODDiJet*) (fDiJetsIn->At(0)); + jj1 = testJ->Jet(0); + jj1->Print(""); + jj2 = testJ->Jet(1); + jj2->Print(""); + } + } + + Int_t nj = jets->GetEntriesFast(); + if (fDebug) printf("There are %5d jets in the event \n", nj); + + if (nj < 2){ + PostData(1, fHistList); + return; + } + AliAODJet* jet1 = (AliAODJet*) (jets->At(0)); + TLorentzVector v1 = *(jet1->MomentumVector()); + AliAODJet* jet2 = (AliAODJet*) (jets->At(1)); + TLorentzVector v2 = *(jet2->MomentumVector()); + TLorentzVector v = v1 + v2; + if (fDiJets) { + Int_t ndi = fDiJets->GetEntriesFast(); + TClonesArray &lref = *fDiJets; + new(lref[ndi]) AliAODDiJet(v); + AliAODDiJet* dijet = (AliAODDiJet*) (fDiJets->At(ndi)); + dijet->SetJetRefs(jet1, jet2); + fH1DeltaPhi->Fill(dijet->DeltaPhi()); + fH1PhiImbal->Fill(dijet->PhiImbalance()); + + } + + fH1DeltaPt->Fill(jet1->Pt()-jet2->Pt()); + fH1Asym->Fill((jet1->Pt()-jet2->Pt())/(jet1->Pt()+jet2->Pt())); + fH2Pt2vsPt1->Fill(jet1->Pt(),jet2->Pt()); + fH2DifvsSum->Fill(jet1->Pt()+jet2->Pt(),jet1->Pt()-jet2->Pt()); + + PostData(1, fHistList); + return; +} + +//---------------------------------------------------------------------- +void AliAnalysisTaskDiJets::Terminate(Option_t */*option*/) +{ +// Terminate analysis +// + if (fDebug) printf("AnalysisDiJets: Terminate() \n"); +} + diff --git a/JETAN/DEV/AliAnalysisTaskDiJets.h b/JETAN/DEV/AliAnalysisTaskDiJets.h new file mode 100644 index 00000000000..70e52d4a42a --- /dev/null +++ b/JETAN/DEV/AliAnalysisTaskDiJets.h @@ -0,0 +1,55 @@ +#ifndef ALIANALYSISTASKDIJETS_H +#define ALIANALYSISTASKDIJETS_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +#include "AliAnalysisTaskSE.h" +#include +#include +#include + +class AliAnalysisTaskDiJets : public AliAnalysisTaskSE +{ + public: + AliAnalysisTaskDiJets(); + AliAnalysisTaskDiJets(const char* name); + virtual ~AliAnalysisTaskDiJets() {;} + + // Implementation of interface methods + virtual void UserCreateOutputObjects(); + virtual void Init(); + virtual void LocalInit() {Init();} + virtual void UserExec(Option_t *option); + virtual void Terminate(Option_t *option); + + void SetAODInput(Bool_t b) {fUseAODInput = b;} + void SetFillAOD(Bool_t fill) { fFillAOD=fill; } + void SetJetBranch(const Char_t *br){ fJetBranch=br; } + + private: + AliAnalysisTaskDiJets(const AliAnalysisTaskDiJets &det); + AliAnalysisTaskDiJets &operator=(const AliAnalysisTaskDiJets &det); + + private: + TClonesArray* fDiJets; // Array of dijets + TClonesArray* fDiJetsIn; // Array of dijets + + Bool_t fUseAODInput; // read jets from input AOD + Bool_t fFillAOD; // option to fill AOD branch + TString fJetBranch; // jet branch to read + + AliAODEvent *fAOD; // AOD event + TList *fHistList; // Output list + + TH1F *fH1DeltaPt; // Pt difference + TH1F *fH1DeltaPhi; // delta phi plot in (0,pi) + TH1F *fH1PhiImbal; // phi imbalance (-pi,pi) + TH1F *fH1Asym; // asymmetry of the dijet + TH2F *fH2Pt2vsPt1; // scatter plot with the two jets' Pt + TH2F *fH2DifvsSum; // Pt difference vs Pt sum + + ClassDef(AliAnalysisTaskDiJets, 2) // Analysis task for standard dijet analysis +}; + +#endif diff --git a/JETAN/DEV/AliAnalysisTaskFastEmbedding.cxx b/JETAN/DEV/AliAnalysisTaskFastEmbedding.cxx new file mode 100644 index 00000000000..c092b06973a --- /dev/null +++ b/JETAN/DEV/AliAnalysisTaskFastEmbedding.cxx @@ -0,0 +1,1196 @@ +/************************************************************************* + * * + * Task for fast embedding * + * read extra input from AOD * + * * + *************************************************************************/ + + +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id: */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "AliAnalysisTaskFastEmbedding.h" +#include "AliAnalysisManager.h" +#include "AliESDEvent.h" +#include "AliESDtrack.h" +#include "AliAODEvent.h" +#include "AliAODTrack.h" +#include "AliAODJet.h" +#include "AliAODMCParticle.h" +#include "AliAODMCHeader.h" +#include "AliInputEventHandler.h" + +#include "AliLog.h" + +ClassImp(AliAnalysisTaskFastEmbedding) + +//__________________________________________________________________________ +AliAnalysisTaskFastEmbedding::AliAnalysisTaskFastEmbedding() +: AliAnalysisTaskSE() +,fESD(0) +,fAODout(0) +,fAODevent(0) +,fAODtree(0) +,fAODfile(0) +,mcHeader(0) +,rndm(0) +,fInputEntries(0) +,fAODPathArray(0) +,fAODEntriesArray(0) +,fAODPath("AliAOD.root") +,fAODEntries(-1) +,fAODEntriesSum(0) +,fAODEntriesMax(0) +,fOfflineTrgMask(AliVEvent::kAny) +,fMinContribVtx(1) +,fVtxZMin(-8.) +,fVtxZMax(8.) +,fEvtClassMin(0) +,fEvtClassMax(4) +,fCentMin(0.) +,fCentMax(100.) +,fNInputTracksMin(0) +,fNInputTracksMax(-1) +,fTrackBranch("aodExtraTracks") +,fMCparticlesBranch("aodExtraMCparticles") +,fJetBranch("") +,fFileId(-1) +,fAODEntry(0) +,fCountEvents(-1) +,fEmbedMode(0) +,fEvtSelecMode(0) +,fEvtSelMinJetPt(-1) +,fEvtSelMaxJetPt(-1) +,fEvtSelMinJetEta(-999.) +,fEvtSelMaxJetEta( 999.) +,fEvtSelMinJetPhi(0.) +,fEvtSelMaxJetPhi(TMath::Pi()*2.) +,fToyMinNbOfTracks(1) +,fToyMaxNbOfTracks(1) +,fToyMinTrackPt(50.) +,fToyMaxTrackPt(50.) +,fToyDistributionTrackPt(0.) +,fToyMinTrackEta(-.5) +,fToyMaxTrackEta(.5) +,fToyMinTrackPhi(0.) +,fToyMaxTrackPhi(2*TMath::Pi()) +,fToyFilterMap(0) +,fTrackFilterMap(0) +,fNPtHard(10) +,fPtHard(0) +,fPtHardBin(-1) +,fAODJets(0x0) +,fNevents(0) +,fXsection(0) +,fAvgTrials(0) +,fHistList(0) +,fHistEvtSelection(0) +,fh1Xsec(0) +,fh1Trials(0) +,fh1TrialsEvtSel(0) +,fh2PtHard(0) +,fh2PtHardEvtSel(0) +,fh2PtHardTrials(0) +,fh1TrackPt(0) +,fh2TrackEtaPhi(0) +,fh1TrackN(0) +,fh1JetPt(0) +,fh2JetEtaPhi(0) +,fh1JetN(0) +,fh1MCTrackPt(0) +,fh2MCTrackEtaPhi(0) +,fh1MCTrackN(0) +,fh1AODfile(0) +,fh2AODevent(0) +{ + // default constructor + +} + + +//__________________________________________________________________________ +AliAnalysisTaskFastEmbedding::AliAnalysisTaskFastEmbedding(const char *name) +: AliAnalysisTaskSE(name) +,fESD(0) +,fAODout(0) +,fAODevent(0) +,fAODtree(0) +,fAODfile(0) +,mcHeader(0) +,rndm(0) +,fInputEntries(0) +,fAODPathArray(0) +,fAODEntriesArray(0) +,fAODPath("AliAOD.root") +,fAODEntries(-1) +,fAODEntriesSum(0) +,fAODEntriesMax(0) +,fOfflineTrgMask(AliVEvent::kAny) +,fMinContribVtx(1) +,fVtxZMin(-8.) +,fVtxZMax(8.) +,fEvtClassMin(0) +,fEvtClassMax(4) +,fCentMin(0.) +,fCentMax(100.) +,fNInputTracksMin(0) +,fNInputTracksMax(-1) +,fTrackBranch("aodExtraTracks") +,fMCparticlesBranch("aodExtraMCparticles") +,fJetBranch("") +,fFileId(-1) +,fAODEntry(0) +,fCountEvents(-1) +,fEmbedMode(0) +,fEvtSelecMode(0) +,fEvtSelMinJetPt(-1) +,fEvtSelMaxJetPt(-1) +,fEvtSelMinJetEta(-999.) +,fEvtSelMaxJetEta( 999.) +,fEvtSelMinJetPhi(0.) +,fEvtSelMaxJetPhi(TMath::Pi()*2.) +,fToyMinNbOfTracks(1) +,fToyMaxNbOfTracks(1) +,fToyMinTrackPt(50.) +,fToyMaxTrackPt(50.) +,fToyDistributionTrackPt(0.) +,fToyMinTrackEta(-.5) +,fToyMaxTrackEta(.5) +,fToyMinTrackPhi(0.) +,fToyMaxTrackPhi(2*TMath::Pi()) +,fToyFilterMap(0) +,fTrackFilterMap(0) +,fNPtHard(10) +,fPtHard(0) +,fPtHardBin(-1) +,fAODJets(0x0) +,fNevents(0) +,fXsection(0) +,fAvgTrials(0) +,fHistList(0) +,fHistEvtSelection(0) +,fh1Xsec(0) +,fh1Trials(0) +,fh1TrialsEvtSel(0) +,fh2PtHard(0) +,fh2PtHardEvtSel(0) +,fh2PtHardTrials(0) +,fh1TrackPt(0) +,fh2TrackEtaPhi(0) +,fh1TrackN(0) +,fh1JetPt(0) +,fh2JetEtaPhi(0) +,fh1JetN(0) +,fh1MCTrackPt(0) +,fh2MCTrackEtaPhi(0) +,fh1MCTrackN(0) +,fh1AODfile(0) +,fh2AODevent(0) +{ + // constructor + DefineOutput(1, TList::Class()); +} + + +//__________________________________________________________________________ +AliAnalysisTaskFastEmbedding::AliAnalysisTaskFastEmbedding(const AliAnalysisTaskFastEmbedding ©) +: AliAnalysisTaskSE() +,fESD(copy.fESD) +,fAODout(copy.fAODout) +,fAODevent(copy.fAODevent) +,fAODtree(copy.fAODtree) +,fAODfile(copy.fAODfile) +,mcHeader(copy.mcHeader) +,rndm(copy.rndm) +,fInputEntries(copy.fInputEntries) +,fAODPathArray(copy.fAODPathArray) +,fAODEntriesArray(copy.fAODEntriesArray) +,fAODPath(copy.fAODPath) +,fAODEntries(copy.fAODEntries) +,fAODEntriesSum(copy.fAODEntriesSum) +,fAODEntriesMax(copy.fAODEntriesMax) +,fOfflineTrgMask(copy.fOfflineTrgMask) +,fMinContribVtx(copy.fMinContribVtx) +,fVtxZMin(copy.fVtxZMin) +,fVtxZMax(copy.fVtxZMax) +,fEvtClassMin(copy.fEvtClassMin) +,fEvtClassMax(copy.fEvtClassMax) +,fCentMin(copy.fCentMin) +,fCentMax(copy.fCentMax) +,fNInputTracksMin(copy.fNInputTracksMin) +,fNInputTracksMax(copy.fNInputTracksMax) +,fTrackBranch(copy.fTrackBranch) +,fMCparticlesBranch(copy.fMCparticlesBranch) +,fJetBranch(copy.fJetBranch) +,fFileId(copy.fFileId) +,fAODEntry(copy.fAODEntry) +,fCountEvents(copy.fCountEvents) +,fEmbedMode(copy.fEmbedMode) +,fEvtSelecMode(copy.fEvtSelecMode) +,fEvtSelMinJetPt(copy.fEvtSelMinJetPt) +,fEvtSelMaxJetPt(copy.fEvtSelMaxJetPt) +,fEvtSelMinJetEta(copy.fEvtSelMinJetEta) +,fEvtSelMaxJetEta(copy.fEvtSelMaxJetEta) +,fEvtSelMinJetPhi(copy.fEvtSelMinJetPhi) +,fEvtSelMaxJetPhi(copy.fEvtSelMaxJetPhi) +,fToyMinNbOfTracks(copy.fToyMinNbOfTracks) +,fToyMaxNbOfTracks(copy.fToyMaxNbOfTracks) +,fToyMinTrackPt(copy.fToyMinTrackPt) +,fToyMaxTrackPt(copy.fToyMaxTrackPt) +,fToyDistributionTrackPt(copy.fToyDistributionTrackPt) +,fToyMinTrackEta(copy.fToyMinTrackEta) +,fToyMaxTrackEta(copy.fToyMaxTrackEta) +,fToyMinTrackPhi(copy.fToyMinTrackPhi) +,fToyMaxTrackPhi(copy.fToyMaxTrackPhi) +,fToyFilterMap(copy.fToyFilterMap) +,fTrackFilterMap(copy.fTrackFilterMap) +,fNPtHard(copy.fNPtHard) +,fPtHard(copy.fPtHard) +,fPtHardBin(copy.fPtHardBin) +,fAODJets(copy.fAODJets) +,fNevents(copy.fNevents) +,fXsection(copy.fXsection) +,fAvgTrials(copy.fAvgTrials) +,fHistList(copy.fHistList) +,fHistEvtSelection(copy.fHistEvtSelection) +,fh1Xsec(copy.fh1Xsec) +,fh1Trials(copy.fh1Trials) +,fh1TrialsEvtSel(copy.fh1TrialsEvtSel) +,fh2PtHard(copy.fh2PtHard) +,fh2PtHardEvtSel(copy.fh2PtHardEvtSel) +,fh2PtHardTrials(copy.fh2PtHardTrials) +,fh1TrackPt(copy.fh1TrackPt) +,fh2TrackEtaPhi(copy.fh2TrackEtaPhi) +,fh1TrackN(copy.fh1TrackN) +,fh1JetPt(copy.fh1JetPt) +,fh2JetEtaPhi(copy.fh2JetEtaPhi) +,fh1JetN(copy.fh1JetN) +,fh1MCTrackPt(copy.fh1MCTrackPt) +,fh2MCTrackEtaPhi(copy.fh2MCTrackEtaPhi) +,fh1MCTrackN(copy.fh1MCTrackN) +,fh1AODfile(copy.fh1AODfile) +,fh2AODevent(copy.fh2AODevent) +{ + // copy constructor +} + + +//__________________________________________________________________________ +AliAnalysisTaskFastEmbedding& AliAnalysisTaskFastEmbedding::operator=(const AliAnalysisTaskFastEmbedding& o) +{ + // assignment + + if(this!=&o){ + AliAnalysisTaskSE::operator=(o); + fESD = o.fESD; + fAODout = o.fAODout; + fAODevent = o.fAODevent; + fAODtree = o.fAODtree; + fAODfile = o.fAODfile; + mcHeader = o.mcHeader; + rndm = o.rndm; + fInputEntries = o.fInputEntries; + fAODPathArray = o.fAODPathArray; + fAODEntriesArray = o.fAODEntriesArray; + fAODPath = o.fAODPath; + fAODEntries = o.fAODEntries; + fAODEntriesSum = o.fAODEntriesSum; + fAODEntriesMax = o.fAODEntriesMax; + fOfflineTrgMask = o.fOfflineTrgMask; + fMinContribVtx = o.fMinContribVtx; + fVtxZMin = o.fVtxZMin; + fVtxZMax = o.fVtxZMax; + fEvtClassMin = o.fEvtClassMin; + fEvtClassMax = o.fEvtClassMax; + fCentMin = o.fCentMin; + fCentMax = o.fCentMax; + fNInputTracksMin = o.fNInputTracksMin; + fNInputTracksMax = o.fNInputTracksMax; + fTrackBranch = o.fTrackBranch; + fMCparticlesBranch = o.fMCparticlesBranch; + fJetBranch = o.fJetBranch; + fFileId = o.fFileId; + fAODEntry = o.fAODEntry; + fCountEvents = o.fCountEvents; + fEmbedMode = o.fEmbedMode; + fEvtSelecMode = o.fEvtSelecMode; + fEvtSelMinJetPt = o.fEvtSelMinJetPt; + fEvtSelMaxJetPt = o.fEvtSelMaxJetPt; + fEvtSelMinJetEta = o.fEvtSelMinJetEta; + fEvtSelMaxJetEta = o.fEvtSelMaxJetEta; + fEvtSelMinJetPhi = o.fEvtSelMinJetPhi; + fEvtSelMaxJetPhi = o.fEvtSelMaxJetPhi; + fToyMinNbOfTracks = o.fToyMinNbOfTracks; + fToyMaxNbOfTracks = o.fToyMaxNbOfTracks; + fToyMinTrackPt = o.fToyMinTrackPt; + fToyMaxTrackPt = o.fToyMaxTrackPt; + fToyDistributionTrackPt = o.fToyDistributionTrackPt; + fToyMinTrackEta = o.fToyMinTrackEta; + fToyMaxTrackEta = o.fToyMaxTrackEta; + fToyMinTrackPhi = o.fToyMinTrackPhi; + fToyMaxTrackPhi = o.fToyMaxTrackPhi; + fToyFilterMap = o.fToyFilterMap; + fTrackFilterMap = o.fTrackFilterMap; + fNPtHard = o.fNPtHard; + fPtHard = o.fPtHard; + fPtHardBin = o.fPtHardBin; + fAODJets = o.fAODJets; + fNevents = o.fNevents; + fXsection = o.fXsection; + fAvgTrials = o.fAvgTrials; + fHistList = o.fHistList; + fHistEvtSelection = o.fHistEvtSelection; + fh1Xsec = o.fh1Xsec; + fh1Trials = o.fh1Trials; + fh1TrialsEvtSel = o.fh1TrialsEvtSel; + fh2PtHard = o.fh2PtHard; + fh2PtHardEvtSel = o.fh2PtHardEvtSel; + fh2PtHardTrials = o.fh2PtHardTrials; + fh1TrackPt = o.fh1TrackPt; + fh2TrackEtaPhi = o.fh2TrackEtaPhi; + fh1TrackN = o.fh1TrackN; + fh1JetPt = o.fh1JetPt; + fh2JetEtaPhi = o.fh2JetEtaPhi; + fh1JetN = o.fh1JetN; + fh1MCTrackPt = o.fh1MCTrackPt; + fh2MCTrackEtaPhi = o.fh2MCTrackEtaPhi; + fh1MCTrackN = o.fh1MCTrackN; + fh1AODfile = o.fh1AODfile; + fh2AODevent = o.fh2AODevent; + } + + return *this; +} + + +//__________________________________________________________________________ +AliAnalysisTaskFastEmbedding::~AliAnalysisTaskFastEmbedding() +{ + // destructor + delete rndm; +} + + +//__________________________________________________________________________ +void AliAnalysisTaskFastEmbedding::UserCreateOutputObjects() +{ + // create output objects + if(fDebug > 1) Printf("AliAnalysisTaskFastEmbedding::UserCreateOutputObjects()"); + AliLog::SetClassDebugLevel("AliAnalysisTaskFastEmbedding", AliLog::kInfo); + + OpenFile(1); + if(!fHistList) fHistList = new TList(); + fHistList->SetOwner(kTRUE); + + + // set seed + rndm = new TRandom3(); + Int_t id = GetJobID(); + if(id>-1) rndm->SetSeed(id); + else rndm->SetSeed(); // a TTUID is generated and used for seed + AliInfo(Form("TRandom3 seed: %d", rndm->GetSeed())); + + + + // embed mode with AOD + if(fEmbedMode==kAODFull || fEmbedMode==kAODJetTracks || fEmbedMode==kAODJet4Mom){ + + // open input AOD + fFileId = OpenAODfile(); + fNevents = 0; // force to open another aod in UserExec() + if(fFileId<0){ + AliError(""); + PostData(1, fHistList); + return; + } + } //end: embed mode with AOD + + + // connect output aod + // create a new branch for extra tracks + fAODout = AODEvent(); + if(!fAODout){ + AliError("Output AOD not found."); + PostData(1, fHistList); + return; + } + if(!fAODout->FindListObject(fTrackBranch.Data()) && strlen(fTrackBranch.Data())){ + AliInfo(Form("Add AOD branch %s", fTrackBranch.Data())); + TClonesArray *tracks = new TClonesArray("AliAODTrack",0); + tracks->SetName(fTrackBranch.Data()); + AddAODBranch("TClonesArray", &tracks); + } + // create new branch for extra mcparticle if available as input + if(fAODevent && fAODevent->FindListObject("mcparticles") && strlen(fMCparticlesBranch.Data())){ + AliInfo(Form("Add AOD branch %s", fMCparticlesBranch.Data())); + TClonesArray *mcparticles = new TClonesArray("AliAODMCParticle",0); + mcparticles->SetName(fMCparticlesBranch.Data()); + AddAODBranch("TClonesArray", &mcparticles); + } + + + + //qa histograms + Bool_t oldStatus = TH1::AddDirectoryStatus(); + TH1::AddDirectory(kFALSE); + + fHistEvtSelection = new TH1I("fHistEvtSelection", "event selection", 6, -0.5, 5.5); + fHistEvtSelection->GetXaxis()->SetBinLabel(1,"ACCEPTED"); + fHistEvtSelection->GetXaxis()->SetBinLabel(2,"events IN"); + fHistEvtSelection->GetXaxis()->SetBinLabel(3,"event selection (rejected)"); + fHistEvtSelection->GetXaxis()->SetBinLabel(4,"vertex cut (rejected)"); + fHistEvtSelection->GetXaxis()->SetBinLabel(5,"centrality (rejected)"); + fHistEvtSelection->GetXaxis()->SetBinLabel(6,"multiplicity (rejected)"); + + fh1Xsec = new TProfile("fh1Xsec","xsec from pyxsec.root;p_{T,hard} bin;<#sigma>",fNPtHard+1,-1.5,fNPtHard-0.5); + fh1Trials = new TH1F("fh1Trials","trials (simulation) from pyxsec.root;p_{T,hard} bin;#sum{ntrials}",fNPtHard+1,-1.5,fNPtHard-0.5); + fh1TrialsEvtSel = new TH1F("fh1TrialsEvtSel","trials (event selection) from pyxsec.root;p_{T,hard} bin;#sum{ntrials}",fNPtHard+1,-1.5,fNPtHard-0.5); + fh2PtHard = new TH2F("fh2PtHard","PYTHIA Pt hard;p_{T,hard} bin;p_{T,hard}",fNPtHard+1,-1.5,fNPtHard-0.5,350,-.5,349.5); + fh2PtHardEvtSel = new TH2F("fh2PtHardEvtSel","PYTHIA Pt hard (event selection);p_{T,hard} bin;p_{T,hard}",fNPtHard+1,-1.5,fNPtHard-0.5,350,-.5,349.5); + fh2PtHardTrials = new TH2F("fh2PtHardTrials","PYTHIA Pt hard weight with trials;p_{T,hard} bin;#sum{p_{T,hard}}",fNPtHard+1,-1.5,fNPtHard-0.5,350,-.5,349.5); + + fHistList->Add(fHistEvtSelection); + fHistList->Add(fh1Xsec); + fHistList->Add(fh1Trials); + fHistList->Add(fh1TrialsEvtSel); + fHistList->Add(fh2PtHard); + fHistList->Add(fh2PtHardEvtSel); + fHistList->Add(fh2PtHardTrials); + + fh1TrackPt = new TH1F("fh1TrackPt","pT of extra tracks;p_{T};entries", 250, 0., 250.); + fh2TrackEtaPhi = new TH2F("fh2TrackEtaPhi","eta-phi distribution of extra tracks;#eta;#phi", 20, -1., 1., 60, 0., 2*TMath::Pi()); + fh1TrackN = new TH1F("fh1TrackN", "nb. of extra tracks per event;nb. of tracks;entries",300, 0., 300.); + + fHistList->Add(fh1TrackPt); + fHistList->Add(fh2TrackEtaPhi); + fHistList->Add(fh1TrackN); + + if(fEmbedMode==kAODFull || fEmbedMode==kAODJetTracks || fEmbedMode==kAODJet4Mom){ + + fh1JetPt = new TH1F("fh1JetPt", "pT of extra jets;p_{T};entries", 120, 0., 120.); + fh2JetEtaPhi = new TH2F("fh2JetEtaPhi", "eta-phi distribution of extra jets;#eta;#phi", 20, -1., 1., 60, 0., 2*TMath::Pi()); + fh1JetN = new TH1F("fh1JetN", "nb. of extra jets per event;nb. of jets;entries",20,0.,20.); + + fHistList->Add(fh1JetPt); + fHistList->Add(fh2JetEtaPhi); + fHistList->Add(fh1JetN); + } + + + if(fAODevent && fAODevent->FindListObject("mcparticles") && strlen(fMCparticlesBranch.Data())){ + + fh1MCTrackPt = new TH1F("fh1MCTrackPt","pT of MC extra tracks;p_{T};entries", 250, 0., 250.); + fh2MCTrackEtaPhi = new TH2F("fh2MCTrackEtaPhi","eta-phi distribution of MC extra tracks;#eta;#phi", 20, -1., 1., 60, 0., 2*TMath::Pi()); + fh1MCTrackN = new TH1F("fh1MCTrackN", "nb. of MC extra tracks per event;nb. of tracks;entries",300, 0., 300.); + + fHistList->Add(fh1MCTrackPt); + fHistList->Add(fh2MCTrackEtaPhi); + fHistList->Add(fh1MCTrackN); + + } + + fh1AODfile = new TH1I("fh1AODfile", "overview of opened AOD files from the array", 2300, -0.5, 2299.5); + fh2AODevent = new TH2I("fh1AODevent","selected events;file;event", 2500,-.5,2499.5,5000,-.5,4999.5); + fHistList->Add(fh1AODfile); + fHistList->Add(fh2AODevent); + + // =========== Switch on Sumw2 for all histos =========== + for (Int_t i=0; iGetEntries(); ++i) { + TH1 *h1 = dynamic_cast(fHistList->At(i)); + if (h1){ + h1->Sumw2(); + continue; + } + } + + TH1::AddDirectory(oldStatus); + + PostData(1, fHistList); +} + + +//__________________________________________________________________________ +void AliAnalysisTaskFastEmbedding::Init() +{ + // Initialization + if(fDebug > 1) Printf("AliAnalysisTaskFastEmbedding::Init()"); + +} + +//__________________________________________________________________________ +Bool_t AliAnalysisTaskFastEmbedding::UserNotify() +{ + + if(fDebug > 1) Printf("AliAnalysisTaskFastEmbedding::UserNotify()"); + + // get total nb of events in tree (of this subjob) + AliInputEventHandler* inputHandler = (AliInputEventHandler*)((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler()); + fInputEntries = inputHandler->GetTree()->GetEntriesFast(); + AliInfo(Form("Total nb. of events: %d", fInputEntries)); + + return kTRUE; + +} + + +//__________________________________________________________________________ +void AliAnalysisTaskFastEmbedding::UserExec(Option_t *) +{ + if(fDebug > 1) Printf("AliAnalysisTaskFastEmbedding::UserExec()"); + + if(!fAODout){ + AliError("Need output AOD, but is not connected."); + PostData(1, fHistList); + return; + } + + fESD=dynamic_cast(InputEvent()); + if (!fESD) { + AliError("ESD not available"); + PostData(1, fHistList); + return; + } + + // -- event selection -- + fHistEvtSelection->Fill(1); // number of events before event selection + + // physics selection + AliInputEventHandler* inputHandler = (AliInputEventHandler*) + ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler()); + if(!(inputHandler->IsEventSelected() & fOfflineTrgMask)){ + if(fDebug) Printf(" Trigger Selection: event REJECTED ... "); + fHistEvtSelection->Fill(2); + PostData(1, fHistList); + return; + } + + // vertex selection + AliAODVertex* primVtx = fAODout->GetPrimaryVertex(); + Int_t nTracksPrim = primVtx->GetNContributors(); + if ((nTracksPrim < fMinContribVtx) || + (primVtx->GetZ() < fVtxZMin) || + (primVtx->GetZ() > fVtxZMax) ){ + if(fDebug) Printf("%s:%d primary vertex z = %f: event REJECTED...",(char*)__FILE__,__LINE__,primVtx->GetZ()); + fHistEvtSelection->Fill(3); + PostData(1, fHistList); + return; + } + + /** takes wrong value, since jet service tasks runs later + // event class selection (from jet helper task) + Int_t eventClass = AliAnalysisHelperJetTasks::EventClass(); + if(fDebug) Printf("Event class %d", eventClass); + if (eventClass < fEvtClassMin || eventClass > fEvtClassMax){ + fHistEvtSelection->Fill(4); + PostData(1, fHistList); + return; + }*/ + + // centrality selection + AliCentrality *cent = 0x0; + Float_t centValue = 0.; + if(fESD) cent = fESD->GetCentrality(); + if(cent) centValue = cent->GetCentralityPercentile("V0M"); + if(fDebug) printf("centrality: %f\n", centValue); + if (centValue < fCentMin || centValue > fCentMax){ + fHistEvtSelection->Fill(4); + PostData(1, fHistList); + return; + } + + + /* ** not implemented ** + // multiplicity due to input tracks + Int_t nInputTracks = GetNInputTracks(); + + if (nInputTracks < fNInputTracksMin || (fNInputTracksMax > -1 && nInputTracks > fNInputTracksMax)){ + fHistEvtSelection->Fill(5); + PostData(1, fHistList); + return; + } + */ + + fHistEvtSelection->Fill(0); // accepted events + // -- end event selection -- + + // connect aod out + TClonesArray *tracks = (TClonesArray*)(fAODout->FindListObject(fTrackBranch.Data())); + if(!tracks){ + AliError("Extra track branch not found in output."); + PostData(1, fHistList); + return; + } + tracks->Delete(); + Int_t nAODtracks=0; + + TRef dummy; + + // === embed mode with AOD === + if(fEmbedMode==kAODFull || fEmbedMode==kAODJetTracks || fEmbedMode==kAODJet4Mom){ + if(!fAODevent){ + AliError("Need input AOD, but is not connected."); + PostData(1, fHistList); + return; + } + + + + Bool_t useEntry = kFALSE; + while(!useEntry){ // protection need, if no event fulfills requierment + + fAODEntry++; // go to next event + fCountEvents++; + if(fAODEntry>=fNevents) fAODEntry=0; + + // open new aod file + if(fCountEvents>=fNevents){ + if(!fAODPathArray){ + AliDebug(AliLog::kDebug, "No list of AODs, keep current AOD."); + } + else { + AliDebug(AliLog::kDebug, "Select new AOD file ..."); + + fFileId = OpenAODfile(); + if(fFileId<0) { + PostData(1, fHistList); + return; + } + fh1AODfile->Fill(fFileId); + if(fAODEntries!=fNevents){ + AliError("File with list of AODs and file with nb. of entries inconsistent"); + PostData(1, fHistList); + return; + } + } + } + + + + // get next event + fAODtree->GetEvent(fAODEntry); + + // get pt hard + if(mcHeader){ + fPtHard = mcHeader->GetPtHard(); + GetPtHard(kTRUE,fPtHard); // make value available for other tasks (e.g. jet response task) + AliDebug(AliLog::kDebug,Form("pt hard %.2f", fPtHard)); + } + else{ + AliDebug(AliLog::kDebug,"No mcHeader"); + } + fPtHardBin = GetPtHardBin(fPtHard); + + //Printf("pt hard (bin) %.2f (%d), xSection %.2e, trials %.2f",fPtHard, fPtHardBin, fXsection, fAvgTrials); + + // fill event variables for each event + fh1Xsec->Fill(fPtHardBin,fXsection); + fh2PtHard->Fill(fPtHardBin,fPtHard); + + fh1Trials->Fill(fPtHardBin, fAvgTrials); + fh1TrialsEvtSel->Fill(fPtHardBin); + fh2PtHardTrials->Fill(fPtHardBin,fPtHard,fAvgTrials); + + // jet pt selection + if(fEvtSelecMode==kEventsJetPt){ + Int_t nJets = fAODJets->GetEntries(); + //Printf("nb. jets: %d",nJets); + for(Int_t ij=0; ij(fAODJets->At(ij)); + if(!jet) continue; + + if( (fEvtSelMinJetPt==-1. || jet->Pt()>=fEvtSelMinJetPt) + && (fEvtSelMaxJetPt==-1. || jet->Pt()<=fEvtSelMaxJetPt) + && (jet->Eta()>=fEvtSelMinJetEta && jet->Eta()<=fEvtSelMaxJetEta) + && (jet->Phi()>=fEvtSelMinJetPhi && jet->Phi()<=fEvtSelMaxJetPhi)){ + useEntry = kTRUE; + break; + } + } + } + + // no selection + if(fEvtSelecMode==kEventsAll){ + useEntry = kTRUE; + } + + } + AliDebug(AliLog::kDebug,Form("Use entry %d from extra AOD.", fAODEntry)); + + fh2PtHardEvtSel->Fill(fPtHardBin,fPtHard); + fh2AODevent->Fill(fFileId,fAODEntry); + + TClonesArray *mcpartIN = (TClonesArray*)(fAODevent->FindListObject("mcparticles")); + TClonesArray *mcpartOUT = 0x0; + if(mcpartIN){ + mcpartOUT = (TClonesArray*)(fAODout->FindListObject(fMCparticlesBranch.Data())); + if(!mcpartOUT){ + AliError("Extra MC particles branch not found in output."); + PostData(1, fHistList); + return; + } + mcpartOUT->Delete(); + } else { + AliInfo("No extra MC particles found."); + } + + + if(fEmbedMode==kAODFull || fEmbedMode==kAODJetTracks){ // take all tracks or jet tracks + // loop over input tracks + // add to output aod + Int_t nTracks = 0; + Int_t nJets = fAODJets->GetEntries(); + Int_t nSelectedJets = 0; + AliAODJet *leadJet = 0x0; // used for jet tracks only + + if(fEmbedMode==kAODFull){ + nTracks = fAODevent->GetNumberOfTracks(); + + for(Int_t ij=0; ij(fAODJets->At(ij)); + if(!jet) continue; + if( (fEvtSelMinJetPt==-1. || jet->Pt()>=fEvtSelMinJetPt) + && (fEvtSelMaxJetPt==-1. || jet->Pt()<=fEvtSelMaxJetPt) + && (jet->Eta()>=fEvtSelMinJetEta && jet->Eta()<=fEvtSelMaxJetEta) + && (jet->Phi()>=fEvtSelMinJetPhi && jet->Eta()<=fEvtSelMaxJetPhi)){ + + fh1JetPt->Fill(jet->Pt()); + fh2JetEtaPhi->Fill(jet->Eta(), jet->Phi()); + nSelectedJets++; + + } + } + fh1JetN->Fill(nSelectedJets); + } + + if(fEmbedMode==kAODJetTracks){ + // look for leading jet within selection + // get reference tracks for this jet + Float_t leadJetPt = 0.; + for(Int_t ij=0; ij(fAODJets->At(ij)); + if(!jet) continue; + if( (fEvtSelMinJetPt==-1. || jet->Pt()>=fEvtSelMinJetPt) + && (fEvtSelMaxJetPt==-1. || jet->Pt()<=fEvtSelMaxJetPt) + && (jet->Eta()>=fEvtSelMinJetEta && jet->Eta()<=fEvtSelMaxJetEta) + && (jet->Phi()>=fEvtSelMinJetPhi && jet->Eta()<=fEvtSelMaxJetPhi)){ + if(jet->Pt()>leadJetPt){ + leadJetPt = jet->Pt(); + leadJet = jet; + } + } + } + if(leadJet){ + nTracks = leadJet->GetRefTracks()->GetEntriesFast(); + fh1JetPt->Fill(leadJet->Pt()); + fh2JetEtaPhi->Fill(leadJet->Eta(), leadJet->Pt()); + fh1JetN->Fill(1); + } + } + + fh1TrackN->Fill((Float_t)nTracks); + + for(Int_t it=0; itGetTrack(it); + if(fEmbedMode==kAODJetTracks) tmpTr = dynamic_cast(leadJet->GetRefTracks()->At(it)); + if(!tmpTr) continue; + + tmpTr->SetStatus(AliESDtrack::kEmbedded); + + new ((*tracks)[nAODtracks++]) AliAODTrack(*tmpTr); + dummy = (*tracks)[nAODtracks-1]; + + if(fTrackFilterMap<=0 || tmpTr->TestFilterBit(fTrackFilterMap)){ + fh1TrackPt->Fill(tmpTr->Pt()); + fh2TrackEtaPhi->Fill(tmpTr->Eta(), tmpTr->Phi()); + } + } + + if(mcpartIN){ + Int_t nMCpart = mcpartIN->GetEntriesFast(); + + Int_t nPhysicalPrimary=0; + Int_t nAODmcpart=0; + for(Int_t ip=0; ipAt(ip); + + if(fEmbedMode==kAODJetTracks){ + // jet track? else continue + // not implemented yet + continue; + } + + new((*mcpartOUT)[nAODmcpart++]) AliAODMCParticle(*tmpPart); + dummy = (*mcpartOUT)[nAODmcpart-1]; + + if(tmpPart->IsPhysicalPrimary() && tmpPart->Charge()!=0. && tmpPart->Charge()!=-99. ){ + fh1MCTrackPt->Fill(tmpPart->Pt()); + fh2MCTrackEtaPhi->Fill(tmpPart->Eta(), tmpPart->Phi()); + nPhysicalPrimary++; + } + } + fh1MCTrackN->Fill((Float_t)nPhysicalPrimary); + + } + } // end: embed all tracks or jet tracks + + + if(fEmbedMode==kAODJet4Mom){ + + // loop over jets + Int_t nJets = fAODJets->GetEntries(); + fh1TrackN->Fill((Float_t)nJets); + for(Int_t ij=0; ij(fAODJets->At(ij)); + if(!jet) continue; + AliAODTrack *tmpTr = (AliAODTrack*)jet; + tmpTr->SetFlags(AliESDtrack::kEmbedded); + + new ((*tracks)[nAODtracks++]) AliAODTrack(*tmpTr); + dummy = (*tracks)[nAODtracks-1]; + + fh1TrackPt->Fill(tmpTr->Pt()); + fh2TrackEtaPhi->Fill(tmpTr->Eta(), tmpTr->Phi()); + } + + } // end: embed jets as 4-momenta + + + } //end: embed mode with AOD + + + // === embed mode with toy === + if(fEmbedMode==kToyTracks){ + Int_t nT = (Int_t)(rndm->Uniform(fToyMinNbOfTracks, fToyMaxNbOfTracks)+0.5); + + fh1TrackN->Fill((Float_t)nT); + + for(Int_t i=0; iUniform(fToyMinTrackPt, fToyMaxTrackPt); + } else { + while(ptfToyMaxTrackPt){ + pt = rndm->Exp(fToyDistributionTrackPt); // no power law yet!! + pt += fToyMinTrackPt; + } + } + } else { + pt = fToyMinTrackPt; + } + Double_t eta = rndm->Uniform(fToyMinTrackEta,fToyMaxTrackEta); + Double_t phi = rndm->Uniform(fToyMinTrackPhi,fToyMaxTrackPhi); + phi = TVector2::Phi_0_2pi(phi); + + if(fDebug) Printf("Add track #%d: pt %.2f, eta %.2f, phi %.2f", i, pt, eta, phi); + + Double_t theta = 2*TMath::ATan(1/TMath::Exp(eta)); + Float_t mom[3]; + mom[0] = pt; + mom[1] = phi; + mom[2] = theta; + + Float_t xyz[3]; + xyz[0] = -999.; + xyz[1] = -999.; + xyz[2] = -999.; + + AliAODTrack *tmpTr = new AliAODTrack( -999, // id + -999, // label + mom, // momentum[3] + kFALSE, // cartesian + xyz, // position + kFALSE, // DCA + NULL, // covMatrix, + -99, // charge + 0, // itsClusMap + NULL, // pid + NULL, // prodVertex + kFALSE, // used for vertex fit + kFALSE, // used for prim vtx fit + AliAODTrack::kUndef, // type + fToyFilterMap, // select info + -999. // chi2 per NDF + ); + tmpTr->SetFlags(AliESDtrack::kEmbedded); + + new((*tracks)[nAODtracks++]) AliAODTrack(*tmpTr); + dummy = (*tracks)[nAODtracks-1]; + + fh1TrackPt->Fill(pt); + fh2TrackEtaPhi->Fill(eta,phi); + + delete tmpTr; + } + } //end: embed mode with toy + + + PostData(1, fHistList); +} + + +//__________________________________________________________________________ +void AliAnalysisTaskFastEmbedding::Terminate(Option_t *) +{ + if(fDebug > 1) Printf("AliAnalysisTaskFastEmbedding::Terminate()"); + + if(fAODfile && fAODfile->IsOpen()) + fAODfile->Close(); + +} + +//__________________________________________________________________________ +Int_t AliAnalysisTaskFastEmbedding::GetJobID() +{ + Int_t id=-1; + + const char* env = gSystem->Getenv("ALIEN_PROC_ID"); // GRID + //if(!env || !strlen(env)) env = gSystem->Getenv("LSB_JOBINDEX"); // GSI + + if(env && strlen(env)){ + id= atoi(env); + AliInfo(Form("Job index %d", id)); + } + else{ + AliInfo("Job index not found. Okay if running locally."); + } + + return id; +} + +//__________________________________________________________________________ + +Int_t AliAnalysisTaskFastEmbedding::SelectAODfile(){ + + Int_t nFiles = fAODPathArray->GetEntries(); + + // choose randomly file and event + Int_t n = -1; + Float_t tmpProp = -1.; + Int_t pendingEvents = fInputEntries-Entry(); + //Printf("input entries %d, entry %d, pending events %d", fInputEntries, (Int_t)Entry(), pendingEvents); + while(rndm->Rndm()>tmpProp){ + n = rndm->Integer(nFiles); + fAODEntries = fAODEntriesArray->At(n); + Int_t tmpEntries = fAODEntriesUniform(fAODEntries)); + + AliInfo(Form("Select AOD file %d", n)); + TObjString *objStr = (TObjString*) fAODPathArray->At(n); + if(!objStr){ + AliError("Could not get path of aod file."); + return -1; + } + fAODPath = objStr->GetString(); + + return n; +} + +//__________________________________________________________________________ + +Int_t AliAnalysisTaskFastEmbedding::OpenAODfile(Int_t trial){ + + if(fAODPathArray) fFileId = SelectAODfile(); + if(fFileId<0) return -1; + + TDirectory *owd = gDirectory; + if (fAODfile) fAODfile->Close(); + fAODfile = TFile::Open(fAODPath.Data(),"TIMEOUT=180"); + owd->cd(); + if(!fAODfile){ + + fFileId = -1; + if(fAODPathArray){ + if(trial<=3){ + AliError(Form("Could not open AOD file %s (trial %d), try again ...", fAODPath.Data(), trial)); + fFileId = OpenAODfile(trial+1); + } else { + AliError(Form("Could not open AOD file %s, give up ...",fAODPath.Data())); + return -1; + } + } else { + AliError(Form("Could not open AOD file %s.", fAODPath.Data())); + } + + return fFileId; + } + + fAODtree = (TTree*)fAODfile->Get("aodTree"); + + if(!fAODtree){ + AliError("AOD tree not found."); + return -1; + } + + /* + fAODtree->SetBranchStatus("*",0); + fAODtree->SetBranchStatus("header",1); + fAODtree->SetBranchStatus("tracks*",1); + fAODtree->SetBranchStatus("jets*",1); + fAODtree->SetBranchStatus("clusters*",1); + fAODtree->SetBranchStatus("mcparticles*",1); + fAODtree->SetBranchStatus("mcHeader*",1); + */ + + delete fAODevent; + fAODevent = new AliAODEvent(); + fAODevent->ReadFromTree(fAODtree); + + + // fetch header, jets, etc. from new file + fNevents = fAODtree->GetEntries(); + mcHeader = (AliAODMCHeader*)fAODevent->FindListObject(AliAODMCHeader::StdBranchName()); + + if(fJetBranch.Length()) fAODJets = dynamic_cast(fAODevent->FindListObject(fJetBranch.Data())); + else fAODJets = fAODevent->GetJets(); + if(!fAODJets){ + AliError("Could not find jets in AOD. Check jet branch when indicated."); + return -1; + } + + TFile *curfile = fAODtree->GetCurrentFile(); + if (!curfile) { + AliError("No current file."); + return -1; + } + + Float_t trials = 1.; + Float_t xsec = 0.; + PythiaInfoFromFile(curfile->GetName(),xsec,trials); + fXsection = xsec; + + // construct a poor man average trials + Float_t nEntries = (Float_t)fAODtree->GetTree()->GetEntries(); + if(trials>=nEntries && nEntries>0.)fAvgTrials = trials/nEntries; + + if(fFileId>=0){ + AliInfo(Form("Read successfully AOD event from file %d",fFileId)); + } + + fCountEvents=0; // new file, reset counter + + return fFileId; // file position in AOD path array, if array available +} + + +//____________________________________________________________________________ +Float_t AliAnalysisTaskFastEmbedding::GetPtHard(Bool_t bSet, Float_t newValue){ + + static Float_t ptHard = -1.; + if(bSet) ptHard = newValue; + + return ptHard; +} + +//____________________________________________________________________________ +Int_t AliAnalysisTaskFastEmbedding::GetPtHardBin(Double_t ptHard){ + + const Int_t nBins = 10; + Double_t binLimits[nBins] = { 5., 11., 21., 36., 57., 84., 117., 156., 200., 249. }; // lower limits + + Int_t bin = -1; + while(binBaseName(file.Data()),""); + } + + TFile *fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec.root")); // problem that we cannot really test the existance of a file in a archive so we have to lvie with open error message from root + if(!fxsec){ + // next trial fetch the histgram file + fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec_hists.root")); + if(!fxsec){ + // not a severe condition but inciate that we have no information + AliDebug(AliLog::kDebug,Form("Neither pyxsec.root nor pyxsec_hists.root found in %s",file.Data())); + return kFALSE; + } + else{ + // find the tlist we want to be independtent of the name so use the Tkey + TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0); + if(!key){ + fxsec->Close(); + return kFALSE; + } + TList *list = dynamic_cast(key->ReadObj()); + if(!list){ + fxsec->Close(); + return kFALSE; + } + fXsec = ((TProfile*)list->FindObject("h1Xsec"))->GetBinContent(1); + fTrials = ((TH1F*)list->FindObject("h1Trials"))->GetBinContent(1); + fxsec->Close(); + } + } // no tree pyxsec.root + else { + TTree *xtree = (TTree*)fxsec->Get("Xsection"); + if(!xtree){ + fxsec->Close(); + return kFALSE; + } + UInt_t ntrials = 0; + Double_t xsection = 0; + xtree->SetBranchAddress("xsection",&xsection); + xtree->SetBranchAddress("ntrials",&ntrials); + xtree->GetEntry(0); + fTrials = ntrials; + fXsec = xsection; + fxsec->Close(); + } + return kTRUE; +} + + diff --git a/JETAN/DEV/AliAnalysisTaskFastEmbedding.h b/JETAN/DEV/AliAnalysisTaskFastEmbedding.h new file mode 100644 index 00000000000..d17a43c4571 --- /dev/null +++ b/JETAN/DEV/AliAnalysisTaskFastEmbedding.h @@ -0,0 +1,197 @@ +#ifndef ALIANALYSISTASKFASTEMBEDDING_H +#define ALIANALYSISTASKFASTEMBEDDING_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* See cxx source for full Copyright notice */ + +/* $Id$ */ + +#include "AliAnalysisTaskSE.h" + +class AliESDEvent; +class AliAODEvent; +class TTree; +class TFile; +class TChain; +class TObjArray; +class TObjString; +class TRandom3; +class TH1F; +class TH2F; +class TProfile; +class AliAODMCHeader; + +class AliAnalysisTaskFastEmbedding : public AliAnalysisTaskSE { + +public: + + AliAnalysisTaskFastEmbedding(); + AliAnalysisTaskFastEmbedding(const char *name); + AliAnalysisTaskFastEmbedding(const AliAnalysisTaskFastEmbedding ©); + AliAnalysisTaskFastEmbedding& operator=(const AliAnalysisTaskFastEmbedding &o); + virtual ~AliAnalysisTaskFastEmbedding(); + + virtual void UserCreateOutputObjects(); + virtual void LocalInit() { Init(); } + virtual void Init(); + virtual Bool_t UserNotify(); + virtual void UserExec(Option_t*); + virtual void Terminate(Option_t */*option*/); + + void SetAODPath(TString path) {fAODPath = path;} + void SetArrayOfAODPaths(TObjArray* arr) {fAODPathArray = arr;} + void SetArrayOfAODEntries(TArrayI* arr) {fAODEntriesArray = arr;} + void SetAODEntriesSum(Int_t i){ fAODEntriesSum = i;} + void SetAODEntriesMax(Int_t i){ fAODEntriesMax = i;} + + virtual void SetOfflineTrgMask(AliVEvent::EOfflineTriggerTypes mask) { fOfflineTrgMask = mask; } + virtual void SetMinContribVtx(Int_t n) { fMinContribVtx = n; } + virtual void SetVtxZMin(Float_t z) { fVtxZMin = z; } + virtual void SetVtxZMax(Float_t z) { fVtxZMax = z; } + virtual void SetEvtClassMin(Int_t evtClass) { fEvtClassMin = evtClass; } + virtual void SetEvtClassMax(Int_t evtClass) { fEvtClassMax = evtClass; } + virtual void SetCentMin(Float_t cent) { fCentMin = cent; } + virtual void SetCentMax(Float_t cent) { fCentMax = cent; } + virtual void SetNInputTracksMin(Int_t nTr) { fNInputTracksMin = nTr; } + virtual void SetNInputTracksMax(Int_t nTr) { fNInputTracksMax = nTr; } + + void SetTrackBranch(TString name) {fTrackBranch = name;} + void SetMCparticlesBranch(TString name) {fMCparticlesBranch = name;} + void SetJetBranch(TString name) {fJetBranch = name;} + + void SetEmbedMode(Int_t m) {fEmbedMode = m;} + Int_t GetEmbedMode() {return fEmbedMode;} + void SetEvtSelecMode(Int_t s) {fEvtSelecMode = s;} + Int_t GetEvtSelecMode() {return fEvtSelecMode;} + + void SetEvtSelJetPtRange(Float_t minPt, Float_t maxPt) {fEvtSelMinJetPt = minPt; fEvtSelMaxJetPt = maxPt;} + void SetEvtSelJetEtaRange(Float_t minEta, Float_t maxEta) {fEvtSelMinJetEta = minEta; fEvtSelMaxJetEta = maxEta;} + void SetEvtSelJetPhiRange(Float_t minPhi, Float_t maxPhi) {fEvtSelMinJetPhi = minPhi; fEvtSelMaxJetPhi = maxPhi;} + + void SetToyNumberOfTrackRange(Int_t minN = 1, Int_t maxN = 1){ fToyMinNbOfTracks = minN, fToyMaxNbOfTracks = maxN; } + void SetToyTrackRanges(Double_t minPt = 50., Double_t maxPt = 50., Double_t ptDistr=0, + Double_t minEta = -.5, Double_t maxEta = .5, + Double_t minPhi = 0., Double_t maxPhi = 2*TMath::Pi()) + { + fToyMinTrackPt = minPt; fToyMaxTrackPt = maxPt; fToyDistributionTrackPt = ptDistr; + fToyMinTrackEta = minEta; fToyMaxTrackEta = maxEta; + fToyMinTrackPhi = minPhi; fToyMaxTrackPhi = maxPhi;} + void SetToyFilterMap(UInt_t f) {fToyFilterMap = f;} + void SetTrackFilterMap(UInt_t f) {fTrackFilterMap = f;} + + static Float_t GetPtHard(Bool_t bSet=kFALSE, Float_t newValue = 0.); + + virtual Int_t GetPtHardBin(Double_t ptHard); + virtual Bool_t PythiaInfoFromFile(const char* currFile,Float_t &fXsec,Float_t &fTrials); + + // embedding modes + enum {kAODFull=0, kAODJetTracks, kAODJet4Mom, kToyTracks}; + // event selection from AOD + enum {kEventsAll=0, kEventsJetPt}; + + +private: + + AliESDEvent *fESD; //! ESD object + AliAODEvent *fAODout; //! AOD out + AliAODEvent *fAODevent; //! AOD in + TTree *fAODtree; //! AODin tree + TFile *fAODfile; //! AODin file + AliAODMCHeader *mcHeader; //! mc header + TRandom3 *rndm; //! random nummer generator + Int_t fInputEntries; // total nb. of events (for this subjob) + + TObjArray *fAODPathArray; // array of paths of AOD in file + TArrayI *fAODEntriesArray; // array of entries of AODs + TString fAODPath; // path of AOD in file + Int_t fAODEntries; // entries of AOD + Int_t fAODEntriesSum; // sum of all entries of AODs + Int_t fAODEntriesMax; // maximum entries of AODs + + AliVEvent::EOfflineTriggerTypes fOfflineTrgMask; // mask of offline triggers to accept + Int_t fMinContribVtx; // minimum number of track contributors for primary vertex + Float_t fVtxZMin; // lower bound on vertex z + Float_t fVtxZMax; // upper bound on vertex z + Int_t fEvtClassMin; // lower bound on event class + Int_t fEvtClassMax; // upper bound on event class + Float_t fCentMin; // lower bound on centrality + Float_t fCentMax; // upper bound on centrality + Int_t fNInputTracksMin; // lower bound of nb. of input tracks + Int_t fNInputTracksMax; // upper bound of nb. of input tracks + + TString fTrackBranch; // name of branch for extra tracks in AOD out + TString fMCparticlesBranch; // name of branch for extra mcparticles in AOD out + TString fJetBranch; // name of branch for extra jets AOD in + + Int_t fFileId; // nb. of file from the list + Int_t fAODEntry; // entry of extra AOD + Int_t fCountEvents; // count processed events in this file + + Int_t fEmbedMode; + Int_t fEvtSelecMode; + + // event selection from AOD + Float_t fEvtSelMinJetPt; // minimum pt of the leading jet + Float_t fEvtSelMaxJetPt; // maximum pt of the leading jet + Float_t fEvtSelMinJetEta; // minimum eta of the leading jet + Float_t fEvtSelMaxJetEta; // maximum eta of the leading jet + Float_t fEvtSelMinJetPhi; // minimum phi of the leading jet + Float_t fEvtSelMaxJetPhi; // maximum phi of the leading jet + + + // settings for toy "track generation" + Int_t fToyMinNbOfTracks; // minimum nb. of tracks per event + Int_t fToyMaxNbOfTracks; // maximum nb. of tracks per event + Float_t fToyMinTrackPt; // minimum track pT + Float_t fToyMaxTrackPt; // maximum track pT + Float_t fToyDistributionTrackPt; // distribution of track pt + Float_t fToyMinTrackEta; // minimum eta of tracks + Float_t fToyMaxTrackEta; // maximum eta of tracks + Float_t fToyMinTrackPhi; // minimum phi of tracks + Float_t fToyMaxTrackPhi; // maximum phi of tracks + UInt_t fToyFilterMap; // filter map of tracks + UInt_t fTrackFilterMap; // filter map of tracks for QA plots + + Int_t fNPtHard; // nb. of pT hard bins + Double_t fPtHard; // pT hard + Int_t fPtHardBin; // pT hard bin + TClonesArray* fAODJets; //! array of jets from aod + Int_t fNevents; // number of events in aod + Float_t fXsection; // average xsection of the event + Float_t fAvgTrials; // average number of trials per event + + + // histos + TList *fHistList; // list of histograms + TH1I *fHistEvtSelection; //! stastic of event selection + TProfile *fh1Xsec; //! cross-section + TH1F *fh1Trials; //! nb. of trials (simulation) + TH1F *fh1TrialsEvtSel; //! nb. of trials (event selection, e.g. jet pT) + TH2F *fh2PtHard; //! pT hard bin + TH2F *fh2PtHardEvtSel; //! pT hard bin (event selection) + TH2F *fh2PtHardTrials; //! pT hard bin, weighted by nb. of trials + + // qa histos + TH1F *fh1TrackPt; //! track pt + TH2F *fh2TrackEtaPhi; //! track eta-phi + TH1F *fh1TrackN; //! nb. of tracks + TH1F *fh1JetPt; //! jet pt + TH2F *fh2JetEtaPhi; //! jet eta-phi + TH1F *fh1JetN; //! nb. of jets + TH1F *fh1MCTrackPt; //! MC track pt + TH2F *fh2MCTrackEtaPhi; //! MC track eta-phi + TH1F *fh1MCTrackN; //! nb. of MC tracks + TH1I *fh1AODfile; //! used AOD files from AODPathArray + TH2I *fh2AODevent; //! selected events in AODs + + + Int_t GetJobID(); // get job id (sub-job id on the GRID) + Int_t SelectAODfile(); + Int_t OpenAODfile(Int_t trial = 0); + + + ClassDef(AliAnalysisTaskFastEmbedding, 5); +}; + +#endif + diff --git a/JETAN/DEV/AliAnalysisTaskJetBackgroundSubtract.cxx b/JETAN/DEV/AliAnalysisTaskJetBackgroundSubtract.cxx new file mode 100644 index 00000000000..baf57fd75d0 --- /dev/null +++ b/JETAN/DEV/AliAnalysisTaskJetBackgroundSubtract.cxx @@ -0,0 +1,727 @@ +// ************************************** +// Task used for the correction of determiantion of reconstructed jet spectra +// Compares input (gen) and output (rec) jets +// ******************************************* + + +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "TDatabasePDG.h" + +#include "AliAnalysisTaskJetBackgroundSubtract.h" +#include "AliAnalysisManager.h" +#include "AliAODHandler.h" +#include "AliAODTrack.h" +#include "AliAODJet.h" +#include "AliAODEvent.h" +#include "AliInputEventHandler.h" +#include "AliAODJetEventBackground.h" + + +ClassImp(AliAnalysisTaskJetBackgroundSubtract) + +AliAnalysisTaskJetBackgroundSubtract::~AliAnalysisTaskJetBackgroundSubtract(){ + delete fJBArray; + delete fOutJetArrayList; + delete fInJetArrayList; +} + +AliAnalysisTaskJetBackgroundSubtract::AliAnalysisTaskJetBackgroundSubtract(): + AliAnalysisTaskSE(), + fAODOut(0x0), + fAODIn(0x0), + fAODExtension(0x0), + fJBArray(new TObjArray()), + fBackgroundBranch(""), + fNonStdFile(""), + fReplaceString1("B0"), + fReplaceString2("B%d"), + fSubtraction(k4Area), + fKeepJets(kFALSE), + fInJetArrayList(0x0), + fOutJetArrayList(0x0), + fh2CentvsRho(0x0), + fh2CentvsSigma(0x0), + fh2MultvsRho(0x0), + fh2MultvsSigma(0x0), + fh2ShiftEta(0x0), + fh2ShiftPhi(0x0), + fh2ShiftEtaLeading(0x0), + fh2ShiftPhiLeading(0x0), + fHistList(0x0) +{ + +} + +AliAnalysisTaskJetBackgroundSubtract::AliAnalysisTaskJetBackgroundSubtract(const char* name): + + AliAnalysisTaskSE(name), + fAODOut(0x0), + fAODIn(0x0), + fAODExtension(0x0), + fJBArray(new TObjArray()), + fBackgroundBranch(""), + fNonStdFile(""), + fReplaceString1("B0"), + fReplaceString2("B%d"), + fSubtraction(k4Area), + fKeepJets(kFALSE), + fInJetArrayList(0x0), + fOutJetArrayList(0x0), + fh2CentvsRho(0x0), + fh2CentvsSigma(0x0), + fh2MultvsRho(0x0), + fh2MultvsSigma(0x0), + fh2ShiftEta(0x0), + fh2ShiftPhi(0x0), + fh2ShiftEtaLeading(0x0), + fh2ShiftPhiLeading(0x0), + fHistList(0x0) +{ + DefineOutput(1, TList::Class()); +} + + + +Bool_t AliAnalysisTaskJetBackgroundSubtract::Notify() +{ + // + fAODIn = dynamic_cast(InputEvent()); + + ResetOutJets(); + + // Now we also have the Input Event Available! Fillvthe pointers in the list + + fInJetArrayList->Clear(); + fOutJetArrayList->Clear(); + + for(int iJB = 0;iJBGetEntries();iJB++){ + TObjString *ostr = (TObjString*)fJBArray->At(iJB); + + + TClonesArray* jarray = 0; + if(!jarray&&fAODOut){ + jarray = (TClonesArray*)(fAODOut->FindListObject(ostr->GetString().Data())); + } + if(!jarray&&fAODExtension){ + jarray = (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(ostr->GetString().Data())); + } + if(!jarray&&fAODIn){ + jarray = (TClonesArray*)(fAODIn->FindListObject(ostr->GetString().Data())); + } + + if(!jarray){ + if(fDebug){ + Printf("%s:%d Input jet branch %s not found",(char*)__FILE__,__LINE__,ostr->GetString().Data()); + } + continue; + } + + TString newName(ostr->GetString().Data()); + newName.ReplaceAll(fReplaceString1.Data(),Form(fReplaceString2.Data(),fSubtraction)); + TClonesArray* jarrayOut = 0; + if(newName.CompareTo(ostr->GetString())==0){ + Printf("%s:%d Input and output branch would have the same name, skipping %s ",(char*)__FILE__,__LINE__,ostr->GetString().Data()); + continue; + } + + if(!jarrayOut&&fAODOut){ + jarrayOut = (TClonesArray*)(fAODOut->FindListObject(newName.Data())); + } + if(!jarrayOut&&fAODExtension){ + jarrayOut = (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(newName.Data())); + } + + if(!jarrayOut){ + if(fDebug){ + Printf("%s:%d Output jet branch %s not found",(char*)__FILE__,__LINE__,newName.Data()); + PrintAODContents(); + } + continue; + } + if(jarrayOut&&jarray){ + fOutJetArrayList->Add(jarrayOut); + fInJetArrayList->Add(jarray); + } + } + return kTRUE; +} + +void AliAnalysisTaskJetBackgroundSubtract::UserCreateOutputObjects() +{ + + // + // Create the output container + // + // Connect the AOD + + if (fDebug > 1) printf("AnalysisTaskJetBackgroundSubtract::UserCreateOutputObjects() \n"); + + + + if(fNonStdFile.Length()!=0){ + + // case that we have an AOD extension we need to fetch the jets from the extended output + // we identifay the extension aod event by looking for the branchname + AliAODHandler *aodH = dynamic_cast(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()); + + fAODExtension = (aodH?aodH->GetExtension(fNonStdFile.Data()):0); + + if(!fAODExtension){ + if(fDebug>1)Printf("AODExtension found for %s",fNonStdFile.Data()); + } + } + fAODOut = AODEvent(); + + // usually we do not have the input already here + + if(!fInJetArrayList)fInJetArrayList =new TList(); + if(!fOutJetArrayList)fOutJetArrayList =new TList(); + + for(int iJB = 0;iJBGetEntries();iJB++){ + TObjString *ostr = (TObjString*)fJBArray->At(iJB); + TString newName(ostr->GetString().Data()); + if(!newName.Contains(fReplaceString1.Data())){ + Printf("%s:%d cannot replace string %s in %s",(char*)__FILE__,__LINE__,fReplaceString1.Data(), + newName.Data()); + continue; + } + + + // add a new branch to the output for the background subtracted jets take the names from + // the input jets and replace the background flag names + TClonesArray *tca = new TClonesArray("AliAODJet", 0); + newName.ReplaceAll(fReplaceString1.Data(),Form(fReplaceString2.Data(),fSubtraction)); + if(newName.CompareTo(ostr->GetString())==0){ + Printf("%s:%d Input and output branch would have the same name, skipping: %s ",(char*)__FILE__,__LINE__,ostr->GetString().Data()); + continue; + } + + if(fDebug){ + Printf("%s:%d created branch \n %s from \n %s",(char*)__FILE__,__LINE__,newName.Data(), + ostr->GetString().Data()); + } + tca->SetName(newName.Data()); + AddAODBranch("TClonesArray",&tca,fNonStdFile.Data()); + } + + + if(!fHistList)fHistList = new TList(); + fHistList->SetOwner(); + PostData(1, fHistList); // post data in any case once + + // + + // delta pT vs. area vs. cent vs. mult + const Int_t nSparseBinsDelta = 4; + const Int_t nBinsDelta[nSparseBinsDelta] = { 241, 10, 10, 25}; + const Double_t xminDelta[nSparseBinsDelta] = {-120.5, 0, 0, 0}; + const Double_t xmaxDelta[nSparseBinsDelta] = { 120.5, 1.0, 100,5000}; + + for(int iJB = 0;iJBGetEntries();iJB++){ + TObjString *ostr = (TObjString*)fJBArray->At(iJB); + TString oldName(ostr->GetString().Data()); + TString newName(ostr->GetString().Data()); + if(!newName.Contains(fReplaceString1.Data())){ + Printf("%s:%d cannot replace string %s in %s",(char*)__FILE__,__LINE__,fReplaceString1.Data(), + newName.Data()); + continue; + } + newName.ReplaceAll(fReplaceString1.Data(),Form(fReplaceString2.Data(),fSubtraction)); + + TH2F *hTmp = new TH2F(Form("h2PtInPtOut_%d",iJB),Form(";%s p_{T}; %s p_{T}",oldName.Data(),newName.Data()),200,0,200.,400,-200.,200.); + fHistList->Add(hTmp); + THnSparseF *hFTmp = new THnSparseF(Form("hnDPtAreaCentMult_%d",iJB),Form("%s delta;#delta p_{T};Area;cent;mult",newName.Data()),nSparseBinsDelta,nBinsDelta,xminDelta,xmaxDelta); + fHistList->Add(hFTmp); + } + + Bool_t oldStatus = TH1::AddDirectoryStatus(); + TH1::AddDirectory(kFALSE); + + // + // Histogram booking, add som control histograms here + // + + + fh2CentvsRho = new TH2F("fh2CentvsRho","centrality vs background density", 100,0.,100.,600,0.,300.); + fh2CentvsSigma = new TH2F("fh2CentvsSigma","centrality vs backgroun sigma",100,0.,100.,500,0.,50.); + fHistList->Add(fh2CentvsRho); + fHistList->Add(fh2CentvsSigma); + + fh2MultvsRho = new TH2F("fh2MultvsRho","mult vs background density", 100,0.,5000.,600,0.,300.); + fh2MultvsSigma = new TH2F("fh2MultvsSigma","mult vs background sigma",100,0.,5000.,500,0.,50.); + fHistList->Add(fh2MultvsRho); + fHistList->Add(fh2MultvsSigma); + + if(fSubtraction==k4Area){ + fh2ShiftEta = new TH2F("fh2ShiftEta","extended correction Eta",100,-0.9,0.9,100,-0.9,0.9); + fh2ShiftPhi = new TH2F("fh2ShiftPhi","extended correction Phi",100,0.,6.5,100,0.,6.5); + fh2ShiftEtaLeading = new TH2F("fh2ShiftEtaLeading","extended correction Eta",100,-0.9,0.9,100,-0.9,0.9); + fh2ShiftPhiLeading = new TH2F("fh2ShiftPhiLeading","extended correction Phi",100,0.,6.5,100,0.,6.5); + fHistList->Add(fh2ShiftEta); + fHistList->Add(fh2ShiftPhi); + fHistList->Add(fh2ShiftEtaLeading); + fHistList->Add(fh2ShiftPhiLeading); + } + + // =========== Switch on Sumw2 for all histos =========== + for (Int_t i=0; iGetEntries(); ++i) { + TH1 *h1 = dynamic_cast(fHistList->At(i)); + if (h1){ + h1->Sumw2(); + continue; + } + THnSparse *hn = dynamic_cast(fHistList->At(i)); + if(hn)hn->Sumw2(); + } + TH1::AddDirectory(oldStatus); + + if(fBackgroundBranch.Length()==0) + AliError(Form("%s:%d No BackgroundBranch defined",(char*)__FILE__,__LINE__)); + if(fJBArray->GetEntries()==0) + AliError(Form("%s:%d No Jet Branches defined defined",(char*)__FILE__,__LINE__)); +} + +void AliAnalysisTaskJetBackgroundSubtract::Init() +{ + // + // Initialization + // + if (fDebug > 1) printf("AnalysisTaskJetBackgroundSubtract::Init() \n"); +} + +void AliAnalysisTaskJetBackgroundSubtract::UserExec(Option_t */*option*/) +{ + + if (fDebug > 1) printf("AnalysisTaskJetBackgroundSubtract::UserExec() \n"); + ResetOutJets(); + if(fBackgroundBranch.Length()==0||fJBArray->GetEntries()==0){ + if(fDebug)Printf("%s:%d No background subtraction done",(char*)__FILE__,__LINE__); + PostData(1,fHistList); + } + if(fJBArray->GetEntries()!=fInJetArrayList->GetEntries()){ + if(fDebug)Printf("%s:%d different Array sizes %d %d %d",(char*)__FILE__,__LINE__,fJBArray->GetEntries(),fInJetArrayList->GetEntries(),fOutJetArrayList->GetEntries()); + PostData(1,fHistList); + } + + + + AliAODJetEventBackground* evBkg = 0; + TClonesArray* bkgClusters = 0; + TClonesArray* bkgClustersRC = 0; + TString bkgClusterName(fBackgroundBranch.Data()); + bkgClusterName.ReplaceAll(Form("%s_",AliAODJetEventBackground::StdBranchName()),""); + TString bkgClusterRCName(Form("%s%s",bkgClusterName.Data(),"RandomCone")); + + if(!evBkg&&!bkgClusters&&!bkgClustersRC&&fAODOut){ + evBkg = (AliAODJetEventBackground*)(fAODOut->FindListObject(fBackgroundBranch.Data())); + bkgClusters = (TClonesArray*)(fAODOut->FindListObject(bkgClusterName.Data())); + bkgClustersRC = (TClonesArray*)(fAODOut->FindListObject(bkgClusterRCName.Data())); + + if(fDebug&&bkgClusters)Printf("%s:%d Background cluster branch %s found",(char*)__FILE__,__LINE__,bkgClusterName.Data()); + if(fDebug&&bkgClustersRC)Printf("%s:%d Background cluster RC branch %s found",(char*)__FILE__,__LINE__,bkgClusterRCName.Data()); + if(fDebug&&evBkg)Printf("%s:%d Backgroundbranch %s found",(char*)__FILE__,__LINE__,fBackgroundBranch.Data()); + } + if(!evBkg&&!bkgClusters&&!bkgClustersRC&&fAODExtension){ + evBkg = (AliAODJetEventBackground*)(fAODExtension->GetAOD()->FindListObject(fBackgroundBranch.Data())); + bkgClusters = (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(bkgClusterName.Data())); + bkgClustersRC = (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(bkgClusterRCName.Data())); + if(fDebug&&bkgClusters)Printf("%s:%d Background cluster branch %s found",(char*)__FILE__,__LINE__,bkgClusterName.Data()); + if(fDebug&&bkgClustersRC)Printf("%s:%d Background cluster RC branch %s found",(char*)__FILE__,__LINE__,bkgClusterRCName.Data()); + + if(fDebug&&evBkg)Printf("%s:%d Backgroundbranch %s found",(char*)__FILE__,__LINE__,fBackgroundBranch.Data()); + } + + if(!evBkg&&!bkgClusters&&!bkgClustersRC&&fAODIn){ + evBkg = (AliAODJetEventBackground*)(fAODIn->FindListObject(fBackgroundBranch.Data())); + bkgClusters = (TClonesArray*)(fAODIn->FindListObject(bkgClusterName.Data())); + bkgClustersRC = (TClonesArray*)(fAODIn->FindListObject(bkgClusterRCName.Data())); + + if(fDebug&&bkgClusters)Printf("%s:%d Background cluster branch %s found",(char*)__FILE__,__LINE__,bkgClusterName.Data()); + if(fDebug&&bkgClustersRC)Printf("%s:%d Background cluster RC branch %s found",(char*)__FILE__,__LINE__,bkgClusterRCName.Data()); + if(fDebug&&evBkg)Printf("%s:%d Backgroundbranch %s found",(char*)__FILE__,__LINE__,fBackgroundBranch.Data()); + } + + if(!evBkg&&(fSubtraction==kArea||fSubtraction==kRhoRecalc||fSubtraction==k4Area)){ + if(fDebug){ + Printf("%s:%d Backgroundbranch %s not found",(char*)__FILE__,__LINE__,fBackgroundBranch.Data()); + PrintAODContents(); + } + PostData(1,fHistList); + return; + } + + if(!bkgClusters&&(fSubtraction==kRhoRecalc)){ + if(fDebug){ + Printf("%s:%d Background cluster branch %s not found",(char*)__FILE__,__LINE__,bkgClusterName.Data()); + PrintAODContents(); + } + PostData(1,fHistList); + return; + } + + if(!bkgClustersRC&&(fSubtraction==kRhoRC)){ + if(fDebug){ + Printf("%s:%d Background cluster RC branch %s not found",(char*)__FILE__,__LINE__,bkgClusterRCName.Data()); + PrintAODContents(); + } + PostData(1,fHistList); + return; + } + // LOOP over all jet branches and subtract the background + + Float_t rho = 0; + Float_t sigma=0.; + Double_t meanarea = 0; + TLorentzVector backgroundv; + Float_t cent=0.; + + if(fAODOut)cent = fAODOut->GetHeader()->GetCentrality(); + if(fAODIn) cent = fAODIn->GetHeader()->GetCentrality(); + + if(evBkg)sigma=evBkg->GetSigma(1); + + if(fSubtraction==kArea) rho = evBkg->GetBackground(1); + if(fSubtraction==k4Area){ + rho = evBkg->GetBackground(0); + sigma=evBkg->GetSigma(0); + } + + if(fSubtraction==kRhoRecalc){ + meanarea=evBkg->GetMeanarea(1); + rho =RecalcRho(bkgClusters,meanarea); + } + if(fSubtraction==kRhoRC) rho=RhoRC(bkgClustersRC); + + Float_t mult = 0; + for(int iJB = 0;iJBGetEntries();iJB++){ + TClonesArray* jarray = (TClonesArray*)fInJetArrayList->At(iJB); + if(jarray){ + TString tmp(jarray->GetName()); + if(tmp.Contains("cluster")){ + mult = MultFromJetRefs(jarray); + if(mult>0)break; + } + } + } + + fh2CentvsRho->Fill(cent,rho); + fh2CentvsSigma->Fill(cent,sigma); + + fh2MultvsRho->Fill(mult,rho); + fh2MultvsSigma->Fill(mult,sigma); + + for(int iJB = 0;iJBGetEntries();iJB++){ + TClonesArray* jarray = (TClonesArray*)fInJetArrayList->At(iJB); + TClonesArray* jarrayOut = (TClonesArray*)fOutJetArrayList->At(iJB); + + if(!jarray||!jarrayOut){ + Printf("%s:%d Array not found %d: %p %p",(char*)__FILE__,__LINE__,iJB,jarray,jarrayOut); + continue; + } + TH2F* h2PtInOut = (TH2F*)fHistList->FindObject(Form("h2PtInPtOut_%d",iJB)); + THnSparseF* hnDPtAreaCentMult = (THnSparseF*)fHistList->FindObject(Form("hnDPtAreaCentMult_%d",iJB)); + // loop over all jets + Int_t nOut = 0; + + Double_t deltaPt[4]; + deltaPt[2] = cent; + deltaPt[3] = mult; + + for(int i = 0;i < jarray->GetEntriesFast();i++){ + AliAODJet *jet = (AliAODJet*)jarray->At(i); + AliAODJet tmpNewJet(*jet); + Bool_t bAdd = false; + Float_t ptSub = 0; + + + if(fSubtraction==kArea){ + Double_t background = rho * jet->EffectiveAreaCharged(); + ptSub = jet->Pt() - background; + if(fDebug>2){ + Printf("%s:%d Jet %d %3.3f %3.3f",(char*)__FILE__,__LINE__,i,jet->Pt(),ptSub); + } + if(ptSub<=0){ + // optionally rescale it and keep?? + if(fKeepJets){ + bAdd = RescaleJetMomentum(&tmpNewJet,0.1); + } + else{ + bAdd = false; + } + } + else{ + bAdd = RescaleJetMomentum(&tmpNewJet,ptSub); + } + // add background estimates to the new jet object + // allows to recover old p_T and rho... + tmpNewJet.SetBgEnergy(background,0); + tmpNewJet.SetPtSubtracted(ptSub,0); + }// kAREA + else if(fSubtraction==kRhoRecalc){ + Double_t background = rho * jet->EffectiveAreaCharged(); + ptSub = jet->Pt() - background; + if(fDebug>2){ + Printf("%s:%d Jet %d %3.3f %3.3f %3.3f %3.3f",(char*)__FILE__,__LINE__,i,jet->Pt(),ptSub,background,rho);} + if(ptSub<=0){ + // optionally rescale it and keep + if(fKeepJets){ + bAdd = RescaleJetMomentum(&tmpNewJet,0.1); + } + else{ + bAdd = false; + } + } + else{ + bAdd = RescaleJetMomentum(&tmpNewJet,ptSub); + } + // add background estimates to the new jet object + // allows to recover old p_T and rho... + tmpNewJet.SetBgEnergy(background,0); + tmpNewJet.SetPtSubtracted(ptSub,0); + }//kRhoRecalc + else if(fSubtraction==kRhoRC){ + Double_t background = rho * jet->EffectiveAreaCharged(); + ptSub = jet->Pt() - background; + if(fDebug>2){ Printf("%s:%d Jet %d %3.3f %3.3f %3.3f %3.3f",(char*)__FILE__,__LINE__,i,jet->Pt(),ptSub,background,rho);} + if(ptSub<=0){ + if(fKeepJets){ + bAdd = RescaleJetMomentum(&tmpNewJet,0.1); + } + else{ + bAdd = false; + } + } + else{ + bAdd = RescaleJetMomentum(&tmpNewJet,ptSub); + } + // add background estimates to the new jet object + // allows to recover old p_T and rho... + tmpNewJet.SetBgEnergy(background,0); + tmpNewJet.SetPtSubtracted(ptSub,0); + }//kRhoRC + + else if(fSubtraction==k4Area&&jet->VectorAreaCharged()){ + backgroundv.SetPxPyPzE(rho*(jet->VectorAreaCharged())->Px(),rho*(jet->VectorAreaCharged())->Py(),rho*(jet->VectorAreaCharged())->Pz(),rho*(jet->VectorAreaCharged())->E()); + ptSub = jet->Pt()-backgroundv.Pt(); + if((backgroundv.E()>=jet->E())||(backgroundv.Pt()>=jet->Pt())){ + if(fKeepJets){ + bAdd = RescaleJetMomentum(&tmpNewJet,0.1); + } + else{ + bAdd = false; + } + } + else{ + bAdd = RescaleJet4vector(&tmpNewJet,backgroundv); + } + // add background estimates to the new jet object + // allows to recover old p_T and rho... + tmpNewJet.SetBgEnergy(backgroundv.Pt(),0); + tmpNewJet.SetPtSubtracted(ptSub,0); + + }//kArea4vector + + if(bAdd){ + AliAODJet *newJet = new ((*jarrayOut)[nOut++]) AliAODJet(tmpNewJet); + // what about track references, clear for now... + if(fSubtraction==k4Area){ + fh2ShiftEta->Fill(jet->Eta(),newJet->Eta()); + fh2ShiftPhi->Fill(jet->Phi(),newJet->Phi()); + if(i==0){fh2ShiftEtaLeading->Fill(jet->Eta(),newJet->Eta()); + fh2ShiftPhiLeading->Fill(jet->Phi(),newJet->Phi());}} + + // set the references + newJet->GetRefTracks()->Clear(); + TRefArray *refs = jet->GetRefTracks(); + for(Int_t ir=0;irGetEntriesFast();ir++){ + AliVParticle *vp = dynamic_cast(refs->At(ir)); + if(vp)newJet->AddTrack(vp); + } + } + if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),ptSub); + if(hnDPtAreaCentMult){ + deltaPt[0] = ptSub; + deltaPt[1] = jet->EffectiveAreaCharged(); + hnDPtAreaCentMult->Fill(deltaPt); + } + } + if(jarrayOut)jarrayOut->Sort(); + } + + PostData(1, fHistList); +} + +void AliAnalysisTaskJetBackgroundSubtract::Terminate(Option_t */*option*/) +{ + // Terminate analysis + // + if (fDebug > 1) printf("AnalysisJetBackgroundSubtract: Terminate() \n"); +} + +Bool_t AliAnalysisTaskJetBackgroundSubtract::RescaleJetMomentum(AliAODJet *jet,Float_t pT){ + // keep the direction and the jet mass + if(pT<=0)return kFALSE; + Double_t pTold = jet->Pt(); + Double_t scale = pT/pTold; + Double_t mass = jet->M(); + Double_t pNew = jet->P() * scale; + jet->SetPxPyPzE(scale*jet->Px(),scale*jet->Py(),scale*jet->Pz(),TMath::Sqrt(mass*mass+pNew*pNew)); + + + + return kTRUE; +} + +Bool_t AliAnalysisTaskJetBackgroundSubtract::RescaleJet4vector(AliAODJet *jet,TLorentzVector backgroundv){ + + if(backgroundv.Pt()<0.) return kFALSE; + jet->SetPxPyPzE(jet->Px()-backgroundv.Px(),jet->Py()-backgroundv.Py(),jet->Pz()-backgroundv.Pz(),jet->E()-backgroundv.E()); + + return kTRUE; +} + + + + + + + + +Double_t AliAnalysisTaskJetBackgroundSubtract::RecalcRho(TClonesArray* bkgClusters,Double_t meanarea){ + + Double_t ptarea=0.; + Int_t count=0; + Double_t rho=0.; + const Double_t Rlimit2=0.8*0.8; //2*jet radius. + TClonesArray* jarray=0; + + for(int iJB = 0;iJBGetEntries();iJB++){ + TObjString *ostr = (TObjString*)fInJetArrayList->At(iJB); + TString jetref=ostr->GetString().Data(); + if(jetref.Contains("ANTIKT04")){ + jarray = (TClonesArray*)fInJetArrayList->At(iJB); + } + } + if(!jarray)return rho; + if(jarray->GetEntries()>=2){ + AliAODJet *first = (AliAODJet*)(jarray->At(0)); + AliAODJet *second= (AliAODJet*)(jarray->At(1)); + for(Int_t k=0;kGetEntriesFast();k++){ + AliAODJet *clus = (AliAODJet*)(bkgClusters->At(k)); + if(TMath::Abs(clus->Eta())>0.5) continue; + if((clus->EffectiveAreaCharged())<0.1*meanarea) continue; + Double_t distance1=(first->Eta()-clus->Eta())*(first->Eta()-clus->Eta())+ + (first->Phi()-clus->Phi())*(first->Phi()-clus->Phi()); + Double_t distance2= (second->Eta()-clus->Eta())*(second->Eta()-clus->Eta())+ + (second->Phi()-clus->Phi())*(second->Phi()-clus->Phi()); + if((distance1Pt()/clus->EffectiveAreaCharged(); + count=count+1;} + if(count!=0) rho=ptarea/count; + } + return rho; +} + + Double_t AliAnalysisTaskJetBackgroundSubtract::RhoRC(TClonesArray* bkgClustersRC){ + + Double_t ptarea=0.; + Int_t count=0; + Double_t rho=0.; + const Double_t Rlimit2=0.8*0.8; //2*jet radius. + TClonesArray* jarray=0; + for(int iJB = 0;iJBGetEntries();iJB++){ + TObjString *ostr = (TObjString*)fInJetArrayList->At(iJB); + TString jetref=ostr->GetString().Data(); + if(jetref.Contains("ANTIKT04")){ + jarray = (TClonesArray*)fInJetArrayList->At(iJB); + } + } + if(!jarray)return rho; + + if(jarray->GetEntries()>=2){ + AliAODJet *first = (AliAODJet*)(jarray->At(0)); + AliAODJet *second=(AliAODJet*)(jarray->At(1)); + for(Int_t k=0;kGetEntriesFast();k++){ + AliAODJet *clus = (AliAODJet*)(bkgClustersRC->At(k)); + if(TMath::Abs(clus->Eta())>0.5) continue; + Double_t distance1=(first->Eta()-clus->Eta())*(first->Eta()-clus->Eta())+ + (first->Phi()-clus->Phi())*(first->Phi()-clus->Phi()); + Double_t distance2= (second->Eta()-clus->Eta())*(second->Eta()-clus->Eta())+ + (second->Phi()-clus->Phi())*(second->Phi()-clus->Phi()); + if((distance1Pt()/clus->EffectiveAreaCharged(); + count=count+1;} + if(count!=0) rho=ptarea/count; } + return rho; +} + + + + + + + + + +void AliAnalysisTaskJetBackgroundSubtract::ResetOutJets(){ + if(!fOutJetArrayList)return; + for(int iJB = 0;iJBGetEntries();iJB++){ + TClonesArray* jarray = (TClonesArray*)fOutJetArrayList->At(iJB); + if(jarray)jarray->Delete(); + } +} + + +void AliAnalysisTaskJetBackgroundSubtract::PrintAODContents(){ + if(fAODIn){ + Printf("%s:%d >>>>>> Input",(char*)__FILE__,__LINE__); + fAODIn->Print(); + } + if(fAODExtension){ + Printf("%s:%d >>>>>> Extenstion",(char*)__FILE__,__LINE__); + fAODExtension->GetAOD()->Print(); + } + if(fAODOut){ + Printf("%s:%d >>>>>> Output",(char*)__FILE__,__LINE__); + fAODOut->Print(); + } +} + +Int_t AliAnalysisTaskJetBackgroundSubtract::MultFromJetRefs(TClonesArray* jets){ + if(!jets)return 0; + + Int_t refMult = 0; + for(int ij = 0;ij < jets->GetEntries();++ij){ + AliAODJet* jet = (AliAODJet*)jets->At(ij); + if(!jet)continue; + TRefArray *refs = jet->GetRefTracks(); + if(!refs)continue; + refMult += refs->GetEntries(); + } + return refMult; + +} diff --git a/JETAN/DEV/AliAnalysisTaskJetBackgroundSubtract.h b/JETAN/DEV/AliAnalysisTaskJetBackgroundSubtract.h new file mode 100644 index 00000000000..9f0e0a193e7 --- /dev/null +++ b/JETAN/DEV/AliAnalysisTaskJetBackgroundSubtract.h @@ -0,0 +1,106 @@ +#ifndef ALIANALYSISTASKJETBACKGROUNDSUBTRACT_H +#define ALIANALYSISTASKJETBACKGROUNDSUBTRACT_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +// ************************************** +// task used for background subtration of all jets found with clustering algos +// ******************************************* + +#include "AliAnalysisTaskSE.h" +#include "TObjString.h" +#include "TString.h" +#include "TObjArray.h" + + +//////////////// +class AliJetHeader; +class AliESDEvent; +class AliAODEvent; +class AliAODExtension; +class AliAODJet; +class AliAODJetEventBackground; +class AliJetFinder; +class TList; +class TChain; +class TH2F; +class TH1F; +class TH3F; +class TProfile; +class TRandom3; +class TRefArray; + + +class AliAnalysisTaskJetBackgroundSubtract : public AliAnalysisTaskSE +{ + public: + AliAnalysisTaskJetBackgroundSubtract(); + AliAnalysisTaskJetBackgroundSubtract(const char* name); + virtual ~AliAnalysisTaskJetBackgroundSubtract(); + // Implementation of interface methods + virtual void UserCreateOutputObjects(); + virtual void Init(); + virtual void LocalInit() { Init(); } + virtual void UserExec(Option_t *option); + virtual void Terminate(Option_t *option); + virtual Bool_t Notify(); + + // Task specific methods... + virtual void AddJetBranch(const char* c){fJBArray->Add(new TObjString(c));} + virtual void SetSubtractionMethod(Int_t i){fSubtraction = i;} + virtual Int_t GetSubtractionMethod(){return fSubtraction;} + virtual void SetKeepJets(Bool_t b = kTRUE){fKeepJets = b;} + virtual void SetBackgroundBranch(char* c){fBackgroundBranch = c;} + virtual void SetNonStdOutputFile(char* c){fNonStdFile = c;} + virtual void SetToReplace(char* c){fReplaceString1 = c;} + const char* GetToReplace(){return fReplaceString1.Data();} + virtual void SetReplacementMask(char* c){fReplaceString2 = c;} + const char* GetReplacementMask(){return fReplaceString2.Data();} + + enum {kNoSubtract = 0,kArea,k4Area,kRhoRecalc,kRhoRC}; + + private: + + + + AliAnalysisTaskJetBackgroundSubtract(const AliAnalysisTaskJetBackgroundSubtract&); + AliAnalysisTaskJetBackgroundSubtract& operator=(const AliAnalysisTaskJetBackgroundSubtract&); + Bool_t RescaleJetMomentum(AliAODJet *jet,Float_t pT); + Bool_t RescaleJet4vector(AliAODJet *jet,TLorentzVector backgroundv); + Int_t MultFromJetRefs(TClonesArray* jets); + Double_t RecalcRho(TClonesArray* fbkgclusters,Double_t meanarea); + Double_t RhoRC(TClonesArray* fbkgclustersRC); + void ResetOutJets(); + void PrintAODContents(); + + AliAODEvent *fAODOut; // ! where we take the jets from and they are modified + AliAODEvent *fAODIn; // ! where we may take the background from, only in case we do not find it in the output + AliAODExtension *fAODExtension; // ! where we take the jets from can be input or output AOD + TObjArray *fJBArray; // Array that stores the name of all jet branches to be subtracted + TString fBackgroundBranch; // name of the branch used for background subtraction + // + TString fNonStdFile; // The optional name of the output file the non-std brnach is written to + TString fReplaceString1; // To construct the new output name + TString fReplaceString2; // To construct the new output name + Int_t fSubtraction; // Parameter for subtraction mode + Bool_t fKeepJets; // keeps the jets with negative p_t rescaled to 0.1 GeV + TList *fInJetArrayList; //! transient list to make ease the handling of input jets + TList *fOutJetArrayList; //! transient list to make ease the reset of output jets + + TH2F* fh2CentvsRho; //! centrality vs background density + TH2F* fh2CentvsSigma; //! centrality vs background sigma + TH2F* fh2MultvsRho; //! centrality vs background density + TH2F* fh2MultvsSigma; //! centrality vs background sigma + TH2F* fh2ShiftEta; //! extended correction Eta + TH2F* fh2ShiftPhi; //! extended correction Phi + TH2F* fh2ShiftEtaLeading; //! extended correction Eta leading jet + TH2F* fh2ShiftPhiLeading; //! extended correction Phi leading jet + + + TList *fHistList; //! the histograms output list + + ClassDef(AliAnalysisTaskJetBackgroundSubtract, 6) +}; + +#endif diff --git a/JETAN/DEV/AliAnalysisTaskJetCluster.cxx b/JETAN/DEV/AliAnalysisTaskJetCluster.cxx new file mode 100644 index 00000000000..1b27611e03a --- /dev/null +++ b/JETAN/DEV/AliAnalysisTaskJetCluster.cxx @@ -0,0 +1,1490 @@ +// ************************************** +// Task used for the correction of determiantion of reconstructed jet spectra +// Compares input (gen) and output (rec) jets +// ******************************************* + + +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "TDatabasePDG.h" + +#include "AliAnalysisTaskJetCluster.h" +#include "AliAnalysisManager.h" +#include "AliJetFinder.h" +#include "AliJetHeader.h" +#include "AliJetReader.h" +#include "AliESDEvent.h" +#include "AliAODEvent.h" +#include "AliAODHandler.h" +#include "AliAODExtension.h" +#include "AliAODTrack.h" +#include "AliAODJet.h" +#include "AliAODMCParticle.h" +#include "AliMCEventHandler.h" +#include "AliMCEvent.h" +#include "AliStack.h" +#include "AliGenPythiaEventHeader.h" +#include "AliJetKineReaderHeader.h" +#include "AliGenCocktailEventHeader.h" +#include "AliInputEventHandler.h" +#include "AliAODJetEventBackground.h" + +#include "fastjet/PseudoJet.hh" +#include "fastjet/ClusterSequenceArea.hh" +#include "fastjet/AreaDefinition.hh" +#include "fastjet/JetDefinition.hh" +// get info on how fastjet was configured +#include "fastjet/config.h" + + +ClassImp(AliAnalysisTaskJetCluster) + +AliAnalysisTaskJetCluster::~AliAnalysisTaskJetCluster(){ + delete fRef; + delete fRandom; + + if(fTCAJetsOut)fTCAJetsOut->Delete(); + delete fTCAJetsOut; + if(fTCAJetsOutRan)fTCAJetsOutRan->Delete(); + delete fTCAJetsOutRan; + if(fTCARandomConesOut)fTCARandomConesOut->Delete(); + delete fTCARandomConesOut; + if(fTCARandomConesOutRan)fTCARandomConesOutRan->Delete(); + delete fTCARandomConesOutRan; + if(fAODJetBackgroundOut)fAODJetBackgroundOut->Reset(); + delete fAODJetBackgroundOut; +} + +AliAnalysisTaskJetCluster::AliAnalysisTaskJetCluster(): + AliAnalysisTaskSE(), + fAOD(0x0), + fAODExtension(0x0), + fRef(new TRefArray), + fUseAODTrackInput(kFALSE), + fUseAODMCInput(kFALSE), + fUseBackgroundCalc(kFALSE), + fEventSelection(kFALSE), + fFilterMask(0), + fFilterType(0), + fJetTypes(kJet), + fTrackTypeRec(kTrackUndef), + fTrackTypeGen(kTrackUndef), + fNSkipLeadingRan(0), + fNSkipLeadingCone(0), + fNRandomCones(0), + fAvgTrials(1), + fExternalWeight(1), + fTrackEtaWindow(0.9), + fRecEtaWindow(0.5), + fTrackPtCut(0.), + fJetOutputMinPt(0.150), + fMaxTrackPtInJet(100.), + fJetTriggerPtCut(0), + fVtxZCut(8), + fVtxR2Cut(1), + fCentCutUp(0), + fCentCutLo(0), + fNonStdBranch(""), + fBackgroundBranch(""), + fNonStdFile(""), + fRparam(1.0), + fAlgorithm(fastjet::kt_algorithm), + fStrategy(fastjet::Best), + fRecombScheme(fastjet::BIpt_scheme), + fAreaType(fastjet::active_area), + fGhostArea(0.01), + fActiveAreaRepeats(1), + fGhostEtamax(1.5), + fTCAJetsOut(0x0), + fTCAJetsOutRan(0x0), + fTCARandomConesOut(0x0), + fTCARandomConesOutRan(0x0), + fAODJetBackgroundOut(0x0), + fRandom(0), + fh1Xsec(0x0), + fh1Trials(0x0), + fh1PtHard(0x0), + fh1PtHardNoW(0x0), + fh1PtHardTrials(0x0), + fh1NJetsRec(0x0), + fh1NConstRec(0x0), + fh1NConstLeadingRec(0x0), + fh1PtJetsRecIn(0x0), + fh1PtJetsLeadingRecIn(0x0), + fh1PtJetConstRec(0x0), + fh1PtJetConstLeadingRec(0x0), + fh1PtTracksRecIn(0x0), + fh1PtTracksLeadingRecIn(0x0), + fh1NJetsRecRan(0x0), + fh1NConstRecRan(0x0), + fh1PtJetsLeadingRecInRan(0x0), + fh1NConstLeadingRecRan(0x0), + fh1PtJetsRecInRan(0x0), + fh1PtTracksGenIn(0x0), + fh1Nch(0x0), + fh1CentralityPhySel(0x0), + fh1Centrality(0x0), + fh1CentralitySelect(0x0), + fh1ZPhySel(0x0), + fh1Z(0x0), + fh1ZSelect(0x0), + fh2NRecJetsPt(0x0), + fh2NRecTracksPt(0x0), + fh2NConstPt(0x0), + fh2NConstLeadingPt(0x0), + fh2JetPhiEta(0x0), + fh2LeadingJetPhiEta(0x0), + fh2JetEtaPt(0x0), + fh2LeadingJetEtaPt(0x0), + fh2TrackEtaPt(0x0), + fh2LeadingTrackEtaPt(0x0), + fh2JetsLeadingPhiEta(0x0), + fh2JetsLeadingPhiPt(0x0), + fh2TracksLeadingPhiEta(0x0), + fh2TracksLeadingPhiPt(0x0), + fh2TracksLeadingJetPhiPt(0x0), + fh2JetsLeadingPhiPtW(0x0), + fh2TracksLeadingPhiPtW(0x0), + fh2TracksLeadingJetPhiPtW(0x0), + fh2NRecJetsPtRan(0x0), + fh2NConstPtRan(0x0), + fh2NConstLeadingPtRan(0x0), + fh2PtNch(0x0), + fh2PtNchRan(0x0), + fh2PtNchN(0x0), + fh2PtNchNRan(0x0), + fh2TracksLeadingJetPhiPtRan(0x0), + fh2TracksLeadingJetPhiPtWRan(0x0), + fHistList(0x0) +{ + for(int i = 0;i<3;i++){ + fh1BiARandomCones[i] = 0; + fh1BiARandomConesRan[i] = 0; + } + for(int i = 0;i 1) printf("AnalysisTaskJetCluster::UserCreateOutputObjects() \n"); + + + + if(fNonStdBranch.Length()!=0) + { + // only create the output branch if we have a name + // Create a new branch for jets... + // -> cleared in the UserExec.... + // here we can also have the case that the brnaches are written to a separate file + + if(fJetTypes&kJet){ + fTCAJetsOut = new TClonesArray("AliAODJet", 0); + fTCAJetsOut->SetName(fNonStdBranch.Data()); + AddAODBranch("TClonesArray",&fTCAJetsOut,fNonStdFile.Data()); + } + + if(fJetTypes&kJetRan){ + fTCAJetsOutRan = new TClonesArray("AliAODJet", 0); + fTCAJetsOutRan->SetName(Form("%s_%s",fNonStdBranch.Data(),"random")); + AddAODBranch("TClonesArray",&fTCAJetsOutRan,fNonStdFile.Data()); + } + + if(fUseBackgroundCalc){ + if(!AODEvent()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()))){ + fAODJetBackgroundOut = new AliAODJetEventBackground(); + fAODJetBackgroundOut->SetName(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data())); + AddAODBranch("AliAODJetEventBackground",&fAODJetBackgroundOut,fNonStdFile.Data()); + } + } + // create the branch for the random cones with the same R + TString cName = Form("%sRandomConeSkip%02d",fNonStdBranch.Data(),fNSkipLeadingCone); + + if(fNRandomCones>0){ + if(fJetTypes&kRC){ + if(!AODEvent()->FindListObject(cName.Data())){ + fTCARandomConesOut = new TClonesArray("AliAODJet", 0); + fTCARandomConesOut->SetName(cName.Data()); + AddAODBranch("TClonesArray",&fTCARandomConesOut,fNonStdFile.Data()); + } + } + // create the branch with the random for the random cones on the random event + if(fJetTypes&kRCRan){ + cName = Form("%sRandomCone_random",fNonStdBranch.Data()); + if(!AODEvent()->FindListObject(cName.Data())){ + fTCARandomConesOutRan = new TClonesArray("AliAODJet", 0); + fTCARandomConesOutRan->SetName(cName.Data()); + AddAODBranch("TClonesArray",&fTCARandomConesOutRan,fNonStdFile.Data()); + } + } + } + + if(fNonStdFile.Length()!=0){ + // + // case that we have an AOD extension we need to fetch the jets from the extended output + // we identify the extension aod event by looking for the branchname + AliAODHandler *aodH = dynamic_cast(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()); + // case that we have an AOD extension we need can fetch the background maybe from the extended output + fAODExtension = (aodH?aodH->GetExtension(fNonStdFile.Data()):0); + } + } + + + if(!fHistList)fHistList = new TList(); + fHistList->SetOwner(); + PostData(1, fHistList); // post data in any case once + + Bool_t oldStatus = TH1::AddDirectoryStatus(); + TH1::AddDirectory(kFALSE); + + // + // Histogram + + const Int_t nBinPt = 100; + Double_t binLimitsPt[nBinPt+1]; + for(Int_t iPt = 0;iPt <= nBinPt;iPt++){ + if(iPt == 0){ + binLimitsPt[iPt] = 0.0; + } + else {// 1.0 + binLimitsPt[iPt] = binLimitsPt[iPt-1] + 2.0; + } + } + + const Int_t nBinPhi = 90; + Double_t binLimitsPhi[nBinPhi+1]; + for(Int_t iPhi = 0;iPhi<=nBinPhi;iPhi++){ + if(iPhi==0){ + binLimitsPhi[iPhi] = -1.*TMath::Pi(); + } + else{ + binLimitsPhi[iPhi] = binLimitsPhi[iPhi-1] + 1/(Float_t)nBinPhi * TMath::Pi()*2; + } + } + + + + const Int_t nBinEta = 40; + Double_t binLimitsEta[nBinEta+1]; + for(Int_t iEta = 0;iEta<=nBinEta;iEta++){ + if(iEta==0){ + binLimitsEta[iEta] = -2.0; + } + else{ + binLimitsEta[iEta] = binLimitsEta[iEta-1] + 0.1; + } + } + + const int nChMax = 5000; + + fh1Xsec = new TProfile("fh1Xsec","xsec from pyxsec.root",1,0,1); + fh1Xsec->GetXaxis()->SetBinLabel(1,"<#sigma>"); + + fh1Trials = new TH1F("fh1Trials","trials root file",1,0,1); + fh1Trials->GetXaxis()->SetBinLabel(1,"#sum{ntrials}"); + + + fh1NJetsRec = new TH1F("fh1NJetsRec","N reconstructed jets",120,-0.5,119.5); + fh1NJetsRecRan = new TH1F("fh1NJetsRecRan","N reconstructed jets",120,-0.5,119.5); + + fh1NConstRec = new TH1F("fh1NConstRec","# jet constituents",120,-0.5,119.5); + fh1NConstRecRan = new TH1F("fh1NConstRecRan","# jet constituents",120,-0.5,119.5); + fh1NConstLeadingRec = new TH1F("fh1NConstLeadingRec","jet constituents",120,-0.5,119.5); + fh1NConstLeadingRecRan = new TH1F("fh1NConstLeadingRecRan","jet constituents",120,-0.5,119.5); + + + fh1PtHard = new TH1F("fh1PtHard","PYTHIA Pt hard;p_{T,hard}",nBinPt,binLimitsPt); + fh1PtHardNoW = new TH1F("fh1PtHardNoW","PYTHIA Pt hard no weight;p_{T,hard}",nBinPt,binLimitsPt); + fh1PtHardTrials = new TH1F("fh1PtHardTrials","PYTHIA Pt hard weight with trials;p_{T,hard}",nBinPt,binLimitsPt); + + fh1PtJetsRecIn = new TH1F("fh1PtJetsRecIn","Rec jets P_T;p_{T} (GeV/c)",nBinPt,binLimitsPt); + fh1PtJetsRecInRan = new TH1F("fh1PtJetsRecInRan","Rec jets P_T;p_{T} (GeV/c)",nBinPt,binLimitsPt); + fh1PtJetsLeadingRecIn = new TH1F("fh1PtJetsLeadingRecIn","Rec jets P_T;p_{T} (GeV/c)",nBinPt,binLimitsPt); + fh1PtJetsLeadingRecInRan = new TH1F("fh1PtJetsLeadingRecInRan","Rec jets P_T;p_{T} (GeV/c)",nBinPt,binLimitsPt); + fh1PtJetConstRec = new TH1F("fh1PtJetsConstRec","Rec jets constituents P_T;p_{T} (GeV/c)",nBinPt,binLimitsPt); + fh1PtJetConstLeadingRec = new TH1F("fh1PtJetsConstLeadingRec","Rec jets constituents P_T;p_{T} (GeV/c)",nBinPt,binLimitsPt); + fh1PtTracksRecIn = new TH1F("fh1PtTracksRecIn",Form("Rec tracks P_T #eta < %1.2f;p_{T} (GeV/c)",fTrackEtaWindow),nBinPt,binLimitsPt); + fh1PtTracksLeadingRecIn = new TH1F("fh1PtTracksLeadingRecIn",Form("Rec tracks P_T #eta < %1.2f ;p_{T} (GeV/c)",fTrackEtaWindow),nBinPt,binLimitsPt); + fh1PtTracksGenIn = new TH1F("fh1PtTracksGenIn",Form("gen tracks P_T #eta < %1.2f ;p_{T} (GeV/c)",fTrackEtaWindow),nBinPt,binLimitsPt); + fh1Nch = new TH1F("fh1Nch","charged multiplicity; N_{ch}",nChMax,-0.5,nChMax-0.5); + + fh1Centrality = new TH1F("fh1Centrality",";cent (%)",111,-0.5,110.5); + fh1CentralitySelect = new TH1F("fh1CentralitySelect",";cent (%)",111,-0.5,110.5); + fh1CentralityPhySel = new TH1F("fh1CentralityPhySel",";cent (%)",111,-0.5,110.5); + + fh1Z = new TH1F("fh1Z",";zvtx",100,-25,25); + fh1ZSelect = new TH1F("fh1ZSelect",";zvtx",100,-25,25); + fh1ZPhySel = new TH1F("fh1ZPhySel",";zvtx",100,-25,25); + + fh2NRecJetsPt = new TH2F("fh2NRecJetsPt","Number of jets above threshhold;p_{T,cut} (GeV/c);N_{jets}",nBinPt,binLimitsPt,50,-0.5,49.5); + fh2NRecJetsPtRan = new TH2F("fh2NRecJetsPtRan","Number of jets above threshhold;p_{T,cut} (GeV/c);N_{jets}",nBinPt,binLimitsPt,50,-0.5,49.5); + fh2NRecTracksPt = new TH2F("fh2NRecTracksPt","Number of tracks above threshhold;p_{T,cut} (GeV/c);N_{tracks}",nBinPt,binLimitsPt,50,-0.5,49.5); + // + + + fh2NConstPt = new TH2F("fh2NConstPt","Number of constituents ;p_{T} (GeV/c);N",nBinPt,binLimitsPt,50,-0.5,49.5); + fh2NConstLeadingPt = new TH2F("fh2NConstLeadingPt","Number of constituents ;p_{T} (GeV/c);N",nBinPt,binLimitsPt,50,-0.5,49.5); + fh2NConstPtRan = new TH2F("fh2NConstPtRan","Number of constituents ;p_{T} (GeV/c);N",nBinPt,binLimitsPt,50,-0.5,49.5); + fh2NConstLeadingPtRan = new TH2F("fh2NConstLeadingPtRan","Number of constituents ;p_{T} (GeV/c);N",nBinPt,binLimitsPt,50,-0.5,49.5); + + fh2PtNch = new TH2F("fh2PtNch","p_T of cluster vs. multiplicity; N_{ch};p_{T} (GeV/c);",nChMax,-0.5,nChMax-0.5,nBinPt,binLimitsPt); + fh2PtNchRan = new TH2F("fh2PtNchRan","p_T of cluster vs. multiplicity ran; N_{ch};p_{T} (GeV/c);",nChMax,-0.5,nChMax-0.5,nBinPt,binLimitsPt); + fh2PtNchN = new TH2F("fh2PtNchN","p_T of cluster vs. multiplicity N weighted; N_{ch};p_{T} (GeV/c);",nChMax,-0.5,nChMax-0.5,nBinPt,binLimitsPt); + fh2PtNchNRan = new TH2F("fh2PtNchNRan","p_T of cluster vs. multiplicity N weighted ran; N_{ch};p_{T} (GeV/c);",nChMax,-0.5,nChMax-0.5,nBinPt,binLimitsPt); + + + + fh2JetPhiEta = new TH2F("fh2JetPhiEta","eta vs phi all jets;#phi;#eta", + nBinPhi,0.,2.*TMath::Pi(),nBinEta,binLimitsEta); + fh2LeadingJetPhiEta = new TH2F("fh2LeadingJetPhiEta","eta vs phi leading jets;#phi;#eta", + nBinPhi,0.,2.*TMath::Pi(),nBinEta,binLimitsEta); + + fh2JetEtaPt = new TH2F("fh2JetEtaPt","pt vs eta all jets;#eta;p_{T}", + nBinEta,binLimitsEta,nBinPt,binLimitsPt); + fh2LeadingJetEtaPt = new TH2F("fh2LeadingJetEtaPt","pT vs eta leading jets;#eta;p_{T}", + nBinEta,binLimitsEta,nBinPt,binLimitsPt); + + fh2TrackEtaPt = new TH2F("fh2TrackEtaPt","pt vs eta all jets;#eta;p_{T}", + nBinEta,binLimitsEta,nBinPt,binLimitsPt); + fh2LeadingTrackEtaPt = new TH2F("fh2LeadingTrackEtaPt","pT vs eta leading jets;#eta;p_{T}", + nBinEta,binLimitsEta,nBinPt,binLimitsPt); + + + + fh2JetsLeadingPhiEta = new TH2F("fh2JetsLeadingPhiEta","delta eta vs delta phi to leading jet;#Delta#phi;#Delta#eta", + nBinPhi,binLimitsPhi,nBinEta,binLimitsEta); + fh2JetsLeadingPhiPt = new TH2F("fh2JetsLeadingPhiPt","leading p_T vs delta phi to leading jet;#Delta#phi;p_{T} (GeV/c)", + nBinPhi,binLimitsPhi,nBinPt,binLimitsPt); + fh2TracksLeadingPhiEta = new TH2F("fh2TracksLeadingPhiEta","delta eta vs delta phi to leading track;#Delta#phi;#Delta#eta", + nBinPhi,binLimitsPhi,nBinEta,binLimitsEta); + fh2TracksLeadingPhiPt = new TH2F("fh2TracksLeadingPhiPt","leading p_T vs delta phi to leading jet;#Delta#phi;p_{T} (GeV/c)", + nBinPhi,binLimitsPhi,nBinPt,binLimitsPt); + fh2TracksLeadingJetPhiPt = new TH2F("fh2TracksLeadingJetPhiPt","leading p_T vs delta phi to leading jet;#Delta#phi;p_{T} (GeV/c)", + nBinPhi,binLimitsPhi,nBinPt,binLimitsPt); + fh2TracksLeadingJetPhiPtRan = new TH2F("fh2TracksLeadingJetPhiPtRan","leading p_T vs delta phi to leading jet;#Delta#phi;p_{T} (GeV/c)", + nBinPhi,binLimitsPhi,nBinPt,binLimitsPt); + + fh2JetsLeadingPhiPtW = new TH2F("fh2JetsLeadingPhiPtW","leading p_T vs delta phi p_T weigted to leading jet;#Delta#phi;p_{T} (GeV/c)", + nBinPhi,binLimitsPhi,nBinPt,binLimitsPt); + fh2TracksLeadingPhiPtW = new TH2F("fh2TracksLeadingPhiPtW","leading p_T vs delta phi to leading jet (p_T weighted);#Delta#phi;p_{T} (GeV/c)", + nBinPhi,binLimitsPhi,nBinPt,binLimitsPt); + + fh2TracksLeadingJetPhiPtW = new TH2F("fh2TracksLeadingJetPhiPtW","leading p_T vs delta phi to leading jet;#Delta#phi;p_{T} (GeV/c)", + nBinPhi,binLimitsPhi,nBinPt,binLimitsPt); + fh2TracksLeadingJetPhiPtWRan = new TH2F("fh2TracksLeadingJetPhiPtWRan","leading p_T vs delta phi to leading jet;#Delta#phi;p_{T} (GeV/c)", + nBinPhi,binLimitsPhi,nBinPt,binLimitsPt); + + + if(fNRandomCones>0&&fUseBackgroundCalc){ + for(int i = 0;i<3;i++){ + fh1BiARandomCones[i] = new TH1F(Form("fh1BiARandomCones%d",i),";B_{i}^{A} (GeV/c)",200,-100,100); + fh1BiARandomConesRan[i] = new TH1F(Form("fh1BiARandomConesRan%d",i),";B_{i}^{A} (GeV/c)",200,-100,100); + } + } + + for(int i = 0;i < kMaxCent;i++){ + fh2JetsLeadingPhiPtC[i] = (TH2F*)fh2JetsLeadingPhiPt->Clone(Form("%s_C%02d",fh2JetsLeadingPhiPt->GetName(),i+1)); + fh2JetsLeadingPhiPtWC[i]= (TH2F*)fh2JetsLeadingPhiPtW->Clone(Form("%s_C%02d",fh2JetsLeadingPhiPtW->GetName(),i+1)); + fh2TracksLeadingJetPhiPtC[i] = (TH2F*)fh2TracksLeadingJetPhiPt->Clone(Form("%s_C%02d",fh2TracksLeadingJetPhiPt->GetName(),i+1)); + fh2TracksLeadingJetPhiPtWC[i] = (TH2F*)fh2TracksLeadingJetPhiPtW->Clone(Form("%s_C%02d",fh2TracksLeadingJetPhiPtW->GetName(),i+1)); + } + + const Int_t saveLevel = 3; // large save level more histos + if(saveLevel>0){ + fHistList->Add(fh1Xsec); + fHistList->Add(fh1Trials); + + fHistList->Add(fh1NJetsRec); + fHistList->Add(fh1NConstRec); + fHistList->Add(fh1NConstLeadingRec); + fHistList->Add(fh1PtJetsRecIn); + fHistList->Add(fh1PtJetsLeadingRecIn); + fHistList->Add(fh1PtTracksRecIn); + fHistList->Add(fh1PtTracksLeadingRecIn); + fHistList->Add(fh1PtJetConstRec); + fHistList->Add(fh1PtJetConstLeadingRec); + fHistList->Add(fh1NJetsRecRan); + fHistList->Add(fh1NConstRecRan); + fHistList->Add(fh1PtJetsLeadingRecInRan); + fHistList->Add(fh1NConstLeadingRecRan); + fHistList->Add(fh1PtJetsRecInRan); + fHistList->Add(fh1Nch); + fHistList->Add(fh1Centrality); + fHistList->Add(fh1CentralitySelect); + fHistList->Add(fh1CentralityPhySel); + fHistList->Add(fh1Z); + fHistList->Add(fh1ZSelect); + fHistList->Add(fh1ZPhySel); + if(fNRandomCones>0&&fUseBackgroundCalc){ + for(int i = 0;i<3;i++){ + fHistList->Add(fh1BiARandomCones[i]); + fHistList->Add(fh1BiARandomConesRan[i]); + } + } + for(int i = 0;i < kMaxCent;i++){ + fHistList->Add(fh2JetsLeadingPhiPtC[i]); + fHistList->Add(fh2JetsLeadingPhiPtWC[i]); + fHistList->Add(fh2TracksLeadingJetPhiPtC[i]); + fHistList->Add(fh2TracksLeadingJetPhiPtWC[i]); + } + + fHistList->Add(fh2NRecJetsPt); + fHistList->Add(fh2NRecTracksPt); + fHistList->Add(fh2NConstPt); + fHistList->Add(fh2NConstLeadingPt); + fHistList->Add(fh2PtNch); + fHistList->Add(fh2PtNchRan); + fHistList->Add(fh2PtNchN); + fHistList->Add(fh2PtNchNRan); + fHistList->Add(fh2JetPhiEta); + fHistList->Add(fh2LeadingJetPhiEta); + fHistList->Add(fh2JetEtaPt); + fHistList->Add(fh2LeadingJetEtaPt); + fHistList->Add(fh2TrackEtaPt); + fHistList->Add(fh2LeadingTrackEtaPt); + fHistList->Add(fh2JetsLeadingPhiEta ); + fHistList->Add(fh2JetsLeadingPhiPt); + fHistList->Add(fh2TracksLeadingPhiEta); + fHistList->Add(fh2TracksLeadingPhiPt); + fHistList->Add(fh2TracksLeadingJetPhiPt); + fHistList->Add(fh2JetsLeadingPhiPtW); + fHistList->Add(fh2TracksLeadingPhiPtW); + fHistList->Add(fh2TracksLeadingJetPhiPtW); + fHistList->Add(fh2NRecJetsPtRan); + fHistList->Add(fh2NConstPtRan); + fHistList->Add(fh2NConstLeadingPtRan); + fHistList->Add(fh2TracksLeadingJetPhiPtRan); + fHistList->Add(fh2TracksLeadingJetPhiPtWRan); + } + + // =========== Switch on Sumw2 for all histos =========== + for (Int_t i=0; iGetEntries(); ++i) { + TH1 *h1 = dynamic_cast(fHistList->At(i)); + if (h1){ + h1->Sumw2(); + continue; + } + THnSparse *hn = dynamic_cast(fHistList->At(i)); + if(hn)hn->Sumw2(); + } + TH1::AddDirectory(oldStatus); +} + +void AliAnalysisTaskJetCluster::Init() +{ + // + // Initialization + // + + if (fDebug > 1) printf("AnalysisTaskJetCluster::Init() \n"); + +} + +void AliAnalysisTaskJetCluster::UserExec(Option_t */*option*/) +{ + + // handle and reset the output jet branch + + if(fTCAJetsOut)fTCAJetsOut->Delete(); + if(fTCAJetsOutRan)fTCAJetsOutRan->Delete(); + if(fTCARandomConesOut)fTCARandomConesOut->Delete(); + if(fTCARandomConesOutRan)fTCARandomConesOutRan->Delete(); + if(fAODJetBackgroundOut)fAODJetBackgroundOut->Reset(); + + AliAODJetEventBackground* externalBackground = 0; + if(!externalBackground&&fBackgroundBranch.Length()){ + externalBackground = (AliAODJetEventBackground*)(AODEvent()->FindListObject(fBackgroundBranch.Data())); + if((!externalBackground)&&fAODExtension)externalBackground = (AliAODJetEventBackground*)(fAODExtension->GetAOD()->FindListObject(fBackgroundBranch.Data())); + if(!externalBackground)Printf("%s:%d Background branch not found %s",(char*)__FILE__,__LINE__,fBackgroundBranch.Data());; + } + // + // Execute analysis for current event + // + AliESDEvent *fESD = 0; + if(fUseAODTrackInput){ + fAOD = dynamic_cast(InputEvent()); + if(!fAOD){ + Printf("%s:%d AODEvent not found in Input Manager %d",(char*)__FILE__,__LINE__,fUseAODTrackInput); + return; + } + // fethc the header + } + else{ + // assume that the AOD is in the general output... + fAOD = AODEvent(); + if(!fAOD){ + Printf("%s:%d AODEvent not found in the Output",(char*)__FILE__,__LINE__); + return; + } + if(fDebug>0){ + fESD = dynamic_cast (InputEvent()); + } + } + + Bool_t selectEvent = false; + Bool_t physicsSelection = true;// handled by the framework(fInputHandler->IsEventSelected()&AliVEvent::kMB)==AliVEvent::kMB; + + Float_t cent = 0; + Float_t zVtx = 0; + Int_t cenClass = -1; + if(fAOD){ + const AliAODVertex *vtxAOD = fAOD->GetPrimaryVertex(); + TString vtxTitle(vtxAOD->GetTitle()); + zVtx = vtxAOD->GetZ(); + + cent = fAOD->GetHeader()->GetCentrality(); + if(cent<10)cenClass = 0; + else if(cent<30)cenClass = 1; + else if(cent<50)cenClass = 2; + else if(cent<80)cenClass = 3; + if(physicsSelection){ + fh1CentralityPhySel->Fill(cent); + fh1ZPhySel->Fill(zVtx); + } + + if(fEventSelection){ + if(vtxAOD->GetNContributors()>2&&!vtxTitle.Contains("TPCVertex")){ + Float_t yvtx = vtxAOD->GetY(); + Float_t xvtx = vtxAOD->GetX(); + Float_t r2 = yvtx*yvtx+xvtx*xvtx; + if(TMath::Abs(zVtx)0){ + if(centfCentCutUp){ + selectEvent = false; + } + } + }else{ + selectEvent = true; + } + } + + + if(!selectEvent){ + PostData(1, fHistList); + return; + } + fh1Centrality->Fill(cent); + fh1Z->Fill(zVtx); + fh1Trials->Fill("#sum{ntrials}",1); + + + if (fDebug > 10)Printf("%s:%d",(char*)__FILE__,__LINE__); + + // ==== General variables needed + + + + // we simply fetch the tracks/mc particles as a list of AliVParticles + + TList recParticles; + TList genParticles; + + Int_t nT = GetListOfTracks(&recParticles,fTrackTypeRec); + Float_t nCh = recParticles.GetEntries(); + fh1Nch->Fill(nCh); + if(fDebug>2)Printf("%s:%d Selected Rec tracks: %d %d",(char*)__FILE__,__LINE__,nT,recParticles.GetEntries()); + nT = GetListOfTracks(&genParticles,fTrackTypeGen); + if(fDebug>2)Printf("%s:%d Selected Gen tracks: %d %d",(char*)__FILE__,__LINE__,nT,genParticles.GetEntries()); + + // find the jets.... + + vector inputParticlesRec; + vector inputParticlesRecRan; + + // Generate the random cones + + AliAODJet vTmpRan(1,0,0,1); + for(int i = 0; i < recParticles.GetEntries(); i++){ + AliVParticle *vp = (AliVParticle*)recParticles.At(i); + // Carefull energy is not well determined in real data, should not matter for p_T scheme? + // we take total momentum here + fastjet::PseudoJet jInp(vp->Px(),vp->Py(),vp->Pz(),vp->P()); + jInp.set_user_index(i); + inputParticlesRec.push_back(jInp); + + // the randomized input changes eta and phi, but keeps the p_T + if(i>=fNSkipLeadingRan){// eventually skip the leading particles + Double_t pT = vp->Pt(); + Double_t eta = 2.*fTrackEtaWindow * fRandom->Rndm() - fTrackEtaWindow; + Double_t phi = 2.* TMath::Pi() * fRandom->Rndm(); + + Double_t theta = 2.*TMath::ATan(TMath::Exp(-eta)); + Double_t pZ = pT/TMath::Tan(theta); + + Double_t pX = pT * TMath::Cos(phi); + Double_t pY = pT * TMath::Sin(phi); + Double_t p = TMath::Sqrt(pT*pT+pZ*pZ); + fastjet::PseudoJet jInpRan(pX,pY,pZ,p); + + jInpRan.set_user_index(i); + inputParticlesRecRan.push_back(jInpRan); + vTmpRan.SetPxPyPzE(pX,pY,pZ,p); + } + + // fill the tref array, only needed when we write out jets + if(fTCAJetsOut){ + if(i == 0){ + fRef->Delete(); // make sure to delete before placement new... + new(fRef) TRefArray(TProcessID::GetProcessWithUID(vp)); + } + fRef->Add(vp); + } + }// recparticles + + if(inputParticlesRec.size()==0){ + if(fDebug)Printf("%s:%d No input particles found, skipping event",(char*)__FILE__,__LINE__); + PostData(1, fHistList); + return; + } + + // run fast jet + // employ setters for these... + + + // now create the object that holds info about ghosts + /* + if(!fUseBackgroundCalc&& fNonStdBranch.Length()==0){ + // reduce CPU time... + fGhostArea = 0.5; + fActiveAreaRepeats = 0; + } + */ + + fastjet::GhostedAreaSpec ghostSpec(fGhostEtamax, fActiveAreaRepeats, fGhostArea); + fastjet::AreaType areaType = fastjet::active_area; + fastjet::AreaDefinition areaDef = fastjet::AreaDefinition(areaType,ghostSpec); + fastjet::JetDefinition jetDef(fAlgorithm, fRparam, fRecombScheme, fStrategy); + fastjet::ClusterSequenceArea clustSeq(inputParticlesRec, jetDef,areaDef); + + //range where to compute background + Double_t phiMin = 0, phiMax = 0, rapMin = 0, rapMax = 0; + phiMin = 0; + phiMax = 2*TMath::Pi(); + rapMax = fGhostEtamax - fRparam; + rapMin = - fGhostEtamax + fRparam; + fastjet::RangeDefinition range(rapMin,rapMax, phiMin, phiMax); + + + const vector &inclusiveJets = clustSeq.inclusive_jets(); + const vector &sortedJets = sorted_by_pt(inclusiveJets); + + + fh1NJetsRec->Fill(sortedJets.size()); + + // loop over all jets an fill information, first on is the leading jet + + Int_t nRecOver = inclusiveJets.size(); + Int_t nRec = inclusiveJets.size(); + if(inclusiveJets.size()>0){ + AliAODJet leadingJet (sortedJets[0].px(), sortedJets[0].py(), sortedJets[0].pz(), sortedJets[0].E()); + Double_t area = clustSeq.area(sortedJets[0]); + leadingJet.SetEffArea(area,0); + Float_t pt = leadingJet.Pt(); + Int_t nAodOutJets = 0; + Int_t nAodOutTracks = 0; + AliAODJet *aodOutJet = 0; + + Int_t iCount = 0; + for(int i = 1;i <= fh2NRecJetsPt->GetNbinsX();i++){ + Float_t ptCut = fh2NRecJetsPt->GetXaxis()->GetBinCenter(i); + while(ptFill(ptCut,nRecOver); + } + Float_t phi = leadingJet.Phi(); + if(phi<0)phi+=TMath::Pi()*2.; + Float_t eta = leadingJet.Eta(); + Float_t pTback = 0; + if(externalBackground){ + // carefull has to be filled in a task before + // todo, ReArrange to the botom + pTback = externalBackground->GetBackground(1)*leadingJet.EffectiveAreaCharged(); + } + pt = leadingJet.Pt() - pTback; + // correlation of leading jet with tracks + TIterator *recIter = recParticles.MakeIterator(); + recIter->Reset(); + AliVParticle *tmpRecTrack = 0; + while((tmpRecTrack = (AliVParticle*)(recIter->Next()))){ + Float_t tmpPt = tmpRecTrack->Pt(); + // correlation + Float_t tmpPhi = tmpRecTrack->Phi(); + if(tmpPhi<0)tmpPhi+=TMath::Pi()*2.; + Float_t dPhi = phi - tmpPhi; + if(dPhi>TMath::Pi())dPhi = dPhi - 2.*TMath::Pi(); + if(dPhi<(-1.*TMath::Pi()))dPhi = dPhi + 2.*TMath::Pi(); + fh2TracksLeadingJetPhiPt->Fill(dPhi,pt); + fh2TracksLeadingJetPhiPtW->Fill(dPhi,pt,tmpPt); + if(cenClass>=0){ + fh2TracksLeadingJetPhiPtC[cenClass]->Fill(dPhi,pt); + fh2TracksLeadingJetPhiPtWC[cenClass]->Fill(dPhi,pt,tmpPt); + } + + } + + + TLorentzVector vecareab; + for(int j = 0; j < nRec;j++){ + AliAODJet tmpRec (sortedJets[j].px(), sortedJets[j].py(), sortedJets[j].pz(), sortedJets[j].E()); + aodOutJet = 0; + nAodOutTracks = 0; + Float_t tmpPt = tmpRec.Pt(); + + if(tmpPt>fJetOutputMinPt&&fTCAJetsOut){// cut on the non-background subtracted... + aodOutJet = new ((*fTCAJetsOut)[nAodOutJets++]) AliAODJet(tmpRec); + aodOutJet->GetRefTracks()->Clear(); + Double_t area1 = clustSeq.area(sortedJets[j]); + aodOutJet->SetEffArea(area1,0); + fastjet::PseudoJet vecarea=clustSeq.area_4vector(sortedJets[j]); + vecareab.SetPxPyPzE(vecarea.px(),vecarea.py(),vecarea.pz(),vecarea.e()); + aodOutJet->SetVectorAreaCharged(&vecareab); + } + + + Float_t tmpPtBack = 0; + if(externalBackground){ + // carefull has to be filled in a task before + // todo, ReArrange to the botom + tmpPtBack = externalBackground->GetBackground(2)*tmpRec.EffectiveAreaCharged(); + } + tmpPt = tmpPt - tmpPtBack; + if(tmpPt<0)tmpPt = 0; // avoid negative weights... + + fh1PtJetsRecIn->Fill(tmpPt); + // Fill Spectra with constituentsemacs + const vector &constituents = clustSeq.constituents(sortedJets[j]); + + fh1NConstRec->Fill(constituents.size()); + fh2PtNch->Fill(nCh,tmpPt); + fh2PtNchN->Fill(nCh,tmpPt,constituents.size()); + fh2NConstPt->Fill(tmpPt,constituents.size()); + // loop over constiutents and fill spectrum + + for(unsigned int ic = 0; ic < constituents.size();ic++){ + AliVParticle *part = (AliVParticle*)recParticles.At(constituents[ic].user_index()); + fh1PtJetConstRec->Fill(part->Pt()); + if(aodOutJet){ + aodOutJet->AddTrack(fRef->At(constituents[ic].user_index())); + if(part->Pt()>fMaxTrackPtInJet)aodOutJet->SetTrigger(AliAODJet::kHighTrackPtTriggered); + } + if(j==0)fh1PtJetConstLeadingRec->Fill(part->Pt()); + } + + // correlation + Float_t tmpPhi = tmpRec.Phi(); + Float_t tmpEta = tmpRec.Eta(); + if(tmpPhi<0)tmpPhi+=TMath::Pi()*2.; + if(j==0){ + fh1PtJetsLeadingRecIn->Fill(tmpPt); + fh2LeadingJetPhiEta->Fill(tmpPhi,tmpEta); + fh2LeadingJetEtaPt->Fill(tmpEta,tmpPt); + fh1NConstLeadingRec->Fill(constituents.size()); + fh2NConstLeadingPt->Fill(tmpPt,constituents.size()); + continue; + } + fh2JetPhiEta->Fill(tmpRec.Phi(),tmpEta); + fh2JetEtaPt->Fill(tmpEta,tmpPt); + Float_t dPhi = phi - tmpPhi; + if(dPhi>TMath::Pi())dPhi = dPhi - 2.*TMath::Pi(); + if(dPhi<(-1.*TMath::Pi()))dPhi = dPhi + 2.*TMath::Pi(); + Float_t dEta = eta - tmpRec.Eta(); + fh2JetsLeadingPhiEta->Fill(dPhi,dEta); + fh2JetsLeadingPhiPt->Fill(dPhi,pt); + if(cenClass>=0){ + fh2JetsLeadingPhiPtC[cenClass]->Fill(dPhi,pt); + fh2JetsLeadingPhiPtWC[cenClass]->Fill(dPhi,pt,tmpPt); + } + fh2JetsLeadingPhiPtW->Fill(dPhi,pt,tmpPt); + }// loop over reconstructed jets + delete recIter; + + + + // Add the random cones... + if(fNRandomCones>0&&fTCARandomConesOut){ + // create a random jet within the acceptance + Double_t etaMax = fTrackEtaWindow - fRparam; + Int_t nCone = 0; + Int_t nConeRan = 0; + Double_t pTC = 1; // small number + for(int ir = 0;ir < fNRandomCones;ir++){ + Double_t etaC = etaMax*2.*(fRandom->Rndm()-0.5); // +- etamax + Double_t phiC = fRandom->Rndm()*2.*TMath::Pi(); // 0 - 2pi + // massless jet + Double_t thetaC = 2.*TMath::ATan(TMath::Exp(-etaC)); + Double_t pZC = pTC/TMath::Tan(thetaC); + Double_t pXC = pTC * TMath::Cos(phiC); + Double_t pYC = pTC * TMath::Sin(phiC); + Double_t pC = TMath::Sqrt(pTC*pTC+pZC*pZC); + AliAODJet tmpRecC (pXC,pYC,pZC, pC); + bool skip = false; + for(int jj = 0; jj < TMath::Min(nRec,fNSkipLeadingCone);jj++){// test for overlap with leading jets + AliAODJet jet (sortedJets[jj].px(), sortedJets[jj].py(), sortedJets[jj].pz(), sortedJets[jj].E()); + if(jet.DeltaR(& tmpRecC)<2.*fRparam+0.2){ + skip = true; + break; + } + } + // test for overlap with previous cones to avoid double counting + for(int iic = 0;iicAt(iic); + if(iicone){ + if(iicone->DeltaR(&tmpRecC)<2.*fRparam){ + skip = true; + break; + } + } + } + if(skip)continue; + tmpRecC.SetBgEnergy(0,0); // this is use as temporary storage of the summed p_T below + if(fTCARandomConesOut)new ((*fTCARandomConesOut)[nCone++]) AliAODJet(tmpRecC); + if(fTCARandomConesOutRan)new ((*fTCARandomConesOutRan)[nConeRan++]) AliAODJet(tmpRecC); + }// loop over random cones creation + + + // loop over the reconstructed particles and add up the pT in the random cones + // maybe better to loop over randomized particles not in the real jets... + // but this by definition brings dow average energy in the whole event + AliAODJet vTmpRanR(1,0,0,1); + for(int i = 0; i < recParticles.GetEntries(); i++){ + AliVParticle *vp = (AliVParticle*)recParticles.At(i); + if(fTCARandomConesOut){ + for(int ir = 0;ir < fNRandomCones;ir++){ + AliAODJet *jC = (AliAODJet*)fTCARandomConesOut->At(ir); + if(jC&&jC->DeltaR(vp)Pt()>fMaxTrackPtInJet)jC->SetTrigger(AliAODJet::kHighTrackPtTriggered); + jC->SetBgEnergy(jC->ChargedBgEnergy()+vp->Pt(),0); + } + } + }// add up energy in cone + + // the randomized input changes eta and phi, but keeps the p_T + if(i>=fNSkipLeadingRan){// eventually skip the leading particles + Double_t pTR = vp->Pt(); + Double_t etaR = 2.*fTrackEtaWindow* fRandom->Rndm() - fTrackEtaWindow; + Double_t phiR = 2.* TMath::Pi() * fRandom->Rndm(); + + Double_t thetaR = 2.*TMath::ATan(TMath::Exp(-etaR)); + Double_t pZR = pTR/TMath::Tan(thetaR); + + Double_t pXR = pTR * TMath::Cos(phiR); + Double_t pYR = pTR * TMath::Sin(phiR); + Double_t pR = TMath::Sqrt(pTR*pTR+pZR*pZR); + vTmpRanR.SetPxPyPzE(pXR,pYR,pZR,pR); + if(fTCARandomConesOutRan){ + for(int ir = 0;ir < fTCARandomConesOutRan->GetEntriesFast();ir++){ + AliAODJet *jC = (AliAODJet*)fTCARandomConesOutRan->At(ir); + if(jC&&jC->DeltaR(&vTmpRanR)fMaxTrackPtInJet)jC->SetTrigger(AliAODJet::kHighTrackPtTriggered); + jC->SetBgEnergy(jC->ChargedBgEnergy()+vTmpRanR.Pt(),0); + } + } + } + } + }// loop over recparticles + + Float_t jetArea = fRparam*fRparam*TMath::Pi(); + if(fTCARandomConesOut){ + for(int ir = 0;ir < fTCARandomConesOut->GetEntriesFast();ir++){ + // rescale the momntum vectors for the random cones + + AliAODJet *rC = (AliAODJet*)fTCARandomConesOut->At(ir); + if(rC){ + Double_t etaC = rC->Eta(); + Double_t phiC = rC->Phi(); + // massless jet, unit vector + pTC = rC->ChargedBgEnergy(); + if(pTC<=0)pTC = 0.001; // for almost empty events + Double_t thetaC = 2.*TMath::ATan(TMath::Exp(-etaC)); + Double_t pZC = pTC/TMath::Tan(thetaC); + Double_t pXC = pTC * TMath::Cos(phiC); + Double_t pYC = pTC * TMath::Sin(phiC); + Double_t pC = TMath::Sqrt(pTC*pTC+pZC*pZC); + rC->SetPxPyPzE(pXC,pYC,pZC, pC); + rC->SetBgEnergy(0,0); + rC->SetEffArea(jetArea,0); + } + } + } + if(fTCARandomConesOutRan){ + for(int ir = 0;ir < fTCARandomConesOutRan->GetEntriesFast();ir++){ + AliAODJet* rC = (AliAODJet*)fTCARandomConesOutRan->At(ir); + // same wit random + if(rC){ + Double_t etaC = rC->Eta(); + Double_t phiC = rC->Phi(); + // massless jet, unit vector + pTC = rC->ChargedBgEnergy(); + if(pTC<=0)pTC = 0.001;// for almost empty events + Double_t thetaC = 2.*TMath::ATan(TMath::Exp(-etaC)); + Double_t pZC = pTC/TMath::Tan(thetaC); + Double_t pXC = pTC * TMath::Cos(phiC); + Double_t pYC = pTC * TMath::Sin(phiC); + Double_t pC = TMath::Sqrt(pTC*pTC+pZC*pZC); + rC->SetPxPyPzE(pXC,pYC,pZC, pC); + rC->SetBgEnergy(0,0); + rC->SetEffArea(jetArea,0); + } + } + } + }// if(fNRandomCones + + //background estimates:all bckg jets(0) & wo the 2 hardest(1) + + + + + + if(fAODJetBackgroundOut){ + vector jets2=sortedJets; + if(jets2.size()>2) jets2.erase(jets2.begin(),jets2.begin()+2); + Double_t bkg1=0; + Double_t sigma1=0.; + Double_t meanarea1=0.; + Double_t bkg2=0; + Double_t sigma2=0.; + Double_t meanarea2=0.; + + clustSeq.get_median_rho_and_sigma(jets2, range, true, bkg1, sigma1, meanarea1, true); + fAODJetBackgroundOut->SetBackground(0,bkg1,sigma1,meanarea1); + + // fh1BiARandomCones[0]->Fill(omCone-(bkg1*areaRandomCone)); + // fh1BiARandomConesRan[0]->Fill(ptRandomConeRan-(bkg1*areaRandomCone)); + + clustSeq.get_median_rho_and_sigma(jets2, range, false, bkg2, sigma2, meanarea2, true); + fAODJetBackgroundOut->SetBackground(1,bkg2,sigma2,meanarea2); + // fh1BiARandomCones[1]->Fill(ptRandomCone-(bkg2*areaRandomCone)); + // fh1BiARandomConesRan[1]->Fill(ptRandomConeRan-(bkg2*areaRandomCone)); + + } + } + + + + + + // fill track information + Int_t nTrackOver = recParticles.GetSize(); + // do the same for tracks and jets + + if(nTrackOver>0){ + TIterator *recIter = recParticles.MakeIterator(); + AliVParticle *tmpRec = (AliVParticle*)(recIter->Next()); + Float_t pt = tmpRec->Pt(); + + // Printf("Leading track p_t %3.3E",pt); + for(int i = 1;i <= fh2NRecTracksPt->GetNbinsX();i++){ + Float_t ptCut = fh2NRecTracksPt->GetXaxis()->GetBinCenter(i); + while(ptNext()); + if(tmpRec){ + pt = tmpRec->Pt(); + } + } + if(nTrackOver<=0)break; + fh2NRecTracksPt->Fill(ptCut,nTrackOver); + } + + recIter->Reset(); + AliVParticle *leading = (AliVParticle*)recParticles.At(0); + Float_t phi = leading->Phi(); + if(phi<0)phi+=TMath::Pi()*2.; + Float_t eta = leading->Eta(); + pt = leading->Pt(); + while((tmpRec = (AliVParticle*)(recIter->Next()))){ + Float_t tmpPt = tmpRec->Pt(); + Float_t tmpEta = tmpRec->Eta(); + fh1PtTracksRecIn->Fill(tmpPt); + fh2TrackEtaPt->Fill(tmpEta,tmpPt); + if(tmpRec==leading){ + fh1PtTracksLeadingRecIn->Fill(tmpPt); + fh2LeadingTrackEtaPt->Fill(tmpEta,tmpPt); + continue; + } + // correlation + Float_t tmpPhi = tmpRec->Phi(); + + if(tmpPhi<0)tmpPhi+=TMath::Pi()*2.; + Float_t dPhi = phi - tmpPhi; + if(dPhi>TMath::Pi())dPhi = dPhi - 2.*TMath::Pi(); + if(dPhi<(-1.*TMath::Pi()))dPhi = dPhi + 2.*TMath::Pi(); + Float_t dEta = eta - tmpRec->Eta(); + fh2TracksLeadingPhiEta->Fill(dPhi,dEta); + fh2TracksLeadingPhiPt->Fill(dPhi,pt); + fh2TracksLeadingPhiPtW->Fill(dPhi,pt,tmpPt); + } + delete recIter; + } + + // find the random jets + + fastjet::ClusterSequenceArea clustSeqRan(inputParticlesRecRan, jetDef, areaDef); + + // fill the jet information from random track + const vector &inclusiveJetsRan = clustSeqRan.inclusive_jets(); + const vector &sortedJetsRan = sorted_by_pt(inclusiveJetsRan); + + fh1NJetsRecRan->Fill(sortedJetsRan.size()); + + // loop over all jets an fill information, first on is the leading jet + + Int_t nRecOverRan = inclusiveJetsRan.size(); + Int_t nRecRan = inclusiveJetsRan.size(); + + if(inclusiveJetsRan.size()>0){ + AliAODJet leadingJet (sortedJetsRan[0].px(), sortedJetsRan[0].py(), sortedJetsRan[0].pz(), sortedJetsRan[0].E()); + Float_t pt = leadingJet.Pt(); + + Int_t iCount = 0; + TLorentzVector vecarearanb; + + for(int i = 1;i <= fh2NRecJetsPtRan->GetNbinsX();i++){ + Float_t ptCut = fh2NRecJetsPtRan->GetXaxis()->GetBinCenter(i); + while(ptFill(ptCut,nRecOverRan); + } + Float_t phi = leadingJet.Phi(); + if(phi<0)phi+=TMath::Pi()*2.; + pt = leadingJet.Pt(); + + // correlation of leading jet with random tracks + + for(unsigned int ip = 0; ip < inputParticlesRecRan.size();ip++) + { + Float_t tmpPt = inputParticlesRecRan[ip].perp(); + // correlation + Float_t tmpPhi = inputParticlesRecRan[ip].phi(); + if(tmpPhi<0)tmpPhi+=TMath::Pi()*2.; + Float_t dPhi = phi - tmpPhi; + if(dPhi>TMath::Pi())dPhi = dPhi - 2.*TMath::Pi(); + if(dPhi<(-1.*TMath::Pi()))dPhi = dPhi + 2.*TMath::Pi(); + fh2TracksLeadingJetPhiPtRan->Fill(dPhi,pt); + fh2TracksLeadingJetPhiPtWRan->Fill(dPhi,pt,tmpPt); + } + + Int_t nAodOutJetsRan = 0; + AliAODJet *aodOutJetRan = 0; + for(int j = 0; j < nRecRan;j++){ + AliAODJet tmpRec (sortedJetsRan[j].px(), sortedJetsRan[j].py(), sortedJetsRan[j].pz(), sortedJetsRan[j].E()); + Float_t tmpPt = tmpRec.Pt(); + fh1PtJetsRecInRan->Fill(tmpPt); + // Fill Spectra with constituents + const vector &constituents = clustSeqRan.constituents(sortedJetsRan[j]); + fh1NConstRecRan->Fill(constituents.size()); + fh2NConstPtRan->Fill(tmpPt,constituents.size()); + fh2PtNchRan->Fill(nCh,tmpPt); + fh2PtNchNRan->Fill(nCh,tmpPt,constituents.size()); + + + if(tmpPt>fJetOutputMinPt&&fTCAJetsOutRan){ + aodOutJetRan = new ((*fTCAJetsOutRan)[nAodOutJetsRan++]) AliAODJet(tmpRec); + Double_t arearan=clustSeqRan.area(sortedJetsRan[j]); + aodOutJetRan->GetRefTracks()->Clear(); + aodOutJetRan->SetEffArea(arearan,0); + fastjet::PseudoJet vecarearan=clustSeqRan.area_4vector(sortedJetsRan[j]); + vecarearanb.SetPxPyPzE(vecarearan.px(),vecarearan.py(),vecarearan.pz(),vecarearan.e()); + aodOutJetRan->SetVectorAreaCharged(&vecarearanb); + + } + + // correlation + Float_t tmpPhi = tmpRec.Phi(); + if(tmpPhi<0)tmpPhi+=TMath::Pi()*2.; + + if(j==0){ + fh1PtJetsLeadingRecInRan->Fill(tmpPt); + fh1NConstLeadingRecRan->Fill(constituents.size()); + fh2NConstLeadingPtRan->Fill(tmpPt,constituents.size()); + continue; + } + } + + + if(fAODJetBackgroundOut){ + Double_t bkg3=0.; + Double_t sigma3=0.; + Double_t meanarea3=0.; + clustSeqRan.get_median_rho_and_sigma(sortedJetsRan ,range, false, bkg3, sigma3, meanarea3, true); + fAODJetBackgroundOut->SetBackground(2,bkg3,sigma3,meanarea3); + // float areaRandomCone = rRandomCone2 *TMath::Pi(); + /* + fh1BiARandomCones[2]->Fill(ptRandomCone-(bkg3*areaRandomCone)); + fh1BiARandomConesRan[2]->Fill(ptRandomConeRan-(bkg3*areaRandomCone)); + */ + } + + + + } + + + // do the event selection if activated + if(fJetTriggerPtCut>0){ + bool select = false; + Float_t minPt = fJetTriggerPtCut; + /* + // hard coded for now ... + // 54.50 44.5 29.5 18.5 for anti-kt rejection 1E-3 + if(cent<10)minPt = 50; + else if(cent<30)minPt = 42; + else if(cent<50)minPt = 28; + else if(cent<80)minPt = 18; + */ + float rho = 0; + if(externalBackground)rho = externalBackground->GetBackground(2); + if(fTCAJetsOut){ + for(int i = 0;i < fTCAJetsOut->GetEntriesFast();i++){ + AliAODJet *jet = (AliAODJet*)fTCAJetsOut->At(i); + Float_t ptSub = jet->Pt() - rho *jet->EffectiveAreaCharged(); + if(ptSub>=minPt){ + select = true; + break; + } + } + } + + if(select){ + static AliAODHandler *aodH = dynamic_cast(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()); + fh1CentralitySelect->Fill(cent); + fh1ZSelect->Fill(zVtx); + aodH->SetFillAOD(kTRUE); + } + } + if (fDebug > 2){ + if(fTCAJetsOut)Printf("%s:%d Rec Jets %d",(char*)__FILE__,__LINE__,fTCAJetsOut->GetEntriesFast()); + if(fTCAJetsOutRan)Printf("%s:%d Rec Jets Ran %d",(char*)__FILE__,__LINE__,fTCAJetsOutRan->GetEntriesFast()); + if(fTCARandomConesOut)Printf("%s:%d RC %d",(char*)__FILE__,__LINE__,fTCARandomConesOut->GetEntriesFast()); + if(fTCARandomConesOutRan)Printf("%s:%d RC Ran %d",(char*)__FILE__,__LINE__,fTCARandomConesOutRan->GetEntriesFast()); + } + PostData(1, fHistList); +} + +void AliAnalysisTaskJetCluster::Terminate(Option_t */*option*/) +{ +// Terminate analysis +// + if (fDebug > 1) printf("AnalysisJetCluster: Terminate() \n"); +} + + +Int_t AliAnalysisTaskJetCluster::GetListOfTracks(TList *list,Int_t type){ + + if(fDebug>2)Printf("%s:%d Selecting tracks with %d",(char*)__FILE__,__LINE__,type); + + Int_t iCount = 0; + if(type==kTrackAOD || type==kTrackAODextra || type==kTrackAODextraonly){ + if(type!=kTrackAODextraonly) { + AliAODEvent *aod = 0; + if(fUseAODTrackInput)aod = dynamic_cast(InputEvent()); + else aod = AODEvent(); + if(!aod){ + if(fDebug>2)Printf("%s:%d No AOD",(char*)__FILE__,__LINE__); + return iCount; + } + for(int it = 0;it < aod->GetNumberOfTracks();++it){ + AliAODTrack *tr = aod->GetTrack(it); + Bool_t bGood = false; + if(fFilterType == 0)bGood = true; + else if(fFilterType == 1)bGood = tr->IsHybridTPCConstrainedGlobal(); + else if(fFilterType == 2)bGood = tr->IsHybridGlobalConstrainedGlobal(); + if((fFilterMask>0)&&((!tr->TestFilterBit(fFilterMask)||(!bGood)))){ + if(fDebug>10)Printf("%s:%d Not matching filter %d/%d %d/%d",(char*)__FILE__,__LINE__,it,aod->GetNumberOfTracks(),fFilterMask,tr->GetFilterMap()); + continue; + } + if(TMath::Abs(tr->Eta())>fTrackEtaWindow){ + if(fDebug>10)Printf("%s:%d Not matching eta %d/%d",(char*)__FILE__,__LINE__,it,aod->GetNumberOfTracks()); + continue; + } + if(tr->Pt()10)Printf("%s:%d Not matching pt %d/%d",(char*)__FILE__,__LINE__,it,aod->GetNumberOfTracks()); + continue; + } + if(fDebug>10)Printf("%s:%d MATCHED %d/%d",(char*)__FILE__,__LINE__,it,aod->GetNumberOfTracks()); + list->Add(tr); + iCount++; + } + } + if(type==kTrackAODextra || type==kTrackAODextraonly) { + AliAODEvent *aod = 0; + if(fUseAODTrackInput)aod = dynamic_cast(InputEvent()); + else aod = AODEvent(); + + if(!aod){ + return iCount; + } + TClonesArray *aodExtraTracks = dynamic_cast(aod->FindListObject("aodExtraTracks")); + if(!aodExtraTracks)return iCount; + for(int it =0; itGetEntries(); it++) { + AliVParticle *track = dynamic_cast ((*aodExtraTracks)[it]); + if (!track) continue; + + AliAODTrack *trackAOD = dynamic_cast (track); + if(!trackAOD)continue; + Bool_t bGood = false; + if(fFilterType == 0)bGood = true; + else if(fFilterType == 1)bGood = trackAOD->IsHybridTPCConstrainedGlobal(); + else if(fFilterType == 2)bGood = trackAOD->IsHybridGlobalConstrainedGlobal(); + if((fFilterMask>0)&&((!trackAOD->TestFilterBit(fFilterMask)||(!bGood))))continue; + if(TMath::Abs(trackAOD->Eta())>fTrackEtaWindow) continue; + if(trackAOD->Pt()Add(trackAOD); + iCount++; + } + } + } + else if (type == kTrackKineAll||type == kTrackKineCharged){ + AliMCEvent* mcEvent = MCEvent(); + if(!mcEvent)return iCount; + // we want to have alivpartilces so use get track + for(int it = 0;it < mcEvent->GetNumberOfTracks();++it){ + if(!mcEvent->IsPhysicalPrimary(it))continue; + AliMCParticle* part = (AliMCParticle*)mcEvent->GetTrack(it); + if(type == kTrackKineAll){ + if(part->Pt()Add(part); + iCount++; + } + else if(type == kTrackKineCharged){ + if(part->Particle()->GetPDG()->Charge()==0)continue; + if(part->Pt()Add(part); + iCount++; + } + } + } + else if (type == kTrackAODMCCharged || type == kTrackAODMCAll || type == kTrackAODMCChargedAcceptance) { + AliAODEvent *aod = 0; + if(fUseAODMCInput)aod = dynamic_cast(InputEvent()); + else aod = AODEvent(); + if(!aod)return iCount; + TClonesArray *tca = dynamic_cast(aod->FindListObject(AliAODMCParticle::StdBranchName())); + if(!tca)return iCount; + for(int it = 0;it < tca->GetEntriesFast();++it){ + AliAODMCParticle *part = (AliAODMCParticle*)(tca->At(it)); + if(!part->IsPhysicalPrimary())continue; + if(type == kTrackAODMCAll){ + if(part->Pt()Add(part); + iCount++; + } + else if (type == kTrackAODMCCharged || type == kTrackAODMCChargedAcceptance ){ + if(part->Charge()==0)continue; + if(part->Pt()Add(part); + } + else { + if(TMath::Abs(part->Eta())>fTrackEtaWindow)continue; + list->Add(part); + } + iCount++; + } + } + }// AODMCparticle + list->Sort(); + return iCount; +} + +/* +Int_t AliAnalysisTaskJetCluster::AddParticlesFastJet(TList &particles,vector &inputParticles){ + for(int i = 0; i < particles.GetEntries(); i++){ + AliVParticle *vp = (AliVParticle*)particles.At(i); + // Carefull energy is not well determined in real data, should not matter for p_T scheme? + fastjet::PseudoJet jInp(vp->Px(),vp->Py(),vp->Pz(),vp->E()); + jInp.set_user_index(i); + inputParticles.push_back(jInp); + } + + return 0; + +} +*/ diff --git a/JETAN/DEV/AliAnalysisTaskJetCluster.h b/JETAN/DEV/AliAnalysisTaskJetCluster.h new file mode 100644 index 00000000000..93d7b27b759 --- /dev/null +++ b/JETAN/DEV/AliAnalysisTaskJetCluster.h @@ -0,0 +1,252 @@ +#ifndef ALIANALYSISTASKJETCLUSTER_H +#define ALIANALYSISTASKJETCLUSTER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +// ************************************** +// task used for comparing different jets D parmaters from fastjet +// ******************************************* + +#include "AliAnalysisTaskSE.h" +#include "THnSparse.h" // cannot forward declare ThnSparseF +#include "fastjet/ClusterSequenceArea.hh" +#include "fastjet/AreaDefinition.hh" +#include "fastjet/JetDefinition.hh" +#include "fastjet/PseudoJet.hh" + +//////////////// +class AliJetHeader; +class AliESDEvent; +class AliAODEvent; +class AliAODExtension; +class AliAODJet; +class AliGenPythiaEventHeader; +class AliCFManager; +class AliAODJetEventBackground; +class AliJetFinder; +class TList; +class TChain; +class TH2F; +class TH1F; +class TH3F; +class TProfile; +class TRandom3; +class TRefArray; +class TClonesArray; + +class AliAnalysisTaskJetCluster : public AliAnalysisTaskSE +{ + public: + AliAnalysisTaskJetCluster(); + AliAnalysisTaskJetCluster(const char* name); + virtual ~AliAnalysisTaskJetCluster(); + // Implementation of interface methods + virtual void UserCreateOutputObjects(); + virtual void Init(); + virtual void LocalInit() { Init(); } + virtual void UserExec(Option_t *option); + virtual void Terminate(Option_t *option); + virtual Bool_t Notify(); + + + + virtual void SetAODTrackInput(Bool_t b){fUseAODTrackInput = b;} + virtual void SetAODMCInput(Bool_t b){fUseAODMCInput = b;} + virtual void SetEventSelection(Bool_t b){fEventSelection = b;} + virtual void SetRecEtaWindow(Float_t f){fRecEtaWindow = f;} + virtual void SetTrackEtaWindow(Float_t f){fTrackEtaWindow = f;} + virtual void SetTrackTypeGen(Int_t i){fTrackTypeGen = i;} + virtual void SetTrackTypeRec(Int_t i){fTrackTypeRec = i;} + virtual void SetTrackPtCut(Float_t x){fTrackPtCut = x;} + virtual void SetCentralityCut(Float_t xLo,Float_t xUp){fCentCutLo = xLo; fCentCutUp = xUp;} + virtual void SetFilterMask(UInt_t i,Int_t iType = 0){fFilterMask = i; + fFilterType = iType;} + virtual void SetJetTypes(UInt_t i){fJetTypes = i;} + virtual void SetJetTriggerPtCut(Float_t x){fJetTriggerPtCut = x;} + virtual void SetVtxCuts(Float_t z,Float_t r = 1){fVtxZCut = z; fVtxR2Cut = r *r;} + virtual void SetBackgroundBranch(const char* c){fBackgroundBranch = c;} + virtual const char* GetBackgroundBranch(){return fBackgroundBranch.Data();} + virtual void SetNSkipLeadingRan(Int_t x){fNSkipLeadingRan = x;} + virtual void SetNSkipLeadingCone(Int_t x){fNSkipLeadingCone = x;} + virtual void SetNRandomCones(Int_t x){fNRandomCones = x;} + + virtual void SetJetOutputBranch(const char *c){fNonStdBranch = c;} + virtual const char* GetJetOutputBranch(){return fNonStdBranch.Data();} + virtual void SetJetOutputFile(const char *c){fNonStdFile = c;} + virtual const char* GetJetOutputFile(){return fNonStdFile.Data();} + virtual void SetMaxTrackPtInJet(Float_t x){fMaxTrackPtInJet = x;} + virtual void SetJetOutputMinPt(Float_t x){fJetOutputMinPt = x;} + virtual void SetBackgroundCalc(Bool_t b){fUseBackgroundCalc = b;} + + + + // for Fast Jet + fastjet::JetAlgorithm GetAlgorithm() const {return fAlgorithm;} + fastjet::Strategy GetStrategy() const {return fStrategy;} + fastjet::RecombinationScheme GetRecombScheme() const {return fRecombScheme;} + fastjet::AreaType GetAreaType() const {return fAreaType;} + // Setters + void SetRparam(Double_t f) {fRparam = f;} + void SetAlgorithm(fastjet::JetAlgorithm f) {fAlgorithm = f;} + void SetStrategy(fastjet::Strategy f) {fStrategy = f;} + void SetRecombScheme(fastjet::RecombinationScheme f) {fRecombScheme = f;} + void SetAreaType(fastjet::AreaType f) {fAreaType = f;} + void SetGhostArea(Double_t f) {fGhostArea = f;} + void SetActiveAreaRepeats(Int_t f) {fActiveAreaRepeats = f;} + void SetGhostEtamax(Double_t f) {fGhostEtamax = f;} + + + + // Helper + // + + // we have different cases + // AOD reading -> MC from AOD + // ESD reading -> MC from Kinematics + // this has to match with our selection of input events + enum {kTrackUndef = 0, kTrackAOD, kTrackKineAll,kTrackKineCharged, kTrackAODMCAll, kTrackAODMCCharged, kTrackAODMCChargedAcceptance, kTrackAODextra, kTrackAODextraonly}; + enum {kMaxJets = 4}; + enum {kMaxCorrelation = 3}; + enum {kMaxRadius = 5}; + enum {kMaxCent = 4}; + enum {kJet = 1<<0, + kJetRan = 1<<1, + kRC = 1<<2, + kRCRan = 1<<3 + }; + + + private: + + AliAnalysisTaskJetCluster(const AliAnalysisTaskJetCluster&); + AliAnalysisTaskJetCluster& operator=(const AliAnalysisTaskJetCluster&); + + Int_t GetListOfTracks(TList *list,Int_t type); + + AliAODEvent *fAOD; // ! where we take the jets from can be input or output AOD + AliAODExtension *fAODExtension; // ! AOD extension in case we write a non-sdt branch to a separate file and the aod is standard + TRefArray *fRef; // ! trefarray for track references within the jet + Bool_t fUseAODTrackInput; // take track from input AOD not from ouptu AOD + Bool_t fUseAODMCInput; // take MC from input AOD not from ouptu AOD + Bool_t fUseBackgroundCalc; // switches on background calculations + Bool_t fEventSelection; // use the event selection of this task, otherwise analyse all + UInt_t fFilterMask; // filter bit for slecected tracks + UInt_t fFilterType; // filter type 0 = all, 1 = ITSTPC, 2 = TPC + UInt_t fJetTypes; // 1<<0 regular jets, 1<<1 << randomized event 1<<2 random cones 1<<3 random cones randomiuzed evetn + Int_t fTrackTypeRec; // type of tracks used for FF + Int_t fTrackTypeGen; // type of tracks used for FF + Int_t fNSkipLeadingRan; // number of leading tracks to be skipped in the randomized event + Int_t fNSkipLeadingCone; // number of leading jets to be for the random cones + Int_t fNRandomCones; // number of generated random cones + Float_t fAvgTrials; // Average nimber of trials + Float_t fExternalWeight; // external weight + Float_t fTrackEtaWindow; // eta window used for corraltion plots between rec and gen + Float_t fRecEtaWindow; // eta window used for corraltion plots between rec and gen + Float_t fTrackPtCut; // minimum track pt to be accepted + Float_t fJetOutputMinPt; // minimum p_t for jets to be written out + Float_t fMaxTrackPtInJet; // maximum track pt within a jet for flagging... + Float_t fJetTriggerPtCut; // minimum jwt pT for AOD to be written + Float_t fVtxZCut; // zvtx cut + Float_t fVtxR2Cut; // R vtx cut (squared) + Float_t fCentCutUp; // upper limit on centrality + Float_t fCentCutLo; // lower limit on centrality + // output configurartion + TString fNonStdBranch; // the name of the non-std branch name, if empty no branch is filled + TString fBackgroundBranch; // name of the branch used for background subtraction + TString fNonStdFile; // The optional name of the output file the non-std brnach is written to + + + // Fast jet + Double_t fRparam; + fastjet::JetAlgorithm fAlgorithm; //fastjet::kt_algorithm + fastjet::Strategy fStrategy; //= fastjet::Best; + fastjet::RecombinationScheme fRecombScheme; // = fastjet::BIpt_scheme; + fastjet::AreaType fAreaType; + Double_t fGhostArea; + Int_t fActiveAreaRepeats; + Double_t fGhostEtamax; + + TClonesArray *fTCAJetsOut; //! TCA of output jets + TClonesArray *fTCAJetsOutRan; //! TCA of output jets in randomized event + TClonesArray *fTCARandomConesOut; //! TCA of output jets in randomized event + TClonesArray *fTCARandomConesOutRan; //! TCA of output jets in randomized event + AliAODJetEventBackground *fAODJetBackgroundOut; //! jet background to be written out + + TRandom3* fRandom; //! random number generator + TProfile* fh1Xsec; //! pythia cross section and trials + TH1F* fh1Trials; //! trials are added + TH1F* fh1PtHard; //! Pt har of the event... + TH1F* fh1PtHardNoW; //! Pt har of the event without weigt + TH1F* fh1PtHardTrials; //! Number of trials + + TH1F* fh1NJetsRec; //! number of reconstructed jets + TH1F* fh1NConstRec;//! number of constiutens in leading jet + TH1F* fh1NConstLeadingRec;//! number of constiutens in leading jet + TH1F* fh1PtJetsRecIn; //! Jet pt for all jets + TH1F* fh1PtJetsLeadingRecIn; //! Jet pt for all jets + TH1F* fh1PtJetConstRec;//! pt of constituents + TH1F* fh1PtJetConstLeadingRec;// pt of constituents + TH1F* fh1PtTracksRecIn; //! track pt for all tracks + TH1F* fh1PtTracksLeadingRecIn; //! track pt for all tracks + + // Randomized track histos + TH1F* fh1NJetsRecRan; //! number of reconstructed jets from randomized + TH1F* fh1NConstRecRan;//! number of constiutens in leading jet + TH1F* fh1PtJetsLeadingRecInRan; //! Jet pt for all jets + TH1F* fh1NConstLeadingRecRan;//! number of constiutens in leading jet + TH1F* fh1PtJetsRecInRan; //! Jet pt for all jets + + TH1F* fh1PtTracksGenIn; //! track pt for all tracks + TH1F* fh1Nch; //! charged particle mult + TH1F* fh1BiARandomCones[3]; //! Residual distribtion from reandom cones on real event + TH1F* fh1BiARandomConesRan[3]; //! Residual distribtion from reandom cones on random event + TH1F* fh1CentralityPhySel; // ! centrality of anaylsed events + TH1F* fh1Centrality; // ! centrality of anaylsed events + TH1F* fh1CentralitySelect; // ! centrality of selected events + TH1F* fh1ZPhySel; // ! centrality of anaylsed events + TH1F* fh1Z; // ! centrality of anaylsed events + TH1F* fh1ZSelect; // ! centrality of selected events + + + TH2F* fh2NRecJetsPt; //! Number of found jets above threshold + TH2F* fh2NRecTracksPt; //! Number of found tracks above threshold + TH2F* fh2NConstPt; //! number of constituents vs. pt + TH2F* fh2NConstLeadingPt; //! number of constituents vs. pt + TH2F* fh2JetPhiEta; //! jet phi eta + TH2F* fh2LeadingJetPhiEta; //! leading jet phi eta + TH2F* fh2JetEtaPt; //! leading jet eta + TH2F* fh2LeadingJetEtaPt; //! leading jet eta + TH2F* fh2TrackEtaPt; //! track eta + TH2F* fh2LeadingTrackEtaPt; //! leading track eta + TH2F* fh2JetsLeadingPhiEta; //! jet phi eta + TH2F* fh2JetsLeadingPhiPt; //! jet correlation with leading jet + TH2F* fh2TracksLeadingPhiEta; //! track correlation with leading track + TH2F* fh2TracksLeadingPhiPt; //! track correlation with leading track + TH2F* fh2TracksLeadingJetPhiPt; //! track correlation with leading Jet + TH2F* fh2JetsLeadingPhiPtW; //! jet correlation with leading jet + TH2F* fh2TracksLeadingPhiPtW; //! track correlation with leading track + TH2F* fh2TracksLeadingJetPhiPtW; //! track correlation with leading Jet + TH2F* fh2NRecJetsPtRan; //! Number of found jets above threshold + TH2F* fh2NConstPtRan; //! number of constituents vs. pt + TH2F* fh2NConstLeadingPtRan; //! number of constituents vs. pt + TH2F* fh2PtNch; //! p_T of cluster vs. multiplicity, + TH2F* fh2PtNchRan; //! p_T of cluster vs. multiplicity,random + TH2F* fh2PtNchN; //! p_T of cluster vs. multiplicity, weigthed with constituents + TH2F* fh2PtNchNRan; //! p_T of cluster vs. multiplicity, weigthed with constituents random + TH2F* fh2TracksLeadingJetPhiPtRan; //! track correlation with leading Jet + TH2F* fh2TracksLeadingJetPhiPtWRan; //! track correlation with leading Jet + + + TH2F* fh2JetsLeadingPhiPtC[kMaxCent]; //! jet correlation with leading jet + TH2F* fh2JetsLeadingPhiPtWC[kMaxCent]; //! jet correlation with leading jet + TH2F* fh2TracksLeadingJetPhiPtC[kMaxCent]; //! track correlation with leading Jet + TH2F* fh2TracksLeadingJetPhiPtWC[kMaxCent]; //! track correlation with leading Jet + + TList *fHistList; //!leading tracks to be skipped in the randomized event Output list + + + ClassDef(AliAnalysisTaskJetCluster, 20) +}; + +#endif diff --git a/JETAN/DEV/AliAnalysisTaskJetsFinder.cxx b/JETAN/DEV/AliAnalysisTaskJetsFinder.cxx new file mode 100644 index 00000000000..a15cd713afc --- /dev/null +++ b/JETAN/DEV/AliAnalysisTaskJetsFinder.cxx @@ -0,0 +1,308 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +//---------------------------------------------------------------- +// Analysis task for interfacing the jet finders with the analysis framework +// +// Author: magali.estienne@subatech.in2p3.fr +// alexandre.shabetai@cern.ch +// +//---------------------------------------------------------------- + +#include +#include +#include +#include +#include +#include +#include + +#include "AliAnalysisTaskJetsFinder.h" +#include "AliAnalysisManager.h" +#include "AliJetFinder.h" +#include "AliJetHeader.h" +#include "AliJetHistos.h" +#include "AliAODEvent.h" +#include "AliAODJetEventBackground.h" +#include "AliAODHandler.h" +#include "AliAODExtension.h" + +ClassImp(AliAnalysisTaskJetsFinder) + +//////////////////////////////////////////////////////////////////////// + +AliAnalysisTaskJetsFinder::AliAnalysisTaskJetsFinder(): + AliAnalysisTaskSE(), + fConfigFile("ConfigJetAnalysis.C"), + fNonStdBranch(""), + fNonStdFile(""), + fJetFinder(0x0), + fHistos(0x0), + fAODExtension(0x0), + fListOfHistos(0x0), + fTreeI(0x0), + fEvent(0x0), + fUseAODBackground(kFALSE), + fFilterPt(0.) +{ + // Default constructor +} + +//---------------------------------------------------------------- +AliAnalysisTaskJetsFinder::AliAnalysisTaskJetsFinder(const char* name): + AliAnalysisTaskSE(name), + fConfigFile("ConfigJetAnalysis.C"), + fNonStdBranch(""), + fNonStdFile(""), + fJetFinder(0x0), + fHistos(0x0), + fAODExtension(0x0), + fListOfHistos(0x0), + fTreeI(0x0), + fEvent(0x0), + fUseAODBackground(kFALSE), + fFilterPt(0.) +{ + // Constructor 2 + DefineInput(1, TTree::Class()); + DefineOutput(1, TList::Class()); + +} + +//---------------------------------------------------------------- +AliAnalysisTaskJetsFinder::~AliAnalysisTaskJetsFinder() +{ + // destructor + if (fHistos && ! AliAnalysisManager::GetAnalysisManager()->IsProofMode()) delete fHistos; + if (fListOfHistos && ! AliAnalysisManager::GetAnalysisManager()->IsProofMode()) delete fListOfHistos; + +} + +//---------------------------------------------------------------- +void AliAnalysisTaskJetsFinder::ConnectInputData(Option_t *) +{ + // Get the exchanged tree and event + AliAnalysisTaskSE::ConnectInputData(); + + fTreeI = (TTree*)GetInputData(1); + + char **address =(char **)GetBranchAddress(1,"AliJetCalTrkEvent"); + if (address) { + fEvent = (AliJetCalTrkEvent*) (*address); + } + else { printf("AliJetCalTrkEvent address not found, pleae check containers"); } + +} + +//---------------------------------------------------------------- +void AliAnalysisTaskJetsFinder::UserCreateOutputObjects() +{ + // Create the output container containt + // + if (fDebug > 1) printf("AnalysisTaskJets::CreateOutPutData() \n"); + + AliJetHeader *fH = fJetFinder->GetJetHeader(); + + if(fNonStdBranch.Length()==0) + { + // Connect default AOD to jet finder + // create a new branch for the background + + if(fUseAODBackground){ + if(!AODEvent()->FindListObject(AliAODJetEventBackground::StdBranchName())){ + AliAODJetEventBackground* evBkg = new AliAODJetEventBackground(); + evBkg->SetName(AliAODJetEventBackground::StdBranchName()); + AddAODBranch("AliAODJetEventBackground",&evBkg); + } + } + fJetFinder->ConnectAOD(AODEvent()); + } + else + { + // Create a new branch for jets... + // how is this reset? -> cleared in the UserExec.... + // Can this be handled by the framework? + // here we can also have the case that the brnaches are written to a separate file + + TClonesArray *tca = new TClonesArray("AliAODJet", 0); + tca->SetName(fNonStdBranch.Data()); + AddAODBranch("TClonesArray",&tca,fNonStdFile.Data()); + if(fUseAODBackground){ + if(!AODEvent() || !AODEvent()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()))){ + AliAODJetEventBackground* evBkg = new AliAODJetEventBackground(); + evBkg->SetName(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data())); + AddAODBranch("AliAODJetEventBackground",&evBkg,fNonStdFile.Data()); + } + } + if(fNonStdFile.Length()!=0){ + // + // case that we have an AOD extension we need to fetch the jets from the extended output + // we identifay the extension aod event by looking for the branchname + AliAODHandler *aodH = dynamic_cast(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()); + fAODExtension = 0; + if(aodH){ + TObjArray* extArray = aodH->GetExtensions(); + if (extArray) { + TIter next(extArray); + while ((fAODExtension=(AliAODExtension*)next())){ + TObject *obj = fAODExtension->GetAOD()->FindListObject(fNonStdBranch.Data()); + if(fDebug>10){ + Printf("%s:%d Dumping..",(char*)__FILE__,__LINE__); + fAODExtension->GetAOD()->Dump(); + } + if(obj){ + if(fDebug>1)Printf("AODExtension found for %s",fNonStdBranch.Data()); + break; + } + fAODExtension = 0; + } + } + } + if(fAODExtension)fJetFinder->ConnectAODNonStd(fAODExtension->GetAOD(), fNonStdBranch.Data()); + } + else{ + if (fDebug > 1) printf("Connecting Non Std Branch AOD %p %s \n",AODEvent(),fNonStdBranch.Data()); + fJetFinder->ConnectAODNonStd(AODEvent(), fNonStdBranch.Data()); + } + } + + // do not add the histograms in the directory + // all handled by the list + Bool_t oldStatus = TH1::AddDirectoryStatus(); + TH1::AddDirectory(kFALSE); + + // Histograms + fListOfHistos = new TList(); + fListOfHistos->SetOwner(); + fHistos = new AliJetHistos(); + fHistos->CreateHistos(); + fHistos->AddHistosToList(fListOfHistos); + // CDF case + if(fJetFinder->InheritsFrom("AliCdfJetFinder")) fJetFinder->CreateOutputObjects(fListOfHistos); + + // Add the JetFinderInformation to the Outputlist + + // Compose a characteristic output name + // with the name of the output branch + if(fH) { + if(fNonStdBranch.Length()==0) { + fH->SetName("AliJetHeader_jets"); + } + else { + fH->SetName(Form("AliJetHeader_%s",fNonStdBranch.Data())); + } + } + + TH1::AddDirectory(oldStatus); + + if(!fAODExtension)OutputTree()->GetUserInfo()->Add(fH); + else fAODExtension->GetTree()->GetUserInfo()->Add(fH); + + // post + PostData(1, fListOfHistos); + +} + +//---------------------------------------------------------------- +void AliAnalysisTaskJetsFinder::Init() +{ + // Initialization + if (fDebug > 1) printf("AnalysisTaskJetsFinder::Init() \n"); + + // Call configuration file + if (fConfigFile.Length()) { + gROOT->LoadMacro(fConfigFile); + fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()"); + } + + // Initialise Jet Analysis + fJetFinder->Init(); + +} + + +//---------------------------------------------------------------- +Bool_t AliAnalysisTaskJetsFinder::Notify() +{ + if (fDebug > 1) printf("AnalysisTaskJetsFinder::Notify() \n"); + return kTRUE; + +} + +//---------------------------------------------------------------- +void AliAnalysisTaskJetsFinder::UserExec(Option_t */*option*/) +{ + + // Execute analysis for current event + + if (fDebug > 1) printf("AnalysisTaskJetsFinder::UserExec() \n"); + + TClonesArray* jarray = 0; + AliAODJetEventBackground* evBkg = 0; + + // only need this once + static AliAODHandler *aodH = dynamic_cast(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()); + + if(fNonStdBranch.Length()==0) { + jarray = AODEvent()->GetJets(); + if(fUseAODBackground){ + evBkg = (AliAODJetEventBackground*)(AODEvent()->FindListObject(AliAODJetEventBackground::StdBranchName())); + evBkg->Reset(); + } + } + else { + if(AODEvent())jarray = (TClonesArray*)(AODEvent()->FindListObject(fNonStdBranch.Data())); + if(!jarray)jarray = (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(fNonStdBranch.Data())); + if(jarray)jarray->Delete(); // this is our responsibility, clear before filling again + if(fUseAODBackground){ + if(AODEvent())evBkg = (AliAODJetEventBackground*)(AODEvent()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()))); + if(!evBkg) evBkg = (AliAODJetEventBackground*)(fAODExtension->GetAOD()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()))); + if(evBkg)evBkg->Reset(); + } + } + + fTreeI->GetEntry(0); + + fJetFinder->SetCalTrkEvent(*fEvent); + + fJetFinder->ProcessEvent(); + + // Fill control histos + if(jarray)fHistos->FillHistos(jarray); + + // Store the jet branch in the AOD + if(jarray&&aodH&&fFilterPt>0){ + if(jarray->GetEntries()>0){ + AliAODJet *jet = (AliAODJet*)jarray->At(0); + if(jet->Pt()>fFilterPt){ + aodH->SetFillAOD(kTRUE); + } + } + } + + // Post the data + PostData(1, fListOfHistos); + return; + +} + +//---------------------------------------------------------------- +void AliAnalysisTaskJetsFinder::Terminate(Option_t */*option*/) +{ + // Terminate analysis + if (fDebug > 1) printf("AnalysisJets: Terminate() \n"); + +} + diff --git a/JETAN/DEV/AliAnalysisTaskJetsFinder.h b/JETAN/DEV/AliAnalysisTaskJetsFinder.h new file mode 100644 index 00000000000..6d0540efb81 --- /dev/null +++ b/JETAN/DEV/AliAnalysisTaskJetsFinder.h @@ -0,0 +1,67 @@ +#ifndef ALIANALYSISTASKJETSFINDER_H +#define ALIANALYSISTASKJETSFINDER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +//---------------------------------------------------------------- +// Analysis task for interfacing the jet finders with the analysis framework +// +// Author: magali.estienne@subatech.in2p3.fr +// alexandre.shabetai@cern.ch +//---------------------------------------------------------------- + +#include "AliAnalysisTaskSE.h" +#include "AliJetCalTrk.h" + +class AliJetFinder; +class AliJetHistos; +class AliAODExtension; +class TTree; +class TString; + +class AliAnalysisTaskJetsFinder : public AliAnalysisTaskSE +{ + public: + AliAnalysisTaskJetsFinder(); + AliAnalysisTaskJetsFinder(const char* name); + virtual ~AliAnalysisTaskJetsFinder(); + // Implementation of interface methods + virtual void UserCreateOutputObjects(); + virtual void Init(); + virtual Bool_t Notify(); + virtual void LocalInit() {Init();} + virtual void ConnectInputData(Option_t *); + virtual void UserExec(Option_t *option); + virtual void SetConfigFile(const char *c) {fConfigFile = c;} + virtual void SetJetFinder(AliJetFinder *finder) {fJetFinder = finder;} + virtual void SetNonStdBranch(const char *c){fNonStdBranch = c;} + virtual const char* GetNonStdBranch(){return fNonStdBranch.Data();} + virtual void SetNonStdOutputFile(const char *c){fNonStdFile = c;} + virtual void SetBookAODBackground(Bool_t b){fUseAODBackground = b;} + virtual void Terminate(Option_t *option); + virtual void SetFilterPt(Float_t f){fFilterPt = f;} + + AliJetFinder* GetJetFinder() {return fJetFinder;} + + private: + AliAnalysisTaskJetsFinder(const AliAnalysisTaskJetsFinder &det); + AliAnalysisTaskJetsFinder &operator=(const AliAnalysisTaskJetsFinder &det); + + TString fConfigFile; // The name of the ConfigFile + TString fNonStdBranch; // The name of the non-std branch name + TString fNonStdFile; // The optional name of the output file the non-std brnach is written to + AliJetFinder* fJetFinder; // Pointer to the jet finder + AliJetHistos* fHistos; //! Histogram manager class + AliAODExtension* fAODExtension; // AOD extension in case we write a non-sdt brnach to a separate file and the aod is standard + TList* fListOfHistos; //! Output list of histograms + TTree* fTreeI; //! Input Tree + AliJetCalTrkEvent* fEvent; //! Pointer to jet input objects + Bool_t fUseAODBackground; // Decide wether we book the backround branch or not + Float_t fFilterPt; // Use this as a switch for writing the AOD, minium p_T of leading jet + + ClassDef(AliAnalysisTaskJetsFinder, 1) // Jet Finder Analysis task + +}; + +#endif diff --git a/JETAN/DEV/AliAnalysisTaskJetsReader.cxx b/JETAN/DEV/AliAnalysisTaskJetsReader.cxx new file mode 100644 index 00000000000..139256bd189 --- /dev/null +++ b/JETAN/DEV/AliAnalysisTaskJetsReader.cxx @@ -0,0 +1,151 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//---------------------------------------------------------------- +// Analysis task for interfacing the jet reader with the analysis framework +// +// Author: magali.estienne@subatech.in2p3.fr +// alexandre.shabetai@cern.ch +//---------------------------------------------------------------- + +#include +#include +#include +#include + +#include "AliAnalysisTaskJetsReader.h" +#include "AliAnalysisManager.h" +#include "AliJetReader.h" +#include "AliAODEvent.h" +#include "AliMCEvent.h" +#include "AliJetCalTrk.h" + +ClassImp(AliAnalysisTaskJetsReader) + +//////////////////////////////////////////////////////////////////////// + +AliAnalysisTaskJetsReader::AliAnalysisTaskJetsReader(): + AliAnalysisTaskSE(), + fConfigFile("ConfigJetReaderAnalysis.C"), + fJetReader(0x0), + fReadAODFromOutput(0), + fReaderEvent(0x0), + fExchangeTree(0x0) +{ + // Default constructor +} + +//---------------------------------------------------------------- +AliAnalysisTaskJetsReader::AliAnalysisTaskJetsReader(const char* name): + AliAnalysisTaskSE(name), + fConfigFile("ConfigJetReaderAnalysis.C"), + fJetReader(0x0), + fReadAODFromOutput(0), + fReaderEvent(0x0), + fExchangeTree(0x0) +{ + // Default constructor + DefineOutput(1, TTree::Class()); + +} + +//---------------------------------------------------------------- +AliAnalysisTaskJetsReader::~AliAnalysisTaskJetsReader() +{ + // Destructor + + if (fExchangeTree) + delete fExchangeTree; + +} + +//---------------------------------------------------------------- +void AliAnalysisTaskJetsReader::UserCreateOutputObjects() +{ + // Create the TTree to be exchanged between the reader and finder + // + + if (fDebug > 1) printf("AnalysisTaskJetsReader::CreateOutPutData() \n"); + + fExchangeTree = new TTree("jets_ExchangeContainer","ExchangeTree"); + + fJetReader->InitTasks(); + + fReaderEvent = fJetReader->GetCalTrkEvent(); + + fExchangeTree->Branch("AliJetCalTrkEvent", &fReaderEvent); + + PostData(1, fExchangeTree); + +} + +//---------------------------------------------------------------- +void AliAnalysisTaskJetsReader::Init() +{ + // Initialization + if (fDebug > 1) printf("AnalysisTaskJets::Init() \n"); + + // Call configuration file + if (fConfigFile.Length()) { + gROOT->LoadMacro(fConfigFile); + fJetReader = (AliJetReader*) gInterpreter->ProcessLine("ConfigJetReaderAnalysis()"); + } + +} + +//---------------------------------------------------------------- +void AliAnalysisTaskJetsReader::UserExec(Option_t */*option*/) +{ + + // Execute analysis for current event + // + + // Clear current CalTrkEvent + fReaderEvent->Clear(); + + fExchangeTree->Reset(); + + // Give InputEvent to the reader + if (dynamic_cast(InputEvent()) != 0 && !fReadAODFromOutput) { + // AOD is input event..........................................V + fJetReader->SetInputEvent(InputEvent(), InputEvent(), MCEvent()); + } else { + // AOD is read from output ....................................V + fJetReader->SetInputEvent(InputEvent(), AODEvent(), MCEvent()); + } + + // Process current event + fJetReader->ProcessEvent(); + + // Fill object to be exchanged between reader and finder tasks + fExchangeTree->Fill(); + + // Post the data + PostData(1, fExchangeTree); + + return; + +} + +//---------------------------------------------------------------- +void AliAnalysisTaskJetsReader::Terminate(Option_t */*option*/) +{ + // Terminate analysis + if (fDebug > 1) printf("AnalysisJets: Terminate() \n"); + +} + diff --git a/JETAN/DEV/AliAnalysisTaskJetsReader.h b/JETAN/DEV/AliAnalysisTaskJetsReader.h new file mode 100644 index 00000000000..2295b0fa977 --- /dev/null +++ b/JETAN/DEV/AliAnalysisTaskJetsReader.h @@ -0,0 +1,50 @@ +#ifndef ALIANALYSISTASKJETSREADER_H +#define ALIANALYSISTASKJETSREADER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +//---------------------------------------------------------------- +// Analysis task for interfacing the jet reader with the analysis framework +// +// Authors: magali.estienne@subatech.in2p3.fr +// alexandre.shabetai@cern.ch +//---------------------------------------------------------------- + +#include "AliAnalysisTaskSE.h" + +class AliJetReader; +class TTree; +class TString; +class AliJetCalTrkEvent; + +class AliAnalysisTaskJetsReader : public AliAnalysisTaskSE +{ + public: + AliAnalysisTaskJetsReader(); + AliAnalysisTaskJetsReader(const char* name); + virtual ~AliAnalysisTaskJetsReader(); + // Implementation of interface methods + virtual void UserCreateOutputObjects(); + virtual void Init(); + virtual void LocalInit() {Init();} + virtual void UserExec(Option_t *option); + virtual void SetConfigFile(const char *c) {fConfigFile = c;} + virtual void SetJetReader(AliJetReader *reader) {fJetReader = reader;} + virtual void Terminate(Option_t *option); + virtual void ReadAODFromOutput() {fReadAODFromOutput = kTRUE;} + virtual AliJetReader* GetJetReader() {return fJetReader;} + + private: + AliAnalysisTaskJetsReader(const AliAnalysisTaskJetsReader& rd); + AliAnalysisTaskJetsReader& operator = (const AliAnalysisTaskJetsReader& rd); + TString fConfigFile; // The name of the ConfigFile + AliJetReader* fJetReader; // Pointer to the jet finder + Bool_t fReadAODFromOutput; // Force reading of the AOD from the output + AliJetCalTrkEvent* fReaderEvent; //! Pointer to AliJetCalTrkEvent + TTree* fExchangeTree; //! Tree of AliJetCalTrkEvent + + ClassDef(AliAnalysisTaskJetsReader, 1) // Jet reader Analysis task + +}; +#endif diff --git a/JETAN/DEV/AliAnalysisTaskKMeans.cxx b/JETAN/DEV/AliAnalysisTaskKMeans.cxx new file mode 100644 index 00000000000..c47df6f0f5c --- /dev/null +++ b/JETAN/DEV/AliAnalysisTaskKMeans.cxx @@ -0,0 +1,559 @@ +/************************************************************************** + * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ +//--------------------------------------------------------------------------------------- +// Analysis Task that uses the Soft K-Means Algorithm to find clusters in +// the eta-phi space of Minimum Bias. No pt information is used for the clustering. +// +// +// Author: Andreas Morsch (CERN) +// andreas.morsch@cern.ch +//--------------------------------------------------------------------------------------- + + + +#include "TChain.h" +#include "TFile.h" +#include "TTree.h" +#include "TH1F.h" +#include "TH2F.h" +#include "TProfile.h" + +#include "TList.h" +#include "TParticle.h" +#include "TParticlePDG.h" +#include "TProfile.h" +#include "TMath.h" +#include "TRandom.h" +#include "TObjArray.h" + +#include "AliAnalysisTask.h" +#include "AliAnalysisManager.h" + +#include "AliVEvent.h" +#include "AliESDEvent.h" +#include "AliExternalTrackParam.h" +#include "AliStack.h" +#include "AliESDVertex.h" +#include "AliESDInputHandler.h" +#include "AliESDtrackCuts.h" +#include "AliMultiplicity.h" + +#include "AliMCParticle.h" +#include "AliMCEvent.h" +#include "AliAnalysisTaskKMeans.h" +#include "AliTrackReference.h" +#include "AliStack.h" +#include "AliHeader.h" +#include "AliKMeansClustering.h" + + + +ClassImp(AliAnalysisTaskKMeans) + +AliAnalysisTaskKMeans::AliAnalysisTaskKMeans() + : AliAnalysisTaskSE() + ,fK(0) + ,fNMin(0) + ,fHists(0) + ,fH1CEta(0) + ,fH1CPhi(0) + ,fH1CEtaR(0) + ,fH2N1N2(0) + ,fH1Pt(0) + ,fH1PtC(0) + ,fH1PtC1(0) + ,fH1PtC2(0) + ,fH1PtAS(0) + ,fH1PtR(0) + ,fH1SPt(0) + ,fH1SPtC(0) + ,fH1DPhi(0) + ,fH1DR(0) + ,fH1DRR(0) + ,fH2DPhiEta(0) + ,fH2DPhiEtaR(0) + ,fH2DPhiEtaL(0) + ,fH2DPhiEtaLR(0) + ,fH2DPhiEtaC(0) + ,fH2DPhiEtaCR(0) + ,fH1Resp(0) + ,fH1RespR(0) + ,fH2Sigma(0) + ,fH2SigmaR(0) + ,fHDensity(0) + ,fHCSize(0) + ,fHNCluster(0) + ,fHPtDensity(0) + ,fHDPhi(0) + ,fH2EtaPhi(0) + ,fH2REtaPhi(0) + ,fCuts(0) + +{ + // + + // Constructor + // + for (Int_t i=0; i< 10; i++) { + fA[i] = 0; + fB[i] = 0; + } +} + +//________________________________________________________________________ +AliAnalysisTaskKMeans::AliAnalysisTaskKMeans(const char *name) + : AliAnalysisTaskSE(name) + ,fK(0) + ,fNMin(0) + ,fHists(0) + ,fH1CEta(0) + ,fH1CPhi(0) + ,fH1CEtaR(0) + ,fH2N1N2(0) + ,fH1Pt(0) + ,fH1PtC(0) + ,fH1PtC1(0) + ,fH1PtC2(0) + ,fH1PtAS(0) + ,fH1PtR(0) + ,fH1SPt(0) + ,fH1SPtC(0) + ,fH1DPhi(0) + ,fH1DR(0) + ,fH1DRR(0) + ,fH2DPhiEta(0) + ,fH2DPhiEtaR(0) + ,fH2DPhiEtaL(0) + ,fH2DPhiEtaLR(0) + ,fH2DPhiEtaC(0) + ,fH2DPhiEtaCR(0) + ,fH1Resp(0) + ,fH1RespR(0) + ,fH2Sigma(0) + ,fH2SigmaR(0) + ,fHDensity(0) + ,fHCSize(0) + ,fHNCluster(0) + ,fHPtDensity(0) + ,fHDPhi(0) + ,fH2EtaPhi(0) + ,fH2REtaPhi(0) + ,fCuts(0) + +{ + // + // Constructor + // + for (Int_t i=0; i< 10; i++) { + fA[i] = 0; + fB[i] = 0; + } + DefineOutput(1, TList::Class()); +} + +AliAnalysisTaskKMeans::AliAnalysisTaskKMeans(const AliAnalysisTaskKMeans &res) +: AliAnalysisTaskSE(res) + ,fK(0) + ,fNMin(0) + ,fHists(0) + ,fH1CEta(0) + ,fH1CPhi(0) + ,fH1CEtaR(0) + ,fH2N1N2(0) + ,fH1Pt(0) + ,fH1PtC(0) + ,fH1PtC1(0) + ,fH1PtC2(0) + ,fH1PtAS(0) + ,fH1PtR(0) + ,fH1SPt(0) + ,fH1SPtC(0) + ,fH1DPhi(0) + ,fH1DR(0) + ,fH1DRR(0) + ,fH2DPhiEta(0) + ,fH2DPhiEtaR(0) + ,fH2DPhiEtaL(0) + ,fH2DPhiEtaLR(0) + ,fH2DPhiEtaC(0) + ,fH2DPhiEtaCR(0) + ,fH1Resp(0) + ,fH1RespR(0) + ,fH2Sigma(0) + ,fH2SigmaR(0) + ,fHDensity(0) + ,fHCSize(0) + ,fHNCluster(0) + ,fHPtDensity(0) + ,fHDPhi(0) + ,fH2EtaPhi(0) + ,fH2REtaPhi(0) + ,fCuts(0) +{ + // Dummy copy constructor + for (Int_t i=0; i< 10; i++) { + fA[i] = 0; + fB[i] = 0; + } +} + +AliAnalysisTaskKMeans& AliAnalysisTaskKMeans::operator=(const AliAnalysisTaskKMeans& /*trclass*/) +{ + // Dummy assignment operator + return *this; +} + + + +//________________________________________________________________________ +void AliAnalysisTaskKMeans::UserCreateOutputObjects() +{ + // Create histograms + // Called once + fHists = new TList(); + fH1CEta = new TH1F("fH1CEta", "eta distribution of clusters", 90, -1.5, 1.5); + fH1CEtaR = new TH1F("fH1CEtaR", "eta distribution of clusters", 90, -1.5, 1.5); + fH1CPhi = new TH1F("fH1CPhi", "phi distribution of clusters", 157, 0.0, 2. * TMath::Pi()); + fH2N1N2 = new TH2F("fH2N1N2", "multiplicity distribution", 50, 0., 50., 50, 0., 50.); + + fH1Pt = new TH1F("fH1Pt", "pt distribution",50, 0., 10.); + fH1PtC = new TH1F("fH1PtC", "pt distribution",50, 0., 10.); + fH1PtC1 = new TH1F("fH1PtC1", "pt distribution",50, 0., 10.); + fH1PtC2 = new TH1F("fH1PtC2", "pt distribution",50, 0., 10.); + fH1PtAS = new TH1F("fH1PtAS", "pt distribution",50, 0., 10.); + fH1PtR = new TH1F("fH1PtR", "pt distribution",50, 0., 10.); + + fH1SPt = new TH1F("fH1SPt", "sum pt distribution",50, 0., 10.); + fH1SPtC = new TH1F("fH1SPtC", "sum pt distribution",50, 0., 10.); + + fH1DR = new TH1F("fH1DR", "dR distribution", 50, 0., 5.); + fH1DPhi = new TH1F("fH1DPhi", "dPhi distribution", 31, 0., TMath::Pi()); + fH2DPhiEta = new TH2F("fH2DPhiEta","eta phi distribution", 31, 0., TMath::Pi(), 20, 0., 2.); + fH2DPhiEtaR = new TH2F("fH2DPhiEtaR","eta phi distribution", 31, 0., TMath::Pi(), 20, 0., 2.); + fH2DPhiEtaL = new TH2F("fH2DPhiEtaL","eta phi distribution", 31, 0., TMath::Pi(), 20, 0., 2.); + fH2DPhiEtaLR = new TH2F("fH2DPhiEtaLR","eta phi distribution", 31, 0., TMath::Pi(), 20, 0., 2.); + fH2DPhiEtaC = new TH2F("fH2DPhiEtaC","eta phi distribution", 31, 0., TMath::Pi(), 20, 0., 2.); + fH2DPhiEtaCR = new TH2F("fH2DPhiEtaCR","eta phi distribution", 31, 0., TMath::Pi(), 20, 0., 2.); + fH1DRR = new TH1F("fH1DRR", "dR distribution", 50, 0., 5.); + fH1Resp = new TH1F("fH1Resp", "Responsibility", 50, 0., 1.); + fH1RespR = new TH1F("fH1RespR", "Responsibility", 50, 0., 1.); + fH2Sigma = new TH2F("fH2Sigma", "Sigma", 31, 0., TMath::Pi(), 20, 0., 2.); + fH2SigmaR = new TH2F("fH2SigmaR", "Sigma", 31, 0., TMath::Pi(), 20, 0., 2.); + + + fHDensity = new TH1F("fHDensity", "density distribution", 100, 0., 20.); + fHCSize = new TH1F("fHCSize", "cluster size", 20, -0.5, 19.5); + + fHNCluster = new TH1F("fHNCluster", "Number of clusters", 11, -0.5, 10.5); + fHPtDensity = new TH2F("fHPtDensity", "Pt vs density", 100, 0., 20., 50, 0., 10.); + fHDPhi = new TH1F("fHDPhi", "phi correlation", 100, 0., 0.5); + fH2EtaPhi = new TH2F("fH2EtaPhi", "Eta Phi", 200, -1., 1., 628, 0., 2. * TMath::Pi()); + fHists->SetOwner(); + + fHists->Add(fH1CEta); + fHists->Add(fH1CEtaR); + fHists->Add(fH1CPhi); + fHists->Add(fH2N1N2); + fHists->Add(fH1Pt); + fHists->Add(fH1PtR); + fHists->Add(fH1PtC); + fHists->Add(fH1PtC1); + fHists->Add(fH1PtC2); + fHists->Add(fH1PtAS); + fHists->Add(fH1DR); + fHists->Add(fH1SPtC); + fHists->Add(fH1SPt); + fHists->Add(fH1DPhi); + fHists->Add(fH2DPhiEta); + fHists->Add(fH2DPhiEtaR); + fHists->Add(fH2DPhiEtaL); + fHists->Add(fH2DPhiEtaLR); + fHists->Add(fH2DPhiEtaC); + fHists->Add(fH2DPhiEtaCR); + fHists->Add(fH1DRR); + fHists->Add(fH1RespR); + fHists->Add(fH1Resp); + fHists->Add(fH2Sigma); + fHists->Add(fH2SigmaR); + fHists->Add(fHCSize); + fHists->Add(fHDensity); + fHists->Add(fHNCluster); + fHists->Add(fHPtDensity); + fHists->Add(fHDPhi); + fHists->Add(fH2EtaPhi); + // + for (Int_t i = 0; i < 10; i++) { + fA[i] = new AliKMeansResult(i+1); + fB[i] = new AliKMeansResult(i+1); + } +} + +//________________________________________________________________________ +void AliAnalysisTaskKMeans::UserExec(Option_t *) +{ + // Main loop + // Called for each event + Double_t phi [500] = {0}; + Double_t phiR[500] = {0}; + Double_t eta[500] = {0}; + Double_t etaR[500] = {0}; + Double_t pt [500] = {0}; + + if (!fInputEvent) { + Printf("ERROR: fESD not available"); + return; + } + + + Int_t ic = 0; + + // + // Fill eta-phi positions + // + + Double_t ptmax = 0.; + Int_t icmax = -1; + + for (Int_t iTracks = 0; iTracks < fInputEvent->GetNumberOfTracks(); iTracks++) { + AliVParticle* track = fInputEvent->GetTrack(iTracks); + if ((fCuts->AcceptTrack((AliESDtrack*)track))) + { + const AliExternalTrackParam * tpcT = ((AliESDtrack*) track)->GetTPCInnerParam(); + if (!tpcT) continue; + if (TMath::Abs(tpcT->Eta()) > 0.9) continue; + + phi [ic] = tpcT->Phi(); + eta [ic] = tpcT->Eta(); + pt [ic] = tpcT->Pt(); + + if (fH2REtaPhi) { + fH2REtaPhi->GetRandom2(etaR[ic], phiR[ic]); + } else { + phiR[ic] = 2. * TMath::Pi() * gRandom->Rndm(); + etaR[ic] = 1.8 * gRandom->Rndm() - 0.9; + } + + + if (pt[ic] > ptmax) { + ptmax = pt[ic]; + icmax = ic; + } + + fH2EtaPhi->Fill(eta[ic], phi[ic]); + ic++; + } + } //track loop + + for (Int_t i = 0; i < ic; i++) { + for (Int_t j = i+1; j < ic; j++) { + Double_t dphi = TMath::Abs(phi[i] - phi[j]); + fHDPhi->Fill(dphi); + } + } + + // + // Cluster + if (ic < fNMin) { + PostData(1, fHists); + return; + } + + // + Double_t rk0[10]; + AliKMeansResult* res = 0; + AliKMeansResult best(10); + Float_t rmaxG = -1.; + + for (Int_t k = 0; k < 20; k++) { + Float_t rmax = -1.; + Int_t imax = 0; + for (Int_t i = 0; i < fK; i++) { + res = fA[i]; + AliKMeansClustering::SoftKMeans2(i+1, ic, phi, eta, res->GetMx(),res->GetMy(), res->GetSigma2(), res->GetRk()); + res->Sort(ic, phi, eta); + Int_t j = (res->GetInd())[0]; + rk0[i] = (res->GetTarget())[j]; + if (rk0[i] > rmax) { + rmax = rk0[i]; + imax = i; + } + } + if (rmax > rmaxG) { + rmaxG = rmax; + best.CopyResults(fA[imax]); + } + } + Double_t* mPhi = best.GetMx(); + Double_t* mEta = best.GetMy(); + Double_t* sigma2 = best.GetSigma2(); + Int_t nk = best.GetK(); + Int_t im = (best.GetInd())[0]; + Double_t etaC = mEta[im]; + + fHDensity->Fill(rmaxG / TMath::Pi()); + fHCSize->Fill(2.28 * rmaxG * sigma2[im]); + fHNCluster->Fill(Float_t(nk)); + + Double_t dphic, detac; + + if (rmaxG > 0. && TMath::Abs(etaC) < 0.4) { + // Analysis + // + // Cluster Multiplicity + Int_t mult[2] = {0, 0}; + // + if (nk > 1) { + dphic = DeltaPhi(mPhi[0], mPhi[1]); + detac = TMath::Abs(mEta[0] - mEta[1]); + fH2DPhiEtaC->Fill(dphic, detac); + } + // + // Random cluster position + Int_t ir = Int_t(Float_t(ic) * gRandom->Rndm()); + + Double_t crPhi = phi[ir]; + Double_t crEta = eta[ir]; + // + Double_t sumPt = 0; + Double_t sumPtC = 0; + + for (Int_t i = 0; i < 1; i++) { + fH1CEta->Fill(mEta[im]); + fH1CPhi->Fill(mPhi[im]); + for (Int_t j = 0; j < ic; j++) { + Double_t r = DeltaR(mPhi[im], mEta[im], phi[j], eta[j]); + Double_t dphi = DeltaPhi(mPhi[im], phi[j]); + Double_t deta = mEta[im] - eta[j]; + Double_t rr = DeltaR(crPhi, crEta, phi[j], eta[j]); + + fH1DR->Fill(r); + fH1DPhi->Fill(dphi); + fH2DPhiEta->Fill(dphi, TMath::Abs(deta)); + if (j == icmax) fH2DPhiEtaL->Fill(dphi, TMath::Abs(deta)); + + if (r < 0.2) { + fH1PtC2->Fill(pt[j]); + } + if (r < 0.3) { + fH1PtC1->Fill(pt[j]); + fHPtDensity->Fill(rmaxG/TMath::Pi(), pt[j]); + } + if (rr < 0.3) { + fH1PtR->Fill(pt[j]); + } + + if (r < 0.4) { + sumPtC += pt[j]; + mult[i]++; + fH1PtC->Fill(pt[j]); + } + if (r > 0.7 && dphi < (TMath::Pi() - 0.3)) { + fH1Pt->Fill(pt[j]); + } + + if (r > 0.7 && r < 1.) { + sumPt += pt[j]; + } + + if (dphi > (TMath::Pi() - 0.3)) { + fH1PtAS->Fill(pt[j], 1.); + } + } + } + + fH2N1N2->Fill(Float_t(mult[0]), Float_t(mult[1])); + fH1SPt ->Fill(sumPt); + fH1SPtC->Fill(sumPtC); + } + // + // Randomized phi + // + rmaxG = -1.; + for (Int_t k = 0; k < 20; k++) { + Float_t rmax = -1.; + Int_t imax = 0; + for (Int_t i = 0; i < fK; i++) { + res = fB[i]; + AliKMeansClustering::SoftKMeans2(i+1, ic, phiR, etaR, res->GetMx(),res->GetMy(), res->GetSigma2(), res->GetRk()); + res->Sort(ic, phiR, etaR); + Int_t j = (res->GetInd())[0]; + rk0[i] = (res->GetTarget())[j]; + if (rk0[i] > rmax) { + rmax = rk0[i]; + imax = i; + } + } + if (rmax > rmaxG) { + rmaxG = rmax; + best.CopyResults(fB[imax]); + } + } + + mPhi = best.GetMx(); + mEta = best.GetMy(); + nk = best.GetK(); + im = (best.GetInd())[0]; + etaC = mEta[im]; + + // + // Cluster Multiplicity + if (rmaxG > 0. && TMath::Abs(etaC) < 0.4) { + for (Int_t i = 0; i < 1; i++) { + im = (best.GetInd())[i]; + fH1CEtaR->Fill(mEta[im]); + } + + for (Int_t i = 0; i < 1; i++) { + im = (best.GetInd())[i]; + for (Int_t j = 0; j < ic; j++) { + Double_t dphi = DeltaPhi(mPhi[im], phiR[j]); + Double_t deta = mEta[im] - etaR[j]; + Double_t r = DeltaR(mPhi[im], mEta[im], phiR[j], etaR[j]); + fH1DRR->Fill(r); + fH2DPhiEtaR->Fill(dphi, TMath::Abs(deta)); + if (j == icmax) fH2DPhiEtaLR->Fill(dphi, TMath::Abs(deta)); + } + } + if (nk > 1) { + dphic = DeltaPhi(mPhi[0], mPhi[1]); + detac = TMath::Abs(mEta[0] - mEta[1]); + fH2DPhiEtaCR->Fill(dphic, detac); + } + } + PostData(1, fHists); +} + +Double_t AliAnalysisTaskKMeans::DeltaPhi(Double_t phi1, Double_t phi2) +{ + Double_t dphi = TMath::Abs(phi1 - phi2); + if (dphi > TMath::Pi()) dphi = 2. * TMath::Pi() - dphi; + return dphi; +} + +Double_t AliAnalysisTaskKMeans::DeltaR(Double_t phi1, Double_t eta1, Double_t phi2, Double_t eta2) +{ + Double_t dphi = DeltaPhi(phi1, phi2); + Double_t deta = eta1 - eta2; + return (TMath::Sqrt(dphi * dphi + deta * deta)); + +} + +//________________________________________________________________________ +void AliAnalysisTaskKMeans::Terminate(Option_t *) +{ +} + diff --git a/JETAN/DEV/AliAnalysisTaskKMeans.h b/JETAN/DEV/AliAnalysisTaskKMeans.h new file mode 100644 index 00000000000..58116b3806e --- /dev/null +++ b/JETAN/DEV/AliAnalysisTaskKMeans.h @@ -0,0 +1,87 @@ +#ifndef ALIANALYSISTASKKMEANS_H +#define ALIANALYSISTASKKMEANS_H + /* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//------------------------------------------------------------------------- +// Analysis Task that uses the Soft K-Means Algorithm to find clusters in +// the eta-phi space of Minimum Bias. No pt information is used for the clustering. +// +// +// Author: Andreas Morsch (CERN) +// andreas.morsch@cern.ch +//------------------------------------------------------------------------- + +class TH1F; +class TH2F; +class TList; +class TProfile; +class AliESDEvent; +class AliESDtrack; +class AliESDtrackCuts; +class AliKMeansResult; + +#include "AliAnalysisTaskSE.h" + +class AliAnalysisTaskKMeans : public AliAnalysisTaskSE { + public: + AliAnalysisTaskKMeans(); + AliAnalysisTaskKMeans(const char *name); + AliAnalysisTaskKMeans(const AliAnalysisTaskKMeans &res); + AliAnalysisTaskKMeans& operator=(const AliAnalysisTaskKMeans& trclass); + virtual ~AliAnalysisTaskKMeans() {} + virtual void UserCreateOutputObjects(); + virtual void UserExec(Option_t *option); + virtual void Terminate(Option_t *); + virtual void SetCuts(AliESDtrackCuts* cuts) {fCuts = cuts;} + virtual Double_t DeltaPhi(Double_t phi1, Double_t phi2); + virtual Double_t DeltaR(Double_t phi1, Double_t eta1, Double_t phi2, Double_t eta2); + virtual void SetK(Int_t k) {fK = k;} + virtual void SetMinimumMultiplicity(Int_t k) {fNMin = k;} + virtual void SetEtaPhi(TH2F* h2) {fH2REtaPhi = h2;} + private: + // Others + Int_t fK; // K + Int_t fNMin; // Minimum multipicity + TList* fHists; //! Histograms + TH1F* fH1CEta; //! Eta distribution of clusters + TH1F* fH1CPhi; //! Phi distribution of clusters + TH1F* fH1CEtaR; //! Eta distribution of clusters for rndm evnt + TH2F* fH2N1N2; //! Cluster sizes + TH1F* fH1Pt; //! pt outside clusters + TH1F* fH1PtC; //! pt outside clusters + TH1F* fH1PtC1; //! pt dr > 0.4 + TH1F* fH1PtC2; //! pt dr > 0.2 + TH1F* fH1PtAS; //! away-side peak + TH1F* fH1PtR; //! away-side peak + TH1F* fH1SPt; //! sum pt + TH1F* fH1SPtC; //! sum pt + TH1F* fH1DPhi; //! Dphi wr to cluster + TH1F* fH1DR; //! DR wr to cluster + TH1F* fH1DRR; //! DR wr to cluster from rndm events + TH2F* fH2DPhiEta; //! eta-phi wr to cluster + TH2F* fH2DPhiEtaR; //! eta-phi wr to cluster for rndm events + TH2F* fH2DPhiEtaL; //! eta-phi of leading particle + TH2F* fH2DPhiEtaLR; //! eta-phi of leading particle + TH2F* fH2DPhiEtaC; //! eta-phi of Clusters + TH2F* fH2DPhiEtaCR; //! eta-phi of Clusters + TH1F* fH1Resp; //! responsibility + TH1F* fH1RespR; //! responsibility + TH2F* fH2Sigma; //! sigma + TH2F* fH2SigmaR; //! sigma random + TH1F* fHDensity; //! Particle density + TH1F* fHCSize; //! Cluster Size + TH1F* fHNCluster; //! Number of clusters + TH2F* fHPtDensity; //! Pt vs density + TH1F* fHDPhi; //! Phi Correlation + TH2F* fH2EtaPhi; //! eta phi + TH2F* fH2REtaPhi; // eta phi + AliKMeansResult* fA[10]; //! Array of results + AliKMeansResult* fB[10]; //! Array of results + AliESDtrackCuts* fCuts; // List of cuts + ClassDef(AliAnalysisTaskKMeans, 1); // A k-means clustering analysis +}; + +#endif diff --git a/JETAN/DEV/AliCdfJetFinder.cxx b/JETAN/DEV/AliCdfJetFinder.cxx new file mode 100644 index 00000000000..a22e6d277e3 --- /dev/null +++ b/JETAN/DEV/AliCdfJetFinder.cxx @@ -0,0 +1,903 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to usec, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// Jet Finder based on CDF algortihm +// Charged jet evolution and the underlying event in proton-antiproton collisions at 1.8 TeV +// Physical Review D, vol. 65, Issue 9, id. 092002 +// http://www.phys.ufl.edu/~rfield/cdf/chgjet/chgjet_intro.html +// Authors : Adrian.Sevcenco@cern.ch (adriansev@spacescience.ro ) +// Daniel.Felea@cern.ch (dfelea@spacescience.ro) +// Ciprian.Mihai.Mitu@cern.ch (mcm@spacescience.ro) +// magali.estienne@subatech.in2p3.fr & +// alexandre.shabetai@cern.ch (Modification of the input object (reader/finder splitting)) +// ** 2011 +// Modified accordingly to reader/finder splitting and new handling of neutral information +//--------------------------------------------------------------------- + +#include +#include +#include +#include +#include +#include +#include + +#include "AliAODJet.h" +#include "AliJetFinder.h" +#include "AliJetCalTrk.h" +#include "AliCdfJetFinder.h" +#include "AliCdfJetHeader.h" + +ClassImp(AliCdfJetFinder) + +//______________________________________________________________________________ +AliCdfJetFinder::AliCdfJetFinder(): + AliJetFinder(), + fHistos(0), + fAODwrite(0), + fAODtracksWrite(0), + fAnalyseJets(0), + fNJets(0), + fNPart(0), + fNInC(0), + fNInN(0), + fRadius(0.7), + fMinJetParticles(1), + fJetPtCut(0.), + fVectParticle(NULL), + fVectJet(NULL), + fPtArray(NULL), + fIdxArray(NULL) +{ + // Default constructor +} + +//______________________________________________________________________________ +AliCdfJetFinder::~AliCdfJetFinder() +{ + // destructor + Clean(); + +} + +//______________________________________________________________________________ +void AliCdfJetFinder::CreateOutputObjects(TList * const histos) +{ + // Create the list of histograms. Only the list is owned. + fHistos = histos; + + // gStyle->SetOptStat(11111111); + + TH1F *h1 = new TH1F ("histo1", "Pt distribution of jets", 200, 0,200); // 1GeV/bin + h1->SetStats(kTRUE); + h1->GetXaxis()->SetTitle("P_{T} of jets"); + h1->GetYaxis()->SetTitle("Number of jets"); + h1->GetXaxis()->SetTitleColor(1); + h1->SetMarkerStyle(kFullCircle); + fHistos->Add(h1); + + TH1F *h2 = new TH1F ("histo2", "Eta distribution of jets", 240, -1.2,1.2); // 1 unit of rapidity / 100 bin + h2->SetStats(kTRUE); + h2->GetXaxis()->SetTitle("Eta of jets"); + h2->GetYaxis()->SetTitle("Number of jets"); + h2->GetXaxis()->SetTitleColor(1); + h2->SetMarkerStyle(kFullCircle); + fHistos->Add(h2); + + TH1F *h3 = new TH1F ("histo3", "Phi distribution of jets", 400, -4,4); + h3->SetStats(kTRUE); + h3->GetXaxis()->SetTitle("Phi of jets"); + h3->GetYaxis()->SetTitle("Number of jets"); + h3->GetXaxis()->SetTitleColor(1); + h3->SetMarkerStyle(kFullCircle); + fHistos->Add(h3); + + TH1F *h4 = new TH1F ("histo4", "Multiplicity of jets", 40, 0,40); // 1 unit of multiplicity /bin + h4->SetStats(kTRUE); + h4->GetXaxis()->SetTitle("Particles in jets"); + h4->GetYaxis()->SetTitle("Number of jets"); + h4->GetXaxis()->SetTitleColor(1); + h4->SetMarkerStyle(kFullCircle); + fHistos->Add(h4); + + TH1F *h5 = new TH1F ("histo5", "Distribution of jets in events", 100, 0,100); + h5->SetStats(kTRUE); + h5->GetXaxis()->SetTitle("Number of jets"); + h5->GetYaxis()->SetTitle("Number of events"); + h5->GetXaxis()->SetTitleColor(1); + h5->SetMarkerStyle(kFullCircle); + fHistos->Add(h5); + + TH1F *h6 = new TH1F ("histo6", "Jet1 Charged Multiplicity Distribution", 30, 0,30); + h6->SetStats(kTRUE); + h6->GetXaxis()->SetTitle("N_{chg}"); + h6->GetYaxis()->SetTitle("Number of jets"); + h6->GetXaxis()->SetTitleColor(1); + h6->SetMarkerStyle(kFullCircle); + fHistos->Add(h6); + + TProfile * h7 = new TProfile ("histo7","N_{chg}(jet1) vs P_{T}(charged jet1)", 200, 0. ,200. , 0.,200. ) ; + h7->SetStats(kTRUE); + h7->GetXaxis()->SetTitle("P_{T} (charged jet1) (GeV/c)"); + h7->GetYaxis()->SetTitle(" in 1 GeV/c bin"); + h7->GetXaxis()->SetTitleColor(1); + h7->SetMarkerStyle(kFullCircle); + fHistos->Add(h7); + + TH1F *h8 = new TH1F ("histo8", "Charge momentum distribution for leading jet", 120, 0 , 1.2); + h8->SetStats(kTRUE); + h8->GetXaxis()->SetTitle("Jets"); + h8->GetYaxis()->SetTitle("Particle distribution"); + h8->GetXaxis()->SetTitleColor(1); + h8->SetMarkerStyle(kFullCircle); + fHistos->Add(h8); + + TProfile *h9 = new TProfile ("histo9", "N_{chg} vs the Azimuthal Angle from Charged Jet1", 50 , 0. , 180. , 0 , 20 ); + h9->SetStats(kTRUE); + h9->GetXaxis()->SetTitle("#Delta#phi (degrees)"); + h9->GetYaxis()->SetTitle(" in 3.6 degree bin"); + h9->GetXaxis()->SetTitleColor(1); + h9->SetMarkerStyle(kFullCircle); + fHistos->Add(h9); + + TProfile *h10 = new TProfile ("histo10", "P_{T} sum vs the Azimuthal Angle from Charged Jet1", 50 , 0. , 180. , 0 , 100 ); + h10->SetStats(kTRUE); + h10->GetXaxis()->SetTitle("#Delta#phi (degrees)"); + h10->GetYaxis()->SetTitle(" in 3.6 degree bin"); + h10->GetXaxis()->SetTitleColor(1); + h10->SetMarkerStyle(kFullCircle); + fHistos->Add(h10); + + TH1F *h11 = new TH1F ("histo11", " \"Transverse\" Pt Distribution ", 70, 0 , 14); + h11->SetStats(kTRUE); + h11->GetXaxis()->SetTitle("P_{T} (GeV/c)"); + h11->GetYaxis()->SetTitle("dN_{chg}/dP_{T} (1/GeV/c)"); + h11->GetXaxis()->SetTitleColor(1); + h11->SetMarkerStyle(kFullCircle); + fHistos->Add(h11); + + TH1F *h20 = new TH1F ("histo20", "Distribution of R in leading jet", 400, 0.,4.); + h20->SetStats(kTRUE); + h20->GetXaxis()->SetTitle("R [formula]"); + h20->GetYaxis()->SetTitle("dN/dR"); + h20->GetXaxis()->SetTitleColor(1); + h20->SetMarkerStyle(kFullCircle); + fHistos->Add(h20); + + TProfile * h21 = new TProfile ("histo21","N_{chg}(in the event - including jet1) vs P_{T}(charged jet1)", 200, 0., 50. , 0., 30. ) ; + h21->SetStats(kTRUE); + h21->GetXaxis()->SetTitle("P_{T} (charged jet1) (GeV/c)"); + h21->GetYaxis()->SetTitle(" in 1 GeV/c bin"); + h21->GetXaxis()->SetTitleColor(1); + h21->SetMarkerStyle(kFullCircle); + fHistos->Add(h21); + + TProfile * h22 = new TProfile ("histo22","PT_{sum}(in the event - including jet1) vs P_{T}(charged jet1)", 200, 0. , 50. , 0., 50. ) ; + h22->SetStats(kTRUE); + h22->GetXaxis()->SetTitle("P_{T} (charged jet1) (GeV/c)"); + h22->GetYaxis()->SetTitle(" in 1 GeV/c bin"); + h22->GetXaxis()->SetTitleColor(1); + h22->SetMarkerStyle(kFullCircle); + fHistos->Add(h22); + + TProfile * h21Toward = new TProfile ("histo21_toward","N_{chg}(in the event - including jet1) vs P_{T}(charged jet1)", 200, 0., 50. , 0., 12. ) ; + h21Toward->SetStats(kTRUE); + h21Toward->GetXaxis()->SetTitle("P_{T} (charged jet1) (GeV/c)"); + h21Toward->GetYaxis()->SetTitle(" in 1 GeV/c bin"); + h21Toward->GetXaxis()->SetTitleColor(1); + h21Toward->SetMarkerStyle(kFullCircle); + fHistos->Add(h21Toward); + + TProfile * h21Transverse = new TProfile ("histo21_transverse","N_{chg}(in the event - including jet1) vs P_{T}(charged jet1)", 200, 0., 50. , 0., 12. ) ; + h21Transverse->SetStats(kTRUE); + h21Transverse->GetXaxis()->SetTitle("P_{T} (charged jet1) (GeV/c)"); + h21Transverse->GetYaxis()->SetTitle(" in 1 GeV/c bin"); + h21Transverse->GetXaxis()->SetTitleColor(1); + h21Transverse->SetMarkerStyle(kFullCircle); + fHistos->Add(h21Transverse); + + TProfile * h21Away = new TProfile ("histo21_away","N_{chg}(in the event - including jet1) vs P_{T}(charged jet1)", 200, 0., 50. , 0., 12. ) ; + h21Away->SetStats(kTRUE); + h21Away->GetXaxis()->SetTitle("P_{T} (charged jet1) (GeV/c)"); + h21Away->GetYaxis()->SetTitle(" in 1 GeV/c bin"); + h21Away->GetXaxis()->SetTitleColor(1); + h21Away->SetMarkerStyle(kFullCircle); + fHistos->Add(h21Away); + + TProfile * h22Toward = new TProfile ("histo22_toward","PT_{sum}(in the event - including jet1) vs P_{T}(charged jet1)", 200, 0. , 50. , 0., 50. ) ; + h22Toward->SetStats(kTRUE); + h22Toward->GetXaxis()->SetTitle("P_{T} (charged jet1) (GeV/c)"); + h22Toward->GetYaxis()->SetTitle(" in 1 GeV/c bin"); + h22Toward->GetXaxis()->SetTitleColor(1); + h22Toward->SetMarkerStyle(kFullCircle); + fHistos->Add(h22Toward); + + TProfile * h22Transverse = new TProfile ("histo22_transverse","PT_{sum}(in the event - including jet1) vs P_{T}(charged jet1)", 200, 0. , 50. , 0., 50. ) ; + h22Transverse->SetStats(kTRUE); + h22Transverse->GetXaxis()->SetTitle("P_{T} (charged jet1) (GeV/c)"); + h22Transverse->GetYaxis()->SetTitle(" in 1 GeV/c bin"); + h22Transverse->GetXaxis()->SetTitleColor(1); + h22Transverse->SetMarkerStyle(kFullCircle); + fHistos->Add(h22Transverse); + + TProfile * h22Away = new TProfile ("histo22_away","PT_{sum}(in the event - including jet1) vs P_{T}(charged jet1)", 200, 0. , 50. , 0., 50. ) ; + h22Away->SetStats(kTRUE); + h22Away->GetXaxis()->SetTitle("P_{T} (charged jet1) (GeV/c)"); + h22Away->GetYaxis()->SetTitle(" in 1 GeV/c bin"); + h22Away->GetXaxis()->SetTitleColor(1); + h22Away->SetMarkerStyle(kFullCircle); + fHistos->Add(h22Away); + + TH1F *h23Toward = new TH1F ("histo23_toward","'Toward' Pt Distribution of charged particles", 200, 0., 14.); + h23Toward->SetStats(kTRUE); + h23Toward->GetXaxis()->SetTitle("P_{T} (charged) (GeV/c)"); + h23Toward->GetYaxis()->SetTitle("dN_{chg}/dP_{T} (1/GeV/c)"); + h23Toward->GetXaxis()->SetTitleColor(1); + h23Toward->SetMarkerStyle(kFullCircle); + fHistos->Add(h23Toward); + + TH1F *h23Transverse = new TH1F ("histo23_transverse","'Transverse' Pt Distribution of charged particles", 200, 0., 14.); + h23Transverse->SetStats(kTRUE); + h23Transverse->GetXaxis()->SetTitle("P_{T} (charged) (GeV/c)"); + h23Transverse->GetYaxis()->SetTitle("dN_{chg}/dP_{T} (1/GeV/c)"); + h23Transverse->GetXaxis()->SetTitleColor(1); + h23Transverse->SetMarkerStyle(kFullCircle); + fHistos->Add(h23Transverse); + + TH1F *h23Away = new TH1F ("histo23_away","'Away' Pt Distribution of charged particles", 200, 0., 14.); + h23Away->SetStats(kTRUE); + h23Away->GetXaxis()->SetTitle("P_{T} (charged) (GeV/c)"); + h23Away->GetYaxis()->SetTitle("dN_{chg}/dP_{T} (1/GeV/c)"); + h23Away->GetXaxis()->SetTitleColor(1); + h23Away->SetMarkerStyle(kFullCircle); + fHistos->Add(h23Away); + + TProfile * h24 = new TProfile ("histo24","Jet1 Size vs P_{T}(charged jet1)", 200, 0., 50. , 0., 0.5) ; + h24->SetStats(kTRUE); + h24->GetXaxis()->SetTitle("P_{T} (charged jet1) (GeV/c)"); + h24->GetYaxis()->SetTitle(" in 1 GeV/c bin"); + h24->GetXaxis()->SetTitleColor(1); + h24->SetMarkerStyle(kFullCircle); + fHistos->Add(h24); + + TProfile * h25 = new TProfile ("histo25","Jet1 Size vs P_{T}(charged jet1)", 200, 0., 50. , 0., 0.5) ; + h25->SetStats(kTRUE); + h25->GetXaxis()->SetTitle("P_{T} (charged jet1) (GeV/c)"); + h25->GetYaxis()->SetTitle(" in 1 GeV/c bin"); + h25->GetXaxis()->SetTitleColor(1); + h25->SetMarkerStyle(kFullCircle); + fHistos->Add(h25); + + TProfile *h26 = new TProfile ("histo26", "N_{chg} vs the Distance R from Charged Jet1", 30, 0., 0.6, 0., 0.8); + h26->SetStats(kTRUE); + h26->GetXaxis()->SetTitle("Distance R"); + h26->GetYaxis()->SetTitle(" in 0.02 bin"); + h26->GetXaxis()->SetTitleColor(1); + h26->SetMarkerStyle(kFullCircle); + fHistos->Add(h26); + + TProfile *h27 = new TProfile ("histo27", "N_{chg} vs the Distance R from Charged Jet1", 30, 0., 0.6, 0., 0.8); + h27->SetStats(kTRUE); + h27->GetXaxis()->SetTitle("Distance R"); + h27->GetYaxis()->SetTitle(" in 0.02 bin"); + h27->GetXaxis()->SetTitleColor(1); + h27->SetMarkerStyle(kFullCircle); + fHistos->Add(h27); + + TProfile *h28 = new TProfile ("histo28", "PT_{sum} vs the Distance R from Charged Jet1", 30, 0., 0.6, 0.01, 10.); + h28->SetStats(kTRUE); + h28->GetXaxis()->SetTitle("Distance R"); + h28->GetYaxis()->SetTitle(" in 0.02 bin"); + h28->GetXaxis()->SetTitleColor(1); + h28->SetMarkerStyle(kFullCircle); + fHistos->Add(h28); + + TProfile *h29 = new TProfile ("histo29", "PT_{sum} vs the Distance R from Charged Jet1", 30, 0., 0.6, 0.01, 10.); + h29->SetStats(kTRUE); + h29->GetXaxis()->SetTitle("Distance R"); + h29->GetYaxis()->SetTitle(" in 0.02 bin"); + h29->GetXaxis()->SetTitleColor(1); + h29->SetMarkerStyle(kFullCircle); + fHistos->Add(h29); + +} + +//______________________________________________________________________________ +void AliCdfJetFinder::FindJets() +{ + // Jet Algorithm: + // * Order all charged particles according to their PT. + // * Start with the highest PT particle and include in the "jet" all particles within the "radius" R = 0.7 + // (considering each particle in the order of decreasing PT and recalculating the centroid of the jet after + // each new particle is added to the jet). + // * Go to the next highest PT particle (not already included in a jet) and include in the "jet" all particles + // (not already included in a jet) within the radius R =0.7. + // * Continue until all particles are in a "jet". + if (fDebug) { printf("AliCDJetfinder::FindJets() %d \n", __LINE__ ); } + AliCdfJetHeader *header = (AliCdfJetHeader*)fHeader; + + if (header) + { + fDebug = header->GetDebug(); + fAODwrite = header->IsAODwrite() ; // write jets to AOD + fAODtracksWrite = header->IsAODtracksWrite() ; // write jet tracks to AOD + fRadius = header->GetRadius(); // get Radius from jet finder header + fMinJetParticles = header->GetMinPartJet (); // get minimum multiplicity of an jet + fJetPtCut = header->GetJetPtCut (); // get minimum of jet pt + fAnalyseJets = header->GetAnalyseJets(); // get analyse jet + } + else + { cout << "Header not found" << endl; return; } + + InitData(); + + if (!fNPart) { + if (fDebug) { + cout << "entries = 0 ; Event empty !!!" << endl ; + } + // no need to call clean, InitData does not + // create pointers if npart == 0 + return; + } // if event empty then exit + + FindCones(); + + ComputeConesWeight(); + + if (fAODwrite) { + if(fDebug)cout << "Writing AOD" << endl ; + WriteJets(); + } + + if (fAnalyseJets) AnalizeJets(); + + Clean(); + +} + +//______________________________________________________________________________ +void AliCdfJetFinder::InitData() +{ + // initialisation of variables and data members + + if( fHeader->GetDebug() && fCalTrkEvent->GetNCalTrkTracks() == 0) { cout << "No charged tracks found" << endl; } + + fNPart = fCalTrkEvent->GetNCalTrkTracks() ; + + if ( fCalTrkEvent->GetNCalTrkTracks() ) { return; } // if event empty then exit + + fVectParticle = new varContainer* [fNPart]; // container for Particles + + fPtArray = new Double_t [fCalTrkEvent->GetNCalTrkTracks()] ; + fIdxArray = new Int_t [fCalTrkEvent->GetNCalTrkTracks()] ; // index array of sorted pts + + // initialisation of momentum and index arrays + for ( Int_t i = 0 ; i GetNCalTrkTracks() ; i++ ) + {// SORTING STEP :: fPtArray with data from CalTrkTracks + + // INITIALISATION of local arrays for temporary storage + varContainer *aParticle = new varContainer; + aParticle->pt = fCalTrkEvent->GetCalTrkTrack(i)->GetPt(); + aParticle->eta = fCalTrkEvent->GetCalTrkTrack(i)->GetEta(); + aParticle->phi = TVector2::Phi_mpi_pi ( fCalTrkEvent->GetCalTrkTrack(i)->GetPhi() ); // normalize to -pi,pi + aParticle->njet = -999; + + fVectParticle[i] = aParticle; // vector of Particles + + // initializing arrays + fIdxArray [i] = -999 ; + fPtArray [i] = aParticle->pt ; + } + + TMath::Sort ( fNPart, fPtArray, fIdxArray ) ; // get a sorted array of indexes + +} + +//______________________________________________________________________________ +void AliCdfJetFinder::FindCones() +{ + // parsing of particles in event and estlabish jets (label them with jet index) + + Double_t ptSeed = 0. , etaSeed = 0. , phiSeed = 0. ; // leading particle params + Double_t pttmp = 0. , etatmp = 0. , phitmp = 0. ; // temporary variables to be used in various calculations + Double_t deta = 0. , dphi = 0. , dcomputed = 0. ; + Bool_t injet = 0 ; + + fNJets = -1 ; // n jets in this event + Int_t idxPtSort = -1 ; // index of array of sorted pt indexes + + if (fDebug) { cout << "\n\n\n\n\n\n------------------\nBegin Event Analysis\n------------------\n\n" << endl ;} + + if(fDebug)cout << "fNPart = " << fNPart << endl; + + TBits lkupTable ( fNPart ) ; // bit container ; 1-to-1 corespondence with fIdxArray + + while ( lkupTable.CountBits() != (UInt_t)fNPart ) + { // loop over particles in event until all flags are set + UInt_t firstnonflagged = lkupTable.FirstNullBit() ; // set the index to the first NON flagged bit ; less conditions + + if(fDebug)cout << "\n\nfirst_non_flagged : " << firstnonflagged << endl; + + ++fNJets; // incrementing the jet counter + if (fDebug) { printf("JET %d \n", fNJets); } + + ptSeed = 0. ; etaSeed = 0. ; phiSeed = 0. ; // reseting leading particle params + + for ( UInt_t ipart = firstnonflagged ; ipart < (UInt_t)fNPart ; ipart++ ) + {// iteration over particles in event + // the loop is done over sorted array of pt + idxPtSort = fIdxArray[ipart] ; // index of particle ! fIdxArray is an index list pt sorted + + if ( lkupTable.TestBitNumber(ipart) ) { continue; } // if 4vector is already flagged skip it + + //init computed and used vars + pttmp = 0. ; etatmp = 0. ; phitmp = 0. ; + deta = 0. ; dphi = 0. ; dcomputed = 0. ; injet = 0 ; + + //taking info from fVectParticle ; + pttmp = fVectParticle[idxPtSort]->pt ; + etatmp = fVectParticle[idxPtSort]->eta ; + phitmp = fVectParticle[idxPtSort]->phi ; + + if ( ipart == firstnonflagged ) + {// this is first particle in event; leading particle + // begin the search around this particle in a fRadius + + // CENTRE OF THE JET + ptSeed = pttmp ; etaSeed = etatmp ; phiSeed = phitmp ; // seeding the jet with first particle idxPtSort + + lkupTable.SetBitNumber ( ipart ) ; // flag the index of particle in lkup_table + fVectParticle[idxPtSort]->njet = fNJets ; // associate particle with current jet number + + if (fDebug) { printf("\nLeading particle :: particle index = %d ; at sorted index %d ; in jet %d \n", idxPtSort, ipart, fNJets); } + if (fDebug) { printf("pt= %g ; eta= %g ; phi = %g \n", pttmp, etatmp, phitmp) ; } + if (fDebug) { lkupTable.Print() ;} + + continue ; // skip to next particle + } + + // condition to be in jet + deta = etatmp - etaSeed ; + dphi = TVector2::Phi_mpi_pi (phitmp - phiSeed) ; // computing dphi and normalizing to (0,2pi) interval in one step + + dcomputed = TMath::Hypot(deta, dphi) ; // Distance(fRadius) to (eta,phi) seed + + injet = ( ( fRadius - dcomputed ) >= 0.000000001 ) ? 1 : 0 ; // if r_computed is within jet_r in_jet == 1 else 0 + + if ( injet ) + { // calculus of jet variables + lkupTable.SetBitNumber ( ipart ) ; // flag the index of particle in lkup_table + fVectParticle[idxPtSort]->njet = fNJets ; // setting in particle list the associated jet + + if (fDebug) { printf("\njet particle :: particle index = %d ; at sorted index %d ; in jet %d ; found at radius %g ; \n", idxPtSort, ipart, fNJets, dcomputed); } + if (fDebug) { printf("pt= %g ; eta= %g ; phi = %g \n", pttmp, etatmp, phitmp) ; } + if (fDebug) { lkupTable.Print() ;} + + continue ; // skip to next particle + } + + } + // end of iteration over event; one jet definition of content ; jet parameters to be computed later + } + +} + +//______________________________________________________________________________ +void AliCdfJetFinder::ComputeConesWeight() +{ + // computing of jets Pt, Eta and Phi (centre of weight in (eta,phi) plane) + // rescan the vector of particles by identify them by asociate jet number for computing of weight centre + + // JET CONTAINER + fVectJet = new varContainer* [fNJets]; // container for Jets + + Double_t ptJet, ptJet2 , etaJet , phiJet ; Int_t npartJet ; + Double_t pttmp = 0. , etatmp = 0. , phitmp = 0. ; // temporary variables to be used in various calculations + Int_t idxPtSort = -999 ; // index of array of sorted pt indexes + + for( Int_t jet = 0 ; jet < fNJets ; jet++ ) + { + if (fDebug) { printf("\n\n--- Computing weight of Jet %d \n", jet ); } + npartJet = 0 ; ptJet = 0. ; etaJet = 0. ; phiJet = 0. ; // reset variables for a new computation + + for ( Int_t ipart = 0 ; ipart < fNPart ; ipart++ ) + {// iteration over particles in event + // the loop is done over sorted array of pt + idxPtSort = fIdxArray[ipart] ; // index of particle ! fIdxArray is an index list pt sorted + + if ( fVectParticle[idxPtSort]->njet == jet ) + { + ++npartJet; // incrementing the counter of jet particles + + //taking info from fVectParticle ; + pttmp = fVectParticle[idxPtSort]->pt ; + etatmp = fVectParticle[idxPtSort]->eta ; + phitmp = TVector2::Phi_mpi_pi (fVectParticle[idxPtSort]->phi) ; + + // jet_new_angular_coordinate = jet_old_angular_coordinate * jet_old_pt / jet_new_pt + + // part[i]_angular_coordinate * part[i]_pt/jet_new_pt + + ptJet2 = ptJet + pttmp ; + + etaJet = etaJet * ptJet / ptJet2 + etatmp * pttmp / ptJet2 ; + phiJet = phiJet * ptJet / ptJet2 + phitmp * pttmp / ptJet2 ; + + ptJet = ptJet2 ; + + } + // add a particle and recalculation of centroid + } + // end of 1 jet computation + + varContainer *aJet = new varContainer; // Jet container + aJet->pt = ptJet; aJet->eta = etaJet; aJet->phi = phiJet; aJet->njet = npartJet; // setting jet vars in container + fVectJet[jet] = aJet; // store the number of the jet(fNJets) and increment afterwards + + if (fDebug) { printf ("=== current jet %d : npartjet= %d ; pt_jet= %g ; eta_jet = %g ; phi_jet = %g \n\n\n", + jet, npartJet, ptJet, etaJet, phiJet ) ; } + + } + //end loop over jets + +} + +//______________________________________________________________________________ +void AliCdfJetFinder::WriteJets() +{ + // Writing AOD jets and AOD tracks + + for( Int_t jetnr = 0 ; jetnr < fNJets ; jetnr++ ) + { + Double_t pt = 0., eta = 0., phi = 0., // jet variables + px = 0., py = 0., pz = 0., en = 0.; // convert to 4-vector + pt = fVectJet[ jetnr ]->pt ; // pt of jet + eta = fVectJet[ jetnr ]->eta ; // eta of jet + phi = fVectJet[ jetnr ]->phi ; // phi of jet + + px = pt * TMath::Cos ( phi ) ; + py = pt * TMath::Sin ( phi ) ; + pz = pt / TMath::Tan ( 2.0 * TMath::ATan ( TMath::Exp ( -eta ) ) ) ; + en = TMath::Sqrt ( px * px + py * py + pz * pz ); + + AliAODJet jet (px, py, pz, en); + + + if (fDebug) jet.Print(""); + + if (fAODtracksWrite) + { + for ( Int_t jetTrack = 0; jetTrack < fCalTrkEvent->GetNCalTrkTracks(); jetTrack++ ) + { + // The first if condition below has to be checked + if ( fVectParticle[jetTrack]->njet == jetnr ) { jet.AddTrack(fCalTrkEvent->GetCalTrkTrack(jetTrack)->GetTrackObject()) ; } + } + } + // tracks REFs written in AOD + AddJet(jet); + + } + //jets vector parsed and written to AOD +} + +//______________________________________________________________________________ +void AliCdfJetFinder::AnalizeJets() +{ + // analyzing of jets and filling of histograms + + const Double_t kPI = TMath::Pi(); + + //persistent pointer to histo20 + TH1F *hR = (TH1F*)fHistos->FindObject("histo20"); + + Int_t *jetsptidx = 0; // sorted array of jets pt + Double_t *jetspt = 0; // array of jets pts + Int_t leadingjetindex = -1 ; // index of leading jet from fVectJet + Int_t partleadjet = 0 ; // number of particles in leading jet + Double_t ptleadjet = 0. ; // pt of leading jet + Double_t etaleadjet = 0. ; // eta of leading jet + Double_t phileadjet = 0. ; // phi of leading jet + + jetsptidx = new Int_t [fNJets] ; + jetspt = new Double_t [fNJets] ; + + //________________________________________________________________________________________ + // Jet sorting and finding the leading jet that coresponds to cuts in pt and multiplicity + //________________________________________________________________________________________ + + // filing the idx_ptjets array + if (fDebug) printf("List of unsorted jets:\n"); + for( Int_t i = 0 ; i < fNJets ; i++ ) + { + jetsptidx [i] = 0 ; + jetspt [i] = fVectJet[i]->pt ; + if (fDebug) { cout << " jet found: " << i << " npartjet=" << fVectJet[i]->njet << " ; jets_pt = " << jetspt[i] << endl; } + } + + TMath::Sort ( fNJets, jetspt , jetsptidx ) ; // sorting pt of jets + + // selection of leading jet + // looping over jets searching for __first__ one that coresponds to cuts + for( Int_t i = 0 ; i < fNJets ; i++ ) + { + if ( ( fVectJet[ jetsptidx[i] ]->njet >= fMinJetParticles ) && ( fVectJet[ jetsptidx[i] ]->pt >= fJetPtCut ) ) + { + leadingjetindex = jetsptidx[i] ; + partleadjet = fVectJet[ leadingjetindex ]->njet ; // number of particles in leading jet + ptleadjet = fVectJet[ leadingjetindex ]->pt ; // pt of leading jet + etaleadjet = fVectJet[ leadingjetindex ]->eta ; // eta of leading jet + phileadjet = fVectJet[ leadingjetindex ]->phi ; // phi of leading jet + + if (fDebug) + { printf("Leading jet %d : npart= %d ; pt= %g ; eta = %g ; phi = %g \n", leadingjetindex, partleadjet, ptleadjet, etaleadjet, phileadjet ); } + + break ; + } + } + // end of selection of leading jet + + + + ////////////////////////////////////////////////// + //// Computing of values used in histograms + ////////////////////////////////////////////////// + + //___________________________________________________________________________ + // pt_sum of all particles in event + //___________________________________________________________________________ + if (fDebug) cout << "Computing sum of pt in event" << endl ; + Double_t ptsumevent = 0.; + for ( Int_t i = 0 ; i< fNPart ; i++ ) { ptsumevent += fVectParticle[i]->pt ; } + if (fDebug) printf ("Sum of all Pt in event : pt_sum_event = %g", ptsumevent) ; + + //___________________________________________________________________________ + // Filling an array with indexes of leading jet particles + //___________________________________________________________________________ + Int_t * idxpartLJ = new Int_t [partleadjet] ; + Int_t counterpartleadjet = 0; + + if (fDebug) cout << "Filling an array with indexes of leading jet particles" << endl; + + for( Int_t i = 0 ; i < fNPart ; i++ ) + { + if ( fVectParticle[i]->njet == leadingjetindex ) + { idxpartLJ[counterpartleadjet++] = i ; } + } + + if ( (counterpartleadjet-1) > partleadjet ) { cout << " Counter_part_lead_jet > part_leadjet !!!!" << endl;} + + + //___________________________________________________________________________ + // Calculus of part distribution in leading jet + //___________________________________________________________________________ + Double_t z = 0. ; + Double_t *zpartljet = new Double_t [ partleadjet ] ; // array of z of particles in leading jet + + if (fDebug) cout << "Entering loop of calculus of part distribution in leading jet" << endl ; + + for( Int_t j = 0 ; j < partleadjet ; j++ ) + { + Double_t zj = fVectParticle[idxpartLJ[j]]->pt ; + z = zj / ptleadjet ; + zpartljet [j] = z ; + if (fDebug) cout << "idx_leadjet_part[j] = " << idxpartLJ[j] + << " p of particle = " << zj + << " pt lead jet = " << ptleadjet + << " Z = " << z << endl; + } + + + //___________________________________________________________________________ + // array of delta phi's between phi of particles and leading jet phi + //___________________________________________________________________________ + if (fDebug) cout << "array of delta phi's between phi of particles and leading jet phi" << endl; + Double_t dphipartLJ = 0. ; + Double_t *dphipartljet = new Double_t [fNPart]; + for( Int_t part = 0 ; part < fNPart ; part++ ) + { + dphipartLJ = fVectParticle[part]->phi - phileadjet ; + dphipartLJ = TVector2::Phi_mpi_pi (dphipartLJ) ; // restrict the delta phi to (-pi,pi) interval + dphipartljet [part] = dphipartLJ ; + if (fDebug) printf("part= %d ; dphi_partLJ = %g \n", part, dphipartLJ ); + } + + + //______________________________________________________________________________ + // Pt distribution for all particles + //______________________________________________________________________________ + TH1F * hpt = (TH1F*)fHistos->FindObject("histo11"); + if ( hpt ) { for ( Int_t i = 0 ; i < fNPart ; i++ ) { hpt->Fill( fVectParticle[i]->pt ); } } + + //___________________________________________________________________________ + // Recomputing of radius of particles in leading jet + //___________________________________________________________________________ + if (fDebug) { printf(" Searching particles with jet index %d\n", leadingjetindex); } + + Double_t ddeta = 0. , ddphi = 0. , rpart = 0. ; + + for( Int_t j = 0 ; j < partleadjet ; j++ ) + { + ddeta = etaleadjet - fVectParticle[idxpartLJ[j]]->eta; + + Double_t phitmp = fVectParticle[idxpartLJ[j]]->phi ; + + ddphi = TVector2::Phi_mpi_pi ( phileadjet - phitmp ) ; // restrict the delta phi to (-pi,pi) interval + + rpart = TMath::Hypot (ddeta, ddphi) ; + + if (fDebug) printf ("Particle %d with Re-Computed radius = %f ", idxpartLJ[j], rpart) ; + if ( (rpart - fRadius) >= 0.00000001 ) + { if (fDebug) printf (" bigger than selected radius of %f\n", fRadius ); } + else + { if (fDebug) printf ("\n") ; } + + if (hR) hR->Fill(rpart); + + } + + + + //_______________________________________________________________________ + // Computing of radius that contain 80% of Leading Jet ( PT and multiplicity ) + //_______________________________________________________________________ + Double_t corepartleadjet = 0.8 * partleadjet ; + Double_t coreptleadjet = 0.8 * ptleadjet ; + Int_t countercorepart = 0 ; + Double_t countercorept = 0. ; + Int_t sortedindex = -1 ; + + TProfile * hprof24 = (TProfile*)fHistos->FindObject("histo24"); + TProfile * hprof25 = (TProfile*)fHistos->FindObject("histo25"); + TProfile * hprof26 = (TProfile*)fHistos->FindObject("histo26"); + TProfile * hprof27 = (TProfile*)fHistos->FindObject("histo27"); + TProfile * hprof28 = (TProfile*)fHistos->FindObject("histo28"); + TProfile * hprof29 = (TProfile*)fHistos->FindObject("histo29"); + + + if ((hprof24) && (hprof25) && (hprof26) && (hprof27) && (hprof28) && (hprof29) ) + { + for( Int_t part = 0 ; part < fNPart ; part++ ) + { + Double_t pttmp = 0. ; Double_t etatmp = 0. ; Double_t phitmp = 0. ; // temporary variables + Double_t dpart = 0. ; + sortedindex = fIdxArray[part] ; + + if ( fVectParticle [ sortedindex ]->njet == leadingjetindex ) + { + pttmp = fVectParticle[sortedindex]->pt ; + etatmp = fVectParticle[sortedindex]->eta ; + phitmp = fVectParticle[sortedindex]->phi ; + + ++countercorepart ; + countercorept += pttmp ; + + dpart = TMath::Hypot ( etaleadjet - etatmp, TVector2::Phi_mpi_pi (phileadjet - phitmp) ) ; + + if ( countercorepart <= corepartleadjet ) { hprof24->Fill(ptleadjet, dpart); } + if ( countercorept <= coreptleadjet ) { hprof25->Fill(ptleadjet, dpart); } + + if (ptleadjet > 5.) { hprof26->Fill(dpart, countercorepart); hprof28->Fill(dpart, countercorept); } + if (ptleadjet > 30.) { hprof27->Fill(dpart, countercorepart); hprof29->Fill(dpart, countercorept); } + + } + } + } + + TH1F *hjetpt = (TH1F*)fHistos->FindObject("histo1"); + TH1F *hjeteta = (TH1F*)fHistos->FindObject("histo2"); + TH1F *hjetphi = (TH1F*)fHistos->FindObject("histo3"); + TH1F *hjetnjet = (TH1F*)fHistos->FindObject("histo4"); + + for( Int_t jet = 0 ; jet < fNJets ; jet++ ) + { + if (hjetpt) hjetpt ->Fill ( fVectJet[jet]->pt ) ; + if (hjeteta) hjeteta ->Fill ( fVectJet[jet]->eta ) ; + if (hjetphi) hjetphi ->Fill ( fVectJet[jet]->phi ) ; + if (hjetnjet) hjetnjet ->Fill ( fVectJet[jet]->njet ) ; + } + + TH1F *hjets = (TH1F*)fHistos->FindObject("histo5"); + if (hjets) hjets->Fill(fNJets); + + TH1F *hleadpart = (TH1F*)fHistos->FindObject("histo6"); + if (hleadpart) hleadpart->Fill(partleadjet); + + TProfile * hprof = (TProfile*)fHistos->FindObject("histo7"); + if (hprof) hprof->Fill(ptleadjet,partleadjet); + + TH1F *hMD = (TH1F*)fHistos->FindObject("histo8"); + for( Int_t k = 0 ; k < partleadjet ; k++) + { hMD->Fill( zpartljet[k] ); } + + TProfile * hphi = (TProfile*)fHistos->FindObject("histo9"); + for( Int_t k = 0 ; k < partleadjet ; k++) + { hphi->Fill( TMath::RadToDeg() * dphipartljet [k] , fNPart ) ; } + + TProfile * htpd = (TProfile*)fHistos->FindObject("histo10"); + for( Int_t k = 0 ; k < fNPart ; k++) + { htpd->Fill( TMath::RadToDeg() * dphipartljet [k] , ptsumevent ) ; } + + + TProfile * hprof1 = (TProfile*)fHistos->FindObject("histo21"); + if (hprof1) hprof1->Fill(ptleadjet, fNPart); + + TProfile * hprof2 = (TProfile*)fHistos->FindObject("histo22"); + if (hprof2) hprof2->Fill(ptleadjet, ptsumevent); + + TProfile * hprof1toward = (TProfile*)fHistos->FindObject("histo21_toward"); + TProfile * hprof1transverse = (TProfile*)fHistos->FindObject("histo21_transverse"); + TProfile * hprof1away = (TProfile*)fHistos->FindObject("histo21_away"); + TProfile * hprof2toward = (TProfile*)fHistos->FindObject("histo22_toward"); + TProfile * hprof2transverse = (TProfile*)fHistos->FindObject("histo22_transverse"); + TProfile * hprof2away = (TProfile*)fHistos->FindObject("histo22_away"); + TH1F * hpttoward = (TH1F*)fHistos->FindObject("histo23_toward"); + TH1F * hpttransverse = (TH1F*)fHistos->FindObject("histo23_transverse"); + TH1F * hptaway = (TH1F*)fHistos->FindObject("histo23_away"); + + if ( (hprof1toward) && (hprof1transverse) && (hprof1away) && (hprof2toward) && (hprof2transverse) && (hprof2away) ) + { + for( Int_t part = 0 ; part < fNPart ; part++) + { + Double_t ptpart = fVectParticle[part]->pt ; // pt of particle + if ( ( dphipartljet[part] >=0.) && ( dphipartljet[part] < kPI/3. ) ) + { + hprof1toward->Fill( ptleadjet, fNPart ); + hprof2toward->Fill( ptleadjet, ptsumevent); + hpttoward->Fill( ptpart ); + } + else + if ( ( dphipartljet[part] >= (kPI/3.)) && ( dphipartljet[part] < (2.*kPI/3.)) ) + { + hprof1transverse->Fill( ptleadjet, fNPart ); + hprof2transverse->Fill( ptleadjet, ptsumevent); + hpttransverse->Fill( ptpart ); + } + else + if ( ( dphipartljet[part] >= ( 2.*kPI/3.)) && ( dphipartljet[part] < kPI ) ) + { + hprof1away->Fill( ptleadjet, fNPart ); + hprof2away->Fill( ptleadjet, ptsumevent); + hptaway->Fill( ptpart ); + } + } + } + +} + +//______________________________________________________________________________ +void AliCdfJetFinder::Clean() +{ + // CLEANING SECTION + for ( Int_t i = 0 ; i < fNPart ; i++ ){ + delete fVectParticle[i]; + fVectParticle[i] = 0; + } + delete [] fVectParticle;fVectParticle = 0; + + for ( Int_t i = 0 ; i < fNJets ; i++ ){ + delete fVectJet[i]; + fVectJet[i] = 0; + } + delete [] fVectJet;fVectJet = 0; + + delete [] fPtArray;fPtArray = 0; + delete [] fIdxArray;fIdxArray = 0; + + Reset(); + +} + diff --git a/JETAN/DEV/AliCdfJetFinder.h b/JETAN/DEV/AliCdfJetFinder.h new file mode 100644 index 00000000000..8407aad21fd --- /dev/null +++ b/JETAN/DEV/AliCdfJetFinder.h @@ -0,0 +1,75 @@ +#ifndef ALICDFJETFINDER_H +#define ALICDFJETFINDER_H + +/* + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. + * See cxx source for full Copyright notice + * +*/ + +/* $Id$ */ + +// Definition of constants, structures and functions for jet finder + +#include "AliJetFinder.h" + +using namespace std ; + + +// structure of jet and particles container +struct varContainer +{ + Double_t pt; // pt of particle/jet + Double_t eta; // eta of particle/jet + Double_t phi; // phi of particle/jet + Int_t njet; // njet is multiplicity of jet or if particles are stored , njet is index number of jet +}; + +class AliCdfJetHeader; + +class AliCdfJetFinder : public AliJetFinder +{ + public: + AliCdfJetFinder(); + virtual ~AliCdfJetFinder(); + + void CreateOutputObjects(TList * const histos); + void FindJets(); + void InitData(); + void FindCones(); + void ComputeConesWeight(); + void WriteJets() ; + void AnalizeJets(); + void Clean(); + + protected: + AliCdfJetFinder ( const AliCdfJetFinder& jf ); + AliCdfJetFinder& operator = ( const AliCdfJetFinder& jf ); + + TList* fHistos; // List of histograms + + Bool_t fAODwrite ; // write jets to AOD + Bool_t fAODtracksWrite; // write jet tracks to AOD + Bool_t fAnalyseJets; // analyse jets + + Int_t fNJets; //! counter of number of jets + Int_t fNPart; //! number of particles in event + Int_t fNInC; //! number of charged particles in event + Int_t fNInN; //! number of neutral cells in event + + Double_t fRadius; // radius of jet + + Int_t fMinJetParticles; // leading jet must contain AT LEAST fMinJetParticles + Double_t fJetPtCut; // leading jet must have AT LEAST fJetPtCut + + varContainer** fVectParticle; //! container for Particles + varContainer** fVectJet; //! container for Jets + + Double_t* fPtArray; //! momentum array + Int_t* fIdxArray; //! index array of sorted pts + + ClassDef(AliCdfJetFinder,3) // CDF jet finder + +}; +#endif + diff --git a/JETAN/DEV/AliCdfJetHeader.cxx b/JETAN/DEV/AliCdfJetHeader.cxx new file mode 100644 index 00000000000..0f0cb324827 --- /dev/null +++ b/JETAN/DEV/AliCdfJetHeader.cxx @@ -0,0 +1,48 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +//--------------------------------------------------------------------- +// Jet Finder based on CDF algortihm +// Charged jet evolution and the underlying event in proton-antiproton collisions at 1.8 TeV +// Physical Review D, vol. 65, Issue 9, id. 092002 +// http://www.phys.ufl.edu/~rfield/cdf/chgjet/chgjet_intro.html +// Authors : Adrian.Sevcenco@cern.ch (adriansev@spacescience.ro ) +// Daniel.Felea@cern.ch (dfelea@spacescience.ro) +// Ciprian.Mihai.Mitu@cern.ch (mcm@spacescience.ro) +//--------------------------------------------------------------------- + + +/* + Changelog + + + +*/ + +#include "AliCdfJetHeader.h" + +ClassImp ( AliCdfJetHeader ) + +//////////////////////////////////////////////////////////////////////// + +AliCdfJetHeader::AliCdfJetHeader(): + fMinPartJet(1), + fJetPtCut(0.), + fAODwrite(kFALSE), + fAODtracksWrite(kFALSE), + fkAnalyseJets(kFALSE) +{ + // Constructor +} diff --git a/JETAN/DEV/AliCdfJetHeader.h b/JETAN/DEV/AliCdfJetHeader.h new file mode 100644 index 00000000000..4356fe89373 --- /dev/null +++ b/JETAN/DEV/AliCdfJetHeader.h @@ -0,0 +1,49 @@ +#ifndef ALICDFJETHEADER_H +#define ALICDFJETHEADER_H + +/* + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. + * See cxx source for full Copyright notice + * +*/ + +// settings for jet finder process + +#include "AliJetHeader.h" + +class AliCdfJetHeader : public AliJetHeader +{ + public: + AliCdfJetHeader(); + virtual ~AliCdfJetHeader() { } + + // Getters + Double_t GetJetPtCut() const { return fJetPtCut; } + Int_t GetMinPartJet() const { return fMinPartJet; } + Bool_t GetAnalyseJets() const { return fkAnalyseJets; } + + // Setters + void SetJetPtCut(Double_t jetptcut) { fJetPtCut = jetptcut; } + void SetAODwrite(Bool_t aodwrite) { fAODwrite = aodwrite; } + void SetAODtracksWrite(Bool_t aodtrackswrite){ fAODtracksWrite = aodtrackswrite; } + void SetMinPartJet(Int_t npart) { fMinPartJet = npart; } + void SetAnalyseJets(Bool_t flag = kTRUE) { fkAnalyseJets = flag; } + + Bool_t IsAODwrite() const { return fAODwrite; } + Bool_t IsAODtracksWrite() const { return fAODtracksWrite; } + + protected: + // Parameters of algorithm + Int_t fMinPartJet; // minimum number of particles in jet + Double_t fJetPtCut; // pt cut of jets + + Bool_t fAODwrite; // flag for writing to AOD + Bool_t fAODtracksWrite; // flag for writing tracks to AOD + + Bool_t fkAnalyseJets; // analyse jets + + ClassDef ( AliCdfJetHeader, 2 ) // CDF jet header class + +}; + +#endif diff --git a/JETAN/DEV/AliDAJetFinder.cxx b/JETAN/DEV/AliDAJetFinder.cxx new file mode 100644 index 00000000000..3bd12ee2422 --- /dev/null +++ b/JETAN/DEV/AliDAJetFinder.cxx @@ -0,0 +1,546 @@ + +// ************************************************************************** +// * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +// * * +// * Author: The ALICE Off-line Project. * +// * Contributors are mentioned in the code where appropriate. * +// * * +// * Permission to use, copy, modify and distribute this software and its * +// * documentation strictly for non-commercial purposes is hereby granted * +// * without fee, provided that the above copyright notice appears in all * +// * copies and that both the copyright notice and this permission notice * +// * appear in the supporting documentation. The authors make no claims * +// * about the suitability of this software for any purpose. It is * +// * provided "as is" without express or implied warranty. * +// ************************************************************************** + +/* $Id$ */ + +//----------------------------------------------------------------------------------- +// Jet finder based on Deterministic Annealing +// For further informations about the DA working features see: +// Phys.Lett. B601 (2004) 56-63 (http://arxiv.org/abs/hep-ph/0407214) +// Author: Davide Perrino (davide.perrino@ba.infn.it, davide.perrino@cern.ch) +// alexandre.shabetai@cern.ch (Modification of the input object (reader/finder splitting)) +// ** 2011 +// Modified accordingly to reader/finder splitting and new handling of neutral information +//----------------------------------------------------------------------------------- + +#include +#include + +#include "AliAODJet.h" +#include "AliDAJetHeader.h" +#include "AliDAJetFinder.h" + +ClassImp(AliDAJetFinder) + +/////////////////////////////////////////////////////////////////////// + +AliDAJetFinder::AliDAJetFinder(): + AliJetFinder(), + fAlpha(1.01), + fDelta(1e-8), + fAvDist(1e-6), + fEps(1e-4), + fEpsMax(1e-2), + fNloopMax(100), + fBeta(0.1), + fNclustMax(0), + fNin(0), + fNeff(0) +{ + // Constructor +} + +//----------------------------------------------------------------------------------- +AliDAJetFinder::~AliDAJetFinder() +{ + // Destructor +} + +//----------------------------------------------------------------------------------- +void AliDAJetFinder::FindJets() +{ + // Find the jets in current event + // + Float_t betaStop=100.; + fDebug = fHeader->GetDebug(); + + Double_t dEtSum=0; + Double_t *xData[2]; + TVectorD *vPx = new TVectorD(); + TVectorD *vPy = new TVectorD(); + TMatrixD *mPyx= new TMatrixD(); + TMatrixD *mY = new TMatrixD(); + InitDetAnn(dEtSum,xData,vPx,vPy,mPyx,mY); + if (fNin < fNclustMax){ + delete [] xData[0], delete [] xData[1]; + delete vPx; + delete vPy; + delete mPyx; + delete mY; + return; + } + Int_t nc=1, nk; + DoubleClusters(nc,nk,vPy,mY); + do{ //loop over beta + fBeta*=fAlpha; + Annealing(nk,xData,vPx,vPy,mPyx,mY); + NumCl(nc,nk,vPy,mPyx,mY); + }while((fBetaGetFixedCl() ? + ((AliDAJetHeader*)fHeader)->GetNclustMax() : + TMath::Max((Int_t)TMath::Sqrt(fNin),5); + Float_t etaEff = ((AliDAJetHeader*)fHeader)->GetEtaEff(); + + fNin=0; + for (Int_t iTr=0; iTrGetNCalTrkTracks(); iTr++) if (GetCalTrkEvent()->GetCalTrkTrack(iTr)->GetCutFlag()==1) fNin++; + + fNeff = ((AliDAJetHeader*)fHeader)->GetNeff(); + fNeff = TMath::Max(fNeff,fNin); + Double_t *xEta = new Double_t[fNeff]; + Double_t *xPhi = new Double_t[fNeff]; + xData[0]=xEta; xData[1]=xPhi; + vPx->ResizeTo(fNeff); + Int_t iIn=0; + + for (Int_t iTr=0; iTrGetNCalTrkTracks(); iTr++){ + AliJetCalTrkTrack* ctT = GetCalTrkEvent()->GetCalTrkTrack(iTr); + if (ctT->GetCutFlag()==0) continue; + xEta[iIn] = ctT->GetEta(); + xPhi[iIn] = ctT->GetPhi()<0 ? ctT->GetPhi() + 2*TMath::Pi() : ctT->GetPhi(); + (*vPx)(iIn)=ctT->GetPt(); + dEtSum+=(*vPx)(iIn); + iIn++; + } + + TRandom2 r; + r.SetSeed(0); + for (iIn=fNin; iInResizeTo(fNeff,njdim); + mY->ResizeTo(4,njdim); + vPy->ResizeTo(njdim); + mY->Zero();mPyx->Zero();vPy->Zero(); + (*vPy)(0)=1; + TMatrixDColumn(*mPyx,0)=1; + Double_t ypos=0,xpos=0; + for (iIn=0; iIn0) ? atan2(ypos,xpos) : atan2(ypos,xpos)+2*TMath::Pi(); + +} + +//----------------------------------------------------------------------------------- +void AliDAJetFinder::DoubleClusters(Int_t nc,Int_t &nk, TVectorD *vPy, TMatrixD *mY) const +{ + // Return double clusters + for(Int_t iClust=0; iClustGetFiducialEtaMax(),pi}; + TVectorD vPart(2); + Double_t *m = new Double_t[nk]; + Double_t chi,chi1; + do{ + Int_t nloop=0; + for (Int_t iClust=0; iClustRndm(24); + ry->Randomize(-0.5,0.5,seed); + for (Int_t i=0; i<2; i++){ + for (Int_t iClust=0; iClustZero(); + y->Zero(); + //recalculate codevectors + for (Int_t iClust=0; iClust0) ? atan2(ypos,xpos) : atan2(ypos,xpos)+2*pi; + } + //verify codevectors' stability + chi=0; + for (Int_t iClust=0; iClustchi) chi=chi1; + } + chi=TMath::Sqrt(chi); + for (Int_t iClust=0; iClustfNloopMax){ + if (chi500) break; + } + }while (chi>fEps); + }while (chi>fEpsMax); + for (Int_t iClust=0; iClust= fNclustMax) growcl=false; + //recalculate the nc distinct codevectors + TMatrixD *pyx = new TMatrixD(fNeff,2*nc); + TVectorD *py = new TVectorD(nk); + TMatrixD *y1 = new TMatrixD(3,nk); + for (Int_t iClust=0; iClust nk/2){ + for (Int_t iClust=0; iClustZero(); + mPyx->Zero(); + vPy->Zero(); + for (Int_t iIn=0; iIn0){ + Double_t xpos=0,ypos=0,pxy; + for (Int_t iIn=0; iIn0) ? atan2(ypos,xpos) : atan2(ypos,xpos)+2*TMath::Pi(); + (*mY)(3,k)=(*mY)(3,iClust); + k++; + } + } + nk=k; + +} + +//----------------------------------------------------------------------------------- +void AliDAJetFinder::StoreJets(Int_t nk, Double_t **xData, const Int_t *xx, const TMatrixD *mY) +{ + //evaluate significant clusters properties + const Double_t pi=TMath::Pi(); + Float_t dFidEtaMax = ((AliDAJetHeader*)fHeader)->GetFiducialEtaMax(); + Float_t dFidEtaMin = ((AliDAJetHeader*)fHeader)->GetFiducialEtaMin(); + Float_t dFiducialEta= dFidEtaMax - dFidEtaMin; + Double_t *xEta = xData[0]; + Double_t *xPhi = xData[1]; + Int_t nEff = 0; + for (Int_t i=0; idFidEtaMin) nEff++; + Double_t dMeanDist=0.; + if (nEff > 0) + dMeanDist=TMath::Sqrt(2*dFiducialEta*pi/nEff); + Bool_t *isJet = new Bool_t[nk]; + Double_t *etNoBg= new Double_t[nk]; + Double_t *dDeltaEta=new Double_t[nk]; + Double_t *dDeltaPhi=new Double_t[nk]; + Double_t *surf = new Double_t[nk]; + Double_t *etDens= new Double_t[nk]; + for (Int_t iClust=0; iClustdFidEtaMax || xEta[iIn] dEtaMax) dEtaMax=xEta[iIn]; + Double_t dPhi=xPhi[iIn]-(*mY)(1,iClust); + if (dPhi > pi ) dPhi-=2*pi; + else if (dPhi < (-1)*pi) dPhi+=2*pi; + if (dPhi < dPhiMin) dPhiMin=dPhi; + else if (dPhi > dPhiMax) dPhiMax=dPhi; + } + dDeltaEta[iClust]=dEtaMax-dEtaMin+dMeanDist; + dDeltaPhi[iClust]=dPhiMax-dPhiMin+dMeanDist; + surf[iClust]=0.25*pi*dDeltaEta[iClust]*dDeltaPhi[iClust]; + etDens[iClust]=(*mY)(3,iClust)/surf[iClust]; + } + + if (((AliDAJetHeader*)fHeader)->GetSelJets()){ + for (Int_t iClust=0; iClustdFidEtaMin){ + Double_t etDensMed=0.; + Double_t etDensSqr=0.; + Int_t norm=0; + for (Int_t iClust1=0; iClust1dFidEtaMin){ + etDensMed+=etDens[iClust1]; + etDensSqr+=TMath::Power(etDens[iClust1],2); + norm++; + } + } + etDensMed/=TMath::Max(norm,1); + etDensSqr/=TMath::Max(norm,1); + Double_t deltaEtDens=TMath::Sqrt(etDensSqr-TMath::Power(etDensMed,2)); + if ((*mY)(3,iClust) > (etDensMed+deltaEtDens)*surf[iClust]) isJet[iClust]=kTRUE; + etNoBg[iClust]=(*mY)(3,iClust)-etDensMed*surf[iClust]; + } + } + for (Int_t iClust=0; iClustGetEtMin()){ + isJet[iClust]=kFALSE; + iClust=-1; + } + } + } + } else { + for (Int_t iClust=0; iClustGetNCalTrkTracks(); + for (Int_t iTr=0; iTrGetCalTrkTrack(iTr); + if (ctT->GetCutFlag()==0) continue; + if (xx[iIn]==iCl) jet.AddTrack(ctT->GetTrackObject()); + iIn++; + } + AddJet(jet); + if (fDebug > 0) printf("jet %d, Eta: %f, Phi: %f, Et: %f\n",iCl,jet.Eta(),jet.Phi(),jet.Pt()); + } + } + delete [] dDeltaEta; delete [] dDeltaPhi; + delete [] etNoBg; + delete [] isJet; + delete [] iSort; + +} + +//----------------------------------------------------------------------------------- +Double_t Dist(TVectorD x,TVectorD y) +{ + // Squared distance + const Double_t pi=TMath::Pi(); + Double_t dphi=TMath::Abs(x(1)-y(1)); + if (dphi > pi) dphi=2*pi-dphi; + Double_t dist=pow(x(0)-y(0),2)+pow(dphi,2); + return dist; + +} diff --git a/JETAN/DEV/AliDAJetFinder.h b/JETAN/DEV/AliDAJetFinder.h new file mode 100644 index 00000000000..b484e6b21a1 --- /dev/null +++ b/JETAN/DEV/AliDAJetFinder.h @@ -0,0 +1,56 @@ +#ifndef ALIDAJETFINDER_H +#define ALIDAJETFINDER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//--------------------------------------------------------------------- +//Jet finder based on Deterministic Annealing +//Author: Davide Perrino (davide.perrino@ba.infn.it) +// magali.estienne@subatech.in2p3.fr & +// alexandre.shabetai@cern.ch (Modification of the input object (reader/finder splitting)) +// ** 2011 +// Modified accordingly to reader/finder splitting and new handling of neutral information +//--------------------------------------------------------------------- + +#include "AliJetFinder.h" + +#include +#include + +class AliDAJetFinder : public AliJetFinder +{ + public: + AliDAJetFinder(); + virtual ~AliDAJetFinder(); + + void FindJets (); + + protected: + Double_t fAlpha; // beta increment + Double_t fDelta; // perturbation proportional to Delta + Double_t fAvDist; // minimum distance to distinguish two clusters + Double_t fEps; // convergence criterium below max number of loops + Double_t fEpsMax; // convergence criterium above max number of loops + Int_t fNloopMax; // maximum number of loops at a fixed beta + Double_t fBeta; // increasing multiplier of entropy + Int_t fNclustMax; // maximum number of clusters to find + Int_t fNin; // number of input data + Int_t fNeff; // total input data, including fakes + + private: + void InitDetAnn (Double_t &dEtSum, Double_t **xData, TVectorD *px, TVectorD *py, TMatrixD *pyx, TMatrixD *y); + void Annealing (Int_t nk, Double_t **xData, const TVectorD *vPx, TVectorD *vPy, TMatrixD *mPyx, TMatrixD *mY); + void NumCl (Int_t &nc, Int_t &nk, TVectorD *vPy, TMatrixD *mPyx, TMatrixD *mY); + void ReduceClusters(Int_t **iSame, Int_t nc, Int_t &ncout, Int_t **cont, Int_t *nSameOut) const; + void DoubleClusters(Int_t nc, Int_t &nk, TVectorD *vPy, TMatrixD *mY) const; + void EndDetAnn (Int_t &nk, Double_t **xData, Int_t *xx, Double_t etx, const TVectorD *px, TVectorD *py, TMatrixD *pyx, TMatrixD *y); + void StoreJets (Int_t nk, Double_t **xData, const Int_t *xx, const TMatrixD *mY); + + ClassDef(AliDAJetFinder,4) // DA Jet finder + +}; + +#endif diff --git a/JETAN/DEV/AliDAJetHeader.cxx b/JETAN/DEV/AliDAJetHeader.cxx new file mode 100644 index 00000000000..bde89afbb67 --- /dev/null +++ b/JETAN/DEV/AliDAJetHeader.cxx @@ -0,0 +1,56 @@ +// ************************************************************************** +// * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +// * * +// * Author: The ALICE Off-line Project. * +// * Contributors are mentioned in the code where appropriate. * +// * * +// * Permission to use, copy, modify and distribute this software and its * +// * documentation strictly for non-commercial purposes is hereby granted * +// * without fee, provided that the above copyright notice appears in all * +// * copies and that both the copyright notice and this permission notice * +// * appear in the supporting documentation. The authors make no claims * +// * about the suitability of this software for any purpose. It is * +// * provided "as is" without express or implied warranty. * +// ************************************************************************** + +//---------------------------------------------------------------------------- +// Deterministic Annealing Jet header class +// Stores parameters of DA jet algorithm +// Author: Davide Perrino (davide.perrino@ba.infn.it, davide.perrino@cern.ch) +// 2011: +// Adding FiducialEta/PhiMin/Max setters/getters and variables to accommodate with reader/finder splitting +//---------------------------------------------------------------------------- + +#include "AliDAJetHeader.h" + +ClassImp(AliDAJetHeader) + +/////////////////////////////////////////////////////////////////////// + +AliDAJetHeader::AliDAJetHeader(): + AliJetHeader("AliDAJetHeader"), + fSelectJets(kTRUE), + fNclustMax(10), + fFixedCl(kFALSE), + fEtMin(10.), + fNeff(0), + fEtaEff(0.9), + fFidEtaMin(-0.9), + fFidEtaMax(0.9), + fFidPhiMin(0.), + fFidPhiMax(2*TMath::Pi()) +{ + // Constructor +} + +//--------------------------------------------------------------------- +void AliDAJetHeader::SetRadius(Float_t radius) +{ + // The radius requested is used to estimate the number of clusters + // to be found, in order to obtain jets with the expected area. + // It must not be intended as a sharp limit on the cluster radius + + Int_t nclust = (Int_t) (4.*fEtaEff/(radius*radius)) + 1; + SetNclust(nclust); + +} diff --git a/JETAN/DEV/AliDAJetHeader.h b/JETAN/DEV/AliDAJetHeader.h new file mode 100644 index 00000000000..c8cfca0a0d7 --- /dev/null +++ b/JETAN/DEV/AliDAJetHeader.h @@ -0,0 +1,62 @@ +#ifndef ALIDAJETHEADER_H +#define ALIDAJETHEADER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +//--------------------------------------------------------------------- +// Jet header class for Deterministic Annealing +// Stores the parameters of the DA jet algorithm +// Author: Davide Perrino (davide.perrino@ba.infn.it) +// 2011: +// Adding FiducialEta/PhiMin/Max setters/getters and variables to accommodate with reader/finder splitting +//--------------------------------------------------------------------- + +#include "AliJetHeader.h" + +class AliDAJetHeader : public AliJetHeader +{ + public: + AliDAJetHeader(); + virtual ~AliDAJetHeader() {} + + void SelectJets (Bool_t seljets) { fSelectJets=seljets; } + void SetRadius (Float_t radius); + void SetNclust (Int_t ncl ) { fNclustMax=ncl ; fFixedCl=kTRUE; } + void SetEtMin (Float_t etmin ) { fEtMin =etmin; } + void SetNeff (Int_t n ) { fNeff = n; } + void SetEtaEff (Float_t eta ) { fEtaEff = eta; } + void SetFiducialEtaMin (Float_t etamin) { fFidEtaMin = etamin; } + void SetFiducialEtaMax (Float_t etamax) { fFidEtaMax = etamax; } + void SetFiducialPhiMin (Float_t phimin) { fFidPhiMin = phimin; } + void SetFiducialPhiMax (Float_t phimax) { fFidPhiMax = phimax; } + + Bool_t GetSelJets() const { return fSelectJets; } + Float_t GetRadius() const { return fRadius; } + Int_t GetNclustMax() const { return fNclustMax; } + Bool_t GetFixedCl() const { return fFixedCl; } + Float_t GetEtMin() const { return fEtMin; } + Int_t GetNeff() const { return fNeff; } + Float_t GetEtaEff() const { return fEtaEff; } + Float_t GetFiducialEtaMin() const { return fFidEtaMin; } + Float_t GetFiducialEtaMax() const { return fFidEtaMax; } + Float_t GetFiducialPhiMin() const { return fFidPhiMin; } + Float_t GetFiducialPhiMax() const { return fFidPhiMax; } + + protected: + Bool_t fSelectJets; // select jets among clusters + Int_t fNclustMax; // number of clusters when to stop annealing + Bool_t fFixedCl; // use a fixed fNclustMax + Float_t fEtMin; // minimum energy for found jets + Int_t fNeff; // number of total input data, including fakes + Float_t fEtaEff; // eta range in which fake tracks are generated + Float_t fFidEtaMin; // fiducial eta min for particles + Float_t fFidEtaMax; // fiducial eta max for particles + Float_t fFidPhiMin; // fiducial phi min for paticles + Float_t fFidPhiMax; // fiducial phi max for paticles + + ClassDef(AliDAJetHeader,4) // DA jet header class + +}; + +#endif diff --git a/JETAN/DEV/AliEventShape.cxx b/JETAN/DEV/AliEventShape.cxx new file mode 100644 index 00000000000..e34640d3670 --- /dev/null +++ b/JETAN/DEV/AliEventShape.cxx @@ -0,0 +1,311 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ +//--------------------------------------------------------------------- +// Event shape utility class +// Circularity, Thrust, ... +// Authors: Antonio Ortiz Velasquez +// +//--------------------------------------------------------------------- + + +#include "AliEventShape.h" + +#include "AliStack.h" +#include "AliLog.h" +#include "AliMCEventHandler.h" +#include "AliMCEvent.h" + +#include +#include +#include +#include +#include + + + + +//____________________________________________________________________ +ClassImp(AliEventShape) + +//___________________________________________________________________ +TArrayD * AliEventShape::GetThrustParamMC(AliMCEvent* mcEvent, Int_t nstudymin, Double_t ptcutoff, Double_t etacutoff, Bool_t chom) +{ + /* + This function returns an array of values of thrust. To get these values you have to do: + TArrayD* eventshapes = 0; + eventshapes = AliShapeEvent::GetThrustParamMC(mcEvent, 3, 1, 1, kFALSE); + Double_t thrust=eventshapes->GetAt(0); + Double_t thrustmin=eventshapes->GetAt(1); + Double_t recoil=eventshapes->GetAt(2); + The calculus uses primary particles. The input parameters: + 1. nstudymin, is the minumum number of particles which you want that participate in the calculus.(default:nstudymin =3) + 2. ptcutoff, is the cut in pt applied to participants to calculate the variables.(default: ptcutoff=1) + 3. etacutoff, is the cut in acceptance applied to participants to calculate the variables.(default: etacutoff=1) + 4. if chom=kTRUE, then the calculus includes neutral particles (rejecting photons and neutrinos). + if chom=kFALSE, then the calculus includes only charged particles (rejecting photons and neutrinos). + Returned values: thrust->0: 2-jet event, thrust->0.5: isotropic event + Recoil is a term which is sensitive to radiation outside from acceptance, 1>=recoil>=0, + thrustmin, is a measure of the radiation which is perpendicular to the plane formed by beam axis and thrust axis, 2/TMath::Pi()>thrustmin>0. In the limit of 2 back-to-back jets thrusmin->0, while in the case of a uniformly distributed event thrustmin->2/TMath::Pi(); + */ + + AliStack* stack = 0; + + stack = mcEvent->Stack(); + Double_t * ptT = 0; + Double_t * pxT = 0; + Double_t * pyT = 0; + Double_t ptsuma = 0; + Double_t pxsuma = 0; + Double_t pysuma = 0; + + TArrayD* evsh = new TArrayD(3); + Int_t nPrim = stack->GetNprimary(); + Int_t nmctracks = 0; + for (Int_t iMCTracks = 0; iMCTracks < nPrim; iMCTracks++) { + TParticle* trackmc = stack->Particle(iMCTracks); + if (!trackmc) continue; + Double_t etamc =trackmc ->Eta(); + Double_t ptmc=trackmc->Pt(); + Int_t pdgCode = TMath::Abs(trackmc->GetPdgCode()); + if (TMath::Abs(etamc) > etacutoff) continue; //only particles in |eta|<=etacutoff + if(ptmc < ptcutoff) continue; // PT cut + Bool_t isprimary = stack->IsPhysicalPrimary(iMCTracks); // Check if particle is charged, and primary + if(isprimary == 0) continue; // only primary particles + TParticlePDG* pdgPart =trackmc ->GetPDG(); + if(chom == 1){//include neutral particles + // skip photons and neutrinos + if (pdgCode == 22 || pdgCode == 12 || pdgCode == 14 || pdgCode == 16) continue; + nmctracks++; + } + else{ //only charged particles + if (pdgPart->Charge() == 0)continue; + nmctracks++; + } + } + // Minimum number of particles used in the analysis + if(nmctracks < nstudymin){ + evsh->AddAt(-2,0); + evsh->AddAt(-2,1); + evsh->AddAt(-2,2); + return evsh; + } + + Int_t j=0; + pxT = new Double_t[nmctracks]; + pyT = new Double_t[nmctracks]; + ptT = new Double_t[nmctracks]; + for (Int_t i = 0; i < nmctracks; i++) + { + pxT[i] = 0; + pyT[i] = 0; + ptT[i] = 0; + } + for (Int_t iMCTracks = 0; iMCTracks < nPrim; ++iMCTracks) { + TParticle* trackmc = stack->Particle(iMCTracks); + if (!trackmc) continue; + Double_t etamc = trackmc ->Eta(); + Double_t pxmc = trackmc->Px(); + Double_t pymc = trackmc->Py(); + Double_t ptmc = trackmc->Pt(); + Int_t pdgCode = TMath::Abs(trackmc->GetPdgCode()); + if (TMath::Abs(etamc) > etacutoff) continue; + if(ptmc < ptcutoff) continue; + Bool_t isprimary = stack->IsPhysicalPrimary(iMCTracks); + if(isprimary==0) continue; + TParticlePDG* pdgPart =trackmc ->GetPDG(); + + if(chom==1){ + if (pdgCode == 22 || pdgCode == 12 || pdgCode == 14 || pdgCode == 16)continue; + } else { + if (pdgPart->Charge() == 0) continue; + } + + ptT[j] = ptmc; + pxT[j] = pxmc; + pyT[j] = pymc; + ptsuma += ptmc; + pxsuma+=pxmc; + pysuma+=pymc; + j++; + } + + Double_t numerador = 0; + Double_t numerador2 = 0; + Double_t phimax = -1; + Double_t pFull = -1; + Double_t pMax = 0; + Double_t phi = 0; + Double_t thrust = 80; + Double_t thrustminor = 80; + Double_t nx = 0; + Double_t ny = 0; + Double_t phiparam = 0; + //Getting thrust + for(Int_t i = 0; i < 360; ++i){ + numerador = 0; + phiparam = 0; + nx = 0; + ny = 0; + phiparam=((TMath::Pi()) * i) / 180; // parametrization of the angle + nx = TMath::Cos(phiparam); // x component of an unitary vector n + ny = TMath::Sin(phiparam); // y component of an unitary vector n + for(Int_t i1 = 0; i1 < nmctracks; ++i1){ + numerador += TMath::Abs(nx * pxT[i1] + ny * pyT[i1]);//product between momentum proyection in XY plane and the unitari vector. + } + pFull=numerador / ptsuma; + if(pFull > pMax)//maximization of pFull + { + pMax = pFull; + phi = phiparam; + } + } + + phimax=(phi * 180) / TMath::Pi();//angular parameter of the unitary vector which maximiza thrust + //if n vector and beam axis form a plane, then we can calculate a second unitary vector perpendicular to that plane + Double_t nx1 = TMath::Cos(phi); + Double_t ny1 = TMath::Sin(phi); + for(Int_t i2 =0; i2 < nmctracks; ++i2){ + numerador2 += TMath::Abs(pxT[i2] * ny1 - nx1 * pyT[i2]);//cross product: P_{i} X n, P_{i}=(px_{i},py_{i}) + } + thrust = 1 - pMax;//this is the value of thrust + thrustminor = numerador2 / ptsuma;//this is the value of thrust minor + Double_t recoil = TMath::Abs(TMath::Sqrt(pxsuma * pxsuma + pysuma * pysuma)) / (ptsuma);//factor sentsitive to radiation outside from acceptance + + evsh->AddAt(thrust, 0); + evsh->AddAt(thrustminor, 1); + evsh->AddAt(recoil, 2); + + + delete [] ptT; + delete [] pxT; + delete [] pyT; + + return evsh; +} + + +Double_t AliEventShape::GetCircularityMC(AliMCEvent* mcEvent, Int_t nstudymin, Double_t ptcutoff, Double_t etacutoff, Bool_t chom) +{ + /* + This function returns the circularity value of the event + + The calculus uses primary particles. The input parameters: + 1. nstudymin, is the minumum number of particles which you want that participate in the calculus.(default:nstudymin =3) + 2. ptcutoff, is the cut in pt applied to participants to calculate the variables.(default: ptcutoff=1) + 3. etacutoff, is the cut in acceptance applied to participants to calculate the variables.(default: etacutoff=1) + 4. if chom=kTRUE, then the calculus includes neutral particles (rejecting photons and neutrinos). + if chom=kFALSE, then the calculus includes only charged particles (rejecting photons and neutrinos). + 1>=circularity>=0 + */ + + + AliStack* stack = 0; + + stack = mcEvent->Stack(); + + TMatrixDSym s(2); + + Double_t s00 = 0; + Double_t s01 = 0; + Double_t s10 = 0; + Double_t s11 = 0; + Double_t ptot = 0; + Double_t circularity = -2; + Int_t nmctracks = 0; + Int_t nPrim = stack->GetNprimary(); + + for (Int_t iMCTracks = 0; iMCTracks < nPrim; ++iMCTracks) { + TParticle* trackmc = stack->Particle(iMCTracks); + if (!trackmc) continue; + Double_t etamc = trackmc ->Eta(); + Double_t ptmc = trackmc->Pt(); + Double_t pxmc = trackmc->Px(); + Double_t pymc = trackmc->Py(); + Int_t pdgCode = TMath::Abs(trackmc->GetPdgCode()); + if (TMath::Abs(etamc) > etacutoff) continue; + if (ptmc < ptcutoff) continue; + Bool_t isprimary = stack->IsPhysicalPrimary(iMCTracks); + if (isprimary == 0) continue; + TParticlePDG* pdgPart = trackmc ->GetPDG(); + if(chom == kTRUE){ + // skip photons and neutrinos + if (pdgCode == 22 || pdgCode == 12 || pdgCode == 14 || pdgCode == 16) continue; + } + else{ + if (pdgPart->Charge() == 0)continue; + } + + ptot = ptot + (ptmc * ptmc); + s00 = s00 + (pxmc * pxmc); + s01 = s01 + (pxmc * pymc); + s10 = s10 + (pymc * pxmc); + s11 = s11 + (pymc * pymc); + nmctracks++; + } //track loop + + + if (nmctracks < nstudymin) { + Printf("Too few particles, stopping"); + return -2; + } + + + + if(ptot != 0){ + s(0,0) = s00 / ptot; + s(0,1) = s01 / ptot; + s(1,0) = s10 / ptot; + s(1,1) = s11 / ptot; + const TMatrixDSymEigen eigen(s); + const TVectorD eigenVal=eigen.GetEigenValues(); + circularity = 2 * (1 - eigenVal(0)); + } + return circularity; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/JETAN/DEV/AliEventShape.h b/JETAN/DEV/AliEventShape.h new file mode 100644 index 00000000000..b5acaa56e94 --- /dev/null +++ b/JETAN/DEV/AliEventShape.h @@ -0,0 +1,33 @@ +#ifndef ALIEVENTSHAPE_H +#define ALIEVENTSHAPE_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +//--------------------------------------------------------------------- +// Event shape utility class +// Circularity, Thrust, ... +// Authors: Antonio Ortiz Velasquez +// +//--------------------------------------------------------------------- + +#include + + +class AliMCEvent; +class TParticle; +class TArrayD; + +class AliEventShape : public TObject +{ + public: + static TArrayD * GetThrustParamMC(AliMCEvent* mcEvent, Int_t NSTUDYMIN=3, Double_t ptcutoff=1, Double_t etacutoff=1, Bool_t chom=kFALSE); + static Double_t GetCircularityMC(AliMCEvent* mcEvent, Int_t NSTUDYMIN=3, Double_t ptcutoff=1, Double_t etacutoff=1, Bool_t chom=kFALSE); + private: + AliEventShape(const AliEventShape&); + AliEventShape& operator=(const AliEventShape&); + ClassDef(AliEventShape, 0) +}; + +#endif + diff --git a/JETAN/DEV/AliFastJetBkg.cxx b/JETAN/DEV/AliFastJetBkg.cxx new file mode 100644 index 00000000000..1fd78456362 --- /dev/null +++ b/JETAN/DEV/AliFastJetBkg.cxx @@ -0,0 +1,553 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// Class to calculate the background per unit area +// manages the search for jets +// Authors: Elena Bruna elena.bruna@yale.edu +// Sevil Salur ssalur@lbl.gov +// +// 2011 : +// renamed from AliJetBkg to AliFastJetBkg as this class uses only FASTJET based algos. +//--------------------------------------------------------------------- + +#include +#include +#include +#include + +#include "AliJetHeader.h" +#include "AliFastJetHeaderV1.h" +#include "AliAODJet.h" +#include "AliFastJetInput.h" +#include "AliFastJetBkg.h" + +#include "fastjet/PseudoJet.hh" +#include "fastjet/ClusterSequenceArea.hh" +#include "fastjet/AreaDefinition.hh" +#include "fastjet/JetDefinition.hh" + +#include + +using namespace std; + +ClassImp(AliFastJetBkg) + +//////////////////////////////////////////////////////////////////////// + +AliFastJetBkg::AliFastJetBkg(): + TObject(), + fHeader(0), + fInputFJ(0) +{ + // Default constructor +} + +//______________________________________________________________________ +AliFastJetBkg::AliFastJetBkg(const AliFastJetBkg& input): + TObject(input), + fHeader(input.fHeader), + fInputFJ(input.fInputFJ) +{ + // copy constructor +} + +//______________________________________________________________________ +AliFastJetBkg& AliFastJetBkg::operator=(const AliFastJetBkg& source) +{ + // Assignment operator. + if(this!=&source){ + TObject::operator=(source); + fHeader = source.fHeader; + fInputFJ = source.fInputFJ; + } + + return *this; + +} + +//___________________________________________________________________ +void AliFastJetBkg::BkgFastJetb(Double_t& rho,Double_t& sigma, + Double_t& meanarea) +{ + // Bkg estimation + + AliFastJetHeaderV1 *header = (AliFastJetHeaderV1*)fHeader; + Bool_t debug = header->GetDebug(); // debug option + if(debug>0) cout<<"=============== AliFastJetBkg::BkgFastJetb() =========== "< inputParticles=fInputFJ->GetInputParticles(); + + double rParamBkg = header->GetRparamBkg(); //Radius for background calculation + + Double_t medianb,sigmab,meanareab; + CalcRhob(medianb,sigmab,meanareab,inputParticles,rParamBkg,"All"); + rho=medianb; + sigma=sigmab; + meanarea=meanareab; + +} + +//_________________________________________________________________ +void AliFastJetBkg::BkgFastJetWoHardest(Double_t& rho,Double_t& sigma, + Double_t& meanarea) +{ + + // Bkg estimation without hardest jet + + AliFastJetHeaderV1 *header = (AliFastJetHeaderV1*)fHeader; + Bool_t debug = header->GetDebug(); // debug option + if(debug) cout<<"=============== AliFastJetBkg::BkgWoHardest() =========== "< inputParticles=fInputFJ->GetInputParticles(); + + double rParamBkg = header->GetRparamBkg(); //Radius for background calculation + Double_t medianb,sigmab,meanareab; + CalcRhoWoHardest(medianb,sigmab,meanareab,inputParticles,rParamBkg,"All"); + rho=medianb; + sigma=sigmab; + meanarea=meanareab; + +} + +//____________________________________________________________________ +void AliFastJetBkg::CalcRhob(Double_t& median,Double_t& + sigma,Double_t& + meanarea,vector inputParticles,Double_t + rParamBkg,TString method) +{ + // calculate rho using the fastjet method + + AliFastJetHeaderV1 *header = (AliFastJetHeaderV1*)fHeader; + Bool_t debug = header->GetDebug(); // debug option + + fastjet::Strategy strategy = header->GetStrategy(); + fastjet::RecombinationScheme recombScheme = header->GetRecombScheme(); + fastjet::JetAlgorithm algorithm = header->GetBGAlgorithm(); + fastjet::JetDefinition jetDef(algorithm, rParamBkg, recombScheme, strategy); + + // create an object that specifies how we to define the area + fastjet::AreaDefinition areaDef; + double ghostEtamax = header->GetGhostEtaMax(); + double ghostArea = header->GetGhostArea(); + int activeAreaRepeats = header->GetActiveAreaRepeats(); + + // now create the object that holds info about ghosts + + fastjet::GhostedAreaSpec ghost_spec(ghostEtamax, activeAreaRepeats, ghostArea); + // and from that get an area definition + fastjet::AreaType areaType = header->GetAreaType(); + areaDef = fastjet::AreaDefinition(areaType,ghost_spec); + + //fastjet::ClusterSequenceArea clust_seq(inputParticles, jetDef); + fastjet::ClusterSequenceArea clust_seq(inputParticles, jetDef,areaDef); + TString comment = "Running FastJet algorithm for BKG calculation with the following setup. "; + comment+= "Jet definition: "; + comment+= TString(jetDef.description()); + // comment+= ". Area definition: "; + // comment+= TString(areaDef.description()); + comment+= ". Strategy adopted by FastJet: "; + comment+= TString(clust_seq.strategy_string()); + comment+= Form("Method: %s",method.Data()); + header->SetComment(comment); + if(debug>0){ + cout << "--------------------------------------------------------" << endl; + cout << comment << endl; + cout << "--------------------------------------------------------" << endl; + } + + vector inclusiveJets = clust_seq.inclusive_jets(0.); + vector jets = sorted_by_pt(inclusiveJets); + + double phiMin = 0, phiMax = 0, rapMin = 0, rapMax = 0; + + phiMin = 0; + phiMax = 2*TMath::Pi(); + + rapMax = ghostEtamax - rParamBkg; + rapMin = - ghostEtamax + rParamBkg; + + fastjet::RangeDefinition range(rapMin, rapMax, phiMin, phiMax); + + double medianb, sigmab, meanareab; + clust_seq.get_median_rho_and_sigma(inclusiveJets, range, false, medianb, sigmab, meanareab, false); + median=medianb; + sigma=sigmab; + meanarea=meanareab; + +} + +//____________________________________________________________________ +void AliFastJetBkg::CalcRhoWoHardest(Double_t& median,Double_t& + sigma,Double_t& meanarea,vector inputParticles,Double_t + rParamBkg,TString method) +{ + // calculate rho (without the hardest jet) using the fastjet method + + AliFastJetHeaderV1 *header = (AliFastJetHeaderV1*)fHeader; + Bool_t debug = header->GetDebug(); // debug option + + fastjet::Strategy strategy = header->GetStrategy(); + fastjet::RecombinationScheme recombScheme = header->GetRecombScheme(); + fastjet::JetAlgorithm algorithm = header->GetBGAlgorithm(); + fastjet::JetDefinition jetDef(algorithm, rParamBkg, recombScheme, strategy); + + // create an object that specifies how we to define the area + fastjet::AreaDefinition areaDef; + double ghostEtamax = header->GetGhostEtaMax(); + double ghostArea = header->GetGhostArea(); + int activeAreaRepeats = header->GetActiveAreaRepeats(); + + // now create the object that holds info about ghosts + + fastjet::GhostedAreaSpec ghost_spec(ghostEtamax, activeAreaRepeats, ghostArea); + // and from that get an area definition + fastjet::AreaType areaType = header->GetAreaType(); + areaDef = fastjet::AreaDefinition(areaType,ghost_spec); + //fastjet::ClusterSequenceArea clust_seq(inputParticles, jetDef); + fastjet::ClusterSequenceArea clust_seq(inputParticles,jetDef,areaDef); + TString comment = "Running FastJet algorithm for BKG calculation with the following setup. "; + comment+= "Jet definition: "; + comment+= TString(jetDef.description()); + // comment+= ". Area definition: "; + // comment+= TString(areaDef.description()); + comment+= ". Strategy adopted by FastJet: "; + comment+= TString(clust_seq.strategy_string()); + comment+= Form("Method: %s",method.Data()); + header->SetComment(comment); +if(debug>0){ + cout << "--------------------------------------------------------" << endl; + cout << comment << endl; + cout << "--------------------------------------------------------" << endl; + } + + vector inclusiveJets = clust_seq.inclusive_jets(0.); + vector jets = sorted_by_pt(inclusiveJets); + vector jets2=sorted_by_pt(inclusiveJets); + if(jets2.size()>=2) jets2.erase(jets2.begin(),jets2.begin()+1); + + double phiMin = 0, phiMax = 0, rapMin = 0, rapMax = 0; + + phiMin = 0; + phiMax = 2*TMath::Pi(); + + rapMax = ghostEtamax - rParamBkg; + rapMin = - ghostEtamax + rParamBkg; + + fastjet::RangeDefinition range(rapMin, rapMax, phiMin, phiMax); + + double medianb, sigmab, meanareab; + clust_seq.get_median_rho_and_sigma(jets2, range, false, medianb, sigmab, + meanareab, false); + median=medianb; + sigma=sigmab; + meanarea=meanareab; + +} + +//___________________________________________________________________ +Float_t AliFastJetBkg::BkgFastJet() +{ + // Return background + + AliFastJetHeaderV1 *header = (AliFastJetHeaderV1*)fHeader; + Bool_t debug = header->GetDebug(); // debug option + + if(debug>0) cout<<"=============== AliFastJetBkg::BkgFastJet() =========== "< inputParticles=fInputFJ->GetInputParticles(); + + if(debug>0) cout<<"printing inputParticles for BKG "<GetRparamBkg(); //Radius for background calculation + Double_t rho=CalcRho(inputParticles,rParamBkg,"All"); + if(debug) cout<<"-------- rho (from all part)="<GetDebug(); // debug option + + if(debug>0) cout<<"=============== AliFastJetBkg::BkgChargedFastJet() =========== "< inputParticlesCharged=fInputFJ->GetInputParticlesCh(); + + if(debug>0) cout<<"printing CHARGED inputParticles for BKG "<GetRparam(); + + Double_t rho=CalcRho(inputParticlesCharged,rParam,"Charg"); + + if(debug>0) cout<<"-------- rho (from CHARGED part)="<GetDebug(); // debug option + + if(debug>0) cout<<"==============AliFastJetBkg::BkgStat()============="<GetDebug(); // debug option + + if(debug>0) cout<<"==============AliFastJetBkg::SubtractFastJetBackgCone()============="<GetRparam(); + + //Hard wired Calorimeter area (get it later from the AliJetReaderHeader.h) + Double_t accEMCal=2*0.7*110./180*TMath::Pi();//2.68 area of EMCal + + Int_t nJ=fAODJets->GetEntries(); //this must be the # of jets... + if(debug>0) cout<<"nJets: "<At(0)); + jeteta=jettmp->Eta(); + jetphi=jettmp->Phi(); + acc=EmcalAcceptance(jeteta,jetphi,rCone); + if(acc==1)restarea= accEMCal-TMath::Pi()*rc*rc; + if(debug) cout<<" acc "<=2) { + AliAODJet *jettmp = (AliAODJet*)(fAODJets->At(0)); + AliAODJet *jettmp1 = (AliAODJet*)(fAODJets->At(1)); + jeteta=jettmp->Eta(); + jetphi=jettmp->Phi(); + jeteta1=jettmp1->Eta(); + jetphi1=jettmp1->Phi(); + acc=EmcalAcceptance(jeteta,jetphi,rCone); + acc1=EmcalAcceptance(jeteta1,jetphi1,rCone); + if(acc1==1 && acc==1)restarea= accEMCal-2*TMath::Pi()*rc*rc; + if(acc1==1 && acc==0)restarea= accEMCal-TMath::Pi()*rc*rc; + if(acc1==0 && acc==1)restarea= accEMCal-TMath::Pi()*rc*rc; + + if(debug) cout<<" acc1="<1) cout<<" out of the cone "<0) cout<<"total area left "<0) cout<<"sumpt="< inputParticles,Double_t rParamBkg,TString method) +{ + // calculate rho using the fastjet method + + AliFastJetHeaderV1 *header = (AliFastJetHeaderV1*)fHeader; + Bool_t debug = header->GetDebug(); // debug option + + fastjet::Strategy strategy = header->GetStrategy(); + fastjet::RecombinationScheme recombScheme = header->GetRecombScheme(); + fastjet::JetAlgorithm algorithm = header->GetBGAlgorithm(); + fastjet::JetDefinition jetDef(algorithm, rParamBkg, recombScheme, strategy); + + // create an object that specifies how we to define the area + fastjet::AreaDefinition areaDef; + double ghostEtamax = header->GetGhostEtaMax(); + double ghostArea = header->GetGhostArea(); + int activeAreaRepeats = header->GetActiveAreaRepeats(); + + // now create the object that holds info about ghosts + + if (method.Contains("Charg"))ghostEtamax=0.9; + + fastjet::GhostedAreaSpec ghost_spec(ghostEtamax, activeAreaRepeats, ghostArea); + // and from that get an area definition + fastjet::AreaType areaType = header->GetAreaType(); + areaDef = fastjet::AreaDefinition(areaType,ghost_spec); + if(debug>0) cout<<"rParamBkg="<SetComment(comment); + if(debug>0){ + cout << "--------------------------------------------------------" << endl; + cout << comment << endl; + cout << "--------------------------------------------------------" << endl; + } + + double ptmin = header->GetPtMin(); + vector inclusiveJets = clust_seq.inclusive_jets(ptmin); + vector jets = sorted_by_pt(inclusiveJets); + + if (debug>0) { + cout<<"# of BKG jets = "<0) cout<<"bkg in R="< input_particles,Double_t RparamBkg,TString method); + void CalcRhob(Double_t& median, Double_t& sigma, Double_t& meanarea, + vector input_particles,Double_t RparamBkg,TString method); + void CalcRhoWoHardest(Double_t& median, Double_t& sigma, Double_t& meanarea, + vector input_particles,Double_t RparamBkg,TString method); + + AliJetHeader* fHeader; //! header + AliFastJetInput* fInputFJ; //! input particles + + ClassDef(AliFastJetBkg, 2) // Fastjet backgroud analysis + +}; + +#endif diff --git a/JETAN/DEV/AliFastJetFinder.cxx b/JETAN/DEV/AliFastJetFinder.cxx new file mode 100644 index 00000000000..ddce4776bc8 --- /dev/null +++ b/JETAN/DEV/AliFastJetFinder.cxx @@ -0,0 +1,369 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// FastJet v2.3.4 finder algorithm interface +// Last modification: Neutral cell energy included in the jet reconstruction +// +// Authors: Rafael.Diaz.Valdes@cern.ch +// Magali.estienne@subatech.in2p3.fr (neutral part + bg subtraction option) +// +// ** 2011 magali.estienne@subatech.in2p3.fr & alexandre.shabetai@cern.ch +// new implementation of background subtraction +// allowing to subtract bkg using a different algo than the one used for signal jets +//--------------------------------------------------------------------- + +#include + +#include "AliFastJetFinder.h" +#include "AliFastJetHeaderV1.h" +#include "AliFastJetInput.h" +#include "AliFastJetBkg.h" +#include "AliAODJetEventBackground.h" +#include "AliAODJet.h" + +#include "fastjet/PseudoJet.hh" +#include "fastjet/ClusterSequenceArea.hh" +#include "fastjet/AreaDefinition.hh" +#include "fastjet/JetDefinition.hh" + +#include + +using namespace std; + +ClassImp(AliFastJetFinder) + +//////////////////////////////////////////////////////////////////////// + +AliFastJetFinder::AliFastJetFinder(): + AliJetFinder(), + fInputFJ(new AliFastJetInput()), + fJetBkg(new AliFastJetBkg()) +{ + // Constructor +} + +//____________________________________________________________________________ +AliFastJetFinder::~AliFastJetFinder() +{ + // destructor + delete fInputFJ; + delete fJetBkg; + +} + +//______________________________________________________________________________ +void AliFastJetFinder::FindJets() +{ + // runs a FASTJET based algo + + //pick up fastjet header + AliFastJetHeaderV1 *header = (AliFastJetHeaderV1*)fHeader; + Int_t debug = header->GetDebug(); // debug option + Bool_t bgMode = header->GetBGMode(); // choose to subtract BG or not + if(debug>0) cout<<"----------in AliFastJetFinder::FindJets() ------------------"< inputParticles=fInputFJ->GetInputParticles(); + if(inputParticles.size()==0){ + if(debug>0) Printf("%s:%d No input particles found, skipping event",(char*)__FILE__,__LINE__); + return; + } + + // create an object that represents your choice of jet algorithm, and + // the associated parameters + double rParam = header->GetRparam(); + double rBkgParam = header->GetRparamBkg(); + fastjet::Strategy strategy = header->GetStrategy(); + fastjet::RecombinationScheme recombScheme = header->GetRecombScheme(); + fastjet::JetAlgorithm algorithm = header->GetAlgorithm(); + fastjet::JetDefinition jetDef(algorithm, rParam, recombScheme, strategy); + + // create an object that specifies how we to define the area + fastjet::AreaDefinition areaDef; + double ghostEtamax = header->GetGhostEtaMax(); + double ghostArea = header->GetGhostArea(); + int activeAreaRepeats = header->GetActiveAreaRepeats(); + + // now create the object that holds info about ghosts + fastjet::GhostedAreaSpec ghostSpec(ghostEtamax, activeAreaRepeats, ghostArea); + // and from that get an area definition + fastjet::AreaType areaType = header->GetAreaType(); + areaDef = fastjet::AreaDefinition(areaType,ghostSpec); + + //***************************** JETS FINDING + // run the jet clustering with the above jet definition + fastjet::ClusterSequenceArea clust_seq(inputParticles, jetDef, areaDef); + + vector jets; + + if(bgMode) // Do BG subtraction directly with the same algorithm (cambridge or kt) for jet signal and background + { + //***************************** JETS FINDING FOR RHO ESTIMATION + // run the jet clustering with the above jet definition + fastjet::JetAlgorithm algorithmBkg = header->GetBGAlgorithm(); + fastjet::JetDefinition jetDefBkg(algorithmBkg, rBkgParam, recombScheme, strategy); + fastjet::ClusterSequenceArea clust_seq_bkg(inputParticles, jetDefBkg, areaDef); + + // save a comment in the header + TString comment = "Running FastJet algorithm with the following setup. "; + comment+= "Jet definition: "; + comment+= TString(jetDef.description()); + comment+= "Jet bckg definition: "; + comment+= TString(jetDefBkg.description()); + comment+= ". Area definition: "; + comment+= TString(areaDef.description()); + comment+= ". Strategy adopted by FastJet: "; + comment+= TString(clust_seq.strategy_string()); + header->SetComment(comment); + if(debug>0){ + cout << "--------------------------------------------------------" << endl; + cout << comment << endl; + cout << "--------------------------------------------------------" << endl; + } + + // extract the inclusive jets sorted by pt + double ptmin = header->GetPtMin(); + vector inclusiveJets = clust_seq.inclusive_jets(); + + //subtract background // =========================================== + // set the rapididty , phi range within which to study the background + double rapMax = header->GetRapMax(); + double rapMin = header->GetRapMin(); + double phiMax = header->GetPhiMax(); + double phiMin = header->GetPhiMin(); + fastjet::RangeDefinition range(rapMin, rapMax, phiMin, phiMax); + + // Extract rho and sigma + Double_t rho = 0.; + Double_t sigma = 0.; + Double_t meanarea = 0.; + Bool_t kUse4VectorArea = header->Use4VectorArea(); + vector bkgJets = clust_seq_bkg.inclusive_jets(); + clust_seq_bkg.get_median_rho_and_sigma(bkgJets,range, kUse4VectorArea, rho, sigma, meanarea, false); + + // subtract background and extract jets bkg subtracted + vector subJets = clust_seq.subtracted_jets(rho,ptmin); + + // sort jets into increasing pt + jets = sorted_by_pt(subJets); + + } + + else { // No BG subtraction!!!!!!!! Default header is bgmode=0. + + // save a comment in the header + TString comment = "Running FastJet algorithm with the following setup. "; + comment+= "Jet definition: "; + comment+= TString(jetDef.description()); + comment+= ". Strategy adopted by FastJet: "; + comment+= TString(clust_seq.strategy_string()); + header->SetComment(comment); + if(debug>0){ + cout << "--------------------------------------------------------" << endl; + cout << comment << endl; + cout << "--------------------------------------------------------" << endl; + } + + // extract the inclusive jets with pt > ptmin, sorted by pt + double ptmin = header->GetPtMin(); + vector inclusiveJets = clust_seq.inclusive_jets(ptmin); + + jets = sorted_by_pt(inclusiveJets); + + } + + for (size_t j = 0; j < jets.size(); j++) { // loop for jets + + double area = clust_seq.area(jets[j]); + double areaError = clust_seq.area_error(jets[j]); + + if(debug>0) printf("Jet found %5d %9.5f %8.5f %10.3f \n",(Int_t)j,jets[j].rap(),jets[j].phi(),jets[j].perp()); + + vector constituents = clust_seq.constituents(jets[j]); + int nCon= constituents.size(); + TArrayI ind(nCon); + + if ((jets[j].eta() > (header->GetJetEtaMax())) || + (jets[j].eta() < (header->GetJetEtaMin())) || + (jets[j].phi() > (header->GetJetPhiMax())) || + (jets[j].phi() < (header->GetJetPhiMin())) || + (jets[j].perp() < header->GetPtMin())) continue; // acceptance eta range and etmin + + // go to write AOD info + AliAODJet aodjet (jets[j].px(), jets[j].py(), jets[j].pz(), jets[j].E()); + aodjet.SetEffArea(area,areaError); + //cout << "Printing jet " << endl; + if(debug>0) aodjet.Print(""); + + for (int i=0; i < nCon; i++) + { + fastjet::PseudoJet mPart=constituents[i]; + ind[i]=mPart.user_index(); + + // Jet constituents (charged tracks) added to the AliAODJet + AliJetCalTrkEvent* calEvt = GetCalTrkEvent(); + for(Int_t itrack=0; itrackGetNCalTrkTracks(); itrack++) + { + if(itrack==ind[i]) + { + TObject *track = calEvt->GetCalTrkTrack(itrack)->GetTrackObject(); + aodjet.AddTrack(track); + } + } + } // End loop on Constituents + + AddJet(aodjet); + + } // end loop for jets + +} + +//____________________________________________________________________________ +void AliFastJetFinder::RunTest(const char* datafile) +{ + // This simple test run the kt algorithm for an ascii file testdata.dat + + // read input particles ----------------------------- + vector inputParticles; + Float_t px,py,pz,en; + ifstream in; + Int_t nlines = 0; + // we assume a file basic.dat in the current directory + // this file has 3 columns of float data + in.open(datafile); + while (1) { + in >> px >> py >> pz >> en; + if (!in.good()) break; + //printf("px=%8f, py=%8f, pz=%8fn",px,py,pz); + nlines++; + inputParticles.push_back(fastjet::PseudoJet(px,py,pz,en)); + } + //printf(" found %d pointsn",nlines); + in.close(); + ////////////////////////////////////////////////// + + // create an object that represents your choice of jet algorithm, and + // the associated parameters + double rParam = 1.0; + fastjet::Strategy strategy = fastjet::Best; + fastjet::RecombinationScheme recombScheme = fastjet::BIpt_scheme; + fastjet::JetDefinition jetDef(fastjet::kt_algorithm, rParam, recombScheme, strategy); + + // create an object that specifies how we to define the area + fastjet::AreaDefinition areaDef; + double ghostEtamax = 7.0; + double ghostArea = 0.05; + int activeAreaRepeats = 1; + + // now create the object that holds info about ghosts + fastjet::GhostedAreaSpec ghostSpec(ghostEtamax, activeAreaRepeats, ghostArea); + // and from that get an area definition + areaDef = fastjet::AreaDefinition(fastjet::active_area,ghostSpec); + + // run the jet clustering with the above jet definition + fastjet::ClusterSequenceArea clust_seq(inputParticles, jetDef, areaDef); + + // tell the user what was done + cout << "--------------------------------------------------------" << endl; + cout << "Jet definition was: " << jetDef.description() << endl; + cout << "Area definition was: " << areaDef.description() << endl; + cout << "Strategy adopted by FastJet was "<< clust_seq.strategy_string()< 5 GeV, sorted by pt + double ptmin = 5.0; + vector inclusiveJets = clust_seq.inclusive_jets(ptmin); + + cout << "Number of unclustered particles: " << clust_seq.unclustered_particles().size() << endl; + + //subtract background // =========================================== + // set the rapididty range within which to study the background + double rapMax = ghostEtamax - rParam; + fastjet::RangeDefinition range(rapMax); + // subtract background + vector subJets = clust_seq.subtracted_jets(range,ptmin); + + // print them out //================================================ + cout << "Printing inclusive jets after background subtraction \n"; + cout << "------------------------------------------------------\n"; + // sort jets into increasing pt + vector jets = sorted_by_pt(subJets); + + printf(" ijet rap phi Pt area +- err\n"); + for (size_t j = 0; j < jets.size(); j++) { + double area = clust_seq.area(jets[j]); + double areaError = clust_seq.area_error(jets[j]); + printf("%5d %9.5f %8.5f %10.3f %8.3f +- %6.3f\n",(Int_t)j,jets[j].rap(), + jets[j].phi(),jets[j].perp(), area, areaError); + } + cout << endl; + // ================================================================ + +} + +//____________________________________________________________________________ +void AliFastJetFinder::WriteJHeaderToFile() const +{ + // Write Jet Header to file + fHeader->Write(); + +} + +//____________________________________________________________________________ +Bool_t AliFastJetFinder::ProcessEvent() +{ + // Process one event + // Charged only or charged+neutral jets + + fInputFJ->SetHeader(fHeader); + fInputFJ->SetCalTrkEvent(GetCalTrkEvent()); + fInputFJ->FillInput(); + + // Find Jets + FindJets(); + + // Background + if(fAODEvBkg){ + AliFastJetHeaderV1 *header = (AliFastJetHeaderV1*)fHeader; + + fJetBkg->SetHeader(fHeader); + fJetBkg->SetFastJetInput(fInputFJ); + + Int_t count = 0; + if(header->GetBkgFastJetb()){ + Double_t sigma1 = 0 , meanarea1= 0, bkg1 = 0; + fJetBkg->BkgFastJetb(bkg1,sigma1,meanarea1); + fAODEvBkg->SetBackground(count,bkg1,sigma1,meanarea1); + count++; + } + + if(header->GetBkgFastJetWoHardest()){ + Double_t sigma2 = 0 , meanarea2 = 0, bkg2 = 0; + fJetBkg->BkgFastJetWoHardest(bkg2,sigma2,meanarea2); + fAODEvBkg->SetBackground(count,bkg2,sigma2,meanarea2); + count++; + } + + } + + Reset(); + return kTRUE; + +} diff --git a/JETAN/DEV/AliFastJetFinder.h b/JETAN/DEV/AliFastJetFinder.h new file mode 100644 index 00000000000..df594d36245 --- /dev/null +++ b/JETAN/DEV/AliFastJetFinder.h @@ -0,0 +1,54 @@ +#ifndef ALIFASTJETFINDER_H +#define ALIFASTJETFINDER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// FastJet v2.3.4 finder algorithm interface +// +// Author: Rafael.Diaz.Valdes@cern.ch +// +// ** 2011 magali.estienne@subatech.in2p3.fr & alexandre.shabetai@cern.ch +// new implementation of background subtraction +// allowing to subtract bkg using a different algo than the one used for signal jets +//--------------------------------------------------------------------- + +// FastJet classes +#include "fastjet/PseudoJet.hh" +#include "fastjet/ClusterSequenceArea.hh" +#include "fastjet/AreaDefinition.hh" +#include "fastjet/JetDefinition.hh" + +#include "AliJetFinder.h" + +class AliFastJetInput; +class AliFastJetBkg; + +using namespace std; + +class AliFastJetFinder : public AliJetFinder +{ + public: + + AliFastJetFinder(); + ~AliFastJetFinder(); + + virtual void FindJets(); + void RunTest(const char* datafile); // a simple test + virtual void WriteJHeaderToFile() const; + virtual Bool_t ProcessEvent(); + + protected: + AliFastJetFinder(const AliFastJetFinder& rfj); + AliFastJetFinder& operator = (const AliFastJetFinder& rsfj); + AliFastJetInput* fInputFJ; //! input particles array + AliFastJetBkg* fJetBkg; //! pointer to bkg class + + ClassDef(AliFastJetFinder,3) // Fastjet analysis class + +}; + +#endif diff --git a/JETAN/DEV/AliFastJetHeaderV1.cxx b/JETAN/DEV/AliFastJetHeaderV1.cxx new file mode 100644 index 00000000000..698a02c0f0a --- /dev/null +++ b/JETAN/DEV/AliFastJetHeaderV1.cxx @@ -0,0 +1,89 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// FastJet v2.3.4 finder algorithm interface +// Finder Header Class +// Author: Rafael.Diaz.Valdes@cern.ch +//--------------------------------------------------------------------- + +#include +#include + +#include "fastjet/AreaDefinition.hh" +#include "fastjet/JetDefinition.hh" + +#include "AliFastJetHeaderV1.h" + +ClassImp(AliFastJetHeaderV1) + +//////////////////////////////////////////////////////////////////////// + +AliFastJetHeaderV1::AliFastJetHeaderV1(): + AliJetHeader("AliFastJetHeaderV1"), + fRparam(0.4), + fRparamBkg(0.4), + fAlgorithm(fastjet::kt_algorithm), + fBGAlgorithm(fastjet::kt_algorithm), + fStrategy(fastjet::Best), + fRecombScheme(fastjet::BIpt_scheme), + fGhostEtaMax(2.0), + fGhostArea(0.01), + fActiveAreaRepeats(1), + fAreaType(fastjet::active_area), + fPtMin(5.0), + fMinCellEt(0.), + fRapMax(0.), + fRapMin(0.), + fPhiMax(TMath::TwoPi()), + fPhiMin(0), + fUse4VectorArea(kFALSE), + fkBkgFastJetb(kFALSE), + fktBkgFastJetWoHardest(kFALSE) +{ + // Default constructor + Double_t rapmax = fGhostEtaMax - fRparam; + Double_t rapmin = -fGhostEtaMax + fRparam; + SetRapRange(rapmin, rapmax); + +} + +//____________________________________________________________________________ +void AliFastJetHeaderV1::PrintParameters() const +{ + // prints out parameters of jet algorithm + + cout << "FastJet algorithm parameters:" << endl; + cout << "-- Jet Definition --- " << endl; + cout << "R " << fRparam << endl; + cout << "Jet Algorithm " << fAlgorithm << endl; + cout << "Bkg Jet Algorithm " << fBGAlgorithm << endl; + cout << "Strategy " << fStrategy << endl; + cout << "Recombination Scheme " << fRecombScheme << endl; + cout << "-- Ghosted Area Spec parameters --- " << endl; + cout << "Ghost Eta Max " << fGhostEtaMax << endl; + cout << "Ghost Area " << fGhostArea << endl; + cout << "Active Area Repeats " << fActiveAreaRepeats << endl; + cout << "-- Area Definition parameters --- " << endl; + cout << "Area Type " << fAreaType << endl; + cout << "-- Cluster Sequence Area parameters --- " << endl; + cout << "pt min " << fPtMin << endl; + cout << "-- Range Definition parameters --- " << endl; + cout << " bkg rapidity range from " << fRapMin << " to " << fRapMax << endl; + cout << " bkg phi range from " << fPhiMin << " to " << fPhiMax << endl; + +} diff --git a/JETAN/DEV/AliFastJetHeaderV1.h b/JETAN/DEV/AliFastJetHeaderV1.h new file mode 100644 index 00000000000..d1c01b84339 --- /dev/null +++ b/JETAN/DEV/AliFastJetHeaderV1.h @@ -0,0 +1,102 @@ +#ifndef ALIFASTJETHEADERV1_H +#define ALIFASTJETHEADERV1_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// FastJet v2.3.4 finder algorithm interface +// Finder Header Class +// Author: Rafael.Diaz.Valdes@cern.ch +//--------------------------------------------------------------------- + +#include "fastjet/AreaDefinition.hh" +#include "fastjet/JetDefinition.hh" + +#include "AliJetHeader.h" + +class AliFastJetHeaderV1 : public AliJetHeader +{ + public: + AliFastJetHeaderV1(); + virtual ~AliFastJetHeaderV1() { } + + // Getters + Double_t GetRparam() const {return fRparam;} + fastjet::JetAlgorithm GetAlgorithm() const {return fAlgorithm;} + fastjet::JetAlgorithm GetBGAlgorithm() const {return fBGAlgorithm;} + fastjet::Strategy GetStrategy() const {return fStrategy;} + fastjet::RecombinationScheme GetRecombScheme() const {return fRecombScheme;} + Double_t GetGhostEtaMax() const {return fGhostEtaMax;} + Double_t GetGhostArea() const {return fGhostArea;} + Int_t GetActiveAreaRepeats() const {return fActiveAreaRepeats;} + fastjet::AreaType GetAreaType() const {return fAreaType;} + Double_t GetPtMin() const {return fPtMin;} + Double_t GetRapMax() const {return fRapMax;} + Double_t GetRapMin() const {return fRapMin;} + Double_t GetPhiMax() const {return fPhiMax;} + Double_t GetPhiMin() const {return fPhiMin;} + Bool_t GetBGMode() const {return fBGMode;} + Double_t GetRparamBkg() const {return fRparamBkg;} + Bool_t Use4VectorArea() const {return fUse4VectorArea;} + Bool_t GetBkgFastJetb() const {return fkBkgFastJetb;} + Bool_t GetBkgFastJetWoHardest() const {return fktBkgFastJetWoHardest;} + // Setters + void SetRparam(Double_t f) {fRparam = f;} + void SetAlgorithm(fastjet::JetAlgorithm f) {fAlgorithm = f;} + void SetBGAlgorithm(fastjet::JetAlgorithm f) {fBGAlgorithm = f;} + void SetStrategy(fastjet::Strategy f) {fStrategy = f;} + void SetRecombScheme(fastjet::RecombinationScheme f) {fRecombScheme = f;} + void SetGhostEtaMax(Double_t f) {fGhostEtaMax = f;} + void SetGhostArea(Double_t f) {fGhostArea = f;} + void SetActiveAreaRepeats(Int_t f) {fActiveAreaRepeats =f;} + void SetAreaType(fastjet::AreaType f) {fAreaType = f;} + void SetRapRange(Double_t fmin, Double_t fmax) {fRapMin = fmin; fRapMax = fmax;} + void SetPhiRange(Double_t fmin, Double_t fmax) {fPhiMin = fmin; fPhiMax = fmax;} + void SetPtMin(Double_t ptmin) {fPtMin = ptmin;} + void SetBGMode(Bool_t bgmode) {fBGMode = bgmode;} + void SetUse4VectorArea() {fUse4VectorArea = kTRUE;} + void SetComment(TString com) {fComment=com;} + void SetComment(const char* com) {AliJetHeader::SetComment(com);} + void SetRparamBkg(Double_t f) {fRparamBkg = f;} + void SetBkgFastJetb(Bool_t f = 1) {fkBkgFastJetb = f;} + void SetBkgFastJetWoHardest(Bool_t f = 1) {fktBkgFastJetWoHardest = f;} + // others + void PrintParameters() const; + + protected: + //fastjet::JetDefinition parameters + Double_t fRparam; // R param + Double_t fRparamBkg; // R param for bkg calculation + fastjet::JetAlgorithm fAlgorithm; // fastjet::kt_algorithm + fastjet::JetAlgorithm fBGAlgorithm; // fastjet::kt_algorithm + fastjet::Strategy fStrategy; // fastjet::Best; + fastjet::RecombinationScheme fRecombScheme; // fastjet::BIpt_scheme; + + //fastjet::GhostedAreaSpec parameters + Double_t fGhostEtaMax; // Max eta for ghosts + Double_t fGhostArea; // Ghost area + Int_t fActiveAreaRepeats; // Active are repetitions + + //fastjet::AreaDefinition parameters + fastjet::AreaType fAreaType; // area types + + //fastjet::ClusterSequenceArea options parameters + Double_t fPtMin; // jets with pt > ptmin + Float_t fMinCellEt; // Min Et in one cell + + //fastjet::RangeDefinition parameters + Double_t fRapMax, fRapMin; // rapidity range of background sub + Double_t fPhiMax, fPhiMin; // phi range of background sub + Bool_t fUse4VectorArea; // Toggle use of 4-vector area + + //background methods flags + Bool_t fkBkgFastJetb; // Toggle background estimation using AliFastJetBkg::BkgFastJetb() + Bool_t fktBkgFastJetWoHardest; // Toggle background estimation using AliFastJetBkg::BkgFastJetWoHardest() + + ClassDef(AliFastJetHeaderV1,4) // Fastjet header class +}; + +#endif diff --git a/JETAN/DEV/AliFastJetInput.cxx b/JETAN/DEV/AliFastJetInput.cxx new file mode 100644 index 00000000000..89ae79cd75b --- /dev/null +++ b/JETAN/DEV/AliFastJetInput.cxx @@ -0,0 +1,132 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// Class for input particles +// manages the search for jets +// Authors: Elena Bruna elena.bruna@yale.edu +// +// ** 2011 magali.estienne@subatech.in2p3.fr & alexandre.shabetai@cern.ch +// Modified accordingly to reader/finder splitting and new handling of neutral information +//--------------------------------------------------------------------- + +#include + +#include "AliJetHeader.h" +#include "AliFastJetHeaderV1.h" +#include "AliFastJetInput.h" +#include "AliJetCalTrk.h" + +#include "fastjet/PseudoJet.hh" + +#include + +using namespace std; + +ClassImp(AliFastJetInput) + +//////////////////////////////////////////////////////////////////////// + +AliFastJetInput::AliFastJetInput(): + fHeader(0x0), + fCalTrkEvent(0x0), + fInputParticles(0), + fInputParticlesCh(0) +{ + // Default constructor +} + +//______________________________________________________________________ +AliFastJetInput::AliFastJetInput(const AliFastJetInput &input): + TObject(input), + fHeader(input.fHeader), + fCalTrkEvent(input.fCalTrkEvent), + fInputParticles(input.fInputParticles), + fInputParticlesCh(input.fInputParticlesCh) +{ + // copy constructor +} + +//______________________________________________________________________ +AliFastJetInput& AliFastJetInput::operator=(const AliFastJetInput& source) +{ + // Assignment operator. + if(this!=&source){ + TObject::operator=(source); + fHeader = source.fHeader; + fCalTrkEvent = source.fCalTrkEvent; + fInputParticles = source.fInputParticles; + fInputParticlesCh = source.fInputParticlesCh; + } + + return *this; + +} + +//___________________________________________________________ +void AliFastJetInput::FillInput() +{ + // fills input particles for FASTJET based analysis + + AliFastJetHeaderV1 *header = (AliFastJetHeaderV1*)fHeader; + Int_t debug = header->GetDebug(); // debug option + + if(debug>0) cout<<"-------- AliFastJetInput::FillInput() ----------------"< inputParticles; + + if(fCalTrkEvent == 0) { cout << "Could not get the CalTrk Event" << endl; return; } + Int_t nIn = fCalTrkEvent->GetNCalTrkTracks() ; + if(nIn == 0) { if (debug>0) cout << "entries = 0 ; Event empty !!!" << endl ; return; } + + // Information extracted from fCalTrkEvent + // load input vectors and calculate total energy in array + Float_t px = -999., py = -999., pz = -999., en = -999.; + + // Fill charged tracks + for(Int_t i = 0; i < fCalTrkEvent->GetNCalTrkTracks(); i++) + { // loop for all input particles + if (fCalTrkEvent->GetCalTrkTrack(i)->GetCutFlag() != 1) continue; + px = fCalTrkEvent->GetCalTrkTrack(i)->GetPx(); + py = fCalTrkEvent->GetCalTrkTrack(i)->GetPy(); + pz = fCalTrkEvent->GetCalTrkTrack(i)->GetPz(); + en = fCalTrkEvent->GetCalTrkTrack(i)->GetP(); + + fastjet::PseudoJet inputPart(px,py,pz,en); // create PseudoJet object + inputPart.set_user_index(i); //label the particle into Fastjet algortihm + fInputParticles.push_back(inputPart); // back of the inputParticles vector + + // only for charged particles (TPC+ITS) + fastjet::PseudoJet inputPartCh(px,py,pz,en); // create PseudoJet object + inputPartCh.set_user_index(i); //label the particle into Fastjet algortihm + fInputParticlesCh.push_back(inputPartCh); // back of the inputParticles vector + } // End loop on CalTrk + +} + +//_____________________________________________________________________ +Double_t AliFastJetInput::Thermalspectrum(const Double_t *x, const Double_t *par) +{ + // compute an exponential function + return x[0]*TMath::Exp(-x[0]/par[0]); + +} diff --git a/JETAN/DEV/AliFastJetInput.h b/JETAN/DEV/AliFastJetInput.h new file mode 100644 index 00000000000..9e6425ec211 --- /dev/null +++ b/JETAN/DEV/AliFastJetInput.h @@ -0,0 +1,53 @@ +#ifndef ALIFASTJETINPUT_H +#define ALIFASTJETINPUT_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// Class for input particles +// manages the search for jets +// Authors: Elena Bruna elena.bruna@yale.edu +// +// ** 2011 magali.estienne@subatech.in2p3.fr & alexandre.shabetai@cern.ch +// Modified accordingly to reader/finder splitting and new handling of neutral information +//--------------------------------------------------------------------- + +#include + +// FastJet classes +#include "fastjet/PseudoJet.hh" + +#include + +class AliJetCalTrkEvent; +class AliJetHeader; + +class AliFastJetInput : public TObject +{ + public: + AliFastJetInput(); + AliFastJetInput(const AliFastJetInput &input); + AliFastJetInput& operator=(const AliFastJetInput& source); + virtual ~AliFastJetInput() {;} + void SetHeader(AliJetHeader *header) {fHeader=header;} + void SetCalTrkEvent(AliJetCalTrkEvent *caltrk) {fCalTrkEvent=caltrk;} + void FillInput(); + vector GetInputParticles() const {return fInputParticles;} + vector GetInputParticlesCh() const {return fInputParticlesCh;} + static Double_t Thermalspectrum(const Double_t *x, const Double_t *par); + + private: + AliJetHeader *fHeader; //! header + AliJetCalTrkEvent *fCalTrkEvent; //! caltrkevent + + vector fInputParticles; //! input particles for FastJet + vector fInputParticlesCh; //! input charged particles for FastJet + + ClassDef(AliFastJetInput, 2) // fills input particles for FASTJET based analysis + +}; + +#endif diff --git a/JETAN/DEV/AliJetBkg.cxx b/JETAN/DEV/AliJetBkg.cxx new file mode 100644 index 00000000000..9409d4a2613 --- /dev/null +++ b/JETAN/DEV/AliJetBkg.cxx @@ -0,0 +1,564 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//-------------------------------------------------- +// Method implementation for background studies and background subtraction with UA1 algorithms +// +// Author: magali.estienne@subatech.in2p3.fr +//------------------------------------------------- + +#include +#include +#include +#include +#include + +#include "AliAODJetEventBackground.h" +#include "AliUA1JetHeaderV1.h" +#include "AliJetCalTrk.h" +#include "AliJetBkg.h" + + +using namespace std; + +ClassImp(AliJetBkg) + +//////////////////////////////////////////////////////////////////////// + +AliJetBkg::AliJetBkg(): + TObject(), + fEvent(0x0), + fHeader(0x0), + fDebug(0), + fhEtBackg(0x0), + fhAreaBackg(0x0) +{ + // Default constructor + for(int i = 0;i < kMaxJets;i++){ + fhAreaJet[i] = fhEtJet[i] = 0; + } +} + +//---------------------------------------------------------------- +AliJetBkg::AliJetBkg(const AliJetBkg& input): + TObject(input), + fEvent(input.fEvent), + fHeader(input.fHeader), + fDebug(input.fDebug), + fhEtBackg(input.fhEtBackg), + fhAreaBackg(input.fhAreaBackg) +{ + // copy constructor + for(int i = 0;i < kMaxJets;i++){ + fhAreaJet[i] = input.fhAreaJet[i]; + fhEtJet[i] = input.fhEtJet[i]; + } + +} + +//---------------------------------------------------------------- +AliJetBkg::~AliJetBkg() +{ + // Destructor + if(fhEtBackg) delete fhEtBackg; + if(fhAreaBackg) delete fhAreaBackg; + for(int i = 0;i < kMaxJets;i++){ + if(fhAreaJet[i]) delete fhAreaJet[i]; + if(fhEtJet[i]) delete fhEtJet[i]; + } + +} + +//---------------------------------------------------------------- +Bool_t AliJetBkg::PtCutPass(Int_t id, Int_t nTracks) +{ + // Check if track or cell passes the cut flag + if(id < nTracks && fEvent->GetCalTrkTrack(id)->GetCutFlag() == 1) + return kTRUE; + else return kFALSE; + +} + +//---------------------------------------------------------------- +Bool_t AliJetBkg::SignalCutPass(Int_t id, Int_t nTracks) +{ + // Check if track or cell passes the cut flag + if(id < nTracks && fEvent->GetCalTrkTrack(id)->GetSignalFlag() == 1) + return kTRUE; + else return kFALSE; + +} + +//---------------------------------------------------------------- +Float_t AliJetBkg::CalcJetAreaEtaCut(Float_t radius, const Float_t etaJet) +{ + // Calculate jet area taking into account an acceptance cut in eta + AliUA1JetHeader* header = (AliUA1JetHeader*) fHeader; + Float_t detamax = etaJet + radius; + Float_t detamin = etaJet - radius; + Float_t accmax = 0.0; Float_t accmin = 0.0; + if(detamax > header->GetLegoEtaMax()){ // sector outside etamax + Float_t h = header->GetLegoEtaMax() - etaJet; + accmax = radius*radius*TMath::ACos(h/radius) - h*TMath::Sqrt(radius*radius - h*h); + } + if(detamin < header->GetLegoEtaMin()){ // sector outside etamin + Float_t h = header->GetLegoEtaMax() + etaJet; + accmin = radius*radius*TMath::ACos(h/radius) - h*TMath::Sqrt(radius*radius - h*h); + } + + return radius*radius*TMath::Pi() - accmax - accmin; + +} + +//---------------------------------------------------------------- +void AliJetBkg::CalcJetAndBckgAreaEtaCut(Bool_t calcOutsideArea, Float_t radius, const Int_t nJets, const Float_t* etaJet, Float_t* &areaJet, Float_t &areaOut) +{ + // Calculate jet and bacground areas taking into account an acceptance cut in eta + + AliUA1JetHeader* header = (AliUA1JetHeader*) fHeader; + areaOut = (header->GetLegoEtaMax()-header->GetLegoEtaMin())*(header->GetLegoPhiMax() - header->GetLegoPhiMin()); + for(Int_t k=0; kGetDebug(); + Float_t rc = header->GetRadius(); + Float_t etOut = 0; + // Get number of tracks from EventCalTrk + Int_t nTracks = fEvent->GetNCalTrkTracks(); + + Float_t etIn[kMaxJets] = {0}; + Float_t areaOut = 0.; + + for(Int_t jpart = 0; jpart < nIn; jpart++){ // loop for all particles in array + + for(Int_t ijet=0; ijet TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi; + Float_t dr = TMath::Sqrt(deta * deta + dphi * dphi); + if(dr <= rc){ // particles inside this cone + if(jpart < nTracks) multJetT[ijet]++; + else multJetC[ijet]++; + multJet[ijet]++; + injet[jpart] = ijet; + if(PtCutPass(jpart,nTracks)){ // pt cut + etIn[ijet] += ptT[jpart]; + if(SignalCutPass(jpart,nTracks)) + etsigJet[ijet]+= ptT[jpart]; + } + break; + } + }// end jets loop + + if((injet[jpart] == -1) && + (PtCutPass(jpart,nTracks))){ + etOut += ptT[jpart]; // particle outside cones and pt cut + } + } //end particle loop + + // Calculate jet and background areas + Bool_t calcAreaOut = kTRUE; + CalcJetAndBckgAreaEtaCut(calcAreaOut,rc, nJ, etaJet, areaJet, areaOut); + + //subtract background using area method + for(Int_t ljet=0; ljetGetLegoEtaMax()-header->GetLegoEtaMin())*(header->GetLegoPhiMax()-header->GetLegoPhiMin()); + etbgTotalN = etOut*areaT/areaOut; + + // estimate standard deviation of background + Int_t count = 0; + for(Int_t jpart = 0; jpart < nIn; jpart++){ // loop for all particles in array + if((injet[jpart] == -1) && + (PtCutPass(jpart,nTracks))){ + sigmaN += etbgTotalN/areaT - ptT[jpart]; + // To be checked (Division by jet area to obtain standard deviation of rho ?) + + count=count+1; + } + } + sigmaN=TMath::Sqrt(TMath::Abs(sigmaN)/count); + +} + +//---------------------------------------------------------------- +void AliJetBkg::SubtractBackgStat(const Int_t& nIn, const Int_t&nJ,Float_t&etbgTotalN, Float_t&sigmaN, + const Float_t* ptT, const Float_t* etaT, const Float_t* phiT, + Float_t* etJet, const Float_t* etaJet, const Float_t* phiJet, + Float_t* etsigJet, Int_t* multJetT, Int_t* multJetC, Int_t* multJet, + Int_t* injet, Float_t* &areaJet) +{ + // + //background subtraction using statistical method + // Cases to take into account the EMCal geometry are included + // + + AliUA1JetHeader* header = (AliUA1JetHeader*) fHeader; + Float_t etbgStat = header->GetBackgStat(); // pre-calculated background + + //calculate energy inside + Float_t rc= header->GetRadius(); + Float_t etIn[kMaxJets] = {0.0}; + // Get number of tracks from EventCalTrk + Int_t nTracks = fEvent->GetNCalTrkTracks(); + Float_t areaOut = 0.; + + for(Int_t jpart = 0; jpart < nIn; jpart++) + { // loop for all particles in array + + for(Int_t ijet=0; ijet TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi; + Float_t dr = TMath::Sqrt(deta * deta + dphi * dphi); + if(dr <= rc){ // particles inside this cone + if(jpart < nTracks) multJetT[ijet]++; + else multJetC[ijet]++; + multJet[ijet]++; + injet[jpart] = ijet; + + if(PtCutPass(jpart,nTracks)){ // pt cut + etIn[ijet] += ptT[jpart]; + if(SignalCutPass(jpart,nTracks)) + etsigJet[ijet]+= ptT[jpart]; + } + break; + } + }// end jets loop + } //end particle loop + + // Calculate jet and background areas + Bool_t calcAreaOut = kFALSE; + CalcJetAndBckgAreaEtaCut(calcAreaOut,rc, nJ, etaJet, areaJet, areaOut); + + //subtract background using area method + for(Int_t ljet=0; ljetGetLegoEtaMax()-header->GetLegoEtaMin())*(header->GetLegoPhiMax()-header->GetLegoPhiMin()); + for(Int_t jpart = 0; jpart < nIn; jpart++){ // loop for all particles in array + if((injet[jpart] == -1) && + (PtCutPass(jpart,nTracks))){ + sigmaN += etbgTotalN/areaT - ptT[jpart]; + count=count+1; + } + } + sigmaN=TMath::Sqrt(TMath::Abs(sigmaN)/count); + +} + +//---------------------------------------------------------------- +void AliJetBkg::SubtractBackgCone(const Int_t& nIn, const Int_t&nJ,Float_t& etbgTotalN, Float_t&sigmaN, + const Float_t* ptT, const Float_t* etaT, const Float_t* phiT, Float_t* etJet, + const Float_t* etaJet, const Float_t* phiJet, Float_t* etsigJet, + Int_t* multJetT, Int_t* multJetC, Int_t* multJet, Int_t* injet, Float_t* &/*areaJet*/) +{ + // + // Cone background subtraction method taking into acount dEt/deta distribution + // Cases to take into account the EMCal geometry are not included + // + + AliUA1JetHeader* header = (AliUA1JetHeader*) fHeader; + //general + Float_t rc= header->GetRadius(); + Float_t etamax = header->GetLegoEtaMax(); + Float_t etamin = header->GetLegoEtaMin(); + Int_t ndiv = 100; + // Get number of tracks from EventCalTrk + Int_t nTracks = fEvent->GetNCalTrkTracks(); + + // jet energy and area arrays + Bool_t oldStatus = TH1::AddDirectoryStatus(); + TH1::AddDirectory(kFALSE); + + for(Int_t mjet=0; mjetReset(); + fhAreaJet[mjet]->Reset(); + } + // background energy and area + if(!fhEtBackg)fhEtBackg = new TH1F("hEtBackg"," backg et dist in eta ",ndiv,etamin,etamax); + fhEtBackg->Reset(); + if(!fhAreaBackg) fhAreaBackg = new TH1F("hAreaBackg","backg area dist in eta ",ndiv,etamin,etamax); + fhAreaBackg->Reset(); + TH1::AddDirectory(oldStatus); + + //fill energies + for(Int_t jpart = 0; jpart < nIn; jpart++){ // loop for all particles in array + for(Int_t ijet=0; ijet TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi; + Float_t dr = TMath::Sqrt(deta * deta + dphi * dphi); + if(dr <= rc){ // particles inside this cone + if(jpart < nTracks) multJetT[ijet]++; + else multJetC[ijet]++; + multJet[ijet]++; + injet[jpart] = ijet; + + if(PtCutPass(jpart,nTracks)){ // pt cut + fhEtJet[ijet]->Fill(etaT[jpart],ptT[jpart]); //particle inside cone + if(SignalCutPass(jpart,nTracks)) + etsigJet[ijet]+= ptT[jpart]; + } + break; + } + }// end jets loop + + if((injet[jpart] == -1) && + (PtCutPass(jpart,nTracks) == 1)) + fhEtBackg->Fill(etaT[jpart],ptT[jpart]); // particle outside cones + } //end particle loop + + //calc areas + Float_t eta0 = etamin; + Float_t etaw = (etamax - etamin)/((Float_t)ndiv); + Float_t eta1 = eta0 + etaw; + for(Int_t etabin = 0; etabin< ndiv; etabin++){ // loop for all eta bins + Float_t etac = eta0 + etaw/2.0; + Float_t areabg = etaw*2.0*TMath::Pi(); + for(Int_t ijet=0; ijet rc && deta1 < rc){ + acc1 = rc*rc*TMath::ACos(deta1/rc) - deta1*TMath::Sqrt(rc*rc - deta1*deta1); + areaj = acc1; + } + if(deta0 < rc && deta1 > rc){ + acc0 = rc*rc*TMath::ACos(deta0/rc) - deta0*TMath::Sqrt(rc*rc - deta0*deta0); + areaj = acc0; + } + if(deta0 < rc && deta1 < rc){ + acc0 = rc*rc*TMath::ACos(deta0/rc) - deta0*TMath::Sqrt(rc*rc - deta0*deta0); + acc1 = rc*rc*TMath::ACos(deta1/rc) - deta1*TMath::Sqrt(rc*rc - deta1*deta1); + if(eta1Fill(etac,areaj); + areabg = areabg - areaj; + } // end jets loop + fhAreaBackg->Fill(etac,areabg); + eta0 = eta1; + eta1 = eta1 + etaw; + } // end loop for all eta bins + + //subtract background + for(Int_t kjet=0; kjetGetBinContent(bin)){ + Float_t areab = fhAreaBackg->GetBinContent(bin); + Float_t etb = fhEtBackg->GetBinContent(bin); + Float_t areaR = (fhAreaJet[kjet]->GetBinContent(bin))/areab; + etJet[kjet] = etJet[kjet] + ((fhEtJet[kjet]->GetBinContent(bin)) - etb*areaR); //subtraction + } + } + } + + // calc background total + Double_t etOut = fhEtBackg->Integral(); + Double_t areaOut = fhAreaBackg->Integral(); + Float_t areaT = (header->GetLegoEtaMax()-header->GetLegoEtaMin())*(header->GetLegoPhiMax()-header->GetLegoPhiMin()); + etbgTotalN = etOut*areaT/areaOut; + + Int_t count=0; + for(Int_t jpart = 0; jpart < nIn; jpart++){ // loop for all particles in array + if((injet[jpart] == -1) && + (PtCutPass(jpart,nTracks))){ + sigmaN += etbgTotalN/areaT - ptT[jpart]; + count=count+1; + } + } + sigmaN=TMath::Sqrt(TMath::Abs(sigmaN)/count); + +} + +//---------------------------------------------------------------- +void AliJetBkg::SubtractBackgRatio(const Int_t& nIn, const Int_t&nJ,Float_t& etbgTotalN, Float_t&sigmaN, + const Float_t* ptT,const Float_t* etaT, const Float_t* phiT, + Float_t* etJet, const Float_t* etaJet, const Float_t* phiJet, + Float_t* etsigJet, Int_t* multJetT, Int_t* multJetC, Int_t* multJet, + Int_t* injet, Float_t* &/*areaJet*/) +{ + // Ratio background subtraction method taking into acount dEt/deta distribution + // Cases to take into account the EMCal geometry are not included + + AliUA1JetHeader* header = (AliUA1JetHeader*) fHeader; + //factor F calc before + Float_t bgRatioCut = header->GetBackgCutRatio(); + + //general + Float_t rc= header->GetRadius(); + Float_t etamax = header->GetLegoEtaMax(); + Float_t etamin = header->GetLegoEtaMin(); + Int_t ndiv = 100; + // Get number of tracks from EventCalTrk + Int_t nTracks = fEvent->GetNCalTrkTracks(); + + // jet energy and area arrays + Bool_t oldStatus = TH1::AddDirectoryStatus(); + TH1::AddDirectory(kFALSE); + for(Int_t mjet=0; mjetReset(); + fhAreaJet[mjet]->Reset(); + } + // background energy and area + if(!fhEtBackg)fhEtBackg = new TH1F("hEtBackg"," backg et dist in eta ",ndiv,etamin,etamax); + fhEtBackg->Reset(); + if(!fhAreaBackg) fhAreaBackg = new TH1F("hAreaBackg","backg area dist in eta ",ndiv,etamin,etamax); + fhAreaBackg->Reset(); + TH1::AddDirectory(oldStatus); + + //fill energies + for(Int_t jpart = 0; jpart < nIn; jpart++){ // loop for all particles in array + for(Int_t ijet=0; ijet TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi; + Float_t dr = TMath::Sqrt(deta * deta + dphi * dphi); + if(dr <= rc){ // particles inside this cone + if(jpart < nTracks) multJetT[ijet]++; + else multJetC[ijet]++; + multJet[ijet]++; + injet[jpart] = ijet; + + if(PtCutPass(jpart,nTracks)){ // pt cut + fhEtJet[ijet]->Fill(etaT[jpart],ptT[jpart]); //particle inside cone + if(SignalCutPass(jpart,nTracks)) + etsigJet[ijet]+= ptT[jpart]; + } + break; + } + }// end jets loop + if(injet[jpart] == -1) fhEtBackg->Fill(etaT[jpart],ptT[jpart]); // particle outside cones + } //end particle loop + + //calc areas + Float_t eta0 = etamin; + Float_t etaw = (etamax - etamin)/((Float_t)ndiv); + Float_t eta1 = eta0 + etaw; + for(Int_t etabin = 0; etabin< ndiv; etabin++){ // loop for all eta bins + Float_t etac = eta0 + etaw/2.0; + Float_t areabg = etaw*2.0*TMath::Pi(); + for(Int_t ijet=0; ijet rc && deta1 < rc){ + acc1 = rc*rc*TMath::ACos(deta1/rc) - deta1*TMath::Sqrt(rc*rc - deta1*deta1); + areaj = acc1; + } + if(deta0 < rc && deta1 > rc){ + acc0 = rc*rc*TMath::ACos(deta0/rc) - deta0*TMath::Sqrt(rc*rc - deta0*deta0); + areaj = acc0; + } + if(deta0 < rc && deta1 < rc){ + acc0 = rc*rc*TMath::ACos(deta0/rc) - deta0*TMath::Sqrt(rc*rc - deta0*deta0); + acc1 = rc*rc*TMath::ACos(deta1/rc) - deta1*TMath::Sqrt(rc*rc - deta1*deta1); + if(eta1Fill(etac,areaj); + areabg = areabg - areaj; + } // end jets loop + fhAreaBackg->Fill(etac,areabg); + eta0 = eta1; + eta1 = eta1 + etaw; + } // end loop for all eta bins + + //subtract background + for(Int_t kjet=0; kjetGetBinContent(bin)){ + Float_t areab = fhAreaBackg->GetBinContent(bin); + Float_t etb = fhEtBackg->GetBinContent(bin); + Float_t areaR = (fhAreaJet[kjet]->GetBinContent(bin))/areab; + etJet[kjet] = etJet[kjet] + ((fhEtJet[kjet]->GetBinContent(bin)) - etb*areaR*bgRatioCut); //subtraction + } + } + } + + // calc background total + Double_t etOut = fhEtBackg->Integral(); + Double_t areaOut = fhAreaBackg->Integral(); + Float_t areaT = (header->GetLegoEtaMax()-header->GetLegoEtaMin())*(header->GetLegoPhiMax()-header->GetLegoPhiMin()); + etbgTotalN = etOut*areaT/areaOut; + + Int_t count=0; + + for(Int_t jpart = 0; jpart < nIn; jpart++){ // loop for all particles in array + if((injet[jpart] == -1) && + (PtCutPass(jpart,nTracks))){ + sigmaN += etbgTotalN/areaT - ptT[jpart]; + count=count+1; + } + } + sigmaN=TMath::Sqrt(TMath::Abs(sigmaN)/count); + +} + diff --git a/JETAN/DEV/AliJetBkg.h b/JETAN/DEV/AliJetBkg.h new file mode 100644 index 00000000000..2b5068eeaaa --- /dev/null +++ b/JETAN/DEV/AliJetBkg.h @@ -0,0 +1,75 @@ +#ifndef ALIJETBKG_H +#define ALIJETBKG_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//-------------------------------------------------- +// Method implementation for background studies and background subtraction with UA1 algorithms +// +// Author: magali.estienne@subatech.in2p3.fr +//------------------------------------------------- + +class TH1F; +class TH2F; +class TList; +class AliAODJetEventBackground; + +class AliJetBkg : public TObject +{ + public: + AliJetBkg(); + AliJetBkg(const AliJetBkg &input); + ~AliJetBkg(); + AliJetBkg& operator=(const AliJetBkg& source); + void SetHeader(AliJetHeader *header) {fHeader=header;} + void SetCalTrkEvent(AliJetCalTrkEvent *evt) {fEvent=evt;} + Bool_t PtCutPass(Int_t id, Int_t nTracks); + Bool_t SignalCutPass(Int_t id, Int_t nTracks); + Float_t CalcJetAreaEtaCut(Float_t radius, const Float_t etaJet); + void CalcJetAndBckgAreaEtaCut(Bool_t calcOutsideArea, Float_t rc, const Int_t nJ, const Float_t* etaJet, Float_t* &areaJet, Float_t &areaOut); + + void SubtractBackg(const Int_t& nIn, const Int_t&nJ, Float_t&EtbgTotalN, Float_t&sigmaN, + const Float_t* ptT, const Float_t* etaT, const Float_t* phiT, + Float_t* etJet, const Float_t* etaJet, const Float_t* phiJet, + Float_t* etsigJet, Int_t* multJetT, Int_t* multJetC, Int_t* multJet, + Int_t* injet, Float_t* &areaJet); + + void SubtractBackgCone(const Int_t& nIn, const Int_t&nJ,Float_t& EtbgTotalN, Float_t&sigmaN, + const Float_t* ptT, const Float_t* etaT, const Float_t* phiT, Float_t* etJet, + const Float_t* etaJet, const Float_t* phiJet, Float_t* etsigJet, + Int_t* multJetT, Int_t* multJetC, Int_t* multJet, Int_t* injet, Float_t* &/*areaJet*/); + + void SubtractBackgRatio(const Int_t& nIn, const Int_t&nJ,Float_t& EtbgTotalN, Float_t&sigmaN, + const Float_t* ptT, const Float_t* etaT, const Float_t* phiT, Float_t* etJet, + const Float_t* etaJet, const Float_t* phiJet, Float_t* etsigJet, + Int_t* multJetT, Int_t* multJetC, Int_t* multJet, Int_t* injet, Float_t* &/*areaJet*/); + + void SubtractBackgStat(const Int_t& nIn, const Int_t&nJ,Float_t&EtbgTotalN, Float_t&sigmaN, + const Float_t* ptT, const Float_t* etaT, const Float_t* phiT, Float_t* etJet, + const Float_t* etaJet, const Float_t* phiJet, Float_t* etsigJet, + Int_t* multJetT, Int_t* multJetC, Int_t* multJet, Int_t* injet, Float_t* &areaJet); + void SetDebug(Int_t debug){fDebug = debug;} + + enum {kMaxJets = 60}; + + private: + // Double_t CalcRho(vector input_particles,Double_t RparamBkg,TString method); + + AliJetCalTrkEvent* fEvent; //! reader + AliJetHeader* fHeader; //! header + Int_t fDebug; // Debug option + + // temporary histos for background, reset for each event, no need to stream + TH1F* fhEtJet[kMaxJets]; //! histogram for background subtraction + TH1F* fhAreaJet[kMaxJets]; //! histogram for background subtraction (store global not to create it with every event + TH1F* fhEtBackg; //! histogram for background subtraction + TH1F* fhAreaBackg; //! histogram for background subtraction + + ClassDef(AliJetBkg, 2) // background jet analysis + +}; + +#endif diff --git a/JETAN/DEV/AliJetCalTrk.cxx b/JETAN/DEV/AliJetCalTrk.cxx new file mode 100644 index 00000000000..634e03bbd40 --- /dev/null +++ b/JETAN/DEV/AliJetCalTrk.cxx @@ -0,0 +1,312 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//-------------------------------------------------- +// CalTrk is used to store Tracks and CaloCells information +// +// Author: alexandre.shabetai@cern.ch & magali.estienne@subatech.in2p3.fr +//------------------------------------------------- + +#include "AliJetCalTrk.h" + +#include "AliVCaloCells.h" + +ClassImp(AliJetCalTrkTrack) + +////////////////////////////////////////////////////////////////// + +AliJetCalTrkTrack::AliJetCalTrkTrack(): + TObject(), + fCalTrkTrackRef(), + fCalTrkCutFlag(kFALSE), + fCalTrkSignalFlag(kFALSE), + fCalTrkPtCorr(1.) +{ + // Default constructor +} + +//------------------------------------------------------------------------ +AliJetCalTrkTrack::AliJetCalTrkTrack(AliVTrack* track, Bool_t cutFlag, Bool_t signalFlag, Float_t ptCorr): + TObject(), + fCalTrkTrackRef(track), + fCalTrkCutFlag(cutFlag), + fCalTrkSignalFlag(signalFlag), + fCalTrkPtCorr(ptCorr) +{ + // Constructor 2 +} + +//------------------------------------------------------------------------ +AliJetCalTrkTrack::AliJetCalTrkTrack(AliVParticle* track, Bool_t cutFlag, Bool_t signalFlag, Float_t ptCorr): + TObject(), + fCalTrkTrackRef(track), + fCalTrkCutFlag(cutFlag), + fCalTrkSignalFlag(signalFlag), + fCalTrkPtCorr(ptCorr) +{ + // Constructor 3 +} + +//------------------------------------------------------------------------ +AliJetCalTrkTrack::AliJetCalTrkTrack(const AliJetCalTrkTrack& rCalTrk): + TObject(rCalTrk), + fCalTrkTrackRef(rCalTrk.fCalTrkTrackRef), + fCalTrkCutFlag(rCalTrk.fCalTrkCutFlag), + fCalTrkSignalFlag(rCalTrk.fCalTrkSignalFlag), + fCalTrkPtCorr(rCalTrk.fCalTrkPtCorr) +{ + // Copy constructor +} + +//------------------------------------------------------------------------ +AliJetCalTrkTrack& AliJetCalTrkTrack::operator=(const AliJetCalTrkTrack& rhs) +{ + // Assignment + if (this != &rhs) { + TObject::operator=(rhs); + fCalTrkTrackRef = rhs.fCalTrkTrackRef; + fCalTrkCutFlag = rhs.fCalTrkCutFlag; + fCalTrkSignalFlag = rhs.fCalTrkSignalFlag; + fCalTrkPtCorr = rhs.fCalTrkPtCorr; + } + return *this; + +} + +//------------------------------------------------------------------------ +void AliJetCalTrkTrack::Clear(Option_t* /*option*/) +{ + // Clear objects + fCalTrkTrackRef = 0; + fCalTrkCutFlag = 0; + fCalTrkSignalFlag = 0; + fCalTrkPtCorr = 1.; + +} + +//----------------------------------------------------------------------- +void AliJetCalTrkTrack::Print(const Option_t* option) +{ + cout << "Track: " << option << ", Pt: " << GetPt() << ", Eta: " << GetEta() << ", Phi: " << GetPhi() << endl; +} + +//........................................................................... +//*************************************************************************** +ClassImp(AliJetCalTrkTrackKine) + + AliJetCalTrkTrackKine::AliJetCalTrkTrackKine(): + AliJetCalTrkTrack(), + fCalTrkPtReso(1.), + fCalTrkTrackE(-999.), + fCalTrkTrackPt(-999.), + fCalTrkTrackP(-999.) +{ + // Default constructor +} + +//------------------------------------------------------------------------ +AliJetCalTrkTrackKine::AliJetCalTrkTrackKine(AliVParticle* track, Bool_t cutFlag, Bool_t signalFlag, Float_t ptReso) : + AliJetCalTrkTrack(track,cutFlag,signalFlag), + fCalTrkPtReso(ptReso), + fCalTrkTrackE(-999.), + fCalTrkTrackPt(-999.), + fCalTrkTrackP(-999.) +{ + // Constructor 2 +} + +//------------------------------------------------------------------------ +void AliJetCalTrkTrackKine::Clear(Option_t* option) +{ + // Clear objects + fCalTrkPtReso = 1.; + fCalTrkTrackE = -999; + fCalTrkTrackPt = -999; + fCalTrkTrackP = -999; + AliJetCalTrkTrack::Clear(option); + +} + +//------------------------------------------------------------------------ +Float_t AliJetCalTrkTrackKine::GetE() +{ + // Particle energy + if(fCalTrkTrackE==-999){ + if ( fCalTrkPtReso != 1 ){ + fCalTrkTrackE = TMath::Sqrt(GetPx()*GetPx()+GetPy()*GetPy()+GetPz()*GetPz()+GetM()*GetM()); + } + else {fCalTrkTrackE = GetParticle()->E(); } + } + + return fCalTrkTrackE; + +} + +//------------------------------------------------------------------------ +Float_t AliJetCalTrkTrackKine::GetPt() +{ + // Particle transverse momentum + if(fCalTrkTrackPt==-999){ + if ( fCalTrkPtReso != 1 ){ + fCalTrkTrackPt = TMath::Sqrt(GetPx()*GetPx()+GetPy()*GetPy()); + } + else {fCalTrkTrackPt = GetParticle()->Pt();} + } + + return fCalTrkTrackPt; + +} + +//------------------------------------------------------------------------ +Float_t AliJetCalTrkTrackKine::GetP() +{ + // Particle momentum + if(fCalTrkTrackP==-999){ + if ( fCalTrkPtReso != 1 ){ + fCalTrkTrackP = TMath::Sqrt(GetPx()*GetPx()+GetPy()*GetPy()+GetPz()*GetPz()); + } + else {fCalTrkTrackP = GetParticle()->P(); } + } + + return fCalTrkTrackP; + +} + +//........................................................................... +//*************************************************************************** + +ClassImp(AliJetCalTrkEvent) + + AliJetCalTrkEvent::AliJetCalTrkEvent(): + TObject(), + fJetCalTrkTrack(0x0), + fJetCalTrkCell(0x0), + fNJetCalTrkTrack(0) +{ + // Default constructor +} + +//---------------------------------------------------------------- +AliJetCalTrkEvent::AliJetCalTrkEvent(Short_t opt,Bool_t kine,Bool_t kIsHighMult): + TObject(), + fJetCalTrkTrack(0x0), + fJetCalTrkCell(0x0), + fNJetCalTrkTrack(0) +{ + // Constructor 2 + if (kine==0) { + // Tracks (real or MC) + if(opt%2==!0 || opt==0){ + fJetCalTrkTrack = new TClonesArray("AliJetCalTrkTrack", kIsHighMult*3800+200); + } + } + else { // Kine cases + fJetCalTrkTrack = new TClonesArray("AliJetCalTrkTrackKine", kIsHighMult*3800+200); + } + +} + +//---------------------------------------------------------------- +AliJetCalTrkEvent::~AliJetCalTrkEvent() +{ + // destructor + if (fJetCalTrkTrack) delete fJetCalTrkTrack; + if (fJetCalTrkCell) delete fJetCalTrkCell; + +} +//---------------------------------------------------------------- +AliJetCalTrkEvent::AliJetCalTrkEvent(const AliJetCalTrkEvent& rCalTrkEvent): + TObject(), + fJetCalTrkTrack(rCalTrkEvent.fJetCalTrkTrack), + fJetCalTrkCell(rCalTrkEvent.fJetCalTrkCell), + fNJetCalTrkTrack(rCalTrkEvent.fNJetCalTrkTrack) +{ + // Copy constructor +} + +//---------------------------------------------------------------- +AliJetCalTrkEvent& AliJetCalTrkEvent::operator=(const AliJetCalTrkEvent& rhs) +{ + // Assignment + if (this != &rhs) { + TObject::operator=(rhs); + if (fJetCalTrkTrack) delete fJetCalTrkTrack; + if (fJetCalTrkCell) delete fJetCalTrkCell; + fJetCalTrkTrack = rhs.fJetCalTrkTrack; + fJetCalTrkCell = rhs.fJetCalTrkCell; + fNJetCalTrkTrack = rhs.fNJetCalTrkTrack; + } + + return *this; + +} + +//---------------------------------------------------------------- +AliJetCalTrkTrack* AliJetCalTrkEvent::AddCalTrkTrack(AliVTrack* track, Bool_t cutFlag, Bool_t signalFlag, Float_t ptCorr) +{ + // Add a track to the CalTrkEvent + TClonesArray &tJetCalTrkTrack = *fJetCalTrkTrack ; + AliJetCalTrkTrack *n = new(tJetCalTrkTrack[fNJetCalTrkTrack++]) AliJetCalTrkTrack(track, cutFlag, signalFlag, ptCorr) ; + return n ; + +} + +//---------------------------------------------------------------- +AliJetCalTrkTrack* AliJetCalTrkEvent::AddCalTrkTrack(AliVParticle* track, Bool_t cutFlag, Bool_t signalFlag, Float_t ptCorr) +{ + // Add a track to the CalTrkEvent + TClonesArray &tJetCalTrkTrack = *fJetCalTrkTrack ; + AliJetCalTrkTrack *n = new(tJetCalTrkTrack[fNJetCalTrkTrack++]) AliJetCalTrkTrack(track, cutFlag, signalFlag, ptCorr) ; + return n ; + +} + +//_________________________________________________________________ +AliJetCalTrkTrackKine* AliJetCalTrkEvent::AddCalTrkTrackKine(AliVParticle* track, Bool_t cutFlag, Bool_t signalFlag, Float_t ptReso) +{ + // Add a track to the CalTrkEvent + TClonesArray &tJetCalTrkTrack = *fJetCalTrkTrack ; + AliJetCalTrkTrackKine *n = new(tJetCalTrkTrack[fNJetCalTrkTrack++]) AliJetCalTrkTrackKine(track, cutFlag, signalFlag, ptReso) ; + return n ; + +} + + +//---------------------------------------------------------------- +AliJetCalTrkTrack* AliJetCalTrkEvent::GetCalTrkTrack(Int_t i) +{ + // Get track i + return (AliJetCalTrkTrack*) fJetCalTrkTrack->At(i); + +} + +//----------------------------------------------------------------- +void AliJetCalTrkEvent::Clear(Option_t* /*option*/) +{ + // Clear object + + if(fJetCalTrkTrack) fJetCalTrkTrack->Clear("C"); // array of Tracks + fNJetCalTrkTrack = 0; // Number of tracks +} + +//________________________________________________________________ +void AliJetCalTrkEvent::Print(const Option_t* /*option*/) const +{ + // prints event information + cout<< "Number of tracks:" << fNJetCalTrkTrack << endl; + +} diff --git a/JETAN/DEV/AliJetCalTrk.h b/JETAN/DEV/AliJetCalTrk.h new file mode 100644 index 00000000000..d5a73e82a55 --- /dev/null +++ b/JETAN/DEV/AliJetCalTrk.h @@ -0,0 +1,129 @@ +#ifndef ALIJETCALTRK_H +#define ALIJETCALTRK_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//------------------------------------------------------ +// CalTrk is used to sore Tracks and CaloCells information +// +// Author: alexandre.shabetai@cern.ch & magali.estienne@subatech.in2p3.fr +//------------------------------------------------------ + +#include +#include +#include +#include + +#include "AliVParticle.h" +#include "AliVTrack.h" + +class AliVCaloCells; + +class AliJetCalTrkTrack : public TObject +{ + public: + AliJetCalTrkTrack(); + AliJetCalTrkTrack(AliVParticle* track, Bool_t CutFlag, Bool_t SignalFlag, Float_t PtCorr = 1.); + AliJetCalTrkTrack(AliVTrack* track, Bool_t CutFlag, Bool_t SignalFlag, Float_t PtCorr = 1.); + virtual ~AliJetCalTrkTrack() {;} + + // Setter + void SetCutFlag(Bool_t cutFlag) {fCalTrkCutFlag = cutFlag;} + void SetSignalFlag(Bool_t signalFlag) {fCalTrkSignalFlag = signalFlag;} + void SetPtCorr(Float_t ptcorr) {fCalTrkPtCorr = ptcorr;} + + // Getter + AliVParticle* GetParticle() const {return ((AliVParticle*)fCalTrkTrackRef.GetObject());} + AliVTrack* GetTrack() const {return ((AliVTrack*)fCalTrkTrackRef.GetObject());} + TRef GetTrackRef() const {return fCalTrkTrackRef;} + TObject* GetTrackObject() const {return fCalTrkTrackRef.GetObject();} + Bool_t GetCutFlag() const {return fCalTrkCutFlag;} + Bool_t GetSignalFlag() const {return fCalTrkSignalFlag;} + Float_t GetPtCorr() const {return fCalTrkPtCorr;} + Float_t GetEta() const {return GetParticle()->Eta();} + Float_t GetPhi() const {return GetParticle()->Phi();} + virtual Float_t GetE() {return GetParticle()->E();} + virtual Float_t GetPt() {return GetParticle()->Pt();} + virtual Float_t GetPx() {return GetParticle()->Px();} + virtual Float_t GetPy() {return GetParticle()->Py();} + virtual Float_t GetPz() {return GetParticle()->Pz();} + virtual Float_t GetP() {return GetParticle()->P();} + Int_t GetID() const {return GetTrack()->GetID();} + Float_t GetM() const {return GetParticle()->M();} + using TObject::Print; + void Print(const Option_t* option); + + virtual void Clear(Option_t* /*option = ""*/); + + private: + AliJetCalTrkTrack(const AliJetCalTrkTrack& rCalTrk); + AliJetCalTrkTrack& operator = (const AliJetCalTrkTrack& rhs); + + TRef fCalTrkTrackRef; //! Reference to a track + Bool_t fCalTrkCutFlag; // Cut flag of the track in the tpc + Bool_t fCalTrkSignalFlag; // Signal flag of the track + Float_t fCalTrkPtCorr; // Correction factor + + ClassDef(AliJetCalTrkTrack,1) // Implementation of AliJetCalTrkTrack + +}; + +//------------------------------------------------------------- +class AliJetCalTrkTrackKine : public AliJetCalTrkTrack +{ + public: + AliJetCalTrkTrackKine(); + AliJetCalTrkTrackKine(AliVParticle* track, Bool_t CutFlag, Bool_t SignalFlag, Float_t ptReso); + virtual ~AliJetCalTrkTrackKine() {;} + + Float_t GetPtReso() const {return fCalTrkPtReso;} + Float_t GetE(); + Float_t GetPt(); + Float_t GetPx() {return GetPtReso()*GetParticle()->Px();} + Float_t GetPy() {return GetPtReso()*GetParticle()->Py();} + Float_t GetPz() {return GetPtReso()*GetParticle()->Pz();} + Float_t GetP(); + void Clear(Option_t* option = ""); + + private: + Float_t fCalTrkPtReso; // Pt resolution rescaling (AliJetFillCalTrkTrackKine::FillKine()) + Float_t fCalTrkTrackE; // Particle energy + Float_t fCalTrkTrackPt; // Particle Pt + Float_t fCalTrkTrackP; // Particle P + + ClassDef(AliJetCalTrkTrackKine,1) // Implementation of AliJetCalTrkTrackKine +}; + +//------------------------------------------------------------- +class AliJetCalTrkEvent : public TObject +{ + public: + AliJetCalTrkEvent(); //default constructor + AliJetCalTrkEvent(Short_t opt,Bool_t kine,Bool_t kIsHighMult=kFALSE); // constructor 2 + virtual ~AliJetCalTrkEvent(); + AliJetCalTrkEvent(const AliJetCalTrkEvent& rCalTrkEvent); + AliJetCalTrkTrack* AddCalTrkTrack(AliVTrack* track, Bool_t cutFlag, Bool_t signalFlag, Float_t ptCorr = 1.); + AliJetCalTrkTrack* AddCalTrkTrack(AliVParticle* track, Bool_t cutFlag, Bool_t signalFlag, Float_t ptCorr = 1.); + AliJetCalTrkTrackKine* AddCalTrkTrackKine(AliVParticle* track, Bool_t cutFlag, Bool_t signalFlag, Float_t ptReso = 1.); + + AliJetCalTrkTrack* GetCalTrkTrack(Int_t i); + Int_t GetNCalTrkTracks() const {return fNJetCalTrkTrack;} + + void Clear(Option_t* option = ""); + void Print(const Option_t* /*option*/) const; + + private: + AliJetCalTrkEvent& operator = (const AliJetCalTrkEvent& rhs); + TClonesArray* fJetCalTrkTrack; //! Array of Tracks + TClonesArray* fJetCalTrkCell; //! Array of Cells + Int_t fNJetCalTrkTrack; // Number of tracks + + ClassDef(AliJetCalTrkEvent,1) // Implementation of AliJetCalTrkEvent + +}; + +#endif + diff --git a/JETAN/DEV/AliJetFillCalTrkEvent.cxx b/JETAN/DEV/AliJetFillCalTrkEvent.cxx new file mode 100644 index 00000000000..030e6ef2e49 --- /dev/null +++ b/JETAN/DEV/AliJetFillCalTrkEvent.cxx @@ -0,0 +1,104 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//-------------------------------------------------- +// Filling of CalTrkEvent objects in the reader task +// +// Author: magali.estienne@subatech.in2p3.fr +// alexandre.shabetai@cern.ch +//------------------------------------------------- + +#include "AliJetFillCalTrkEvent.h" + +// --- ROOT system --- +class TSystem; +class TLorentzVector; +class TVector3; +class TGeoManager; + +// --- AliRoot header files --- +class AliJetFinder; +class AliJetReader; +class AliJetReader; +class AliJetReaderHeader; +class AliJetCalTrkEvent; + +ClassImp(AliJetFillCalTrkEvent) + +///////////////////////////////////////////////////////////////////// + +AliJetFillCalTrkEvent::AliJetFillCalTrkEvent() : + fOpt(0), + fDebug(0), + fReaderHeader(0x0), + fCalTrkEvent(0x0), + fGeom(0x0) +{ + // constructor +} + +//----------------------------------------------------------------------- +AliJetFillCalTrkEvent::AliJetFillCalTrkEvent(const AliJetFillCalTrkEvent& cpfrom) : + fOpt(0), + fDebug(0), + fReaderHeader(0x0), + fCalTrkEvent(0x0), + fGeom(0x0) +{ + // Copy constructor + fOpt = cpfrom.fOpt; + fDebug = cpfrom.fDebug; + fReaderHeader = cpfrom.fReaderHeader; + fCalTrkEvent = cpfrom.fCalTrkEvent; + fGeom = cpfrom.fGeom; +} + +//----------------------------------------------------------------------- +AliJetFillCalTrkEvent& AliJetFillCalTrkEvent::operator=(const AliJetFillCalTrkEvent& rhs) +{ + // Assignment operator + if (this != &rhs) { + fOpt = rhs.fOpt; + fDebug = rhs.fDebug; + fReaderHeader = rhs.fReaderHeader; + fCalTrkEvent = rhs.fCalTrkEvent; + fGeom = rhs.fGeom; + } + + return *this; + +} + +//----------------------------------------------------------------------- +AliJetFillCalTrkEvent::~AliJetFillCalTrkEvent() +{ + // destructor +} + +//----------------------------------------------------------------------- +Float_t AliJetFillCalTrkEvent::EtaToTheta(Float_t arg) +{ + // Transform eta to theta + return 2.*atan(exp(-arg)); +} + + + + + + + diff --git a/JETAN/DEV/AliJetFillCalTrkEvent.h b/JETAN/DEV/AliJetFillCalTrkEvent.h new file mode 100644 index 00000000000..e526882317f --- /dev/null +++ b/JETAN/DEV/AliJetFillCalTrkEvent.h @@ -0,0 +1,67 @@ +#ifndef ALIJETFILLCALTRKEVENT_H +#define ALIJETFILLCALTRKEVENT_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//-------------------------------------------------- +// Filling of CalTrkEvent objects in the reader task +// +// Author: magali.estienne@subatech.in2p3.fr +// alexandre.shabetai@cern.ch +//------------------------------------------------- + +class AliJetReaderHeader; +class AliEMCALGeometry; +class AliEMCALRecoUtils; +class AliVEvent; +class AliMCEvent; +class AliJetHadronCorrection; + +#include +#include "AliJetCalTrk.h" + +class AliJetFillCalTrkEvent +{ + public: + AliJetFillCalTrkEvent(); + virtual ~AliJetFillCalTrkEvent(); + AliJetFillCalTrkEvent(const AliJetFillCalTrkEvent &det); + AliJetFillCalTrkEvent &operator=(const AliJetFillCalTrkEvent &det); + + // Setter + virtual void SetReaderHeader(AliJetReaderHeader* const readerHeader) {fReaderHeader = readerHeader;} + virtual void SetGeom(AliEMCALGeometry* const geom) {fGeom = geom;} + virtual void SetCalTrkEvent(AliJetCalTrkEvent* caltrkevt) {fCalTrkEvent = caltrkevt;} + virtual void SetHadCorrector(AliJetHadronCorrection* /*corr*/) {;} + virtual void SetApplyMIPCorrection(Bool_t /*val*/) {;} + virtual void SetVEvent(AliVEvent */*aod*/) {;} + virtual void SetMCEvent(AliMCEvent */*MC*/) {;} + virtual void SetEMCALRecoUtils(AliEMCALRecoUtils */*ru*/) {;} + virtual void SetApplyElectronCorrection(Int_t /*flag*/) {;} + virtual void SetApplyFractionHadronicCorrection(Bool_t /*val*/) {;} + virtual void SetFractionHadronicCorrection(Double_t /*val*/) {;} + + // Getter + virtual AliJetCalTrkEvent* GetCalTrkEvent() const {return fCalTrkEvent;} + + // Other + virtual void Exec(Option_t* const /*option*/) {;} + virtual Float_t EtaToTheta(Float_t arg); + + protected: + Int_t fOpt; // Detector to be used for jet reconstruction + Int_t fDebug; // Debug option + AliJetReaderHeader *fReaderHeader; // ReaderHeader + AliJetCalTrkEvent *fCalTrkEvent; // CalTrk event + + AliEMCALGeometry *fGeom; // Define EMCal geometry + + private: + + ClassDef(AliJetFillCalTrkEvent,1) // Fill AliJetFillCalTrkEvent with tpc and/or emcal information +}; + +#endif diff --git a/JETAN/DEV/AliJetFillCalTrkTrack.cxx b/JETAN/DEV/AliJetFillCalTrkTrack.cxx new file mode 100644 index 00000000000..9f11c767621 --- /dev/null +++ b/JETAN/DEV/AliJetFillCalTrkTrack.cxx @@ -0,0 +1,230 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//-------------------------------------------------- +// Filling of CalTrkTrack objects in the reader task +// +// Author: magali.estienne@subatech.in2p3.fr +// alexandre.shabetai@cern.ch +//------------------------------------------------- + +// --- AliRoot header files --- +#include "AliJetFillCalTrkTrack.h" +#include "AliJetReaderHeader.h" +#include "AliVEvent.h" +#include "AliESDtrack.h" +#include "AliAODTrack.h" + +ClassImp(AliJetFillCalTrkTrack) + +///////////////////////////////////////////////////////////////////// + +AliJetFillCalTrkTrack::AliJetFillCalTrkTrack(): + AliJetFillCalTrkEvent(), + fHadCorr(0), + fApplyMIPCorrection(kTRUE), + fVEvt(0x0) +{ + // constructor +} + +//----------------------------------------------------------------------- +AliJetFillCalTrkTrack::AliJetFillCalTrkTrack(AliVEvent* evt): + AliJetFillCalTrkEvent(), + fHadCorr(0), + fApplyMIPCorrection(kTRUE), + fVEvt(evt) +{ + // constructor +} + +//----------------------------------------------------------------------- +AliJetFillCalTrkTrack::AliJetFillCalTrkTrack(const AliJetFillCalTrkTrack &det): + AliJetFillCalTrkEvent(det), + fHadCorr(det.fHadCorr), + fApplyMIPCorrection(det.fApplyMIPCorrection), + fVEvt(det.fVEvt) +{ + // Copy constructor +} + +//----------------------------------------------------------------------- +AliJetFillCalTrkTrack& AliJetFillCalTrkTrack::operator=(const AliJetFillCalTrkTrack& other) +{ + // Assignment + if (this != &other) { + fHadCorr = other.fHadCorr; + fApplyMIPCorrection = other.fApplyMIPCorrection; + fVEvt = other.fVEvt; + } + + return (*this); + +} + +//----------------------------------------------------------------------- +AliJetFillCalTrkTrack::~AliJetFillCalTrkTrack() +{ + // destructor +} + +//----------------------------------------------------------------------- +void AliJetFillCalTrkTrack::Exec(Option_t* const /*option*/) +{ + // Main method. + // Fill AliJetFillCalTrkTrack the with the charged particle information + + fDebug = fReaderHeader->GetDebug(); + fOpt = fReaderHeader->GetDetector(); + TString datatype = fReaderHeader->GetDataType(); + datatype.ToUpper(); + + Int_t type=0; + + if (datatype.Contains("AODEXTRAONLY")) { type=kTrackAODextraonly;} + else if (datatype.Contains("AODEXTRA")) { type=kTrackAODextra; } + else if (datatype.Contains("AOD")) { type=kTrackAOD; } + else if (datatype.Contains("ESD")) { type=kTrackESD; } + else { cout<< "Unknown Data type !" << endl; } + + // temporary storage of signal and pt cut flag + Bool_t sflag = 0; + Bool_t cflag = 0; + + // get cuts set by user + Float_t ptMin = fReaderHeader->GetPtCut(); + Float_t etaMin = fReaderHeader->GetFiducialEtaMin(); + Float_t etaMax = fReaderHeader->GetFiducialEtaMax(); + Float_t phiMin = fReaderHeader->GetFiducialPhiMin(); + Float_t phiMax = fReaderHeader->GetFiducialPhiMax(); + UInt_t filterMask = ((AliJetReaderHeader*)fReaderHeader)->GetTestFilterMask(); + UInt_t filterType = ((AliJetReaderHeader*)fReaderHeader)->GetFilterType(); + + if(fDebug>2)Printf("%s:%d Selecting tracks with %d",(char*)__FILE__,__LINE__,type); + + Int_t goodTrackStd = 0; + Int_t goodTrackNonStd = 0; + if(type==kTrackESD || type==kTrackAOD || type==kTrackAODextra || type==kTrackAODextraonly){ + if(type!=kTrackAODextraonly) { + if(!fVEvt){ + if(fDebug>2)Printf("%s:%d No AOD or ESD input event",(char*)__FILE__,__LINE__); + return; + } + for(int it = 0;it < fVEvt->GetNumberOfTracks();++it){ + AliVTrack *tr = (AliVTrack*)fVEvt->GetTrack(it); + cflag=sflag=0; + if(fVEvt->InheritsFrom("AliESDEvent")){ + // ESD case .... + if(tr->GetStatus()==0){ + if(fDebug>10)Printf("%s:%d Not matching status %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks()); + continue; + } + if ((tr->GetStatus() & AliESDtrack::kTPCrefit) == 0) continue; // quality check + if ((tr->GetStatus() & AliESDtrack::kITSrefit) == 0) continue; // quality check + if (((AliJetReaderHeader*) fReaderHeader)->ReadSignalOnly() + && TMath::Abs(tr->GetLabel()) > 10000) continue; // quality check + if (((AliJetReaderHeader*) fReaderHeader)->ReadBkgdOnly() + && TMath::Abs(tr->GetLabel()) < 10000) continue; // quality check + } + if((fVEvt->InheritsFrom("AliAODEvent"))){ + // AOD case .... + AliAODTrack *trAOD = dynamic_cast (tr); + Bool_t bGood = false; + if(filterType == 0)bGood = true; + else if(filterType == 1)bGood = trAOD->IsHybridTPCConstrainedGlobal(); + else if(filterType == 2)bGood = trAOD->IsHybridGlobalConstrainedGlobal(); + if((filterMask>0)&&((!trAOD->TestFilterBit(filterMask)||(!bGood)))){ + if(fDebug>10)Printf("%s:%d Not matching filter %d/%d %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks(),filterMask,trAOD->GetFilterMap()); + continue; + } + // Should we also check the GetStatus ? + } + if((tr->Eta()> etaMax) || (tr->Eta() < etaMin)){ + if(fDebug>10)Printf("%s:%d Not matching eta %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks()); + continue; + } + Float_t phi = ( (tr->Phi()) < 0) ? (tr->Phi()) + 2. * TMath::Pi() : (tr->Phi()); + if((phi > phiMax) || (phi < phiMin)){ + if(fDebug>10)Printf("%s:%d Not matching eta %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks()); + continue; + } + if(tr->Pt() <= ptMin){ + if(fDebug>10)Printf("%s:%d Not matching pt %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks()); + } + else {cflag=1;} + sflag=(TMath::Abs(tr->GetLabel()) < 10000) ? 1 : 0; + + if(fDebug>10)Printf("%s:%d MATCHED %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks()); + + fCalTrkEvent->AddCalTrkTrack(tr,cflag,sflag); + goodTrackStd++; + } + } + if(type==kTrackAODextra || type==kTrackAODextraonly) { + if(!fVEvt){ + return; + } + TClonesArray *aodExtraTracks = dynamic_cast(fVEvt->FindListObject("aodExtraTracks")); + if(!aodExtraTracks) return; + for(int it =0; itGetEntries(); it++) { + cflag=sflag=0; + AliVParticle *track = dynamic_cast ((*aodExtraTracks)[it]); + if (!track) continue; + AliAODTrack *trackAOD = dynamic_cast (track); + if(!trackAOD) continue; + if (trackAOD->GetStatus() == 0) continue; + Bool_t bGood = false; + if(filterType == 0)bGood = true; + else if(filterType == 1)bGood = trackAOD->IsHybridTPCConstrainedGlobal(); + else if(filterType == 2)bGood = trackAOD->IsHybridGlobalConstrainedGlobal(); + if((filterMask>0)&&((!trackAOD->TestFilterBit(filterMask)||(!bGood))))continue; + if((trackAOD->Eta()> etaMax) || (trackAOD->Eta() < etaMin)){ + if(fDebug>10)Printf("%s:%d Not matching eta %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks()); + continue; + } + Float_t phi = ( (trackAOD->Phi()) < 0) ? (trackAOD->Phi()) + 2. * TMath::Pi() : (trackAOD->Phi()); + if((phi > phiMax) || (phi < phiMin)){ + if(fDebug>10)Printf("%s:%d Not matching eta %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks()); + continue; + } + if(trackAOD->Pt() <= ptMin){ + if(fDebug>10)Printf("%s:%d Not matching pt %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks()); + } + else {cflag=1;} + sflag=(TMath::Abs(trackAOD->GetLabel()) < 10000) ? 1 : 0; + fCalTrkEvent->AddCalTrkTrack(trackAOD,cflag,sflag); + goodTrackNonStd++; + } + } + } + + if(fDebug>0)printf("Number of good tracks selected: %5d \n", goodTrackStd+goodTrackNonStd); + +} + + + + + + + + + + + + + diff --git a/JETAN/DEV/AliJetFillCalTrkTrack.h b/JETAN/DEV/AliJetFillCalTrkTrack.h new file mode 100644 index 00000000000..fc29d2d4e13 --- /dev/null +++ b/JETAN/DEV/AliJetFillCalTrkTrack.h @@ -0,0 +1,55 @@ +#ifndef ALIJETFILLCALTRKTRACK_H +#define ALIJETFILLCALTRKTRACK_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//-------------------------------------------------- +// Filling of CalTrkTrack objects in the reader task +// +// Author: magali.estienne@subatech.in2p3.fr +// alexandre.shabetai@cern.ch +//------------------------------------------------- + +#include "AliJetFillCalTrkEvent.h" + +class AliJetFillCalTrkTrack : public AliJetFillCalTrkEvent +{ + public: + AliJetFillCalTrkTrack(); + AliJetFillCalTrkTrack(AliVEvent *fVEvt); + virtual ~AliJetFillCalTrkTrack(); + + // Setter + void SetHadCorrector(AliJetHadronCorrection* const corr) {fHadCorr = corr;} + void SetApplyMIPCorrection(Bool_t const val) {fApplyMIPCorrection = val;} + void SetVEvent(AliVEvent* const evt) {fVEvt = evt;} + + // Getter + Int_t GetHadCorrection() const {return fApplyMIPCorrection;} + + // Other + void Exec(Option_t* const option); + + // we have different cases + // AOD reading -> MC from AOD + // ESD reading -> MC from Kinematics + // this has to match with our selection of input events + enum {kTrackUndef = 0, kTrackESD, kTrackAOD, kTrackAODextra, kTrackAODextraonly}; + + protected: + AliJetHadronCorrection* fHadCorr; // Pointer to Hadron Correction Object + Bool_t fApplyMIPCorrection; // Apply MIP or not ? Exclusive with fApplyFractionHadronicCorrection + AliVEvent* fVEvt; // Pointer to AliVEvent object + + private: + AliJetFillCalTrkTrack(const AliJetFillCalTrkTrack &det); + AliJetFillCalTrkTrack &operator=(const AliJetFillCalTrkTrack &det); + + ClassDef(AliJetFillCalTrkTrack,1) // Fill AliJetCalTrkTrack with track information + +}; + +#endif diff --git a/JETAN/DEV/AliJetFillCalTrkTrackMC.cxx b/JETAN/DEV/AliJetFillCalTrkTrackMC.cxx new file mode 100644 index 00000000000..e2d5c534995 --- /dev/null +++ b/JETAN/DEV/AliJetFillCalTrkTrackMC.cxx @@ -0,0 +1,322 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//-------------------------------------------------- +// Filling of CalTrkTrack objects in the MC reader task +// +// Author: magali.estienne@subatech.in2p3.fr +// alexandre.shabetai@cern.ch +//------------------------------------------------- + +// --- ROOT system --- +#include +#include +#include + +// --- AliRoot system --- +#include "AliJetFillCalTrkTrackMC.h" +#include "AliAODMCParticle.h" +#include "AliJetKineReaderHeader.h" +#include "AliVEvent.h" +#include "AliMCEvent.h" + +ClassImp(AliJetFillCalTrkTrackMC) + +///////////////////////////////////////////////////////////////////////// + +AliJetFillCalTrkTrackMC::AliJetFillCalTrkTrackMC(): + AliJetFillCalTrkEvent(), + fHadCorr(0), + fApplyMIPCorrection(kTRUE), + fVEvt(0x0), + fMCEvent(0x0) +{ + // constructor +} + +//----------------------------------------------------------------------- +AliJetFillCalTrkTrackMC::AliJetFillCalTrkTrackMC(AliVEvent* evt): + AliJetFillCalTrkEvent(), + fHadCorr(0), + fApplyMIPCorrection(kTRUE), + fVEvt(evt), + fMCEvent(0x0) +{ + // constructor +} + +//----------------------------------------------------------------------- +AliJetFillCalTrkTrackMC::AliJetFillCalTrkTrackMC(const AliJetFillCalTrkTrackMC &det): + AliJetFillCalTrkEvent(det), + fHadCorr(det.fHadCorr), + fApplyMIPCorrection(det.fApplyMIPCorrection), + fVEvt(det.fVEvt), + fMCEvent(det.fMCEvent) +{ + // Copy constructor +} + +//----------------------------------------------------------------------- +AliJetFillCalTrkTrackMC& AliJetFillCalTrkTrackMC::operator=(const AliJetFillCalTrkTrackMC& other) +{ + // Assignment + if (this != &other) { + fHadCorr = other.fHadCorr; + fApplyMIPCorrection = other.fApplyMIPCorrection; + fVEvt = other.fVEvt; + fMCEvent = other.fMCEvent; + } + + return (*this); + +} + +//----------------------------------------------------------------------- +AliJetFillCalTrkTrackMC::~AliJetFillCalTrkTrackMC() +{ + // destructor +} + +//----------------------------------------------------------------------- +void AliJetFillCalTrkTrackMC::Exec(Option_t* const /*option*/) +{ + // Main method. + // Fill AliJetFillCalTrkTrackMC the with the charged particle information + + fDebug = fReaderHeader->GetDebug(); + fOpt = fReaderHeader->GetDetector(); + TString datatype = fReaderHeader->GetDataType(); + datatype.ToUpper(); + + Int_t type=0; + + if (datatype.Contains("AODMC2B")) { type=kTrackAODMCChargedAcceptance; } + else if (datatype.Contains("AODMC2")) { type=kTrackAODMCCharged; } + else if (datatype.Contains("AODMC")) { type=kTrackAODMCAll; } + + else if (!datatype.Contains("AOD") && datatype.Contains("MC2")) {type=kTrackKineCharged;} + else if (!datatype.Contains("AOD") && datatype.Contains("MC")) {type=kTrackKineAll;} + + else { cout<< "Unknown Data type !" << endl; } + + // temporary storage of signal and pt cut flag + Bool_t sflag = 0; + Bool_t cflag = 0; + + // get cuts set by user + Float_t ptMin = fReaderHeader->GetPtCut(); + Float_t etaMin = fReaderHeader->GetFiducialEtaMin(); + Float_t etaMax = fReaderHeader->GetFiducialEtaMax(); + Float_t phiMin = fReaderHeader->GetFiducialPhiMin(); + Float_t phiMax = fReaderHeader->GetFiducialPhiMax(); + + if(fDebug>2) Printf("%s:%d Selecting tracks with %d",(char*)__FILE__,__LINE__,type); + + Int_t goodTrackStd = 0; + Int_t goodTrackNonStd = 0; + + if (type == kTrackKineAll || type == kTrackKineCharged){ + + FillKine(); + } // Kine + + else if (type == kTrackAODMCCharged || type == kTrackAODMCAll || type == kTrackAODMCChargedAcceptance) { + if(!fVEvt) return; + TClonesArray *mcArray = dynamic_cast(fVEvt->FindListObject(AliAODMCParticle::StdBranchName())); + if(!mcArray) { + Printf("%s:%d No MC particle branch found",(char*)__FILE__,__LINE__); + return; + } + for(int it = 0;it < mcArray->GetEntriesFast();++it){ + cflag=sflag=0; + AliAODMCParticle *part = (AliAODMCParticle*)(mcArray->At(it)); + if(!part->IsPhysicalPrimary())continue; + Int_t pdg = TMath::Abs(part->GetPdgCode()); + // exclude neutrinos anyway + if((pdg == 12 || pdg == 14 || pdg == 16)) continue; + cflag = ( part->Pt()>ptMin ) ? 1 : 0; + sflag = ( TMath::Abs(part->GetLabel()) < 10000 ) ? 1 : 0; + if(type == kTrackAODMCAll){ + fCalTrkEvent->AddCalTrkTrack(part,cflag,sflag); + goodTrackStd++; + } + else if (type == kTrackAODMCCharged || type == kTrackAODMCChargedAcceptance ){ + if(part->Charge()==0)continue; + if(kTrackAODMCCharged){ + fCalTrkEvent->AddCalTrkTrack(part,cflag,sflag); + goodTrackStd++; + } + else { + if((part->Eta()>etaMax) || (part->Eta()Phi()) < 0) ? (part->Phi()) + 2. * TMath::Pi() : (part->Phi()); + if((phi>phiMax) || (phiAddCalTrkTrack(part,cflag,sflag); + goodTrackStd++; + } + } + } + if(fDebug>0) printf("Number of good tracks selected: %5d \n", goodTrackStd+goodTrackNonStd); + } // AODMCparticle + +} + +//----------------------------------------------------------------------- +Bool_t AliJetFillCalTrkTrackMC::FillKine() +{ + // Fill event + Int_t goodTrack = 0; + + // Get the stack + if(!fMCEvent) {cout<<"could not get MCEvent!"<GetNumberOfTracks(); + + // Get cuts set by user and header + Double_t ptMin = ((AliJetKineReaderHeader*) fReaderHeader)->GetPtCut(); + Float_t etaMin = fReaderHeader->GetFiducialEtaMin(); + Float_t etaMax = fReaderHeader->GetFiducialEtaMax(); + + TLorentzVector p4; + // Loop over particles + for (Int_t it = 0; it < nt; it++) { + if(!fMCEvent->IsPhysicalPrimary(it)) continue; + AliVParticle* part = fMCEvent->GetTrack(it); + Int_t pdg = TMath::Abs(part->PdgCode()); + Float_t pt = part->Pt(); + + if( (pdg == 12 || pdg == 14 || pdg == 16)) continue; + + Float_t p = part->P(); + Float_t p0 = p; + Float_t eta = part->Eta(); + Float_t phi = part->Phi(); + Float_t charge = part->Charge(); + + if (((AliJetKineReaderHeader*)fReaderHeader)->ChargedOnly()) { + if (charge == 0) continue; + } // End charged only + + // Fast simulation of EMCAL if requested + if (((AliJetKineReaderHeader*)fReaderHeader)->FastSimEMCAL()) { + // Charged particles only + if (charge != 0){ + // Simulate efficiency + if (!Efficiency(p0, eta, phi)) continue; + // Simulate resolution + p = SmearMomentum(4, p0); + } // end "if" charged particles + // Neutral particles (exclude K0L, n, nbar) + if (pdg == kNeutron || pdg == kK0Long) continue; + } // End fast EMCAL + + // Fast simulation of TPC if requested + if (((AliJetKineReaderHeader*)fReaderHeader)->FastSimTPC()) { + // Charged particles only + if (charge == 0) continue; + // Simulate efficiency + if (!Efficiency(p0, eta, phi)) continue; + // Simulate resolution + p = SmearMomentum(4, p0); + } // End fast TPC + + // Fill momentum array + Float_t r = p/p0; + Float_t px = r * part->Px(); + Float_t py = r * part->Py(); + Float_t pz = r * part->Pz(); + Float_t m = part->M(); + + Float_t e = TMath::Sqrt(px * px + py * py + pz * pz + m * m); + p4 = TLorentzVector(px, py, pz, e); + if ((p4.Eta()>etaMax) || (p4.Eta() ptMin) cflag = kTRUE; // track surviving pt cut + + fCalTrkEvent->AddCalTrkTrackKine(part,cflag,sflag,ptReso); + + goodTrack++; + + } // track loop + + if(fDebug>0) printf(" Number of good tracks %d \n", goodTrack); + + return kTRUE; + +} + +//----------------------------------------------------------------------- +Float_t AliJetFillCalTrkTrackMC::SmearMomentum(Int_t ind, Float_t p) +{ + // The relative momentum error, i.e. + // (delta p)/p = sqrt (a**2 + (b*p)**2) * 10**-2, + // where typically a = 0.75 and b = 0.16 - 0.24 depending on multiplicity + // (the lower value is for dn/d(eta) about 2000, and the higher one for 8000) + // + // If we include information from TRD, b will be a factor 2/3 smaller. + // + // ind = 1: high multiplicity + // ind = 2: low multiplicity + // ind = 3: high multiplicity + TRD + // ind = 4: low multiplicity + TRD + + Float_t pSmeared; + Float_t a = 0.75; + Float_t b = 0.12; + + if (ind == 1) b = 0.12; + if (ind == 2) b = 0.08; + if (ind == 3) b = 0.12; + if (ind == 4) b = 0.08; + + Float_t sigma = p * TMath::Sqrt(a * a + b * b * p * p)*0.01; + pSmeared = p + gRandom->Gaus(0., sigma); + return pSmeared; + +} + +//----------------------------------------------------------------------- +Bool_t AliJetFillCalTrkTrackMC::Efficiency(Float_t p, Float_t /*eta*/, Float_t phi) +{ + // Fast simulation of geometrical acceptance and tracking efficiency + + // Tracking + Float_t eff = 0.99; + if (p < 0.5) eff -= (0.5-p)*0.2/0.3; + // Geometry + if (p > 0.5) { + phi *= 180. / TMath::Pi(); + // Sector number 0 - 17 + Int_t isec = Int_t(phi / 20.); + // Sector centre + Float_t phi0 = isec * 20. + 10.; + Float_t phir = TMath::Abs(phi-phi0); + // 2 deg of dead space + if (phir > 9.) eff = 0.; + } + + if (gRandom->Rndm() > eff) { + return kFALSE; + } else { + return kTRUE; + } + +} + + diff --git a/JETAN/DEV/AliJetFillCalTrkTrackMC.h b/JETAN/DEV/AliJetFillCalTrkTrackMC.h new file mode 100644 index 00000000000..32fd7c188e2 --- /dev/null +++ b/JETAN/DEV/AliJetFillCalTrkTrackMC.h @@ -0,0 +1,63 @@ +#ifndef ALIJETFILLCALTRKTRACKMC_H +#define ALIJETFILLCALTRKTRACKMC_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//-------------------------------------------------- +// Filling of CalTrkTrack objects in the MC reader task +// +// Author: magali.estienne@subatech.in2p3.fr +// alexandre.shabetai@cern.ch +//------------------------------------------------- + +#include "AliJetFillCalTrkEvent.h" + +class AliVEvent; +class AliMCEvent; + +class AliJetFillCalTrkTrackMC : public AliJetFillCalTrkEvent +{ + public: + AliJetFillCalTrkTrackMC(); + AliJetFillCalTrkTrackMC(AliVEvent *fVEvt); + virtual ~AliJetFillCalTrkTrackMC(); + + // Setter + void SetHadCorrector(AliJetHadronCorrection* const corr) {fHadCorr = corr;} + void SetApplyMIPCorrection(Bool_t const val) {fApplyMIPCorrection = val;} + void SetVEvent(AliVEvent* const evt) {fVEvt = evt;} + void SetMCEvent(AliMCEvent* const mc) {fMCEvent = mc ;} + + // Getter + Int_t GetHadCorrection() const {return fApplyMIPCorrection;} + + // Other + void Exec(Option_t* const option); + Bool_t FillKine(); + // Fast Simulation + Float_t SmearMomentum(Int_t ind, Float_t p); + Bool_t Efficiency(Float_t pt, Float_t eta, Float_t phi); + + // we have different cases + // AOD reading -> MC from AOD + // ESD reading -> MC from Kinematics + // this has to match with our selection of input events + enum {kTrackUndef = 0, kTrackKineAll, kTrackKineCharged, kTrackAODMCAll, kTrackAODMCCharged, kTrackAODMCChargedAcceptance}; + + protected: + AliJetHadronCorrection* fHadCorr; // Pointer to Hadron Correction Object + Bool_t fApplyMIPCorrection; // Apply MIP or not ? Exclusive with fApplyFractionHadronicCorrection + AliVEvent* fVEvt; // Pointer to AliVEvent object + AliMCEvent* fMCEvent; // Pointer to AliMCEvent object + + private: + AliJetFillCalTrkTrackMC(const AliJetFillCalTrkTrackMC &det); + AliJetFillCalTrkTrackMC &operator=(const AliJetFillCalTrkTrackMC &det); + + ClassDef(AliJetFillCalTrkTrackMC,1) // Fill AliJetCalTrkTrack/TrackKine with MC track information +}; + +#endif diff --git a/JETAN/DEV/AliJetFinder.cxx b/JETAN/DEV/AliJetFinder.cxx new file mode 100644 index 00000000000..79961386344 --- /dev/null +++ b/JETAN/DEV/AliJetFinder.cxx @@ -0,0 +1,115 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * 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 +// Authors: jgcn@mda.cinvestav.mx +// andreas.morsch@cern.ch +// magali.estienne@subatech.in2p3.fr +// alexandre.shabetai@cern.ch +//--------------------------------------------------------------------- + +#include + +#include "AliJetFinder.h" +#include "AliUA1JetHeaderV1.h" +#include "AliAODJetEventBackground.h" +#include "AliAODJet.h" +#include "AliAODEvent.h" + +ClassImp(AliJetFinder) + +/////////////////////////////////////////////////////////////////////// + +AliJetFinder::AliJetFinder(): + fHeader(0x0), + fAODjets(0x0), + fNAODjets(0), + fAODEvBkg(0), + fDebug(0), + fCalTrkEvent(0x0) +{ + // Constructor +} + +//----------------------------------------------------------------------- +AliJetFinder::~AliJetFinder() +{ + // Destructor +} + +//----------------------------------------------------------------------- +void AliJetFinder::WriteHeader() +{ + // 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(); + +} + +//----------------------------------------------------------------------- +Bool_t AliJetFinder::ProcessEvent() +{ + // Process one event + + // Find jets + FindJets(); + + Reset(); + return kTRUE; + +} + +//----------------------------------------------------------------------- +void AliJetFinder::AddJet(AliAODJet p) +{ + // Add new jet to the list + if (fAODjets) { new ((*fAODjets)[fNAODjets++]) AliAODJet(p);} + else { Warning("AliJetFinder::AddJet(AliAODJet p)","fAODjets is null!");} + +} + +//----------------------------------------------------------------------- +void AliJetFinder::ConnectAOD(const AliAODEvent* aod) +{ + // Connect to the AOD + fAODjets = aod->GetJets(); + fAODEvBkg = (AliAODJetEventBackground*)(aod->FindListObject(AliAODJetEventBackground::StdBranchName())); + +} + +//----------------------------------------------------------------------- +void AliJetFinder::ConnectAODNonStd(AliAODEvent* aod,const char *bname) +{ + // 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!! + +} + diff --git a/JETAN/DEV/AliJetFinder.h b/JETAN/DEV/AliJetFinder.h new file mode 100644 index 00000000000..3737e76f2bf --- /dev/null +++ b/JETAN/DEV/AliJetFinder.h @@ -0,0 +1,68 @@ +#ifndef ALIJETFINDER_H +#define ALIJETFINDER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +//--------------------------------------------------------------------- +// 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 "AliJetCalTrk.h" +#include "AliAODJet.h" + +class AliJetHeader; +class AliAODJetEventBackground; +class AliAODEvent; + +class AliJetFinder : public TObject +{ + public: + AliJetFinder(); + virtual ~AliJetFinder(); + + // Getters + virtual AliJetCalTrkEvent* GetCalTrkEvent() const {return fCalTrkEvent;} + virtual AliJetHeader *GetJetHeader() const {return fHeader;} + virtual AliAODJetEventBackground* GetEventBackground() const {return fAODEvBkg;} + // Setters + virtual void SetCalTrkEvent(AliJetCalTrkEvent& event) {fCalTrkEvent = &event;} + virtual void SetJetHeader(AliJetHeader* h) {fHeader=h;} + virtual void SetEventBackground(AliAODJetEventBackground* bkg) {fAODEvBkg = bkg;} + // Others + virtual void AddJet(AliAODJet jet); + virtual void WriteHeaderToFile(); + virtual void WriteHeader(); + // the following have to be implemented for each specific finder + virtual void Init() {} + virtual void Reset() {fNAODjets = 0;} + virtual void FindJets() {} + virtual void ComputeBkgs() {} + virtual void CreateOutputObjects(TList * const /*histos*/) {} // Used by CDF for histo storage + + // some methods to allow steering from the outside + virtual Bool_t ProcessEvent(); + virtual void ConnectAOD(const AliAODEvent* aod); + virtual void ConnectAODNonStd(AliAODEvent* aod,const char* bname); + virtual void AddHistosToList(TList */*list*/) {} + + protected: + AliJetFinder(const AliJetFinder& rJetFinder); + AliJetFinder& operator = (const AliJetFinder& rhsf); + AliJetHeader* fHeader; // pointer to header + TClonesArray* fAODjets; //! reconstructed jets + Int_t fNAODjets; // number of reconstructed jets + AliAODJetEventBackground* fAODEvBkg; //! bkg object to be store + Int_t fDebug; // debug option, set through the header + AliJetCalTrkEvent* fCalTrkEvent; // pointer to AliJetCalTrkEvent object + + ClassDef(AliJetFinder,3) // base class for any jet finder + +}; + +#endif diff --git a/JETAN/DEV/AliJetHeader.cxx b/JETAN/DEV/AliJetHeader.cxx new file mode 100644 index 00000000000..2c6b111249e --- /dev/null +++ b/JETAN/DEV/AliJetHeader.cxx @@ -0,0 +1,60 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// Jet header base class +// Stores a comment which describes the jet analysis +// Author: jgcn@mda.cinvestav.mx +//--------------------------------------------------------------------- + +#include "AliJetHeader.h" + +ClassImp(AliJetHeader) + +//////////////////////////////////////////////////////////////////////// + +AliJetHeader::AliJetHeader(): + TNamed("AliJetHeader", "Jet Header"), + fComment("No comment"), + fJetEtaMax(0.5), + fJetEtaMin(-0.5), + fJetPhiMax(2*TMath::Pi()), + fJetPhiMin(0.), + fDebug(0), + fBGMode(kFALSE), + fRadius(0.4) +{ + // Default constructor +} + +//----------------------------------------------------------------------- +AliJetHeader::AliJetHeader(const char * name): + TNamed(name, "Jet Header"), + fComment("No comment"), + fJetEtaMax(0.5), + fJetEtaMin(-0.5), + fJetPhiMax(2*TMath::Pi()), + fJetPhiMin(0.), + fDebug(0), + fBGMode(kFALSE), + fRadius(0.4) +{ + // Constructor +} + + + diff --git a/JETAN/DEV/AliJetHeader.h b/JETAN/DEV/AliJetHeader.h new file mode 100644 index 00000000000..af53f584850 --- /dev/null +++ b/JETAN/DEV/AliJetHeader.h @@ -0,0 +1,63 @@ +#ifndef ALIJETHEADER_H +#define ALIJETHEADER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// Jet header base class +// Stores a comment which describes the jet analysis +// Author: jgcn@mda.cinvestav.mx +//--------------------------------------------------------------------- + +#include +#include + +class TString; + +class AliJetHeader : public TNamed +{ + public: + + AliJetHeader(const char* name); + AliJetHeader(); + virtual ~AliJetHeader() { } + + // Getters + virtual TString GetComment() const {return fComment; } + virtual Float_t GetJetEtaMax() const {return fJetEtaMax;} + virtual Float_t GetJetEtaMin() const {return fJetEtaMin;} + virtual Float_t GetJetPhiMax() const {return fJetPhiMax;} + virtual Float_t GetJetPhiMin() const {return fJetPhiMin;} + virtual Int_t GetDebug() const {return fDebug; } + virtual Bool_t GetBGMode() const {return fBGMode; } + virtual Float_t GetRadius() const {return fRadius; } + + // Setters + virtual void SetComment(const char* com) {fComment=TString(com);} + virtual void SetJetEtaMax(Float_t eta= 0.5) {fJetEtaMax = eta;} + virtual void SetJetEtaMin(Float_t eta= -0.5) {fJetEtaMin = eta;} + virtual void SetJetPhiMax(Float_t phi= 2*TMath::Pi()) {fJetPhiMax = phi;} + virtual void SetJetPhiMin(Float_t phi= 0.) {fJetPhiMin = phi;} + virtual void SetDebug(Int_t debug) {fDebug = debug;} + virtual void SetBGMode(Bool_t bgMode) {fBGMode = bgMode;} + virtual void SetRadius(Float_t rad) {fRadius = rad;} + + // others + +protected: + TString fComment; // a comment + Float_t fJetEtaMax; // maximum eta for the jet + Float_t fJetEtaMin; // minimum eta for the jet + Float_t fJetPhiMax; // maximum phi for the jet + Float_t fJetPhiMin; // minimum phi for the jet + Int_t fDebug; // debug option + Bool_t fBGMode; // background mode + Float_t fRadius; // jet radius param + + ClassDef(AliJetHeader,4) // jet header base class +}; + +#endif diff --git a/JETAN/DEV/AliJetHistos.cxx b/JETAN/DEV/AliJetHistos.cxx new file mode 100644 index 00000000000..932cc2deb9c --- /dev/null +++ b/JETAN/DEV/AliJetHistos.cxx @@ -0,0 +1,122 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// Jet Histos class +// Creates and fills a few cummon histograms for jet analysis +// +//--------------------------------------------------------------------- + +#include +#include +#include +#include +#include + +#include "AliAODJet.h" +#include "AliJetHistos.h" + +ClassImp(AliJetHistos) + +/////////////////////////////////////////////////////////////////////// + +AliJetHistos::AliJetHistos(): + fNJetsH(0x0), + fPtH(0x0), + fEtaH(0x0), + fEneH(0x0), + fPhiH(0x0) +{ + // Default constructor +} + +//----------------------------------------------------------------------- +void AliJetHistos::CreateHistos() +{ + // create histos + + fNJetsH = new TH1I("NJetsH","Number of Jets",12,0,11); + SetProperties(fNJetsH,"Number of jets","Entries"); + + fPtH = new TH1F("PtH","Pt of Jets",50,0.,200.); + SetProperties(fPtH,"P_{#perp} [GeV]","Entries"); + + fEtaH = new TH1F("EtaH","Pseudorapidity of Jets",30,-1.5,1.5); + SetProperties(fEtaH,"#eta","Entries"); + + fEneH = new TH1F("EneH","Energy of Jets",50,0.,200.); + SetProperties(fEneH,"Energy [GeV]","Entries"); + + fPhiH = new TH1F("PhiH","Azimuthal angle of Jets", + 60,0.,2.0*TMath::Pi()); + SetProperties(fPhiH,"#phi","Entries"); +} + +//----------------------------------------------------------------------- +AliJetHistos::~AliJetHistos() +{ + // Destructor + delete fNJetsH; + delete fPtH; + delete fEtaH; + delete fEneH; + delete fPhiH; +} + +//----------------------------------------------------------------------- +void AliJetHistos::SetProperties(TH1* h,const char* x, const char* y) const +{ + // Sets the histogram style properties + h->SetMarkerStyle(20); + h->SetMarkerSize(.5); + h->SetMarkerColor(2); + h->SetXTitle(x); + h->SetYTitle(y); + h->Sumw2(); +} + +//----------------------------------------------------------------------- +void AliJetHistos::AddHistosToList(TList *list) const +{ + // Add histos to the list + list->Add(fNJetsH); + list->Add(fPtH); + list->Add(fEtaH); + list->Add(fEneH); + list->Add(fPhiH); +} + +//----------------------------------------------------------------------- +void AliJetHistos::FillHistos(TClonesArray *jets) +{ + // Fill histograms + if(!jets)return; + Int_t nj = jets->GetEntries(); + fNJetsH->Fill(nj,1); + + if (nj == 0 ) return; + + AliAODJet *j; + for (Int_t i=0;iAt(i); + fPtH->Fill(j->Pt(),1); + fEtaH->Fill(j->Eta(),1); + fEneH->Fill(j->E(),1); + fPhiH->Fill(j->Phi(),1); + } + +} diff --git a/JETAN/DEV/AliJetHistos.h b/JETAN/DEV/AliJetHistos.h new file mode 100644 index 00000000000..9a29d750d61 --- /dev/null +++ b/JETAN/DEV/AliJetHistos.h @@ -0,0 +1,46 @@ +#ifndef ALIJETHISTOS_H +#define ALIJETHISTOS_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +//--------------------------------------------------------------------- +// Jet Histos class +// Creates and fills a few cummon histograms for jet analysis +// +//--------------------------------------------------------------------- + +class TList; +class TClonesArray; +class TH1I; +class TH1F; + +class AliJetHistos : public TObject { + public: + AliJetHistos(); + ~AliJetHistos(); + + void CreateHistos(); + void AddHistosToList(TList *list) const; + void FillHistos(TClonesArray *jets); + + private: + void SetProperties(TH1* h,const char* x, const char* y) const; + AliJetHistos(const AliJetHistos &det); + AliJetHistos &operator=(const AliJetHistos &det); + + private: + + TH1I *fNJetsH; // distribution of number of jets + TH1F *fPtH; // pt spectra + TH1F *fEtaH; // eta distribution + TH1F *fEneH; // energy distribution + TH1F *fPhiH; // phi distribution + + ClassDef(AliJetHistos,2) // some jet histos + +}; + +#endif + + diff --git a/JETAN/DEV/AliJetKineReaderHeader.cxx b/JETAN/DEV/AliJetKineReaderHeader.cxx new file mode 100644 index 00000000000..487277378b4 --- /dev/null +++ b/JETAN/DEV/AliJetKineReaderHeader.cxx @@ -0,0 +1,38 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// Jet Kine Reader Header +// Header for the reader in the jet analysis for the Kinematics +// Author: Andreas Morsch (andreas.morsch@cern.ch) +//--------------------------------------------------------------------- + +#include "AliJetKineReaderHeader.h" + +ClassImp(AliJetKineReaderHeader) + +///////////////////////////////////////////////////////////////////// + +AliJetKineReaderHeader::AliJetKineReaderHeader(): + AliJetReaderHeader("AliJetKineReaderHeader"), + fFastSimTPC(kFALSE), + fFastSimEMCAL(kFALSE), + fChargedOnly(kFALSE) +{ + // Default constructor +} + diff --git a/JETAN/DEV/AliJetKineReaderHeader.h b/JETAN/DEV/AliJetKineReaderHeader.h new file mode 100644 index 00000000000..855c976e7e5 --- /dev/null +++ b/JETAN/DEV/AliJetKineReaderHeader.h @@ -0,0 +1,42 @@ +#ifndef ALIJETKINEREADERHEADER_H +#define ALIJETKINEREADERHEADER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//---------------------------------------------------- +// Jet Kinematics Reader Header +// Header for the reader in the jet analysis for Kinematics +// Author: Andreas Morsch (andreas.morsch@cern.ch) +//---------------------------------------------------- + +#include "AliJetReaderHeader.h" + +class AliJetKineReaderHeader : public AliJetReaderHeader +{ + public: + AliJetKineReaderHeader(); + virtual ~AliJetKineReaderHeader() {} + + // Setters + void SetFastSimTPC(Bool_t flag = kTRUE) {fFastSimTPC = flag;} // if TPC fast simulation + void SetFastSimEMCAL(Bool_t flag = kTRUE) {fFastSimEMCAL = flag;} // if EMCAL fast simulation + void SetChargedOnly(Bool_t flag = kTRUE) {fChargedOnly = flag;} // for charged particles only, no smearing and no acceptance cuts + + // Getter + Bool_t FastSimTPC() const {return fFastSimTPC;} + Bool_t FastSimEMCAL() const {return fFastSimEMCAL;} + Bool_t ChargedOnly() const {return fChargedOnly;} + + protected: + //parameters set by user + Bool_t fFastSimTPC; // TPC fast simulation flag + Bool_t fFastSimEMCAL; // EMCAL fast simulation flag + Bool_t fChargedOnly; // charged particles only flag + + ClassDef(AliJetKineReaderHeader,3) // Kinematics reader header class +}; + +#endif diff --git a/JETAN/DEV/AliJetReader.cxx b/JETAN/DEV/AliJetReader.cxx new file mode 100644 index 00000000000..49ffb52101b --- /dev/null +++ b/JETAN/DEV/AliJetReader.cxx @@ -0,0 +1,199 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//------------------------------------------------------------------------ +// Jet reader base class +// manages the reading of input for jet algorithms +// Authors: jgcn@mda.cinvestav.mx +// magali.estienne@subatech.in2p3.fr +// alexandre.shabetai@cern.ch +// +// **February 2011 +// implemented standard geometry (AliEMCALGeometry) (was AliJetDummyGeo implented separately in ESDReader and AODReader +// local2master matrices are now get from $ALICE_ROOT/OADB/PWG4/JetReconstruction/EMCALlocal2master.root +// you can choose the geometry (EMCAL_COMPLETE, EMCAL_FIRSTYEARv1, etc) via SetEMCALgeo2bLoad('Name_of_Geometry') in the Readerheader +// different options for survey(ed) matrice are provided too +// ** August 2011 +// OADB path changed from '../OADB/PWG4/JetReconstruction/' to '../OADB/EMCAL/' +// marco.bregant@subatech.in2p3.fr +// ** 2011 +// - AliJetESD/AODReader classes removed from JETAN. Reader now ESD/AOD independent. It uses VEvent in the AliJetFill* classes. +// - EMCal utilities added for bad cells id, calibration, etc. +//------------------------------------------------------------------------ + +// root +#include + +//AliRoot +#include "AliVEvent.h" +#include "AliAODEvent.h" +#include "AliESDEvent.h" +#include "AliJetReader.h" +#include "AliJetReaderHeader.h" +#include "AliAnalysisManager.h" +#include "AliJetFillCalTrkTrack.h" +#include "AliJetFillCalTrkTrackMC.h" +#include "AliJetCalTrk.h" + +ClassImp(AliJetReader) + +//////////////////////////////////////////////////////////////////////// + + +AliJetReader::AliJetReader(): + fCalTrkEvent(0x0), + fFillEvent(0x0), + fReaderHeader(0), + fFillEventwTrks(0x0), + fDebug(0), + fVEvent(0x0), + fMCEvent(0x0), + fOpt(0) +{ + // Default constructor +} + +//----------------------------------------------------------------------- +AliJetReader::~AliJetReader() +{ + // Destructor + if (fCalTrkEvent) { + fCalTrkEvent->Delete(); + delete fCalTrkEvent; + } + + if (fFillEventwTrks) { + delete fFillEventwTrks; + } + +} + +//----------------------------------------------------------------------- +void AliJetReader::InitTasks() +{ + // Initialization + fOpt = GetReaderHeader()->GetDetector(); + + TString datatype = fReaderHeader->GetDataType(); + datatype.ToUpper(); + Bool_t kIsKine = kFALSE; + if((!datatype.Contains("AOD") && datatype.Contains("MC")) || + (!datatype.Contains("AOD") && datatype.Contains("MC2")) ){ + kIsKine = kTRUE; + } + Bool_t kIsHighMult = GetReaderHeader()->GetIsHighMult(); + fCalTrkEvent = new AliJetCalTrkEvent(fOpt,kIsKine,kIsHighMult); + + // Initialize jet analysis + CreateTasks(); + +} + +//----------------------------------------------------------------------- +Bool_t AliJetReader::ProcessEvent() +{ + // Process one event + // Charged only or charged+neutral jets + + Bool_t ok = ExecTasks(); + + if(!ok) {return kFALSE;} + + return kTRUE; + +} + +//----------------------------------------------------------------------- +void AliJetReader::SetInputEvent(const TObject* esd, const TObject* aod, const AliMCEvent* mc) +{ + // set input event pointers + if( fReaderHeader->GetDataType().Contains("AOD") && aod) {fVEvent = (AliAODEvent*) aod;} + else if( fReaderHeader->GetDataType().Contains("ESD") && esd) {fVEvent = (AliESDEvent*) esd;} + else if ( fReaderHeader->GetDataType().Contains("MC") || fReaderHeader->GetDataType().Contains("MC2")) { fMCEvent = (AliMCEvent*) mc;} + else {printf("No input event ! ");} + +} + +//----------------------------------------------------------------------- +Bool_t AliJetReader::CreateTasks() +{ + // For reader task initialization + + fDebug = fReaderHeader->GetDebug(); + + fFillEvent = new AliJetFillCalTrkEvent(); + if (fOpt>0) { + // Tracks + if(fOpt%2==!0 && fOpt!=0){ + fFillEventwTrks = new AliJetFillCalTrkTrack(); + fFillEventwTrks->SetReaderHeader(fReaderHeader); + } + } + else { // MC/Kine cases + fFillEventwTrks = new AliJetFillCalTrkTrackMC(); + fFillEventwTrks->SetReaderHeader(fReaderHeader); + } + + if(fDebug>1) cout << "Tasks instantiated at that stage ! " << endl; + + return kTRUE; + +} + +//----------------------------------------------------------------------- +Bool_t AliJetReader::ExecTasks() +{ + // Main function + // Fill the reader part + + fDebug = fReaderHeader->GetDebug(); + + if(!fVEvent && !fMCEvent) { + return kFALSE; + } + + // TPC only or Digits+TPC or Clusters+TPC + if(fOpt%2==!0 || fOpt==0){ + fFillEventwTrks->SetVEvent(fVEvent); + fFillEventwTrks->SetMCEvent(fMCEvent); + fFillEventwTrks->SetCalTrkEvent(fCalTrkEvent); + fFillEventwTrks->Exec("tpc"); + } + + return kTRUE; + +} + +//----------------------------------------------------------------------- +void AliJetReader::WriteRHeaderToFile() const +{ + // write reader header + AliJetReaderHeader *rh = GetReaderHeader(); + rh->Write(); + +} + +//----------------------------------------------------------------------- +void AliJetReader::WriteReaderHeader() +{ + // Write the Headers + TFile* f = new TFile("jets_local.root", "recreate"); + WriteRHeaderToFile(); + f->Close(); + +} + diff --git a/JETAN/DEV/AliJetReader.h b/JETAN/DEV/AliJetReader.h new file mode 100644 index 00000000000..c5b05261764 --- /dev/null +++ b/JETAN/DEV/AliJetReader.h @@ -0,0 +1,62 @@ +#ifndef ALIJETREADER_H +#define ALIJETREADER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +// Jet reader base class +// manages the reading of input for jet algorithms +// Authors: jgcn@mda.cinvestav.mx +// Magali Estienne +// alexandre.shabetai@cern.ch + +#include + +class AliJetReaderHeader; +class AliJetFillCalTrkEvent; +class AliJetCalTrkEvent; +class AliVEvent; +class AliMCEvent; + +class AliJetReader : public TObject +{ + public: + AliJetReader(); + virtual ~AliJetReader(); + + // Getters + AliJetCalTrkEvent* GetCalTrkEvent() const {return fCalTrkEvent;} + AliJetReaderHeader* GetReaderHeader() const {return fReaderHeader;} + + // Setters + void SetReaderHeader(AliJetReaderHeader* header) {fReaderHeader = header;} + + // Others + void SetInputEvent(const TObject* esd, const TObject* aod, const AliMCEvent* mc); + void InitTasks(); + Bool_t CreateTasks(); + Bool_t ExecTasks(); + Bool_t ProcessEvent(); + void WriteRHeaderToFile() const; + void WriteReaderHeader(); + + protected: + AliJetReader(const AliJetReader& rJetReader); + AliJetReader& operator = (const AliJetReader& rhsr); + + AliJetCalTrkEvent* fCalTrkEvent; //! Pointer to calTrkEvent + AliJetFillCalTrkEvent* fFillEvent; //! Pointer to AliJetFillCalTrkEvent + AliJetReaderHeader* fReaderHeader; // Pointer to header + AliJetFillCalTrkEvent* fFillEventwTrks; // For charged particle task + Int_t fDebug; // Debug option + AliVEvent* fVEvent; //! Input event + AliMCEvent* fMCEvent; //! MC Event; + Int_t fOpt; // Detector config + + ClassDef(AliJetReader,2) // jet reader class + +}; + +#endif diff --git a/JETAN/DEV/AliJetReaderHeader.cxx b/JETAN/DEV/AliJetReaderHeader.cxx new file mode 100644 index 00000000000..7de0aa98d98 --- /dev/null +++ b/JETAN/DEV/AliJetReaderHeader.cxx @@ -0,0 +1,120 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//------------------------------------------------------------------------- +// base class for Jet Reader Header +// Author: jgcn@mda.cinvestav.mx +//------------------------------------------------------------------------- + +#include + +#include "AliJetReaderHeader.h" +#include "AliEMCALRecoUtils.h" + +ClassImp(AliJetReaderHeader) + +//////////////////////////////////////////////////////////////////////// + +AliJetReaderHeader::AliJetReaderHeader(): + TNamed("AliJetReaderHeader", "Jet Reader Header"), + fOption(0), + fCluster(0), + fDebug(0), + fFiducialEtaMin(-0.9), + fFiducialEtaMax(0.9), + fFiducialPhiMin(0.), + fFiducialPhiMax(2*TMath::Pi()), + fPtCut(2.0), + fEtCellCut(0.0), + fComment("No comment"), + fDir(""), + fMatricesEMCAL("survey11"), + fGeomEMCAL("EMCAL_COMPLETEV1"), + fMyOADBfile(""), + fTestFilterMask(0), + fFilterType(0), + fReadSignalOnly(kFALSE), + fReadBkgdOnly(kFALSE), + fDataType(""), + fIsHighMult(kFALSE) +{ + // Default constructor +} + +//----------------------------------------------------------------------- +AliJetReaderHeader::AliJetReaderHeader(Int_t det): + TNamed("AliJetReaderHeader", "Jet Reader Header"), + fOption(det), + fCluster(0), + fDebug(0), + fFiducialEtaMin(-0.9), + fFiducialEtaMax(0.9), + fFiducialPhiMin(0.), + fFiducialPhiMax(2*TMath::Pi()), + fPtCut(2.0), + fEtCellCut(0.0), + fComment("No comment"), + fDir(""), + fMatricesEMCAL("survey11"), + fGeomEMCAL("EMCAL_COMPLETEV1"), + fMyOADBfile(""), + fTestFilterMask(0), + fFilterType(0), + fReadSignalOnly(kFALSE), + fReadBkgdOnly(kFALSE), + fDataType(""), + fIsHighMult(kFALSE) +{ + // Constructor + +} + +//----------------------------------------------------------------------- +AliJetReaderHeader::AliJetReaderHeader(const char * name): + TNamed(name, "Jet Reader Header"), + fOption(0), + fCluster(0), + fDebug(0), + fFiducialEtaMin(-0.9), + fFiducialEtaMax(0.9), + fFiducialPhiMin(0.), + fFiducialPhiMax(2*TMath::Pi()), + fPtCut(2.0), + fEtCellCut(0.0), + fComment("No comment"), + fDir(""), + fMatricesEMCAL("survey11"), + fGeomEMCAL("EMCAL_COMPLETEV1"), + fMyOADBfile(""), + fTestFilterMask(0), + fFilterType(0), + fReadSignalOnly(kFALSE), + fReadBkgdOnly(kFALSE), + fDataType(""), + fIsHighMult(kFALSE) +{ + // Constructor 2 + +} + + +//----------------------------------------------------------------------- +AliJetReaderHeader::~AliJetReaderHeader() +{ + // destructor + +} diff --git a/JETAN/DEV/AliJetReaderHeader.h b/JETAN/DEV/AliJetReaderHeader.h new file mode 100644 index 00000000000..8bd2105e294 --- /dev/null +++ b/JETAN/DEV/AliJetReaderHeader.h @@ -0,0 +1,108 @@ +#ifndef ALIJETREADERHEADER_H +#define ALIJETREADERHEADER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// base class for Jet Reader Header +// +// Author: jgcn@mda.cinvestav.mx +//--------------------------------------------------------------------- +#include +#include +#include + +class AliEMCALRecoUtils; + +class AliJetReaderHeader : public TNamed +{ + + public: + AliJetReaderHeader(const char* name); + AliJetReaderHeader(); + AliJetReaderHeader(Int_t det); + virtual ~AliJetReaderHeader(); + + // Getters + virtual const TString GetComment() {return fComment;} + virtual const char* GetDirectory() {return fDir.Data();} + virtual const TString GetEMCALmatrices2bLoad() {return fMatricesEMCAL;} + virtual const TString GetEMCALgeo2bLoad() {return fGeomEMCAL;} + virtual const TString GetMyOADBfile() {return fMyOADBfile;} + virtual Float_t GetFiducialEtaMin() const {return fFiducialEtaMin;} + virtual Float_t GetFiducialEtaMax() const {return fFiducialEtaMax;} + virtual Float_t GetFiducialPhiMin() const {return fFiducialPhiMin;} + virtual Float_t GetFiducialPhiMax() const {return fFiducialPhiMax;} + virtual Float_t GetPtCut() const {return fPtCut;} + virtual Float_t GetEtCellCut() const {return fEtCellCut;} + Int_t GetDetector() const {return fOption;} + Int_t GetCluster() const {return fCluster;} + Int_t GetDebug() const {return fDebug;} + UInt_t GetTestFilterMask() const {return fTestFilterMask;} + UInt_t GetFilterType() const {return fFilterType;} + TString GetDataType() const {return fDataType;} + Bool_t GetIsHighMult() const {return fIsHighMult;} + + // Setters + virtual void SetComment(const char* s) {fComment=TString(s);} + virtual void SetDirectory(const char* s) {fDir=TString(s);} + virtual void SetEMCALgeo2bLoad(const char* s) {fGeomEMCAL=TString(s);} + virtual void SetEMCALmatrices2bLoad(const char* s) {fMatricesEMCAL=TString(s);} + virtual void SetMyOADBfile(const char* s) {fMyOADBfile=TString(s);} + virtual void SetFiducialEta(Float_t etamin, Float_t etamax) + { fFiducialEtaMin = etamin; fFiducialEtaMax = etamax;} + virtual void SetFiducialPhi(Float_t phimin, Float_t phimax) + { fFiducialPhiMin = phimin; fFiducialPhiMax = phimax;} + virtual void SetPtCut(Float_t par = 2.0) {fPtCut = par;} + virtual void SetEtCellCut(Float_t par = 0.0) {fEtCellCut = par;} + virtual void SetDetector(Int_t option = 0) {fOption = option;} + virtual void SetCluster(Int_t option = 0) {fCluster = option;} + virtual void SetDebug(Int_t debug = 0) {fDebug = debug;} + + virtual void SetDataType(const char* type /*= "AOD"*/) {fDataType = TString(type);} + virtual void SetTestFilterMask(UInt_t i) {fTestFilterMask = i;} + virtual void SetFilterType(UInt_t i) {fFilterType = i;} + virtual void SetReadSignalOnly(Bool_t flag = kTRUE) {fReadSignalOnly = flag;} + virtual void SetReadBkgdOnly(Bool_t flag = kTRUE) {fReadBkgdOnly = flag;} + virtual void SetIsHighMult(Bool_t mult = kFALSE) {fIsHighMult = mult;} + + // Other + Bool_t ReadSignalOnly() const {return fReadSignalOnly;} + Bool_t ReadBkgdOnly() const {return fReadBkgdOnly;} + + // we have different cases + // AOD reading -> MC from AOD + // ESD reading -> MC from Kinematics + // this has to match with our selection of input events + enum {kTrackUndef = 0, kTrackESD, kTrackAOD, kTrackKineAll,kTrackKineCharged, kTrackAODMCAll, kTrackAODMCCharged, kTrackAODMCChargedAcceptance, kTrackAODextra, kTrackAODextraonly}; + + protected: + Int_t fOption; // detector used for jet reconstruction + Int_t fCluster; // cluster type + Int_t fDebug; // debug option + Float_t fFiducialEtaMin; // Fiducial minimum eta + Float_t fFiducialEtaMax; // Fiducial maximum eta + Float_t fFiducialPhiMin; // Fiducial minimum phi + Float_t fFiducialPhiMax; // Fiducial maximum phi + Float_t fPtCut; // pt cut + Float_t fEtCellCut; // et cell cut + TString fComment; // a comment + TString fDir; // directory with input files for signal + TString fMatricesEMCAL; // survey/matrices version for EMCAL + TString fGeomEMCAL; // geometry version for EMCAL + TString fMyOADBfile; // private version of the OADB file with EMCAL matrices + UInt_t fTestFilterMask; // Filter Mask for jets, not tested if 0 + UInt_t fFilterType; // Filter type: 0 = all, 1 = ITSTPC, 2 = TPC + Bool_t fReadSignalOnly; // read particles from signal event only + Bool_t fReadBkgdOnly; // read particles from bkgd event only + TString fDataType; // Input data type + Bool_t fIsHighMult; // High multiplicity flag + + ClassDef(AliJetReaderHeader,4) // jet reader header base class + +}; + +#endif diff --git a/JETAN/DEV/AliKMeansClustering.cxx b/JETAN/DEV/AliKMeansClustering.cxx new file mode 100644 index 00000000000..618b6763529 --- /dev/null +++ b/JETAN/DEV/AliKMeansClustering.cxx @@ -0,0 +1,570 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +// Implemenatation of the K-Means Clustering Algorithm +// See http://en.wikipedia.org/wiki/K-means_clustering and references therein. +// +// This particular implementation is the so called Soft K-means algorithm. +// It has been modified to work on the cylindrical topology in eta-phi space. +// +// Author: Andreas Morsch (CERN) +// andreas.morsch@cern.ch + +#include "AliKMeansClustering.h" +#include +#include +#include + +ClassImp(AliKMeansClustering) + +Double_t AliKMeansClustering::fBeta = 10.; + + +Int_t AliKMeansClustering::SoftKMeans(Int_t k, Int_t n, const Double_t* x, const Double_t* y, Double_t* mx, Double_t* my , Double_t* rk ) +{ + // + // The soft K-means algorithm + // + Int_t i,j; + // + // (1) Initialisation of the k means + + for (i = 0; i < k; i++) { + mx[i] = 2. * TMath::Pi() * gRandom->Rndm(); + my[i] = -1. + 2. * gRandom->Rndm(); + } + + // + // (2a) The responsibilities + Double_t** r = new Double_t*[n]; // responsibilities + for (j = 0; j < n; j++) {r[j] = new Double_t[k];} + // + // (2b) Normalisation + Double_t* nr = new Double_t[n]; + // (3) Iterations + Int_t nit = 0; + + while(1) { + nit++; + // + // Assignment step + // + for (j = 0; j < n; j++) { + nr[j] = 0.; + for (i = 0; i < k; i++) { + r[j][i] = TMath::Exp(- fBeta * d(mx[i], my[i], x[j], y[j])); + nr[j] += r[j][i]; + } // mean i + } // data point j + + for (j = 0; j < n; j++) { + for (i = 0; i < k; i++) { + r[j][i] /= nr[j]; + } // mean i + } // data point j + + // + // Update step + Double_t di = 0; + + for (i = 0; i < k; i++) { + Double_t oldx = mx[i]; + Double_t oldy = my[i]; + + mx[i] = x[0]; + my[i] = y[0]; + rk[i] = r[0][i]; + + for (j = 1; j < n; j++) { + Double_t xx = x[j]; +// +// Here we have to take into acount the cylinder topology where phi is defined mod 2xpi +// If two coordinates are separated by more than pi in phi one has to be shifted by +/- 2 pi + + Double_t dx = mx[i] - x[j]; + if (dx > TMath::Pi()) xx += 2. * TMath::Pi(); + if (dx < -TMath::Pi()) xx -= 2. * TMath::Pi(); + mx[i] = mx[i] * rk[i] + r[j][i] * xx; + my[i] = my[i] * rk[i] + r[j][i] * y[j]; + rk[i] += r[j][i]; + mx[i] /= rk[i]; + my[i] /= rk[i]; + if (mx[i] > 2. * TMath::Pi()) mx[i] -= 2. * TMath::Pi(); + if (mx[i] < 0. ) mx[i] += 2. * TMath::Pi(); + } // Data + di += d(mx[i], my[i], oldx, oldy); + } // means + // + // ending condition + if (di < 1.e-8 || nit > 1000) break; + } // while + +// Clean-up + delete[] nr; + for (j = 0; j < n; j++) delete[] r[j]; + delete[] r; +// + return (nit < 1000); + +} + +Int_t AliKMeansClustering::SoftKMeans2(Int_t k, Int_t n, Double_t* x, Double_t* y, Double_t* mx, Double_t* my , Double_t* sigma2, Double_t* rk ) +{ + // + // The soft K-means algorithm + // + Int_t i,j; + // + // (1) Initialisation of the k means using k-means++ recipe + // + OptimalInit(k, n, x, y, mx, my); + // + // (2a) The responsibilities + Double_t** r = new Double_t*[n]; // responsibilities + for (j = 0; j < n; j++) {r[j] = new Double_t[k];} + // + // (2b) Normalisation + Double_t* nr = new Double_t[n]; + // + // (2c) Weights + Double_t* pi = new Double_t[k]; + // + // + // (2d) Initialise the responsibilties and weights + for (j = 0; j < n; j++) { + nr[j] = 0.; + for (i = 0; i < k; i++) { + r[j][i] = TMath::Exp(- fBeta * d(mx[i], my[i], x[j], y[j])); + nr[j] += r[j][i]; + } // mean i + } // data point j + + for (i = 0; i < k; i++) { + rk[i] = 0.; + sigma2[i] = 1./fBeta; + + for (j = 0; j < n; j++) { + r[j][i] /= nr[j]; + rk[i] += r[j][i]; + } // mean i + pi[i] = rk[i] / Double_t(n); + } // data point j + // (3) Iterations + Int_t nit = 0; + + while(1) { + nit++; + // + // Assignment step + // + for (j = 0; j < n; j++) { + nr[j] = 0.; + for (i = 0; i < k; i++) { + r[j][i] = pi[i] * TMath::Exp(- d(mx[i], my[i], x[j], y[j]) / sigma2[i] ) + / (2. * sigma2[i] * TMath::Pi() * TMath::Pi()); + nr[j] += r[j][i]; + } // mean i + } // data point j + + for (i = 0; i < k; i++) { + for (j = 0; j < n; j++) { + r[j][i] /= nr[j]; + } // mean i + } // data point j + + // + // Update step + Double_t di = 0; + + for (i = 0; i < k; i++) { + Double_t oldx = mx[i]; + Double_t oldy = my[i]; + + mx[i] = x[0]; + my[i] = y[0]; + rk[i] = r[0][i]; + for (j = 1; j < n; j++) { + Double_t xx = x[j]; +// +// Here we have to take into acount the cylinder topology where phi is defined mod 2xpi +// If two coordinates are separated by more than pi in phi one has to be shifted by +/- 2 pi + + Double_t dx = mx[i] - x[j]; + if (dx > TMath::Pi()) xx += 2. * TMath::Pi(); + if (dx < -TMath::Pi()) xx -= 2. * TMath::Pi(); + if (r[j][i] > 1.e-15) { + mx[i] = mx[i] * rk[i] + r[j][i] * xx; + my[i] = my[i] * rk[i] + r[j][i] * y[j]; + rk[i] += r[j][i]; + mx[i] /= rk[i]; + my[i] /= rk[i]; + } + if (mx[i] > 2. * TMath::Pi()) mx[i] -= 2. * TMath::Pi(); + if (mx[i] < 0. ) mx[i] += 2. * TMath::Pi(); + } // Data + di += d(mx[i], my[i], oldx, oldy); + + } // means + // + // Sigma + for (i = 0; i < k; i++) { + sigma2[i] = 0.; + for (j = 0; j < n; j++) { + sigma2[i] += r[j][i] * d(mx[i], my[i], x[j], y[j]); + } // Data + sigma2[i] /= rk[i]; + if (sigma2[i] < 0.0025) sigma2[i] = 0.0025; + } // Clusters + // + // Fractions + for (i = 0; i < k; i++) pi[i] = rk[i] / Double_t(n); + // +// ending condition + if (di < 1.e-8 || nit > 1000) break; + } // while + +// Clean-up + delete[] nr; + delete[] pi; + for (j = 0; j < n; j++) delete[] r[j]; + delete[] r; +// + return (nit < 1000); +} + +Int_t AliKMeansClustering::SoftKMeans3(Int_t k, Int_t n, Double_t* x, Double_t* y, Double_t* mx, Double_t* my , + Double_t* sigmax2, Double_t* sigmay2, Double_t* rk ) +{ + // + // The soft K-means algorithm + // + Int_t i,j; + // + // (1) Initialisation of the k means using k-means++ recipe + // + OptimalInit(k, n, x, y, mx, my); + // + // (2a) The responsibilities + Double_t** r = new Double_t*[n]; // responsibilities + for (j = 0; j < n; j++) {r[j] = new Double_t[k];} + // + // (2b) Normalisation + Double_t* nr = new Double_t[n]; + // + // (2c) Weights + Double_t* pi = new Double_t[k]; + // + // + // (2d) Initialise the responsibilties and weights + for (j = 0; j < n; j++) { + nr[j] = 0.; + for (i = 0; i < k; i++) { + + r[j][i] = TMath::Exp(- fBeta * d(mx[i], my[i], x[j], y[j])); + nr[j] += r[j][i]; + } // mean i + } // data point j + + for (i = 0; i < k; i++) { + rk[i] = 0.; + sigmax2[i] = 1./fBeta; + sigmay2[i] = 1./fBeta; + + for (j = 0; j < n; j++) { + r[j][i] /= nr[j]; + rk[i] += r[j][i]; + } // mean i + pi[i] = rk[i] / Double_t(n); + } // data point j + // (3) Iterations + Int_t nit = 0; + + while(1) { + nit++; + // + // Assignment step + // + for (j = 0; j < n; j++) { + nr[j] = 0.; + for (i = 0; i < k; i++) { + + Double_t dx = TMath::Abs(mx[i]-x[j]); + if (dx > TMath::Pi()) dx = 2. * TMath::Pi() - dx; + Double_t dy = TMath::Abs(my[i]-y[j]); + r[j][i] = pi[i] * TMath::Exp(-0.5 * (dx * dx / sigmax2[i] + dy * dy / sigmay2[i])) + / (2. * TMath::Sqrt(sigmax2[i] * sigmay2[i]) * TMath::Pi() * TMath::Pi()); + nr[j] += r[j][i]; + } // mean i + } // data point j + + for (i = 0; i < k; i++) { + for (j = 0; j < n; j++) { + r[j][i] /= nr[j]; + } // mean i + } // data point j + + // + // Update step + Double_t di = 0; + + for (i = 0; i < k; i++) { + Double_t oldx = mx[i]; + Double_t oldy = my[i]; + + mx[i] = x[0]; + my[i] = y[0]; + rk[i] = r[0][i]; + for (j = 1; j < n; j++) { + Double_t xx = x[j]; +// +// Here we have to take into acount the cylinder topology where phi is defined mod 2xpi +// If two coordinates are separated by more than pi in phi one has to be shifted by +/- 2 pi + + Double_t dx = mx[i] - x[j]; + if (dx > TMath::Pi()) xx += 2. * TMath::Pi(); + if (dx < -TMath::Pi()) xx -= 2. * TMath::Pi(); + if (r[j][i] > 1.e-15) { + mx[i] = mx[i] * rk[i] + r[j][i] * xx; + my[i] = my[i] * rk[i] + r[j][i] * y[j]; + rk[i] += r[j][i]; + mx[i] /= rk[i]; + my[i] /= rk[i]; + } + if (mx[i] > 2. * TMath::Pi()) mx[i] -= 2. * TMath::Pi(); + if (mx[i] < 0. ) mx[i] += 2. * TMath::Pi(); + } // Data + di += d(mx[i], my[i], oldx, oldy); + + } // means + // + // Sigma + for (i = 0; i < k; i++) { + sigmax2[i] = 0.; + sigmay2[i] = 0.; + + for (j = 0; j < n; j++) { + Double_t dx = TMath::Abs(mx[i]-x[j]); + if (dx > TMath::Pi()) dx = 2. * TMath::Pi() - dx; + Double_t dy = TMath::Abs(my[i]-y[j]); + sigmax2[i] += r[j][i] * dx * dx; + sigmay2[i] += r[j][i] * dy * dy; + } // Data + sigmax2[i] /= rk[i]; + sigmay2[i] /= rk[i]; + if (sigmax2[i] < 0.0025) sigmax2[i] = 0.0025; + if (sigmay2[i] < 0.0025) sigmay2[i] = 0.0025; + } // Clusters + // + // Fractions + for (i = 0; i < k; i++) pi[i] = rk[i] / Double_t(n); + // +// ending condition + if (di < 1.e-8 || nit > 1000) break; + } // while + +// Clean-up + delete[] nr; + delete[] pi; + for (j = 0; j < n; j++) delete[] r[j]; + delete[] r; +// + return (nit < 1000); +} + +Double_t AliKMeansClustering::d(Double_t mx, Double_t my, Double_t x, Double_t y) +{ + // + // Distance definition + // Quasi - Euclidian on the eta-phi cylinder + + Double_t dx = TMath::Abs(mx-x); + if (dx > TMath::Pi()) dx = 2. * TMath::Pi() - dx; + + return (0.5*(dx * dx + (my - y) * (my - y))); +} + + + +void AliKMeansClustering::OptimalInit(Int_t k, Int_t n, const Double_t* x, const Double_t* y, Double_t* mx, Double_t* my) +{ + // + // Optimal initialisation using the k-means++ algorithm + // http://en.wikipedia.org/wiki/K-means%2B%2B + // + // k-means++ is an algorithm for choosing the initial values for k-means clustering in statistics and machine learning. + // It was proposed in 2007 by David Arthur and Sergei Vassilvitskii as an approximation algorithm for the NP-hard k-means problem--- + // a way of avoiding the sometimes poor clusterings found by the standard k-means algorithm. + // + // + TH1F d2("d2", "", n, -0.5, Float_t(n)-0.5); + d2.Reset(); + + // (1) Chose first center as a random point among the input data. + Int_t ir = Int_t(Float_t(n) * gRandom->Rndm()); + mx[0] = x[ir]; + my[0] = y[ir]; + + // (2) Iterate + Int_t icl = 1; + while(icl < k) + { + // find min distance to existing clusters + for (Int_t j = 0; j < n; j++) { + Double_t dmin = 1.e10; + for (Int_t i = 0; i < icl; i++) { + Double_t dij = d(mx[i], my[i], x[j], y[j]); + if (dij < dmin) dmin = dij; + } // clusters + d2.Fill(Float_t(j), dmin); + } // data points + // select a new cluster from data points with probability ~d2 + ir = Int_t(d2.GetRandom() + 0.5); + mx[icl] = x[ir]; + my[icl] = y[ir]; + icl++; + } // icl +} + + +ClassImp(AliKMeansResult) + + + +AliKMeansResult::AliKMeansResult(Int_t k): + TObject(), + fK(k), + fMx (new Double_t[k]), + fMy (new Double_t[k]), + fSigma2(new Double_t[k]), + fRk (new Double_t[k]), + fTarget(new Double_t[k]), + fInd (new Int_t[k]) +{ +// Constructor +} + +AliKMeansResult::AliKMeansResult(const AliKMeansResult &res): + TObject(res), + fK(res.GetK()), + fMx(new Double_t[res.GetK()]), + fMy(new Double_t[res.GetK()]), + fSigma2(new Double_t[res.GetK()]), + fRk(new Double_t[res.GetK()]), + fTarget(new Double_t[res.GetK()]), + fInd(new Int_t[res.GetK()]) +{ + // Copy constructor + for (Int_t i = 0; i 2.9) { + fTarget[i] = fRk[i] / fSigma2[i]; + } + else fTarget[i] = 0.; + } + + TMath::Sort(fK, fTarget, fInd); +} + +void AliKMeansResult::Sort(Int_t n, const Double_t* x, const Double_t* y) +{ + // Build target array and sort + for (Int_t i = 0; i < fK; i++) + { + Int_t nc = 0; + for (Int_t j = 0; j < n; j++) + { + if (2. * AliKMeansClustering::d(fMx[i], fMy[i], x[j], y[j]) < 2.28 * fSigma2[i]) nc++; + } + + if (nc > 2) { + fTarget[i] = Double_t(nc) / (2.28 * fSigma2[i]); + } else { + fTarget[i] = 0.; + } + } + + TMath::Sort(fK, fTarget, fInd); +} + +void AliKMeansResult::CopyResults(const AliKMeansResult* res) +{ + fK = res->GetK(); + for (Int_t i = 0; i GetMx()) [i]; + fMy[i] = (res->GetMy()) [i]; + fSigma2[i] = (res->GetSigma2())[i]; + fRk[i] = (res->GetRk()) [i]; + fTarget[i] = (res->GetTarget())[i]; + fInd[i] = (res->GetInd()) [i]; + } +} diff --git a/JETAN/DEV/AliKMeansClustering.h b/JETAN/DEV/AliKMeansClustering.h new file mode 100644 index 00000000000..52edef5fb13 --- /dev/null +++ b/JETAN/DEV/AliKMeansClustering.h @@ -0,0 +1,67 @@ +#ifndef ALIKMEANSCLUSTERING_H +#define ALIKMEANSCLUSTERING_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +// Implemenatation of the K-Means Clustering Algorithm +// http://en.wikipedia.org/wiki/K-means_clustering +// This particular implementation is the so called Soft K-means algorithm. +// It has been modified to work on the cylindrical topology in eta-phi space. +// +// Author: Andreas Morsch (CERN) +// andreas.morsch@cern.ch + +#include + +class AliKMeansClustering : public TObject +{ + public: + AliKMeansClustering() {} + virtual ~AliKMeansClustering() {} + + static Int_t SoftKMeans (Int_t k, Int_t n, const Double_t* x, const Double_t* y, Double_t* mx, Double_t* my , Double_t* rk ); + static Int_t SoftKMeans2(Int_t k, Int_t n, Double_t* x, Double_t* y, Double_t* mx, Double_t* my , Double_t* sigma2, + Double_t* rk ); + static Int_t SoftKMeans3(Int_t k, Int_t n, Double_t* x, Double_t* y, Double_t* mx, Double_t* my , + Double_t* sigmax2, Double_t* sigmay2, Double_t* rk ); + static void OptimalInit(Int_t k, Int_t n, const Double_t* x, const Double_t* y, Double_t* mx, Double_t* my); + static void SetBeta(Double_t beta) {fBeta = beta;} + static Double_t d(Double_t mx, Double_t my, Double_t x, Double_t y); +protected: + static Double_t fBeta; // beta parameter + + ClassDef(AliKMeansClustering, 1) +}; + +class AliKMeansResult : public TObject +{ + public: + AliKMeansResult(Int_t k); + AliKMeansResult(const AliKMeansResult &res); + AliKMeansResult& operator=(const AliKMeansResult& trclass); + + virtual ~AliKMeansResult(); + Int_t GetK() const {return fK;} + Double_t* GetMx() const {return fMx;} + Double_t* GetMy() const {return fMy;} + Double_t* GetSigma2() const {return fSigma2;} + Double_t* GetRk() const {return fRk;} + Int_t* GetInd() const {return fInd;} + Double_t* GetTarget() const {return fTarget;} + void CopyResults(const AliKMeansResult* res); + void Sort(); + void Sort(Int_t n, const Double_t* x, const Double_t* y); +protected: + Int_t fK; //! Number of clusters + Double_t* fMx; //! Position x + Double_t* fMy; //! Position y + Double_t* fSigma2; //! Sigma2 + Double_t* fRk; //! Responsibility + Double_t* fTarget; //! Target for sorting + Int_t* fInd; //! Index for sorting + + ClassDef(AliKMeansResult, 1) +}; + +#endif diff --git a/JETAN/DEV/AliSISConeJetFinder.cxx b/JETAN/DEV/AliSISConeJetFinder.cxx new file mode 100644 index 00000000000..c25321923e4 --- /dev/null +++ b/JETAN/DEV/AliSISConeJetFinder.cxx @@ -0,0 +1,314 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// FastJet v2.3.4 finder algorithm interface +// +// Author: swensy.jangal@ires.in2p3.fr +// +// ** 2011 magali.estienne@subatech.in2p3.fr & alexandre.shabetai@cern.ch +// Modified accordingly to reader/finder splitting and new handling of neutral information (via FastJetInput) +//--------------------------------------------------------------------- + +#include + +#include "AliFastJetInput.h" +#include "AliFastJetBkg.h" +#include "AliAODJetEventBackground.h" +#include "AliAODJet.h" +#include "AliSISConeJetFinder.h" +#include "AliSISConeJetHeader.h" + +#include "fastjet/AreaDefinition.hh" +#include "fastjet/ClusterSequenceArea.hh" +#include "fastjet/JetDefinition.hh" +#include "fastjet/PseudoJet.hh" +// get info on how fastjet was configured +#include "fastjet/config.h" + +#ifdef ENABLE_PLUGIN_SISCONE +#include "fastjet/SISConePlugin.hh" +#endif + +#include + + +using namespace std; + +ClassImp(AliSISConeJetFinder) + +//////////////////////////////////////////////////////////////////////// + +AliSISConeJetFinder::AliSISConeJetFinder(): + AliJetFinder(), + fInputFJ(new AliFastJetInput()), + fJetBkg(new AliFastJetBkg()) +{ + // Constructor +} + +//____________________________________________________________________________ +AliSISConeJetFinder::~AliSISConeJetFinder() +{ + // destructor + delete fInputFJ; + delete fJetBkg; + +} + +//______________________________________________________________________________ +void AliSISConeJetFinder::FindJets() +{ + // run the SISCone Jet finder + + // Pick up siscone header + AliSISConeJetHeader *header = (AliSISConeJetHeader*)fHeader; + Int_t debug = header->GetDebug(); // debug option + Bool_t bgMode = header->GetBGMode();// Here one choose to subtract BG or not + + // Read input particles + vector inputParticles=fInputFJ->GetInputParticles(); + if(inputParticles.size()==0){ + if(debug>0) Printf("%s:%d No input particles found, skipping event",(char*)__FILE__,__LINE__); + return; + } + + //------------------- SISCONE PLUGIN CONFIGURATION ---------------------- + // Look for SISCone parameters in the header and definition of the plugin. + + Double_t coneRadius = header->GetConeRadius(); // cone radius + Double_t overlapThreshold = header->GetOverlapThreshold(); // overlap parameter + Int_t nPassMax = header->GetNPassMax(); // maximum number of passes + Double_t ptProtoJetMin = header->GetPtProtojetMin(); // pT min of protojets + Double_t caching = header->GetCaching(); // do we record found cones for this set of data? + // For bckg + double rBkgParam = header->GetRparamBkg(); + fastjet::Strategy strategy = header->GetStrategy(); + fastjet::RecombinationScheme recombScheme = header->GetRecombScheme(); + + // if (header->GetSplitMergeScale() == 0) fastjet::SISConePlugin::SplitMergeScale splitMergeScale = fastjet::SISConePlugin::SM_pttilde; // There's only one split merge scale + // Double_t splitMergeStoppingScale = header->GetSplitMergeStoppingScale(); // Additional cut on pt_tilde of protojets + + fastjet::JetDefinition::Plugin * plugin; + plugin = new fastjet::SISConePlugin(coneRadius, overlapThreshold, nPassMax, ptProtoJetMin, caching); + + //------------------- CHOICE OF JET AREA ---------------------- + // Definition of jet areas for background subtraction + // For more informations about jet areas see : The Catchment Area of Jets M. Cacciari, G. Salam and G. Soyez + + Double_t ghostEtamax = header->GetGhostEtaMax(); // maximum eta in which a ghost can be generated + Double_t ghostArea = header->GetGhostArea(); // area of a ghost + Int_t activeAreaRepeats = header->GetActiveAreaRepeats(); // do we repeat area calculation? + Double_t gridScatter = header->GetGridScatter(); // fractional random fluctuations of the position of the ghosts on the y-phi grid + Double_t ktScatter = header->GetKtScatter(); // fractional random fluctuations of the tranverse momentum of the ghosts on the y-phi grid + Double_t meanGhostKt = header->GetMeanGhostKt(); // average transverse momentum of the ghosts. + + Double_t areaTypeNumber = header->GetAreaTypeNumber(); // the number determines jet area type + fastjet::AreaType areaType = fastjet::active_area; + if (areaTypeNumber == 1) areaType = fastjet::active_area; + if (areaTypeNumber == 2) areaType = fastjet::active_area_explicit_ghosts; + if (areaTypeNumber == 3) areaType = fastjet::one_ghost_passive_area; + if (areaTypeNumber == 4) areaType = fastjet::passive_area; + if (areaTypeNumber == 5) areaType = fastjet::voronoi_area; + + fastjet::AreaDefinition areaDef; + + if (areaTypeNumber < 5) + { + fastjet::GhostedAreaSpec ghostSpec(ghostEtamax, activeAreaRepeats, ghostArea, gridScatter, ktScatter, meanGhostKt); + areaDef = fastjet::AreaDefinition(areaType,ghostSpec); + } + + if (areaTypeNumber == 5) + { + Double_t effectiveRFact = header->GetEffectiveRFact(); + fastjet::VoronoiAreaSpec ghostSpec(effectiveRFact); + areaDef = fastjet::AreaDefinition(areaType,ghostSpec); + } + + //------------------- JETS FINDING AND EXTRACTION ---------------------- + fastjet::ClusterSequenceArea clust_seq(inputParticles, plugin, areaDef); + + vector jets; + + if (bgMode == 1)// BG subtraction mode + { + //------------------- CLUSTER JETS FINDING FOR RHO ESTIMATION ---------------------- + // run the jet clustering with the above jet definition + fastjet::JetAlgorithm algorithmBkg = fastjet::kt_algorithm; + Int_t algo = header->GetBGAlgorithm(); + if (algo == 0) algorithmBkg = fastjet::kt_algorithm; + if (algo == 1) algorithmBkg = fastjet::cambridge_algorithm; + fastjet::JetDefinition jetDefBkg(algorithmBkg, rBkgParam, recombScheme, strategy); + fastjet::ClusterSequenceArea clust_seq_bkg(inputParticles, jetDefBkg, areaDef); + + // save a comment in the header + TString comment = "Running Siscone algorithm with the following setup. "; + comment+= "Jet definition: "; + // comment+= TString(plugin.description()); + comment+= "Jet bckg definition: "; + comment+= TString(jetDefBkg.description()); + comment+= ". Area definition: "; + comment+= TString(areaDef.description()); + comment+= ". Strategy adopted by FastJet and bkg: "; + comment+= TString(clust_seq.strategy_string()); + header->SetComment(comment); + if(debug>0){ + cout << "--------------------------------------------------------" << endl; + cout << comment << endl; + cout << "--------------------------------------------------------" << endl; + } + + // Here we extract inclusive jets with pt > ptmin, sorted by pt + Double_t ptMin = header->GetMinJetPt(); + vector inclusiveJets = clust_seq.inclusive_jets(); // ptMin removed + // vector jets = sorted_by_pt(inclusiveJets); + + //------------------- BACKGROUND SUBTRACTION ---------------------- + + // Set the rapidity-azimuth range within which to study background + Double_t rapMin = header->GetRapMin(); + Double_t rapMax = header->GetRapMax(); + Double_t phiMin = header->GetPhiMin(); + Double_t phiMax = header->GetPhiMax(); + fastjet::RangeDefinition range(rapMin, rapMax, phiMin, phiMax); + + // Extract rho and sigma + Double_t rho = 0.; + Double_t sigma = 0.; + Double_t meanarea = 0.; + Bool_t kUse4VectorArea = header->Use4VectorArea(); + vector bkgJets = clust_seq_bkg.inclusive_jets(); + clust_seq_bkg.get_median_rho_and_sigma(bkgJets,range, kUse4VectorArea, rho, sigma, meanarea, false); + + // subtract background and extract jets bkg subtracted + vector subJets = clust_seq.subtracted_jets(rho,ptMin); + + // sort jets into increasing pt + jets = sorted_by_pt(subJets); + + } + else // No BG subtraction + { + + // save a comment in the header + TString comment = "Running Siscone algorithm with the following setup. "; + comment+= "Jet definition: "; + // comment+= TString(plugin.description()); + comment+= ". Strategy adopted by FastJet: "; + comment+= TString(clust_seq.strategy_string()); + header->SetComment(comment); + if(debug>0){ + cout << "--------------------------------------------------------" << endl; + cout << comment << endl; + cout << "--------------------------------------------------------" << endl; + } + //header->PrintParameters(); + + // Here we extract inclusive jets with pt > ptmin, sorted by pt + Double_t ptMin = header->GetMinJetPt(); + vector inclusiveJets = clust_seq.inclusive_jets(ptMin); + jets = sorted_by_pt(inclusiveJets); + + } + + //------------------- JET AND TRACK STORAGE ---------------------- + for (size_t j = 0; j < jets.size(); j++) { // loop for jets + + double area = clust_seq.area(jets[j]); + double areaError = clust_seq.area_error(jets[j]); + + if(debug>0) printf("Jet found %5d %9.5f %8.5f %10.3f %8.3f +- %6.3f\n", (Int_t)j,jets[j].rap(),jets[j].phi(),jets[j].perp(), area, areaError); + + vector constituents = clust_seq.constituents(jets[j]); + int nCon= constituents.size(); + TArrayI ind(nCon); + + if ((jets[j].eta() > (header->GetJetEtaMax())) || + (jets[j].eta() < (header->GetJetEtaMin())) || + (jets[j].phi() > (header->GetJetPhiMax())) || + (jets[j].phi() < (header->GetJetPhiMin())) || + (jets[j].perp() < header->GetMinJetPt())) continue; // acceptance eta range and etmin + + // go to write AOD info + AliAODJet aodjet (jets[j].px(), jets[j].py(), jets[j].pz(), jets[j].E()); + aodjet.SetEffArea(area,areaError); + //cout << "Printing jet " << endl; + if(debug>0) aodjet.Print(""); + + for (int i=0; i < nCon; i++) + { + fastjet::PseudoJet mPart=constituents[i]; + ind[i]=mPart.user_index(); + + // Jet constituents (charged tracks) added to the AliAODJet + AliJetCalTrkEvent* calEvt = GetCalTrkEvent(); + for(Int_t itrack=0; itrackGetNCalTrkTracks(); itrack++) + { + if(itrack==ind[i]) + { + TObject *track = calEvt->GetCalTrkTrack(itrack)->GetTrackObject(); + aodjet.AddTrack(track); + } + } + } // End loop on Constituents + + AddJet(aodjet); + + } // end loop for jets + + delete plugin; + +} + +//____________________________________________________________________________ +void AliSISConeJetFinder::WriteJHeaderToFile() const +{ + // Write Jet Header To File( + fHeader->Write(); +} + +//____________________________________________________________________________ +Bool_t AliSISConeJetFinder::ProcessEvent() +{ + // Process one event + // Charged only or charged+neutral jets + + fInputFJ->SetHeader(fHeader); + fInputFJ->SetCalTrkEvent(GetCalTrkEvent()); + fInputFJ->FillInput(); + + // Jets + FindJets(); + + // Background + if( fAODEvBkg){ + fJetBkg->SetHeader(fHeader); + Double_t sigma1 = 0,meanarea1= 0,sigma2 = 0,meanarea2 = 0; + Double_t bkg1 = 0,bkg2 = 0; + + fJetBkg->SetFastJetInput(fInputFJ); + fJetBkg->BkgFastJetb(bkg1,sigma1,meanarea1); + fJetBkg->BkgFastJetWoHardest(bkg2,sigma2,meanarea2); + fAODEvBkg->SetBackground(0,bkg1,sigma1,meanarea1); + fAODEvBkg->SetBackground(1,bkg2,sigma2,meanarea2); + } + + Reset(); + return kTRUE; + +} diff --git a/JETAN/DEV/AliSISConeJetFinder.h b/JETAN/DEV/AliSISConeJetFinder.h new file mode 100644 index 00000000000..ecac61e4bef --- /dev/null +++ b/JETAN/DEV/AliSISConeJetFinder.h @@ -0,0 +1,48 @@ +#ifndef ALISISCONEJETFINDER_H +#define ALISISCONEJETFINDER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// SISCone (FastJet v2.3.4) finder algorithm interface +// +// Author: swensy.jangal@ires.in2p3.fr +// +// ** 2011 magali.estienne@subatech.in2p3.fr & alexandre.shabetai@cern.ch +// Modified accordingly to reader/finder splitting and new handling of neutral information (via FastJetInput) +//--------------------------------------------------------------------- + +#include "AliJetFinder.h" + +class AliFastJetHeaderV1; +class AliFastJetInput; +class AliFastJetBkg; +using namespace std; + +class AliSISConeJetFinder : public AliJetFinder +{ + public: + AliSISConeJetFinder(); + ~AliSISConeJetFinder(); + + void FindJets(); + + // others + Bool_t ProcessEvent(); + void WriteJHeaderToFile() const; + + protected: + AliSISConeJetFinder(const AliSISConeJetFinder& rfj); + AliSISConeJetFinder& operator = (const AliSISConeJetFinder& rsfj); + + AliFastJetInput* fInputFJ; //! input particles array + AliFastJetBkg* fJetBkg; //! pointer to bkg class + + ClassDef(AliSISConeJetFinder,3) // SISCONE analysis class + +}; + +#endif diff --git a/JETAN/DEV/AliSISConeJetHeader.cxx b/JETAN/DEV/AliSISConeJetHeader.cxx new file mode 100644 index 00000000000..e9e26aec7dc --- /dev/null +++ b/JETAN/DEV/AliSISConeJetHeader.cxx @@ -0,0 +1,98 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// SISCone (FastJet v2.3.4) finder algorithm interface +// Finder Header Class +// Author: swensy.jangal@ires.in2p3.fr +//--------------------------------------------------------------------- + +#include +#include + +#include "AliSISConeJetHeader.h" + +ClassImp(AliSISConeJetHeader) + +//////////////////////////////////////////////////////////////////////// + +AliSISConeJetHeader::AliSISConeJetHeader(): + AliJetHeader("AliSISConeJetHeader"), + fActiveAreaRepeats(1), + fAreaTypeNumber(4), + fBGAlgo(1), + fCaching(0), + fConeRadius(0.7), + fEffectiveRFact(1), + fGhostEtaMax(4.0), + fGhostArea(0.05), + fGridScatter(1), + fKtScatter(0.1), + fMeanGhostKt(1e-100), + fMinJetPt(2), + fNPassMax(0), + fOverlapThreshold(0.75), + fPhiMax(TMath::TwoPi()), + fPhiMin(0), + fPtProtoJetMin(2), + fRapMax(0.9), + fRapMin(-0.9), + fRRho(0.5), + fSplitMergeScaleNumber(0), + fSplitMergeStoppingScale(0), + fRparamBkg(0.4), + fStrategy(fastjet::Best), + fRecombScheme(fastjet::BIpt_scheme), + fkUse4VectorArea(kTRUE) +{ + // Constructor +} + +//____________________________________________________________________________ +void AliSISConeJetHeader::PrintParameters() const +{ + // prints out parameters of jet algorithm + + cout << "SISConeJet algorithm parameters:"< +#include + +#include "AliUA1JetFinder.h" +#include "AliUA1JetHeaderV1.h" +#include "AliJetCalTrk.h" +#include "AliJetBkg.h" +#include "AliAODJetEventBackground.h" +#include "AliAODJet.h" + +ClassImp(AliUA1JetFinder) + +//////////////////////////////////////////////////////////////////////// + +AliUA1JetFinder::AliUA1JetFinder(): + AliJetFinder(), + fLego(0), + fJetBkg(new AliJetBkg()) +{ + // Default constructor +} + +//----------------------------------------------------------------------- +AliUA1JetFinder::~AliUA1JetFinder() +{ + // Destructor + delete fLego; + delete fJetBkg; + +} + +//----------------------------------------------------------------------- +void AliUA1JetFinder::FindJets() +{ + // Used to find jets using charged particle momentum information + // & neutral energy from calo cells + // + // 1) Fill cell map array + // 2) calculate total energy and fluctuation level + // 3) Run algorithm + // 3.1) look centroides in cell map + // 3.2) calculate total energy in cones + // 3.3) flag as a possible jet + // 3.4) reorder cones by energy + // 4) subtract backg in accepted jets + // 5) fill AliJet list + + // transform input to pt,eta,phi plus lego + + AliUA1JetHeader* header = (AliUA1JetHeader*) fHeader; + Int_t nIn = fCalTrkEvent->GetNCalTrkTracks(); + fDebug = fHeader->GetDebug(); + + if (nIn <= 0) return; + fJetBkg->SetHeader(fHeader); + fJetBkg->SetCalTrkEvent(GetCalTrkEvent()); + fJetBkg->SetDebug(fDebug); + // local arrays for input + // ToDo: check memory fragmentation, maybe better to + // define them globally and resize as needed + // Fragmentation should be worse for low mult... + Float_t* ptT = new Float_t[nIn]; + Float_t* etaT = new Float_t[nIn]; + Float_t* phiT = new Float_t[nIn]; + Int_t* injet = new Int_t[nIn]; + Int_t* injetOk = new Int_t[nIn]; + + memset(ptT,0,sizeof(Float_t)*nIn); + memset(etaT,0,sizeof(Float_t)*nIn); + memset(phiT,0,sizeof(Float_t)*nIn); + memset(injet,0,sizeof(Int_t)*nIn); + memset(injetOk,-1,sizeof(Int_t)*nIn); + + // load input vectors and calculate total energy in array + + // total energy in array + Float_t etbgTotal = 0.; + Float_t npart = 0.; + Float_t etbg2 = 0.; + + for (Int_t i = 0; i < fCalTrkEvent->GetNCalTrkTracks(); i++){ + ptT[i] = fCalTrkEvent->GetCalTrkTrack(i)->GetPt(); + etaT[i] = fCalTrkEvent->GetCalTrkTrack(i)->GetEta(); + phiT[i] = ((fCalTrkEvent->GetCalTrkTrack(i)->GetPhi() < 0) ? (fCalTrkEvent->GetCalTrkTrack(i)->GetPhi()) + 2 * TMath::Pi() : fCalTrkEvent->GetCalTrkTrack(i)->GetPhi()); + //fCalTrkEvent->GetCalTrkTrack(i)->Print(Form("%d",i)); + if (fCalTrkEvent->GetCalTrkTrack(i)->GetCutFlag() != 1) continue; + fLego->Fill(etaT[i], phiT[i], ptT[i]); + npart += 1; + etbgTotal+= ptT[i]; + etbg2 += ptT[i]*ptT[i]; + } + + // calculate total energy and fluctuation in map + Double_t meanpt = 0.; + Double_t ptRMS = 0.; + if(npart>0){ + meanpt = etbgTotal/npart; + etbg2 = etbg2/npart; + if(etbg2>(meanpt*meanpt)){// prenent NAN, should only happen due to numerical instabilities + ptRMS = TMath::Sqrt(etbg2-meanpt*meanpt); + } + } + Double_t dEtTotal = (TMath::Sqrt(npart))*TMath::Sqrt(meanpt * meanpt + ptRMS*ptRMS); + + // arrays to hold jets + Float_t etaJet[kMaxJets]; + Float_t phiJet[kMaxJets]; + Float_t etJet[kMaxJets]; + Float_t etsigJet[kMaxJets]; //signal et in jet + Float_t etallJet[kMaxJets]; // total et in jet (tmp variable) + Int_t ncellsJet[kMaxJets]; + Int_t multJetT[kMaxJets]; + Int_t multJetC[kMaxJets]; + Int_t multJet[kMaxJets]; + Float_t *areaJet = new Float_t[kMaxJets]; + // Used for jet reordering at the end of the jet finding procedure + Float_t etaJetOk[kMaxJets]; + Float_t phiJetOk[kMaxJets]; + Float_t etJetOk[kMaxJets]; + Float_t etsigJetOk[kMaxJets]; //signal et in jet + Float_t etallJetOk[kMaxJets]; // total et in jet (tmp variable) + Int_t ncellsJetOk[kMaxJets]; + Int_t multJetOk[kMaxJets]; + Float_t *areaJetOk = new Float_t[kMaxJets]; + Int_t nJets; // to hold number of jets found by algorithm + Int_t nj; // number of jets accepted + Float_t prec = header->GetPrecBg(); + Float_t bgprec = 1; + + while(bgprec > prec){ + //reset jet arrays in memory + memset(etaJet,0,sizeof(Float_t)*kMaxJets); + memset(phiJet,0,sizeof(Float_t)*kMaxJets); + memset(etJet,0,sizeof(Float_t)*kMaxJets); + memset(etallJet,0,sizeof(Float_t)*kMaxJets); + memset(etsigJet,0,sizeof(Float_t)*kMaxJets); + memset(ncellsJet,0,sizeof(Int_t)*kMaxJets); + memset(multJetT,0,sizeof(Int_t)*kMaxJets); + memset(multJetC,0,sizeof(Int_t)*kMaxJets); + memset(multJet,0,sizeof(Int_t)*kMaxJets); + memset(areaJet,0,sizeof(Float_t)*kMaxJets); + memset(etaJetOk,0,sizeof(Float_t)*kMaxJets); + memset(phiJetOk,0,sizeof(Float_t)*kMaxJets); + memset(etJetOk,0,sizeof(Float_t)*kMaxJets); + memset(etallJetOk,0,sizeof(Float_t)*kMaxJets); + memset(etsigJetOk,0,sizeof(Float_t)*kMaxJets); + memset(ncellsJetOk,0,sizeof(Int_t)*kMaxJets); + memset(multJetOk,0,sizeof(Int_t)*kMaxJets); + memset(areaJetOk,0,sizeof(Float_t)*kMaxJets); + nJets = 0; + nj = 0; + // reset particles-jet array in memory + memset(injet,-1,sizeof(Int_t)*nIn); + //run cone algorithm finder + RunAlgoritm(etbgTotal,dEtTotal,nJets,etJet,etaJet,phiJet,etallJet,ncellsJet); + //run background subtraction + if(nJets > header->GetNAcceptJets()) // limited number of accepted jets per event + nj = header->GetNAcceptJets(); + else + nj = nJets; + + //subtract background + Float_t etbgTotalN = 0.0; //new background + Float_t sigmaN = 0.0; //new background + if(header->GetBackgMode() == 1) {// standard + fJetBkg->SubtractBackg(nIn,nj,etbgTotalN,sigmaN,ptT,etaT,phiT,etJet,etaJet,phiJet,etsigJet,multJetT,multJetC,multJet,injet,areaJet);} + if(header->GetBackgMode() == 2) //cone + fJetBkg->SubtractBackgCone(nIn,nj,etbgTotalN,sigmaN,ptT,etaT,phiT,etJet,etaJet,phiJet,etsigJet,multJetT,multJetC,multJet,injet,areaJet); + if(header->GetBackgMode() == 3) //ratio + fJetBkg->SubtractBackgRatio(nIn,nj,etbgTotalN,sigmaN,ptT,etaT,phiT,etJet,etaJet,phiJet,etsigJet,multJetT,multJetC,multJet,injet,areaJet); + if(header->GetBackgMode() == 4) //statistic + fJetBkg->SubtractBackgStat(nIn,nj,etbgTotalN,sigmaN,ptT,etaT,phiT,etJet,etaJet,phiJet,etsigJet,multJetT,multJetC,multJet,injet,areaJet); + + //calc precision + if(etbgTotalN != 0.0) + bgprec = (etbgTotal - etbgTotalN)/etbgTotalN; + else + bgprec = 0; + etbgTotal = etbgTotalN; // update with new background estimation + + } //end while + + // add tracks to the jet if it wasn't yet done + if (header->GetBackgMode() == 0){ + Float_t rc= header->GetRadius(); + for(Int_t jpart = 0; jpart < nIn; jpart++){ // loop for all particles in array + for(Int_t ijet=0; ijet TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi; + Float_t dr = TMath::Sqrt(deta * deta + dphi * dphi); + if(dr <= rc){ // particles inside this cone + injet[jpart] = ijet; + break; + } + }// end jets loop + } //end particle loop + } + + // add jets to list + if (fDebug>1) printf("Found %d jets \n", nj); + + // Reorder jets by et in cone + // Sort jets by energy + Int_t idx[kMaxJets]; + TMath::Sort(nJets, etJet, idx); + for(Int_t p = 0; p < nJets; p++) + { + etaJetOk[p] = etaJet[idx[p]]; + phiJetOk[p] = phiJet[idx[p]]; + etJetOk[p] = etJet[idx[p]]; + etallJetOk[p] = etJet[idx[p]]; + etsigJetOk[p] = etsigJet[idx[p]]; + ncellsJetOk[p] = ncellsJet[idx[p]]; + multJetOk[p] = multJet[idx[p]]; + areaJetOk[p] = areaJet[idx[p]]; + } + + ////////////////////////// + + Int_t nTracks = fCalTrkEvent->GetNCalTrkTracks(); + + for(Int_t kj=0; kj (header->GetJetEtaMax())) || + (etaJetOk[kj] < (header->GetJetEtaMin())) || + (phiJetOk[kj] > (header->GetJetPhiMax())) || + (phiJetOk[kj] < (header->GetJetPhiMin())) || + (etJetOk[kj] < header->GetMinJetEt())) continue; // acceptance eta range and etmin + Float_t px=-999, py=-999 ,pz=-999 ,en=-999; // convert to 4-vector + px = etJetOk[kj] * TMath::Cos(phiJetOk[kj]); + py = etJetOk[kj] * TMath::Sin(phiJetOk[kj]); + pz = etJetOk[kj] / TMath::Tan(2.0 * TMath::ATan(TMath::Exp(-etaJetOk[kj]))); + en = TMath::Sqrt(px * px + py * py + pz * pz); + AliAODJet jet(px, py, pz, en); + + // Calc jet area if it wasn't yet done + if (header->GetBackgMode() == 0){ + // calculate the area of the jet + Float_t rc= header->GetRadius(); + areaJetOk[kj] = fJetBkg->CalcJetAreaEtaCut(rc,etaJetOk[kj]); + } + + jet.SetEffArea(areaJetOk[kj],0.,0.,0.); + jet.SetBgEnergy(etbgTotal,0.); + if (fDebug>1) jet.Print(Form("%d",kj)); + + for(Int_t jpart = 0; jpart < nTracks; jpart++) { // loop for all particles in array + // Track to jet reordering + if(injet[jpart] == idx[kj]){ + injetOk[jpart] = kj; + } + // Check if the particle belongs to the jet and add the ref + if(injetOk[jpart] == kj && fCalTrkEvent->GetCalTrkTrack(jpart)->GetCutFlag() == 1) { + jet.AddTrack(fCalTrkEvent->GetCalTrkTrack(jpart)->GetTrackObject()); + } + } + + AddJet(jet); + + } + + //delete + delete[] ptT; + delete[] etaT; + delete[] phiT; + delete[] injet; + delete[] injetOk; + delete[] areaJet; + delete[] areaJetOk; + +} + +//----------------------------------------------------------------------- +void AliUA1JetFinder::RunAlgoritm(Float_t etbgTotal, Double_t dEtTotal, Int_t& nJets, + Float_t* const etJet,Float_t* const etaJet, Float_t* const phiJet, + Float_t* const etallJet, Int_t* const ncellsJet) +{ + // Dump lego + AliUA1JetHeader* header = (AliUA1JetHeader*) fHeader; + const Int_t nBinsMax = 120000; // we use a fixed array not to fragment memory + + const Int_t nBinEta = header->GetLegoNbinEta(); + const Int_t nBinPhi = header->GetLegoNbinPhi(); + if((nBinPhi*nBinEta)>nBinsMax){ + AliError("Too many bins of the ETA-PHI histogram"); + } + + Float_t etCell[nBinsMax] = {0.}; //! Cell Energy + Float_t etaCell[nBinsMax] = {0.}; //! Cell eta + Float_t phiCell[nBinsMax] = {0.}; //! Cell phi + Short_t flagCell[nBinsMax] = {0}; //! Cell flag + + Int_t nCell = 0; + TAxis* xaxis = fLego->GetXaxis(); + TAxis* yaxis = fLego->GetYaxis(); + Float_t e = 0.0; + for (Int_t i = 1; i <= nBinEta; i++) { + for (Int_t j = 1; j <= nBinPhi; j++) { + e = fLego->GetBinContent(i,j); + if (e < 0.0) continue; // don't include this cells + Float_t eta = xaxis->GetBinCenter(i); + Float_t phi = yaxis->GetBinCenter(j); + etCell[nCell] = e; + etaCell[nCell] = eta; + phiCell[nCell] = phi; + flagCell[nCell] = 0; //default + nCell++; + } + } + // Parameters from header + Float_t minmove = header->GetMinMove(); + Float_t maxmove = header->GetMaxMove(); + Float_t rc = header->GetRadius(); + Float_t etseed = header->GetEtSeed(); + // Tmp array of jets form algoritm + Float_t etaAlgoJet[kMaxJets] = {0.0}; + Float_t phiAlgoJet[kMaxJets] = {0.0}; + Float_t etAlgoJet[kMaxJets] = {0.0}; + Int_t ncellsAlgoJet[kMaxJets] = {0}; + + // Run algorithm// + + // Sort cells by et + Int_t index[nBinsMax]; + TMath::Sort(nCell, etCell, index); + // variable used in centroide loop + Float_t eta = 0.0; + Float_t phi = 0.0; + Float_t eta0 = 0.0; + Float_t phi0 = 0.0; + Float_t etab = 0.0; + Float_t phib = 0.0; + Float_t etas = 0.0; + Float_t phis = 0.0; + Float_t ets = 0.0; + Float_t deta = 0.0; + Float_t dphi = 0.0; + Float_t dr = 0.0; + Float_t etsb = 0.0; + Float_t etasb = 0.0; + Float_t phisb = 0.0; + Float_t dphib = 0.0; + + for(Int_t icell = 0; icell < nCell; icell++) + { + Int_t jcell = index[icell]; + if(etCell[jcell] <= etseed) continue; // if cell energy is low et seed + if(flagCell[jcell] != 0) continue; // if cell was used before + + eta = etaCell[jcell]; + phi = phiCell[jcell]; + eta0 = eta; + phi0 = phi; + etab = eta; + phib = phi; + ets = etCell[jcell]; + etas = 0.0; + phis = 0.0; + etsb = ets; + etasb = 0.0; + phisb = 0.0; + for(Int_t kcell =0; kcell < nCell; kcell++) + { + Int_t lcell = index[kcell]; + if(lcell == jcell) continue; // cell itself + if(flagCell[lcell] != 0) continue; // cell used before + if(etCell[lcell] > etCell[jcell]) continue; // can this happen + //calculate dr + deta = etaCell[lcell] - eta; + dphi = TMath::Abs(phiCell[lcell] - phi); + if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi; + dr = TMath::Sqrt(deta * deta + dphi * dphi); + if(dr <= rc) + { + // calculate offset from initiate cell + deta = etaCell[lcell] - eta0; + dphi = phiCell[lcell] - phi0; + if (dphi < -TMath::Pi()) dphi= dphi + 2.0 * TMath::Pi(); + if (dphi > TMath::Pi()) dphi = dphi - 2.0 * TMath::Pi(); + etas = etas + etCell[lcell]*deta; + phis = phis + etCell[lcell]*dphi; + ets = ets + etCell[lcell]; + //new weighted eta and phi including this cell + eta = eta0 + etas/ets; + phi = phi0 + phis/ets; + // if cone does not move much, just go to next step + dphib = TMath::Abs(phi - phib); + if (dphib > TMath::Pi()) dphib = 2. * TMath::Pi() - dphib; + dr = TMath::Sqrt((eta-etab)*(eta-etab) + dphib * dphib); + if(dr <= minmove) break; + // cone should not move more than max_mov + dr = TMath::Sqrt((etas/ets)*(etas/ets) + (phis/ets)*(phis/ets)); + if(dr > maxmove){ + eta = etab; + phi = phib; + ets = etsb; + etas = etasb; + phis = phisb; + } else { // store this loop information + etab=eta; + phib=phi; + etsb = ets; + etasb = etas; + phisb = phis; + } + } // inside cone + }//end of cells loop looking centroide + + // Avoid cones overloap (to be implemented in the future) + + // Flag cells in Rc, estimate total energy in cone + Float_t etCone = 0.0; + Int_t nCellIn = 0; + rc = header->GetRadius(); + + for(Int_t ncell =0; ncell < nCell; ncell++) + { + if(flagCell[ncell] != 0) continue; // cell used before + //calculate dr + deta = etaCell[ncell] - eta; + dphi = phiCell[ncell] - phi; + if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi(); + if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi; + dr = TMath::Sqrt(deta * deta + dphi * dphi); + if(dr <= rc){ // cell in cone + flagCell[ncell] = -1; + etCone+=etCell[ncell]; + nCellIn++; + } + } + + // Select jets with et > background + // estimate max fluctuation of background in cone + Double_t ncellin = (Double_t)nCellIn; + Double_t ntcell = (Double_t)nCell; + Double_t etbmax = (etbgTotal + dEtTotal )*(ncellin/ntcell); + // min cone et + Double_t etcmin = etCone ; // could be used etCone - etmin !! + //decisions !! etbmax < etcmin + + for(Int_t mcell =0; mcell < nCell; mcell++){ + if(flagCell[mcell] == -1){ + if(etbmax < etcmin) + flagCell[mcell] = 1; //flag cell as used + else + flagCell[mcell] = 0; // leave it free + } + } + //store tmp jet info !!! + if(etbmax < etcmin) { + if(nJets %d) found by UA1JetFinder, adapt your cuts",kMaxJets)); + break; + } + } + } // end of cells loop + + //reorder jets by et in cone + //sort jets by energy + for(Int_t p = 0; p < nJets; p++) + { + etaJet[p] = etaAlgoJet[p]; + phiJet[p] = phiAlgoJet[p]; + etJet[p] = etAlgoJet[p]; + etallJet[p] = etAlgoJet[p]; + ncellsJet[p] = ncellsAlgoJet[p]; + } + +} + +//----------------------------------------------------------------------- +void AliUA1JetFinder::Reset() +{ + fLego->Reset(); + AliJetFinder::Reset(); + +} + +//----------------------------------------------------------------------- +void AliUA1JetFinder::WriteJHeaderToFile() const +{ + AliUA1JetHeader* header = (AliUA1JetHeader*) fHeader; + header->Write(); + +} + +//----------------------------------------------------------------------- +void AliUA1JetFinder::Init() +{ + + // initializes some variables + AliUA1JetHeader* header = (AliUA1JetHeader*) fHeader; + // book lego + fLego = new TH2F("legoH","eta-phi", + header->GetLegoNbinEta(), header->GetLegoEtaMin(), + header->GetLegoEtaMax(), header->GetLegoNbinPhi(), + header->GetLegoPhiMin(), header->GetLegoPhiMax()); + +} + diff --git a/JETAN/DEV/AliUA1JetFinder.h b/JETAN/DEV/AliUA1JetFinder.h new file mode 100644 index 00000000000..00f72ebdf98 --- /dev/null +++ b/JETAN/DEV/AliUA1JetFinder.h @@ -0,0 +1,55 @@ +#ifndef ALIUA1JETFINDER_H +#define ALIUA1JETFINDER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// UA1 Cone Algorithm Finder +// manages the search for jets +// Author: Rafael.Diaz.Valdes@cern.ch +// (version in c++) +// ** 2011 +// Modified accordingly to reader/finder splitting and new handling of neutral information +// Versions V1 and V2 merged +//--------------------------------------------------------------------- + +#include "AliJetFinder.h" + +class TH2F; +class AliJetBkg; + +class AliUA1JetFinder : public AliJetFinder +{ + public: + + AliUA1JetFinder(); + ~AliUA1JetFinder(); + + // others + void FindJets(); + void RunAlgoritm(Float_t EtbgTotal, Double_t dEtTotal, Int_t& nJets, + Float_t* const etJet,Float_t* const etaJet, Float_t* const phiJet, + Float_t* const etallJet, Int_t* const ncellsJet); + + void Reset(); + void Init(); + void WriteJHeaderToFile() const; + + enum {kMaxJets = 60}; + + protected: + AliUA1JetFinder(const AliUA1JetFinder& rJetF1); + AliUA1JetFinder& operator = (const AliUA1JetFinder& rhsf); + + TH2F* fLego; // Lego Histo + + AliJetBkg* fJetBkg; //! pointer to bkg class + + ClassDef(AliUA1JetFinder,3) // UA1 jet finder + +}; + +#endif diff --git a/JETAN/DEV/AliUA1JetHeaderV1.cxx b/JETAN/DEV/AliUA1JetHeaderV1.cxx new file mode 100644 index 00000000000..f5bc7aaeaf2 --- /dev/null +++ b/JETAN/DEV/AliUA1JetHeaderV1.cxx @@ -0,0 +1,74 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// Jet Gen header class +// Stores parameters of particle algoritm +// Author: Rafael.Diaz.Valdes@cern.ch +//--------------------------------------------------------------------- + +#include +#include + +#include "AliUA1JetHeaderV1.h" + +ClassImp(AliUA1JetHeader) + +//////////////////////////////////////////////////////////////////////// + +AliUA1JetHeader::AliUA1JetHeader(): + AliJetHeader("AliUA1JetHeader"), + fEtSeed(3.0), + fMinJetEt(10.), + fMinMove(0.05), + fMaxMove(0.15), + fBackgMode(1), + fPrecBg(0.035), + fBackgStat(0.0), + fBackgCutRatio(1.0), + fNAcceptJets(3), + fLegoNbinEta(36), + fLegoNbinPhi(124), + fLegoEtaMin(-0.9), + fLegoEtaMax(0.9), + fLegoPhiMin(0.), + fLegoPhiMax(2.*TMath::Pi()), + fConeRadius(0.4) +{ + // Constructor +} + +//----------------------------------------------------------------------- +void AliUA1JetHeader::PrintParameters() const +{ + // prints out parameters of jet algorithm + + cout << " UA version1 jet algorithm " << endl; + cout << " * Jet parameters: " << endl; + cout << " Cone size: " << fConeRadius<< endl; + cout << " Minimum energy for a seed: " << fEtSeed << endl; + cout << " Minumum energy for a jet: " << fMinJetEt << endl; + cout << " Minimum allowed move: " << fMinMove << endl; + cout << " Maximum allowed move: " << fMaxMove << endl; + cout << " * Lego parameters: " << endl; + cout << " Number of bins in eta: " << fLegoNbinEta<< endl; + cout << " Number of bins in phi: " << fLegoNbinPhi<< endl; + cout << " Minimum azimuthal angle: " << fLegoPhiMin<< endl; + cout << " Maximum azimuthal angle: " << fLegoPhiMax<< endl; + cout << " Minimum rapidity angle: " << fLegoEtaMin<< endl; + cout << " Maximum rapidity angle: " << fLegoEtaMax<< endl; +} diff --git a/JETAN/DEV/AliUA1JetHeaderV1.h b/JETAN/DEV/AliUA1JetHeaderV1.h new file mode 100644 index 00000000000..7ecb9e514aa --- /dev/null +++ b/JETAN/DEV/AliUA1JetHeaderV1.h @@ -0,0 +1,90 @@ +#ifndef ALIUA1JETHEADER_H +#define ALIUA1JETHEADER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//--------------------------------------------------------------------- +// Jet Finder header class for algoritm using particles +// Stores the parameters of the particles algoritm +// Author: Rafael.Diaz.Valdes@cern.ch +//--------------------------------------------------------------------- + +#include "AliJetHeader.h" + + +class AliUA1JetHeader : public AliJetHeader +{ + public: + AliUA1JetHeader(); + virtual ~AliUA1JetHeader() { } + + // Getters + Float_t GetRadius() const {return fConeRadius;} + Float_t GetMinMove() const {return fMinMove;} + Float_t GetMaxMove() const {return fMaxMove;} + Float_t GetEtSeed() const {return fEtSeed;} + Float_t GetMinJetEt() const {return fMinJetEt;} + Int_t GetLegoNbinEta() const {return fLegoNbinEta;} + Int_t GetLegoNbinPhi() const {return fLegoNbinPhi;} + Float_t GetLegoEtaMin() const {return fLegoEtaMin;} + Float_t GetLegoEtaMax() const {return fLegoEtaMax;} + Float_t GetLegoPhiMin() const {return fLegoPhiMin;} + Float_t GetLegoPhiMax() const {return fLegoPhiMax;} + Int_t GetBackgMode() const {return fBackgMode;} + Float_t GetPrecBg() const {return fPrecBg;} + Float_t GetBackgStat() const {return fBackgStat;} + Float_t GetBackgCutRatio() const {return fBackgCutRatio;} + Int_t GetNAcceptJets() const {return fNAcceptJets;} + + // Setters + void SetRadius(Float_t f) {fConeRadius=f;} + void SetMinMove(Float_t f) {fMinMove=f;} + void SetMaxMove(Float_t f) {fMaxMove=f;} + void SetEtSeed(Float_t f) {fEtSeed=f;} + void SetMinJetEt(Float_t f) {fMinJetEt=f;} + void SetLegoNbinEta(Int_t f) {fLegoNbinEta=f;} + void SetLegoNbinPhi(Int_t f) {fLegoNbinPhi=f;} + void SetLegoEtaMin(Float_t f) {fLegoEtaMin=f;} + void SetLegoEtaMax(Float_t f) {fLegoEtaMax=f;} + void SetLegoPhiMin(Float_t f) {fLegoPhiMin=f;} + void SetLegoPhiMax(Float_t f) {fLegoPhiMax=f;} + void BackgMode(Int_t mod ) {fBackgMode = mod;} + void SetPrecBg(Float_t f) {fPrecBg=f;} + void SetBackgStat(Float_t f) {fBackgStat=f;} + void SetBackgCutRatio(Float_t f) {fBackgCutRatio=f;} + void SetNAcceptJets(Int_t ajets) {fNAcceptJets = ajets;} + + // others + void PrintParameters() const; + + protected: + + // parameters of algorithm + Float_t fEtSeed; // Min. Et for seed + Float_t fMinJetEt; // Min Et of jet + // parameters of backgound substraction + Float_t fMinMove; // min cone move + Float_t fMaxMove; // max cone move + Int_t fBackgMode; // background subtraction mode + Float_t fPrecBg; // max value of change for BG (in %) + Float_t fBackgStat; // pre-calculated background used in statistic subtraction method + Float_t fBackgCutRatio; // pre-calculated pt-cut ratio used in ratio subtraction method + Int_t fNAcceptJets; // number of accepted jets per events + + // parameters for legos + Int_t fLegoNbinEta; // number of cells in eta + Int_t fLegoNbinPhi; // number of cells in phi + Float_t fLegoEtaMin; // minimum eta + Float_t fLegoEtaMax; // maximum eta + Float_t fLegoPhiMin; // minimun phi + Float_t fLegoPhiMax; // maximum phi + Float_t fConeRadius; // Cone radius + + ClassDef(AliUA1JetHeader,2) // UA1 jet finder header + +}; + +#endif diff --git a/JETAN/FASTJETANdevLinkDef.h b/JETAN/FASTJETANdevLinkDef.h new file mode 100644 index 00000000000..96a29fc05ba --- /dev/null +++ b/JETAN/FASTJETANdevLinkDef.h @@ -0,0 +1,15 @@ +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class AliFastJetBkg+; +#pragma link C++ class AliFastJetInput+; +#pragma link C++ class AliFastJetFinder+; +#pragma link C++ class AliFastJetHeaderV1+; +#pragma link C++ class AliSISConeJetFinder+; +#pragma link C++ class AliSISConeJetHeader+; +#pragma link C++ class AliAnalysisTaskJetCluster+; +#pragma link C++ class AliAnalysisTaskJetBackgroundSubtract+; +#endif diff --git a/JETAN/JETANdevLinkDef.h b/JETAN/JETANdevLinkDef.h new file mode 100644 index 00000000000..a93b55c14ee --- /dev/null +++ b/JETAN/JETANdevLinkDef.h @@ -0,0 +1,34 @@ +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class AliJetHeader+; +#pragma link C++ class AliUA1JetHeader+; +#pragma link C++ class AliJetFinder+; +#pragma link C++ class AliJetReaderHeader+; +#pragma link C++ class AliJetReader+; +#pragma link C++ class AliUA1JetFinder+; +#pragma link C++ class AliCdfJetFinder+; +#pragma link C++ class AliCdfJetHeader+; +#pragma link C++ class AliAnalysisTaskJetsReader+; +#pragma link C++ class AliAnalysisTaskJetsFinder+; +#pragma link C++ class AliDAJetFinder+; +#pragma link C++ class AliDAJetHeader+; +#pragma link C++ class AliJetKineReaderHeader+; +#pragma link C++ class AliJetHistos+; +#pragma link C++ class AliAnalysisTaskDiJets+; +#pragma link C++ class AliEventShape+; +#pragma link C++ class AliKMeansClustering+; +#pragma link C++ class AliKMeansResult+; +#pragma link C++ class AliAnalysisTaskKMeans+; +#pragma link C++ class AliAnalysisTaskFastEmbedding+; +#pragma link C++ class AliJetBkg+; +#pragma link C++ class AliJetCalTrkEvent+; +#pragma link C++ class AliJetCalTrkTrack+; +#pragma link C++ class AliJetCalTrkTrackKine+; +#pragma link C++ class AliJetFillCalTrkTrack+; +#pragma link C++ class AliJetFillCalTrkTrackMC+; +#pragma link C++ class AliJetFillCalTrkEvent+; +#endif diff --git a/JETAN/Makefile b/JETAN/Makefile index 6a2f5569928..c468efdcd4f 100644 --- a/JETAN/Makefile +++ b/JETAN/Makefile @@ -8,6 +8,9 @@ DHDR = $(PACKAGE)LinkDef.h ALICEINC = -I. +ifneq ($(findstring dev,$(PACKAGE)),) + ALICEINC += -I./DEV +endif ### define include dir for local case and par case ifneq ($(OADB_INCLUDE),) @@ -16,26 +19,45 @@ endif ifneq ($(EMCALUtils_INCLUDE),) ALICEINC += -I../$(EMCALUtils_INCLUDE) endif +ifneq ($(JETANDEV_INCLUDE),) + ifneq ($(FASTJET_ROOT),) + ALICEINC += -I$(FASTJET_ROOT)/include + else + ALICEINC += -I$(ALICE_ROOT)/JETAN/fastjet + endif +endif ifneq ($(JETAN_INCLUDE),) + ifeq ($(findstring dev,$(PACKAGE)),) ifneq ($(FASTJET_ROOT),) ALICEINC += -I$(FASTJET_ROOT)/include else ALICEINC += -I$(ALICE_ROOT)/JETAN/fastjet endif + endif endif + ifneq ($(ESD_INCLUDE),) ALICEINC += -I../$(ESD_INCLUDE) ALICEINC += -I../$(AOD_INCLUDE) ALICEINC += -I../$(STEERBase_INCLUDE) ALICEINC += -I../$(ANALYSIS_INCLUDE) ALICEINC += -I../$(ANALYSISalice_INCLUDE) - ifneq ($(JETAN_INCLUDE),) + ifneq ($(JETANDEV_INCLUDE),) + ALICEINC += -I../$(JETANDEV_INCLUDE) + endif + ifneq ($(JETAN_INCLUDE),) + ifeq ($(findstring dev,$(PACKAGE)),) ALICEINC += -I../$(JETAN_INCLUDE) + endif endif else ifneq ($(ALICE_ROOT),) + ifneq ($(findstring dev,$(PACKAGE)),) + ALICEINC += -I$(ALICE_ROOT)/include -I$(ALICE_ROOT)/JETAN/DEV -I$(ALICE_ROOT)/ANALYSIS + else ALICEINC += -I$(ALICE_ROOT)/include -I$(ALICE_ROOT)/JETAN -I$(ALICE_ROOT)/ANALYSIS endif + endif endif CXXFLAGS += $(ALICEINC) -g diff --git a/JETAN/PROOF-INF.FASTJETANdev/BUILD.sh b/JETAN/PROOF-INF.FASTJETANdev/BUILD.sh new file mode 100644 index 00000000000..fc9490a6c2d --- /dev/null +++ b/JETAN/PROOF-INF.FASTJETANdev/BUILD.sh @@ -0,0 +1,3 @@ +#! /bin/sh + +make diff --git a/JETAN/PROOF-INF.FASTJETANdev/SETUP.C b/JETAN/PROOF-INF.FASTJETANdev/SETUP.C new file mode 100644 index 00000000000..ff8045b0327 --- /dev/null +++ b/JETAN/PROOF-INF.FASTJETANdev/SETUP.C @@ -0,0 +1,11 @@ +void SETUP() +{ + // Load some ROOT libraries + gSystem->Load("libFASTJETANdev"); + + // Set the Inlucde paths + gROOT->ProcessLine(".include FASTJETANdev"); + + // Set our location, so that other packages can find us + gSystem->Setenv("FASTJETANDEV_INCLUDE", "FASTJETANdev/DEV"); +} diff --git a/JETAN/PROOF-INF.JETANdev/BUILD.sh b/JETAN/PROOF-INF.JETANdev/BUILD.sh new file mode 100644 index 00000000000..fc9490a6c2d --- /dev/null +++ b/JETAN/PROOF-INF.JETANdev/BUILD.sh @@ -0,0 +1,3 @@ +#! /bin/sh + +make diff --git a/JETAN/PROOF-INF.JETANdev/SETUP.C b/JETAN/PROOF-INF.JETANdev/SETUP.C new file mode 100644 index 00000000000..f3736e1e976 --- /dev/null +++ b/JETAN/PROOF-INF.JETANdev/SETUP.C @@ -0,0 +1,12 @@ +void SETUP() +{ + // Load some ROOT libraries + gSystem->Load("libJETANdev"); + + // Set the Inlucde paths + gSystem->SetIncludePath("-I$ROOTSYS/include -IJETANdev"); + gROOT->ProcessLine(".include JETANdev"); + + // Set our location, so that other packages can find us + gSystem->Setenv("JETANDEV_INCLUDE", "JETANdev/DEV/"); +} diff --git a/PWG4/Makefile b/PWG4/Makefile index 6e88ae683cb..0f49f15c087 100644 --- a/PWG4/Makefile +++ b/PWG4/Makefile @@ -41,6 +41,10 @@ ifneq ($(CORRFW_INCLUDE),) ALICEINC += -I../$(CORRFW_INCLUDE) endif +ifneq ($(PWGBase_INCLUDE),) + ALICEINC += -I../$(PWGBase_INCLUDE) +endif + ifneq ($(PHOSUtils_INCLUDE),) ALICEINC += -I../$(PHOSUtils_INCLUDE) CXXFLAGS+=-D__PHOSUTIL__ @@ -84,6 +88,10 @@ ifneq ($(JETAN_INCLUDE),) ALICEINC += -I../$(JETAN_INCLUDE) endif +ifneq ($(JETANDEV_INCLUDE),) + ALICEINC += -I../$(JETANDEV_INCLUDE) +endif + ifneq ($(PWG4JCORRAN_INCLUDE),) ALICEINC += -I../$(PWG4JCORRAN_INCLUDE) endif @@ -145,7 +153,7 @@ endif $(CXX) $(PACKCXXFLAGS) -c $< -o $@ clean: - @rm -f $(OBJS) *.so G__$(PACKAGE).* + @rm -f $(OBJS_PWG4) *.so G__$(PACKAGE).* G__$(PACKAGE).cxx G__$(PACKAGE).h: $(HDRS) $(DHDR) @echo "Generating dictionaries ..." $(ALICEINC) diff --git a/PWG4/macros/AnalysisTrainPWG4Jets.C b/PWG4/macros/AnalysisTrainPWG4Jets.C index 3d8a5a26fba..e3f44a465e4 100644 --- a/PWG4/macros/AnalysisTrainPWG4Jets.C +++ b/PWG4/macros/AnalysisTrainPWG4Jets.C @@ -83,7 +83,9 @@ Bool_t kIsPbPb = kFALSE; // Pb+Pb // ### Analysis modules to be included. Some may not be yet fully implemented. //============================================================================== Int_t iJETAN = 1; // Jet analysis (PWG4) // 1 write standard 2 write non-standard jets, 3 wrtie both -Int_t iJETSUBTRACT = 1; // Jet background subtration +Int_t iJETANReader = 0; // Jet analysis (PWG4) // DEV +Int_t iJETANFinder = 0; // Jet analysis (PWG4) // DEV +Int_t iJETSUBTRACT = 0; // Jet background subtration TList kJetListSpectrum; // list of jets contains TObjString of possible jet finder names TExMap kJetMapSpectrum; // Maps the jet finder pairs to be used in the spectrum task second number negative no pair other wise (j1+1) + (1000 * (j2+1)) +10000 * (j3+1) TExMap kJetBackMapSpectrum; // Maps the jet finder pairs with the background branch used, just for countint of trackrefs @@ -106,6 +108,7 @@ TString kJetSubtractMask1 = "B0"; TString kJetSubtractMask2 = "B%d"; Int_t iDIJETAN = 1; Int_t iJETANLib = 1; +Int_t iJETANdevLib = 0; Int_t iPWGPPQASym = 0; // Eva's QA task compiled on the fly... Int_t iPWG4FastEmbedding = 0; // Generate non-standard AOD for embedding Int_t iPWG4JetTasks = 0; // all jet tasks flag for lib laoding @@ -256,6 +259,8 @@ void AnalysisTrainPWG4Jets(const char *analysis_mode="local", if (useTender) printf("= Using tender =\n"); if (iESDfilter) printf("= ESD filter =\n"); if (iJETAN) printf("= Jet analysis =\n"); + if (iJETANReader) printf("= Jet analysis Reader (DEV) =\n"); + if (iJETANFinder) printf("= Jet analysis Finder (DEV) =\n"); printf("==================================================================\n"); char *printMask = ":: %20s %10d\n"; @@ -570,6 +575,51 @@ void AnalysisTrainPWG4Jets(const char *analysis_mode="local", if (!taskjets) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJets cannot run for this train conditions - EXCLUDED"); } + // Jet analysis DEV + if (iJETANReader) { + gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetsReader.C"); + AliAnalysisTaskJetsReader *taskjets = 0; + + if(iJETANReader&1) { + AliAnalysisDataContainer* cont_jet1 = AddJetExchangeContainer("jets_1"); + taskjets = AddTaskJetsReader(cont_jet1,kHighPtFilterMask); + } + + if(iJETANReader&2) { + AliAnalysisDataContainer* cont_jet1 = AddJetExchangeContainer("jets_1"); + taskjets = AddTaskJetsReader(cont_jet1,"AOD",kHighPtFilterMask,0.15); + + + AliAnalysisDataContainer* cont_jet2 = AddJetExchangeContainer("jets_2"); + taskjets = AddTaskJetsReader(cont_jet2,"AOD", kHighPtFilterMask,1.); + + } + + taskjets->GetJetReader()->GetReaderHeader()->SetIsHighMult(kIsPbPb); + + + if ( !taskjets ) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetsReader cannot run for this train conditions - EXCLUDED"); + + } + + if (iJETANFinder && iJETANReader) { + gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetsFinder.C"); + AliAnalysisTaskJetsFinder *taskjetsFinder = 0; + + if(iJETANFinder&1) { + taskjetsFinder = AddTaskJetsFinder(cont_jet1); + } + + if(iJETANFinder&2) { + taskjetsFinder = AddTaskJetsFinder(cont_jet1,"UA1",0.4,0); // UA1 no bkg subtraction (reader: jet_1) + taskjetsFinder = AddTaskJetsFinder(cont_jet1,"FASTJET",0.4,1); // FASTJET B1 (reader: jet_1) + + taskjetsFinder = AddTaskJetsFinder(cont_jet2,"FASTJET",0.4,0); // FASTJET B0 (reader: jet_2) + } + + if ( !taskjetsFinder || !taskjets ) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetsFinder cannot run for this train conditions - EXCLUDED"); + + } if (iPWG4FastEmbedding && iJETAN) { AliAnalysisTaskJets *taskEmbJets = AddTaskJets("AODextra", "FASTJET", 0.4, kHighPtFilterMask); @@ -1529,9 +1579,11 @@ void CheckModuleFlags(const char *mode) { ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "Physics Selection disabled in analysis on AOD's"); iPhysicsSelection = 0; if (!iAODhandler) { - if (iJETAN) + if (iJETAN || iJETANReader || iJETANFinder) ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "JETAN disabled in analysis on AOD's without AOD handler"); iJETAN = 0; + iJETANReader=0; + iJETANFinder=0; iDIJETAN = 0; } // Disable tasks that do not work yet on AOD data @@ -1579,14 +1631,14 @@ void CheckModuleFlags(const char *mode) { if( iPWG4CorrectionsUE)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 CorrectionsUE disabled in analysis without MC"); iPWG4CorrectionsUE = 0; } - if (iJETAN){ - iESDfilter=1; + if (iJETAN || iJETANReader || iJETANFinder){ + iESDfilter=0; } if (!iESDfilter){ kUseKinefilter = kFALSE; kUseMuonfilter = kFALSE; } - if(!iJETAN){ + if(!iJETAN ||iJETANReader || iJETANFinder){ iPWG4JetSpectrum = iPWG4UE = iPWG4CorrectionsUE = iPWG4ThreeJets = iPWG4QGSep = iDIJETAN = 0; } } @@ -1595,8 +1647,9 @@ void CheckModuleFlags(const char *mode) { iPWG4GammaConvLib = iPWG4GammaConv||iPWG4CaloConv; - iEMCUtilLibs = iPWG4JetTasks||iPWG4PartCorrLibs||iPWG4JCORRAN||iPWG4GammaConvLib||iJETAN; - iJETANLib = iPWG4JetTasks||iJETAN||iDIJETAN; + iEMCUtilLibs = iPWG4JetTasks||iPWG4PartCorrLibs||iPWG4JCORRAN||iPWG4GammaConvLib||iJETAN||iJETANReader||iJETANFinder; + iJETANLib = (iPWG4JetTasks||iJETAN||iDIJETAN) && !(iJETANReader||iJETANFinder) ; + iJETANdevLib = (iPWG4JetTasks||iJETANReader||iJETANFinder||iDIJETAN) && !iJETAN ; if (iESDfilter) {iAODhandler=1;} if (kUseKinefilter && !kUseMC) kUseKinefilter = kFALSE; @@ -1805,8 +1858,37 @@ Bool_t LoadAnalysisLibraries(const char *mode) } if (!LoadLibrary("FASTJETAN", mode, kTRUE)) return kFALSE; } + + // JETANdev + if (iJETANdevLib) { + // this part needs some rework in case we do not need the fastjed finders for processing + if(iEMCUtilLibs){ + if (!LoadLibrary("EMCALUtils", mode, kTRUE) && + !LoadLibrary("PHOSUtils", mode, kTRUE)) return kFALSE; + } + if (!LoadLibrary("JETANdev", mode, kTRUE)) return kFALSE; + if (!strcmp(mode, "PROOF")){ + if (!LoadLibrary("FASTJET", mode, kTRUE)) return kFALSE; + } + if(!kUsePAR){ + if (!LoadLibrary("CGAL", mode, kTRUE)) return kFALSE; + if (!LoadLibrary("fastjet", mode, kTRUE)) return kFALSE; + if (!LoadLibrary("siscone", mode, kTRUE)) return kFALSE; + if (!LoadLibrary("SISConePlugin", mode, kTRUE)) return kFALSE; + } + else{ + // par files plus FASTJET needs some extra work... need to change + // the loading sequence in the auto generated .C file + if (!LoadLibrary("libCGAL.so", mode, kTRUE)) return kFALSE; + if (!LoadLibrary("libfastjet.so", mode, kTRUE)) return kFALSE; + if (!LoadLibrary("libsiscone.so", mode, kTRUE)) return kFALSE; + if (!LoadLibrary("libSISConePlugin.so", mode, kTRUE)) return kFALSE; + } + if (!LoadLibrary("FASTJETANdev", mode, kTRUE)) return kFALSE; + } + if(iPWG4JetTasks){ - if (!LoadLibrary("PWG4Base", mode, kTRUE)) return kFALSE; + if (!LoadLibrary("PWGBase", mode, kTRUE)) return kFALSE; if (!LoadLibrary("PWG4JetTasks", mode, kTRUE)) return kFALSE; } -- 2.43.0