From: jotwinow Date: Wed, 14 Oct 2009 10:12:29 +0000 (+0000) Subject: new macro and small modifications X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=a62207f110b3eea976d153cc90af31699d1577b8 new macro and small modifications --- diff --git a/PWG1/macros/AddTaskPerformanceTPC.C b/PWG1/macros/AddTaskPerformanceTPC.C new file mode 100644 index 00000000000..d35ebbdc64a --- /dev/null +++ b/PWG1/macros/AddTaskPerformanceTPC.C @@ -0,0 +1,195 @@ +/////////////////////////////////////////////////////////////////////////////// +// Macro to setup AliPerformanceTask for +// TPC performance QA to run on PWG1 QA train. +// +// Input: ESDs, ESDfriends (optional), Kinematics (optional), TrackRefs (optional) +// ESD and MC input handlers must be attached to AliAnalysisManager +// to run default configuration. +// +// By default 7 performance components are added to +// the task: +// 1. AliPerformanceRes (TPC track resolution w.r.t MC at DCA) +// 2. AliPerformanceResTPCInner (TPC track resolution w.r.t MC at inner TPC wall) +// 3. AliPerformanceResTPCOuter (TPC track resolution w.r.t MC at outer TPC wall) +// 4. AliPerformanceEff (TPC track reconstruction efficiency, MC primaries) +// 5. AliPerformanceDEdxTPCInner (TPC dEdx response - track parameters at TPC inner wall) +// 6. AliPerformanceDCA (TPC impact parameters resolution at DCA) +// 7. AliPerformanceTPC (TPC cluster and track information) +// +// Usage on the analysis train (default configuration): +// gSystem->Load("libANALYSIS"); +// gSystem->Load("libANALYSISalice"); +// gSystem->Load("libTPCcalib.so"); +// gSystem->Load("libPWG1.so"); +// +// gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddTaskPerformanceTPC.C"); +// AliPerformanceTask *tpcQA = AddTaskPerformanceTPC("kTRUE","kTRUE"); +// +// Output: +// TPC.Performance.root file with TPC performance components is created. +// +// Each of the components contains THnSparse generic histograms which +// have to be analysed (post-analysis) by using Analyse() function. +// Each component contains such function. +// +//13.10.2009 - J.Otwinowski@gsi.de +/////////////////////////////////////////////////////////////////////////////// + +//____________________________________________ +AliPerformanceTask* AddTaskPerformanceTPC(Bool_t bUseMCInfo=kTRUE, Bool_t bUseESDfriend=kTRUE) +{ + // + // Add AliPerformanceTask with TPC performance components + // + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + if(!mgr) { + Error("AddTaskPerformanceTPC","AliAnalysisManager not set!"); + return NULL; + } + + TString type = mgr->GetInputEventHandler()->GetDataType(); + if (!type.Contains("ESD")) { + Error("AddTaskPerformanceTPC", "ESD input handler needed!"); + return NULL; + } + + AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler(); + if (!mcH && bUseMCInfo) { + Error("AddTaskPerformanceTPC", "MC input handler needed!"); + return NULL; + } + + // + // Create task + // + AliPerformanceTask *task = new AliPerformanceTask("Performance","TPC Performance"); + if (!task) { + Error("AddTaskPerformanceTPC", "TPC performance task cannot be created!"); + return NULL; + } + task->SetUseMCInfo(bUseMCInfo); + task->SetUseESDfriend(bUseESDfriend); + + // + // Add task to analysis manager + // + mgr->AddTask(task); + + // + // Create TPC-ESD track reconstruction cuts + // + AliRecInfoCuts *pRecInfoCuts = new AliRecInfoCuts(); + if(pRecInfoCuts) { + pRecInfoCuts->SetMaxDCAToVertexXY(3.0); + pRecInfoCuts->SetMaxDCAToVertexZ(3.0); + pRecInfoCuts->SetMinNClustersTPC(50); + pRecInfoCuts->SetMinNClustersITS(2); + pRecInfoCuts->SetHistogramsOn(kFALSE); + } + else { + Error("AddTaskPerformanceTPC", "AliRecInfoCuts cannot be created!"); + return NULL; + } + // + // Create TPC-MC track reconstruction cuts + // + AliMCInfoCuts *pMCInfoCuts = new AliMCInfoCuts(); + if(pMCInfoCuts) { + pMCInfoCuts->SetMinTrackLength(70); + } + else { + Error("AddTaskPerformanceTPC", "AliMCInfoCuts cannot be created!"); + return NULL; + } + + // + // Create performance objects for TPC and set cuts + // + enum { kTPC = 0, kTPCITS, kConstrained, kTPCInner, kTPCOuter, kTPCSec }; + + // + // Resolution + // + AliPerformanceRes *pCompRes0 = new AliPerformanceRes("AliPerformanceRes","AliPerformanceRes",kTPC,kFALSE); + if(!pCompRes0) { + Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceRes"); + } + pCompRes0->SetAliRecInfoCuts(pRecInfoCuts); + pCompRes0->SetAliMCInfoCuts(pMCInfoCuts); + + AliPerformanceRes *pCompRes3 = new AliPerformanceRes("AliPerformanceResTPCInner","AliPerformanceResTPCInner",kTPCInner,kFALSE); + if(!pCompRes3) { + Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceResTPCInner"); + } + pCompRes3->SetAliRecInfoCuts(pRecInfoCuts); + pCompRes3->SetAliMCInfoCuts(pMCInfoCuts); + + AliPerformanceRes *pCompRes4 = new AliPerformanceRes("AliPerformanceResTPCOuter","AliPerformanceResTPCOuter",kTPCOuter,kFALSE); + if(!pCompRes4) { + Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceResTPCOuter"); + } + pCompRes4->SetAliRecInfoCuts(pRecInfoCuts); + pCompRes4->SetAliMCInfoCuts(pMCInfoCuts); + + // + // Efficiency + // + AliPerformanceEff *pCompEff0 = new AliPerformanceEff("AliPerformanceEff","AliPerformanceEff",kTPC,kFALSE); + if(!pCompEff0) { + Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceEff"); + } + pCompEff0->SetAliRecInfoCuts(pRecInfoCuts); + pCompEff0->SetAliMCInfoCuts(pMCInfoCuts); + // + // dEdx + // + AliPerformanceDEdx *pCompDEdx3 = new AliPerformanceDEdx("AliPerformanceDEdxTPCInner","AliPerformanceDEdxTPCInner",kTPCInner,kFALSE); + if(!pCompDEdx3) { + Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceDEdxTPCInner"); + } + pCompDEdx3->SetAliRecInfoCuts(pRecInfoCuts); + pCompDEdx3->SetAliMCInfoCuts(pMCInfoCuts); + // + // DCA + // + AliPerformanceDCA *pCompDCA0 = new AliPerformanceDCA("AliPerformanceDCA","AliPerformanceDCA",kTPC,kFALSE); + if(!pCompDCA0) { + Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceDCA"); + } + pCompDCA0->SetAliRecInfoCuts(pRecInfoCuts); + pCompDCA0->SetAliMCInfoCuts(pMCInfoCuts); + // + // TPC performance + // + AliPerformanceTPC *pCompTPC0 = new AliPerformanceTPC("AliPerformanceTPC","AliPerformanceTPC",kTPC,kFALSE); + if(!pCompTPC0) { + Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceTPC"); + } + pCompTPC0->SetAliRecInfoCuts(pRecInfoCuts); + pCompTPC0->SetAliMCInfoCuts(pMCInfoCuts); + + // + // add components to the performance task + // + task->AddPerformanceObject( pCompRes0 ); + task->AddPerformanceObject( pCompRes3 ); + task->AddPerformanceObject( pCompRes4 ); + task->AddPerformanceObject( pCompEff0 ); + task->AddPerformanceObject( pCompDEdx3 ); + task->AddPerformanceObject( pCompDCA0 ); + task->AddPerformanceObject( pCompTPC0 ); + + // + // Create containers for input + // + AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer(); + mgr->ConnectInput(task, 0, cinput); + + // + // Create containers for output + // + AliAnalysisDataContainer *coutput = mgr->CreateContainer("coutput", TList::Class(), AliAnalysisManager::kOutputContainer, Form("TPC.%s.root", task->GetName())); + mgr->ConnectOutput(task, 0, coutput); + +return task; +} diff --git a/PWG1/macros/ProofEnableAliRoot.C b/PWG1/macros/ProofEnableAliRoot.C index 59347fdd02a..638ab018b07 100644 --- a/PWG1/macros/ProofEnableAliRoot.C +++ b/PWG1/macros/ProofEnableAliRoot.C @@ -2,14 +2,6 @@ void ProofEnableAliRoot(const char* location = "/usr/local/grid/AliRoot/v4-05-Release") { // enables a locally deployed AliRoot in a PROOF cluster - - /* executes the following commands on each node: - gSystem->Setenv("ALICE_ROOT", "/home/alicecaf/ALICE/aliroot-head") - gSystem->AddIncludePath("/home/alicecaf/ALICE/aliroot-head/include"); - gSystem->SetDynamicPath(Form("%s:%s", gSystem->GetDynamicPath(), "/home/alicecaf/ALICE/aliroot-head/lib/tgt_linux")) - gROOT->Macro("$ALICE_ROOT/macros/loadlibs.C"); - */ - gProof->Exec(Form("TString str(gSystem->ExpandPathName(\"%s\")); gSystem->Setenv(\"ALICE_ROOT\", str);", location), kTRUE); gProof->AddIncludePath(Form("%s/include", location)); diff --git a/PWG1/macros/RunPerformanceTaskMC.C b/PWG1/macros/RunPerformanceTaskMC.C index 61806aa222e..157b59343c4 100644 --- a/PWG1/macros/RunPerformanceTaskMC.C +++ b/PWG1/macros/RunPerformanceTaskMC.C @@ -6,15 +6,15 @@ // Track references are propagate in B-field and // material by using: // -// AliTracker::PropagateTrackTo() -// AliExternalTrackParam::PropagateTo() +// AliTracker::PropagateTrackToBxByBz() +// AliExternalTrackParam::PropagateToBxByBz() // // // Available test components: // -// AliPerformanceRes (propagation TPCin(ref) -> DCA(particle) by using AliTracker::PropagateTrackTo() and comparison at DCA) +// AliPerformanceRes (propagation TPCin(ref) -> DCA(particle) by using AliTracker::PropagateTrackToBxByBz() and comparison at DCA) // AliPerformanceResTCPInner (propagation TPCout(ref) -> TPCin(ref) and comparison at TPCin) -// AliPerformanceResTPCOuter (propagation TPCin(ref) -> TPCout(ref) by using AliExternalTrackParam::PropagateTo() and comparison at TPCout) +// AliPerformanceResTPCOuter (propagation TPCin(ref) -> TPCout(ref) by using AliExternalTrackParam::PropagateToBxByBz() and comparison at TPCout) // /* @@ -23,15 +23,14 @@ gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/LoadMyLibs.C"); gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C"); - TChain* chain = CreateESDChain("flatPt_uniB.txt", 100, 0); + TChain* chain = CreateESDChain("list_flatP_JB.txt", 500, 0); chain->Lookup(); // Geometry (need for the track propagation through material) - AliGeomManager::LoadGeometry("/lustre/alice/jacek/sim/HEADJB/flatPt_uniB/0/geometry.root"); + //AliGeomManager::LoadGeometry("/lustre/alice/jacek/sim/HEADJB/flatPt_uniB/0/geometry.root"); // set magnetic field - //TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 2, 1., 1., 10., AliMagF::k5kG)); - TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 2, 1., 1., 10., AliMagF::k5kGUniform)); + TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 2, 1., 1., 10., AliMagF::k5kG)); gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/RunPerformanceTaskMC.C"); RunPerformanceTaskMC(chain, kTRUE, kFALSE, kFALSE, 0); @@ -41,28 +40,25 @@ TProof::Open(""); gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/ProofEnableAliRoot.C"); - ProofEnableAliRoot("/u/jacek/alice/AliRoot/HEADJB/"); + ProofEnableAliRoot("/d/alice11/jacek/alice/x86_64/AliRoot/trunkJB"); gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C"); - TChain* chain = CreateESDChain("flatPt_uniB.txt", 100, 0); + TChain* chain = CreateESDChain("list_flatP_JB.txt", 400, 0); chain->Lookup(); - // Geometry (need for the track propagation through material) - AliGeomManager::LoadGeometry("/lustre/alice/jacek/sim/HEADJB/flatPt_uniB/0/geometry.root"); - // set magnetic field - //TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 2, 1., 1., 10., AliMagF::k5kG)); - TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 2, 1., 1., 10., AliMagF::k5kGUniform)); + // the best is to create macro MagField.C with the line: + // TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 2, 1., 1., 10., AliMagF::k5kG)); + gProof->Exec("gROOT->Macro(\"MagField.C\")"); gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/RunPerformanceTaskMC.C"); - RunPerformanceTaskMC(chain, kTRUE, kFALSE, kTRUE,0); - + RunPerformanceTaskMC(chain, kTRUE, kTRUE, kTRUE,0); //3. Run only on static PROOF at GSI e.g. TProof::Reset("jacek@lxgrid5.gsi.de"); TProofMgr * proofmgr = TProof::Mgr("jacek@lxgrid5.gsi.de"); - proofmgr->SetROOTVersion("523-04"); + //proofmgr->SetROOTVersion("523-04"); TProof * proof = proofmgr->CreateSession(); proof->SetParameter("PROOF_MaxSlavesPerNode", (Long_t)10000); @@ -70,15 +66,14 @@ ProofEnableAliRoot("/u/jacek/alice/AliRoot/HEADJB/"); gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C"); - TChain* chain = CreateESDChain("flat_JB_AB.txt", 50, 0); + TChain* chain = CreateESDChain("flat_JB.txt", 50, 0); chain->Lookup(); // Geometry (need for the track propagation through material) - AliGeomManager::LoadGeometry("/lustre/alice/local/TRDdata/SIM/P-Flat/TRUNK/test/RUN0/geometry.root"); + //AliGeomManager::LoadGeometry("/lustre/alice/local/TRDdata/SIM/P-Flat/TRUNK/test/RUN0/geometry.root"); // set magnetic field - //TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 2, 1., 1., 10., AliMagF::k5kG)); - TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 2, 1., 1., 10., AliMagF::k5kGUniform)); + gProof->Exec("gROOT->ProcessLine(\"TGeoGlobalMagField::Instance()->SetField(new AliMagF(\"Maps\",\"Maps\", 2, 1., 1., 10., AliMagF::k5kG))\")"); gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/RunPerformanceTaskMC.C"); RunPerformanceTaskMC(chain, kTRUE, kTRUE, kTRUE); @@ -100,7 +95,7 @@ */ //_____________________________________________________________________________ -void RunPerformanceTaskMC(TChain *chain, Bool_t bUseMCInfo=kTRUE, Bool_t bUseFriend=kTRUE, Bool_t bProof=kTRUE, Int_t debugStreamLevel=0) +void RunPerformanceTaskMC(TChain *chain, Bool_t bUseMCInfo=kTRUE, Bool_t bUseESDfriend=kTRUE, Bool_t bProof=kTRUE, Int_t debugStreamLevel=0) { if(!chain) { @@ -119,7 +114,7 @@ void RunPerformanceTaskMC(TChain *chain, Bool_t bUseMCInfo=kTRUE, Bool_t bUseFri pRecInfoCuts->SetMaxDCAToVertexZ(3.0); pRecInfoCuts->SetMinNClustersTPC(50); pRecInfoCuts->SetMinNClustersITS(2); - pRecInfoCuts->SetPtRange(0.1,1.e10); + pRecInfoCuts->SetPtRange(0.15,1.e10); pRecInfoCuts->SetHistogramsOn(kFALSE); } else { AliDebug(AliLog::kError, "ERROR: Cannot create AliRecInfoCuts object"); @@ -155,7 +150,7 @@ void RunPerformanceTaskMC(TChain *chain, Bool_t bUseMCInfo=kTRUE, Bool_t bUseFri } pCompMC3->SetAliRecInfoCuts(pRecInfoCuts); pCompMC3->SetAliMCInfoCuts(pMCInfoCuts); - pCompMC3->SetStreamLevel(debugStreamLevel); + //pCompMC3->SetStreamLevel(debugStreamLevel); AliPerformanceMC *pCompMC4 = new AliPerformanceMC("AliPerformanceMCTPCOuter","AliPerformanceMCTPCOuter",kTPCOuter,kFALSE); if(!pCompMC4) { @@ -163,7 +158,7 @@ void RunPerformanceTaskMC(TChain *chain, Bool_t bUseMCInfo=kTRUE, Bool_t bUseFri } pCompMC4->SetAliRecInfoCuts(pRecInfoCuts); pCompMC4->SetAliMCInfoCuts(pMCInfoCuts); - pCompMC4->SetStreamLevel(debugStreamLevel); + //pCompMC4->SetStreamLevel(debugStreamLevel); // Swtich off all AliInfo (too much output!!!) @@ -173,10 +168,10 @@ void RunPerformanceTaskMC(TChain *chain, Bool_t bUseMCInfo=kTRUE, Bool_t bUseFri AliAnalysisManager *mgr = new AliAnalysisManager; // Create task - AliPerformanceTask *task = new AliPerformanceTask("Performance","TPC Performance"); - if (bUseMCInfo) task->SetUseMCInfo(kTRUE); - if (bUseFriend) task->SetUseESDfriend(kTRUE); - //task->AddPerformanceObject( pCompMC0 ); + AliPerformanceTask *task = new AliPerformanceTask("PerformanceMC","TPC Performance"); + task->SetUseMCInfo(bUseMCInfo); + task->SetUseESDfriend(bUseESDfriend); + task->AddPerformanceObject( pCompMC0 ); task->AddPerformanceObject( pCompMC3 ); task->AddPerformanceObject( pCompMC4 ); @@ -185,13 +180,12 @@ void RunPerformanceTaskMC(TChain *chain, Bool_t bUseMCInfo=kTRUE, Bool_t bUseFri // Add ESD handler AliESDInputHandler* esdH = new AliESDInputHandler; - if(bUseFriend) esdH->SetActiveBranches("ESDfriend*"); + if(bUseESDfriend) esdH->SetActiveBranches("ESDfriend"); mgr->SetInputEventHandler(esdH); if(bUseMCInfo) { // Enable MC event handler AliMCEventHandler* handler = new AliMCEventHandler; - //handler->SetReadTR(kFALSE); handler->SetReadTR(kTRUE); mgr->SetMCtruthEventHandler(handler); } diff --git a/PWG1/macros/RunPerformanceTrain.C b/PWG1/macros/RunPerformanceTrain.C index 55deec5aac0..78c3246617d 100644 --- a/PWG1/macros/RunPerformanceTrain.C +++ b/PWG1/macros/RunPerformanceTrain.C @@ -1,220 +1,80 @@ // -// 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 -aliroot -q -b RunPerformanceTrain.C'("list_PbPb_EMCAL_small.txt","ALL",2)' - -OPTIONS: - -ALL - all TPC performance components -RES - TPC resolution components -EFF - TPC efficiency component -DEDX - TPC dedx component -DCA - TPC DCA component - -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. - -*/ - -#ifndef __CINT__ -#include - -#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 *list="esdList.txt", Int_t nFiles=20, Int_t fistFile=0, Bool_t bUseMCInfo=kTRUE, Bool_t bUseESDfriend=kTRUE) { - TMemStat *mem = 0x0; - if(MEM){ - gSystem->Load("libMemStat.so"); - gSystem->Load("libMemStatGui.so"); - mem = new TMemStat("new, gnubuildin"); - mem->AddStamp("Start"); - } - TStopwatch timer; - timer.Start(); - - // VERY GENERAL SETTINGS + // + // Swtich off all AliInfo (too much output!) + // 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 - AliCDBManager *cdbManager = AliCDBManager::Instance(); - cdbManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); - cdbManager->SetRun(0); - cdbManager->SetCacheFlag(kFALSE); - // initialize magnetic field from the GRP manager. - AliGRPManager grpMan; - grpMan.ReadGRPEntry(); - grpMan.SetMagField(); - //AliRunInfo *runInfo = grpMan.GetRunInfo(); - AliGeomManager::LoadGeometry(); - - // 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); + // + // Create analysis manager + // + AliAnalysisManager *mgr = new AliAnalysisManager; + if(!mgr) { + Error("RunPerformanceTrain","AliAnalysisManager not set!"); + return; } - 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; + // + // Set ESD input handler + // + AliESDInputHandler* esdH = new AliESDInputHandler; + if(!esdH) { + Error("RunPerformanceTrain","AliESDInputHandler not created!"); + 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()); + if(bUseESDfriend) esdH->SetActiveBranches("ESDfriend"); + mgr->SetInputEventHandler(esdH); + + // + // Set MC input handler + // + if(bUseMCInfo) { + AliMCEventHandler* mcH = new AliMCEventHandler; + if(!esdH) { + Error("RunPerformanceTrain","AliMCEventHandler not created!"); + return; + } + mcH->SetReadTR(kTRUE); + mgr->SetMCtruthEventHandler(mcH); } - - in.close(); - - return chain; -} - -//____________________________________________ -TChain* MakeChainXML(const char* xmlfile) -{ - if (!TFile::Open(xmlfile)) { - Error("MakeChainXML", Form("No file %s was found", xmlfile)); - return 0x0; + // + // Add task to AliAnalysisManager + // + gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddTaskPerformanceTPC.C"); + AliPerformanceTask *tpcQA = AddTaskPerformanceTPC(bUseMCInfo,bUseESDfriend); + if(!tpcQA) { + Error("RunPerformanceTrain","TaskPerformanceTPC not created!"); + return; } - if(gSystem->Load("libNetx.so")<0) return 0x0; - if(gSystem->Load("libRAliEn.so")<0) return 0x0; - TGrid::Connect("alien://") ; + // + // Disable debug printouts + // + mgr->SetDebugLevel(0); - TGridCollection *collection = (TGridCollection*) TAlienCollection::Open(xmlfile); - if (!collection) { - Error("MakeChainXML", Form("No collection found in %s", xmlfile)) ; - return 0x0; - } - //collection->CheckIfOnline(); + if (!mgr->InitAnalysis()) + return; - TGridResult* result = collection->GetGridResult("",0 ,0); - if(!result->GetEntries()){ - Error("MakeChainXML", Form("No entries found in %s", xmlfile)) ; - return 0x0; - } - // Makes the ESD chain - TChain* chain = new TChain("esdTree"); - for (Int_t idx = 0; idx < result->GetEntries(); idx++) { - chain->Add(result->GetKey(idx, "turl")); - } - return chain; + mgr->PrintStatus(); + mgr->StartAnalysis("local",chain); } +