]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/MakeTRDFullMisAlignment.C
AliAlignObjAngles becomes AliAlignObjParams (Raffaele)
[u/mrichter/AliRoot.git] / TRD / MakeTRDFullMisAlignment.C
CommitLineData
1895a097 1void MakeTRDFullMisAlignment(){
2 // Create TClonesArray of full misalignment objects for TRD
6fce62af 3 // Expects to read objects for FRAME
1895a097 4 //
90dbf5fb 5 TClonesArray *array = new TClonesArray("AliAlignObjParams",1000);
6fce62af 6 const char* macroname = "MakeTRDFullMisAlignment.C";
7
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
15 if( gSystem->Getenv("TOCDB") == TString("kTRUE") ){
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 }
35
36 // load FRAME full misalignment objects (if needed, the macro
37 // for FRAME has to be ran in advance) and apply them to geometry
38 Info(macroname,"Loading FRAME alignment objects from CDB storage %s",
39 Storage.Data());
40 AliCDBPath fpath("GRP","Align","Data");
41 if( gSystem->Getenv("TOCDB") == TString("kTRUE") ){
42 AliCDBEntry *eFrame = storage->Get(fpath.GetPath(),cdb->GetRun());
43 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
44 TClonesArray* arFrame = (TClonesArray*) eFrame->GetObject();
45 arFrame->Sort();
46 Int_t nvols = arFrame->GetEntriesFast();
47 Bool_t flag = kTRUE;
48 for(Int_t j=0; j<nvols; j++)
49 {
50 AliAlignObj* alobj = (AliAlignObj*) arFrame->UncheckedAt(j);
51 if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE;
52 }
53 if(!flag)
54 Fatal(macroname,"Error in the application of FRAME objects");
55 }else{
56 AliCDBEntry *eFrame = cdb->Get(fpath.GetPath());
57 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
58 TClonesArray* arFrame = (TClonesArray*) eFrame->GetObject();
59 arFrame->Sort();
60 Int_t nvols = arFrame->GetEntriesFast();
61 Bool_t flag = kTRUE;
62 for(Int_t j=0; j<nvols; j++)
63 {
64 AliAlignObj* alobj = (AliAlignObj*) arFrame->UncheckedAt(j);
65 if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE;
66 }
67 if(!flag)
68 Fatal(macroname,"Error in the application of FRAME objects");
69 }
1895a097 70
6fce62af 71
d3a9c52a 72 // sigmas for the supermodules
73 Double_t smdx=0.3; // 3 mm
74 Double_t smdy=0.3; // 3 mm
75 Double_t smdz=0.3; // 3 mm
76 Double_t smrx=0.4/1000/TMath::Pi()*180; // 0.4 mrad
77 Double_t smry=2.0/1000/TMath::Pi()*180; // 2 mrad
78 Double_t smrz=0.4/1000/TMath::Pi()*180; // 0.4 mrad
79
80
1895a097 81 // sigmas for the chambers
d3a9c52a 82 Double_t chdx=0.1; // 1 mm
83 Double_t chdy=0.1; // 1 mm
84 Double_t chdz=0.1; // 1 mm
1895a097 85 Double_t chrx=1.0/1000/TMath::Pi()*180; // 1 mrad
86 Double_t chry=1.0/1000/TMath::Pi()*180; // 1 mrad
87 Double_t chrz=0.7/1000/TMath::Pi()*180; // 0.7 mrad
88
89 Double_t dx,dy,dz,rx,ry,rz;
90
91 Int_t j=0;
92 TRandom *ran = new TRandom(4357);
93 UShort_t volid;
d3a9c52a 94 const char *symname;
95
d3a9c52a 96 // create the supermodules' alignment objects
97 for (int i; i<18; i++) {
98 TString sm_symname(Form("TRD/sm%02d",i));
99 ran->Rannor(dx,rx);
100 ran->Rannor(dy,ry);
101 ran->Rannor(dz,rz);
102 dx*=smdx;
103 dy*=smdy;
104 dz*=smdz;
105 rx*=smrx;
106 ry*=smry;
107 rz*=smrz;
6fce62af 108 new((*array)[j++]) AliAlignObjParams(sm_symname.Data(),0,dx,dy,dz,rx,ry,rz,kFALSE);
d3a9c52a 109 }
1895a097 110
d3a9c52a 111 for(Int_t k=0; k<18; k++){
90dbf5fb 112 AliAlignObjParams* smobj = (AliAlignObjParams*)array->UncheckedAt(k);
d3a9c52a 113 if(!smobj->ApplyToGeometry()){
114 cout<<"application of object "<<k<<" failed!"<<endl;
115 return;
116 }
117 }
6fce62af 118
1895a097 119 // create the chambers' alignment objects
d3a9c52a 120 ran = new TRandom(4357);
ae079791 121 for (Int_t iLayer = AliGeomManager::kTRD1; iLayer <= AliGeomManager::kTRD6; iLayer++) {
122 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer); iModule++) {
d3a9c52a 123 ran->Rannor(dx,rx);
124 ran->Rannor(dy,ry);
125 ran->Rannor(dz,rz);
1895a097 126 dx*=chdx;
127 dy*=chdy;
128 dz*=chdz;
129 rx*=chrx;
130 ry*=chry;
131 rz*=chrz;
ae079791 132 volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
133 symname = AliGeomManager::SymName(volid);
6fce62af 134 new((*array)[j++]) AliAlignObjParams(symname,volid,dx,dy,dz,rx,ry,rz,kFALSE);
1895a097 135 }
136 }
137
5bd470e1 138 if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
1895a097 139 // save on file
dfe9c69d 140 const char* filename = "TRDfullMisalignment.root";
141 TFile f(filename,"RECREATE");
142 if(!f){
143 Error(macroname,"cannot open file for output\n");
144 return;
145 }
146 Info(macroname,"Saving alignment objects to the file %s", filename);
1895a097 147 f.cd();
148 f.WriteObject(array,"TRDAlignObjs","kSingleKey");
149 f.Close();
150 }else{
151 // save in CDB storage
dfe9c69d 152 Info(macroname,"Saving alignment objects in CDB storage %s",
153 Storage.Data());
1895a097 154 AliCDBMetaData* md = new AliCDBMetaData();
155 md->SetResponsible("Dariusz Miskowiec");
156 md->SetComment("Full misalignment for TRD");
5bd470e1 157 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 158 AliCDBId id("TRD/Align/Data",0,AliCDBRunRange::Infinity());
1895a097 159 storage->Put(array,id,md);
160 }
161
162 array->Delete();
1895a097 163}
164
165