]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/anaPhos.C
adatped to the new AliAnalysisGoodies functionalities
[u/mrichter/AliRoot.git] / PWG4 / anaPhos.C
1 Bool_t gIsAnalysisLoaded = kFALSE ; 
2
3 //______________________________________________________________________
4 Bool_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) ;
25     gROOT->ProcessLine(processline) ;   
26     sprintf(processline,".! tar xvzf %s",parpar);
27     gROOT->ProcessLine(processline);
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, "ESD") ) {
49     //gSystem->Load("libVMC.so");
50     //gSystem->Load("libRAliEn.so");
51     //gSystem->Load("libESD.so") ;
52     //gSystem->Load("libProof.so") ;
53   }
54
55   if ( strstr(pararchivename, "AnalysisCheck") ) {
56     gSystem->Load("libSpectrum.so");
57   }
58   
59   printf("lib%s done\n", pararchivename);
60
61   gSystem->ChangeDirectory(cdir);
62
63   gIsAnalysisLoaded = kTRUE ; 
64   return rv ; 
65 }
66
67 //______________________________________________________________________
68 void anaPhos(const Int_t kEvent=100)  
69
70   if (! gIsAnalysisLoaded ) {
71     LoadLib("ESD") ; 
72     LoadLib("AOD") ;
73     LoadLib("ANALYSIS") ; 
74     LoadLib("PWG4Gamma") ; 
75   }
76   
77   // create the analysis goodies object
78   AliAnalysisGoodies * ag = new AliAnalysisGoodies() ; 
79
80   // definition of analysis tasks
81  
82   // first task 
83   AliAnaGammaPhos * task = new AliAnaGammaPhos("GammaPhos") ;
84   ag->ConnectInput(task, TChain::Class(), 0) ; 
85   ag->ConnectOuput(task, TTree::Class(), 0, "AOD") ;  
86   ag->ConnectOuput(task, TList::Class(), 1) ;  
87
88   // second task 
89  
90   // get the data to analyze
91
92   // definition of Tag cuts 
93   const char * runCuts = 0x0 ; 
94   const char * evtCuts = 0x0 ; 
95   const char * lhcCuts = 0x0 ; 
96   const char * detCuts = 0x0 ; 
97   
98 //"fEventTag.fNPHOSClustersMin == 1 && fEventTag.fNEMCALClustersMin == 1" ; 
99
100   
101   TString input = gSystem->Getenv("ANA_INPUT") ; 
102   if ( input != "") {
103     char argument[1024] ;  
104     if ( input.Contains("tag?") ) {
105       //create the ESD collection from the tag collection 
106       input.ReplaceAll("tag?", "") ; 
107       const char * collESD = "esdCollection.xml" ;
108       ag->MakeEsdCollectionFromTagCollection(runCuts, lhcCuts, detCuts, evtCuts, input.Data(), collESD) ;
109       sprintf(argument, "esd?%s", collESD) ; 
110     } else if ( input.Contains("esd?") ) 
111       sprintf(argument, "%s", input.Data()) ; 
112     ag->Process(argument) ;
113
114   } else {
115
116     TChain* analysisChain = new TChain("esdTree") ;
117     //   input = "alien:///alice/cern.ch/user/a/aliprod/prod2006_2/output_pp/105/411/AliESDs.root" ; 
118     //   analysisChain->AddFile(input);
119     input = "AliESDs.root" ; 
120     const char * kInDir = gSystem->Getenv("OUTDIR") ; 
121     if ( kInDir ) {
122       if ( ! gSystem->cd(kInDir) ) {
123         printf("%s does not exist\n", kInDir) ;
124         return ;
125       }     
126       Int_t event, skipped=0 ; 
127       char file[120] ;
128       for (event = 0 ; event < kEvent ; event++) {
129         sprintf(file, "%s/%d/AliESDs.root", kInDir,event) ; 
130         TFile * fESD = 0 ; 
131         if ( fESD = TFile::Open(file)) 
132           if ( fESD->Get("esdTree") ) { 
133             printf("++++ Adding %s\n", file) ;
134             analysisChain->AddFile(file);
135           }
136           else { 
137             printf("---- Skipping %s\n", file) ;
138             skipped++ ;
139           }
140       }
141       printf("number of entries # %lld, skipped %d\n", analysisChain->GetEntries(), skipped*100) ;      
142     }
143     else  
144       analysisChain->AddFile(input);
145     
146     ag->Process(analysisChain) ; 
147   }
148   return ;
149 }
150
151 //______________________________________________________________________
152 void Merge(const char * xml, const char * sub, const char * out) 
153 {
154   if (! gIsAnalysisLoaded ) 
155     LoadLib("ESD") ; 
156   
157   AliAnalysisGoodies * ag = new AliAnalysisGoodies() ; 
158   ag->Merge(xml, sub, out) ;
159 }
160