1 void MakeTPCResMisAlignment(){
2 // Create TClonesArray of residual misalignment objects for TPC
4 const char* macroname = "MakeTPCResMisAlignment.C";
6 // Activate CDB storage and load geometry from CDB
7 AliCDBManager* cdb = AliCDBManager::Instance();
8 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
11 AliCDBStorage* storage;
13 if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
14 TString Storage = gSystem->Getenv("STORAGE");
15 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
16 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
19 storage = cdb->GetStorage(Storage.Data());
21 Error(macroname,"Unable to open storage %s\n",Storage.Data());
24 AliCDBPath path("GRP","Geometry","Data");
25 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
26 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
28 TGeoManager* geom = (TGeoManager*) entry->GetObject();
29 AliGeomManager::SetGeometry(geom);
31 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
34 TClonesArray *array = new TClonesArray("AliAlignObjParams",100);
35 TClonesArray &alobj = *array;
37 TRandom *rnd = new TRandom(4357);
38 Double_t dx, dy, dz, dpsi, dtheta, dphi;
42 // sigma translation = 0.1 mm
43 // sigma rotation = 0.1 mrad
45 Float_t sigmarot = 0.006;
46 for (Int_t iLayer = AliGeomManager::kTPC1; iLayer <= AliGeomManager::kTPC2; iLayer++) {
47 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer); iModule++) {
49 dx = rnd->Gaus(0,sigmatr);
50 dy = rnd->Gaus(0,sigmatr);
51 dz = rnd->Gaus(0,sigmatr);
52 dpsi = rnd->Gaus(0,sigmarot);
53 dtheta = rnd->Gaus(0,sigmarot);
54 dphi = rnd->Gaus(0,sigmarot);
56 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
57 const char *symname = AliGeomManager::SymName(volid);
58 new(alobj[j]) AliAlignObjParams(symname, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
63 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
65 const char* filename = "TPCresidualMisalignment.root";
66 TFile f(filename,"RECREATE");
68 Error(macroname,"cannot open file for output\n");
71 Info(macroname,"Saving alignment objects to the file %s", filename);
73 f.WriteObject(array,"TPCAlignObjs","kSingleKey");
76 // save in CDB storage
77 AliCDBMetaData* md = new AliCDBMetaData();
78 md->SetResponsible("Marian Ivanov");
79 md->SetComment("Residual misalignment for TPC, sigmatr=0.01 and sigmarot=0.6 in the local RS");
80 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
81 AliCDBId id("TPC/Align/Data",0,AliCDBRunRange::Infinity());
82 storage->Put(array,id,md);