//
-// Performance train to run expert QA.
-// At the moment TPC expert QA task is added
-// to the train.
+// Macro to run performance QA train
+// locally. The TPC performance task is attached.
+//
//
-// Usage:
+//13.10.2009 - J.Otwinowski@gsi.de
+//
+//
+
/*
+Quick Start:
-aliroot -q -b RunPerformanceTrain.C'("list_PbPb_EMCAL_small.txt","ALL",2)'
+1. Start train macro (real data from GSI::SE). Source your own Alien environment.
-OPTIONS:
+source /u/jacek/alien/set_alien_env.sh
+aliroot -b -q 'RunPerformanceTrain.C("AliESDs.root",2,kFALSE,kTRUE,kTRUE)'
-ALL - all TPC performance components
-RES - TPC resolution components
-EFF - TPC efficiency component
-DEDX - TPC dedx component
-DCA - TPC DCA component
+3. Start train macro (real data from lustre)
-It is recommended to fill all components while runing
-over small statistsics (10^5 pp @ 10 TeV) and selected one if one runs over
-big statistsics (10^6 pp @ 10 TeV) due to size of output files.
+aliroot -b -q 'RunPerformanceTrain.C("AliESDs.root",2,kFALSE,kTRUE,kFALSE)'
*/
-#ifndef __CINT__
-#include <Riostream.h>
-
-#include "TStopwatch.h"
-#include "TMemStat.h"
-#include "TMemStatViewerGUI.h"
-
-#include "TROOT.h"
-#include "TClass.h"
-#include "TSystem.h"
-#include "TError.h"
-#include "TChain.h"
-#include "TGrid.h"
-#include "TAlienCollection.h"
-#include "TGridCollection.h"
-#include "TGridResult.h"
-#include "TGeoGlobalMagField.h"
-
-#include "AliMagF.h"
-#include "AliTracker.h"
-#include "AliLog.h"
-#include "AliCDBManager.h"
-#include "AliGRPManager.h"
-#include "AliGeomManager.h"
-#include "AliAnalysisManager.h"
-#include "AliAnalysisDataContainer.h"
-#include "AliMCEventHandler.h"
-#include "AliESDInputHandler.h"
-
-#include "PWG1/macros/AddPerformanceTask.C"
-#endif
-
-#include "AddPerformanceTask.h"
-
-Bool_t MEM = kFALSE;
-Bool_t fHasMCdata = kTRUE;
-Bool_t fHasFriends = kTRUE;
-
-TChain* MakeChainLST(const char* filename = 0x0);
-TChain* MakeChainXML(const char* filename = 0x0);
-void RunPerformanceTrain(const Char_t *files=0x0, const Char_t *tpc="ALL", Long64_t nev=1234567890, Long64_t first = 0)
+//_____________________________________________________________________________
+void RunPerformanceTrain(Char_t *file="esd.root", Int_t runNumber = 2, const char* triggerClass ="CINT1B-ABCE-NOPF-ALL", Bool_t bUseMCInfo=kFALSE, Bool_t bUseESDfriend=kTRUE, Bool_t bGrid=kFALSE)
{
- TMemStat *mem = 0x0;
- if(MEM){
- gSystem->Load("libMemStat.so");
- gSystem->Load("libMemStatGui.so");
- mem = new TMemStat("new, gnubuildin");
- mem->AddStamp("Start");
+ //
+ // Grid settings
+ // use GSI::SE
+ if(bGrid) {
+ gSystem->Setenv("alien_CLOSE_SE","ALICE::GSI::SE");
+ TGrid * alien = TGrid::Connect("alien://",0,0,"t");
+ gSystem->Setenv("alien_CLOSE_SE","ALICE::GSI::SE");
}
- TStopwatch timer;
- timer.Start();
- // VERY GENERAL SETTINGS
- AliLog::SetGlobalLogLevel(AliLog::kError);
- if(gSystem->Load("libANALYSIS.so")<0) return;
- if(gSystem->Load("libANALYSISalice.so")<0) return;
-
- // INITIALIZATION OF RUNNING ENVIRONMENT
- //TODO We should use the GRP if available similar to AliReconstruction::InitGRP()!
- // initialize OCDB manager
+ //
+ // Train Configuration
+ //
+ Int_t iPWG1perfTPC = 1; // Test TPC performance
+ Int_t iPWG1perfTRD = 0; // Test TRD performance
+ Int_t iPWG1perfITS = 0; // Test ITS performance
+ Int_t iPWG1perfCalo = 0; // Test Calo performance
+ Int_t iPWG1perfMuonTrig = 0; // Test Muon Trigger performance
+ Int_t iPWG1perfMuonEff = 0; // Test Muon Efficiency performance
+ Int_t iPWG1perfTOF = 0; // Test TOF-TPC matching performance
+ Int_t iPWG1perfPrimVertex = 0; // Test Primary Vertex performance
+ Int_t iPWG1v0QA = 0; // V0 algorithm QA task
+
+ //
+ // Load Libraries
+ //
+ gSystem->Load("libANALYSIS");
+ gSystem->Load("libANALYSISalice");
+ gSystem->Load("libTENDER");
+ gSystem->Load("libCORRFW");
+
+ gSystem->Load("libTPCcalib.so");
+ gSystem->Load("libPWG1");
+
+ gSystem->Load("libPHOSUtils");
+ gSystem->Load("libEMCALUtils");
+ gSystem->Load("libPWG4PartCorrBase");
+ gSystem->Load("libPWG4PartCorrDep");
+
+ gSystem->Load("libPWG3muon.so"); // The class is here
+
+ //
+ // OCDB Configuration
+ //
AliCDBManager *cdbManager = AliCDBManager::Instance();
- cdbManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
- cdbManager->SetRun(0);
- cdbManager->SetCacheFlag(kFALSE);
+ cdbManager->SetDefaultStorage("local:///lustre/alice/alien/alice/data/2009/OCDB");
+ //cdbManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+ //cdbManager->SetSpecificStorage("GRP/GRP/Data", Form("local://%s",gSystem->pwd()));
+ cdbManager->SetRun(runNumber);
+ //cdbManager->SetCacheFlag(kFALSE);
// initialize magnetic field from the GRP manager.
+ //if(magField==0) TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 0., 0., AliMagF::k2kG));
+ //if(magField==1) TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", -1., -1., AliMagF::k2kG));
+ //if(magField==2) TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", -1., -1., AliMagF::k5kG));
+
+ /*
AliGRPManager grpMan;
grpMan.ReadGRPEntry();
grpMan.SetMagField();
- //AliRunInfo *runInfo = grpMan.GetRunInfo();
+ AliRunInfo *runInfo = grpMan.GetRunInfo();
+
+ //
+ // Load geometry
+ //
+ */
AliGeomManager::LoadGeometry();
+ //
+ // Swtich off all AliInfo (too much output!)
+ //
+ AliLog::SetGlobalLogLevel(AliLog::kError);
- // DEFINE DATA CHAIN
- TChain *chain = 0x0;
- if(!files) chain = MakeChainLST();
- else{
- TString fn(files);
- if(fn.EndsWith("xml")) chain = MakeChainXML(files);
- else chain = MakeChainLST(files);
+ //
+ // Create input ESD chain
+ //
+ /*
+ gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
+ TChain* chain = CreateESDChain(list,nFiles,fistFile);
+ if(!chain) {
+ Error("RunPerformanceTrain","ESD chain not created!");
+ return;
}
- if(!chain) return;
- chain->SetBranchStatus("*FMD*",0);
- chain->SetBranchStatus("*Calo*",0);
- chain->SetBranchStatus("Tracks", 1);
- chain->SetBranchStatus("ESDfriend*",1);
- chain->Lookup();
- chain->GetListOfFiles()->Print();
- printf("\n ----> CHAIN HAS %d ENTRIES <----\n\n", (Int_t)chain->GetEntries());
-
-
- // BUILD ANALYSIS MANAGER
- AliAnalysisManager *mgr = new AliAnalysisManager("Post Reconstruction Calibration/QA");
- AliVEventHandler *esdH = 0x0, *mcH = 0x0;
- mgr->SetInputEventHandler(esdH = new AliESDInputHandler);
- if(fHasMCdata) mgr->SetMCtruthEventHandler(mcH = new AliMCEventHandler());
- //mgr->SetDebugLevel(10);
-
-///////////////////////////////////////////////////////////
-/////////////// TPC ///////////
-///////////////////////////////////////////////////////////
- if(gSystem->Load("libPWG1.so")<0) return;
-
- // BUILD STEERING TASK FOR TPC
- if(tpc){
- //if(gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddPerformanceTask.C+")) {
- if(gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddPerformanceTask.C")) {
- Error("run.C", "Error loading AliPerformanceTask task.");
- return;
- }
- AddPerformanceTask(mgr, tpc);
+ */
+ TChain *chain = new TChain("esdTree");
+ if(!chain) {
+ Error("RunPerformanceTrain","ESD chain not created!");
+ return;
}
+ chain->Add(file);
+ chain->Lookup();
- if (!mgr->InitAnalysis()) return;
- // verbosity
- printf("\n\tRUNNING TRAIN FOR TASKS:\n");
- mgr->GetTasks()->ls();
- //mgr->PrintStatus();
-
- mgr->StartAnalysis("local", chain, nev, first);
-
- timer.Stop();
- timer.Print();
-
- TGeoGlobalMagField::Instance()->SetField(NULL);
- delete cdbManager;
-
- // verbosity
- printf("\n\tCLEANING UP TRAIN:\n");
- mgr->GetTasks()->Delete();
-
- if(mcH) delete mcH;
- delete esdH;
- delete mgr;
- delete chain;
- if(MEM) delete mem;
- if(MEM) TMemStatViewerGUI::ShowGUI();
-}
-
-//____________________________________________
-TChain* MakeChainLST(const char* filename)
-{
- // Create the chain
- TChain* chain = new TChain("esdTree");
-
- if(!filename){
- chain->Add(Form("%s/AliESDs.root", gSystem->pwd()));
- return chain;
+ //
+ // Create analysis manager
+ //
+ AliAnalysisManager *mgr = new AliAnalysisManager;
+ if(!mgr) {
+ Error("RunPerformanceTrain","AliAnalysisManager not set!");
+ return;
}
-
- // read ESD files from the input list.
- ifstream in;
- in.open(filename);
- TString esdfile;
- while(in.good()) {
- in >> esdfile;
- if (!esdfile.Contains("root")) continue; // protection
- chain->Add(esdfile.Data());
+ //
+ // Set ESD input handler
+ //
+ AliESDInputHandler* esdH = new AliESDInputHandler;
+ if(!esdH) {
+ Error("RunPerformanceTrain","AliESDInputHandler not created!");
+ return;
+ }
+ if(bUseESDfriend) esdH->SetActiveBranches("ESDfriend");
+ mgr->SetInputEventHandler(esdH);
+
+ /*
+ //
+ // Set RecPoints and ESD input handler
+ //
+ AliESDInputHandlerRP* rpH = new AliESDInputHandlerRP;
+ if(!rpH) {
+ Error("RunPerformanceTrain","AliESDInputHandlerRP not created!");
+ return;
+ }
+ if(bUseESDfriend) rpH->SetActiveBranches("ESDfriend");
+ mgr->SetInputEventHandler(rpH);
+ */
+
+ //
+ // Set MC input handler
+ //
+ if(bUseMCInfo) {
+ AliMCEventHandler* mcH = new AliMCEventHandler;
+ if(!mcH) {
+ Error("RunPerformanceTrain","AliMCEventHandler not created!");
+ return;
+ }
+ mcH->SetReadTR(kTRUE);
+ mgr->SetMCtruthEventHandler(mcH);
}
- in.close();
- return chain;
-}
+ //
+ // Add task to AliAnalysisManager
+ //
-//____________________________________________
-TChain* MakeChainXML(const char* xmlfile)
-{
- if (!TFile::Open(xmlfile)) {
- Error("MakeChainXML", Form("No file %s was found", xmlfile));
- return 0x0;
+ //
+ // TPC performance
+ //
+ if(iPWG1perfTPC) {
+ gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddTaskPerformanceTPC.C");
+ AliPerformanceTask *tpcQA = AddTaskPerformanceTPC(bUseMCInfo,bUseESDfriend,triggerClass);
+ if(!tpcQA) {
+ Error("RunPerformanceTrain","AliPerformanceTask not created!");
+ return;
+ }
+ }
+ else {
+ Printf("RunPerformanceTrain: TPC Performance - EXCLUDED!");
}
-
- if(gSystem->Load("libNetx.so")<0) return 0x0;
- if(gSystem->Load("libRAliEn.so")<0) return 0x0;
- TGrid::Connect("alien://") ;
-
- TGridCollection *collection = (TGridCollection*) TAlienCollection::Open(xmlfile);
- if (!collection) {
- Error("MakeChainXML", Form("No collection found in %s", xmlfile)) ;
- return 0x0;
+ //
+ // TRD perormance
+ //
+ if(iPWG1perfTRD) {
+ gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddTrainPerformanceTRD.C");
+ if(!AddTrainPerformanceTRD(bUseMCInfo,bUseESDfriend)) {
+ Error("RunPerformanceTrain","TrainPerformanceTRD not created!");
+ return;
+ }
+ } else {
+ Printf("RunPerformanceTrain: TRD TrainPerformanceTRD - EXCLUDED!");
}
- //collection->CheckIfOnline();
-
- TGridResult* result = collection->GetGridResult("",0 ,0);
- if(!result->GetEntries()){
- Error("MakeChainXML", Form("No entries found in %s", xmlfile)) ;
- return 0x0;
+ //
+ // ITS performance
+ //
+ if(iPWG1perfITS) {
+ gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddTaskPerformanceITS.C");
+ AliAnalysisTaskITSTrackingCheck *itsQA = AddTaskPerformanceITS(bUseMCInfo);
+ if(!itsQA) {
+ Error("RunPerformanceTrain","AliAnalysisTaskITSTrackingCheck not created!");
+ return;
+ }
+ }
+ else {
+ Printf("RunPerformanceTrain: AliAnalysisTaskITSTrackingCheck - EXCLUDED!");
+ }
+ //
+ // Calorimeter Performance
+ //
+ if(iPWG1perfCalo) {
+ gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskCalorimeterQA.C");
+ AliAnalysisTaskParticleCorrelation *taskCaloQA = AddTaskCalorimeterQA("ESD",bUseMCInfo,kFALSE);
+ if(!taskCaloQA) {
+ Error("RunPerformanceTrain","AliAnalysisTaskParticleCorrelation not created!");
+ return;
+ }
+ mgr->AddTask(taskCaloQA);
+ }
+ else {
+ Printf("RunPerformanceTrain: AliAnalysisTaskParticleCorrelation - EXCLUDED!");
+ }
+ //
+ // Muon Trigger
+ //
+ if(iPWG1perfMuonTrig) {
+ gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddTaskMTRchamberEfficiency.C");
+ AliAnalysisTaskTrigChEff *taskMuonTrig = AddTaskMTRchamberEfficiency();
+ if(!taskMuonTrig) {
+ Error("RunPerformanceTrain","AliAnalysisTaskTrigChEff not created!");
+ return;
+ }
+ mgr->AddTask(taskMuonTrig);
+ }
+ else {
+ Printf("RunPerformanceTrain: AliAnalysisTaskTrigChEff - EXCLUDED!");
}
- // Makes the ESD chain
- TChain* chain = new TChain("esdTree");
- for (Int_t idx = 0; idx < result->GetEntries(); idx++) {
- chain->Add(result->GetKey(idx, "turl"));
+ //
+ // Muon Efficiency
+ //
+ if(iPWG1perfMuonEff) {
+ gROOT->LoadMacro("$ALICE_ROOT/PWG3/muondep/AddTaskMUONTrackingEfficiency.C");
+ AliAnalysisTaskMuonTrackingEff *taskMuonTrackEff = AliAnalysisTaskMuonTrackingEff();
+ if(!taskMuonTrackEff) {
+ Error("RunPerformanceTrain","AliAnalysisTaskMuonTrackingEff not created!");
+ return;
}
- return chain;
+ mgr->AddTask(taskMuonTrackEff);
+ }
+ else {
+ Printf("RunPerformanceTrain: Muon Efficiency - EXCLUDED!");
+ }
+ //
+ // TOF performance
+ //
+ if(iPWG1perfTOF) {
+ //
+ }
+ else {
+ Printf("RunPerformanceTrain: TOF - EXCLUDED!");
+ }
+ //
+ // PWG1 Primary Vertex
+ //
+ if(iPWG1perfPrimVertex) {
+ gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddTaskVertexESD.C");
+ AliAnalysisTaskVertexESD *taskPrimVertex = AddTaskVertexESD();
+ if(!taskPrimVertex) {
+ Error("RunPerformanceTrain","AliAnalysisTaskVertexESD not created!");
+ return;
+ }
+ }
+ else {
+ Printf("RunPerformanceTrain: AliAnalysisTaskVertexESD - EXCLUDED!");
+ }
+ //
+ // PWG1 V0 QA
+ //
+ if (iPWG1v0QA) {
+ gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddTaskV0QA.C");
+ AliAnalysisTaskV0QA *taskv0QA = AddTaskV0QA(bUseMCInfo);
+ if(!taskv0QA) {
+ Error("RunPerformanceTrain","AliAnalysisTaskV0QA not created!");
+ return;
+ }
+ }
+ else {
+ Printf("RunPerformanceTrain: AliAnalysisTaskV0QA - EXCLUDED!");
+ }
+
+ //
+ // Disable debug printouts
+ //
+ mgr->SetDebugLevel(0);
+
+ if (!mgr->InitAnalysis())
+ return;
+
+ mgr->PrintStatus();
+ //mgr->StartAnalysis("local",chain, nEvents, firstEvent);
+ mgr->StartAnalysis("local",chain);
}
+