当前位置: 首页>>代码示例>>C++>>正文


C++ EventBuffer::getSize方法代码示例

本文整理汇总了C++中EventBuffer::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ EventBuffer::getSize方法的具体用法?C++ EventBuffer::getSize怎么用?C++ EventBuffer::getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventBuffer的用法示例。


在下文中一共展示了EventBuffer::getSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
	assert(argc == 11);
	char *shmObjectPath = argv[1];
	unsigned long dataFrameSharedMemorySize = boost::lexical_cast<unsigned long>(argv[2]);	
	char outputType = argv[3][0];
	char *outputFilePrefix = argv[4];
	float cWindow = boost::lexical_cast<float>(argv[5]);
	float minToT = boost::lexical_cast<float>(argv[6]);
	float preWindow = boost::lexical_cast<float>(argv[7]);
	float postWindow = boost::lexical_cast<float>(argv[8]);
	char *channelMapFileName = argv[9];
	char *triggerMapFileName = argv[10];

	DAQ::Common::SystemInformation *systemInformation = new DAQ::Core::SystemInformation();
	if(cWindow != 0) {
		systemInformation->loadMapFile(channelMapFileName);
		systemInformation->loadTriggerMapFile(triggerMapFileName);
	}
	
	FILE *rawFrameFile = NULL;

	DAQd::SHM *shm = new DAQd::SHM(shmObjectPath);
		
	AbstractRawHitWriter *writer = NULL;
	bool pipeWriterIsNull = true;
	if(outputType == 'T') {
		writer = new TOFPET::RawWriterV3(outputFilePrefix);
		pipeWriterIsNull = false;
	}
	else if(outputType == 'E') {
		writer = new ENDOTOFPET::RawWriterE(outputFilePrefix, 0);
		pipeWriterIsNull = false;
	}
	else if(outputType == 'R') {
		writer = new NullRawHitWriter();

		char fName[1024];
		sprintf(fName, "%s.rawf", outputFilePrefix);
		rawFrameFile = fopen(fName, "wb");
		assert(rawFrameFile != NULL);
		pipeWriterIsNull = true;
	}
	else {
		writer = new NullRawHitWriter();
		pipeWriterIsNull = true;
	}


	bool firstBlock = true;
	float step1;
	float step2;
	BlockHeader blockHeader;
	
	long long stepGoodFrames = 0;
	long long stepEvents = 0;
	long long stepMaxFrame = 0;
	long long stepLostFrames = 0;
	long long stepLostFrames0 = 0;
	
	EventSink<RawHit> *sink = NULL;
	EventBuffer<RawHit> *outBuffer = NULL;
	long long minFrameID = 0x7FFFFFFFFFFFFFFFLL, maxFrameID = 0, lastMaxFrameID = 0;
	
	long long lastFrameID = -1;
	long long stepFirstFrameID = -1;

	while(fread(&blockHeader, sizeof(blockHeader), 1, stdin) == 1) {

		step1 = blockHeader.step1;
		step2 = blockHeader.step2;
		
		if(sink == NULL) {
			writer->openStep(step1, step2);
			if (pipeWriterIsNull) {
				sink = new NullSink<RawHit>();
			}
			else if (cWindow == 0) {
				sink =	new CoarseSorter(
					new RawHitWriterHandler(writer,
					new NullSink<RawHit>()
					));
			}
			else {
				// Round up cWindow and minToT for use in CoincidenceFilter
				float cWindowCoarse = (ceil(cWindow/SYSTEM_PERIOD)) * SYSTEM_PERIOD;
				float minToTCoarse = (floor(minToT/SYSTEM_PERIOD) - 2) * SYSTEM_PERIOD;
				sink =	new CoarseSorter(
					new CoincidenceFilter(systemInformation, cWindowCoarse, minToTCoarse,
					new RawHitWriterHandler(writer,
					new NullSink<RawHit>()
					)));
			}
		}
		
		unsigned bs = shm->getSizeInFrames();
		unsigned rdPointer = blockHeader.rdPointer % (2*bs);
		unsigned wrPointer = blockHeader.wrPointer % (2*bs);
		while(rdPointer != wrPointer) {
			unsigned index = rdPointer % bs;
//.........这里部分代码省略.........
开发者ID:lferramacho,项目名称:sw_daq_tofpet,代码行数:101,代码来源:writeRaw.cpp

示例2: run

void RawReader::run()
{

	unsigned nWraps = 0;
	
	EventBuffer<RawPulse> *outBuffer = NULL;
	
	int nEventsInFrame = 0;
	
	long long tMax = 0, lastTMax = 0;
	long long FrameID;
	
	sink->pushT0(0);
	
	long long minFrameID = LLONG_MAX;
	long long maxFrameID = LLONG_MIN;
	uint8_t code;
	
	long long events=0;
	int bytes;
	while (fread(&code, 1, 1, dataFile) == 1) {
		  events++;
		  
		  
		  if(code>0x03){
				fprintf(stderr, "Impossible code: %u, at event %ld\n\n", code, events);
				break;
		  }
		  fseek(dataFile, -1, SEEK_CUR);
		
		
			
		  switch(code){
		  case 0:{
				StartTime rawStartTime;
				bytes= fread(&rawStartTime, sizeof(StartTime), 1, dataFile);
				AcqStartTime=rawStartTime.time;
				//fprintf(stderr, "rawStartTime=%d %d\n",rawStartTime.code,rawStartTime.time);
				continue;
		  }
		  case 1:{
				FrameHeader rawFrameHeader;
				bytes=fread(&rawFrameHeader, sizeof(FrameHeader), 1, dataFile);
				CurrentFrameID=rawFrameHeader.frameID;
				//fprintf(stderr, "Current frameID= %d %lld %lld\n", rawFrameHeader.code,rawFrameHeader.frameID,rawFrameHeader.drift   );
				continue;
		  }
		  case 2:{
				RawTOFPET rawEvent;
		
				bytes=fread(&rawEvent, sizeof(RawTOFPET), 1, dataFile);
				//fprintf(stderr, "tof.struct=%d\n %d\n %d\n %ld\n %ld\n %ld\n %lld\n %lld\n \n\n", rawEvent.code, rawEvent.tac, rawEvent.channelID,rawEvent.tCoarse,  rawEvent.eCoarse, rawEvent.tFine , rawEvent.eFine , rawEvent.tacIdleTime , rawEvent.channelIdleTime );
				if(outBuffer == NULL) {
					  outBuffer = new EventBuffer<RawPulse>(outBlockSize);
				}
				
			
				RawPulse &p = outBuffer->getWriteSlot();
				


				// Carefull with the float/double/integer conversions here..
				p.T = T * 1E12;
				p.time = (1024LL * CurrentFrameID + rawEvent.tCoarse) * p.T;
				p.timeEnd = (1024LL * CurrentFrameID + rawEvent.eCoarse) * p.T;
				if((p.timeEnd - p.time) < -256*p.T) p.timeEnd += (1024LL * p.T);
				p.channelID = rawEvent.channelID;
				p.channelIdleTime = rawEvent.channelIdleTime;
				p.region = rawEvent.channelID / 16;
				p.feType = RawPulse::TOFPET;
				p.d.tofpet.tac = rawEvent.tac;
				p.d.tofpet.tcoarse = rawEvent.tCoarse;
				p.d.tofpet.ecoarse = rawEvent.eCoarse;
				p.d.tofpet.tfine =  rawEvent.tFine;
				p.d.tofpet.efine = rawEvent.eFine;
				p.d.tofpet.tacIdleTime = rawEvent.tacIdleTime;

				//printf("DBG T frameID = %20lld tCoarse = %6u time = %20lld\n", CurrentFrameID, rawEvent.tCoarse, p.time);

				if(CurrentFrameID < minFrameID) minFrameID = CurrentFrameID;
				if(CurrentFrameID > maxFrameID) maxFrameID = CurrentFrameID;
				
				if(p.channelID >= SYSTEM_NCHANNELS)
					  continue;
				
				if(p.time > tMax)
					  tMax = p.time;
				
				outBuffer->pushWriteSlot();
				
				if(outBuffer->getSize() >= (outBlockSize - 512)) {
					  outBuffer->setTMin(lastTMax);
					  outBuffer->setTMax(tMax);		
					  sink->pushEvents(outBuffer);
					  outBuffer = NULL;
				}
				continue;
		  }
		  case 3:{
				RawSTICv3 rawEvent2;
//.........这里部分代码省略.........
开发者ID:andrea-celentano,项目名称:OptoTrackerTofpet,代码行数:101,代码来源:Raw.cpp

示例3: sizeof

void RawReaderV2::run()
{

	unsigned nWraps = 0;
	
	EventBuffer<RawPulse> *outBuffer = NULL;
	
	int nEventsInFrame = 0;
	
	long long tMax = 0, lastTMax = 0;

	sink->pushT0(0);
	
	long long minFrameID = LLONG_MAX;
	long long maxFrameID = LLONG_MIN;
	
	fprintf(stderr, "Reading %llu to %llu\n", eventsBegin, eventsEnd);
	fseek(dataFile, eventsBegin * sizeof(RawEventV2), SEEK_SET);
	
	int maxReadBlock = 1024*1024;
	RawEventV2 *rawEvents = new RawEventV2[maxReadBlock];

	unsigned long long readPointer = eventsBegin;
	while (readPointer < eventsEnd) {
		unsigned long long count = eventsEnd - readPointer;
		if(count > maxReadBlock) count = maxReadBlock;
		int r = fread(rawEvents, sizeof(RawEventV2), count, dataFile);
		if(r <= 0) break;
		readPointer += r;
	
		//printf("events extracted= %lld\n",readPointer);
	
		for(int j = 0; j < r; j++) {
			RawEventV2 &rawEvent = rawEvents[j];

			if(outBuffer == NULL) {
				outBuffer = new EventBuffer<RawPulse>(outBlockSize);
			}
		

			RawPulse &p = outBuffer->getWriteSlot();
			
			// Carefull with the float/double/integer conversions here..
			p.T = T * 1E12;
			p.time = (1024LL * rawEvent.frameID + rawEvent.tCoarse) * p.T;
			p.timeEnd = (1024LL * rawEvent.frameID + rawEvent.eCoarse) * p.T;
			if((p.timeEnd - p.time) < -256*p.T) p.timeEnd += (1024LL * p.T);
			p.channelID = (64 * rawEvent.asicID) + rawEvent.channelID;
			p.channelIdleTime = rawEvent.channelIdleTime;
			p.region = (64 * rawEvent.asicID + rawEvent.channelID) / 16;
			p.feType = RawPulse::TOFPET;
			p.d.tofpet.tac = rawEvent.tacID;
			p.d.tofpet.tcoarse = rawEvent.tCoarse;
			p.d.tofpet.ecoarse = rawEvent.eCoarse;
			p.d.tofpet.tfine =  rawEvent.tFine;
			p.d.tofpet.efine = rawEvent.eFine;
			p.channelIdleTime = rawEvent.channelIdleTime;
			p.d.tofpet.tacIdleTime = rawEvent.tacIdleTime;
		
			if(rawEvent.frameID < minFrameID) minFrameID = rawEvent.frameID;
			if(rawEvent.frameID > maxFrameID) maxFrameID = rawEvent.frameID;
				
			if(p.channelID >= SYSTEM_NCHANNELS)
				continue;
		
			if(p.time > tMax)
				tMax = p.time;
		
			outBuffer->pushWriteSlot();
		
			if(outBuffer->getSize() >= outBlockSize) {
				outBuffer->setTMin(lastTMax);
				outBuffer->setTMax(tMax);
				sink->pushEvents(outBuffer);
				lastTMax = tMax;
				outBuffer = NULL;
			}
		}
	}
	
	delete [] rawEvents;

	
	if(outBuffer != NULL) {
		outBuffer->setTMin(lastTMax);
		outBuffer->setTMax(tMax);		
		sink->pushEvents(outBuffer);
		outBuffer = NULL;
		
	}
	
	sink->finish();
	
	fprintf(stderr, "RawReaderV2 report\n");
	fprintf(stderr, "\t%16lld minFrameID\n", minFrameID);
	fprintf(stderr, "\t%16lld maxFrameID\n", maxFrameID);
	sink->report();
}
开发者ID:andrea-celentano,项目名称:OptoTrackerTofpet,代码行数:98,代码来源:RawV2.cpp


注:本文中的EventBuffer::getSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。