Changeset 49


Ignore:
Timestamp:
05/28/09 10:35:43 (15 years ago)
Author:
ogrimm
Message:
Small change to data format
Location:
drsdaq
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • drsdaq/DAQReadout.cc

    r44 r49  
    7171  NumEvents             = 0;
    7272  NumEventsRequested    = 100;
    73   NumCMCBoards          = 0;
     73  NumBoards             = 0;
    7474  FirstBoard            = 0;
    7575  LastBoard             = -1;
     
    125125      i, (drs->GetBoard(i)->GetSlotNumber() >> 1)+2, ((drs->GetBoard(i)->GetSlotNumber() & 1) == 0) ? "upper" : "lower",
    126126      drs->GetBoard(i)->GetCMCSerialNumber(), drs->GetBoard(i)->GetFirmwareVersion());
    127     NumCMCBoards++;
     127    NumBoards++;
    128128    LastBoard++;
    129129    drs->GetBoard(i)->Init();
     
    131131    DRSFreq[i] = 0;
    132132  }
    133   BStruct  = new BoardStructure [NumCMCBoards == 0 ? 1:drs->GetNumberOfBoards()];
    134   WaveForm = new short [NumCMCBoards == 0 ? 1:NumCMCBoards][kNumberOfChips][kNumberOfChannels][kNumberOfBins];
     133  BStruct  = new BoardStructure [NumBoards == 0 ? 1:drs->GetNumberOfBoards()];
     134  WaveForm = new short [NumBoards == 0 ? 1:NumBoards][kNumberOfChips][kNumberOfChannels][kNumberOfBins];
    135135 
    136136  // Create instance of HV feedback (must be called after CMC board detection)
     
    182182    if (Match(Param[0], CommandList[CmdNumber].Name)) {
    183183      if(CommandList[CmdNumber].NeedNotBusy && daq_state==active) PrintMessage("DAQ is busy\n");
    184       else if(CommandList[CmdNumber].NeedNotBusy && NumCMCBoards==0) PrintMessage("No mezzanine boards available\n");
     184      else if(CommandList[CmdNumber].NeedNotBusy && NumBoards==0) PrintMessage("No mezzanine boards available\n");
    185185      else (this->*CommandList[CmdNumber].CommandPointer)();
    186186      return 0; 
     
    223223 
    224224  if(!Match(Param[1],"test")) {
    225     if (daq_state==active || NumCMCBoards==0) {
     225    if (daq_state==active || NumBoards==0) {
    226226      PrintMessage("DAQ is busy or no boards available.\n");
    227227      return;
     
    322322  }
    323323 
    324   if (NumCMCBoards) for (i=FirstBoard; i<=LastBoard; i++) {
     324  if (NumBoards) for (i=FirstBoard; i<=LastBoard; i++) {
    325325        PrintMessage("BLT test started (board #%d)\n",i);
    326326        (drs->GetBoard(i))->TestRead(Param[2][0] && atoi(Param[2])<=10000 && atoi(Param[2])>0 ? atoi(Param[2]):1, Type);
     
    345345
    346346void DAQReadout::cmd_read() {
    347   if(NumCMCBoards==0) {
     347  if(NumBoards==0) {
    348348    PrintMessage("No mezzanine boards available\n");
    349349    return;
     
    475475      NumEventsRequested, fRawDataPath,
    476476      CheckDisk(fRawDataPath), Socket==-1 ? "disconnected":"connected",
    477       NumCMCBoards, LastBoard - FirstBoard + 1);
     477      NumBoards, LastBoard - FirstBoard + 1);
    478478
    479479    for (int i=FirstBoard;i<=LastBoard;i++)
     
    483483  if(NParam==1 || Match(Param[1],"drs")) {
    484484    PrintMessage("\n********** DRS STATUS **********\n");
    485     if (NumCMCBoards) {
     485    if (NumBoards) {
    486486      for (int i=FirstBoard; i<=LastBoard; i++) {
    487487
     
    552552    LastBoard = drs->GetNumberOfBoards()-1;
    553553  }
    554   else if (NParam==2 && atoi(Param[1]) >= 0 && atoi(Param[1]) < NumCMCBoards) {
     554  else if (NParam==2 && atoi(Param[1]) >= 0 && atoi(Param[1]) < NumBoards) {
    555555    FirstBoard = atoi(Param[1]);
    556556    LastBoard = FirstBoard;
    557557  }
    558   else if (NParam==3 && atoi(Param[1])>=0 && atoi(Param[1])<NumCMCBoards &&
    559            atoi(Param[2])>0 && atoi(Param[2])<NumCMCBoards) {
     558  else if (NParam==3 && atoi(Param[1])>=0 && atoi(Param[1])<NumBoards &&
     559           atoi(Param[2])>0 && atoi(Param[2])<NumBoards) {
    560560    FirstBoard = atoi(Param[1]);
    561561    LastBoard = atoi(Param[2]);
     
    710710void DAQReadout::SetDOMINOMode(int mode) {
    711711 
    712   if (NumCMCBoards)
     712  if (NumBoards)
    713713    for (int i=FirstBoard; i<=LastBoard; i++) {
    714714      (drs->GetBoard(i))->SetDominoMode(mode==1 ? 1:0);
     
    721721void DAQReadout::SetDOMINOReadMode(int mode) {
    722722
    723   if (NumCMCBoards)
     723  if (NumBoards)
    724724    for (int i=FirstBoard; i<=LastBoard; i++) {
    725725      (drs->GetBoard(i))->SetReadoutMode(mode==1 ? 1:0);
     
    732732void DAQReadout::SetDOMINOWaveMode(int mode) {
    733733
    734   if (NumCMCBoards)
     734  if (NumBoards)
    735735    for (int i=FirstBoard; i<=LastBoard; i++) {
    736736      (drs->GetBoard(i))->SetDominoActive(mode==1 ? 1:0);
     
    743743void DAQReadout::SetDelayedStart(int mode) {
    744744
    745   if (NumCMCBoards)
     745  if (NumBoards)
    746746    for (int i=FirstBoard; i<=LastBoard; i++) {
    747747      (drs->GetBoard(i))->SetDelayedStart(mode==1 ? 1:0);
     
    754754void DAQReadout::HWTrigger(int mode) {
    755755
    756   if (NumCMCBoards)
     756  if (NumBoards)
    757757    for (int i=FirstBoard; i<=LastBoard; i++) {
    758758      drs->GetBoard(i)->EnableTrigger(mode==1 ? 1:0);
     
    789789  DIR *pdir;
    790790     
    791   if (NumCMCBoards) {
     791  if (NumBoards) {
    792792    if(dir!=NULL) {
    793793      if ((pdir=opendir(str))==0){
     
    893893}
    894894
    895 // Write run header and board structures
     895// Write run header and board structures (revision number is zero for svn modified working copy)
    896896bool DAQReadout::WriteRunHeader() {
    897897
     
    900900  RHeader->MagicNum = MAGICNUM_OPEN;
    901901  RHeader->DataFormat = DATA_FORMAT;
    902   RHeader->SoftwareRevision = atoi(REVISION);
     902  RHeader->SoftwareRevision = atoi(REVISION) * (strchr(REVISION, 'M')==NULL ? 1:-1);
    903903
    904904  RHeader->RunHeaderSize = sizeof(RunHeader);
     
    914914  RHeader->StartMicrosecond = Time.tv_usec;
    915915 
    916   RHeader->NCMCBoards = NumCMCBoards==0 && daq_runtype==test ? 1 : (LastBoard - FirstBoard) + 1; 
    917   RHeader->NChips     = kNumberOfChips;
    918   RHeader->NChannels  = kNumberOfChannels;
     916  RHeader->NBoards   = NumBoards==0 && daq_runtype==test ? 1 : (LastBoard - FirstBoard) + 1; 
     917  RHeader->NChips    = kNumberOfChips;
     918  RHeader->NChannels = kNumberOfChannels;
    919919
    920920  RHeader->Offset  = fFirstSample;
     
    934934
    935935  // In case no boards are available, dummy data is written for one board structure   
    936   if (NumCMCBoards == 0) {
     936  if (NumBoards == 0) {
    937937    BStruct[0].NomFreq     = 1;
    938938    BStruct[0].ScaleFactor = 0.1;
    939939  }   
    940940
    941   if(write(Rawfile, BStruct, sizeof(BoardStructure)*(LastBoard-FirstBoard+1+(NumCMCBoards==0))) != (ssize_t) sizeof(BoardStructure)*(LastBoard-FirstBoard+1+(NumCMCBoards==0))) {
     941  if(write(Rawfile, BStruct, sizeof(BoardStructure)*(LastBoard-FirstBoard+1+(NumBoards==0))) != (ssize_t) sizeof(BoardStructure)*(LastBoard-FirstBoard+1+(NumBoards==0))) {
    942942    PrintMessage("Error: Could not write (all) board structures, terminating run (%s)\n", strerror(errno));
    943943    return false;
     
    979979  EHeader->EventNumber = NumEvents;
    980980  EHeader->TriggerType = 0x0;
    981   EHeader->Seconds = Time.tv_sec;
    982   EHeader->Microseconds = Time.tv_usec;
    983   EHeader->EventSize = sizeof(short)*RHeader->NCMCBoards*RHeader->NChips*RHeader->NChannels*RHeader->Samples;
     981  EHeader->Second = Time.tv_sec;
     982  EHeader->Microsecond = Time.tv_usec;
     983  EHeader->EventSize = sizeof(short)*RHeader->NBoards*RHeader->NChips*RHeader->NChannels*RHeader->Samples;
    984984
    985985  if(write(Rawfile, EHeader, sizeof(EventHeader)) != sizeof(EventHeader)) {
     
    10261026    // New prompt only after newline
    10271027    if(Textbuffer[strlen(Textbuffer)-1]=='\n' || strlen(Textbuffer)==0) {
    1028       if (NumCMCBoards == 0) printf("\rDAQ> ");
     1028      if (NumBoards == 0) printf("\rDAQ> ");
    10291029      else if (FirstBoard == LastBoard) printf("\rDAQ|B%d> ",FirstBoard);
    10301030      else printf("\rDAQ|B%d-%d> ",FirstBoard,LastBoard);
     
    11891189      else {
    11901190        double Period = ((double) rand())/RAND_MAX*20;
    1191         for (long int i=0; i<(m->NumCMCBoards>0 ?  m->NumCMCBoards : 1)*kNumberOfChips*kNumberOfChannels*kNumberOfBins; i++)
     1191        for (long int i=0; i<(m->NumBoards>0 ?  m->NumBoards : 1)*kNumberOfChips*kNumberOfChannels*kNumberOfBins; i++)
    11921192          *((short *) m->WaveForm+i) = (short) (sin(i/Period)*1000);
    11931193      }
     
    11951195      // Write data to disk (using writev() for performance reason)
    11961196      Count  = 0;
    1197       for (int i=m->FirstBoard; (i<=m->LastBoard + (m->NumCMCBoards==0)) && !WriteError; i++) {
     1197      for (int i=m->FirstBoard; (i<=m->LastBoard + (m->NumBoards==0)) && !WriteError; i++) {
    11981198        for (unsigned int k=0; k<m->RHeader->NChips*m->RHeader->NChannels; k++) {
    11991199          DataPart[Count].iov_base = &m->WaveForm[i][k/m->RHeader->NChannels][k%m->RHeader->NChannels][m->RHeader->Offset];
     
    12011201       
    12021202          // Write to disk if either maximum size of DataPart[] array or last loop interation is reached
    1203           if (Count==IOV_MAX || (k==(m->RHeader->NChips*m->RHeader->NChannels-1) && i==(m->LastBoard+(m->NumCMCBoards==0)))) {
     1203          if (Count==IOV_MAX || (k==(m->RHeader->NChips*m->RHeader->NChannels-1) && i==(m->LastBoard+(m->NumBoards==0)))) {
    12041204            if ((WriteResult=writev(m->Rawfile, DataPart, Count)) != (int) (Count*DataPart[0].iov_len)) {
    12051205              if (WriteResult==-1) m->PrintMessage("Error: Could not write event data, terminating run (%s)\n", strerror(errno));
  • drsdaq/DAQReadout.h

    r44 r49  
    6666    int NParam;                 // Number of parameters
    6767    const char *Param[MAX_NUM_TOKEN]; // Pointers to parameters
    68     int NumCMCBoards;
     68    int NumBoards;
    6969    int FirstBoard;
    7070    int LastBoard;
  • drsdaq/HVFeedback.cc

    r44 r49  
    5656
    5757  // Initialise with zero content
    58   Average    = new float [m->NumCMCBoards][kNumberOfChips][kNumberOfChannels]();
    59   Sigma      = new float [m->NumCMCBoards][kNumberOfChips][kNumberOfChannels]();
    60   Response   = new float [m->NumCMCBoards][kNumberOfChips][kNumberOfChannels]();
    61   Target     = new float [m->NumCMCBoards][kNumberOfChips][kNumberOfChannels]();
    62   Buffer     = new float [m->NumCMCBoards][kNumberOfChips][kNumberOfChannels](); 
     58  Average    = new float [m->NumBoards][kNumberOfChips][kNumberOfChannels]();
     59  Sigma      = new float [m->NumBoards][kNumberOfChips][kNumberOfChannels]();
     60  Response   = new float [m->NumBoards][kNumberOfChips][kNumberOfChannels]();
     61  Target     = new float [m->NumBoards][kNumberOfChips][kNumberOfChannels]();
     62  Buffer     = new float [m->NumBoards][kNumberOfChips][kNumberOfChannels](); 
    6363
    6464  Gain = 1;
     
    267267//
    268268void HVFeedback::SetTarget(int Board, int Chip, int Channel, float TargetVal) {
    269   if(Board<m->NumCMCBoards && Chip<kNumberOfChips && Channel<kNumberOfChannels)
     269  if(Board<m->NumBoards && Chip<kNumberOfChips && Channel<kNumberOfChannels)
    270270    Target[Board][Chip][Channel] = TargetVal;
    271271  else printf("Invalid board, chip or channel number.\n");
  • drsdaq/History.txt

    r44 r49  
    272718/5/2009   Included some version and size checking in RawDataCTX.cc.
    282819/5/2009   Subversion revision number included in run header. Added human readable
    29             date and time to slow data.
     29            date and time to slow data.
     3028/5/2009   Replaced NCMCBoards by NBoards for clarity.
  • drsdaq/RawDataCTX.cc

    r44 r49  
    6262 
    6363  // Read board structures
    64   BStruct = new BoardStructure [RHeader->NCMCBoards];
    65   for(unsigned int i=0; i<RHeader->NCMCBoards; i++) {
     64  BStruct = new BoardStructure [RHeader->NBoards];
     65  for(unsigned int i=0; i<RHeader->NBoards; i++) {
    6666    if(fread(&BStruct[i], RHeader->BoardStructureSize, 1, Rawfile) != 1) {
    6767      if(!Silent) printf("Error: Could not read board structure of board number %d\n",i+1);
     
    7272  }
    7373  // Allocate memory for event data
    74   Data = new short[RHeader->NCMCBoards*RHeader->NChips*RHeader->NChannels*RHeader->Samples];
     74  Data = new short[RHeader->NBoards*RHeader->NChips*RHeader->NChannels*RHeader->Samples];
    7575  FileOpen = true;
    7676 
     
    7979    fprintf(fptr, "Magic number          %x (%s)\n", RHeader->MagicNum, RHeader->MagicNum==MAGICNUM_CLOSED?"OK":(RHeader->MagicNum==MAGICNUM_OPEN?"File not closed":"Error"));
    8080    fprintf(fptr, "Data format:          %u\n", RHeader->DataFormat);
    81     fprintf(fptr, "Software revision:    %u\n", RHeader->SoftwareRevision);         
     81    fprintf(fptr, "Software revision:    %d\n", RHeader->SoftwareRevision);         
    8282
    8383    fprintf(fptr, "Run header size:      %d\n", RHeader->RunHeaderSize);
     
    9191   
    9292    fprintf(fptr, "Events:           %u\n", RHeader->Events);
    93     fprintf(fptr, "CMC Boards:       %u\n", RHeader->NCMCBoards);
     93    fprintf(fptr, "Boards:           %u\n", RHeader->NBoards);
    9494    fprintf(fptr, "DRS chips:        %u\n", RHeader->NChips);
    9595    fprintf(fptr, "Channels/chip:    %u\n", RHeader->NChannels);
     
    102102    fprintf(fptr, "  microsecond:    %u\n", RHeader->EndMicrosecond);
    103103
    104     for (unsigned int i=0; i<RHeader->NCMCBoards; i++) {
     104    for (unsigned int i=0; i<RHeader->NBoards; i++) {
    105105      fprintf(fptr, "*** Board %d ***\n", i);
    106106      fprintf(fptr, "Serial number:            %d\n", BStruct[i].SerialNo);
     
    139139 
    140140/*   // Move file pointer to desired event header (if zero read next event)
    141   if(EventNo!=0 && fseek(Rawfile, RHeader->RunHeaderSize+RHeader->BoardStructureSize*RHeader->NCMCBoards+(EventNo-1)*(RHeader->EventHeaderSize+RHeader->NCMCBoards*RHeader->NChips*
     141  if(EventNo!=0 && fseek(Rawfile, RHeader->RunHeaderSize+RHeader->BoardStructureSize*RHeader->NBoards+(EventNo-1)*(RHeader->EventHeaderSize+RHeader->NBoards*RHeader->NChips*
    142142      RHeader->NChannels*RHeader->Samples*sizeof(short)), SEEK_SET)!=0) {
    143143    if(!Silent) printf("Error: Could not move to requested event\n");
     
    149149  if (EventNo != 0) {
    150150    bool SEEK_OK=true;
    151     if (fseek(Rawfile, RHeader->RunHeaderSize+RHeader->BoardStructureSize*RHeader->NCMCBoards, SEEK_SET) != 0) SEEK_OK=false;
     151    if (fseek(Rawfile, RHeader->RunHeaderSize+RHeader->BoardStructureSize*RHeader->NBoards, SEEK_SET) != 0) SEEK_OK=false;
    152152    while(SEEK_OK) {
    153153      if (fread(EHeader, RHeader->EventHeaderSize, 1, Rawfile) != 0) SEEK_OK = false;
     
    178178  if(fptr != NULL) {
    179179    fprintf(fptr, "Event number:    %u\n",        EHeader->EventNumber);
    180     fprintf(fptr, "Time [sec]:      %u - UTC %s", EHeader->Seconds, asctime(gmtime((time_t *) &EHeader->Seconds)));
    181     fprintf(fptr, "Time [usec]:     %u\n",        EHeader->Microseconds);
     180    fprintf(fptr, "Time [sec]:      %u - UTC %s", EHeader->Second, asctime(gmtime((time_t *) &EHeader->Second)));
     181    fprintf(fptr, "Time [usec]:     %u\n",        EHeader->Microsecond);
    182182    fprintf(fptr, "Trigger type:    0x%0X\n",     EHeader->TriggerType);
    183183    fprintf(fptr, "Size [byte]:     %u\n",        EHeader->EventSize);
  • drsdaq/RawDataCTX.h

    r44 r49  
    2626
    2727typedef char I8;
    28 typedef unsigned char U8;
    29 typedef short I16;
    30 typedef unsigned short U16;
    3128typedef int I32;
    3229typedef unsigned int U32;
     
    4744  U32 MagicNum;
    4845  U32 DataFormat;       // Increasing whenever format changes
    49   U32 SoftwareRevision; // Subversion revision number
     46  I32 SoftwareRevision; // Subversion revision number (negative for modified working copy)
    5047
    5148  U32 RunHeaderSize;
     
    6057   
    6158  U32 Events;           // Number of events in the file
    62   U32 NCMCBoards;       // Number of used mezzanine boards
     59  U32 NBoards;          // Number of used mezzanine boards
    6360  U32 NChips;           // Number of DRS chips per board
    6461  U32 NChannels;        // Number of channels per chip
     
    8380typedef struct {
    8481  U32 EventNumber;
    85   U32 Seconds;          // Event time stamp (result of gettimeofday())
    86   U32 Microseconds;
     82  U32 Second;          // Event time stamp (result of gettimeofday())
     83  U32 Microsecond;
    8784  U32 TriggerType;
    8885  U32 EventSize;        // Size of following data in bytes
Note: See TracChangeset for help on using the changeset viewer.