Coverity fix
[u/mrichter/AliRoot.git] / TRD / TRDbase / AliTRDCreateDummyCDB.C
CommitLineData
7754cd1f 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 "AliTRDCalROC.h"
7754cd1f 13#include "AliTRDCalPad.h"
14#include "AliTRDCalDet.h"
7754cd1f 15
7754cd1f 16#include "AliTRDCalChamberStatus.h"
7754cd1f 17#include "AliTRDCalPadStatus.h"
18#include "AliTRDCalSingleChamberStatus.h"
19
20#include "AliTRDCalPIDLQ.h"
21#include "AliTRDCalMonitoring.h"
22
23#endif
24
ec9303f8 25// Run numbers for the dummy file
26const Int_t gkDummyRunBeg = 0;
27const Int_t gkDummyRunEnd = 999999999;
28AliCDBStorage *gStorLoc = 0;
7754cd1f 29
d4c6453d 30//_____________________________________________________________________________
31TObject *CreatePadObject(const char *shortName, const char *description
32 , Float_t value)
7754cd1f 33{
d4c6453d 34
7754cd1f 35 AliTRDCalPad *calPad = new AliTRDCalPad(shortName, description);
d4c6453d 36 for (Int_t det = 0; det < AliTRDgeometry::kNdet; ++det) {
7754cd1f 37 AliTRDCalROC *calROC = calPad->GetCalROC(det);
d4c6453d 38 for (Int_t channel = 0; channel < calROC->GetNchannels(); ++channel) {
7754cd1f 39 calROC->SetValue(channel, value);
d4c6453d 40 }
7754cd1f 41 }
42 return calPad;
d4c6453d 43
7754cd1f 44}
45
d4c6453d 46//_____________________________________________________________________________
47TObject *CreateDetObject(const char *shortName, const char *description
48 , Float_t value)
7754cd1f 49{
d4c6453d 50
7754cd1f 51 AliTRDCalDet *object = new AliTRDCalDet(shortName, description);
d4c6453d 52 for (Int_t det = 0; det < AliTRDgeometry::kNdet; ++det) {
7754cd1f 53 object->SetValue(det, value);
d4c6453d 54 }
7754cd1f 55 return object;
d4c6453d 56
7754cd1f 57}
58
d4c6453d 59//_____________________________________________________________________________
d4c6453d 60TObject *CreatePRFWidthObject()
7754cd1f 61{
d4c6453d 62
7754cd1f 63 AliTRDCalPad *calPad = new AliTRDCalPad("PRFWidth","PRFWidth");
b846cb23 64 for (Int_t iLayer = 0; iLayer < AliTRDgeometry::kNlayer; ++iLayer) {
d4c6453d 65
66 Float_t value = 0.0;
b846cb23 67 switch (iLayer) {
d4c6453d 68 case 0:
69 value = 0.515;
70 break;
71 case 1:
72 value = 0.502;
73 break;
74 case 2:
75 value = 0.491;
76 break;
77 case 3:
78 value = 0.481;
79 break;
80 case 4:
81 value = 0.471;
82 break;
83 case 5:
84 value = 0.463;
85 break;
86 default:
87 cout << "CreatePRFWidthObject: UNEXPECTED" << endl;
88 return 0;
7754cd1f 89 }
d4c6453d 90
b846cb23 91 for (Int_t iStack = 0; iStack < AliTRDgeometry::kNstack; ++iStack) {
92 for (Int_t iSector = 0; iSector < AliTRDgeometry::kNsector; ++iSector) {
93 AliTRDCalROC *calROC = calPad->GetCalROC(iLayer,iStack,iSector);
94 for (Int_t iChannel = 0; iChannel < calROC->GetNchannels(); ++iChannel) {
95 calROC->SetValue(iChannel, value);
d4c6453d 96 }
7754cd1f 97 }
98 }
d4c6453d 99
7754cd1f 100 }
101
102 return calPad;
7754cd1f 103
7754cd1f 104}
105
d4c6453d 106//_____________________________________________________________________________
107AliTRDCalChamberStatus *CreateChamberStatusObject()
7754cd1f 108{
7754cd1f 109
d4c6453d 110 AliTRDCalChamberStatus *obj = new AliTRDCalChamberStatus("chamberstatus"
111 ,"chamberstatus");
112
113 for (Int_t i = 0; i < AliTRDgeometry::kNdet; ++i) {
7754cd1f 114 obj->SetStatus(i, AliTRDCalChamberStatus::kInstalled);
d4c6453d 115 }
7754cd1f 116
117 return obj;
d4c6453d 118
7754cd1f 119}
120
d4c6453d 121//_____________________________________________________________________________
122AliTRDCalPadStatus *CreatePadStatusObject()
7754cd1f 123{
d4c6453d 124 AliTRDCalPadStatus *obj = new AliTRDCalPadStatus("padstatus"
125 ,"padstatus");
7754cd1f 126
127 return obj;
d4c6453d 128
7754cd1f 129}
130
d4c6453d 131//_____________________________________________________________________________
d4c6453d 132AliTRDCalMonitoring *CreateMonitoringObject()
7754cd1f 133{
d4c6453d 134 AliTRDCalMonitoring *obj = new AliTRDCalMonitoring();
7754cd1f 135
136 return obj;
d4c6453d 137
7754cd1f 138}
139
d4c6453d 140//_____________________________________________________________________________
a2348794 141TClonesArray* CreateRecoParamObject()
142{
143 TClonesArray *recos = new TClonesArray("AliTRDrecoParam", 3);
144 recos->SetOwner(kTRUE);
145
146 AliTRDrecoParam *rec = 0x0;
147 AliTRDrecoParam *reco = new((*recos)[0]) AliTRDrecoParam(*(rec = AliTRDrecoParam::GetLowFluxParam()));
148 delete rec;
149 // further settings for low flux reco param
150 // reco->SetThisAndThat()
151
152 reco = new((*recos)[1]) AliTRDrecoParam(*(rec = AliTRDrecoParam::GetHighFluxParam()));
153 delete rec;
154
155 reco = new((*recos)[2]) AliTRDrecoParam(*(rec = AliTRDrecoParam::GetCosmicTestParam()));
156 delete rec;
157
158 return recos;
159
160}
161
162//_____________________________________________________________________________
d4c6453d 163AliCDBMetaData *CreateMetaObject(const char *objectClassName)
7754cd1f 164{
d4c6453d 165
7754cd1f 166 AliCDBMetaData *md1= new AliCDBMetaData();
167 md1->SetObjectClassName(objectClassName);
f777d98f 168 md1->SetResponsible("Christoph Blume");
7754cd1f 169 md1->SetBeamPeriod(1);
f777d98f 170 md1->SetAliRootVersion("05-16-00"); //root version
171 md1->SetComment("Ideal calibration values");
7754cd1f 172
173 return md1;
d4c6453d 174
7754cd1f 175}
176
d4c6453d 177//_____________________________________________________________________________
178void StoreObject(const char *cdbPath, TObject *object, AliCDBMetaData *metaData)
7754cd1f 179{
d4c6453d 180
ec9303f8 181 AliCDBId id1(cdbPath,gkDummyRunBeg,gkDummyRunEnd);
d4c6453d 182 gStorLoc->Put(object,id1,metaData);
183
7754cd1f 184}
185
a2348794 186
d4c6453d 187//_____________________________________________________________________________
7754cd1f 188void AliTRDCreateDummyCDB()
189{
d4c6453d 190
191 cout << endl
ec9303f8 192 << "TRD :: Creating dummy CDB for the runs "
193 << gkDummyRunBeg
194 << " -- "
195 << gkDummyRunEnd
d4c6453d 196 << endl;
7754cd1f 197
198 AliCDBManager *man = AliCDBManager::Instance();
162637e4 199 gStorLoc = man->GetStorage("local://$ALICE_ROOT/OCDB");
d4c6453d 200 if (!gStorLoc) {
7754cd1f 201 return;
d4c6453d 202 }
7754cd1f 203
d4c6453d 204 TObject *obj = 0;
205 AliCDBMetaData *metaData = 0;
a2348794 206
207 //
208 // Reco Param Object
209 //
210
211 metaData= new AliCDBMetaData();
212 metaData->SetObjectClassName("TClonesArray");
213 metaData->SetResponsible("Alexandru Bercuci");
214 metaData->SetBeamPeriod(1);
215 metaData->SetAliRootVersion("05-19-04"); //root version
216 metaData->SetComment("Ideal reconstruction parameters for low, high and cosmic runs");
217 StoreObject("TRD/Calib/RecoParam",CreateRecoParamObject(),metaData);
218 return;
219
d4c6453d 220 //
221 // Pad objects
222 //
223
224 metaData = CreateMetaObject("AliTRDCalPad");
225
9b5afbe3 226 obj = CreatePadObject("LocalVdrift" ,"TRD drift velocities (local variations)",1);
227 StoreObject("TRD/Calib/LocalVdrift" ,obj,metaData);
7754cd1f 228
8d786fb8 229 obj = CreatePadObject("LocalT0" ,"T0 (local variations)",0);
d4c6453d 230 StoreObject("TRD/Calib/LocalT0" ,obj,metaData);
7754cd1f 231
9b5afbe3 232 obj = CreatePadObject("GainFactor" ,"GainFactor (local variations)",1);
233 StoreObject("TRD/Calib/LocalGainFactor" ,obj,metaData);
7754cd1f 234
9b5afbe3 235 obj = CreatePRFWidthObject();
236 StoreObject("TRD/Calib/PRFWidth" ,obj,metaData);
d4c6453d 237
238 //
239 // Detector objects
240 //
7754cd1f 241
242 metaData = CreateMetaObject("AliTRDCalDet");
243
9b5afbe3 244 obj = CreateDetObject("ChamberVdrift" ,"TRD drift velocities (detector value)", 1.5);
245 StoreObject("TRD/Calib/ChamberVdrift" ,obj,metaData);
7754cd1f 246
8d786fb8 247 obj = CreateDetObject("ChamberT0" ,"T0 (detector value)",0);
d4c6453d 248 StoreObject("TRD/Calib/ChamberT0" ,obj,metaData);
7754cd1f 249
9b5afbe3 250 obj = CreateDetObject("ChamberGainFactor" ,"GainFactor (detector value)", 1);
251 StoreObject("TRD/Calib/ChamberGainFactor" ,obj,metaData);
7754cd1f 252
d4c6453d 253 //
d4c6453d 254 // Status objects
255 //
7754cd1f 256
9b5afbe3 257 metaData = CreateMetaObject("AliTRDCalChamberStatus");
258 obj = CreateChamberStatusObject();
259 StoreObject("TRD/Calib/ChamberStatus" ,obj,metaData);
7754cd1f 260
9b5afbe3 261 metaData = CreateMetaObject("AliTRDCalPadStatus");
262 obj = CreatePadStatusObject();
263 StoreObject("TRD/Calib/PadStatus" ,obj,metaData);
7754cd1f 264
d4c6453d 265 //
266 // Monitoring object
267 //
7754cd1f 268
9b5afbe3 269 metaData = CreateMetaObject("AliTRDCalMonitoring");
270 obj = CreateMonitoringObject();
271 StoreObject("TRD/Calib/MonitoringData" ,obj,metaData);
d4c6453d 272
7754cd1f 273}