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