// // File : PixelPattern.hh // // Purpose: Header file for class PixelPattern // // $Id: PixelPattern.hh 9725 2010-09-28 07:31:17Z mathes $ // /** @file PixelPattern.hh * Declaration of the class PixelPattern. * @author H.-J. Mathes, FzK */ #ifndef _PixelPattern_hh_ #define _PixelPattern_hh_ #include #include #include #include // --- forward declaration(s) class LongPixelPattern; class TMirrorBitArray; /** Class to describe a valid pattern in the SLT data. * * This class contains the data structures for the shortest possible and * valid pattern, i.e. for 4 pixels. Furthermore the static data of this * class represents the logic of the different patterns of the SLT and can * be used to find valid pixels along a given pattern. * * Note: Some functionality in this class overlaps with the class SltPattern * which is in the fdhwlib. */ class PixelPattern : public SltPattern { friend class LongPixelPattern; public: /** Constructor for the class PixelPattern. The pattern's id is preset * to the passed value. */ PixelPattern(unsigned int id); /** Constructor for the class PixelPattern. The pattern's id and the its * start time are preset to the passed values. */ PixelPattern(unsigned int id,unsigned int start_col); /** Copy constructor for an object of type PixelPattern. */ PixelPattern(PixelPattern&); /** Destructor for the class PixelPattern. */ virtual ~PixelPattern(); /** Add a pixels (col,row) indices to a pattern. According to the usual * notation, both indices start from 1 ! */ virtual void AddPixel(unsigned int,unsigned int); /** Show the contents of the PixelPattern object to cout. */ virtual void Show(const char *where=NULL); /** Return the FADC pulse time for the specified pixel of the pattern */ virtual int GetAdcTime(int n) { return fAdcTime[n]; } /** Get a pair of column and row indices. This method may cause a SegFault * as the limits (internal array overflow) are not checked. The returned * indices are according to the usual conventions starting from 1 ! */ virtual void GetColumnRow(unsigned int n, unsigned int& col,unsigned int& row) { col = fCol[n]; row = fRow[n]; } /** Get the column number of the n-th pixel of the pattern. */ virtual unsigned int GetColumn(unsigned int n) { return fCol[n]; } /** Get a pair of column and row indices. */ //void GetColumnRowChecked(unsigned int,unsigned int*,unsigned int*); /** Get the number of pixels in the pattern, Usually 4. */ virtual unsigned int GetNPixel() { return fNPixel; } /** Return the pattern id/class of the actual pattern. */ virtual int GetPatternId() { return fPatternId; } /** Get the row number of the n-th pixel of the pattern. */ virtual unsigned int GetRow(unsigned int n) { return fRow[n]; } /** Return the start bin of a pattern. */ unsigned int GetStartBin() { return fStartBin; } /** Return the start column of a pattern. */ unsigned int GetStartColumn() { return fStartColumn; } /** Return the start time of the pattern. This time is returned in units * of 100 nsec to be directly comparable with the FADCs raw data reading. */ virtual unsigned int GetStartTime() { return fSltTime[0]; } /** Get the time of the n-th pixel in units of 100 ns. * * Each time a pixel is added to the PixelPattern, its time is calculated * from the column number and the time of the start pixel. */ virtual unsigned int GetTime(unsigned int n) { return fSltTime[n]; } /** Return the end time of the pattern in units of 100 nsec. */ virtual unsigned int GetEndTime(unsigned int n) { return fSltTime2[n]; } /** Return the status of the validity check. */ bool IsValid() { return fIsValid; } /** Reset some of the internal data structures to assign new pixels. */ void Reset() { fIsValid = false; fNPixel = 0; } /** Set the time of the pulse (derived from FADC trace). */ virtual void SetAdcTime(int n,unsigned short ptime) { fAdcTime[n] = ptime; }; /** Set the print level for all objects of this class. */ static void SetPrintLevel(unsigned int level = 1) { fgPrintLevel = level; } /** Set the SLT time for the n-th pixel in column 'col'. * * The column number is internally taken into account to calculate the * column dependant shift. */ virtual void SetSltTime(int n,unsigned int col,unsigned int t_start, unsigned int t_end); /** Set the column and the bin where a pattern starts. * * This method calculates then the start time for this pixel. */ virtual void SetStart(unsigned int col,unsigned int bin); /** Validate a given pattern, i.e. check if the pixels contained in * a pattern have really seen a trigger. */ bool Validate(TMirrorBitArray*); /** Get 'pseudo-X' value. */ static int GetX(unsigned int col,unsigned int row) { if ( row % 2 == 0 ) return (col << 1) + 1; else return col << 1; } /** Get 'pseudo-Y' value. */ static int GetY(unsigned int,unsigned int row) { return row << 1; } /** Get distance between cartesian 'pseudo (X,Y)-coordinates'. */ static float GetR(unsigned int rcol,unsigned int rrow, unsigned int col,unsigned int row) { int dx = GetX(col, row) - GetX(rcol, rrow); int dy = GetY(col, row) - GetY(rcol, rrow); return (float)std::sqrt( (float)(dx * dx + dy * dy) ); } protected: static unsigned int fgPrintLevel; unsigned int *fAdcTime; // pulse times derived from FADC trace unsigned int *fCol; // column indices of these pixels unsigned int fNPixel; // number of pixels in pattern, up to 5 unsigned int *fRow; // row indices of these pixels unsigned int *fSltTime; // pixel times measured in ns // derived from the SLT data, raising edge unsigned int *fSltTime2; // trailing SLT time edge unsigned int fStartBin; // the time bin where the pattern started unsigned int fStartColumn; // column where the pattern started private: PixelPattern(); // prevent clients from calling that ... virtual void AddPixel(FdUtil::Fd::PixelNumber) { std::cout << "PixelPattern::AddPixel()" << std::endl; } bool fIsValid; unsigned short fPatternId; }; #endif // _PixelPattern_hh_