]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/MakeITSUResMisAlignment.C
technial fix to suppress the warning
[u/mrichter/AliRoot.git] / ITS / UPGRADE / MakeITSUResMisAlignment.C
1 // macro to create 
2 Double_t sgXMod=30e-4,sgYMod=30e-4,sgZMod=30e-4,sgThtMod=0.1,sgPsiMod=0.1,sgPhiMod=0.1;
3 Double_t sgXSta=30e-4,sgYSta=30e-4,sgZSta=30e-4,sgThtSta=0.1,sgPsiSta=0.1,sgPhiSta=0.1;
4 Double_t sgXLay=30e-4,sgYLay=30e-4,sgZLay=30e-4,sgThtLay=0.1,sgPsiLay=0.1,sgPhiLay=0.1;
5 Double_t sgXITS=100e-4,sgYITS=100e-4,sgZITS=2000e-4,sgThtITS=0.1,sgPsiITS=0.1,sgPhiITS=0.1;
6 //
7 TClonesArray* deltas=0;
8 //
9 void MakeITSUResMisAlignment()                           
10 {
11   gSystem->Load("libITSUpgradeBase");
12   //
13   // at the moment we don't want to write to official CDB
14   gSystem->Setenv("TOCDB","kTRUE");
15   gSystem->Setenv("STORAGE","local://");
16   //
17   // Activate CDB storage and load geometry from CDB
18   AliCDBManager* cdb = AliCDBManager::Instance();
19   if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://");
20   cdb->SetRun(0);
21   AliCDBStorage* storage;
22   // 
23   if (!gGeoManager) {
24     if (!gSystem->AccessPathName("geometry.root")) {
25       printf("Loading geometry.root from current directory\n");
26       AliGeomManager::LoadGeometry("geometry.root"); //load geom from default CDB storage      
27     }
28   }
29   //
30   if (TString(gSystem->Getenv("TOCDB")) == TString("kTRUE")) {
31     TString Storage = gSystem->Getenv("STORAGE");
32     if (!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
33       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
34       return;
35     }
36     storage = cdb->GetStorage(Storage.Data());
37     if (!storage) {
38       Error(macroname,"Unable to open storage %s\n",Storage.Data());
39       return;
40     }
41     //
42     if (!gGeoManager) {
43       AliCDBPath path("GRP","Geometry","Data");
44       AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
45       if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
46       entry->SetOwner(0);
47       TGeoManager* geom = (TGeoManager*) entry->GetObject();
48       AliGeomManager::SetGeometry(geom);
49     }
50   }
51   //
52   const UShort_t dummyVID = 0xffff;
53   AliITSUGeomTGeo* gm0 = new AliITSUGeomTGeo(kTRUE);
54   //
55   deltas = new TClonesArray("AliAlignObjParams");
56   double dx,dy,dz,dtht,dpsi,dphi;
57   //
58   TString sname;
59   int idel = 0;
60   //
61   dx   = sgXITS*gRandom->Gaus();
62   dy   = sgYITS*gRandom->Gaus();        
63   dz   = sgZITS*gRandom->Gaus();
64   dtht = sgThtITS*gRandom->Gaus(); 
65   dpsi = sgPsiITS*gRandom->Gaus(); 
66   dphi = sgPhiITS*gRandom->Gaus();      
67   sname = gm0->ComposeSymNameITS();
68   new( (*deltas)[idel++] ) AliAlignObjParams(sname.Data(),dummyVID,
69                                              dx,dy,dz,dtht,dpsi,dphi,kTRUE);
70   //
71   for (int ilr=0;ilr<gm0->GetNLayers();ilr++) {
72     //
73     dx   = sgXLay*gRandom->Gaus();
74     dy   = sgYLay*gRandom->Gaus();      
75     dz   = sgZLay*gRandom->Gaus();
76     dtht = sgThtLay*gRandom->Gaus(); 
77     dpsi = sgPsiLay*gRandom->Gaus(); 
78     dphi = sgPhiLay*gRandom->Gaus();    
79     sname = gm0->ComposeSymNameLayer(ilr);
80     new( (*deltas)[idel++] ) AliAlignObjParams(sname.Data(),dummyVID,
81                                                dx,dy,dz,dtht,dpsi,dphi,kTRUE);
82     //
83     for (int ild=0;ild<gm0->GetNStaves(ilr);ild++) {
84       //
85       dx   = sgXSta*gRandom->Gaus();
86       dy   = sgYSta*gRandom->Gaus();    
87       dz   = sgZSta*gRandom->Gaus();
88       dtht = sgThtSta*gRandom->Gaus(); 
89       dpsi = sgPsiSta*gRandom->Gaus(); 
90       dphi = sgPhiSta*gRandom->Gaus();  
91       sname = gm0->ComposeSymNameStave(ilr,ild);
92       new( (*deltas)[idel++] ) AliAlignObjParams(sname.Data(),dummyVID,
93                                                  dx,dy,dz,dtht,dpsi,dphi,kTRUE);
94       //
95       for (int isn=0;isn<gm0->GetNChipsPerModule(ilr);isn++) {
96         dx   = sgXMod*gRandom->Gaus();
97         dy   = sgYMod*gRandom->Gaus();  
98         dz   = sgZMod*gRandom->Gaus();
99         dtht = sgThtMod*gRandom->Gaus(); 
100         dpsi = sgPsiMod*gRandom->Gaus(); 
101         dphi = sgPhiMod*gRandom->Gaus();        
102         int mid = gm0->GetChipIndex(ilr,ild,isn);
103         sname = gm0->GetSymName(mid);
104         new( (*deltas)[idel++] ) AliAlignObjParams(sname.Data(),gm0->ChipVolUID(mid),
105                                                    dx,dy,dz,dtht,dpsi,dphi,kTRUE);
106       }
107     }
108   }
109   //
110   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
111     // save on file
112     const char* filename = "ITSUresidualMisalignment.root";
113     TFile f(filename,"RECREATE");
114     if(!f){
115       Error(macroname,"cannot open file for output\n");
116       return;
117     }
118     Info(macroname,"Saving alignment objects to the file %s", filename);
119     f.cd();
120     f.WriteObject(deltas,"ITSUAlignObjs","kSingleKey");
121     f.Close();
122   } 
123   else{
124     // save in CDB storage
125     AliCDBMetaData* md = new AliCDBMetaData();
126     md->SetResponsible("R.S.");
127     md->SetComment("Residual misalignment for ITSU");
128     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
129     AliCDBId id("ITS/Align/Data",0,AliCDBRunRange::Infinity());
130     storage->Put(deltas,id,md);
131   }
132
133   // apply to geometry
134   printf("Applying created misalignment to geometry in memory\n");
135   AliGeomManager::ApplyAlignObjsToGeom(*deltas);
136   gGeoManager->LockGeometry();
137   //
138 }