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