1 void MakePMDResMisAlignment(){
2 // Create TClonesArray of residual misalignment objects for PMD
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
17 // Now specify the path of the module to be misaligned
18 // as followed in the PMD geant
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
37 const char* macroname = "MakePMDResMisAlignment.C";
39 // Activate CDB storage and load geometry from CDB
40 AliCDBManager* cdb = AliCDBManager::Instance();
41 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
44 AliCDBStorage* storage;
46 if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
47 TString Storage = gSystem->Getenv("STORAGE");
48 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
49 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
52 storage = cdb->GetStorage(Storage.Data());
54 Error(macroname,"Unable to open storage %s\n",Storage.Data());
57 AliCDBPath path("GRP","Geometry","Data");
58 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
59 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
61 TGeoManager* geom = (TGeoManager*) entry->GetObject();
62 AliGeomManager::SetGeometry(geom);
64 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
67 Float_t max_trans=0.1;
70 const char *Sector1="PMD/Sector1";
71 const char *Sector2="PMD/Sector2";
72 const char *Sector3="PMD/Sector3";
73 const char *Sector4="PMD/Sector4";
77 Double_t dx14, dy14, dz14; // Misalignment in X,Y and Z
78 Double_t dpsi14, dtheta14, dphi14; // Angular displacements
80 Double_t dx23, dy23, dz23; // Misalignment in X,Y and Z
81 Double_t dpsi23, dtheta23, dphi23; // Angular displacements
85 // At present give some random shifts
86 // generated by random numbers
87 // max_trans : Maximun shifts in X,Y,Z in centimeters
88 // max_rot : Maximum shifts in angles in degrees
89 // Double_t max_trans, max_rot;
92 TRandom *rnd = new TRandom(4357);
94 // For sectors 1 and 4
95 // Translation displacement
96 dx14 = (rnd->Uniform()-0.5)*max_trans;
97 dy14 = (rnd->Uniform()-0.5)*max_trans;
98 dz14 = (rnd->Uniform()-0.5)*max_trans;
100 dpsi14 = (rnd->Uniform()-0.5)*max_rot;
101 dtheta14 = (rnd->Uniform()-0.5)*max_rot;
102 dphi14 = (rnd->Uniform()-0.5)*max_rot;
104 // For sectors 2 and 3
105 // Translation displacement
106 dx23 = (rnd->Uniform()-0.5)*max_trans;
107 dy23 = (rnd->Uniform()-0.5)*max_trans;
108 dz23 = (rnd->Uniform()-0.5)*max_trans;
110 dpsi23 = (rnd->Uniform()-0.5)*max_rot;
111 dtheta23 = (rnd->Uniform()-0.5)*max_rot;
112 dphi23 = (rnd->Uniform()-0.5)*max_rot;
115 //Create a TClonesArray of Align Object to store displacement Angles
116 TClonesArray *array = new TClonesArray("AliAlignObjParams",10);
117 TClonesArray &alobj = *array;
119 Int_t iIndex=0; // let all modules have index=0 in a layer with no LUT
120 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
121 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
123 new(alobj[0]) AliAlignObjParams(Sector1, volid, dx14, dy14, dz14, dpsi14, dtheta14, dphi14, kFALSE);
124 new(alobj[1]) AliAlignObjParams(Sector2, volid, dx14, dy14, dz14, dpsi14, dtheta14, dphi14, kFALSE);
125 new(alobj[2]) AliAlignObjParams(Sector3, volid, dx23, dy23, dz23, dpsi23, dtheta23, dphi23, kFALSE);
126 new(alobj[3]) AliAlignObjParams(Sector4, volid, dx23, dy23, dz23, dpsi23, dtheta23, dphi23, kFALSE);
128 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
129 // Create a File to store the alignment data
130 const char* filename = "PMDresidualMisalignment.root";
131 TFile f(filename,"RECREATE");
133 Error(macroname,"cannot open file for output\n");
136 Info(macroname,"Saving alignment objects to the file %s", filename);
138 f.WriteObject(array,"PMDAlignObjs","kSingleKey");
141 // save in CDB storage
142 AliCDBMetaData* md = new AliCDBMetaData();
143 md->SetResponsible("");
144 md->SetComment("Residual misalignment for PMD, produced with sigmatr=0.1 and sigmarot=0.1 in the local RS");
145 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
146 AliCDBId id("PMD/Align/Data",0,AliCDBRunRange::Infinity());
147 storage->Put(array,id,md);