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