AliAlignObjAngles becomes AliAlignObjParams (Raffaele)
[u/mrichter/AliRoot.git] / T0 / MakeT0FullMisAlignment.C
CommitLineData
dc7ca31d 1void MakeT0FullMisAlignment(){
2 // Create TClonesArray of full misalignment objects for T0
3 //
90dbf5fb 4 TClonesArray *array = new TClonesArray("AliAlignObjParams",30);
dc7ca31d 5 TClonesArray &alobj = *array;
6
dfe9c69d 7 if(!AliGeomManager::GetGeometry()){
8 if(!(AliCDBManager::Instance())->IsDefaultStorageSet())
9 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
10 AliCDBManager::Instance()->SetRun(0);
11 AliGeomManager::LoadGeometry();
12 }
dc7ca31d 13
90dbf5fb 14 AliAlignObjParams a;
dc7ca31d 15
16 Double_t dx, dy, dz, dpsi, dtheta, dphi;
17 TRandom *rnd = new TRandom(4321);
d3a9c52a 18 Double_t sigmatr = 0.05; // sigma for shifts in cm
19 Double_t sigmarot = 0.3; // sigma for tilts in degrees
dc7ca31d 20
d3a9c52a 21 TString symName, sn;
dc7ca31d 22
d3a9c52a 23 Int_t iIndex=0;
ae079791 24 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
25 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
dc7ca31d 26
d3a9c52a 27 Int_t j=0;
28 for (Int_t imod=0; imod<24; imod++){
29 if (imod < 12){
30 sn="T0/C/PMT";
31 }else{
32 sn="T0/A/PMT";
33 }
34 symName = sn;
35 symName += imod+1;
36
37 dx = rnd->Gaus(0.,sigmatr);
38 dy = rnd->Gaus(0.,sigmatr);
39 dz = rnd->Gaus(0.,sigmatr);
40 dpsi = rnd->Gaus(0.,sigmarot);
41 dtheta = rnd->Gaus(0.,sigmarot);
42 dphi = rnd->Gaus(0.,sigmarot);
43
90dbf5fb 44 new(alobj[j++]) AliAlignObjParams(symName.Data(), volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
d3a9c52a 45 }
46
dfe9c69d 47 const char* macroname = "MakeT0FullMisAlignment.C";
48 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
dc7ca31d 49 // save on file
dfe9c69d 50 const char* filename = "T0fullMisalignment.root";
51 TFile f(filename,"RECREATE");
52 if(!f){
53 Error(macroname,"cannot open file for output\n");
54 return;
55 }
56 Info(macroname,"Saving alignment objects to the file %s", filename);
dc7ca31d 57 f.cd();
dfe9c69d 58 f.WriteObject(array,"T0AlignObjs","kSingleKey");
59 f.Close(); TFile f(filename,"RECREATE");
dc7ca31d 60 }else{
61 // save in CDB storage
dfe9c69d 62 TString Storage = gSystem->Getenv("STORAGE");
63 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
64 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
65 return;
66 }
67 Info(macroname,"Saving alignment objects in CDB storage %s",
68 Storage.Data());
dc7ca31d 69 AliCDBManager* cdb = AliCDBManager::Instance();
dfe9c69d 70 AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
71 if(!storage){
72 Error(macroname,"Unable to open storage %s\n",Storage.Data());
73 return;
74 }
dc7ca31d 75 AliCDBMetaData* md = new AliCDBMetaData();
76 md->SetResponsible("Tomasz Malkiewicz");
77 md->SetComment("Full misalignment for T0, produced with sigmatr=0.05 and sigmarot=0.3 in the local RS");
8d0a15a4 78 md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
dfe9c69d 79 AliCDBId id("T0/Align/Data",0,AliCDBRunRange::Infinity());
dc7ca31d 80 storage->Put(array,id,md);
81 }
82
83 array->Delete();
84
85}
86