propagator and setup task
authorloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 12 Dec 2011 21:53:40 +0000 (21:53 +0000)
committerloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 12 Dec 2011 21:53:40 +0000 (21:53 +0000)
PWG4/CMakelibPWG4UserTasks.pkg
PWG4/PWG4UserTasksLinkDef.h
PWG4/UserTasks/EmcalTasks/AliEmcalSetupTask.cxx [new file with mode: 0644]
PWG4/UserTasks/EmcalTasks/AliEmcalSetupTask.h [new file with mode: 0644]
PWG4/UserTasks/EmcalTasks/AliEmcalTrackPropagatorTask.cxx [new file with mode: 0644]
PWG4/UserTasks/EmcalTasks/AliEmcalTrackPropagatorTask.h [new file with mode: 0644]

index ea3fb16f732c1b2ede3287b5cbd0a56b22d3d24a..5946442ae0baf4c61cdc90bb2f38a6be491cbccd 100644 (file)
@@ -35,12 +35,14 @@ set ( SRCS
  UserTasks/PHOS_PbPbQA/AliAnalysisTaskPHOSPbPbQA.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
  UserTasks/EmcalTasks/AliAnalysisTaskEMCALTriggerQA.cxx
+ UserTasks/EmcalTasks/AliEmcalEsdTpcTrackTask.cxx
+ UserTasks/EmcalTasks/AliEmcalPhysicsSelection.cxx
+ UserTasks/EmcalTasks/AliEmcalPhysicsSelectionTask.cxx
+ UserTasks/EmcalTasks/AliEmcalSetupTask.cxx
+ UserTasks/EmcalTasks/AliEmcalTrackPropagatorTask.cxx
 )
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
index 146748d4029e185cf494fe1058510ee964aa0374..2a3869784deac3aca65931f3c1c3c7dc94816c97 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 AliAnalysisTaskEMCALPi0PbPb+;
+#pragma link C++ class AliAnalysisTaskEMCALTriggerQA+;
+#pragma link C++ class AliEmcalEsdTpcTrackTask+;
+#pragma link C++ class AliEmcalPhysicsSelection+;
+#pragma link C++ class AliEmcalPhysicsSelectionTask+;
+#pragma link C++ class AliEmcalSetupTask+;
+#pragma link C++ class AliEmcalTrackPropagatorTask+;
 #pragma link C++ class AliStaHeader+;
 #pragma link C++ class AliStaCluster+;
 #pragma link C++ class AliStaVertex+;
 #pragma link C++ class AliStaTrigger+;
 #pragma link C++ class AliStaPart+;
-#pragma link C++ class AliAnalysisTaskEMCALTriggerQA+;
 
 #endif
