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