]> git.uio.no Git - u/mrichter/AliRoot.git/blob - T0/MakeT0FullMisAlignment.C
misalignment macro from Tomek
[u/mrichter/AliRoot.git] / T0 / MakeT0FullMisAlignment.C
1 void MakeT0FullMisAlignment(){
2   // Create TClonesArray of full misalignment objects for T0
3   //
4   TClonesArray *array = new TClonesArray("AliAlignObjParams",30);
5   TClonesArray &alobj = *array;
6
7   Double_t dx, dy, dz, dpsi, dtheta, dphi;
8   TRandom *rnd   = new TRandom(4321);
9   Double_t sigmatr = 0.05; // sigma for shifts in cm
10   Double_t sigmarot = 0.3; // sigma for tilts in degrees
11
12   TString symName, sn;
13
14   Int_t iIndex=0;
15   AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
16   UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
17
18   Int_t j=0;
19   for (Int_t imod=0; imod<24; imod++){
20     if (imod < 12){
21       sn="T0/C/PMT";
22     }else{
23       sn="T0/A/PMT";
24     }
25     symName = sn;
26     symName += imod+1;
27
28     dx = rnd->Gaus(0.,sigmatr);
29     dy = rnd->Gaus(0.,sigmatr);
30     dz = rnd->Gaus(0.,sigmatr);
31     dpsi = rnd->Gaus(0.,sigmarot);
32     dtheta = rnd->Gaus(0.,sigmarot);
33     dphi = rnd->Gaus(0.,sigmarot);
34
35     new(alobj[j++]) AliAlignObjParams(symName.Data(), volid, dx, dy, dz, dpsi,
36 dtheta, dphi, kTRUE);
37   }
38
39   const char* macroname = "MakeT0FullMisAlignment.C";
40   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
41     // save on file
42     const char* filename = "T0fullMisalignment.root";
43     TFile f(filename,"RECREATE");
44     if(!f){
45       Error(macroname,"cannot open file for output\n");
46       return;
47     }
48     Info(macroname,"Saving alignment objects to the file %s", filename);
49     f.cd();
50     f.WriteObject(array,"T0AlignObjs","kSingleKey");
51     f.Close();
52   }else{
53
54    // save in CDB storage
55     TString Storage = gSystem->Getenv("STORAGE");
56     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
57       Error(macroname,"STORAGE variable set to %s is not valid.
58 Exiting\n",Storage.Data());
59       return;
60     }
61     Info(macroname,"Saving alignment objects in CDB storage %s",
62          Storage.Data());
63     AliCDBManager* cdb = AliCDBManager::Instance();
64     AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
65     if(!storage){
66       Error(macroname,"Unable to open storage %s\n",Storage.Data());
67       return;
68     }
69     AliCDBMetaData* md = new AliCDBMetaData();
70     md->SetResponsible("Tomasz Malkiewicz");
71     md->SetComment("Full misalignment for T0, produced with sigmatr=0.05 and
72 sigmarot=0.3 in the local RS");
73     md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
74     AliCDBId id("T0/Align/Data",0,AliCDBRunRange::Infinity());
75     storage->Put(array,id,md);
76   }
77
78   array->Delete();
79 }
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104 void MakeT0FullMisAlignment(){
105   // Create TClonesArray of full misalignment objects for T0
106   //
107   TClonesArray *array = new TClonesArray("AliAlignObjParams",30);
108   TClonesArray &alobj = *array;
109
110   Double_t dx, dy, dz, dpsi, dtheta, dphi;
111   TRandom *rnd   = new TRandom(4321);
112   Double_t sigmatr = 0.05; // sigma for shifts in cm
113   Double_t sigmarot = 0.3; // sigma for tilts in degrees
114
115   TString symName, sn;
116
117   Int_t iIndex=0;
118   AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
119   UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
120
121   Int_t j=0;
122   for (Int_t imod=0; imod<24; imod++){
123     if (imod < 12){
124       sn="T0/C/PMT";
125     }else{
126       sn="T0/A/PMT";
127     }
128     symName = sn;
129     symName += imod+1;
130     
131     dx = rnd->Gaus(0.,sigmatr);
132     dy = rnd->Gaus(0.,sigmatr);
133     dz = rnd->Gaus(0.,sigmatr);
134     dpsi = rnd->Gaus(0.,sigmarot);
135     dtheta = rnd->Gaus(0.,sigmarot);
136     dphi = rnd->Gaus(0.,sigmarot);
137     
138     new(alobj[j++]) AliAlignObjParams(symName.Data(), volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
139   }
140   
141   const char* macroname = "MakeT0FullMisAlignment.C";
142   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
143     // save on file
144     const char* filename = "T0fullMisalignment.root";
145     TFile f(filename,"RECREATE");
146     if(!f){
147       Error(macroname,"cannot open file for output\n");
148       return;
149     }
150     Info(macroname,"Saving alignment objects to the file %s", filename);
151     f.cd();
152     f.WriteObject(array,"T0AlignObjs","kSingleKey");
153     f.Close();    TFile f(filename,"RECREATE");
154   }else{
155     // save in CDB storage
156     TString Storage = gSystem->Getenv("STORAGE");
157     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
158       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
159       return;
160     }
161     Info(macroname,"Saving alignment objects in CDB storage %s",
162          Storage.Data());
163     AliCDBManager* cdb = AliCDBManager::Instance();
164     AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
165     if(!storage){
166       Error(macroname,"Unable to open storage %s\n",Storage.Data());
167       return;
168     }
169     AliCDBMetaData* md = new AliCDBMetaData();
170     md->SetResponsible("Tomasz Malkiewicz");
171     md->SetComment("Full misalignment for T0, produced with sigmatr=0.05 and sigmarot=0.3 in the local RS");
172     md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
173     AliCDBId id("T0/Align/Data",0,AliCDBRunRange::Infinity());
174     storage->Put(array,id,md);
175   }
176
177   array->Delete();
178
179 }
180