Task to provide spd vertex constrained tracks
authorloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 6 Sep 2011 21:25:04 +0000 (21:25 +0000)
committerloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 6 Sep 2011 21:25:04 +0000 (21:25 +0000)
PWG4/CMakelibPWG4UserTasks.pkg
PWG4/PWG4UserTasksLinkDef.h
PWG4/UserTasks/EmcalTasks/AliEmcalEsdTpcTrackTask.cxx [new file with mode: 0644]
PWG4/UserTasks/EmcalTasks/AliEmcalEsdTpcTrackTask.h [new file with mode: 0644]

index b252499e41b64c2098399e993563584e99efdeaf..85d43bea4ccfabe0db9a4be7bf12886bb65f4eaf 100644 (file)
@@ -31,6 +31,9 @@ set ( SRCS
  UserTasks/PHOS_pp_pi0/AliAnalysisTaskPi0.cxx
  UserTasks/CaloCellQA/AliCaloCellsQA.cxx
  UserTasks/CaloCellQA/AliAnalysisTaskCaloCellsQA.cxx
+ UserTasks/EmcalTasks/AliEmcalPhysicsSelection.cxx
+ UserTasks/EmcalTasks/AliEmcalPhysicsSelectionTask.cxx
+ UserTasks/EmcalTasks/AliEmcalEsdTpcTrackTask.cxx
  UserTasks/EmcalTasks/AliAnalysisTaskEMCALClusterizeFast.cxx
  UserTasks/EmcalTasks/AliAnalysisTaskEMCALPi0PbPb.cxx
 )
index dae94a5178f090a25cbb0997a627c140a4df975f..7bcd3c5ad82017856ed6461d258eb50624823742 100644 (file)
 #pragma link C++ class AliAnalysisTaskCaloCellsQA+;
 
 // EmcalTasks
+#pragma link C++ class AliEmcalPhysicsSelection+;
+#pragma link C++ class AliEmcalPhysicsSelectionTask+;
+#pragma link C++ class AliEmcalEsdTpcTrackTask+;
+#pragma link C++ class AliAnalysisTaskEMCALPi0PbPb+;
 #pragma link C++ class AliAnalysisTaskEMCALClusterizeFast+;
 #pragma link C++ class AliAnalysisTaskEMCALPi0PbPb+;
 #pragma link C++ class AliStaHeader+;
