Updated comments (Raffaele)
[u/mrichter/AliRoot.git] / TRD / MakeTRDResMisAlignment.C
CommitLineData
1895a097 1void MakeTRDResMisAlignment(){
2 // Create TClonesArray of residual misalignment objects for TRD
3 //
4 TClonesArray *array = new TClonesArray("AliAlignObjAngles",1000);
5 TClonesArray &alobj = *array;
6
7 if(!gGeoManager) TGeoManager::Import("geometry.root");
8 // needed for the constructors with local coordinates not to fail
9
10 AliAlignObjAngles a;
11
12 // sigmas for the supermodules
13 Double_t smdx=3; // 300 microns
14 Double_t smdy=3; // 300 microns
15 Double_t smdz=3; // 300 microns
16 Double_t smrx=0.4/1000/TMath::Pi()*180; // 0.4 mrad
17 Double_t smry=2.0/1000/TMath::Pi()*180; // 2 mrad
18 Double_t smrz=0.4/1000/TMath::Pi()*180; // 0.4 mrad
19
20 // sigmas for the chambers
21 Double_t chdx=0.02; // 200 microns
22 Double_t chdy=0.03; // 300 microns
23 Double_t chdz=0.07; // 700 microns
24 Double_t chrx=0.3/1000/TMath::Pi()*180; // 0.3 mrad
25 Double_t chry=0.3/1000/TMath::Pi()*180; // 0.3 mrad
26 Double_t chrz=0.1/1000/TMath::Pi()*180; // 0.1 mrad
27
28 Double_t dx,dy,dz,rx,ry,rz;
29
30 Int_t j=0;
31 TRandom *ran = new TRandom(4357);
32 UShort_t volid;
33 const char *path;
34
35 //generate the paths for the 18 supermodules
36 Double_t r=325.;
37 Double_t phi;
38 Int_t isec;
39 TString ts0;
40 TString* sm_path = new TString[18];
41 TRegexp regexp(".*BTRD[0-9][^/]*");
42
43 for (isec=0; isec<18; isec++) {
44 phi=(isec+0.5)/18*2*TMath::Pi();
45 gGeoManager->FindNode(r*cos(phi),r*sin(phi),0.);
46 ts0 = gGeoManager->GetPath();
47 sm_path[isec] = ts0(regexp);
48 sm_path[isec] +='\0';
49 }
50
51 // create the supermodules' alignment objects
52 for (int i; i<18; i++) {
53 ran.Rannor(dx,rx);
54 ran.Rannor(dy,ry);
55 ran.Rannor(dz,rz);
56 dx*=smdx;
57 dy*=smdy;
58 dz*=smdz;
59 rx*=smrx;
60 ry*=smry;
61 rz*=smrz;
62 new(alobj[j++]) AliAlignObjAngles(sm_path[i].Data(),0,dx,dy,dz,rx,ry,rz,kFALSE);
63 }
64
65 // create the chambers' alignment objects
66 for (Int_t iLayer = AliAlignObj::kTRD1; iLayer <= AliAlignObj::kTRD6; iLayer++) {
67 for (Int_t iModule = 0; iModule < AliAlignObj::LayerSize(iLayer); iModule++) {
68 ran.Rannor(dx,rx);
69 ran.Rannor(dy,ry);
70 ran.Rannor(dz,rz);
71 dx*=chdx;
72 dy*=chdy;
73 dz*=chdz;
74 rx*=chrx;
75 ry*=chry;
76 rz*=chrz;
77 volid = AliAlignObj::LayerToVolUID(iLayer,iModule);
78 path = AliAlignObj::SymName(volid);
79 new(alobj[j++]) AliAlignObjAngles(path,volid,dx,dy,dz,rx,ry,rz,kFALSE);
80 }
81 }
82
83 if(!gSystem->Getenv("$TOCDB")){
84 // save on file
85 TFile f("TRDresidualMisalignment.root","RECREATE");
86 if(!f) cerr<<"cannot open file for output\n";
87 f.cd();
88 f.WriteObject(array,"TRDAlignObjs","kSingleKey");
89 f.Close();
90 }else{
91 // save in CDB storage
92 const char* Storage = gSystem->Getenv("$STORAGE");
93 AliCDBManager* cdb = AliCDBManager::Instance();
94 AliCDBStorage* storage = cdb->GetStorage(Storage);
95 AliCDBMetaData* md = new AliCDBMetaData();
96 md->SetResponsible("Dariusz Miskowiec");
97 md->SetComment("Residual misalignment for TRD");
98 md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
99 AliCDBId id("TRD/Align/Data",0,9999999);
100 storage->Put(array,id,md);
101 }
102
103 array->Delete();
104
105}
106
107