Exemple #1
0
TrdHSegmentR::TrdHSegmentR(int d_, float m_, float em_, float r_, float er_, float z_, float w_, int Nhits_, TrdRawHitR* pthit[])
  : d(d_), m(m_), r(r_), z(z_), w(w_), em(em_), er(er_), Nhits(Nhits_)
{
  fTrdRawHit.clear();
#ifndef __ROOTSHAREDLIBRARY__
  gbhits.clear();
#endif
  hits.clear();
  SetHits(Nhits_,pthit);
};
Exemple #2
0
// ALL SET HITS
void NPC::AllSetHits(int identity, int section, float hits) {
    bool anyID = (identity == -1 ? true : false);
    bool anySec = (section == -1 ? true : false);
    NPCMOB* thisnpc;

    for(int i = 0; i < GM_NPCS_COUNT; i++) {
        thisnpc = Get(i);
        if (anyID || thisnpc->id == identity) {
            if(anySec || GetSection(thisnpc) == section) {
                SetHits(thisnpc, hits);
            }
        }
    }	
}
void
PoorManWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case MSG_MENU_FILE_SAVE_AS:
			fSaveConsoleFilePanel->Show();
			break;
		case MSG_FILE_PANEL_SAVE_CONSOLE:
			printf("FilePanel: Save console\n");
			SaveConsole(message, false);
			break;
		case MSG_MENU_FILE_SAVE_SELECTION:
			fSaveConsoleSelectionFilePanel->Show();
			break;
		case MSG_FILE_PANEL_SAVE_CONSOLE_SELECTION:
			printf("FilePanel: Save console selection\n");
			SaveConsole(message, true);
			break;
		case MSG_FILE_PANEL_SELECT_WEB_DIR:		
			fPrefWindow->MessageReceived(message);
			break;
		case MSG_MENU_EDIT_PREF:
			fPrefWindow = new PoorManPreferencesWindow(fSetwindowFrame,
				STR_WIN_NAME_PREF);
			fPrefWindow->Show();
			break;
		case MSG_MENU_CTRL_RUN:
			if (fStatus)
				StopServer();
			else
				StartServer();
			break;
		case MSG_MENU_CTRL_CLEAR_HIT:
			SetHits(0);
			//UpdateHitsLabel();
			break;
		case MSG_MENU_CTRL_CLEAR_CONSOLE:
			fLoggingView->SelectAll();
			fLoggingView->Delete();
			break;
		case MSG_MENU_CTRL_CLEAR_LOG:
			FILE* f;
			f = fopen(fLogPath.String(), "w");
			fclose(f);
			break;
		case MSG_LOG: {
			if (!fLogConsoleFlag && !fLogFileFlag)
				break;
	
			time_t time;
			in_addr_t address;
			rgb_color color;
			const void* pointer;
			ssize_t size;
			const char* msg;
			BString line;
		
			if (message->FindString("cstring", &msg) != B_OK)
				break;
			if (message->FindData("time_t", B_TIME_TYPE, &pointer, &size) != B_OK)
				time = -1;
			else
				time = *static_cast<const time_t*>(pointer);

			if (message->FindData("in_addr_t", B_ANY_TYPE, &pointer, &size) != B_OK)
				address = INADDR_NONE;
			else
				address = *static_cast<const in_addr_t*>(pointer);

			if (message->FindData("rgb_color", B_RGB_COLOR_TYPE, &pointer, &size) != B_OK)
				color = BLACK;
			else
				color = *static_cast<const rgb_color*>(pointer);
		
			if (time != -1) {
				BString timeString;
				if (BDateTimeFormat().Format(timeString, time, DATE_FORMAT,
						TIME_FORMAT) == B_OK) {
					line << '[' << timeString << "]: ";
				}
			}
		
			if (address != INADDR_NONE) {
				char addr[INET_ADDRSTRLEN];
				struct in_addr sin_addr;
				sin_addr.s_addr = address;
				if (inet_ntop(AF_INET, &sin_addr, addr, sizeof(addr)) != NULL) {
					addr[strlen(addr)] = '\0';
					line << '(' << addr << ") ";
				}
			}
		
			line << msg;
		
			text_run run;
			text_run_array runs;
		
			run.offset = 0;
			run.color = color;
		
			runs.count = 1;
			runs.runs[0] = run;
		
			if (Lock()) {
				if (fLogConsoleFlag) {
					fLoggingView->Insert(fLoggingView->TextLength(),
						line.String(), line.Length(), &runs);
					fLoggingView->ScrollToOffset(fLoggingView->TextLength());
				}
		
				if (fLogFileFlag) {
					if (pthread_rwlock_rdlock(&fLogFileLock) == 0) {
						fLogFile->Write(line.String(), line.Length());
						pthread_rwlock_unlock(&fLogFileLock);
					}
				}
			
				Unlock();
			}
		
			break;
		}
		default:
			BWindow::MessageReceived(message);
			break;
	}
}
multiTDC::multiTDC(int ntdc, int *TDC_channel_import, float *TDC_value_import)
{
  printf("Number of TDC channels: %d\n",128*TDCModules);
  TDChits = 0;
  int *ChannelCounter = new int[128*TDCModules];
  int *GoodChannelCounter = new int[128*TDCModules];
  
  //printf("L7\n");
  for(int i=0;i<128*TDCModules;i++)ChannelCounter[i]=0;
  for(int i=0;i<128*TDCModules;i++)GoodChannelCounter[i]=0;
  //printf("***\n");
  for(int n=0;n<ntdc;n++)
  {
    printf("n: %d \t TDC_channel_import: %d \t TDC_value_import: %d \n",n,TDC_channel_import[n],TDC_value_import[n]);

    //if(TDC_channel_import[n]==845)printf("1: TDC_channel_import[n]: %d \t ChannelCounter: %d\n",TDC_channel_import[n],ChannelCounter[TDC_channel_import[n]]);
    ChannelCounter[TDC_channel_import[n]]++;
    //if(TDC_channel_import[n]==845)printf("2: TDC_channel_import[n]: %d \t ChannelCounter: %d\n",TDC_channel_import[n],ChannelCounter[TDC_channel_import[n]]);

    if(TDC_channel_import[n]>0 && TDC_channel_import[n]<128*TDCModules && TDC_value_import[n]>PulseLimits[0] && TDC_value_import[n]<PulseLimits[1])GoodChannelCounter[TDC_channel_import[n]]+=1;
    //if(TDC_channel_import[n]==845)printf("3: TDC_channel_import[n]: %d \t ChannelCounter: %d\n",TDC_channel_import[n],ChannelCounter[TDC_channel_import[n]]);
  }

  for(int n=0;n<ntdc;n++)//Loop over and dispose of the simple events (the single hit events)
  {
    //if(TDC_channel_import[n]==845)printf("4: TDC_channel_import[n]: %d \t ChannelCounter: %d\n",TDC_channel_import[n],ChannelCounter[TDC_channel_import[n]]);
    if(TDC_channel_import[n]>=6*128+48 && TDC_channel_import[n]<128*TDCModules)
    {
      if(ChannelCounter[TDC_channel_import[n]]==0)
      {
	printf("Something has gone wrong - the number of counts for channel %d is expected to be zero but something (%d) is seen.\n",TDC_channel_import[n],ChannelCounter[TDC_channel_import[n]]);
	for(int nn=0;nn<ntdc;nn++){printf("Dump: \t ntdc: %d \t n: %d \t TDC_channel_import[n]: %d \t ChannelCounter[TDC_channel_import[n]]: %d \t TDC_value_import[n]: %f \n",
					  ntdc,nn,TDC_channel_import[nn],ChannelCounter[TDC_channel_import[nn]],TDC_value_import[nn]);}
	//Removed this condition as it clashes with one of the sort things from further down in the code. Should probably put it back at some point.
	
      }
      else if(ChannelCounter[TDC_channel_import[n]]==1)//Only store events from the last TDC -> These are the ancillary detector events
      {
	//The reason that we do this this way is to look at how many events fall outside the good beampulse - only when we have multiple hits do we need to worry about the multiple hits and this should be quicker 
	printf("\n ChannelCounter[%d]==1 \n",TDC_channel_import[n]);
	SetChannel(TDC_channel_import[n]);
	SetValue(TDC_value_import[n]);
	SetMult(ChannelCounter[TDC_channel_import[n]]);
	TDChits++;
      }
      else if(ChannelCounter[TDC_channel_import[n]]>1 && GoodChannelCounter[TDC_channel_import[n]]==1 && TDC_value_import[n]>PulseLimits[0] && TDC_value_import[n]<PulseLimits[1])
      {
	SetChannel(TDC_channel_import[n]);
	SetValue(TDC_value_import[n]);
	SetMult(ChannelCounter[TDC_channel_import[n]]);
	TDChits++;
      }
//       else if(ChannelCounter[TDC_channel_import[n]]>1 && GoodChannelCounter[TDC_channel_import[n]]==2
      else if(ChannelCounter[TDC_channel_import[n]]>1 && GoodChannelCounter[TDC_channel_import[n]]>1)
      {
	printf("The number of TDC hits within the user-defined 'good pulse' is greater than 1; the number of hits is %d. The code currently doesn't deal with this.\n",GoodChannelCounter[TDC_channel_import[n]]);
      }
      else if(ChannelCounter[TDC_channel_import[n]]>1 && GoodChannelCounter[TDC_channel_import[n]]==0)
      {
	SetChannel(TDC_channel_import[n]);
	SetValue(TDC_value_import[n]);
	TDChits++;
	SetMult(ChannelCounter[TDC_channel_import[n]]);
	//Take the first TDC event for a channel where nothing falls within the good beampulse
	ChannelCounter[TDC_channel_import[n]]*=-1;//Now set the ChannelCounter for the channel to zero as we don't want to take any more of these events - this forces the change above in the first part of the if chain. Need to fix at some point.
      }
    }
  }
//   printf("\n multiTDC.c:L74 \n");
  SetHits(TDChits);//printf("\n multiTDC.c:L75 \n");
  delete ChannelCounter;//printf("\n multiTDC.c:L76 \n");
  //delete GoodChannelCounter;printf("\n multiTDC.c:L77 \n");
}