]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/totEt/macros/runCaloEt.C
changes to run with plugin
[u/mrichter/AliRoot.git] / PWG4 / totEt / macros / runCaloEt.C
1 //Create by Christine Nattrass, Rebecca Scott, Irakli Martashvili
2 //University of Tennessee at Knoxville
3
4 //by default this runs locally
5 //With the argument true this submits jobs to the grid
6 //As written this requires an xml script tag.xml in the ~/et directory on the grid to submit jobs
7 void runCaloEt(bool submit = false, // true or false 
8                const char *dataType="simPbPb/LHC10e18a", // "sim" or "real" etc.
9                const char *pluginRunMode="full", // "test" or "full" or "terminate"
10                const char *det = "EMCAL") // "PHOS" or "EMCAL"
11 {
12   TStopwatch timer;
13   timer.Start();
14   gSystem->Load("libTree");
15   gSystem->Load("libGeom");
16   gSystem->Load("libVMC");
17   gSystem->Load("libPhysics");
18
19   gSystem->Load("libMinuit");
20
21   gSystem->AddIncludePath("-I$ALICE_ROOT/include");
22   gSystem->AddIncludePath("-I. -I$ALICE_ROOT/EMCAL -I$ALICE_ROOT/ANALYSIS");
23
24   gSystem->Load("libSTEERBase");
25   gSystem->Load("libESD");
26   gSystem->Load("libAOD");
27   
28   gSystem->Load("libANALYSIS");
29   gSystem->Load("libANALYSISalice");
30   gSystem->Load("libCORRFW");
31
32   if (!submit) { 
33     cout << "local - no submitting" << endl;
34   }
35   else { 
36     cout << "submitting to grid" << endl;
37   }
38    
39   gROOT->ProcessLine(".L AliAnalysisEtCuts.cxx+g");
40   gROOT->ProcessLine(".L AliAnalysisEt.cxx+g");
41   gROOT->ProcessLine(".L AliAnalysisEtMonteCarlo.cxx+g");
42   gROOT->ProcessLine(".L AliAnalysisEtMonteCarloPhos.cxx+g");
43   gROOT->ProcessLine(".L AliAnalysisEtMonteCarloEmcal.cxx+g");
44   gROOT->ProcessLine(".L AliAnalysisEtReconstructed.cxx+g");
45   gROOT->ProcessLine(".L AliAnalysisEtReconstructedPhos.cxx+g");
46   gROOT->ProcessLine(".L AliAnalysisEtReconstructedEmcal.cxx+g");  
47   gROOT->ProcessLine(".L AliAnalysisTaskTotEt.cxx+g");
48
49   char *kTreeName = "esdTree" ;
50   TChain * chain   = new TChain(kTreeName,"myESDTree") ;
51   
52   if(submit){      
53     gSystem->Load("libNetx") ; 
54     gSystem->Load("libgapiUI");
55     gSystem->Load("libRAliEn"); 
56     TGrid::Connect("alien://") ;
57   }
58   
59   // Make the analysis manager
60   AliAnalysisManager *mgr = new AliAnalysisManager("TotEtManager");
61   
62   TString detStr(det);
63   TString taskName = "TaskTotEt" + detStr;
64   TString dataStr(dataType);
65   TString dataStrName(dataType);
66   dataStrName.ReplaceAll("/",".");
67   TString outputName = "Et.ESD." + dataStrName + "." + detStr + ".root";
68   TString outputDir = "totEt" + dataStr;
69
70   cout << " taskName " << taskName
71        << " outputName " << outputName 
72        << " outputDir (alien) " << outputDir << endl;
73
74   if (submit) {
75     gROOT->LoadMacro("CreateAlienHandlerCaloEtSim.C");
76     AliAnalysisGrid *alienHandler = CreateAlienHandlerCaloEtSim(outputDir, outputName, pluginRunMode);  
77     if (!alienHandler) return;
78     mgr->SetGridHandler(alienHandler);
79   }
80
81   AliVEventHandler* esdH = new AliESDInputHandler;
82   mgr->SetInputEventHandler(esdH);
83   AliMCEventHandler* handler = new AliMCEventHandler;
84   if ( dataStr.Contains("sim") ) {
85     cout << " MC " << endl;
86     if ( dataStr.Contains("PbPb") ) { // a la: simPbPb/LHC10e18a
87       cout << " PbPb " << endl;
88       TString fileLocation = "/home/dsilverm/data/E_T/" + dataStr + "/dir/AliESDs.root";
89       cout << "fileLocation " << fileLocation.Data() << endl; 
90       chain->Add(fileLocation.Data()); // link to local test file
91     }
92     else { // pp
93       chain->Add("/home/dsilverm/data/E_T/sim/LHC10d1/117222/100/AliESDs.root"); // link to local test file
94     }
95     handler->SetReadTR(kFALSE);
96     mgr->SetMCtruthEventHandler(handler);
97   }
98   else { // real data
99     chain->Add("/home/dsilverm/data/E_T/data/2010/LHC10b/000117222/ESDs/pass2/10000117222021.30/AliESDs.root"); // link to local test file
100     cout << " not MC " << endl;
101   }
102
103
104   AliAnalysisTaskTotEt *task1 = new AliAnalysisTaskTotEt(taskName);
105   mgr->AddTask(task1);
106
107   AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
108   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("out1", TList::Class(), AliAnalysisManager::kOutputContainer, outputName);
109   
110   //____________________________________________//
111   mgr->ConnectInput(task1,0,cinput1);
112   mgr->ConnectOutput(task1,1,coutput1);
113   
114   mgr->SetDebugLevel(0);
115   
116   if (!mgr->InitAnalysis()) return;
117   mgr->PrintStatus();
118   if(submit){
119     mgr->StartAnalysis("grid");
120   }
121   else{
122     mgr->StartAnalysis("local",chain);
123   }
124   
125   timer.Stop();
126   timer.Print();
127 }