]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/ana.C
Preprocessor with new DA
[u/mrichter/AliRoot.git] / PWG4 / ana.C
CommitLineData
bdcfac30 1Bool_t gIsAnalysisLoaded = kFALSE ;
2
3//______________________________________________________________________
4Bool_t LoadLib( const char* pararchivename)
5{
6 // Loads the AliRoot required libraries from a tar file
7
8 Bool_t rv = kTRUE ;
9
10 char cdir[1024] ;
11 sprintf(cdir, "%s", gSystem->WorkingDirectory() ) ;
12
13 // Setup par File
14 if (pararchivename) {
15 char parpar[80] ;
16 sprintf(parpar, "%s.par", pararchivename) ;
17 if ( gSystem->AccessPathName(parpar) ) {
18 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
19 char processline[1024];
20 sprintf(processline, ".! make %s", parpar) ;
21 cout << processline << endl ;
22 gROOT->ProcessLine(processline) ;
23 gSystem->ChangeDirectory(cdir) ;
24 sprintf(processline, ".! mv /tmp/%s .", parpar) ;
4b707925 25 //gROOT->ProcessLine(processline) ;
bdcfac30 26 sprintf(processline,".! tar xvzf %s",parpar);
4b707925 27 //gROOT->ProcessLine(processline);
bdcfac30 28 }
29 gSystem->ChangeDirectory(pararchivename);
30
31 // check for BUILD.sh and execute
32 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
33 printf("*** Building PAR archive %s ***\n", pararchivename);
34
35 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
36 AliError(Form("Cannot Build the PAR Archive %s! - Abort!", pararchivename) );
37 return kFALSE ;
38 }
39 }
40
41 // check for SETUP.C and execute
42 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
43 printf("*** Setup PAR archive %s ***\n", pararchivename);
44 gROOT->Macro("PROOF-INF/SETUP.C");
45 }
46 }
47
48 if ( strstr(pararchivename, "AnalysisCheck") ) {
49 gSystem->Load("libSpectrum.so");
50 }
51
52 printf("lib%s done\n", pararchivename);
53
54 gSystem->ChangeDirectory(cdir);
55
56 gIsAnalysisLoaded = kTRUE ;
57 return rv ;
58}
59
60//________________________________ana______________________________________
61
62void ana(const Int_t kEvent=10)
63{
64
4b707925 65 //AliLog::SetGlobalDebugLevel(1);
bdcfac30 66 gSystem->AddIncludePath("-I\"$ALICE_ROOT/include\"");
67 gSystem->Load("libANALYSIS.so");
4b707925 68
bdcfac30 69 if (! gIsAnalysisLoaded ) {
70 // LoadLib("ESD") ;
71 // LoadLib("AOD") ;
72 // LoadLib("ANALYSIS") ;
73 LoadLib("PWG4Gamma") ;
74 }
75
76 // create the analysis goodies object
77 AliAnalysisGoodies * ag = new AliAnalysisGoodies() ;
78
4b707925 79 AliAnalysisTaskGamma * task = new AliAnalysisTaskGamma ("Gamma");
bdcfac30 80 ag->ConnectInput(task, TChain::Class(), 0) ;
4b707925 81 ag->ConnectOuput(task, TTree::Class(), 0, "AOD") ;
82 ag->ConnectOuput(task, TList::Class(), 1) ;
bdcfac30 83
84 // get the data to analyze
85
86 // definition of Tag cuts
87 const char * runCuts = 0x0 ;
88 const char * evtCuts = 0x0 ;
89 const char * lhcCuts = 0x0 ;
90 const char * detCuts = 0x0 ;
91
92 //"fEventTag.fNPHOSClustersMin == 1 && fEventTag.fNEMCALClustersMin == 1" ;
93
94 TString input = gSystem->Getenv("ANA_INPUT") ;
95 cout<<"ANA_INPUT >>> "<<input<<endl;
96 if ( input != "") {
97 cout<<"ANALYSIS 1"<<endl;
98
99 char argument[1024] ;
100
101 if ( input.Contains("tag?") ) {
102 //create the ESD collection from the tag collection
103 input.ReplaceAll("tag?", "") ;
104
105 const char * collESD = "esdCollection.xml" ;
106 ag->MakeEsdCollectionFromTagCollection(runCuts, lhcCuts, detCuts, evtCuts, input.Data(), collESD) ;
107 sprintf(argument, "esd?%s", collESD) ;
108 cout<<"TAG collection >> "<<argument<<endl;
109 }
110
111 else if ( input.Contains("esd?") ){
112 sprintf(argument, "%s", input.Data()) ;
113 cout<<"ESD collection >> "<<argument<<endl;
114 }
115
116 ag->Process(argument) ;
117
118 }
119 else {
120 cout<<"ANALYSIS 2"<<endl;
121 TChain* analysisChain = new TChain("esdTree") ;
122 // input = "alien:///alice/cern.ch/user/a/aliprod/prod2006_2/output_pp/105/411/AliESDs.root" ;
123 // analysisChain->AddFile(input);
124 input = "AliESDs.root" ;
125 const char * kInDir = gSystem->Getenv("OUTDIR") ;
126 if ( kInDir ) {
127 if ( ! gSystem->cd(kInDir) ) {
128 printf("%s does not exist\n", kInDir) ;
129 return ;
130 }
131 Int_t event, skipped=0 ;
132 char file[120] ;
133 for (event = 0 ; event < kEvent ; event++) {
134 sprintf(file, "%s/%d/AliESDs.root", kInDir,event) ;
135 TFile * fESD = 0 ;
136 if ( fESD = TFile::Open(file))
137 if ( fESD->Get("esdTree") ) {
138 printf("++++ Adding %s\n", file) ;
139 analysisChain->AddFile(file);
140 }
141 else {
142 printf("---- Skipping %s\n", file) ;
143 skipped++ ;
144 }
145 }
146 printf("number of entries # %lld, skipped %d\n", analysisChain->GetEntries(), skipped*100) ;
147 }
148 else
149 analysisChain->AddFile(input);
150
151 ag->Process(analysisChain) ;
152 }
153 return ;
154}
155
156//______________________________________________________________________
157void Merge(const char * xml, const char * sub, const char * out)
158{
159 if (! gIsAnalysisLoaded )
160 LoadLib("ESD") ;
161
162 AliAnalysisGoodies * ag = new AliAnalysisGoodies() ;
163 ag->Merge(xml, sub, out) ;
164}
165