]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
take the sigma cut for cluster/trackRef association from recoParam. add a MC label...
authorpcrochet <pcrochet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 1 Mar 2012 16:02:40 +0000 (16:02 +0000)
committerpcrochet <pcrochet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 1 Mar 2012 16:02:40 +0000 (16:02 +0000)
PWG/muondep/AddTaskESDMCLabelAddition.C
PWG/muondep/AliAnalysisTaskESDMCLabelAddition.cxx
PWG/muondep/AliAnalysisTaskESDMCLabelAddition.h

index e00b8217eba6154d07100a071e2c65a05dd9fe9f..8dfda420bf3e0408c91515fd53b3a44a2a2683b6 100644 (file)
@@ -1,40 +1,42 @@
-AliAnalysisTaskESDMCLabelAddition *AddTaskESDMCLabelAddition(Bool_t useKineFilter=kTRUE)
+AliAnalysisTaskESDMCLabelAddition *AddTaskESDMCLabelAddition()
 {
-// Creates a filter task and adds it to the analysis manager.
-// This file allows the creation of MC labels (based on the code of Philippe P.)
+  /// Add AliAnalysisTaskESDMCLabelAddition to the train (Philippe Pillot)
+  
+  // Get the pointer to the existing analysis manager via the static access method.
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if(!mgr) { 
+    Error("AddTaskESDMCLabelAddition","AliAnalysisManager not set!");
+    return NULL;
+  }
+  
+  // This task runs on ESDs
+  TString type = mgr->GetInputEventHandler()->GetDataType();
+  if (!type.Contains("ESD")) {
+    Error("AddTaskESDMCLabelAddition", "ESD input handler needed!");
+    return NULL;
+  }
+  
+  // This task needs MC input
+  AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler();
+  if (!mcH) {
+    Error("AddTaskESDMCLabelAddition", "No MC handler connected!");
+    return NULL;
+  }   
+  
+  // Create and configure task
+  AliAnalysisTaskESDMCLabelAddition *task = new AliAnalysisTaskESDMCLabelAddition("ESD MC Labels addition");
+  if (!task) {
+    Error("AddTaskESDMCLabelAddition", "MClabel addition task cannot be created!");
+    return NULL;
+  }
+  
+  // Add task to analysis manager
+  mgr->AddTask(task);
+  
+  // Connect input container
+  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
+  
+  return task;
+  
+}
 
-   // Get the pointer to the existing analysis manager via the static access method.
-   //==============================================================================
-   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
-   if (!mgr) {
-      ::Error("AddTaskESDMCLabelAddition", "No analysis manager to connect to.");
-      return NULL;
-   }   
-   
-   TString type = mgr->GetInputEventHandler()->GetDataType();
-   // Check if MC handler is connected in case kine filter requested
-   AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler();
-   if (!mcH && useKineFilter) {
-      ::Error("AddTaskESDFilter", "No MC handler connected while kine filtering requested");
-      return NULL;
-   }   
-   
-   if (useKineFilter) {
-      AliAnalysisTaskMCParticleFilter *kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Kine Filter");
-      mgr->AddTask(kinefilter);
-   }   
-
-
-   // Create the task, add it to the manager and configure it.
-   //===========================================================================   
-   // Barrel tracks filter
-   AliAnalysisTaskESDMCLabelAddition *ESDMCLabeltask = new AliAnalysisTaskESDMCLabelAddition("ESD MC Labels addition");
-   mgr->AddTask(ESDMCLabeltask);
-   
-   // Create ONLY the output containers for the data produced by the task.
-   // Get and connect other common input/output containers via the manager as below
-   //==============================================================================
-   mgr->ConnectInput  (ESDMCLabeltask,  0, mgr->GetCommonInputContainer());
-
-   return ESDMCLabeltask;
-}   
index edf5ff458435cf476905e619381ad652c509d3dd..60fb464a1d4facc5ab16d29acc449e8b94ba2158 100644 (file)
 
 /* $Id$ */
 
-#include <TChain.h>
-#include <TFile.h>
-#include <TParticle.h>
-
-#include "AliAnalysisTaskESDMCLabelAddition.h"
-#include "AliAnalysisManager.h"
+// STEER includes
 #include "AliESDEvent.h"
