#include "AliCDBEntry.h"
#include "AliDCSValue.h"
#include "AliGRPObject.h"
+#include "AliMpArrayI.h"
+#include "AliMpConstants.h"
#include "AliMpDCSNamer.h"
#include "AliMpDEStore.h"
+#include "AliMpDetElement.h"
+#include "AliMUON2DMap.h"
+#include "AliMUONCalibParamND.h"
#include "AliMUONCalibrationData.h"
#include "AliMUONCDB.h"
+#include "AliMUONPainterDataRegistry.h"
+#include "AliMUONTrackerData.h"
+#include "AliMUONTrackerDataWrapper.h"
#include "AliLog.h"
#include "TCanvas.h"
delete fDCSNamer;
}
+//____________________________________________________________________________
+TMultiGraph* AliMUONTrackerHV::CombineMulti(TObjArray& graphs)
+{
+ // combine multigraphs
+
+ TMultiGraph* rv = new TMultiGraph;
+
+ TIter next(&graphs);
+ TMultiGraph* mg;
+ TMultiGraph* ref = static_cast<TMultiGraph*>(next());
+
+ Int_t dref = ref->GetListOfGraphs()->GetEntries();
+
+ while ( ( mg = static_cast<TMultiGraph*>(next())) )
+ {
+ TList* list = mg->GetListOfGraphs();
+ Int_t d1 = list->GetEntries();
+
+ if ( d1 != dref )
+ {
+ AliError(Form("%d vs %d",d1,dref));
+ return 0x0;
+ }
+ }
+
+ for ( Int_t i = 0; i < dref; ++i )
+ {
+ TObjArray graph;
+ next.Reset();
+ while ( ( mg = static_cast<TMultiGraph*>(next())) )
+ {
+ graph.Add(mg->GetListOfGraphs()->At(i));
+ TGraph* g = Combine(graph);
+ rv->Add(g);
+ }
+ }
+ return rv;
+}
+
+//____________________________________________________________________________
+TGraph* AliMUONTrackerHV::Combine(TObjArray& graphs)
+{
+ // make one graph out of several
+ // x axis is supposed to be time and will end up ordered in the
+ // returned graph
+
+ std::map<int, std::vector<double> > values;
+ std::map<int, std::vector<double> >::const_iterator it;
+
+ TIter next(&graphs);
+ TGraph* g;
+
+ while ( ( g = static_cast<TGraph*>(next())) )
+ {
+ for ( Int_t i = 0; i < g->GetN(); ++i )
+ {
+ std::vector<double> pair;
+
+ pair.push_back(g->GetX()[i]);
+ pair.push_back(g->GetY()[i]);
+
+ values.insert( std::make_pair(g->GetX()[i],pair));
+ }
+ }
+
+ TGraph* rv(0x0);
+
+ if ( values.size() )
+ {
+ std::vector<double> vx;
+ std::vector<double> vy;
+
+ for ( it = values.begin(); it != values.end(); ++it )
+ {
+ const std::vector<double>& q = it->second;
+
+ vx.push_back(q[0]);
+ vy.push_back(q[1]);
+ }
+
+ rv = new TGraph(values.size(),&vx[0],&vy[0]);
+ rv->GetXaxis()->SetNoExponent();
+
+ g = static_cast<TGraph*>(graphs.At(0));
+
+ rv->SetName(g->GetName());
+ rv->SetTitle(g->GetTitle());
+ }
+
+ return rv;
+}
+
//______________________________________________________________________________
void AliMUONTrackerHV::ReadIntegers(const char* filename, std::vector<int>& integers)
{
g->SetPoint(i,val->GetTimeStamp(),val->GetFloat());
++i;
}
+ g->SetName(dcsname);
return g;
}
if ( run > 0 )
{
- results.insert(std::make_pair<int,std::string>(run,message));
+ results.insert(std::make_pair(run,message));
}
message = "";
}
}
- results.insert(std::make_pair<int,std::string>(run,message));
+ results.insert(std::make_pair(run,message));
TH2* hvoff = new TH2I(outputBaseName,outputBaseName,1,0,1,1,0,1);
TObjArray* parts = s.Tokenize(":");
TString alias = (static_cast<TObjString*>(parts->At(0)))->String();
TString channel = DCSNamer()->DCSNameFromAlias(alias.Data());
+ channel += Form("(%4d)",DCSNamer()->DetElemIdFromDCSAlias(alias.Data()));
channel.ReplaceAll(".actual.vMon","");
hvoff->Fill(Form("%6d",it->first),channel.Data(),1.0);
delete parts;
hx->Draw();
c2->Print(Form("%s-perrun.pdf",outputBaseName));
TCanvas* c3 = new TCanvas;
- c3->SetBottomMargin(0.5);
+ c3->SetBottomMargin(0.55);
TH1* perchannel = hvoff->ProjectionY("hvoffperchannel");
perchannel->GetXaxis()->SetBit(TAxis::kLabelsVert);
perchannel->GetXaxis()->LabelsOption(">");
- perchannel->Draw();
+ perchannel->Draw("texthist");
c3->Print(Form("%s-perchannel.pdf",outputBaseName));
}
AliCDBManager::Instance()->SetRun(runNumber);
- TMap* m = AliMUONCalibrationData::CreateHV(runNumber,0x0,kFALSE,&messages,kTRUE);
+ Bool_t patchValues(kFALSE);
+ Bool_t dryRun(kTRUE);
+
+ TMap* m = AliMUONCalibrationData::CreateHV(runNumber,0x0,patchValues,&messages,dryRun);
TIter next(m);
TObjString* s;
while ( ( s = static_cast<TObjString*>(next()) ) )
- {
+ {
TString name(DCSNamer()->DCSNameFromAlias(s->String()));
if ( dcsname && !name.Contains(dcsname)) continue;
-
- TPair* p = static_cast<TPair*>(m->FindObject(DCSNamer()->DCSAliasFromName(dcsname).Data()));
+
+ TPair* p = static_cast<TPair*>(m->FindObject(s->String()));
if (!p) continue;
//______________________________________________________________________________
void
-AliMUONTrackerHV::Plot(const char* dcsname, Bool_t withPatch)
+AliMUONTrackerHV::Plot(const char* dcsname, Bool_t withPatch, Bool_t plotIntermediate)
{
/// Show HV values for a given dcs name (or all if dcsname=0)
/// Each canvas for each run will go to a separate PDF file
AliCDBManager::Instance()->SetDefaultStorage(fOCDBPath.Data());
TList messages;
messages.SetOwner(kTRUE);
+ TObjArray graphs;
for ( std::vector<int>::size_type i = 0; i < fRunList.size(); ++i )
{
if ( !mg ) continue;
+ graphs.Add(mg);
+
TString cname(Form("MCH_HV_RUN%09d",runNumber));
if ( strlen(dcsname) > 0 )
mg->Add(g,"");
}
- TCanvas* c = new TCanvas(cname.Data(),cname.Data());
+ if ( plotIntermediate )
+ {
+ TCanvas* c = new TCanvas(cname.Data(),cname.Data());
- c->Draw();
+ c->Draw();
- mg->SetTitle(cname.Data());
+ mg->SetTitle(cname.Data());
- mg->Draw("AL");
+ mg->Draw("AL");
- TimeAxis(mg);
+ TimeAxis(mg);
- if ( start )
- {
- startRunLine = new TLine(start,mg->GetYaxis()->GetXmin(),start,mg->GetYaxis()->GetXmax());
- startRunLine->SetLineColor(2);
- startRunLine->SetLineWidth(4);
- }
- if ( end )
- {
- endRunLine = new TLine(end,mg->GetYaxis()->GetXmin(),end,mg->GetYaxis()->GetXmax());
- endRunLine->SetLineColor(2);
- endRunLine->SetLineWidth(4);
- }
+ if ( start )
+ {
+ startRunLine = new TLine(start,mg->GetYaxis()->GetXmin(),start,mg->GetYaxis()->GetXmax());
+ startRunLine->SetLineColor(2);
+ startRunLine->SetLineWidth(4);
+ }
+ if ( end )
+ {
+ endRunLine = new TLine(end,mg->GetYaxis()->GetXmin(),end,mg->GetYaxis()->GetXmax());
+ endRunLine->SetLineColor(2);
+ endRunLine->SetLineWidth(4);
+ }
- if ( startRunLine ) startRunLine->Draw();
- if ( endRunLine ) endRunLine->Draw();
+ if ( startRunLine ) startRunLine->Draw();
+ if ( endRunLine ) endRunLine->Draw();
- c->SaveAs(Form("%s.pdf",cname.Data()));
+ c->SaveAs(Form("%s.pdf",cname.Data()));
+ }
+ }
+
+ new TCanvas;
+
+ TMultiGraph* g = CombineMulti(graphs);
+
+ TIter next(g->GetListOfGraphs());
+ TGraph* gi;
+
+ while ( ( gi = static_cast<TGraph*>(next())))
+ {
+ gi->SetMarkerStyle(kPlus);
}
+ g->Draw("alp");
+ TimeAxis(g);
}
//______________________________________________________________________________
messages.SetOwner(kTRUE);
TObjString* msg(0);
+ std::map<std::string,int> channels;
+
for ( std::vector<int>::size_type i = 0; i < fRunList.size(); ++i )
{
Int_t runNumber = fRunList[i];
TString tmp(msg->String());
tmp.ReplaceAll(channelName.Data(),DCSNamer()->DCSNameFromAlias(channelName.Data()));
report[timeStamp] = tmp.Data();
+ channels[channelName.Data()]++;
}
}
}
AliInfo(Form("%s %s",TTimeStamp(it->first).AsString("s"),it->second.c_str()));
}
}
+
+ AliInfo("--------------------------------------------------------------------");
+ AliInfo("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+
+ int totalTrips(0);
+ AliMUON2DMap tripMap(kTRUE);
+ Int_t nofChannels(AliMpConstants::ManuNofChannels());
+
+ for ( std::map<std::string,int>::const_iterator it = channels.begin(); it != channels.end(); ++it )
+ {
+ AliInfo(Form("%40s %3d",DCSNamer()->DCSNameFromAlias(it->first.c_str()).Data(),it->second));
+ totalTrips += it->second;
+
+ Int_t detElemId = DCSNamer()->DetElemIdFromDCSAlias(it->first.c_str());
+
+ AliMpDetElement* de = AliMpDEStore::Instance()->GetDetElement(detElemId);
+
+ // build the list of manuIds for this channel
+ AliMpArrayI manuArray;
+
+ manuArray.SetSize(300);
+
+ Int_t index = DCSNamer()->DCSIndexFromDCSAlias(it->first.c_str());
+ Int_t firstIndex(index);
+ Int_t lastIndex(index);
+
+ if ( index < 0 )
+ {
+ // it's a slat, must loop over PCBs
+ firstIndex = 0;
+ lastIndex = DCSNamer()->NumberOfPCBs(detElemId)-1;
+ }
+
+ for ( int i = firstIndex; i <= lastIndex ; ++i )
+ {
+ const AliMpArrayI* ma = de->ManusForHV(i);
+ if (!ma)
+ {
+ AliError(Form("Could not get ma for de %d index %d",detElemId,i));
+ continue;
+ }
+ for ( int j = 0; j < ma->GetSize(); ++j )
+ {
+ manuArray.Add(ma->GetValue(j),kFALSE);
+ }
+ }
+
+ for ( Int_t iManu = 0; iManu < manuArray.GetSize(); ++iManu )
+ {
+ Int_t manuId = manuArray.GetValue(iManu);
+
+ AliMUONVCalibParam* tripRate = new AliMUONCalibParamND(1,nofChannels,detElemId,manuId,0);
+
+ tripMap.Add(tripRate);
+
+ for ( Int_t j = 0 ; j < nofChannels; ++j )
+ {
+ tripRate->SetValueAsDouble(j,0,it->second*1.0);
+ }
+ }
+ }
+
+ AliInfo("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+ AliInfo(Form("Total of %3d trips for %4ld runs",totalTrips,fRunList.size()));
+
+ AliMUONTrackerData* data = new AliMUONTrackerData("tripcount","Number of trips",1);
+ data->Add(tripMap);
+ data->SetDimensionName(0,"ntrips");
+
+ AliMUONVTrackerDataMaker* dw = new AliMUONTrackerDataWrapper(data);
+
+ AliMUONPainterDataRegistry::Instance()->Register(dw);
+
}