Using AliGeomManager in the macros (Raffaele)
[u/mrichter/AliRoot.git] / PHOS / MakePHOSZeroMisAlignment.C
CommitLineData
d3a9c52a 1void MakePHOSZeroMisAlignment(){
2 // Create TClonesArray of zero misalignment objects for PHOS
3 //
3c759505 4 const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
5 if (!phosGeom) {
6 Error("MakePHOSFullMisAlignment", "Cannot obtain AliPHOSGeometry singleton\n");
7 return;
8 }
9
10 AliPHOSEMCAGeometry *emca = phosGeom->GetEMCAGeometry();
11 TClonesArray *array = new TClonesArray("AliAlignObjAngles", 16 + phosGeom->GetNModules() *
12 emca->GetNStripX() * emca->GetNStripZ());
d3a9c52a 13 TClonesArray &alobj = *array;
14
d3a9c52a 15 Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
d3a9c52a 16 Int_t iIndex=0; // let all modules have index=0 in a layer with no LUT
ae079791 17 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
18 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
d3a9c52a 19
a3627590 20 Int_t i=0 ;
d3a9c52a 21 // Alignment for 5 PHOS modules
a3627590 22 new(alobj[i++]) AliAlignObjAngles("PHOS/Module1",
d3a9c52a 23 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
a3627590 24 new(alobj[i++]) AliAlignObjAngles("PHOS/Module2",
d3a9c52a 25 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
a3627590 26 new(alobj[i++]) AliAlignObjAngles("PHOS/Module3",
d3a9c52a 27 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
a3627590 28 new(alobj[i++]) AliAlignObjAngles("PHOS/Module4",
d3a9c52a 29 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
a3627590 30 new(alobj[i++]) AliAlignObjAngles("PHOS/Module5",
d3a9c52a 31 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
32
a3627590 33 // Alignment of CPV modules
34 new(alobj[i++]) AliAlignObjAngles("PHOS/Module1/CPV",
35 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
36 new(alobj[i++]) AliAlignObjAngles("PHOS/Module2/CPV",
37 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
38 new(alobj[i++]) AliAlignObjAngles("PHOS/Module3/CPV",
39 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
40 new(alobj[i++]) AliAlignObjAngles("PHOS/Module4/CPV",
41 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
42 new(alobj[i++]) AliAlignObjAngles("PHOS/Module5/CPV",
43 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
44
45
d3a9c52a 46 // Alignment for PHOS cradle
a3627590 47 new(alobj[i++]) AliAlignObjAngles("PHOS/Cradle0",
d3a9c52a 48 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
a3627590 49 new(alobj[i++]) AliAlignObjAngles("PHOS/Cradle1",
d3a9c52a 50 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
51
52 // Alignment for cradle wheels
a3627590 53 new(alobj[i++]) AliAlignObjAngles("PHOS/Wheel0",
d3a9c52a 54 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
a3627590 55 new(alobj[i++]) AliAlignObjAngles("PHOS/Wheel1",
d3a9c52a 56 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
a3627590 57 new(alobj[i++]) AliAlignObjAngles("PHOS/Wheel2",
d3a9c52a 58 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
a3627590 59 new(alobj[i++]) AliAlignObjAngles("PHOS/Wheel3",
d3a9c52a 60 volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
61
3c759505 62 AliPHOSSurvey geodesicData;
63 geodesicData.CreateNullObjects(alobj, phosGeom);
d3a9c52a 64
dfe9c69d 65 const char* macroname = "MakePHOSZeroMisAlignment.C";
66 if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
d3a9c52a 67 // save on file
dfe9c69d 68 const char* filename = "PHOSzeroMisalignment.root";
69 TFile f(filename,"RECREATE");
70 if(!f){
71 Error(macroname,"cannot open file for output\n");
72 return;
73 }
74 Info(macroname,"Saving alignment objects to the file %s", filename);
d3a9c52a 75 f.cd();
76 f.WriteObject(array,"PHOSAlignObjs","kSingleKey");
77 f.Close();
78 }else{
79 // save in CDB storage
dfe9c69d 80 TString Storage = gSystem->Getenv("STORAGE");
81 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
82 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
83 return;
84 }
85 Info(macroname,"Saving alignment objects in CDB storage %s",
86 Storage.Data());
87 AliCDBManager* cdb = AliCDBManager::Instance();
88 AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
89 if(!storage){
90 Error(macroname,"Unable to open storage %s\n",Storage.Data());
91 return;
92 }
d3a9c52a 93 AliCDBMetaData *md= new AliCDBMetaData();
94 md->SetResponsible("Yuri Kharlov");
95 md->SetComment("Zero misalignment objects");
3c759505 96 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 97 AliCDBId id("PHOS/Align/Data",0,AliCDBRunRange::Infinity());
d3a9c52a 98 storage->Put(array,id, md);
99 }
100
101 array->Delete();
102
103}