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