Using AliGeomManager in the macros (Raffaele)
[u/mrichter/AliRoot.git] / PMD / MakePMDFullMisAlignment.C
CommitLineData
1895a097 1void MakePMDFullMisAlignment(){
2 // Create TClonesArray of full misalignment objects for PMD
3 //
4
5 // Macro to randomly displace the 4 sectors of the PMD
6 // in each plane. Each sector (to be misaligned)
7 // of PMD houses the following :
8 // (a) 6 modules of preshower plane
9 // (b) 6 modules of veto plane
10 // (c) The FEE boards on back plane of each module
11 // (d) 6 modules of convertor plates
12 // The clustering is done module-wise
13 // The actual amount displacement will be provided
14 // by the survey data and has to be converted into
15 // displacement in x,y,z,theta, phi and psi
16
17
18 // Now specify the path of the module to be misaligned
19 // as followed in the PMD geant
20
21 /*
22 _____________
23 | | |
24 | 1 | 3 |
25 | |________|
26 |____|___| |
27 | | 2 |
28 | 4 | |
29 |________|____|
30
31 // Misalignment Matrix is expected to be
32 // same for sectors 1 and 4
33 // and for the sectors 2 and 3
34 // As these will be mounted on the same
35 // Steel plate
36 */
37
dfe9c69d 38 if(!AliGeomManager::GetGeometry()){
39 if(!(AliCDBManager::Instance())->IsDefaultStorageSet())
40 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
41 AliCDBManager::Instance()->SetRun(0);
42 AliGeomManager::LoadGeometry();
43 }
1895a097 44 // needed for the constructors with local coordinates not to fail
45
46 Float_t max_trans=0.1;
47 Float_t max_rot=0.1;
48
49 TString path;
d3a9c52a 50 const char *Sector1="PMD/Sector1";
51 const char *Sector2="PMD/Sector2";
52 const char *Sector3="PMD/Sector3";
53 const char *Sector4="PMD/Sector4";
1895a097 54
55
56 //Sectors 1 and 4
57 Double_t dx14, dy14, dz14; // Misalignment in X,Y and Z
58 Double_t dpsi14, dtheta14, dphi14; // Angular displacements
59 //Sectors 2 and 3
60 Double_t dx23, dy23, dz23; // Misalignment in X,Y and Z
61 Double_t dpsi23, dtheta23, dphi23; // Angular displacements
62
63
64
65 // At present give some random shifts
66 // generated by random numbers
67 // max_trans : Maximun shifts in X,Y,Z in centimeters
68 // max_rot : Maximum shifts in angles in degrees
69 // Double_t max_trans, max_rot;
70
71
72 TRandom *rnd = new TRandom(4357);
73
74 // For sectors 1 and 4
75 // Translation displacement
76 dx14 = (rnd->Uniform()-0.5)*max_trans;
77 dy14 = (rnd->Uniform()-0.5)*max_trans;
78 dz14 = (rnd->Uniform()-0.5)*max_trans;
79 //Rotation angles
80 dpsi14 = (rnd->Uniform()-0.5)*max_rot;
81 dtheta14 = (rnd->Uniform()-0.5)*max_rot;
82 dphi14 = (rnd->Uniform()-0.5)*max_rot;
83
84 // For sectors 2 and 3
85 // Translation displacement
86 dx23 = (rnd->Uniform()-0.5)*max_trans;
87 dy23 = (rnd->Uniform()-0.5)*max_trans;
88 dz23 = (rnd->Uniform()-0.5)*max_trans;
89 //Rotation angles
90 dpsi23 = (rnd->Uniform()-0.5)*max_rot;
91 dtheta23 = (rnd->Uniform()-0.5)*max_rot;
92 dphi23 = (rnd->Uniform()-0.5)*max_rot;
93
94
95 //Create a TClonesArray of Align Object to store displacement Angles
96 TClonesArray *array = new TClonesArray("AliAlignObjAngles",10);
97 TClonesArray &alobj = *array;
98
99 AliAlignObjAngles o;
100
101 Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
ae079791 102 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
103 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
1895a097 104
105 new(alobj[0]) AliAlignObjAngles(Sector1, volid, dx14, dy14, dz14, dpsi14, dtheta14, dphi14, kFALSE);
106 new(alobj[1]) AliAlignObjAngles(Sector2, volid, dx14, dy14, dz14, dpsi14, dtheta14, dphi14, kFALSE);
107 new(alobj[2]) AliAlignObjAngles(Sector3, volid, dx23, dy23, dz23, dpsi23, dtheta23, dphi23, kFALSE);
108 new(alobj[3]) AliAlignObjAngles(Sector4, volid, dx23, dy23, dz23, dpsi23, dtheta23, dphi23, kFALSE);
109
dfe9c69d 110 const char* macroname = "MakePMDFullMisAlignment.C";
5bd470e1 111 if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
1895a097 112 // Create a File to store the alignment data
dfe9c69d 113 const char* filename = "PMDfullMisalignment.root";
114 TFile f(filename,"RECREATE");
115 if(!f){
116 Error(macroname,"cannot open file for output\n");
117 return;
118 }
119 Info(macroname,"Saving alignment objects to the file %s", filename);
1895a097 120 f.cd();
dfe9c69d 121 f.WriteObject(array,"PMDAlignObjs","kSingleKey");
1895a097 122 f.Close();
123 }else{
124 // save in CDB storage
dfe9c69d 125 TString Storage = gSystem->Getenv("STORAGE");
126 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
127 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
128 return;
129 }
130 Info(macroname,"Saving alignment objects in CDB storage %s",
131 Storage.Data());
1895a097 132 AliCDBManager* cdb = AliCDBManager::Instance();
dfe9c69d 133 AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
134 if(!storage){
135 Error(macroname,"Unable to open storage %s\n",Storage.Data());
136 return;
137 }
1895a097 138 AliCDBMetaData* md = new AliCDBMetaData();
139 md->SetResponsible("");
140 md->SetComment("Full misalignment for PMD, produced with sigmatr=0.1 and sigmarot=0.1 in the local RS");
5bd470e1 141 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 142 AliCDBId id("PMD/Align/Data",0,AliCDBRunRange::Infinity());
1895a097 143 storage->Put(array,id,md);
144 }
145 array->Delete();
146
147}