]>
Commit | Line | Data |
---|---|---|
3cd4b27c | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //------------------------------------------------------------------------- | |
19 | // Event handler for ESD input reading the RecPoint Trees in parallel | |
20 | // Author: Andreas Morsch, CERN | |
21 | //------------------------------------------------------------------------- | |
22 | ||
23 | #include <TTree.h> | |
24 | #include <TList.h> | |
25 | #include <TFile.h> | |
26 | #include <TArchiveFile.h> | |
27 | #include <TSystemDirectory.h> | |
28 | #include <TString.h> | |
29 | #include <TObjString.h> | |
30 | #include <TObjArray.h> | |
31 | #include <TProcessID.h> | |
32 | #include <TSystem.h> | |
33 | ||
34 | #include "AliESDInputHandlerRPITS.h" | |
35 | #include "AliESDEvent.h" | |
36 | #include "AliESD.h" | |
37 | #include "AliLog.h" | |
38 | ||
39 | ClassImp(AliESDInputHandlerRPITS) | |
40 | ||
41 | //______________________________________________________________________________ | |
42 | AliESDInputHandlerRPITS::AliESDInputHandlerRPITS() : | |
43 | AliESDInputHandlerRP() | |
44 | { | |
45 | // Default constructor | |
46 | } | |
47 | ||
48 | ||
49 | //______________________________________________________________________________ | |
50 | AliESDInputHandlerRPITS::AliESDInputHandlerRPITS(const char* name, const char* title): | |
51 | AliESDInputHandlerRP(name, title) | |
52 | { | |
53 | // Constructor | |
54 | } | |
55 | ||
56 | //______________________________________________________________________________ | |
57 | AliESDInputHandlerRPITS::~AliESDInputHandlerRPITS() | |
58 | { | |
59 | // Destructor | |
60 | } | |
61 | ||
62 | ||
63 | Bool_t AliESDInputHandlerRPITS::Notify(const char *path) | |
64 | { | |
65 | // Notify about directory change | |
66 | // The directory is taken from the 'path' argument | |
67 | // | |
68 | AliInfo(Form("Directory change %s \n", path)); | |
69 | // Get path to directory | |
70 | TString fileName(path); | |
71 | ||
72 | if(fileName.Contains("#")){ | |
73 | // If this is an archive it will contain a # | |
74 | fIsArchive = kTRUE; | |
75 | } else if(fileName.Contains("AliESDs.root")){ | |
76 | fileName.ReplaceAll("AliESDs.root", ""); | |
77 | } | |
78 | ||
79 | // | |
80 | // At this point we have a path to the directory or to the archive anchor | |
81 | *fPathName = fileName; | |
82 | // | |
83 | // Now filter the files containing RecPoints *.RecPoints.* | |
84 | ||
85 | TSeqCollection* members; | |
86 | ||
87 | ||
88 | if (fIsArchive) { | |
89 | // Archive | |
90 | TFile* file = TFile::Open(fPathName->Data()); | |
91 | TArchiveFile* arch = file->GetArchive(); | |
92 | members = arch->GetMembers(); | |
93 | } else { | |
94 | // Directory or alien archive | |
95 | if (fileName.BeginsWith("alien:")) { | |
96 | TFile* file = TFile::Open(Form("%s/root_archive.zip", fPathName->Data())); | |
97 | TArchiveFile* arch = file->GetArchive(); | |
98 | members = arch->GetMembers(); | |
99 | } else { | |
100 | TString wd = gSystem->WorkingDirectory(); | |
101 | TSystemDirectory dir(".", fPathName->Data()); | |
102 | members = dir.GetListOfFiles(); | |
103 | gSystem->cd(wd); | |
104 | } | |
105 | } | |
106 | ||
107 | TIter next(members); | |
108 | TFile* entry; | |
109 | Int_t ien = 0; | |
110 | fDetectors->Delete(); | |
111 | ||
112 | while ( (entry = (TFile*) next()) ) | |
113 | { | |
114 | TString name(entry->GetName()); | |
115 | TObjArray* tokens = name.Tokenize("."); | |
116 | Int_t ntok = tokens->GetEntries(); | |
117 | if (ntok <= 1) continue; | |
118 | TString str = ((TObjString*) tokens->At(1))->GetString(); | |
119 | if (!(strcmp(str.Data(), "RecPoints"))){ | |
120 | TString det = ((TObjString*) tokens->At(0))->GetString(); | |
121 | if (!(strcmp(det.Data(), "ITS"))) { | |
122 | printf("Found file with RecPoints for %s \n", det.Data()); | |
123 | TNamed* ent = new TNamed(det.Data(), det.Data()); | |
124 | fRTrees->AddAt(0, ien); | |
125 | ent->SetUniqueID(ien++); | |
126 | fDetectors->Add(ent); | |
127 | } | |
128 | } | |
129 | if(tokens) delete tokens; | |
130 | } // loop over files | |
131 | ||
132 | ||
133 | // Now we have the path and the list of detectors | |
134 | ||
135 | printf("AliESDInputHandlerRPITS::Notify() Path: %s\n", fPathName->Data()); | |
136 | // | |
137 | ResetIO(); | |
138 | InitIO(""); | |
139 | // Some clean-up | |
140 | members->Delete(); | |
141 | ||
142 | return kTRUE; | |
143 | } | |
144 |