char * to TString
[u/mrichter/AliRoot.git] / ESDCheck / ana.C
CommitLineData
1dfe075f 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) {
398a3deb 15 char parpar[80] ;
16 sprintf(parpar, "%s.par", pararchivename) ;
17 if ( gSystem->AccessPathName(parpar) ) {
18 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
1dfe075f 19 char processline[1024];
398a3deb 20 sprintf(processline, ".! make %s", parpar) ;
21 cout << processline << endl ;
22 gROOT->ProcessLine(processline) ;
23 gSystem->ChangeDirectory(cdir) ;
24 sprintf(processline, ".! mv %s/%s .", gSystem->Getenv("ALICE_ROOT"), parpar) ;
25 gROOT->ProcessLine(processline) ;
26 sprintf(processline,".! tar xvzf %s",parpar);
381c19ed 27 gROOT->ProcessLine(processline);
398a3deb 28 }
29 gSystem->ChangeDirectory(pararchivename);
30
1dfe075f 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
38 return kFALSE ;
39 }
40 }
41
42 // check for SETUP.C and execute
43 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
44 printf("*** Setup PAR archive %s ***\n", pararchivename);
45 gROOT->Macro("PROOF-INF/SETUP.C");
46 }
47 }
48
49 if ( strstr(pararchivename, "ESD") ) {
84eb42a1 50 //gSystem->Load("libVMC.so");
2704006a 51 //gSystem->Load("libRAliEn.so");
52 gSystem->Load("libESD.so") ;
84eb42a1 53 //gSystem->Load("libProof.so") ;
1dfe075f 54 }
55
2704006a 56 if ( strstr(pararchivename, "AnalysisCheck") ) {
57 gSystem->Load("libSpectrum.so");
58 }
59
60 printf("lib%s done\n", pararchivename);
1dfe075f 61
62 gSystem->ChangeDirectory(cdir);
63
64 gIsAnalysisLoaded = kTRUE ;
2704006a 65 return rv ;
1dfe075f 66}
67
68//______________________________________________________________________
398a3deb 69void ana(const Int_t kEvent=100)
70{
1dfe075f 71 if (! gIsAnalysisLoaded ) {
72 LoadLib("ESD") ;
c52c2132 73 LoadLib("ANALYSIS") ;
1dfe075f 74 LoadLib("AnalysisCheck") ;
75 }
76
77 // create the analysis goodies object
78 AliAnalysisGoodies * ag = new AliAnalysisGoodies() ;
79
80 // definition of analysis tasks
81
398a3deb 82 const Int_t knumberOfTasks = 10 ;
83 AliAnalysisTask * taskList[knumberOfTasks] ;
84 TClass * taskInputList[knumberOfTasks] ;
85 TClass * taskOutputList[knumberOfTasks] ;
1dfe075f 86
87 taskList[0] = new AliPHOSQATask("PHOS") ;
398a3deb 88 taskInputList[0] = TChain::Class() ;
89 taskOutputList[0] = TObjArray::Class() ;
1dfe075f 90
91 taskList[1] = new AliEMCALQATask("EMCal") ;
398a3deb 92 taskInputList[1] = taskInputList[0] ; // only one top input container allowed
93 taskOutputList[1] = TObjArray::Class() ;
1dfe075f 94
95 taskList[2] = new AliPMDQATask("PMD") ;
398a3deb 96 taskInputList[2] = taskInputList[0] ; // only one top input container allowed
97 taskOutputList[2] = TObjArray::Class() ;
1dfe075f 98
99 taskList[3] = new AliAnalysisTaskPt("Pt") ;
398a3deb 100 taskInputList[3] = taskInputList[0] ; // only one top input container allowed
101 taskOutputList[3] = TObjArray::Class() ;
102
1dfe075f 103 taskList[4] = new AliHMPIDQATask("HMPID") ;
398a3deb 104 taskInputList[4] = taskInputList[0] ; // only one top input container allowed
105 taskOutputList[4] = TObjArray::Class() ;
1dfe075f 106
107 taskList[5] = new AliT0QATask("T0") ;
398a3deb 108 taskInputList[5] = taskInputList[0] ; // only one top input container allowed
109 taskOutputList[5] = TObjArray::Class() ;
1dfe075f 110
111 taskList[6] = new AliMUONQATask("MUON") ;
398a3deb 112 taskInputList[6] = taskInputList[0] ; // only one top input container allowed
113 taskOutputList[6] = TObjArray::Class() ;
114
98c8c1f8 115 taskList[7] = new AliTRDQATask("TRD") ;
398a3deb 116 taskInputList[7] = taskInputList[0] ; // only one top input container allowed
117 taskOutputList[7] = TObjArray::Class() ;
1dfe075f 118
98c8c1f8 119 taskList[8] = new AliTOFQATask("TOF") ;
398a3deb 120 taskInputList[8] = taskInputList[0] ; // only one top input container allowed
121 taskOutputList[8] = TObjArray::Class() ;
98c8c1f8 122
123 taskList[9] = new AliVZEROQATask("VZERO") ;
398a3deb 124 taskInputList[9] = taskInputList[0] ; // only one top input container allowed
125 taskOutputList[9] = TObjArray::Class() ;
98c8c1f8 126
127// taskList[8] = new AliFMDQATask("FMD") ;
398a3deb 128// taskInputList[8] = taskInputList[0] ; // only one top input container allowed
129// taskOutputList[8] = TObjArray::Class() ;
130
1dfe075f 131 ag->SetTasks(knumberOfTasks, taskList, taskInputList, taskOutputList) ;
132
133 // get the data to analyze
134
135 // definition of Tag cuts
136 const char * runCuts = 0x0 ;
84eb42a1 137 const char * evtCuts = 0x0 ;
138 const char * lhcCuts = 0x0 ;
139 const char * detCuts = 0x0 ;
140
141//"fEventTag.fNPHOSClustersMin == 1 && fEventTag.fNEMCALClustersMin == 1" ;
1dfe075f 142
143
144 TString input = gSystem->Getenv("ANA_INPUT") ;
145 if ( input != "") {
146 char argument[1024] ;
147 if ( input.Contains("tag?") ) {
148 //create the ESD collection from the tag collection
149 input.ReplaceAll("tag?", "") ;
150 const char * collESD = "esdCollection.xml" ;
84eb42a1 151 ag->MakeEsdCollectionFromTagCollection(runCuts, lhcCuts, detCuts, evtCuts, input.Data(), collESD) ;
1dfe075f 152 sprintf(argument, "esd?%s", collESD) ;
153 } else if ( input.Contains("esd?") )
98c8c1f8 154 sprintf(argument, "%s", input.Data()) ;
1dfe075f 155 ag->Process(argument) ;
156
157 } else {
158
159 TChain* analysisChain = new TChain("esdTree") ;
160 // input = "alien:///alice/cern.ch/user/a/aliprod/prod2006_2/output_pp/105/411/AliESDs.root" ;
161 // analysisChain->AddFile(input);
84eb42a1 162 input = "AliESDs.root" ;
398a3deb 163 const char * kInDir = gSystem->Getenv("OUTDIR") ;
164 if ( kInDir ) {
165 if ( ! gSystem->cd(kInDir) ) {
166 printf("%s does not exist\n", kInDir) ;
167 return ;
168 }
169 Int_t event, skipped=0 ;
170 char file[120] ;
171 for (event = 0 ; event < kEvent ; event++) {
172 sprintf(file, "%s/%d/AliESDs.root", kInDir,event) ;
173 TFile * fESD = 0 ;
174 if ( fESD = TFile::Open(file))
175 if ( fESD->Get("esdTree") ) {
176 printf("++++ Adding %s\n", file) ;
177 analysisChain->AddFile(file);
178 }
179 else {
180 printf("---- Skipping %s\n", file) ;
181 skipped++ ;
182 }
183 }
184 printf("number of entries # %lld, skipped %d\n", analysisChain->GetEntries(), skipped*100) ;
185 }
186 else
187 analysisChain->AddFile(input);
188
1dfe075f 189 ag->Process(analysisChain) ;
190 }
2704006a 191 return ;
1dfe075f 192}
193
194//______________________________________________________________________
195void Merge(const char * xml, const char * sub, const char * out)
196{
197 if (! gIsAnalysisLoaded )
198 LoadLib("ESD") ;
199
200 AliAnalysisGoodies * ag = new AliAnalysisGoodies() ;
201 ag->Merge(xml, sub, out) ;
202}
203