]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/MakeVZEROZeroMisAlignment.C
Using AliGeomManager in the macros (Raffaele)
[u/mrichter/AliRoot.git] / VZERO / MakeVZEROZeroMisAlignment.C
1 void MakeVZEROZeroMisAlignment(){
2   // Create TClonesArray of zero misalignment objects for VZERO
3   //
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   }
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;
20   AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
21   UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
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
28   const char* macroname = "MakeVZEROZeroMisAlignment.C";
29   if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
30     // save on file
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);
38     f.cd();
39     f.WriteObject(array,"VZEROAlignObjs","kSingleKey");
40     f.Close();
41   }else{
42     // save in CDB storage
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());
50     AliCDBManager* cdb = AliCDBManager::Instance();
51     AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
52     if(!storage){
53       Error(macroname,"Unable to open storage %s\n",Storage.Data());
54       return;
55     }
56     AliCDBMetaData* md = new AliCDBMetaData();
57     md->SetResponsible("Brigitte Cheynis");
58     md->SetComment("Alignment objects for V0 zero-misalignment");
59     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
60     AliCDBId id("VZERO/Align/Data",0,AliCDBRunRange::Infinity());
61     storage->Put(array,id,md);
62   }
63
64   array->Delete();
65
66 }
67