]> git.uio.no Git - u/mrichter/AliRoot.git/blame - SHUTTLE/DCSClient/macros/TestClientAlias.C
set arrays to 0 after delete to avoid crash in Pb reconstruction - Ruben
[u/mrichter/AliRoot.git] / SHUTTLE / DCSClient / macros / TestClientAlias.C
CommitLineData
1d172743 1TMap* GetValues(const char* host, Int_t port, const char* request,
1790d4b7 2 UInt_t startTime, UInt_t endTime, Int_t multiSplit)
4b4eb769 3{
1790d4b7 4 AliDCSClient client(host, port, 1000, 20, multiSplit);
542b6cc8 5 // The 5th parameter switches from single alias to multi aliases!
4b4eb769 6
1d172743 7 //Int_t result;
4b4eb769 8
9 TTimeStamp currentTime;
1d172743 10 //TMap values;
4b4eb769 11
12 TString rString(request);
13
14 TObjArray* requests = rString.Tokenize(",");
15
16 cout<<"Requests: "<<requests->GetEntries()<<endl;
17
1d172743 18 TMap* values=0;
19
4b4eb769 20 TStopwatch sw;
21 sw.Start();
1d172743 22
23 if(requests->GetEntries() == 0) return NULL;
24
25// TIter iter(requests);
26// TObjString* aString;
27// TObjArray* valueSet;
28// while ((aString = (TObjString*) iter.Next())) {
29// cout<<" Querying: "<<aString->GetName()<<endl;
30// valueSet = new TObjArray();
31// valueSet->SetOwner(1);
32//
33// result = client.GetAliasValues(aString->GetName(), startTime,
34// endTime, valueSet);
35// values.Add(aString->Clone(), valueSet);
36// }
37
38 values = client.GetAliasValues(requests, startTime, endTime);
39
40 if (!values) {
1790d4b7 41 cout<<"Query failed! Result error: "<<
42 client.GetErrorString(client.GetResultErrorCode()) <<endl;
43 if(client.GetResultErrorCode() == AliDCSClient::fgkServerError)
44 cout<<"Server error: "<<
45 client.GetServerError().Data() <<endl;
1d172743 46 return NULL;
4b4eb769 47 }
48
49 sw.Stop();
50 cout<<"Elapsed time: "<<sw.RealTime()<<endl;
4b4eb769 51
1d172743 52 cout<<"Time per alias: "<<sw.RealTime()/requests->GetEntries()<<endl;
53
54 cout<<"Received values: "<<endl;
55
56 Int_t nValues=0;
57
58 TIter iter(values);
4b4eb769 59 TObjString* aRequest;
60 while ((aRequest = (TObjString*) iter.Next())) {
61
1d172743 62 TObjArray* valueSet = (TObjArray*) values->GetValue(aRequest);
4b4eb769 63
64 cout<<" '"<<aRequest->String()<<"' values: "
65 <<valueSet->GetEntriesFast()<<endl;
66
67 TIter valIter(valueSet);
68 AliDCSValue* aValue;
69 while ((aValue = (AliDCSValue*) valIter.Next())) {
70 cout<<aValue->ToString()<<endl;
1d172743 71 nValues++;
4b4eb769 72 }
73 }
1d172743 74
75 cout<<"Number of received values: "<< nValues <<endl;
76
4b4eb769 77
78/*
79 TFile file("dump.root", "UPDATE");
80 file.cd();
eba76848 81 values.Write("DCSAliasMap", TObject::kSingleKey);
4b4eb769 82 file.Close();
83*/
84
1d172743 85 //values.DeleteAll();
86 //delete requests;
4b4eb769 87
88 cout<<"All values returned in runrange: "<<endl;
89 cout<<"StartTime: "<<TTimeStamp(startTime).AsString()<<endl;
90 cout<<"EndTime: "<<TTimeStamp(endTime).AsString()<<endl;
1d172743 91
92 return values;
4b4eb769 93}
94
1d172743 95TMap* TestClientAlias(const char* host, Int_t port, const char* request,
1790d4b7 96 UInt_t startShift, UInt_t endShift, UInt_t multiSplit) {
4b4eb769 97
2c15234c 98 gSystem->Load("$ALICE_ROOT/SHUTTLE/DCSClient/AliDCSClient");
4b4eb769 99
100// AliLog::EnableDebug(kFALSE);
101// AliLog::SetGlobalDebugLevel(3);
102
103 TTimeStamp currentTime;
104
542b6cc8 105
1d172743 106 TMap* values = GetValues(host, port, request,
4b4eb769 107 currentTime.GetSec() - startShift,
1790d4b7 108 currentTime.GetSec() - endShift, multiSplit);
542b6cc8 109
1d172743 110 if(values) values->Print();
111
112 cout << endl;
113 cout <<"Client done"<<endl;
114
115 return values;
4b4eb769 116}