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