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