]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/MakeTPCFullMisAlignment.C
Some of the coding violations corrected
[u/mrichter/AliRoot.git] / TPC / MakeTPCFullMisAlignment.C
1 void MakeTPCFullMisAlignment(){
2   // Create TClonesArray of full misalignment objects for TPC
3   //
4   const char* macroname = "MakeTPCFullMisAlignment.C";
5   // Activate CDB storage and load geometry from CDB
6   AliCDBManager* cdb = AliCDBManager::Instance();
7   if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
8   cdb->SetRun(0);
9   
10   AliCDBStorage* storage;
11   
12   if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
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                   
33   TClonesArray *array = new TClonesArray("AliAlignObjParams",100);
34   TClonesArray &alobj = *array;
35   
36   TRandom *rnd   = new TRandom(4357);
37   Int_t j = 0;
38   Double_t dx, dy, dz, dpsi, dtheta, dphi;
39
40   // RS = local
41   // sigma translation = 0.1 mm
42   // sigma rotation = 0.1 mrad
43   Float_t sigmatr=0.01;
44   Float_t sigmarot = 0.006;
45
46   for (Int_t iLayer = AliGeomManager::kTPC1; iLayer <= AliGeomManager::kTPC2; iLayer++) {
47     for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer); iModule++) {
48
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);
55
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);
59     }
60   }
61
62   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
63     // save on file
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);
71     f.cd();
72     f.WriteObject(array,"TPCAlignObjs","kSingleKey");
73     f.Close();
74   }else{
75     // save in CDB storage
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");
79     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
80     AliCDBId id("TPC/Align/Data",0,AliCDBRunRange::Infinity());
81     storage->Put(array,id,md);
82   }
83
84   array->Delete();
85
86 }
87