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