Extacting the OCDB in a separate module. The detectors have write permission in the...
[u/mrichter/AliRoot.git] / PHOS / macros / AlignmentDB / MakePHOSAlignmentModule2.C
CommitLineData
13fcd0bb 1void MakePHOSAlignmentModule2()\r
2{\r
3 // Create misalignment object for PHOS module 2 \r
4 // from the survey measurements on P2 in May 2008.\r
5 // To store alignment in OCDB, define the evnironment variables:\r
6 // TOCDB=kTRUE\r
162637e4 7 // STORAGE="local://$ALICE_ROOT/OCDB"\r
13fcd0bb 8 // Author: Timur Pocheptsov, 19.06.2008\r
9\r
10 const char * macroName = "MakePHOS2Alignment";\r
11 \r
12 const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");\r
13 if (!phosGeom) {\r
14 Error(macroName, "Cannot obtain AliPHOSGeometry singleton.\n");\r
15 return;\r
16 }\r
17\r
18 //Activate CDB storage and load geometry from CDB\r
19 //I need valid gGeoManager to create local transformations.\r
20 \r
21 //[Part of code, taken from ITS version of MakexxxFullMisalignment\r
22 AliCDBManager * cdb = AliCDBManager::Instance();\r
23 if (!cdb->IsDefaultStorageSet())\r
162637e4 24 cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");\r
13fcd0bb 25 cdb->SetRun(0);\r
26\r
27 if (TString(gSystem->Getenv("TOCDB")) == TString("kTRUE")) {\r
28 const TString storageENV(gSystem->Getenv("STORAGE"));\r
29 if (!storageENV.BeginsWith("local://") && !storageENV.BeginsWith("alien://")) {\r
30 Error(macroName, "STORAGE variable set to %s is not valid.\n", storageENV.Data());\r
31 return;\r
32 }\r
33 \r
34 AliCDBStorage * storage = cdb->GetStorage(storageENV.Data());\r
35 if (!storage) {\r
36 Error(macroName, "Unable to open storage %s.\n", storageENV.Data());\r
37 return;\r
38 }\r
39 \r
40 AliCDBPath path("GRP","Geometry","Data");\r
41 AliCDBEntry * entry = storage->Get(path.GetPath(), cdb->GetRun());\r
42 if (!entry) {\r
43 Error(macroName,"Could not get the specified CDB entry!");\r
44 return; \r
45 }\r
46 \r
47 entry->SetOwner(0);\r
48 AliGeomManager::SetGeometry((TGeoManager*) entry->GetObject());\r
49 }else{\r
50 AliGeomManager::LoadGeometry("geometry.root"); //load geom from default CDB storage\r
51 } \r
52 //end of code taken from ITS version of MakexxxFullMisalignment]\r
53\r
54 AliPHOSEMCAGeometry * emca = phosGeom->GetEMCAGeometry();\r
55 TClonesArray alobj("AliAlignObjParams", 16);// + phosGeom->GetNModules() * emca->GetNStripX() * emca->GetNStripZ());\r
56 \r
57 const Double_t dpsi = 0., dtheta = 0., dphi = 0.;\r
58 const Double_t displacement = 10.;\r
59 Int_t iIndex = 0; //let all modules have index=0 in a layer with no LUT\r
60 const AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;\r
61 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer, iIndex);\r
62 Int_t i = 0;\r
63\r
64 // Alignment for 5 PHOS modules\r
65\r
66 new(alobj[i++]) AliAlignObjParams("PHOS/Module1",\r
67 volid, 0., 0., 0., 0., 0., 0., kTRUE);\r
68 new(alobj[i++]) AliAlignObjParams("PHOS/Module2",\r
69 volid, 0., 0., 0., 0., 0., 0., kTRUE);\r
70\r
71 Double_t rotMatrix[9] = {0.999992695, -0.00295322, -0.0024267, \r
72 0.002955489, 0.999995199, 0.00093165, \r
73 0.002423942, -0.000938811, 0.99999662};\r
74 TGeoRotation rotation;\r
75 rotation.SetMatrix(rotMatrix);\r
76 Double_t dX=1.25474126, dY=-1.4088643, dZ=-12.856;\r
77 AliAlignObjParams * mod3 = \r
78 new(alobj[i++]) AliAlignObjParams("PHOS/Module3", volid, dX, dY, dZ, 0., 0., 0., kFALSE);\r
79 mod3->SetRotation(rotation);\r
80 \r
81 new(alobj[i++]) AliAlignObjParams("PHOS/Module4",\r
82 volid, 0., 0., 0., 0., 0., 0., kTRUE);\r
83 new(alobj[i++]) AliAlignObjParams("PHOS/Module5",\r
84 volid, 0., 0., 0., 0., 0., 0., kTRUE);\r
85\r
86 const Double_t dx = 0., dy = 0., dz = 0. ;\r
87 // Alignment of CPV modules\r
88 new(alobj[i++]) AliAlignObjParams("PHOS/Module1/CPV",\r
89 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);\r
90 new(alobj[i++]) AliAlignObjParams("PHOS/Module2/CPV",\r
91 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);\r
92 new(alobj[i++]) AliAlignObjParams("PHOS/Module3/CPV",\r
93 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);\r
94 new(alobj[i++]) AliAlignObjParams("PHOS/Module4/CPV",\r
95 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);\r
96 new(alobj[i++]) AliAlignObjParams("PHOS/Module5/CPV",\r
97 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);\r
98 \r
99 // Alignment for PHOS cradle\r
100 new(alobj[i++]) AliAlignObjParams("PHOS/Cradle0",\r
101 volid, 0., 0., -displacement, dpsi, dtheta, dphi, kTRUE);\r
102 new(alobj[i++]) AliAlignObjParams("PHOS/Cradle1",\r
103 volid, 0., 0., +displacement, dpsi, dtheta, dphi, kTRUE);\r
104\r
105 // Alignment for cradle wheels\r
106 new(alobj[i++]) AliAlignObjParams("PHOS/Wheel0",\r
107 volid, 0., 0., -displacement, dpsi, dtheta, dphi, kTRUE);\r
108 new(alobj[i++]) AliAlignObjParams("PHOS/Wheel1",\r
109 volid, 0., 0., -displacement, dpsi, dtheta, dphi, kTRUE);\r
110 new(alobj[i++]) AliAlignObjParams("PHOS/Wheel2",\r
111 volid, 0., 0., +displacement, dpsi, dtheta, dphi, kTRUE);\r
112 new(alobj[i++]) AliAlignObjParams("PHOS/Wheel3",\r
113 volid, 0., 0., +displacement, dpsi, dtheta, dphi, kTRUE);\r
114\r
115 // ************************* 2nd step ***************\r
116 if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {\r
117 // save on file\r
118 const char * fileName = "PHOSfullMisalignment.root";\r
119 TFile f(fileName,"RECREATE");\r
120 if (!f) {\r
121 Error(macroName, "cannot open file for output\n");\r
122 return;\r
123 }\r
124 \r
125 Info(macroName,"Saving alignment objects to the file %s", fileName);\r
126 f.cd();\r
127 f.WriteObject(&alobj,"PHOSAlignObjs","kSingleKey");\r
128 f.Close();\r
129 }else{\r
130 // save in CDB storage\r
131 TString storageENV = gSystem->Getenv("STORAGE");\r
132 if(!storageENV.BeginsWith("local://") && !storageENV.BeginsWith("alien://")) {\r
133 Error(macroName,"STORAGE variable set to %s is not valid. Exiting\n", storageENV.Data());\r
134 return;\r
135 }\r
136 \r
137 Info(macroName,"Saving alignment objects in CDB storage %s", storageENV.Data());\r
138 AliCDBManager * cdb = AliCDBManager::Instance();\r
139 AliCDBStorage * storage = cdb->GetStorage(storageENV.Data());\r
140 if (!storage) {\r
141 Error(macroName, "Unable to open storage %s\n", storageENV.Data());\r
142 return;\r
143 }\r
144 \r
145 AliCDBMetaData md;\r
146 md.SetResponsible("Timur Pocheptsov");\r
147 md.SetComment("Alignment objects for PHOS module 2; survey in May 2008");\r
148 md.SetAliRootVersion(gSystem->Getenv("ARVERSION"));\r
149 AliCDBId id("PHOS/Align/Data",0,AliCDBRunRange::Infinity());\r
150 storage->Put(&alobj, id, &md);\r
151 }\r
152\r
153 alobj.Delete();\r
154}\r