Skip to content
Jonas Kunze edited this page Mar 18, 2015 · 14 revisions

Table of Contents

Code structure and data flow

The code is optimized to be used within IDEs like Eclipse. So please use the autocompletion (ctrl+space) and read the list of available methods together with their documentation within your IDE!

Data flow

An introductory overview of the data flow can be found here.

The L1 trigger algorithms are executed with all data sent by all detectors except the LKr. The result of the L1 is an 8-bit word being the L1 trigger type word.

If the L1 result is not zero the remaining data from the LKr is requested and the L2 algorithms are executed. The result of L2 is the L2 trigger type word (8 bit). If the L2 trigger is not zero the event will be sent to the merger PC.

TriggerProcessor

L1 and L2 trigger algorithms must be implemented in the compute method of the respective TriggerProcessors: (L1/L2)TriggerProcessor::compute(Event* event)

These methods are called after each event building (L1 and L2 event building) with the Event object containing all the raw data at this stage.

Guideline

Please keep the TriggerProcessor classes clean and outsource your code into the "l1", "l2" and "common" folders. Also feel free to provide external libraries to be used within the TrigerProcessor implementations.

Following sections show how you can access the raw data as it has been sent within MEPs. Please see also example codes in the examples branch.

Accessing data

Please see Lazy-decoding for the way to access the decoded version of the raw data. The following chapters only describe if you want to access the raw data without any decoding:

Accessing L0 data
// Access a specific detector:

Subevent* lav = event->getLAVSubevent();
for (int p = lav->getNumberOfParts() - 1; p >= 0; p--) {
	MEPFragment* fragment = lav->getPart(p);
	const MEPFragment_HDR* data = fragment->getData();

	for(int i=0; i<fragment->getDataLength(); i++){
		sum+=((char*)data)[i];
	}
}

// Access all detectors:
for (int i = 0; i != SourceIDManager::NUMBER_OF_L0_DATA_SOURCES; i++) {
	Subevent* subevent = event->getL0SubeventBySourceIDNum(i);

	for (int j = subevent->getNumberOfParts() - 1; j >= 0; j--) {
		MEPEvent* e = subevent->getPart(j);

		const char* data = e->getDataWithHeader();
		const uint dataSize = e->getEventLength();
	}
}
Accessing LKr data
std::vector<uint16_t> localCreamIDsToRequestNonZSuppressedData;
for (int localCreamID = event->getNumberOfZSuppressedLkrFragments() - 1;
		localCreamID != -1; localCreamID--) {
	LkrFragment* fragment = event->getZSuppressedLkrFragment(localCreamID);
	localCreamIDsToRequestNonZSuppressedData.push_back(
			fragment->getCrateCREAMID());
	const char* data = fragment->getDataWithHeader();
	const uint dataSize = fragment->getEventLength();
}