AliAlignObjAngles becomes AliAlignObjParams (Raffaele)
[u/mrichter/AliRoot.git] / EMCAL / MakeEMCALFullMisAlignment.C
CommitLineData
1895a097 1void MakeEMCALFullMisAlignment(){
2 // Create TClonesArray of full misalignment objects for EMCAL
3 //
90dbf5fb 4 TClonesArray *array = new TClonesArray("AliAlignObjParams",10);
1895a097 5 TClonesArray &alobj = *array;
6
dfe9c69d 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 }
90dbf5fb 13 AliAlignObjParams a;
1895a097 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
7e154d52 22 const TString basepath = "EMCAL/FullSupermodule";
d3a9c52a 23 const TString hbasepath = "EMCAL/HalfSupermodule";
1895a097 24 TString pathstr;
25
26 Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
ae079791 27 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
28 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy volume identity
1895a097 29 Int_t i;
d3a9c52a 30 Int_t j=0;
1895a097 31
32 for(i=0; i<10; i++){
1895a097 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";
90dbf5fb 42 new(alobj[j++]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
d3a9c52a 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);
90dbf5fb 54 new(alobj[j++]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
1895a097 55 }
56
dfe9c69d 57 const char* macroname = "MakeEMCALFullMisAlignment.C";
5bd470e1 58 if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
1895a097 59 // save on file
dfe9c69d 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);
1895a097 67 f.cd();
dfe9c69d 68 f.WriteObject(array,"EMCALAlignObjs","kSingleKey");
1895a097 69 f.Close();
70 }else{
71 // save in CDB storage
dfe9c69d 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());
1895a097 79 AliCDBManager* cdb = AliCDBManager::Instance();
dfe9c69d 80 AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
81 if(!storage){
82 Error(macroname,"Unable to open storage %s\n",Storage.Data());
83 return;
84 }
1895a097 85 AliCDBMetaData* md = new AliCDBMetaData();
86 md->SetResponsible("Jennifer Clay");
87 md->SetComment("Full misalignment for EMCAL");
5bd470e1 88 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 89 AliCDBId id("EMCAL/Align/Data",0,AliCDBRunRange::Infinity());
1895a097 90 storage->Put(array,id,md);
91 }
92
93 array->Delete();
94
95}
96