24 #if !defined(__CINT__) || defined(__MAKECINT__) 26 #include <Riostream.h> 36 #include "TObjArray.h" 37 #include "THashList.h" 39 #include "TTimeStamp.h" 40 #include "TObjString.h" 59 TGraph*
GetGraph ( Int_t imeas, Int_t ich, Int_t irpc, TList* graphList )
61 TString graphName = Form(
"%s_RPC%i_ch%i",imeas ==
kDcsI ?
"I" :
"HV", irpc, ich+1);
62 TGraph* graph =
static_cast<TGraph*
>(graphList->FindObject(graphName.Data()));
65 graph->SetName(graphName.Data());
66 graph->GetXaxis()->SetTitle(
"Time");
67 graph->GetXaxis()->SetTimeDisplay(1);
68 graph->GetYaxis()->SetTitle(imeas ==
kDcsI ?
"RPC Currents (#muA)" :
"RPC HV (V)");
69 graphList->Add(graph);
78 printf(
"Missing points can be obtained in the correct format by querying the amanda server asking for the advanced options:\n");
79 printf(
"Identification: alias; Time: Epoch\n");
80 printf(
"Identification: alias; Time: Epoch\n");
88 if ( gSystem->AccessPathName(recoveredPointsFilename.Data()) ) {
89 printf(
"Error: cannot open file %s\n",recoveredPointsFilename.Data());
93 TString currLine =
"";
94 ifstream inFile(recoveredPointsFilename.Data());
95 while ( ! inFile.eof() ) {
96 currLine.ReadLine(inFile);
97 if ( ! currLine.Contains(
";") )
continue;
99 if ( arr->GetEntries() == 3 ) {
100 Double_t timeStampFloat =
static_cast<TObjString*
>(arr->At(0))->String().Atof();
101 UInt_t timeStamp = (UInt_t)timeStampFloat;
102 TString alias =
static_cast<TObjString*
>(arr->At(1))->GetString();
103 Float_t value =
static_cast<TObjString*
>(arr->At(2))->String().Atof();
105 if ( ! missingAliases.FindObject(alias.Data()) ) {
106 printf(
"Warning: alias %s is not in the list of missing points\n",alias.Data());
109 if ( timeStamp < startTime || timeStamp > stopTime ) {
110 printf(
"Warning: the point %s %u is not in the time range (%u, %u)\n",alias.Data(),timeStamp,
startTime,
stopTime);
116 triggerDcsMap->Add(
new TObjString(alias),values);
122 printf(
"Warning: ill formed point: %s\n",currLine.Data());
137 TString cdb[2] = {cdb1, cdb2};
138 TMap* maps[2] = {0x0,0x0};
140 for ( Int_t icdb=0; icdb<2; icdb++ ) {
144 TMap* triggerDcsMap = calibrationData.
TriggerDCS();
145 if ( ! triggerDcsMap ) {
146 printf(
"Error: cannot find TriggerDCS in %s",cdb[icdb].Data());
149 maps[icdb] =
static_cast<TMap*
>(triggerDcsMap->Clone());
152 printf(
"\n\n Checking for differences between %s and %s :\n\n",cdb[0].Data(),cdb[1].Data());
155 TObjString* key = 0x0;
156 while ( (key = static_cast<TObjString*>(next())) ) {
160 printf(
"Alias %s only in %s\n",key->GetName(),cdb[0].Data());
163 if ( values1->GetEntriesFast() == values2->GetEntriesFast() ) {
164 for ( Int_t ival=0; ival<values1->GetEntries(); ival++ ) {
176 printf(
"Alias %s. Number of points: %i != %i\n",key->GetName(),values1->GetEntriesFast(),values2->GetEntriesFast());
178 maps[1]->DeleteEntry(static_cast<TPair*>(maps[1]->FindObject(key->GetName()))->Key());
181 TIter next1(maps[1]);
182 while ( (key = static_cast<TObjString*>(next1())) ) {
183 printf(
"Alias %s only in %s\n",key->GetName(),cdb[1].Data());
184 maps[1]->GetValue(key->GetName())->
Print();
187 for ( Int_t icdb=0; icdb<2; icdb++ )
delete maps[icdb
194 void CheckTriggerDCS ( Int_t
runNumber, TString ocdbPath=
"raw://", TString recoveredPointsFilename =
"", TString outDirRecovery =
"CDB" )
200 if (ocdbPath.Contains(
"alien")) TGrid::Connect(
"alien://");
211 TMap* triggerDcsMap = calibrationData.
TriggerDCS();
213 if ( ! triggerDcsMap ) {
214 printf(
"Cannot fill DCS histos, as triggerDcsMap is NULL\n");
220 UInt_t minTimeStamp = 0xFFFFFFFF;
222 UInt_t maxTimeStamp = 0;
224 THashList missingPoints;
225 missingPoints.SetOwner();
236 Int_t irpc = detElemId%100;
239 TString currAlias = triggerDcsNamer.
DCSAliasName(detElemId, 0, imeas);
241 TObjArray* values =
static_cast<TObjArray*
>(triggerDcsMap->GetValue(currAlias.Data()));
246 while ( ( val = static_cast<AliDCSValue*>(next()) ) ) {
249 if ( timeStamp < minTimeStamp ) minTimeStamp = timeStamp;
250 if ( timeStamp > maxTimeStamp ) maxTimeStamp = timeStamp;
251 TGraph* graph =
GetGraph(imeas,ich,irpc,&graphList);
253 TTimeStamp ts(timeStamp);
254 graph->SetTitle(Form(
"Date: %u (yyyymmdd)\n",ts.GetDate()));
256 graph->SetPoint(ipoint++,timeStamp,hvi);
260 printf(
"Did not find expected alias (%s) for DE %d\n",currAlias.Data(),detElemId);
261 missingPoints.Add(
new TObjString(currAlias));
269 if ( missingPoints.GetEntries() > 0 ) {
270 if ( recoveredPointsFilename.IsNull() ) {
271 printf(
"\n\nNo values found for the following aliases:\n");
272 TIter next(&missingPoints);
274 while ( (obj = next() ) )
printf(
"%s\n",obj->GetName());
277 printf(
"\nIn the time range\n");
278 UInt_t
year, month, day, hour, min, sec;
279 for ( Int_t itime=0; itime<2; itime++) {
280 UInt_t timeStamp = ( itime == 0 ) ? minTimeStamp : maxTimeStamp;
281 TTimeStamp ts(timeStamp);
282 ts.GetDate(kTRUE,0,&year,&month,&day);
283 ts.GetTime(kTRUE,0,&hour,&min,&sec);
284 TString usTime =
"AM";
289 if ( hour == 0 ) hour = 12;
291 printf(
" Amanda format: %i/%i/%i %i:%i:%i %s\n",month,day,year,hour,min,sec,usTime.Data());
295 printf(
"\nRecover missing points with data in %s\n",recoveredPointsFilename.Data());
297 TMap* clonedTriggerDCSmap =
static_cast<TMap*
>(triggerDcsMap->Clone());
299 if (
UpdateMap(clonedTriggerDCSmap, recoveredPointsFilename, minTimeStamp, maxTimeStamp, missingPoints) ) {
300 TString specStorageDir =
"MUON/Calib/TriggerDCS";
301 TString fullDir = Form(
"%s/%s",outDirRecovery.Data(),specStorageDir.Data());
302 if ( gSystem->AccessPathName(fullDir) ) gSystem->Exec(Form(
"mkdir -p %s",fullDir.Data()));
304 mgr->
SetSpecificStorage(specStorageDir.Data(),Form(
"local://%s",outDirRecovery.Data()));
311 for ( Int_t imeas=0; imeas<2; imeas++ ){
312 for ( Int_t ich=10; ich<14; ich++ ){
313 TString canName = Form(
"%s_ch%i",imeas ==
kDcsI ?
"I" :
"HV", ich+1);
314 TCanvas* can =
new TCanvas(canName.Data(), canName.Data(), 200, 10, 600, 600);
315 TLegend* leg =
new TLegend(0.6,0.6,0.9,0.9);
316 leg->SetBorderSize(1);
318 for ( Int_t irpc = 0; irpc<18; irpc++ ) {
319 TGraph* graph =
GetGraph(imeas,ich,irpc,&graphList);
320 if ( graph->GetN() == 0 ) {
324 TString drawOpt =
"lp";
325 if ( can->GetListOfPrimitives()->GetEntries() == 0 ) drawOpt.Append(
"a");
326 if ( irpc<9 ) icolor = irpc+1;
327 else icolor = (irpc-8)*10+1;
330 graph->SetLineColor(icolor);
331 graph->SetMarkerColor(icolor);
332 graph->SetMarkerStyle(20+irpc%10);
333 if ( imeas ==
kDcsHV ) graph->GetYaxis()->SetRangeUser(9500.,11000.);
334 else graph->GetYaxis()->SetRangeUser(0,10);
335 graph->GetXaxis()->SetTimeDisplay(1);
336 graph->Draw(drawOpt.Data());
337 leg->AddEntry(graph,Form(
"RPC %i",irpc),
"lp");
TMap * TriggerDCS() const
Get the Trigger HV and current values.
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
Bool_t UpdateMap(TMap *triggerDcsMap, TString recoveredPointsFilename, UInt_t startTime, UInt_t stopTime, THashList &missingAliases)
The iterator over detection elements.
Int_t year
year for detector configuration
Collection of methods usefull to DCS handling for MUON TRK and TRG.
static Bool_t LoadDDLStore(Bool_t warn=false)
Int_t CurrentDEId() const
void Print(const char *method, TStopwatch &timer, Int_t n)
static Int_t GetChamberId(Int_t detElemId, Bool_t warn=true)
void SetSpecificStorage(const char *calibType, const char *dbString, Int_t version=-1, Int_t subVersion=-1)
TGraph * GetGraph(Int_t imeas, Int_t ich, Int_t irpc, TList *graphList)
TTimeStamp startTime(2009, 8, 7, 0, 0, 0)
void CheckTriggerDCS(Int_t runNumber, TString ocdbPath="raw://", TString recoveredPointsFilename="", TString outDirRecovery="CDB")
static AliMp::StationType GetStationType(Int_t detElemId)
void UnloadFromCache(const char *path)
void SetDefaultStorage(const char *dbString)
void WriteToCDB(const char *calibpath, TObject *object, Int_t startRun, Int_t endRun, const char *filename)
Single entry point to access MUON calibration data.
Number of measured quantities.
TTimeStamp stopTime(2009, 12, 31, 0, 0, 0)
UInt_t GetTimeStamp() const
static AliCDBManager * Instance(TMap *entryCache=NULL, Int_t run=-1)
TString DCSAliasName(Int_t detElemId, Int_t sector=0, Int_t dcsMeasure=0) const
void CompareDCSvalues(Int_t runNumber, const char *cdb1, const char *cdb2)