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