AliPhysics  8630145 (8630145)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anaGenKine.C
Go to the documentation of this file.
1 
11 //___________________________
13 //________________________
15 {
16  // Main
17 
18  //--------------------------------------------------------------------
19  // Load analysis libraries
20  // Look at the method below,
21  // ------------------------------------------------------------------
22 
23  LoadLibraries() ;
24  //gSystem->ListLibraries();
25 
26  TChain * chain = new TChain("TE") ;
27  TChain * chainxs = new TChain("Xsection") ;
28 
29  chain ->AddFile("galice.root");
30  chainxs->AddFile("pyxsec.root");
31 
32 
33  Double_t scale = -1;
34  if(chainxs && chainxs->GetEntries() > 0)
35  {
36  Int_t nfiles = chainxs->GetEntries();
37 
38  //Get the cross section
39  Double_t xsection = 0;
40  Float_t ntrials = 0;
41 
42  GetAverageXsection(chainxs, xsection, ntrials);
43 
44  Int_t nEventsPerFile = chain->GetEntries() / nfiles;
45 
46  Double_t trials = ntrials / nEventsPerFile ;
47 
48  scale = xsection/trials;
49 
50  printf("Get Cross section : nfiles %d, nevents %d, nevents per file %d \n",nfiles, chain->GetEntries(),nEventsPerFile);
51  printf(" ntrials %d, trials %2.2f, xs %2.2e, scale factor %2.2e\n", ntrials,trials,xsection,scale);
52 
53  }
54 
55  printf("*********************************************\n");
56  printf("number of entries # %lld, skipped %d\n", chain->GetEntries()) ;
57  printf("*********************************************\n");
58 
59  if(!chain)
60  {
61  printf("STOP, no chain available\n");
62  return;
63  }
64 
65  AliLog::SetGlobalLogLevel(AliLog::kError);//Minimum prints on screen
66 
67  //--------------------------------------
68  // Make the analysis manager
69  //-------------------------------------
70  AliAnalysisManager *mgr = new AliAnalysisManager("Manager", "Manager");
71 
72  // MC handler
73  AliMCEventHandler* mcHandler = new AliMCEventHandler();
74  mcHandler->SetReadTR(kFALSE);//Do not search TrackRef file
75  mgr->SetMCtruthEventHandler(mcHandler);
76  mgr->SetInputEventHandler(NULL);
77 
78  //mgr->SetDebugLevel(1); // For debugging, do not uncomment if you want no messages.
79 
80  TString outputFile = AliAnalysisManager::GetCommonFileName();
81 
82  gROOT->LoadMacro("AddTaskGenKine.C");
83 
85 
86  //-----------------------
87  // Run the analysis
88  //-----------------------
89  mgr->InitAnalysis();
90  mgr->PrintStatus();
91 
92  mgr->StartAnalysis("local",chain);
93 
94  cout <<" Analysis ended sucessfully "<< endl ;
95 
96 }
97 
98 //--------------------------------------
100 //--------------------------------------
102 {
103  gSystem->Load("libTree");
104  gSystem->Load("libGeom");
105  gSystem->Load("libVMC");
106  gSystem->Load("libXMLIO");
107  gSystem->Load("libMatrix");
108  gSystem->Load("libPhysics");
109  gSystem->Load("libMinuit"); // Root + libraries to if reclusterization is done
110 
111  gSystem->Load("libSTEERBase");
112  gSystem->Load("libGui"); // Root + libraries to if reclusterization is done
113  gSystem->Load("libCDB"); // Root + libraries to if reclusterization is done
114  gSystem->Load("libESD"); // Root + libraries to if reclusterization is done
115  gSystem->Load("libAOD");
116  gSystem->Load("libRAWDatabase"); // Root + libraries to if reclusterization is done
117  gSystem->Load("libProof");
118  gSystem->Load("libOADB");
119  gSystem->Load("libANALYSIS");
120  gSystem->Load("libSTEER"); // Root + libraries to if reclusterization is done
121 
122  gSystem->Load("libRAWDatarec"); // Root + libraries to if reclusterization is done
123  gSystem->Load("libRAWDatasim"); // Root + libraries to if reclusterization is done
124  gSystem->Load("libVZERObase"); // Root + libraries to if reclusterization is done
125  gSystem->Load("libVZEROrec"); // Root + libraries to if reclusterization is done
126 
127  gSystem->Load("libANALYSISalice");
128 
129  gSystem->Load("libPHOSUtils");
130  gSystem->Load("libEMCALUtils");
131  gSystem->Load("libPWGCaloTrackCorrBase");
132  gSystem->Load("libPWGGACaloTrackCorrelations");
133  //SetupPar("PWGCaloTrackCorrBase");
134  //SetupPar("PWGGACaloTrackCorrelations");
135 
136  // needed for plugin?
137  gSystem->AddIncludePath("-I$ALICE_ROOT");
138  gSystem->AddIncludePath("-I$ALICE_PHYSICS");
139  gSystem->AddIncludePath("-I./");
140 }
141 
142 //_________________________________
146 //_________________________________
147 void SetupPar(char* pararchivename)
148 {
149  TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
150  TString parpar(Form("%s.par", pararchivename)) ;
151 
152  if ( gSystem->AccessPathName(pararchivename) )
153  {
154  TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
155  gROOT->ProcessLine(processline.Data());
156  }
157 
158  TString ocwd = gSystem->WorkingDirectory();
159  gSystem->ChangeDirectory(pararchivename);
160 
161  // check for BUILD.sh and execute
162  if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
163  printf("*******************************\n");
164  printf("*** Building PAR archive ***\n");
165  cout<<pararchivename<<endl;
166  printf("*******************************\n");
167 
168  if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
169  Error("runProcess","Cannot Build the PAR Archive! - Abort!");
170  return -1;
171  }
172  }
173  // check for SETUP.C and execute
174  if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
175  printf("*******************************\n");
176  printf("*** Setup PAR archive ***\n");
177  cout<<pararchivename<<endl;
178  printf("*******************************\n");
179  gROOT->Macro("PROOF-INF/SETUP.C");
180  }
181 
182  gSystem->ChangeDirectory(ocwd.Data());
183  printf("Current dir: %s\n", ocwd.Data());
184 }
185 
186 //______________________________________________________________________________
200 //______________________________________________________________________________
201 void GetAverageXsection(TTree * tree, Double_t & xs, Float_t & ntr)
202 {
203  Double_t xsection = 0;
204  UInt_t ntrials = 0;
205  xs = 0;
206  ntr = 0;
207 
208  Int_t nfiles = tree->GetEntries() ;
209  if (tree && nfiles > 0)
210  {
211  tree->SetBranchAddress("xsection",&xsection);
212  tree->SetBranchAddress("ntrials" ,&ntrials );
213  for(Int_t i = 0; i < nfiles; i++)
214  {
215  tree->GetEntry(i);
216  xs += xsection ;
217  ntr += ntrials ;
218  cout << "xsection " <<xsection<<" ntrials "<<ntrials<<endl;
219  }
220 
221  xs = xs / nfiles;
222  ntr = ntr / nfiles;
223  cout << "-----------------------------------------------------------------"<<endl;
224  cout << "Average of "<< nfiles<<" files: xsection " <<xs<<" ntrials "<<ntr<<endl;
225  cout << "-----------------------------------------------------------------"<<endl;
226  }
227  else cout << " >>>> Empty tree !!!! <<<<< "<<endl;
228 }
229 
230 
231 
void ana(Int_t mode=mGRID)
Definition: ana.C:86
double Double_t
Definition: External.C:58
TSystem * gSystem
AliAnalysisTaskCaloTrackCorrelation * AddTaskGenKine(TString outputfile, const Double_t scaleFactor=-1)
print configuration settings.
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
float Float_t
Definition: External.C:68
void LoadLibraries()
Load the needed libraries most of them already loaded by aliroot.
Definition: anaGenKine.C:101
Int_t mode
Definition: anaM.C:40
void anaGenKine(Int_t mode)
Main execution method.
Definition: anaGenKine.C:14
void GetAverageXsection(TTree *tree, Double_t &xs, Float_t &ntr)
Definition: anaGenKine.C:201
Main class conecting the CaloTrackCorrelations package and Analysis Frame.
void SetupPar(char *pararchivename)
Definition: anaGenKine.C:147