* Example macro to run locally an analysis task for comparing the offline
* with the HLT esd tree.
*
- * The output is a root file containing the histograms defined in the
- * analysis task. There is one output file per detector.
+ * The output is a root file containing the objects defined in the
+ * analysis task. These could be histograms or THnSparse objects.
+ * There is one output file per task containing a TList of TH1 or THnSparse objects.
*
- * Usage:
- * <pre>
- * aliroot -b -q -l compare_HLT_offline_local.C'("phos")' 2>&1 | tee task.log
- * aliroot -b -q -l compare_HLT_offline_local.C'("phos tpc")' 2>&1 | tee task.log
- * aliroot -b -q -l compare_HLT_offline_local.C 2>&1 | tee task.log
- * </pre>
+ * Run without arguments to get a few examples how to use the macro
+ * and which tasks are available in svn.
+ *
+ * The arguments are:
+ * - the input file or txt file containing a list of ESDs to be processed (CreateESDChain takes 20 files as a default argument)
+ * - the task you want to use
+ * - the path of the task location
+ * - the beam type, "p-p" or "Pb-Pb", this is relevant for the central barrel and global tasks at the moment and is
+ * used to select proper binning and axes ranges for the THnSparse/TH1 objects that it fills
+ * - options to make the central barrel task more flexible and lightweight; you can select if you want to
+ * fill the THnSparse object with only event or track properties or only HLT data or only OFF
+ * possible options are: event-off event-hlt track-off track-hlt, all are turned on by default
+ * - boolean variable for selecting events which contain an HLT trigger
+ * - number of events to be analyzed
*
- * If no argument is specified, ALL detector tasks are run.
+ * If alien:// is placed before the input filename, then the macro connects to the grid to access the file.
+ *
+ * In case you want to run over many ESD files, then prepare a list of them in a .txt file and they will be chained for the analysis.
+ * The .txt file takes the place of the first argument in that case. The chain can take up to 200 files at the moment. The user
+ * can modify this in the call CreateESDChain(file.Data(),200);
*
- * @ingroup alihlt_tpc
- * @author zbyin@mail.ccnu.edu.cn, Kalliopi.Kanaki@ift.uib.no
+ * If the files are not sitting locally but on the GRID, then their location should be designated like:
+ * alien:///alice/data/2011/LHC11a/000146018/ESDs/pass1/11000146018023.20/AliESDs.root in the *txt file.
+ * The macro takes care of connecting to the GRID, as soon as the first file is found that begins with alien://
+ *
+ * @ingroup alihlt_qa
+ * @author Kalliopi.Kanaki@ift.uib.no, Hege.Erdal@student.uib.no
*/
-void compare_HLT_offline_local(const char* detectorTask="all"){
-
+void compare_HLT_offline_local( TString file
+ ,const char* detectorTask="global"
+ ,TString taskFolder="$ALICE_ROOT/HLT/QA/tasks/"
+ ,TString beamType="p-p"
+ ,TString options="event-off event-hlt track-off track-hlt"
+ ,bool fUseHLTTrigger=kFALSE
+ ,Long64_t nEvents=1234567890
+ )
+{
+
TStopwatch timer;
timer.Start();
- gSystem->Load("libTree.so");
- gSystem->Load("libGeom.so");
- gSystem->Load("libVMC.so");
- gSystem->Load("libPhysics.so");
+ gSystem->Load("libTree");
+ gSystem->Load("libGeom");
+ gSystem->Load("libVMC");
+ gSystem->Load("libPhysics");
//----------- Loading the required libraries ---------//
- gSystem->Load("libSTEERBase.so");
- gSystem->Load("libESD.so");
- gSystem->Load("libAOD.so");
- gSystem->Load("libANALYSIS.so");
- gSystem->Load("libANALYSISalice.so");
- gSystem->Load("libHLTbase.so");
- gROOT->ProcessLine(".include $ALICE_ROOT/include");
-
+ gSystem->Load("libSTEERBase");
+ gSystem->Load("libESD");
+ gSystem->Load("libAOD");
+ gSystem->Load("libANALYSIS");
+ gSystem->Load("libANALYSISalice");
+ gSystem->Load("libHLTbase");
+
+ gSystem->AddIncludePath("-I$ALICE_ROOT/HLT/BASE -I$ALICE_ROOT/PWGPP/TPC -I. -I$ALICE_ROOT/STEER -I$ALICE_ROOT/ANALYSIS");
- Bool_t bAll=kFALSE, bTPC=kFALSE, bPHOS=kFALSE, bITS=kFALSE;
+ gSystem->Load("libTPCcalib");
+ gSystem->Load("libTRDbase");
+ gSystem->Load("libTRDrec");
+ gSystem->Load("libITSbase");
+ gSystem->Load("libITSrec");
+ gSystem->Load("libTender");
+ gSystem->Load("libPWGPP");
+
+ gROOT->ProcessLine(".include $ALICE_ROOT/include");
+ //gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
+
+ Bool_t bPHOS = kFALSE, bGLOBAL = kFALSE, bEMCAL = kFALSE, bPWGPP = kFALSE, bD0 = kFALSE, bCB = kFALSE;
TString allArgs = detectorTask;
TString argument;
TObjArray *pTokens = allArgs.Tokenize(" ");
if(pTokens){
- for(int i=0; i<pTokens->GetEntries(); i++){
- argument=((TObjString*)pTokens->At(i))->GetString();
- if(argument.IsNull()) continue;
+ for(int i=0; i<pTokens->GetEntries(); i++){
+ argument=((TObjString*)pTokens->At(i))->GetString();
+ if(argument.IsNull()) continue;
- if(argument.CompareTo("tpc", TString::kIgnoreCase)==0){
- bTPC = kTRUE;
- continue;
- }
-
- if(argument.CompareTo("phos", TString::kIgnoreCase)==0){
- bPHOS = kTRUE;
- continue;
- }
-
- if(argument.CompareTo("its", TString::kIgnoreCase)==0){
- bITS = kTRUE;
- continue;
- }
-
- if(argument.CompareTo("all",TString::kIgnoreCase)==0){
- bTPC = kTRUE;
- bPHOS = kTRUE;
- bITS = kTRUE;
- bAll = kTRUE;
- continue;
- }
- else break;
+ if(argument.CompareTo("phos", TString::kIgnoreCase)==0){
+ bPHOS = kTRUE;
+ continue;
+ }
+ else if(argument.CompareTo("emcal", TString::kIgnoreCase)==0){
+ bEMCAL = kTRUE;
+ continue;
+ }
+ if(argument.CompareTo("global", TString::kIgnoreCase)==0){
+ bGLOBAL = kTRUE;
+ continue;
+ }
+ if(argument.CompareTo("pwgpp", TString::kIgnoreCase)==0){
+ bPWGPP = kTRUE;
+ continue;
+ }
+ if(argument.CompareTo("D0", TString::kIgnoreCase)==0){
+ bD0 = kTRUE;
+ continue;
+ }
+ if(argument.CompareTo("cb", TString::kIgnoreCase)==0){
+ bCB = kTRUE;
+ continue;
+ }
+ else break;
}
}
-
-
+
//-------------- Compile the analysis tasks ---------- //
- if(bTPC) gROOT->LoadMacro("AliAnalysisTaskHLTTPC.cxx+");
- if(bPHOS) gROOT->LoadMacro("AliAnalysisTaskHLTPHOS.cxx+");
- if(bITS) gROOT->LoadMacro("AliAnalysisTaskHLTITS.cxx+");
-
- AliTagAnalysis *TagAna = new AliTagAnalysis("ESD");
- //TagAna->ChainLocalTags("../Tags");
-
-// AliRunTagCuts *runCuts = new AliRunTagCuts();
-// AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
-// AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
-// AliEventTagCuts *evCuts = new AliEventTagCuts();
-// evCuts->SetMultiplicityRange(11,12);
+ if(bPHOS){
+ //gSystem->Load("libHLTbase");
+ gSystem->Load("libAliHLTUtil");
+ gSystem->Load("libAliHLTGlobal");
+ TString strTask1("AliAnalysisTaskHLTCalo.cxx+");
+ TString strTask2("AliAnalysisTaskHLTPHOS.cxx+");
+ gROOT->LoadMacro(taskFolder+strTask1);
+ gROOT->LoadMacro(taskFolder+strTask2);
+ cout << "\n========= You are loading the following tasks --> "<< (taskFolder+strTask1).Chop() << " and " << (taskFolder+strTask2).Chop() << endl;
+ }
-
- TChain *chain = 0x0;
- //chain = TagAna->QueryTags(runCuts,lhcCuts,detCuts,evCuts);
- chain = new TChain("esdTree");
+ if(bEMCAL){
+ //gSystem->Load("libHLTbase");
+ gSystem->Load("libAliHLTUtil");
+ gSystem->Load("libAliHLTGlobal");
+ TString strTask1("AliAnalysisTaskHLTCalo.cxx+");
+ TString strTask2("AliAnalysisTaskHLTEMCAL.cxx+");
+ gROOT->LoadMacro(taskFolder+strTask1);
+ gROOT->LoadMacro(taskFolder+strTask2);
+ cout << "\n========= You are loading the following tasks --> "<< (taskFolder+strTask1).Chop() << " and " << (taskFolder+strTask2).Chop() << endl;
+ }
+
+ if(bGLOBAL){
+ TString strTask("AliAnalysisTaskHLT.cxx+");
+ gROOT->LoadMacro(taskFolder+strTask);
+ cout << "\n========= You are loading the following task --> "<< (taskFolder+strTask).Chop() << endl;
+ }
+ if(bD0){
+ TString strTask("AliAnalysisTaskD0Trigger.cxx+");
+ gROOT->LoadMacro(taskFolder+strTask);
+ cout << "\n========= You are loading the following task --> "<< (taskFolder+strTask).Chop() << endl;
+ }
- //gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
- //chain = CreateESDChain("esd_run84254.txt", 2);
+ if(bCB){
+ TString strTask("AliAnalysisTaskHLTCentralBarrel.cxx+");
+ gROOT->LoadMacro(taskFolder+strTask);
+ cout << "\n========= You are loading the following task --> "<< (taskFolder+strTask).Chop() << endl;
+ }
- //chain->Add("/afs/.alihlt.cern.ch/public/rec/79876/AliESDs.root");
- //chain->Add("/opt/HLT-public/rec/83683/rec/09000083683000.10/AliESDs.root");
+ if(bPWGPP) gROOT->LoadMacro("$ALICE_ROOT/HLT/QA/tasks/macros/AddTaskPerformance.C");
+
+ if(file.BeginsWith("alien://")) TGrid::Connect("alien://");
+
+ if(file.Contains("AliESDs.root")){
+ TChain *chain = new TChain("esdTree");
+ chain->Add(file);
+ }
- //chain->Add("/opt/HLT-public/rec/82762/ESDs/pass1/09000082762002.10/AliESDs.root");
- //chain->Add("/opt/HLT-public/rec/82762/ESDs/pass1/09000082762004.10/AliESDs.root");
- //chain->Add("/opt/HLT-public/rec/82762/ESDs/pass1/09000082762005.10/AliESDs.root");
- //chain->Add("/opt/HLT-public/rec/82762/ESDs/pass1/09000082762006.10/AliESDs.root");
+ // Constructs chain from filenames in *.txt
+ // in the form $DIR/AliESDs.root
+ else if(file.Contains(".txt")){
+ gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
+ chain = CreateESDChain(file.Data(),200);
+ // chain can contain up to 200 files, value can be modified to
+ // include a subset of what the *txt file contains
+
+ TObjArray *fileElements = chain->GetListOfFiles();
+ TIter next(fileElements);
+ TChainElement *chEl = 0;
+ bool alienList = kFALSE;
+ while(( chEl = (TChainElement*)next() )){
+ // loop over the list of files in the *txt and as soon as one is found that starts with alien://,
+ // the boolean alienList turns to kTRUE, which allows the TGrid::Connect call outside the loop.
+ TString tmp = chEl->GetTitle();
+ if(tmp.BeginsWith("alien://")) alienList = kTRUE;
+ }
+ if(alienList==kTRUE) TGrid::Connect("alien://");
+ }
- //chain->Add("/opt/HLT-public/rec/84254/alien/09000084254009.200/AliESDs.root");
- //chain->Add("/opt/HLT-public/rec/84254/alien/09000084254009.40/AliESDs.root");
- //chain->Add("/opt/HLT-public/rec/84254/alien/09000084254009.10/AliESDs.root");
-
- chain->Add("~/7TeV/115322/10000115322040.110/AliESDs.root");
- //chain->SetBranchStatus("*Calo*",0);
+ else if(!file){
+ printf("File %s does not exist or is corrupted.\n",file.Data());
+ return;
+ }
-
+ if(!chain){
+ Printf("Chain is empty.\n");
+ return;
+ }
+
//-------- Make the analysis manager ---------------//
AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
AliESDInputHandler *esdH = new AliESDInputHandler;
- esdH->SetReadHLT();
+
+ //For the PWGPP task, setting HLT is handled inside AliPerformanceTask.C
+ if(!bPWGPP) esdH->SetReadHLT();
+ esdH->SetReadFriends(kFALSE);
mgr->SetInputEventHandler(esdH);
mgr->SetNSysInfo(1000);
+
+ //AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(kFALSE,kTRUE);
//-------------- define the tasks ------------//
- if(bTPC){
- AliAnalysisTaskHLTTPC *taskTPC = new AliAnalysisTaskHLTTPC("offhlt_comparison_TPC");
- mgr->AddTask(taskTPC);
- AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("tpc_histograms", TList::Class(), AliAnalysisManager::kOutputContainer, "HLT-OFFLINE-TPC-comparison.root");
- mgr->ConnectInput(taskTPC,0,mgr->GetCommonInputContainer());
- //mgr->ConnectOutput (taskTPC, 0, mgr->GetCommonOutputContainer());
- mgr->ConnectOutput(taskTPC,1,coutput1);
+ if(bPHOS){
+ AliAnalysisTaskHLTPHOS *taskPHOS = new AliAnalysisTaskHLTPHOS("offhlt_comparison_PHOS");
+ taskPHOS->SetUseHLTTriggerDecision(fUseHLTTrigger);
+ if(fUseHLTTrigger==kTRUE) printf("\n\nOnly HLT triggered events will be used to fill the distributions for task %s.\n\n", taskPHOS->GetName());
+ mgr->AddTask(taskPHOS);
+ if(fUseHLTTrigger==kFALSE)
+ AliAnalysisDataContainer *coutputPHOS = mgr->CreateContainer("phos_histograms",TList::Class(), AliAnalysisManager::kOutputContainer, "HLT-OFFLINE-PHOS-comparison.root");
+ else
+ AliAnalysisDataContainer *coutputPHOS = mgr->CreateContainer("phos_histograms",TList::Class(), AliAnalysisManager::kOutputContainer, "HLT-OFFLINE-PHOS-comparison_triggered.root");
+ mgr->ConnectInput(taskPHOS,0,mgr->GetCommonInputContainer());
+ mgr->ConnectOutput(taskPHOS,1,coutputPHOS);
}
- if(bPHOS){
- AliAnalysisTaskHLTPHOS *taskPHOS = new AliAnalysisTaskHLTPHOS("offhlt_comparison_PHOS");
- mgr->AddTask(taskPHOS);
- AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("phos_histograms",TList::Class(), AliAnalysisManager::kOutputContainer, "HLT-OFFLINE-PHOS-comparison.root");
- mgr->ConnectInput(taskPHOS,0,mgr->GetCommonInputContainer());
- mgr->ConnectOutput(taskPHOS,1,coutput2);
+ if(bEMCAL){
+ AliAnalysisTaskHLTEMCAL *taskEMCAL = new AliAnalysisTaskHLTEMCAL("offhlt_comparison_EMCAL");
+ taskEMCAL->SetUseHLTTriggerDecision(fUseHLTTrigger);
+ if(fUseHLTTrigger==kTRUE) printf("\n\nOnly HLT triggered events will be used to fill the distributions for task %s.\n\n", taskEMCAL->GetName());
+ mgr->AddTask(taskEMCAL);
+ if(fUseHLTTrigger==kFALSE)
+ AliAnalysisDataContainer *coutputEMCAL = mgr->CreateContainer("emcal_histograms",TList::Class(), AliAnalysisManager::kOutputContainer, "HLT-OFFLINE-EMCAL-comparison.root");
+ else
+ AliAnalysisDataContainer *coutputEMCAL = mgr->CreateContainer("emcal_histograms",TList::Class(), AliAnalysisManager::kOutputContainer, "HLT-OFFLINE-EMCAL-comparison_triggered.root");
+ mgr->ConnectInput(taskEMCAL,0,mgr->GetCommonInputContainer());
+ mgr->ConnectOutput(taskEMCAL,1,coutputEMCAL);
+ }
+
+ if(bGLOBAL){
+ AliAnalysisTaskHLT *taskGLOBAL = new AliAnalysisTaskHLT("offhlt_comparison_GLOBAL",0.9,0.3,7,7,20); // eta, pt, DCAr, DCAz, vertexZ
+ taskGLOBAL->SetUseHLTTriggerDecision(fUseHLTTrigger);
+ taskGLOBAL->SetBeamType(beamType);
+ mgr->AddTask(taskGLOBAL);
+ if(beamType.Contains("Pb")){
+ gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
+ AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
+ taskCentrality->SetPass(1);
+ }
+ if(fUseHLTTrigger==kTRUE) printf("\n\nOnly HLT triggered events will be used to fill the distributions for task %s.\n\n", taskGLOBAL->GetName());
+ //taskGLOBAL->SelectCollisionCandidates();
+ if(fUseHLTTrigger==kFALSE)
+ AliAnalysisDataContainer *coutputGLOBAL = mgr->CreateContainer("global_histograms",TList::Class(), AliAnalysisManager::kOutputContainer, "HLT-OFFLINE-GLOBAL-comparison.root");
+ else
+ AliAnalysisDataContainer *coutputGLOBAL = mgr->CreateContainer("global_histograms",TList::Class(), AliAnalysisManager::kOutputContainer,"HLT-OFFLINE-GLOBAL-comparison_triggered.root");
+ mgr->ConnectInput(taskGLOBAL,0,mgr->GetCommonInputContainer());
+ mgr->ConnectOutput(taskGLOBAL,1,coutputGLOBAL);
+ }
+
+ if(bPWGPP){
+ Bool_t hasMC=kFALSE;
+ // -- Add Task for HLT and Offline
+ AliPerformanceTask *HLTtpcQA = AddTaskPerformance(hasMC,kFALSE,kTRUE);
+ AliPerformanceTask *tpcQA = AddTaskPerformance(hasMC,kFALSE);
+ if(!HLTtpcQA || !tpcQA) {
+ Error("RunPerformanceTrain","AliPerformanceTask not created!");
+ return;
+ }
}
+ if(bD0){
+ float cuts[7]={0.5,0.04,0.7,0.8,0.05,-0.00025,0.7};
+ AliAnalysisTaskD0Trigger *taskD0 = new AliAnalysisTaskD0Trigger("offhlt_comparison_D0",cuts);
+ mgr->AddTask(taskD0);
+ AliAnalysisDataContainer *coutputD0 = mgr->CreateContainer("D0_histograms",TList::Class(), AliAnalysisManager::kOutputContainer, "HLT-OFFLINE-D0-comparison.root");
+ mgr->ConnectInput(taskD0,0,mgr->GetCommonInputContainer());
+ mgr->ConnectOutput(taskD0,1,coutputD0);
+ }
- if(bITS){
- AliAnalysisTaskHLTITS *taskITS = new AliAnalysisTaskHLTITS("offhlt_comparison_ITS");
- mgr->AddTask(taskITS);
- AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("its_histograms",TList::Class(), AliAnalysisManager::kOutputContainer, "HLT-OFFLINE-ITS-comparison.root");
- mgr->ConnectInput(taskITS,0,mgr->GetCommonInputContainer());
- mgr->ConnectOutput(taskITS,1,coutput3);
+ if(bCB){
+ AliAnalysisTaskHLTCentralBarrel *taskCB = new AliAnalysisTaskHLTCentralBarrel("offhlt_comparison_CB");
+ mgr->AddTask(taskCB);
+ taskCB->SetBeamType(beamType);
+ if(beamType.Contains("Pb")){
+ gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
+ AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
+ taskCentrality->SetPass(1);
+ }
+ taskCB->SetOptions(options);
+ AliAnalysisDataContainer *coutputCB = mgr->CreateContainer("esd_thnsparse", TList::Class(), AliAnalysisManager::kOutputContainer, "HLT-OFFLINE-CentralBarrel-comparison.root");
+ mgr->ConnectInput(taskCB,0,mgr->GetCommonInputContainer());
+ mgr->ConnectOutput(taskCB,1,coutputCB);
}
if (!mgr->InitAnalysis()) return;
mgr->PrintStatus();
- mgr->StartAnalysis("local",chain);
+ mgr->StartAnalysis("local",chain, nEvents);
timer.Stop();
timer.Print();
}
+
+void compare_HLT_offline_local(){
+ cout << "\n The following tasks and respective plotting macros are available and maintained in $ALICE_ROOT/HLT/QA/tasks/ :\n"<< endl;
+ cout << " AliAnalysisTaskHLTCentralBarrel (macros/drawTHnSparse.C)\n AliAnalysisTaskHLT.cxx (macros/drawGlobalESDHistograms.C)" << endl;
+ cout << " AliAnalysisTaskHLTCalo (EMCAL+PHOS) (macros/drawCaloHistograms.C) \n AliAnalysisTaskD0Trigger (no plotting macro committed)\n" << endl;
+
+ cout << " Usage examples:" << endl;
+ cout << " compare-HLT-offline-local.C'(file, taskOption, taskFolder, beamType, options, fUseHLTTrigger, nEvents)' 2>&1 | tee log" << endl;
+ cout << " compare-HLT-offline-local.C'(\"AliESDs.root\",\"global\")' 2>&1 | tee log" << endl;
+ cout << " compare-HLT-offline-local.C'(\"AliESDs.root\",\"global\",\"./\", \"p-p\", \"event-off event-hlt track-off track-hlt\", kFALSE, nEvents)' 2>&1 | tee log" << endl;
+ cout << " compare-HLT-offline-local.C'(\"AliESDs.root\",\"global phos cb D0\", \"./\", \"Pb-Pb\", \"event-hlt\", kTRUE, nEvents)' 2>&1 | tee log" << endl;
+ cout << " compare-HLT-offline-local.C'(\"alien:///alice/data/2010/LHC10b/000115322/ESDs/pass1/10000115322040.20/AliESDs.root\",\"global\")' 2>&1 | tee log" << endl;
+ cout << " " << endl;
+}