]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFAlignment.cxx
Double precision (Marian). Coding conventions (Federico)
[u/mrichter/AliRoot.git] / TOF / AliTOFAlignment.cxx
CommitLineData
b33ed6c7 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14$Log$
7aeeaf38 15Revision 1.4 2006/04/05 08:35:38 hristov
16Coding conventions (S.Arcelli, C.Zampolli)
17
340693af 18Revision 1.3 2006/03/31 13:49:07 arcelli
19Removing some junk printout
20
0120b1d1 21Revision 1.2 2006/03/31 11:26:30 arcelli
22 changing CDB Ids according to standard convention
23
28dd10b6 24Revision 1.1 2006/03/28 14:54:48 arcelli
25class for TOF alignment
26
b33ed6c7 27author: Silvia Arcelli, arcelli@bo.infn.it
28*/
29
30#include <TBenchmark.h>
31#include <Rtypes.h>
32#include "TClonesArray.h"
33#include "TObjString.h"
34#include "AliLog.h"
35#include "AliRun.h"
36#include "AliModule.h"
37#include "AliTOFAlignment.h"
38#include "AliAlignObj.h"
39#include "AliAlignObjAngles.h"
40#include "AliCDBManager.h"
41#include "AliCDBMetaData.h"
42#include "AliCDBStorage.h"
43#include "AliCDBId.h"
44#include "AliCDBEntry.h"
45
46ClassImp(AliTOFAlignment)
47
48//_____________________________________________________________________________
49AliTOFAlignment::AliTOFAlignment():TTask("AliTOFAlignment","") {
50 //AliTOFalignment main Ctor
51
52 fNTOFAlignObj=0;
53 fTOFAlignObjArray=0x0;
54}
55//_____________________________________________________________________________
56AliTOFAlignment::AliTOFAlignment(const AliTOFAlignment &t):TTask("AliTOFAlignment",""){
57 //AliTOFAlignment copy Ctor
58
59 fNTOFAlignObj=t.fNTOFAlignObj;
60 fTOFAlignObjArray=t.fTOFAlignObjArray;
61
62}
63
64//_____________________________________________________________________________
7aeeaf38 65AliTOFAlignment& AliTOFAlignment::operator=(const AliTOFAlignment &t){
66 //AliTOFAlignment assignment operator
67
68 this->fNTOFAlignObj=t.fNTOFAlignObj;
69 this->fTOFAlignObjArray=t.fTOFAlignObjArray;
70 return *this;
71
72}
73
74//_____________________________________________________________________________
340693af 75void AliTOFAlignment::Smear( Float_t *tr, Float_t *rot)
76{
77 //Introduce Random Offset/Tilts
b33ed6c7 78 fTOFAlignObjArray = new TObjArray(kMaxAlignObj);
79 Float_t dx, dy, dz; // shifts
80 Float_t dpsi, dtheta, dphi; // angular displacements
81 TRandom *rnd = new TRandom(1567);
82
83 TString path;
340693af 84 const char *sSM71="/ALIC_1/B077_1/B071_"; //1-13
b33ed6c7 85 const char *sm71="/BTO1_1";
340693af 86 const char *sSM74="/ALIC_1/B077_1/B074_"; //1-2
b33ed6c7 87 const char *sm74="/BTO2_1";
340693af 88 const char *sSM75="/ALIC_1/B077_1/B075_"; //1-3
b33ed6c7 89 const char *sm75="/BTO3_1";
90
91
92 Int_t nSM71 = 13, nSM74=2, nSM75=3;
28dd10b6 93 AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
94 UShort_t iIndex=0; //dummy volume index
95 // AliAlignObj::ELayerID iLayer = AliAlignObj::kTOF;
96 // Int_t iIndex=1; //dummy volume index
b33ed6c7 97 UShort_t dvoluid = AliAlignObj::LayerToVolUID(iLayer,iIndex); //dummy volume identity
98 Int_t i;
99 for (i = 1; i<=nSM71 ; i++) {
100
101 dx = (rnd->Gaus(0.,1.))*tr[0]/nSM71;
102 dy = (rnd->Gaus(0.,1.))*tr[1]/nSM71;
103 dz = (rnd->Gaus(0.,1.))*tr[2]/nSM71;
104 dpsi = rot[0]/nSM71;
105 dtheta = rot[1]/nSM71;
106 dphi = rot[2]/nSM71;
107
340693af 108 path = sSM71;
b33ed6c7 109 path += i;
110 path += sm71;
111 AliAlignObjAngles *o =new AliAlignObjAngles(path, dvoluid, dx, dy, dz, dpsi, dtheta, dphi);
112 fTOFAlignObjArray->Add(o);
113 }
114
115 for (i = 1; i<=nSM74 ; i++) {
116
117 dx = (rnd->Gaus(0.,1.))*tr[0]/nSM74;
118 dy = (rnd->Gaus(0.,1.))*tr[1]/nSM74;
119 dz = (rnd->Gaus(0.,1.))*tr[2]/nSM74;
120 dpsi = rot[0]/nSM74;
121 dtheta = rot[1]/nSM74;
122 dphi = rot[2]/nSM74;
123
340693af 124 path = sSM74;
b33ed6c7 125 path += i;
126 path += sm74;
127 AliAlignObjAngles *o =new AliAlignObjAngles(path, dvoluid, dx, dy, dz, dpsi, dtheta, dphi);
128 fTOFAlignObjArray->Add(o);
129 }
130
131 for (i = 1; i<=nSM75; i++) {
132
133 dx = (rnd->Gaus(0.,1.))*tr[0]/nSM75;
134 dy = (rnd->Gaus(0.,1.))*tr[1]/nSM75;
135 dz = (rnd->Gaus(0.,1.))*tr[2]/nSM75;
136 dpsi = rot[0]/nSM75;
137 dtheta = rot[1]/nSM75;
138 dphi = rot[2]/nSM75;
139
340693af 140 path = sSM75;
b33ed6c7 141 path += i;
142 path += sm75;
143 AliAlignObjAngles *o =new AliAlignObjAngles(path, dvoluid, dx, dy, dz, dpsi, dtheta, dphi);
144 fTOFAlignObjArray->Add(o);
145 }
146 fNTOFAlignObj=fTOFAlignObjArray->GetEntries();
147 AliInfo(Form("Number of Alignable Volumes: %d",fNTOFAlignObj));
148 delete rnd;
149}
150
151//_____________________________________________________________________________
340693af 152void AliTOFAlignment::Align( Float_t *tr, Float_t *rot)
153{
154 //Introduce Offset/Tilts
b33ed6c7 155
156 fTOFAlignObjArray = new TObjArray(kMaxAlignObj);
157 Float_t dx, dy, dz; // shifts
158 Float_t dpsi, dtheta, dphi; // angular displacements
159 TString path;
340693af 160 const char *sSM71="/ALIC_1/B077_1/B071_"; //1-13
b33ed6c7 161 const char *sm71="/BTO1_1";
340693af 162 const char *sSM74="/ALIC_1/B077_1/B074_"; //1-2
b33ed6c7 163 const char *sm74="/BTO2_1";
340693af 164 const char *sSM75="/ALIC_1/B077_1/B075_"; //1-3
b33ed6c7 165 const char *sm75="/BTO3_1";
166
167
168 Int_t nSM71 = 13, nSM74=2, nSM75=3;
28dd10b6 169 AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
170 UShort_t iIndex=0; //dummy volume index
171 // AliAlignObj::ELayerID iLayer = AliAlignObj::kTOF;
172 // Int_t iIndex=1; //dummy volume index
b33ed6c7 173 UShort_t dvoluid = AliAlignObj::LayerToVolUID(iLayer,iIndex); //dummy volume identity
174 Int_t i;
175 for (i = 1; i<=nSM71 ; i++) {
176
177 dx = tr[0]/nSM71;
178 dy = tr[1]/nSM71;
179 dz = tr[2]/nSM71;
180 dpsi = rot[0]/nSM71;
181 dtheta = rot[1]/nSM71;
182 dphi = rot[2]/nSM71;
183
340693af 184 path = sSM71;
b33ed6c7 185 path += i;
186 path += sm71;
187 AliAlignObjAngles *o =new AliAlignObjAngles(path, dvoluid, dx, dy, dz, dpsi, dtheta, dphi);
188 fTOFAlignObjArray->Add(o);
189 }
190
191 for (i = 1; i<=nSM74 ; i++) {
192
193 dx = tr[0]/nSM74;
194 dy = tr[1]/nSM74;
195 dz = tr[2]/nSM74;
196 dpsi = rot[0]/nSM74;
197 dtheta = rot[1]/nSM74;
198 dphi = rot[2]/nSM74;
199
340693af 200 path = sSM74;
b33ed6c7 201 path += i;
202 path += sm74;
203 AliAlignObjAngles *o =new AliAlignObjAngles(path, dvoluid, dx, dy, dz, dpsi, dtheta, dphi);
204 fTOFAlignObjArray->Add(o);
205 }
206
207 for (i = 1; i<=nSM75; i++) {
208
209 dx = tr[0]/nSM75;
210 dy = tr[1]/nSM75;
211 dz = tr[2]/nSM75;
212 dpsi = rot[0]/nSM75;
213 dtheta = rot[1]/nSM75;
214 dphi = rot[2]/nSM75;
215
340693af 216 path = sSM75;
b33ed6c7 217 path += i;
218 path += sm75;
219 AliAlignObjAngles *o =new AliAlignObjAngles(path, dvoluid, dx, dy, dz, dpsi, dtheta, dphi);
220 fTOFAlignObjArray->Add(o);
221 }
222 fNTOFAlignObj=fTOFAlignObjArray->GetEntries();
223 AliInfo(Form("Number of Alignable Volumes: %d",fNTOFAlignObj));
224}
225//_____________________________________________________________________________
340693af 226void AliTOFAlignment::WriteParOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun)
227{
228 //Write Align Par on CDB
b33ed6c7 229 AliCDBManager *man = AliCDBManager::Instance();
230 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
231 Char_t *sel1 = "AlignPar" ;
232 Char_t out[100];
233 sprintf(out,"%s/%s",sel,sel1);
234 AliCDBId idTOFAlign(out,minrun,maxrun);
235 AliCDBMetaData *mdTOFAlign = new AliCDBMetaData();
236 mdTOFAlign->SetResponsible("TOF");
237 AliInfo(Form("Number of Alignable Volumes: %d",fNTOFAlignObj));
238 man->Put(fTOFAlignObjArray,idTOFAlign,mdTOFAlign);
239}
240//_____________________________________________________________________________
340693af 241void AliTOFAlignment::ReadParFromCDB(Char_t *sel, Int_t nrun)
242{
243 //Read Align Par from CDB
b33ed6c7 244 AliCDBManager *man = AliCDBManager::Instance();
245 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
246 Char_t *sel1 = "AlignPar" ;
247 Char_t out[100];
248 sprintf(out,"%s/%s",sel,sel1);
249 AliCDBEntry *entry = man->Get(out,nrun);
250 fTOFAlignObjArray=(TObjArray*)entry->GetObject();
251 fNTOFAlignObj=fTOFAlignObjArray->GetEntries();
252 AliInfo(Form("Number of Alignable Volumes from CDB: %d",fNTOFAlignObj));
253
254}
255//_____________________________________________________________________________
340693af 256void AliTOFAlignment::WriteSimParOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun)
257{
258 //Write Sim Align Par on CDB
b33ed6c7 259 AliCDBManager *man = AliCDBManager::Instance();
260 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
261 Char_t *sel1 = "AlignSimPar" ;
262 Char_t out[100];
263 sprintf(out,"%s/%s",sel,sel1);
264 AliCDBId idTOFAlign(out,minrun,maxrun);
265 AliCDBMetaData *mdTOFAlign = new AliCDBMetaData();
266 mdTOFAlign->SetResponsible("TOF");
267 AliInfo(Form("Number of Alignable Volumes: %d",fNTOFAlignObj));
268 man->Put(fTOFAlignObjArray,idTOFAlign,mdTOFAlign);
269}
270//_____________________________________________________________________________
271void AliTOFAlignment::ReadSimParFromCDB(Char_t *sel, Int_t nrun){
340693af 272 //Read Sim Align Par from CDB
b33ed6c7 273 AliCDBManager *man = AliCDBManager::Instance();
274 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
275 Char_t *sel1 = "AlignSimPar" ;
276 Char_t out[100];
277 sprintf(out,"%s/%s",sel,sel1);
278 AliCDBEntry *entry = man->Get(out,nrun);
279 fTOFAlignObjArray=(TObjArray*)entry->GetObject();
280 fNTOFAlignObj=fTOFAlignObjArray->GetEntries();
281 AliInfo(Form("Number of Alignable Volumes from CDB: %d",fNTOFAlignObj));
282
283}
28dd10b6 284//_____________________________________________________________________________
340693af 285void AliTOFAlignment::WriteOnCDBforDC()
286{
287 //Write Align Par on CDB for DC06
28dd10b6 288 AliCDBManager *man = AliCDBManager::Instance();
289 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
290 AliCDBId idTOFAlign("TOF/Align/Data",0,0);
291 AliCDBMetaData *mdTOFAlign = new AliCDBMetaData();
292 mdTOFAlign->SetComment("Alignment objects for ideal geometry, i.e. applying them to TGeo has to leave geometry unchanged");
293 mdTOFAlign->SetResponsible("TOF");
294 AliInfo(Form("Number of Alignable Volumes: %d",fNTOFAlignObj));
295 man->Put(fTOFAlignObjArray,idTOFAlign,mdTOFAlign);
296}
297//_____________________________________________________________________________
340693af 298void AliTOFAlignment::ReadFromCDBforDC()
299{
300 //Read Sim Align Par from CDB for DC06
28dd10b6 301 AliCDBManager *man = AliCDBManager::Instance();
302 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
303 AliCDBEntry *entry = man->Get("TOF/Align/Data",0);
304 fTOFAlignObjArray=(TObjArray*)entry->GetObject();
305 fNTOFAlignObj=fTOFAlignObjArray->GetEntries();
306 AliInfo(Form("Number of Alignable Volumes from CDB: %d",fNTOFAlignObj));
307
308}