Major refactoring of the code - Rebase task from AliAnalysisTaskSE to AliAnalysisTask...
authormfasel <mfasel@lbl.gov>
Tue, 16 Sep 2014 12:50:05 +0000 (14:50 +0200)
committermverweij <marta.verweij@cern.ch>
Tue, 16 Sep 2014 13:01:28 +0000 (15:01 +0200)
PWGJE/CMakelibPWGJEEMCALJetTasks.pkg
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskPtEMCalTrigger.cxx
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskPtEMCalTrigger.h
PWGJE/EMCALJetTasks/UserTasks/AliEMCalPtTaskTrackSelectionESD.cxx [new file with mode: 0644]
PWGJE/EMCALJetTasks/UserTasks/AliEMCalPtTaskTrackSelectionESD.h [new file with mode: 0644]
PWGJE/EMCALJetTasks/macros/AddTaskPtEMCalTrigger.C
PWGJE/PWGJEEMCALJetTasksLinkDef.h

index 4408dfd..d42c9ac 100644 (file)
@@ -88,6 +88,8 @@ set ( SRCS
  EMCALJetTasks/UserTasks/AliCutValueRange.cxx 
  EMCALJetTasks/UserTasks/AliEMCalHistoContainer.cxx 
  EMCALJetTasks/UserTasks/AliAnalysisTaskPtEMCalTrigger.cxx 
+ EMCALJetTasks/UserTasks/AliEMCalPtTaskVTrackSelection.cxx
+ EMCALJetTasks/UserTasks/AliEMCalPtTaskTrackSelectionESD.cxx
 )
 
 # Add code that needs fastjet or FJWrapper here
index ce76a6b..e0a4282 100644 (file)
 #include <TObjArray.h>
 #include <TString.h>
 
-#include "AliESDCaloCluster.h"
+#include "AliAODEvent.h"
 #include "AliESDEvent.h"
-#include "AliESDInputHandler.h"
-#include "AliESDtrack.h"
-#include "AliESDVertex.h"
+#include "AliInputEventHandler.h"
+#include "AliMCEvent.h"
+#include "AliParticleContainer.h"
+#include "AliVCluster.h"
+#include "AliVParticle.h"
+#include "AliVTrack.h"
+#include "AliVVertex.h"
 
 #include "AliEMCalHistoContainer.h"
+#include "AliEMCalPtTaskVTrackSelection.h"
+#include "AliEMCalPtTaskTrackSelectionESD.h"
 #include "AliAnalysisTaskPtEMCalTrigger.h"
 
 ClassImp(EMCalTriggerPtAnalysis::AliAnalysisTaskPtEMCalTrigger)
