]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/MakeTOFResMisAlignment.C
Macros for residual and full misalignment, collected by Raffaele
[u/mrichter/AliRoot.git] / TOF / MakeTOFResMisAlignment.C
1 void MakeTOFResMisAlignment(){
2   // Create TClonesArray of residual misalignment objects for TOF
3   //
4   TClonesArray *array = new TClonesArray("AliAlignObjAngles",2000);
5   TClonesArray &alobj = *array;
6    
7   if(!gGeoManager) TGeoManager::Import("geometry.root");
8   // needed for the constructors with local coordinates not to fail
9
10   AliAlignObjAngles a;
11
12   AliAlignObj::ELayerID idTOF = AliAlignObj::kTOF;
13   Int_t i;
14   Int_t j=0;
15   Double_t dx=0.; 
16   Double_t dy=0.; 
17   Double_t dz=0.;
18   Double_t  dpsi, dtheta, dphi;
19   TRandom *rnd   = new TRandom(4357);
20   Double_t sigmatr = 0.1; // max shift in cm w.r.t. local ideal RS
21
22   for(i=0; i<AliAlignObj::LayerSize(idTOF); i++) {
23     dx = 0;
24     dy = rnd->Gaus(0.,sigmatr);
25     dz = rnd->Gaus(0.,sigmatr);
26     dpsi = 0.;
27     dtheta = 0.;
28     dphi = 0.;
29     new(alobj[j]) AliAlignObjAngles(AliAlignObj::SymName(idTOF,i), AliAlignObj::LayerToVolUID(idTOF,i), dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
30     j++;
31   }
32
33   if(!gSystem->Getenv("$TOCDB")){
34     // save on file
35     TFile f("TOFresidualMisalignment.root","RECREATE");
36     if(!f) cerr<<"cannot open file for output\n";
37     f.cd();
38     f.WriteObject(array,"TOFAlignObjs","kSingleKey");
39     f.Close();
40   }else{
41     // save in CDB storage
42     const char* Storage = gSystem->Getenv("$STORAGE");
43     AliCDBManager* cdb = AliCDBManager::Instance();
44     AliCDBStorage* storage = cdb->GetStorage(Storage);
45     AliCDBMetaData* md = new AliCDBMetaData();
46     md->SetResponsible("Silvia Arcelli");
47     md->SetComment("Residual misalignment for TOF, sigmatr=1mm in the local RS");
48     md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
49     AliCDBId id("TOF/Align/Data",0,9999999);
50     storage->Put(array,id,md);
51   }
52
53   array->Delete();
54
55 }
56
57