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 // see header file for class documentation
27 // refer to README to build package
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
31 #include "AliHLTLoaderPublisherComponent.h"
32 #include "AliRunLoader.h"
33 #include "AliLoader.h"
37 /** global instance for agent registration */
38 AliHLTLoaderPublisherComponent gAliHLTLoaderPublisherComponent;
40 /** ROOT macro for the implementation of ROOT specific class methods */
41 ClassImp(AliHLTLoaderPublisherComponent)
43 AliHLTLoaderPublisherComponent::AliHLTLoaderPublisherComponent()
49 fDataType(kAliHLTAnyDataType),
53 // see header file for class documentation
55 // refer to README to build package
57 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
60 AliHLTLoaderPublisherComponent::~AliHLTLoaderPublisherComponent()
62 // see header file for class documentation
65 const char* AliHLTLoaderPublisherComponent::GetComponentID()
67 // see header file for class documentation
68 return "AliLoaderPublisher";
71 AliHLTComponentDataType AliHLTLoaderPublisherComponent::GetOutputDataType()
76 void AliHLTLoaderPublisherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
82 AliHLTComponent* AliHLTLoaderPublisherComponent::Spawn()
84 // see header file for class documentation
85 return new AliHLTLoaderPublisherComponent;
88 int AliHLTLoaderPublisherComponent::DoInit( int argc, const char** argv )
90 // see header file for class documentation
96 for (int i=0; i<argc && iResult>=0; i++) {
98 if (argument.IsNull()) continue;
101 if (argument.CompareTo("-loader")==0) {
102 if ((bMissingParam=(++i>=argc))) break;
106 } else if (argument.CompareTo("-tree")==0) {
107 if ((bMissingParam=(++i>=argc))) break;
111 } else if (argument.CompareTo("-verbose")==0) {
115 } else if (argument.CompareTo("-datatype")==0) {
116 if ((bMissingParam=(++i>=argc))) break;
117 memcpy(&fDataType.fID, argv[i], TMath::Min(kAliHLTComponentDataTypefIDsize, (Int_t)strlen(argv[i])));
118 if ((bMissingParam=(++i>=argc))) break;
119 memcpy(&fDataType.fOrigin, argv[i], TMath::Min(kAliHLTComponentDataTypefOriginSize, (Int_t)strlen(argv[i])));
122 } else if (argument.CompareTo("-dataspec")==0) {
123 if ((bMissingParam=(++i>=argc))) break;
124 TString parameter(argv[i]);
125 parameter.Remove(TString::kLeading, ' '); // remove all blanks
126 if (parameter.IsDigit()) {
127 fSpecification=(AliHLTUInt32_t)parameter.Atoi();
128 } else if (parameter.BeginsWith("0x") &&
129 parameter.Replace(0,2,"",0).IsHex()) {
130 sscanf(parameter.Data(),"%x", &fSpecification);
132 HLTError("wrong parameter for argument %s, number expected", argument.Data());
136 HLTError("unknown argument %s", argument.Data());
141 HLTError("missing parameter for argument %s", argument.Data());
145 if (iResult<0) return iResult;
147 if (fLoaderType.IsNull()) {
148 AliErrorStream() << "loader type required, use \'-loader\' option" << endl;
152 // fetch runLoader instance from interface
153 AliRunLoader* pRunLoader=GetRunLoader();
156 // get the TPC loader
157 fpLoader=pRunLoader->GetLoader(fLoaderType.Data());
159 // prepare the loader
160 fpLoader->LoadDigits("read");
162 // scan trough all events and estimate the size of the digits
163 for (int i=0; i<pRunLoader->GetNumberOfEvents(); i++) {
164 pRunLoader->GetEvent(i);
165 TTree* pTree=GetTree();
167 int size=EstimateObjectSize(pTree);
168 if (size>fMaxSize) fMaxSize=size;
170 AliInfoStream() << "event " << i << " "
171 << fTreeType <<" size " << size
172 << " count " << pTree->GetEntries() << endl;
175 AliWarningStream() << "no " << fTreeType << " tree for event " << i << endl;
179 AliErrorStream() << "can not get loader of type " << fLoaderType << endl;
183 AliErrorStream() << "can not get runLoader" << endl;
189 int AliHLTLoaderPublisherComponent::DoDeinit()
191 // see header file for class documentation
194 fpLoader->UnloadDigits();
200 int AliHLTLoaderPublisherComponent::GetEvent(const AliHLTComponentEventData& /*evtData*/,
201 AliHLTComponentTriggerData& /*trigData*/)
203 // see header file for class documentation
205 // fetch runLoader instance from interface
206 AliRunLoader* pRunLoader=GetRunLoader();
207 if (pRunLoader && fpLoader) {
208 pRunLoader->GetEvent(GetEventCount());
209 TTree* pTree=GetTree();
211 PushBack(pTree, fDataType);
213 AliWarningStream() << "no " << fTreeType << " tree for event " << GetEventCount() << endl;
216 AliErrorStream() << "component not initialized" << endl;
222 TTree* AliHLTLoaderPublisherComponent::GetTree()
226 if (fTreeType.CompareTo("digits")==0)
227 pTree=fpLoader->TreeD();
228 else if (fTreeType.CompareTo("clusters")==0) {
229 pTree=fpLoader->TreeR();