]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/MakeITSResMisAlignment.C
Fixes for reading zero-suppressed data. These should be propagated to
[u/mrichter/AliRoot.git] / ITS / MakeITSResMisAlignment.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <TError.h>
3 #include <TFile.h>
4 #include <TGeoManager.h>
5 #include <TMath.h>
6 #include <TString.h>
7 #include <TSystem.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"
14 #endif
15
16
17 TRandom3 rnd;
18 rnd.SetSeed(98723456);
19
20 void MakeITSResMisAlignment() {
21 //========================================================================
22 //
23 // Steering macro for ITS residual (realistic) misalignment
24 //
25 // Main author: L. Gaudichet
26 // Contact: andrea.dainese@lnl.infn.it
27 //
28 //========================================================================
29
30
31   const char* macroname = "MakeITSResMisAlignment.C";
32
33   // Activate CDB storage and load geometry from CDB
34   AliCDBManager* cdb = AliCDBManager::Instance();
35   if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
36   cdb->SetRun(0);
37   
38   AliCDBStorage* storage = NULL;
39
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());
44       return;
45     }
46     storage = cdb->GetStorage(Storage.Data());
47     if(!storage){
48       Error(macroname,"Unable to open storage %s\n",Storage.Data());
49       return;
50     }
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!");
54     entry->SetOwner(0);
55     TGeoManager* geom = (TGeoManager*) entry->GetObject();
56     AliGeomManager::SetGeometry(geom);
57   }else{
58     AliGeomManager::LoadGeometry("geometry.root"); //load geom from default CDB storage
59   }    
60
61   //   SETTINGS:
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
68   //     being misaligned
69   //
70   const Float_t kRadToDeg = 180./TMath::Pi();
71
72
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";
86
87   //=****************************************
88   // misalignment at the level of SPD sectors : source - A.Pepato
89   //=****************************************
90   Float_t spdsector_dx     = 0.0050/5.; //  50 micron (~tangetial, i.e. rphi) 
91   Float_t spdsector_dy     = 0.0100/5.; // 100 micron (~radial)
92   Float_t spdsector_dz     = 0.0100/5.; // 100 micron
93   Float_t spdsector_dpsi   = 0.0100/30.*kRadToDeg/5.; // so as to have 100 micron difference at the two extremes
94   Float_t spdsector_dtheta = 0.0100/30.*kRadToDeg/5.; // so as to have 100 micron difference at the two extremes
95   Float_t spdsector_dphi   = 0.0050/1.5*kRadToDeg/5.; // so as to have 50 micron difference at the two extremes
96   Bool_t unifspdsector=kFALSE;
97
98   //=****************************************
99   // misalignment at the level of SPD half-barrels : source - A.Pepato
100   //=****************************************
101   Float_t spdhalfbarrel_dx     = 0.000; // 200 micron  
102   Float_t spdhalfbarrel_dy     = 0.000; // 200 micron 
103   Float_t spdhalfbarrel_dz     = 0.000; // 200 micron
104   Float_t spdhalfbarrel_dpsi   = 0.000/30.*kRadToDeg; // so as to have 100 micron difference at the two extremes
105   Float_t spdhalfbarrel_dtheta = 0.000/30.*kRadToDeg; // so as to have 100 micron difference at the two extremes
106   Float_t spdhalfbarrel_dphi   = 0.000/7.*kRadToDeg; // so as to have 100 micron difference at the two extremes
107
108   //=****************************************
109   // misalignment at the level of SPD barrel : source - A.Pepato
110   //=****************************************
111   Float_t spdbarrel_dx     = 0.000; // 1 mm (very pessimistic)  
112   Float_t spdbarrel_dy     = 0.000; // 1 mm (very pessimistic)
113   Float_t spdbarrel_dz     = 0.000; // 1 mm (very pessimistic)
114   Float_t spdbarrel_dpsi   = 0.000/30.*kRadToDeg; // so as to have 500 micron difference at the two extremes
115   Float_t spdbarrel_dtheta = 0.000/30.*kRadToDeg; // so as to have 500 micron difference at the two extremes
116   Float_t spdbarrel_dphi   = 0.000/7.*kRadToDeg; // so as to have 500 micron difference at the two extremes
117   
118
119   //=****************************************
120   // misalignment at the level of SDD and SSD layers: source
121   //=****************************************
122   Float_t sddlayer_dx     = 0.0000; 
123   Float_t sddlayer_dy     = 0.0000; 
124   Float_t sddlayer_dz     = 0.0000; 
125   Float_t sddlayer_dpsi   = 0.0000;
126   Float_t sddlayer_dtheta = 0.0000; 
127   Float_t sddlayer_dphi   = 0.0000;
128
129   Float_t ssdlayer_dx     = 0.0000;
130   Float_t ssdlayer_dy     = 0.0000;
131   Float_t ssdlayer_dz     = 0.0000;
132   Float_t ssdlayer_dpsi   = 0.0000;
133   Float_t ssdlayer_dtheta = 0.0000;
134   Float_t ssdlayer_dphi   = 0.0000;
135   
136
137   //=****************************************
138   // misalignment at the level of half-staves (SPD) : source - S.Moretto
139   //                              ladders (SDD,SSD) : source -
140   //=****************************************
141   Float_t spdhalfstave_dx     = 0.0100/4.; // 100 micron  
142   Float_t spdhalfstave_dy     = 0.0020/4.; // 20 micron 
143   Float_t spdhalfstave_dz     = 0.0020/4.; // 20 micron
144   Float_t spdhalfstave_dpsi   = 0.0020/7.*kRadToDeg/4.; // so as to have 20 micron difference at the two extremes
145   Float_t spdhalfstave_dtheta = 0.0050/7.*kRadToDeg/4.; // so as to have 50 micron difference at the two extremes
146   Float_t spdhalfstave_dphi   = 0.0050/0.7*kRadToDeg/4.; // so as to have 50 micron difference at the two extremes
147   Bool_t unifspdhalfstave=kFALSE;
148
149   Float_t sddladder_dx     = 0.0005; // 5 micron  
150   Float_t sddladder_dy     = 0.0005; // 5 micron 
151   Float_t sddladder_dz     = 0.0005; // 5 micron
152   Float_t sddladder_dpsi   = 0.00; //  ?
153   Float_t sddladder_dtheta = 0.00; //  ?
154   Float_t sddladder_dphi   = 0.00; //  ?
155
156   Float_t ssdladder_dx     = 0.0005; // 5 micron  
157   Float_t ssdladder_dy     = 0.0005; // 5 micron 
158   Float_t ssdladder_dz     = 0.0005; // 5 micron
159   Float_t ssdladder_dpsi   = 0.00; //  ?
160   Float_t ssdladder_dtheta = 0.00; //  ?
161   Float_t ssdladder_dphi   = 0.00; //  ?
162
163
164   //=****************************************
165   // misalignment at the level of ladders (SPD) : source - R.Santoro
166   //                              modules (SDD) : source - L.Gaudichet
167   //                              modules (SSD) : source - 
168   //=****************************************
169   Float_t spdladder_dx     = 0.0010/5.; // 10 micron  
170   Float_t spdladder_dy     = 0.0050/5.; // 50 micron 
171   Float_t spdladder_dz     = 0.0010/5.; // 10 micron
172   Float_t spdladder_dpsi   = 0.0001*kRadToDeg/5.; // 0.1 mrad
173   Float_t spdladder_dtheta = 0.0001*kRadToDeg/5.; // 0.1 mrad
174   Float_t spdladder_dphi   = 0.0001*kRadToDeg/5.; // 0.1 mrad
175
176   Float_t sddmodule_dx     = 0.0045/5.; // 45 micron  
177   Float_t sddmodule_dy     = 0.0045/5.; // 45 micron 
178   Float_t sddmodule_dz     = 0.0105/5.; // 105 micron
179   Float_t sddmodule_dpsi   = 0.00; // ?
180   Float_t sddmodule_dtheta = 0.00; //  ?
181   Float_t sddmodule_dphi   = 0.00; //  ?
182
183   Float_t ssdmodule_dx     = 0.0050/5.; // 50 micron  
184   Float_t ssdmodule_dy     = 0.0050/5.; // 50 micron 
185   Float_t ssdmodule_dz     = 0.0050/5.; // 50 micron
186   Float_t ssdmodule_dpsi   = 0.00; // ?
187   Float_t ssdmodule_dtheta = 0.00; //  ?
188   Float_t ssdmodule_dphi   = 0.00; //  ?
189   //
190   // END SETTINGS
191
192   AliITSMisalignMaker alignMaker;
193
194   //=****************************************
195   // overall ITS misalignment :
196   //=****************************************
197
198   alignMaker.AddAlignObj("ITS",its_dx,its_dy,its_dz,its_dpsi,its_dtheta,its_dphi,unifits);
199
200
201   //=****************************************
202   // misalignment at the level of SPD barrel, half-barrels, and at the level
203   // of SPD sectors
204   //=****************************************
205
206   Double_t vx,vy,vz,vpsi,vtheta,vphi;
207   Double_t vxbarrel,vybarrel,vzbarrel,vpsibarrel,vthetabarrel,vphibarrel;
208
209   //   barrel
210   vxbarrel = AliMathBase::TruncatedGaus(0.,spdbarrel_dx/3,spdbarrel_dx);
211   vxbarrel = AliMathBase::TruncatedGaus(0,spdbarrel_dx/3,spdbarrel_dx);
212   vybarrel = AliMathBase::TruncatedGaus(0,spdbarrel_dy/3,spdbarrel_dy);
213   vzbarrel = AliMathBase::TruncatedGaus(0,spdbarrel_dz/3,spdbarrel_dz);
214   vpsibarrel = AliMathBase::TruncatedGaus(0,spdbarrel_dpsi/3,spdbarrel_dpsi);
215   vthetabarrel = AliMathBase::TruncatedGaus(0,spdbarrel_dtheta/3,spdbarrel_dtheta);
216   vphibarrel = AliMathBase::TruncatedGaus(0,spdbarrel_dphi/3,spdbarrel_dphi);
217
218   //  top half-barrel
219   vx = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dx/3,spdhalfbarrel_dx);
220   vy = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dy/3,spdhalfbarrel_dy);
221   vz = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dz/3,spdhalfbarrel_dz);
222   vpsi = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dpsi/3,spdhalfbarrel_dpsi);
223   vtheta = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dtheta/3,spdhalfbarrel_dtheta);
224   vphi = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dphi/3,spdhalfbarrel_dphi);
225
226   vx += vxbarrel;
227   vy += vybarrel;
228   vz += vzbarrel;
229   vpsi += vpsibarrel;
230   vtheta += vthetabarrel;
231   vphi += vphibarrel;
232
233   alignMaker.AddSectorAlignObj(1,5,spdsector_dx,spdsector_dy,spdsector_dz,
234                                spdsector_dpsi,spdsector_dtheta,spdsector_dphi,
235                                vx,vy,vz,vpsi,vtheta,vphi,unifspdsector);
236
237   //  bottom half-barrel
238   vx = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dx/3,spdhalfbarrel_dx);
239   vy = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dy/3,spdhalfbarrel_dy);
240   vz = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dz/3,spdhalfbarrel_dz);
241   vpsi = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dpsi/3,spdhalfbarrel_dpsi);
242   vtheta = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dtheta/3,spdhalfbarrel_dtheta);
243   vphi = AliMathBase::TruncatedGaus(0,spdhalfbarrel_dphi/3,spdhalfbarrel_dphi);
244
245   vx += vxbarrel;
246   vy += vybarrel;
247   vz += vzbarrel;
248   vpsi += vpsibarrel;
249   vtheta += vthetabarrel;
250   vphi += vphibarrel;
251
252   alignMaker.AddSectorAlignObj(6,10,spdsector_dx,spdsector_dy,spdsector_dz,
253                                spdsector_dpsi,spdsector_dtheta,spdsector_dphi,
254                                vx,vy,vz,vpsi,vtheta,vphi,unifspdsector);
255
256
257   //=****************************************
258   // misalignment at the level of half-staves (SPD)/ladders (SDD,SSD) :
259   //=****************************************
260
261   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
262   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
263
264   alignMaker.AddAlignObj(2,-1,sddladder_dx,sddladder_dy,sddladder_dz,sddladder_dpsi,sddladder_dtheta,sddladder_dphi,0,0,0,0,0,0,kFALSE); // all SDD1 ladders
265   alignMaker.AddAlignObj(3,-1,sddladder_dx,sddladder_dy,sddladder_dz,sddladder_dpsi,sddladder_dtheta,sddladder_dphi,0,0,0,0,0,0,kFALSE); // all SDD2 ladders
266
267   alignMaker.AddAlignObj(4,-1,ssdladder_dx,ssdladder_dy,ssdladder_dz,ssdladder_dpsi,ssdladder_dtheta,ssdladder_dphi,0,0,0,0,0,0,kFALSE); // all SSD1 ladders
268   alignMaker.AddAlignObj(5,-1,ssdladder_dx,ssdladder_dy,ssdladder_dz,ssdladder_dpsi,ssdladder_dtheta,ssdladder_dphi,0,0,0,0,0,0,kFALSE); // all SSD2 ladders
269
270   //=****************************************
271   // misalignment at the level of ladders (SPD)/modules (SDD,SSD) :
272   //=****************************************
273
274   alignMaker.AddAlignObj(0,spdladder_dx,spdladder_dy,spdladder_dz,spdladder_dpsi,spdladder_dtheta,spdladder_dphi,kFALSE); // all SPD1 ladders
275   alignMaker.AddAlignObj(1,spdladder_dx,spdladder_dy,spdladder_dz,spdladder_dpsi,spdladder_dtheta,spdladder_dphi,kFALSE); // all SPD2 ladders
276
277   alignMaker.AddAlignObj(2,sddmodule_dx,sddmodule_dy,sddmodule_dz,sddmodule_dpsi,sddmodule_dtheta,sddmodule_dphi,kFALSE); // all SDD1 modules
278   alignMaker.AddAlignObj(3,sddmodule_dx,sddmodule_dy,sddmodule_dz,sddmodule_dpsi,sddmodule_dtheta,sddmodule_dphi,kFALSE); // all SDD2 modules
279
280   alignMaker.AddAlignObj(4,ssdmodule_dx,ssdmodule_dy,ssdmodule_dz,ssdmodule_dpsi,ssdmodule_dtheta,ssdmodule_dphi,kFALSE); // all SSD1 modules
281   alignMaker.AddAlignObj(5,ssdmodule_dx,ssdmodule_dy,ssdmodule_dz,ssdmodule_dpsi,ssdmodule_dtheta,ssdmodule_dphi,kFALSE); // all SSD2 modules
282
283
284   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
285     // save on file
286     const char* filename = "ITSresidualMisalignment.root";
287     TFile f(filename,"RECREATE");
288     if(!f.IsOpen()){
289       Error(macroname,"cannot open file for output\n");
290       return;
291     }
292     Info(macroname,"Saving alignment objects to the file %s",filename);
293     f.cd();
294     f.WriteObject(alignMaker.GetArray(),"ITSAlignObjs","kSingleKey");
295     f.Close();
296   }else{
297     // save in CDB storage
298     AliCDBMetaData *md= new AliCDBMetaData();
299     md->SetResponsible("Andrea Dainese");
300     md->SetComment("Alignment objects with residual ITS misalignment");
301     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
302     AliCDBId id("ITS/Align/Data",0,AliCDBRunRange::Infinity());
303     storage->Put(alignMaker.GetArray(),id,md);
304   }
305
306
307   return;
308 }
309