Extacting the OCDB in a separate module. The detectors have write permission in the...
[u/mrichter/AliRoot.git] / PHOS / MakePHOSFullMisAlignment.C
CommitLineData
79ba47c3 1void MakePHOSFullMisAlignment()
2{
3 // Create misalignment object for PHOS module 2
4 // from the survey measurements on P2 in May 2008.
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
9
10 const char * macroName = "MakePHOS2Alignment";
11
3c759505 12 const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
13 if (!phosGeom) {
79ba47c3 14 Error(macroName, "Cannot obtain AliPHOSGeometry singleton.\n");
3c759505 15 return;
16 }
17
79ba47c3 18 //Activate CDB storage and load geometry from CDB
19 //I need valid gGeoManager to create local transformations.
20
d7c519b2 21 //[Part of code, taken from ITS version of MakexxxFullMisalignment.
22 //This code was required only for local delta transformations.
23 //Now, transformations are global, so no gGeoManager and geometry are required.
24 /*
79ba47c3 25 AliCDBManager * cdb = AliCDBManager::Instance();
26 if (!cdb->IsDefaultStorageSet())
162637e4 27 cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
79ba47c3 28 cdb->SetRun(0);
29
30 if (TString(gSystem->Getenv("TOCDB")) == TString("kTRUE")) {
31 const TString storageENV(gSystem->Getenv("STORAGE"));
32 if (!storageENV.BeginsWith("local://") && !storageENV.BeginsWith("alien://")) {
33 Error(macroName, "STORAGE variable set to %s is not valid.\n", storageENV.Data());
34 return;
35 }
36
37 AliCDBStorage * storage = cdb->GetStorage(storageENV.Data());
38 if (!storage) {
39 Error(macroName, "Unable to open storage %s.\n", storageENV.Data());
40 return;
41 }
42
43 AliCDBPath path("GRP","Geometry","Data");
44 AliCDBEntry * entry = storage->Get(path.GetPath(), cdb->GetRun());
45 if (!entry) {
46 Error(macroName,"Could not get the specified CDB entry!");
47 return;
48 }
49
50 entry->SetOwner(0);
51 AliGeomManager::SetGeometry((TGeoManager*) entry->GetObject());
52 }else{
53 AliGeomManager::LoadGeometry("geometry.root"); //load geom from default CDB storage
d7c519b2 54 }
55 */
79ba47c3 56 //end of code taken from ITS version of MakexxxFullMisalignment]
57
58 AliPHOSEMCAGeometry * emca = phosGeom->GetEMCAGeometry();
d7c519b2 59 TClonesArray alobj("AliAlignObjParams", 16);// + phosGeom->GetNModules() * emca->GetNStripX() *
60 // emca->GetNStripZ());
61
79ba47c3 62 const Double_t dpsi = 0., dtheta = 0., dphi = 0.;
63 const Double_t displacement = 10.;
64 Int_t iIndex = 0; //let all modules have index=0 in a layer with no LUT
65 const AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
66 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer, iIndex);
67 Int_t i = 0;
1895a097 68
69 // Alignment for 5 PHOS modules
79ba47c3 70
d7c519b2 71 TString surveyFileName;
79ba47c3 72
d7c519b2 73 const Char_t * szEnv = gSystem->Getenv("ALICE_ROOT");
74 if (szEnv && szEnv[0]) {
75 surveyFileName += szEnv;
76 if (surveyFileName[surveyFileName.Length() - 1] != '/')
77 surveyFileName += '/';
78 } else {
79 Warning(macroName, "cannot find ALICE_ROOT environment variable\n"
80 "probably, I wan't be able to find survey file");
81 }
82
83 surveyFileName += "PHOS/data/phos_mod3_survey_2008.txt";
84
85 new(alobj[i++]) AliAlignObjParams("PHOS/Module1", volid, 0., 0., 0., 0., 0., 0., kTRUE);
86 new(alobj[i++]) AliAlignObjParams("PHOS/Module2", volid, 2., 0., 0., 0., 0., 0., kTRUE);
87 //
88 AliSurveyObj survey;
89 survey.FillFromLocalFile(surveyFileName.Data());
90 TGeoHMatrix module3Delta;
91 AliPHOSModuleMisalignment delta(*phosGeom);
92 delta.DeltaTransformation(2, survey.GetData(), "T2_10000", "T2_10027", "T2_24000",
93 &module3Delta);
94 new(alobj[i++]) AliAlignObjParams("PHOS/Module3", volid, module3Delta, kTRUE);
95 //
96 new(alobj[i++]) AliAlignObjParams("PHOS/Module4", volid, 0., 0., 0., 0., 0., 0., kTRUE);
97 new(alobj[i++]) AliAlignObjParams("PHOS/Module5", volid, 0., 0., 0., 0., 0., 0., kTRUE);
1895a097 98
79ba47c3 99 const Double_t dx = 0., dy = 0., dz = 0. ;
a45bb6dc 100 // Alignment of CPV modules
90dbf5fb 101 new(alobj[i++]) AliAlignObjParams("PHOS/Module1/CPV",
a45bb6dc 102 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 103 new(alobj[i++]) AliAlignObjParams("PHOS/Module2/CPV",
a45bb6dc 104 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 105 new(alobj[i++]) AliAlignObjParams("PHOS/Module3/CPV",
a45bb6dc 106 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 107 new(alobj[i++]) AliAlignObjParams("PHOS/Module4/CPV",
a45bb6dc 108 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 109 new(alobj[i++]) AliAlignObjParams("PHOS/Module5/CPV",
a45bb6dc 110 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
111
1895a097 112 // Alignment for PHOS cradle
90dbf5fb 113 new(alobj[i++]) AliAlignObjParams("PHOS/Cradle0",
1895a097 114 volid, 0., 0., -displacement, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 115 new(alobj[i++]) AliAlignObjParams("PHOS/Cradle1",
1895a097 116 volid, 0., 0., +displacement, dpsi, dtheta, dphi, kTRUE);
117
118 // Alignment for cradle wheels
90dbf5fb 119 new(alobj[i++]) AliAlignObjParams("PHOS/Wheel0",
1895a097 120 volid, 0., 0., -displacement, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 121 new(alobj[i++]) AliAlignObjParams("PHOS/Wheel1",
1895a097 122 volid, 0., 0., -displacement, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 123 new(alobj[i++]) AliAlignObjParams("PHOS/Wheel2",
1895a097 124 volid, 0., 0., +displacement, dpsi, dtheta, dphi, kTRUE);
90dbf5fb 125 new(alobj[i++]) AliAlignObjParams("PHOS/Wheel3",
1895a097 126 volid, 0., 0., +displacement, dpsi, dtheta, dphi, kTRUE);
127
128 // ************************* 2nd step ***************
79ba47c3 129 if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
1895a097 130 // save on file
79ba47c3 131 const char * fileName = "PHOSfullMisalignment.root";
132 TFile f(fileName,"RECREATE");
133 if (!f) {
134 Error(macroName, "cannot open file for output\n");
dfe9c69d 135 return;
136 }
79ba47c3 137
138 Info(macroName,"Saving alignment objects to the file %s", fileName);
1895a097 139 f.cd();
79ba47c3 140 f.WriteObject(&alobj,"PHOSAlignObjs","kSingleKey");
1895a097 141 f.Close();
142 }else{
143 // save in CDB storage
79ba47c3 144 TString storageENV = gSystem->Getenv("STORAGE");
145 if(!storageENV.BeginsWith("local://") && !storageENV.BeginsWith("alien://")) {
146 Error(macroName,"STORAGE variable set to %s is not valid. Exiting\n", storageENV.Data());
dfe9c69d 147 return;
148 }
79ba47c3 149
150 Info(macroName,"Saving alignment objects in CDB storage %s", storageENV.Data());
151 AliCDBManager * cdb = AliCDBManager::Instance();
152 AliCDBStorage * storage = cdb->GetStorage(storageENV.Data());
153 if (!storage) {
154 Error(macroName, "Unable to open storage %s\n", storageENV.Data());
dfe9c69d 155 return;
156 }
79ba47c3 157
158 AliCDBMetaData md;
159 md.SetResponsible("Timur Pocheptsov");
160 md.SetComment("Alignment objects for PHOS module 2; survey in May 2008");
161 md.SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 162 AliCDBId id("PHOS/Align/Data",0,AliCDBRunRange::Infinity());
79ba47c3 163 storage->Put(&alobj, id, &md);
1895a097 164 }
165
79ba47c3 166 alobj.Delete();
1895a097 167}