]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/MakeEMCALFullMisAlignment.C
updates from trying things out at WSU
[u/mrichter/AliRoot.git] / EMCAL / MakeEMCALFullMisAlignment.C
1 void MakeEMCALFullMisAlignment(){
2   // Create TClonesArray of full misalignment objects for EMCAL
3   //
4   const char* macroname = "MakeEMCALFullMisAlignment.C";
5   const AliEMCALGeometry *emcalGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName(),"");
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;
12
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   
20   if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
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{
38     AliGeomManager::LoadGeometry(); //load geom from default CDB
39                                     //storage
40   }    
41
42
43   AliEMCALSurvey emcalSurvey("emcal_survey_data.txt");
44   emcalSurvey.CreateAliAlignObjParams(alobj);
45
46   // *************************    2nd step    ***************
47
48   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
49     // save on file
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);
57     f.cd();
58     f.WriteObject(array,"EMCALAlignObjs","kSingleKey");
59     f.Close();
60   }else{
61     // save in CDB storage
62     AliCDBMetaData* md = new AliCDBMetaData();
63     md->SetResponsible("Jennifer Klay");
64     md->SetComment("Full misalignment for EMCAL");
65     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
66     AliCDBId id("EMCAL/Align/Data",0,AliCDBRunRange::Infinity());
67     storage->Put(array,id,md);
68   }
69
70   array->Delete();
71
72 }
73