]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/rec/AddCalibStreamerInfo.C
Fixed naming for different cone size, added new AOD cut (16), added fastkt option
[u/mrichter/AliRoot.git] / HLT / rec / AddCalibStreamerInfo.C
CommitLineData
dc5556e5 1// $Id$
2/**
3 * @file AddCalibStreamerInfo.C
4 * @brief Extraction of data blocks from HLTOUT
5 *
6 * <pre>
7 * Usage: aliroot -b -q AddCalibStreamerInfo.C'(classname, uri, version, firstRun, lastRun)'
8 * classname name of the class to add the streamer info
9 * uri optional URI of the OCDB, default local://$ALICE_ROOT/OCDB
10 * version version number of the entry (optional)
11 * firstRun first run (optional)
12 * lastRun last run (optional)
13 * </pre>
14 *
15 * The macro checks whether the streamer info of the current version
16 * of the class 'classname' is available in the
17 * HLT/Calib/StreamerInfo entry, and adds it if not.
18 *
19 * Streamer infos are needed in order to extract TObjects from the HLT raw data
20 * payload.
21 *
22 * @author Matthias.Richter@ift.uib.no
23 * @ingroup alihlt_rec
24 */
25void AddCalibStreamerInfo(
26 const char* className,
27 const char* cdbPath = "local://$ALICE_ROOT/OCDB",
28 Int_t version = 0,
29 Int_t firstRun = 0,
30 Int_t lastRun = AliCDBRunRange::Infinity()
31 )
32{
33 const char* gkCalibStreamerInfoEntry="HLT/Calib/StreamerInfo";
34
35 // Setup the CDB default storage and run number.
36 AliCDBManager* cdbManager = AliCDBManager::Instance();
37 if (cdbManager == NULL) {
38 cerr << "ERROR: Global CDB manager object does not exist." << endl;
39 return;
40 }
41 AliCDBStorage* storage = cdbManager->GetStorage(cdbPath);
42 if (storage == NULL) {
43 cerr << "ERROR: Could not get storage for: " << cdbPath << endl;
44 return;
45 }
46
47 TClass* pClass=TClass::GetClass(className);
48 if (!pClass) {
49 cerr << "ERROR: Can not find TClass object: " << className << endl;
50 return;
51 }
52 Int_t classVersion=pClass->GetClassVersion();
53
54 TObjArray* pInfos=NULL;
55 AliCDBRunRange runRange(firstRun, lastRun);
56 AliCDBEntry* pExistingEntry=storage->Get(gkCalibStreamerInfoEntry, runRange);
57 if (pExistingEntry) pInfos=(TObjArray*)pExistingEntry->GetObject();
58 else pInfos=new TObjArray;
59
60 TStreamerInfo* pInfo=NULL;
61 for (int i=0; i<pInfos->GetEntriesFast(); i++) {
62 if (pInfos->At(i)==NULL) continue;
63
64 if (pInfos->At(i)->IsA()!=TStreamerInfo::Class()) {
65 cout << "skipping object " << pInfos->At(i)->GetName() << " class " << pInfos->At(i)->Class()->GetName() << endl;
66 continue;
67 }
68
69 pInfo=(TStreamerInfo*)pInfos->At(i);
70 TString infoname=pInfo->GetName();
71 if (infoname.CompareTo(className)!=0) continue;
72
73 if (pInfo->GetClassVersion()==classVersion) {
74 cout << "nothing to be done, class " << className << " version " << classVersion << " already in the object" << endl;
75 return;
76 }
77 }
78 pInfo=new TStreamerInfo(pClass);
79 pInfo->Build();
80 pInfos->AddAtFree(pInfo);
81
82 ///////////////////////////////////////////////////////////////////////////////////////////
83 // Write the updated object to OCDB
84 AliCDBId id(gkCalibStreamerInfoEntry, firstRun, lastRun, version);
85 AliCDBMetaData* metaData = new AliCDBMetaData();
86 metaData->SetResponsible("HLT");
87 metaData->SetComment("Streamer info for streamed objects in the HLT raw data payload.");
88 storage->Put(pInfos, id, metaData);
89}