diff --git a/PWG4/UserTasks/EmcalTasks/AliEmcalSetupTask.cxx b/PWG4/UserTasks/EmcalTasks/AliEmcalSetupTask.cxx
new file mode 100644 (file)
index 0000000..7063d51
--- /dev/null
@@ -0,0 +1,134 @@
+// $Id$
+//
+// Task to setup emcal related global objects
+//
+//
+
+#include <TClonesArray.h>
+#include <TGeoManager.h>
+#include <TGeoGlobalMagField.h>
+#include "AliAnalysisManager.h"
+#include "AliCDBManager.h"
+#include "AliEMCALGeometry.h"
+#include "AliESDEvent.h"
+#include "AliEmcalSetupTask.h"
+#include "AliGeomManager.h"
+#include "AliOADBContainer.h"
+
+ClassImp(AliEmcalSetupTask)
+
+//________________________________________________________________________
+AliEmcalSetupTask::AliEmcalSetupTask() : 
+  AliAnalysisTaskSE(),
+  fOcdbPath(),
+  fOadbPath("$ALICE_ROOT/OADB/EMCAL"),
+  fEsdEv(0),
+  fIsInit(kFALSE)
+{
+  // Constructor.
+}
+
+//________________________________________________________________________
+AliEmcalSetupTask::AliEmcalSetupTask(const char *name) : 
+  AliAnalysisTaskSE(name),
+  fOcdbPath(),
+  fOadbPath("$ALICE_ROOT/OADB/EMCAL"),
+  fEsdEv(0),
+  fIsInit(kFALSE)
+{
+  // Constructor.
+  fBranchNames = "ESD:AliESDHeader.,AliESDRun.";
+}
+
+//________________________________________________________________________
+AliEmcalSetupTask::~AliEmcalSetupTask()
+{
+  // Destructor.
+}
+
+//________________________________________________________________________
+void AliEmcalSetupTask::UserExec(Option_t *) 
+{
+  // Main loop, called for each event.
+
+  if (fIsInit)
+    return;
+
+  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;
+  }
+  am->LoadBranch("AliESDRun.");
+  am->LoadBranch("AliESDHeader.");
+
+  Int_t runno = fEsdEv->GetRunNumber();
+  Bool_t is2010 = kTRUE;
+  if (runno>139517) {
+    is2010 = kFALSE;
+  }
+
+  TString geoname("EMCAL_FIRSTYEARV1");
+  if (!is2010)
+    geoname = "EMCAL_COMPLETEV1";
+  AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(geoname);
+  if (!geom) {
+    AliFatal(Form("Can not create geometry: %s",geoname.Data()));
+    return;
+  }
+
+  AliCDBManager *man = 0;
+  if (fOcdbPath.Length()>0) {
+    AliInfo(Form("Setting up OCDB"));
+    man = AliCDBManager::Instance();
+    man->SetDefaultStorage(fOcdbPath);
+    man->SetRun(runno);
+  }
+
+  TGeoManager *geo = AliGeomManager::GetGeometry();
+  if (!geo) {
+    TString fname("geometry_2010.root");
+    if (!is2010)
+      fname = "geometry_2011.root";
+    if (gSystem->AccessPathName(fname)!=0)
+      fname = "geometry.root";
+    if (gSystem->AccessPathName(fname)==0) {
+      AliInfo(Form("Loading geometry from %s", fname.Data()));
+      AliGeomManager::LoadGeometry(fname);
+    } else if (man) {
+      AliInfo(Form("Loading geometry from OCDB"));
+      AliGeomManager::LoadGeometry();
+    }
+  }
+  if (geo) {
+    AliGeomManager::ApplyAlignObjsFromCDB("EMCAL");
+    AliInfo(Form("Locking geometry"));
+    geo->LockGeometry();
+  }
+
+  if (!TGeoGlobalMagField::Instance()->GetField()) { // construct field map
+    AliInfo("Constructing field map from ESD run info");
+    fEsdEv->InitMagneticField();
+  }
+
+  if (fOadbPath.Length()>0) {
+    AliOADBContainer emcalgeoCont(Form("emcal"));
+    emcalgeoCont.InitFromFile(Form("%s/EMCALlocal2master.root",fOadbPath.Data()),
+                              Form("AliEMCALgeo"));
+    TObjArray *mobj=dynamic_cast<TObjArray*>(emcalgeoCont.GetObject(runno,"EmcalMatrices"));
+    if (mobj) {
+      for(Int_t mod=0; mod < (geom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
+        //AliInfo(Form("Misalignment matrix %d", mod));
+        geom->SetMisalMatrix((TGeoHMatrix*) mobj->At(mod),mod);
+      } 
+    }
+  }
+
+  fIsInit = kTRUE;
+}
diff --git a/PWG4/UserTasks/EmcalTasks/AliEmcalSetupTask.h b/PWG4/UserTasks/EmcalTasks/AliEmcalSetupTask.h
new file mode 100644 (file)
index 0000000..6e29aac
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef ALIEMCALSETUPTASK_H
+#define ALIEMCALSETUPTASK_H
+
+// $Id$
+
+class TClonesArray;
+class AliESDEvent;
+class AliESDtrack;
+class AliESDtrackCuts;
+
+#include "AliAnalysisTaskSE.h"
+
+class AliEmcalSetupTask : public AliAnalysisTaskSE {
+ public:
+  AliEmcalSetupTask();
+  AliEmcalSetupTask(const char *name);
+  virtual ~AliEmcalSetupTask();
+
+  void UserExec(Option_t *option);
+  void SetOadbPath(const char *n) { fOadbPath = n; }
+  void SetOcdbPath(const char *n) { fOcdbPath = n; }
+
+ protected:
+  TString            fOcdbPath;        // path to ocdb (def=none)
+  TString            fOadbPath;        // path to oadb
+  AliESDEvent       *fEsdEv;           //!esd event
+  Bool_t             fIsInit;          //!=true then already initialized 
+
+ private:
+  AliEmcalSetupTask(const AliEmcalSetupTask&);            // not implemented
+  AliEmcalSetupTask &operator=(const AliEmcalSetupTask&); // not implemented
+
+  ClassDef(AliEmcalSetupTask, 1); // Class to setup geometry for emcal
+};
+
+#endif
diff --git a/PWG4/UserTasks/EmcalTasks/AliEmcalTrackPropagatorTask.cxx b/PWG4/UserTasks/EmcalTasks/AliEmcalTrackPropagatorTask.cxx
new file mode 100644 (file)
index 0000000..43663d2
--- /dev/null
@@ -0,0 +1,116 @@
+// $Id$
+//
+// Task to propagate tracks to EMCAL surface.
+//
+//
+
+#include <TClonesArray.h>
+#include "AliAnalysisManager.h"
+#include "AliEMCALRecoUtils.h"
+#include "AliESDEvent.h"
+#include "AliEmcalTrackPropagatorTask.h"
+
+ClassImp(AliEmcalTrackPropagatorTask)
+
+//________________________________________________________________________
+AliEmcalTrackPropagatorTask::AliEmcalTrackPropagatorTask() : 
+  AliAnalysisTaskSE(),
+  fRecoUtils(0),
+  fTracksName(),
+  fDist(430),
+  fMinPtCut(0.5),
+  fEsdEv(0),
+  fTracks(0)
+{
+  // Constructor.
+}
+
+//________________________________________________________________________
+AliEmcalTrackPropagatorTask::AliEmcalTrackPropagatorTask(const char *name) : 
+  AliAnalysisTaskSE(name),
+  fRecoUtils(0),
+  fTracksName("TpcSpdVertexConstrainedTracks"),
+  fDist(430),
+  fMinPtCut(0.5),
+  fEsdEv(0),
+  fTracks(0)
+{
+  // Constructor.
+  fBranchNames = "ESD:AliESDHeader.,Tracks";
+}
+
+//________________________________________________________________________
+AliEmcalTrackPropagatorTask::~AliEmcalTrackPropagatorTask()
+{
+  //Destructor.
+
+  delete fRecoUtils;
+}
+
+//________________________________________________________________________
+void AliEmcalTrackPropagatorTask::UserCreateOutputObjects()
+{
+  // Create histograms.
+
+  if (!fRecoUtils) {
+    fRecoUtils = new AliEMCALRecoUtils;
+    fRecoUtils->SetStep(25);
+    AliInfo("No reoc utils given, creating default utils");
+  }
+}
+
+//________________________________________________________________________
+void AliEmcalTrackPropagatorTask::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;
+  }
+
+  // get tracks from event if not yet there
+  if (fTracksName == "Tracks")
+    am->LoadBranch("Tracks");
+  fTracks = dynamic_cast<TClonesArray*>((InputEvent()->FindListObject(fTracksName)));
+  if (!fTracks) {
+    AliError(Form("Could not get tracks %s, returning", fTracksName.Data()));
+    return;
+  }
+
+  // Loop over all tracks
+  const Int_t ntr = fTracks->GetEntries();
+  for (Int_t i=0; i<ntr; ++i) {
+    AliESDtrack *eTrack = static_cast<AliESDtrack*>(fTracks->At(i));
+    if (!eTrack)
+      continue;
+    if(eTrack->Pt()<fMinPtCut) 
+      continue;
+    Double_t phi = eTrack->Phi()*TMath::RadToDeg();
+    if (TMath::Abs(eTrack->Eta())>0.8 || phi <= 20 || phi >= 240) 
+      continue;
+    AliExternalTrackParam *trackParam =  const_cast<AliExternalTrackParam*>(eTrack->GetInnerParam());
+    if(!trackParam) 
+      continue;
+
+    // Extrapolate the track to EMCal surface
+    AliExternalTrackParam emcalParam(*trackParam);
+    Float_t etaout=0, phiout=0;
+    Bool_t ret = fRecoUtils->ExtrapolateTrackToEMCalSurface(&emcalParam, 
+                                                            fDist, 
+                                                            fRecoUtils->GetMass(), 
+                                                            fRecoUtils->GetStepSurface(), 
+                                                            etaout, 
+                                                            phiout);
+    if (!ret)
+      continue;
+    eTrack->SetOuterParam(&emcalParam,AliExternalTrackParam::kMultSec);
+  }
+}
diff --git a/PWG4/UserTasks/EmcalTasks/AliEmcalTrackPropagatorTask.h b/PWG4/UserTasks/EmcalTasks/AliEmcalTrackPropagatorTask.h
new file mode 100644 (file)
index 0000000..e4e606c
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef ALIEMCALTRACKPROPAGATORTASK_H
+#define ALIEMCALTRACKPROPAGATORTASK_H
+
+// $Id$
+
+class TClonesArray;
+class AliEMCALRecoUtils;
+class AliESDEvent;
+class AliESDtrack;
+
+#include "AliAnalysisTaskSE.h"
+
+class AliEmcalTrackPropagatorTask : public AliAnalysisTaskSE {
+ public:
+  AliEmcalTrackPropagatorTask();
+  AliEmcalTrackPropagatorTask(const char *name);
+  virtual ~AliEmcalTrackPropagatorTask();
+
+  void UserCreateOutputObjects();
+  void UserExec(Option_t *option);
+   
+  void SetDist(Double_t d)                 { fDist       = d;    }
+  void SetMinPt(Double_t pt)               { fMinPtCut = pt;     }
+  void SetRecoUtils(AliEMCALRecoUtils *ru) { fRecoUtils  = ru;   }
+  void SetTracksName(const char *name)     { fTracksName = name; }
+
+ protected:
+  AliEMCALRecoUtils *fRecoUtils;         // esd reco utils
+  TString            fTracksName;        // name of tracks 
+  Double_t           fDist;              // distance to surface (430cm default)
+  Double_t           fMinPtCut;          // minimum track pt cut (500 MeV/c default)
+  AliESDEvent       *fEsdEv;             //!esd event
+  TClonesArray      *fTracks;            //!track array
+
+ private:
+  AliEmcalTrackPropagatorTask(const AliEmcalTrackPropagatorTask&);            // not implemented
+  AliEmcalTrackPropagatorTask &operator=(const AliEmcalTrackPropagatorTask&); // not implemented
+
+  ClassDef(AliEmcalTrackPropagatorTask, 1); // Class to propagate and store track parameters at EMCAL surface
+};
+
+#endif