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