Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / PHOS / MakePHOSFullMisAlignment.C
CommitLineData
79ba47c3 1void MakePHOSFullMisAlignment()
2{
6d16ed75 3 // Create misalignment object for PHOS module 2,3,3
4 // from the survey measurements on P2 in August 2009.
79ba47c3 5 // To store alignment in OCDB, define the evnironment variables:
6 // TOCDB=kTRUE
162637e4 7 // STORAGE="local://$ALICE_ROOT/OCDB"
79ba47c3 8 // Author: Timur Pocheptsov, 19.06.2008
6d16ed75 9 // Modified: Yuri Kharlov, 11.03.2010
79ba47c3 10
11 const char * macroName = "MakePHOS2Alignment";
12
3c759505 13 const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
14 if (!phosGeom) {
79ba47c3 15 Error(macroName, "Cannot obtain AliPHOSGeometry singleton.\n");
3c759505 16 return;
17 }
18
79ba47c3 19 AliPHOSEMCAGeometry * emca = phosGeom->GetEMCAGeometry();
d7c519b2 20 TClonesArray alobj("AliAlignObjParams", 16);// + phosGeom->GetNModules() * emca->GetNStripX() *
21 // emca->GetNStripZ());
22
79ba47c3 23 const Double_t dpsi = 0., dtheta = 0., dphi = 0.;
24 const Double_t displacement = 10.;
25 Int_t iIndex = 0; //let all modules have index=0 in a layer with no LUT
26 const AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
27 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer, iIndex);
28 Int_t i = 0;
1895a097 29
30 // Alignment for 5 PHOS modules
79ba47c3 31
d7c519b2 32 TString surveyFileName;
79ba47c3 33
d7c519b2 34 const Char_t * szEnv = gSystem->Getenv("ALICE_ROOT");
35 if (szEnv && szEnv[0]) {
36 surveyFileName += szEnv;
37 if (surveyFileName[surveyFileName.Length() - 1] != '/')
38 surveyFileName += '/';
39 } else {
40 Warning(macroName, "cannot find ALICE_ROOT environment variable\n"
41 "probably, I wan't be able to find survey file");
42 }
43
6d16ed75 44 surveyFileName += "PHOS/data/Survey_1053236_PHOS.txt";
d7c519b2 45
d7c519b2 46 AliSurveyObj survey;
47 survey.FillFromLocalFile(surveyFileName.Data());
6d16ed75 48 TGeoHMatrix module3Delta, module2Delta, module1Delta;
d7c519b2 49 AliPHOSModuleMisalignment delta(*phosGeom);
6d16ed75 50
51 delta.DeltaTransformation(0, survey.GetData(), "410000", "410027", "424000",
52 &module1Delta);
53 new(alobj[i++]) AliAlignObjParams("PHOS/Module1", volid, module1Delta, kTRUE);
54
55 delta.DeltaTransformation(1, survey.GetData(), "310000", "310027", "324000",
56 &module2Delta);
57 new(alobj[i++]) AliAlignObjParams("PHOS/Module2", volid, module2Delta, kTRUE);
58
59 delta.DeltaTransformation(2, survey.GetData(), "210000", "210027", "224000",
d7c519b2 60 &module3Delta);
61 new(alobj[i++]) AliAlignObjParams("PHOS/Module3", volid, module3Delta, kTRUE);
6d16ed75 62
63 new(alobj[i++]) AliAlignObjParams("PHOS/Module4", volid, 0., 0., 0., 0., 0., 0., kTRUE);
64
d7c519b2 65 new(alobj[i++]) AliAlignObjParams("PHOS/Module5", volid, 0., 0., 0., 0., 0., 0., kTRUE);
1895a097 66
79ba47c3 67 const Double_t dx = 0., dy = 0., dz = 0. ;
a45bb6dc 68 // Alignment of CPV modules
90dbf5fb 69 new(alobj[i++]) AliAlignObjParams("PHOS/Module1/CPV",
a45bb6dc 70 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 71 new(alobj[i++]) AliAlignObjParams("PHOS/Module2/CPV",
a45bb6dc 72 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 73 new(alobj[i++]) AliAlignObjParams("PHOS/Module3/CPV",
a45bb6dc 74 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 75 new(alobj[i++]) AliAlignObjParams("PHOS/Module4/CPV",
a45bb6dc 76 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 77 new(alobj[i++]) AliAlignObjParams("PHOS/Module5/CPV",
a45bb6dc 78 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
79
1895a097 80 // Alignment for PHOS cradle
90dbf5fb 81 new(alobj[i++]) AliAlignObjParams("PHOS/Cradle0",
1895a097 82 volid, 0., 0., -displacement, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 83 new(alobj[i++]) AliAlignObjParams("PHOS/Cradle1",
1895a097 84 volid, 0., 0., +displacement, dpsi, dtheta, dphi, kTRUE);
85
86 // Alignment for cradle wheels
90dbf5fb 87 new(alobj[i++]) AliAlignObjParams("PHOS/Wheel0",
1895a097 88 volid, 0., 0., -displacement, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 89 new(alobj[i++]) AliAlignObjParams("PHOS/Wheel1",
1895a097 90 volid, 0., 0., -displacement, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 91 new(alobj[i++]) AliAlignObjParams("PHOS/Wheel2",
1895a097 92 volid, 0., 0., +displacement, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 93 new(alobj[i++]) AliAlignObjParams("PHOS/Wheel3",
1895a097 94 volid, 0., 0., +displacement, dpsi, dtheta, dphi, kTRUE);
95
96 // ************************* 2nd step ***************
79ba47c3 97 if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
1895a097 98 // save on file
79ba47c3 99 const char * fileName = "PHOSfullMisalignment.root";
100 TFile f(fileName,"RECREATE");
101 if (!f) {
102 Error(macroName, "cannot open file for output\n");
dfe9c69d 103 return;
104 }
79ba47c3 105
106 Info(macroName,"Saving alignment objects to the file %s", fileName);
1895a097 107 f.cd();
79ba47c3 108 f.WriteObject(&alobj,"PHOSAlignObjs","kSingleKey");
1895a097 109 f.Close();
110 }else{
111 // save in CDB storage
79ba47c3 112 TString storageENV = gSystem->Getenv("STORAGE");
113 if(!storageENV.BeginsWith("local://") && !storageENV.BeginsWith("alien://")) {
114 Error(macroName,"STORAGE variable set to %s is not valid. Exiting\n", storageENV.Data());
dfe9c69d 115 return;
116 }
79ba47c3 117
118 Info(macroName,"Saving alignment objects in CDB storage %s", storageENV.Data());
119 AliCDBManager * cdb = AliCDBManager::Instance();
120 AliCDBStorage * storage = cdb->GetStorage(storageENV.Data());
121 if (!storage) {
122 Error(macroName, "Unable to open storage %s\n", storageENV.Data());
dfe9c69d 123 return;
124 }
79ba47c3 125
126 AliCDBMetaData md;
4c5cf843 127 md.SetResponsible("Yuri Kharlov");
128 md.SetComment("Alignment objects for PHOS modules 2,3,4; survey in August 2009");
79ba47c3 129 md.SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 130 AliCDBId id("PHOS/Align/Data",0,AliCDBRunRange::Infinity());
79ba47c3 131 storage->Put(&alobj, id, &md);
1895a097 132 }
133
79ba47c3 134 alobj.Delete();
1895a097 135}