-#include "AliAODEvent.h"
-#include "AliESDInputHandler.h"
-#include "AliAODHandler.h"
-#include "AliAnalysisFilter.h"
-#include "AliESDtrack.h"
 #include "AliESDMuonTrack.h"
-#include "AliESDMuonCluster.h"
-#include "AliESDVertex.h"
-#include "AliMultiplicity.h"
 #include "AliLog.h"
-#include "AliStack.h"
-#include "AliMCEvent.h"
 #include "AliMCEventHandler.h"
-#include "AliAODMCParticle.h"
+#include "AliGeomManager.h"
+#include "AliCDBManager.h"
+
+// ANALYSIS includes
+#include "AliAnalysisManager.h"
 
+// MUON includes
+#include "AliMUONCDB.h"
+#include "AliMUONRecoParam.h"
 #include "AliMUONRecoCheck.h"
 #include "AliMUONESDInterface.h"
 #include "AliMUONTrack.h"
-#include "AliMUONTrackParam.h"
 #include "AliMUONVTrackStore.h"
-#include "AliMUONVCluster.h"
-#include "AliMUONVClusterStore.h"
+#include "AliMUONTriggerTrack.h"
+#include "AliMUONVTriggerTrackStore.h"
+#include "AliMUONLocalTrigger.h"
 
-ClassImp(AliAnalysisTaskESDMCLabelAddition)
+#include "AliAnalysisTaskESDMCLabelAddition.h"
 
-// sigma cut applied to match a reconstructed cluster with a trackref
-const Double_t AliAnalysisTaskESDMCLabelAddition::fgkSigmaCut = 10.;
+ClassImp(AliAnalysisTaskESDMCLabelAddition)
 
 //----------------------------------------------------------------------
 AliAnalysisTaskESDMCLabelAddition::AliAnalysisTaskESDMCLabelAddition():
-  AliAnalysisTaskSE()
+AliAnalysisTaskSE(),
+fDefaultStorage(""),
+fSigmaCut(-1.),
+fSigmaCutTrig(-1.)
 {
-  // Default constructor
+  /// Default constructor
 }
 
 
 //----------------------------------------------------------------------
 AliAnalysisTaskESDMCLabelAddition::AliAnalysisTaskESDMCLabelAddition(const char* name):
-  AliAnalysisTaskSE(name)
+AliAnalysisTaskSE(name),
+fDefaultStorage("raw://"),
+fSigmaCut(-1.),
+fSigmaCutTrig(-1.)
 {
-  // Constructor
+  /// Constructor
 }
 
 
 //----------------------------------------------------------------------
 void AliAnalysisTaskESDMCLabelAddition::UserCreateOutputObjects()
 {
+  /// Create output objects
 }
 
 
 //----------------------------------------------------------------------
