]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/AnalysisMacros/Batch/runBatch.C
07171061b6706c42209e204779d5becd18a2d28f
[u/mrichter/AliRoot.git] / PWG2 / AnalysisMacros / Batch / runBatch.C
1 void runBatch() {
2   TStopwatch timer;
3   timer.Start();
4
5   printf("*** Connect to AliEn ***\n");
6   TGrid::Connect("alien://");
7   gSystem->Load("libProofPlayer.so");
8
9   //____________________________________________________//
10   //_____________Setting up STEERBase.par_______________//
11   //____________________________________________________//
12   setupPar("STEERBase");
13   gSystem->Load("libSTEERBase.so");
14
15   //____________________________________________________//
16   //_____________Setting up ESD.par_____________________//
17   //____________________________________________________//
18   setupPar("ESD");
19   gSystem->Load("libVMC.so");
20   gSystem->Load("libESD.so");
21
22   //____________________________________________________//
23   //_____________Setting up AOD.par_____________________//
24   //____________________________________________________//
25   setupPar("AOD");
26   gSystem->Load("libAOD.so");
27
28   //_____________________________________________________________//
29   //_____________Setting up ANALYSIS_NEW.par_____________________//
30   //_____________________________________________________________//
31   setupPar("ANALYSIS");
32   gSystem->Load("libANALYSIS.so");
33
34   //CreateXML();
35   
36   //ANALYSIS PART
37   gROOT->LoadMacro("AliAnalysisTaskPt.cxx+");
38   const char *collectionfile = "wn.xml";
39
40   //____________________________________________//
41   //Usage of event tags
42   AliTagAnalysis *analysis = new AliTagAnalysis();
43   TChain *chain = 0x0;
44   chain = analysis->GetChainFromCollection(collectionfile,"esdTree");
45   chain->SetBranchStatus("*Calo*",0);
46    
47   //____________________________________________//
48   // Make the analysis manager
49   AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
50   AliVEventHandler* esdH = new AliESDInputHandler;
51   mgr->SetInputEventHandler(esdH);  
52   //____________________________________________//
53   // 1st Pt task
54   AliAnalysisTaskPt *task1 = new AliAnalysisTaskPt("TaskPt");
55   mgr->AddTask(task1);
56   // Create containers for input/output
57   AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
58   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("chist1", TH1::Class(),AliAnalysisManager::kOutputContainer,"Pt.ESD.root");
59   
60   //____________________________________________//
61   mgr->ConnectInput(task1,0,cinput1);
62   mgr->ConnectOutput(task1,0,coutput1);
63   if (!mgr->InitAnalysis()) return;
64   mgr->PrintStatus();
65   mgr->StartAnalysis("local",chain);
66
67   timer.Stop();
68   timer.Print();
69 }
70
71 void CreateXML() {
72   // Create A tag analysis object and impose some selection criteria
73   AliTagAnalysis *tagAna = new AliTagAnalysis(); 
74
75   //Case where the tag files are stored locally
76   //TagAna->ChainLocalTags(".");
77
78   //Case where the tag files are stored in the file catalog
79   //pp.xml is the xml collection of tag files that was produced 
80   //by querying the file catalog.
81   TAlienCollection* coll = TAlienCollection::Open("tag.xml");
82   TGridResult* tagResult = coll->GetGridResult("",0,0);
83   tagAna->ChainGridTags(tagResult);
84
85   //__________________________//
86   //Usage of string statements//
87   //__________________________//
88   /*const char* fRunCuts = "fAliceRunId == 340";
89   const char* fEventCuts = "(fEventTag.fTopPtMin >= 1.0)&&(fEventTag.fNumberOfTracks >= 11)&&(fEven
90 tTag.fNumberOfTracks <= 12)";
91   tagAna->CreateXMLCollection("global",fRunCuts,fEventCuts);*/
92
93   //________________________________________________//
94   //          Usage of Ali*TagCuts classes          //
95   //________________________________________________//
96   // create a RunTagCut object
97   AliRunTagCuts *runCuts = new AliRunTagCuts();
98   // create a LHCTagCut object
99   AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
100   // create a DetectorTagCut object
101   AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
102   // create an EventTagCut object
103   AliEventTagCuts *evCuts = new AliEventTagCuts();
104   evCuts->SetMultiplicityRange(11,12);
105   tagAna->CreateXMLCollection("global",runCuts,lhcCuts,detCuts,evCuts);
106 }  
107
108 Int_t setupPar(const char* pararchivename) {
109   ///////////////////
110   // Setup PAR File//
111   ///////////////////
112   if (pararchivename) {
113     char processline[1024];
114     sprintf(processline,".! tar xvzf %s.par",pararchivename);
115     gROOT->ProcessLine(processline);
116     const char* ocwd = gSystem->WorkingDirectory();
117     gSystem->ChangeDirectory(pararchivename);
118
119     // check for BUILD.sh and execute
120     if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
121       printf("*******************************\n");
122       printf("*** Building PAR archive    ***\n");
123       printf("*******************************\n");
124
125       if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
126         Error("runProcess","Cannot Build the PAR Archive! - Abort!");
127         return -1;
128       }
129     }
130     // check for SETUP.C and execute
131     if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
132       printf("*******************************\n");
133       printf("*** Setup PAR archive       ***\n");
134       printf("*******************************\n");
135       gROOT->Macro("PROOF-INF/SETUP.C");
136     }
137     
138     gSystem->ChangeDirectory("../");
139   }
140
141   return 1;
142 }