- coverity fixes
[u/mrichter/AliRoot.git] / TRD / Cal / AliTRDCreateDummyCDB_DP.C
CommitLineData
bbe2dd8d 1#if !defined( __CINT__) || defined(__MAKECINT__)
2
3#include <iostream>
4
5#include <AliCDBManager.h>
6#include <AliCDBStorage.h>
7#include <AliCDBEntry.h>
8#include <AliCDBMetaData.h>
9
10#include "AliTRDgeometry.h"
11
12#include "AliTRDCalDCS.h"
13#include "AliTRDCalDCSFEE.h"
14
15#endif
16
17// ===================================================
18// Modified version of the macro AliTRDCreateDummyCDB
19// to create the default CDB object for the DCS
20// data points
21// Modifications done by Frederick Kramer 2010-05-11
22// ===================================================
23
24
25
26// Run numbers for the dummy file
27const Int_t gkDummyRunBeg = 0;
28const Int_t gkDummyRunEnd = 999999999;
29AliCDBStorage *gStorLoc = 0;
30
31
32//_____________________________________________________________________________
33TMap* CreateDCSAliasMap(Int_t entries) {
34 // Creates a DCS structure
35 // The structure is the following:
36 // TMap (key --> value)
37 // <DCSAlias> --> <valueList>
38 // <DCSAlias> is a string
39 // <valueList> is a TObjArray of AliDCSValue
40 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
41
42 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
43
44 TMap* aliasMap = new TMap;
45 aliasMap->SetOwner(1);
46
47 TRandom random;
48
49 for(int nAlias=0;nAlias<entries;nAlias++)
50 {
51 TObjArray* valueSet = new TObjArray;
52 valueSet->SetOwner(1);
53
54 TString aliasName="DCSAlias";
55 aliasName += nAlias;
56 //printf("\n\n alias: %s\n\n",aliasName.Data());
57
58 for (int timeStamp=0;timeStamp<1000;timeStamp+=10)
59 {
60 AliDCSValue* dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
61 //printf("%s\n",dcsVal->ToString().Data());
62 valueSet->Add(dcsVal);
63 }
64 aliasMap->Add(new TObjString(aliasName), valueSet);
65 }
66
67 return aliasMap;
68}
69
70
71//_____________________________________________________________________________
72AliCDBMetaData *CreateMetaObject(const char *objectClassName)
73{
74
75 AliCDBMetaData *md1= new AliCDBMetaData();
76 md1->SetObjectClassName(objectClassName);
77 md1->SetResponsible("Frederick Kramer");
78 md1->SetBeamPeriod(1);
79 md1->SetAliRootVersion("05-26-00b"); //root version
80 md1->SetComment("Ideal DCS DP CDB object");
81
82 return md1;
83
84}
85
86//_____________________________________________________________________________
87void StoreObject(const char* cdbPath, AliTRDSensorArray* object, AliCDBMetaData* metaData)
88{
89
90 AliCDBId id1(cdbPath,gkDummyRunBeg,gkDummyRunEnd);
91 gStorLoc->Put(object,id1,metaData);
92
93}
94
95
96//_____________________________________________________________________________
97void AliTRDCreateDummyCDB_DP()
98{
99
100 cout << endl
101 << "TRD :: Creating dummy CDB for the runs "
102 << gkDummyRunBeg
103 << " -- "
104 << gkDummyRunEnd
105 << endl;
106
107 AliCDBManager *man = AliCDBManager::Instance();
108 gStorLoc = man->GetStorage("local://$ALICE_ROOT/OCDB");
109 if (!gStorLoc) {
110 return;
111 }
112
113 AliCDBMetaData *metaData = 0;
114 TObjArray* list = AliTRDSensorArray::GetList();
115
116 if (list == 0x0) {
117 printf("Error during AliTRDSensorArray::GetList\n");
118 printf("DCS will not be processing\n");
119 }
120
121 Int_t nEntries = list->GetEntries();
122 printf("%d alias loaded\n", nEntries);
123
124 Bool_t* results = new Bool_t [nEntries];
125 Int_t* nGraph = new Int_t [nEntries];
126 TMap* dcsAliasMap = CreateDCSAliasMap(nEntries);
127
128 for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) {
129
130 AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At(iAlias);
131
132 oneTRDDCS->SetStartTime(TTimeStamp (1000000000));
133 oneTRDDCS->SetEndTime(TTimeStamp (2000000000));
134 printf("Processing DCS : \"%s\"\n", oneTRDDCS->GetStoreName().Data());
135
136 TMap * map;
137 map = oneTRDDCS->ExtractDCS(dcsAliasMap);
138 nGraph[iAlias] = map->GetEntries();
139 oneTRDDCS->SetGraph(map);
140
141 char ocdbpath[256];
142 sprintf(ocdbpath, "TRD/Calib/%s", oneTRDDCS->GetStoreName().Data());
143 metaData = CreateMetaObject(oneTRDDCS->GetStoreName().Data());
144
145 StoreObject(ocdbpath, oneTRDDCS, metaData);
146 }
147
148}
149