AliAlignObjAngles becomes AliAlignObjParams (Raffaele)
[u/mrichter/AliRoot.git] / TRD / MakeTRDFullMisAlignment.C
CommitLineData
1895a097 1void MakeTRDFullMisAlignment(){
2 // Create TClonesArray of full misalignment objects for TRD
3 //
90dbf5fb 4 TClonesArray *array = new TClonesArray("AliAlignObjParams",1000);
1895a097 5 TClonesArray &alobj = *array;
6
90dbf5fb 7 AliAlignObjParams a;
1895a097 8
d3a9c52a 9 // sigmas for the supermodules
10 Double_t smdx=0.3; // 3 mm
11 Double_t smdy=0.3; // 3 mm
12 Double_t smdz=0.3; // 3 mm
13 Double_t smrx=0.4/1000/TMath::Pi()*180; // 0.4 mrad
14 Double_t smry=2.0/1000/TMath::Pi()*180; // 2 mrad
15 Double_t smrz=0.4/1000/TMath::Pi()*180; // 0.4 mrad
16
17
1895a097 18 // sigmas for the chambers
d3a9c52a 19 Double_t chdx=0.1; // 1 mm
20 Double_t chdy=0.1; // 1 mm
21 Double_t chdz=0.1; // 1 mm
1895a097 22 Double_t chrx=1.0/1000/TMath::Pi()*180; // 1 mrad
23 Double_t chry=1.0/1000/TMath::Pi()*180; // 1 mrad
24 Double_t chrz=0.7/1000/TMath::Pi()*180; // 0.7 mrad
25
26 Double_t dx,dy,dz,rx,ry,rz;
27
28 Int_t j=0;
29 TRandom *ran = new TRandom(4357);
30 UShort_t volid;
d3a9c52a 31 const char *symname;
32
dfe9c69d 33 AliGeomManager::LoadGeometry("./geom_misalBSEGMO.root"); // geometry where the BSEGMO volumes have been misaligned
d3a9c52a 34
35 // create the supermodules' alignment objects
36 for (int i; i<18; i++) {
37 TString sm_symname(Form("TRD/sm%02d",i));
38 ran->Rannor(dx,rx);
39 ran->Rannor(dy,ry);
40 ran->Rannor(dz,rz);
41 dx*=smdx;
42 dy*=smdy;
43 dz*=smdz;
44 rx*=smrx;
45 ry*=smry;
46 rz*=smrz;
90dbf5fb 47 new(alobj[j++]) AliAlignObjParams(sm_symname.Data(),0,dx,dy,dz,rx,ry,rz,kFALSE);
d3a9c52a 48 }
1895a097 49
d3a9c52a 50 for(Int_t k=0; k<18; k++){
90dbf5fb 51 AliAlignObjParams* smobj = (AliAlignObjParams*)array->UncheckedAt(k);
d3a9c52a 52 if(!smobj->ApplyToGeometry()){
53 cout<<"application of object "<<k<<" failed!"<<endl;
54 return;
55 }
56 }
dfe9c69d 57 gGeoManager->Export("./geom_misalBSEGMO_trdSM.root");
58 AliGeomManager::LoadGeometry("./geom_misalBSEGMO_trdSM.root");
1895a097 59 // create the chambers' alignment objects
d3a9c52a 60 ran = new TRandom(4357);
ae079791 61 for (Int_t iLayer = AliGeomManager::kTRD1; iLayer <= AliGeomManager::kTRD6; iLayer++) {
62 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer); iModule++) {
d3a9c52a 63 ran->Rannor(dx,rx);
64 ran->Rannor(dy,ry);
65 ran->Rannor(dz,rz);
1895a097 66 dx*=chdx;
67 dy*=chdy;
68 dz*=chdz;
69 rx*=chrx;
70 ry*=chry;
71 rz*=chrz;
ae079791 72 volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
73 symname = AliGeomManager::SymName(volid);
90dbf5fb 74 new(alobj[j++]) AliAlignObjParams(symname,volid,dx,dy,dz,rx,ry,rz,kFALSE);
1895a097 75 }
76 }
77
dfe9c69d 78 const char* macroname = "MakeTRDFullMisAlignment.C";
5bd470e1 79 if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
1895a097 80 // save on file
dfe9c69d 81 const char* filename = "TRDfullMisalignment.root";
82 TFile f(filename,"RECREATE");
83 if(!f){
84 Error(macroname,"cannot open file for output\n");
85 return;
86 }
87 Info(macroname,"Saving alignment objects to the file %s", filename);
1895a097 88 f.cd();
89 f.WriteObject(array,"TRDAlignObjs","kSingleKey");
90 f.Close();
91 }else{
92 // save in CDB storage
dfe9c69d 93 TString Storage = gSystem->Getenv("STORAGE");
94 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
95 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
96 return;
97 }
98 Info(macroname,"Saving alignment objects in CDB storage %s",
99 Storage.Data());
1895a097 100 AliCDBManager* cdb = AliCDBManager::Instance();
dfe9c69d 101 AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
102 if(!storage){
103 Error(macroname,"Unable to open storage %s\n",Storage.Data());
104 return;
105 }
1895a097 106 AliCDBMetaData* md = new AliCDBMetaData();
107 md->SetResponsible("Dariusz Miskowiec");
108 md->SetComment("Full misalignment for TRD");
5bd470e1 109 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 110 AliCDBId id("TRD/Align/Data",0,AliCDBRunRange::Infinity());
1895a097 111 storage->Put(array,id,md);
112 }
113
114 array->Delete();
dfe9c69d 115 gGeoManager = 0x0;
1895a097 116}
117
118