examople of macro to do a correlation analysis
authorschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 9 Feb 2007 18:58:17 +0000 (18:58 +0000)
committerschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 9 Feb 2007 18:58:17 +0000 (18:58 +0000)
PWG4/anaCorr.C [new file with mode: 0644]

diff --git a/PWG4/anaCorr.C b/PWG4/anaCorr.C
new file mode 100644 (file)
index 0000000..5736a4d
--- /dev/null
@@ -0,0 +1,155 @@
+Bool_t gIsAnalysisLoaded = kFALSE ; 
+
+//______________________________________________________________________
+Bool_t LoadLib( const char* pararchivename) 
+{
+  // Loads the AliRoot required libraries from a tar file 
+
+  Bool_t rv = kTRUE ; 
+  char cdir[1024] ; 
+  sprintf(cdir, "%s", gSystem->WorkingDirectory() ) ; 
+  // Setup par File
+  if (pararchivename) {
+    char processline[1024];
+    sprintf(processline,".! tar xvzf %s.par",pararchivename);
+    gROOT->ProcessLine(processline);
+    gSystem->ChangeDirectory(pararchivename);
+
+    // check for BUILD.sh and execute
+    if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
+      printf("*** Building PAR archive  %s  ***\n", pararchivename);
+
+      if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
+       AliError(Form("Cannot Build the PAR Archive %s! - Abort!", pararchivename) );
+
+        return kFALSE ;
+      }
+    }
+
+    // check for SETUP.C and execute
+    if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
+      printf("*** Setup PAR archive  %s     ***\n", pararchivename);
+      gROOT->Macro("PROOF-INF/SETUP.C");
+    }    
+  }
+
+  if ( strstr(pararchivename, "ESD") ) {
+    gSystem->Load("libVMC.so");
+    gSystem->Load("libESD.so");
+    gSystem->Load("libRAliEn.so") ;
+    gSystem->Load("libProof.so") ;
+  }
+
+  printf("*** %s library loaded *** %s **\n", pararchivename);
+
+  gSystem->ChangeDirectory(cdir);
+
+  gIsAnalysisLoaded = kTRUE ; 
+  return rv ;  
+}
+
+//______________________________________________________________________
+void anaCorr() 
+{  
+
+  if (! gIsAnalysisLoaded ) {
+    cout<<"Load ESD"<<endl;  
+    LoadLib("ESD") ;   
+    cout<<"Load ANALYSIS"<<endl;  
+    LoadLib("ANALYSIS") ; 
+    printf("Include path = %s\n", gSystem->GetIncludePath()) ; 
+    LoadLib("PWG4Gamma") ; 
+  }
+  //AliLog::SetGlobalDebugLevel(3);
+  
+  // create the analysis goodies object
+  AliAnalysisGoodies * ag = new AliAnalysisGoodies() ; 
+
+  // definition of analysis tasks
+  const Int_t knumberOfTasks = 4 ; 
+  AliAnalysisTask * taskList[knumberOfTasks] ; 
+  TClass * taskInputList[knumberOfTasks]  ; 
+  TClass * taskOutputList[knumberOfTasks] ; 
+
+//   taskList[0]       = new AliAnaGammaHadron("GammaTest") ;
+//   taskInputList[0]  = TChain::Class() ; 
+//   taskOutputList[0] = TObjArray::Class() ; 
+
+//   AliAnaGammaDirect * gd = new AliAnaGammaDirect("GammaDirect") ;
+//   gd->SetMinGammaPt(1.);
+//   taskList[0]       = gd ;
+  taskList[0]          = new AliAnaGammaDirect("GammaDirect") ;
+  taskInputList[0]  = TChain::Class() ; 
+  taskOutputList[0] = TObjArray::Class() ; 
+
+  taskList[1]       = new AliAnaGammaIsolCut("GammaIC") ;
+  taskInputList[1]  = TChain::Class() ; 
+  taskOutputList[1] = TObjArray::Class() ; 
+
+  taskList[2]       = new AliAnaGammaHadron("GammaHadron") ;
+  taskInputList[2]  = TChain::Class() ; 
+  taskOutputList[2] = TObjArray::Class() ; 
+
+ taskList[3]       = new AliAnaGammaJet("GammaJet") ;
+  taskInputList[3]  = TChain::Class() ; 
+  taskOutputList[3] = TObjArray::Class() ; 
+
+  ag->SetTasks(knumberOfTasks, taskList, taskInputList, taskOutputList) ; 
+
+  // get the data to analyze
+
+  // definition of Tag cuts 
+  const char * runCuts = 0x0 ; 
+  const char * evtCuts = "fEventTag.fNPHOSClustersMin == 1 && fEventTag.fNEMCALClustersMin == 1" ; 
+
+  
+  TString input = gSystem->Getenv("ANA_INPUT") ; 
+  cout<<"INPUT 0"<<input<<endl;
+  if ( input != "") {
+    char argument[1024] ;  
+    if ( input.Contains("tag?") ) {
+      //create the ESD collection from the tag collection 
+      input.ReplaceAll("tag?", "") ; 
+      const char * collESD = "esdCollection.xml" ;
+      ag->MakeEsdCollectionFromTagCollection(runCuts, evtCuts, input.Data(), collESD) ;
+      sprintf(argument, "esd?%s", collESD) ; 
+    } else if ( input.Contains("esd?") ) 
+      //argument = input.Data() ; 
+      sprintf(argument, "%s", input.Data()) ;
+    printf("................ %s", input.Data()) ;
+    ag->Process(argument) ;
+
+  } else {
+
+    TChain* analysisChain = new TChain("esdTree") ;
+    input = "AliESDs.root" ; 
+    analysisChain->AddFile(input);
+    ag->Process(analysisChain) ; 
+  }
+}
+
+//______________________________________________________________________
+void Merge(const char * xml, const char * sub, const char * out) 
+{
+  if (! gIsAnalysisLoaded ) 
+    LoadLib("ESD") ; 
+  
+  AliAnalysisGoodies * ag = new AliAnalysisGoodies() ; 
+  ag->Merge(xml, sub, out) ;
+}
+
+//______________________________________________________________________
+void test(const char * fcollection1) 
+{
+  AliXMLCollection collection1(fcollection1);
+ TChain* analysisChain = new TChain("esdTree");
+ collection1.Reset();
+ while (collection1.Next()) {
+   cout<<"Adding "<<collection1.GetTURL()<<endl;
+   analysisChain->Add(collection1.GetTURL());
+ }
+ return ;
+}