AliAlignObjAngles becomes AliAlignObjParams (Raffaele)
[u/mrichter/AliRoot.git] / ZDC / MakeZDCZeroMisAlignment.C
CommitLineData
d3a9c52a 1void MakeZDCZeroMisAlignment(){
2 // Create TClonesArray of zero misalignment objects for ZDC
3 //
dfe9c69d 4 if(!AliGeomManager::GetGeometry()){
5 if(!(AliCDBManager::Instance())->IsDefaultStorageSet())
6 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
7 AliCDBManager::Instance()->SetRun(0);
8 AliGeomManager::LoadGeometry();
9 }
d3a9c52a 10 // needed for the constructors with local coordinates not to fail
11
90dbf5fb 12 TClonesArray *array = new TClonesArray("AliAlignObjParams",10);
d3a9c52a 13 TClonesArray &alobj = *array;
14
90dbf5fb 15 AliAlignObjParams a;
d3a9c52a 16
17 Double_t dx=0., dy=0., dz=0.;
18 Double_t dpsi=0., dtheta=0., dphi=0.;
19
20 const char *ZDCn="ZDC/NeutronZDC";
21 const char *ZDCp="ZDC/ProtonZDC";
22
23 UShort_t iIndex=0;
ae079791 24 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
25 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
d3a9c52a 26
90dbf5fb 27 new(alobj[0]) AliAlignObjParams(ZDCn, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
28 new(alobj[1]) AliAlignObjParams(ZDCp, volid, dx, dy, dz, dpsi, dtheta, dphi,kTRUE);
d3a9c52a 29
dfe9c69d 30 const char* macroname = "MakeZDCZeroMisAlignment.C";
5bd470e1 31 if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
d3a9c52a 32 // save in file
dfe9c69d 33 const char* filename = "ZDCzeroMisalignment.root";
34 TFile f(filename,"RECREATE");
35 if(!f){
36 Error(macroname,"cannot open file for output\n");
37 return;
38 }
39 Info(macroname,"Saving alignment objects to the file %s", filename);
d3a9c52a 40 f.cd();
dfe9c69d 41 f.WriteObject(array,"ZDCAlignObjs","kSingleKey");
d3a9c52a 42 f.Close();
43 }else{
44 // save in CDB storage
dfe9c69d 45 TString Storage = gSystem->Getenv("STORAGE");
46 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
47 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
48 return;
49 }
50 Info(macroname,"Saving alignment objects in CDB storage %s",
51 Storage.Data());
d3a9c52a 52 AliCDBManager* cdb = AliCDBManager::Instance();
dfe9c69d 53 AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
54 if(!storage){
55 Error(macroname,"Unable to open storage %s\n",Storage.Data());
56 return;
57 }
d3a9c52a 58 AliCDBMetaData* md = new AliCDBMetaData();
59 md->SetResponsible("Chiara Oppedisano");
60 md->SetComment("Alignment objects for ZDC zero misalignment");
5bd470e1 61 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 62 AliCDBId id("ZDC/Align/Data",0,AliCDBRunRange::Infinity());
d3a9c52a 63 storage->Put(array,id,md);
64 }
65
66 array->Delete();
67
68}
69