Adding macros to configure an example calibration train with two tasks filtering
authorzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 4 Feb 2010 08:52:44 +0000 (08:52 +0000)
committerzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 4 Feb 2010 08:52:44 +0000 (08:52 +0000)
the friends, and one task adding a histogram to the AliESDfriends.root file.

ANALYSIS/macros/AddTaskAddObject.C [new file with mode: 0644]
ANALYSIS/macros/AddTaskCopyESD.C [new file with mode: 0644]
ANALYSIS/macros/AddTaskFilterFriend.C [new file with mode: 0644]
ANALYSIS/macros/AddTaskFilterFriendSecond.C [new file with mode: 0644]
ANALYSIS/macros/runCalibTrain.C [new file with mode: 0644]

diff --git a/ANALYSIS/macros/AddTaskAddObject.C b/ANALYSIS/macros/AddTaskAddObject.C
new file mode 100644 (file)
index 0000000..56eb5bd
--- /dev/null
@@ -0,0 +1,38 @@
+//=============================================================================
+//
+// *** AddTaskAddObject.C ***
+//
+// This macro initialize a complete AnalysisTask object for filtering ESD with AliAnalysisTaskFilterFriendSecond.
+//
+//=============================================================================
+
+AliAnalysisTaskAddObject *AddTaskAddObject()
+{
+
+       // pointer to the analysis manager
+       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+       if (!mgr) {
+               Error("AddTaskTOFCalib", "No analysis manager to connect to.");
+               return NULL;
+       }  
+
+       // check the input handler
+       if (!mgr->GetInputEventHandler()) {
+               ::Error("AddTask", "This task requires an input event handler");
+               return NULL;
+       }  
+       TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
+
+       // create the task
+       AliAnalysisTaskAddObject* add = new AliAnalysisTaskAddObject("addObj");
+       mgr->AddTask(add);
+
+       // connecting the input/output containers
+       AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();
+       AliAnalysisDataContainer *coutput0 = mgr->CreateContainer("histo",  TH1::Class(), AliAnalysisManager::kOutputContainer, "AliESDfriends_v1.root");
+
+       mgr->ConnectInput (add, 0, cinput0 );
+       mgr->ConnectOutput(add, 0, coutput0);
+
+       return add;
+}
diff --git a/ANALYSIS/macros/AddTaskCopyESD.C b/ANALYSIS/macros/AddTaskCopyESD.C
new file mode 100644 (file)
index 0000000..9ec32da
--- /dev/null
@@ -0,0 +1,38 @@
+//=============================================================================
+//
+// *** AddTaskCopyESD.C ***
+//
+// This macro initialize a complete AnalysisTask object for Copying ESD.
+//
+//=============================================================================
+
+AliAnalysisTaskCopyESD *AddTaskCopyESD()
+{
+
+       // pointer to the analysis manager
+       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+       if (!mgr) {
+               Error("AddTaskTOFCalib", "No analysis manager to connect to.");
+               return NULL;
+       }  
+
+       // check the input handler
+       if (!mgr->GetInputEventHandler()) {
+               ::Error("AddTask", "This task requires an input event handler");
+               return NULL;
+       }  
+       TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
+
+       // create the task
+       AliAnalysisTaskCopyESD *copy = new AliAnalysisTaskCopyESD("ESD copying task");
+       mgr->AddTask(copy);        
+
+       // connecting the input/output containers
+       AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();
+       AliAnalysisDataContainer *coutput0 = mgr->GetCommonOutputContainer();
+
+       mgr->ConnectInput (copy, 0, cinput0 );
+       mgr->ConnectOutput(copy, 0, coutput0);
+
+       return copy;
+}
diff --git a/ANALYSIS/macros/AddTaskFilterFriend.C b/ANALYSIS/macros/AddTaskFilterFriend.C
new file mode 100644 (file)
index 0000000..0076536
--- /dev/null
@@ -0,0 +1,38 @@
+//=============================================================================
+//
+// *** AddTaskFilterFriend.C ***
+//
+// This macro initialize a complete AnalysisTask object for filtering ESD with AliAnalysisTaskFilterFriend.
+//
+//=============================================================================
+
+AliAnalysisTaskFilterFriend *AddTaskFilterFriend()
+{
+
+       // pointer to the analysis manager
+       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+       if (!mgr) {
+               Error("AddTaskTOFCalib", "No analysis manager to connect to.");
+               return NULL;
+       }  
+
+       // check the input handler
+       if (!mgr->GetInputEventHandler()) {
+               ::Error("AddTask", "This task requires an input event handler");
+               return NULL;
+       }  
+       TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
+
+       // create the task
+       AliAnalysisTaskFilterFriend* filter = new AliAnalysisTaskFilterFriend("filter_1");
+       mgr->AddTask(filter);
+
+       // connecting the input/output containers
+       AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();
+       AliAnalysisDataContainer *coutput0 = mgr->GetCommonOutputContainer();
+
+       mgr->ConnectInput (filter, 0, cinput0 );
+       //mgr->ConnectOutput(filter, 0, coutput0);
+
+       return filter;
+}
diff --git a/ANALYSIS/macros/AddTaskFilterFriendSecond.C b/ANALYSIS/macros/AddTaskFilterFriendSecond.C
new file mode 100644 (file)
index 0000000..dc19fdf
--- /dev/null
@@ -0,0 +1,38 @@
+//=============================================================================
+//
+// *** AddTaskFilterFriendSecond.C ***
+//
+// This macro initialize a complete AnalysisTask object for filtering ESD with AliAnalysisTaskFilterFriendSecond.
+//
+//=============================================================================
+
+AliAnalysisTaskFilterFriendSecond *AddTaskFilterFriendSecond()
+{
+
+       // pointer to the analysis manager
+       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+       if (!mgr) {
+               Error("AddTaskTOFCalib", "No analysis manager to connect to.");
+               return NULL;
+       }  
+
+       // check the input handler
+       if (!mgr->GetInputEventHandler()) {
+               ::Error("AddTask", "This task requires an input event handler");
+               return NULL;
+       }  
+       TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
+
+       // create the task
+       AliAnalysisTaskFilterFriendSecond* filter = new AliAnalysisTaskFilterFriendSecond("filter_2");
+       mgr->AddTask(filter);
+
+       // connecting the input/output containers
+       AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();
+       AliAnalysisDataContainer *coutput0 = mgr->GetCommonOutputContainer();
+
+       mgr->ConnectInput (filter, 0, cinput0 );
+       //mgr->ConnectOutput(filter, 0, coutput0);
+
+       return filter;
+}
diff --git a/ANALYSIS/macros/runCalibTrain.C b/ANALYSIS/macros/runCalibTrain.C
new file mode 100644 (file)
index 0000000..6f5087e
--- /dev/null
@@ -0,0 +1,72 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include <TChain.h>
+#include <TSystem.h>
+#include "AliAnalysisManager.h"
+#include "AliESDInputHandler.h"
+#include "AliAnalysisTaskESDfilter.h"
+#include "AliAnalysisDataContainer.h"
+#endif
+
+void runCalibTrain(const char *inFileName = "AliESDs.root",
+                     const char *outFileName = "AliESDs_v1.root") 
+{
+  
+    gSystem->Load("libTree");
+    gSystem->Load("libGeom");
+    gSystem->Load("libPhysics");
+    gSystem->Load("libVMC");
+    gSystem->Load("libSTEERBase");
+    gSystem->Load("libESD");
+    gSystem->Load("libAOD");
+    
+    gSystem->Load("libANALYSIS");
+    gSystem->Load("libANALYSISalice");
+    gSystem->Load("libANALYSIScalib");
+    gSystem->Load("libCORRFW");
+    gSystem->Load("libPWG3muon");
+
+    gROOT->LoadMacro("AddTaskCopyESD.C");
+    gROOT->LoadMacro("AddTaskFilterFriend.C");
+    gROOT->LoadMacro("AddTaskFilterFriendSecond.C");
+    gROOT->LoadMacro("AddTaskAddObject.C");
+
+    AliLog::SetClassDebugLevel("AliESDEvent",19);
+    TChain *chain = new TChain("esdTree");
+    // Steering input chain
+    chain->Add(inFileName);
+    AliAnalysisManager *mgr  = new AliAnalysisManager("ESD to ESD", "Analysis Manager");
+    //mgr->SetDebugLevel(3);
+
+    // Input
+    AliESDInputHandler* inpHandler = new AliESDInputHandler();
+    inpHandler->SetActiveBranches("ESDfriend*");
+    mgr->SetInputEventHandler  (inpHandler);
+
+    // Output
+    AliESDHandler* esdHandler   = new AliESDHandler();
+    esdHandler->SetOutputFileName(outFileName);
+    mgr->SetOutputEventHandler(esdHandler);
+
+    // Tasks 
+    AliAnalysisTaskCopyESD *copy = AddTaskCopyESD();
+    
+    AliAnalysisTaskFilterFriend* filter = AddTaskFilterFriend();
+
+    AliAnalysisTaskFilterFriendSecond* filter2 = AddTaskFilterFriendSecond();
+    
+    AliAnalysisTaskAddObject* add = AddTaskAddObject();
+    
+    //
+    // Run the analysis
+    //
+    if (!mgr->InitAnalysis()) {
+           printf("Analysis cannot be started, returning\n");
+           return;
+    }
+
+    mgr->PrintStatus();
+    mgr->StartAnalysis("local", chain);
+   
+    return;
+}
+