]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/MakePHOSAltroMapping.C
Input number added to Print
[u/mrichter/AliRoot.git] / PHOS / MakePHOSAltroMapping.C
1 void MakePHOSAltroMapping(){
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
8   //
9   // Yuri Kharlov. 10 September 2009
10   // $Id$
11
12   const char* macroname = "MakePHOSAltroMapping.C";
13
14   TObjArray mappingsArray(20);
15   
16   nModules = 5;
17   nRCU     = 4;
18   TString path = gSystem->Getenv("ALICE_ROOT");
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     }
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");
65     md->SetComment("Default ALTRO mapping for PHOS: 20 mapping objects, one per modules per RCU");
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