00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CAENCARD_H
00020 #define CAENCARD_H
00021
00022 #include <stdio.h>
00023 #include <sys/types.h>
00024 #include <sys/stat.h>
00025 #include <sys/mman.h>
00026 #include <errno.h>
00027 #include <fcntl.h>
00028 #include <unistd.h>
00029 #include <signal.h>
00030 #include <sys/ioctl.h>
00031
00032 #ifndef __CVMEINTERFACE_H
00033 #include <CVMEInterface.h>
00034 #endif
00035
00036 #ifndef SPECTRODAQ_H
00037
00038
00039 #ifdef HAVE_STD_NAMESPACE
00040 using namespace std;
00041 #endif
00042
00043 #include <spectrodaq.h>
00044 #endif
00045
00046
00047 #ifndef HAVE_VME_MAPPING
00048 #include <VmeModule.h>
00049 #endif
00050
00051
00052
00053 #define CAEN_DATUM_TYPE 0x07000000
00054 #define CAEN_HEADER 0x02000000
00055 #define CAEN_DATA 0x00000000
00056 #define CAEN_FOOTER 0x04000000
00057 #define CAEN_INVALID 0x06000000
00058
00059
00078 class CAENcard {
00079 public:
00080 typedef enum _ChainMember {
00081 NotInChain,
00082 FirstInChain,
00083 LastInChain,
00084 IntermediateInChain
00085 } ChainMember;
00086
00087 protected:
00088 int m_nSlot;
00089 int m_nCrate;
00090 bool m_fGeo;
00091 unsigned long m_nBase;
00092 #ifdef HAVE_VME_MAPPING
00093 volatile unsigned short* m_pModule;
00094 #else
00095 CVmeModule* m_pModule;
00096 #endif
00097 long m_nCardType;
00098 void* m_nFd;
00099 int m_nSerialno;
00100 int m_nHardwareRev;
00101 bool m_fSmallThresholds;
00102 int m_nInvalidTrailers;
00103 int m_nChancountHigh;
00104 int m_nChancountLow;
00105 int m_nEvents;
00106 unsigned short m_nFirmware;
00107
00108
00109
00110
00111
00112 public:
00113
00114
00115
00116
00117 CAENcard(int slotNum = -1, int crateNum = 0,
00118 bool fGeo=true, long nBase = 0);
00119 CAENcard(const CAENcard& card);
00120 CAENcard& operator=(const CAENcard& card);
00121 ~CAENcard();
00122
00123
00124 int getPhysicalCrate() const {
00125 return m_nCrate;
00126 }
00127 int getSlot() const {
00128 return m_nSlot;
00129 }
00130 bool isGeo() const {
00131 return m_fGeo;
00132 }
00133 unsigned long getBase() const {
00134 return m_nBase;
00135 }
00136 int getSerial() const {
00137 return m_nSerialno;
00138 }
00139 int getHardwareRev() const {
00140 return m_nHardwareRev;
00141 }
00142
00143
00144
00145 int cardType();
00146 int getFirmware();
00147 int getCrate();
00148 void setCrate(int crateNum);
00149 void setThreshold(int ch, int threshold);
00150 void setThresholdVoltage(int ch, double voltage);
00151 void keepUnderThresholdData();
00152 void discardUnderThresholdData();
00153 void keepOverflowData();
00154 void discardOverflowData();
00155 void keepInvalidData();
00156 void discardInvalidData();
00157 void emptyEnable();
00158 void emptyDisable();
00159 void commonStart();
00160 void commonStop();
00161 void setRange(int range);
00162 void setPedestalCurrent(int ped);
00163 void cardOff();
00164 void cardOn();
00165 void channelOff(int ch);
00166 void channelOn(int ch);
00167 void resetEventCounter();
00168 void clearData();
00169 void reset();
00170 bool dataPresent();
00171 bool gdataPresent();
00172 bool Busy();
00173 bool gBusy();
00174 bool MEBFull();
00175 bool MEBEmpty();
00176 int readEvent(void* buf);
00177 int readEvent(DAQWordBuffer& wbuf, int offset);
00178 int readEvent(DAQWordBufferPtr& wp);
00179 int readEvent(DAQDWordBuffer& dwbuf, int offset);
00180 int readEvent(DAQDWordBufferPtr& dwp);
00181 void setIped(int value);
00182 int getIped();
00183 void setFastClearWindow(int n);
00184 void enableSmallThresholds();
00185 void disableSmallThresholds();
00186 void SetCBLTChainMembership(int cbltaddr,
00187 ChainMember where);
00188
00189 void ClearStatistics();
00190 int InvalidTrailerCount();
00191 int ChannelsTooBigCount();
00192 int ChannelsTooSmallCount();
00193 int EventCount();
00194
00195
00196 protected:
00197 void DestroyCard();
00198 void slotInit();
00199 void MapCard();
00200 private:
00201 void Bitset1(short mask);
00202 void Bitclear1(short mask);
00203 void Bitset2(short mask);
00204 void Bitclear2(short mask);
00205 void ReadBufferBlock(int* pDest, Int_t size);
00206 };
00207
00208 #endif