3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
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 **************************************************************************/
19 /** @file AliHLTLoaderPublisherComponent.cxx
20 @author Matthias Richter
22 @brief A general tree publisher component for the AliLoader.
25 #include "AliHLTLoaderPublisherComponent.h"
26 #include "AliRunLoader.h"
27 #include "AliLoader.h"
31 /** global instance for agent registration */
32 AliHLTLoaderPublisherComponent gAliHLTLoaderPublisherComponent;
34 /** ROOT macro for the implementation of ROOT specific class methods */
35 ClassImp(AliHLTLoaderPublisherComponent)
37 AliHLTLoaderPublisherComponent::AliHLTLoaderPublisherComponent()
43 fDataType(kAliHLTAnyDataType),
47 // see header file for class documentation
49 // refer to README to build package
51 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
54 AliHLTLoaderPublisherComponent::~AliHLTLoaderPublisherComponent()
56 // see header file for class documentation
59 const char* AliHLTLoaderPublisherComponent::GetComponentID()
61 // see header file for class documentation
62 return "AliLoaderPublisher";
65 AliHLTComponentDataType AliHLTLoaderPublisherComponent::GetOutputDataType()
70 void AliHLTLoaderPublisherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
76 AliHLTComponent* AliHLTLoaderPublisherComponent::Spawn()
78 // see header file for class documentation
79 return new AliHLTLoaderPublisherComponent;
82 int AliHLTLoaderPublisherComponent::DoInit( int argc, const char** argv )
84 // see header file for class documentation
90 for (int i=0; i<argc && iResult>=0; i++) {
92 if (argument.IsNull()) continue;
95 if (argument.CompareTo("-loader")==0) {
96 if ((bMissingParam=(++i>=argc))) break;
100 } else if (argument.CompareTo("-tree")==0) {
101 if ((bMissingParam=(++i>=argc))) break;
105 } else if (argument.CompareTo("-verbose")==0) {
109 } else if (argument.CompareTo("-datatype")==0) {
110 if ((bMissingParam=(++i>=argc))) break;
111 memcpy(&fDataType.fID, argv[i], TMath::Min(kAliHLTComponentDataTypefIDsize, (Int_t)strlen(argv[i])));
112 if ((bMissingParam=(++i>=argc))) break;
113 memcpy(&fDataType.fOrigin, argv[i], TMath::Min(kAliHLTComponentDataTypefOriginSize, (Int_t)strlen(argv[i])));
116 } else if (argument.CompareTo("-dataspec")==0) {
117 if ((bMissingParam=(++i>=argc))) break;
118 TString parameter(argv[i]);
119 parameter.Remove(TString::kLeading, ' '); // remove all blanks
120 if (parameter.IsDigit()) {
121 fSpecification=(AliHLTUInt32_t)parameter.Atoi();
122 } else if (parameter.BeginsWith("0x") &&
123 parameter.Replace(0,2,"",0).IsHex()) {
124 sscanf(parameter.Data(),"%x", &fSpecification);
126 HLTError("wrong parameter for argument %s, number expected", argument.Data());
130 HLTError("unknown argument %s", argument.Data());
135 HLTError("missing parameter for argument %s", argument.Data());
139 if (iResult<0) return iResult;
141 if (fLoaderType.IsNull()) {
142 HLTError("loader type required, use \'-loader\' option");
146 // fetch runLoader instance from interface
147 AliRunLoader* pRunLoader=GetRunLoader();
150 // get the TPC loader
151 fpLoader=pRunLoader->GetLoader(fLoaderType.Data());
153 // prepare the loader
154 fpLoader->LoadDigits("read");
156 // scan trough all events and estimate the size of the digits
157 for (int i=0; i<pRunLoader->GetNumberOfEvents(); i++) {
158 pRunLoader->GetEvent(i);
159 TTree* pTree=GetTree();
161 int size=EstimateObjectSize(pTree);
162 if (size>fMaxSize) fMaxSize=size;
164 AliInfoStream() << "event " << i << " "
165 << fTreeType <<" size " << size
166 << " count " << pTree->GetEntries() << endl;
169 AliWarningStream() << "no " << fTreeType << " tree for event " << i << endl;
173 AliErrorStream() << "can not get loader of type " << fLoaderType << endl;
177 AliErrorStream() << "can not get runLoader" << endl;
183 int AliHLTLoaderPublisherComponent::DoDeinit()
185 // see header file for class documentation
188 fpLoader->UnloadDigits();
194 int AliHLTLoaderPublisherComponent::GetEvent(const AliHLTComponentEventData& evtData,
195 AliHLTComponentTriggerData& trigData)
197 // see header file for class documentation
199 // fetch runLoader instance from interface
200 AliRunLoader* pRunLoader=GetRunLoader();
201 if (pRunLoader && fpLoader) {
202 pRunLoader->GetEvent(GetEventCount());
203 TTree* pTree=GetTree();
205 PushBack(pTree, fDataType);
207 AliWarningStream() << "no " << fTreeType << " tree for event " << GetEventCount() << endl;
210 AliErrorStream() << "component not initialized" << endl;
215 TTree* AliHLTLoaderPublisherComponent::GetTree()
219 if (fTreeType.CompareTo("digits")==0)
220 pTree=fpLoader->TreeD();
221 else if (fTreeType.CompareTo("clusters")==0) {
222 pTree=fpLoader->TreeR();