Merge branch 'master' into LocalDev
[u/mrichter/AliRoot.git] / PHOS / MakePHOSAltroMapping.C
CommitLineData
81ad091b 1void MakePHOSAltroMapping(){
12b7f67f 2 // Create TObjArray of PHOS altro mapping objects.
3 // Set the environment variables in order to store it in the OCDB:
4 // export TOCDB=kTRUE
5 // export STORAGE=local://$ALICE_ROOT/OCDB
6 // Then the newly created root file $ALICE_ROOT/OCDB/PHOS/Calib/Mapping
7 // should be committed to SVN and submitted to AliEn production manager
81ad091b 8 //
12b7f67f 9 // Yuri Kharlov. 10 September 2009
7db44046 10 // $Id$
12b7f67f 11
81ad091b 12 const char* macroname = "MakePHOSAltroMapping.C";
13
12b7f67f 14 TObjArray mappingsArray(20);
81ad091b 15
12b7f67f 16 nModules = 5;
17 nRCU = 4;
81ad091b 18 TString path = gSystem->Getenv("ALICE_ROOT");
12b7f67f 19 path += "/PHOS/mapping/";
20 TString path1, path2;
21 for(Int_t m = 0; m < nModules; m++) {
22 path1 = path;
23 path1 += "Mod";
24 path1 += m;
25 path1 += "RCU";
26 for(Int_t i = 0; i < nRCU; i++) {
27 path2 = path1;
28 path2 += i;
29 path2 += ".data";
30 Info(macroname,"Mapping file: %s",path2.Data());
31 AliAltroMapping *mapping = new AliCaloAltroMapping(path2.Data());
32 mappingsArray.Add(mapping);
33 }
81ad091b 34 }
35
36 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
37 // save on file
38 const char* filename = "PHOSAltroMapping.root";
39 TFile f(filename,"RECREATE");
40 if(!f){
41 Error(macroname,"cannot open file for output\n");
42 return;
43 }
44 Info(macroname,"Saving altro mapping objects to the file %s", filename);
45 f.cd();
46 f.WriteObject(&mappingsArray,"PHOSAtroMappings","kSingleKey");
47 f.Close();
48 }else{
49 // save in CDB storage
50 TString Storage = gSystem->Getenv("STORAGE");
51 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
52 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
53 return;
54 }
55 Info(macroname,"Saving altro mapping objects in CDB storage %s",
56 Storage.Data());
57 AliCDBManager* cdb = AliCDBManager::Instance();
58 AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
59 if(!storage){
60 Error(macroname,"Unable to open storage %s\n",Storage.Data());
61 return;
62 }
63 AliCDBMetaData* md = new AliCDBMetaData();
64 md->SetResponsible("Yuri Kharlov");
12b7f67f 65 md->SetComment("Default ALTRO mapping for PHOS: 20 mapping objects, one per modules per RCU");
81ad091b 66 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
67 AliCDBId id("PHOS/Calib/Mapping",0,AliCDBRunRange::Infinity());
68 storage->Put(&mappingsArray,id,md);
69
70 delete md;
71 }
72
73 mappingsArray.Delete();
74
75}
76