]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/MakeTRDResMisAlignment.C
Using AliGeomManager in the macros (Raffaele)
[u/mrichter/AliRoot.git] / TRD / MakeTRDResMisAlignment.C
1 void MakeTRDResMisAlignment(){
2   // Create TClonesArray of residual misalignment objects for TRD
3   //
4   TClonesArray *array = new TClonesArray("AliAlignObjAngles",1000);
5   TClonesArray &alobj = *array;
6    
7   if(!AliGeomManager::GetGeometry()){
8     if(!(AliCDBManager::Instance())->IsDefaultStorageSet())
9       AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
10       AliCDBManager::Instance()->SetRun(0);
11     AliGeomManager::LoadGeometry();
12   }
13   // needed for the constructors with local coordinates not to fail
14
15   AliAlignObjAngles a;
16
17   // sigmas for the chambers
18   Double_t chdx=0.002; // 20 microns
19   Double_t chdy=0.003; // 30 microns
20   Double_t chdz=0.007; // 70 microns
21   Double_t chrx=0.3/1000/TMath::Pi()*180; // 0.3 mrad
22   Double_t chry=0.3/1000/TMath::Pi()*180; // 0.3 mrad
23   Double_t chrz=0.1/1000/TMath::Pi()*180; // 0.1 mrad
24
25   Double_t dx,dy,dz,rx,ry,rz;
26
27   Int_t j=0;
28   TRandom *ran = new TRandom(4357);
29   UShort_t volid;
30   const char *path;
31
32   // create the chambers' alignment objects
33   for (Int_t iLayer = AliGeomManager::kTRD1; iLayer <= AliGeomManager::kTRD6; iLayer++) {
34     for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer); iModule++) {
35       ran.Rannor(dx,rx);
36       ran.Rannor(dy,ry);
37       ran.Rannor(dz,rz);
38       dx*=chdx;
39       dy*=chdy;
40       dz*=chdz;
41       rx*=chrx;
42       ry*=chry;
43       rz*=chrz;
44       volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
45       symname = AliGeomManager::SymName(volid);
46       new(alobj[j++]) AliAlignObjAngles(symname,volid,dx,dy,dz,rx,ry,rz,kFALSE);
47     }
48   }
49
50   const char* macroname = "MakeTRDResMisAlignment.C";
51   if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
52     // save on file
53     const char* filename = "TRDresidualMisalignment.root";
54     TFile f(filename,"RECREATE");
55     if(!f){
56       Error(macroname,"cannot open file for output\n");
57       return;
58     }
59     Info(macroname,"Saving alignment objects to the file %s", filename);
60     f.cd();
61     f.WriteObject(array,"TRDAlignObjs","kSingleKey");
62     f.Close();
63   }else{
64     // save in CDB storage
65     TString Storage = gSystem->Getenv("STORAGE");
66     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
67       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
68       return;
69     }
70     Info(macroname,"Saving alignment objects in CDB storage %s",
71          Storage.Data());
72     AliCDBManager* cdb = AliCDBManager::Instance();
73     AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
74     if(!storage){
75       Error(macroname,"Unable to open storage %s\n",Storage.Data());
76       return;
77     }
78     AliCDBMetaData* md = new AliCDBMetaData();
79     md->SetResponsible("Dariusz Miskowiec");
80     md->SetComment("Residual misalignment for TRD");
81     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
82     AliCDBId id("TRD/Align/Data",0,AliCDBRunRange::Infinity());
83     storage->Put(array,id,md);
84   }
85
86   array->Delete();
87
88 }
89
90