Classed moved form libJETANMC to libJETAN.
[u/mrichter/AliRoot.git] / ZDC / MakeZDCFullMisAlignment.C
CommitLineData
1895a097 1void MakeZDCFullMisAlignment(){
2 // Create TClonesArray of full 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 }
1895a097 10 // needed for the constructors with local coordinates not to fail
11
12 TClonesArray *array = new TClonesArray("AliAlignObjAngles",10);
13 TClonesArray &alobj = *array;
14
15 AliAlignObjAngles a;
16
17 Double_t dx=0., dy=2., dz=0.;
18 Double_t dpsi=0., dtheta=0., dphi=0.;
19
e953c953 20 const char *ZDCn="ZDC/NeutronZDC";
21 const char *ZDCp="ZDC/ProtonZDC";
1895a097 22
23 Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
ae079791 24 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
25 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
1895a097 26
e953c953 27 new(alobj[0]) AliAlignObjAngles(ZDCn, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
28 new(alobj[1]) AliAlignObjAngles(ZDCp, volid, dx, dy, dz, dpsi, dtheta, dphi,kTRUE);
1895a097 29
dfe9c69d 30 const char* macroname = "MakeZDCFullMisAlignment.C";
5bd470e1 31 if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
1895a097 32 // save in file
dfe9c69d 33 const char* filename = "ZDCfullMisalignment.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);
1895a097 40 f.cd();
dfe9c69d 41 f.WriteObject(array,"ZDCAlignObjs","kSingleKey");
1895a097 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());
1895a097 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 }
1895a097 58 AliCDBMetaData* md = new AliCDBMetaData();
59 md->SetResponsible("Chiara Oppedisano");
60 md->SetComment("Alignment objects for ZDC full misalignment");
5bd470e1 61 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 62 AliCDBId id("ZDC/Align/Data",0,AliCDBRunRange::Infinity());
1895a097 63 storage->Put(array,id,md);
64 }
65
66 array->Delete();
67
68}
69