18#include <fairlogger/Logger.h>
24#include <TParameter.h>
29namespace event_visualisation
33void VisualisationEventROOTSerializer::save(
const char*
name,
const std::string&
value)
39std::string VisualisationEventROOTSerializer::readString(TFile&
f,
const char*
name)
41 auto*
v = (TNamed*)
f.Get(
name);
45 std::string
result =
v->GetTitle();
50void VisualisationEventROOTSerializer::saveInt(
const char*
name,
int value)
57void VisualisationEventROOTSerializer::saveUInt64(
const char*
name,
uint64_t value)
60 obj.SetVal((
long)
value);
64int VisualisationEventROOTSerializer::readInt(TFile&
f,
const char*
name)
66 auto v = (TParameter<int>*)
f.Get(
name);
75uint64_t VisualisationEventROOTSerializer::readUInt64(TFile&
f,
const char*
name)
77 auto v = (TParameter<uint64_t>*)
f.Get(
name);
86bool VisualisationEventROOTSerializer::existUInt64(TFile&
f,
const char*
name)
88 auto v = (TParameter<uint64_t>*)
f.Get(
name);
98 std::string fileName =
location.fileName();
99 TFile
f(fileName.c_str(),
"recreate");
101 LOGF(
error,
"Could not create output file %s", fileName.c_str());
105 saveInt(
"runNumber",
event.mRunNumber);
106 saveInt(
"runType",
event.mRunType);
107 saveInt(
"clMask",
event.mClMask);
108 saveInt(
"trkMask",
event.mTrkMask);
109 saveInt(
"tfCounter",
event.mTfCounter);
110 saveInt(
"firstTForbit",
event.mFirstTForbit);
111 saveInt(
"primaryVertex",
event.mPrimaryVertex);
112 saveUInt64(
"creationTime",
event.mCreationTime);
115 saveInt(
"version",
event.mEveVersion);
119 TNtuple xyz(
"xyz",
"xyz",
"x:y:z");
122 TTree
clusters(
"clusters",
"Clusters");
124 unsigned cluster_bgid;
126 clusters.Branch(
"BGID", &cluster_bgid);
127 clusters.Branch(
"time", &cluster_time);
128 clusters.Branch(
"xyz", &cluster_xyz);
129 for (
auto cluster :
event.getClustersSpan()) {
130 cluster_time = cluster.Time();
132 cluster_xyz = xyzPos;
133 xyz.Fill(cluster.X(), cluster.Y(), cluster.Z());
150 TTree
tracks(
"tracks",
"Tracks");
151 tracks.Branch(
"xyz", &track_xyz);
152 tracks.Branch(
"time", &track_time);
153 tracks.Branch(
"charge", &track_charge);
154 tracks.Branch(
"theta", &track_theta);
155 tracks.Branch(
"phi", &track_phi);
156 tracks.Branch(
"eta", &track_eta);
157 tracks.Branch(
"PID", &track_PID);
158 tracks.Branch(
"BGID", &track_BGID);
159 tracks.Branch(
"points", &track_points);
160 tracks.Branch(
"clusters", &track_clusters);
162 for (
auto track :
event.getTracksSpan()) {
164 track_time = std::isnan(track.mTime) ? 0 : track.mTime;
165 track_charge = track.mCharge;
166 track_theta = std::isnan(track.mTheta) ? 0 : track.mTheta;
167 track_phi = std::isnan(track.mPhi) ? 0 : track.mPhi;
168 track_eta = std::isnan(track.mEta) ? 0 : track.mEta;
169 track_PID = track.mPID;
172 xyz.Fill(track.mStartCoordinates[0], track.mStartCoordinates[1], track.mStartCoordinates[2]);
174 track_points = track.getPointCount();
176 for (
size_t i = 0;
i < track.getPointCount();
i++) {
177 xyz.Fill(track.mPolyX[
i], track.mPolyY[
i], track.mPolyZ[
i]);
180 track_clusters = track.getClusterCount();
181 for (
auto cluster : track.getClustersSpan()) {
182 xyz.Fill(cluster.X(), cluster.Y(), cluster.Z());
191 TTree calo(
"calo",
"Calorimeters");
199 calo.Branch(
"time", &calo_time);
200 calo.Branch(
"energy", &calo_energy);
201 calo.Branch(
"eta", &calo_eta);
202 calo.Branch(
"phi", &calo_phi);
203 calo.Branch(
"BGID", &calo_BGID);
204 calo.Branch(
"PID", &calo_PID);
206 for (
const auto& calorimeter :
event.getCalorimetersSpan()) {
207 calo_time = calorimeter.getTime();
208 calo_energy = calorimeter.getEnergy();
209 calo_eta = calorimeter.getEta();
210 calo_phi = calorimeter.getPhi();
211 calo_BGID =
serialize(calorimeter.mBGID);
212 calo_PID = calorimeter.getPID();
225 event.mTracks.clear();
226 event.mClusters.clear();
229 TFile
f(fileName.c_str());
231 event.setRunNumber(readInt(
f,
"runNumber"));
233 event.setClMask(readInt(
f,
"clMask"));
234 event.setTrkMask(readInt(
f,
"trkMask"));
235 event.setTfCounter(readInt(
f,
"tfCounter"));
236 event.setFirstTForbit(readInt(
f,
"firstTForbit"));
237 event.mPrimaryVertex = readInt(
f,
"primaryVertex");
239 if (existUInt64(
f,
"creationTime")) {
240 event.setCreationTime(readInt(
f,
"creationTime"));
242 auto collisionTime = readString(
f,
"collisionTime");
246 event.mEveVersion = 0;
247 if (
f.Get(
"version") !=
nullptr) {
248 event.mEveVersion = readInt(
f,
"version");
250 std::string
version = readString(
f,
"eveVersion");
251 event.mEveVersion = (int)(100 * std::stof(
version));
255 auto* xyz = (TNtuple*)
f.Get(
"xyz");
256 if (xyz ==
nullptr) {
261 auto*
tracks = (TTree*)
f.Get(
"tracks");
271 std::string* track_GID =
nullptr;
280 tracks->SetBranchAddress(
"xyz", &track_xyz);
281 tracks->SetBranchAddress(
"time", &track_time);
282 tracks->SetBranchAddress(
"charge", &track_charge);
283 tracks->SetBranchAddress(
"theta", &track_theta);
284 tracks->SetBranchAddress(
"phi", &track_phi);
285 tracks->SetBranchAddress(
"eta", &track_eta);
286 tracks->SetBranchAddress(
"PID", &track_PID);
287 auto gid =
tracks->GetBranch(
"GID");
288 if (gid !=
nullptr) {
289 tracks->SetBranchAddress(
"GID", &track_GID);
291 auto bgid =
tracks->GetBranch(
"BGID");
292 if (bgid !=
nullptr) {
293 tracks->SetBranchAddress(
"BGID", &track_BGID);
297 tracks->SetBranchAddress(
"source", &track_source);
299 tracks->SetBranchAddress(
"points", &track_points);
300 tracks->SetBranchAddress(
"clusters", &track_clusters);
302 auto tracksNoOfEntries = (Int_t)
tracks->GetEntries();
303 for (Int_t
i = 0;
i < tracksNoOfEntries;
i++) {
306 track.mTime = track_time;
307 track.mCharge = track_charge;
308 track.mTheta = track_theta;
309 track.mPhi = track_phi;
310 track.mEta = track_eta;
311 track.mPID = track_PID;
317 xyz->GetEntry(track_xyz);
318 track.addStartCoordinates(xyz->GetArgs());
319 for (
int p = 0; p < track_points; p++) {
320 xyz->GetEntry(track_xyz + 1 + p);
321 track.addPolyPoint(xyz->GetArgs());
323 for (
size_t it = 0; it < track_clusters; it++) {
324 xyz->GetEntry(track_xyz + 1 + track_points + it);
326 track.mClusters.emplace_back(cluster);
328 event.mTracks.emplace_back(track);
331 if (gid !=
nullptr) {
336 if (!readClusters(
event,
f, xyz)) {
342 if (!readCalo(
event,
f)) {
351 event.afterLoading();
357 auto*
clusters = (TTree*)
f.Get(
"clusters");
364 unsigned cluster_BGID;
369 clusters->SetBranchAddress(
"source", &cluster_source);
372 auto bgid =
clusters->GetBranch(
"BGID");
373 if (bgid !=
nullptr) {
374 clusters->SetBranchAddress(
"BGID", &cluster_BGID);
377 clusters->SetBranchAddress(
"time", &cluster_time);
378 clusters->SetBranchAddress(
"xyz", &cluster_xyz);
379 auto clustersNoOfEntries = (Int_t)
clusters->GetEntries();
380 for (Int_t
i = 0;
i < clustersNoOfEntries;
i++) {
382 xyz->GetEntry(cluster_xyz);
383 dataformats::GlobalTrackID gid = 0;
389 VisualisationCluster cluster(xyz->GetArgs(), cluster_time, gid);
390 event.mClusters.emplace_back(cluster);
396bool VisualisationEventROOTSerializer::readCalo(VisualisationEvent&
event, TFile&
f)
398 auto* calo = (TTree*)
f.Get(
"calo");
399 if (calo ==
nullptr) {
411 auto source = calo->GetBranch(
"source");
413 calo->SetBranchAddress(
"source", &calo_source);
415 auto bgid = calo->GetBranch(
"BGID");
416 if (bgid !=
nullptr) {
417 calo->SetBranchAddress(
"BGID", &calo_BGID);
420 calo->SetBranchAddress(
"time", &calo_time);
421 calo->SetBranchAddress(
"energy", &calo_energy);
422 calo->SetBranchAddress(
"eta", &calo_eta);
423 calo->SetBranchAddress(
"phi", &calo_phi);
424 calo->SetBranchAddress(
"PID", &calo_PID);
426 auto nentries = (Int_t)calo->GetEntries();
427 for (Int_t
i = 0;
i < nentries;
i++) {
429 VisualisationCalo calorimeter;
430 calorimeter.mTime = calo_time;
431 calorimeter.mEnergy = calo_energy;
432 calorimeter.mEta = calo_eta;
433 calorimeter.mPhi = calo_phi;
437 calorimeter.mBGID =
deserialize(calo_source, 0, 0);
439 calorimeter.mPID = calo_PID;
440 event.mCalo.emplace_back(calorimeter);
std::function< std::string(const void *)> serialize
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
char error[CURL_ERROR_SIZE]
std::vector< o2::its::TrackITS > tracks
bool fromFile(VisualisationEvent &event, std::string fileName) override
void toFile(const VisualisationEvent &event, Location &location) override
static o2::dataformats::GlobalTrackID deserialize(unsigned seralizedValue)
static o2::dataformats::GlobalTrackID gidFromString(const std::string &gid)
static time_t parseDateTime(const char *datetimeString)
GLuint const GLchar * name
GLsizei GLsizei GLchar * source
GLsizei const GLfloat * value
constexpr int ROOT_FILE_VERSION
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string to_string(gsl::span< T, Size > span)
std::vector< Cluster > clusters