Deleted wrong file
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDAnalysisTask.C
CommitLineData
38b8c336 1void AliHMPIDAnalysisTask()
9a8aafa5 2{
740b6bde 3
38b8c336 4 //
5 // Macro to run the AliHMPIDAnalysisTask
740b6bde 6 // To use: copy this macro to your work directory, modify the global
7 // part to match your needs, then run root.
8 // root[0] .x AliHMPIDAnalysisTask.C
38b8c336 9 //
740b6bde 10
38b8c336 11 //______ Input settings
740b6bde 12 Int_t nEvents = 650000; //on Proof
38b8c336 13 Int_t nOffset = 0; //on Proof
14 Int_t nFile2Xml = 10; //on Grid - how many ESD files to chain in xml
740b6bde 15 TString xmlName="HmpidCheckRun122080_test.xml";//new.xml"; //name of the xml collection created
16 Char_t *indataset = "/alice/sim/LHC10b4_114932";
17// char *indataset = "$HOME/HMPID/data/AliESDs.root";
18
38b8c336 19 //______ Select Local, Proof or Intercative Grid Analysis (but just only one :-))
20 Bool_t bLOCAL = kFALSE;
740b6bde 21 Bool_t bPROOF = kTRUE;
22 Bool_t bGRIDINT = kFALSE;
38b8c336 23
740b6bde 24// AliLog::SetGlobalDebugLevel(2);
25// AliLog::SetGlobalLogLevel(0);
38b8c336 26
27
28 //______ Init data set chain
29 TString dataset(indataset);
30 TChain *chain = new TChain("esdTree");
31
32 //______ Define settings for PROOF
740b6bde 33 const char* proofNode = "alice-caf";
38b8c336 34 gEnv->SetValue("XSec.GSI.DelegProxy","2");
740b6bde 35 gSystem->SetIncludePath("-I. -I$HOME/HMPID -I$ALICE_ROOT/include -I$ROOTSYS/include");
38b8c336 36 gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
740b6bde 37 gSystem->Load("libTree.so");
38 gSystem->Load("libGeom.so");
39 gSystem->Load("libVMC.so");
40 gSystem->Load("libPhysics.so");
38b8c336 41 gSystem->Load("libSTEERBase");
42 gSystem->Load("libESD");
43 gSystem->Load("libAOD");
44 gSystem->Load("libANALYSIS");
740b6bde 45 gSystem->Load("libANALYSISalice");
46
38b8c336 47 //______ Create analysis manager
48 AliAnalysisManager *mgr = new AliAnalysisManager("HMPID Analysis Train", "HMPID Analysis Train");
740b6bde 49 mgr->SetDebugLevel(0);
50
38b8c336 51 //______ Create input handler, default ESD
52 AliESDInputHandler *esdHandler = new AliESDInputHandler();
53 mgr->SetInputEventHandler(esdHandler);
740b6bde 54
55 //______ Create MC input handler
56 AliMCEventHandler* mcHandler = new AliMCEventHandler();
57 mgr->SetMCtruthEventHandler(mcHandler);
58
38b8c336 59 //______ Create default input container
60 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
61 AliAnalysisDataContainer *hmpoutput= mgr->CreateContainer("hmpoutput", TList::Class(),AliAnalysisManager::kOutputContainer,"HmpidOutput.root");
740b6bde 62
63 if(bLOCAL)
38b8c336 64 {
740b6bde 65
38b8c336 66 Printf("========> Running LOCAL HMPID Analysis <=========");
67 gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
68 gSystem->Load("libSTEERBase");
69 gSystem->Load("libESD");
70 gSystem->Load("libAOD");
71 gSystem->Load("libANALYSIS");
740b6bde 72 gSystem->Load("libANALYSISalice");
38b8c336 73 //chain = CreateESDChain(dataset.Data());//,1,0,kFALSE,kFALSE,0);
740b6bde 74 chain->Add(indataset);
75 gROOT->LoadMacro("AliHMPIDAnalysisTask.cxx++g");//"AliHMPIDAnalysisTask.cxx++");
38b8c336 76 AliHMPIDAnalysisTask *hmpTask = new AliHMPIDAnalysisTask("HMPIDAnalysisTask");
740b6bde 77 mgr->AddTask(hmpTask);
38b8c336 78 }
740b6bde 79 else if(bPROOF)
38b8c336 80 {
81 Printf("========> Running PROOF HMPID Analysis <=========");
740b6bde 82 TProof::Open(proofNode);
83// gProof->SetParallel(2);
84 gProof->EnablePackage("VO_ALICE@AliRoot::v4-19-14-AN");
38b8c336 85 gProof->Load(Form("%s/HMPID/AliHMPIDAnalysisTask.cxx++g",gSystem->Getenv("ALICE_ROOT")));
740b6bde 86// gProof->Load("AliHMPIDAnalysisTask.cxx++g");//"AliHMPIDAnalysisTask.cxx++");
38b8c336 87 AliHMPIDAnalysisTask *hmpTask = new AliHMPIDAnalysisTask("HMPIDAnalysisTask");
740b6bde 88 mgr->AddTask(hmpTask);
38b8c336 89 }
740b6bde 90 else if(bGRIDINT)
38b8c336 91 {
92 Printf("========> Running INTERCATIVE GRID HMPID Analysis <=========");
93 gSystem->Load("libSTEERBase");
94 gSystem->Load("libESD");
95 gSystem->Load("libANALYSIS");
740b6bde 96 gSystem->Load("libANALYSISalice");
97 //______ Add HMPID task
38b8c336 98 gSystem->SetIncludePath("-I. -I$HOME/HMPID -I$ALICE_ROOT/include -I$ROOTSYS/include");
99 gROOT->LoadMacro("$ALICE_ROOT/HMPID/AliHMPIDAnalysisTask.cxx++");
740b6bde 100
101
38b8c336 102 TGrid::Connect("alien://");
740b6bde 103 chain = CreateChainFromCollection(xmlName.Data(),"esdTree",nFile2Xml);
38b8c336 104 //gROOT->LoadMacro(Form("%s/HMPID/AliHMPIDAnalysisTask.cxx++g",gSystem->Getenv("ALICE_ROOT")));//"AliHMPIDAnalysisTask.cxx++");
105 //gROOT->LoadMacro("$ALICE_ROOT/HMPID/AliHMPIDAnalysisTask.cxx++");
106 AliHMPIDAnalysisTask *hmpTask = new AliHMPIDAnalysisTask("HMPIDAnalysisTask");
740b6bde 107 mgr->AddTask(hmpTask);
38b8c336 108
109 }
9a8aafa5 110
740b6bde 111
112 if(bLOCAL)
113 {
114 //______ Add HMPID task
115 gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
116 gSystem->Load("libSTEERBase");
117 gSystem->Load("libESD");
118 gSystem->Load("libAOD");
119 gSystem->Load("libANALYSIS");
120 gSystem->Load("libANALYSISalice");
38b8c336 121 }
122 if ( bPROOF )
123 {
124
740b6bde 125 }
126
127 mgr->ConnectInput(hmpTask,0,cinput);
128 mgr->ConnectOutput(hmpTask,0,hmpoutput);
129
130
131 if (mgr->InitAnalysis()) {
132 mgr->PrintStatus();
133 if(bLOCAL || bGRIDINT) mgr->StartAnalysis("local",chain);
134 else if(bPROOF) mgr->StartAnalysis("proof",dataset.Data(), nEvents,nOffset);
135 }
38b8c336 136}
740b6bde 137
38b8c336 138//__________________________________________________________________________________
139TChain *CreateChainFromCollection(const char* xmlfile, const char *treeName="esdTree",Int_t nFiles = 0)
140{
740b6bde 141// Create a chain from an alien collection.
38b8c336 142 TAlienCollection * myCollection = TAlienCollection::Open(xmlfile);
143
144 if (!myCollection) {
740b6bde 145 ::Error("CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile);
38b8c336 146 return NULL ;
147 }
148
149 TChain* chain = new TChain(treeName);
740b6bde 150 myCollection->Reset();
38b8c336 151 Int_t iCount = 0;
152 while ( myCollection->Next() ){
153 if(nFiles!=0)iCount++;
154 if(iCount > nFiles)break;
155 chain->Add(myCollection->GetTURL("")) ;
156 Printf("Adding %s",myCollection->GetTURL(""));
9a8aafa5 157 }
38b8c336 158 chain->ls();
159 return chain;
740b6bde 160}
161
162//__________________________________________________________________________________
38b8c336 163void SetupPar(char* pararchivename)
164{
740b6bde 165 //Load par files, create analysis libraries
166 //For testing, if par file already decompressed and modified
167 //classes then do not decompress.
168
169 TString cdir(Form("%s", gSystem->WorkingDirectory() ));
170 TString parpar(Form("%s.par", pararchivename));
9a8aafa5 171
38b8c336 172 if (!gSystem->AccessPathName(pararchivename) ) {
740b6bde 173 TString processline = Form(".! tar xvzf %s",parpar.Data());
38b8c336 174 gROOT->ProcessLine(processline.Data());
175 }
9a8aafa5 176
38b8c336 177 TString ocwd = gSystem->WorkingDirectory();
178 gSystem->ChangeDirectory(pararchivename);
9a8aafa5 179
740b6bde 180 // check for BUILD.sh and execute
38b8c336 181 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
182 printf("*******************************\n");
183 printf("*** Building PAR archive ***\n");
184 cout<<pararchivename<<endl;
185 printf("*******************************\n");
9a8aafa5 186
38b8c336 187 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
188 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
189 return -1;
190 }
191 }
740b6bde 192 // check for SETUP.C and execute
38b8c336 193 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
194 printf("*******************************\n");
195 printf("*** Setup PAR archive ***\n");
196 cout<<pararchivename<<endl;
197 printf("*******************************\n");
198 gROOT->Macro("PROOF-INF/SETUP.C");
199 }
9a8aafa5 200
38b8c336 201 gSystem->ChangeDirectory(ocwd.Data());
202 printf("Current dir: %s\n", ocwd.Data());
740b6bde 203}