Changeset 132 for drsdaq


Ignore:
Timestamp:
12/08/09 15:07:25 (15 years ago)
Author:
ogrimm
Message:
Clean-up DRS class by removing unnecessary overloaded function for CT VME controller
Location:
drsdaq
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • drsdaq/DRS/DRS.cc

    r22 r132  
    66  Created by:   Stefan Ritt, Matthias Schneebeli
    77
    8   Modified by:  Sebastian Commichau, May-November 2008
    9                 commichau@phys.ethz.ch
     8  Modified by:  Sebastian Commichau (2008)
     9                Oliver Grimm (Nov 2009)
    1010
    1111  Modification: This library works with:
     
    1313                - Struck VME controller (SIS 3100) => faster!
    1414
    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
    1716
    1817\********************************************************************/
     
    139138 
    140139#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");
    146142#endif
    147143
     
    155151}
    156152
    157 /*------------------------------------------------------------------*/
     153
     154void DRS::InitialScan() {
     155
     156  int index = 0;
     157 
     158  unsigned short Firmware, Serial, Temperature;
     159
    158160#ifdef CT_VME
    159 int DRS::OpenVME() {
    160 
    161   // Open VME connection
    162   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 #endif
    172 /*------------------------------------------------------------------*/
    173 
    174 void DRS::InitialScan() {
    175 
    176   int index = 0;
    177  
    178   unsigned short Firmware, Serial, Temperature;
    179 
    180 #ifdef CT_VME
    181161 
    182162  unsigned int BoardAddress;
     
    185165   
    186166    printf("VME connection opened\n");
    187 
    188     if (!OpenCMEM())
    189       printf("CMEM opened\n");
     167    if (!OpenCMEM()) printf("CMEM opened\n");
    190168    else return;
    191169   
     
    195173
    196174    MasterMap.window_size       = GEVPC_WINSIZE;                           // VME address window size
    197    
    198175    MasterMap.address_modifier  = VME_A32; 
    199176    MasterMap.options           = 0;
    200    
    201    
     177     
    202178    // Check all VME slave slots
    203179    for (index = First_VME_Slot; index <= Last_VME_Slot; index++) {
    204      
    205      
     180       
    206181      MasterMap.vmebus_address  = GEVPC_BASE_ADDR + index * GEVPC_WINSIZE; // Update VME board base address
    207 
    208      
     182   
    209183      if (DEBUG)
    210184        printf("Checking VME slot %d (base address: 0X%08X)\n",index,MasterMap.vmebus_address);
     
    399373}
    400374
    401 /*------------------------------------------------------------------*/
    402 
    403 #ifdef CT_VME
    404 int DRS::MasterMapVME(int *MMap) {
    405  
    406   // Do master mapping 
    407   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 #endif
    417 
    418 /*------------------------------------------------------------------*/
    419 
    420 #ifdef CT_VME
    421 int DRS::MasterUnMapVME(int MMap) {
    422  
    423   // Delete master mapping
    424   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 #endif
    434 
    435 /*------------------------------------------------------------------*/
    436 
    437 #ifdef CT_VME
    438 int DRS::CloseVME() {
    439  
    440   // Close VME connection
    441   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 #endif
    451 
    452 /*------------------------------------------------------------------*/
    453 
    454 #ifdef CT_VME
    455 int DRS::OpenCMEM() {
    456  
    457   // Open CMEM package
    458   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 #endif
    468 
    469 /*------------------------------------------------------------------*/
    470 
    471 #ifdef CT_VME
    472 int DRS::CloseCMEM() {
    473  
    474   // Close CMEM package
    475   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 #endif
    485375
    486376/*------------------------------------------------------------------*/
     
    506396  ,fDAC_INOFS(0)
    507397  ,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
    508406  ,fRequiredFirmwareVersion(0)
    509407  ,fFirmwareVersion(0)
     
    514412  ,fNumberOfReadoutChannels(0)
    515413  ,fExternalClockFrequency(0)
    516   ,fBaseAddress(BaseAddress)
    517 #ifdef CT_VME
    518   ,fBoardAddress(BoardAddress)
    519   ,fMasterMapping(MasterMapping)
    520414  ,fSlotNumber(SlotNumber)
    521 #endif
    522 #ifdef STRUCK_VME
    523   ,fVMEInterface(MVME_Interface)
    524   ,fSlotNumber(SlotNumber)
    525 #endif
    526415  ,fFrequency(0)
    527416  ,fDominoMode(0)
     
    941830   
    942831    // 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);
    944833
    945834    // Assign fields for BLT
     
    1003892#ifdef CT_VME
    1004893
    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;
    1018900
    1019901  if (size == 1) {
    1020    
    1021902    VME_ReadFastUChar(fMasterMapping, fBoardAddress + addr, static_cast<unsigned char*>(data));
    1022  
    1023   } else if (size == 2) {
    1024    
     903  } else if (size == 2) {   
    1025904    VME_ReadFastUShort(fMasterMapping, fBoardAddress + addr, static_cast<unsigned short*>(data));
    1026    
    1027905  } else if (size == 4) {
    1028    
    1029906    VME_ReadFastUInt(fMasterMapping, fBoardAddress + addr, static_cast<unsigned int*>(data));
    1030 
    1031907  } else {
    1032908
     
    1036912    BLT_List.list_of_items[0].size_requested       = MEM_SEGMENT;
    1037913    BLT_List.list_of_items[0].control_word         = VME_DMA_D64R | VME_A32;
    1038    
    1039914    BLT_List.number_of_items = 1;
    1040915
     
    1046921   
    1047922    // 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);
    1061924  }
    1062925  return size;
     
    1119982}
    1120983
    1121 
    1122 /*------------------------------------------------------------------*/
    1123 
    1124 #ifdef CT_VME
    1125 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 #endif
    1137 
    1138 /*------------------------------------------------------------------*/
    1139 
    1140 #ifdef CT_VME
    1141 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 #endif
    1154 
    1155 /*------------------------------------------------------------------*/
    1156 
    1157 #ifdef CT_VME
    1158 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 #endif
    1171 
    1172 /*------------------------------------------------------------------*/
    1173 
    1174 #ifdef CT_VME
    1175  int DRSBoard::FreeSegmentCMEM(int CMEM_SegIdentifier) {
    1176  
    1177   // Free memory segment
    1178   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 #endif
    1188984
    1189985/*------------------------------------------------------------------*/
     
    19261722}
    19271723
    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 once
    1941   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 transferred
    1968   for (i = firstChannel; i <= lastChannel; i++)
    1969     fWaveTransferred[i] = true;
    1970    
    1971   //fNumberOfTransferredWaves = numberOfChannels;
    1972   return n;
    1973 }
    1974 
    19751724/*------------------------------------------------------------------*/
    19761725
     
    20251774/*------------------------------------------------------------------*/
    20261775
    2027 int DRSBoard::DecodeWave(unsigned long *waveforms, unsigned int chipIndex, unsigned char channel, unsigned short *waveform)
    2028 {
    2029 
    2030   // Get waveform
    2031   int i, offset, ind;
    2032  
    2033   // Check valid parameters
    2034   if (channel > 9 || chipIndex > 1)
    2035     return kWrongChannelOrChip;
    2036  
    2037   // Re-map channel
    2038   if (fBoardVersion == 1) {
    2039     if (channel < 8)
    2040       channel = 7 - channel;
    2041     else
    2042       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 bit
    2054     if (chipIndex == 0)
    2055       waveform[i] = (unsigned short)(waveforms[ind] & 0X00000FFF);
    2056     // Upper 12 bit
    2057     else
    2058       waveform[i] = (unsigned short)(((unsigned long)(waveforms[ind] & 0X00FFF000)) >> 12);
    2059   }
    2060  
    2061   return kSuccess;
    2062 }
    2063 
    2064 /*------------------------------------------------------------------*/
    2065 
    20661776int DRSBoard::GetWave(unsigned int chipIndex, unsigned char channel, short *waveform, bool responseCalib,
    20671777                      int triggerCell, bool adjustToClock, float threshold)
     
    21761886/*------------------------------------------------------------------*/
    21771887
    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 
    21941888int DRSBoard::GetADCWave(unsigned int chipIndex, unsigned char channel, unsigned short *waveform)
    21951889{
     
    22001894
    22011895int 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)
    22091896{
    22101897  return DecodeWave(waveforms, chipIndex, channel, waveform);
     
    23111998  fTriggerCell = triggerCell;
    23121999  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, SCC
    2330    
    2331   triggerCell = -1;
    2332   for (j = 0; j < kNumberOfBins; j++) {
    2333     if (calib) {
    2334 
    2335       if (triggerChannel[j] <= baseLevel+200
    2336           && triggerChannel[(j + 1) % kNumberOfBins] > baseLevel+200) {
    2337         triggerCell = j;
    2338         break;
    2339       }
    2340     } else {
    2341 
    2342       if (triggerChannel[j] >= 2000
    2343           && 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 
    23562000}
    23572001
     
    44454089}
    44464090
     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
     4103int 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 
     4113int 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
     4123int 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
     4133int 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
     4143int 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
     4153int 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
     4162int 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
     4172int 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
     4182int 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
     4192int 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  
    2020// Concurrent Technologies VME single board computer
    2121#ifdef CT_VME
    22 #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
     22  #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
    2626#endif
    2727
    2828// Struck VME interface
    2929#ifdef STRUCK_VME
    30 #include "mvmestd.h"
     30  #include "mvmestd.h"
    3131#endif
    3232
     
    321321  unsigned int         fDAC_INOFS;
    322322  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
    324349 protected:
    325350  // Fields for DRS
     
    334359  double               fExternalClockFrequency;
    335360
    336   // VME
    337 #ifdef CT_VME
    338   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 buffer
    346   unsigned long        VirtualAddress;    // Virtual address of contiguous buffer 
    347 
    348   unsigned int         fBaseAddress;
    349   unsigned int         fBoardAddress;
    350   int                  fMasterMapping;
    351 #endif
    352 #ifdef STRUCK_VME
    353   mvme_addr_t          fBaseAddress;
    354   MVME_INTERFACE      *fVMEInterface;
    355 #endif
    356 
    357361  int                  fSlotNumber;
    358362  double               fFrequency;
     
    361365  int                  fTriggerEnable;
    362366  int                  fDelayedStart;
    363   int                  fTriggerCell;
    364  
    365 #ifdef STRUCK_VME
     367  int                  fTriggerCell; 
    366368  unsigned char        fWaveforms[kNumberOfChips * kNumberOfChannels * 2 * kNumberOfBins];
    367 #endif
    368 #ifdef CT_VME
    369   unsigned long        fWaveforms[kNumberOfChannels * kNumberOfBins];
    370 #endif
    371369 
    372370  // Fields for Calibration
     
    390388  int                  fTriggerStartBin; // Start bin of the trigger
    391389  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:
    399392  ~DRSBoard();
    400393 
     
    408401  // VME
    409402  int          GetSlotNumber() const { return fSlotNumber; }
    410 
    411 #ifdef CT_VME
    412   unsigned int GetBaseAddress() const {return fBaseAddress; }
    413   unsigned int GetBoardAddress() const {return fBoardAddress; }
    414 #endif
    415 
    416403  int          Read(int type, void *data, unsigned int addr, int size);
    417404  int          Write(int type, unsigned int addr, void *data, int size);
    418 
    419 #ifdef CT_VME
    420   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 #endif
    425405
    426406  void         RegisterTest(void);
     
    471451  int          TransferWaves(unsigned char *p, int numberOfChannels = kNumberOfChips * kNumberOfChannels);
    472452  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);
    475453  int          TransferWaves(int firstChannel, int lastChannel);
    476454
    477455  int          DecodeWave(unsigned char *waveforms, unsigned int chipIndex, unsigned char channel,
    478456                          unsigned short *waveform);
    479   int          DecodeWave(unsigned long *waveforms, unsigned int chipIndex, unsigned char channel,
    480                           unsigned short *waveform);
    481457  int          DecodeWave(unsigned int chipIndex, unsigned char channel, unsigned short *waveform);
    482458
    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);
    486459  int          GetWave(unsigned char *waveforms, unsigned int chipIndex, unsigned char channel, short *waveform,
    487460                       bool responseCalib = false, int triggerCell = -1, bool adjustToClock = false,
     
    497470  int          GetADCWave(unsigned char *waveforms,unsigned int chipIndex, unsigned char channel,
    498471                  unsigned short *waveform);
    499   int          GetADCWave(unsigned long *waveforms,unsigned int chipIndex, unsigned char channel,
    500                   unsigned short *waveform);
    501472 
    502473  void         RotateWave(int triggerCell, short *waveform); 
     
    507478  int          GetTriggerCell(unsigned int chipIndex);
    508479  int          GetTriggerCell(unsigned char *waveforms,unsigned int chipIndex);
    509   int          GetTriggerCell(unsigned long *waveforms,unsigned int chipIndex);
    510480  int          GetTriggerCell(float *waveform);
    511481
     
    538508 
    539509 protected:
    540   // Protected methods
    541510  void         ConstructBoard();
    542511  void         ReadSerialNumber();
    543512 
    544  
    545   TimeData    *GetTimeCalibration(unsigned int chipIndex, bool reinit = false);
    546  
     513  TimeData    *GetTimeCalibration(unsigned int chipIndex, bool reinit = false); 
    547514  int          GetStretchedTime(float *time, float *measurement, int numberOfMeasurements, float period);
    548515 
    549516 public:
    550  
    551517#ifdef CT_VME
    552518  DRSBoard(int MasterMapping, unsigned int BaseAddress, unsigned int BoardAddress, int SlotNumber);
    553519#endif
    554 
    555520#ifdef STRUCK_VME
    556521  DRSBoard(MVME_INTERFACE * MVME_Interface, mvme_addr_t BaseAddress, int SlotNumber);
     
    575540 
    576541  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
    577551 
    578552#ifdef CT_VME
    579553  VME_MasterMap_t  MasterMap;
    580554  VME_ErrorCode_t  ErrorCode;
    581  
    582555  char             ErrorString[VME_MAXSTRING];
    583  
    584556  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
    600558  int OpenVME();
    601559  int MasterMapVME(int* MMap);
    602560  int MasterUnMapVME(int MMap);
    603561  int CloseVME();
    604  
    605562  int OpenCMEM();
    606563  int CloseCMEM();
  • drsdaq/RawDataCTX.cc

    r110 r132  
    161161    }
    162162    else {
    163       if ((Count++) == EventNo) break;
     163      if ((++Count)==EventNo || EventNo==0) break;
    164164      if (fseek(Rawfile, EHeader->EventSize, SEEK_CUR) != 0) SEEK_OK = false;
    165165    }
Note: See TracChangeset for help on using the changeset viewer.