]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/macros/AlignmentDB/AliEMCALSetAlignment.C
AliAlignObjAngles becomes AliAlignObjParams (Raffaele)
[u/mrichter/AliRoot.git] / EMCAL / macros / AlignmentDB / AliEMCALSetAlignment.C
CommitLineData
a46ff39d 1/* $Id$*/
2
3// Script to create alignment parameters and store them into CDB
4// Three sets of alignment parameters can be created:
5// 1) Ideal geometry
6// 2) Geometry with disalignments and disorientations
7// 3) Geometry small disalignments and disorientations
8
9#if !defined(__CINT__)
10#include "TControlBar.h"
11#include "TString.h"
12#include "TRandom.h"
13#include "TClonesArray.h"
14
90dbf5fb 15#include "AliAlignObjParams.h"
a46ff39d 16#include "AliCDBMetaData.h"
17#include "AliCDBId.h"
18#include "AliCDBEntry.h"
19#include "AliCDBManager.h"
20#include "AliCDBStorage.h"
21#endif
22
23
24void AliEMCALSetAlignment()
25{
26 TControlBar *menu = new TControlBar("vertical","EMCAL alignment control");
27 menu->AddButton("Help to run EMCAL alignment control","Help()",
28 "Explains how to use EMCAL alignment control menus");
29
30 menu->AddButton("Ideal geometry","IdealAlignment()",
31 "Set ideal EMCAL geometry with zero displacement");
32 menu->AddButton("Misaligned geometry","FullMisalignment()",
33 "Set EMCAL geometry with large displacement");
34 menu->AddButton("Residual misaligned geometry","ResidualAlignment()",
35 "Set EMCAL geometry with small residual displacement");
36
37 menu->Show();
38}
39
40//------------------------------------------------------------------------
41void Help()
42{
43 char *string =
44 "\n\n\nSet EMCAL alignment parameters and write them into ALICE CDB.
45Press button \"Ideal geometry\" to create EMCAL geometry with ideal geometry.
46Press button \"Misaligned geometry\" to create EMCAL geometry with fully displaced and disorientated geometry.
47Press button \"Residual misaligned geometry\" to create EMCAL geometry with infinitesimal displacement and disorientation\n\n\n";
48 printf(string);
49}
50
51//------------------------------------------------------------------------
52void IdealAlignment()
53{
54 // Create alignment objects for EMCAL with ideally aligned geometry,
55 // i.e. with zero displacements and zero disorientations
56
57 // ************************* 1st step ***************
58 // Create TClonesArray of alignment objects for EMCAL
59
90dbf5fb 60 TClonesArray *array = new TClonesArray("AliAlignObjParams",12);
a46ff39d 61 TClonesArray &alobj = *array;
62
90dbf5fb 63 AliAlignObjParams a;
a46ff39d 64
65 Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
66 // null shifts and rotations
67
68 UShort_t iIndex=0;
ae079791 69 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
70 UShort_t dvoluid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy volume identity
a46ff39d 71
72 TString basePath = "EMCAL/FullSupermodule";
73 const Int_t nModules=10;
74
75 for (Int_t iModule = 0; iModule < nModules; iModule++) {
76 TString newPath = basePath;
77 newPath += iModule+1;
90dbf5fb 78 new(alobj[iModule]) AliAlignObjParams(newPath.Data(),
a46ff39d 79 dvoluid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
80 }
81
82 //half SMs
90dbf5fb 83 new(alobj[10]) AliAlignObjParams("EMCAL/HalfSupermodule1",
a46ff39d 84 dvoluid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 85 new(alobj[11]) AliAlignObjParams("EMCAL/HalfSupermodule2",
a46ff39d 86 dvoluid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
87
88
89 // ************************* 2nd step ***************
90 // Make CDB storage and put TClonesArray in
91 //
92 AliCDBManager *CDB = AliCDBManager::Instance();
93 CDB->SetDefaultStorage("local://$ALICE_ROOT");
94
95 AliCDBMetaData *md= new AliCDBMetaData();
96 md->SetResponsible("EMCAL Expert");
97 md->SetComment("Alignment objects for ideal geometry, i.e. applying them to TGeo has to leave geometry unchanged");
98 AliCDBId id("EMCAL/Align/Data",0,999999);
99 CDB->Put(array,id, md);
100}
101
102//------------------------------------------------------------------------
103void ResidualAlignment()
104{
105 // Create alignment objects for EMCAL with residual alignment,
106 // i.e. with infinitesimal displacement and disorientation
107
108 // ************************* 1st step ***************
109 // Create TClonesArray of alignment objects for EMCAL
110
90dbf5fb 111 TClonesArray *array = new TClonesArray("AliAlignObjParams",12);
a46ff39d 112 TClonesArray &alobj = *array;
113
90dbf5fb 114 AliAlignObjParams a;
a46ff39d 115
116 UShort_t iIndex=0;
ae079791 117 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
118 UShort_t dvoluid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy volume identity
a46ff39d 119
120 Double_t sigmaTrans = 0.01; Double_t sigmaRot = 0.001;
121 Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
122
123 TRandom *pRnd = new TRandom(4357);
124
125 TString basePath = "EMCAL/FullSupermodule";
126 for(Int_t iSM = 0; iSM < 10; iSM++) {
127 dx = pRnd->Gaus(0,sigmaTrans); dy = pRnd->Gaus(0,sigmaTrans); dz = pRnd->Gaus(0,sigmaTrans);
128 dpsi = pRnd->Gaus(0,sigmaRot); dtheta = pRnd->Gaus(0,sigmaRot); dphi = pRnd->Gaus(0,sigmaRot);
129 TString newPath = basePath;
130 newPath += iSM + 1;
90dbf5fb 131 new(alobj[iSM]) AliAlignObjParams(newPath.Data(),
a46ff39d 132 dvoluid, dx,dy,dz,dpsi,dtheta,dphi, kTRUE);
133 }
134
135 dx = pRnd->Gaus(0,sigmaTrans); dy = pRnd->Gaus(0,sigmaTrans); dz = pRnd->Gaus(0,sigmaTrans);
136 dpsi = pRnd->Gaus(0,sigmaRot); dtheta = pRnd->Gaus(0,sigmaRot); dphi = pRnd->Gaus(0,sigmaRot);
90dbf5fb 137 new(alobj[10]) AliAlignObjParams("EMCAL/HalfSupermodule1",
a46ff39d 138 dvoluid, dx,dy,dz,dpsi,dtheta,dphi, kTRUE);
139
140 dx = pRnd->Gaus(0,sigmaTrans); dy = pRnd->Gaus(0,sigmaTrans); dz = pRnd->Gaus(0,sigmaTrans);
141 dpsi = pRnd->Gaus(0,sigmaRot); dtheta = pRnd->Gaus(0,sigmaRot); dphi = pRnd->Gaus(0,sigmaRot);
90dbf5fb 142 new(alobj[11]) AliAlignObjParams("EMCAL/HalfSupermodule2",
a46ff39d 143 dvoluid, dx,dy,dz,dpsi,dtheta,dphi, kTRUE);
144
145 // ************************* 2nd step ***************
146 // Make CDB storage and put TClonesArray in
147 //
148 AliCDBManager *CDB = AliCDBManager::Instance();
149 CDB->SetDefaultStorage("local://$ALICE_ROOT");
150
151 AliCDBMetaData *md= new AliCDBMetaData();
152 md->SetResponsible("EMCAL Expert");
153 md->SetComment("Alignment objects for slightly misaligned geometry, i.e. applying them to TGeo has to distirbes geometry very little (resisual misalignment");
154 AliCDBId id("EMCAL/Align/Data",1000000,1999999);
155 CDB->Put(array,id, md);
156}
157
158//------------------------------------------------------------------------
159void FullMisalignment()
160{
161 // Create alignment objects for EMCAL with fully misaligned geometry
162
163 // ************************* 1st step ***************
164 // Create TClonesArray of alignment objects for EMCAL
165
90dbf5fb 166 TClonesArray *array = new TClonesArray("AliAlignObjParams",12);
a46ff39d 167 TClonesArray &alobj = *array;
168
90dbf5fb 169 AliAlignObjParams a;
a46ff39d 170
171 UShort_t iIndex=0;
ae079791 172 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
173 UShort_t dvoluid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy volume identity
a46ff39d 174
175
176 Double_t sigmaTrans = 10.; Double_t sigmaRot = 0.1;
177 Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
178
179 TRandom *pRnd = new TRandom(4357);
180
181 TString basePath = "EMCAL/FullSupermodule";
182 for(Int_t iSM = 0; iSM < 10; iSM++) {
183 dx = pRnd->Gaus(0,sigmaTrans); dy = pRnd->Gaus(0,sigmaTrans); dz = pRnd->Gaus(0,sigmaTrans);
184 dpsi = pRnd->Gaus(0,sigmaRot); dtheta = pRnd->Gaus(0,sigmaRot); dphi = pRnd->Gaus(0,sigmaRot);
185 TString newPath = basePath;
186 newPath += iSM + 1;
90dbf5fb 187 new(alobj[iSM]) AliAlignObjParams(newPath.Data(),
a46ff39d 188 dvoluid, dx,dy,dz,dpsi,dtheta,dphi, kTRUE);
189 }
190
191 dx = pRnd->Gaus(0,sigmaTrans); dy = pRnd->Gaus(0,sigmaTrans); dz = pRnd->Gaus(0,sigmaTrans);
192 dpsi = pRnd->Gaus(0,sigmaRot); dtheta = pRnd->Gaus(0,sigmaRot); dphi = pRnd->Gaus(0,sigmaRot);
90dbf5fb 193 new(alobj[10]) AliAlignObjParams("EMCAL/HalfSupermodule1",
a46ff39d 194 dvoluid, dx,dy,dz,dpsi,dtheta,dphi, kTRUE);
195
196 dx = pRnd->Gaus(0,sigmaTrans); dy = pRnd->Gaus(0,sigmaTrans); dz = pRnd->Gaus(0,sigmaTrans);
197 dpsi = pRnd->Gaus(0,sigmaRot); dtheta = pRnd->Gaus(0,sigmaRot); dphi = pRnd->Gaus(0,sigmaRot);
90dbf5fb 198 new(alobj[11]) AliAlignObjParams("EMCAL/HalfSupermodule2",
a46ff39d 199 dvoluid, dx,dy,dz,dpsi,dtheta,dphi, kTRUE);
200
201 // ************************* 2nd step ***************
202 // Make CDB storage and put TClonesArray in
203 //
204 AliCDBManager *CDB = AliCDBManager::Instance();
205 CDB->SetDefaultStorage("local://$ALICE_ROOT");
206
207 AliCDBMetaData *md= new AliCDBMetaData();
208 md->SetResponsible("EMCAL Expert");
209 md->SetComment("Alignment objects for fully misaligned geometry, i.e. applying them to TGeo has to distirbes geometry very much");
210 AliCDBId id("EMCAL/Align/Data",2000000,2999999);
211 CDB->Put(array,id, md);
212}