START AlignObj added
[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$
28dd10b6 15Revision 1.1 2006/03/28 14:54:48 arcelli
16class for TOF alignment
17
b33ed6c7 18author: Silvia Arcelli, arcelli@bo.infn.it
19*/
20
21#include <TBenchmark.h>
22#include <Rtypes.h>
23#include "TClonesArray.h"
24#include "TObjString.h"
25#include "AliLog.h"
26#include "AliRun.h"
27#include "AliModule.h"
28#include "AliTOFAlignment.h"
29#include "AliAlignObj.h"
30#include "AliAlignObjAngles.h"
31#include "AliCDBManager.h"
32#include "AliCDBMetaData.h"
33#include "AliCDBStorage.h"
34#include "AliCDBId.h"
35#include "AliCDBEntry.h"
36
37ClassImp(AliTOFAlignment)
38
39//_____________________________________________________________________________
40AliTOFAlignment::AliTOFAlignment():TTask("AliTOFAlignment","") {
41 //AliTOFalignment main Ctor
42
43 fNTOFAlignObj=0;
44 fTOFAlignObjArray=0x0;
45}
46//_____________________________________________________________________________
47AliTOFAlignment::AliTOFAlignment(const AliTOFAlignment &t):TTask("AliTOFAlignment",""){
48 //AliTOFAlignment copy Ctor
49
50 fNTOFAlignObj=t.fNTOFAlignObj;
51 fTOFAlignObjArray=t.fTOFAlignObjArray;
52
53}
54
55//_____________________________________________________________________________
56void AliTOFAlignment::Smear( Float_t *tr, Float_t *rot){
57
58 fTOFAlignObjArray = new TObjArray(kMaxAlignObj);
59 Float_t dx, dy, dz; // shifts
60 Float_t dpsi, dtheta, dphi; // angular displacements
61 TRandom *rnd = new TRandom(1567);
62
63 TString path;
64 const char *SM71="/ALIC_1/B077_1/B071_"; //1-13
65 const char *sm71="/BTO1_1";
66 const char *SM74="/ALIC_1/B077_1/B074_"; //1-2
67 const char *sm74="/BTO2_1";
68 const char *SM75="/ALIC_1/B077_1/B075_"; //1-3
69 const char *sm75="/BTO3_1";
70
71
72 Int_t nSM71 = 13, nSM74=2, nSM75=3;
28dd10b6 73 AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
74 UShort_t iIndex=0; //dummy volume index
75 // AliAlignObj::ELayerID iLayer = AliAlignObj::kTOF;
76 // Int_t iIndex=1; //dummy volume index
b33ed6c7 77 UShort_t dvoluid = AliAlignObj::LayerToVolUID(iLayer,iIndex); //dummy volume identity
78 Int_t i;
79 for (i = 1; i<=nSM71 ; i++) {
80
81 dx = (rnd->Gaus(0.,1.))*tr[0]/nSM71;
82 dy = (rnd->Gaus(0.,1.))*tr[1]/nSM71;
83 dz = (rnd->Gaus(0.,1.))*tr[2]/nSM71;
84 dpsi = rot[0]/nSM71;
85 dtheta = rot[1]/nSM71;
86 dphi = rot[2]/nSM71;
87
88 path = SM71;
89 path += i;
90 path += sm71;
91 AliAlignObjAngles *o =new AliAlignObjAngles(path, dvoluid, dx, dy, dz, dpsi, dtheta, dphi);
92 fTOFAlignObjArray->Add(o);
93 }
94
95 for (i = 1; i<=nSM74 ; i++) {
96
97 dx = (rnd->Gaus(0.,1.))*tr[0]/nSM74;
98 dy = (rnd->Gaus(0.,1.))*tr[1]/nSM74;
99 dz = (rnd->Gaus(0.,1.))*tr[2]/nSM74;
100 dpsi = rot[0]/nSM74;
101 dtheta = rot[1]/nSM74;
102 dphi = rot[2]/nSM74;
103
104 path = SM74;
105 path += i;
106 path += sm74;
107 AliAlignObjAngles *o =new AliAlignObjAngles(path, dvoluid, dx, dy, dz, dpsi, dtheta, dphi);
108 fTOFAlignObjArray->Add(o);
109 }
110
111 for (i = 1; i<=nSM75; i++) {
112
113 dx = (rnd->Gaus(0.,1.))*tr[0]/nSM75;
114 dy = (rnd->Gaus(0.,1.))*tr[1]/nSM75;
115 dz = (rnd->Gaus(0.,1.))*tr[2]/nSM75;
116 dpsi = rot[0]/nSM75;
117 dtheta = rot[1]/nSM75;
118 dphi = rot[2]/nSM75;
119
120 path = SM75;
121 path += i;
122 path += sm75;
123 AliAlignObjAngles *o =new AliAlignObjAngles(path, dvoluid, dx, dy, dz, dpsi, dtheta, dphi);
124 fTOFAlignObjArray->Add(o);
125 }
126 fNTOFAlignObj=fTOFAlignObjArray->GetEntries();
127 AliInfo(Form("Number of Alignable Volumes: %d",fNTOFAlignObj));
128 delete rnd;
129}
130
131//_____________________________________________________________________________
132void AliTOFAlignment::Align( Float_t *tr, Float_t *rot){
133
134 fTOFAlignObjArray = new TObjArray(kMaxAlignObj);
135 Float_t dx, dy, dz; // shifts
136 Float_t dpsi, dtheta, dphi; // angular displacements
137 TString path;
138 const char *SM71="/ALIC_1/B077_1/B071_"; //1-13
139 const char *sm71="/BTO1_1";
140 const char *SM74="/ALIC_1/B077_1/B074_"; //1-2
141 const char *sm74="/BTO2_1";
142 const char *SM75="/ALIC_1/B077_1/B075_"; //1-3
143 const char *sm75="/BTO3_1";
144
145
146 Int_t nSM71 = 13, nSM74=2, nSM75=3;
28dd10b6 147 AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
148 UShort_t iIndex=0; //dummy volume index
149 // AliAlignObj::ELayerID iLayer = AliAlignObj::kTOF;
150 // Int_t iIndex=1; //dummy volume index
b33ed6c7 151 UShort_t dvoluid = AliAlignObj::LayerToVolUID(iLayer,iIndex); //dummy volume identity
152 Int_t i;
153 for (i = 1; i<=nSM71 ; i++) {
154
155 dx = tr[0]/nSM71;
156 dy = tr[1]/nSM71;
157 dz = tr[2]/nSM71;
158 dpsi = rot[0]/nSM71;
159 dtheta = rot[1]/nSM71;
160 dphi = rot[2]/nSM71;
161
162 path = SM71;
163 path += i;
164 path += sm71;
165 AliAlignObjAngles *o =new AliAlignObjAngles(path, dvoluid, dx, dy, dz, dpsi, dtheta, dphi);
166 fTOFAlignObjArray->Add(o);
167 }
168
169 for (i = 1; i<=nSM74 ; i++) {
170
171 dx = tr[0]/nSM74;
172 dy = tr[1]/nSM74;
173 dz = tr[2]/nSM74;
174 dpsi = rot[0]/nSM74;
175 dtheta = rot[1]/nSM74;
176 dphi = rot[2]/nSM74;
177
178 path = SM74;
179 path += i;
180 path += sm74;
181 AliAlignObjAngles *o =new AliAlignObjAngles(path, dvoluid, dx, dy, dz, dpsi, dtheta, dphi);
182 fTOFAlignObjArray->Add(o);
183 }
184
185 for (i = 1; i<=nSM75; i++) {
186
187 dx = tr[0]/nSM75;
188 dy = tr[1]/nSM75;
189 dz = tr[2]/nSM75;
190 dpsi = rot[0]/nSM75;
191 dtheta = rot[1]/nSM75;
192 dphi = rot[2]/nSM75;
193
194 path = SM75;
195 path += i;
196 path += sm75;
197 AliAlignObjAngles *o =new AliAlignObjAngles(path, dvoluid, dx, dy, dz, dpsi, dtheta, dphi);
198 fTOFAlignObjArray->Add(o);
199 }
200 fNTOFAlignObj=fTOFAlignObjArray->GetEntries();
201 AliInfo(Form("Number of Alignable Volumes: %d",fNTOFAlignObj));
28dd10b6 202 AliInfo("Sono nel cesso");
b33ed6c7 203}
204//_____________________________________________________________________________
205void AliTOFAlignment::WriteParOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun){
206 AliCDBManager *man = AliCDBManager::Instance();
207 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
208 Char_t *sel1 = "AlignPar" ;
209 Char_t out[100];
210 sprintf(out,"%s/%s",sel,sel1);
211 AliCDBId idTOFAlign(out,minrun,maxrun);
212 AliCDBMetaData *mdTOFAlign = new AliCDBMetaData();
213 mdTOFAlign->SetResponsible("TOF");
214 AliInfo(Form("Number of Alignable Volumes: %d",fNTOFAlignObj));
215 man->Put(fTOFAlignObjArray,idTOFAlign,mdTOFAlign);
216}
217//_____________________________________________________________________________
218void AliTOFAlignment::ReadParFromCDB(Char_t *sel, Int_t nrun){
219 AliCDBManager *man = AliCDBManager::Instance();
220 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
221 Char_t *sel1 = "AlignPar" ;
222 Char_t out[100];
223 sprintf(out,"%s/%s",sel,sel1);
224 AliCDBEntry *entry = man->Get(out,nrun);
225 fTOFAlignObjArray=(TObjArray*)entry->GetObject();
226 fNTOFAlignObj=fTOFAlignObjArray->GetEntries();
227 AliInfo(Form("Number of Alignable Volumes from CDB: %d",fNTOFAlignObj));
228
229}
230//_____________________________________________________________________________
231void AliTOFAlignment::WriteSimParOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun){
232 AliCDBManager *man = AliCDBManager::Instance();
233 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
234 Char_t *sel1 = "AlignSimPar" ;
235 Char_t out[100];
236 sprintf(out,"%s/%s",sel,sel1);
237 AliCDBId idTOFAlign(out,minrun,maxrun);
238 AliCDBMetaData *mdTOFAlign = new AliCDBMetaData();
239 mdTOFAlign->SetResponsible("TOF");
240 AliInfo(Form("Number of Alignable Volumes: %d",fNTOFAlignObj));
241 man->Put(fTOFAlignObjArray,idTOFAlign,mdTOFAlign);
242}
243//_____________________________________________________________________________
244void AliTOFAlignment::ReadSimParFromCDB(Char_t *sel, Int_t nrun){
245 AliCDBManager *man = AliCDBManager::Instance();
246 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
247 Char_t *sel1 = "AlignSimPar" ;
248 Char_t out[100];
249 sprintf(out,"%s/%s",sel,sel1);
250 AliCDBEntry *entry = man->Get(out,nrun);
251 fTOFAlignObjArray=(TObjArray*)entry->GetObject();
252 fNTOFAlignObj=fTOFAlignObjArray->GetEntries();
253 AliInfo(Form("Number of Alignable Volumes from CDB: %d",fNTOFAlignObj));
254
255}
28dd10b6 256//_____________________________________________________________________________
257void AliTOFAlignment::WriteOnCDBforDC(){
258 AliCDBManager *man = AliCDBManager::Instance();
259 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
260 AliCDBId idTOFAlign("TOF/Align/Data",0,0);
261 AliCDBMetaData *mdTOFAlign = new AliCDBMetaData();
262 mdTOFAlign->SetComment("Alignment objects for ideal geometry, i.e. applying them to TGeo has to leave geometry unchanged");
263 mdTOFAlign->SetResponsible("TOF");
264 AliInfo(Form("Number of Alignable Volumes: %d",fNTOFAlignObj));
265 man->Put(fTOFAlignObjArray,idTOFAlign,mdTOFAlign);
266}
267//_____________________________________________________________________________
268void AliTOFAlignment::ReadFromCDBforDC(){
269 AliCDBManager *man = AliCDBManager::Instance();
270 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
271 AliCDBEntry *entry = man->Get("TOF/Align/Data",0);
272 fTOFAlignObjArray=(TObjArray*)entry->GetObject();
273 fNTOFAlignObj=fTOFAlignObjArray->GetEntries();
274 AliInfo(Form("Number of Alignable Volumes from CDB: %d",fNTOFAlignObj));
275
276}