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.
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.
10 // The output file name is defined from the config file name
11 // irrespectively of its location.
12 //=========================================================================
15 // Macro to build an analysis chain from a dataset
17 TChain* CreateChainFromDataSet
18 (TFileCollection* coll, const char* treeName, const Int_t nMaxFiles)
20 TIter iter(coll->GetList());
21 TChain* target = new TChain(treeName);
23 TFileInfo* fileInfo = 0;
24 Int_t nFilesAdded = 0;
25 while ((fileInfo = dynamic_cast<TFileInfo*> (iter())) && nFilesAdded < nMaxFiles)
27 if (fileInfo->GetFirstUrl()) {
28 target->Add(fileInfo->GetFirstUrl()->GetUrl());
33 Printf("Added %d files to chain", target->GetListOfFiles()->GetEntries());
38 // Core macro which executes analysis
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"
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(".");
56 TProof::Open("alicecaf");
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");
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());
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");
89 if (!mgr->InitAnalysis()) return;
91 mgr->StartAnalysis("proof", analysisChain);