6 //const char *inputSource = "file-collections/AOD048_LHC11a10b.txt",
7 //const char *options = "aod_mc_pbpb",
8 //const char *inputSource = "file-collections/AOD049_LHC10h_pass2.txt",
9 //const char *options = "aod_data_pbpb",
10 const char *inputSource = "file-collections/ESD_LHC10d1.txt",
11 const char *options = "esd_mc",
12 //const char *inputSource = "000117112.xml",
13 //const char *options = "esd_data",
14 //const char *inputSource = "aod_test.xml",
15 //const char *options = "aod_data",
16 //const char *inputSource = "LHC11a10a_bis_test.xml",
17 //const char *options = "esd_mc_pbpb",
18 const char *outName = "test.root",
19 const char *macroPath = ".",
20 const char *setupName = "AnalysisSetupRsnMini.C"
24 // === PREPARATION ==============================================================================
27 //AliLog::SetClassDebugLevel("AliRsnMiniOutput" , 2);
28 //AliLog::SetClassDebugLevel("AliRsnMiniAnalysisTask", 2);
29 //AliLog::SetClassDebugLevel("AliRsnCutKaonForPhi2010", 2);
31 // execute the general setup from the apposite macro
32 // it returns also a TString value with the input tree name
33 gROOT->LoadMacro(setupName);
34 TString out = Setup(nmix, options, outName, macroPath);
35 cout << "OUT = " << out.Data() << endl;
36 if (out.Length() < 1) return;
39 // === BUILD INPUT LIST =========================================================================
42 // check extension of input to distinguish between XML and TXT
43 TString sInput(inputSource);
45 Bool_t isTXT = (!strcmp(sInput(sInput.Length() - 3, 3).Data(), "txt"));
46 cout << "Input = " << (isTXT ? "TXT" : "XML") << endl;
48 // if input is XML, connect to AliEn
49 if (!isTXT) TGrid::Connect("alien://");
51 // create TChain of input events
52 TChain *analysisChain = 0x0;
53 if (isTXT) analysisChain = CreateChainFromText(inputSource, out.Data(), nReadFiles, nSkipFiles);
54 else analysisChain = CreateChainFromXML (inputSource, out.Data(), nReadFiles, nSkipFiles);
56 Error("runLocal", "Analysis chain not properly initialized");
61 // === ANALYSIS TASK CREATION AND INCLUSION =====================================================
64 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
67 // initialize and start analysis
68 if (!mgr->InitAnalysis()) {
69 ::Error("runLocal.C", "Failed to init analysis");
73 if (isTXT) mgr->StartAnalysis("local", analysisChain);
74 else mgr->StartAnalysis("alien", analysisChain);
77 //_________________________________________________________________________________________________
78 TChain* CreateChainFromXML
79 (const char *xmlFileName, const char *treeName, Int_t nread, Int_t nskip)
82 // Create a TChain with all required files listed into an XML collection.
83 // Necessary to run analysis in AliEn jobs.
86 // - xmlFileName = input list
87 // - treeName = "esdTree" or "aodTree"
88 // - nread = how many files to read (0 = all)
89 // - nskip = how many files to skip from beginning
92 // if nread argument is 0, it is disabled
93 if (nread == 0) nread = 1000000000;
95 // initialize output object
96 TChain *chain = new TChain(treeName);
98 // initialize the AliEn collection
99 TAlienCollection *myCollection = TAlienCollection::Open(xmlFileName);
101 Error("CreateChainFromXML", "Cannot create an AliEn collection from %s", xmlFileName);
105 // loop on collection
106 myCollection->Reset();
107 while (myCollection->Next()) {
108 // skip until reached required number of offset
109 if (nskip > 0) {--nskip; continue;}
111 // stop if required number of read files is reached
112 // otherwise update the counter
113 if (nread <= 0) break;
116 // recovery file and add it
117 Info("CreateChainFromXML", Form("Adding: %s", myCollection->GetTURL("")));
118 chain->Add(myCollection->GetTURL(""));
124 //__________________________________________________________________________________________________
125 TChain* CreateChainFromText(const char *fileName, const char *treeName, Int_t nread, Int_t nskip)
128 // Create a TChain with all required files listed into a text file.
129 // Necessary to run analysis in local jobs.
132 // - xmlFileName = input file list
133 // - treeName = "esdTree" or "aodTree"
134 // - nread = how many files to read (0 = all)
135 // - nskip = how many files to skip from beginning
138 // if third argument is 0, it is interpreted
139 // as "read all lines"
140 Bool_t readAll = (nread <= 0);
142 // initialize output object
143 TChain* target = new TChain(treeName);
146 ifstream fileIn(fileName);
148 // loop on collection
150 while (fileIn.good()) {
152 if (line.IsNull()) continue;
154 // skip until reached required number of offset
155 if (nskip > 0) {--nskip; continue;}
157 // stop if required number of read files is reached
158 // otherwise update the counter
159 if (!readAll && nread <= 0) break;
163 Info("CreateChainFromText", "Adding '%s'", line.Data());
164 target->Add(line.Data());