Bugfixes and clean-up of alignment object classes. Introduction of so called symbolic...
[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. *
0e46b9ae 14***************************************************************************/
15
16/*
b33ed6c7 17$Log$
b760c02e 18Revision 1.10 2006/08/22 13:26:05 arcelli
19removal of effective c++ warnings (C.Zampolli)
20
655e379f 21Revision 1.9 2006/08/10 14:46:54 decaro
22TOF raw data format: updated version
23
d0eb8f39 24Revision 1.8 2006/05/04 19:41:42 hristov
25Possibility for partial TOF geometry (S.Arcelli)
26
06e24a91 27Revision 1.7 2006/04/27 13:13:29 hristov
28Moving the destructor to the implementation file
29
e78d8265 30Revision 1.6 2006/04/20 22:30:49 hristov
31Coding conventions (Annalisa)
32
0e46b9ae 33Revision 1.5 2006/04/16 22:29:05 hristov
34Coding conventions (Annalisa)
35
7aeeaf38 36Revision 1.4 2006/04/05 08:35:38 hristov
37Coding conventions (S.Arcelli, C.Zampolli)
38
340693af 39Revision 1.3 2006/03/31 13:49:07 arcelli
40Removing some junk printout
41
0120b1d1 42Revision 1.2 2006/03/31 11:26:30 arcelli
43 changing CDB Ids according to standard convention
44
28dd10b6 45Revision 1.1 2006/03/28 14:54:48 arcelli
46class for TOF alignment
47
b33ed6c7 48author: Silvia Arcelli, arcelli@bo.infn.it
49*/
50
0e46b9ae 51/////////////////////////////////////////////////////////
52// //
53// Class for alignment procedure //
54// //
55// //
56// //
57/////////////////////////////////////////////////////////
58
b33ed6c7 59#include <Rtypes.h>
0e46b9ae 60
61#include "TRandom.h"
0e46b9ae 62
b33ed6c7 63#include "AliLog.h"
b33ed6c7 64#include "AliAlignObj.h"
65#include "AliAlignObjAngles.h"
66#include "AliCDBManager.h"
67#include "AliCDBMetaData.h"
b33ed6c7 68#include "AliCDBId.h"
69#include "AliCDBEntry.h"
0e46b9ae 70#include "AliTOFAlignment.h"
b33ed6c7 71
72ClassImp(AliTOFAlignment)
73
74//_____________________________________________________________________________
655e379f 75AliTOFAlignment::AliTOFAlignment():
76 TTask("AliTOFAlignment",""),
77 fNTOFAlignObj(0),
78 fTOFAlignObjArray(0x0)
79 {
b33ed6c7 80 //AliTOFalignment main Ctor
81
b33ed6c7 82}
83//_____________________________________________________________________________
655e379f 84AliTOFAlignment::AliTOFAlignment(const AliTOFAlignment &t):
85 TTask("AliTOFAlignment",""),
86 fNTOFAlignObj(0),
87 fTOFAlignObjArray(0x0)
88{
b33ed6c7 89 //AliTOFAlignment copy Ctor
90
91 fNTOFAlignObj=t.fNTOFAlignObj;
92 fTOFAlignObjArray=t.fTOFAlignObjArray;
93
94}
95
96//_____________________________________________________________________________
7aeeaf38 97AliTOFAlignment& AliTOFAlignment::operator=(const AliTOFAlignment &t){
98 //AliTOFAlignment assignment operator
99
100 this->fNTOFAlignObj=t.fNTOFAlignObj;
101 this->fTOFAlignObjArray=t.fTOFAlignObjArray;
102 return *this;
103
104}
105
106//_____________________________________________________________________________
e78d8265 107AliTOFAlignment::~AliTOFAlignment() {delete fTOFAlignObjArray;}
108
109//_____________________________________________________________________________
340693af 110void AliTOFAlignment::Smear( Float_t *tr, Float_t *rot)
111{
112 //Introduce Random Offset/Tilts
b33ed6c7 113 fTOFAlignObjArray = new TObjArray(kMaxAlignObj);
114 Float_t dx, dy, dz; // shifts
115 Float_t dpsi, dtheta, dphi; // angular displacements
116 TRandom *rnd = new TRandom(1567);
06e24a91 117
118 Int_t nSMTOF = 18;
28dd10b6 119 AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
120 UShort_t iIndex=0; //dummy volume index
121 // AliAlignObj::ELayerID iLayer = AliAlignObj::kTOF;
122 // Int_t iIndex=1; //dummy volume index
b33ed6c7 123 UShort_t dvoluid = AliAlignObj::LayerToVolUID(iLayer,iIndex); //dummy volume identity
124 Int_t i;
06e24a91 125 for (i = 0; i<nSMTOF ; i++) {
126 Char_t path[100];
127 sprintf(path,"/ALIC_1/B077_1/BSEGMO%i_1/BTOF%i_1",i,i);
128
129 dx = (rnd->Gaus(0.,1.))*tr[0];
130 dy = (rnd->Gaus(0.,1.))*tr[1];
131 dz = (rnd->Gaus(0.,1.))*tr[2];
132 dpsi = rot[0];
133 dtheta = rot[1];
134 dphi = rot[2];
b760c02e 135 AliAlignObjAngles *o =new AliAlignObjAngles(path, dvoluid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
b33ed6c7 136 fTOFAlignObjArray->Add(o);
137 }
138
b33ed6c7 139 fNTOFAlignObj=fTOFAlignObjArray->GetEntries();
140 AliInfo(Form("Number of Alignable Volumes: %d",fNTOFAlignObj));
141 delete rnd;
142}
143
144//_____________________________________________________________________________
340693af 145void AliTOFAlignment::Align( Float_t *tr, Float_t *rot)
146{
147 //Introduce Offset/Tilts
b33ed6c7 148
149 fTOFAlignObjArray = new TObjArray(kMaxAlignObj);
150 Float_t dx, dy, dz; // shifts
151 Float_t dpsi, dtheta, dphi; // angular displacements
b33ed6c7 152
153
06e24a91 154 Int_t nSMTOF = 18;
28dd10b6 155 AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
156 UShort_t iIndex=0; //dummy volume index
157 // AliAlignObj::ELayerID iLayer = AliAlignObj::kTOF;
158 // Int_t iIndex=1; //dummy volume index
b33ed6c7 159 UShort_t dvoluid = AliAlignObj::LayerToVolUID(iLayer,iIndex); //dummy volume identity
160 Int_t i;
06e24a91 161 for (i = 0; i<nSMTOF ; i++) {
162
163 Char_t path[100];
164 sprintf(path,"/ALIC_1/B077_1/BSEGMO%i_1/BTOF%i_1",i,i);
165 dx = tr[0];
166 dy = tr[1];
167 dz = tr[2];
168 dpsi = rot[0];
169 dtheta = rot[1];
170 dphi = rot[2];
b33ed6c7 171
b760c02e 172 AliAlignObjAngles *o =new AliAlignObjAngles(path, dvoluid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
b33ed6c7 173 fTOFAlignObjArray->Add(o);
174 }
175 fNTOFAlignObj=fTOFAlignObjArray->GetEntries();
176 AliInfo(Form("Number of Alignable Volumes: %d",fNTOFAlignObj));
177}
178//_____________________________________________________________________________
340693af 179void AliTOFAlignment::WriteParOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun)
180{
181 //Write Align Par on CDB
b33ed6c7 182 AliCDBManager *man = AliCDBManager::Instance();
183 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
184 Char_t *sel1 = "AlignPar" ;
185 Char_t out[100];
186 sprintf(out,"%s/%s",sel,sel1);
187 AliCDBId idTOFAlign(out,minrun,maxrun);
188 AliCDBMetaData *mdTOFAlign = new AliCDBMetaData();
189 mdTOFAlign->SetResponsible("TOF");
190 AliInfo(Form("Number of Alignable Volumes: %d",fNTOFAlignObj));
191 man->Put(fTOFAlignObjArray,idTOFAlign,mdTOFAlign);
192}
193//_____________________________________________________________________________
340693af 194void AliTOFAlignment::ReadParFromCDB(Char_t *sel, Int_t nrun)
195{
196 //Read Align Par from CDB
b33ed6c7 197 AliCDBManager *man = AliCDBManager::Instance();
198 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
199 Char_t *sel1 = "AlignPar" ;
200 Char_t out[100];
201 sprintf(out,"%s/%s",sel,sel1);
202 AliCDBEntry *entry = man->Get(out,nrun);
203 fTOFAlignObjArray=(TObjArray*)entry->GetObject();
204 fNTOFAlignObj=fTOFAlignObjArray->GetEntries();
205 AliInfo(Form("Number of Alignable Volumes from CDB: %d",fNTOFAlignObj));
206
207}
208//_____________________________________________________________________________
340693af 209void AliTOFAlignment::WriteSimParOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun)
210{
211 //Write Sim Align Par on CDB
b33ed6c7 212 AliCDBManager *man = AliCDBManager::Instance();
213 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
214 Char_t *sel1 = "AlignSimPar" ;
215 Char_t out[100];
216 sprintf(out,"%s/%s",sel,sel1);
217 AliCDBId idTOFAlign(out,minrun,maxrun);
218 AliCDBMetaData *mdTOFAlign = new AliCDBMetaData();
219 mdTOFAlign->SetResponsible("TOF");
220 AliInfo(Form("Number of Alignable Volumes: %d",fNTOFAlignObj));
221 man->Put(fTOFAlignObjArray,idTOFAlign,mdTOFAlign);
222}
223//_____________________________________________________________________________
224void AliTOFAlignment::ReadSimParFromCDB(Char_t *sel, Int_t nrun){
340693af 225 //Read Sim Align Par from CDB
b33ed6c7 226 AliCDBManager *man = AliCDBManager::Instance();
227 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
228 Char_t *sel1 = "AlignSimPar" ;
229 Char_t out[100];
230 sprintf(out,"%s/%s",sel,sel1);
231 AliCDBEntry *entry = man->Get(out,nrun);
232 fTOFAlignObjArray=(TObjArray*)entry->GetObject();
233 fNTOFAlignObj=fTOFAlignObjArray->GetEntries();
234 AliInfo(Form("Number of Alignable Volumes from CDB: %d",fNTOFAlignObj));
235
236}
28dd10b6 237//_____________________________________________________________________________
340693af 238void AliTOFAlignment::WriteOnCDBforDC()
239{
240 //Write Align Par on CDB for DC06
28dd10b6 241 AliCDBManager *man = AliCDBManager::Instance();
242 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
243 AliCDBId idTOFAlign("TOF/Align/Data",0,0);
244 AliCDBMetaData *mdTOFAlign = new AliCDBMetaData();
245 mdTOFAlign->SetComment("Alignment objects for ideal geometry, i.e. applying them to TGeo has to leave geometry unchanged");
246 mdTOFAlign->SetResponsible("TOF");
247 AliInfo(Form("Number of Alignable Volumes: %d",fNTOFAlignObj));
248 man->Put(fTOFAlignObjArray,idTOFAlign,mdTOFAlign);
249}
250//_____________________________________________________________________________
340693af 251void AliTOFAlignment::ReadFromCDBforDC()
252{
253 //Read Sim Align Par from CDB for DC06
28dd10b6 254 AliCDBManager *man = AliCDBManager::Instance();
255 if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
256 AliCDBEntry *entry = man->Get("TOF/Align/Data",0);
257 fTOFAlignObjArray=(TObjArray*)entry->GetObject();
258 fNTOFAlignObj=fTOFAlignObjArray->GetEntries();
259 AliInfo(Form("Number of Alignable Volumes from CDB: %d",fNTOFAlignObj));
260
261}