]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/MakeTPCResMisAlignment.C
TPC/Rec/AliTPCtracker.cxx - adding itteration information
[u/mrichter/AliRoot.git] / TPC / MakeTPCResMisAlignment.C
1 void MakeTPCResMisAlignment(){
2   // Create TClonesArray of residual misalignment objects for TPC
3   //
4   const char* macroname = "MakeTPCResMisAlignment.C";
5
6   // Activate CDB storage and load geometry from CDB
7   AliCDBManager* cdb = AliCDBManager::Instance();
8   if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
9   cdb->SetRun(0);
10   
11   AliCDBStorage* storage;
12   
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());
17       return;
18     }
19     storage = cdb->GetStorage(Storage.Data());
20     if(!storage){
21       Error(macroname,"Unable to open storage %s\n",Storage.Data());
22       return;
23     }
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!");
27     entry->SetOwner(0);
28     TGeoManager* geom = (TGeoManager*) entry->GetObject();
29     AliGeomManager::SetGeometry(geom);
30   }else{
31     AliGeomManager::LoadGeometry(); //load geom from default CDB storage
32   }    
33
34   TClonesArray *array = new TClonesArray("AliAlignObjParams",100);
35   TClonesArray &alobj = *array;
36   
37   TRandom *rnd   = new TRandom(4357);
38   Double_t dx, dy, dz, dpsi, dtheta, dphi;
39   Int_t j = 0;
40
41   // RS = local
42   // sigma translation = 0.1 mm
43   // sigma rotation = 0.1 mrad
44   Float_t sigmatr=0.01;
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++) {
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       j++;
60     }
61   }
62
63   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
64     // save on file
65     const char* filename = "TPCresidualMisalignment.root";
66     TFile f(filename,"RECREATE");
67     if(!f){
68       Error(macroname,"cannot open file for output\n");
69       return;
70     }
71     Info(macroname,"Saving alignment objects to the file %s", filename);
72     f.cd();
73     f.WriteObject(array,"TPCAlignObjs","kSingleKey");
74     f.Close();
75   }else{
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);
83   }
84
85   array->Delete();
86
87 }
88