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