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