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