bugfix: corrected defines to use right default algorithms
[u/mrichter/AliRoot.git] / VZERO / MakeVZEROResMisAlignment.C
... / ...
CommitLineData
1void MakeVZEROResMisAlignment(){
2 // Create TClonesArray of residual misalignment objects for VZERO
3 //
4 const char* macroname = "MakeVZEROResMisAlignment.C";
5
6 TClonesArray *array = new TClonesArray("AliAlignObjParams",10);
7 TClonesArray &alobj = *array;
8
9 // Activate CDB storage and load geometry from CDB
10 AliCDBManager* cdb = AliCDBManager::Instance();
11 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
12 cdb->SetRun(0);
13
14 AliCDBStorage* storage;
15
16 if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
17 TString Storage = gSystem->Getenv("STORAGE");
18 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
19 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
20 return;
21 }
22 storage = cdb->GetStorage(Storage.Data());
23 if(!storage){
24 Error(macroname,"Unable to open storage %s\n",Storage.Data());
25 return;
26 }
27 AliCDBPath path("GRP","Geometry","Data");
28 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
29 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
30 entry->SetOwner(0);
31 TGeoManager* geom = (TGeoManager*) entry->GetObject();
32 AliGeomManager::SetGeometry(geom);
33 }else{
34 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
35 }
36
37 Double_t dx, dy, dz, dpsi, dtheta, dphi;
38 TRandom *rnd = new TRandom(4321);
39 Double_t sigmatr = 0.1; // max shift in cm
40 Double_t sigmarot = 0.5; // max rot in degrees
41
42 const char *V0right="VZERO/V0C";
43 const char *V0left="VZERO/V0A";
44
45 Int_t iIndex=0;
46 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
47 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
48
49 dx = rnd->Gaus(0.,sigmatr);
50 dy = rnd->Gaus(0.,sigmatr);
51 dz = rnd->Gaus(0.,sigmatr);
52 dpsi = rnd->Gaus(0.,sigmarot);
53 dtheta = rnd->Gaus(0.,sigmarot);
54 dphi = rnd->Gaus(0.,sigmarot);
55 new(alobj[0]) AliAlignObjParams(V0right, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
56 dx = rnd->Gaus(0.,sigmatr);
57 dy = rnd->Gaus(0.,sigmatr);
58 dz = rnd->Gaus(0.,sigmatr);
59 dpsi = rnd->Gaus(0.,sigmarot);
60 dtheta = rnd->Gaus(0.,sigmarot);
61 dphi = rnd->Gaus(0.,sigmarot);
62 new(alobj[1]) AliAlignObjParams(V0left, volid, dx, dy, dz, dpsi, dtheta, dphi,kFALSE);
63
64 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
65 // save on file
66 const char* filename = "VZEROresidualMisalignment.root";
67 TFile f(filename,"RECREATE");
68 if(!f){
69 Error(macroname,"cannot open file for output\n");
70 return;
71 }
72 Info(macroname,"Saving alignment objects to the file %s", filename);
73 f.cd();
74 f.WriteObject(array,"VZEROAlignObjs","kSingleKey");
75 f.Close();
76 }else{
77 // save in CDB storage
78 AliCDBMetaData* md = new AliCDBMetaData();
79 md->SetResponsible("Brigitte Cheynis");
80 md->SetComment("Alignment objects for V0 residual misalignment");
81 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
82 AliCDBId id("VZERO/Align/Data",0,AliCDBRunRange::Infinity());
83 storage->Put(array,id,md);
84 }
85
86 array->Delete();
87
88}
89