1 enum analysisModes {mLocal,mLocalPAR,mPROOF,mGrid,mGridPAR};
2 enum analysisTypes {mESD,mAOD,mMC,mMCESD};
6 class AliAnalysisTaskBF;
9 //________________________________________________________________________//
10 void runBalanceFunctionInpp(Int_t mode = mLocal,
12 Bool_t DATA = kFALSE) {
18 if((mode < 0) || (mode > 4)) {
19 Printf("Analysis mode not recognized!");
20 Printf("You can select out of 0: local, 1: local with par files, 2: proof, 3: grid, 4: grid with par files");
25 if((type < 0) || (type > 3)) {
26 Printf("Analysis type not recognized!");
27 Printf("You can select out of 0: ESD, 1: AOD, 2: MC (stack), 3: MC (from the ESD)");
31 // Load needed libraries:
34 // Create and configure the AliEn plug-in:
35 if(mode == mGrid || mode == mGridPAR) {
36 gROOT->LoadMacro("CreateAlienHandler.C");
37 AliAnalysisGrid *alienHandler = CreateAlienHandler(runListFileName);
38 if (!alienHandler) return;
41 if(mode == mLocal || mode == mLocalPAR) {
43 if((type == mESD)||(type == mMCESD))
44 chain = new TChain("esdTree");
46 chain = new TChain("aodTree");
48 chain = new TChain("TE");
51 for(Int_t i = 1; i < 20; i++) {
52 filename = "/data/alice2/pchrist/pp/LHC10c/0.9TeV/Data/";
53 filename += "Set"; filename += i;
54 if((type == mESD)||(type == mMCESD))
55 filename += "/AliESDs.root";
57 filename += "/AliAOD.root";
59 filename += "/galice.root";
61 chain->Add(filename.Data());
66 gROOT->ProcessLine(Form(".include %s/include", gSystem->ExpandPathName("$ALICE_ROOT")));
70 AliAnalysisManager* mgr = new AliAnalysisManager("balanceFunctionManager");
71 if(mode == mGrid || mode == mGridPAR)
72 mgr->SetGridHandler(alienHandler);
74 // input handler (ESD or AOD)
75 AliVEventHandler* inputH = NULL;
76 if((type == mESD)||(type == mMCESD))
77 inputH = new AliESDInputHandler();
79 inputH = new AliAODInputHandler();
80 mgr->SetInputEventHandler(inputH);
83 if((type == mMC) || (type == mMCESD)) {
84 AliMCEventHandler* mchandler = new AliMCEventHandler();
85 // Not reading track references
86 mchandler->SetReadTR(kFALSE);
87 mgr->SetMCtruthEventHandler(mchandler);
91 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
92 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection();
95 //Add the BF task (all centralities)
96 gROOT->LoadMacro("AddTaskBalanceFunctionInpp.C");
97 AddTaskBalanceFunctionInpp();
99 // enable debug printouts
100 mgr->SetDebugLevel(2);
101 mgr->SetUseProgressBar(1,100);
102 if (!mgr->InitAnalysis()) return;
106 if(mode == mLocal || mode == mLocalPAR)
107 mgr->StartAnalysis("local",chain);
108 else if(mode == mPROOF)
109 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
110 else if(mode == mGrid || mode == mGridPAR)
111 mgr->StartAnalysis("grid");
113 // Print real and CPU time used for analysis:
118 //=============================================================//
119 void LoadLibraries(const analysisModes mode) {
120 //--------------------------------------
121 // Load the needed libraries most of them already loaded by aliroot
122 //--------------------------------------
123 gSystem->Load("libCore");
124 gSystem->Load("libGeom");
125 gSystem->Load("libVMC");
126 gSystem->Load("libPhysics");
127 gSystem->Load("libTree");
129 //----------------------------------------------------------
130 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
131 //----------------------------------------------------------
132 if (mode==mLocal || mode==mGrid || mode == mGridPAR) {
133 //--------------------------------------------------------
134 // If you want to use already compiled libraries
135 // in the aliroot distribution
136 //--------------------------------------------------------
137 gSystem->Load("libSTEERBase");
138 gSystem->Load("libESD");
139 gSystem->Load("libAOD");
140 gSystem->Load("libANALYSIS");
141 gSystem->Load("libANALYSISalice");
142 gSystem->Load("libEventMixing");
143 gSystem->Load("libPWGCFebye");
144 // Use AliRoot includes to compile our task
145 gROOT->ProcessLine(".include $ALICE_ROOT/include");
148 else if (mode == mLocalPAR) {
149 //--------------------------------------------------------
150 //If you want to use root and par files from aliroot
151 //--------------------------------------------------------
152 SetupPar("STEERBase");
155 SetupPar("ANALYSIS");
156 SetupPar("ANALYSISalice");
157 SetupPar("PWGCFebye");
160 //---------------------------------------------------------
161 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
162 //---------------------------------------------------------
163 else if (mode==mPROOF) {
165 printf("*** Connect to PROOF ***\n");
166 gEnv->SetValue("XSec.GSI.DelegProxy","2");
167 // Put appropriate username here
168 TProof::Open("alice-caf.cern.ch");
169 //TProof::Open("skaf.saske.sk");
170 //TProof::Open("prf000-iep-grid.saske.sk");
172 gProof->EnablePackage("VO_ALICE@AliRoot::v4-21-12-AN");
175 } // end of void LoadLibraries(const anaModes mode)
177 //======================================================================//
178 void SetupPar(char* pararchivename) {
179 //Load par files, create analysis libraries
180 //For testing, if par file already decompressed and modified
181 //classes then do not decompress.
183 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
184 TString parpar(Form("%s.par", pararchivename)) ;
185 if ( gSystem->AccessPathName(parpar.Data()) ) {
186 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
187 TString processline(Form(".! make %s", parpar.Data())) ;
188 gROOT->ProcessLine(processline.Data()) ;
189 gSystem->ChangeDirectory(cdir) ;
190 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
191 gROOT->ProcessLine(processline.Data()) ;
193 if ( gSystem->AccessPathName(pararchivename) ) {
194 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
195 gROOT->ProcessLine(processline.Data());
198 TString ocwd = gSystem->WorkingDirectory();
199 gSystem->ChangeDirectory(pararchivename);
201 // check for BUILD.sh and execute
202 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
203 printf("*******************************\n");
204 printf("*** Building PAR archive ***\n");
205 cout<<pararchivename<<endl;
206 printf("*******************************\n");
207 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
208 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
212 // check for SETUP.C and execute
213 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
214 printf("*******************************\n");
215 printf("*** Setup PAR archive ***\n");
216 cout<<pararchivename<<endl;
217 printf("*******************************\n");
218 gROOT->Macro("PROOF-INF/SETUP.C");
221 gSystem->ChangeDirectory(ocwd.Data());
222 printf("Current dir: %s\n", ocwd.Data());
224 } // end of void SetupPar(char* pararchivename)