Loaders removed from the reconstruction code (C.Cheshkov)
[u/mrichter/AliRoot.git] / TOF / MakeTOFResMisAlignment.C
CommitLineData
1895a097 1void MakeTOFResMisAlignment(){
2 // Create TClonesArray of residual misalignment objects for TOF
3 //
4 TClonesArray *array = new TClonesArray("AliAlignObjAngles",2000);
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 }
1895a097 13 // needed for the constructors with local coordinates not to fail
14
15 AliAlignObjAngles a;
16
ae079791 17 AliGeomManager::ELayerID idTOF = AliGeomManager::kTOF;
1895a097 18 Int_t i;
19 Int_t j=0;
20 Double_t dx=0.;
21 Double_t dy=0.;
22 Double_t dz=0.;
23 Double_t dpsi, dtheta, dphi;
24 TRandom *rnd = new TRandom(4357);
25 Double_t sigmatr = 0.1; // max shift in cm w.r.t. local ideal RS
26
ae079791 27 for(i=0; i<AliGeomManager::LayerSize(idTOF); i++) {
1895a097 28 dx = 0;
29 dy = rnd->Gaus(0.,sigmatr);
30 dz = rnd->Gaus(0.,sigmatr);
31 dpsi = 0.;
32 dtheta = 0.;
33 dphi = 0.;
ae079791 34 new(alobj[j]) AliAlignObjAngles(AliGeomManager::SymName(idTOF,i), AliGeomManager::LayerToVolUID(idTOF,i), dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
1895a097 35 j++;
36 }
37
dfe9c69d 38 const char* macroname = "MakeTOFResMisAlignment.C";
5bd470e1 39 if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
1895a097 40 // save on file
dfe9c69d 41 const char* filename = "TOFresidualMisalignment.root";
42 TFile f(filename,"RECREATE");
43 if(!f){
44 Error(macroname,"cannot open file for output\n");
45 return;
46 }
47 Info(macroname,"Saving alignment objects to the file %s", filename);
1895a097 48 f.cd();
49 f.WriteObject(array,"TOFAlignObjs","kSingleKey");
50 f.Close();
51 }else{
52 // save in CDB storage
dfe9c69d 53 TString Storage = gSystem->Getenv("STORAGE");
54 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
55 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
56 return;
57 }
58 Info(macroname,"Saving alignment objects in CDB storage %s",
59 Storage.Data());
1895a097 60 AliCDBManager* cdb = AliCDBManager::Instance();
dfe9c69d 61 AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
62 if(!storage){
63 Error(macroname,"Unable to open storage %s\n",Storage.Data());
64 return;
65 }
1895a097 66 AliCDBMetaData* md = new AliCDBMetaData();
67 md->SetResponsible("Silvia Arcelli");
68 md->SetComment("Residual misalignment for TOF, sigmatr=1mm in the local RS");
5bd470e1 69 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 70 AliCDBId id("TOF/Align/Data",0,AliCDBRunRange::Infinity());
1895a097 71 storage->Put(array,id,md);
72 }
73
74 array->Delete();
75
76}
77
78