]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/MakeEMCALResMisAlignment.C
add option to compare the online reference stored in OADB and OCDB
[u/mrichter/AliRoot.git] / EMCAL / MakeEMCALResMisAlignment.C
CommitLineData
8cc543cb 1void MakeEMCALResMisAlignment(TString geoname = "EMCAL_COMPLETE12SMV1_DCAL_8SM"){
1895a097 2 // Create TClonesArray of residual misalignment objects for EMCAL
3 //
6fce62af 4 const char* macroname = "MakeEMCALResMisAlignment.C";
1e4f558f 5 if(geoname=="")geoname=AliEMCALGeometry::GetDefaultGeometryName();
6 const AliEMCALGeometry *emcalGeom = AliEMCALGeometry::GetInstance(geoname,"");
9d9bbd17 7 if(!emcalGeom) {
289cc8a7 8 Error("MakeEMCALResMisAlignment","Cannot obtain AliEMCALGeometry singleton\n");
9 return;
10 }
11
9d9bbd17 12 TClonesArray *array = new TClonesArray("AliAlignObjParams",emcalGeom->GetNumberOfSuperModules());
289cc8a7 13 TClonesArray &alobj = *array;
14
1895a097 15
6fce62af 16 // Activate CDB storage and load geometry from CDB
17 AliCDBManager* cdb = AliCDBManager::Instance();
162637e4 18 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
6fce62af 19 cdb->SetRun(0);
20
21 AliCDBStorage* storage;
22
a24be56b 23 if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
6fce62af 24 TString Storage = gSystem->Getenv("STORAGE");
25 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
26 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
27 return;
28 }
29 storage = cdb->GetStorage(Storage.Data());
30 if(!storage){
31 Error(macroname,"Unable to open storage %s\n",Storage.Data());
32 return;
33 }
34 AliCDBPath path("GRP","Geometry","Data");
35 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
36 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
37 entry->SetOwner(0);
38 TGeoManager* geom = (TGeoManager*) entry->GetObject();
39 AliGeomManager::SetGeometry(geom);
40 }else{
41 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
42 }
1895a097 43
44 Double_t dx, dy, dz, dpsi, dtheta, dphi;
45
8cc543cb 46 const TString fbasepath = "EMCAL/FullSupermodule";
d3a9c52a 47 const TString hbasepath = "EMCAL/HalfSupermodule";
8cc543cb 48 const TString tbasepath = "EMCAL/OneThrdSupermodule";
49 const TString dbasepath = "EMCAL/DCALSupermodule";
50 const TString debasepath= "EMCAL/DCALExtensionSM";
1895a097 51 TString pathstr;
52
53 Int_t iIndex=0; // let all modules have index=0 in a layer with no LUT
ae079791 54 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
55 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
1895a097 56
57 Int_t i;
58
59 // RS = local
60 // sigma translation = 1mm
61 // sigma rotation = 0.1 degree
62 TRandom *rnd = new TRandom(4321);
289cc8a7 63 Double_t sigmatr = 0.05; // max shift in cm w.r.t. local RS
1895a097 64 Double_t sigmarot = 0.1; // max rot in degrees w.r.t. local RS
d3a9c52a 65
8cc543cb 66 Int_t nSM = emcalGeom->GetEMCGeometry()->GetNumberOfSuperModules();
67 for(i=0; i<nSM; i++){
1895a097 68 dx = rnd->Gaus(0.,sigmatr);
69 dy = rnd->Gaus(0.,sigmatr);
70 dz = rnd->Gaus(0.,sigmatr);
71 dpsi = rnd->Gaus(0.,sigmarot);
72 dtheta = rnd->Gaus(0.,sigmarot);
73 dphi = rnd->Gaus(0.,sigmarot);
8cc543cb 74 if( emcalGeom->GetSMType(i) == kEMCAL_Standard) pathstr=fbasepath;
75 else if(emcalGeom->GetSMType(i) == kEMCAL_Half ) pathstr=hbasepath;
76 else if(emcalGeom->GetSMType(i) == kEMCAL_3rd ) pathstr=tbasepath;
77 else if(emcalGeom->GetSMType(i) == kDCAL_Standard ) pathstr=dbasepath;
78 else if(emcalGeom->GetSMType(i) == kDCAL_Ext ) pathstr=debasepath;
1895a097 79 pathstr+=(i+1);
8cc543cb 80 new(alobj[i]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
1895a097 81 }
82
a24be56b 83 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
1895a097 84 // save on file
dfe9c69d 85 const char* filename = "EMCALresidualMisalignment.root";
86 TFile f(filename,"RECREATE");
87 if(!f){
88 Error(macroname,"cannot open file for output\n");
89 return;
90 }
91 Info(macroname,"Saving alignment objects to the file %s", filename);
1895a097 92 f.cd();
dfe9c69d 93 f.WriteObject(array,"EMCALAlignObjs","kSingleKey");
1895a097 94 f.Close();
95 }else{
96 // save in CDB storage
1895a097 97 AliCDBMetaData* md = new AliCDBMetaData();
289cc8a7 98 md->SetResponsible("Jennifer Klay");
99 md->SetComment("Residual misalignment for EMCAL, produced with sigmatr=0.05 and sigmarot=0.1 in the local RS");
5bd470e1 100 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 101 AliCDBId id("EMCAL/Align/Data",0,AliCDBRunRange::Infinity());
1895a097 102 storage->Put(array,id,md);
103 }
104
105 array->Delete();
106
107}
108