]>
Commit | Line | Data |
---|---|---|
4ddfc222 | 1 | // $Id$ |
2 | ||
3 | /************************************************************************** | |
9be2600f | 4 | * This file is property of and copyright by the ALICE HLT Project * |
5 | * ALICE Experiment at CERN, All rights reserved. * | |
4ddfc222 | 6 | * * |
9be2600f | 7 | * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * |
8 | * for The ALICE HLT Project. * | |
4ddfc222 | 9 | * * |
10 | * Permission to use, copy, modify and distribute this software and its * | |
11 | * documentation strictly for non-commercial purposes is hereby granted * | |
12 | * without fee, provided that the above copyright notice appears in all * | |
13 | * copies and that both the copyright notice and this permission notice * | |
14 | * appear in the supporting documentation. The authors make no claims * | |
15 | * about the suitability of this software for any purpose. It is * | |
16 | * provided "as is" without express or implied warranty. * | |
17 | **************************************************************************/ | |
18 | ||
19 | /** @file AliHLTRootFilePublisherComponent.cxx | |
992ea13b | 20 | @author Matthias Richter, Jochen Thaeder |
4ddfc222 | 21 | @date |
22 | @brief HLT file publisher component implementation. */ | |
23 | ||
24 | #include "AliHLTRootFilePublisherComponent.h" | |
25 | //#include <TObjString.h> | |
26 | //#include <TMath.h> | |
27 | //#include <TFile.h> | |
28 | ||
992ea13b | 29 | #include "TList.h" |
30 | #include "TTree.h" | |
31 | #include "TKey.h" | |
32 | #include "TFile.h" | |
33 | ||
4ddfc222 | 34 | |
4ddfc222 | 35 | /** ROOT macro for the implementation of ROOT specific class methods */ |
36 | ClassImp(AliHLTRootFilePublisherComponent) | |
37 | ||
992ea13b | 38 | /* |
39 | * --------------------------------------------------------------------------------- | |
40 | * Constructor / Destructor | |
41 | * --------------------------------------------------------------------------------- | |
42 | */ | |
43 | ||
44 | // ################################################################################# | |
4ddfc222 | 45 | AliHLTRootFilePublisherComponent::AliHLTRootFilePublisherComponent() |
46 | : | |
992ea13b | 47 | AliHLTFilePublisher(), |
48 | fpCurrentEvent(NULL), | |
49 | fObjectName("") { | |
4ddfc222 | 50 | // see header file for class documentation |
51 | // or | |
52 | // refer to README to build package | |
53 | // or | |
54 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
55 | ||
992ea13b | 56 | // Set file to ROOT-File |
57 | SetIsRawFile( kFALSE ); | |
4ddfc222 | 58 | } |
59 | ||
992ea13b | 60 | // ################################################################################# |
61 | AliHLTRootFilePublisherComponent::~AliHLTRootFilePublisherComponent() { | |
4ddfc222 | 62 | // see header file for class documentation |
63 | ||
64 | // file list and file name list are owner of their objects and | |
65 | // delete all the objects | |
66 | } | |
67 | ||
992ea13b | 68 | /* |
69 | * --------------------------------------------------------------------------------- | |
70 | * Public functions to implement AliHLTComponent's interface. | |
71 | * These functions are required for the registration process | |
72 | * --------------------------------------------------------------------------------- | |
73 | */ | |
4ddfc222 | 74 | |
992ea13b | 75 | // ################################################################################# |
76 | const char* AliHLTRootFilePublisherComponent::GetComponentID() { | |
4ddfc222 | 77 | // see header file for class documentation |
992ea13b | 78 | return "ROOTFilePublisher"; |
4ddfc222 | 79 | } |
80 | ||
992ea13b | 81 | // ################################################################################# |
82 | AliHLTComponent* AliHLTRootFilePublisherComponent::Spawn() { | |
4ddfc222 | 83 | // see header file for class documentation |
84 | return new AliHLTRootFilePublisherComponent; | |
85 | } | |
86 | ||
992ea13b | 87 | /* |
88 | * --------------------------------------------------------------------------------- | |
89 | * Protected functions to implement AliHLTComponent's interface. | |
90 | * These functions provide initialization as well as the actual processing | |
91 | * capabilities of the component. | |
92 | * --------------------------------------------------------------------------------- | |
93 | */ | |
94 | ||
95 | // ################################################################################# | |
96 | Int_t AliHLTRootFilePublisherComponent::ScanArgument(Int_t argc, const char** argv) { | |
4ddfc222 | 97 | // see header file for class documentation |
98 | ||
992ea13b | 99 | Int_t iResult = 0; |
100 | ||
101 | TString argument = ""; | |
102 | TString parameter = ""; | |
103 | Int_t bMissingParam = 0; | |
104 | ||
105 | argument=argv[iResult]; | |
106 | if (argument.IsNull()) return -EINVAL; | |
107 | ||
108 | // -objectname | |
109 | if ( !argument.CompareTo("-objectname") ) { | |
110 | if ( ! (bMissingParam=(++iResult>=argc)) ) { | |
111 | parameter = argv[iResult]; | |
112 | parameter.Remove(TString::kLeading, ' '); // remove all blanks | |
113 | fObjectName = parameter; | |
114 | } | |
115 | } | |
116 | else { | |
117 | HLTError("unknown argument %s", argument.Data()); | |
118 | iResult = -EINVAL; | |
119 | } | |
120 | ||
121 | if ( bMissingParam ) { | |
122 | HLTError("missing parameter for argument %s", argument.Data()); | |
123 | iResult = -EPROTO; | |
4ddfc222 | 124 | } |
4ddfc222 | 125 | |
4ddfc222 | 126 | return iResult; |
127 | } | |
128 | ||
992ea13b | 129 | // ################################################################################# |
130 | Int_t AliHLTRootFilePublisherComponent::GetEvent( const AliHLTComponentEventData& /*evtData*/, | |
d76bc02a | 131 | AliHLTComponentTriggerData& /*trigData*/, |
14aa20d4 | 132 | AliHLTUInt8_t* /*outputPtr*/, |
992ea13b | 133 | AliHLTUInt32_t& size, |
134 | vector<AliHLTComponentBlockData>& /*outputBlocks*/ ) { | |
f3506ea2 | 135 | // see header file for class documentation |
992ea13b | 136 | |
137 | if ( !IsDataEvent() ) return 0; | |
138 | ||
139 | Int_t iResult=0; | |
140 | size=0; | |
141 | ||
142 | // -- Ptr to current event | |
143 | TObjLink *lnk = fpCurrentEvent; | |
144 | if ( lnk == NULL) { | |
145 | lnk = GetEventList()->FirstLink(); | |
146 | fpCurrentEvent = lnk; | |
147 | } | |
148 | ||
149 | if ( lnk ) { | |
150 | EventFiles* pEventDesc = dynamic_cast<EventFiles*>( lnk->GetObject() ); | |
151 | if (pEventDesc) { | |
152 | ||
153 | HLTDebug("publishing files for event %p", pEventDesc); | |
154 | TList& files=*pEventDesc; // type conversion operator defined | |
155 | TObjLink *flnk=files.FirstLink(); | |
156 | ||
157 | while (flnk && iResult>=0) { | |
158 | ||
159 | FileDesc* pFileDesc=dynamic_cast<FileDesc*>(flnk->GetObject()); | |
160 | ||
161 | if (not fOpenFilesAtStart) pFileDesc->OpenFile(); | |
162 | TFile* pFile=NULL; | |
163 | ||
164 | if (pFileDesc && (pFile=*pFileDesc)!=NULL) { | |
165 | ||
166 | for ( Int_t i = 0; i < pFile->GetListOfKeys()->GetEntries(); i++ ){ | |
167 | TKey * key= dynamic_cast<TKey*>( pFile->GetListOfKeys()->At(i) ); | |
168 | ||
169 | if ( fObjectName ) { | |
170 | if ( !( ((TString) key->GetName()).CompareTo(fObjectName) ) ) | |
171 | PushBack( key->ReadObj(), *pFileDesc, *pFileDesc ); | |
172 | } | |
173 | else | |
174 | PushBack( key->ReadObj(), *pFileDesc, *pFileDesc ); | |
175 | // above : type conversion operator defined for DataType and Spec | |
176 | } | |
177 | ||
178 | if (not fOpenFilesAtStart) pFileDesc->CloseFile(); | |
179 | } else { | |
180 | HLTError("no file available"); | |
181 | iResult=-EFAULT; | |
182 | } | |
183 | flnk = flnk->Next(); | |
184 | } | |
185 | } else { | |
186 | HLTError("can not get event descriptor from list link"); | |
187 | iResult=-EFAULT; | |
188 | } | |
4ddfc222 | 189 | } else { |
992ea13b | 190 | iResult=-ENOENT; |
4ddfc222 | 191 | } |
992ea13b | 192 | if (iResult>=0 && fpCurrentEvent) fpCurrentEvent=fpCurrentEvent->Next(); |
4ddfc222 | 193 | |
194 | return iResult; | |
195 | } |