87 static const std::vector<std::string> det_coma = {
88 "ITS",
"TPC",
"TRD",
"TOF",
"PHS",
"CPV",
"EMC",
"HMP",
"MFT",
"MCH",
"MID",
"ZDC",
"FT0",
"FV0",
"FDD",
"ITS-TPC",
89 "TPC-TOF",
"TPC-TRD",
"MFT-MCH",
"ITS-TPC-TRD",
"ITS-TPC-TOF",
"TPC-TRD-TOF",
"MFT-MCH-MID",
"ITS-TPC-TRD-TOF",
"ITS-AB",
"CTP",
91 std::ostringstream
buf;
92 constexpr auto SIGSIZE = 512;
93 unsigned char data[SIGSIZE];
94 std::ofstream out(fileName, std::ios::out | std::ios::binary);
96 buf <<
"eve" << std::endl;
97 buf <<
"version=1.00" << std::endl;
98 buf <<
"run=" <<
event.getRunNumber() << std::endl;
99 buf <<
"firstTForbit=" <<
event.getFirstTForbit() << std::endl;
102 <<
"dd if=thisFileName.eve of=thisFileName.png skip=20 bs=1 count=6000000" << std::endl;
103 buf << std::string(SIGSIZE,
' ');
104 memcpy((
char*)&
data[0],
buf.str().c_str(), SIGSIZE);
105 data[SIGSIZE - 2] =
'\n';
106 data[SIGSIZE - 1] = 0;
107 out.write((
char*)&
data[0], SIGSIZE);
109 const auto trackNo =
event.getTracksSpan().size();
113 for (
const auto& calo :
event.getCalorimetersSpan()) {
126 const auto head = asUnsigned(chunkHEAD);
129 unsigned long creationTime =
event.getCreationTime();
143 out.write(
static_cast<char*
>(chunkHEAD), chunkSize(chunkHEAD));
148 unsigned totalPoints = 0;
149 unsigned totalClusters = 0;
151 const auto chunkTELM = createChunk(
TELM, trackNo);
152 const auto telm = asByte(chunkTELM);
153 const auto chunkTGID = createChunk(
TGID, 4 * trackNo);
154 const auto tgid = asUnsigned(chunkTGID);
155 const auto chunkTPID = createChunk(
TPID, 4 * trackNo);
156 const auto tpid = asUnsigned(chunkTPID);
157 const auto chunkCELM = createChunk(
CELM, trackNo);
158 const auto celm = asByte(chunkCELM);
160 const auto chunkTTYP = createChunk(
TTYP, 4 * 27);
161 const auto ttyp = asUnsigned(chunkTTYP);
163 for (
const auto& track :
event.getTracksSpan()) {
164 tgid[
index] = track.mBGID;
165 tpid[
index] = track.mPID;
166 const auto ttypeidx = track.mBGID.getSource();
168 totalPoints += track.getPointCount();
169 totalClusters += track.getClusterCount();
170 telm[
index] = track.getPointCount();
171 celm[
index] = track.getClusterCount();
174 out.write(
static_cast<char*
>(chunkTTYP), chunkSize(chunkTTYP));
176 out.write(
static_cast<char*
>(chunkTELM), chunkSize(chunkTELM));
178 out.write(
static_cast<char*
>(chunkCELM), chunkSize(chunkCELM));
180 out.write(
static_cast<char*
>(chunkTGID), chunkSize(chunkTGID));
182 out.write(
static_cast<char*
>(chunkTPID), chunkSize(chunkTPID));
187 const auto chunkTXYZ = createChunk(
TXYZ, totalPoints * 4 * 3);
188 const auto txyz = asFloat(chunkTXYZ);
191 const auto chunkTIME = createChunk(
TIME, trackNo * 4);
192 const auto time = asFloat(chunkTIME);
195 const auto chunkSXYZ = createChunk(
SXYZ, trackNo * 4 * 3);
196 const auto sxyz = asFloat(chunkSXYZ);
197 unsigned sxyzidx = 0;
199 const auto chunkATPE = createChunk(
ATPE, trackNo * 4 * 3);
200 const auto atpe = asFloat(chunkATPE);
201 unsigned atpeidx = 0;
203 const auto chunkCRGE = createChunk(
CRGE, trackNo);
204 const auto crge = asSignedByte(chunkCRGE);
206 const auto chunkCXYZ = createChunk(
CXYZ, totalClusters * 4 * 3);
207 const auto cxyz = asFloat(chunkCXYZ);
210 for (
const auto& track :
event.getTracksSpan()) {
211 time[tno] = track.getTime();
212 crge[tno] =
static_cast<signed char>(track.getCharge());
214 sxyz[sxyzidx++] = track.getStartCoordinates()[0];
215 sxyz[sxyzidx++] = track.getStartCoordinates()[1];
216 sxyz[sxyzidx++] = track.getStartCoordinates()[2];
218 atpe[atpeidx++] = track.getTheta();
219 atpe[atpeidx++] = track.getPhi();
220 atpe[atpeidx++] = track.mEta;
222 for (
unsigned i = 0;
i < track.mPolyX.size();
i++) {
223 txyz[tidx++] = track.mPolyX[
i];
224 txyz[tidx++] = track.mPolyY[
i];
225 txyz[tidx++] = track.mPolyZ[
i];
227 for (
unsigned i = 0;
i < track.getClusterCount();
i++) {
228 cxyz[cidx++] = track.getClustersSpan()[
i].X();
229 cxyz[cidx++] = track.getClustersSpan()[
i].Y();
230 cxyz[cidx++] = track.getClustersSpan()[
i].Z();
233 out.write(
static_cast<char*
>(chunkTXYZ), chunkSize(chunkTXYZ));
235 out.write(
static_cast<char*
>(chunkCXYZ), chunkSize(chunkCXYZ));
237 out.write(
static_cast<char*
>(chunkTIME), chunkSize(chunkTIME));
239 out.write(
static_cast<char*
>(chunkSXYZ), chunkSize(chunkSXYZ));
241 out.write(
static_cast<char*
>(chunkCRGE), chunkSize(chunkCRGE));
243 out.write(
static_cast<char*
>(chunkATPE), chunkSize(chunkATPE));
249 const auto uxyz = asFloat(chunkUXYZ);
251 const auto utim = asFloat(chunkUTIM);
253 const auto ugid = asUnsigned(chunkUGID);
256 for (
const auto&
c :
event.getClustersSpan()) {
257 utim[idx / 3] =
c.mTime;
263 out.write(
static_cast<char*
>(chunkUGID), chunkSize(chunkUGID));
265 out.write(
static_cast<char*
>(chunkUTIM), chunkSize(chunkUTIM));
267 out.write(
static_cast<char*
>(chunkUXYZ), chunkSize(chunkUXYZ));
273 const auto calo = asFloat(chunkCALO);
275 const auto calp = asUnsigned(chunkCALP);
277 const auto calg = asUnsigned(chunkCALG);
279 const auto calt = asFloat(chunkCALT);
282 for (
const auto&
c :
event.getCalorimetersSpan()) {
284 calt[idx / 3] =
c.getTime();
287 calo[idx++] =
c.getPhi();
288 calo[idx++] =
c.getEta();
289 calo[idx++] =
c.getEnergy();
292 for (
const auto&
c :
event.getCalorimetersSpan()) {
294 calt[idx / 3] =
c.getTime();
297 calo[idx++] =
c.getPhi();
298 calo[idx++] =
c.getEta();
299 calo[idx++] =
c.getEnergy();
303 out.write((
char*)chunkCALO, chunkSize(chunkCALO));
305 out.write((
char*)chunkCALP, chunkSize(chunkCALP));
307 out.write((
char*)chunkCALG, chunkSize(chunkCALG));
309 out.write((
char*)chunkCALT, chunkSize(chunkCALT));
314 const auto chunkFINE = createChunk(
FINE, 0);
315 out.write(
static_cast<char*
>(chunkFINE), chunkSize(chunkFINE));
357 std::filesystem::path inputFilePath{fileName};
358 auto length = (
long)std::filesystem::file_size(inputFilePath);
363 std::ifstream inputFile(fileName, std::ios_base::binary);
364 inputFile.read(
reinterpret_cast<char*
>(
buffer.data()),
length);
374 unsigned char* telm =
nullptr;
375 unsigned char* celm =
nullptr;
376 unsigned int* ttyp =
nullptr;
377 float* txyz =
nullptr;
378 float* cxyz =
nullptr;
380 float*
time =
nullptr;
381 float* sxyz =
nullptr;
382 signed char* crge =
nullptr;
383 float* atpe =
nullptr;
384 unsigned* tgid =
nullptr;
385 unsigned* tpid =
nullptr;
387 float* calo =
nullptr;
388 unsigned* calp =
nullptr;
389 unsigned* calg =
nullptr;
390 float* calt =
nullptr;
392 unsigned* ugid =
nullptr;
393 float* utim =
nullptr;
394 float* uxyz =
nullptr;
396 unsigned phsCaloCount = 0;
397 unsigned emcCaloCount = 0;
400 for (
auto c = 0;
c < 4;
c++) {
403 auto* words = (
unsigned*)(
buffer.data() + position + 4);
404 position = position + *words + 8;
420 event.setPrimaryVertex(head[11]);
421 event.setTfCounter(head[12]);
422 }
else if (std::string(
type) ==
TELM) {
423 telm = (
unsigned char*)words;
424 }
else if (std::string(
type) ==
CELM) {
425 celm = (
unsigned char*)words;
426 }
else if (std::string(
type) ==
TTYP) {
427 ttyp = (
unsigned int*)words;
428 }
else if (std::string(
type) ==
TIME) {
429 time = (
float*)words;
430 }
else if (std::string(
type) ==
TXYZ) {
431 txyz = (
float*)words;
432 }
else if (std::string(
type) ==
CXYZ) {
433 cxyz = (
float*)words;
434 }
else if (std::string(
type) ==
SXYZ) {
435 sxyz = (
float*)words;
436 }
else if (std::string(
type) ==
CRGE) {
437 crge = (
signed char*)words;
438 }
else if (std::string(
type) ==
ATPE) {
439 atpe = (
float*)words;
440 }
else if (std::string(
type) ==
TGID) {
441 tgid = (
unsigned*)words;
442 }
else if (std::string(
type) ==
TPID) {
443 tpid = (
unsigned*)words;
444 }
else if (std::string(
type) ==
UXYZ) {
445 uxyz = (
float*)words;
446 }
else if (std::string(
type) ==
UGID) {
447 ugid = (
unsigned*)words;
448 }
else if (std::string(
type) ==
UTIM) {
449 utim = (
float*)words;
450 }
else if (std::string(
type) ==
CALO) {
451 calo = (
float*)words;
452 }
else if (std::string(
type) ==
CALP) {
453 calp = (
unsigned*)words;
454 }
else if (std::string(
type) ==
CALG) {
455 calg = (
unsigned*)words;
456 }
else if (std::string(
type) ==
CALT) {
457 calt = (
float*)words;
458 }
else if (std::string(
type) ==
FINE) {
459 assert(telm !=
nullptr);
460 assert(celm !=
nullptr);
461 assert(ttyp !=
nullptr);
462 assert(txyz !=
nullptr);
463 assert(cxyz !=
nullptr);
464 assert(
time !=
nullptr);
465 assert(sxyz !=
nullptr);
466 assert(crge !=
nullptr);
467 assert(atpe !=
nullptr);
468 assert(tgid !=
nullptr);
469 assert(tpid !=
nullptr);
470 assert(uxyz !=
nullptr);
471 assert(ugid !=
nullptr);
472 assert(utim !=
nullptr);
473 assert(calo !=
nullptr);
474 assert(calp !=
nullptr);
475 assert(calg !=
nullptr);
476 assert(calt !=
nullptr);
482 while (ttyp[ttypidx] == 0) {
486 auto track =
event.addTrack({.time =
time[t],
489 .startXYZ = {sxyz[3 * t + 0], sxyz[3 * t + 1], sxyz[3 * t + 2]},
490 .phi = atpe[3 * t + 1],
491 .theta = atpe[3 * t + 0],
492 .eta = atpe[3 * t + 2],
494 track->mPolyX.reserve(telm[t]);
495 track->mPolyY.reserve(telm[t]);
496 track->mPolyZ.reserve(telm[t]);
497 while (telm[t]-- > 0) {
498 track->mPolyX.push_back(txyz[txyzidx++]);
499 track->mPolyY.push_back(txyz[txyzidx++]);
500 track->mPolyZ.push_back(txyz[txyzidx++]);
502 track->mClusters.reserve(celm[t]);
503 while (celm[t]-- > 0) {
506 track->mClusters.push_back(cluster);
512 event.addGlobalCluster(uxyz + 3 *
c, utim[
c],
deserialize(ugid[
c]));
517 for (
auto c = 0u;
c < phsCaloCount + emcCaloCount;
c++) {
518 auto phi = calo[idx++];
519 auto eta = calo[idx++];
520 auto energy = calo[idx++];
521 event.addCalo({.time = calt[
c],