]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/global/AliHLTGlobalPreprocessor.cxx
LHAPDF: Removing lhapdf 5.3.1 version
[u/mrichter/AliRoot.git] / HLT / global / AliHLTGlobalPreprocessor.cxx
CommitLineData
a37fc0f5 1// $Id$
2
3//**************************************************************************
24835001 4//* This file is property of and copyright by the *
a37fc0f5 5//* ALICE Experiment at CERN, All rights reserved. *
6//* *
7//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no *
8//* for The ALICE HLT Project. *
9//* *
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//**************************************************************************
18
19// @file AliHLTGlobalPreprocessor.cxx
20// @author Matthias Richter
21// @date 2010-08-20
22// @brief HLT Preprocessor plugin for global HLT
23//
24
25#include "AliHLTGlobalPreprocessor.h"
e0047231 26#include "AliPreprocessor.h"
24835001 27#include "AliHLTMisc.h"
a37fc0f5 28#include "AliCDBManager.h"
29#include "AliCDBEntry.h"
30#include "AliGRPObject.h"
31#include "AliCDBMetaData.h"
32#include "AliCDBId.h"
33#include "AliLog.h"
34#include <cassert>
35#include <cerrno>
36
37#include <TObjArray.h>
38#include <TStreamerInfo.h>
39//#include <AliDCSValue.h>
40//#include <TTimeStamp.h>
41
42
43ClassImp(AliHLTGlobalPreprocessor)
44
45AliHLTGlobalPreprocessor::AliHLTGlobalPreprocessor()
46 : AliHLTModulePreprocessor()
47{
48 // constructor
24835001 49 // HLT preprocessor for global HLT objects
50 //
51 // Produced OCDB objects:
52 // - HLT/Calib/Streamerinfo
53 // The streamer info object is produced by the ROOTSchemaEvolutionComponent
54 // See ProcessStreamerInfo() for details.
a37fc0f5 55}
56
57const char* AliHLTGlobalPreprocessor::fgkStreamerInfoAlias="StreamerInfo";
58const char* AliHLTGlobalPreprocessor::fgkStreamerInfoName="StreamerInfo";
59const char* AliHLTGlobalPreprocessor::fgkStreamerInfoType="Calib";
60
61AliHLTGlobalPreprocessor::~AliHLTGlobalPreprocessor()
62{
63 // destructor
64}
65
66
67void AliHLTGlobalPreprocessor::Initialize(Int_t /*run*/, UInt_t /*startTime*/,
68 UInt_t /*endTime*/)
69{
70 // initializes AliHLTGlobalPreprocessor
71
72}
73
e0047231 74UInt_t AliHLTGlobalPreprocessor::Process(TMap* /*dcsAliasMap*/)
a37fc0f5 75{
e0047231 76 Int_t returnValue = ProcessStreamerInfo();
77 if (returnValue < 0) {
78 AliInfo(Form("Processing for %s failed with return code %d", fgkStreamerInfoAlias, returnValue));
79 }
80 return 0; // return success
a37fc0f5 81}
82
24835001 83Int_t AliHLTGlobalPreprocessor::GetModuleNumber()
84{
85 // get module number of this preprocessor, corresponds to the position
86 // in the detector bit field, or 0 if no corresponding detector existing
a37fc0f5 87 Int_t modulenumber = 0;
88 //modulenumber = AliHLTModulePreprocessor::DetectorBitMask("GRP");
89 return modulenumber;
24835001 90}
a37fc0f5 91
e0047231 92Int_t AliHLTGlobalPreprocessor::ProcessStreamerInfo() {
93 // get file sources
94 TList* list = GetFileSources(AliPreprocessor::kHLT, fgkStreamerInfoAlias);
95 if ((!list) || (list->GetEntries() == 0)) {
96 AliInfo(Form("No sources for %s found",fgkStreamerInfoAlias));
97 return -1; // no sources
98 }
99 bool bStore = false;
100 TObjArray* clone = NULL;
101 // get existing object or create new one
102 AliCDBEntry* entry = GetFromOCDB(fgkStreamerInfoType, fgkStreamerInfoName);
103 if (entry && entry->GetObject()) {
104 TObject* cloneObj = entry->GetObject()->Clone();
105 if (cloneObj) clone = dynamic_cast<TObjArray*>(cloneObj);
106 } else {
107 clone = new TObjArray();
108 bStore = true;
109 }
110 if (!clone) {
111 AliError(Form("Could not clone %s, %s", fgkStreamerInfoType, fgkStreamerInfoName));
112 return -2; // no clone
113 }
114 // loop over all sources
115 TObjLink *lnk = list->FirstLink();
116 while (lnk) {
117 TObject* obj = lnk->GetObject();
118 TObjString* objStr = dynamic_cast<TObjString*>(obj);
119 if (!objStr) {
120 AliError(Form("GetFileSources returned TList with no TObjString entry?! %s", obj->ClassName()));
121 // continue with next list entry
122 lnk = lnk->Next();
123 continue;
124 }
125 TString fileName = GetFile(AliPreprocessor::kHLT,fgkStreamerInfoAlias ,objStr->GetString().Data());
126 if (fileName.Length() == 0) {
127 AliError(Form("Could not get %d-%s-%s", AliPreprocessor::kHLT,fgkStreamerInfoAlias ,objStr->GetString().Data()));
128 }
129 // time to process the file...
130 TFile* f = new TFile(fileName.Data(), "READ");
131 if (!f || !f->IsOpen()) {
132 AliError(Form("Could not open %s", objStr->GetString().Data()));
133 return -3;
134 }
135 // loop over objects and create new TObjArrary to feed into merger...
136 TObjArray* streamerinfos = new TObjArray(100);
137 TList* keys = f->GetListOfKeys();
138 TObjLink *lnkFile = keys->FirstLink();
139 while (lnkFile) {
140 // processing
141 TObject* streamerobj = f->Get(lnkFile->GetObject()->GetName());
142 TStreamerInfo* streamer=dynamic_cast<TStreamerInfo*>(streamerobj);
143 if (!streamer) {
144 AliError(Form("StreamerInfo object has wrong class type %s, expecting TStreamerInfo", streamerobj->ClassName()));
145 } else {
146 streamerinfos->Add(streamer);
147 }
148 lnkFile = lnkFile->Next();
149 }
150 if (streamerinfos->GetEntriesFast()!=0) {
151 bStore |= AliHLTMisc::Instance().MergeStreamerInfo(clone, streamerinfos, 1)>0;
152 }
153 delete streamerinfos;
154 f->Close();
155 delete f;
156 lnk = lnk->Next();
157 }
158 // store if necessary
159 if (bStore) {
160 AliCDBMetaData* metaData=entry?entry->GetMetaData():NULL;
161 AliCDBMetaData* newMetaData=NULL;
162 if (!metaData) {
163 newMetaData=new AliCDBMetaData;
164 if (newMetaData) {
165 metaData=newMetaData;
166 metaData->SetBeamPeriod(0);
167 metaData->SetResponsible("ALICE HLT alice-hlt-core@cern.ch");
168 metaData->SetComment("Streamer info for HLTOUT payload");
0492edf5 169 //metaData->SetAliRootVersion(ALIROOT_BRANCH);
e0047231 170 } else {
171 return -ENOMEM;
172 }
173 }
f32f8dd3 174 Store(fgkStreamerInfoType, fgkStreamerInfoName, clone, metaData, 0, kTRUE);
e0047231 175 if (newMetaData) {
176 delete newMetaData;
177 newMetaData=NULL;
178 metaData=NULL;
179 }
180 } else {
181 if (entry) {
182 AliInfo(Form("StreamerInfo object in OCDB is already up-to-date, skipping new object"));
183 //entry->PrintId();
184 }
185 }
186 delete clone;
187 return 0;
188}
189
a37fc0f5 190