]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Adding functionality so that AliHLTMUONRawDataHistoComponent histograms raw data...
authoraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 10 Aug 2008 21:49:04 +0000 (21:49 +0000)
committeraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 10 Aug 2008 21:49:04 +0000 (21:49 +0000)
HLT/MUON/utils/AliHLTMUONRawDataHistoComponent.cxx
HLT/MUON/utils/AliHLTMUONRawDataHistoComponent.h

index d4b416cef176dbbd6e06f7ef5146c3842a2e525e..9485c2d7d5bbe27e83a9754d5b7a0dd462eb0327 100644 (file)
@@ -31,7 +31,6 @@
 #include "AliCDBEntry.h"
 #include "AliCDBManager.h"
 #include "AliRawDataHeader.h"
-#include "TH1D.h"
 #include "TTimeStamp.h"
 #include <cstdlib>
 #include <cstring>
@@ -49,9 +48,13 @@ ClassImp(AliHLTMUONRawDataHistoComponent);
 
 AliHLTMUONRawDataHistoComponent::AliHLTMUONRawDataHistoComponent() :
        AliHLTMUONProcessor(),
+       fTrackerDecoder(),
+       fTriggerDecoder(),
        fLastPublishTime(-1),
        fCurrentEventTime(-1),
-       fPublishDelay(1)
+       fPublishDelay(1),
+       fSuppressEmptyHists(false),
+       fProcessDataEventsOnly(false)
 {
        /// Default constructor initialises all histogram object pointers to NULL.
        
@@ -64,6 +67,16 @@ AliHLTMUONRawDataHistoComponent::AliHLTMUONRawDataHistoComponent() :
                fManuHist[i] = NULL;
                fSignalHist[i] = NULL;
        }
+       
+       fTrackerDecoder.ExitOnError(false);
+       fTrackerDecoder.TryRecover(false);
+       fTrackerDecoder.SendDataOnParityError(true);
+       fTrackerDecoder.AutoDetectTrailer(true);
+       fTrackerDecoder.CheckForTrailer(true);
+       
+       fTriggerDecoder.ExitOnError(false);
+       fTriggerDecoder.TryRecover(false);
+       fTriggerDecoder.AutoDetectScalars(false);
 }
 
 
@@ -76,9 +89,7 @@ AliHLTMUONRawDataHistoComponent::~AliHLTMUONRawDataHistoComponent()
 
 const char* AliHLTMUONRawDataHistoComponent::GetComponentID()
 {
-       ///
        /// Inherited from AliHLTComponent. Returns the component ID.
-       ///
        
        return AliHLTMUONConstants::RawDataHistogrammerId();
 }
