]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/MakeVZEROZeroMisAlignment.C
Using AliGeomManager in the macros (Raffaele)
[u/mrichter/AliRoot.git] / VZERO / MakeVZEROZeroMisAlignment.C
CommitLineData
d3a9c52a 1void MakeVZEROZeroMisAlignment(){
2 // Create TClonesArray of zero misalignment objects for VZERO
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
12 TClonesArray *array = new TClonesArray("AliAlignObjAngles",10);
13 TClonesArray &alobj = *array;
14
15 AliAlignObjAngles a;
16
17 Double_t dx, dy, dz, dpsi, dtheta, dphi;
18
19 Int_t iIndex=0;
ae079791 20 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
21 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
d3a9c52a 22
23 TString V0right("VZERO/V0C");
24 new(alobj[0]) AliAlignObjAngles(V0right.Data(), volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
25 TString V0left("VZERO/V0A");
26 new(alobj[1]) AliAlignObjAngles(V0left.Data(), volid, dx, dy, dz, dpsi, dtheta, dphi,kTRUE);
27
dfe9c69d 28 const char* macroname = "MakeVZEROZeroMisAlignment.C";
5bd470e1 29 if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
d3a9c52a 30 // save on file
dfe9c69d 31 const char* filename = "VZEROzeroMisalignment.root";
32 TFile f(filename,"RECREATE");
33 if(!f){
34 Error(macroname,"cannot open file for output\n");
35 return;
36 }
37 Info(macroname,"Saving alignment objects to the file %s", filename);
d3a9c52a 38 f.cd();
dfe9c69d 39 f.WriteObject(array,"VZEROAlignObjs","kSingleKey");
d3a9c52a 40 f.Close();
41 }else{
42 // save in CDB storage
dfe9c69d 43 TString Storage = gSystem->Getenv("STORAGE");
44 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
45 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
46 return;
47 }
48 Info(macroname,"Saving alignment objects in CDB storage %s",
49 Storage.Data());
d3a9c52a 50 AliCDBManager* cdb = AliCDBManager::Instance();
dfe9c69d 51 AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
52 if(!storage){
53 Error(macroname,"Unable to open storage %s\n",Storage.Data());
54 return;
55 }
d3a9c52a 56 AliCDBMetaData* md = new AliCDBMetaData();
57 md->SetResponsible("Brigitte Cheynis");
58 md->SetComment("Alignment objects for V0 zero-misalignment");
5bd470e1 59 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 60 AliCDBId id("VZERO/Align/Data",0,AliCDBRunRange::Infinity());
d3a9c52a 61 storage->Put(array,id,md);
62 }
63
64 array->Delete();
65
66}
67