* provided "as is" without express or implied warranty. *
**************************************************************************/
-// $Id$
+// $Id: AliMUONCalibrationData.cxx 59486 2012-11-07 22:06:24Z laphecet $
#include "AliMUONCalibrationData.h"
#include "AliLog.h"
#include "AliMpDCSNamer.h"
#include "AliMpIntPair.h"
-#include "AliMUONConstants.h"
#include "AliMUONGlobalCrateConfig.h"
#include "AliMUONRegionalTriggerConfig.h"
#include "AliMUONRejectList.h"
/// \author Laurent Aphecetche
//-----------------------------------------------------------------------------
+using std::cout;
+using std::endl;
/// \cond CLASSIMP
ClassImp(AliMUONCalibrationData)
/// \endcond
AliMUONVStore* AliMUONCalibrationData::fgBypassPedestals(0x0);
AliMUONVStore* AliMUONCalibrationData::fgBypassGains(0x0);
-namespace
+UInt_t AliMUONCalibrationData::fgkDCSSt1Flag(42);
+
+namespace
{
void MarkForDeletion(Int_t* indices, Int_t first, Int_t last)
{
//______________________________________________________________________________
Bool_t AliMUONCalibrationData::PatchHVValues(TObjArray& values,
- TString* msg)
+ TString* msg,
+ Bool_t dryRun)
{
/// We do here a little bit of massaging of the HV values, if needed.
///
/// This is to avoid both the "ramp-down-before-end-of-run" and the
/// "ramp-up-after-start-of-run" syndroms...
///
+ /// Use dryRun = kTRUE to fill the messages *without* altering the values
+ ///
/// Return kFALSE is the kind of HV (trouble) case we have here
/// has not been identified...
///
Int_t nEndRD(0);
Int_t nTripRD(0);
Int_t nFluct(0);
+ TObjArray trips;
+ trips.SetOwner(kTRUE);
while ( ( p = static_cast<AliMpIntPair*>(nextGroup()) ) )
{
if ( d->GetFloat() < AliMpDCSNamer::TrackerHVOFF() )
{
++nTripRD;
+ AliDCSValue* tripStart = static_cast<AliDCSValue*>(values.At(p->GetFirst()));
+ trips.Add(new AliMpIntPair(tripStart->GetTimeStamp(),TMath::Nint(tripStart->GetFloat())));
}
}
else
}
else if ( nTripRD > 0 )
{
+ const Double_t HVLOWTRIP(600); // a trip below this value is considered a "low trip"
+ // i.e. one starting for a non-operational voltage
+
+ internalMsg += Form("NT:%d ",nTripRD);
+
if ( nRU > 0 && nRD > 0 )
{
hvCase = "F";
{
hvCase = "E";
}
- internalMsg += "TRIP ";
- MarkForDeletion(indices,0,values.GetLast());
- values.Add(new AliDCSValue(static_cast<Float_t>(0),meanTimeStamp));
+
+ for ( Int_t iTrip = 0; iTrip <= trips.GetLast(); ++iTrip )
+ {
+ AliMpIntPair* tripPair = static_cast<AliMpIntPair*>(trips.At(iTrip));
+ TString tripType("TRIP");
+ if ( tripPair->GetSecond() < HVLOWTRIP)
+ {
+ tripType = "LOWTRIP";
+ }
+
+ internalMsg += Form("%s SV:%d TS:%d ",tripType.Data(),tripPair->GetSecond(),tripPair->GetFirst());
+ }
+
+ // we put here the TRIP value as SV:value
+ // for cases where there's a drop in voltage but the starting point was
+ // below operational voltage, so strictly speaking it's *not* a trip, but
+ // more a big fluctuation
+ if ( !dryRun )
+ {
+ MarkForDeletion(indices,0,values.GetLast());
+ values.Add(new AliDCSValue(static_cast<Float_t>(0),meanTimeStamp));
+ }
}
else if ( nStartRU > 0 && nRU == 0 && nRD == 0 && nEndRD == 0 )
{
hvCase = "C";
- sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
- MarkForDeletion(indices,a,b);
+ if (!dryRun)
+ {
+ sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
+ MarkForDeletion(indices,a,b);
+ }
}
else if ( nStartRU > 0 && nEndRD > 0 && nRD == 0 && nRU == 0 )
{
hvCase = "D";
- sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
- MarkForDeletion(indices,a,b-1);
- Int_t i = internalMsg.Index("RD",strlen("RD"),0,TString::kExact);
- sscanf(internalMsg(i,internalMsg.Length()-i).Data(),
- "RD%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
- MarkForDeletion(indices,a+1,b);
+ if (!dryRun)
+ {
+ sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
+ MarkForDeletion(indices,a,b-1);
+ Int_t i = internalMsg.Index("RD",strlen("RD"),0,TString::kExact);
+ sscanf(internalMsg(i,internalMsg.Length()-i).Data(),
+ "RD%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
+ MarkForDeletion(indices,a+1,b);
+ }
}
else if ( nEndRD > 0 && nStartRU == 0 && nRU == 0 && nRD == 0 )
{
hvCase = "B";
- Int_t i = internalMsg.Index("RD",strlen("RD"),0,TString::kExact);
- sscanf(internalMsg(i,internalMsg.Length()-i).Data(),
- "RD%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
- MarkForDeletion(indices,a,b);
+ if (!dryRun)
+ {
+ Int_t i = internalMsg.Index("RD",strlen("RD"),0,TString::kExact);
+ sscanf(internalMsg(i,internalMsg.Length()-i).Data(),
+ "RD%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
+ MarkForDeletion(indices,a,b);
+ }
}
else if ( nFluct > 0 )
{
hvCase = "G";
- TObjArray* af = internalMsg.Tokenize(" ");
- TIter next(af);
- TObjString* str;
- while ( ( str = static_cast<TObjString*>(next()) ) )
+ if (!dryRun)
{
- TString s(str->String());
- if ( s.BeginsWith("FLUCT") )
+ TObjArray* af = internalMsg.Tokenize(" ");
+ TIter next(af);
+ TObjString* str;
+ while ( ( str = static_cast<TObjString*>(next()) ) )
{
- sscanf(s.Data(),"FLUCT%d[%d:%d]",&dummy,&a,&b);
- MarkForDeletion(indices,a,b);
+ TString s(str->String());
+ if ( s.BeginsWith("FLUCT") )
+ {
+ sscanf(s.Data(),"FLUCT%d[%d:%d]",&dummy,&a,&b);
+ MarkForDeletion(indices,a,b);
+ }
}
+ delete af;
}
- delete af;
}
else if ( nEndAndShortRU > 0 && nStartRU == 0 && nRU == 0 && nRD == 0 && nEndRD == 0 )
{
hvCase = "H";
- sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
- MarkForDeletion(indices,a,b);
+ if (!dryRun)
+ {
+ sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
+ MarkForDeletion(indices,a,b);
+ }
}
else
{
{
hvCase = "Z";
}
- MarkForDeletion(indices,1,nvalues-1);
+ if (!dryRun)
+ {
+ MarkForDeletion(indices,1,nvalues-1);
+ }
}
- for ( Int_t i = 0; i < nvalues; ++i )
+ if (!dryRun)
{
- if ( indices[i] )
+ for ( Int_t i = 0; i < nvalues; ++i )
{
- values.RemoveAt(i);
+ if ( indices[i] )
+ {
+ values.RemoveAt(i);
+ }
}
+
+ values.Compress();
}
- values.Compress();
-
delete[] indices;
if ( !values.GetEntries() )
hvCase = "OTHER";
}
- // take the max of the remaining values
- TIter nextA(&values);
- AliDCSValue* val;
- Float_t maxval(-9999);
-
- while ( ( val = static_cast<AliDCSValue*>(nextA()) ) )
+ if (!dryRun)
{
- if ( val->GetFloat() > maxval )
+ // take the max of the remaining values
+ TIter nextA(&values);
+ AliDCSValue* val;
+ Float_t maxval(-9999);
+
+ while ( ( val = static_cast<AliDCSValue*>(nextA()) ) )
{
- maxval = val->GetFloat();
+ if ( val->GetFloat() > maxval )
+ {
+ maxval = val->GetFloat();
+ }
}
- }
- values.Clear();
+ values.Clear();
- values.Add(new AliDCSValue(maxval,meanTimeStamp));
+ values.Add(new AliDCSValue(maxval,meanTimeStamp));
+ }
// once the case is inferred, add a "CASE:%10d",hvCase.Data()
// to the msg
return hvCase=="OTHER" ? kFALSE : kTRUE;
}
+//_____________________________________________________________________________
+void AliMUONCalibrationData::AddToMap(const TMap& sourceMap,
+ TMap& destMap,
+ const TString& key,
+ const char* source,
+ const char* dest)
+{
+ /// Remap
+
+ TString newkey(key);
+
+ newkey.ReplaceAll(source,dest);
+
+ TPair* pair = static_cast<TPair*>(sourceMap.FindObject(key.Data()));
+
+ destMap.Add(new TObjString(newkey.Data()),pair->Value());
+}
+
+//_____________________________________________________________________________
+void AliMUONCalibrationData::PatchSt1DCSAliases(TMap& hvMap)
+{
+ /// It was discovered (in sept. 2013) that the DCS aliases for St1 was
+ /// wrongly assigned (in the hardware), so the correspondence between DCS channels
+ /// and actual HV channels is wrong for St1 in the DCS (and thus in the DCS archive,
+ /// and so in the OCDB HV object).
+ ///
+ /// It affects all the OCDB object written in 2010-2013.
+ ///
+ /// This method fixes that.
+
+ if ( hvMap.GetUniqueID() == fgkDCSSt1Flag )
+ {
+ // already clean object. Do nothing
+ return;
+ }
+
+ TIter next(&hvMap);
+ TObjString* hvChannelName;
+
+ TMap newmap;
+ newmap.SetOwnerKeyValue(kTRUE,kFALSE);
+
+ while ( ( hvChannelName = static_cast<TObjString*>(next()) ) )
+ {
+ TString name(hvChannelName->String());
+ TString newname(name);
+
+ // the problem is limited to St1 = ch1+ch2 (or, in DCS parlance, ch0+ch1)
+ // do it "by hand" as we "only" have 8 names to change
+
+ if ( name.Contains("Chamber00Left") )
+ {
+ if (name.Contains("Quad1Sect0")) AddToMap(hvMap,newmap,name,"Quad1Sect0","Quad2Sect0"); // channel 0 of Board00 (alidcscae020)
+
+ if (name.Contains("Quad1Sect1")) AddToMap(hvMap,newmap,name,"Quad1Sect1","Quad2Sect1"); // channel 1
+ if (name.Contains("Quad1Sect2")) AddToMap(hvMap,newmap,name,"Quad1Sect2","Quad2Sect2"); // channel 2
+
+ if (name.Contains("Quad2Sect2")) AddToMap(hvMap,newmap,name,"Quad2Sect2","Quad1Sect0"); // channel 3
+ if (name.Contains("Quad2Sect1")) AddToMap(hvMap,newmap,name,"Quad2Sect1","Quad1Sect1"); // channel 4
+ if (name.Contains("Quad2Sect0")) AddToMap(hvMap,newmap,name,"Quad2Sect0","Quad1Sect2"); // channel 5
+ }
+ else if ( name.Contains("Chamber01Left"))
+ {
+ if (name.Contains("Quad2Sect2")) AddToMap(hvMap,newmap,name,"Quad2Sect2","Quad2Sect0"); // channel 9 of Board00 (alidcscae020)
+ if (name.Contains("Quad2Sect0")) AddToMap(hvMap,newmap,name,"Quad2Sect0","Quad2Sect2"); // channel 11
+ }
+ else
+ {
+ AddToMap(hvMap,newmap,name,name,name);
+ }
+ }
+
+ // copy newmap to hvMap
+
+ TIter nextNewMap(&newmap);
+ while ( ( hvChannelName = static_cast<TObjString*>(nextNewMap()) ) )
+ {
+ TPair* oldPair = static_cast<TPair*>(hvMap.FindObject(hvChannelName->String().Data()));
+ TPair* newPair = static_cast<TPair*>(newmap.FindObject(hvChannelName->String().Data()));
+
+ TObjArray* newValues = static_cast<TObjArray*>(newPair->Value());
+
+ oldPair->SetValue(newValues);
+ }
+}
+
//_____________________________________________________________________________
TMap*
AliMUONCalibrationData::CreateHV(Int_t runNumber,
Int_t* startOfValidity,
Bool_t patched,
- TList* messages)
+ TList* messages,
+ Bool_t dryRun)
{
/// Create a new HV map from the OCDB for a given run
+ ///
+ /// dryRun is only usefull with patched=kTRUE and non-empty messages) :
+ /// it allow to get the list of messages without altering the values at all
+ /// (A patch without a patch, so to speak...)
+ ///
+
TMap* hvMap = dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV",startOfValidity));
if (!hvMap) return 0x0;
+
+ PatchSt1DCSAliases(*hvMap);
if (patched)
{
TString name(hvChannelName->String());
if ( name.Contains("sw") ) continue; // skip switches
-
+
+ if ( name.Contains("iMon") ) continue; // skip HV currents
+
TPair* hvPair = static_cast<TPair*>(hvMap->FindObject(name.Data()));
TObjArray* values = static_cast<TObjArray*>(hvPair->Value());
if (!values)
TString msg;
AliDebugClass(1,Form("channel %s",name.Data()));
- Bool_t ok = PatchHVValues(*values,&msg);
+ Bool_t ok = PatchHVValues(*values,&msg,dryRun);
if ( messages )
{
- messages->Add(new TObjString(Form("%s:%s",hvChannelName->String().Data(),msg.Data())));
+ messages->Add(new TObjString(Form("%s %s",hvChannelName->String().Data(),msg.Data())));
}
if (!ok)
Int_t a(0),b(0),c(0),d(0),e(0),f(0),g(0),h(0),u(0),z(0);
TIter next(messages);
TObjString* msg;
- char hvCase;
+ char hvCase('u');
while ( ( msg = static_cast<TObjString*>(next()) ) )
{
entry->SetOwner(kFALSE);
delete entry;
}
+// else
+// {
+// entry->SetOwner(kTRUE); //FIXME : this should be done but is causing problems with RecoParams at the end of the reco : investigate why...
+// }
return object;
}
else