--- /dev/null
+// $Id$
+/**
+ * @file AddCalibStreamerInfo.C
+ * @brief Extraction of data blocks from HLTOUT
+ *
+ * <pre>
+ * Usage: aliroot -b -q AddCalibStreamerInfo.C'(classname, uri, version, firstRun, lastRun)'
+ * classname name of the class to add the streamer info
+ * uri optional URI of the OCDB, default local://$ALICE_ROOT/OCDB
+ * version version number of the entry (optional)
+ * firstRun first run (optional)
+ * lastRun last run (optional)
+ * </pre>
+ *
+ * The macro checks whether the streamer info of the current version
+ * of the class 'classname' is available in the
+ * HLT/Calib/StreamerInfo entry, and adds it if not.
+ *
+ * Streamer infos are needed in order to extract TObjects from the HLT raw data
+ * payload.
+ *
+ * @author Matthias.Richter@ift.uib.no
+ * @ingroup alihlt_rec
+ */
+void AddCalibStreamerInfo(
+ const char* className,
+ const char* cdbPath = "local://$ALICE_ROOT/OCDB",
+ Int_t version = 0,
+ Int_t firstRun = 0,
+ Int_t lastRun = AliCDBRunRange::Infinity()
+ )
+{
+ const char* gkCalibStreamerInfoEntry="HLT/Calib/StreamerInfo";
+
+ // Setup the CDB default storage and run number.
+ AliCDBManager* cdbManager = AliCDBManager::Instance();
+ if (cdbManager == NULL) {
+ cerr << "ERROR: Global CDB manager object does not exist." << endl;
+ return;
+ }
+ AliCDBStorage* storage = cdbManager->GetStorage(cdbPath);
+ if (storage == NULL) {
+ cerr << "ERROR: Could not get storage for: " << cdbPath << endl;
+ return;
+ }
+
+ TClass* pClass=TClass::GetClass(className);
+ if (!pClass) {
+ cerr << "ERROR: Can not find TClass object: " << className << endl;
+ return;
+ }
+ Int_t classVersion=pClass->GetClassVersion();
+
+ TObjArray* pInfos=NULL;
+ AliCDBRunRange runRange(firstRun, lastRun);
+ AliCDBEntry* pExistingEntry=storage->Get(gkCalibStreamerInfoEntry, runRange);
+ if (pExistingEntry) pInfos=(TObjArray*)pExistingEntry->GetObject();
+ else pInfos=new TObjArray;
+
+ TStreamerInfo* pInfo=NULL;
+ for (int i=0; i<pInfos->GetEntriesFast(); i++) {
+ if (pInfos->At(i)==NULL) continue;
+
+ if (pInfos->At(i)->IsA()!=TStreamerInfo::Class()) {
+ cout << "skipping object " << pInfos->At(i)->GetName() << " class " << pInfos->At(i)->Class()->GetName() << endl;
+ continue;
+ }
+
+ pInfo=(TStreamerInfo*)pInfos->At(i);
+ TString infoname=pInfo->GetName();
+ if (infoname.CompareTo(className)!=0) continue;
+
+ if (pInfo->GetClassVersion()==classVersion) {
+ cout << "nothing to be done, class " << className << " version " << classVersion << " already in the object" << endl;
+ return;
+ }
+ }
+ pInfo=new TStreamerInfo(pClass);
+ pInfo->Build();
+ pInfos->AddAtFree(pInfo);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ // Write the updated object to OCDB
+ AliCDBId id(gkCalibStreamerInfoEntry, firstRun, lastRun, version);
+ AliCDBMetaData* metaData = new AliCDBMetaData();
+ metaData->SetResponsible("HLT");
+ metaData->SetComment("Streamer info for streamed objects in the HLT raw data payload.");
+ storage->Put(pInfos, id, metaData);
+}
#include <TObjString.h>
#include "TFile.h"
#include "TTree.h"
+#include "TObject.h"
+#include "TObjArray.h"
+#include "TClass.h"
+#include "TStreamerInfo.h"
#include "AliHLTReconstructor.h"
#include "AliLog.h"
#include "AliRawReader.h"
#include "AliHLTOUTDigitReader.h"
#include "AliHLTEsdManager.h"
#include "AliHLTPluginBase.h"
+#include "AliHLTMisc.h"
+#include "AliCDBManager.h"
+#include "AliCDBEntry.h"
+
+class AliCDBEntry;
ClassImp(AliHLTReconstructor)
fpEsdManager=AliHLTEsdManager::New();
fpEsdManager->SetOption(esdManagerOptions.Data());
+
+ InitStreamerInfos();
+}
+
+const char* AliHLTReconstructor::fgkCalibStreamerInfoEntry="HLT/Calib/StreamerInfo";
+
+int AliHLTReconstructor::InitStreamerInfos()
+{
+ // init streamer infos for HLT reconstruction
+ // Root schema evolution is not enabled for AliHLTMessage and all streamed objects.
+ // Objects in the raw data payload rely on the availability of the correct stream info.
+ // The relevant streamer info for a specific run is stored in the OCDB.
+ // The method evaluates the following entries:
+ // - HLT/Calib/StreamerInfo
+
+ // to be activated later, this is supposed to go as patch into the v4-17-Release branch
+ // which doe snot have the AliHLTMisc implementation
+ //AliCDBEntry* pEntry=AliHLTMisc::Instance().LoadOCDBEntry(fgkCalibStreamerInfoEntry);
+ AliCDBEntry* pEntry=AliCDBManager::Instance()->Get(fgkCalibStreamerInfoEntry);
+ TObject* pObject=NULL;
+ //if (pEntry && (pObject=AliHLTMisc::Instance().ExtractObject(pEntry))!=NULL)
+ if (pEntry && (pObject=pEntry->GetObject())!=NULL)
+ {
+ TObjArray* pSchemas=dynamic_cast<TObjArray*>(pObject);
+ if (pSchemas) {
+ for (int i=0; i<pSchemas->GetEntriesFast(); i++) {
+ if (pSchemas->At(i)) {
+ TStreamerInfo* pSchema=dynamic_cast<TStreamerInfo*>(pSchemas->At(i));
+ if (pSchema) {
+ int version=pSchema->GetClassVersion();
+ TClass* pClass=TClass::GetClass(pSchema->GetName());
+ if (pClass) {
+ if (pClass->GetClassVersion()==version) {
+ AliDebug(0,Form("skipping schema definition %d version %d to class %s as this is the native version", i, version, pSchema->GetName()));
+ continue;
+ }
+ TObjArray* pInfos=pClass->GetStreamerInfos();
+ if (pInfos /*&& version<pInfos->GetEntriesFast()*/) {
+ if (pInfos->At(version)==NULL) {
+ TStreamerInfo* pClone=(TStreamerInfo*)pSchema->Clone();
+ if (pClone) {
+ pClone->SetClass(pClass);
+ pClone->BuildOld();
+ pInfos->AddAtAndExpand(pClone, version);
+ AliDebug(0,Form("adding schema definition %d version %d to class %s", i, version, pSchema->GetName()));
+ } else {
+ AliError(Form("skipping schema definition %d (%s), unable to create clone object", i, pSchema->GetName()));
+ }
+ } else {
+ TStreamerInfo* pInfo=dynamic_cast<TStreamerInfo*>(pInfos->At(version));
+ if (pInfo && pInfo->GetClassVersion()==version) {
+ AliDebug(0,Form("schema definition %d version %d already available in class %s", i, version, pSchema->GetName()));
+ } else {
+ AliError(Form("can not verify version for already existing schema definition %d (%s) version %d: version of existing definition is %d", i, pSchema->GetName(), version, pInfo?pInfo->GetClassVersion():-1));
+ }
+ }
+ } else {
+ AliError(Form("skipping schema definition %d (%s), unable to set version %d in info array of size %d", i, pSchema->GetName(), version, pInfos?pInfos->GetEntriesFast():-1));
+ }
+ } else {
+ AliError(Form("skipping schema definition %d (%s), unable to find class", i, pSchema->GetName()));
+ }
+ } else {
+ AliError(Form("skipping schema definition %d, not of TStreamerInfo", i));
+ }
+ }
+ }
+ } else {
+ AliError(Form("internal mismatch in OCDB entry %s: wrong class type", fgkCalibStreamerInfoEntry));
+ }
+ } else {
+ AliWarning(Form("missing HLT reco data (%s), skipping initialization of streamer info for TObjects in HLT raw data payload", fgkCalibStreamerInfoEntry));
+ }
+ return 0;
}
void AliHLTReconstructor::Reconstruct(AliRawReader* rawReader, TTree* /*clustersTree*/) const