1 #if !defined(__CINT__) || defined(__MAKECINT__)
4 #include <TGeoManager.h>
8 #include "AliCDBPath.h"
9 #include "AliCDBEntry.h"
10 #include "AliCDBManager.h"
11 #include "AliCDBStorage.h"
12 #include "AliGeomManager.h"
13 #include "AliITSMisalignMaker.h"
18 rnd.SetSeed(23457856);
20 void MakeITSFullMisAlignment() {
21 //========================================================================
23 // Macro for ITS full (realistic) misalignment
25 // Main author: L. Gaudichet
26 // Contact: andrea.dainese@lnl.infn.it
28 //========================================================================
31 const char* macroname = "MakeITSFullMisAlignment.C";
33 // Activate CDB storage and load geometry from CDB
34 AliCDBManager* cdb = AliCDBManager::Instance();
35 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
38 AliCDBStorage* storage = NULL;
40 if(TString(gSystem->Getenv("TOCDB")) == TString("kTRUE")){
41 TString Storage = gSystem->Getenv("STORAGE");
42 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
43 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
46 storage = cdb->GetStorage(Storage.Data());
48 Error(macroname,"Unable to open storage %s\n",Storage.Data());
51 AliCDBPath path("GRP","Geometry","Data");
52 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
53 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
55 TGeoManager* geom = (TGeoManager*) entry->GetObject();
56 AliGeomManager::SetGeometry(geom);
58 AliGeomManager::LoadGeometry("geometry.root"); //load geom from default CDB storage
62 // - tranformations are defined by the "maximum transformation"
63 // dx,dy,dz,dpsi,dtheta,dphi: then we take a Gaussian with sigma=dx/3
64 // and we cut it at +- 3*sigma = dx
65 // (the option "unif" allows to sample from a uniform distr.)
66 // - units are cm and deg
67 // - transformations are defined in the local frame of the volume
70 const Float_t kRadToDeg = 180./TMath::Pi();
73 //=****************************************
74 // misalignment of the whole ITS according to survey as reported by Werner Riegler (18/07/2008)
75 // + 100um smearing for translations and 0.1mrad smearing for rotations
76 //=****************************************
77 Double_t sigmatrW = 0.01;
78 Double_t sigmarotW = 0.006;
79 Double_t its_dx = AliMathBase::TruncatedGaus(-0.12,sigmatrW,3.*sigmatrW);
80 Double_t its_dy = AliMathBase::TruncatedGaus(-0.07,sigmatrW,3.*sigmatrW);
81 Double_t its_dz = AliMathBase::TruncatedGaus(0.29,sigmatrW,3.*sigmatrW);
82 Double_t its_dpsi = AliMathBase::TruncatedGaus(0.,sigmarotW,3.*sigmarotW);
83 Double_t its_dtheta = AliMathBase::TruncatedGaus(0.03,sigmarotW,3.*sigmarotW);
84 Double_t its_dphi = AliMathBase::TruncatedGaus(0.04,sigmarotW,3.*sigmarotW);
85 const char* unifits="fixed";
87 //=****************************************
88 // misalignment at the level of SPD sectors : source - A.Pepato
89 //=****************************************
90 Float_t spdsector_dx = 0.0050; // 50 micron (~tangetial, i.e. rphi)
91 Float_t spdsector_dy = 0.0100; // 100 micron (~radial)
92 Float_t spdsector_dz = 0.0100; // 100 micron
93 Float_t spdsector_dpsi = 0.0100/30.*kRadToDeg;; // so as to have 100 micron difference at the two extremes
94 Float_t spdsector_dtheta = 0.0100/30.*kRadToDeg;; // so as to have 100 micron difference at the two extremes
95 Float_t spdsector_dphi = 0.0050/1.5*kRadToDeg;; // so as to have 50 micron difference at the two extremes
96 Bool_t unifspdsector=kTRUE;
98 //=****************************************
99 // misalignment at the level of SPD half-barrels : source - A.Pepato
100 //=****************************************
101 Float_t spdhalfbarrel_dx = 0.0200; // 200 micron
102 Float_t spdhalfbarrel_dy = 0.0200; // 200 micron
103 Float_t spdhalfbarrel_dz = 0.0200; // 200 micron
104 Float_t spdhalfbarrel_dpsi = 0.0100/30.*kRadToDeg; // so as to have 100 micron difference at the two extremes
105 Float_t spdhalfbarrel_dtheta = 0.0100/30.*kRadToDeg; // so as to have 100 micron difference at the two extremes
106 Float_t spdhalfbarrel_dphi = 0.0100/7.*kRadToDeg; // so as to have 100 micron difference at the two extremes
108 //=****************************************
109 // misalignment at the level of SPD barrel : source - A.Pepato
110 //=****************************************
111 Float_t spdbarrel_dx = 0.1000; // 1 mm (very pessimistic)
112 Float_t spdbarrel_dy = 0.1000; // 1 mm (very pessimistic)
113 Float_t spdbarrel_dz = 0.1000; // 1 mm (very pessimistic)
114 Float_t spdbarrel_dpsi = 0.0500/30.*kRadToDeg; // so as to have 500 micron difference at the two extremes
115 Float_t spdbarrel_dtheta = 0.0500/30.*kRadToDeg; // so as to have 500 micron difference at the two extremes
116 Float_t spdbarrel_dphi = 0.0500/7.*kRadToDeg; // so as to have 500 micron difference at the two extremes
119 //=****************************************
120 // misalignment at the level of SDD and SSD layers: source - B.Giraudo
121 //=****************************************
122 Float_t sddlayer_dx = 0.0010; // 10 micron
123 Float_t sddlayer_dy = 0.0010; // 10 micron
124 Float_t sddlayer_dz = 0.0010; // 10 micron
125 Float_t sddlayer_dpsi = 0.0010/52.*kRadToDeg; // so as to have 10 micron difference at the two extremes
126 Float_t sddlayer_dtheta = 0.0010/52.*kRadToDeg; // so as to have 10 micron difference at the two extremes
127 Float_t sddlayer_dphi = 0.0010/20.*kRadToDeg; // so as to have 10 micron difference at the two extremes
129 Float_t ssdlayer_dx = 0.0010; // 10 micron
130 Float_t ssdlayer_dy = 0.0010; // 10 micron
131 Float_t ssdlayer_dz = 0.0010; // 10 micron
132 Float_t ssdlayer_dpsi = 0.0010/90.*kRadToDeg; // so as to have 10 micron difference at the two extremes
133 Float_t ssdlayer_dtheta = 0.0010/90.*kRadToDeg; // so as to have 10 micron difference at the two extremes
134 Float_t ssdlayer_dphi = 0.0010/40.*kRadToDeg; // so as to have 10 micron difference at the two extremes
136 Float_t sddbarrel_dx = 0.0020; // 20 micron
137 Float_t sddbarrel_dy = 0.0020; // 20 micron
138 Float_t sddbarrel_dz = 0.0020; // 20 micron
139 Float_t sddbarrel_dpsi = 0.0020/52.*kRadToDeg; // so as to have 20 micron difference at the two extremes
140 Float_t sddbarrel_dtheta = 0.0020/52.*kRadToDeg; // so as to have 20 micron difference at the two extremes
141 Float_t sddbarrel_dphi = 0.0020/20.*kRadToDeg; // so as to have 20 micron difference at the two extremes
143 Float_t ssdbarrel_dx = 0.0020; // 20 micron
144 Float_t ssdbarrel_dy = 0.0020; // 20 micron
145 Float_t ssdbarrel_dz = 0.0020; // 20 micron
146 Float_t ssdbarrel_dpsi = 0.0020/90.*kRadToDeg; // so as to have 20 micron difference at the two extremes
147 Float_t ssdbarrel_dtheta = 0.0020/90.*kRadToDeg; // so as to have 20 micron difference at the two extremes
148 Float_t ssdbarrel_dphi = 0.0020/40.*kRadToDeg; // so as to have 20 micron difference at the two extremes
150 //=****************************************
151 // misalignment at the level of half-staves (SPD) : source - S.Moretto
152 // ladders (SDD,SSD) : source -
153 //=****************************************
154 Float_t spdhalfstave_dx = 0.0100; // 100 micron // normal to plane
155 Float_t spdhalfstave_dy = 0.0020; // 20 micron
156 Float_t spdhalfstave_dz = 0.0020; // 20 micron
157 Float_t spdhalfstave_dpsi = 0.0020/7.*kRadToDeg; // so as to have 20 micron difference at the two extremes
158 Float_t spdhalfstave_dtheta = 0.0050/7.*kRadToDeg; // so as to have 50 micron difference at the two extremes
159 Float_t spdhalfstave_dphi = 0.0050/0.7*kRadToDeg; // so as to have 50 micron difference at the two extremes
160 Bool_t unifspdhalfstave=kTRUE;
162 Float_t sddladder_dx = 0.0005; // 5 micron
163 Float_t sddladder_dy = 0.0005; // 5 micron
164 Float_t sddladder_dz = 0.0005; // 5 micron
165 Float_t sddladder_dpsi = 0.00; // ?
166 Float_t sddladder_dtheta = 0.00; // ?
167 Float_t sddladder_dphi = 0.00; // ?
169 Float_t ssdladder_dx = 0.0005; // 5 micron
170 Float_t ssdladder_dy = 0.0005; // 5 micron
171 Float_t ssdladder_dz = 0.0005; // 5 micron
172 Float_t ssdladder_dpsi = 0.00; // ?
173 Float_t ssdladder_dtheta = 0.00; // ?
174 Float_t ssdladder_dphi = 0.00; // ?
177 //=****************************************
178 // misalignment at the level of ladders (SPD) : source - R.Santoro
179 // modules (SDD) : source - L.Gaudichet
180 // modules (SSD) : source -
181 //=****************************************
182 Float_t spdladder_dx = 0.0010; // 10 micron
183 Float_t spdladder_dy = 0.0030; // 50 micron
184 Float_t spdladder_dz = 0.0010; // 10 micron
185 Float_t spdladder_dpsi = 0.0001*kRadToDeg; // 0.1 mrad
186 Float_t spdladder_dtheta = 0.0001*kRadToDeg; // 0.1 mrad
187 Float_t spdladder_dphi = 0.0001*kRadToDeg; // 0.1 mrad
189 Float_t sddmodule_dx = 0.0045; // 45 micron
190 Float_t sddmodule_dy = 0.0045; // 45 micron
191 Float_t sddmodule_dz = 0.0105; // 105 micron
192 Float_t sddmodule_dpsi = 0.00; // ?
193 Float_t sddmodule_dtheta = 0.00; // ?
194 Float_t sddmodule_dphi = 0.00; // ?
196 Float_t ssdmodule_dx = 0.0050; // 50 micron
197 Float_t ssdmodule_dy = 0.0050; // 50 micron
198 Float_t ssdmodule_dz = 0.0050; // 50 micron
199 Float_t ssdmodule_dpsi = 0.00; // ?
200 Float_t ssdmodule_dtheta = 0.00; // ?
201 Float_t ssdmodule_dphi = 0.00; // ?
206 AliITSMisalignMaker alignMaker;
208 //=****************************************
209 // overall ITS misalignment :
210 //=****************************************
212 alignMaker.AddAlignObj("ITS",its_dx,its_dy,its_dz,its_dpsi,its_dtheta,its_dphi,unifits);
214 //=****************************************
215 // misalignment at the level of SPD barrel, half-barrels, and at the level
217 //=****************************************
219 Double_t vx,vy,vz,vpsi,vtheta,vphi;
220 Double_t vxbarrel,vybarrel,vzbarrel,vpsibarrel,vthetabarrel,vphibarrel;
223 vxbarrel = AliMathBase::TruncatedGaus(0,spdbarrel_dx/3,spdbarrel_dx);
224 vybarrel = AliMathBase::TruncatedGaus(0,spdbarrel_dy/3,spdbarrel_dy);
225 vzbarrel = AliMathBase::TruncatedGaus(0,spdbarrel_dz/3,spdbarrel_dz);
226 vpsibarrel = AliMathBase::TruncatedGaus(0,spdbarrel_dpsi/3,spdbarrel_dpsi);
227 vthetabarrel = AliMathBase::TruncatedGaus(0,spdbarrel_dtheta/3,spdbarrel_dtheta);
228 vphibarrel = AliMathBase::TruncatedGaus(0,spdbarrel_dphi/3,spdbarrel_dphi);
231 vx = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dx/3,spdhalfbarrel_dx);
232 vy = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dy/3,spdhalfbarrel_dy);
233 vz = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dz/3,spdhalfbarrel_dz);
234 vpsi = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dpsi/3,spdhalfbarrel_dpsi);
235 vtheta = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dtheta/3,spdhalfbarrel_dtheta);
236 vphi = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dphi/3,spdhalfbarrel_dphi);
242 vtheta += vthetabarrel;
245 alignMaker.AddSectorAlignObj(1,5,spdsector_dx,spdsector_dy,spdsector_dz,
246 spdsector_dpsi,spdsector_dtheta,spdsector_dphi,
247 vx,vy,vz,vpsi,vtheta,vphi,unifspdsector);
249 // bottom half-barrel
250 vx = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dx/3,spdhalfbarrel_dx);
251 vy = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dy/3,spdhalfbarrel_dy);
252 vz = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dz/3,spdhalfbarrel_dz);
253 vpsi = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dpsi/3,spdhalfbarrel_dpsi);
254 vtheta = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dtheta/3,spdhalfbarrel_dtheta);
255 vphi = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dphi/3,spdhalfbarrel_dphi);
261 vtheta += vthetabarrel;
264 alignMaker.AddSectorAlignObj(6,10,spdsector_dx,spdsector_dy,spdsector_dz,
265 spdsector_dpsi,spdsector_dtheta,spdsector_dphi,
266 vx,vy,vz,vpsi,vtheta,vphi,unifspdsector);
270 //=****************************************
271 // misalignment at the level of half-staves (SPD)/ladders&layers (SDD,SSD) :
272 //=****************************************
275 alignMaker.AddAlignObj(0,-1,spdhalfstave_dx,spdhalfstave_dy,spdhalfstave_dz,spdhalfstave_dpsi,spdhalfstave_dtheta,spdhalfstave_dphi,0,0,0,0,0,0,unifspdhalfstave); // all SPD1 half-staves
276 alignMaker.AddAlignObj(1,-1,spdhalfstave_dx,spdhalfstave_dy,spdhalfstave_dz,spdhalfstave_dpsi,spdhalfstave_dtheta,spdhalfstave_dphi,0,0,0,0,0,0,unifspdhalfstave); // all SPD2 half-staves
280 vxbarrel = alignMaker.GetUnif(-sddbarrel_dx,sddbarrel_dx);
281 vybarrel = alignMaker.GetUnif(-sddbarrel_dy,sddbarrel_dy);
282 vzbarrel = alignMaker.GetUnif(-sddbarrel_dz,sddbarrel_dz);
283 vpsibarrel = alignMaker.GetUnif(-sddbarrel_dpsi,sddbarrel_dpsi);
284 vthetabarrel = alignMaker.GetUnif(-sddbarrel_dtheta,sddbarrel_dtheta);
285 vphibarrel = alignMaker.GetUnif(-sddbarrel_dphi,sddbarrel_dphi);
288 vx = alignMaker.GetUnif(-sddlayer_dx,sddlayer_dx);
289 vy = alignMaker.GetUnif(-sddlayer_dy,sddlayer_dy);
290 vz = alignMaker.GetUnif(-sddlayer_dz,sddlayer_dz);
291 vpsi = alignMaker.GetUnif(-sddlayer_dpsi,sddlayer_dpsi);
292 vtheta = alignMaker.GetUnif(-sddlayer_dtheta,sddlayer_dtheta);
293 vphi = alignMaker.GetUnif(-sddlayer_dphi,sddlayer_dphi);
299 vtheta += vthetabarrel;
302 alignMaker.AddAlignObj(2,-1,sddladder_dx,sddladder_dy,sddladder_dz,sddladder_dpsi,sddladder_dtheta,sddladder_dphi,vx,vy,vz,vpsi,vtheta,vphi,kFALSE); // all SDD1 ladders
305 vx = alignMaker.GetUnif(-sddlayer_dx,sddlayer_dx);
306 vy = alignMaker.GetUnif(-sddlayer_dy,sddlayer_dy);
307 vz = alignMaker.GetUnif(-sddlayer_dz,sddlayer_dz);
308 vpsi = alignMaker.GetUnif(-sddlayer_dpsi,sddlayer_dpsi);
309 vtheta = alignMaker.GetUnif(-sddlayer_dtheta,sddlayer_dtheta);
310 vphi = alignMaker.GetUnif(-sddlayer_dphi,sddlayer_dphi);
316 vtheta += vthetabarrel;
319 alignMaker.AddAlignObj(3,-1,sddladder_dx,sddladder_dy,sddladder_dz,sddladder_dpsi,sddladder_dtheta,sddladder_dphi,vx,vy,vz,vpsi,vtheta,vphi,kFALSE); // all SDD2 ladders
323 vxbarrel = alignMaker.GetUnif(-ssdbarrel_dx,ssdbarrel_dx);
324 vybarrel = alignMaker.GetUnif(-ssdbarrel_dy,ssdbarrel_dy);
325 vzbarrel = alignMaker.GetUnif(-ssdbarrel_dz,ssdbarrel_dz);
326 vpsibarrel = alignMaker.GetUnif(-ssdbarrel_dpsi,ssdbarrel_dpsi);
327 vthetabarrel = alignMaker.GetUnif(-ssdbarrel_dtheta,ssdbarrel_dtheta);
328 vphibarrel = alignMaker.GetUnif(-ssdbarrel_dphi,ssdbarrel_dphi);
331 vx = alignMaker.GetUnif(-ssdlayer_dx,ssdlayer_dx);
332 vy = alignMaker.GetUnif(-ssdlayer_dy,ssdlayer_dy);
333 vz = alignMaker.GetUnif(-ssdlayer_dz,ssdlayer_dz);
334 vpsi = alignMaker.GetUnif(-ssdlayer_dpsi,ssdlayer_dpsi);
335 vtheta = alignMaker.GetUnif(-ssdlayer_dtheta,ssdlayer_dtheta);
336 vphi = alignMaker.GetUnif(-ssdlayer_dphi,ssdlayer_dphi);
342 vtheta += vthetabarrel;
345 alignMaker.AddAlignObj(4,-1,ssdladder_dx,ssdladder_dy,ssdladder_dz,ssdladder_dpsi,ssdladder_dtheta,ssdladder_dphi,vx,vy,vz,vpsi,vtheta,vphi,kFALSE); // all SSD1 ladders
348 vx = alignMaker.GetUnif(-ssdlayer_dx,ssdlayer_dx);
349 vy = alignMaker.GetUnif(-ssdlayer_dy,ssdlayer_dy);
350 vz = alignMaker.GetUnif(-ssdlayer_dz,ssdlayer_dz);
351 vpsi = alignMaker.GetUnif(-ssdlayer_dpsi,ssdlayer_dpsi);
352 vtheta = alignMaker.GetUnif(-ssdlayer_dtheta,ssdlayer_dtheta);
353 vphi = alignMaker.GetUnif(-ssdlayer_dphi,ssdlayer_dphi);
359 vtheta += vthetabarrel;
362 alignMaker.AddAlignObj(5,-1,ssdladder_dx,ssdladder_dy,ssdladder_dz,ssdladder_dpsi,ssdladder_dtheta,ssdladder_dphi,vx,vy,vz,vpsi,vtheta,vphi,kFALSE); // all SSD2 ladders
364 //=****************************************
365 // misalignment at the level of ladders (SPD)/modules (SDD,SSD) :
366 //=****************************************
368 alignMaker.AddAlignObj(0,spdladder_dx,spdladder_dy,spdladder_dz,spdladder_dpsi,spdladder_dtheta,spdladder_dphi,kFALSE); // all SPD1 ladders
369 alignMaker.AddAlignObj(1,spdladder_dx,spdladder_dy,spdladder_dz,spdladder_dpsi,spdladder_dtheta,spdladder_dphi,kFALSE); // all SPD2 ladders
371 alignMaker.AddAlignObj(2,sddmodule_dx,sddmodule_dy,sddmodule_dz,sddmodule_dpsi,sddmodule_dtheta,sddmodule_dphi,kFALSE); // all SDD1 modules
372 alignMaker.AddAlignObj(3,sddmodule_dx,sddmodule_dy,sddmodule_dz,sddmodule_dpsi,sddmodule_dtheta,sddmodule_dphi,kFALSE); // all SDD2 modules
374 alignMaker.AddAlignObj(4,ssdmodule_dx,ssdmodule_dy,ssdmodule_dz,ssdmodule_dpsi,ssdmodule_dtheta,ssdmodule_dphi,kFALSE); // all SSD1 modules
375 alignMaker.AddAlignObj(5,ssdmodule_dx,ssdmodule_dy,ssdmodule_dz,ssdmodule_dpsi,ssdmodule_dtheta,ssdmodule_dphi,kFALSE); // all SSD2 modules
379 if(TString(gSystem->Getenv("TOCDB")) != TString("kTRUE")){
381 const char* filename = "ITSfullMisalignment.root";
382 TFile f(filename,"RECREATE");
384 Error(macroname,"cannot open file for output\n");
387 Info(macroname,"Saving alignment objects to the file %s",filename);
389 f.WriteObject(alignMaker.GetArray(),"ITSAlignObjs","kSingleKey");
392 // save in CDB storage
393 AliCDBMetaData *md= new AliCDBMetaData();
394 md->SetResponsible("Andrea Dainese");
395 md->SetComment("Alignment objects with actual ITS misalignment");
396 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
397 AliCDBId id("ITS/Align/Data",0,AliCDBRunRange::Infinity());
398 storage->Put(alignMaker.GetArray(),id,md);