@@ -52,16 +58,13 @@ namespace EMCalTriggerPtAnalysis {
 
        //______________________________________________________________________________
        AliAnalysisTaskPtEMCalTrigger::AliAnalysisTaskPtEMCalTrigger():
-                               AliAnalysisTaskSE(),
-                               fCalibratedClusters(NULL),
-                               fMatchedTracks(NULL),
-                               fResults(NULL),
+                               AliAnalysisTaskEmcal(),
                                fHistos(NULL),
                                fListTrackCuts(NULL),
                                fEtaRange(),
                                fPtRange(),
                                fSwapEta(kFALSE),
-                               fNameTrackContainer()
+                               fUseTriggersFromTriggerMaker(kFALSE)
        {
                /*
                 * Dummy constructor, initialising the values with default (NULL) values
@@ -70,21 +73,17 @@ namespace EMCalTriggerPtAnalysis {
 
        //______________________________________________________________________________
        AliAnalysisTaskPtEMCalTrigger::AliAnalysisTaskPtEMCalTrigger(const char *name):
-                               AliAnalysisTaskSE(name),
-                               fCalibratedClusters(NULL),
-                               fMatchedTracks(NULL),
-                               fResults(NULL),
+                               AliAnalysisTaskEmcal(name, kTRUE),
                                fHistos(NULL),
                                fListTrackCuts(NULL),
                                fEtaRange(),
                                fPtRange(),
                                fSwapEta(kFALSE),
-                               fNameTrackContainer("ESDFilterTracks")
+                               fUseTriggersFromTriggerMaker(kFALSE)
        {
                /*
                 * Main constructor, setting default values for eta and zvertex cut
                 */
-               DefineOutput(1, TList::Class());
 
                fListTrackCuts = new TList;
                fListTrackCuts->SetOwner(false);
@@ -92,7 +91,7 @@ namespace EMCalTriggerPtAnalysis {
                // Set default cuts
                fEtaRange.SetLimits(-0.8, 0.8);
                fPtRange.SetLimits(0.15, 100.);
-
+               SetMakeGeneralHistograms(kTRUE);
        }
 
        //______________________________________________________________________________
@@ -111,9 +110,16 @@ namespace EMCalTriggerPtAnalysis {
                 * Create the list of output objects and define the histograms.
                 * Also adding the track cuts to the list of histograms.
                 */
-               fResults = new TList;
-               fResults->SetOwner();
-
+               AliAnalysisTaskEmcal::UserCreateOutputObjects();
+               TString trackContainerName = "ESDFilterTracks", clusterContainerName = "EmcCaloClusters";
+               if(!fIsEsd){
+                       trackContainerName = "AODFilterTracks";
+                       clusterContainerName = "EmcCaloClusters";
+               }
+               AliParticleContainer *trackContainer = this->AddParticleContainer(trackContainerName.Data());
+               trackContainer->SetClassName("AliVTrack");
+               this->AddClusterContainer(clusterContainerName.Data());
+               this->SetCaloTriggerPatchInfoName("EmcalTriggers");
                fHistos = new AliEMCalHistoContainer("PtEMCalTriggerHistograms");
                fHistos->ReleaseOwner();
 
@@ -175,6 +181,8 @@ namespace EMCalTriggerPtAnalysis {
                const TAxis *clusteraxes[3];
                for(int iaxis = 0; iaxis < 3; ++iaxis) clusteraxes[iaxis] = hclusteraxes + iaxis;
                try{
+                       // Create histogram for MC-truth
+                       fHistos->CreateTHnSparse("hMCtrueParticles", "Particle-based histogram for MC-true particles", 3, trackaxes);
                        for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
                                const std::string name = it->first, &title = it->second;
                                // Create event-based histogram
@@ -193,35 +201,50 @@ namespace EMCalTriggerPtAnalysis {
                        errormessage << "Creation of histogram failed: " << e.what();
                        AliError(errormessage.str().c_str());
                }
-               fResults->Add(fHistos->GetListOfHistograms());
+               fOutput->Add(fHistos->GetListOfHistograms());
                if(fListTrackCuts && fListTrackCuts->GetEntries()){
                        TIter cutIter(fListTrackCuts);
-                       AliESDtrackCuts *cutObject(NULL);
-                       while((cutObject = dynamic_cast<AliESDtrackCuts *>(cutIter()))){
-                               cutObject->DefineHistograms();
-                               fResults->Add(cutObject);
+                       AliEMCalPtTaskVTrackSelection *cutObject(NULL);
+                       while((cutObject = dynamic_cast<AliEMCalPtTaskVTrackSelection *>(cutIter()))){
+                               AliESDtrackCuts *cuts = dynamic_cast<AliESDtrackCuts *>(cutObject->GetTrackCuts());
+                               if(cuts){
+                                       cuts->DefineHistograms();
+                                       fOutput->Add(cuts);
+                               }
                        }
                }
-               PostData(1, fResults);
+               PostData(1, fOutput);
        }
 
        //______________________________________________________________________________
-       void AliAnalysisTaskPtEMCalTrigger::UserExec(Option_t* /*option*/){
+       Bool_t AliAnalysisTaskPtEMCalTrigger::Run(){
                /*
                 * Runs the event loop
                 *
                 * @param option: Additional options
                 */
                // Common checks: Have SPD vertex and primary vertex from tracks, and both need to have at least one contributor
-               fCalibratedClusters = dynamic_cast<TClonesArray *>(fInputEvent->FindListObject("EmcCaloClusters"));
-               AliDebug(1,Form("Number of calibrated clusters: %d", fCalibratedClusters->GetEntries()));
-               fMatchedTracks = dynamic_cast<TClonesArray *>(fInputEvent->FindListObject(fNameTrackContainer.Data()));
+               AliDebug(1,Form("Number of calibrated clusters: %d", fCaloClusters->GetEntries()));
+               AliDebug(1,Form("Number of matched tracks: %d", fTracks->GetEntries()));
+
+               TList *esdentries = static_cast<AliESDEvent *>(fInputEvent)->GetList();
+               TIter esditer(esdentries);
+               TObject *esdobject(NULL);
+
+               if(fMCEvent){
+                       for(int ipart = 0; ipart < fMCEvent->GetNumberOfTracks(); ipart++){
+                               // Select only physical primary particles
+                               if(!fMCEvent->IsPhysicalPrimary(ipart)) continue;
+                               FillMCParticleHist(fMCEvent->GetTrack(ipart));
+                       }
+                       // Build always trigger strig from the trigger maker in case of MC
+               fUseTriggersFromTriggerMaker = kTRUE;
+               }
 
-               AliESDEvent *esd = static_cast<AliESDEvent *>(fInputEvent);
-               const AliESDVertex *vtxTracks = esd->GetPrimaryVertex(),
-                               *vtxSPD = esd->GetPrimaryVertexSPD();
-               if(!(vtxTracks && vtxSPD)) return;
-               if(vtxTracks->GetNContributors() < 1 || vtxSPD->GetNContributors() < 1) return;
+               const AliVVertex *vtxTracks = fInputEvent->GetPrimaryVertex(),
+                               *vtxSPD = GetSPDVertex();
+               if(!(vtxTracks && vtxSPD)) return false;
+               if(vtxTracks->GetNContributors() < 1 || vtxSPD->GetNContributors() < 1) return false;
 
                double triggers[5]; memset(triggers, 0, sizeof(double) * 5);
                double triggerbits[4]; memset(triggerbits, 0, sizeof(double) * 4);
@@ -250,7 +273,8 @@ namespace EMCalTriggerPtAnalysis {
 
                std::vector<std::string> triggerstrings;
                // EMCal-triggered event, distinguish types
-               TString trgstr(fInputEvent->GetFiredTriggerClasses());
+               TString trgstr(fUseTriggersFromTriggerMaker ? BuildTriggerString() : fInputEvent->GetFiredTriggerClasses());
+               AliDebug(1, Form("Triggerstring: %s\n", trgstr.Data()));
                if(trgstr.Contains("EJ1")){
                        triggerstrings.push_back("EMCJHigh");
                        triggers[1] = 1;
@@ -289,7 +313,7 @@ namespace EMCalTriggerPtAnalysis {
                }
 
                // apply event selection: Combine the Pileup cut from SPD with the other pA Vertex selection cuts.
-               bool isPileupEvent = esd->IsPileupFromSPD();
+               bool isPileupEvent = fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.);
                isPileupEvent = isPileupEvent || (TMath::Abs(vtxTracks->GetZ() - vtxSPD->GetZ()) > 0.5);
                double covSPD[6]; vtxSPD->GetCovarianceMatrix(covSPD);
                isPileupEvent = isPileupEvent || (TString(vtxSPD->GetTitle()).Contains("vertexer:Z") && TMath::Sqrt(covSPD[5]) > 0.25);
@@ -305,10 +329,11 @@ namespace EMCalTriggerPtAnalysis {
                                FillEventHist(it->c_str(), zv, isPileupEvent);
                }
 
-               AliESDtrack *track(NULL);
+               AliVTrack *track(NULL);
                // Loop over all tracks (No cuts applied)
-               for(int itrk = 0; itrk < fMatchedTracks->GetEntries(); ++itrk){
-                       track = dynamic_cast<AliESDtrack *>(fMatchedTracks->At(itrk));
+               TIter allTrackIter(fTracks);
+               while((track = dynamic_cast<AliVTrack *>(allTrackIter()))){
+                       if(!IsTrueTrack(track)) continue;
                        if(!fEtaRange.IsInRange(track->Eta())) continue;
                        if(!fPtRange.IsInRange(track->Pt())) continue;
                        if(triggers[0]) FillTrackHist("MinBias", track, zv, isPileupEvent, 0);
@@ -327,10 +352,10 @@ namespace EMCalTriggerPtAnalysis {
                // cut ID 0 is reserved for the case of no cuts
                if(fListTrackCuts && fListTrackCuts->GetEntries()){
                        for(int icut = 0; icut < fListTrackCuts->GetEntries(); icut++){
-                               AliESDtrackCuts *trackSelection = static_cast<AliESDtrackCuts *>(fListTrackCuts->At(icut));
-                               std::auto_ptr<TObjArray> acceptedTracks(GetAcceptedTracks(fMatchedTracks,trackSelection));
-                               TIter trackIter(acceptedTracks.get());
-                               while((track = dynamic_cast<AliESDtrack *>(trackIter()))){
+                               AliEMCalPtTaskVTrackSelection *trackSelection = static_cast<AliEMCalPtTaskVTrackSelection *>(fListTrackCuts->At(icut));
+                               TIter trackIter(trackSelection->GetAcceptedTracks(fTracks));
+                               while((track = dynamic_cast<AliVTrack *>(trackIter()))){
+                                       //if(!IsTrueTrack(track)) continue;
                                        if(!fEtaRange.IsInRange(track->Eta())) continue;
                                        if(!fPtRange.IsInRange(track->Pt())) continue;
                                        if(triggers[0]) FillTrackHist("MinBias", track, zv, isPileupEvent, icut + 1);
@@ -346,8 +371,9 @@ namespace EMCalTriggerPtAnalysis {
                }
 
                // Next step we loop over the (uncalibrated) emcal clusters and fill histograms with the cluster energy
+               const AliVCluster *clust(NULL);
                for(int icl = 0; icl < fInputEvent->GetNumberOfCaloClusters(); icl++){
-                       const AliVCluster *clust = fInputEvent->GetCaloCluster(icl);
+                       clust = fInputEvent->GetCaloCluster(icl);
                        if(!clust->IsEMCAL()) continue;
                        if(triggers[0]) FillClusterHist("MinBias", clust, false, zv, isPileupEvent);
                        if(!triggerstrings.size())      // Non-EMCal-triggered
@@ -359,9 +385,9 @@ namespace EMCalTriggerPtAnalysis {
                        }
                }
 
-               if(fCalibratedClusters){
-                       for(int icl = 0; icl < fCalibratedClusters->GetEntries(); icl++){
-                               const AliVCluster *clust = dynamic_cast<const AliVCluster *>((*fCalibratedClusters)[icl]);
+               if(fCaloClusters){
+                       TIter clustIter(fCaloClusters);
+                       while((clust = dynamic_cast<const AliVCluster *>(clustIter()))){
                                if(!clust->IsEMCAL()) continue;
                                if(triggers[0]) FillClusterHist("MinBias", clust, true, zv, isPileupEvent);
                                if(!triggerstrings.size())      // Non-EMCal-triggered
@@ -374,7 +400,8 @@ namespace EMCalTriggerPtAnalysis {
                        }
                }
 
-               PostData(1, fResults);
+               PostData(1, fOutput);
+               return true;
        }
 
        //______________________________________________________________________________
@@ -492,6 +519,7 @@ namespace EMCalTriggerPtAnalysis {
                }
        }
 
+
        //______________________________________________________________________________
        void AliAnalysisTaskPtEMCalTrigger::FillEventHist(const char* trigger,
                        double vz, bool isPileup) {
@@ -524,7 +552,7 @@ namespace EMCalTriggerPtAnalysis {
 
        //______________________________________________________________________________
        void AliAnalysisTaskPtEMCalTrigger::FillTrackHist(const char* trigger,
-                       const AliESDtrack* track, double vz, bool isPileup, int cut) {
+                       const AliVTrack* track, double vz, bool isPileup, int cut) {
                /*
                 * Fill track-based histogram with corresponding information
                 *
@@ -544,9 +572,9 @@ namespace EMCalTriggerPtAnalysis {
                        // Check if the cluster is matched to only one track
                        AliVCluster *emcclust(NULL);
                        AliDebug(2, Form("cluster id: %d\n", track->GetEMCALcluster()));
-                       if(fCalibratedClusters) {
+                       if(fCaloClusters) {
                                AliDebug(2, "Using calibrated clusters");
-                               emcclust = dynamic_cast<AliVCluster *>(fCalibratedClusters->At(track->GetEMCALcluster()));
+                               emcclust = dynamic_cast<AliVCluster *>(fCaloClusters->At(track->GetEMCALcluster()));
                        } else {
                                AliDebug(2, "Using uncalibrated clusters");
                                emcclust = fInputEvent->GetCaloCluster(track->GetEMCALcluster());
@@ -614,14 +642,76 @@ namespace EMCalTriggerPtAnalysis {
                }
        }
 
-       TObjArray *AliAnalysisTaskPtEMCalTrigger::GetAcceptedTracks(const TClonesArray * const inputlist, AliESDtrackCuts *const cuts){
-               TObjArray *acceptedTracks = new TObjArray;
-               TIter trackIter(inputlist);
-               AliESDtrack *track(NULL);
-               while((track = dynamic_cast<AliESDtrack *>(trackIter()))){
-                       if(cuts->AcceptTrack(track)) acceptedTracks->Add(track);
+       //______________________________________________________________________________
+       void AliAnalysisTaskPtEMCalTrigger::FillMCParticleHist(const AliVParticle * const track){
+               /*
+                * Fill histogram for MC-true particles with the information pt, eta and phi
+                *
+                * @param track: the Monte-Carlo track
+                */
+               double data[3] = {TMath::Abs(track->Pt()), track->Eta(), track->Phi()};
+               fHistos->FillTHnSparse("hMCtrueParticles", data);
+       }
+
+       //______________________________________________________________________________
+       bool AliAnalysisTaskPtEMCalTrigger::IsTrueTrack(const AliVTrack *const track) const{
+               /*
+                * Check if the track has an associated MC particle, and that the particle is a physical primary
+                * In case of data we do not do the selection at that step (always return true)
+                *
+                * @param track: Track to check
+                * @result: true primary track (true or false)
+                */
+               if(!fMCEvent) return true;
+               AliVParticle *mcassociate = fMCEvent->GetTrack(TMath::Abs(track->GetLabel()));
+               if(!mcassociate) return false;
+               return fMCEvent->IsPhysicalPrimary(TMath::Abs(track->GetLabel()));
+       }
+
+       //______________________________________________________________________________
+       void AliAnalysisTaskPtEMCalTrigger::AddESDTrackCuts(AliESDtrackCuts* trackCuts) {
+               /*
+                * Add new track cuts to the task
+                *
+                * @param trackCuts: Object of type AliESDtrackCuts
+                */
+               fListTrackCuts->AddLast(new AliEMCalPtTaskTrackSelectionESD(trackCuts));
+       }
+
+       //______________________________________________________________________________
+       TString AliAnalysisTaskPtEMCalTrigger::BuildTriggerString() {
+               /*
+                * Build trigger string from the trigger maker
+                *
+                * @return: blank-separated string of fired trigger classes
+                */
+               AliDebug(1, "trigger checking");
+               TString result = "";
+               if(HasTriggerType(kJ1)) result += "EJ1 ";
+               if(HasTriggerType(kJ2)) result += "EJ2 ";
+               if(HasTriggerType(kG1)) result += "EG1 ";
+               if(HasTriggerType(kG2)) result += "EG2 ";
+               return result;
+       }
+
+       //______________________________________________________________________________
+       const AliVVertex* AliAnalysisTaskPtEMCalTrigger::GetSPDVertex() const {
+               /*
+                * Accessor for the SPD vertex, creating transparency for ESDs and AODs
+                *
+                * @return: the spd vertex
+                */
+               AliESDEvent *esd = dynamic_cast<AliESDEvent *>(fInputEvent);
+               if(esd){
+                       return esd->GetPrimaryVertexSPD();
+               } else {
+                       AliAODEvent *aod = dynamic_cast<AliAODEvent *>(fInputEvent);
+                       if(aod){
+                               return aod->GetPrimaryVertexSPD();
+                       }
                }
-               return acceptedTracks;
+               return NULL;
        }
+
 }
 
index 5ee4849..98242f2 100644 (file)
@@ -5,7 +5,7 @@
 
 // Author: Markus Fasel
 
-#include "AliAnalysisTaskSE.h"
+#include "AliAnalysisTaskEmcal.h"
 #include "AliCutValueRange.h"
 #include "AliESDtrackCuts.h"
 #include <TClonesArray.h>
@@ -15,11 +15,12 @@ class TArrayD;
 class Axis;
 class AliESDtrack;
 class AliVTrack;
+class AliVParticle;
 
 namespace EMCalTriggerPtAnalysis {
 class AliEMCalHistoContainer;
 
-class AliAnalysisTaskPtEMCalTrigger : public AliAnalysisTaskSE {
+class AliAnalysisTaskPtEMCalTrigger : public AliAnalysisTaskEmcal {
 public:
        enum EEMCalTriggerType_t{
                kEMCalJetLow = 0,
@@ -31,15 +32,14 @@ public:
        AliAnalysisTaskPtEMCalTrigger(const char *name);
        ~AliAnalysisTaskPtEMCalTrigger();
 
-       void UserCreateOutputObjects();
-       void UserExec(Option_t* /*option*/);
-       void Terminate(Option_t * /*option*/) {}
+       virtual void UserCreateOutputObjects();
+       virtual Bool_t Run();
 
-       void AddTrackCuts(AliESDtrackCuts *trackCuts) { fListTrackCuts->Add(trackCuts); }
+       void AddESDTrackCuts(AliESDtrackCuts *trackCuts);
        void SetEtaRange(double etamin, double etamax) { fEtaRange.SetLimits(etamin, etamax); }
        void SetPtRange(double ptmin, double ptmax) { fPtRange.SetLimits(ptmin, ptmax); }
-       void SetTrackContainerName(const char *name) { fNameTrackContainer = name; }
        void SetSwapEta() { fSwapEta = kTRUE; }
+       void UseTriggersFromTriggerMaker() { fUseTriggersFromTriggerMaker = kTRUE; }
 
 private:
        AliAnalysisTaskPtEMCalTrigger(const AliAnalysisTaskPtEMCalTrigger &);
@@ -50,13 +50,15 @@ private:
        void DefineAxis(TAxis &axis, const char *name, const char *title, const TArrayD &binning, const char **labels = NULL);
        void DefineAxis(TAxis &axis, const char *name, const char *title, int nbins, double min, double max, const char **labels = NULL);
        void FillEventHist(const char *trigger, double vz, bool isPileup);
-       void FillTrackHist(const char *trigger, const AliESDtrack *track, double vz, bool isPileup, int cut);
+       void FillTrackHist(const char *trigger, const AliVTrack *track, double vz, bool isPileup, int cut);
        void FillClusterHist(const char *trigger, const AliVCluster *clust, bool isCalibrated, double vz, bool isPileup);
-       TObjArray *GetAcceptedTracks(const TClonesArray * const inputlist, AliESDtrackCuts *const cuts);
+       void FillMCParticleHist(const AliVParticle * const part);
+       bool IsTrueTrack(const AliVTrack *const) const;
+       TString BuildTriggerString();
+       const AliVVertex *GetSPDVertex() const;
 
-       TClonesArray                              *fCalibratedClusters;   //! container of recalibrated EMCal clusters
-       TClonesArray                              *fMatchedTracks;                //! container of tracks used for track matching
-       TList                         *fResults;              //! container for results
+       TString                                           fClusterContainerName;  // Name of the EMCal cluster container
+       TString                                           fTrackContainerName;    // Name of the Container used for EMCal track matching
        AliEMCalHistoContainer        *fHistos;               //! Histogram container for the task
        TList                                             *fListTrackCuts;                // List of track cuts
 
@@ -64,7 +66,7 @@ private:
        AliCutValueRange<double>      fEtaRange;              // Eta Selection Range
        AliCutValueRange<double>          fPtRange;                               // Pt Selection Range
        Bool_t                                            fSwapEta;                               // Allow swapping of the eta sign in asymmetric collision systems
-       TString                                           fNameTrackContainer;    // Name of the Track container
+       Bool_t                                            fUseTriggersFromTriggerMaker; // Use trigger classes from trigger maker
 
        ClassDef(AliAnalysisTaskPtEMCalTrigger, 1);           // Analysis of EMCal triggered events
 };
diff --git a/PWGJE/EMCALJetTasks/UserTasks/AliEMCalPtTaskTrackSelectionESD.cxx b/PWGJE/EMCALJetTasks/UserTasks/AliEMCalPtTaskTrackSelectionESD.cxx
new file mode 100644 (file)
index 0000000..c639a43
--- /dev/null
@@ -0,0 +1,143 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+/*
+ * Implementation of the track selection for the analysis on ESDs using
+ * AliESDtrackCuts as underlying structure
+ *
+ * Author:
+ *             Markus Fasel
+ */
+#include <TClonesArray.h>
+
+#include "AliESDEvent.h"
+#include "AliESDtrack.h"
+#include "AliESDtrackCuts.h"
+#include "AliLog.h"
+
+#include <AliEMCalPtTaskTrackSelectionESD.h>
+
+ClassImp(EMCalTriggerPtAnalysis::AliEMCalPtTaskTrackSelectionESD)
+
+namespace EMCalTriggerPtAnalysis {
+
+//______________________________________________________________________________
+AliEMCalPtTaskTrackSelectionESD::AliEMCalPtTaskTrackSelectionESD():
+               AliEMCalPtTaskVTrackSelection(),
+               fTrackCuts(NULL)
+{
+       /*
+        * Default constructor
+        */
+}
+
+//______________________________________________________________________________
+AliEMCalPtTaskTrackSelectionESD::AliEMCalPtTaskTrackSelectionESD(AliESDtrackCuts* cuts):
+               AliEMCalPtTaskVTrackSelection(),
+               fTrackCuts(cuts)
+{
+       /*
+        * Constructor with cuts
+        */
+}
+
+//______________________________________________________________________________
+AliEMCalPtTaskTrackSelectionESD::AliEMCalPtTaskTrackSelectionESD(
+               const AliEMCalPtTaskTrackSelectionESD& ref):
+               AliEMCalPtTaskVTrackSelection(ref),
+               fTrackCuts(NULL)
+{
+       /*
+        * Copy constructor, creating a new cut object
+        */
+       if(ref.fTrackCuts) fTrackCuts = new AliESDtrackCuts(*(ref.fTrackCuts));
+}
+
+//______________________________________________________________________________
+AliEMCalPtTaskTrackSelectionESD& AliEMCalPtTaskTrackSelectionESD::operator=(
+               const AliEMCalPtTaskTrackSelectionESD& ref)
+{
+       /*
+        * Assignment operator
+        */
+       AliEMCalPtTaskVTrackSelection::operator=(ref);
+       if(&ref != this){
+               this->~AliEMCalPtTaskTrackSelectionESD();
+       }
+       if(ref.fTrackCuts) fTrackCuts = new AliESDtrackCuts(*(ref.fTrackCuts));
+       return *this;
+}
+
+//______________________________________________________________________________
+AliEMCalPtTaskTrackSelectionESD::~AliEMCalPtTaskTrackSelectionESD() {
+       /*
+        * Destructor, deleting track cuts
+        */
+       if(fTrackCuts) delete fTrackCuts;
+}
+
+//______________________________________________________________________________
+TObjArray* AliEMCalPtTaskTrackSelectionESD::GetAcceptedTracks(
+               const TClonesArray* const tracks) {
+       /*
+        * Select tracks from a TClonesArray of input tracks
+        *
+        * @param tracks: TClonesArray of tracks (must not be null)
+        * @return: TObjArray of selected tracks
+        */
+       if(!fListOfTracks) fListOfTracks = new TObjArray;
+       else fListOfTracks->Clear();
+       if(!fTrackCuts){
+               AliError("Track cuts not provided");
+               return fListOfTracks;
+       }
+       TIter trackIter(tracks);
+       AliESDtrack *track(NULL);
+       while((track = dynamic_cast<AliESDtrack *>(trackIter()))){
+               if(fTrackCuts->AcceptTrack(track)) fListOfTracks->AddLast(track);
+       }
+       return fListOfTracks;
+}
+
+
+
+//______________________________________________________________________________
+TObjArray* AliEMCalPtTaskTrackSelectionESD::GetAcceptedTracks(const AliVEvent* const event) {
+       /*
+        * Select tracks from a virtual event
+        *
+        * @param event: AliESDEvent, via interface of virtual event (must not be null)
+        * @return: TObjArray of selected tracks
+        */
+       if(!fListOfTracks) fListOfTracks = new TObjArray;
+       else fListOfTracks->Clear();
+       if(!fTrackCuts){
+               AliError("Track cuts not provided");
+               return fListOfTracks;
+       }
+       const AliESDEvent *esd = dynamic_cast<const AliESDEvent *>(event);
+       if(!esd){
+               AliError("Event not of type AliESDEvent");
+               return fListOfTracks;
+       }
+       std::auto_ptr<TObjArray> accepted(fTrackCuts->GetAcceptedTracks(esd));
+       TIter trackIter(accepted.get());
+       AliESDtrack *track(NULL);
+       while((track = dynamic_cast<AliESDtrack *>(trackIter()))){
+               fListOfTracks->AddLast(track);
+       }
+       return fListOfTracks;
+}
+
+} /* namespace EMCalTriggerPtAnalysis */
diff --git a/PWGJE/EMCALJetTasks/UserTasks/AliEMCalPtTaskTrackSelectionESD.h b/PWGJE/EMCALJetTasks/UserTasks/AliEMCalPtTaskTrackSelectionESD.h
new file mode 100644 (file)
index 0000000..1a4314b
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef ALIEMCALPTTASKTRACKSELECTIONESD_H_
+#define ALIEMCALPTTASKTRACKSELECTIONESD_H_
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+// Author: Markus Fasel
+
+#include <AliEMCalPtTaskVTrackSelection.h>
+#include <AliESDtrackCuts.h>
+
+namespace EMCalTriggerPtAnalysis {
+
+class AliEMCalPtTaskTrackSelectionESD: public AliEMCalPtTaskVTrackSelection {
+public:
+       AliEMCalPtTaskTrackSelectionESD();
+       AliEMCalPtTaskTrackSelectionESD(AliESDtrackCuts *cuts);
+       AliEMCalPtTaskTrackSelectionESD(const AliEMCalPtTaskTrackSelectionESD &ref);
+       AliEMCalPtTaskTrackSelectionESD &operator=(const AliEMCalPtTaskTrackSelectionESD &ref);
+       virtual ~AliEMCalPtTaskTrackSelectionESD();
+
+       virtual TObjArray *GetAcceptedTracks(const TClonesArray * const tracks);
+       virtual TObjArray *GetAcceptedTracks(const AliVEvent *const event);
+
+       void SetTrackCuts(AliESDtrackCuts * cuts) { fTrackCuts = cuts; }
+       virtual TObject *GetTrackCuts() { return fTrackCuts; }
+
+private:
+       AliESDtrackCuts *fTrackCuts;                            // Track cuts
+
+       ClassDef(AliEMCalPtTaskTrackSelectionESD,1);    // Selection of ESD tracks for analysis
+};
+
+} /* namespace EMCalTriggerPtAnalysis */
+
+#endif /* ALIEMCALPTTASKTRACKSELECTIONESD_H_ */
index 209148b..7990134 100644 (file)
@@ -6,7 +6,8 @@
 #include <TString.h>
 #endif
 
-AliAnalysisTask* AddTaskPtEMCalTrigger(const char *period ="LHC13d"){
+AliAnalysisTask* AddTaskPtEMCalTrigger(bool isMC, const char *period ="LHC13d"){
+               //AliLog::SetClassDebugLevel("EMCalTriggerPtAnalysis::AliAnalysisTaskPtEMCalTrigger", 2);
         AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
          
         if (!mgr) {
@@ -25,13 +26,17 @@ AliAnalysisTask* AddTaskPtEMCalTrigger(const char *period ="LHC13d"){
         if(!TString(period).CompareTo("LHC13f")) pttriggertask->SetSwapEta();
         mgr->AddTask(pttriggertask);
         pttriggertask->SetPtRange(2., 100.);
+        if(isMC){
+               pttriggertask->SetIsPythia(kTRUE);
+        }
+        std::cout << EMCalTriggerPtAnalysis::AliAnalysisTaskPtEMCalTrigger::Class_Name() << std::endl;
 
         // Create charged hadrons pPb standard track cuts
         AliESDtrackCuts *standardTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(true, 1);
         standardTrackCuts->SetName("Standard Track cuts");
         standardTrackCuts->SetMinNCrossedRowsTPC(120);
         standardTrackCuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
-        pttriggertask->AddTrackCuts(standardTrackCuts);
+        pttriggertask->AddESDTrackCuts(standardTrackCuts);
 
         // Create hybrid track cuts as used in the jet analysis
         AliESDtrackCuts* hybridTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
@@ -41,7 +46,7 @@ AliAnalysisTask* AddTaskPtEMCalTrigger(const char *period ="LHC13d"){
         hybridTrackCuts->SetDCAToVertex2D(kTRUE);
         hybridTrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
         hybridTrackCuts->SetMaxFractionSharedTPCClusters(0.4);
-        pttriggertask->AddTrackCuts(hybridTrackCuts);
+        pttriggertask->AddESDTrackCuts(hybridTrackCuts);
 
         TString containerName = mgr->GetCommonFileName();
         containerName += ":PtEMCalTriggerTask";
index d8fa959..89bb4b0 100644 (file)
@@ -75,6 +75,8 @@
 #pragma link C++ class EMCalTriggerPtAnalysis::AliCutValueRange<double>+;
 #pragma link C++ class EMCalTriggerPtAnalysis::AliCutValueRange<int>+;
 #pragma link C++ class EMCalTriggerPtAnalysis::AliAnalysisTaskPtEMCalTrigger+;
+#pragma link C++ class EMCalTriggerPtAnalysis::AliEMCalPtTaskVTrackSelection+;
+#pragma link C++ class EMCalTriggerPtAnalysis::AliEMCalPtTaskTrackSelectionESD+;
 
 #ifdef HAVE_FASTJET
 #pragma link C++ class AliEmcalJetTask+;