]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONRawStreamTriggerHP.h
Adding PiKP-only histograms and eliminating a number of switches where histograms...
[u/mrichter/AliRoot.git] / MUON / AliMUONRawStreamTriggerHP.h
index b8bf625ad70071d487fad35a5bb794a0128465cb..31857550f256b272f41f2159fbeac32ec01c71c5 100644 (file)
@@ -60,13 +60,10 @@ public:
        virtual Int_t GetMaxDDL() const { return fgkMaxDDL; }
        
        /// Return maximum number of regional cards in the DDL.
-       virtual Int_t GetMaxReg() const { return (Int_t) fDecoder.RegionalsDecoded(); }
+       virtual Int_t GetMaxReg() const { return (Int_t) fDecoder.MaxRegionals(); }
        
-       /// Return maximum allowed number of regional cards in the DDL.
-       virtual Int_t GetMaxRegAllowed() const { return (Int_t) fDecoder.MaxRegionals(); }
-       
-       /// Set the maximum allowed number of regional cards in the DDL.
-       virtual void SetMaxRegAllowed(Int_t reg);
+       /// Set the maximum number of regional cards in the DDL.
+       virtual void SetMaxReg(Int_t reg);
        
        /// Return maximum number of local cards in the DDL.
        virtual Int_t GetMaxLoc() const { return (Int_t) fDecoder.MaxLocals(); }
@@ -74,7 +71,7 @@ public:
        /// Sets the maximum number of local cards in the DDL.
        virtual void SetMaxLoc(Int_t loc);
        
-       /// Return number of the current DDL being handled.
+       /// Return number of the current DDL being handled in the range [0..1] and -1 if no DDL set.
        virtual Int_t GetDDL() const { return fDDL - 1; }
        
        /// check error/Warning presence
@@ -85,18 +82,42 @@ public:
        /// Set warnings flag to enable warnings on data errors.
        virtual void EnableWarnings() { fDecoder.GetHandler().Warnings(kTRUE); }
        
-       /// Get number of end of DARC word errors.
+       /// Get number of end of DARC word errors in the DDL last decoded.
        UInt_t GetDarcEoWErrors() const {return fDecoder.GetHandler().GetDarcEoWErrors();}
        
-       /// Get number of end of Global word errors.
+       /// Get number of end of Global word errors in the DDL last decoded.
        UInt_t GetGlobalEoWErrors() const {return fDecoder.GetHandler().GetGlobalEoWErrors();}
        
-       /// Get number of end of regional word errors.
+       /// Get number of end of regional word errors in the DDL last decoded.
        UInt_t GetRegEoWErrors() const {return fDecoder.GetHandler().GetRegEoWErrors();}
        
-       /// Get number of end of local word errors.
+       /// Get number of end of local word errors in the DDL last decoded.
        UInt_t GetLocalEoWErrors() const {return fDecoder.GetHandler().GetLocalEoWErrors();}
        
+       /// Number of end of DARC word errors since First() was called.
+       UInt_t NumberOfDarcEoWErrors() const { return fTotalNumberOfDarcEoWErrors; }
+       
+       /// Number of end of global word errors since First() was called.
+       UInt_t NumberOfGlobalEoWErrors() const { return fTotalNumberOfGlobalEoWErrors; }
+       
+       /// Number of end of regional word errors since First() was called.
+       UInt_t NumberOfRegEoWErrors() const { return fTotalNumberOfRegEoWErrors; }
+       
+       /// Number of end of local word errors since First() was called.
+       UInt_t NumberOfLocalEoWErrors() const { return fTotalNumberOfLocalEoWErrors; }
+       
+       /// Whether we got any end of DARC word errors or not since calling First().
+       Bool_t HasDarcEoWError() const { return NumberOfDarcEoWErrors() > 0; }
+       
+       /// Whether we got any end of global word errors or not since calling First().
+       Bool_t HasGlobalEoWError() const { return NumberOfGlobalEoWErrors() > 0; }
+       
+       /// Whether we got any end of regional word errors or not since calling First().
+       Bool_t HasRegEoWError() const { return NumberOfRegEoWErrors() > 0; }
+       
+       /// Whether we got any end of local word errors or not since calling First().
+       Bool_t HasLocalEoWError() const { return NumberOfLocalEoWErrors() > 0; }
+       
        /// Returns the "try to recover from errors" flag.
        Bool_t TryRecover() const { return Bool_t(fDecoder.TryRecover()); }
        
