3 /** @file AliHLTLoaderPublisherComponent.cxx
4 @author Matthias Richter
6 @brief A general tree publisher component for the AliLoader.
9 #include "AliHLTLoaderPublisherComponent.h"
10 #include "AliRunLoader.h"
11 #include "AliLoader.h"
15 /** global instance for agent registration */
16 AliHLTLoaderPublisherComponent gAliHLTLoaderPublisherComponent;
18 /** ROOT macro for the implementation of ROOT specific class methods */
19 ClassImp(AliHLTLoaderPublisherComponent)
21 AliHLTLoaderPublisherComponent::AliHLTLoaderPublisherComponent()
27 fDataType(kAliHLTAnyDataType),
31 // see header file for class documentation
33 // refer to README to build package
35 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
38 AliHLTLoaderPublisherComponent::~AliHLTLoaderPublisherComponent()
40 // see header file for class documentation
43 const char* AliHLTLoaderPublisherComponent::GetComponentID()
45 // see header file for class documentation
46 return "AliLoaderPublisher";
49 AliHLTComponentDataType AliHLTLoaderPublisherComponent::GetOutputDataType()
54 void AliHLTLoaderPublisherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
60 AliHLTComponent* AliHLTLoaderPublisherComponent::Spawn()
62 // see header file for class documentation
63 return new AliHLTLoaderPublisherComponent;
66 int AliHLTLoaderPublisherComponent::DoInit( int argc, const char** argv )
68 // see header file for class documentation
74 for (int i=0; i<argc && iResult>=0; i++) {
76 if (argument.IsNull()) continue;
79 if (argument.CompareTo("-loader")==0) {
80 if ((bMissingParam=(++i>=argc))) break;
84 } else if (argument.CompareTo("-tree")==0) {
85 if ((bMissingParam=(++i>=argc))) break;
89 } else if (argument.CompareTo("-verbose")==0) {
93 } else if (argument.CompareTo("-datatype")==0) {
94 if ((bMissingParam=(++i>=argc))) break;
95 memcpy(&fDataType.fID, argv[i], TMath::Min(kAliHLTComponentDataTypefIDsize, (Int_t)strlen(argv[i])));
96 if ((bMissingParam=(++i>=argc))) break;
97 memcpy(&fDataType.fOrigin, argv[i], TMath::Min(kAliHLTComponentDataTypefOriginSize, (Int_t)strlen(argv[i])));
100 } else if (argument.CompareTo("-dataspec")==0) {
101 if ((bMissingParam=(++i>=argc))) break;
102 TString parameter(argv[i]);
103 parameter.Remove(TString::kLeading, ' '); // remove all blanks
104 if (parameter.IsDigit()) {
105 fSpecification=(AliHLTUInt32_t)parameter.Atoi();
106 } else if (parameter.BeginsWith("0x") &&
107 parameter.Replace(0,2,"",0).IsHex()) {
108 sscanf(parameter.Data(),"%x", &fSpecification);
110 HLTError("wrong parameter for argument %s, number expected", argument.Data());
114 HLTError("unknown argument %s", argument.Data());
119 HLTError("missing parameter for argument %s", argument.Data());
123 if (iResult<0) return iResult;
125 if (fLoaderType.IsNull()) {
126 HLTError("loader type required, use \'-loader\' option");
130 // fetch runLoader instance from interface
131 AliRunLoader* pRunLoader=GetRunLoader();
134 // get the TPC loader
135 fpLoader=pRunLoader->GetLoader(fLoaderType.Data());
137 // prepare the loader
138 fpLoader->LoadDigits("read");
140 // scan trough all events and estimate the size of the digits
141 for (int i=0; i<pRunLoader->GetNumberOfEvents(); i++) {
142 pRunLoader->GetEvent(i);
143 TTree* pTree=GetTree();
145 int size=EstimateObjectSize(pTree);
146 if (size>fMaxSize) fMaxSize=size;
148 AliInfoStream() << "event " << i << " "
149 << fTreeType <<" size " << size
150 << " count " << pTree->GetEntries() << endl;
153 AliWarningStream() << "no " << fTreeType << " tree for event " << i << endl;
157 AliErrorStream() << "can not get loader of type " << fLoaderType << endl;
161 AliErrorStream() << "can not get runLoader" << endl;
167 int AliHLTLoaderPublisherComponent::DoDeinit()
169 // see header file for class documentation
172 fpLoader->UnloadDigits();
178 int AliHLTLoaderPublisherComponent::GetEvent(const AliHLTComponentEventData& evtData,
179 AliHLTComponentTriggerData& trigData)
181 // see header file for class documentation
183 // fetch runLoader instance from interface
184 AliRunLoader* pRunLoader=GetRunLoader();
185 if (pRunLoader && fpLoader) {
186 pRunLoader->GetEvent(GetEventCount());
187 TTree* pTree=GetTree();
189 PushBack(pTree, fDataType);
191 AliWarningStream() << "no " << fTreeType << " tree for event " << GetEventCount() << endl;
194 AliErrorStream() << "component not initialized" << endl;
199 TTree* AliHLTLoaderPublisherComponent::GetTree()
203 if (fTreeType.CompareTo("digits")==0)
204 pTree=fpLoader->TreeD();
205 else if (fTreeType.CompareTo("clusters")==0) {
206 pTree=fpLoader->TreeR();