3 // Script to create alignment parameters and store them into CDB
4 // Three sets of alignment parameters can be created:
5 // 0) 1 PHOS module with ideal geometry
6 // 1) 5 PHOS modules with small disalignments
7 // 2) 5 PHOS modules with ideal geometry
10 #include "TControlBar.h"
15 #include "AliPHOSAlignData.h"
16 #include "AliCDBMetaData.h"
18 #include "AliCDBEntry.h"
19 #include "AliCDBManager.h"
20 #include "AliCDBStorage.h"
24 void AliPHOSSetAlignment()
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");
30 menu->AddButton("PHOS 2007","SetAlignment(0)",
31 "Set PHOS alignment for the LHC run 2007");
32 menu->AddButton("Full misaligned PHOS","SetAlignment(1)",
33 "Set all 5 modules with random displacement");
34 menu->AddButton("Full ideal PHOS","SetAlignment(2)",
35 "Set all 5 modules with random displacement");
37 menu->AddButton("Read PHOS 2007","GetAlignment(0)",
38 "Read PHOS geometry for the LHC run 2007");
39 menu->AddButton("Read full misaligned PHOS","GetAlignment(1)",
40 "Read full PHOS geometry with random displacements");
41 menu->AddButton("Read full ideal PHOS","GetAlignment(2)",
42 "Read full PHOS geometry with random displacements");
47 //------------------------------------------------------------------------
51 "\nSet PHOS alignment parameters and write them into ALICE CDB.
52 Press button \"PHOS 2007\" to create PHOS geometry for the first LHC run in 2007.
53 Press button \"Full PHOS\" to create full PHOS geometry with radnomly displaced modules\n";
57 //------------------------------------------------------------------------
58 void SetAlignment(Int_t flag=0)
60 // Write alignment parameters into CDB
62 // flag=0: ideal geometry with one module
63 // flag=1: disligned geometry with 5 modules
64 // Author: Yuri Kharlov
73 AliPHOSAlignData *alignda=new AliPHOSAlignData("PHOS");
77 DBFolder ="local://InitAlignDB";
80 objFormat = "PHOS ideal geometry with 1 module";
82 alignda->SetNModules(1);
84 alignda->SetModuleCenter(0,0, 0.);
85 alignda->SetModuleCenter(0,1,-460.);
86 alignda->SetModuleCenter(0,2, 0.);
88 alignda->SetModuleAngle(0,0,0, 90.);
89 alignda->SetModuleAngle(0,0,1, 0.);
90 alignda->SetModuleAngle(0,1,0, 0.);
91 alignda->SetModuleAngle(0,1,1, 0.);
92 alignda->SetModuleAngle(0,2,0, 90.);
93 alignda->SetModuleAngle(0,2,1, 270.);
96 DBFolder ="local://DisAlignDB";
99 objFormat = "PHOS disaligned geometry with 5 modules";
102 alignda->SetNModules(nModules);
107 for (Int_t iModule=0; iModule<nModules; iModule++) {
108 Float_t r = r0 + gRandom->Uniform(0.,40.);
109 Float_t angle = dAngle * ( iModule - nModules / 2.0 + 0.5 ) ;
110 angle += gRandom->Uniform(-0.1,+0.1);
111 Float_t x = r * TMath::Sin(angle * TMath::DegToRad() );
112 Float_t y =-r * TMath::Cos(angle * TMath::DegToRad() );
113 Float_t z = gRandom->Uniform(-0.05,0.05);
115 alignda->SetModuleCenter(iModule,0,x);
116 alignda->SetModuleCenter(iModule,1,y);
117 alignda->SetModuleCenter(iModule,2,z);
119 theta = 90 + gRandom->Uniform(-1.,1.);
121 alignda->SetModuleAngle(iModule,0,0,theta);
122 alignda->SetModuleAngle(iModule,0,1,phi);
125 alignda->SetModuleAngle(iModule,1,0,theta);
126 alignda->SetModuleAngle(iModule,1,1,phi);
127 theta = 90 + gRandom->Uniform(-1.,1.);
129 alignda->SetModuleAngle(iModule,2,0,theta);
130 alignda->SetModuleAngle(iModule,2,1,phi);
133 DBFolder ="local://AlignDB";
136 objFormat = "PHOS disaligned geometry with 5 modules";
139 alignda->SetNModules(nModules);
144 for (Int_t iModule=0; iModule<nModules; iModule++) {
146 Float_t angle = dAngle * ( iModule - nModules / 2.0 + 0.5 ) ;
147 Float_t x = r * TMath::Sin(angle * TMath::DegToRad() );
148 Float_t y =-r * TMath::Cos(angle * TMath::DegToRad() );
151 alignda->SetModuleCenter(iModule,0,x);
152 alignda->SetModuleCenter(iModule,1,y);
153 alignda->SetModuleCenter(iModule,2,z);
157 alignda->SetModuleAngle(iModule,0,0,theta);
158 alignda->SetModuleAngle(iModule,0,1,phi);
161 alignda->SetModuleAngle(iModule,1,0,theta);
162 alignda->SetModuleAngle(iModule,1,1,phi);
165 alignda->SetModuleAngle(iModule,2,0,theta);
166 alignda->SetModuleAngle(iModule,2,1,phi);
170 printf("Unknown flag %d, can be 0 or 1 only\n",flag);
175 //Store calibration data into database
178 md.SetComment(objFormat);
179 md.SetBeamPeriod(beamPeriod);
180 md.SetResponsible("Yuri Kharlov");
182 AliCDBId id("PHOS/Alignment/Geometry",firstRun,lastRun);
184 AliCDBManager* man = AliCDBManager::Instance();
185 AliCDBStorage* loc = man->GetStorage(DBFolder.Data());
186 loc->Put(alignda, id, &md);
190 //------------------------------------------------------------------------
191 void GetAlignment(Int_t flag=0)
193 // Read alignment parameters into CDB
195 // flag=0: ideal geometry with one module
196 // flag=1: disligned geometry with 5 modules
197 // Author: Yuri Kharlov
201 AliPHOSAlignData *alignda=new AliPHOSAlignData("PHOS");
205 DBFolder ="local://InitAlignDB";
208 DBFolder ="local://DisAlignDB";
211 DBFolder ="local://AlignDB";
214 printf("Unknown flag %d, can be 0 or 1 only\n",flag);
217 AliPHOSAlignData* alignda = (AliPHOSAlignData*)
218 (AliCDBManager::Instance()
219 ->GetStorage(DBFolder.Data())
220 ->Get("PHOS/Alignment/Geometry",run)->GetObject());