@@ -86,9 +97,7 @@ const char* AliHLTMUONRawDataHistoComponent::GetComponentID()
 
 void AliHLTMUONRawDataHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
 {
-       ///
        /// Inherited from AliHLTProcessor. Returns the list of expected input data types.
-       ///
        
        assert( list.empty() );
        list.push_back( AliHLTMUONConstants::DDLRawDataType() );
@@ -107,9 +116,7 @@ void AliHLTMUONRawDataHistoComponent::GetOutputDataSize(
                unsigned long& constBase, double& inputMultiplier
        )
 {
-       ///
        /// Inherited from AliHLTComponent. Returns an estimate of the expected output data size.
-       ///
        
        constBase = sizeof(TH1D) * 1024*1024;
        inputMultiplier = 0;
@@ -118,9 +125,7 @@ void AliHLTMUONRawDataHistoComponent::GetOutputDataSize(
 
 AliHLTComponent* AliHLTMUONRawDataHistoComponent::Spawn()
 {
-       ///
        /// Inherited from AliHLTComponent. Creates a new object instance.
-       ///
        
        return new AliHLTMUONRawDataHistoComponent;
 }
@@ -157,6 +162,10 @@ int AliHLTMUONRawDataHistoComponent::DoInit(int argc, const char** argv)
        fLastPublishTime = fCurrentEventTime = -1;
        fPublishDelay = 1;
        bool pubDelaySet = false;
+       fSuppressEmptyHists = false;
+       fProcessDataEventsOnly = false;
+       fTrackerDecoder.TryRecover(false);
+       fTriggerDecoder.TryRecover(false);
        
        for (int i = 0; i < argc; i++)
        {
@@ -192,6 +201,25 @@ int AliHLTMUONRawDataHistoComponent::DoInit(int argc, const char** argv)
                        i++;
                        continue;
                }
+               
+               if (strcmp(argv[i], "-noemptyhists") == 0)
+               {
+                       fSuppressEmptyHists = true;
+                       continue;
+               }
+               
+               if (strcmp(argv[i], "-onlydataevents") == 0)
+               {
+                       fProcessDataEventsOnly = true;
+                       continue;
+               }
+               
+               if (strcmp(argv[i], "-tryrecover") == 0)
+               {
+                       fTrackerDecoder.TryRecover(true);
+                       fTriggerDecoder.TryRecover(true);
+                       continue;
+               }
 
                HLTError("Unknown option '%s'.", argv[i]);
                return -EINVAL;
@@ -211,7 +239,6 @@ int AliHLTMUONRawDataHistoComponent::DoInit(int argc, const char** argv)
                        AliHLTInt32_t equipId = AliHLTMUONUtils::DDLNumberToEquipId(i);
                        sprintf(name, "rawDataErrors_%d", equipId);
                        sprintf(title, "Distribution of errors found in raw data from DDL %d.", equipId);
-                       cout << "TRACE: " << name << endl;
                        fErrorHist[i] = new TH1D(name, title, 40, 0.5, 40.5);
                        fErrorHist[i]->SetXTitle("Error code");
                        fErrorHist[i]->SetYTitle("Number of errors");
@@ -262,6 +289,8 @@ int AliHLTMUONRawDataHistoComponent::DoEvent(
        /// Inherited from AliHLTProcessor.
        /// Processes the new event data and generates summary histograms.
        
+       if (fProcessDataEventsOnly and not IsDataEvent()) return 0;  // Only process data events.
+       
        fCurrentEventTime = TTimeStamp().AsDouble();
        
        const AliHLTComponentBlockData* block = GetFirstInputBlock(AliHLTMUONConstants::DDLRawDataType());
@@ -291,10 +320,14 @@ int AliHLTMUONRawDataHistoComponent::DoEvent(
                }
        }
        
-       if (fLastPublishTime == -1 or fCurrentEventTime - fLastPublishTime > fPublishDelay)
+       // See if 'fPublishDelay' number of seconds has elapsed or this is the first event,
+       // in that case publish the histograms. Do not publish histograms that are empty
+       // if the fSuppressEmptyHists flag is set.
+       if (fLastPublishTime == -1 or fCurrentEventTime - fLastPublishTime >= fPublishDelay)
        {
                for (int i = 0; i < 22; i++)
                {
+                       if (fSuppressEmptyHists and fErrorHist[i]->GetEntries() == 0) continue;
                        PushBack(fErrorHist[i],
                                AliHLTMUONConstants::HistogramDataType(),
                                AliHLTMUONUtils::DDLNumberToSpec(i)
@@ -303,8 +336,14 @@ int AliHLTMUONRawDataHistoComponent::DoEvent(
                for (int i = 0; i < 20; i++)
                {
                        AliHLTUInt32_t spec = AliHLTMUONUtils::DDLNumberToSpec(i);
-                       PushBack(fManuHist[i], AliHLTMUONConstants::HistogramDataType(), spec);
-                       PushBack(fSignalHist[i], AliHLTMUONConstants::HistogramDataType(), spec);
+                       if (not (fSuppressEmptyHists and fManuHist[i]->GetEntries() == 0))
+                       {
+                               PushBack(fManuHist[i], AliHLTMUONConstants::HistogramDataType(), spec);
+                       }
+                       if (not (fSuppressEmptyHists and fSignalHist[i]->GetEntries() == 0))
+                       {
+                               PushBack(fSignalHist[i], AliHLTMUONConstants::HistogramDataType(), spec);
+                       }
                }
                fLastPublishTime = fCurrentEventTime;
        }
@@ -320,11 +359,16 @@ void AliHLTMUONRawDataHistoComponent::ProcessTrackerDDL(const AliHLTComponentBlo
        AliHLTInt32_t ddl = AliHLTMUONUtils::SpecToDDLNumber(block->fSpecification);
        assert(0 <= ddl and ddl < 20);
        
+       fTrackerDecoder.GetHandler().ErrorHist(fErrorHist[ddl]);
+       fTrackerDecoder.GetHandler().ManuHist(fManuHist[ddl]);
+       fTrackerDecoder.GetHandler().SignalHist(fSignalHist[ddl]);
+       
        if (block->fSize >= sizeof(AliRawDataHeader))
        {
-               AliHLTUInt8_t* buffer = reinterpret_cast<AliHLTUInt8_t*>(block->fPtr);
-               buffer += sizeof(AliRawDataHeader);
-               UInt_t bufferSize = UInt_t(block->fSize) - sizeof(AliRawDataHeader);
+               AliHLTUInt8_t* payload = reinterpret_cast<AliHLTUInt8_t*>(block->fPtr)
+                       + sizeof(AliRawDataHeader);
+               UInt_t payloadSize = UInt_t(block->fSize) - sizeof(AliRawDataHeader);
+               fTrackerDecoder.Decode(payload, payloadSize);
        }
        else
        {
@@ -341,16 +385,18 @@ void AliHLTMUONRawDataHistoComponent::ProcessTriggerDDL(const AliHLTComponentBlo
 {
        /// Processes a raw data block from the trigger stations.
        
-       HLTFatal("Processing of trigger data not yet implemented!");
-       
        AliHLTInt32_t ddl = AliHLTMUONUtils::SpecToDDLNumber(block->fSpecification);
        assert(21 <= ddl and ddl < 22);
        
+       fTriggerDecoder.GetHandler().ErrorHist(fErrorHist[ddl]);
+       
        if (block->fSize >= sizeof(AliRawDataHeader))
        {
                AliRawDataHeader* header = reinterpret_cast<AliRawDataHeader*>(block->fPtr);
-               AliHLTUInt8_t* buffer = reinterpret_cast<AliHLTUInt8_t*>(header+1);
-               UInt_t bufferSize = UInt_t(block->fSize) - sizeof(AliRawDataHeader);
+               AliHLTUInt8_t* payload = reinterpret_cast<AliHLTUInt8_t*>(header+1);
+               UInt_t payloadSize = UInt_t(block->fSize) - sizeof(AliRawDataHeader);
+               bool scalarEvent = ((header->GetL1TriggerMessage() & 0x1) == 0x1);
+               fTriggerDecoder.Decode(payload, payloadSize, scalarEvent);
        }
        else
        {
@@ -389,3 +435,4 @@ void AliHLTMUONRawDataHistoComponent::FreeObjects()
                }
        }
 }
+
index 13fccb4b5ffb50bcacc08697b8fa5914e5520c63..9385aa6e665afddc6ce7c051c6beb6bacd8758ae 100644 (file)
@@ -15,8 +15,9 @@
 
 #include "AliHLTMUONProcessor.h"
 #include "AliHLTMUONDataTypes.h"
-
-class TH1D;
+#include "AliMUONTrackerDDLDecoder.h"
+#include "AliMUONTriggerDDLDecoder.h"
+#include "TH1D.h"
 
 /**
  * @class AliHLTMUONRawDataHistoComponent
@@ -53,6 +54,105 @@ protected:
 
 private:
 
+       class AliDecoderHandler : public AliHLTLogging
+       {
+       public:
+       
+               AliDecoderHandler() : AliHLTLogging(), fErrorHist(NULL) {}
+               virtual ~AliDecoderHandler() {}
+               
+               /// Returns the error codes histogram.
+               TH1D* ErrorHist() const { return fErrorHist; }
+               
+               /// Sets the error codes histogram.
+               void ErrorHist(TH1D* hist) { fErrorHist = hist; }
+       
+       protected:
+       
+               /// Fills the error histogram with the given error code.
+               void FillErrorHist(Int_t code);
+       
+               TH1D* fErrorHist;   /// Histogram of error codes found.
+               
+       private:
+       
+               // Do not allow copying of this object.
+               /// Not implemented.
+               AliDecoderHandler(const AliDecoderHandler& obj);
+               /// Not implemented.
+               AliDecoderHandler& operator = (const AliDecoderHandler& obj);
+       };
+
+       class AliTrackerDecoderHandler :
+               public AliMUONTrackerDDLDecoderEventHandler, public AliDecoderHandler
+       {
+       public:
+               AliTrackerDecoderHandler() :
+                       AliMUONTrackerDDLDecoderEventHandler(),
+                       AliDecoderHandler(),
+                       fManuHist(NULL),
+                       fSignalHist(NULL)
+               {}
+               
+               virtual ~AliTrackerDecoderHandler() {}
+               
+               /// Returns the signals per MANU histogram.
+               TH1D* ManuHist() const { return fManuHist; }
+               
+               /// Sets the signals per MANU histogram.
+               void ManuHist(TH1D* hist) { fManuHist = hist; }
+               
+               /// Returns the signals histogram.
+               TH1D* SignalHist() const { return fSignalHist; }
+               
+               /// Sets the signals histogram.
+               void SignalHist(TH1D* hist) { fSignalHist = hist; }
+               
+               // Methods inherited from AliMUONTrackerDDLDecoderEventHandler:
+               
+               /// Called for each new data word found.
+               void OnData(UInt_t data, bool /*parityError*/);
+               
+               /// Fills the fErrorHist histogram with the error code received.
+               void OnError(ErrorCode code, const void* /*location*/) { FillErrorHist(Int_t(code)); }
+       
+       private:
+       
+               // Do not allow copying of this object.
+               /// Not implemented.
+               AliTrackerDecoderHandler(const AliTrackerDecoderHandler& obj);
+               /// Not implemented.
+               AliTrackerDecoderHandler& operator = (const AliTrackerDecoderHandler& obj);
+               
+               TH1D* fManuHist;    /// Histogram of signal distribution per MANU.
+               TH1D* fSignalHist;  /// Histogram of the ADC signal distribution.
+       };
+       
+       class AliTriggerDecoderHandler :
+               public AliMUONTriggerDDLDecoderEventHandler, public AliDecoderHandler
+       {
+       public:
+               AliTriggerDecoderHandler() :
+                       AliMUONTriggerDDLDecoderEventHandler(),
+                       AliDecoderHandler()
+               {}
+               
+               virtual ~AliTriggerDecoderHandler() {}
+               
+               // Methods inherited from AliMUONTriggerDDLDecoderEventHandler:
+               
+               /// Fills the fErrorHist histogram with the error code received.
+               void OnError(ErrorCode code, const void* /*location*/) { FillErrorHist(Int_t(code)); }
+       
+       private:
+       
+               // Do not allow copying of this object.
+               /// Not implemented.
+               AliTriggerDecoderHandler(const AliTriggerDecoderHandler& obj);
+               /// Not implemented.
+               AliTriggerDecoderHandler& operator = (const AliTriggerDecoderHandler& obj);
+       };
+
        // Do not allow copying of this class.
        AliHLTMUONRawDataHistoComponent(const AliHLTMUONRawDataHistoComponent& /*obj*/);
        AliHLTMUONRawDataHistoComponent& operator = (const AliHLTMUONRawDataHistoComponent& /*obj*/);
@@ -61,14 +161,73 @@ private:
        void ProcessTriggerDDL(const AliHLTComponentBlockData* block);
        void FreeObjects();
        
+       AliMUONTrackerDDLDecoder<AliTrackerDecoderHandler> fTrackerDecoder;  // Raw data decoder for the tracker data.
+       AliMUONTriggerDDLDecoder<AliTriggerDecoderHandler> fTriggerDecoder;  // Raw data decoder for the trigger data.
+       
        double fLastPublishTime;  /// Timestamp for the last time we published data (seconds).
        double fCurrentEventTime;  /// Timestamp for the current event being processed (seconds).
        double fPublishDelay;  /// Delay in second to wait between publishing data.
        TH1D* fErrorHist[22]; /// Histograms for error codes per DDL.
        TH1D* fManuHist[20]; /// Histograms for MANU distributions per DDL.
        TH1D* fSignalHist[20]; /// Histograms for signal distributions per DDL.
+       bool fSuppressEmptyHists;  /// Flag indicating if empty histograms should be published or not.
+       bool fProcessDataEventsOnly;  /// Flag indicating if only data events should be processed.
        
        ClassDef(AliHLTMUONRawDataHistoComponent, 0);  // Trigger decision component for the dimuon HLT.
 };
 
+//-----------------------------------------------------------------------------
+
+inline void AliHLTMUONRawDataHistoComponent::AliDecoderHandler::FillErrorHist(Int_t code)
+{
+       /// Fills the error code into the error code histogram.
+       
+       assert(fErrorHist != NULL);
+       Int_t mincode = Int_t( fErrorHist->GetXaxis()->GetBinCenter(1) );
+       Int_t maxcode = Int_t( fErrorHist->GetXaxis()->GetBinCenter(fErrorHist->GetNbinsX()) );
+       if (code < mincode or maxcode < code)
+       {
+               HLTError("Filling an error code which is out of range."
+                       " Received code %d, but expected it to be in the range [%d..%d]",
+                       int(code), mincode, maxcode
+               );
+       }
+       fErrorHist->Fill(code);
+}
+
+
+inline void AliHLTMUONRawDataHistoComponent::AliTrackerDecoderHandler::OnData(
+               UInt_t data, bool /*parityError*/
+       )
+{
+       /// Fills the signals histogram and also the signal per MANU histogram.
+
+       UInt_t minadc = UInt_t( fSignalHist->GetXaxis()->GetBinCenter(1) );
+       UInt_t maxadc = UInt_t( fSignalHist->GetXaxis()->GetBinCenter(fSignalHist->GetNbinsX()) );
+       UInt_t minmanu = UInt_t( fManuHist->GetXaxis()->GetBinCenter(1) );
+       UInt_t maxmanu = UInt_t( fManuHist->GetXaxis()->GetBinCenter(fManuHist->GetNbinsX()) );
+       
+       UShort_t manuId; UChar_t channelId; UShort_t adc;
+       UnpackADC(data, manuId, channelId, adc);
+       
+       if (adc < minadc or maxadc < adc)
+       {
+               HLTError("Filling a signal value which is out of range. Received ADC value"
+                       " of %d channels, but expected it to be in the range [%d..%d]",
+                       int(adc), minadc, maxadc
+               );
+       }
+       fSignalHist->Fill(adc);
+       
+       if (manuId < minmanu or maxmanu < manuId)
+       {
+               HLTError("Filling a MANU ID value which is out of range. Received"
+                       " value of %d, but expected it to be in the range [%d..%d]",
+                       int(manuId), minmanu, maxmanu
+               );
+       }
+       fManuHist->Fill(manuId);
+}
+
 #endif // AliHLTMUONRAWDATAHISTOCOMPONENT_H
+