diff --git a/PWG4/UserTasks/EmcalTasks/AliEmcalEsdTpcTrackTask.cxx b/PWG4/UserTasks/EmcalTasks/AliEmcalEsdTpcTrackTask.cxx
new file mode 100644 (file)
index 0000000..5255cf0
--- /dev/null
@@ -0,0 +1,135 @@
+// $Id$
+
+#include <TClonesArray.h>
+#include <TGeoGlobalMagField.h>
+#include "AliAnalysisManager.h"
+#include "AliESDEvent.h"
+#include "AliESDtrackCuts.h"
+#include "AliEmcalEsdTpcTrackTask.h"
+#include "AliMagF.h"
+
+ClassImp(AliEmcalEsdTpcTrackTask)
+
+//________________________________________________________________________
+AliEmcalEsdTpcTrackTask::AliEmcalEsdTpcTrackTask() : 
+  AliAnalysisTaskSE(),
+  fEsdTrackCuts(0),
+  fTracksName(),
+  fEsdEv(0),
+  fTracks(0)
+{
+  // Constructor
+}
+
+//________________________________________________________________________
+AliEmcalEsdTpcTrackTask::AliEmcalEsdTpcTrackTask(const char *name) : 
+  AliAnalysisTaskSE(name),
+  fEsdTrackCuts(0),
+  fTracksName("TpcSpdVertexConstrainedTracks"),
+  fEsdEv(0),
+  fTracks(0)
+{
+  // Constructor
+}
+
+//________________________________________________________________________
+AliEmcalEsdTpcTrackTask::~AliEmcalEsdTpcTrackTask()
+{
+  //Destructor
+
+  delete fEsdTrackCuts;
+}
+
+//________________________________________________________________________
+void AliEmcalEsdTpcTrackTask::UserCreateOutputObjects()
+{
+  // Create histograms
+
+  fTracks = new TClonesArray("AliESDtrack");
+  fTracks->SetName(fTracksName);
+
+  if (!fEsdTrackCuts) {
+    AliInfo("No track cuts given, creating default cuts");
+    fEsdTrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
+    fEsdTrackCuts->SetPtRange(0.15,1e3);
+  }
+}
+
+//________________________________________________________________________
+void AliEmcalEsdTpcTrackTask::UserExec(Option_t *) 
+{
+  // Main loop, called for each event.
+
+  fEsdEv = dynamic_cast<AliESDEvent*>(InputEvent());
+  if (!fEsdEv) {
+    AliError("Task works only on ESD events, returning");
+    return;
+  }
+
+  AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
+  if (!am) {
+    AliError("Manager zero, returning");
+    return;
+  }
+
+  // add tracks to event if not yet there
+  if (!(InputEvent()->FindListObject(fTracksName)))
+    InputEvent()->AddObject(fTracks);
+
+  am->LoadBranch("AliESDRun.");
+  am->LoadBranch("AliESDHeader.");
+  if (!TGeoGlobalMagField::Instance()->GetField()) { // construct field map
+    const AliESDRun *erun = fEsdEv->GetESDRun();
+    AliMagF *field = AliMagF::CreateFieldMap(erun->GetCurrentL3(),
+                                             erun->GetCurrentDip(),
+                                             AliMagF::kConvLHC,
+                                             kFALSE,
+                                             erun->GetBeamEnergy(),
+                                             erun->GetBeamType());
+    TGeoGlobalMagField::Instance()->SetField(field);
+  }
+
+  am->LoadBranch("SPDVertex.");
+  const AliESDVertex *vtxSPD = fEsdEv->GetPrimaryVertexSPD();
+  if (!vtxSPD) {
+    AliError("No SPD vertex, returning");
+    return;
+  }
+
+  am->LoadBranch("Tracks");
+  Int_t ntr = fEsdEv->GetNumberOfTracks();
+  for (Int_t i=0; i<ntr; ++i) {
+    AliESDtrack *etrack = fEsdEv->GetTrack(i);
+    if (!etrack)
+      continue;
+    if (!fEsdTrackCuts->AcceptTrack(etrack))
+      continue;
+
+    AliESDtrack *ntrack = AliESDtrackCuts::GetTPCOnlyTrack(fEsdEv,etrack->GetID());
+    if (!ntrack)
+      continue;
+    if (ntrack->Pt()<=0) {
+      delete ntrack;
+      continue;
+    }
+
+    Double_t bfield[3] = {0,0,0};
+    ntrack->GetBxByBz(bfield);
+    AliExternalTrackParam exParam;
+    Bool_t relate = ntrack->RelateToVertexBxByBz(vtxSPD,bfield,kVeryBig,&exParam);
+    if (!relate) {
+      delete ntrack;
+      continue;
+    }
+
+    // set the constraint parameters to the track
+    ntrack->Set(exParam.GetX(),exParam.GetAlpha(),exParam.GetParameter(),exParam.GetCovariance());
+
+    if (ntrack->Pt()<=0) {
+      delete ntrack;
+      continue;
+    }
+
+    fTracks->Add(ntrack);
+  }
+}
diff --git a/PWG4/UserTasks/EmcalTasks/AliEmcalEsdTpcTrackTask.h b/PWG4/UserTasks/EmcalTasks/AliEmcalEsdTpcTrackTask.h
new file mode 100644 (file)
index 0000000..8a90356
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef ALIEMCALESDTPCTRACKTASK_H
+#define ALIEMCALESDTPCTRACKTASK_H
+
+// $Id$
+
+class TClonesArray;
+class AliESDEvent;
+class AliESDtrack;
+class AliESDtrackCuts;
+
+#include "AliAnalysisTaskSE.h"
+
+class AliEmcalEsdTpcTrackTask : public AliAnalysisTaskSE {
+ public:
+  AliEmcalEsdTpcTrackTask();
+  AliEmcalEsdTpcTrackTask(const char *name);
+  virtual ~AliEmcalEsdTpcTrackTask();
+
+  void UserCreateOutputObjects();
+  void UserExec(Option_t *option);
+   
+  void SetTrackCuts(AliESDtrackCuts *cuts) { fEsdTrackCuts = cuts; }
+  void SetTracksName(const char *name)     { fTracksName   = name; }
+
+ protected:
+  AliESDtrackCuts   *fEsdTrackCuts;      // esd track cuts
+  TString            fTracksName;        // name of tracks 
+  AliESDEvent       *fEsdEv;             //!esd event
+  TClonesArray      *fTracks;            //!track array
+
+ private:
+  AliEmcalEsdTpcTrackTask(const AliEmcalEsdTpcTrackTask&);            // not implemented
+  AliEmcalEsdTpcTrackTask &operator=(const AliEmcalEsdTpcTrackTask&); // not implemented
+
+  ClassDef(AliEmcalEsdTpcTrackTask, 1); //
+};
+
+#endif