Changes for Root6 (Mikolaj)
[u/mrichter/AliRoot.git] / ACORDE / MakeACORDEZeroMisAlignment.C
CommitLineData
a65a7e70 1void MakeACORDEZeroMisAlignment(){
2 // Create TClonesArray of zero misalignment objects for ACORDE
3 //
4 const char* macroname = "MakeACORDEZeroMisAlignment.C";
5 // Activate CDB storage and load geometry from CDB
6 AliCDBManager* cdb = AliCDBManager::Instance();
7 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
8 cdb->SetRun(0);
9
10 AliCDBStorage* storage;
11
12 //load geom from local file till ACORDE is not switched on by default in standard config-files
13 if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
14 TString Storage = gSystem->Getenv("STORAGE");
15 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
16 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
17 return;
18 }
19 storage = cdb->GetStorage(Storage.Data());
20 if(!storage){
21 Error(macroname,"Unable to open storage %s\n",Storage.Data());
22 return;
23 }
24
25 AliCDBPath path("GRP","Geometry","Data");
26 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
27 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
28 entry->SetOwner(0);
29 TGeoManager* geom = (TGeoManager*) entry->GetObject();
30 AliGeomManager::SetGeometry(geom);
31 }else{
32 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
33
34 }
35 // AliGeomManager::LoadGeometry("geometry.root");
36
37 TClonesArray *array = new TClonesArray("AliAlignObjParams",64);
38 TClonesArray &alobj = *array;
39
40 TRandom *rnd = new TRandom(4321);
41 Int_t j = 0;
42 Double_t dx=0, dy=0, dz=0, dpsi=0, dtheta=0, dphi=0;
43
44 // RS = local
45 // sigma translation
46 // sigma rotation
47
48 TString symname;
49 TString basename = "ACORDE/Array";
50 Int_t iIndex=0;
51 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
52 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
53
54 for (Int_t imod=0; imod<60; imod++){
55 symname = basename;
56 symname += imod;
57 new(alobj[j++]) AliAlignObjParams(symname, volid, dx, dy, dz,dpsi, dtheta, dphi, kFALSE);
58 }
59
60 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
61 // save on file
62 const char* filename = "ACORDEZeroMisalignment.root";
63 TFile f(filename,"RECREATE");
64 if(!f){
65 Error(macroname,"cannot open file for output\n");
66 return;
67 }
68 Info(macroname,"Saving alignment objects to the file %s", filename);
69 f.cd();
70 f.WriteObject(array,"ACORDEAlignObjs","kSingleKey");
71 f.Close();
72 }else{
73 // save in CDB storage
74 AliCDBMetaData* md = new AliCDBMetaData();
75 md->SetResponsible("E. Cuautle & M. Rodriguez");
76 md->SetComment("Zero misalignment for ACORDE");
77 md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
78 AliCDBId id("ACORDE/Align/Data",0,AliCDBRunRange::Infinity());
79 storage->Put(array,id,md);
80 }
81
82 array->Delete();
83
84}
85