AliPhysics  5364b50 (5364b50)
runITSTPCalignment.C
Go to the documentation of this file.
1 void runITSTPCalignment( UInt_t saveinterval = 1000000 )
2 {
3  TStopwatch timer;
4  timer.Start();
5 
6  //runProof("/COMMON/COMMON/LHC09a4_run8100X#esdTree");
7  runLocal("AliESDs.root");
8 
9  timer.Stop();
10  timer.Print();
11 }
12 
13 //_________________________________________________//
14 void runLocal(const char* filenamestr = "AliESDs.root" ) {
15 
16  TString inputFilename(filenamestr);
17  TString outputArrayFilename = "ITSTPCalignmentArray.root";
18  TString outputHistFilename = "ITSTPCalignmentHist.root";
19 
20  //____________________________________________________//
21  //_____________Setting up the par files_______________//
22  //____________________________________________________//
23  setupPar("STEERBase");
24  gSystem->Load("libSTEERBase");
25  setupPar("ESD");
26  gSystem->Load("libVMC");
27  gSystem->Load("libESD");
28  setupPar("AOD");
29  gSystem->Load("libAOD");
30  setupPar("ANALYSIS");
31  gSystem->Load("libANALYSIS");
32  setupPar("ANALYSISalice");
33  gSystem->Load("libANALYSISalice");
34  //____________________________________________________//
35 
36  //add input files from dirs
37  TChain* chain = new TChain("esdTree");
38  chain->SetBranchStatus("*ESDfriend*",0);
39  TString workingDir = gSystem->pwd();
40  void* dirhandle = gSystem->OpenDirectory(workingDir.Data());
41  if (!dirhandle) return;
42  const char* filenamestr;
43  while ((filenamestr = gSystem->GetDirEntry(dirhandle)))
44  {
45  TString filename(filenamestr);
46  if (filename=="." || filename=="..") continue;
47  if (gSystem->cd(filename.Data()))
48  {
49  if (!gSystem->AccessPathName(inputFilename.Data()))//return value is here inverted!
50  {
51  TString inputESDfile(workingDir);
52  inputESDfile += "/";
53  inputESDfile += filename;
54  inputESDfile += "/";
55  inputESDfile += inputFilename;
56  chain->Add(inputESDfile.Data());
57  printf("found file: %s\n", inputESDfile.Data());
58  }
59  gSystem->cd(workingDir.Data());
60  }
61  }
62 
63  //____________________________________________//
64  gROOT->LoadMacro("AliRelAlignerKalman.cxx++");
65  gROOT->LoadMacro("AliRelAlignerKalmanArray.cxx++");
66  gROOT->LoadMacro("AliAnalysisTaskITSTPCalignment.cxx++");
67 
68  // analysis manager
69  AliAnalysisManager *mgr = new AliAnalysisManager("ITSTPCalignmentAnalysisManager");
70  AliVEventHandler* esdH = new AliESDInputHandler;
71  mgr->SetInputEventHandler(esdH);
72 
73  //create the task
74  AliAnalysisTaskITSTPCalignment *taskITSTPCalignment =
75  new AliAnalysisTaskITSTPCalignment("TaskITSTPCalignment");
76  taskITSTPCalignment->SetDoQA(kTRUE);
77 
78  mgr->AddTask(taskITSTPCalignment);
79 
80  AliAnalysisDataContainer* cinput0 = mgr->GetCommonInputContainer();
81  AliAnalysisDataContainer* coutput0 = mgr->CreateContainer("outputArray",
82  AliRelAlignerKalmanArray::Class(),
83  AliAnalysisManager::kOutputContainer,
84  outputArrayFilename.Data());
85  AliAnalysisDataContainer* coutput1 = mgr->CreateContainer("outputList",
86  TList::Class(),
87  AliAnalysisManager::kOutputContainer,
88  outputHistFilename.Data());
89 
90  mgr->ConnectInput(taskITSTPCalignment,0,cinput0);
91  mgr->ConnectOutput(taskITSTPCalignment,0,coutput0);
92  mgr->ConnectOutput(taskITSTPCalignment,1,coutput1);
93  if (!mgr->InitAnalysis()) return;
94  mgr->PrintStatus();
95 
96  mgr->StartAnalysis("local",chain);
97 }
98 
99 //_________________________________________________//
100 void runInteractive(const char* collectionName = "tag.xml") {
101  gSystem->Load("libProofPlayer");
102 
103  TString outputArrayFilename = "ITSTPCalignmentArray.root";
104  TString outputHistFilename = "ITSTPCalignmentHist.root";
105 
106  printf("*** Connect to AliEn ***\n");
107  TGrid::Connect("alien://");
108 
109  //____________________________________________________//
110  //_____________Setting up the par files_______________//
111  //____________________________________________________//
112  setupPar("STEERBase");
113  gSystem->Load("libSTEERBase");
114  setupPar("ESD");
115  gSystem->Load("libVMC");
116  gSystem->Load("libESD");
117  setupPar("AOD");
118  gSystem->Load("libAOD");
119  setupPar("ANALYSIS");
120  gSystem->Load("libANALYSIS");
121  setupPar("ANALYSISalice");
122  gSystem->Load("libANALYSISalice");
123  //____________________________________________________//
124 
125  //____________________________________________//
126  AliTagAnalysis *tagAnalysis = new AliTagAnalysis("ESD");
127 
128  AliRunTagCuts *runCuts = new AliRunTagCuts();
129  AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
130  AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
131  AliEventTagCuts *evCuts = new AliEventTagCuts();
132 
133  //grid tags
134  TAlienCollection* coll = TAlienCollection::Open(collectionName);
135  TGridResult* TagResult = coll->GetGridResult("",0,0);
136  tagAnalysis->ChainGridTags(TagResult);
137  TChain* chain = 0x0;
138  chain = tagAnalysis->QueryTags(runCuts,lhcCuts,detCuts,evCuts);
139  chain->SetBranchStatus("*Calo*",0);
140 
141  //____________________________________________//
142  gROOT->LoadMacro("AliRelAlignerKalman.cxx++");
143  gROOT->LoadMacro("AliRelAlignerKalmanArray.cxx++");
144  gROOT->LoadMacro("AliAnalysisTaskITSTPCalignment.cxx++");
145 
146  // analysis manager
147  AliAnalysisManager *mgr = new AliAnalysisManager("ITSTPCalignmentAnalysisManager");
148  AliVEventHandler* esdH = new AliESDInputHandler;
149  mgr->SetInputEventHandler(esdH);
150 
151  //create the task
152  AliAnalysisTaskITSTPCalignment *taskITSTPCalignment =
153  new AliAnalysisTaskITSTPCalignment("TaskITSTPCalignment");
154  taskITSTPCalignment->SetDoQA(kTRUE);
155 
156  mgr->AddTask(taskITSTPCalignment);
157 
158  AliAnalysisDataContainer* cinput0 = mgr->GetCommonInputContainer();
159  AliAnalysisDataContainer* coutput0 = mgr->CreateContainer("outputArray",
160  AliRelAlignerKalmanArray::Class(),
161  AliAnalysisManager::kOutputContainer,
162  outputArrayFilename.Data());
163  AliAnalysisDataContainer* coutput1 = mgr->CreateContainer("outputList",
164  TList::Class(),
165  AliAnalysisManager::kOutputContainer,
166  outputHistFilename.Data());
167 
168  mgr->ConnectInput(taskITSTPCalignment,0,cinput0);
169  mgr->ConnectOutput(taskITSTPCalignment,0,coutput0);
170  mgr->ConnectOutput(taskITSTPCalignment,1,coutput1);
171  if (!mgr->InitAnalysis()) return;
172  mgr->PrintStatus();
173 
174  mgr->StartAnalysis("local",chain);
175 }
176 
177 //______________________________________________________________________________
178 Int_t setupPar(const char* pararchivename) {
180  // Setup PAR File//
182  if (pararchivename) {
183  char processline[1024];
184  sprintf(processline,".! tar xvzf %s.par",pararchivename);
185  gROOT->ProcessLine(processline);
186  const char* ocwd = gSystem->WorkingDirectory();
187  gSystem->ChangeDirectory(pararchivename);
188 
189  // check for BUILD.sh and execute
190  if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
191  printf("*******************************\n");
192  printf("*** Building PAR archive ***\n");
193  printf("*******************************\n");
194 
195  if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
196  Error("runAnalysis","Cannot Build the PAR Archive! - Abort!");
197  return -1;
198  }
199  }
200  // check for SETUP.C and execute
201  if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
202  printf("*******************************\n");
203  printf("*** Setup PAR archive ***\n");
204  printf("*******************************\n");
205  gROOT->Macro("PROOF-INF/SETUP.C");
206  }
207 
208  gSystem->ChangeDirectory("../");
209  }
210  return 1;
211 }
const char * filename
Definition: TestFCM.C:1
void runITSTPCalignment(UInt_t saveinterval=1000000)
TSystem * gSystem
void runLocal(const char *filenamestr="AliESDs.root")
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
Int_t setupPar(const char *pararchivename)
void runInteractive(const char *collectionName="tag.xml")