1 void MakeTOFFullMisAlignment(){
2 // Create TClonesArray of full misalignment objects for TOF
4 TClonesArray *array = new TClonesArray("AliAlignObjAngles",2000);
5 TClonesArray &alobj = *array;
7 if(!AliGeomManager::GetGeometry()){
8 if(!(AliCDBManager::Instance())->IsDefaultStorageSet())
9 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
10 AliCDBManager::Instance()->SetRun(0);
11 AliGeomManager::LoadGeometry();
15 Double_t sfdpsi=0.,sfdtheta=0.,sfdphi=0.;
16 Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
17 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
18 UShort_t dvoluid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy vol id
20 // FRAME part !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
21 const char* basepath ="ALIC_1/B077_1/BSEGMO";
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;}
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;}
39 // avarage displacements
49 Double_t dx,dy,dz,drot;
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))
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);
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))
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);
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
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);
80 Int_t sm,outc,outclw; //outer number counterclock and clockwise
81 for(sm=0; sm<18; sm++){
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]);
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);
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;
110 gGeoManager->Export("./geom_misalBSEGMO.root");
112 AliGeomManager::LoadGeometry("./geom_misalBSEGMO.root");
114 // TOF part !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
118 Double_t tofdx, tofdy, tofdz, dpsi, dtheta, dphi;
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)
123 for(i=0; i<18; i++) {
124 TString symname(Form("TOF/sm%02d",i));
125 tofdx = rnd->Gaus(0.,sigmatr);
126 tofdy = rnd->Gaus(0.,sigmatr);
129 dtheta = rnd->Gaus(0.,sigmarot);
131 new(alobj[j++]) AliAlignObjAngles(symname.Data(), dvoluid, tofdx, tofdy, tofdz, dpsi, dtheta, dphi, kFALSE);
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;
140 gGeoManager->Export("./geom_misalBSEGMO_tofSM.root");
142 AliGeomManager::LoadGeometry("./geom_misalBSEGMO_tofSM.root");
143 // tof strips as in residual
144 AliGeomManager::ELayerID idTOF = AliGeomManager::kTOF;
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
153 for(i=0; i<AliGeomManager::LayerSize(idTOF); i++) {
155 sdy = rnds->Gaus(0.,sigmatr);
156 sdz = rnds->Gaus(0.,sigmatr);
160 new(alobj[j++]) AliAlignObjAngles(AliGeomManager::SymName(idTOF,i), AliGeomManager::LayerToVolUID(idTOF,i), sdx, sdy, sdz, sdpsi, sdtheta, sdphi, kFALSE);
163 const char* macroname = "MakeTOFFullMisAlignment.C";
164 if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
166 const char* filename = "TOFfullMisalignment.root";
167 TFile f(filename,"RECREATE");
169 Error(macroname,"cannot open file for output\n");
172 Info(macroname,"Saving alignment objects to the file %s", filename);
174 f.WriteObject(array,"TOFAlignObjs","kSingleKey");
177 // save in CDB storage
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());
183 Info(macroname,"Saving alignment objects in CDB storage %s",
185 AliCDBManager* cdb = AliCDBManager::Instance();
186 AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
188 Error(macroname,"Unable to open storage %s\n",Storage.Data());
191 AliCDBMetaData* md = new AliCDBMetaData();
192 md->SetResponsible("Silvia Arcelli");
193 md->SetComment("Full misalignment for TOF and FRAME");
194 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
195 AliCDBId id("TOF/Align/Data",0,AliCDBRunRange::Infinity());
196 storage->Put(array,id,md);