Temporary disable the raw version, it will be taken from FEE
[u/mrichter/AliRoot.git] / TOF / MakeTOFFullMisAlignment.C
CommitLineData
1895a097 1void MakeTOFFullMisAlignment(){
2 // Create TClonesArray of full misalignment objects for TOF
3 //
d3a9c52a 4 TClonesArray *array = new TClonesArray("AliAlignObjAngles",2000);
1895a097 5 TClonesArray &alobj = *array;
6
d3a9c52a 7 if(!gGeoManager) TGeoManager::Import("/home/rgrosso/Prove/AliRoot/geometry.root");
1895a097 8
9 AliAlignObjAngles a;
d3a9c52a 10 Double_t sfdpsi=0.,sfdtheta=0.,sfdphi=0.;
1895a097 11 Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
ae079791 12 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
13 UShort_t dvoluid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy vol id
d3a9c52a 14
15 // FRAME part !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16 const char* basepath ="ALIC_1/B077_1/BSEGMO";
17 TString segmpath;
18
19 // for dead weight !!!! carefull: in mm
20 ifstream dw_file("/home/rgrosso/MacroAllineamento010207/disp_deadweight.txt", ios::in);
21 if(!dw_file) {cerr<<"cannot open dead weight file for input\n"; return;}
22 TArrayD dwdx(36);
23 TArrayD dwdy(36);
24 TArrayD dwdz(36);
25 TArrayD dwdrot(36);
26 // for additional load
27 ifstream orig_file("/home/rgrosso/MacroAllineamento010207/disp_full.txt", ios::in);
28// ifstream orig_file("disp_full_nohmpid.txt", ios::in);
29 if(!orig_file) {cerr<<"cannot open file for input\n"; return;}
30 TArrayD adx(36);
31 TArrayD ady(36);
32 TArrayD adz(36);
33 TArrayD adrot(36);
34 // avarage displacements
35 Double_t mean_dx[18];
36 Double_t mean_dy[18];
37 Double_t idx[18];
38 Double_t idy[18];
39 Double_t newx[18];
40 Double_t newy[18];
41
42 string buffer;
43 Int_t point;
44 Double_t dx,dy,dz,drot;
45
46 // fill in from file the array for dead weight deformations
47 dw_file>>point>>dx>>dy>>dz>>drot;
48 dwdx.AddAt(dx,point-1);dwdy.AddAt(dy,point-1);dwdz.AddAt(dz,point-1);dwdrot.AddAt(drot,point-1);
49 while(getline(dw_file,buffer))
50 {
51 dw_file>>point>>dx>>dy>>dz>>drot;
52 dwdx.AddAt(dx,point-1);dwdy.AddAt(dy,point-1);dwdz.AddAt(dz,point-1);dwdrot.AddAt(drot,point-1);
53 }
54
55 // fill in from file the array for remaining load deformations
56 orig_file>>point>>dx>>dy>>dz>>drot;
57 adx.AddAt(dx,point-1);ady.AddAt(dy,point-1);adz.AddAt(dz,point-1);adrot.AddAt(drot,point-1);
58 while(getline(orig_file,buffer))
59 {
60 orig_file>>point>>dx>>dy>>dz>>drot;
61 adx.AddAt(dx,point-1);ady.AddAt(dy,point-1);adz.AddAt(dz,point-1);adrot.AddAt(drot,point-1);
62 }
63
64 //calculate the displacement of the center of the sm neglecting rotations,
65 //thus as average of the four surrounding point for dw + other load
66 // Prepare also to plot with respect to ideal circle.
67 Double_t cx=0.5; //just for plotting
68 Double_t cy=0.5;
69 Double_t rr=0.3;
70 Double_t kk = TMath::Pi()*20./180.;
71 Double_t scale = 100./4000.;
72 TPolyMarker* iddu = new TPolyMarker(18,newx,newy);
73 TPolyMarker* disp = new TPolyMarker(18,newx,newy);
74
75 Int_t sm,outc,outclw; //outer number counterclock and clockwise
76 for(sm=0; sm<18; sm++){
77 outc=5-sm;
78 if(outc<1) outc+=18;
79 outclw=outc-1;
80 if(outclw<1) outclw+=18;
81 mean_dx[sm]=0.125*(adx[outc-1]+adx[outclw-1]+adx[outc+18-1]+adx[outclw+18-1]+dwdx[outc-1]+dwdx[outclw-1]+dwdx[outc+18-1]+dwdx[outclw+18-1]);
82 mean_dy[sm]=0.125*(ady[outc-1]+ady[outclw-1]+ady[outc+18-1]+ady[outclw+18-1]+dwdy[outc-1]+dwdy[outclw-1]+dwdy[outc+18-1]+dwdy[outclw+18-1]);
83 idx[sm]=cx+rr*TMath::Sin(sm*kk);
84 idy[sm]=cy+rr*TMath::Cos(sm*kk);
85 newx[sm]=idx[sm]+scale*mean_dx[sm];
86 newy[sm]=idy[sm]+scale*mean_dy[sm];
87 iddu->SetPoint(sm,idx[sm],idy[sm]);
88 disp->SetPoint(sm,newx[sm],newy[sm]);
89
90 segmpath=basepath;
91 segmpath+=sm;
92 segmpath+="_1";
93 cout<<segmpath.Data()<<" "<<dvoluid<<" "<<mean_dx[sm]*0.1<<" "<<mean_dy[sm]*0.1<<" "<<dz<<" "<<sfdpsi<<" "<<sfdtheta<<" "<<sfdphi<<endl;
94 new(alobj[sm]) AliAlignObjAngles(segmpath.Data(), dvoluid, mean_dx[sm]*0.1,
95 mean_dy[sm]*0.1, dz, sfdpsi, sfdtheta, sfdphi, kTRUE);
96 }
1895a097 97
d3a9c52a 98 for(Int_t k=0; k<18; k++){
99 AliAlignObjAngles* smobj = (AliAlignObjAngles*)array->UncheckedAt(k);
100 if(!smobj->ApplyToGeometry()){
101 cout<<"application of object "<<k<<" failed!"<<endl;
102 return;
103 }
104 }
105 gGeoManager->Export("/home/rgrosso/MacroAllineamento010207/geom_misalBSEGMO.root");
106 gGeoManager=0x0;
107 TGeoManager::Import("/home/rgrosso/MacroAllineamento010207/geom_misalBSEGMO.root");
108
109 // TOF part !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
110 Int_t nSMTOF = 18;
1895a097 111 Int_t i;
d3a9c52a 112 Int_t j=18;
113 Double_t tofdx, tofdy, tofdz, dpsi, dtheta, dphi;
1895a097 114 TRandom *rnd = new TRandom(2345);
115 Double_t sigmatr = 0.4; // max shift in cm w.r.t. local ideal RS
116 Double_t sigmarot = 0.06; // max rot in deg w.r.t. local ideal RS (~ 1 mrad)
d3a9c52a 117
1895a097 118 for(i=0; i<18; i++) {
d3a9c52a 119 TString symname(Form("TOF/sm%02d",i));
120 tofdx = rnd->Gaus(0.,sigmatr);
3b2d5e3b 121 tofdy = rnd->Gaus(0.,sigmatr);
122 tofdz =0;
123 dpsi = 0.;
1895a097 124 dtheta = rnd->Gaus(0.,sigmarot);
125 dphi = 0.;
d3a9c52a 126 new(alobj[j++]) AliAlignObjAngles(symname.Data(), dvoluid, tofdx, tofdy, tofdz, dpsi, dtheta, dphi, kFALSE);
127 }
128 for(Int_t k=18; k<36; k++){
129 AliAlignObjAngles* smobj = (AliAlignObjAngles*)array->UncheckedAt(k);
130 if(!smobj->ApplyToGeometry()){
131 cout<<"application of object "<<k<<" failed!"<<endl;
132 return;
133 }
134 }
135 gGeoManager->Export("/home/rgrosso/MacroAllineamento010207/geom_misalBSEGMO_tofSM.root");
136
137
138 gGeoManager=0x0;
139 TGeoManager::Import("/home/rgrosso/MacroAllineamento010207/geom_misalBSEGMO_tofSM.root");
140 // tof strips as in residual
ae079791 141 AliGeomManager::ELayerID idTOF = AliGeomManager::kTOF;
d3a9c52a 142
143 Double_t sdx=0.;
144 Double_t sdy=0.;
145 Double_t sdz=0.;
146 Double_t sdpsi, sdtheta, sdphi;
147 TRandom *rnds = new TRandom(4357);
148 sigmatr = 0.1; // max shift in cm w.r.t. local ideal RS
149
ae079791 150 for(i=0; i<AliGeomManager::LayerSize(idTOF); i++) {
d3a9c52a 151 sdx = 0;
152 sdy = rnds->Gaus(0.,sigmatr);
153 sdz = rnds->Gaus(0.,sigmatr);
154 sdpsi = 0.;
155 sdtheta = 0.;
156 sdphi = 0.;
ae079791 157 new(alobj[j++]) AliAlignObjAngles(AliGeomManager::SymName(idTOF,i), AliGeomManager::LayerToVolUID(idTOF,i), sdx, sdy, sdz, sdpsi, sdtheta, sdphi, kFALSE);
1895a097 158 }
159
5bd470e1 160 if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
1895a097 161 // save on file
162 TFile f("TOFfullMisalignment.root","RECREATE");
163 if(!f) cerr<<"cannot open file for output\n";
164 f.cd();
165 f.WriteObject(array,"TOFAlignObjs","kSingleKey");
166 f.Close();
167 }else{
168 // save in CDB storage
5bd470e1 169 const char* Storage = gSystem->Getenv("STORAGE");
1895a097 170 AliCDBManager* cdb = AliCDBManager::Instance();
171 AliCDBStorage* storage = cdb->GetStorage(Storage);
172 AliCDBMetaData* md = new AliCDBMetaData();
173 md->SetResponsible("Silvia Arcelli");
d3a9c52a 174 md->SetComment("Full misalignment for TOF and FRAME");
5bd470e1 175 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
1895a097 176 AliCDBId id("TOF/Align/Data",0,9999999);
177 storage->Put(array,id,md);
178 }
179
180 array->Delete();
181
182}
183
184