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