Full set of updated misalignment macros (Raffaele)
[u/mrichter/AliRoot.git] / TRD / MakeTRDFullMisAlignment.C
CommitLineData
1895a097 1void MakeTRDFullMisAlignment(){
2 // Create TClonesArray of full misalignment objects for TRD
3 //
4 TClonesArray *array = new TClonesArray("AliAlignObjAngles",1000);
5 TClonesArray &alobj = *array;
6
1895a097 7 AliAlignObjAngles a;
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
33 TGeoManager::Import("/home/rgrosso/MacroAllineamento010207/geom_misalBSEGMO.root"); // geometry where the BSEGMO volumes have been misaligned
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;
47 new(alobj[j++]) AliAlignObjAngles(sm_symname.Data(),0,dx,dy,dz,rx,ry,rz,kFALSE);
48 }
1895a097 49
d3a9c52a 50 for(Int_t k=0; k<18; k++){
51 AliAlignObjAngles* smobj = (AliAlignObjAngles*)array->UncheckedAt(k);
52 if(!smobj->ApplyToGeometry()){
53 cout<<"application of object "<<k<<" failed!"<<endl;
54 return;
55 }
56 }
57 gGeoManager->Export("/home/rgrosso/MacroAllineamento010207/geom_misalBSEGMO_trdSM.root");
58 gGeoManager=0x0;
59 TGeoManager::Import("/home/rgrosso/MacroAllineamento010207/geom_misalBSEGMO_trdSM.root");
1895a097 60 // create the chambers' alignment objects
d3a9c52a 61 ran = new TRandom(4357);
1895a097 62 for (Int_t iLayer = AliAlignObj::kTRD1; iLayer <= AliAlignObj::kTRD6; iLayer++) {
63 for (Int_t iModule = 0; iModule < AliAlignObj::LayerSize(iLayer); iModule++) {
d3a9c52a 64 ran->Rannor(dx,rx);
65 ran->Rannor(dy,ry);
66 ran->Rannor(dz,rz);
1895a097 67 dx*=chdx;
68 dy*=chdy;
69 dz*=chdz;
70 rx*=chrx;
71 ry*=chry;
72 rz*=chrz;
73 volid = AliAlignObj::LayerToVolUID(iLayer,iModule);
7e154d52 74 symname = AliAlignObj::SymName(volid);
75 new(alobj[j++]) AliAlignObjAngles(symname,volid,dx,dy,dz,rx,ry,rz,kFALSE);
1895a097 76 }
77 }
78
79 if(!gSystem->Getenv("$TOCDB")){
80 // save on file
81 TFile f("TRDfullMisalignment.root","RECREATE");
82 if(!f) cerr<<"cannot open file for output\n";
83 f.cd();
84 f.WriteObject(array,"TRDAlignObjs","kSingleKey");
85 f.Close();
86 }else{
87 // save in CDB storage
88 const char* Storage = gSystem->Getenv("$STORAGE");
89 AliCDBManager* cdb = AliCDBManager::Instance();
90 AliCDBStorage* storage = cdb->GetStorage(Storage);
91 AliCDBMetaData* md = new AliCDBMetaData();
92 md->SetResponsible("Dariusz Miskowiec");
93 md->SetComment("Full misalignment for TRD");
94 md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
95 AliCDBId id("TRD/Align/Data",0,9999999);
96 storage->Put(array,id,md);
97 }
98
99 array->Delete();
100
101}
102
103