1 enum analysisModes {mLocal,mLocalPAR,mPROOF,mGrid,mGridPAR};
2 enum analysisTypes {mESD,mAOD,mMC,mMCESD};
6 class AliAnalysisTaskBF;
10 Int_t binfirst = 0; //where do we start numbering bins
11 Int_t binlast = 8; //where do we stop numbering bins
12 const Int_t numberOfCentralityBins = 9;
13 Float_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile
14 Float_t impactParameterArray[numberOfCentralityBins+1] = {0.0,3.79,5.30,7.41,9.04,10.40,11.61,12.68,13.67,14.63}; // in fm (impact parametger taken from the MC header)
16 //Acceptance parameterization
17 Bool_t kUseAcceptance = kTRUE;
18 const char *acceptanceFilename = "efficiencyALICE.root";
19 TF1 *fParameterization[numberOfCentralityBins];
24 //________________________________________________________________________//
25 void runBalanceFunctionMC(Int_t mode = mLocal,
27 Bool_t DATA = kFALSE) {
33 if((mode < 0) || (mode > 4)) {
34 Printf("Analysis mode not recognized!");
35 Printf("You can select out of 0: local, 1: local with par files, 2: proof, 3: grid, 4: grid with par files");
40 if((type < 0) || (type > 3)) {
41 Printf("Analysis type not recognized!");
42 Printf("You can select out of 0: ESD, 1: AOD, 2: MC (stack), 3: MC (from the ESD)");
46 // Load needed libraries:
50 // Create and configure the AliEn plug-in:
51 if(mode == mGrid || mode == mGridPAR) {
52 gROOT->LoadMacro("CreateAlienHandler.C");
53 AliAnalysisGrid *alienHandler = CreateAlienHandler(runListFileName);
54 if (!alienHandler) return;
57 if(mode == mLocal || mode == mLocalPAR) {
59 if((type == mESD)||(type == mMCESD))
60 chain = new TChain("esdTree");
62 chain = new TChain("aodTree");
64 chain = new TChain("TE");
66 TString filename = "galice.root";
67 chain->Add(filename.Data());
72 gROOT->ProcessLine(Form(".include %s/include", gSystem->ExpandPathName("$ALICE_ROOT")));
76 AliAnalysisManager* mgr = new AliAnalysisManager("balanceFunctionManager");
77 if(mode == mGrid || mode == mGridPAR)
78 mgr->SetGridHandler(alienHandler);
80 // input handler (ESD or AOD)
81 AliVEventHandler* inputH = NULL;
82 if((type == mESD)||(type == mMCESD)||(type == mMC))
83 inputH = new AliESDInputHandler();
85 inputH = new AliAODInputHandler();
86 mgr->SetInputEventHandler(inputH);
89 if((type == mMC) || (type == mMCESD)) {
90 AliMCEventHandler* mchandler = new AliMCEventHandler();
91 // Not reading track references
92 mchandler->SetReadTR(kFALSE);
93 mgr->SetMCtruthEventHandler(mchandler);
97 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
98 AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
100 // Add physics selection task (NOT needed for AODs)
101 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
102 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(DATA);
105 //Setup the parameterization
107 TFile *gParamFile = TFile::Open(acceptanceFilename);
108 if((!gParamFile) || (!gParamFile->IsOpen())) {
109 Printf("File %s not found!!!",acceptanceFilename);
114 for(Int_t iCentrality = 0; iCentrality < numberOfCentralityBins; iCentrality++) {
115 gParamName = "gParamCentrality"; gParamName += iCentrality;
116 fParameterization[iCentrality] = dynamic_cast<TF1 *>(gParamFile->Get(gParamName.Data()));
120 //Add the BF task (all centralities)
121 gROOT->LoadMacro("AddTaskBalanceMCCentralityTrain.C");
122 for (Int_t i=binfirst; i<binlast+1; i++) {
123 Float_t lowCentralityBinEdge = centralityArray[i];
124 Float_t highCentralityBinEdge = centralityArray[i+1];
125 Printf("\nWagon for centrality bin %i: %.0f-%.0f",i,lowCentralityBinEdge,highCentralityBinEdge);
126 AddTaskBalanceMCCentralityTrain(lowCentralityBinEdge,
127 highCentralityBinEdge,
128 impactParameterArray[i],
129 impactParameterArray[i+1],
131 10.,0.3,1.5,-0.8,0.8,
132 fParameterization[i],
136 // enable debug printouts
137 mgr->SetDebugLevel(2);
138 mgr->SetUseProgressBar(1,100);
139 if (!mgr->InitAnalysis()) return;
143 if(mode == mLocal || mode == mLocalPAR)
144 mgr->StartAnalysis("local",chain);
145 else if(mode == mPROOF)
146 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
147 else if(mode == mGrid || mode == mGridPAR)
148 mgr->StartAnalysis("grid");
150 // Print real and CPU time used for analysis:
155 //=============================================================//
156 void LoadLibraries(const analysisModes mode) {
157 //--------------------------------------
158 // Load the needed libraries most of them already loaded by aliroot
159 //--------------------------------------
160 gSystem->Load("libCore.so");
161 gSystem->Load("libGeom.so");
162 gSystem->Load("libVMC.so");
163 gSystem->Load("libPhysics.so");
164 gSystem->Load("libTree.so");
166 //----------------------------------------------------------
167 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
168 //----------------------------------------------------------
169 if (mode==mLocal || mode==mGrid || mode == mGridPAR) {
170 //--------------------------------------------------------
171 // If you want to use already compiled libraries
172 // in the aliroot distribution
173 //--------------------------------------------------------
174 gSystem->Load("libSTEERBase.so");
175 gSystem->Load("libESD.so");
176 gSystem->Load("libAOD.so");
177 gSystem->Load("libANALYSIS.so");
178 gSystem->Load("libANALYSISalice.so");
179 gSystem->Load("libEventMixing.so");
180 gSystem->Load("libPWGCFebye.so");
181 // Use AliRoot includes to compile our task
182 gROOT->ProcessLine(".include $ALICE_ROOT/include");
185 else if (mode == mLocalPAR) {
186 //--------------------------------------------------------
187 //If you want to use root and par files from aliroot
188 //--------------------------------------------------------
189 SetupPar("STEERBase");
192 SetupPar("ANALYSIS");
193 SetupPar("ANALYSISalice");
194 SetupPar("PWGCFebye");
197 //---------------------------------------------------------
198 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
199 //---------------------------------------------------------
200 else if (mode==mPROOF) {
202 printf("*** Connect to PROOF ***\n");
203 gEnv->SetValue("XSec.GSI.DelegProxy","2");
204 // Put appropriate username here
205 TProof::Open("alice-caf.cern.ch");
206 //TProof::Open("skaf.saske.sk");
207 //TProof::Open("prf000-iep-grid.saske.sk");
209 gProof->EnablePackage("VO_ALICE@AliRoot::v4-21-12-AN");
212 } // end of void LoadLibraries(const anaModes mode)
214 //======================================================================//
215 void SetupPar(char* pararchivename) {
216 //Load par files, create analysis libraries
217 //For testing, if par file already decompressed and modified
218 //classes then do not decompress.
220 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
221 TString parpar(Form("%s.par", pararchivename)) ;
222 if ( gSystem->AccessPathName(parpar.Data()) ) {
223 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
224 TString processline(Form(".! make %s", parpar.Data())) ;
225 gROOT->ProcessLine(processline.Data()) ;
226 gSystem->ChangeDirectory(cdir) ;
227 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
228 gROOT->ProcessLine(processline.Data()) ;
230 if ( gSystem->AccessPathName(pararchivename) ) {
231 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
232 gROOT->ProcessLine(processline.Data());
235 TString ocwd = gSystem->WorkingDirectory();
236 gSystem->ChangeDirectory(pararchivename);
238 // check for BUILD.sh and execute
239 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
240 printf("*******************************\n");
241 printf("*** Building PAR archive ***\n");
242 cout<<pararchivename<<endl;
243 printf("*******************************\n");
244 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
245 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
249 // check for SETUP.C and execute
250 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
251 printf("*******************************\n");
252 printf("*** Setup PAR archive ***\n");
253 cout<<pararchivename<<endl;
254 printf("*******************************\n");
255 gROOT->Macro("PROOF-INF/SETUP.C");
258 gSystem->ChangeDirectory(ocwd.Data());
259 printf("Current dir: %s\n", ocwd.Data());
261 } // end of void SetupPar(char* pararchivename)