Extacting the OCDB in a separate module. The detectors have write permission in the...
[u/mrichter/AliRoot.git] / FMD / analysis / RunLocalFMDAnalysis.C
1 void RunLocalFMDAnalysis(const Char_t* filename= "AliESDs.root",
2                          const Char_t* cdbPath = "local://$ALICE_ROOT/OCDB",
3                          const Char_t* outFile = "fmd_analysis.root"){
4   
5   gSystem->Load("libANALYSIS");
6   gSystem->Load("libANALYSISalice");
7   gSystem->Load("libFMDanalysis");
8   
9   AliCDBManager* cdb = AliCDBManager::Instance();
10   cdb->SetDefaultStorage(cdbPath);
11   cdb->SetRun(0);
12   AliFMDParameters* recopars = AliFMDParameters::Instance();
13   recopars->Init();
14   AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
15   pars->Init();
16   if (AliGeomManager::GetGeometry() == NULL)
17     AliGeomManager::LoadGeometry();
18   
19   AliFMDGeometry* geo = AliFMDGeometry::Instance();
20   geo->Init();
21   geo->InitTransformations();
22   
23   cout<<"Creating task for analysis"<<endl;
24   AliFMDAnalysisTaskESDReader *FMDana0 = new AliFMDAnalysisTaskESDReader("reader");
25   FMDana0->SetDebugLevel(10);
26   AliFMDAnalysisTaskSharing *FMDana1 = new AliFMDAnalysisTaskSharing("sharing");
27   AliFMDAnalysisTaskDensity *FMDana2 = new AliFMDAnalysisTaskDensity("density");
28   AliFMDAnalysisTaskBackgroundCorrection *FMDana3 = new AliFMDAnalysisTaskBackgroundCorrection("background");
29   AliFMDAnalysisTaskDndeta *FMDana4 = new AliFMDAnalysisTaskDndeta("dNdeta");
30   
31   cout<<"Creating the manager"<<endl;
32   AliAnalysisManager* mgr = new AliAnalysisManager("fmd_analysis","fmd_analysis");
33   mgr->AddTask(FMDana0); 
34   mgr->AddTask(FMDana1); 
35   mgr->AddTask(FMDana2);
36   mgr->AddTask(FMDana3);
37   mgr->AddTask(FMDana4);
38   
39   
40   AliAnalysisDataContainer* cin_esd = mgr->CreateContainer("esdTree",TTree::Class(),AliAnalysisManager::kInputContainer,"AliESDs.root");
41   AliAnalysisDataContainer* cexchangevertex = mgr->CreateContainer("esdvertex",AliESDVertex::Class(),AliAnalysisManager::kExchangeContainer);
42   AliAnalysisDataContainer* cexchange0 = mgr->CreateContainer("exchangeESDFMD0",AliESDEvent::Class(),AliAnalysisManager::kExchangeContainer);
43   AliAnalysisDataContainer* cdiag1 = mgr->CreateContainer("diagSharing1",AliESDEvent::Class(),AliAnalysisManager::kExchangeContainer);
44   AliAnalysisDataContainer* cdiag2 = mgr->CreateContainer("diagSharing2",TList::Class(),AliAnalysisManager::kOutputContainer,"edists.root");
45   AliAnalysisDataContainer* cexchange1 = mgr->CreateContainer("exchangeESDFMD1",AliESDFMD::Class(),AliAnalysisManager::kExchangeContainer);
46   AliAnalysisDataContainer* cexchange2 = mgr->CreateContainer("list_of_hits",TList::Class(),AliAnalysisManager::kExchangeContainer);
47   AliAnalysisDataContainer* cvertex = mgr->CreateContainer("vertex",TObjString::Class(),AliAnalysisManager::kExchangeContainer);
48   AliAnalysisDataContainer* cexchange3 = mgr->CreateContainer("list_of_hits_and_mult",TList::Class(),AliAnalysisManager::kOutputContainer,"testOut.root");
49   AliAnalysisDataContainer* coutput = mgr->CreateContainer("BackgroundCorrected",TList::Class(),AliAnalysisManager::kOutputContainer,outFile);
50   
51   mgr->ConnectInput(FMDana0, 0 , cin_esd);   
52   mgr->ConnectOutput(FMDana0, 0 , cexchange0);
53   
54   mgr->ConnectInput(FMDana1, 0 , cexchange0);   
55
56   mgr->ConnectOutput(FMDana1, 0 , cexchange1);  
57   mgr->ConnectOutput(FMDana1, 1 , cexchangevertex);   
58   mgr->ConnectOutput(FMDana1, 2 , cdiag1);
59   mgr->ConnectOutput(FMDana1, 3 , cdiag2);
60   
61   
62   mgr->ConnectInput(FMDana2, 0 , cexchange1);   
63   mgr->ConnectInput(FMDana2, 1 , cexchangevertex);   
64   mgr->ConnectOutput(FMDana2, 0 , cexchange2);
65   
66   mgr->ConnectInput(FMDana3, 0 , cexchange2);   
67   mgr->ConnectOutput(FMDana3, 0 , cexchange3);
68   mgr->ConnectOutput(FMDana3, 1 , cvertex);
69   
70   mgr->ConnectInput(FMDana4, 0 , cexchange3);   
71   mgr->ConnectInput(FMDana4, 1 , cvertex);   
72   mgr->ConnectOutput(FMDana4, 0 , coutput);
73   
74  
75   TFile::Open(filename);
76   TChain* chain = (TChain*)gFile->Get("esdTree");
77
78   
79   mgr->InitAnalysis();
80   mgr->PrintStatus();
81   
82   TStopwatch timer;
83   timer.Start();
84   cout<<"Executing analysis"<<endl;
85   mgr->StartAnalysis("local",chain,1000);
86   timer.Stop();
87   timer.Print();
88 }