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