Extacting the OCDB in a separate module. The detectors have write permission in the...
[u/mrichter/AliRoot.git] / FMD / analysis / RunAliEnFMDAnalysis.C
1 void RunAliEnFMDAnalysis(const Char_t* collectionfile = "collection.xml",
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   
13   AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
14   pars->Init();
15   if (AliGeomManager::GetGeometry() == NULL)
16     AliGeomManager::LoadGeometry();
17   AliFMDGeometry* geo = AliFMDGeometry::Instance();
18   geo->Init();
19   geo->InitTransformations();
20   
21   cout<<"Creating task for analysis"<<endl;
22   AliFMDAnalysisTaskESDReader *FMDana0 = new AliFMDAnalysisTaskESDReader("reader");
23   FMDana0->SetDebugLevel(10);
24   AliFMDAnalysisTaskSharing *FMDana1 = new AliFMDAnalysisTaskSharing("sharing");
25   AliFMDAnalysisTaskDensity *FMDana2 = new AliFMDAnalysisTaskDensity("density");
26   AliFMDAnalysisTaskBackgroundCorrection *FMDana3 = new AliFMDAnalysisTaskBackgroundCorrection("background");
27   AliFMDAnalysisTaskDndeta *FMDana4 = new AliFMDAnalysisTaskDndeta("dNdeta");
28   
29   cout<<"Creating the manager"<<endl;
30   AliAnalysisManager* mgr = new AliAnalysisManager("fmd_analysis","fmd_analysis");
31   mgr->AddTask(FMDana0); 
32   mgr->AddTask(FMDana1); 
33   mgr->AddTask(FMDana2);
34   mgr->AddTask(FMDana3);
35   mgr->AddTask(FMDana4);
36   
37   
38   AliAnalysisDataContainer* cin_esd = mgr->CreateContainer("esdTree",TTree::Class(),AliAnalysisManager::kInputContainer,"AliESDs.root");
39   AliAnalysisDataContainer* cexchangevertex = mgr->CreateContainer("esdvertex",AliESDVertex::Class(),AliAnalysisManager::kExchangeContainer);
40   AliAnalysisDataContainer* cexchange0 = mgr->CreateContainer("exchangeESDFMD0",AliESDEvent::Class(),AliAnalysisManager::kExchangeContainer);
41   AliAnalysisDataContainer* cdiag1 = mgr->CreateContainer("diagSharing1",AliESDEvent::Class(),AliAnalysisManager::kExchangeContainer);
42   AliAnalysisDataContainer* cdiag2 = mgr->CreateContainer("diagSharing2",TList::Class(),AliAnalysisManager::kOutputContainer,"edists.root");
43   AliAnalysisDataContainer* cexchange1 = mgr->CreateContainer("exchangeESDFMD1",AliESDFMD::Class(),AliAnalysisManager::kExchangeContainer);
44   AliAnalysisDataContainer* cexchange2 = mgr->CreateContainer("listOfhists",TList::Class(),AliAnalysisManager::kExchangeContainer);
45   AliAnalysisDataContainer* cvertex = mgr->CreateContainer("vertex",TObjString::Class(),AliAnalysisManager::kExchangeContainer);
46   AliAnalysisDataContainer* cexchange3 = mgr->CreateContainer("BackgroundCorrectedperevent",TList::Class(),AliAnalysisManager::kOutputContainer,"testOut.root");
47   AliAnalysisDataContainer* coutput = mgr->CreateContainer("BackgroundCorrected",TList::Class(),AliAnalysisManager::kOutputContainer,outFile);
48   
49   mgr->ConnectInput(FMDana0, 0 , cin_esd);   
50   mgr->ConnectOutput(FMDana0, 0 , cexchange0);
51   
52   mgr->ConnectInput(FMDana1, 0 , cexchange0);   
53
54   mgr->ConnectOutput(FMDana1, 0 , cexchange1);  
55   mgr->ConnectOutput(FMDana1, 1 , cexchangevertex);   
56   mgr->ConnectOutput(FMDana1, 2 , cdiag1);
57   mgr->ConnectOutput(FMDana1, 3 , cdiag2);
58   
59   
60   mgr->ConnectInput(FMDana2, 0 , cexchange1);   
61   mgr->ConnectInput(FMDana2, 1 , cexchangevertex);   
62   mgr->ConnectOutput(FMDana2, 0 , cexchange2);
63   
64   mgr->ConnectInput(FMDana3, 0 , cexchange2);   
65   mgr->ConnectOutput(FMDana3, 0 , cexchange3);
66   mgr->ConnectOutput(FMDana3, 1 , cvertex);
67   
68   mgr->ConnectInput(FMDana4, 0 , cexchange3);   
69   mgr->ConnectInput(FMDana4, 1 , cvertex);   
70   mgr->ConnectOutput(FMDana4, 0 , coutput);
71   
72   TGrid::Connect("alien://",0,0,"t");
73   
74   
75   TChain* chain = new TChain("esdTree","esdTree");
76   
77   TAlienCollection* coll =  TAlienCollection::Open(collectionfile);  
78   coll->Reset();
79   Int_t nFiles = 0;
80   while(coll->Next() && nFiles<2) {
81     cout<<coll->GetTURL("")<<endl;
82     TString test(coll->GetTURL(""));
83     chain->Add(coll->GetTURL(""));
84     
85     nFiles++;
86   }
87   
88   mgr->InitAnalysis();
89   mgr->PrintStatus();
90   TStopwatch timer;
91   timer.Start();
92   cout<<"Executing analysis"<<endl;
93   mgr->StartAnalysis("local",chain);
94   timer.Stop();
95   timer.Print();
96 }