Changeset 132
- Timestamp:
- 12/08/09 15:07:25 (15 years ago)
- Location:
- drsdaq
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
drsdaq/DRS/DRS.cc
r22 r132 6 6 Created by: Stefan Ritt, Matthias Schneebeli 7 7 8 Modified by: Sebastian Commichau , May-November 20089 commichau@phys.ethz.ch 8 Modified by: Sebastian Commichau (2008) 9 Oliver Grimm (Nov 2009) 10 10 11 11 Modification: This library works with: … … 13 13 - Struck VME controller (SIS 3100) => faster! 14 14 15 Contents: Library functions for DRS board CMC card - requires 16 DRS version 2 or 3 15 Library functions for DRS board CMC card - requires DRS version 2 or 3 17 16 18 17 \********************************************************************/ … … 139 138 140 139 #ifdef CT_VME 141 if (!CloseVME()) 142 printf("VME connection closed\n"); 143 144 if (!CloseCMEM()) 145 printf("CMEM closed\n"); 140 if (!CloseVME()) printf("VME connection closed\n"); 141 if (!CloseCMEM()) printf("CMEM closed\n"); 146 142 #endif 147 143 … … 155 151 } 156 152 157 /*------------------------------------------------------------------*/ 153 154 void DRS::InitialScan() { 155 156 int index = 0; 157 158 unsigned short Firmware, Serial, Temperature; 159 158 160 #ifdef CT_VME 159 int DRS::OpenVME() {160 161 // Open VME connection162 if ((ErrorCode = VME_Open()) != VME_SUCCESS) {163 164 VME_ErrorString(ErrorCode,ErrorString);165 166 printf("Error: %s\n",ErrorString);167 }168 169 return ErrorCode;170 }171 #endif172 /*------------------------------------------------------------------*/173 174 void DRS::InitialScan() {175 176 int index = 0;177 178 unsigned short Firmware, Serial, Temperature;179 180 #ifdef CT_VME181 161 182 162 unsigned int BoardAddress; … … 185 165 186 166 printf("VME connection opened\n"); 187 188 if (!OpenCMEM()) 189 printf("CMEM opened\n"); 167 if (!OpenCMEM()) printf("CMEM opened\n"); 190 168 else return; 191 169 … … 195 173 196 174 MasterMap.window_size = GEVPC_WINSIZE; // VME address window size 197 198 175 MasterMap.address_modifier = VME_A32; 199 176 MasterMap.options = 0; 200 201 177 202 178 // Check all VME slave slots 203 179 for (index = First_VME_Slot; index <= Last_VME_Slot; index++) { 204 205 180 206 181 MasterMap.vmebus_address = GEVPC_BASE_ADDR + index * GEVPC_WINSIZE; // Update VME board base address 207 208 182 209 183 if (DEBUG) 210 184 printf("Checking VME slot %d (base address: 0X%08X)\n",index,MasterMap.vmebus_address); … … 399 373 } 400 374 401 /*------------------------------------------------------------------*/402 403 #ifdef CT_VME404 int DRS::MasterMapVME(int *MMap) {405 406 // Do master mapping407 if (ErrorCode = VME_MasterMap(&MasterMap, MMap)) {408 409 VME_ErrorString(ErrorCode,ErrorString);410 411 printf("Error: %s\n",ErrorString);412 }413 414 return(ErrorCode);415 }416 #endif417 418 /*------------------------------------------------------------------*/419 420 #ifdef CT_VME421 int DRS::MasterUnMapVME(int MMap) {422 423 // Delete master mapping424 if (ErrorCode = VME_MasterUnmap(MMap)) {425 426 VME_ErrorString(ErrorCode,ErrorString);427 428 printf("Error: %s\n",ErrorString);429 }430 431 return(ErrorCode);432 }433 #endif434 435 /*------------------------------------------------------------------*/436 437 #ifdef CT_VME438 int DRS::CloseVME() {439 440 // Close VME connection441 if ((ErrorCode = VME_Close()) != VME_SUCCESS) {442 443 VME_ErrorString(ErrorCode,ErrorString);444 445 printf("Error: %s\n",ErrorString);446 }447 448 return ErrorCode;449 }450 #endif451 452 /*------------------------------------------------------------------*/453 454 #ifdef CT_VME455 int DRS::OpenCMEM() {456 457 // Open CMEM package458 if ((ErrorCode = CMEM_Open()) != CMEM_RCC_SUCCESS) {459 460 VME_ErrorString(ErrorCode,ErrorString);461 462 printf("Error: %s\n",ErrorString);463 }464 465 return ErrorCode;466 }467 #endif468 469 /*------------------------------------------------------------------*/470 471 #ifdef CT_VME472 int DRS::CloseCMEM() {473 474 // Close CMEM package475 if ((ErrorCode = CMEM_Close()) != CMEM_RCC_SUCCESS) {476 477 VME_ErrorString(ErrorCode,ErrorString);478 479 printf("Error: %s\n",ErrorString);480 }481 482 return ErrorCode;483 }484 #endif485 375 486 376 /*------------------------------------------------------------------*/ … … 506 396 ,fDAC_INOFS(0) 507 397 ,fDAC_BIAS(0) 398 ,fBaseAddress(BaseAddress) 399 #ifdef CT_VME 400 ,fBoardAddress(BoardAddress) 401 ,fMasterMapping(MasterMapping) 402 #endif 403 #ifdef STRUCK_VME 404 ,fVMEInterface(MVME_Interface) 405 #endif 508 406 ,fRequiredFirmwareVersion(0) 509 407 ,fFirmwareVersion(0) … … 514 412 ,fNumberOfReadoutChannels(0) 515 413 ,fExternalClockFrequency(0) 516 ,fBaseAddress(BaseAddress)517 #ifdef CT_VME518 ,fBoardAddress(BoardAddress)519 ,fMasterMapping(MasterMapping)520 414 ,fSlotNumber(SlotNumber) 521 #endif522 #ifdef STRUCK_VME523 ,fVMEInterface(MVME_Interface)524 ,fSlotNumber(SlotNumber)525 #endif526 415 ,fFrequency(0) 527 416 ,fDominoMode(0) … … 941 830 942 831 // Copy contiguous block of memory starting from VirtualAddress 943 memcpy(( unsigned long*)((unsigned long)VirtualAddress),(unsigned long*)data,size);832 memcpy((void *) VirtualAddress, data, size); 944 833 945 834 // Assign fields for BLT … … 1003 892 #ifdef CT_VME 1004 893 1005 if (size > MEM_SEGMENT) 1006 size = MEM_SEGMENT; 1007 1008 if (type == T_CTRL) 1009 addr += PMC_CTRL_OFFSET; 1010 else if (type == T_STATUS) 1011 addr += PMC_STATUS_OFFSET; 1012 else if (type == T_RAM) { 1013 addr += PMC_RAM_OFFSET; 1014 } 1015 else if (type == T_FIFO) { 1016 addr += PMC_FIFO_OFFSET; 1017 } 894 if (size > MEM_SEGMENT) size = MEM_SEGMENT; 895 896 if (type == T_CTRL) addr += PMC_CTRL_OFFSET; 897 else if (type == T_STATUS) addr += PMC_STATUS_OFFSET; 898 else if (type == T_RAM) addr += PMC_RAM_OFFSET; 899 else if (type == T_FIFO) addr += PMC_FIFO_OFFSET; 1018 900 1019 901 if (size == 1) { 1020 1021 902 VME_ReadFastUChar(fMasterMapping, fBoardAddress + addr, static_cast<unsigned char*>(data)); 1022 1023 } else if (size == 2) { 1024 903 } else if (size == 2) { 1025 904 VME_ReadFastUShort(fMasterMapping, fBoardAddress + addr, static_cast<unsigned short*>(data)); 1026 1027 905 } else if (size == 4) { 1028 1029 906 VME_ReadFastUInt(fMasterMapping, fBoardAddress + addr, static_cast<unsigned int*>(data)); 1030 1031 907 } else { 1032 908 … … 1036 912 BLT_List.list_of_items[0].size_requested = MEM_SEGMENT; 1037 913 BLT_List.list_of_items[0].control_word = VME_DMA_D64R | VME_A32; 1038 1039 914 BLT_List.number_of_items = 1; 1040 915 … … 1046 921 1047 922 // Copy contiguous block of memory starting from VirtualAddress 1048 memcpy((unsigned long*)data,(unsigned long*)((unsigned long)VirtualAddress),size); 1049 1050 // Do pseudo BLT 1051 /*for (i = 0; i < size; i += 4) 1052 VME_ReadFastUInt(fMasterMapping, fBoardAddress + addr + i, (unsigned int*)((unsigned char*)data + i)); 1053 1054 // Decode data 1055 printf("pseudo BLT: %d %d\n",((*((unsigned char*)data + 1) & 0x0f) << 8) | *((unsigned char*)data), 1056 ((*((unsigned char*)data + 2)) << 4) | ((*((unsigned char*)data + 1)) >> 4) ); 1057 1058 printf("pseudo BLT: %d %d\n",((*((unsigned char*)data + 5) & 0x0f) << 8) | *((unsigned char*)data + 4), 1059 ((*((unsigned char*)data + 6)) << 4) | ((*((unsigned char*)data + 5)) >> 4) ); 1060 */ 923 memcpy(data, (void *) VirtualAddress ,size); 1061 924 } 1062 925 return size; … … 1119 982 } 1120 983 1121 1122 /*------------------------------------------------------------------*/1123 1124 #ifdef CT_VME1125 int DRSBoard::AllocateSegmentCMEM(unsigned int SegSize, int *CMEM_SegIdentifier) {1126 1127 if ((ErrorCode = CMEM_SegmentAllocate(SegSize, "DMA_BUFFER", CMEM_SegIdentifier)) != CMEM_RCC_SUCCESS) {1128 1129 VME_ErrorString(ErrorCode,ErrorString);1130 1131 printf("Error: %s\n",ErrorString);1132 }1133 1134 return ErrorCode;1135 }1136 #endif1137 1138 /*------------------------------------------------------------------*/1139 1140 #ifdef CT_VME1141 int DRSBoard::AssignPhysicalSegAddressCMEM(int CMEM_SegIdentifier, unsigned long* PCIAddress) {1142 1143 if ((ErrorCode = CMEM_SegmentPhysicalAddress(CMEM_SegIdentifier, PCIAddress)) != CMEM_RCC_SUCCESS) {1144 1145 VME_ErrorString(ErrorCode,ErrorString);1146 1147 printf("Error: %s\n",ErrorString);1148 1149 }1150 1151 return ErrorCode;1152 }1153 #endif1154 1155 /*------------------------------------------------------------------*/1156 1157 #ifdef CT_VME1158 int DRSBoard::AssignVirtualSegAddressCMEM(int CMEM_SegIdentifier, unsigned long* VirtualAddress) {1159 1160 if ((ErrorCode = CMEM_SegmentVirtualAddress(CMEM_SegIdentifier, VirtualAddress)) != CMEM_RCC_SUCCESS) {1161 1162 VME_ErrorString(ErrorCode,ErrorString);1163 1164 printf("Error: %s\n",ErrorString);1165 1166 }1167 1168 return ErrorCode;1169 }1170 #endif1171 1172 /*------------------------------------------------------------------*/1173 1174 #ifdef CT_VME1175 int DRSBoard::FreeSegmentCMEM(int CMEM_SegIdentifier) {1176 1177 // Free memory segment1178 if ((ErrorCode = CMEM_SegmentFree(CMEM_SegIdentifier)) != CMEM_RCC_SUCCESS) {1179 1180 VME_ErrorString(ErrorCode,ErrorString);1181 1182 printf("Error: %s\n",ErrorString);1183 }1184 1185 return ErrorCode;1186 }1187 #endif1188 984 1189 985 /*------------------------------------------------------------------*/ … … 1926 1722 } 1927 1723 1928 /*------------------------------------------------------------------*/1929 1930 int DRSBoard::TransferWaves(unsigned long *p, int numberOfChannels)1931 {1932 return TransferWaves(p, 0, numberOfChannels-1);1933 }1934 1935 /*------------------------------------------------------------------*/1936 1937 int DRSBoard::TransferWaves(unsigned long *p, int firstChannel, int lastChannel)1938 {1939 1940 // Transfer all waveforms at once1941 int i, n, offset, n_requested;1942 1943 if (lastChannel < 0 || lastChannel > kNumberOfChips*kNumberOfChannels) {1944 printf("Error: Invalid channel index %d\n", lastChannel);1945 return 0;1946 }1947 1948 if (firstChannel < 0 || firstChannel > kNumberOfChips*kNumberOfChannels) {1949 printf("Error: Invalid channel index %d\n", firstChannel);1950 return 0;1951 }1952 1953 firstChannel = 0;1954 lastChannel = kNumberOfChips*kNumberOfChannels - 1;1955 1956 1957 n_requested = (lastChannel - firstChannel + 1) * sizeof(short int) * kNumberOfBins;1958 offset = firstChannel * sizeof(short int) * kNumberOfBins;1959 1960 n = Read(T_RAM, p, offset, n_requested);1961 1962 if (n != n_requested) {1963 printf("Error: only %d bytes read\n", n);1964 return n;1965 }1966 1967 // Remember which waveforms have been transferred1968 for (i = firstChannel; i <= lastChannel; i++)1969 fWaveTransferred[i] = true;1970 1971 //fNumberOfTransferredWaves = numberOfChannels;1972 return n;1973 }1974 1975 1724 /*------------------------------------------------------------------*/ 1976 1725 … … 2025 1774 /*------------------------------------------------------------------*/ 2026 1775 2027 int DRSBoard::DecodeWave(unsigned long *waveforms, unsigned int chipIndex, unsigned char channel, unsigned short *waveform)2028 {2029 2030 // Get waveform2031 int i, offset, ind;2032 2033 // Check valid parameters2034 if (channel > 9 || chipIndex > 1)2035 return kWrongChannelOrChip;2036 2037 // Re-map channel2038 if (fBoardVersion == 1) {2039 if (channel < 8)2040 channel = 7 - channel;2041 else2042 channel = 16 - channel;2043 } else {2044 channel = channel;2045 }2046 2047 offset = kNumberOfBins * channel;2048 2049 for (i = 0; i < kNumberOfBins; i++) {2050 2051 ind = i + offset;2052 2053 // Lower 12 bit2054 if (chipIndex == 0)2055 waveform[i] = (unsigned short)(waveforms[ind] & 0X00000FFF);2056 // Upper 12 bit2057 else2058 waveform[i] = (unsigned short)(((unsigned long)(waveforms[ind] & 0X00FFF000)) >> 12);2059 }2060 2061 return kSuccess;2062 }2063 2064 /*------------------------------------------------------------------*/2065 2066 1776 int DRSBoard::GetWave(unsigned int chipIndex, unsigned char channel, short *waveform, bool responseCalib, 2067 1777 int triggerCell, bool adjustToClock, float threshold) … … 2176 1886 /*------------------------------------------------------------------*/ 2177 1887 2178 int DRSBoard::GetWave(unsigned long *waveforms, unsigned int chipIndex, unsigned char channel, short *waveform, bool responseCalib,2179 int triggerCell, bool adjustToClock, float threshold)2180 {2181 if (!fWaveTransferred[chipIndex*kNumberOfChannels+channel])2182 return kWaveNotAvailable;2183 unsigned short adcWaveform[kNumberOfBins];2184 int ret = DecodeWave(waveforms, chipIndex, channel, adcWaveform);2185 if (ret!=kSuccess)2186 return ret;2187 2188 return CalibrateWaveform(chipIndex, channel, adcWaveform, waveform, responseCalib,2189 triggerCell, adjustToClock, threshold);2190 }2191 2192 /*------------------------------------------------------------------*/2193 2194 1888 int DRSBoard::GetADCWave(unsigned int chipIndex, unsigned char channel, unsigned short *waveform) 2195 1889 { … … 2200 1894 2201 1895 int DRSBoard::GetADCWave(unsigned char *waveforms,unsigned int chipIndex, unsigned char channel, unsigned short *waveform) 2202 {2203 return DecodeWave(waveforms, chipIndex, channel, waveform);2204 }2205 2206 /*------------------------------------------------------------------*/2207 2208 int DRSBoard::GetADCWave(unsigned long *waveforms,unsigned int chipIndex, unsigned char channel, unsigned short *waveform)2209 1896 { 2210 1897 return DecodeWave(waveforms, chipIndex, channel, waveform); … … 2311 1998 fTriggerCell = triggerCell; 2312 1999 return triggerCell; 2313 }2314 2315 /*------------------------------------------------------------------*/2316 2317 2318 int DRSBoard::GetTriggerCell(unsigned long *waveforms,unsigned int chipIndex)2319 {2320 2321 int j, triggerCell;2322 bool calib = 0;2323 unsigned short baseLevel = 1000;2324 unsigned short triggerChannel[1024];2325 if (!fWaveTransferred[chipIndex*kNumberOfChannels+8])2326 return -1;2327 2328 GetADCWave(waveforms,chipIndex, 8, triggerChannel);2329 //calib = fResponseCalibration->SubtractADCOffset(chipIndex, 8, triggerChannel, triggerChannel, baseLevel); // Changed 07/10/2008, SCC2330 2331 triggerCell = -1;2332 for (j = 0; j < kNumberOfBins; j++) {2333 if (calib) {2334 2335 if (triggerChannel[j] <= baseLevel+2002336 && triggerChannel[(j + 1) % kNumberOfBins] > baseLevel+200) {2337 triggerCell = j;2338 break;2339 }2340 } else {2341 2342 if (triggerChannel[j] >= 20002343 && triggerChannel[(j + 1) % kNumberOfBins] < 2000) {2344 triggerCell = j;2345 break;2346 }2347 }2348 }2349 2350 if (triggerCell == -1) {2351 return kInvalidTriggerSignal;2352 }2353 fTriggerCell = triggerCell;2354 return triggerCell;2355 2356 2000 } 2357 2001 … … 4445 4089 } 4446 4090 4091 4092 4093 4094 //************************************************************************************************** 4095 //** 4096 //** All functions special to the Concurrent Technologies single-board computer are collected here 4097 //** 4098 //************************************************************************************************** 4099 4100 #ifdef CT_VME 4101 4102 // Open VME connection 4103 int DRS::OpenVME() { 4104 4105 if ((ErrorCode = VME_Open()) != VME_SUCCESS) { 4106 VME_ErrorString(ErrorCode,ErrorString); 4107 printf("Error: %s\n",ErrorString); 4108 } 4109 return ErrorCode; 4110 } 4111 4112 // Do master mapping 4113 int DRS::MasterMapVME(int *MMap) { 4114 4115 if (ErrorCode = VME_MasterMap(&MasterMap, MMap)) { 4116 VME_ErrorString(ErrorCode,ErrorString); 4117 printf("Error: %s\n",ErrorString); 4118 } 4119 return(ErrorCode); 4120 } 4121 4122 // Delete master mapping 4123 int DRS::MasterUnMapVME(int MMap) { 4124 4125 if (ErrorCode = VME_MasterUnmap(MMap)) { 4126 VME_ErrorString(ErrorCode,ErrorString); 4127 printf("Error: %s\n",ErrorString); 4128 } 4129 return(ErrorCode); 4130 } 4131 4132 // Close VME connection 4133 int DRS::CloseVME() { 4134 4135 if ((ErrorCode = VME_Close()) != VME_SUCCESS) { 4136 VME_ErrorString(ErrorCode,ErrorString); 4137 printf("Error: %s\n",ErrorString); 4138 } 4139 return ErrorCode; 4140 } 4141 4142 // Open CMEM package 4143 int DRS::OpenCMEM() { 4144 4145 if ((ErrorCode = CMEM_Open()) != CMEM_RCC_SUCCESS) { 4146 VME_ErrorString(ErrorCode,ErrorString); 4147 printf("Error: %s\n",ErrorString); 4148 } 4149 return ErrorCode; 4150 } 4151 4152 // Close CMEM package 4153 int DRS::CloseCMEM() { 4154 4155 if ((ErrorCode = CMEM_Close()) != CMEM_RCC_SUCCESS) { 4156 VME_ErrorString(ErrorCode,ErrorString); 4157 printf("Error: %s\n",ErrorString); 4158 } 4159 return ErrorCode; 4160 } 4161 4162 int DRSBoard::AllocateSegmentCMEM(unsigned int SegSize, int *CMEM_SegIdentifier) { 4163 4164 if ((ErrorCode = CMEM_SegmentAllocate(SegSize, "DMA_BUFFER", CMEM_SegIdentifier)) != CMEM_RCC_SUCCESS) { 4165 VME_ErrorString(ErrorCode,ErrorString); 4166 printf("Error: %s\n",ErrorString); 4167 } 4168 return ErrorCode; 4169 } 4170 4171 4172 int DRSBoard::AssignPhysicalSegAddressCMEM(int CMEM_SegIdentifier, unsigned long* PCIAddress) { 4173 4174 if ((ErrorCode = CMEM_SegmentPhysicalAddress(CMEM_SegIdentifier, PCIAddress)) != CMEM_RCC_SUCCESS) { 4175 VME_ErrorString(ErrorCode,ErrorString); 4176 printf("Error: %s\n",ErrorString); 4177 } 4178 return ErrorCode; 4179 } 4180 4181 4182 int DRSBoard::AssignVirtualSegAddressCMEM(int CMEM_SegIdentifier, unsigned long* VirtualAddress) { 4183 4184 if ((ErrorCode = CMEM_SegmentVirtualAddress(CMEM_SegIdentifier, VirtualAddress)) != CMEM_RCC_SUCCESS) { 4185 VME_ErrorString(ErrorCode,ErrorString); 4186 printf("Error: %s\n",ErrorString); 4187 } 4188 return ErrorCode; 4189 } 4190 4191 // Free memory segment 4192 int DRSBoard::FreeSegmentCMEM(int CMEM_SegIdentifier) { 4193 4194 if ((ErrorCode = CMEM_SegmentFree(CMEM_SegIdentifier)) != CMEM_RCC_SUCCESS) { 4195 VME_ErrorString(ErrorCode,ErrorString); 4196 printf("Error: %s\n",ErrorString); 4197 } 4198 return ErrorCode; 4199 } 4200 4201 4202 #endif -
drsdaq/DRS/DRS.h
r22 r132 20 20 // Concurrent Technologies VME single board computer 21 21 #ifdef CT_VME 22 #include "rcc_error/rcc_error.h" // Error reporting23 #include "vme_rcc/vme_rcc.h" // VME access24 #include "cmem_rcc/cmem_rcc.h" // Allocation of contiguous memory25 #include "rcc_time_stamp/tstamp.h" // Time stamp library22 #include "rcc_error/rcc_error.h" // Error reporting 23 #include "vme_rcc/vme_rcc.h" // VME access 24 #include "cmem_rcc/cmem_rcc.h" // Allocation of contiguous memory 25 #include "rcc_time_stamp/tstamp.h" // Time stamp library 26 26 #endif 27 27 28 28 // Struck VME interface 29 29 #ifdef STRUCK_VME 30 #include "mvmestd.h"30 #include "mvmestd.h" 31 31 #endif 32 32 … … 321 321 unsigned int fDAC_INOFS; 322 322 unsigned int fDAC_BIAS; 323 323 324 private: 325 #ifdef CT_VME 326 VME_ErrorCode_t ErrorCode; 327 VME_BlockTransferList_t BLT_List; 328 char ErrorString[VME_MAXSTRING]; 329 int CMEM_SegIdentifier; 330 unsigned long PCIAddress; // Physical address of contiguous buffer 331 unsigned long VirtualAddress; // Virtual address of contiguous buffer 332 unsigned int fBaseAddress; 333 unsigned int fBoardAddress; 334 int fMasterMapping; 335 336 unsigned int GetBaseAddress() const {return fBaseAddress; } 337 unsigned int GetBoardAddress() const {return fBoardAddress; } 338 339 int AllocateSegmentCMEM(unsigned int SegSize, int *CMEM_SegIdentifier); 340 int AssignPhysicalSegAddressCMEM(int CMEM_SegIdentifier, unsigned long* PCIAddress); 341 int AssignVirtualSegAddressCMEM(int CMEM_SegIdentifier, unsigned long* VirtualAddress); 342 int FreeSegmentCMEM(int CMEM_SegIdentifier); 343 #endif 344 #ifdef STRUCK_VME 345 mvme_addr_t fBaseAddress; 346 MVME_INTERFACE *fVMEInterface; 347 #endif 348 324 349 protected: 325 350 // Fields for DRS … … 334 359 double fExternalClockFrequency; 335 360 336 // VME337 #ifdef CT_VME338 VME_ErrorCode_t ErrorCode;339 VME_BlockTransferList_t BLT_List;340 341 char ErrorString[VME_MAXSTRING];342 343 int CMEM_SegIdentifier;344 345 unsigned long PCIAddress; // Physical address of contiguous buffer346 unsigned long VirtualAddress; // Virtual address of contiguous buffer347 348 unsigned int fBaseAddress;349 unsigned int fBoardAddress;350 int fMasterMapping;351 #endif352 #ifdef STRUCK_VME353 mvme_addr_t fBaseAddress;354 MVME_INTERFACE *fVMEInterface;355 #endif356 357 361 int fSlotNumber; 358 362 double fFrequency; … … 361 365 int fTriggerEnable; 362 366 int fDelayedStart; 363 int fTriggerCell; 364 365 #ifdef STRUCK_VME 367 int fTriggerCell; 366 368 unsigned char fWaveforms[kNumberOfChips * kNumberOfChannels * 2 * kNumberOfBins]; 367 #endif368 #ifdef CT_VME369 unsigned long fWaveforms[kNumberOfChannels * kNumberOfBins];370 #endif371 369 372 370 // Fields for Calibration … … 390 388 int fTriggerStartBin; // Start bin of the trigger 391 389 bool kRotateWave; 392 393 private: 394 DRSBoard(const DRSBoard &c); // Not implemented 395 DRSBoard &operator=(const DRSBoard &rhs); // Not implemented 396 397 public: 398 390 391 public: 399 392 ~DRSBoard(); 400 393 … … 408 401 // VME 409 402 int GetSlotNumber() const { return fSlotNumber; } 410 411 #ifdef CT_VME412 unsigned int GetBaseAddress() const {return fBaseAddress; }413 unsigned int GetBoardAddress() const {return fBoardAddress; }414 #endif415 416 403 int Read(int type, void *data, unsigned int addr, int size); 417 404 int Write(int type, unsigned int addr, void *data, int size); 418 419 #ifdef CT_VME420 int AllocateSegmentCMEM(unsigned int SegSize, int *CMEM_SegIdentifier);421 int AssignPhysicalSegAddressCMEM(int CMEM_SegIdentifier, unsigned long* PCIAddress);422 int AssignVirtualSegAddressCMEM(int CMEM_SegIdentifier, unsigned long* VirtualAddress);423 int FreeSegmentCMEM(int CMEM_SegIdentifier);424 #endif425 405 426 406 void RegisterTest(void); … … 471 451 int TransferWaves(unsigned char *p, int numberOfChannels = kNumberOfChips * kNumberOfChannels); 472 452 int TransferWaves(unsigned char *p, int firstChannel, int lastChannel); 473 int TransferWaves(unsigned long *p, int numberOfChannels = kNumberOfChips * kNumberOfChannels);474 int TransferWaves(unsigned long *p, int firstChannel, int lastChannel);475 453 int TransferWaves(int firstChannel, int lastChannel); 476 454 477 455 int DecodeWave(unsigned char *waveforms, unsigned int chipIndex, unsigned char channel, 478 456 unsigned short *waveform); 479 int DecodeWave(unsigned long *waveforms, unsigned int chipIndex, unsigned char channel,480 unsigned short *waveform);481 457 int DecodeWave(unsigned int chipIndex, unsigned char channel, unsigned short *waveform); 482 458 483 int GetWave(unsigned long *waveforms, unsigned int chipIndex, unsigned char channel, short *waveform,484 bool responseCalib = false, int triggerCell = -1, bool adjustToClock = false,485 float threshold = 0);486 459 int GetWave(unsigned char *waveforms, unsigned int chipIndex, unsigned char channel, short *waveform, 487 460 bool responseCalib = false, int triggerCell = -1, bool adjustToClock = false, … … 497 470 int GetADCWave(unsigned char *waveforms,unsigned int chipIndex, unsigned char channel, 498 471 unsigned short *waveform); 499 int GetADCWave(unsigned long *waveforms,unsigned int chipIndex, unsigned char channel,500 unsigned short *waveform);501 472 502 473 void RotateWave(int triggerCell, short *waveform); … … 507 478 int GetTriggerCell(unsigned int chipIndex); 508 479 int GetTriggerCell(unsigned char *waveforms,unsigned int chipIndex); 509 int GetTriggerCell(unsigned long *waveforms,unsigned int chipIndex);510 480 int GetTriggerCell(float *waveform); 511 481 … … 538 508 539 509 protected: 540 // Protected methods541 510 void ConstructBoard(); 542 511 void ReadSerialNumber(); 543 512 544 545 TimeData *GetTimeCalibration(unsigned int chipIndex, bool reinit = false); 546 513 TimeData *GetTimeCalibration(unsigned int chipIndex, bool reinit = false); 547 514 int GetStretchedTime(float *time, float *measurement, int numberOfMeasurements, float period); 548 515 549 516 public: 550 551 517 #ifdef CT_VME 552 518 DRSBoard(int MasterMapping, unsigned int BaseAddress, unsigned int BoardAddress, int SlotNumber); 553 519 #endif 554 555 520 #ifdef STRUCK_VME 556 521 DRSBoard(MVME_INTERFACE * MVME_Interface, mvme_addr_t BaseAddress, int SlotNumber); … … 575 540 576 541 DRSBoard *fBoard[kMaxNumberOfBoards]; 542 int fNumberOfBoards; 543 544 #ifdef STRUCK_VME 545 MVME_INTERFACE *fVMEInterface; 546 #endif 547 548 private: 549 DRS(const DRS &c); // Not implemented 550 DRS &operator=(const DRS &rhs); // Not implemented 577 551 578 552 #ifdef CT_VME 579 553 VME_MasterMap_t MasterMap; 580 554 VME_ErrorCode_t ErrorCode; 581 582 555 char ErrorString[VME_MAXSTRING]; 583 584 556 int MasterMapping[kMaxNumberOfBoards]; 585 #endif 586 587 int fNumberOfBoards; 588 589 #ifdef STRUCK_VME 590 MVME_INTERFACE *fVMEInterface; 591 #endif 592 593 594 private: 595 DRS(const DRS &c); // Not implemented 596 DRS &operator=(const DRS &rhs); // Not implemented 597 598 599 #ifdef CT_VME 557 600 558 int OpenVME(); 601 559 int MasterMapVME(int* MMap); 602 560 int MasterUnMapVME(int MMap); 603 561 int CloseVME(); 604 605 562 int OpenCMEM(); 606 563 int CloseCMEM(); -
drsdaq/RawDataCTX.cc
r110 r132 161 161 } 162 162 else { 163 if (( Count++) == EventNo) break;163 if ((++Count)==EventNo || EventNo==0) break; 164 164 if (fseek(Rawfile, EHeader->EventSize, SEEK_CUR) != 0) SEEK_OK = false; 165 165 }
Note:
See TracChangeset
for help on using the changeset viewer.