- Timestamp:
- 05/28/09 10:35:43 (16 years ago)
- Location:
- drsdaq
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
drsdaq/DAQReadout.cc
r44 r49 71 71 NumEvents = 0; 72 72 NumEventsRequested = 100; 73 Num CMCBoards = 0;73 NumBoards = 0; 74 74 FirstBoard = 0; 75 75 LastBoard = -1; … … 125 125 i, (drs->GetBoard(i)->GetSlotNumber() >> 1)+2, ((drs->GetBoard(i)->GetSlotNumber() & 1) == 0) ? "upper" : "lower", 126 126 drs->GetBoard(i)->GetCMCSerialNumber(), drs->GetBoard(i)->GetFirmwareVersion()); 127 Num CMCBoards++;127 NumBoards++; 128 128 LastBoard++; 129 129 drs->GetBoard(i)->Init(); … … 131 131 DRSFreq[i] = 0; 132 132 } 133 BStruct = new BoardStructure [Num CMCBoards == 0 ? 1:drs->GetNumberOfBoards()];134 WaveForm = new short [Num CMCBoards == 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]; 135 135 136 136 // Create instance of HV feedback (must be called after CMC board detection) … … 182 182 if (Match(Param[0], CommandList[CmdNumber].Name)) { 183 183 if(CommandList[CmdNumber].NeedNotBusy && daq_state==active) PrintMessage("DAQ is busy\n"); 184 else if(CommandList[CmdNumber].NeedNotBusy && Num CMCBoards==0) PrintMessage("No mezzanine boards available\n");184 else if(CommandList[CmdNumber].NeedNotBusy && NumBoards==0) PrintMessage("No mezzanine boards available\n"); 185 185 else (this->*CommandList[CmdNumber].CommandPointer)(); 186 186 return 0; … … 223 223 224 224 if(!Match(Param[1],"test")) { 225 if (daq_state==active || Num CMCBoards==0) {225 if (daq_state==active || NumBoards==0) { 226 226 PrintMessage("DAQ is busy or no boards available.\n"); 227 227 return; … … 322 322 } 323 323 324 if (Num CMCBoards) for (i=FirstBoard; i<=LastBoard; i++) {324 if (NumBoards) for (i=FirstBoard; i<=LastBoard; i++) { 325 325 PrintMessage("BLT test started (board #%d)\n",i); 326 326 (drs->GetBoard(i))->TestRead(Param[2][0] && atoi(Param[2])<=10000 && atoi(Param[2])>0 ? atoi(Param[2]):1, Type); … … 345 345 346 346 void DAQReadout::cmd_read() { 347 if(Num CMCBoards==0) {347 if(NumBoards==0) { 348 348 PrintMessage("No mezzanine boards available\n"); 349 349 return; … … 475 475 NumEventsRequested, fRawDataPath, 476 476 CheckDisk(fRawDataPath), Socket==-1 ? "disconnected":"connected", 477 Num CMCBoards, LastBoard - FirstBoard + 1);477 NumBoards, LastBoard - FirstBoard + 1); 478 478 479 479 for (int i=FirstBoard;i<=LastBoard;i++) … … 483 483 if(NParam==1 || Match(Param[1],"drs")) { 484 484 PrintMessage("\n********** DRS STATUS **********\n"); 485 if (Num CMCBoards) {485 if (NumBoards) { 486 486 for (int i=FirstBoard; i<=LastBoard; i++) { 487 487 … … 552 552 LastBoard = drs->GetNumberOfBoards()-1; 553 553 } 554 else if (NParam==2 && atoi(Param[1]) >= 0 && atoi(Param[1]) < Num CMCBoards) {554 else if (NParam==2 && atoi(Param[1]) >= 0 && atoi(Param[1]) < NumBoards) { 555 555 FirstBoard = atoi(Param[1]); 556 556 LastBoard = FirstBoard; 557 557 } 558 else if (NParam==3 && atoi(Param[1])>=0 && atoi(Param[1])<Num CMCBoards &&559 atoi(Param[2])>0 && atoi(Param[2])<Num CMCBoards) {558 else if (NParam==3 && atoi(Param[1])>=0 && atoi(Param[1])<NumBoards && 559 atoi(Param[2])>0 && atoi(Param[2])<NumBoards) { 560 560 FirstBoard = atoi(Param[1]); 561 561 LastBoard = atoi(Param[2]); … … 710 710 void DAQReadout::SetDOMINOMode(int mode) { 711 711 712 if (Num CMCBoards)712 if (NumBoards) 713 713 for (int i=FirstBoard; i<=LastBoard; i++) { 714 714 (drs->GetBoard(i))->SetDominoMode(mode==1 ? 1:0); … … 721 721 void DAQReadout::SetDOMINOReadMode(int mode) { 722 722 723 if (Num CMCBoards)723 if (NumBoards) 724 724 for (int i=FirstBoard; i<=LastBoard; i++) { 725 725 (drs->GetBoard(i))->SetReadoutMode(mode==1 ? 1:0); … … 732 732 void DAQReadout::SetDOMINOWaveMode(int mode) { 733 733 734 if (Num CMCBoards)734 if (NumBoards) 735 735 for (int i=FirstBoard; i<=LastBoard; i++) { 736 736 (drs->GetBoard(i))->SetDominoActive(mode==1 ? 1:0); … … 743 743 void DAQReadout::SetDelayedStart(int mode) { 744 744 745 if (Num CMCBoards)745 if (NumBoards) 746 746 for (int i=FirstBoard; i<=LastBoard; i++) { 747 747 (drs->GetBoard(i))->SetDelayedStart(mode==1 ? 1:0); … … 754 754 void DAQReadout::HWTrigger(int mode) { 755 755 756 if (Num CMCBoards)756 if (NumBoards) 757 757 for (int i=FirstBoard; i<=LastBoard; i++) { 758 758 drs->GetBoard(i)->EnableTrigger(mode==1 ? 1:0); … … 789 789 DIR *pdir; 790 790 791 if (Num CMCBoards) {791 if (NumBoards) { 792 792 if(dir!=NULL) { 793 793 if ((pdir=opendir(str))==0){ … … 893 893 } 894 894 895 // Write run header and board structures 895 // Write run header and board structures (revision number is zero for svn modified working copy) 896 896 bool DAQReadout::WriteRunHeader() { 897 897 … … 900 900 RHeader->MagicNum = MAGICNUM_OPEN; 901 901 RHeader->DataFormat = DATA_FORMAT; 902 RHeader->SoftwareRevision = atoi(REVISION) ;902 RHeader->SoftwareRevision = atoi(REVISION) * (strchr(REVISION, 'M')==NULL ? 1:-1); 903 903 904 904 RHeader->RunHeaderSize = sizeof(RunHeader); … … 914 914 RHeader->StartMicrosecond = Time.tv_usec; 915 915 916 RHeader->N CMCBoards = NumCMCBoards==0 && daq_runtype==test ? 1 : (LastBoard - FirstBoard) + 1;917 RHeader->NChips 918 RHeader->NChannels 916 RHeader->NBoards = NumBoards==0 && daq_runtype==test ? 1 : (LastBoard - FirstBoard) + 1; 917 RHeader->NChips = kNumberOfChips; 918 RHeader->NChannels = kNumberOfChannels; 919 919 920 920 RHeader->Offset = fFirstSample; … … 934 934 935 935 // In case no boards are available, dummy data is written for one board structure 936 if (Num CMCBoards == 0) {936 if (NumBoards == 0) { 937 937 BStruct[0].NomFreq = 1; 938 938 BStruct[0].ScaleFactor = 0.1; 939 939 } 940 940 941 if(write(Rawfile, BStruct, sizeof(BoardStructure)*(LastBoard-FirstBoard+1+(Num CMCBoards==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))) { 942 942 PrintMessage("Error: Could not write (all) board structures, terminating run (%s)\n", strerror(errno)); 943 943 return false; … … 979 979 EHeader->EventNumber = NumEvents; 980 980 EHeader->TriggerType = 0x0; 981 EHeader->Second s= Time.tv_sec;982 EHeader->Microsecond s= Time.tv_usec;983 EHeader->EventSize = sizeof(short)*RHeader->N CMCBoards*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; 984 984 985 985 if(write(Rawfile, EHeader, sizeof(EventHeader)) != sizeof(EventHeader)) { … … 1026 1026 // New prompt only after newline 1027 1027 if(Textbuffer[strlen(Textbuffer)-1]=='\n' || strlen(Textbuffer)==0) { 1028 if (Num CMCBoards == 0) printf("\rDAQ> ");1028 if (NumBoards == 0) printf("\rDAQ> "); 1029 1029 else if (FirstBoard == LastBoard) printf("\rDAQ|B%d> ",FirstBoard); 1030 1030 else printf("\rDAQ|B%d-%d> ",FirstBoard,LastBoard); … … 1189 1189 else { 1190 1190 double Period = ((double) rand())/RAND_MAX*20; 1191 for (long int i=0; i<(m->Num CMCBoards>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++) 1192 1192 *((short *) m->WaveForm+i) = (short) (sin(i/Period)*1000); 1193 1193 } … … 1195 1195 // Write data to disk (using writev() for performance reason) 1196 1196 Count = 0; 1197 for (int i=m->FirstBoard; (i<=m->LastBoard + (m->Num CMCBoards==0)) && !WriteError; i++) {1197 for (int i=m->FirstBoard; (i<=m->LastBoard + (m->NumBoards==0)) && !WriteError; i++) { 1198 1198 for (unsigned int k=0; k<m->RHeader->NChips*m->RHeader->NChannels; k++) { 1199 1199 DataPart[Count].iov_base = &m->WaveForm[i][k/m->RHeader->NChannels][k%m->RHeader->NChannels][m->RHeader->Offset]; … … 1201 1201 1202 1202 // 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->Num CMCBoards==0)))) {1203 if (Count==IOV_MAX || (k==(m->RHeader->NChips*m->RHeader->NChannels-1) && i==(m->LastBoard+(m->NumBoards==0)))) { 1204 1204 if ((WriteResult=writev(m->Rawfile, DataPart, Count)) != (int) (Count*DataPart[0].iov_len)) { 1205 1205 if (WriteResult==-1) m->PrintMessage("Error: Could not write event data, terminating run (%s)\n", strerror(errno)); -
drsdaq/DAQReadout.h
r44 r49 66 66 int NParam; // Number of parameters 67 67 const char *Param[MAX_NUM_TOKEN]; // Pointers to parameters 68 int Num CMCBoards;68 int NumBoards; 69 69 int FirstBoard; 70 70 int LastBoard; -
drsdaq/HVFeedback.cc
r44 r49 56 56 57 57 // Initialise with zero content 58 Average = new float [m->Num CMCBoards][kNumberOfChips][kNumberOfChannels]();59 Sigma = new float [m->Num CMCBoards][kNumberOfChips][kNumberOfChannels]();60 Response = new float [m->Num CMCBoards][kNumberOfChips][kNumberOfChannels]();61 Target = new float [m->Num CMCBoards][kNumberOfChips][kNumberOfChannels]();62 Buffer = new float [m->Num CMCBoards][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](); 63 63 64 64 Gain = 1; … … 267 267 // 268 268 void HVFeedback::SetTarget(int Board, int Chip, int Channel, float TargetVal) { 269 if(Board<m->Num CMCBoards && Chip<kNumberOfChips && Channel<kNumberOfChannels)269 if(Board<m->NumBoards && Chip<kNumberOfChips && Channel<kNumberOfChannels) 270 270 Target[Board][Chip][Channel] = TargetVal; 271 271 else printf("Invalid board, chip or channel number.\n"); -
drsdaq/History.txt
r44 r49 27 27 18/5/2009 Included some version and size checking in RawDataCTX.cc. 28 28 19/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. 30 28/5/2009 Replaced NCMCBoards by NBoards for clarity. -
drsdaq/RawDataCTX.cc
r44 r49 62 62 63 63 // Read board structures 64 BStruct = new BoardStructure [RHeader->N CMCBoards];65 for(unsigned int i=0; i<RHeader->N CMCBoards; i++) {64 BStruct = new BoardStructure [RHeader->NBoards]; 65 for(unsigned int i=0; i<RHeader->NBoards; i++) { 66 66 if(fread(&BStruct[i], RHeader->BoardStructureSize, 1, Rawfile) != 1) { 67 67 if(!Silent) printf("Error: Could not read board structure of board number %d\n",i+1); … … 72 72 } 73 73 // Allocate memory for event data 74 Data = new short[RHeader->N CMCBoards*RHeader->NChips*RHeader->NChannels*RHeader->Samples];74 Data = new short[RHeader->NBoards*RHeader->NChips*RHeader->NChannels*RHeader->Samples]; 75 75 FileOpen = true; 76 76 … … 79 79 fprintf(fptr, "Magic number %x (%s)\n", RHeader->MagicNum, RHeader->MagicNum==MAGICNUM_CLOSED?"OK":(RHeader->MagicNum==MAGICNUM_OPEN?"File not closed":"Error")); 80 80 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); 82 82 83 83 fprintf(fptr, "Run header size: %d\n", RHeader->RunHeaderSize); … … 91 91 92 92 fprintf(fptr, "Events: %u\n", RHeader->Events); 93 fprintf(fptr, " CMC Boards: %u\n", RHeader->NCMCBoards);93 fprintf(fptr, "Boards: %u\n", RHeader->NBoards); 94 94 fprintf(fptr, "DRS chips: %u\n", RHeader->NChips); 95 95 fprintf(fptr, "Channels/chip: %u\n", RHeader->NChannels); … … 102 102 fprintf(fptr, " microsecond: %u\n", RHeader->EndMicrosecond); 103 103 104 for (unsigned int i=0; i<RHeader->N CMCBoards; i++) {104 for (unsigned int i=0; i<RHeader->NBoards; i++) { 105 105 fprintf(fptr, "*** Board %d ***\n", i); 106 106 fprintf(fptr, "Serial number: %d\n", BStruct[i].SerialNo); … … 139 139 140 140 /* // Move file pointer to desired event header (if zero read next event) 141 if(EventNo!=0 && fseek(Rawfile, RHeader->RunHeaderSize+RHeader->BoardStructureSize*RHeader->N CMCBoards+(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* 142 142 RHeader->NChannels*RHeader->Samples*sizeof(short)), SEEK_SET)!=0) { 143 143 if(!Silent) printf("Error: Could not move to requested event\n"); … … 149 149 if (EventNo != 0) { 150 150 bool SEEK_OK=true; 151 if (fseek(Rawfile, RHeader->RunHeaderSize+RHeader->BoardStructureSize*RHeader->N CMCBoards, SEEK_SET) != 0) SEEK_OK=false;151 if (fseek(Rawfile, RHeader->RunHeaderSize+RHeader->BoardStructureSize*RHeader->NBoards, SEEK_SET) != 0) SEEK_OK=false; 152 152 while(SEEK_OK) { 153 153 if (fread(EHeader, RHeader->EventHeaderSize, 1, Rawfile) != 0) SEEK_OK = false; … … 178 178 if(fptr != NULL) { 179 179 fprintf(fptr, "Event number: %u\n", EHeader->EventNumber); 180 fprintf(fptr, "Time [sec]: %u - UTC %s", EHeader->Second s, asctime(gmtime((time_t *) &EHeader->Seconds)));181 fprintf(fptr, "Time [usec]: %u\n", EHeader->Microsecond s);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); 182 182 fprintf(fptr, "Trigger type: 0x%0X\n", EHeader->TriggerType); 183 183 fprintf(fptr, "Size [byte]: %u\n", EHeader->EventSize); -
drsdaq/RawDataCTX.h
r44 r49 26 26 27 27 typedef char I8; 28 typedef unsigned char U8;29 typedef short I16;30 typedef unsigned short U16;31 28 typedef int I32; 32 29 typedef unsigned int U32; … … 47 44 U32 MagicNum; 48 45 U32 DataFormat; // Increasing whenever format changes 49 U32 SoftwareRevision; // Subversion revision number46 I32 SoftwareRevision; // Subversion revision number (negative for modified working copy) 50 47 51 48 U32 RunHeaderSize; … … 60 57 61 58 U32 Events; // Number of events in the file 62 U32 N CMCBoards;// Number of used mezzanine boards59 U32 NBoards; // Number of used mezzanine boards 63 60 U32 NChips; // Number of DRS chips per board 64 61 U32 NChannels; // Number of channels per chip … … 83 80 typedef struct { 84 81 U32 EventNumber; 85 U32 Second s; // Event time stamp (result of gettimeofday())86 U32 Microsecond s;82 U32 Second; // Event time stamp (result of gettimeofday()) 83 U32 Microsecond; 87 84 U32 TriggerType; 88 85 U32 EventSize; // Size of following data in bytes
Note:
See TracChangeset
for help on using the changeset viewer.