88 std::string fileName =
location.fileName();
89 static const std::vector<std::string> det_coma = {
90 "ITS",
"TPC",
"TRD",
"TOF",
"PHS",
"CPV",
"EMC",
"HMP",
"MFT",
"MCH",
"MID",
"ZDC",
"FT0",
"FV0",
"FDD",
"ITS-TPC",
91 "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",
93 std::ostringstream
buf;
94 constexpr auto SIGSIZE = 512;
95 unsigned char data[SIGSIZE];
100 buf <<
"eve" << std::endl;
101 buf <<
"version=1.00" << std::endl;
102 buf <<
"run=" <<
event.getRunNumber() << std::endl;
103 buf <<
"firstTForbit=" <<
event.getFirstTForbit() << std::endl;
106 <<
"dd if=thisFileName.eve of=thisFileName.png skip=20 bs=1 count=6000000" << std::endl;
107 buf << std::string(SIGSIZE,
' ');
108 memcpy((
char*)&
data[0],
buf.str().c_str(), SIGSIZE);
109 data[SIGSIZE - 2] =
'\n';
110 data[SIGSIZE - 1] = 0;
113 const auto trackNo =
event.getTracksSpan().size();
117 for (
const auto& calo :
event.getCalorimetersSpan()) {
130 const auto head = asUnsigned(chunkHEAD);
133 unsigned long creationTime =
event.getCreationTime();
147 location.write(
static_cast<char*
>(chunkHEAD), chunkSize(chunkHEAD));
152 unsigned totalPoints = 0;
153 unsigned totalClusters = 0;
155 const auto chunkTELM = createChunk(
TELM, trackNo);
156 const auto telm = asByte(chunkTELM);
157 const auto chunkTGID = createChunk(
TGID, 4 * trackNo);
158 const auto tgid = asUnsigned(chunkTGID);
159 const auto chunkTPID = createChunk(
TPID, 4 * trackNo);
160 const auto tpid = asUnsigned(chunkTPID);
161 const auto chunkCELM = createChunk(
CELM, trackNo);
162 const auto celm = asByte(chunkCELM);
164 const auto chunkTTYP = createChunk(
TTYP, 4 * 27);
165 const auto ttyp = asUnsigned(chunkTTYP);
167 for (
const auto& track :
event.getTracksSpan()) {
168 tgid[
index] = track.mBGID;
169 tpid[
index] = track.mPID;
170 const auto ttypeidx = track.mBGID.getSource();
172 totalPoints += track.getPointCount();
173 totalClusters += track.getClusterCount();
174 telm[
index] = track.getPointCount();
175 celm[
index] = track.getClusterCount();
178 location.write(
static_cast<char*
>(chunkTTYP), chunkSize(chunkTTYP));
180 location.write(
static_cast<char*
>(chunkTELM), chunkSize(chunkTELM));
182 location.write(
static_cast<char*
>(chunkCELM), chunkSize(chunkCELM));
184 location.write(
static_cast<char*
>(chunkTGID), chunkSize(chunkTGID));
186 location.write(
static_cast<char*
>(chunkTPID), chunkSize(chunkTPID));
191 const auto chunkTXYZ = createChunk(
TXYZ, totalPoints * 4 * 3);
192 const auto txyz = asFloat(chunkTXYZ);
195 const auto chunkTIME = createChunk(
TIME, trackNo * 4);
196 const auto time = asFloat(chunkTIME);
199 const auto chunkSXYZ = createChunk(
SXYZ, trackNo * 4 * 3);
200 const auto sxyz = asFloat(chunkSXYZ);
201 unsigned sxyzidx = 0;
203 const auto chunkATPE = createChunk(
ATPE, trackNo * 4 * 3);
204 const auto atpe = asFloat(chunkATPE);
205 unsigned atpeidx = 0;
207 const auto chunkCRGE = createChunk(
CRGE, trackNo);
208 const auto crge = asSignedByte(chunkCRGE);
210 const auto chunkCXYZ = createChunk(
CXYZ, totalClusters * 4 * 3);
211 const auto cxyz = asFloat(chunkCXYZ);
214 for (
const auto& track :
event.getTracksSpan()) {
215 time[tno] = track.getTime();
216 crge[tno] =
static_cast<signed char>(track.getCharge());
218 sxyz[sxyzidx++] = track.getStartCoordinates()[0];
219 sxyz[sxyzidx++] = track.getStartCoordinates()[1];
220 sxyz[sxyzidx++] = track.getStartCoordinates()[2];
222 atpe[atpeidx++] = track.getTheta();
223 atpe[atpeidx++] = track.getPhi();
224 atpe[atpeidx++] = track.mEta;
226 for (
unsigned i = 0;
i < track.mPolyX.size();
i++) {
227 txyz[tidx++] = track.mPolyX[
i];
228 txyz[tidx++] = track.mPolyY[
i];
229 txyz[tidx++] = track.mPolyZ[
i];
231 for (
unsigned i = 0;
i < track.getClusterCount();
i++) {
232 cxyz[cidx++] = track.getClustersSpan()[
i].X();
233 cxyz[cidx++] = track.getClustersSpan()[
i].Y();
234 cxyz[cidx++] = track.getClustersSpan()[
i].Z();
237 location.write(
static_cast<char*
>(chunkTXYZ), chunkSize(chunkTXYZ));
239 location.write(
static_cast<char*
>(chunkCXYZ), chunkSize(chunkCXYZ));
241 location.write(
static_cast<char*
>(chunkTIME), chunkSize(chunkTIME));
243 location.write(
static_cast<char*
>(chunkSXYZ), chunkSize(chunkSXYZ));
245 location.write(
static_cast<char*
>(chunkCRGE), chunkSize(chunkCRGE));
247 location.write(
static_cast<char*
>(chunkATPE), chunkSize(chunkATPE));
253 const auto uxyz = asFloat(chunkUXYZ);
255 const auto utim = asFloat(chunkUTIM);
257 const auto ugid = asUnsigned(chunkUGID);
260 for (
const auto&
c :
event.getClustersSpan()) {
261 utim[idx / 3] =
c.mTime;
267 location.write(
static_cast<char*
>(chunkUGID), chunkSize(chunkUGID));
269 location.write(
static_cast<char*
>(chunkUTIM), chunkSize(chunkUTIM));
271 location.write(
static_cast<char*
>(chunkUXYZ), chunkSize(chunkUXYZ));
277 const auto calo = asFloat(chunkCALO);
279 const auto calp = asUnsigned(chunkCALP);
281 const auto calg = asUnsigned(chunkCALG);
283 const auto calt = asFloat(chunkCALT);
286 for (
const auto&
c :
event.getCalorimetersSpan()) {
288 calt[idx / 3] =
c.getTime();
291 calo[idx++] =
c.getPhi();
292 calo[idx++] =
c.getEta();
293 calo[idx++] =
c.getEnergy();
296 for (
const auto&
c :
event.getCalorimetersSpan()) {
298 calt[idx / 3] =
c.getTime();
301 calo[idx++] =
c.getPhi();
302 calo[idx++] =
c.getEta();
303 calo[idx++] =
c.getEnergy();
307 location.write((
char*)chunkCALO, chunkSize(chunkCALO));
309 location.write((
char*)chunkCALP, chunkSize(chunkCALP));
311 location.write((
char*)chunkCALG, chunkSize(chunkCALG));
313 location.write((
char*)chunkCALT, chunkSize(chunkCALT));
318 const auto chunkFINE = createChunk(
FINE, 0);
319 location.write(
static_cast<char*
>(chunkFINE), chunkSize(chunkFINE));
361 std::filesystem::path inputFilePath{fileName};
362 auto length = (
long)std::filesystem::file_size(inputFilePath);
367 std::ifstream inputFile(fileName, std::ios_base::binary);
368 inputFile.read(
reinterpret_cast<char*
>(
buffer.data()),
length);
378 unsigned char* telm =
nullptr;
379 unsigned char* celm =
nullptr;
380 unsigned int* ttyp =
nullptr;
381 float* txyz =
nullptr;
382 float* cxyz =
nullptr;
384 float*
time =
nullptr;
385 float* sxyz =
nullptr;
386 signed char* crge =
nullptr;
387 float* atpe =
nullptr;
388 unsigned* tgid =
nullptr;
389 unsigned* tpid =
nullptr;
391 float* calo =
nullptr;
392 unsigned* calp =
nullptr;
393 unsigned* calg =
nullptr;
394 float* calt =
nullptr;
396 unsigned* ugid =
nullptr;
397 float* utim =
nullptr;
398 float* uxyz =
nullptr;
400 unsigned phsCaloCount = 0;
401 unsigned emcCaloCount = 0;
404 for (
auto c = 0;
c < 4;
c++) {
407 auto* words = (
unsigned*)(
buffer.data() + position + 4);
408 position = position + *words + 8;
424 event.setPrimaryVertex(head[11]);
425 event.setTfCounter(head[12]);
426 }
else if (std::string(
type) ==
TELM) {
427 telm = (
unsigned char*)words;
428 }
else if (std::string(
type) ==
CELM) {
429 celm = (
unsigned char*)words;
430 }
else if (std::string(
type) ==
TTYP) {
431 ttyp = (
unsigned int*)words;
432 }
else if (std::string(
type) ==
TIME) {
433 time = (
float*)words;
434 }
else if (std::string(
type) ==
TXYZ) {
435 txyz = (
float*)words;
436 }
else if (std::string(
type) ==
CXYZ) {
437 cxyz = (
float*)words;
438 }
else if (std::string(
type) ==
SXYZ) {
439 sxyz = (
float*)words;
440 }
else if (std::string(
type) ==
CRGE) {
441 crge = (
signed char*)words;
442 }
else if (std::string(
type) ==
ATPE) {
443 atpe = (
float*)words;
444 }
else if (std::string(
type) ==
TGID) {
445 tgid = (
unsigned*)words;
446 }
else if (std::string(
type) ==
TPID) {
447 tpid = (
unsigned*)words;
448 }
else if (std::string(
type) ==
UXYZ) {
449 uxyz = (
float*)words;
450 }
else if (std::string(
type) ==
UGID) {
451 ugid = (
unsigned*)words;
452 }
else if (std::string(
type) ==
UTIM) {
453 utim = (
float*)words;
454 }
else if (std::string(
type) ==
CALO) {
455 calo = (
float*)words;
456 }
else if (std::string(
type) ==
CALP) {
457 calp = (
unsigned*)words;
458 }
else if (std::string(
type) ==
CALG) {
459 calg = (
unsigned*)words;
460 }
else if (std::string(
type) ==
CALT) {
461 calt = (
float*)words;
462 }
else if (std::string(
type) ==
FINE) {
463 assert(telm !=
nullptr);
464 assert(celm !=
nullptr);
465 assert(ttyp !=
nullptr);
466 assert(txyz !=
nullptr);
467 assert(cxyz !=
nullptr);
468 assert(
time !=
nullptr);
469 assert(sxyz !=
nullptr);
470 assert(crge !=
nullptr);
471 assert(atpe !=
nullptr);
472 assert(tgid !=
nullptr);
473 assert(tpid !=
nullptr);
474 assert(uxyz !=
nullptr);
475 assert(ugid !=
nullptr);
476 assert(utim !=
nullptr);
477 assert(calo !=
nullptr);
478 assert(calp !=
nullptr);
479 assert(calg !=
nullptr);
480 assert(calt !=
nullptr);
486 while (ttyp[ttypidx] == 0) {
490 auto track =
event.addTrack({.time =
time[t],
493 .startXYZ = {sxyz[3 * t + 0], sxyz[3 * t + 1], sxyz[3 * t + 2]},
494 .phi = atpe[3 * t + 1],
495 .theta = atpe[3 * t + 0],
496 .eta = atpe[3 * t + 2],
498 track->mPolyX.reserve(telm[t]);
499 track->mPolyY.reserve(telm[t]);
500 track->mPolyZ.reserve(telm[t]);
501 while (telm[t]-- > 0) {
502 track->mPolyX.push_back(txyz[txyzidx++]);
503 track->mPolyY.push_back(txyz[txyzidx++]);
504 track->mPolyZ.push_back(txyz[txyzidx++]);
506 track->mClusters.reserve(celm[t]);
507 while (celm[t]-- > 0) {
510 track->mClusters.push_back(cluster);
516 event.addGlobalCluster(uxyz + 3 *
c, utim[
c],
deserialize(ugid[
c]));
521 for (
auto c = 0u;
c < phsCaloCount + emcCaloCount;
c++) {
522 auto phi = calo[idx++];
523 auto eta = calo[idx++];
524 auto energy = calo[idx++];
525 event.addCalo({.time = calt[
c],