]>
Commit | Line | Data |
---|---|---|
504b172d | 1 | //____________________________________________________________________ |
2 | ////////////////////////////////////////////////////////////////////// | |
3 | // // | |
4 | // class AliRunLoader // | |
5 | // // | |
6 | // This class aims to be the unque interface for managing data I/O. // | |
7 | // It stores Loaders for all modules which, knows names // | |
8 | // of the files were data are to be stored. // | |
9 | // // | |
10 | // It aims to substitud AliRun in automatic data managing // | |
11 | // thus there is no necessity of loading gAlice from file in order // | |
12 | // to get access to the data. // | |
13 | // // | |
14 | // Logical place to put the specific Loader to the given // | |
15 | // detector is detector itself (i.e ITSLoader in ITS). // | |
16 | // But, to load detector object one need to load gAlice, and // | |
17 | // by the way all other detectors with their geometrieces and // | |
18 | // so on. So, if one need to open TPC clusters there is no // | |
19 | // principal need to read everything. // | |
20 | // // | |
21 | // // | |
22 | // When RunLoader is read from the file it does not connect to // | |
23 | // the folder structure automatically. It must be connected // | |
24 | // (mounted) manualy. Default event folder is defined by // | |
e191bb57 | 25 | // AliConfig::GetDefaultEventFolderName() // |
504b172d | 26 | // but can be mounted elsewhere. Usefull specially in merging case, // |
27 | // when more than pone session needs to be loaded // | |
28 | // // | |
29 | ////////////////////////////////////////////////////////////////////// | |
88cb7938 | 30 | |
4095d1ca | 31 | #include <TBranch.h> |
4095d1ca | 32 | #include <TFile.h> |
33 | #include <TFolder.h> | |
34 | #include <TGeometry.h> | |
35 | #include <TObjArray.h> | |
88cb7938 | 36 | #include <TString.h> |
024a7e64 | 37 | class TTask; |
88cb7938 | 38 | #include <TTree.h> |
88cb7938 | 39 | |
40 | #include "AliRun.h" | |
41 | #include "AliConfig.h" | |
42 | #include "AliLoader.h" | |
43 | #include "AliHeader.h" | |
44 | #include "AliStack.h" | |
88cb7938 | 45 | #include "AliDetector.h" |
024a7e64 | 46 | #include "AliRunLoader.h" |
88cb7938 | 47 | |
48 | ClassImp(AliRunLoader) | |
49 | ||
50 | AliRunLoader* AliRunLoader::fgRunLoader = 0x0; | |
51 | ||
52 | const TString AliRunLoader::fgkRunLoaderName("RunLoader"); | |
53 | ||
54 | const TString AliRunLoader::fgkHeaderBranchName("Header"); | |
55 | const TString AliRunLoader::fgkHeaderContainerName("TE"); | |
56 | const TString AliRunLoader::fgkKineContainerName("TreeK"); | |
57 | const TString AliRunLoader::fgkTrackRefsContainerName("TreeTR"); | |
58 | const TString AliRunLoader::fgkKineBranchName("Particles"); | |
59 | const TString AliRunLoader::fgkDefaultKineFileName("Kinematics.root"); | |
60 | const TString AliRunLoader::fgkDefaultTrackRefsFileName("TrackRefs.root"); | |
61 | const TString AliRunLoader::fgkGAliceName("gAlice"); | |
62 | /**************************************************************************/ | |
63 | ||
64 | AliRunLoader::AliRunLoader(): | |
65 | fLoaders(0x0), | |
66 | fEventFolder(0x0), | |
67 | fCurrentEvent(0), | |
68 | fGAFile(0x0), | |
69 | fHeader(0x0), | |
70 | fStack(0x0), | |
71 | fKineDataLoader(0x0), | |
72 | fTrackRefsDataLoader(0x0), | |
73 | fNEventsPerFile(1), | |
74 | fUnixDirName(".") | |
75 | { | |
76 | AliConfig::Instance();//force to build the folder structure | |
85a5290f | 77 | if (!fgRunLoader) fgRunLoader = this; |
88cb7938 | 78 | } |
79 | /**************************************************************************/ | |
80 | ||
81 | AliRunLoader::AliRunLoader(const char* eventfoldername): | |
82 | TNamed(fgkRunLoaderName,fgkRunLoaderName), | |
83 | fLoaders(new TObjArray()), | |
84 | fEventFolder(0x0), | |
85 | fCurrentEvent(0), | |
86 | fGAFile(0x0), | |
87 | fHeader(0x0), | |
88 | fStack(0x0), | |
89 | fKineDataLoader(new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics")), | |
90 | fTrackRefsDataLoader(new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References")), | |
91 | fNEventsPerFile(1), | |
92 | fUnixDirName(".") | |
93 | { | |
94 | //ctor | |
95 | SetEventFolderName(eventfoldername); | |
85a5290f | 96 | if (!fgRunLoader) fgRunLoader = this; |
88cb7938 | 97 | } |
98 | /**************************************************************************/ | |
99 | ||
024a7e64 | 100 | AliRunLoader::AliRunLoader(const AliRunLoader &rl): |
101 | TNamed(rl), | |
102 | fLoaders(0x0), | |
103 | fEventFolder(0x0), | |
104 | fCurrentEvent(0), | |
105 | fGAFile(0x0), | |
106 | fHeader(0x0), | |
107 | fStack(0x0), | |
108 | fKineDataLoader(0x0), | |
109 | fTrackRefsDataLoader(0x0), | |
110 | fNEventsPerFile(0), | |
111 | fUnixDirName(".") | |
112 | { | |
113 | // | |
114 | // Copy ctor | |
115 | // | |
116 | rl.Copy(*this); | |
117 | } | |
118 | /**************************************************************************/ | |
119 | ||
88cb7938 | 120 | AliRunLoader::~AliRunLoader() |
121 | { | |
f2a509af | 122 | //dtor |
1bb20a37 | 123 | if (fgRunLoader == this) fgRunLoader = 0x0; |
124 | ||
88cb7938 | 125 | UnloadHeader(); |
126 | UnloadgAlice(); | |
127 | ||
128 | if(fLoaders) { | |
129 | fLoaders->SetOwner(); | |
130 | delete fLoaders; | |
131 | } | |
132 | ||
133 | delete fKineDataLoader; | |
134 | delete fTrackRefsDataLoader; | |
135 | ||
136 | ||
137 | RemoveEventFolder(); | |
138 | ||
139 | //fEventFolder is deleted by the way of removing - TopAliceFolder owns it | |
140 | delete fHeader; | |
141 | delete fStack; | |
142 | delete fGAFile; | |
143 | } | |
144 | /**************************************************************************/ | |
145 | ||
85a5290f | 146 | AliRunLoader::AliRunLoader(TFolder* topfolder): |
147 | TNamed(fgkRunLoaderName,fgkRunLoaderName), | |
148 | fLoaders(new TObjArray()), | |
149 | fEventFolder(topfolder), | |
150 | fCurrentEvent(0), | |
151 | fGAFile(0x0), | |
152 | fHeader(0x0), | |
153 | fStack(0x0), | |
154 | fKineDataLoader(new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics")), | |
155 | fTrackRefsDataLoader(new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References")), | |
156 | fNEventsPerFile(1), | |
157 | fUnixDirName(".") | |
88cb7938 | 158 | { |
f2a509af | 159 | //ctor |
88cb7938 | 160 | if(topfolder == 0x0) |
161 | { | |
131d919a | 162 | TString errmsg("Parameter is NULL"); |
163 | Error("AliRunLoader(TFolder*)","%s",errmsg.Data()); | |
164 | throw errmsg; | |
88cb7938 | 165 | return; |
166 | } | |
88cb7938 | 167 | |
168 | TObject* obj = fEventFolder->FindObject(fgkRunLoaderName); | |
169 | if (obj) | |
170 | { //if it is, then sth. is going wrong... exits aliroot session | |
131d919a | 171 | TString errmsg("In Event Folder Named "); |
172 | errmsg+=fEventFolder->GetName(); | |
173 | errmsg+=" object named "+fgkRunLoaderName+" already exists. I am confused ..."; | |
174 | ||
175 | Error("AliRunLoader(const char*)","%s",errmsg.Data()); | |
176 | throw errmsg; | |
88cb7938 | 177 | return;//never reached |
178 | } | |
131d919a | 179 | |
180 | if (!fgRunLoader) fgRunLoader = this; | |
88cb7938 | 181 | |
88cb7938 | 182 | fEventFolder->Add(this);//put myself to the folder to accessible for all |
183 | ||
184 | } | |
185 | /**************************************************************************/ | |
186 | ||
024a7e64 | 187 | void AliRunLoader::Copy(TObject &) const |
188 | { | |
189 | Fatal("Copy","Not implemented"); | |
190 | } | |
191 | /**************************************************************************/ | |
192 | ||
88cb7938 | 193 | Int_t AliRunLoader::GetEvent(Int_t evno) |
194 | { | |
195 | //Gets event number evno | |
196 | //Reloads all data properly | |
197 | if (fCurrentEvent == evno) return 0; | |
198 | ||
199 | if (evno < 0) | |
200 | { | |
201 | Error("GetEvent","Can not give the event with negative number"); | |
202 | return 4; | |
203 | } | |
204 | ||
205 | if (evno >= GetNumberOfEvents()) | |
206 | { | |
207 | Error("GetEvent","There is no event with number %d",evno); | |
208 | return 3; | |
209 | } | |
210 | ||
211 | if (GetDebug()) | |
212 | { | |
213 | Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); | |
214 | Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); | |
215 | Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); | |
216 | Info("GetEvent"," GETTING EVENT %d",evno); | |
217 | Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); | |
218 | Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); | |
219 | Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); | |
220 | } | |
221 | ||
222 | fCurrentEvent = evno; | |
223 | ||
224 | Int_t retval; | |
225 | ||
226 | //Reload header (If header was loaded) | |
227 | if (GetHeader()) | |
228 | { | |
229 | retval = TreeE()->GetEvent(fCurrentEvent); | |
230 | if ( retval == 0) | |
231 | { | |
232 | Error("GetEvent","Cannot find event: %d\n ",fCurrentEvent); | |
233 | return 5; | |
234 | } | |
235 | } | |
236 | //Reload stack (If header was loaded) | |
237 | if (TreeE()) fStack = GetHeader()->Stack(); | |
238 | //Set event folder in stack (it does not mean that we read kinematics from file) | |
239 | if (fStack) | |
240 | { | |
241 | fStack->SetEventFolderName(fEventFolder->GetName()); | |
242 | } | |
243 | else | |
244 | { | |
245 | Warning("GetEvent","Stack not found in header"); | |
246 | } | |
247 | ||
248 | retval = SetEvent(); | |
249 | if (retval) | |
250 | { | |
251 | Error("GetEvent","Error occured while setting event %d",evno); | |
252 | return 1; | |
253 | } | |
254 | ||
255 | //Post Track References | |
256 | retval = fTrackRefsDataLoader->GetEvent(); | |
257 | if (retval) | |
258 | { | |
259 | Error("GetEvent","Error occured while GetEvent for Track References. Event %d",evno); | |
260 | return 2; | |
261 | } | |
262 | ||
263 | //Read Kinematics if loaded | |
264 | fKineDataLoader->GetEvent(); | |
265 | if (retval) | |
266 | { | |
267 | Error("GetEvent","Error occured while GetEvent for Kinematics. Event %d",evno); | |
268 | return 2; | |
269 | } | |
270 | ||
271 | if (fStack && fKineDataLoader->GetBaseLoader(0)->IsLoaded()) fStack->GetEvent(); | |
272 | ||
273 | //Trigger data reloading in all loaders | |
274 | TIter next(fLoaders); | |
275 | AliLoader *loader; | |
276 | while((loader = (AliLoader*)next())) | |
277 | { | |
278 | retval = loader->GetEvent(); | |
279 | if (retval) | |
280 | { | |
281 | Error("GetEvent","Error occured while getting event for %s. Event %d.", | |
282 | loader->GetDetectorName().Data(), evno); | |
283 | return 3; | |
284 | } | |
285 | } | |
286 | ||
287 | SetDetectorAddresses(); | |
288 | ||
289 | return 0; | |
290 | } | |
291 | /**************************************************************************/ | |
292 | Int_t AliRunLoader::SetEvent() | |
293 | { | |
f2a509af | 294 | //if kinematics was loaded Cleans folder data |
295 | ||
88cb7938 | 296 | Int_t retval; |
297 | ||
298 | retval = fKineDataLoader->SetEvent(); | |
299 | if (retval) | |
300 | { | |
301 | Error("SetEvent","SetEvent for Kinamtics Data Loader retutned error."); | |
302 | return retval; | |
303 | } | |
304 | retval = fTrackRefsDataLoader->SetEvent(); | |
305 | if (retval) | |
306 | { | |
307 | Error("SetEvent","SetEvent for Track References Data Loader retutned error."); | |
308 | return retval; | |
309 | } | |
310 | ||
311 | TIter next(fLoaders); | |
312 | AliLoader *loader; | |
313 | while((loader = (AliLoader*)next())) | |
314 | { | |
315 | retval = loader->SetEvent(); | |
316 | if (retval) | |
317 | { | |
318 | Error("SetEvent","SetEvent for %s Data Loader retutned error.",loader->GetName()); | |
319 | return retval; | |
320 | } | |
321 | } | |
322 | ||
323 | return 0; | |
324 | } | |
325 | /**************************************************************************/ | |
326 | ||
327 | Int_t AliRunLoader::SetEventNumber(Int_t evno) | |
328 | { | |
329 | //cleans folders and sets the root dirs in files | |
330 | if (fCurrentEvent == evno) return 0; | |
331 | fCurrentEvent = evno; | |
332 | return SetEvent(); | |
333 | } | |
334 | ||
335 | /**************************************************************************/ | |
336 | AliRunLoader* AliRunLoader::Open | |
337 | (const char* filename, const char* eventfoldername, Option_t* option) | |
338 | { | |
339 | //Opens a desired file 'filename' | |
340 | //gets the the run-Loader and mounts it desired folder | |
341 | //returns the pointer to run Loader which can be further used for accessing data | |
342 | //in case of error returns NULL | |
343 | ||
024a7e64 | 344 | static const TString kwebaddress("http://alisoft.cern.ch/people/skowron/codedoc/split/index.html"); |
d0d4a6b3 | 345 | if (AliLoader::GetDebug()) |
88cb7938 | 346 | ::Info("AliRunLoader::Open", |
024a7e64 | 347 | "\n\n\nNew I/O strcture: See more info:\n %s\n\n\n",kwebaddress.Data()); |
88cb7938 | 348 | |
349 | AliRunLoader* result = 0x0; | |
350 | ||
351 | /* ************************************************ */ | |
352 | /* Chceck if folder with given name already exists */ | |
353 | /* ************************************************ */ | |
354 | ||
355 | TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername); | |
356 | if(obj) | |
357 | { | |
358 | TFolder* fold = dynamic_cast<TFolder*>(obj); | |
359 | if (fold == 0x0) | |
360 | { | |
361 | ::Error("AliRunLoader::Open","Such a obejct already exists in top alice folder and it is not a folder."); | |
362 | return 0x0; | |
363 | } | |
364 | ||
365 | //check if we can get RL from that folder | |
366 | result = AliRunLoader::GetRunLoader(eventfoldername); | |
367 | if (result == 0x0) | |
368 | { | |
369 | ::Error("AliRunLoader::Open", | |
370 | "Folder %s already exists, and can not find session there. Can not mount.",eventfoldername); | |
371 | return 0x0; | |
372 | } | |
373 | ||
374 | if (result->GetFileName().CompareTo(filename) != 0) | |
375 | { | |
376 | ::Error("AliRunLoader::Open","Other file is mounted in demanded folder. Can not mount."); | |
377 | return 0x0; | |
378 | } | |
379 | ||
380 | //check if now is demanded (re)creation | |
381 | if ( AliLoader::TestFileOption(option) == kFALSE) | |
382 | { | |
383 | ::Error("AliRunLoader::Open", | |
384 | "Session already exists in folder %s and this session option is %s. Unable to proceed.", | |
385 | eventfoldername,option); | |
386 | return 0x0; | |
387 | } | |
388 | ||
389 | //check if demanded option is update and existing one | |
390 | TString tmpstr(option); | |
391 | if ( (tmpstr.CompareTo("update",TString::kIgnoreCase) == 0) && | |
392 | (result->fGAFile->IsWritable() == kFALSE) ) | |
393 | { | |
394 | ::Error("AliRunLoader::Open", | |
395 | "Session already exists in folder %s and is not writable while this session option is %s. Unable to proceed.", | |
396 | eventfoldername,option); | |
397 | return 0x0; | |
398 | } | |
399 | ||
400 | ::Warning("AliRunLoader::Open","Session is already opened and mounted in demanded folder"); | |
401 | return result; | |
402 | } //end of checking in case of existance of object named identically that folder session is being opened | |
403 | ||
404 | ||
405 | TFile * gAliceFile = TFile::Open(filename,option);//open a file | |
406 | if (!gAliceFile) | |
407 | {//null pointer returned | |
408 | ::Error("AliRunLoader::Open","Can not open file %s.",filename); | |
409 | return 0x0; | |
410 | } | |
411 | ||
412 | if (gAliceFile->IsOpen() == kFALSE) | |
413 | {//pointer to valid object returned but file is not opened | |
414 | ::Error("AliRunLoader::Open","Can not open file %s.",filename); | |
415 | return 0x0; | |
416 | } | |
417 | ||
418 | //if file is "read" or "update" than we try to find AliRunLoader there - if not found cry and exit | |
419 | //else create new AliRunLoader | |
420 | if ( AliLoader::TestFileOption(option) ) | |
421 | { | |
d0d4a6b3 | 422 | if (AliLoader::GetDebug()) |
88cb7938 | 423 | ::Info("AliRunLoader::Open","Reading RL from file"); |
424 | ||
425 | result = dynamic_cast<AliRunLoader*>(gAliceFile->Get(fgkRunLoaderName));//get the run Loader from the file | |
426 | if (result == 0x0) | |
427 | {//didn't get | |
428 | ::Error("AliRunLoader::Open","Can not find run-Loader in file %s.",filename); | |
429 | delete gAliceFile;//close the file | |
430 | return 0x0; | |
431 | } | |
432 | Int_t tmp = result->SetEventFolderName(eventfoldername);//mount a event folder | |
433 | if (tmp)//if SetEvent returned error | |
434 | { | |
435 | ::Error("AliRunLoader::Open","Can not mount event in folder %s.",eventfoldername); | |
436 | delete result; //delete run-Loader | |
437 | delete gAliceFile;//close the file | |
438 | return 0x0; | |
439 | } | |
440 | } | |
441 | else | |
442 | { | |
d0d4a6b3 | 443 | if (AliLoader::GetDebug()) |
88cb7938 | 444 | ::Info("AliRunLoader::Open","Creating new AliRunLoader. Folder name is %s",eventfoldername); |
131d919a | 445 | try |
446 | { | |
447 | result = new AliRunLoader(eventfoldername); | |
448 | } | |
449 | catch (TString& errmsg) | |
450 | { | |
451 | ::Error("Open","AliRunLoader constrcutor has thrown exception: %s\n",errmsg.Data()); | |
452 | delete result; | |
453 | delete gAliceFile;//close the file | |
454 | return 0x0; | |
455 | } | |
88cb7938 | 456 | } |
457 | ||
458 | //procedure for extracting dir name from the file name | |
459 | TString fname(filename); | |
460 | Int_t nsl = fname.Last('/');//look for slash in file name | |
461 | TString dirname; | |
462 | if (nsl < 0) | |
463 | {//slash not found | |
464 | Int_t nsl = fname.Last(':');//look for colon e.g. rfio:galice.root | |
465 | if (nsl < 0) dirname = ".";//not found | |
466 | else dirname = fname.Remove(nsl);//found | |
467 | } | |
468 | else dirname = fname.Remove(nsl);//slash found | |
469 | ||
d0d4a6b3 | 470 | if (AliLoader::GetDebug()) |
88cb7938 | 471 | ::Info("AliRunLoader::Open","Dir name is : %s",dirname.Data()); |
472 | ||
473 | result->SetDirName(dirname); | |
474 | result->SetGAliceFile(gAliceFile);//set the pointer to gAliceFile | |
85a5290f | 475 | if (!fgRunLoader) fgRunLoader = result; //PH get access from any place |
88cb7938 | 476 | return result; |
477 | } | |
478 | /**************************************************************************/ | |
479 | Int_t AliRunLoader::GetNumberOfEvents() | |
480 | { | |
481 | //returns number of events in Run | |
482 | Int_t retval; | |
483 | if( TreeE() == 0x0 ) | |
484 | { | |
485 | retval = LoadHeader(); | |
486 | if (retval) | |
487 | { | |
488 | Error("GetNumberOfEvents","Error occured while loading header"); | |
489 | return -1; | |
490 | } | |
491 | } | |
492 | return (Int_t)TreeE()->GetEntries(); | |
493 | } | |
88cb7938 | 494 | /**************************************************************************/ |
f2a509af | 495 | |
88cb7938 | 496 | void AliRunLoader::MakeHeader() |
497 | { | |
498 | //Makes header and connects it to header tree (if it exists) | |
499 | if (GetDebug()) Info("MakeHeader",""); | |
500 | if(fHeader == 0x0) | |
501 | { | |
502 | if (GetDebug()) Info("MakeHeader","Creating new Header Object"); | |
503 | fHeader= new AliHeader(); | |
504 | } | |
505 | TTree* tree = TreeE(); | |
506 | if (tree) | |
507 | { | |
508 | if (GetDebug()) Info("MakeHeader","Got Tree from folder."); | |
509 | TBranch* branch = tree->GetBranch(fgkHeaderBranchName); | |
510 | if (branch == 0x0) | |
511 | { | |
512 | if (GetDebug()) Info("MakeHeader","Creating new branch"); | |
513 | branch = tree->Branch(fgkHeaderBranchName, "AliHeader", &fHeader, 4000, 0); | |
514 | branch->SetAutoDelete(kFALSE); | |
515 | } | |
516 | else | |
517 | { | |
518 | if (GetDebug()) Info("MakeHeader","Got Branch from Tree"); | |
519 | branch->SetAddress(&fHeader); | |
520 | tree->GetEvent(fCurrentEvent); | |
521 | fStack = fHeader->Stack(); //should be safe - if we created Stack, header returns pointer to the same object | |
522 | if (fStack) | |
523 | { | |
524 | fStack->SetEventFolderName(fEventFolder->GetName()); | |
525 | if (TreeK()) fStack->GetEvent(); | |
526 | } | |
527 | else | |
528 | { | |
529 | if (GetDebug()) Info("MakeHeader","Haeder do not have a stack."); | |
530 | } | |
531 | } | |
532 | } | |
533 | if (GetDebug()) Info("MakeHeader","Exiting MakeHeader method"); | |
534 | } | |
535 | /**************************************************************************/ | |
536 | ||
537 | void AliRunLoader::MakeStack() | |
538 | { | |
539 | //Creates the stack object - do not connect the tree | |
540 | if(fStack == 0x0) | |
541 | { | |
542 | fStack = new AliStack(10000); | |
543 | fStack->SetEventFolderName(fEventFolder->GetName()); | |
544 | } | |
545 | } | |
546 | ||
547 | /**************************************************************************/ | |
548 | ||
549 | void AliRunLoader::MakeTree(Option_t *option) | |
550 | { | |
551 | //Creates trees | |
552 | const char *oK = strstr(option,"K"); //Kine | |
553 | const char *oE = strstr(option,"E"); //Header | |
554 | ||
555 | if(oK && !TreeK()) | |
556 | { | |
557 | if (fKineDataLoader->GetBaseLoader(0)->IsLoaded() == kFALSE) | |
558 | { | |
559 | Error("MakeTree(\"K\")","Load Kinematics first"); | |
560 | } | |
561 | else | |
562 | { | |
563 | fKineDataLoader->MakeTree(); | |
564 | MakeStack(); | |
565 | fStack->ConnectTree(); | |
566 | WriteKinematics("OVERWRITE"); | |
567 | } | |
568 | } | |
569 | ||
570 | if(oE && !TreeE()) | |
571 | { | |
572 | fGAFile->cd(); | |
573 | TTree* tree = new TTree(fgkHeaderContainerName,"Tree with Headers"); | |
574 | GetEventFolder()->Add(tree); | |
575 | MakeHeader(); | |
576 | WriteHeader("OVERWRITE"); | |
577 | } | |
578 | ||
579 | TIter next(fLoaders); | |
580 | AliLoader *loader; | |
581 | while((loader = (AliLoader*)next())) | |
582 | { | |
583 | loader->MakeTree(option); | |
584 | } | |
585 | ||
586 | } | |
587 | /**************************************************************************/ | |
588 | ||
589 | Int_t AliRunLoader::LoadgAlice() | |
590 | { | |
591 | //Loads gAlice from file | |
592 | if (GetAliRun()) | |
593 | { | |
594 | Warning("LoadgAlice","AliRun is already in folder. Unload first."); | |
595 | return 0; | |
596 | } | |
597 | AliRun* alirun = dynamic_cast<AliRun*>(fGAFile->Get(fgkGAliceName)); | |
598 | if (alirun == 0x0) | |
599 | { | |
600 | Error("LoadgAlice"," Can not find gAlice in file %s",fGAFile->GetName()); | |
601 | return 2; | |
602 | } | |
603 | alirun->SetRunLoader(this); | |
604 | if (gAlice) | |
605 | { | |
606 | Warning("LoadgAlice","gAlice already exists. Putting retrived object in folder named %s", | |
607 | GetEventFolder()->GetName()); | |
608 | } | |
609 | else | |
610 | { | |
611 | gAlice = alirun; | |
612 | } | |
613 | SetDetectorAddresses();//calls SetTreeAddress for all detectors | |
614 | return 0; | |
615 | } | |
616 | /**************************************************************************/ | |
617 | ||
618 | Int_t AliRunLoader::LoadHeader() | |
619 | { | |
f2a509af | 620 | //loads treeE and reads header object for current event |
88cb7938 | 621 | if (TreeE()) |
622 | { | |
623 | Warning("LoadHeader","Header is already loaded. Use ReloadHeader to force reload. Nothing done"); | |
624 | return 0; | |
625 | } | |
626 | ||
627 | if (GetEventFolder() == 0x0) | |
628 | { | |
581ab618 | 629 | Error("LoadHeader","Event folder not specified yet"); |
88cb7938 | 630 | return 1; |
631 | } | |
632 | ||
633 | if (fGAFile == 0x0) | |
634 | { | |
581ab618 | 635 | Error("LoadHeader","Session not opened. Use AliRunLoader::Open"); |
88cb7938 | 636 | return 2; |
637 | } | |
638 | ||
639 | if (fGAFile->IsOpen() == kFALSE) | |
640 | { | |
581ab618 | 641 | Error("LoadHeader","Session not opened. Use AliRunLoader::Open"); |
88cb7938 | 642 | return 2; |
643 | } | |
644 | ||
645 | TTree* tree = dynamic_cast<TTree*>(fGAFile->Get(fgkHeaderContainerName)); | |
646 | if (tree == 0x0) | |
647 | { | |
131d919a | 648 | Error("LoadHeader","Can not find header tree named %s in file %s", |
88cb7938 | 649 | fgkHeaderContainerName.Data(),fGAFile->GetName()); |
650 | return 2; | |
651 | } | |
652 | ||
653 | if (tree == TreeE()) return 0; | |
654 | ||
655 | CleanHeader(); | |
656 | GetEventFolder()->Add(tree); | |
657 | MakeHeader();//creates header object and connects to tree | |
658 | return 0; | |
659 | ||
660 | } | |
661 | /**************************************************************************/ | |
662 | ||
663 | Int_t AliRunLoader::LoadKinematics(Option_t* option) | |
664 | { | |
665 | //Loads the kinematics | |
666 | Int_t retval = fKineDataLoader->GetBaseLoader(0)->Load(option); | |
667 | if (retval) | |
668 | { | |
669 | Error("LoadKinematics","Error occured while loading kinamatics tree."); | |
670 | return retval; | |
671 | } | |
443b7449 | 672 | if (fStack) |
673 | { | |
674 | retval = fStack->GetEvent(); | |
675 | if ( retval == kFALSE) | |
676 | { | |
677 | Error("LoadKinematics","Error occured while loading kinamatics tree."); | |
678 | return retval; | |
679 | } | |
680 | ||
681 | } | |
88cb7938 | 682 | return 0; |
683 | } | |
684 | /**************************************************************************/ | |
685 | ||
686 | Int_t AliRunLoader::OpenDataFile(const TString& filename,TFile*& file,TDirectory*& dir,Option_t* opt,Int_t cl) | |
687 | { | |
688 | //Opens File with kinematics | |
689 | if (file) | |
690 | { | |
691 | if (file->IsOpen() == kFALSE) | |
692 | {//pointer is not null but file is not opened | |
693 | Warning("OpenDataFile","Pointer to file is not null, but file is not opened");//risky any way | |
694 | delete file; | |
695 | file = 0x0; //proceed with opening procedure | |
696 | } | |
697 | else | |
698 | { | |
699 | Warning("OpenDataFile","File %s already opened",filename.Data()); | |
700 | return 0; | |
701 | } | |
702 | } | |
703 | //try to find if that file is opened somewere else | |
704 | file = (TFile *)( gROOT->GetListOfFiles()->FindObject(filename) ); | |
705 | if (file) | |
706 | { | |
707 | if(file->IsOpen() == kTRUE) | |
708 | { | |
709 | Warning("OpenDataFile","File %s already opened by sombody else.",file->GetName()); | |
710 | return 0; | |
711 | } | |
712 | } | |
713 | ||
714 | file = TFile::Open(filename,opt); | |
715 | if (file == 0x0) | |
716 | {//file is null | |
717 | Error("LoadKinematics","Can not open file %s",filename.Data()); | |
718 | return 1; | |
719 | } | |
720 | if (file->IsOpen() == kFALSE) | |
721 | {//file is not opened | |
722 | Error("LoadKinematics","Can not open file %s",filename.Data()); | |
723 | return 1; | |
724 | } | |
725 | ||
726 | file->SetCompressionLevel(cl); | |
727 | ||
728 | dir = AliLoader::ChangeDir(file,fCurrentEvent); | |
729 | if (dir == 0x0) | |
730 | { | |
731 | Error("OpenKineFile","Can not change to root directory in file %s",filename.Data()); | |
732 | return 3; | |
733 | } | |
734 | return 0; | |
735 | } | |
736 | /**************************************************************************/ | |
737 | ||
738 | TTree* AliRunLoader::TreeE() const | |
739 | { | |
740 | //returns the tree from folder; shortcut method | |
443b7449 | 741 | if (GetDebug() > 10) fEventFolder->ls(); |
88cb7938 | 742 | TObject *obj = fEventFolder->FindObject(fgkHeaderContainerName); |
743 | return (obj)?dynamic_cast<TTree*>(obj):0x0; | |
744 | } | |
745 | /**************************************************************************/ | |
746 | ||
747 | AliHeader* AliRunLoader::GetHeader() const | |
748 | { | |
f2a509af | 749 | //returns pointer header object |
88cb7938 | 750 | return fHeader; |
751 | } | |
752 | /**************************************************************************/ | |
753 | ||
754 | TTree* AliRunLoader::TreeK() const | |
755 | { | |
756 | //returns the tree from folder; shortcut method | |
757 | TObject *obj = GetEventFolder()->FindObject(fgkKineContainerName); | |
758 | return (obj)?dynamic_cast<TTree*>(obj):0x0; | |
759 | } | |
760 | /**************************************************************************/ | |
761 | ||
762 | TTree* AliRunLoader::TreeTR() const | |
763 | { | |
764 | //returns the tree from folder; shortcut method | |
765 | TObject* obj = GetEventFolder()->FindObject(fgkTrackRefsContainerName); | |
766 | return (obj)?dynamic_cast<TTree*>(obj):0x0; | |
767 | } | |
768 | /**************************************************************************/ | |
769 | ||
770 | AliRun* AliRunLoader::GetAliRun() const | |
771 | { | |
772 | //returns AliRun which sits in the folder | |
773 | if (fEventFolder == 0x0) return 0x0; | |
774 | TObject *obj = fEventFolder->FindObject(fgkGAliceName); | |
775 | return (obj)?dynamic_cast<AliRun*>(obj):0x0; | |
776 | } | |
777 | /**************************************************************************/ | |
778 | ||
d1898505 | 779 | Int_t AliRunLoader::WriteGeometry(Option_t* /*opt*/) |
88cb7938 | 780 | { |
f2a509af | 781 | //writes geometry to the file |
88cb7938 | 782 | fGAFile->cd(); |
783 | TGeometry* geo = GetAliRun()->GetGeometry(); | |
784 | if (geo == 0x0) | |
785 | { | |
786 | Error("WriteGeometry","Can not get geometry from gAlice"); | |
787 | return 1; | |
788 | } | |
789 | geo->Write(); | |
790 | return 0; | |
791 | } | |
792 | /**************************************************************************/ | |
793 | ||
794 | Int_t AliRunLoader::WriteHeader(Option_t* opt) | |
795 | { | |
f2a509af | 796 | //writes treeE |
88cb7938 | 797 | if (GetDebug()) Info("WriteHeader"," WRITING HEADER"); |
798 | ||
799 | TTree* tree = TreeE(); | |
800 | if ( tree == 0x0) | |
801 | { | |
802 | Warning("WriteHeader","Can not find Header Tree in Folder"); | |
803 | return 0; | |
804 | } | |
805 | if (fGAFile->IsWritable() == kFALSE) | |
806 | { | |
807 | Error("WriteHeader","File %s is not writable",fGAFile->GetName()); | |
808 | return 1; | |
809 | } | |
810 | ||
811 | TObject* obj = fGAFile->Get(fgkHeaderContainerName); | |
812 | if (obj) | |
813 | { //if they exist, see if option OVERWRITE is used | |
814 | TString tmp(opt); | |
815 | if(tmp.Contains("OVERWRITE",TString::kIgnoreCase) == 0) | |
816 | {//if it is not used - give an error message and return an error code | |
817 | Error("WriteHeader","Tree already exisists. Use option \"OVERWRITE\" to overwrite previous data"); | |
818 | return 3; | |
819 | } | |
820 | } | |
821 | fGAFile->cd(); | |
822 | tree->SetDirectory(fGAFile); | |
823 | tree->Write(0,TObject::kOverwrite); | |
824 | ||
825 | if (GetDebug()) Info("WriteHeader","WRITTEN\n\n"); | |
826 | ||
827 | return 0; | |
828 | } | |
829 | /**************************************************************************/ | |
830 | ||
d1898505 | 831 | Int_t AliRunLoader::WriteAliRun(Option_t* /*opt*/) |
88cb7938 | 832 | { |
f2a509af | 833 | //writes AliRun object to the file |
88cb7938 | 834 | fGAFile->cd(); |
f2a509af | 835 | if (GetAliRun()) GetAliRun()->Write(); |
88cb7938 | 836 | return 0; |
837 | } | |
838 | /**************************************************************************/ | |
839 | ||
840 | Int_t AliRunLoader::WriteKinematics(Option_t* opt) | |
841 | { | |
f2a509af | 842 | //writes Kinematics |
88cb7938 | 843 | return fKineDataLoader->GetBaseLoader(0)->WriteData(opt); |
844 | } | |
845 | /**************************************************************************/ | |
846 | Int_t AliRunLoader::WriteTrackRefs(Option_t* opt) | |
847 | { | |
f2a509af | 848 | //writes Track References tree |
88cb7938 | 849 | return fTrackRefsDataLoader->GetBaseLoader(0)->WriteData(opt); |
850 | } | |
851 | /**************************************************************************/ | |
852 | ||
853 | Int_t AliRunLoader::WriteHits(Option_t* opt) | |
854 | { | |
855 | //Calls WriteHits for all loaders | |
856 | Int_t res; | |
857 | Int_t result = 0; | |
858 | TIter next(fLoaders); | |
859 | AliLoader *loader; | |
860 | while((loader = (AliLoader*)next())) | |
861 | { | |
862 | res = loader->WriteHits(opt); | |
863 | if (res) | |
864 | { | |
865 | Error("WriteHits","Failed to write hits for %s (%d)",loader->GetDetectorName().Data(),res); | |
866 | result = 1; | |
867 | } | |
868 | } | |
869 | return result; | |
870 | } | |
871 | /**************************************************************************/ | |
872 | ||
873 | Int_t AliRunLoader::WriteSDigits(Option_t* opt) | |
874 | { | |
f2a509af | 875 | //Calls WriteSDigits for all loaders |
88cb7938 | 876 | Int_t res; |
877 | Int_t result = 0; | |
878 | TIter next(fLoaders); | |
879 | AliLoader *loader; | |
880 | while((loader = (AliLoader*)next())) | |
881 | { | |
882 | res = loader->WriteSDigits(opt); | |
883 | if (res) | |
884 | { | |
885 | Error("WriteSDigits","Failed to write summable digits for %s.",loader->GetDetectorName().Data()); | |
886 | result = 1; | |
887 | } | |
888 | } | |
889 | return result; | |
890 | } | |
891 | /**************************************************************************/ | |
892 | ||
893 | Int_t AliRunLoader::WriteDigits(Option_t* opt) | |
894 | { | |
f2a509af | 895 | //Calls WriteDigits for all loaders |
88cb7938 | 896 | Int_t res; |
897 | Int_t result = 0; | |
898 | TIter next(fLoaders); | |
899 | AliLoader *loader; | |
900 | while((loader = (AliLoader*)next())) | |
901 | { | |
902 | res = loader->WriteDigits(opt); | |
903 | if (res) | |
904 | { | |
905 | Error("WriteDigits","Failed to write digits for %s.",loader->GetDetectorName().Data()); | |
906 | result = 1; | |
907 | } | |
908 | } | |
909 | return result; | |
910 | } | |
911 | /**************************************************************************/ | |
912 | ||
913 | Int_t AliRunLoader::WriteRecPoints(Option_t* opt) | |
914 | { | |
f2a509af | 915 | //Calls WriteRecPoints for all loaders |
88cb7938 | 916 | Int_t res; |
917 | Int_t result = 0; | |
918 | TIter next(fLoaders); | |
919 | AliLoader *loader; | |
920 | while((loader = (AliLoader*)next())) | |
921 | { | |
922 | res = loader->WriteRecPoints(opt); | |
923 | if (res) | |
924 | { | |
925 | Error("WriteRecPoints","Failed to write Reconstructed Points for %s.", | |
926 | loader->GetDetectorName().Data()); | |
927 | result = 1; | |
928 | } | |
929 | } | |
930 | return result; | |
931 | } | |
932 | /**************************************************************************/ | |
933 | ||
934 | Int_t AliRunLoader::WriteTracks(Option_t* opt) | |
935 | { | |
f2a509af | 936 | //Calls WriteTracks for all loaders |
88cb7938 | 937 | Int_t res; |
938 | Int_t result = 0; | |
939 | TIter next(fLoaders); | |
940 | AliLoader *loader; | |
941 | while((loader = (AliLoader*)next())) | |
942 | { | |
943 | res = loader->WriteTracks(opt); | |
944 | if (res) | |
945 | { | |
946 | Error("WriteTracks","Failed to write Tracks for %s.", | |
947 | loader->GetDetectorName().Data()); | |
948 | result = 1; | |
949 | } | |
950 | } | |
951 | return result; | |
952 | } | |
953 | /**************************************************************************/ | |
954 | ||
d1898505 | 955 | Int_t AliRunLoader::WriteRunLoader(Option_t* /*opt*/) |
88cb7938 | 956 | { |
f2a509af | 957 | //Writes itself to the file |
88cb7938 | 958 | CdGAFile(); |
959 | this->Write(0,TObject::kOverwrite); | |
960 | return 0; | |
961 | } | |
962 | /**************************************************************************/ | |
963 | ||
964 | Int_t AliRunLoader::SetEventFolderName(const TString& name) | |
f2a509af | 965 | { |
966 | //sets top folder name for this run; of alread | |
88cb7938 | 967 | if (name.IsNull()) |
968 | { | |
969 | Error("SetTopFolderName","Name is empty"); | |
970 | return 1; | |
971 | } | |
972 | ||
973 | //check if such a folder already exists - try to find it in alice top folder | |
974 | TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(name); | |
975 | if(obj) | |
976 | { | |
977 | TFolder* fold = dynamic_cast<TFolder*>(obj); | |
978 | if (fold == 0x0) | |
979 | { | |
980 | Error("SetTopFolderName","Such a obejct already exists in top alice folder and it is not a folder."); | |
981 | return 2; | |
982 | } | |
983 | //folder which was found is our folder | |
984 | if (fEventFolder == fold) | |
985 | { | |
986 | return 0; | |
987 | } | |
988 | else | |
989 | { | |
990 | Error("SetTopFolderName","Such a folder already exists in top alice folder. Can not mount."); | |
991 | return 2; | |
992 | } | |
993 | } | |
994 | ||
995 | //event is alredy connected, just change name of the folder | |
996 | if (fEventFolder) | |
997 | { | |
998 | fEventFolder->SetName(name); | |
999 | return 0; | |
1000 | } | |
1001 | ||
1002 | if (fKineDataLoader == 0x0) | |
1003 | fKineDataLoader = new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics"); | |
1004 | ||
1005 | if ( fTrackRefsDataLoader == 0x0) | |
1006 | fTrackRefsDataLoader = new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References"); | |
1007 | ||
1008 | //build the event folder structure | |
1009 | if (GetDebug()) Info("SetEventFolderName","Creating new event folder named %s",name.Data()); | |
1010 | fEventFolder = AliConfig::Instance()->BuildEventFolder(name,"Event Folder"); | |
1011 | fEventFolder->Add(this);//put myself to the folder to accessible for all | |
1012 | ||
1013 | if (Stack()) Stack()->SetEventFolderName(fEventFolder->GetName()); | |
1014 | TIter next(fLoaders); | |
1015 | AliLoader *loader; | |
1016 | while((loader = (AliLoader*)next())) | |
1017 | { | |
1018 | loader->Register(fEventFolder);//build folder structure for this detector | |
1019 | } | |
1020 | ||
1021 | fKineDataLoader->SetEventFolder(GetEventFolder()); | |
1022 | fTrackRefsDataLoader->SetEventFolder(GetEventFolder()); | |
1023 | fKineDataLoader->SetFolder(GetEventFolder()); | |
1024 | fTrackRefsDataLoader->SetFolder(GetEventFolder()); | |
1025 | ||
1026 | fEventFolder->SetOwner(); | |
1027 | return 0; | |
1028 | } | |
1029 | /**************************************************************************/ | |
1030 | ||
1031 | void AliRunLoader::AddLoader(AliLoader* loader) | |
1032 | { | |
1033 | //Adds the Loader for given detector | |
1034 | if (loader == 0x0) //if null shout and exit | |
1035 | { | |
1036 | Error("AddLoader","Parameter is NULL"); | |
1037 | return; | |
1038 | } | |
1039 | loader->SetDirName(fUnixDirName); | |
1040 | if (fEventFolder) loader->SetEventFolder(fEventFolder); //if event folder is already defined, | |
1041 | //pass information to the Loader | |
1042 | fLoaders->Add(loader);//add the Loader to the array | |
1043 | } | |
1044 | /**************************************************************************/ | |
1045 | ||
1046 | void AliRunLoader::AddLoader(AliDetector* det) | |
1047 | { | |
1048 | //Asks module (detector) ro make a Loader and stores in the array | |
1049 | if (det == 0x0) return; | |
1050 | AliLoader* get = det->GetLoader();//try to get loader | |
1051 | if (get == 0x0) get = det->MakeLoader(fEventFolder->GetName());//if did not obtain, ask to make it | |
1052 | ||
1053 | if (get) | |
1054 | { | |
1055 | if (GetDebug()) Info("AddLoader","Detector: %s Loader : %s",det->GetName(),get->GetName()); | |
1056 | AddLoader(get); | |
1057 | } | |
1058 | } | |
1059 | ||
1060 | /**************************************************************************/ | |
1061 | ||
1062 | AliLoader* AliRunLoader::GetLoader(const char* detname) const | |
1063 | { | |
f2a509af | 1064 | //returns loader for given detector |
1065 | //note that naming convention is TPCLoader not just TPC | |
88cb7938 | 1066 | return (AliLoader*)fLoaders->FindObject(detname); |
1067 | } | |
1068 | ||
1069 | /**************************************************************************/ | |
1070 | ||
1071 | AliLoader* AliRunLoader::GetLoader(AliDetector* det) const | |
1072 | { | |
f2a509af | 1073 | //get loader for detector det |
88cb7938 | 1074 | if(det == 0x0) return 0x0; |
1075 | TString getname(det->GetName()); | |
1076 | getname+="Loader"; | |
1077 | if (GetDebug()) Info("GetLoader(AliDetector* det)"," Loader name is %s",getname.Data()); | |
1078 | return GetLoader(getname); | |
1079 | } | |
1080 | ||
1081 | /**************************************************************************/ | |
1082 | ||
1083 | void AliRunLoader::CleanFolders() | |
1084 | { | |
1085 | // fEventFolder->Add(this);//put myself to the folder to accessible for all | |
1086 | ||
1087 | CleanDetectors(); | |
1088 | CleanHeader(); | |
1089 | CleanKinematics(); | |
1090 | } | |
1091 | /**************************************************************************/ | |
1092 | ||
1093 | void AliRunLoader::CleanDetectors() | |
1094 | { | |
1095 | //Calls CleanFolders for all detectors | |
1096 | TIter next(fLoaders); | |
d0d4a6b3 | 1097 | AliLoader *loader; |
1098 | while((loader = (AliLoader*)next())) | |
88cb7938 | 1099 | { |
d0d4a6b3 | 1100 | loader->CleanFolders(); |
88cb7938 | 1101 | } |
1102 | } | |
1103 | /**************************************************************************/ | |
1104 | ||
1105 | void AliRunLoader::RemoveEventFolder() | |
1106 | { | |
1107 | //remove all the tree of event | |
1108 | //all the stuff changing EbE stays untached (PDGDB, tasks, etc.) | |
1109 | ||
1110 | if (fEventFolder == 0x0) return; | |
1111 | fEventFolder->SetOwner(kFALSE);//don't we want to deleted while removing the folder that we are sitting in | |
1112 | fEventFolder->Remove(this);//remove us drom folder | |
1113 | ||
1114 | AliConfig::Instance()->GetTopFolder()->SetOwner(); //brings ownership back for fEventFolder since it sits in top folder | |
1115 | AliConfig::Instance()->GetTopFolder()->Remove(fEventFolder); //remove the event tree | |
1116 | delete fEventFolder; | |
1117 | } | |
1118 | /**************************************************************************/ | |
1119 | ||
1120 | void AliRunLoader::SetGAliceFile(TFile* gafile) | |
1121 | { | |
f2a509af | 1122 | //sets pointer to galice.root file |
88cb7938 | 1123 | fGAFile = gafile; |
1124 | } | |
1125 | ||
1126 | /**************************************************************************/ | |
1127 | ||
1128 | Int_t AliRunLoader::LoadHits(Option_t* detectors,Option_t* opt) | |
1129 | { | |
1130 | //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all" | |
1131 | ||
1132 | if (GetDebug()) Info("LoadHits","Loading Hits"); | |
1133 | TObjArray* loaders; | |
1134 | TObjArray arr; | |
1135 | ||
1136 | const char* oAll = strstr(detectors,"all"); | |
1137 | if (oAll) | |
1138 | { | |
1139 | if (GetDebug()) Info("LoadHits","Option is All"); | |
1140 | loaders = fLoaders; | |
1141 | } | |
1142 | else | |
1143 | { | |
1144 | GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option | |
1145 | loaders = &arr;//get the pointer array | |
1146 | } | |
1147 | ||
1148 | if (GetDebug()) Info("LoadHits","For detectors. Number of detectors chosen for loading %d",loaders->GetEntries()); | |
1149 | ||
1150 | TIter next(loaders); | |
1151 | AliLoader *loader; | |
1152 | while((loader = (AliLoader*)next())) | |
1153 | { | |
1154 | if (GetDebug()) Info("LoadHits"," Calling LoadHits(%s) for %s",opt,loader->GetName()); | |
1155 | loader->LoadHits(opt); | |
1156 | } | |
1157 | if (GetDebug()) Info("LoadHits","Done"); | |
1158 | return 0; | |
1159 | } | |
1160 | ||
1161 | /**************************************************************************/ | |
1162 | ||
1163 | Int_t AliRunLoader::LoadSDigits(Option_t* detectors,Option_t* opt) | |
1164 | { | |
1165 | //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all" | |
1166 | ||
1167 | TObjArray* loaders; | |
1168 | TObjArray arr; | |
1169 | ||
1170 | const char* oAll = strstr(detectors,"all"); | |
1171 | if (oAll) | |
1172 | { | |
1173 | loaders = fLoaders; | |
1174 | } | |
1175 | else | |
1176 | { | |
1177 | GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option | |
1bb20a37 | 1178 | loaders = &arr;//get the pointer to array |
88cb7938 | 1179 | } |
1180 | ||
1181 | TIter next(loaders); | |
1182 | AliLoader *loader; | |
1183 | while((loader = (AliLoader*)next())) | |
1184 | { | |
1185 | loader->LoadSDigits(opt); | |
1186 | } | |
1187 | return 0; | |
1188 | } | |
1189 | ||
1190 | /**************************************************************************/ | |
1191 | ||
1192 | Int_t AliRunLoader::LoadDigits(Option_t* detectors,Option_t* opt) | |
1193 | { | |
1194 | //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all" | |
1195 | ||
d0d4a6b3 | 1196 | TObjArray* loaders; |
88cb7938 | 1197 | TObjArray arr; |
1198 | ||
1199 | const char* oAll = strstr(detectors,"all"); | |
1200 | if (oAll) | |
1201 | { | |
d0d4a6b3 | 1202 | loaders = fLoaders; |
88cb7938 | 1203 | } |
1204 | else | |
1205 | { | |
1206 | GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option | |
d0d4a6b3 | 1207 | loaders = &arr;//get the pointer array |
88cb7938 | 1208 | } |
1209 | ||
d0d4a6b3 | 1210 | TIter next(loaders); |
1211 | AliLoader *loader; | |
1212 | while((loader = (AliLoader*)next())) | |
88cb7938 | 1213 | { |
d0d4a6b3 | 1214 | loader->LoadDigits(opt); |
88cb7938 | 1215 | } |
1216 | return 0; | |
1217 | } | |
88cb7938 | 1218 | /**************************************************************************/ |
1219 | ||
1220 | Int_t AliRunLoader::LoadRecPoints(Option_t* detectors,Option_t* opt) | |
1221 | { | |
1222 | //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all" | |
1223 | ||
d0d4a6b3 | 1224 | TObjArray* loaders; |
88cb7938 | 1225 | TObjArray arr; |
1226 | ||
1227 | const char* oAll = strstr(detectors,"all"); | |
1228 | if (oAll) | |
1229 | { | |
d0d4a6b3 | 1230 | loaders = fLoaders; |
88cb7938 | 1231 | } |
1232 | else | |
1233 | { | |
1234 | GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option | |
d0d4a6b3 | 1235 | loaders = &arr;//get the pointer array |
88cb7938 | 1236 | } |
1237 | ||
d0d4a6b3 | 1238 | TIter next(loaders); |
1239 | AliLoader *loader; | |
1240 | while((loader = (AliLoader*)next())) | |
88cb7938 | 1241 | { |
d0d4a6b3 | 1242 | loader->LoadRecPoints(opt); |
88cb7938 | 1243 | } |
1244 | return 0; | |
1245 | } | |
1bb20a37 | 1246 | /**************************************************************************/ |
88cb7938 | 1247 | |
1bb20a37 | 1248 | Int_t AliRunLoader::LoadRecParticles(Option_t* detectors,Option_t* opt) |
1249 | { | |
1250 | //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all" | |
1251 | ||
d0d4a6b3 | 1252 | TObjArray* loaders; |
1bb20a37 | 1253 | TObjArray arr; |
1254 | ||
1255 | const char* oAll = strstr(detectors,"all"); | |
1256 | if (oAll) | |
1257 | { | |
d0d4a6b3 | 1258 | loaders = fLoaders; |
1bb20a37 | 1259 | } |
1260 | else | |
1261 | { | |
1262 | GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option | |
d0d4a6b3 | 1263 | loaders = &arr;//get the pointer array |
1bb20a37 | 1264 | } |
1265 | ||
d0d4a6b3 | 1266 | TIter next(loaders); |
1267 | AliLoader *loader; | |
1268 | while((loader = (AliLoader*)next())) | |
1bb20a37 | 1269 | { |
d0d4a6b3 | 1270 | loader->LoadRecParticles(opt); |
1bb20a37 | 1271 | } |
1272 | return 0; | |
1273 | } | |
88cb7938 | 1274 | /**************************************************************************/ |
1275 | ||
1276 | Int_t AliRunLoader::LoadTracks(Option_t* detectors,Option_t* opt) | |
1277 | { | |
1278 | //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all" | |
1279 | ||
d0d4a6b3 | 1280 | TObjArray* loaders; |
88cb7938 | 1281 | TObjArray arr; |
1282 | ||
1283 | const char* oAll = strstr(detectors,"all"); | |
1284 | if (oAll) | |
1285 | { | |
d0d4a6b3 | 1286 | loaders = fLoaders; |
88cb7938 | 1287 | } |
1288 | else | |
1289 | { | |
1290 | GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option | |
d0d4a6b3 | 1291 | loaders = &arr;//get the pointer array |
88cb7938 | 1292 | } |
1293 | ||
d0d4a6b3 | 1294 | TIter next(loaders); |
1295 | AliLoader *loader; | |
1296 | while((loader = (AliLoader*)next())) | |
88cb7938 | 1297 | { |
d0d4a6b3 | 1298 | loader->LoadTracks(opt); |
88cb7938 | 1299 | } |
1300 | return 0; | |
1301 | } | |
1bb20a37 | 1302 | /**************************************************************************/ |
1303 | ||
1304 | void AliRunLoader::UnloadHits(Option_t* detectors) | |
1305 | { | |
1306 | //unloads hits for detectors specified in parameter | |
1307 | TObjArray* loaders; | |
1308 | TObjArray arr; | |
1309 | ||
1310 | const char* oAll = strstr(detectors,"all"); | |
1311 | if (oAll) | |
1312 | { | |
1313 | loaders = fLoaders; | |
1314 | } | |
1315 | else | |
1316 | { | |
1317 | GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option | |
1318 | loaders = &arr;//get the pointer to array | |
1319 | } | |
1320 | ||
1321 | TIter next(loaders); | |
1322 | AliLoader *loader; | |
1323 | while((loader = (AliLoader*)next())) | |
1324 | { | |
1325 | loader->UnloadHits(); | |
1326 | } | |
1327 | } | |
1328 | /**************************************************************************/ | |
1329 | ||
1330 | void AliRunLoader::UnloadSDigits(Option_t* detectors) | |
1331 | { | |
1332 | //unloads SDigits for detectors specified in parameter | |
1333 | TObjArray* loaders; | |
1334 | TObjArray arr; | |
1335 | ||
1336 | const char* oAll = strstr(detectors,"all"); | |
1337 | if (oAll) | |
1338 | { | |
1339 | loaders = fLoaders; | |
1340 | } | |
1341 | else | |
1342 | { | |
1343 | GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option | |
1344 | loaders = &arr;//get the pointer to array | |
1345 | } | |
1346 | ||
1347 | TIter next(loaders); | |
1348 | AliLoader *loader; | |
1349 | while((loader = (AliLoader*)next())) | |
1350 | { | |
1351 | loader->UnloadSDigits(); | |
1352 | } | |
1353 | } | |
1354 | /**************************************************************************/ | |
1355 | ||
1356 | void AliRunLoader::UnloadDigits(Option_t* detectors) | |
1357 | { | |
1358 | //unloads Digits for detectors specified in parameter | |
1359 | TObjArray* loaders; | |
1360 | TObjArray arr; | |
1361 | ||
1362 | const char* oAll = strstr(detectors,"all"); | |
1363 | if (oAll) | |
1364 | { | |
1365 | loaders = fLoaders; | |
1366 | } | |
1367 | else | |
1368 | { | |
1369 | GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option | |
1370 | loaders = &arr;//get the pointer to array | |
1371 | } | |
1372 | ||
1373 | TIter next(loaders); | |
1374 | AliLoader *loader; | |
1375 | while((loader = (AliLoader*)next())) | |
1376 | { | |
1377 | loader->UnloadDigits(); | |
1378 | } | |
1379 | } | |
1380 | /**************************************************************************/ | |
1381 | ||
1382 | void AliRunLoader::UnloadRecPoints(Option_t* detectors) | |
1383 | { | |
1384 | //unloads RecPoints for detectors specified in parameter | |
1385 | TObjArray* loaders; | |
1386 | TObjArray arr; | |
1387 | ||
1388 | const char* oAll = strstr(detectors,"all"); | |
1389 | if (oAll) | |
1390 | { | |
1391 | loaders = fLoaders; | |
1392 | } | |
1393 | else | |
1394 | { | |
1395 | GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option | |
1396 | loaders = &arr;//get the pointer to array | |
1397 | } | |
1398 | ||
1399 | TIter next(loaders); | |
1400 | AliLoader *loader; | |
1401 | while((loader = (AliLoader*)next())) | |
1402 | { | |
1403 | loader->UnloadRecPoints(); | |
1404 | } | |
1405 | } | |
1406 | /**************************************************************************/ | |
1407 | ||
1408 | void AliRunLoader::UnloadAll(Option_t* detectors) | |
1409 | { | |
1410 | //calls UnloadAll for detectors names specified in parameter | |
1411 | // option "all" passed can be passed | |
1412 | TObjArray* loaders; | |
1413 | TObjArray arr; | |
1414 | ||
1415 | const char* oAll = strstr(detectors,"all"); | |
1416 | if (oAll) | |
1417 | { | |
1418 | loaders = fLoaders; | |
1419 | } | |
1420 | else | |
1421 | { | |
1422 | GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option | |
1423 | loaders = &arr;//get the pointer to array | |
1424 | } | |
88cb7938 | 1425 | |
1bb20a37 | 1426 | TIter next(loaders); |
1427 | AliLoader *loader; | |
1428 | while((loader = (AliLoader*)next())) | |
1429 | { | |
1430 | loader->UnloadAll(); | |
1431 | } | |
1432 | } | |
1433 | /**************************************************************************/ | |
1434 | ||
1435 | void AliRunLoader::UnloadTracks(Option_t* detectors) | |
1436 | { | |
1437 | //unloads Tracks for detectors specified in parameter | |
1438 | TObjArray* loaders; | |
1439 | TObjArray arr; | |
1440 | ||
1441 | const char* oAll = strstr(detectors,"all"); | |
1442 | if (oAll) | |
1443 | { | |
1444 | loaders = fLoaders; | |
1445 | } | |
1446 | else | |
1447 | { | |
1448 | GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option | |
1449 | loaders = &arr;//get the pointer to array | |
1450 | } | |
1451 | ||
1452 | TIter next(loaders); | |
1453 | AliLoader *loader; | |
1454 | while((loader = (AliLoader*)next())) | |
1455 | { | |
1456 | loader->UnloadTracks(); | |
1457 | } | |
1458 | } | |
1459 | /**************************************************************************/ | |
1460 | ||
1461 | void AliRunLoader::UnloadRecParticles(Option_t* detectors) | |
1462 | { | |
1463 | //unloads Particles for detectors specified in parameter | |
1464 | TObjArray* loaders; | |
1465 | TObjArray arr; | |
1466 | ||
1467 | const char* oAll = strstr(detectors,"all"); | |
1468 | if (oAll) | |
1469 | { | |
1470 | loaders = fLoaders; | |
1471 | } | |
1472 | else | |
1473 | { | |
1474 | GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option | |
1475 | loaders = &arr;//get the pointer to array | |
1476 | } | |
1477 | ||
1478 | TIter next(loaders); | |
1479 | AliLoader *loader; | |
1480 | while((loader = (AliLoader*)next())) | |
1481 | { | |
1482 | loader->UnloadRecParticles(); | |
1483 | } | |
1484 | } | |
88cb7938 | 1485 | /**************************************************************************/ |
1486 | ||
1487 | AliRunLoader* AliRunLoader::GetRunLoader(const char* eventfoldername) | |
f2a509af | 1488 | { |
1489 | //returns RunLoader from folder named eventfoldername | |
88cb7938 | 1490 | TFolder* evfold= dynamic_cast<TFolder*>(AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername)); |
1491 | if (evfold == 0x0) | |
1492 | { | |
1493 | return 0x0; | |
1494 | } | |
1495 | AliRunLoader* runget = dynamic_cast<AliRunLoader*>(evfold->FindObject(AliRunLoader::fgkRunLoaderName)); | |
1496 | return runget; | |
1497 | ||
f2a509af | 1498 | } |
88cb7938 | 1499 | /**************************************************************************/ |
1500 | ||
1bb20a37 | 1501 | AliLoader* AliRunLoader::GetDetectorLoader(const char* detname, const char* eventfoldername) |
8de97894 | 1502 | { |
1503 | //get the loader of the detector with the given name from the global | |
1504 | //run loader object | |
1bb20a37 | 1505 | AliRunLoader* runLoader = GetRunLoader(eventfoldername); |
8de97894 | 1506 | if (!runLoader) { |
1bb20a37 | 1507 | ::Error("AliRunLoader::GetDetectorLoader","No run loader found"); |
8de97894 | 1508 | return NULL; |
1509 | } | |
1bb20a37 | 1510 | return runLoader->GetDetectorLoader(detname); |
1511 | } | |
1512 | /**************************************************************************/ | |
1513 | ||
1514 | AliLoader* AliRunLoader::GetDetectorLoader(const char* detname) | |
1515 | { | |
1516 | //get the loader of the detector with the given name from the global | |
1517 | //run loader object | |
1518 | ||
8de97894 | 1519 | char loadername[256]; |
1520 | sprintf(loadername, "%sLoader", detname); | |
1bb20a37 | 1521 | AliLoader* loader = GetLoader(loadername); |
8de97894 | 1522 | if (!loader) { |
1bb20a37 | 1523 | Error("GetDetectorLoader", "No loader for %s found", detname); |
8de97894 | 1524 | return NULL; |
1525 | } | |
1526 | return loader; | |
1527 | } | |
1bb20a37 | 1528 | /**************************************************************************/ |
1529 | ||
1530 | TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree, const char* eventfoldername) | |
1531 | { | |
1532 | //get the tree with hits of the detector with the given name | |
1533 | //if maketree is true and the tree does not exist, the tree is created | |
1534 | AliLoader* loader = GetDetectorLoader(detname,eventfoldername); | |
1535 | if (!loader) return NULL; | |
1536 | if (!loader->TreeH() && maketree) loader->MakeTree("H"); | |
1537 | return loader->TreeH(); | |
1538 | } | |
8de97894 | 1539 | |
1540 | /**************************************************************************/ | |
1541 | ||
1542 | TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree) | |
1543 | { | |
1544 | //get the tree with hits of the detector with the given name | |
1545 | //if maketree is true and the tree does not exist, the tree is created | |
1546 | AliLoader* loader = GetDetectorLoader(detname); | |
1547 | if (!loader) return NULL; | |
1548 | if (!loader->TreeH() && maketree) loader->MakeTree("H"); | |
1549 | return loader->TreeH(); | |
1550 | } | |
1bb20a37 | 1551 | /**************************************************************************/ |
8de97894 | 1552 | |
1bb20a37 | 1553 | TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree,const char* eventfoldername) |
1554 | { | |
1555 | //get the tree with summable digits of the detector with the given name | |
1556 | //if maketree is true and the tree does not exist, the tree is created | |
1557 | AliLoader* loader = GetDetectorLoader(detname,eventfoldername); | |
1558 | if (!loader) return NULL; | |
1559 | if (!loader->TreeS() && maketree) loader->MakeTree("S"); | |
1560 | return loader->TreeS(); | |
1561 | } | |
8de97894 | 1562 | /**************************************************************************/ |
1563 | ||
1564 | TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree) | |
1565 | { | |
1566 | //get the tree with summable digits of the detector with the given name | |
1567 | //if maketree is true and the tree does not exist, the tree is created | |
1568 | AliLoader* loader = GetDetectorLoader(detname); | |
1569 | if (!loader) return NULL; | |
1570 | if (!loader->TreeS() && maketree) loader->MakeTree("S"); | |
1571 | return loader->TreeS(); | |
1572 | } | |
1bb20a37 | 1573 | /**************************************************************************/ |
8de97894 | 1574 | |
1bb20a37 | 1575 | TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree,const char* eventfoldername) |
1576 | { | |
1577 | //get the tree with digits of the detector with the given name | |
1578 | //if maketree is true and the tree does not exist, the tree is created | |
1579 | AliLoader* loader = GetDetectorLoader(detname,eventfoldername); | |
1580 | if (!loader) return NULL; | |
1581 | if (!loader->TreeD() && maketree) loader->MakeTree("D"); | |
1582 | return loader->TreeD(); | |
1583 | } | |
8de97894 | 1584 | /**************************************************************************/ |
1585 | ||
1586 | TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree) | |
1587 | { | |
1588 | //get the tree with digits of the detector with the given name | |
1589 | //if maketree is true and the tree does not exist, the tree is created | |
1590 | AliLoader* loader = GetDetectorLoader(detname); | |
1591 | if (!loader) return NULL; | |
1592 | if (!loader->TreeD() && maketree) loader->MakeTree("D"); | |
1593 | return loader->TreeD(); | |
1594 | } | |
1bb20a37 | 1595 | /**************************************************************************/ |
1596 | TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree,const char* eventfoldername) | |
1597 | { | |
1598 | //get the tree with clusters of the detector with the given name | |
1599 | //if maketree is true and the tree does not exist, the tree is created | |
1600 | AliLoader* loader = GetDetectorLoader(detname,eventfoldername); | |
1601 | if (!loader) return NULL; | |
1602 | if (!loader->TreeR() && maketree) loader->MakeTree("R"); | |
1603 | return loader->TreeR(); | |
1604 | } | |
8de97894 | 1605 | /**************************************************************************/ |
1606 | ||
1607 | TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree) | |
1608 | { | |
1609 | //get the tree with clusters of the detector with the given name | |
1610 | //if maketree is true and the tree does not exist, the tree is created | |
1611 | AliLoader* loader = GetDetectorLoader(detname); | |
1612 | if (!loader) return NULL; | |
1613 | if (!loader->TreeR() && maketree) loader->MakeTree("R"); | |
1614 | return loader->TreeR(); | |
1615 | } | |
1bb20a37 | 1616 | /**************************************************************************/ |
8de97894 | 1617 | |
1bb20a37 | 1618 | TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree,const char* eventfoldername) |
1619 | { | |
1620 | //get the tree with tracks of the detector with the given name | |
1621 | //if maketree is true and the tree does not exist, the tree is created | |
1622 | AliLoader* loader = GetDetectorLoader(detname,eventfoldername); | |
1623 | if (!loader) return NULL; | |
1624 | if (!loader->TreeT() && maketree) loader->MakeTree("T"); | |
1625 | return loader->TreeT(); | |
1626 | } | |
8de97894 | 1627 | /**************************************************************************/ |
1628 | ||
1629 | TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree) | |
1630 | { | |
1631 | //get the tree with tracks of the detector with the given name | |
1632 | //if maketree is true and the tree does not exist, the tree is created | |
1633 | AliLoader* loader = GetDetectorLoader(detname); | |
1634 | if (!loader) return NULL; | |
1635 | if (!loader->TreeT() && maketree) loader->MakeTree("T"); | |
1636 | return loader->TreeT(); | |
1637 | } | |
1bb20a37 | 1638 | /**************************************************************************/ |
8de97894 | 1639 | |
1bb20a37 | 1640 | TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree,const char* eventfoldername) |
1641 | { | |
1642 | //get the tree with particles of the detector with the given name | |
1643 | //if maketree is true and the tree does not exist, the tree is created | |
1644 | AliLoader* loader = GetDetectorLoader(detname,eventfoldername); | |
1645 | if (!loader) return NULL; | |
1646 | if (!loader->TreeP() && maketree) loader->MakeTree("P"); | |
1647 | return loader->TreeP(); | |
1648 | } | |
8de97894 | 1649 | /**************************************************************************/ |
1650 | ||
1651 | TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree) | |
1652 | { | |
1653 | //get the tree with particles of the detector with the given name | |
1654 | //if maketree is true and the tree does not exist, the tree is created | |
1655 | AliLoader* loader = GetDetectorLoader(detname); | |
1656 | if (!loader) return NULL; | |
1657 | if (!loader->TreeP() && maketree) loader->MakeTree("P"); | |
1658 | return loader->TreeP(); | |
1659 | } | |
1660 | ||
1661 | /**************************************************************************/ | |
1662 | ||
88cb7938 | 1663 | void AliRunLoader::CdGAFile() |
1664 | { | |
1665 | //sets gDirectory to galice file | |
1666 | //work around | |
1667 | if(fGAFile) fGAFile->cd(); | |
1668 | } | |
1669 | ||
1670 | /**************************************************************************/ | |
1671 | ||
1672 | void AliRunLoader::GetListOfDetectors(const char * namelist,TObjArray& pointerarray) const | |
1673 | { | |
1674 | //this method looks for all Loaders corresponding | |
1675 | //to names (many) specified in namelist i.e. namelist ("ITS TPC TRD") | |
1676 | ||
1677 | char buff[10]; | |
1678 | char dets [200]; | |
1679 | strcpy(dets,namelist);//compiler cries when char* = const Option_t*; | |
1680 | dets[strlen(dets)+1] = '\n';//set endl at the end of string | |
1681 | char* pdet = dets; | |
1682 | Int_t tmp; | |
1683 | for(;;) | |
1684 | { | |
1685 | tmp = sscanf(pdet,"%s",buff);//read the string from the input string pdet into buff | |
1686 | if ( (buff[0] == 0) || (tmp == 0) ) break; //if not read | |
1687 | ||
f2a509af | 1688 | pdet = strstr(pdet,buff) + strlen(buff);//move the input pointer about number of bytes (letters) read |
88cb7938 | 1689 | //I am aware that is a little complicated. I don't know the number of spaces between detector names |
1690 | //so I read the string, than I find where it starts (strstr) and move the pointer about length of a string | |
1691 | //If there is a better way, please write me (Piotr.Skowronski@cern.ch) | |
1692 | //construct the Loader name | |
1693 | TString getname(buff); | |
1694 | getname+="Loader"; | |
1695 | AliLoader* loader = GetLoader(getname);//get the Loader | |
1696 | if (loader) | |
1697 | { | |
1698 | pointerarray.Add(loader); | |
1699 | } | |
1700 | else | |
1701 | { | |
1702 | Error("GetListOfDetectors","Can not find Loader for %s",buff); | |
1703 | } | |
1704 | ||
1705 | buff[0] = 0; | |
1706 | } | |
1707 | } | |
1708 | /*****************************************************************************/ | |
1709 | ||
1710 | void AliRunLoader::Clean(const TString& name) | |
1711 | { | |
1712 | //removes object with given name from event folder and deletes it | |
1713 | if (GetEventFolder() == 0x0) return; | |
1714 | TObject* obj = GetEventFolder()->FindObject(name); | |
1715 | if(obj) | |
1716 | { | |
1717 | if (GetDebug()) Info("Clean(const TString&)","name=%s, cleaning %s.",GetName(),name.Data()); | |
1718 | GetEventFolder()->Remove(obj); | |
1719 | delete obj; | |
1720 | } | |
1721 | } | |
1722 | ||
1723 | /*****************************************************************************/ | |
1724 | ||
1725 | TTask* AliRunLoader::GetRunDigitizer() | |
1726 | { | |
1727 | //returns Run Digitizer from folder | |
1728 | ||
1729 | TFolder* topf = AliConfig::Instance()->GetTaskFolder(); | |
1730 | TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetDigitizerTaskName()); | |
1731 | return (obj)?dynamic_cast<TTask*>(obj):0x0; | |
1732 | } | |
1733 | /*****************************************************************************/ | |
1734 | ||
1735 | TTask* AliRunLoader::GetRunSDigitizer() | |
1736 | { | |
1737 | //returns SDigitizer Task from folder | |
1738 | ||
1739 | TFolder* topf = AliConfig::Instance()->GetTaskFolder(); | |
1740 | TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetSDigitizerTaskName()); | |
1741 | return (obj)?dynamic_cast<TTask*>(obj):0x0; | |
1742 | } | |
1743 | /*****************************************************************************/ | |
1744 | ||
1745 | TTask* AliRunLoader::GetRunReconstructioner() | |
1746 | { | |
1747 | //returns Reconstructioner Task from folder | |
1748 | TFolder* topf = AliConfig::Instance()->GetTaskFolder(); | |
1749 | TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetReconstructionerTaskName()); | |
1750 | return (obj)?dynamic_cast<TTask*>(obj):0x0; | |
1751 | } | |
1752 | /*****************************************************************************/ | |
1753 | ||
1754 | TTask* AliRunLoader::GetRunTracker() | |
1755 | { | |
1756 | //returns Tracker Task from folder | |
1757 | TFolder* topf = AliConfig::Instance()->GetTaskFolder(); | |
1758 | TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetTrackerTaskName()); | |
1759 | return (obj)?dynamic_cast<TTask*>(obj):0x0; | |
1760 | } | |
1761 | /*****************************************************************************/ | |
1762 | ||
1763 | TTask* AliRunLoader::GetRunPIDTask() | |
1764 | { | |
1765 | //returns Tracker Task from folder | |
1766 | TFolder* topf = AliConfig::Instance()->GetTaskFolder(); | |
1767 | TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetPIDTaskName()); | |
1768 | return (obj)?dynamic_cast<TTask*>(obj):0x0; | |
1769 | } | |
1770 | /*****************************************************************************/ | |
1771 | ||
1772 | TTask* AliRunLoader::GetRunQATask() | |
1773 | { | |
1774 | //returns Quality Assurance Task from folder | |
1775 | TFolder* topf = AliConfig::Instance()->GetTaskFolder(); | |
1776 | if (topf == 0x0) | |
1777 | { | |
1778 | ::Error("AliRunLoader::GetRunQATask","Can not get task folder from AliConfig"); | |
1779 | return 0x0; | |
1780 | } | |
1781 | TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetQATaskName()); | |
1782 | return (obj)?dynamic_cast<TTask*>(obj):0x0; | |
1783 | } | |
1784 | ||
1785 | /*****************************************************************************/ | |
1786 | ||
1787 | void AliRunLoader::SetCompressionLevel(Int_t cl) | |
1788 | { | |
1789 | //Sets Compression Level in all files | |
1790 | if (fGAFile) fGAFile->SetCompressionLevel(cl); | |
1791 | SetKineComprLevel(cl); | |
1792 | SetTrackRefsComprLevel(cl); | |
1793 | TIter next(fLoaders); | |
1794 | AliLoader *loader; | |
1795 | while((loader = (AliLoader*)next())) | |
1796 | { | |
1797 | loader->SetCompressionLevel(cl); | |
1798 | } | |
1799 | } | |
1800 | /**************************************************************************/ | |
1801 | ||
1802 | void AliRunLoader::SetKineComprLevel(Int_t cl) | |
1803 | { | |
1804 | //Sets comression level in Kine File | |
1805 | fKineDataLoader->SetCompressionLevel(cl); | |
1806 | } | |
1807 | /**************************************************************************/ | |
1808 | ||
1809 | void AliRunLoader::SetTrackRefsComprLevel(Int_t cl) | |
1810 | { | |
1811 | //Sets comression level in Track Refences File | |
1812 | fTrackRefsDataLoader->SetCompressionLevel(cl); | |
1813 | } | |
1814 | /**************************************************************************/ | |
1815 | ||
1816 | void AliRunLoader::UnloadHeader() | |
1817 | { | |
1818 | //removes TreeE from folder and deletes it | |
1819 | // as well as fHeader object | |
1820 | CleanHeader(); | |
1821 | delete fHeader; | |
1822 | fHeader = 0x0; | |
1823 | } | |
1824 | /**************************************************************************/ | |
1825 | ||
1826 | void AliRunLoader::UnloadKinematics() | |
1827 | { | |
f2a509af | 1828 | //Unloads Kinematics |
88cb7938 | 1829 | fKineDataLoader->GetBaseLoader(0)->Unload(); |
1830 | } | |
1831 | /**************************************************************************/ | |
1832 | ||
1833 | void AliRunLoader::UnloadTrackRefs() | |
1834 | { | |
f2a509af | 1835 | //Unloads Track Refernces |
88cb7938 | 1836 | fTrackRefsDataLoader->GetBaseLoader(0)->Unload(); |
1837 | } | |
1838 | /**************************************************************************/ | |
1839 | ||
1840 | void AliRunLoader::UnloadgAlice() | |
1841 | { | |
f2a509af | 1842 | //Unloads gAlice |
88cb7938 | 1843 | if (gAlice == GetAliRun()) |
1844 | { | |
1845 | if (GetDebug()) Info("UnloadgAlice","Set gAlice = 0x0"); | |
1846 | gAlice = 0x0;//if gAlice is the same that in folder (to be deleted by the way of folder) | |
1847 | } | |
1848 | AliRun* alirun = GetAliRun(); | |
1849 | if (GetEventFolder()) GetEventFolder()->Remove(alirun); | |
1850 | delete alirun; | |
1851 | } | |
1852 | /**************************************************************************/ | |
1853 | ||
1854 | void AliRunLoader::MakeTrackRefsContainer() | |
1855 | { | |
1856 | // Makes a tree for Track References | |
1857 | fTrackRefsDataLoader->MakeTree(); | |
1858 | } | |
1859 | /**************************************************************************/ | |
1860 | ||
1861 | Int_t AliRunLoader::LoadTrackRefs(Option_t* option) | |
1862 | { | |
1863 | //Load track references from file (opens file and posts tree to folder) | |
1864 | ||
f2a509af | 1865 | return fTrackRefsDataLoader->GetBaseLoader(0)->Load(option); |
88cb7938 | 1866 | } |
1867 | /**************************************************************************/ | |
1868 | ||
1869 | void AliRunLoader::SetDirName(TString& dirname) | |
1870 | { | |
1871 | //sets directory name | |
1872 | if (dirname.IsNull()) return; | |
1873 | fUnixDirName = dirname; | |
1874 | fKineDataLoader->SetDirName(dirname); | |
1875 | fTrackRefsDataLoader->SetDirName(dirname); | |
1876 | ||
1877 | TIter next(fLoaders); | |
1878 | AliLoader *loader; | |
1879 | while((loader = (AliLoader*)next())) | |
1880 | { | |
1881 | loader->SetDirName(dirname); | |
1882 | } | |
1883 | ||
1884 | } | |
1885 | /*****************************************************************************/ | |
1886 | ||
1887 | Int_t AliRunLoader::GetFileOffset() const | |
1888 | { | |
f2a509af | 1889 | //returns the file number that is added to the file name for current event |
88cb7938 | 1890 | return Int_t(fCurrentEvent/fNEventsPerFile); |
1891 | } | |
1892 | ||
1893 | /*****************************************************************************/ | |
1894 | const TString AliRunLoader::SetFileOffset(const TString& fname) | |
1895 | { | |
f2a509af | 1896 | //adds the the number to the file name at proper place for current event |
88cb7938 | 1897 | Long_t offset = (Long_t)GetFileOffset(); |
1898 | if (offset < 1) return fname; | |
1899 | TString soffset; | |
1900 | soffset += offset;//automatic conversion to string | |
1901 | TString dotroot(".root"); | |
1902 | const TString& offfsetdotroot = offset + dotroot; | |
1903 | TString out = fname; | |
1904 | out = out.ReplaceAll(dotroot,offfsetdotroot); | |
1905 | if (GetDebug()) Info("SetFileOffset"," in=%s out=%s",fname.Data(),out.Data()); | |
1906 | return out; | |
1907 | } | |
1908 | /*****************************************************************************/ | |
1909 | ||
1910 | void AliRunLoader::SetDigitsFileNameSuffix(const TString& suffix) | |
1911 | { | |
1912 | //adds the suffix before ".root", | |
1913 | //e.g. TPC.Digits.root -> TPC.DigitsMerged.root | |
1914 | //made on Jiri Chudoba demand | |
1915 | ||
1916 | TIter next(fLoaders); | |
d0d4a6b3 | 1917 | AliLoader *loader; |
1918 | while((loader = (AliLoader*)next())) | |
88cb7938 | 1919 | { |
d0d4a6b3 | 1920 | loader->SetDigitsFileNameSuffix(suffix); |
88cb7938 | 1921 | } |
1922 | } | |
1923 | /*****************************************************************************/ | |
1924 | ||
1925 | TString AliRunLoader::GetFileName() const | |
1926 | { | |
1927 | //returns name of galice file | |
1928 | TString result; | |
1929 | if (fGAFile == 0x0) return result; | |
1930 | result = fGAFile->GetName(); | |
1931 | return result; | |
1932 | } | |
1933 | /*****************************************************************************/ | |
1934 | ||
1935 | void AliRunLoader::SetDetectorAddresses() | |
1936 | { | |
1937 | //calls SetTreeAddress for all detectors | |
1938 | if (GetAliRun()==0x0) return; | |
1939 | TIter next(GetAliRun()->Modules()); | |
1940 | AliModule* mod; | |
1941 | while((mod = (AliModule*)next())) | |
1942 | { | |
1943 | AliDetector* det = dynamic_cast<AliDetector*>(mod); | |
1944 | if (det) det->SetTreeAddress(); | |
1945 | } | |
1946 | } | |
1947 | /*****************************************************************************/ | |
f0f6f856 | 1948 | |
1949 | void AliRunLoader::Synchronize() | |
1950 | { | |
1951 | //synchrinizes all writtable files | |
1952 | TIter next(fLoaders); | |
1953 | AliLoader *loader; | |
1954 | while((loader = (AliLoader*)next())) | |
1955 | { | |
1956 | loader->Synchronize(); | |
1957 | } | |
1958 | ||
1959 | fKineDataLoader->Synchronize(); | |
1960 | fTrackRefsDataLoader->Synchronize(); | |
1961 | ||
504b172d | 1962 | if (fGAFile) fGAFile->Flush(); |
f0f6f856 | 1963 | } |
88cb7938 | 1964 | /*****************************************************************************/ |
1965 | /*****************************************************************************/ |