@@ -141,7 +162,7 @@ public:
                /// Return first word
                UInt_t   GetWord()               const {return GetDarcHeader();}
                /// Return global input
-               Int_t    GetGlobalInput(Int_t n) const {return fGlobalHeader->fInput[n];}
+               UInt_t   GetGlobalInput(Int_t n) const {return fGlobalHeader->fInput[n];}
                /// Return global output
                UChar_t  GetGlobalOutput() const {return AliMUONTriggerDDLDecoderEventHandler::GetGlobalOutput(fGlobalHeader);}
                /// Return global config
@@ -368,14 +389,16 @@ public:
                                const AliMUONLocalScalarsStruct* scalars = NULL
                        ) :
                        fRegional(regionalHeader), fNext(NULL),
-                       fLocalStruct(localStruct), fScalars(scalars)
+                       fLocalStruct(localStruct), fScalars(scalars),
+                       fCalculatedId(0)
                {
                }
                
                /// Implement shallow copying in the copy constructor.
                AliLocalStruct(const AliLocalStruct& o) :
                        fRegional(o.fRegional), fNext(o.fNext),
-                       fLocalStruct(o.fLocalStruct), fScalars(o.fScalars)
+                       fLocalStruct(o.fLocalStruct), fScalars(o.fScalars),
+                       fCalculatedId(o.fCalculatedId)
                {
                }
                
@@ -429,7 +452,7 @@ public:
                }
        
                /// Return Id
-               UChar_t GetId() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalId(fLocalStruct);}
+               UChar_t GetId() const {return fgOverrideId ? fCalculatedId : AliMUONTriggerDDLDecoderEventHandler::GetLocalId(fLocalStruct);}
                /// Return Dec
                UChar_t GetDec() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalDec(fLocalStruct);}
                /// Return TrigY
@@ -516,9 +539,18 @@ public:
                
                /// Sets the next local trigger structure.
                void SetNext(const AliLocalStruct* next) { fNext = next; }
+       
+               /// Sets the calculated ID value to be returned by GetId if fgOverrideId is true.
+               void SetCalculatedId(UChar_t id) { fCalculatedId = id; }
                
                /// Print the contents of the local trigger structure and contents to screen.
                void Print() const;
+               
+               /// Returns the override flag indicating if the GetId method should return the calculated Id value or not.
+               static bool GetOverrideIdFlag() { return fgOverrideId; }
+               
+               /// Sets the override flag to control what value the GetId method returns.
+               static void SetOverrideIdFlag(bool value) { fgOverrideId = value; }
        
        private:
        
@@ -526,6 +558,8 @@ public:
                const AliLocalStruct* fNext;  ///< Next local structure object in the regional structure.
                const AliMUONLocalInfoStruct* fLocalStruct;  ///< Pointer to the local trigger structure data in the DDL payload.
                const AliMUONLocalScalarsStruct* fScalars;  ///< Pointer to the local trigger scalars data in the DDL payload.
+               UChar_t fCalculatedId;  ///< Calculated ID value returned by GetId() if fgOverrideId == true.
+               static bool fgOverrideId; //!< Flag indicating if we should return a calculated number in the GetId method.
        };
        
        /// Returns the DARC and global headers plus scalars if they exist.
@@ -568,8 +602,8 @@ public:
        /// Returns the current local struct being decoded or NULL if none found.
        const AliLocalStruct* CurrentLocalStruct() const
        {
-               return (fCurrentLocalStruct != fDecoder.GetHandler().EndOfLocalStructs()) ?
-                       fCurrentLocalStruct : NULL;
+               return (fkCurrentLocalStruct != fDecoder.GetHandler().EndOfLocalStructs()) ?
+                       fkCurrentLocalStruct : NULL;
        }
 
        /// Returns the current regional structure being decoded
@@ -672,13 +706,15 @@ private:
                }
                
                /// Handler for new regional card structures.
-               void OnNewRegionalStruct(const AliMUONRegionalHeaderStruct* header,
-                                        const AliMUONRegionalScalarsStruct* scalars,
-                                        const void* data);
+               void OnNewRegionalStructV2(UInt_t iReg,
+                                          const AliMUONRegionalHeaderStruct* header,
+                                          const AliMUONRegionalScalarsStruct* scalars,
+                                          const void* data);
                
                /// Handler for new local card structures.
