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