AliRsnReader:
[u/mrichter/AliRoot.git] / EMCAL / MakeEMCALFullMisAlignment.C
CommitLineData
1895a097 1void MakeEMCALFullMisAlignment(){
2 // Create TClonesArray of full misalignment objects for EMCAL
3 //
6fce62af 4 const char* macroname = "MakeEMCALFullMisAlignment.C";
937d0661 5 const AliEMCALGeometry *emcalGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName(),"");
289cc8a7 6 if(!emcalGeom) {
7 Error("MakeEMCALFullMisAlignment","Cannot obtain AliEMCALGeometry singleton\n");
8 return;
9 }
10 TClonesArray *array = new TClonesArray("AliAlignObjParams",emcalGeom->GetNumberOfSuperModules());
11 TClonesArray &alobj = *array;
1895a097 12
6fce62af 13 // Activate CDB storage and load geometry from CDB
14 AliCDBManager* cdb = AliCDBManager::Instance();
15 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
16 cdb->SetRun(0);
17
18 AliCDBStorage* storage;
19
a24be56b 20 if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
6fce62af 21 TString Storage = gSystem->Getenv("STORAGE");
22 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
23 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
24 return;
25 }
26 storage = cdb->GetStorage(Storage.Data());
27 if(!storage){
28 Error(macroname,"Unable to open storage %s\n",Storage.Data());
29 return;
30 }
31 AliCDBPath path("GRP","Geometry","Data");
32 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
33 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
34 entry->SetOwner(0);
35 TGeoManager* geom = (TGeoManager*) entry->GetObject();
36 AliGeomManager::SetGeometry(geom);
37 }else{
289cc8a7 38 AliGeomManager::LoadGeometry(); //load geom from default CDB
39 //storage
6fce62af 40 }
1895a097 41
1895a097 42
289cc8a7 43 AliEMCALSurvey emcalSurvey("emcal_survey_data.txt");
44 emcalSurvey.CreateAliAlignObjParams(alobj);
1895a097 45
289cc8a7 46 // ************************* 2nd step ***************
1895a097 47
a24be56b 48 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
1895a097 49 // save on file
dfe9c69d 50 const char* filename = "EMCALfullMisalignment.root";
51 TFile f(filename,"RECREATE");
52 if(!f){
53 Error(macroname,"cannot open file for output\n");
54 return;
55 }
56 Info(macroname,"Saving alignment objects to the file %s", filename);
1895a097 57 f.cd();
dfe9c69d 58 f.WriteObject(array,"EMCALAlignObjs","kSingleKey");
1895a097 59 f.Close();
60 }else{
61 // save in CDB storage
1895a097 62 AliCDBMetaData* md = new AliCDBMetaData();
289cc8a7 63 md->SetResponsible("Jennifer Klay");
1895a097 64 md->SetComment("Full misalignment for EMCAL");
5bd470e1 65 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 66 AliCDBId id("EMCAL/Align/Data",0,AliCDBRunRange::Infinity());
1895a097 67 storage->Put(array,id,md);
68 }
69
70 array->Delete();
71
72}
73