-void AliAnalysisTaskESDMCLabelAddition::Init()
+void AliAnalysisTaskESDMCLabelAddition::NotifyRun()
 {
-  AliDebug(2, "Init()");
+  /// Load OCDB inputs
+  
+  // set OCDB location
+  AliCDBManager* cdbm = AliCDBManager::Instance();
+  cdbm->SetDefaultStorage(fDefaultStorage.Data());
+  cdbm->SetRun(fCurrentRunNumber);
+  
+  // load mapping
+  if (!AliMUONCDB::LoadMapping()) return;
+  
+  // load geometry
+  if (!AliGeomManager::GetGeometry()) AliGeomManager::LoadGeometry();
+  if (!AliGeomManager::GetGeometry()) return;
+  
+  // load recoParam
+  AliMUONRecoParam* recoParam = AliMUONCDB::LoadRecoParam();
+  if (!recoParam) {
+    fSigmaCut = -1.;
+    fSigmaCutTrig = -1.;
+    return;
+  }
+  
+  // get sigma cut from recoParam to associate clusters with TrackRefs in case the labels are not used
+  fSigmaCut = (recoParam->ImproveTracks()) ? recoParam->GetSigmaCutForImprovement() : recoParam->GetSigmaCutForTracking();
+  
+  // get sigma cut from recoParam to associate trigger track to triggerable track
+  fSigmaCutTrig = recoParam->GetSigmaCutForTrigger();
+  
 }
 
 
 //----------------------------------------------------------------------
 void AliAnalysisTaskESDMCLabelAddition::UserExec(Option_t */*option*/)
 {
-  // Execute analysis for current event                                            
-  Long64_t ientry = Entry();
-  AliDebug(1, Form("MCLabel Addition: Analysing event # %5d\n",(Int_t) ientry)); 
-  AddMCLabel();
-}
-
-
-//----------------------------------------------------------------------
-void AliAnalysisTaskESDMCLabelAddition::AddMCLabel() 
-{
-  // Load ESD event
+  /// Execute analysis for current event                               
+  
+  AliDebug(1, Form("MCLabel Addition: Analysing event # %5d\n",(Int_t) Entry())); 
+  
+  // make sure necessary information from PCDB have been loaded
+  if (fSigmaCut < 0) return;
+  
+  /// Load ESD event
   AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
   if (!esd) {
     AliError("Cannot get input event");
@@ -100,12 +122,17 @@ void AliAnalysisTaskESDMCLabelAddition::AddMCLabel()
   }      
   
   // Load MC event 
-  AliMCEventHandler *mcH = 0;
-  if(MCEvent()) mcH = (AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler()); 
+  AliMCEventHandler* mcH = static_cast<AliMCEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
+  if ( ! mcH ) {
+    AliError ("MCH event handler not found. Nothing done!");
+    return;
+  }
+  
   
   // Get reference tracks
   AliMUONRecoCheck rc(esd,mcH);
   AliMUONVTrackStore* trackRefStore = rc.TrackRefs(-1);
+  AliMUONVTriggerTrackStore* triggerTrackRefStore = rc.TriggerableTracks(-1);
   
   // Loop over reconstructed tracks
   AliESDMuonTrack *esdTrack = 0x0;
@@ -114,20 +141,37 @@ void AliAnalysisTaskESDMCLabelAddition::AddMCLabel()
     
     esdTrack = esd->GetMuonTrack(nMuTrack);
     
-    // skip ghosts
-    if (!esdTrack->ContainTrackerData()) continue;
-    
-    // convert ESD track to MUON track (without recomputing track parameters at each clusters)
-    AliMUONTrack muonTrack;
-    AliMUONESDInterface::ESDToMUON(*esdTrack, muonTrack, kFALSE);
-    
-    // try to match the reconstructed track with a simulated one
-    Int_t nMatchClusters = 0;
-    AliMUONTrack* matchedTrackRef = rc.FindCompatibleTrack(muonTrack, *trackRefStore, nMatchClusters, kFALSE, fgkSigmaCut);
-    
-    // set the MC label
-    if (matchedTrackRef) esdTrack->SetLabel(matchedTrackRef->GetUniqueID());
-    else esdTrack->SetLabel(-1);
+    // tracker tracks
+    if (esdTrack->ContainTrackerData()) {
+      
+      // convert ESD track to MUON track (without recomputing track parameters at each clusters)
+      AliMUONTrack muonTrack;
+      AliMUONESDInterface::ESDToMUON(*esdTrack, muonTrack, kFALSE);
+      
+      // try to match the reconstructed track with a simulated one
+      Int_t nMatchClusters = 0;
+      AliMUONTrack* matchedTrackRef = rc.FindCompatibleTrack(muonTrack, *trackRefStore, nMatchClusters, kFALSE, fSigmaCut);
+      
+      // set the MC label
+      if (matchedTrackRef) esdTrack->SetLabel(matchedTrackRef->GetUniqueID());
+      else esdTrack->SetLabel(-1);
+      
+    } else { // ghosts
+      
+      // Convert ESD track to trigger track
+      AliMUONLocalTrigger locTrg;
+      AliMUONESDInterface::ESDToMUON(*esdTrack, locTrg);
+      AliMUONTriggerTrack trigTrack;
+      rc.TriggerToTrack(locTrg, trigTrack);
+      
+      // try to match the reconstructed track with a simulated one
+      AliMUONTriggerTrack* matchedTrigTrackRef = rc.FindCompatibleTrack(trigTrack, *triggerTrackRefStore, fSigmaCutTrig);
+      
+      // set the MC label
+      if (matchedTrigTrackRef) esdTrack->SetLabel(matchedTrigTrackRef->GetUniqueID());
+      else esdTrack->SetLabel(-1);
+      
+    }
     
   }
   
