// $Id$
#include "AliMUONTrackerHV.h"
-#include "Riostream.h"
-#include "TObjArray.h"
-#include "TObjString.h"
-#include "AliDCSValue.h"
-#include "TMap.h"
+
+#include <algorithm>
#include <map>
-#include "AliMpDCSNamer.h"
-#include "TH2.h"
-#include "TStyle.h"
-#include "AliCDBEntry.h"
-#include "AliCDBManager.h"
-#include "TLine.h"
#include <set>
+
+#include "AliCDBManager.h"
+#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"
#include "TGraph.h"
+#include "TH2.h"
+#include "TLine.h"
+#include "TMap.h"
#include "TMultiGraph.h"
-#include "AliMUONCDB.h"
-#include "TCanvas.h"
-#include "AliMUONCalibrationData.h"
-#include "AliGRPObject.h"
-#include <map>
-#include <algorithm>
+#include "TObjArray.h"
+#include "TObjString.h"
+#include "TStyle.h"
+#include "Riostream.h"
+
+//
+// Class to inspect the MUON TRACKER HV values
+//
+// With this class you can :
+//
+// a) get a list of trips (method ReportTrips)
+// b) print the values for some (or all) HV channels (method Print)
+// c) plot the values for some (or all) HV channels (method Plot)
+// d) get a list of HV channels that are "OFF" (methods Scan and HVoff)
+//
+// Note that in this class, all the output (either text or canvas) or the
+// channel *names* used are the same as in the DCS UI at Pt2
+// Specifically the chamber ids start at 1, the slat numbers at 1 and
+// the quad and sect number at 1 also. And not at zero like for the
+// DCS *aliases*. On the contraty, the internal map, coming from the OCDB,
+// only contains aliases, not names. Confusing ? It is.
+//
ClassImp(AliMUONTrackerHV)
//______________________________________________________________________________
-AliMUONTrackerHV::AliMUONTrackerHV(const char* runlist, const char* ocdbPath) : TObject(), fRunList(), fOCDBPath(ocdbPath)
+AliMUONTrackerHV::AliMUONTrackerHV(const char* runlist, const char* ocdbPath)
+: TObject(), fRunList(), fOCDBPath(ocdbPath), fDCSNamer(0x0)
{
// ctor from a runlist (txt file)
SetRunList(runlist);
}
//______________________________________________________________________________
-AliMUONTrackerHV::AliMUONTrackerHV(Int_t runNumber, const char* ocdbPath) : TObject(), fRunList(), fOCDBPath(ocdbPath)
+AliMUONTrackerHV::AliMUONTrackerHV(Int_t runNumber, const char* ocdbPath)
+: TObject(), fRunList(), fOCDBPath(ocdbPath), fDCSNamer(0x0)
{
// ctor for a single run
SetRunList(runNumber);
AliMUONTrackerHV::~AliMUONTrackerHV()
{
// dtor
+ delete fDCSNamer;
}
//______________________________________________________________________________
std::sort(integers.begin(),integers.end());
}
+//______________________________________________________________________________
+AliMpDCSNamer*
+AliMUONTrackerHV::DCSNamer() const
+{
+ // return the dcs namer
+ if (!fDCSNamer)
+ {
+ if (!AliMpDEStore::Instance(false))
+ {
+ AliMUONCDB::LoadMapping();
+ }
+ fDCSNamer = new AliMpDCSNamer("TRACKER");
+ }
+ return fDCSNamer;
+}
//______________________________________________________________________________
void AliMUONTrackerHV::SetRunList(Int_t runNumber)
//______________________________________________________________________________
TGraph*
-AliMUONTrackerHV::ShowValues(TMap* m, const char* name)
+AliMUONTrackerHV::GraphValues(TMap* m, const char* dcsname)
{
- // make a graph of HV channels' voltage values for a given dcs alias (name)
+ // make a graph of HV channels' voltage values for a given dcs name (name, not
+ // alias)
+
+ if ( TString(dcsname).Contains("sw") )
+ {
+ // do not graph switches
+ return 0x0;
+ }
+
- TGraph* g(0x0);
+ AliInfo(dcsname);
- AliInfo(name);
+ TPair* p = static_cast<TPair*>(m->FindObject(DCSNamer()->DCSAliasFromName(dcsname).Data()));
+
+ if (!p) return 0x0;
- TPair* p = static_cast<TPair*>(m->FindObject(name));
TObjArray* a = static_cast<TObjArray*>(p->Value());
TIter n2(a);
AliDCSValue* val;
Int_t i(0);
-
- while ( ( val = static_cast<AliDCSValue*>(n2()) ) )
- {
- StdoutToAliInfo(std::cout << Form("i=%5d ",i);
- val->Print(""););
- ++i;
- }
-
- if ( TString(name).Contains("sw") )
- {
- // do not graph switches
- return 0x0;
- }
-
- n2.Reset();
- g = new TGraph(a->GetEntries());
- i = 0;
+
+ TGraph* g = new TGraph(a->GetEntries());
while ( ( val = static_cast<AliDCSValue*>(n2()) ) )
{
g->SetPoint(i,val->GetTimeStamp(),val->GetFloat());
{
/// Retrieve HV values from OCDB for a given run list, and check whether
/// we have some issues with them...
+ /// If you pipe the results of this into a text file, you can then
+ /// feed it to the HVoff method for further investigations.
+ ///
if ( fRunList.empty() )
{
- std::cout << "No runs to process..." << std::endl;
+ AliError("No runs to process...");
return;
}
results.insert(std::make_pair<int,std::string>(run,message));
- AliMpDCSNamer hvNamer("TRACKER");
-
TH2* hvoff = new TH2I(outputBaseName,outputBaseName,1,0,1,1,0,1);
std::map<int,std::string>::const_iterator it;
TString s(str->String());
TObjArray* parts = s.Tokenize(":");
TString alias = (static_cast<TObjString*>(parts->At(0)))->String();
- TString channel = hvNamer.DCSChannelNameFromAlias(alias.Data());
+ TString channel = DCSNamer()->DCSNameFromAlias(alias.Data());
channel.ReplaceAll(".actual.vMon","");
hvoff->Fill(Form("%6d",it->first),channel.Data(),1.0);
delete parts;
//______________________________________________________________________________
TMultiGraph*
-AliMUONTrackerHV::ShowHV(TMap* m, const char* dcsname)
+AliMUONTrackerHV::GraphHV(TMap* m, const char* dcsname)
{
+ // Make a graph of the values matching dcsname
TIter next(m);
TObjString* s;
- AliMpDCSNamer hvNamer("TRACKER");
+
TMultiGraph* mg = new TMultiGraph;
while ( ( s = static_cast<TObjString*>(next()) ) )
{
- TString name(s->String());
+ TString name(DCSNamer()->DCSNameFromAlias(s->String()));
if ( dcsname && !name.Contains(dcsname)) continue;
- TGraph* g = ShowValues(m,name);
+ TGraph* g = GraphValues(m,name);
if ( g )
{
return mg;
}
+//______________________________________________________________________________
+void
+AliMUONTrackerHV::Print(Option_t* dcsname) const
+{
+ /// Print HV values for a given dcs name (or all if dcsname=0)
+
+ AliCDBManager::Instance()->SetDefaultStorage(fOCDBPath.Data());
+ TList messages;
+ messages.SetOwner(kTRUE);
+
+ for ( std::vector<int>::size_type iRun = 0; iRun < fRunList.size(); ++iRun )
+ {
+ Int_t runNumber = fRunList[iRun];
+
+ AliInfo("---------------------");
+ AliInfo(Form("RUN %09d",runNumber));
+
+ messages.Delete();
+
+ AliCDBManager::Instance()->SetRun(runNumber);
+
+ 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()));
+
+ if (!p) continue;
+
+ TObjArray* a = static_cast<TObjArray*>(p->Value());
+ TIter n2(a);
+ AliDCSValue* val;
+ Int_t i(0);
+
+ while ( ( val = static_cast<AliDCSValue*>(n2()) ) )
+ {
+ std::cout << Form("i=%5d ",i) << std::endl;
+ val->Print("");
+ ++i;
+ }
+ }
+ }
+}
+
//______________________________________________________________________________
void
AliMUONTrackerHV::Plot(const char* dcsname, Bool_t withPatch)
{
- /// Show HV values for a given dcs alias (or all if dcsname=0)
+ /// 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());
AliCDBManager::Instance()->SetRun(runNumber);
- TMap* m = AliMUONCalibrationData::CreateHV(runNumber,0x0,withPatch,&messages);
+ TMap* m = AliMUONCalibrationData::CreateHV(runNumber,0x0,withPatch,&messages,kTRUE);
- TMultiGraph* mg = ShowHV(m,dcsname);
+ TMultiGraph* mg = GraphHV(m,dcsname);
if ( !mg ) continue;
//______________________________________________________________________________
void
-AliMUONTrackerHV::ReportTrips()
+AliMUONTrackerHV::ReportTrips(Bool_t includeLowOnes)
{
/// Report trips
+ /// if includeLowOnes is kTRUE we'll report also the trips which starts from non-operational voltage values
AliCDBManager::Instance()->SetDefaultStorage(fOCDBPath.Data());
TList messages;
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];
AliCDBManager::Instance()->SetRun(runNumber);
- AliMUONCalibrationData::CreateHV(runNumber,0x0,kTRUE,&messages);
+ AliMUONCalibrationData::CreateHV(runNumber,0x0,kTRUE,&messages,kTRUE);
+
+ if (!AliMpDEStore::Instance(false))
+ {
+ AliMUONCDB::LoadMapping();
+ }
TIter next(&messages);
while ( ( msg = static_cast<TObjString*>(next())) )
{
- if ( msg->String().Contains("TRIP") )
+ if ( msg->String().Contains("TRIP") && ( includeLowOnes || !msg->String().Contains("LOWTRIP") ) )
{
++ntrips;
}
{
if ( msg->String().Contains("TRIP") )
{
- Int_t index = msg->String().Index("TS:");
- UInt_t timeStamp = TString(msg->String()(index+strlen("TS:"),msg->String().Length()-index)).Atoi();
- report[timeStamp] = msg->String().Data();
+ TObjArray* parts = msg->String().Tokenize(" ");
+ TString channelName(static_cast<TObjString*>(parts->At(0))->String());
+
+ for ( Int_t ip = 0; ip <= parts->GetLast(); ++ip)
+ {
+ TString p(static_cast<TObjString*>(parts->At(ip))->String());
+
+ if ( p.Contains("TRIP") )
+ {
+ if ( includeLowOnes || !p.Contains("LOWTRIP") )
+ {
+ TString ts(static_cast<TObjString*>(parts->At(ip+2))->String());
+
+ ip += 3;
+
+ Int_t index = ts.Index("TS:");
+
+ UInt_t timeStamp = TString(ts(index+strlen("TS:"),ts.Length()-index)).Atoi();
+
+ TString tmp(msg->String());
+ tmp.ReplaceAll(channelName.Data(),DCSNamer()->DCSNameFromAlias(channelName.Data()));
+ report[timeStamp] = tmp.Data();
+ channels[channelName.Data()]++;
+ }
+ }
+ }
+ delete parts;
}
}
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);
+
}