]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/MakeTRDFullMisAlignment.C
AliAlignObjAngles becomes AliAlignObjParams (Raffaele)
[u/mrichter/AliRoot.git] / TRD / MakeTRDFullMisAlignment.C
1 void MakeTRDFullMisAlignment(){
2   // Create TClonesArray of full misalignment objects for TRD
3   // 
4   TClonesArray *array = new TClonesArray("AliAlignObjParams",1000);
5   TClonesArray &alobj = *array;
6    
7   AliAlignObjParams a;
8
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
18   // sigmas for the chambers
19   Double_t chdx=0.1; // 1 mm
20   Double_t chdy=0.1; // 1 mm
21   Double_t chdz=0.1; // 1 mm
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;
31   const char *symname;
32
33   AliGeomManager::LoadGeometry("./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++]) AliAlignObjParams(sm_symname.Data(),0,dx,dy,dz,rx,ry,rz,kFALSE);
48   }
49
50   for(Int_t k=0; k<18; k++){
51     AliAlignObjParams* smobj = (AliAlignObjParams*)array->UncheckedAt(k);
52     if(!smobj->ApplyToGeometry()){
53       cout<<"application of object "<<k<<" failed!"<<endl;
54       return;
55     }
56   }
57   gGeoManager->Export("./geom_misalBSEGMO_trdSM.root");
58   AliGeomManager::LoadGeometry("./geom_misalBSEGMO_trdSM.root");
59   // create the chambers' alignment objects
60   ran = new TRandom(4357);
61   for (Int_t iLayer = AliGeomManager::kTRD1; iLayer <= AliGeomManager::kTRD6; iLayer++) {
62     for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer); iModule++) {
63       ran->Rannor(dx,rx);
64       ran->Rannor(dy,ry);
65       ran->Rannor(dz,rz);
66       dx*=chdx;
67       dy*=chdy;
68       dz*=chdz;
69       rx*=chrx;
70       ry*=chry;
71       rz*=chrz;
72       volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
73       symname = AliGeomManager::SymName(volid);
74       new(alobj[j++]) AliAlignObjParams(symname,volid,dx,dy,dz,rx,ry,rz,kFALSE);
75     }
76   }
77
78   const char* macroname = "MakeTRDFullMisAlignment.C";
79   if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
80     // save on file
81     const char* filename = "TRDfullMisalignment.root";
82     TFile f(filename,"RECREATE");
83     if(!f){
84       Error(macroname,"cannot open file for output\n");
85       return;
86     }
87     Info(macroname,"Saving alignment objects to the file %s", filename);
88     f.cd();
89     f.WriteObject(array,"TRDAlignObjs","kSingleKey");
90     f.Close();
91   }else{
92     // save in CDB storage
93     TString Storage = gSystem->Getenv("STORAGE");
94     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
95       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
96       return;
97     }
98     Info(macroname,"Saving alignment objects in CDB storage %s",
99          Storage.Data());
100     AliCDBManager* cdb = AliCDBManager::Instance();
101     AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
102     if(!storage){
103       Error(macroname,"Unable to open storage %s\n",Storage.Data());
104       return;
105     }
106     AliCDBMetaData* md = new AliCDBMetaData();
107     md->SetResponsible("Dariusz Miskowiec");
108     md->SetComment("Full misalignment for TRD");
109     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
110     AliCDBId id("TRD/Align/Data",0,AliCDBRunRange::Infinity());
111     storage->Put(array,id,md);
112   }
113
114   array->Delete();
115   gGeoManager = 0x0;
116 }
117
118