including files not added in the previous commit
authormcosenti <mcosenti@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 18 Apr 2012 08:09:26 +0000 (08:09 +0000)
committermcosenti <mcosenti@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 18 Apr 2012 08:09:26 +0000 (08:09 +0000)
PWGGA/EMCALTasks/AliEmcalAodTrackFilterTask.cxx [new file with mode: 0644]
PWGGA/EMCALTasks/AliEmcalAodTrackFilterTask.h [new file with mode: 0644]
PWGGA/EMCALTasks/macros/AddTaskEmcalAodTrackFilter.C [new file with mode: 0644]
PWGGA/EMCALTasks/macros/AddTaskEmcalSetup.C [new file with mode: 0644]

diff --git a/PWGGA/EMCALTasks/AliEmcalAodTrackFilterTask.cxx b/PWGGA/EMCALTasks/AliEmcalAodTrackFilterTask.cxx
new file mode 100644 (file)
index 0000000..de98ad5
--- /dev/null
@@ -0,0 +1,154 @@
+// $Id: AliEmcalAodTrackFilterTask.cxx  $
+//
+// Class to filter hybrid tracks in AOD events.
+//
+//
+
+#include <TClonesArray.h>
+
+#include "AliAnalysisManager.h"
+#include "AliAODEvent.h"
+#include "AliPicoTrack.h"
+
+#include "AliEmcalAodTrackFilterTask.h"
+
+ClassImp(AliEmcalAodTrackFilterTask)
+
+//________________________________________________________________________
+AliEmcalAodTrackFilterTask::AliEmcalAodTrackFilterTask() : 
+  AliAnalysisTaskSE("AliEmcalAodTrackFilterTask"),
+  fAODfilterBit(16),
+  fTracksOutName("PicoTracks"),
+  fTracksInName("tracks"),
+  fAOD(0),
+  fTracksIn(0),
+  fTracksOut(0)
+{
+  // Constructor.
+}
+
+//________________________________________________________________________
+AliEmcalAodTrackFilterTask::AliEmcalAodTrackFilterTask(const char *name) : 
+  AliAnalysisTaskSE("AliEmcalAodTrackFilterTask"),
+  fAODfilterBit(16),
+  fTracksOutName("PicoTracks"),
+  fTracksInName("tracks"),
+  fAOD(0),
+  fTracksIn(0),
+  fTracksOut(0)
+{
+  // Constructor.
+
+  if (!name)
+    return;
+
+  SetName(name);
+
+  fBranchNames = "ESD:AliESDHeader.,AliESDRun.,SPDVertex.,Tracks";
+}
+
+//________________________________________________________________________
+AliEmcalAodTrackFilterTask::~AliEmcalAodTrackFilterTask()
+{
+  //Destructor
+
+}
+
+//________________________________________________________________________
+void AliEmcalAodTrackFilterTask::UserCreateOutputObjects()
+{
+  // Create histograms.
+
+  fTracksOut = new TClonesArray("AliPicoTrack");
+  fTracksOut->SetName(fTracksOutName);
+}
+
+//________________________________________________________________________
+void AliEmcalAodTrackFilterTask::UserExec(Option_t *) 
+{
+  // Main loop, called for each event.
+
+  AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
+  if (!am) {
+    AliError("Manager zero, returning");
+    return;
+  }
+
+  RetrieveEventObjects();
+
+  // add tracks to event if not yet there
+  if (!(InputEvent()->FindListObject(fTracksOutName)))
+    InputEvent()->AddObject(fTracksOut);
+
+  Int_t Ntracks = GetNumberOfTracks();
+  for (Int_t iTracks = 0, nacc = 0; iTracks < Ntracks; ++iTracks) {
+    AliAODTrack *track = GetTrack(iTracks);
+
+    if (!track)
+      continue;
+    
+    if (!AcceptTrack(track))
+      continue;
+
+    AliPicoTrack *picotrack = new ((*fTracksOut)[nacc]) AliPicoTrack(track->Pt(), track->Eta(), track->Phi(), 
+                                          track->Charge(), track->GetLabel(), 
+                                          track->GetTrackEtaOnEMCal(), track->GetTrackPhiOnEMCal(), track->IsEMCAL());
+    if (track->IsEMCAL()) {
+      picotrack->SetEMCALcluster(track->GetEMCALcluster());
+    }
+    //cout << iTracks << " - is emcal = " << track->IsEMCAL() << ", phiemc = " << track->GetTrackPhiOnEMCal() << ", etaemc = " << track->GetTrackEtaOnEMCal() << ", emcid = " << track->GetEMCALcluster() << endl;
+    ++nacc;
+  }
+}
+
+
+//________________________________________________________________________
+Bool_t AliEmcalAodTrackFilterTask::AcceptTrack(AliAODTrack *track)
+{
+  AliAODTrack *aodtrack = dynamic_cast<AliAODTrack*>(track);
+  if (aodtrack) {
+    //cout << "filter bit = " << fFilterBit << ", filter map = " << aodtrack->GetFilterMap() << endl;
+    return aodtrack->TestFilterBit(fAODfilterBit);
+    //return aodtrack->IsHybridGlobalConstrainedGlobal();
+  }
+  return 1;
+}
+
+//________________________________________________________________________
+void AliEmcalAodTrackFilterTask::SetRunPeriod(const char *p)
+{
+  if (!strcmp(p, "LHC11h")) {
+    SetAODfilterBit(256+512); // hybrid tracks for LHC11h
+  }
+  else {
+    AliWarning(Form("Run period %s not known. AOD filter bit not set.", p));
+  }
+}
+
+//________________________________________________________________________
+void AliEmcalAodTrackFilterTask::RetrieveEventObjects()
+{
+  fAOD = dynamic_cast<AliAODEvent*>(InputEvent());
+  if (!fAOD) {
+    AliError("Task works only on AOD events, returning");
+    return;
+  }
+
+  fTracksIn = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksInName));
+
+  if (!fTracksIn) {
+    AliError(Form("ERROR: Could not retrieve tracks %s!", fTracksInName.Data())); 
+  }
+}
+
+//________________________________________________________________________
+AliAODTrack* AliEmcalAodTrackFilterTask::GetTrack(const Int_t i) const
+{
+  return dynamic_cast<AliAODTrack*>(fTracksIn->At(i));
+}
+
+//________________________________________________________________________
+Int_t AliEmcalAodTrackFilterTask::GetNumberOfTracks() const
+{
+  return fTracksIn->GetEntriesFast();
+}
diff --git a/PWGGA/EMCALTasks/AliEmcalAodTrackFilterTask.h b/PWGGA/EMCALTasks/AliEmcalAodTrackFilterTask.h
new file mode 100644 (file)
index 0000000..9031c33
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef ALIEMCALAODTRACKFILTERTASK_H
+#define ALIEMCALAODTRACKFILTERTASK_H
+
+// $Id: AliEmcalAodTrackFilterTask.h 54003 2012-01-19 16:40:42Z loizides $
+
+class TClonesArray;
+class AliAODEvent;
+class AliAODTrack;
+
+#include "AliAnalysisTaskSE.h"
+
+class AliEmcalAodTrackFilterTask : public AliAnalysisTaskSE {
+ public:
+  AliEmcalAodTrackFilterTask();
+  AliEmcalAodTrackFilterTask(const char *name);
+  virtual ~AliEmcalAodTrackFilterTask();
+
+  void UserCreateOutputObjects();
+  void UserExec(Option_t *option);
+  void SetRunPeriod(const char *p);
+  Bool_t AcceptTrack(AliAODTrack *track);
+  void RetrieveEventObjects();
+  AliAODTrack* GetTrack(const Int_t i) const;
+  Int_t GetNumberOfTracks() const;
+   
+  void SetAODfilterBit(Int_t b)                  { fAODfilterBit     = b;    }
+  void SetTracksName(const char *name)           { fTracksOutName    = name; }
+  void SetTracksIn(const char *name)             { fTracksInName     = name; }
+
+ protected:
+  Int_t              fAODfilterBit;         // if true then do vertex constraint
+  TString            fTracksOutName;        // name of output tracks 
+  TString            fTracksInName;         // name of input tracks
+  AliAODEvent       *fAOD;                  //!aod event
+  TClonesArray      *fTracksIn;             //!track array in
+  TClonesArray      *fTracksOut;            //!track array out
+
+ private:
+  AliEmcalAodTrackFilterTask(const AliEmcalAodTrackFilterTask&);            // not implemented
+  AliEmcalAodTrackFilterTask &operator=(const AliEmcalAodTrackFilterTask&); // not implemented
+
+  ClassDef(AliEmcalAodTrackFilterTask, 1); // Class to filter hybrid tracks in AOD events
+};
+
+#endif
diff --git a/PWGGA/EMCALTasks/macros/AddTaskEmcalAodTrackFilter.C b/PWGGA/EMCALTasks/macros/AddTaskEmcalAodTrackFilter.C
new file mode 100644 (file)
index 0000000..dd48df0
--- /dev/null
@@ -0,0 +1,51 @@
+AliEmcalAodTrackFilterTask* AddTaskEmcalAodTrackFilter(
+                                                      const char *name       = "PicoTracks",
+                                                      const char *inname     = "tracks",
+                                                      const char *runPeriod  = "LHC11h"
+                                                       )
+{  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr)
+  {
+    ::Error("AddTaskEmcalAodTrackFilter", "No analysis manager to connect to.");
+    return NULL;
+  }  
+  
+  // Check the analysis type using the event handlers connected to the analysis manager.
+  //==============================================================================
+  if (!mgr->GetInputEventHandler())
+  {
+    ::Error("AddTaskEmcalAodTrackFilter", "This task requires an input event handler");
+    return NULL;
+  }
+  
+  //-------------------------------------------------------
+  // Init the task and do settings
+  //-------------------------------------------------------
+
+  // Add aod track filter task.
+
+
+  AliEmcalAodTrackFilterTask *eTask = new AliEmcalAodTrackFilterTask();
+  eTask->SetTracksName(name);
+  eTask->SetTracksIn(inname);
+  eTask->SetRunPeriod(runPeriod);
+
+  //-------------------------------------------------------
+  // Final settings, pass to manager and set the containers
+  //-------------------------------------------------------
+
+  mgr->AddTask(eTask);
+  
+  // Create containers for input/output
+  AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer()  ;
+  //AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer() ;
+  
+  mgr->ConnectInput  (eTask, 0,  cinput1 );
+  //mgr->ConnectOutput (eTask, 0, coutput1 );
+  
+  return eTask;
+  
+}
diff --git a/PWGGA/EMCALTasks/macros/AddTaskEmcalSetup.C b/PWGGA/EMCALTasks/macros/AddTaskEmcalSetup.C
new file mode 100644 (file)
index 0000000..0b3c13e
--- /dev/null
@@ -0,0 +1,41 @@
+AliEmcalSetupTask* AddTaskEmcalSetup()
+{  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr)
+  {
+    ::Error("AddTaskEmcalSetup", "No analysis manager to connect to.");
+    return NULL;
+  }  
+  
+  // Check the analysis type using the event handlers connected to the analysis manager.
+  //==============================================================================
+  if (!mgr->GetInputEventHandler())
+  {
+    ::Error("AddTaskEmcalSetup", "This task requires an input event handler");
+    return NULL;
+  }
+  
+  //-------------------------------------------------------
+  // Init the task and do settings
+  //-------------------------------------------------------
+
+  // Add emcal setup task.
+
+  AliEmcalSetupTask *eTask = new AliEmcalSetupTask("EmcalSetupTask");
+
+  //-------------------------------------------------------
+  // Final settings, pass to manager and set the containers
+  //-------------------------------------------------------
+
+  mgr->AddTask(eTask);
+  
+  // Create containers for input/output
+  AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer();
+  
+  mgr->ConnectInput  (eTask, 0,  cinput1 );
+
+  return eTask;
+  
+}