Changes for Root6 (Mikolaj)
[u/mrichter/AliRoot.git] / macros / MakeCDBSnapshot.C
1 #include "AliCDBManager.h"
2 #include "AliCDBId.h"
3 #include "TCollection.h"
4 #include "TMap.h"
5 #include "TKey.h"
6 #include "TString.h"
7 #include "TObjString.h"
8 #include "TFile.h"
9 #include "TSystem.h"
10
11 void MakeSnapshot(Int_t run, const char* defStorage, TMap* specStorages, const char* snapshotFileName)
12 {
13     AliCDBManager *cdb = AliCDBManager::Instance();
14     cdb->SetDefaultStorage(defStorage);
15     cdb->SetRun(run);
16
17     TIter iter(specStorages->GetTable());
18     TPair *pair = 0;
19     while((pair = dynamic_cast<TPair*> (iter.Next()))){
20         TObjString* caltype = dynamic_cast<TObjString*> (pair->Key());
21         TObjString* specstor= dynamic_cast<TObjString*> (pair->Value());
22         if (caltype && specstor)
23             //TString calType = caltype->GetString();
24             //TString specStor = specstor->GetString();
25             //cdb->SetSpecificStorage(calType.Data(),specStor.Data());
26             cdb->SetSpecificStorage(caltype->GetString().Data(),specstor->GetString().Data());
27         else
28             //AliFatal("Error reading info for specific storage")
29             Printf("Error reading info for specific storage");
30     }
31
32     // ********************************** GRP ******************************************
33     cdb->Get("GRP/CTP/Config");
34     cdb->Get("GRP/Calib/LHCClockPhase");
35     cdb->Get("GRP/GRP/Data");
36     cdb->Get("GRP/Align/Data");
37     cdb->Get("GRP/Calib/MeanVertexSPD");
38     cdb->Get("GRP/Calib/MeanVertex");
39     cdb->Get("GRP/Calib/MeanVertexTPC");
40     cdb->Get("GRP/Calib/CosmicTriggers");
41     cdb->Get("GRP/CTP/Scalers");
42     cdb->Get("GRP/CTP/CTPtiming");
43     cdb->Get("GRP/CTP/TimeAlign");
44     cdb->Get("GRP/GRP/LHCData");
45     cdb->Get("GRP/Calib/RecoParam");
46
47     // ********************************** ALL ******************************************
48     TString detStr = ("ITS TPC TRD TOF PHOS HMPID EMCAL MUON ZDC PMD T0 VZERO");
49     //TString detStr = ("ITS MUON TPC");
50     TObjArray *arr = detStr.Tokenize(' ');
51     for (Int_t iDet=0; iDet<arr->GetEntries(); iDet++) {
52         TObjString *detOStr = dynamic_cast<TObjString*>(arr->At(iDet));
53         AliCDBManager::Instance()->GetAll(Form("%s/Calib/*",detOStr->GetString().Data()));
54         AliCDBManager::Instance()->Get(Form("%s/Align/Data",detOStr->GetString().Data()));
55     }
56
57     // ******************************** TRIGGER ****************************************
58     // Temporary fix - one has to define the correct policy in order
59     // to load the trigger OCDB entries only for the detectors that
60     // in the trigger or that are needed in order to put correct
61     // information in ESD
62     AliCDBManager::Instance()->GetAll("TRIGGER/*/*");
63
64     // ********************************** HLT ******************************************
65     // cdb->Get("HLT/ConfigHLT/esdLayout");
66     // cdb->Get("HLT/Calib/StreamerInfo");
67
68     TMap* entriesMap = const_cast<TMap*>(cdb->GetEntryCache());
69     Printf("\nentriesMap has %d entries!\n", entriesMap->GetEntries());
70
71     TList* entriesList = const_cast<TList*>(cdb->GetRetrievedIds());
72     Printf("\nentriesList has %d entries!\n", entriesList->GetEntries());
73
74     //TString filename(TString::Format("CDBsnapshot_Run%d.root",run));
75     TString filename(snapshotFileName);
76     TFile *f = new TFile(filename.Data(),"recreate");
77     f->cd();
78     f->WriteObject(entriesMap,"entriesMap");
79     f->WriteObject(entriesList,"entriesList");
80     f->Close();
81     entriesMap->SetOwnerKeyValue(kFALSE,kFALSE);
82     entriesList->SetOwner(kFALSE);
83 }
84
85 void MakeCDBSnapshot()
86 {
87     //TMap *specMap = new TMap(10);
88     TMap *specMap = new TMap(30);
89     specMap->SetName("mapOfSpecificStorages");
90     specMap->SetOwner(1);
91     specMap->Add(new TObjString("ITS/Align/Data"), new TObjString("alien://folder=/alice/simulation/2008/v4-15-Release/Residual"));
92
93     specMap->Add(new TObjString("MUON/Align/Data"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
94     specMap->Add(new TObjString("MUON/Calib/Gains"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
95     //      MTR
96     specMap->Add(new TObjString("MUON/Calib/GlobalTriggerCrateConfig"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Full"));
97     specMap->Add(new TObjString("MUON/Calib/LocalTriggerBoardMasks"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Full"));
98     specMap->Add(new TObjString("MUON/Calib/RegionalTriggerConfig"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Full"));
99     specMap->Add(new TObjString("MUON/Calib/TriggerEfficiency"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Full"));
100     // TPC (23 total) 
101     specMap->Add(new TObjString("TPC/Calib/PadGainFactor"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
102     specMap->Add(new TObjString("TPC/Calib/TimeGain"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
103     specMap->Add(new TObjString("TPC/Calib/GainFactorDedx"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
104     specMap->Add(new TObjString("TPC/Calib/PadTime0"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
105     specMap->Add(new TObjString("TPC/Calib/Distortion"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
106     specMap->Add(new TObjString("TPC/Calib/PadNoise"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
107     specMap->Add(new TObjString("TPC/Calib/PadNoise"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
108     specMap->Add(new TObjString("TPC/Calib/Pedestals"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
109     specMap->Add(new TObjString("TPC/Calib/Temperature"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
110     specMap->Add(new TObjString("TPC/Calib/Parameters"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
111     specMap->Add(new TObjString("TPC/Calib/ClusterParam"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
112     specMap->Add(new TObjString("TPC/Calib/AltroConfig"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
113     specMap->Add(new TObjString("TPC/Calib/Pulser"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
114     specMap->Add(new TObjString("TPC/Calib/Pulser"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
115     specMap->Add(new TObjString("TPC/Calib/CE"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
116     specMap->Add(new TObjString("TPC/Calib/Mapping"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
117     specMap->Add(new TObjString("TPC/Calib/Correction"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
118     specMap->Add(new TObjString("TPC/Align/Data"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
119     specMap->Add(new TObjString("TPC/Calib/Goofie"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
120     specMap->Add(new TObjString("TPC/Calib/TimeDrift"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
121     specMap->Add(new TObjString("TPC/Calib/Raw"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
122     specMap->Add(new TObjString("TPC/Calib/QA"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"));
123     specMap->Add(new TObjString("TPC/Calib/HighVoltage"), new TObjString("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/")); 
124
125
126     MakeSnapshot(139517,"alien://folder=/alice/data/2010/OCDB",specMap,"cdbSnapshot.root");
127
128 }