@@ -137,8 +181,7 @@ void AliAnalysisTaskESDMCLabelAddition::AddMCLabel()
 //----------------------------------------------------------------------
 void AliAnalysisTaskESDMCLabelAddition::Terminate(Option_t */*option*/)
 {
-  // Terminate analysis
-  //
+  /// Terminate analysis
   AliDebug(2, "Terminate()");
 }
 
index 9887b25d7e6eb1f42f4b6d9a42b5e0e9e5eccde8..64dc4d5d8a5e8805a137051cb39eaee4eec6b6bc 100644 (file)
@@ -6,44 +6,39 @@
 
 /* $Id$ */ 
 
-#include <TList.h> 
+#include <TString.h>
 #include "AliAnalysisTaskSE.h"
 
-class AliAnalysisFilter;
-class AliStack;
-class AliESDMuonTrack;
-class AliMUONTrack;
-class AliMUONVTrackStore;
-
 class AliAnalysisTaskESDMCLabelAddition : public AliAnalysisTaskSE
 {
   
-  public:
-    AliAnalysisTaskESDMCLabelAddition();
-    AliAnalysisTaskESDMCLabelAddition(const char* name);
-    virtual ~AliAnalysisTaskESDMCLabelAddition() {;}
-    // Implementation of interface methods
-    virtual void UserCreateOutputObjects();
-    virtual void Init();
-    virtual void LocalInit() {Init();}
-    virtual void UserExec(Option_t *option);
-    virtual void Terminate(Option_t *option);
-    
-    
-  private:
-    
-    static const Double_t fgkSigmaCut; // sigma cut applied to match a reconstructed cluster with a trackref
-    
-    AliAnalysisTaskESDMCLabelAddition(const AliAnalysisTaskESDMCLabelAddition&);
-    AliAnalysisTaskESDMCLabelAddition& operator=(const AliAnalysisTaskESDMCLabelAddition&);
-    
-    void AddMCLabel();
-    AliMUONTrack* ESDToMUON(AliESDMuonTrack &esdTrack);
-    AliMUONTrack* MatchWithTrackRef(AliESDMuonTrack &esdTrack, AliMUONVTrackStore &trackRefStore);
-    Bool_t TrackMatched(AliMUONTrack &track, AliMUONTrack &trackRef);
-    
-    ClassDef(AliAnalysisTaskESDMCLabelAddition, 1); // Analysis task for standard ESD filtering
-    
+public:
+  AliAnalysisTaskESDMCLabelAddition();
+  AliAnalysisTaskESDMCLabelAddition(const char* name);
+  virtual ~AliAnalysisTaskESDMCLabelAddition() {;}
+  
+  // Implementation of interface methods
+  virtual void UserCreateOutputObjects();
+  virtual void NotifyRun();
+  virtual void UserExec(Option_t *option);
+  virtual void Terminate(Option_t *option);
+  
+  /// Set location of the default OCDB storage (if not set use "raw://")
+  void SetDefaultStorage(const char* ocdbPath) { fDefaultStorage = ocdbPath; }
+  
+  
+private:
+  
+  AliAnalysisTaskESDMCLabelAddition(const AliAnalysisTaskESDMCLabelAddition&);
+  AliAnalysisTaskESDMCLabelAddition& operator=(const AliAnalysisTaskESDMCLabelAddition&);
+  
+  TString  fDefaultStorage; ///< location of the default OCDB storage
+  Double_t fSigmaCut;       //!< sigma cut to associate clusters with TrackRefs
+  Double_t fSigmaCutTrig;   //!< sigma cut to associate trigger track to triggerable track
+  
+  ClassDef(AliAnalysisTaskESDMCLabelAddition, 2); // Analysis task for standard ESD filtering
+  
 };
 
 #endif
+