-               void OnLocalStruct(const AliMUONLocalInfoStruct* localStruct,
-                                  const AliMUONLocalScalarsStruct* scalars);
+               void OnLocalStructV2(UInt_t iLoc,
+                                    const AliMUONLocalInfoStruct* localStruct,
+                                    const AliMUONLocalScalarsStruct* scalars);
                
                /// Error handler.
                void OnError(ErrorCode error, const void* location);
@@ -707,16 +743,22 @@ private:
                UInt_t fRegEoWErrors;     //!< Number of end of regional word errors.
                UInt_t fLocalEoWErrors;   //!< Number of end of local word errors.
                Bool_t fWarnings;       //!< Flag indicating if we should generate a warning for errors.
+               
+               static const AliMUONRegionalHeaderStruct fgkEmptyHeader;  //!< Empty header for skipped regional structures.
        };
        
        AliMUONTriggerDDLDecoder<AliDecoderEventHandler> fDecoder;  //!< The decoder for the DDL payload.
        Int_t fDDL;         //!< The current DDL number being handled.
        Int_t fBufferSize;  //!< This is the buffer size in bytes of fBuffer.
        UChar_t* fBuffer;   //!< This is the buffer in which we store the DDL payload read from AliRawReader.
-       const AliLocalStruct* fCurrentLocalStruct;  //!< The current local trigger structure being handled by Next().
+       const AliLocalStruct* fkCurrentLocalStruct;  //!< The current local trigger structure being handled by Next().
        Bool_t fHadError;   //!< Flag indicating if there was a decoding error or not.
        Bool_t fDone;       //!< Flag indicating if the iteration is done or not.
        mutable AliMUONDDLTrigger* fDDLObject; //!< Temporary DDL object used by GetDDLTrigger() for caching.
+       UInt_t fTotalNumberOfDarcEoWErrors; //!< The total number of end of DARC word errors since the last call to First().
+       UInt_t fTotalNumberOfGlobalEoWErrors; //!< The total number of end of global word errors since the last call to First().
+       UInt_t fTotalNumberOfRegEoWErrors; //!< The total number of end of regional word errors since the last call to First().
+       UInt_t fTotalNumberOfLocalEoWErrors; //!< The total number of end of local word errors since the last call to First().
        
        static const Int_t  fgkMaxDDL;     //!< Maximum number of DDLs
        
@@ -731,14 +773,15 @@ inline const AliMUONRawStreamTriggerHP::AliLocalStruct* AliMUONRawStreamTriggerH
        /// When no more local triggers are found then NULL is returned.
 
        do {
-               if (fCurrentLocalStruct != fDecoder.GetHandler().EndOfLocalStructs())
-                       return fCurrentLocalStruct++;
+               if (fkCurrentLocalStruct != fDecoder.GetHandler().EndOfLocalStructs())
+                       return fkCurrentLocalStruct++;
        } while (NextDDL());
        return NULL;
 }
 
 
-inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnNewRegionalStruct(
+inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnNewRegionalStructV2(
+               UInt_t iReg,
                const AliMUONRegionalHeaderStruct* header,
                const AliMUONRegionalScalarsStruct* scalars,
                const void* /*data*/
@@ -749,22 +792,21 @@ inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnNewRegionalStru
        /// the appropriate counters.
        
        assert( header != NULL );
-       assert( fCurrentRegional != NULL );
-       assert( fRegionalsCount < (UInt_t)fRawStream->GetMaxReg() );
+       assert( iReg < fRegionalsCount );
        
-       // Link the previous regional structure unless it is the first one.
-       if (fRegionalsCount > 0)
+       fCurrentRegional = fRegionals+iReg;
+       *fCurrentRegional = AliRegionalHeader(fCurrentLocal+1, header, scalars);
+       
+       // Link to the next regional structure unless this is the last one.
+       if (iReg+1 < fRegionalsCount)
        {
                fCurrentRegional->SetNext(fCurrentRegional+1);
        }
-       
-       fCurrentRegional++;
-       *fCurrentRegional = AliRegionalHeader(fCurrentLocal+1, header, scalars);
-       fRegionalsCount++;
 }
 
 
-inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnLocalStruct(
+inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnLocalStructV2(
+               UInt_t iLoc,
                const AliMUONLocalInfoStruct* localStruct,
                const AliMUONLocalScalarsStruct* scalars
        )
@@ -788,6 +830,7 @@ inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnLocalStruct(
        
        fCurrentLocal++;
        *fCurrentLocal = AliLocalStruct(fCurrentRegional, localStruct, scalars);
+       fCurrentLocal->SetCalculatedId(iLoc);
        fCurrentRegional->IncLocalStructCount();
 }