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 /** ROOT macro for the implementation of ROOT specific class methods */
38 ClassImp(AliHLTLoaderPublisherComponent)
40 AliHLTLoaderPublisherComponent::AliHLTLoaderPublisherComponent()
46 fDataType(kAliHLTAnyDataType),
47 fSpecification(kAliHLTVoidDataSpec),
50 // see header file for class documentation
52 // refer to README to build package
54 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
57 AliHLTLoaderPublisherComponent::~AliHLTLoaderPublisherComponent()
59 // see header file for class documentation
62 const char* AliHLTLoaderPublisherComponent::GetComponentID()
64 // see header file for class documentation
65 return "AliLoaderPublisher";
68 AliHLTComponentDataType AliHLTLoaderPublisherComponent::GetOutputDataType()
70 // see header file for class documentation
74 void AliHLTLoaderPublisherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
76 // see header file for class documentation
81 AliHLTComponent* AliHLTLoaderPublisherComponent::Spawn()
83 // see header file for class documentation
84 return new AliHLTLoaderPublisherComponent;
87 int AliHLTLoaderPublisherComponent::DoInit( int argc, const char** argv )
89 // see header file for class documentation
95 for (int i=0; i<argc && iResult>=0; i++) {
97 if (argument.IsNull()) continue;
100 if (argument.CompareTo("-loader")==0) {
101 if ((bMissingParam=(++i>=argc))) break;
105 } else if (argument.CompareTo("-tree")==0) {
106 if ((bMissingParam=(++i>=argc))) break;
110 } else if (argument.CompareTo("-verbose")==0) {
114 } else if (argument.CompareTo("-datatype")==0) {
115 if ((bMissingParam=(++i>=argc))) break;
116 memcpy(&fDataType.fID, argv[i], TMath::Min(kAliHLTComponentDataTypefIDsize, (Int_t)strlen(argv[i])));
117 if ((bMissingParam=(++i>=argc))) break;
118 memcpy(&fDataType.fOrigin, argv[i], TMath::Min(kAliHLTComponentDataTypefOriginSize, (Int_t)strlen(argv[i])));
121 } else if (argument.CompareTo("-dataspec")==0) {
122 if ((bMissingParam=(++i>=argc))) break;
123 TString parameter(argv[i]);
124 parameter.Remove(TString::kLeading, ' '); // remove all blanks
125 if (parameter.IsDigit()) {
126 fSpecification=(AliHLTUInt32_t)parameter.Atoi();
127 } else if (parameter.BeginsWith("0x") &&
128 parameter.Replace(0,2,"",0).IsHex()) {
129 sscanf(parameter.Data(),"%x", &fSpecification);
131 HLTError("wrong parameter for argument %s, number expected", argument.Data());
135 HLTError("unknown argument %s", argument.Data());
140 HLTError("missing parameter for argument %s", argument.Data());
144 if (iResult<0) return iResult;
146 if (fLoaderType.IsNull()) {
147 AliErrorStream() << "loader type required, use \'-loader\' option" << endl;
151 // fetch runLoader instance from interface
152 AliRunLoader* pRunLoader=GetRunLoader();
155 // get the TPC loader
156 fpLoader=pRunLoader->GetLoader(fLoaderType.Data());
158 // prepare the loader
159 fpLoader->LoadDigits("read");
161 // scan trough all events and estimate the size of the digits
162 for (int i=0; i<pRunLoader->GetNumberOfEvents(); i++) {
163 pRunLoader->GetEvent(i);
164 TTree* pTree=GetTree();
166 int size=EstimateObjectSize(pTree);
167 if (size>fMaxSize) fMaxSize=size;
169 AliInfoStream() << "event " << i << " "
170 << fTreeType <<" size " << size
171 << " count " << pTree->GetEntries() << endl;
174 AliWarningStream() << "no " << fTreeType << " tree for event " << i << endl;
178 AliErrorStream() << "can not get loader of type " << fLoaderType << endl;
182 AliErrorStream() << "can not get runLoader" << endl;
188 int AliHLTLoaderPublisherComponent::DoDeinit()
190 // see header file for class documentation
193 fpLoader->UnloadDigits();
199 int AliHLTLoaderPublisherComponent::GetEvent(const AliHLTComponentEventData& /*evtData*/,
200 AliHLTComponentTriggerData& /*trigData*/)
202 // see header file for class documentation
204 // fetch runLoader instance from interface
205 AliRunLoader* pRunLoader=GetRunLoader();
206 if (pRunLoader && fpLoader) {
207 pRunLoader->GetEvent(GetEventCount());
208 TTree* pTree=GetTree();
210 PushBack(pTree, fDataType);
212 AliWarningStream() << "no " << fTreeType << " tree for event " << GetEventCount() << endl;
215 AliErrorStream() << "component not initialized" << endl;
221 TTree* AliHLTLoaderPublisherComponent::GetTree()
223 // see header file for class documentation
226 if (fTreeType.CompareTo("digits")==0)
227 pTree=fpLoader->TreeD();
228 else if (fTreeType.CompareTo("clusters")==0) {
229 pTree=fpLoader->TreeR();