doxy: all TPC/Cal converted
[u/mrichter/AliRoot.git] / TPC / Cal / AliTPCCreateDummyCDB.C
CommitLineData
f29f1f3d 1/// \file AliTPCCreateDummyCDB.C
2
e5d28b08 3#if !defined( __CINT__) || defined(__MAKECINT__)
4
5#include <iostream>
6#include <TRandom.h>
7#include <TClonesArray.h>
8#include <TFile.h>
9
e5d28b08 10#include <AliAlignObj.h>
90dbf5fb 11#include <AliAlignObjParams.h>
e5d28b08 12#include <AliCDBManager.h>
13#include <AliCDBStorage.h>
14#include <AliCDBEntry.h>
15#include <AliCDBMetaData.h>
16
e5d28b08 17#include "AliTPCROC.h"
18#include "AliTPCCalROC.h"
19#include "AliTPCCalPad.h"
20#include "AliTPCCalDet.h"
ed6e5cc2 21#include "AliTPCParamSR.h"
e5d28b08 22
e5d28b08 23#endif
24
e5d28b08 25// run number for the dummy file
ed6e5cc2 26Int_t gkDummyRun = 0;
162637e4 27char *gCDBpath = "local://$ALICE_ROOT/OCDB";
e5d28b08 28AliCDBStorage* gStorLoc = 0;
29
ed6e5cc2 30//
7b295b66 31//Float_t gTSample = 2.0000000e-07;
ed6e5cc2 32//
33//
34Float_t gMeanGain = 1;
35Float_t gSigmaGain = 0;
36//
37Float_t gMeanTime0 = 0;
38Float_t gSigmaTime0 = 0;
39//
40Float_t gMeanNoise = 1;
41Float_t gSigmaNoise = 0;
42//
ed6e5cc2 43//
44Float_t gMeanPedestal = 0;
45Float_t gSigmaPedestal = 0;
46//
47// Missalignment
48//
49Float_t gSigmaDx = 0;
50Float_t gSigmaDy = 0;
51Float_t gSigmaDz = 0;
52Float_t gSigmaAngle = 0;
53
54
e5d28b08 55
56
57TObject* CreatePadObject(const char* shortName, const char* description, Float_t value, Float_t sigma=0)
58{
59 AliTPCCalPad *calPad = new AliTPCCalPad(shortName, description);
60 for (UInt_t det=0; det<AliTPCROC::Instance()->GetNSectors(); det++){
61 AliTPCCalROC *calROC = calPad->GetCalROC(det);
62 for (UInt_t channel=0; channel<calROC->GetNchannels(); channel++){
63 Float_t rvalue = gRandom->Gaus(value,sigma);
64 calROC->SetValue(channel, rvalue);
65 }
66 }
67 return calPad;
68}
69
70
71void StoreObject(const char* cdbPath, TObject* object, AliCDBMetaData* metaData)
72{
7b295b66 73 AliCDBId id1(cdbPath, gkDummyRun, AliCDBRunRange::Infinity());
e5d28b08 74 gStorLoc->Put(object, id1, metaData);
75}
76
77
78AliCDBMetaData* CreateMetaObject(const char* objectClassName)
79{
80 AliCDBMetaData *md1= new AliCDBMetaData();
81 md1->SetObjectClassName(objectClassName);
82 md1->SetResponsible("Marian Ivanov");
83 md1->SetBeamPeriod(1);
84 md1->SetAliRootVersion("05-06-00"); //root version
85 md1->SetComment("The dummy values in this calibration file are for testing only");
86
87 return md1;
88}
89
90
ed6e5cc2 91void CDBAlignmentObjectCreation(const char *fileName, const char *arrayName, const char *detName){
e5d28b08 92 // make instance of storage
93 AliCDBManager *CDB = AliCDBManager::Instance();
ed6e5cc2 94 AliCDBStorage* storLoc = CDB->GetStorage(gCDBpath);
e5d28b08 95
96 // create or get from a file the TClonesArray of alignment objects
97 // for given detector, DET should be TPC, TRD ...
98 TFile* f = TFile::Open(fileName,"READ");
99 TClonesArray* tc = ((TClonesArray*) f->Get(arrayName));
100
101 // AliCDBStorage::Put will make a file containing that TClonesArray in
102 // the CDB directory structure
103 AliCDBMetaData *md= new AliCDBMetaData();
104 md->SetObjectClassName("TClonesArray");
105 md->SetResponsible("Your name here");
106 md->SetComment("Alignment objects storage example. Please give more details here.");
107 AliCDBId id(Form("%s/Align/Data",detName),0,0); //you have to specify the run validity,
108// although in the case of saving ideal objects makes not much sense
109 storLoc->Put(tc,id,md);
110
111 // In this way it's good enough because AliSimulation is then expecting
112 // as default to find the files in $ALICE_ROOT/DET/Align/Data
113 // Then just
114 // AliSimulation sim
115 // sim.Run()
116 // Look at the AliInfo messages from AliSimulation::Run() to check that
117 // the expected CDB objects have been retrieved.
118}
119
120
121
122
ce3aadc1 123void GenerateRndTPC(Float_t sigmatrx=0., Float_t sigmatry=0, Float_t sigmatrz=0, Float_t sigmarot = 0.){
e5d28b08 124
90dbf5fb 125 TClonesArray *array = new TClonesArray("AliAlignObjParams",10000);
e5d28b08 126 TClonesArray &alobj = *array;
127
128 TFile f("TPC_alignment.root","RECREATE");
129
130 TRandom *rnd = new TRandom(4357);
90dbf5fb 131 AliAlignObjParams o;
e5d28b08 132 Int_t j = 0;
ae079791 133 for (Int_t iLayer = AliGeomManager::kTPC1; iLayer <= AliGeomManager::kTPC2; iLayer++) {
134 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer); iModule++) {
e5d28b08 135
ce3aadc1 136 Float_t dx = (rnd->Uniform()-0.5)*sigmatrx;
137 Float_t dy = (rnd->Uniform()-0.5)*sigmatry;
138 Float_t dz = (rnd->Uniform()-0.5)*sigmatrz;
e5d28b08 139 Float_t dpsi = (rnd->Uniform()-0.5)*sigmarot;
140 Float_t dtheta = (rnd->Uniform()-0.5)*sigmarot;
141 Float_t dphi = (rnd->Uniform()-0.5)*sigmarot;
142
ae079791 143 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
144 const char *path = AliGeomManager::GetVolPath(volid);
90dbf5fb 145 new(alobj[j]) AliAlignObjParams(path, volid, dx, dy, dz, dpsi, dtheta, dphi);
e5d28b08 146 j++;
147 }
148 }
149 f.cd();
150 f.WriteObject(array,"TPCAlignObjs","kSingleKey");
151 f.Close();
152 array->Delete();
153 CDBAlignmentObjectCreation("TPC_alignment.root","TPCAlignObjs","TPC");
154}
155
156
157
158void AliTPCCreateDummyCDB()
159{
160 cout << endl << "TPC :: Creating dummy CDB with event number " << gkDummyRun << endl;
161
162
163 AliCDBManager *man = AliCDBManager::Instance();
ed6e5cc2 164 gStorLoc = man->GetStorage(gCDBpath);
e5d28b08 165 if (!gStorLoc)
166 return;
167
168 TObject* obj = 0;
169 AliCDBMetaData* metaData = 0;
170
171 //
ce3aadc1 172 // Gain factor (relative) - normalized to 1 - spread 0
e5d28b08 173 //
174 metaData = CreateMetaObject("AliTPCCalPad");
ed6e5cc2 175 obj = CreatePadObject("PadGainFactor","TPC Gain Factor (local -pad- variations)", gMeanGain , gSigmaGain);
e5d28b08 176 StoreObject("TPC/Calib/PadGainFactor", obj, metaData);
177 //
ce3aadc1 178 // Time0 fluctuation - normalized to 0 - spread 0.00 mus
e5d28b08 179 //
180 metaData = CreateMetaObject("AliTPCCalPad");
ed6e5cc2 181 obj = CreatePadObject("PadTime0","TPC Time 0 (local -pad- variations)", gMeanTime0 , gSigmaTime0);
e5d28b08 182 StoreObject("TPC/Calib/PadTime0", obj, metaData);
183 //
ce3aadc1 184 // Noise fluctuation - normalized to 1.0 - spread - 0.0
e5d28b08 185 //
186 metaData = CreateMetaObject("AliTPCCalPad");
ed6e5cc2 187 obj = CreatePadObject("PadNoise","TPC Noise (local -pad- variations)", gMeanNoise , gSigmaNoise);
e5d28b08 188 StoreObject("TPC/Calib/PadNoise", obj, metaData);
189 //
ce3aadc1 190 // Pedestals
191 //
192 metaData = CreateMetaObject("AliTPCCalPad");
ed6e5cc2 193 obj = CreatePadObject("PadPedestal","TPC pedestals (local -pad- variations)", gMeanPedestal, gSigmaPedestal);
ce3aadc1 194 StoreObject("TPC/Calib/Pedestals", obj, metaData);
195 //
196 // Parameters
197 //
198 metaData = CreateMetaObject("AliTPCParam");
199 AliTPCParam * param = new AliTPCParamSR;
7b295b66 200 // param->SetTSample(gTSample);
ed6e5cc2 201 param->Update();
ce3aadc1 202 StoreObject("TPC/Calib/Parameters", param, metaData);
203 //
204 //
7b295b66 205 // generate random missalignemnt - TO BE MODIFIED ACCCRDING NEW ALIROOT
e5d28b08 206 //
7b295b66 207 // GenerateRndTPC(gSigmaDx,gSigmaDy,gSigmaDz,gSigmaAngle);
55f67952 208 //
209 // ExB
210 //
211 //
212 // Put there your mag field
213 // to simulate distortion the scaling factor in magf can be used
214 // currently scaling factor 0 used - no magnetic field
215 //
216 metaData = CreateMetaObject("AliTPCExB");
4642ac4b 217 AliMagF* field = new AliMagF("Maps","Maps", 0., 0., AliMagF::k5kG));
55f67952 218 AliTPCExBFirst *exbfirst = new AliTPCExBFirst(field,2.83000000000000000e+04,50,50,50);
219 StoreObject("TPC/Calib/ExB", exbfirst, metaData);
220
e5d28b08 221}