24 #include "AliCDBManager.h"
25 #include "AliCDBEntry.h"
26 #include "AliDCSValue.h"
27 #include "AliGRPObject.h"
47 #include "TMultiGraph.h"
48 #include "TObjArray.h"
49 #include "TObjString.h"
51 #include "Riostream.h"
75 : TObject(), fRunList(), fOCDBPath(ocdbPath), fDCSNamer(0x0)
83 : TObject(), fRunList(), fOCDBPath(ocdbPath), fDCSNamer(0x0)
101 TMultiGraph* rv =
new TMultiGraph;
105 TMultiGraph* ref =
static_cast<TMultiGraph*
>(next());
107 Int_t dref = ref->GetListOfGraphs()->GetEntries();
109 while ( ( mg = static_cast<TMultiGraph*>(next())) )
111 TList* list = mg->GetListOfGraphs();
112 Int_t d1 = list->GetEntries();
116 AliError(Form(
"%d vs %d",d1,dref));
121 for ( Int_t i = 0; i < dref; ++i )
125 while ( ( mg = static_cast<TMultiGraph*>(next())) )
127 graph.Add(mg->GetListOfGraphs()->At(i));
142 std::map<int, std::vector<double> > values;
143 std::map<int, std::vector<double> >::const_iterator it;
148 while ( ( g = static_cast<TGraph*>(next())) )
150 for ( Int_t i = 0; i < g->GetN(); ++i )
152 std::vector<double> pair;
154 pair.push_back(g->GetX()[i]);
155 pair.push_back(g->GetY()[i]);
157 values.insert( std::make_pair(g->GetX()[i],pair));
165 std::vector<double> vx;
166 std::vector<double> vy;
168 for ( it = values.begin(); it != values.end(); ++it )
170 const std::vector<double>& q = it->second;
176 rv =
new TGraph(values.size(),&vx[0],&vy[0]);
177 rv->GetXaxis()->SetNoExponent();
179 g =
static_cast<TGraph*
>(graphs.At(0));
181 rv->SetName(g->GetName());
182 rv->SetTitle(g->GetTitle());
193 std::ifstream in(gSystem->ExpandPathName(filename));
196 std::set<int> runset;
200 in.getline(line,10000,
'\n');
204 if (sline.Contains(
","))
209 while ( ( s = static_cast<TObjString*>(next()) ) )
211 runset.insert(s->String().Atoi());
217 runset.insert(sline.Atoi());
225 for ( std::set<int>::const_iterator it = runset.begin(); it != runset.end(); ++it )
227 integers.push_back((*it));
230 std::sort(integers.begin(),integers.end());
266 if ( TString(runlist).Contains(
",") || TString(runlist).Contains(
" ") )
269 if ( TString(runlist).Contains(
",") )
271 runs = TString(runlist).Tokenize(
",");
275 runs = TString(runlist).Tokenize(
" ");
279 std::set<int> runset;
281 while ( ( s = static_cast<TObjString*>(next()) ) )
283 runset.insert(s->String().Atoi());
286 for ( std::set<int>::const_iterator it = runset.begin(); it != runset.end(); ++it )
309 if ( TString(dcsname).Contains(
"sw") )
318 TPair* p =
static_cast<TPair*
>(m->FindObject(
DCSNamer()->DCSAliasFromName(dcsname).Data()));
327 TGraph* g =
new TGraph(a->GetEntries());
328 while ( ( val = static_cast<AliDCSValue*>(n2()) ) )
330 g->SetPoint(i,val->GetTimeStamp(),val->GetFloat());
349 AliError(
"No runs to process...");
353 AliCDBManager::Instance()->SetDefaultStorage(
fOCDBPath.Data());
355 for ( std::vector<int>::size_type i = 0; i <
fRunList.size(); ++i )
374 std::ifstream in(logfile);
375 int run(-1),a,b,c,d,e,
f,g,h,z,other;
376 std::map<int,std::string> results;
379 const char* testProblem =
"I-AliMUONCDB::CheckHV::CheckHV: Problem at ";
381 while ( in.getline(line,1023,
'\n') )
384 if (sline.Contains(
"SUMMARY"))
388 sscanf(line,
"I-AliMUONCDB::CheckHV::CheckHV: RUN %09d HVchannel SUMMARY : # of cases A(%3d) B(%3d) C(%3d) D(%3d) E(%3d) F(%3d) G(%3d) H(%3d) Z(%3d) OTHER(%3d)",
389 &r,&a,&b,&c,&d,&e,&f,&g,&h,&z,&other);
394 AliCDBManager::Instance()->SetDefaultStorage(
fOCDBPath.Data());
395 AliCDBManager::Instance()->SetRun(r);
401 results.insert(std::make_pair(run,message));
408 else if ( sline.Contains(testProblem) )
411 message += sline(strlen(testProblem),sline.Length()-1).Data();
415 results.insert(std::make_pair(run,message));
417 TH2* hvoff =
new TH2I(outputBaseName,outputBaseName,1,0,1,1,0,1);
419 std::map<int,std::string>::const_iterator it;
421 for ( it = results.begin(); it != results.end(); ++it )
423 AliInfo(Form(
"%d -> %s",it->first,it->second.c_str()));
427 while ( ( str = static_cast<TObjString*>(next()) ) )
429 TString s(str->String());
431 TString alias = (
static_cast<TObjString*
>(parts->At(0)))->String();
433 channel += Form(
"(%4d)",
DCSNamer()->DetElemIdFromDCSAlias(alias.Data()));
434 channel.ReplaceAll(
".actual.vMon",
"");
435 hvoff->Fill(Form(
"%6d",it->first),channel.Data(),1.0);
441 hvoff->LabelsDeflate(
"x");
442 hvoff->LabelsDeflate(
"y");
443 hvoff->LabelsOption(
"x",
"<");
444 hvoff->LabelsOption(
"y",
"<");
446 TCanvas* c1 =
new TCanvas;
447 c1->SetLeftMargin(0.35);
449 c1->Print(Form(
"%s.pdf",outputBaseName));
450 TCanvas* c2 =
new TCanvas;
451 TH1* hx = hvoff->ProjectionX(
"hvoffperrun");
453 c2->Print(Form(
"%s-perrun.pdf",outputBaseName));
454 TCanvas* c3 =
new TCanvas;
455 c3->SetBottomMargin(0.55);
456 TH1* perchannel = hvoff->ProjectionY(
"hvoffperchannel");
457 perchannel->GetXaxis()->SetBit(TAxis::kLabelsVert);
458 perchannel->GetXaxis()->LabelsOption(
">");
459 perchannel->Draw(
"texthist");
460 c3->Print(Form(
"%s-perchannel.pdf",outputBaseName));
466 g->GetXaxis()->SetTimeDisplay(1);
468 g->GetXaxis()->SetTimeFormat(
"%d/%m %H:%M");
469 g->GetXaxis()->SetTimeOffset(0,
"gmt");
470 g->GetXaxis()->SetNdivisions(505);
481 TMultiGraph* mg =
new TMultiGraph;
483 while ( ( s = static_cast<TObjString*>(next()) ) )
485 TString name(
DCSNamer()->DCSNameFromAlias(s->String()));
487 if ( dcsname && !name.Contains(dcsname))
continue;
493 g->SetMarkerSize(1.5);
494 g->SetMarkerStyle(2);
497 g->SetTitle(name.Data());
510 AliCDBManager::Instance()->SetDefaultStorage(
fOCDBPath.Data());
512 messages.SetOwner(kTRUE);
514 for ( std::vector<int>::size_type iRun = 0; iRun <
fRunList.size(); ++iRun )
518 AliInfo(
"---------------------");
519 AliInfo(Form(
"RUN %09d",runNumber));
523 AliCDBManager::Instance()->SetRun(runNumber);
525 Bool_t patchValues(kFALSE);
526 Bool_t dryRun(kTRUE);
533 while ( ( s = static_cast<TObjString*>(next()) ) )
535 TString name(
DCSNamer()->DCSNameFromAlias(s->String()));
537 if ( dcsname && !name.Contains(dcsname))
continue;
539 TPair* p =
static_cast<TPair*
>(m->FindObject(s->String()));
548 while ( ( val = static_cast<AliDCSValue*>(n2()) ) )
550 std::cout << Form(
"i=%5d ",i) << std::endl;
565 AliCDBManager::Instance()->SetDefaultStorage(
fOCDBPath.Data());
567 messages.SetOwner(kTRUE);
570 for ( std::vector<int>::size_type i = 0; i <
fRunList.size(); ++i )
576 AliCDBManager::Instance()->SetRun(runNumber);
580 TMultiGraph* mg =
GraphHV(m,dcsname);
586 TString cname(Form(
"MCH_HV_RUN%09d",runNumber));
588 if ( strlen(dcsname) > 0 )
591 s.ReplaceAll(
"/",
"_");
592 cname += Form(
"_dcsname_%s",s.Data());
595 AliCDBEntry* e = AliCDBManager::Instance()->Get(
"GRP/GRP/Data",runNumber);
597 TLine* startRunLine(0);
598 TLine* endRunLine(0);
604 AliGRPObject* grp =
static_cast<AliGRPObject*
>(e->GetObject());
607 start = grp->GetTimeStart();
608 end = grp->GetTimeEnd();
614 TGraph* g =
new TGraph(1);
615 g->SetPoint(0,end,0);
619 if ( plotIntermediate )
621 TCanvas* c =
new TCanvas(cname.Data(),cname.Data());
625 mg->SetTitle(cname.Data());
633 startRunLine =
new TLine(start,mg->GetYaxis()->GetXmin(),start,mg->GetYaxis()->GetXmax());
634 startRunLine->SetLineColor(2);
635 startRunLine->SetLineWidth(4);
639 endRunLine =
new TLine(end,mg->GetYaxis()->GetXmin(),end,mg->GetYaxis()->GetXmax());
640 endRunLine->SetLineColor(2);
641 endRunLine->SetLineWidth(4);
644 if ( startRunLine ) startRunLine->Draw();
645 if ( endRunLine ) endRunLine->Draw();
647 c->SaveAs(Form(
"%s.pdf",cname.Data()));
655 TIter next(g->GetListOfGraphs());
658 while ( ( gi = static_cast<TGraph*>(next())))
660 gi->SetMarkerStyle(kPlus);
673 AliCDBManager::Instance()->SetDefaultStorage(
fOCDBPath.Data());
676 messages.SetOwner(kTRUE);
679 std::map<std::string,int> channels;
681 for ( std::vector<int>::size_type i = 0; i <
fRunList.size(); ++i )
685 AliInfo(
"---------------------");
691 AliCDBManager::Instance()->SetRun(runNumber);
700 TIter next(&messages);
702 while ( ( msg = static_cast<TObjString*>(next())) )
704 if ( msg->String().Contains(
"TRIP") && ( includeLowOnes || !msg->String().Contains(
"LOWTRIP") ) )
710 AliInfo(Form(
"RUN %09d - %d trip%c",runNumber,ntrips,(ntrips>1 ?
's':
' ')));
713 std::map<int,std::string> report;
715 while ( ( msg = static_cast<TObjString*>(next())) )
717 if ( msg->String().Contains(
"TRIP") )
719 TObjArray* parts = msg->String().Tokenize(
" ");
720 TString channelName(static_cast<TObjString*>(parts->At(0))->String());
722 for ( Int_t ip = 0; ip <= parts->GetLast(); ++ip)
724 TString p(static_cast<TObjString*>(parts->At(ip))->String());
726 if ( p.Contains(
"TRIP") )
728 if ( includeLowOnes || !p.Contains(
"LOWTRIP") )
730 TString ts(static_cast<TObjString*>(parts->At(ip+2))->String());
734 Int_t index = ts.Index(
"TS:");
736 UInt_t timeStamp = TString(ts(index+strlen(
"TS:"),ts.Length()-index)).Atoi();
738 TString tmp(msg->String());
740 report[timeStamp] = tmp.Data();
741 channels[channelName.Data()]++;
749 for ( std::map<int,std::string>::const_iterator it = report.begin(); it != report.end(); ++it )
751 AliInfo(Form(
"%s %s",TTimeStamp(it->first).AsString(
"s"),it->second.c_str()));
755 AliInfo(
"--------------------------------------------------------------------");
756 AliInfo(
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
762 for ( std::map<std::string,int>::const_iterator it = channels.begin(); it != channels.end(); ++it )
764 AliInfo(Form(
"%40s %3d",
DCSNamer()->DCSNameFromAlias(it->first.c_str()).Data(),it->second));
765 totalTrips += it->second;
777 Int_t firstIndex(index);
778 Int_t lastIndex(index);
787 for (
int i = firstIndex; i <= lastIndex ; ++i )
792 AliError(Form(
"Could not get ma for de %d index %d",detElemId,i));
795 for (
int j = 0; j < ma->
GetSize(); ++j )
801 for ( Int_t iManu = 0; iManu < manuArray.
GetSize(); ++iManu )
803 Int_t manuId = manuArray.
GetValue(iManu);
807 tripMap.
Add(tripRate);
809 for ( Int_t j = 0 ; j < nofChannels; ++j )
816 AliInfo(
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
817 AliInfo(Form(
"Total of %3d trips for %4ld runs",totalTrips,
fRunList.size()));
Implementation of AliMUONVTrackerData.
void Plot(const char *dcsname=0x0, Bool_t withPatch=kFALSE, Bool_t plotIntermediate=kFALSE)
AliMpDCSNamer * fDCSNamer
TMultiGraph * GraphHV(TMap *m, const char *dcsname)
static AliMpDEStore * Instance(Bool_t warn=true)
AliMUONTrackerHV(const char *runlist, const char *ocdbPath="raw://")
void HVoff(const char *logfile="lhc11de.log", const char *outputBaseName="hvoff")
void CheckHV(Int_t runNumber, Int_t verbose=0)
TFile f("CalibObjects.root")
Producer of some AliMUONVTrackerData.
Collection of methods usefull to DCS handling for MUON TRK and TRG.
strP3 Tokenize("+") -> Print()
Bool_t Add(Int_t value, Bool_t warn=kTRUE)
virtual void SetDimensionName(Int_t index, const char *value)
Set the name of a given dimension.
Int_t NumberOfPCBs(Int_t detElemId) const
AliMpDetElement * GetDetElement(Int_t detElemId, Bool_t warn=true) const
The class defines the electronics properties of detection element.
TMultiGraph * CombineMulti(TObjArray &graphs)
void TimeAxis(TMultiGraph *g)
void Register(AliMUONVTrackerDataMaker *reader)
static AliMUONPainterDataRegistry * Instance()
Container of calibration values for a given number of channels.
TString DCSNameFromAlias(const char *dcsAlias) const
static Int_t ManuNofChannels()
Max number of channels per manu.
void ReportTrips(Bool_t includeLowOnes=kFALSE)
std::vector< int > fRunList
std::vector< RunInfo > runs
Implementation of AliMUONVCalibParam for tuples of double.
Int_t DCSIndexFromDCSAlias(const char *dcsAlias) const
TGraph * Combine(TObjArray &graphs)
Helper class for sorted integer array.
Bool_t Add(const AliMUONTrackerData &data)
Basic implementation of AliMUONVStore container using AliMpExMap internally.
TGraph * GraphValues(TMap *m, const char *name)
Simple wrapper of AliMUONVTrackerData (for backward compatibility)
AliMpDCSNamer * DCSNamer() const
virtual Bool_t Add(TObject *object)
Add an object to the store.
void ReadIntegers(const char *filename, std::vector< int > &integers)
virtual ~AliMUONTrackerHV()
static TMap * CreateHV(Int_t runNumber, Int_t *startOfValidity=0, Bool_t patched=kTRUE, TList *messages=0x0, Bool_t dryRun=kFALSE)
Create a hv map (which must be deleted) from OCDB for the given run.
const AliMpArrayI * ManusForHV(Int_t hvIndex) const
Int_t GetValue(Int_t index) const
Int_t DetElemIdFromDCSAlias(const char *dcsAlias) const
Bool_t LoadMapping(Bool_t segmentationOnly=kFALSE)
void Print(Option_t *dcsname="") const
void Scan(Int_t verbose=0)
ClassImp(AliMUONTrackerHV) AliMUONTrackerHV
virtual void SetValueAsDouble(Int_t i, Int_t j, Double_t value)
void SetRunList(Int_t runNumber)