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