Extacting the OCDB in a separate module. The detectors have write permission in the...
[u/mrichter/AliRoot.git] / TPC / MakeTPCFullMisAlignment.C
CommitLineData
1895a097 1void MakeTPCFullMisAlignment(){
2 // Create TClonesArray of full misalignment objects for TPC
3 //
6fce62af 4 const char* macroname = "MakeTPCFullMisAlignment.C";
5 // Activate CDB storage and load geometry from CDB
6 AliCDBManager* cdb = AliCDBManager::Instance();
162637e4 7 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
6fce62af 8 cdb->SetRun(0);
9
10 AliCDBStorage* storage;
11
a24be56b 12 if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
6fce62af 13 TString Storage = gSystem->Getenv("STORAGE");
14 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
15 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
16 return;
17 }
18 storage = cdb->GetStorage(Storage.Data());
19 if(!storage){
20 Error(macroname,"Unable to open storage %s\n",Storage.Data());
21 return;
22 }
23 AliCDBPath path("GRP","Geometry","Data");
24 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
25 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
26 entry->SetOwner(0);
27 TGeoManager* geom = (TGeoManager*) entry->GetObject();
28 AliGeomManager::SetGeometry(geom);
29 }else{
30 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
31 }
32
90dbf5fb 33 TClonesArray *array = new TClonesArray("AliAlignObjParams",100);
1895a097 34 TClonesArray &alobj = *array;
35
36 TRandom *rnd = new TRandom(4357);
1895a097 37 Int_t j = 0;
d3a9c52a 38 Double_t dx, dy, dz, dpsi, dtheta, dphi;
39
1895a097 40 // RS = local
d3a9c52a 41 // sigma translation = 0.1 mm
42 // sigma rotation = 0.1 mrad
1895a097 43 Float_t sigmatr=0.01;
d3a9c52a 44 Float_t sigmarot = 0.006;
45
ae079791 46 for (Int_t iLayer = AliGeomManager::kTPC1; iLayer <= AliGeomManager::kTPC2; iLayer++) {
47 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer); iModule++) {
1895a097 48
5bd470e1 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);
1895a097 55
ae079791 56 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
57 const char *symname = AliGeomManager::SymName(volid);
90dbf5fb 58 new(alobj[j++]) AliAlignObjParams(symname, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
1895a097 59 }
60 }
61
a24be56b 62 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
1895a097 63 // save on file
dfe9c69d 64 const char* filename = "TPCfullMisalignment.root";
65 TFile f(filename,"RECREATE");
66 if(!f){
67 Error(macroname,"cannot open file for output\n");
68 return;
69 }
70 Info(macroname,"Saving alignment objects to the file %s", filename);
1895a097 71 f.cd();
72 f.WriteObject(array,"TPCAlignObjs","kSingleKey");
73 f.Close();
74 }else{
75 // save in CDB storage
1895a097 76 AliCDBMetaData* md = new AliCDBMetaData();
77 md->SetResponsible("Marian Ivanov");
78 md->SetComment("Full misalignment for TPC, sigmatr=0.01 and sigmarot=0.6 in the local RS");
5bd470e1 79 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 80 AliCDBId id("TPC/Align/Data",0,AliCDBRunRange::Infinity());
1895a097 81 storage->Put(array,id,md);
82 }
83
84 array->Delete();
85
86}
87