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