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 AliHLTRootSchemaEvolutionComponent.cxx
20 @author Matthias Richter
22 @brief Handler component for ROOT schema evolution of streamed objects
25 #include "AliHLTRootSchemaEvolutionComponent.h"
26 #include "AliHLTMessage.h"
27 #include "TObjArray.h"
28 #include "TStreamerInfo.h"
31 /** ROOT macro for the implementation of ROOT specific class methods */
32 ClassImp(AliHLTRootSchemaEvolutionComponent)
34 AliHLTRootSchemaEvolutionComponent::AliHLTRootSchemaEvolutionComponent()
37 , fpStreamerInfos(NULL)
40 // see header file for class documentation
42 // refer to README to build package
44 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
47 const char* AliHLTRootSchemaEvolutionComponent::fgkConfigurationObject=NULL;
49 AliHLTRootSchemaEvolutionComponent::~AliHLTRootSchemaEvolutionComponent()
51 // see header file for class documentation
52 if (fpStreamerInfos) {
53 fpStreamerInfos->Clear();
54 delete fpStreamerInfos;
59 void AliHLTRootSchemaEvolutionComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
61 // see header file for class documentation
62 list.push_back(kAliHLTAnyDataType);
65 AliHLTComponentDataType AliHLTRootSchemaEvolutionComponent::GetOutputDataType()
67 // see header file for class documentation
68 return kAliHLTDataTypeStreamerInfo;
71 void AliHLTRootSchemaEvolutionComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
73 // see header file for class documentation
75 // this is nothing more than an assumption, in fact it's very difficult to predict how
76 // much output the component produces
81 int AliHLTRootSchemaEvolutionComponent::DoInit(int argc, const char** argv)
83 // see header file for class documentation
87 // default configuration from CDB
88 if (iResult>=0 && fgkConfigurationObject!=NULL) iResult=ConfigureFromCDBTObjString(fgkConfigurationObject);
90 // custom configuration from command line arguments
91 if (iResult>=0 && argc>0) iResult=ConfigureFromArgumentString(argc, argv);
94 fpStreamerInfos=new TObjArray();
95 if (!fpStreamerInfos) iResult=-ENOMEM;
100 int AliHLTRootSchemaEvolutionComponent::DoDeinit()
102 // see header file for class documentation
103 if (fpStreamerInfos) {
104 fpStreamerInfos->Clear();
105 delete fpStreamerInfos;
107 fpStreamerInfos=NULL;
112 int AliHLTRootSchemaEvolutionComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
113 AliHLTComponentTriggerData& /*trigData*/ )
115 // see header file for class documentation
117 AliHLTUInt32_t eventType=gkAliEventTypeUnknown;
118 if (!IsDataEvent(&eventType) &&
119 eventType==gkAliEventTypeStartOfRun) {
123 AliHLTMessage msg(kMESS_OBJECT);
124 msg.EnableSchemaEvolution();
125 for (const TObject* pObj=GetFirstInputObject();
127 pObj=GetNextInputObject()) {
128 msg.WriteObject(pObj);
129 iResult=UpdateStreamerInfos(msg.GetStreamerInfos(), fpStreamerInfos);
133 if ((TestBits(kHLTOUTatFirstEvent) && GetEventCount()==0) ||
134 (TestBits(kHLTOUTatAllEvents)) ||
135 (TestBits(kHLTOUTatEOR) && eventType==gkAliEventTypeEndOfRun)) {
136 PushBack(fpStreamerInfos, kAliHLTDataTypeStreamerInfo);
139 if (TestBits(kFXS) && eventType==gkAliEventTypeEndOfRun) {
140 // push to FXS, needs to be implemented in the base class
147 int AliHLTRootSchemaEvolutionComponent::UpdateStreamerInfos(const TList* list, TObjArray* infos) const
149 // see header file for class documentation
151 if (!list || !infos) {
155 TObject* element=NULL;
156 TIter next((TList*)list);
157 while ((element = next())) {
158 TStreamerInfo* pInfo=dynamic_cast<TStreamerInfo*>(element);
159 if (!pInfo) continue;
160 TString name=pInfo->GetName();
162 for (; i<infos->GetEntriesFast(); i++) {
163 if (name.CompareTo(infos->At(i)->GetName())==0 &&
164 pInfo->GetClassVersion() == ((TStreamerInfo*)infos->At(i))->GetClassVersion()) {
177 int AliHLTRootSchemaEvolutionComponent::ScanConfigurationArgument(int argc, const char** argv)
179 // see header file for class documentation
181 if (argc<=0) return 0;
183 TString argument=argv[i];
185 // -hltout=[all,first,eor,off]
186 if (argument.Contains("-hltout")) {
187 argument.ReplaceAll("-hltout", "");
188 argument.ReplaceAll("=", "");
189 if (argument.IsNull() || argument.CompareTo("all")) {
190 SetBits(kHLTOUTatAllEvents);
191 } else if (argument.CompareTo("first")) {
192 SetBits(kHLTOUTatFirstEvent);
193 } else if (argument.CompareTo("eor")) {
194 SetBits(kHLTOUTatEOR);
195 } else if (argument.CompareTo("off")) {
196 ClearBits(kHLTOUTatAllEvents | kHLTOUTatFirstEvent | kHLTOUTatEOR);
198 HLTError("invalid parameter for argument -hltout= : %s", argument.Data());
205 if (argument.Contains("-fxs")) {
206 argument.ReplaceAll("-fxs", "");
207 argument.ReplaceAll("=", "");
208 if (argument.IsNull()) {
210 } else if (argument.CompareTo("off")) {
212 } else if (argument.IsDigit()) {
213 fFXSPrescaler=argument.Atoi();
215 HLTError("invalid parameter for argument -fxs= : %s", argument.Data());