Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:39

0001 #ifndef __PACKET_H__
0002 #define __PACKET_H__
0003 
0004 
0005 #include "generalDefinitions.h"
0006 
0007 #include "event_io.h"
0008 
0009 #define WINDOWSEXPORT
0010 
0011 // --------------------------------------------------
0012 // the virtual base base class for all Packets.
0013 // --------------------------------------------------
0014 
0015 
0016 /**
0017     This is the abstract packet class.
0018 */
0019 #ifndef __CINT__
0020 class WINDOWSEXPORT Packet
0021 #else
0022 class  Packet
0023 #endif
0024   {
0025 
0026    /* @name Description of the interface routines
0027       these are the interface routines to get at decoded values.
0028       iValue and rValue return int's and float's, respectively.
0029       the optional "what" parameter is needed for some devices
0030       which have more than one type of information, such as the
0031       MIZAR board, which gets ADC and TDC values.
0032       iValue(0), iValue(0,""), and iValue("ADC") all
0033       return what we call "natural data", which means ADC information
0034       (I decided that), while iValue(0,"TDC") gives you the TDC
0035       value of channel 0. All Packet classes accept "RAW" as a type,
0036       directing them to return unprocessed/undecoded packet raw data.
0037 
0038       The array-type interface iValue(const int channel,const int iy)
0039       is just a convenient call for devices which inherently have
0040       two-dimensional arrays of data, such as the Hammond flash ADC
0041       board, where you get 8 channels with 512 time samples each.
0042       Another example is a group of several, say, LC2249W ADC's read out
0043       in one packet, so that iValue(0,2) refers to channel 0 of the
0044       second ADC in the group.
0045    */
0046 
0047 
0048 
0049 
0050   public:
0051   /// the virtual destructor
0052   inline virtual ~Packet() {};
0053 
0054   // **** getting decoded values ****
0055 
0056 
0057 
0058   /// iValue returns the value of a given channel as an int.
0059   virtual int    iValue(const int /*channel*/) =0;
0060 
0061   /** with the "what" parameter you can decide which aspect
0062       of the data you want to see (for devices which have more than one)
0063   */
0064   virtual int    iValue(const int /*channel*/, const char * /*what*/) =0;
0065 
0066   /** we have a few recent devices which have one more dimension
0067       (such as card, time sample, channel)
0068   */
0069   virtual int    iValue(const int /*channel*/, const int /*y*/, const char * /*what*/) =0;
0070 
0071   /** this supports devices which are inherently organized as two-dimensional
0072       data, such as flash ADC's (channel vs time slice)
0073   */
0074   virtual int    iValue(const int /*channel*/,const int /*iy*/) =0;
0075 
0076   /** this supports devices  organized as three-dimensional
0077       data (card vs channel vs time slice )
0078   */
0079   virtual int    iValue(const int /*channel*/,const int /*iy*/, const int /*iz*/) =0;
0080 
0081   /** this supports devices  organized as three-dimensional
0082       data (card vs channel vs time slice, with a "what" selection )
0083   */
0084   virtual int    iValue(const int /*channel*/,const int /*iy*/, const int /*iz*/, const char */*what*/) =0;
0085 
0086   /** rValue returns the value of a given channel as a float */
0087   virtual float  rValue(const int /*channel*/) =0;
0088 
0089   /** dValue returns the value of a given channel as a double */
0090   virtual double  dValue(const int channel)
0091   {return rValue(channel);};
0092 
0093   virtual double  dValue(const int channel, const char *what)
0094   {return iValue(channel, what);};
0095 
0096   virtual double  dValue(const int channel, const int iy)
0097   {return iValue(channel, iy);};
0098 
0099   /** lValue returns the value of a given channel as a long long */
0100   virtual long long  lValue(const int channel)
0101   {return iValue(channel);};
0102 
0103   virtual long long  lValue(const int channel, const char *what)
0104   {return iValue(channel,what);};
0105 
0106   virtual long long  lValue(const int channel, const int iy)
0107   {return iValue(channel, iy);};
0108 
0109   virtual long long  lValue(const int channel, const int iy, const char *what)
0110   {return iValue(channel, iy, what);};
0111 
0112   /** with the "what" parameter you can decide which aspect
0113       of the data you want to see (for devices which have more than one)
0114   */
0115   virtual float  rValue(const int /*channel*/, const char * /*what*/) =0;
0116 
0117 
0118   /** this supports devices which are inherently organized as two-dimensional
0119       data, such as flash ADC's (channel vs time slice)
0120   */
0121   virtual float  rValue(const int /*channel*/, const int /*iy*/) =0;
0122 
0123   virtual void * pValue(const int /*channel*/)
0124   {
0125     return 0;
0126   }
0127 
0128   virtual void * pValue(const int /*channel*/, const char * /*what*/)
0129   {
0130     return 0;
0131   }
0132 
0133   virtual void * pValue(const int /*chan*/, const int /*iy*/)
0134   {
0135     return 0;
0136   }
0137 
0138 
0139 
0140 
0141   // *** now getting all the decoded values in one go ***
0142   // these routines get you all the decoded values into an array
0143   // of float's or int's. The what parameter has the usual meaning.
0144 
0145   /** getArraylength returns the length of the array needed to store the
0146       decoded values.
0147   */
0148   virtual int    getArraylength(const char * what ="") =0;
0149 
0150   /** fillIntArray and fillFloatArray fill existing (user-supplied) arrays
0151       with the decoded data
0152   */
0153   virtual int    fillIntArray (int destination[],    // the data go here
0154                    const int /*length*/,      // space we have in destination
0155                    int * /*nw*/,              // words actually used
0156                    const char * what="") = 0; // type of data (see above)
0157 
0158   ///  fillFloatArray fills an array of floats
0159   virtual int    fillFloatArray (float destination[],    // the data go here
0160                  const int /*length*/,      // space we have in destination
0161                  int * /*nw*/,              // words actually used
0162                  const char * what="") = 0; // type of data (see above)
0163 
0164   /** getIntArray and getFloatArray create a new array of the approriate size
0165       fill it with the decoded values, and return a pointer to the array.
0166       nw is the length of the array created.
0167   */
0168   virtual int*   getIntArray (int * /*nw*/,const char * ="") =0;
0169 
0170   ///  getFloatArray creates and returns an array of floats
0171   virtual float* getFloatArray (int * /*nw*/,const char * ="") =0;
0172 
0173 
0174   /// find out what type (pointer- or data based) packet object we have
0175   virtual int is_pointer_type() const = 0;
0176 
0177   /// convert from pointer- to data based object, if it is already data-based, do nothing.
0178   virtual int convert() =0;
0179 
0180 
0181   // access to envelope information:
0182 
0183   /** getLength() returns the length of the raw packet data. If you were to copy the data
0184       somewhere, the destination must be able to hold as many words.
0185   */
0186   virtual int   getLength() const = 0;
0187 
0188   //  virtual int   getType() const = 0;
0189   //  virtual int   getDecoding() const = 0;
0190 
0191   // some more header fields which are not yet implemented, marked "//*"
0192   //* virtual int   gethdrVersion() const = 0; // Version of header definition
0193   //* virtual int   getHdrLength() const = 0;     // inclusive of alignment data
0194   virtual int   getStatus() const = 0;         // returns 0 for all ok 
0195 
0196   virtual int   getErrorLength() const = 0;    // Length of error block in Dwords
0197 
0198   /// get the length of the debug block
0199   virtual int   getDebugLength() const = 0;// Length of debug block in Dwords
0200 
0201   /// get the packet identifier
0202   virtual int   getIdentifier() const = 0; // Identifier
0203 
0204   //* virtual int   getEndianism() const = 0;  // Big/little endian indicator
0205 
0206   /// get the number of padding units in the packet data.
0207   virtual int   getPadding() const = 0;    // number of padding units
0208 
0209   /// get the structure of the packet data; unformatted, hitlist, etc.
0210   virtual int   getStructure() const = 0;  // Structure of packet
0211 
0212   //* virtual int   getWordSize() const = 0;   // "Word" size used to store packet data
0213   //* virtual int   getAddrLength() const = 0; // number of bytes used for channel address
0214   //* virtual int   getHitLength() const = 0;  // Length of a single "hit" in bytes
0215 
0216   /// get the hit format; in case of unformatted get the encoding scheme.
0217   virtual int   getHitFormat() const = 0;  // Format of a single hit
0218   //* virtual int   getNumEntries() const = 0; // Number of "objects" stored in packet
0219 
0220   /// get what the name says...
0221   virtual int   getDataLength() const = 0;  // Format of a single hit
0222 
0223   // debugging-type information
0224   // identify will write a short identification message to
0225   // standard output or to the iOSTREAM provided. Nice to see.
0226 
0227 
0228   //#ifdef LVL2_WINNT
0229   ///see below for comments
0230   //  virtual void  identify( std::OSTREAM&os =std::COUT ) const = 0;
0231   //  virtual void  fullIdentify( std::OSTREAM& os =std::COUT ) const
0232   //    { identify(os);};
0233   //  virtual void  dump ( std::OSTREAM& =std::COUT )  = 0;
0234   //  virtual void  gdump (const int how = EVT_HEXADECIMAL, std::OSTREAM& =std::COUT) const = 0;
0235 
0236 
0237   /// write an identification message to the supplied OSTREAM.
0238 
0239   virtual void identify(std::ostream& os = std::cout) const = 0;
0240 
0241   /// set a new packet identifier
0242   virtual int   setIdentifier(const int /*newid*/) = 0; // Identifier
0243 
0244   /// write an indepth identification message to the supplied OSTREAM.
0245   virtual void fullIdentify(std::ostream& os = std::cout) const
0246   { identify(os);};
0247 
0248   /**dump (either to standard output or the specified OSTREAM)
0249      the packet's data in some packet-specific way.
0250   */
0251 
0252   virtual void dump(std::ostream& os = std::cout)  = 0;
0253 
0254 
0255   /** Since dump()
0256       requires the packet data to be consistent, gdump ("generic" dump)
0257       dumps the data without making assumptions about the integrity of
0258       the packet data. For many Packet classes dump just calls gdump
0259       because it is good enough. The "how" parameter for gdump specifies
0260       decimal, octal, or hexadecimal (0,1,2) dump.
0261   */
0262 
0263   virtual void gdump(const int how = EVT_HEXADECIMAL, std::ostream& os = std::cout) const  = 0;
0264 
0265   /** This functiion returns the status of the DCM transfer checksum.
0266       0  = cannot be calculated for this packet
0267       1  = ok
0268       -1  = fail
0269 
0270   */
0271   virtual int getCheckSumStatus() const { return 0;};
0272   virtual int   copyMe(int [],  const int /*maxlength*/) const { return 0;};
0273 
0274   virtual int setInternalParameter ( const int p1=0, const int p2=0, const char *what = "") = 0;
0275 
0276 
0277   };
0278 
0279 // some structures for the LVL triggers
0280 
0281 // emcal
0282 
0283 struct emcChannelLongList
0284 {
0285   int channel;
0286   int time;
0287   int highpost;
0288   int lowpost;
0289   int highpre;
0290   int lowpre;
0291 };
0292 
0293 
0294 #define RICH_TIME 0
0295 #define RICH_POSTSAMPLE 1
0296 #define RICH_PRESAMPLE 2
0297 
0298 struct richChannelList
0299 {
0300   int channel;
0301   int time;
0302   int post;
0303   int pre;
0304 };
0305 
0306 struct emcChannelShortList
0307 {
0308   int channel;
0309   int gain;  // 0 = low, else high
0310   int time;
0311   int post;
0312   int pre;
0313 
0314 };
0315 
0316 struct tecChannelList
0317 {
0318   int channel;
0319   int time;
0320   int value;
0321 
0322 };
0323 
0324 
0325 #endif /* __PACKET_H__ */