]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/MakeEMCALResMisAlignment.C
AliAlignObjAngles becomes AliAlignObjParams (Raffaele)
[u/mrichter/AliRoot.git] / EMCAL / MakeEMCALResMisAlignment.C
1 void MakeEMCALResMisAlignment(){
2   // Create TClonesArray of residual misalignment objects for EMCAL
3   //
4   TClonesArray *array = new TClonesArray("AliAlignObjParams",10);
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   AliAlignObjParams a;
14
15   Double_t dx, dy, dz, dpsi, dtheta, dphi;
16
17   const TString basepath = "EMCAL/FullSupermodule";
18   const TString hbasepath = "EMCAL/HalfSupermodule";
19   TString pathstr;
20
21   Int_t iIndex=0; // let all modules have index=0 in a layer with no LUT
22   AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
23   UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
24
25   Int_t i;
26   Int_t j=0;
27
28   // RS = local
29   // sigma translation = 1mm
30   // sigma rotation = 0.1 degree
31   TRandom *rnd   = new TRandom(4321);
32   Double_t sigmatr = 0.1; // max shift in cm w.r.t. local RS
33   Double_t sigmarot = 0.1; // max rot in degrees w.r.t. local RS
34
35   for(i=0; i<10; i++){
36     dx = rnd->Gaus(0.,sigmatr);
37     dy = rnd->Gaus(0.,sigmatr);
38     dz = rnd->Gaus(0.,sigmatr);
39     dpsi = rnd->Gaus(0.,sigmarot);
40     dtheta = rnd->Gaus(0.,sigmarot);
41     dphi = rnd->Gaus(0.,sigmarot);
42     pathstr=basepath;
43     pathstr+=(i+1);
44     new(alobj[j++]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
45   }
46
47   for(i=0; i<2; i++){
48     dx = rnd->Gaus(0.,sigmatr);
49     dy = rnd->Gaus(0.,sigmatr);
50     dz = rnd->Gaus(0.,sigmatr);
51     dpsi = rnd->Gaus(0.,sigmarot);
52     dtheta = rnd->Gaus(0.,sigmarot);
53     dphi = rnd->Gaus(0.,sigmarot);
54     pathstr=hbasepath;
55     pathstr+=(i+1);
56     new(alobj[j++]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
57   }
58
59   const char* macroname = "MakeEMCALResMisAlignment.C";
60   if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
61     // save on file
62     const char* filename = "EMCALresidualMisalignment.root";
63     TFile f(filename,"RECREATE");
64     if(!f){
65       Error(macroname,"cannot open file for output\n");
66       return;
67     }
68     Info(macroname,"Saving alignment objects to the file %s", filename);
69     f.cd();
70     f.WriteObject(array,"EMCALAlignObjs","kSingleKey");
71     f.Close();
72   }else{
73     // save in CDB storage
74     TString Storage = gSystem->Getenv("STORAGE");
75     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
76       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
77       return;
78     }
79     Info(macroname,"Saving alignment objects in CDB storage %s",
80          Storage.Data());
81     AliCDBManager* cdb = AliCDBManager::Instance();
82     AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
83     if(!storage){
84       Error(macroname,"Unable to open storage %s\n",Storage.Data());
85       return;
86     }
87     AliCDBMetaData* md = new AliCDBMetaData();
88     md->SetResponsible("Jennifer Clay");
89     md->SetComment("Residual misalignment for EMCAL, produced with sigmatr=0.05 and sigmarot=0.3 in the local RS");
90     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
91     AliCDBId id("EMCAL/Align/Data",0,AliCDBRunRange::Infinity());
92     storage->Put(array,id,md);
93   }
94
95   array->Delete();
96
97 }
98