New Calorimeter Calibration directory, now only PHOS
[u/mrichter/AliRoot.git] / PWG4 / CaloCalib / macros / AnaPHOSPi0Select.C
1 void AnaPi0Select(const char* dataset="minbias_LHC09a4_81040_81050.xml")
2 {
3     
4     gSystem->Load("libTree.so");
5     gSystem->Load("libGeom.so");
6     gSystem->Load("libVMC.so");
7     gSystem->Load("libPhysics.so");
8
9     //load analysis framework
10     gSystem->Load("libANALYSIS");
11     gSystem->Load("libANALYSISalice"); //AliAnalysisTaskSE
12     gSystem->Load("libPWG4CaloCalib");
13
14     //Set local DB for PHOS
15     gROOT->ProcessLine(".! tar xzvf PHOS.tgz") ;
16     AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
17     AliCDBManager::Instance()->SetSpecificStorage("PHOS/*","local://./");
18
19     // Connect to alien
20     TString token = gSystem->Getenv("GRID_TOKEN") ;
21     if ( token == "OK" ) 
22      TGrid::Connect("alien://");
23     else 
24      AliInfo("You are not connected to the GRID") ; 
25
26     // Create the chain
27     TChain* chain = new TChain("esdTree");
28     TGridCollection * collection = dynamic_cast<TGridCollection*>(TAlienCollection::Open(dataset));
29    
30     TAlienResult* result = collection->GetGridResult("",0 ,0);
31     TList* rawFileList = result->GetFileInfoList();
32
33     for (Int_t counter=0 ; counter < rawFileList->GetEntries() ; counter++) {
34      TFileInfo * fi =  static_cast<TFileInfo*>(rawFileList->At(counter)) ; 
35      const char * rawFile = fi->GetCurrentUrl()->GetUrl() ;  
36      printf("Processing %s\n", rawFile) ;
37      chain->Add(rawFile);
38      printf("Chain: %d entries.\n",chain->GetEntries()); 
39     }
40
41     // Make the analysis manager
42     AliAnalysisManager *mgr = new AliAnalysisManager("PHOSPi0CalibSelect","PHOSPi0CalibSelection");
43
44     // ESD input handler
45     AliESDInputHandler* esdH = new AliESDInputHandler();
46     mgr->SetInputEventHandler(esdH);
47
48         //Output event handler
49         AliAODHandler* aodoutHandler   = new AliAODHandler();
50         aodoutHandler->SetOutputFileName("aod.root");
51         //aodoutHandler->SetCreateNonStandardAOD();
52         mgr->SetOutputEventHandler(aodoutHandler);
53         
54     // Debug level
55     mgr->SetDebugLevel(10);
56
57         // ESD filter task
58         // 
59         gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskESDfilter.C");
60         AliAnalysisTaskESDfilter *esdfilter = AddTaskESDfilter(kFALSE);
61         
62         // Calibration task 
63         //
64         AliAnalysisTaskPHOSPi0CalibSelection *task = new AliAnalysisTaskPHOSPi0CalibSelection("PHOSPi0CalibSelection");
65         task->SetClusterMinEnergy(0.4);         
66
67     // Create containers for input/output
68     AliAnalysisDataContainer *cinput   = mgr->GetCommonInputContainer();
69     AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("histos",TList::Class(),AliAnalysisManager::kOutputContainer,"PHOShistos.root");
70
71         // Connect to data containers   
72     mgr->ConnectInput (task, 0, cinput);
73     mgr->ConnectOutput(task, 1, coutput2);
74
75     if (mgr->InitAnalysis()) {
76              mgr->PrintStatus();
77              mgr->StartAnalysis("local", chain);
78     }
79
80 }
81
82