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