From 7f2a4d8bc231e84d94afbd62ca8ae597fd1f19ab Mon Sep 17 00:00:00 2001 From: akisiel Date: Mon, 18 Feb 2008 10:54:49 +0000 Subject: [PATCH] Adding the PWG2 AOD code Creates a new library with a PWG2 specific information that needs to be added to the AOD as an additional track information, which has a TRef pointing back at the original AliAODTrack Adding a filter task which creates the PWG2 AOD --- PWG2/AOD/AliAnalysisTaskESDfilter.h | 45 ++ PWG2/AOD/AliAnalysisTaskPWG2ESDfilter.cxx | 837 ++++++++++++++++++++++ PWG2/AOD/AliAnalysisTaskPWG2ESDfilter.h | 56 ++ PWG2/AOD/AliPWG2AODTrack.cxx | 150 ++++ PWG2/AOD/AliPWG2AODTrack.h | 56 ++ PWG2/Makefile | 27 +- PWG2/PROOF-INF.PWG2AOD/BUILD.sh | 3 + PWG2/PROOF-INF.PWG2AOD/SETUP.C | 32 + PWG2/PWG2AODLinkDef.h | 10 + PWG2/libPWG2AOD.pkg | 11 + 10 files changed, 1225 insertions(+), 2 deletions(-) create mode 100644 PWG2/AOD/AliAnalysisTaskESDfilter.h create mode 100644 PWG2/AOD/AliAnalysisTaskPWG2ESDfilter.cxx create mode 100644 PWG2/AOD/AliAnalysisTaskPWG2ESDfilter.h create mode 100644 PWG2/AOD/AliPWG2AODTrack.cxx create mode 100644 PWG2/AOD/AliPWG2AODTrack.h create mode 100755 PWG2/PROOF-INF.PWG2AOD/BUILD.sh create mode 100644 PWG2/PROOF-INF.PWG2AOD/SETUP.C create mode 100644 PWG2/PWG2AODLinkDef.h create mode 100644 PWG2/libPWG2AOD.pkg diff --git a/PWG2/AOD/AliAnalysisTaskESDfilter.h b/PWG2/AOD/AliAnalysisTaskESDfilter.h new file mode 100644 index 00000000000..1da73c3ed48 --- /dev/null +++ b/PWG2/AOD/AliAnalysisTaskESDfilter.h @@ -0,0 +1,45 @@ +#ifndef ALIANALYSISTASKPWG2ESDFILTER_H +#define ALIANALYSISTASKPWG2ESDFILTER_H + +#include +#include + +class AliESDEvent; +class TChain; +class AliAODEvent; +class AliAnalysisFilter; + +class AliAnalysisTaskPWG2ESDfilter : public AliAnalysisTask +{ + public: + AliAnalysisTaskPWG2ESDfilter(); + AliAnalysisTaskPWG2ESDfilter(const char* name); + virtual ~AliAnalysisTaskPWG2ESDfilter() {;} + // Implementation of interface methods + virtual void ConnectInputData(Option_t *option = ""); + virtual void CreateOutputObjects(); + virtual void Init(); + virtual void LocalInit() {Init();} + virtual void Exec(Option_t *option); + virtual void Terminate(Option_t *option); + // Setters + virtual void SetTrackFilter(AliAnalysisFilter* trackF) {fTrackFilter = trackF;} + virtual void SetKinkFilter (AliAnalysisFilter* KinkF) {fKinkFilter = KinkF;} + virtual void SetV0Filter (AliAnalysisFilter* V0F) {fV0Filter = V0F;} + virtual void SetDebugLevel(Int_t level) {fDebug = level;} + + private: + Int_t fDebug; // Debug flag + TTree* fTree; //! chained files + AliESDEvent* fESD; //! ESD + AliAODEvent* fAOD; //! AOD event + TTree* fTreeA; //! AOD tree + AliAnalysisFilter* fTrackFilter; // Track Filter + AliAnalysisFilter* fKinkFilter; // Kink Filter + AliAnalysisFilter* fV0Filter; // V0 Filter + TClonesArray fPWG2AODTracks; //! container for PWG2 specific information + + ClassDef(AliAnalysisTaskPWG2ESDfilter, 1); // Analysis task for standard ESD filtering +}; + +#endif diff --git a/PWG2/AOD/AliAnalysisTaskPWG2ESDfilter.cxx b/PWG2/AOD/AliAnalysisTaskPWG2ESDfilter.cxx new file mode 100644 index 00000000000..083b0d2fad9 --- /dev/null +++ b/PWG2/AOD/AliAnalysisTaskPWG2ESDfilter.cxx @@ -0,0 +1,837 @@ +//------------------------------------------------------------------------- +// Task for the Analysis Framework +// Creates a PWG2 specific AOD, from the ESD adding information required +// for PWG2 analysis. +// - Puts the per-track information into the AliPWG2AODTrack container, +// together with the link to the original AliAODTrack +// +// Author: Adam Kisiel, OSU, Adam.Kisiel@cern.ch +//------------------------------------------------------------------------- +#include +#include +#include + +#include "AliAnalysisTaskPWG2ESDfilter.h" +#include "AliAnalysisManager.h" +#include "AliESDEvent.h" +#include "AliAODEvent.h" +#include "AliESDInputHandler.h" +#include "AliAODHandler.h" +#include "AliAnalysisFilter.h" +#include "AliESDtrack.h" +#include "AliESDMuonTrack.h" +#include "AliESDVertex.h" +#include "AliESDv0.h" +#include "AliESDkink.h" +#include "AliESDcascade.h" +#include "AliLog.h" +#include "AliPWG2AODTrack.h" + +ClassImp(AliAnalysisTaskPWG2ESDfilter) + +//////////////////////////////////////////////////////////////////////// + +AliAnalysisTaskPWG2ESDfilter::AliAnalysisTaskPWG2ESDfilter(): + fDebug(0), + fTree(0x0), + fESD(0x0), + fAOD(0x0), + fTreeA(0x0), + fTrackFilter(0x0), + fKinkFilter(0x0), + fV0Filter(0x0), + fPWG2AODTracks(0x0) +{ + // Default constructor +} + +AliAnalysisTaskPWG2ESDfilter::AliAnalysisTaskPWG2ESDfilter(const char* name): + AliAnalysisTask(name, "AnalysisTaskESDfilter"), + fDebug(0), + fTree(0x0), + fESD(0x0), + fAOD(0x0), + fTreeA(0x0), + fTrackFilter(0x0), + fKinkFilter(0x0), + fV0Filter(0x0), + fPWG2AODTracks(0x0) +{ + // Default constructor + DefineInput (0, TChain::Class()); + DefineOutput(0, TTree::Class()); +} + +void AliAnalysisTaskPWG2ESDfilter::CreateOutputObjects() +{ +// Create the output container + if (fDebug > 1) AliInfo("CreateOutPutData() \n"); + AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()); + + fAOD = handler->GetAOD(); + fTreeA = handler->GetTree(); + fTreeA->GetUserInfo()->Add(fTrackFilter); + + // *** PWG2 specific *** + + fPWG2AODTracks = new TClonesArray("AliPWG2AODTrack", 0); + const char *name = "pwg2aodtracks"; + fPWG2AODTracks->SetName(name); + + fAOD->AddObject(fPWG2AODTracks); + + TBranch *newBranch = fTreeA->Branch(name, &fPWG2AODTracks); + fTreeA->GetUserInfo()->Add(fPWG2AODTracks); + + // --- END PWG2 specific --- +} + +void AliAnalysisTaskPWG2ESDfilter::Init() +{ + // Initialization + if (fDebug > 1) AliInfo("Init() \n"); + // Call configuration file +} + +void AliAnalysisTaskPWG2ESDfilter::ConnectInputData(Option_t */*option*/) +{ +// Connect the input data +// + if (fDebug > 1) AliInfo("ConnectInputData() \n"); + // Input + AliESDInputHandler* esdH = (AliESDInputHandler*) + ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler()); + fESD = (AliESDEvent*) esdH->GetEvent(); + fTree = esdH->GetTree(); +} + +void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/) +{ +// Execute analysis for current event +// + // ESD Filter analysis task executed for each event + AliESD* old = fESD->GetAliESDOld(); + + Long64_t ientry = fTree->GetReadEntry(); + printf("Filter: Analysing event # %5d\n", (Int_t) ientry); + + // set arrays and pointers + Double_t pos[3]; + Double_t p[3]; + Double_t covVtx[6]; + Double_t covTr[21]; + Double_t pid[10]; + + for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.; + for (Int_t i = 0; i < 21; i++) covTr [i] = 0.; + + // *** PWG2 specific *** + + Double_t tpcentrancepoint[3]; + Double_t tpcexitpoint[3]; + TBits sharemap; + TBits clustermap; + + for (Int_t i = 0; i < 3; i++) { tpcentrancepoint[i] = 0.; tpcexitpoint[i] = 0; } + + // --- END PWG2 specific --- + + + // loop over events and fill them + + // Multiplicity information needed by the header (to be revised!) + Int_t nTracks = fESD->GetNumberOfTracks(); + Int_t nPosTracks = 0; + for (Int_t iTrack = 0; iTrack < nTracks; ++iTrack) + if (fESD->GetTrack(iTrack)->GetSign()> 0) nPosTracks++; + + // Update the header + + AliAODHeader* header = fAOD->GetHeader(); + header->SetRunNumber(fESD->GetRunNumber()); + if (old) { + header->SetBunchCrossNumber(0); + header->SetOrbitNumber(0); + header->SetPeriodNumber(0); + header->SetEventType(0); + header->SetMuonMagFieldScale(-999.); + header->SetCentrality(-999.); + } else { + header->SetBunchCrossNumber(fESD->GetBunchCrossNumber()); + header->SetOrbitNumber(fESD->GetOrbitNumber()); + header->SetPeriodNumber(fESD->GetPeriodNumber()); + header->SetEventType(fESD->GetEventType()); + header->SetMuonMagFieldScale(-999.); + header->SetCentrality(-999.); + } + + header->SetTriggerMask(fESD->GetTriggerMask()); + header->SetTriggerCluster(fESD->GetTriggerCluster()); + header->SetMagneticField(fESD->GetMagneticField()); + header->SetZDCN1Energy(fESD->GetZDCN1Energy()); + header->SetZDCP1Energy(fESD->GetZDCP1Energy()); + header->SetZDCN2Energy(fESD->GetZDCN2Energy()); + header->SetZDCP2Energy(fESD->GetZDCP2Energy()); + header->SetZDCEMEnergy(fESD->GetZDCEMEnergy(0),fESD->GetZDCEMEnergy(1)); + header->SetRefMultiplicity(nTracks); + header->SetRefMultiplicityPos(nPosTracks); + header->SetRefMultiplicityNeg(nTracks - nPosTracks); +// +// + Int_t nV0s = fESD->GetNumberOfV0s(); + Int_t nCascades = fESD->GetNumberOfCascades(); + Int_t nKinks = fESD->GetNumberOfKinks(); + Int_t nVertices = nV0s + nCascades + nKinks + 1 /* = prim. vtx*/; + Int_t nJets = 0; + Int_t nCaloClus = fESD->GetNumberOfCaloClusters(); + Int_t nFmdClus = 0; + Int_t nPmdClus = fESD->GetNumberOfPmdTracks(); + + printf(" NV0=%d NCASCADES=%d NKINKS=%d\n", nV0s, nCascades, nKinks); + +// fAOD->ResetStd(nTracks, nVertices, nV0s+nCascades, nJets, nCaloClus, nFmdClus, nPmdClus); + + AliAODTrack *aodTrack; + + + // Array to take into account the tracks already added to the AOD + Bool_t * usedTrack = NULL; + if (nTracks>0) { + usedTrack = new Bool_t[nTracks]; + for (Int_t iTrack=0; iTrack0) { + usedV0 = new Bool_t[nV0s]; + for (Int_t iV0=0; iV00) { + usedKink = new Bool_t[nKinks]; + for (Int_t iKink=0; iKinkGetVertices()); + Int_t jVertices=0; + + // Access to the AOD container of tracks + TClonesArray &tracks = *(fAOD->GetTracks()); + Int_t jTracks=0; + Int_t pTracks=0; + + // Add primary vertex. The primary tracks will be defined + // after the loops on the composite objects (V0, cascades, kinks) + const AliESDVertex *vtx = fESD->GetPrimaryVertex(); + + vtx->GetXYZ(pos); // position + vtx->GetCovMatrix(covVtx); //covariance matrix + + AliAODVertex * primary = new(vertices[jVertices++]) + AliAODVertex(pos, covVtx, vtx->GetChi2toNDF(), NULL, AliAODVertex::kPrimary); + primary->Print(); + + + // Create vertices starting from the most complex objects + Double_t chi2 = 0.; + + // Cascades + for (Int_t nCascade = 0; nCascade < nCascades; ++nCascade) { + AliESDcascade *cascade = fESD->GetCascade(nCascade); + + cascade->GetXYZ(pos[0], pos[1], pos[2]); + + if (!old) { + chi2 = vtx->GetChi2toNDF(); + cascade->GetPosCovXi(covVtx); + } else { + chi2 = -999.; + } + // Add the cascade vertex + AliAODVertex * vcascade = new(vertices[jVertices++]) AliAODVertex(pos, + covVtx, + chi2, // = chi2/NDF since NDF = 2*2-3 (AM) + primary, + AliAODVertex::kCascade); + + primary->AddDaughter(vcascade); + + // Add the V0 from the cascade. The ESD class have to be optimized... + // Now we have to search for the corresponding Vo in the list of V0s + // using the indeces of the positive and negative tracks + + Int_t posFromV0 = cascade->GetPindex(); + Int_t negFromV0 = cascade->GetNindex(); + + + AliESDv0 * v0 = 0x0; + Int_t indV0 = -1; + + for (Int_t iV0=0; iV0GetV0(iV0); + Int_t posV0 = v0->GetPindex(); + Int_t negV0 = v0->GetNindex(); + + if (posV0==posFromV0 && negV0==negFromV0) { + indV0 = iV0; + break; + } + } + + AliAODVertex * vV0FromCascade = 0x0; + + if (indV0>-1 && !usedV0[indV0] ) { + + // the V0 exists in the array of V0s and is not used + + usedV0[indV0] = kTRUE; + + v0->GetXYZ(pos[0], pos[1], pos[2]); + if (!old) { + chi2 = v0->GetChi2V0(); + v0->GetPosCov(covVtx); + } else { + chi2 = -999.; + } + + vV0FromCascade = new(vertices[jVertices++]) AliAODVertex(pos, + covVtx, + chi2, // = chi2/NDF since NDF = 2*2-3 (AM) + vcascade, + AliAODVertex::kV0); + } else { + + // the V0 doesn't exist in the array of V0s or was used +// cerr << "Error: event " << fESD->GetEventNumberInFile() << " cascade " << nCascade +// << " The V0 " << indV0 +// << " doesn't exist in the array of V0s or was used!" << endl; + + cascade->GetXYZ(pos[0], pos[1], pos[2]); + + if (!old) { + chi2 = v0->GetChi2V0(); + cascade->GetPosCov(covVtx); + } else { + chi2 = -999.; + } + + vV0FromCascade = new(vertices[jVertices++]) AliAODVertex(pos, + covVtx, + chi2, // = chi2/NDF since NDF = 2*2-3 (AM) + vcascade, + AliAODVertex::kV0); + vcascade->AddDaughter(vV0FromCascade); + } + + // Add the positive tracks from the V0 + + if (posFromV0>-1 && !usedTrack[posFromV0]) { + + usedTrack[posFromV0] = kTRUE; + + AliESDtrack *esdTrack = fESD->GetTrack(posFromV0); + esdTrack->GetPxPyPz(p); + esdTrack->GetXYZ(pos); + esdTrack->GetCovarianceXYZPxPyPz(covTr); + esdTrack->GetESDpid(pid); + + vV0FromCascade->AddDaughter(aodTrack = + new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), + esdTrack->GetLabel(), + p, + kTRUE, + pos, + kFALSE, + covTr, + (Short_t)esdTrack->GetSign(), + esdTrack->GetITSClusterMap(), + pid, + vV0FromCascade, + kTRUE, // check if this is right + kFALSE, // check if this is right + AliAODTrack::kSecondary) + ); + aodTrack->ConvertAliPIDtoAODPID(); + } + else { +// cerr << "Error: event " << fESD->GetEventNumberInFile() << " cascade " << nCascade +// << " track " << posFromV0 << " has already been used!" << endl; + } + + // Add the negative tracks from the V0 + + if (negFromV0>-1 && !usedTrack[negFromV0]) { + + usedTrack[negFromV0] = kTRUE; + + AliESDtrack *esdTrack = fESD->GetTrack(negFromV0); + esdTrack->GetPxPyPz(p); + esdTrack->GetXYZ(pos); + esdTrack->GetCovarianceXYZPxPyPz(covTr); + esdTrack->GetESDpid(pid); + + vV0FromCascade->AddDaughter(aodTrack = + new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), + esdTrack->GetLabel(), + p, + kTRUE, + pos, + kFALSE, + covTr, + (Short_t)esdTrack->GetSign(), + esdTrack->GetITSClusterMap(), + pid, + vV0FromCascade, + kTRUE, // check if this is right + kFALSE, // check if this is right + AliAODTrack::kSecondary) + ); + aodTrack->ConvertAliPIDtoAODPID(); + } + else { +// cerr << "Error: event " << fESD->GetEventNumberInFile() << " cascade " << nCascade +// << " track " << negFromV0 << " has already been used!" << endl; + } + + // Add the bachelor track from the cascade + + Int_t bachelor = cascade->GetBindex(); + + if(bachelor>-1 && !usedTrack[bachelor]) { + + usedTrack[bachelor] = kTRUE; + + AliESDtrack *esdTrack = fESD->GetTrack(bachelor); + esdTrack->GetPxPyPz(p); + esdTrack->GetXYZ(pos); + esdTrack->GetCovarianceXYZPxPyPz(covTr); + esdTrack->GetESDpid(pid); + + vcascade->AddDaughter(aodTrack = + new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), + esdTrack->GetLabel(), + p, + kTRUE, + pos, + kFALSE, + covTr, + (Short_t)esdTrack->GetSign(), + esdTrack->GetITSClusterMap(), + pid, + vcascade, + kTRUE, // check if this is right + kFALSE, // check if this is right + AliAODTrack::kSecondary) + ); + aodTrack->ConvertAliPIDtoAODPID(); + } + else { +// cerr << "Error: event " << fESD->GetEventNumberInFile() << " cascade " << nCascade +// << " track " << bachelor << " has already been used!" << endl; + } + + // Add the primary track of the cascade (if any) + + } // end of the loop on cascades + + // V0s + + for (Int_t nV0 = 0; nV0 < nV0s; ++nV0) { + + if (usedV0[nV0]) continue; // skip if aready added to the AOD + + AliESDv0 *v0 = fESD->GetV0(nV0); + + v0->GetXYZ(pos[0], pos[1], pos[2]); + + if (!old) { + chi2 = v0->GetChi2V0(); + v0->GetPosCov(covVtx); + } else { + chi2 = -999.; + } + + + AliAODVertex * vV0 = + new(vertices[jVertices++]) AliAODVertex(pos, + covVtx, + chi2, // = chi2/NDF since NDF = 2*2-3 + primary, + AliAODVertex::kV0); + primary->AddDaughter(vV0); + + Int_t posFromV0 = v0->GetPindex(); + Int_t negFromV0 = v0->GetNindex(); + + // Add the positive tracks from the V0 + + if (posFromV0>-1 && !usedTrack[posFromV0]) { + + usedTrack[posFromV0] = kTRUE; + + AliESDtrack *esdTrack = fESD->GetTrack(posFromV0); + esdTrack->GetPxPyPz(p); + esdTrack->GetXYZ(pos); + esdTrack->GetCovarianceXYZPxPyPz(covTr); + esdTrack->GetESDpid(pid); + + vV0->AddDaughter(aodTrack = + new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), + esdTrack->GetLabel(), + p, + kTRUE, + pos, + kFALSE, + covTr, + (Short_t)esdTrack->GetSign(), + esdTrack->GetITSClusterMap(), + pid, + vV0, + kTRUE, // check if this is right + kFALSE, // check if this is right + AliAODTrack::kSecondary) + ); + aodTrack->ConvertAliPIDtoAODPID(); + } + else { +// cerr << "Error: event " << fESD->GetEventNumberInFile() << " V0 " << nV0 +// << " track " << posFromV0 << " has already been used!" << endl; + } + + // Add the negative tracks from the V0 + + if (negFromV0>-1 && !usedTrack[negFromV0]) { + + usedTrack[negFromV0] = kTRUE; + + AliESDtrack *esdTrack = fESD->GetTrack(negFromV0); + esdTrack->GetPxPyPz(p); + esdTrack->GetXYZ(pos); + esdTrack->GetCovarianceXYZPxPyPz(covTr); + esdTrack->GetESDpid(pid); + + vV0->AddDaughter(aodTrack = + new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), + esdTrack->GetLabel(), + p, + kTRUE, + pos, + kFALSE, + covTr, + (Short_t)esdTrack->GetSign(), + esdTrack->GetITSClusterMap(), + pid, + vV0, + kTRUE, // check if this is right + kFALSE, // check if this is right + AliAODTrack::kSecondary) + ); + aodTrack->ConvertAliPIDtoAODPID(); + } + else { +// cerr << "Error: event " << fESD->GetEventNumberInFile() << " V0 " << nV0 +// << " track " << negFromV0 << " has already been used!" << endl; + } + + } // end of the loop on V0s + + // Kinks: it is a big mess the access to the information in the kinks + // The loop is on the tracks in order to find the mother and daugther of each kink + + + for (Int_t iTrack=0; iTrackGetTrack(iTrack); + + Int_t ikink = esdTrack->GetKinkIndex(0); + + if (ikink && nKinks) { + // Negative kink index: mother, positive: daughter + + // Search for the second track of the kink + + for (Int_t jTrack = iTrack+1; jTrackGetTrack(jTrack); + + Int_t jkink = esdTrack1->GetKinkIndex(0); + + if ( TMath::Abs(ikink)==TMath::Abs(jkink) ) { + + // The two tracks are from the same kink + + if (usedKink[TMath::Abs(ikink)-1]) continue; // skip used kinks + + Int_t imother = -1; + Int_t idaughter = -1; + + if (ikink<0 && jkink>0) { + + imother = iTrack; + idaughter = jTrack; + } + else if (ikink>0 && jkink<0) { + + imother = jTrack; + idaughter = iTrack; + } + else { +// cerr << "Error: Wrong combination of kink indexes: " +// << ikink << " " << jkink << endl; + continue; + } + + // Add the mother track + + AliAODTrack * mother = NULL; + + if (!usedTrack[imother]) { + + usedTrack[imother] = kTRUE; + + AliESDtrack *esdTrack = fESD->GetTrack(imother); + esdTrack->GetPxPyPz(p); + esdTrack->GetXYZ(pos); + esdTrack->GetCovarianceXYZPxPyPz(covTr); + esdTrack->GetESDpid(pid); + + mother = + new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), + esdTrack->GetLabel(), + p, + kTRUE, + pos, + kFALSE, + covTr, + (Short_t)esdTrack->GetSign(), + esdTrack->GetITSClusterMap(), + pid, + primary, + kTRUE, // check if this is right + kTRUE, // check if this is right + AliAODTrack::kPrimary); + primary->AddDaughter(mother); + mother->ConvertAliPIDtoAODPID(); + } + else { +// cerr << "Error: event " << fESD->GetEventNumberInFile() << " kink " << TMath::Abs(ikink)-1 +// << " track " << imother << " has already been used!" << endl; + } + + // Add the kink vertex + AliESDkink * kink = fESD->GetKink(TMath::Abs(ikink)-1); + + AliAODVertex * vkink = + new(vertices[jVertices++]) AliAODVertex(kink->GetPosition(), + NULL, + 0., + mother, + AliAODVertex::kKink); + // Add the daughter track + + AliAODTrack * daughter = NULL; + + if (!usedTrack[idaughter]) { + + usedTrack[idaughter] = kTRUE; + + AliESDtrack *esdTrack = fESD->GetTrack(idaughter); + esdTrack->GetPxPyPz(p); + esdTrack->GetXYZ(pos); + esdTrack->GetCovarianceXYZPxPyPz(covTr); + esdTrack->GetESDpid(pid); + + daughter = + new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), + esdTrack->GetLabel(), + p, + kTRUE, + pos, + kFALSE, + covTr, + (Short_t)esdTrack->GetSign(), + esdTrack->GetITSClusterMap(), + pid, + vkink, + kTRUE, // check if this is right + kTRUE, // check if this is right + AliAODTrack::kPrimary); + vkink->AddDaughter(daughter); + daughter->ConvertAliPIDtoAODPID(); + } + else { +// cerr << "Error: event " << fESD->GetEventNumberInFile() << " kink " << TMath::Abs(ikink)-1 +// << " track " << idaughter << " has already been used!" << endl; + } + } + } + } + } + + + // Tracks (primary and orphan) + + printf("NUMBER OF TRACKS %5d\n", nTracks); + + // *** PWG2 specific *** + + fPWG2AODTracks->Delete(); + fPWG2AODTracks->Expand(nTracks); + TClonesArray &tPWG2AODTracks = *fPWG2AODTracks; + + // --- END PWG2 specific --- + + for (Int_t nTrack = 0; nTrack < nTracks; ++nTrack) { + + if (usedTrack[nTrack]) continue; + AliESDtrack *esdTrack = fESD->GetTrack(nTrack); + UInt_t selectInfo = 0; + // + // Track selection + if (fTrackFilter) { + selectInfo = fTrackFilter->IsSelected(esdTrack); + if (!selectInfo) continue; + } + + // + esdTrack->GetPxPyPz(p); + esdTrack->GetXYZ(pos); + esdTrack->GetCovarianceXYZPxPyPz(covTr); + esdTrack->GetESDpid(pid); + + Float_t impactXY, impactZ; + + esdTrack->GetImpactParameters(impactXY,impactZ); + + // *** PWG2 specific *** + + sharemap = esdTrack->GetTPCSharedMap(); + clustermap = esdTrack->GetTPCClusterMap(); + + esdTrack->GetInnerXYZ(tpcentrancepoint); + tpcentrancepoint[2] -= pos[2]; + + esdTrack->GetOuterXYZ(tpcexitpoint); + tpcexitpoint[2] -= pos[2]; + + // --- END PWG2 specific --- + + + if (impactXY<3) { + // track inside the beam pipe + + primary->AddDaughter(aodTrack = + new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), + esdTrack->GetLabel(), + p, + kTRUE, + pos, + kFALSE, + covTr, + (Short_t)esdTrack->GetSign(), + esdTrack->GetITSClusterMap(), + pid, + primary, + kTRUE, // check if this is right + kTRUE, // check if this is right + AliAODTrack::kPrimary, + selectInfo) + ); + aodTrack->ConvertAliPIDtoAODPID(); + + // *** PWG2 specific **** + // Add the PWG2 info into the AOD + new (tPWG2AODTracks[pTracks++]) AliPWG2AODTrack(tpcentrancepoint, + tpcexitpoint, + sharemap, + clustermap, + aodTrack); + // --- END PWG2 specific --- + } + else { + // outside the beam pipe: orphan track + aodTrack = + new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), + esdTrack->GetLabel(), + p, + kTRUE, + pos, + kFALSE, + covTr, + (Short_t)esdTrack->GetSign(), + esdTrack->GetITSClusterMap(), + pid, + NULL, + kFALSE, // check if this is right + kFALSE, // check if this is right + AliAODTrack::kOrphan, + selectInfo); + aodTrack->ConvertAliPIDtoAODPID(); + + // *** PWG2 specific **** + // Add the PWG2 info into the AOD + new (tPWG2AODTracks[pTracks++]) AliPWG2AODTrack(tpcentrancepoint, + tpcexitpoint, + sharemap, + clustermap, + aodTrack); + // --- END PWG2 specific --- + } + } // end of loop on tracks + + // muon tracks + Int_t nMuTracks = fESD->GetNumberOfMuonTracks(); + for (Int_t nMuTrack = 0; nMuTrack < nMuTracks; ++nMuTrack) { + + AliESDMuonTrack *esdMuTrack = fESD->GetMuonTrack(nMuTrack); + p[0] = esdMuTrack->Px(); + p[1] = esdMuTrack->Py(); + p[2] = esdMuTrack->Pz(); + pos[0] = primary->GetX(); + pos[1] = primary->GetY(); + pos[2] = primary->GetZ(); + + // has to be changed once the muon pid is provided by the ESD + for (Int_t i = 0; i < 10; pid[i++] = 0.); pid[AliAODTrack::kMuon]=1.; + + primary->AddDaughter( + new(tracks[jTracks++]) AliAODTrack(0, // no ID provided + 0, // no label provided + p, + kTRUE, + pos, + kFALSE, + NULL, // no covariance matrix provided + (Short_t)-99, // no charge provided + 0, // no ITSClusterMap + pid, + primary, + kTRUE, // check if this is right + kTRUE, // not used for vertex fit + AliAODTrack::kPrimary) + ); + } + + printf(" jTracks=%d pTracks=%d PWG2=%d\n", jTracks, pTracks, fPWG2AODTracks->GetEntries()); + + delete [] usedTrack; + delete [] usedV0; + delete [] usedKink; + + + // + PostData(0, fTreeA); + return; +} + +void AliAnalysisTaskPWG2ESDfilter::Terminate(Option_t */*option*/) +{ +// Terminate analysis +// + if (fDebug > 1) printf("AnalysisESDfilter: Terminate() \n"); +} + diff --git a/PWG2/AOD/AliAnalysisTaskPWG2ESDfilter.h b/PWG2/AOD/AliAnalysisTaskPWG2ESDfilter.h new file mode 100644 index 00000000000..a0537f3ac22 --- /dev/null +++ b/PWG2/AOD/AliAnalysisTaskPWG2ESDfilter.h @@ -0,0 +1,56 @@ +//------------------------------------------------------------------------- +// Task for the Analysis Framework +// Creates a PWG2 specific AOD, from the ESD, adding information required +// for PWG2 analysis. +// - Puts the per-track information into the AliPWG2AODTrack container, +// together with the link to the original AliAODTrack +// +// Author: Adam Kisiel, OSU, Adam.Kisiel@cern.ch +//------------------------------------------------------------------------- +#ifndef ALIANALYSISTASKPWG2ESDFILTER_H +#define ALIANALYSISTASKPWG2ESDFILTER_H + +#include + +class AliESDEvent; +class TChain; +class AliAODEvent; +class AliAnalysisFilter; +class TTree; +class TClonesArray; +class TList; + +class AliAnalysisTaskPWG2ESDfilter : public AliAnalysisTask +{ + public: + AliAnalysisTaskPWG2ESDfilter(); + AliAnalysisTaskPWG2ESDfilter(const char* name); + virtual ~AliAnalysisTaskPWG2ESDfilter() {;} + // Implementation of interface methods + virtual void ConnectInputData(Option_t *option = ""); + virtual void CreateOutputObjects(); + virtual void Init(); + virtual void LocalInit() {Init();} + virtual void Exec(Option_t *option); + virtual void Terminate(Option_t *option); + // Setters + virtual void SetTrackFilter(AliAnalysisFilter* trackF) {fTrackFilter = trackF;} + virtual void SetKinkFilter (AliAnalysisFilter* KinkF) {fKinkFilter = KinkF;} + virtual void SetV0Filter (AliAnalysisFilter* V0F) {fV0Filter = V0F;} + virtual void SetDebugLevel(Int_t level) {fDebug = level;} + + private: + Int_t fDebug; // Debug flag + TTree* fTree; //! chained files + AliESDEvent* fESD; //! ESD + AliAODEvent* fAOD; //! AOD event + TTree* fTreeA; //! AOD tree + AliAnalysisFilter* fTrackFilter; // Track Filter + AliAnalysisFilter* fKinkFilter; // Kink Filter + AliAnalysisFilter* fV0Filter; // V0 Filter + TClonesArray* fPWG2AODTracks; //! container for PWG2 specific information + + ClassDef(AliAnalysisTaskPWG2ESDfilter, 1); // Analysis task for standard ESD filtering +}; + +#endif diff --git a/PWG2/AOD/AliPWG2AODTrack.cxx b/PWG2/AOD/AliPWG2AODTrack.cxx new file mode 100644 index 00000000000..a8ee88a2098 --- /dev/null +++ b/PWG2/AOD/AliPWG2AODTrack.cxx @@ -0,0 +1,150 @@ +//------------------------------------------------------------------------- +// PWG2 specific additional information for the AOD Track +// Stores a per-track information for the AOD track that is not +// included in the standard AliAODTrack +// Author: Adam Kisiel, OSU, Adam.Kisiel@cern.ch +//------------------------------------------------------------------------- + +#include + +#include +#include "AliPWG2AODTrack.h" + +ClassImp(AliPWG2AODTrack) + +AliPWG2AODTrack::AliPWG2AODTrack(): + fSharedMap(160), + fClusterMap(160), + fAODTrack(NULL) +{ + // Default constructor + SetTPCNominalEntrancePoint(); + SetTPCNominalExitPoint(); + fSharedMap.ResetAllBits(kFALSE); + fClusterMap.ResetAllBits(kTRUE); +} + +AliPWG2AODTrack::AliPWG2AODTrack(Double_t tpcentr[3], + Double_t tpcexit[3], + TBits tpcshare, + TBits tpcclus, + AliAODTrack *track): + fSharedMap(tpcshare), + fClusterMap(tpcclus), + fAODTrack(track) +{ + // Constructor initializing all fields + SetTPCNominalEntrancePoint(tpcentr); + SetTPCNominalExitPoint(tpcexit); +} + +AliPWG2AODTrack::~AliPWG2AODTrack() +{ +} + +AliPWG2AODTrack::AliPWG2AODTrack(const AliPWG2AODTrack& trk): + TObject(), + fSharedMap(trk.fSharedMap), + fClusterMap(trk.fClusterMap), + fAODTrack(trk.fAODTrack) +{ + // Copy constructor + Double_t tpcp[3]; + trk.GetTPCNominalEntrancePoint(tpcp); + SetTPCNominalEntrancePoint(tpcp); + trk.GetTPCNominalExitPoint(tpcp); + SetTPCNominalExitPoint(tpcp); +} + +AliPWG2AODTrack& AliPWG2AODTrack::operator=(const AliPWG2AODTrack& trk) +{ + // Assignment operator + if(this!=&trk) { + fSharedMap = trk.fSharedMap; + fClusterMap = trk.fClusterMap; + fAODTrack = trk.fAODTrack; + + Double_t tpcp[3]; + trk.GetTPCNominalEntrancePoint(tpcp); + SetTPCNominalEntrancePoint(tpcp); + trk.GetTPCNominalExitPoint(tpcp); + SetTPCNominalExitPoint(tpcp); + } + return *this; +} + +void AliPWG2AODTrack::GetTPCNominalEntrancePoint(Double_t *tpce) const +{ + // Return TPC entrance point coordinates + tpce[0] = fTPCNominalEntrancePoint[0]; + tpce[1] = fTPCNominalEntrancePoint[1]; + tpce[2] = fTPCNominalEntrancePoint[2]; +} + +void AliPWG2AODTrack::GetTPCNominalExitPoint(Double_t *tpce) const +{ + // Return TPC exit point coordinates + tpce[0] = fTPCNominalExitPoint[0]; + tpce[1] = fTPCNominalExitPoint[1]; + tpce[2] = fTPCNominalExitPoint[2]; +} + +void AliPWG2AODTrack::SetTPCNominalEntrancePoint(Double_t *tpce) +{ + // Set TPC entrance point coordinates + if (tpce) { + fTPCNominalEntrancePoint[0] = tpce[0]; + fTPCNominalEntrancePoint[1] = tpce[1]; + fTPCNominalEntrancePoint[2] = tpce[2]; + } + else { + fTPCNominalEntrancePoint[0] = 0.0; + fTPCNominalEntrancePoint[1] = 0.0; + fTPCNominalEntrancePoint[2] = 0.0; + } +} + +void AliPWG2AODTrack::SetTPCNominalExitPoint(Double_t *tpce) +{ + // Set TPC exit point coordinates + if (tpce) { + fTPCNominalExitPoint[0] = tpce[0]; + fTPCNominalExitPoint[1] = tpce[1]; + fTPCNominalExitPoint[2] = tpce[2]; + } + else { + fTPCNominalExitPoint[0] = 0.0; + fTPCNominalExitPoint[1] = 0.0; + fTPCNominalExitPoint[2] = 0.0; + } +} + +const TBits &AliPWG2AODTrack::GetTPCSharedMap() const +{ + return fSharedMap; +} +const TBits &AliPWG2AODTrack::GetTPCClusterMap() const +{ + return fClusterMap; +} + +void AliPWG2AODTrack::SetTPCSharedMap(const TBits &bits) +{ + fSharedMap = bits; +} + +void AliPWG2AODTrack::SetTPCClusterMap(const TBits &bits) +{ + fClusterMap = bits; +} + +void AliPWG2AODTrack::SetAODTrackRef(AliAODTrack *track) +{ + fAODTrack = track; +} + +AliAODTrack *AliPWG2AODTrack::GetRefAODTrack() +{ + return (AliAODTrack *) fAODTrack.GetObject(); +} + diff --git a/PWG2/AOD/AliPWG2AODTrack.h b/PWG2/AOD/AliPWG2AODTrack.h new file mode 100644 index 00000000000..dd723b02431 --- /dev/null +++ b/PWG2/AOD/AliPWG2AODTrack.h @@ -0,0 +1,56 @@ +#ifndef AliPWG2AODTrack_H +#define AliPWG2AODTrack_H +//------------------------------------------------------------------------- +// PWG2 specific additional information for the AOD Track +// Author: Adam Kisiel, OSU, Adam.Kisiel@cern.ch +//------------------------------------------------------------------------- + +#include +#include + +class AliAODTrack; + +class AliPWG2AODTrack : public TObject { + + public: + + AliPWG2AODTrack(); + AliPWG2AODTrack(Double_t tpcentr[3], + Double_t tpcexit[3], + TBits tpcshare, + TBits tpcclus, + AliAODTrack *track); + + virtual ~AliPWG2AODTrack(); + AliPWG2AODTrack(const AliPWG2AODTrack& trk); + AliPWG2AODTrack& operator=(const AliPWG2AODTrack& trk); + + void GetTPCNominalEntrancePoint(Double_t *tpce) const; + void GetTPCNominalExitPoint(Double_t *tpce) const; + + void SetTPCNominalEntrancePoint(Double_t *tpce=0); + void SetTPCNominalExitPoint(Double_t *tpce=0); + + const TBits &GetTPCSharedMap() const; + const TBits &GetTPCClusterMap() const; + + void SetTPCSharedMap(const TBits &bits); + void SetTPCClusterMap(const TBits &bits); + + void SetAODTrackRef(AliAODTrack *track); + AliAODTrack *GetRefAODTrack(); + + private : + + // TPC quality and geometrical information + Double32_t fTPCNominalEntrancePoint[3]; // Nominal entrance point of the track to the TPC + Double32_t fTPCNominalExitPoint[3]; // Nominal exit point of the track from the TPC + TBits fSharedMap; // TPC sharing bitmap + TBits fClusterMap; // TPC cluster-per-padrow bitmap + + TRef fAODTrack; // pointer to the original AOD track + + ClassDef(AliPWG2AODTrack,1); +}; + +#endif diff --git a/PWG2/Makefile b/PWG2/Makefile index b6aab7c54c8..0c4eb642491 100644 --- a/PWG2/Makefile +++ b/PWG2/Makefile @@ -23,9 +23,9 @@ endif # ALICEINC += -I../$(PWG0base_INCLUDE) #endif -CXXFLAGS += $(ALICEINC) -g -IFEMTOSCOPY/AliFemto -IFEMTOSCOPY/AliFemto/Base -IFEMTOSCOPY/AliFemto/Infrastructure -IFEMTOSCOPY/AliFemtoUser +CXXFLAGS += $(ALICEINC) -g -IFEMTOSCOPY/AliFemto -IANALYSIS -IFEMTOSCOPY/AliFemtoUser -ALICEINC += -IFEMTOSCOPY/AliFemto -IFEMTOSCOPY/AliFemto/Base -IFEMTOSCOPY/AliFemto/Infrastructure -IFEMTOSCOPY/AliFemtoUser +ALICEINC += -IFEMTOSCOPY/AliFemto -IANALYSIS -IFEMTOSCOPY/AliFemtoUser PACKAGE = PWG2 include lib$(PACKAGE).pkg @@ -209,3 +209,26 @@ G__PWG2femtoscopyUser.cxx G__PWG2femtoscopyUser.h: $(HDRS_PWG2femtoscopyUser) $( @echo "Generating dictionary ..." rootcint -f $@ -c $(ALICEINC) $^ +## libPWG2AOD part +include libPWG2AOD.pkg + +DHDR_PWG2AOD := $(DHDR) +HDRS_PWG2AOD := $(HDRS) +SRCS_PWG2AOD := $(SRCS) G__PWG2AOD.cxx +OBJS_PWG2AOD := $(SRCS_PWG2AOD:.cxx=.o) + +libPWG2AOD.so: $(OBJS_PWG2AOD) + @echo "Linking" $@ ... + @/bin/rm -f $@ +ifeq ($(PLATFORM),macosx) + @$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ -o $@ +else + @$(LD) $(SOFLAGS) $(LDFLAGS) $^ -o $@ +endif + @chmod a+x $@ + @echo "done" + +G__PWG2AOD.cxx G__PWG2AOD.h: $(HDRS_PWG2AOD) $(DHDR_PWG2AOD) + @echo "Generating dictionary ..." + rootcint -f $@ -c $(ALICEINC) $^ + diff --git a/PWG2/PROOF-INF.PWG2AOD/BUILD.sh b/PWG2/PROOF-INF.PWG2AOD/BUILD.sh new file mode 100755 index 00000000000..921e6271681 --- /dev/null +++ b/PWG2/PROOF-INF.PWG2AOD/BUILD.sh @@ -0,0 +1,3 @@ +#! /bin/sh + +make libPWG2AAOD.so diff --git a/PWG2/PROOF-INF.PWG2AOD/SETUP.C b/PWG2/PROOF-INF.PWG2AOD/SETUP.C new file mode 100644 index 00000000000..daa4c0b2e57 --- /dev/null +++ b/PWG2/PROOF-INF.PWG2AOD/SETUP.C @@ -0,0 +1,32 @@ +void SETUP() { + // Load some ROOT libraries + CheckLoadLibrary("libEG"); + CheckLoadLibrary("libGeom"); + + // Load the ESD library + CheckLoadLibrary("libESD"); + + // Load the ESD library + CheckLoadLibrary("libAOD"); + + // Load the ESD library + CheckLoadLibrary("libANALYSIS"); + + // Load the PWG2 library + CheckLoadLibrary("libPWG2AOD"); + + // Set the include paths + gROOT->ProcessLine(".include PWG2AOD"); + + // Set our location, so that other packages can find us + gSystem->Setenv("PWG2AOD_INCLUDE", "PWG2/AOD"); +} + +Int_t CheckLoadLibrary(const char* library) { + // checks if a library is already loaded, if not loads the library + + if (strlen(gSystem->GetLibraries(Form("%s.so", library), "", kFALSE)) > 0) + return 1; + + return gSystem->Load(library); +} diff --git a/PWG2/PWG2AODLinkDef.h b/PWG2/PWG2AODLinkDef.h new file mode 100644 index 00000000000..5eb7bb9d743 --- /dev/null +++ b/PWG2/PWG2AODLinkDef.h @@ -0,0 +1,10 @@ +#ifdef __CINT__ + +#pragma link off all glols; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class AliPWG2AODTrack+; +#pragma link C++ class AliAnalysisTaskPWG2ESDfilter+; + +#endif diff --git a/PWG2/libPWG2AOD.pkg b/PWG2/libPWG2AOD.pkg new file mode 100644 index 00000000000..4fce5fc8e9b --- /dev/null +++ b/PWG2/libPWG2AOD.pkg @@ -0,0 +1,11 @@ +SRCS = AOD/AliPWG2AODTrack.cxx \ + AOD/AliAnalysisTaskPWG2ESDfilter.cxx + +HDRS= $(SRCS:.cxx=.h) + +DHDR:=PWG2AODLinkDef.h + +EXPORT:= + +EINCLUDE:= PYTHIA6 + -- 2.43.0