1 void MakeEMCALResMisAlignment(){
2 // Create TClonesArray of residual misalignment objects for EMCAL
4 const char* macroname = "MakeEMCALResMisAlignment.C";
5 const AliEMCALGeometry *emcalGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName(),"");
7 Error("MakeEMCALResMisAlignment","Cannot obtain AliEMCALGeometry singleton\n");
11 TClonesArray *array = new TClonesArray("AliAlignObjParams",emcalGeom->GetNumberOfSuperModules());
12 TClonesArray &alobj = *array;
15 // Activate CDB storage and load geometry from CDB
16 AliCDBManager* cdb = AliCDBManager::Instance();
17 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
20 AliCDBStorage* storage;
22 if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
23 TString Storage = gSystem->Getenv("STORAGE");
24 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
25 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
28 storage = cdb->GetStorage(Storage.Data());
30 Error(macroname,"Unable to open storage %s\n",Storage.Data());
33 AliCDBPath path("GRP","Geometry","Data");
34 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
35 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
37 TGeoManager* geom = (TGeoManager*) entry->GetObject();
38 AliGeomManager::SetGeometry(geom);
40 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
43 Double_t dx, dy, dz, dpsi, dtheta, dphi;
45 const TString basepath = "EMCAL/FullSupermodule";
46 const TString hbasepath = "EMCAL/HalfSupermodule";
49 Int_t iIndex=0; // let all modules have index=0 in a layer with no LUT
50 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
51 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
57 // sigma translation = 1mm
58 // sigma rotation = 0.1 degree
59 TRandom *rnd = new TRandom(4321);
60 Double_t sigmatr = 0.05; // max shift in cm w.r.t. local RS
61 Double_t sigmarot = 0.1; // max rot in degrees w.r.t. local RS
64 dx = rnd->Gaus(0.,sigmatr);
65 dy = rnd->Gaus(0.,sigmatr);
66 dz = rnd->Gaus(0.,sigmatr);
67 dpsi = rnd->Gaus(0.,sigmarot);
68 dtheta = rnd->Gaus(0.,sigmarot);
69 dphi = rnd->Gaus(0.,sigmarot);
72 new(alobj[j++]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
76 dx = rnd->Gaus(0.,sigmatr);
77 dy = rnd->Gaus(0.,sigmatr);
78 dz = rnd->Gaus(0.,sigmatr);
79 dpsi = rnd->Gaus(0.,sigmarot);
80 dtheta = rnd->Gaus(0.,sigmarot);
81 dphi = rnd->Gaus(0.,sigmarot);
84 new(alobj[j++]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
87 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
89 const char* filename = "EMCALresidualMisalignment.root";
90 TFile f(filename,"RECREATE");
92 Error(macroname,"cannot open file for output\n");
95 Info(macroname,"Saving alignment objects to the file %s", filename);
97 f.WriteObject(array,"EMCALAlignObjs","kSingleKey");
100 // save in CDB storage
101 AliCDBMetaData* md = new AliCDBMetaData();
102 md->SetResponsible("Jennifer Klay");
103 md->SetComment("Residual misalignment for EMCAL, produced with sigmatr=0.05 and sigmarot=0.1 in the local RS");
104 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
105 AliCDBId id("EMCAL/Align/Data",0,AliCDBRunRange::Infinity());
106 storage->Put(array,id,md);