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