]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/MakeEMCALResMisAlignment.C
fix event range call in rec macro
[u/mrichter/AliRoot.git] / EMCAL / MakeEMCALResMisAlignment.C
CommitLineData
1895a097 1void MakeEMCALResMisAlignment(){
2 // Create TClonesArray of residual misalignment objects for EMCAL
3 //
90dbf5fb 4 TClonesArray *array = new TClonesArray("AliAlignObjParams",10);
1895a097 5 TClonesArray &alobj = *array;
6fce62af 6 const char* macroname = "MakeEMCALResMisAlignment.C";
1895a097 7
6fce62af 8 // Activate CDB storage and load geometry from CDB
9 AliCDBManager* cdb = AliCDBManager::Instance();
10 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
11 cdb->SetRun(0);
12
13 AliCDBStorage* storage;
14
a24be56b 15 if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
6fce62af 16 TString Storage = gSystem->Getenv("STORAGE");
17 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
18 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
19 return;
20 }
21 storage = cdb->GetStorage(Storage.Data());
22 if(!storage){
23 Error(macroname,"Unable to open storage %s\n",Storage.Data());
24 return;
25 }
26 AliCDBPath path("GRP","Geometry","Data");
27 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
28 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
29 entry->SetOwner(0);
30 TGeoManager* geom = (TGeoManager*) entry->GetObject();
31 AliGeomManager::SetGeometry(geom);
32 }else{
33 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
34 }
1895a097 35
36 Double_t dx, dy, dz, dpsi, dtheta, dphi;
37
7e154d52 38 const TString basepath = "EMCAL/FullSupermodule";
d3a9c52a 39 const TString hbasepath = "EMCAL/HalfSupermodule";
1895a097 40 TString pathstr;
41
42 Int_t iIndex=0; // let all modules have index=0 in a layer with no LUT
ae079791 43 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
44 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
1895a097 45
46 Int_t i;
d3a9c52a 47 Int_t j=0;
1895a097 48
49 // RS = local
50 // sigma translation = 1mm
51 // sigma rotation = 0.1 degree
52 TRandom *rnd = new TRandom(4321);
53 Double_t sigmatr = 0.1; // max shift in cm w.r.t. local RS
54 Double_t sigmarot = 0.1; // max rot in degrees w.r.t. local RS
d3a9c52a 55
1895a097 56 for(i=0; i<10; i++){
57 dx = rnd->Gaus(0.,sigmatr);
58 dy = rnd->Gaus(0.,sigmatr);
59 dz = rnd->Gaus(0.,sigmatr);
60 dpsi = rnd->Gaus(0.,sigmarot);
61 dtheta = rnd->Gaus(0.,sigmarot);
62 dphi = rnd->Gaus(0.,sigmarot);
63 pathstr=basepath;
64 pathstr+=(i+1);
90dbf5fb 65 new(alobj[j++]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
d3a9c52a 66 }
67
68 for(i=0; i<2; i++){
69 dx = rnd->Gaus(0.,sigmatr);
70 dy = rnd->Gaus(0.,sigmatr);
71 dz = rnd->Gaus(0.,sigmatr);
72 dpsi = rnd->Gaus(0.,sigmarot);
73 dtheta = rnd->Gaus(0.,sigmarot);
74 dphi = rnd->Gaus(0.,sigmarot);
75 pathstr=hbasepath;
76 pathstr+=(i+1);
90dbf5fb 77 new(alobj[j++]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
1895a097 78 }
79
a24be56b 80 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
1895a097 81 // save on file
dfe9c69d 82 const char* filename = "EMCALresidualMisalignment.root";
83 TFile f(filename,"RECREATE");
84 if(!f){
85 Error(macroname,"cannot open file for output\n");
86 return;
87 }
88 Info(macroname,"Saving alignment objects to the file %s", filename);
1895a097 89 f.cd();
dfe9c69d 90 f.WriteObject(array,"EMCALAlignObjs","kSingleKey");
1895a097 91 f.Close();
92 }else{
93 // save in CDB storage
1895a097 94 AliCDBMetaData* md = new AliCDBMetaData();
95 md->SetResponsible("Jennifer Clay");
96 md->SetComment("Residual misalignment for EMCAL, produced with sigmatr=0.05 and sigmarot=0.3 in the local RS");
5bd470e1 97 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 98 AliCDBId id("EMCAL/Align/Data",0,AliCDBRunRange::Infinity());
1895a097 99 storage->Put(array,id,md);
100 }
101
102 array->Delete();
103
104}
105