]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/macros/AliRsnTaskProof.C
Modifications in the balance function code + addition of the very first version of...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / macros / AliRsnTaskProof.C
1 //=========================================================================
2 // This macro loops on a dataset in CAF and performs a single-step
3 // resonance analysis, which reads the ESD events (with MC if available)
4 // and saves directly the invariant mass spectra.
5 //
6 // All required configurations (reader, PID, pairs, dataSet) is defined
7 // inside a macro which must be built in the same way as 
8 // the example named "PhiExample.C" in the "macros/config" directory.
9 //
10 // The output file name is defined from the config file name
11 // irrespectively of its location.
12 //=========================================================================
13
14 //
15 // Macro to build an analysis chain from a dataset
16 //
17 TChain* CreateChainFromDataSet
18 (TFileCollection* coll, const char* treeName, const Int_t nMaxFiles)
19 {
20   TIter iter(coll->GetList());
21   TChain* target = new TChain(treeName);
22         
23   TFileInfo* fileInfo = 0;
24   Int_t nFilesAdded = 0;
25   while ((fileInfo = dynamic_cast<TFileInfo*> (iter())) && nFilesAdded < nMaxFiles)
26   {
27     if (fileInfo->GetFirstUrl()) {
28           target->Add(fileInfo->GetFirstUrl()->GetUrl());
29           nFilesAdded++;
30         }
31   }
32         
33   Printf("Added %d files to chain", target->GetListOfFiles()->GetEntries());
34   return target;
35 }
36
37 //
38 // Core macro which executes analysis
39 //
40 void AliRsnTaskProof
41 (
42   const char   *fileOut         = "rsn.root",
43   const char   *macro           = "CreateAnalysisManager.C",
44   Int_t         nFilesToProcess = 2,
45   const Char_t *dataSetName     = "/COMMON/COMMON/LHC08c11_10TeV_0.5T",
46   const Char_t *treeName        = "esdTree"
47 )
48 {
49   // path for the "CreateAnalysisManager.C" macro which creates the AnalysisManager
50   // in this case, assuming that one copies this in an area in lxplus, the path
51   // is set to the same directory
52   //TString strTaskPath(Form("%s/PWG2/RESONANCES/macros", getenv("ALICE_ROOT")));
53   TString strTaskPath(".");
54   
55   // connect to CAF
56   TProof::Open("alicecaf");
57
58   // upload packages
59   gProof->UploadPackage("STEERBase.par");
60   gProof->EnablePackage("STEERBase");
61   gProof->UploadPackage("ESD.par");
62   gProof->EnablePackage("ESD");
63   gProof->UploadPackage("AOD.par");
64   gProof->EnablePackage("AOD");
65   gProof->UploadPackage("ANALYSIS.par");
66   gProof->EnablePackage("ANALYSIS");
67   gProof->UploadPackage("ANALYSISalice.par");
68   gProof->EnablePackage("ANALYSISalice");
69   gProof->UploadPackage("PWG2resonances.par");
70   gProof->EnablePackage("PWG2resonances");
71         
72   // create chains for processing
73   TChain *analysisChain = 0;
74   TFileCollection *fc = gProof->GetDataSet(dataSetName)->GetStagedSubset();
75   if (nFilesToProcess <= 0) nFilesToProcess = 10000;
76   analysisChain = CreateChainFromDataSet(fc, treeName, nFilesToProcess);
77   Printf("Found %d entries", analysisChain->GetEntries());
78         
79   // load and execute the macro which creates the AnalysisManager
80   // this macro is expected to define a function with the standard name
81   // *** "CreateAnalysisManager()" *** [without arguments],
82   // irrespectively of the filename of the macro itself,
83   // which returns an AliAnalysisManager object
84   cout << Form("%s/%s", strTaskPath.Data(), macro) << endl;
85   gROOT->LoadMacro(Form("%s/%s", strTaskPath.Data(), macro));
86   AliAnalysisManager *mgr = CreateAnalysisManager(kTRUE);
87   if (!mgr) Error("", "no Analysis Mgr");
88         
89   if (!mgr->InitAnalysis()) return;
90   mgr->PrintStatus();
91   mgr->StartAnalysis("proof", analysisChain);
92 }