#include "AliMUONPreprocessor.h"
-#include "AliMUONPedestalSubprocessor.h"
-#include "AliMUONHVSubprocessor.h"
-#include "AliMUONGMSSubprocessor.h"
-
+#include "AliCDBEntry.h"
#include "AliLog.h"
+#include "AliMUONGMSSubprocessor.h"
+#include "AliMUONHVSubprocessor.h"
+#include "AliMUONPedestalSubprocessor.h"
+#include "AliMpCDB.h"
+#include "AliMpDDLStore.h"
+#include "AliMpDataMap.h"
+#include "AliMpDataStreams.h"
+#include "AliMpSegmentation.h"
#include "AliShuttleInterface.h"
#include "Riostream.h"
#include "TObjArray.h"
+//-----------------------------------------------------------------------------
/// \class AliMUONPreprocessor
///
/// Shuttle preprocessor for MUON subsystems (TRK and TRG)
/// (of type AliMUONVSubprocessor).
///
/// \author Laurent Aphecetche
+//-----------------------------------------------------------------------------
/// \cond CLASSIMP
ClassImp(AliMUONPreprocessor)
/// \endcond
-const TString AliMUONPreprocessor::fgkTrackerDetName = "MCH";
-const TString AliMUONPreprocessor::fgkTriggerDetName = "MTR";
-
//_____________________________________________________________________________
-AliMUONPreprocessor::AliMUONPreprocessor(const TString& detName,
- AliShuttleInterface* shuttle)
-: AliPreprocessor(detName.Data(),shuttle),
-// fSubprocessors(new TObjArray[kLast])
- fSubprocessors(new TObjArray())
+AliMUONPreprocessor::AliMUONPreprocessor(const char* detName, AliShuttleInterface* shuttle)
+: AliPreprocessor(detName, shuttle),
+ fIsValid(kFALSE),
+ fIsApplicable(kTRUE),
+ fSubprocessors(new TObjArray()),
+ fProcessDCS(kFALSE)
{
- /// ctor. Builds the list of subtasks
- /// Tests detector wrt to tracker or trigger to
- /// instantiate the correct list of subtasks, which should be :
- /// Tracker :
- /// - pedestals
- /// - gains
- /// - deadchannels
- /// - gms
- ///
- /// Trigger :
- /// - masks
- /// - lut
-
- if ( detName == fgkTrackerDetName )
- {
- TString runType = shuttle->GetRunParameter("RunType");
- if ( runType == "PEDESTAL_RUN" ) // FIXME : check the name
- {
- fSubprocessors->Add(new AliMUONPedestalSubprocessor(this)); // to be called only for pedestal runs
- Log("INFO-Will run Pedestal subprocessor");
- }
- else if ( runType == "ELECTRONICS_CALIBRATION_RUN" ) // FIXME : check the name
- {
- Log("WARNING-Subprocessor for gains not yet implemented");
- //fSubprocessors->Add(new AliMUONGainSubprocessor(this)); // to be called only for gain runs
- }
- else if ( runType == "GMS" ) // FIXME : check the name
- {
- fSubprocessors->Add(new AliMUONGMSSubprocessor(this));
- Log("INFO-Will run GMS subprocessor");
- }
- else if ( runType == "PHYSICS" ) // FIXME : check the name
- {
- fSubprocessors->Add(new AliMUONHVSubprocessor(this)); // to be called only for physics runs
- Log("INFO-Will run HV subprocessor");
- }
- else
- {
- Log(Form("ERROR-Unknown RunType=%",runType.Data()));
- }
- }
- else if ( detName == fgkTriggerDetName )
- {
- Log("WARNING-Trigger subprocessors not yet implemented.");
- }
- else
- {
- // Wrong detector name
- Log("ERROR-Wrong detector name.");
- }
+ /// ctor
}
//_____________________________________________________________________________
delete fSubprocessors;
}
+//_____________________________________________________________________________
+void
+AliMUONPreprocessor::ClearSubprocessors()
+{
+ /// Empty our subprocessor list
+ fSubprocessors->Clear();
+ fProcessDCS = kFALSE;
+ fIsValid = kFALSE;
+ fIsApplicable = kTRUE;
+}
+
+//_____________________________________________________________________________
+void
+AliMUONPreprocessor::Add(AliMUONVSubprocessor* sub, Bool_t processDCS)
+{
+ /// Add a subprocessor to our list of workers
+ fSubprocessors->Add(sub);
+ if ( processDCS == kTRUE ) fProcessDCS = processDCS;
+}
+
//_____________________________________________________________________________
void
AliMUONPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
{
- /// loop over subtasks and initialize them
- for ( Int_t i = 0; i <= fSubprocessors->GetLast(); ++i )
+ /// Load mapping and initialize subtasks
+
+ // Delete previous mapping
+ AliMpCDB::UnloadAll();
+
+ if ( ! IsApplicable() ) {
+ Log(Form("WARNING-RunType=%s is not one I should handle.",GetRunType()));
+ return;
+ }
+
+ // Load mapping from CDB for this run
+ AliCDBEntry* cdbEntry = GetFromOCDB("Calib", "MappingData");
+ if (!cdbEntry)
{
- Subprocessor(i)->Initialize(run,startTime,endTime);
+ Log("Could not get MappingData from OCDB !");
+ fIsValid = kFALSE;
+ }
+ else
+ {
+ AliMpDataMap* dataMap = dynamic_cast<AliMpDataMap*>(cdbEntry->GetObject());
+ if (!dataMap)
+ {
+ Log("DataMap is not of the expected type. That is bad...");
+ fIsValid = kFALSE;
+ }
+ else
+ {
+ AliMpDataStreams dataStreams(dataMap);
+ AliMpDDLStore::ReadData(dataStreams);
+ }
}
+
+ if (IsValid())
+ {
+ // loop over subtasks and initialize them
+ for ( Int_t i = 0; i <= fSubprocessors->GetLast(); ++i )
+ {
+ Subprocessor(i)->Initialize(run,startTime,endTime);
+ }
+ }
+ Log(Form("Initialize was %s",( IsValid() ? "fine" : "NOT OK")));
}
//_____________________________________________________________________________
AliMUONPreprocessor::Process(TMap* dcsAliasMap)
{
/// loop over subtasks to make them work
+
+ if (!IsValid())
+ {
+ Log("Will not run as not properly initialized");
+ return 99;
+ }
+
+ if (!IsApplicable())
+ {
+ Log("Nothing to do for me");
+ return 0;
+ }
+
UInt_t rv(0);
for ( Int_t i = 0; i <= fSubprocessors->GetLast(); ++i )
{
rv += Subprocessor(i)->Process(dcsAliasMap);
}
+
return rv;
}