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