Full set of updated misalignment macros (Raffaele)
[u/mrichter/AliRoot.git] / ITS / MakeITSFullMisAlignment.C
CommitLineData
1895a097 1void MakeITSFullMisAlignment(){
2 // Create TClonesArray of full misalignment objects for ITS
3 //
4 TClonesArray *array = new TClonesArray("AliAlignObjAngles",4000);
5 TClonesArray &alobj = *array;
6
7 if(!gGeoManager) TGeoManager::Import("geometry.root");
8 // needed for the constructors with local coordinates not to fail
9
a2de6586 10 Double_t globalZ = 0.015; // in cm, = 150 microns
11 Double_t mecanicalPrec = 0.0020;
12
13 Double_t resFact = 0.;
1895a097 14 Double_t spdXY = 0.0015*resFact;
15 Double_t sddXYZ = 0.0030*resFact;
16 Double_t ssdXY = 0.0020*resFact;
17 Double_t rot = 0.018;
18
19 Double_t spdZ = 0.002;
20 Double_t ssdZ = 0.010;
21
a2de6586 22
1895a097 23 TRandom *rnd = new TRandom(65416087);
24 AliAlignObjAngles a;
25
26 Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
27
28 Int_t j = 0;
a2de6586 29 new(alobj[j++]) AliAlignObjAngles("ITS", 0, dx, dy, globalZ, dpsi, dtheta, dphi, kTRUE);
d3a9c52a 30 AliAlignObjAngles* its_alobj = (AliAlignObjAngles*) array->UncheckedAt(0);
31 its_alobj->ApplyToGeometry();
1895a097 32
33 for ( Int_t l = AliAlignObj::kSPD1; l <= AliAlignObj::kSSD2; l++) {
34
35 printf("%i modules in layer %i\n", AliAlignObj::LayerSize(l), l);
36 for (Int_t iModule = 0; iModule < AliAlignObj::LayerSize(l); iModule++) {
37
38 dpsi = rnd->Gaus(0., rot);
39 dtheta = rnd->Gaus(0., rot);
40 dphi = rnd->Gaus(0., rot);
41
42 AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
43 switch (l) {
44 case 1: {
45 iLayer = AliAlignObj::kSPD1;
a2de6586 46 dx = rnd->Gaus(0., spdXY + mecanicalPrec);
47 dy = rnd->Gaus(0., spdXY + mecanicalPrec);
48 dz = rnd->Gaus(0., spdZ + mecanicalPrec);
1895a097 49 }; break;
50 case 2: {
51 iLayer = AliAlignObj::kSPD2;
a2de6586 52 dx = rnd->Gaus(0., spdXY + mecanicalPrec);
53 dy = rnd->Gaus(0., spdXY + mecanicalPrec);
54 dz = rnd->Gaus(0., spdZ + mecanicalPrec);
1895a097 55 }; break;
56 case 3: {
57 iLayer = AliAlignObj::kSDD1;
a2de6586 58 dx = rnd->Gaus(0., sddXYZ + mecanicalPrec);
59 dy = rnd->Gaus(0., sddXYZ + mecanicalPrec);
60 dz = rnd->Gaus(0., sddXYZ + mecanicalPrec);
1895a097 61 }; break;
62 case 4: {
63 iLayer = AliAlignObj::kSDD2;
a2de6586 64 dx = rnd->Gaus(0., sddXYZ + mecanicalPrec);
65 dy = rnd->Gaus(0., sddXYZ + mecanicalPrec);
66 dz = rnd->Gaus(0., sddXYZ + mecanicalPrec);
1895a097 67 }; break;
68 case 5: {
69 iLayer = AliAlignObj::kSSD1;
a2de6586 70 dx = rnd->Gaus(0., ssdXY + mecanicalPrec);
71 dy = rnd->Gaus(0., ssdXY + mecanicalPrec);
72 dz = rnd->Gaus(0., ssdZ + mecanicalPrec);
1895a097 73 }; break;
74 case 6: {
75 iLayer = AliAlignObj::kSSD2;
a2de6586 76 dx = rnd->Gaus(0., ssdXY + mecanicalPrec);
77 dy = rnd->Gaus(0., ssdXY + mecanicalPrec);
78 dz = rnd->Gaus(0., ssdZ + mecanicalPrec);
1895a097 79 }; break;
80 default: Printf("Wrong layer index in ITS (%d) !",l);
81 };
82 UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iModule);
7e154d52 83 const char *symname = AliAlignObj::SymName(volid);
1895a097 84
a2de6586 85 new(alobj[j++]) AliAlignObjAngles(symname, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
1895a097 86
87 }
88 }
89
90 if(!gSystem->Getenv("$TOCDB")){
91 // save on file
92 TFile f("ITSfullMisalignment.root","RECREATE");
93 if(!f) {cerr<<"cannot open file for output\n";}
94 f.WriteObject(array,"ITSAlignObjs","kSingleKey");
95 f.Close();
96 }else{
97 // save in CDB storage
98 const char* Storage = gSystem->Getenv("$STORAGE");
99 AliCDBManager *CDB = AliCDBManager::Instance();
100 AliCDBStorage* storage = CDB->GetStorage(Storage);
101 AliCDBMetaData *md= new AliCDBMetaData();
102 md->SetResponsible("Ludovic Gaudichet");
103 md->SetComment("Alignment objects with actual ITS misalignment");
104 md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
105 AliCDBId id("ITS/Align/Data",0,9999999);
106 storage->Put(array,id, md);
107 }
108
109 array->Delete();
110
111}
112
113
a2de6586 114