]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/MakeEMCALZeroMisAlignment.C
Using AliGeomManager in the macros (Raffaele)
[u/mrichter/AliRoot.git] / EMCAL / MakeEMCALZeroMisAlignment.C
1 void MakeEMCALZeroMisAlignment(){
2   // Create TClonesArray of zero misalignment objects for EMCAL
3   //
4   TClonesArray *array = new TClonesArray("AliAlignObjAngles",10);
5   TClonesArray &alobj = *array;
6
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   }
13   AliAlignObjAngles a;
14
15   Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
16
17   const TString fbasepath = "EMCAL/FullSupermodule";
18   const TString hbasepath = "EMCAL/HalfSupermodule";
19   TString pathstr;
20
21   Int_t iIndex=0; // let all modules have index=0 in a layer with no LUT
22   AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
23   UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
24
25   Int_t i;
26   Int_t j=0;
27
28   for(i=0; i<10; i++){
29     pathstr=fbasepath;
30     pathstr+=(i+1);
31     new(alobj[j++]) AliAlignObjAngles(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
32   }
33
34   for(i=0; i<2; i++){
35     pathstr=hbasepath;
36     pathstr+=(i+1);
37     new(alobj[j++]) AliAlignObjAngles(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
38   }
39
40   const char* macroname = "MakeEMCALZeroMisAlignment.C";
41   if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
42     // save on file
43     const char* filename = "EMCALzeroMisalignment.root";
44     TFile f(filename,"RECREATE");
45     if(!f){
46       Error(macroname,"cannot open file for output\n");
47       return;
48     }
49     Info(macroname,"Saving alignment objects to the file %s", filename);
50     f.cd();
51     f.WriteObject(array,"EMCALAlignObjs","kSingleKey");
52     f.Close();
53   }else{
54     // save in CDB storage
55     TString Storage = gSystem->Getenv("STORAGE");
56     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
57       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
58       return;
59     }
60     Info(macroname,"Saving alignment objects in CDB storage %s",
61       Storage.Data());
62     AliCDBManager* cdb = AliCDBManager::Instance();
63     AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
64     if(!storage){
65       Error(macroname,"Unable to open storage %s\n",Storage.Data());
66       return;
67     }
68     AliCDBMetaData* md = new AliCDBMetaData();
69     md->SetResponsible("Jennifer Clay");
70     md->SetComment("Zero misalignment for EMCAL");
71     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
72     AliCDBId id("EMCAL/Align/Data",0,AliCDBRunRange::Infinity());
73     storage->Put(array,id,md);
74   }
75
76   array->Delete();
77
78 }
79