@@ -35,6 +35,7 @@ VisualisationTrack::VisualisationTrack(const VisualisationTrackVO& vo)
3535 this ->mPhi = vo.phi ;
3636 this ->addStartCoordinates (vo.startXYZ );
3737 this ->mSource = vo.source ;
38+ this ->mEta = vo.eta ;
3839}
3940
4041void VisualisationTrack::addStartCoordinates (const float xyz[3 ])
@@ -53,14 +54,18 @@ void VisualisationTrack::addPolyPoint(float x, float y, float z)
5354
5455VisualisationTrack::VisualisationTrack (rapidjson::Value& tree)
5556{
57+ mClusters .clear ();
5658 rapidjson::Value& jsonPolyX = tree[" mPolyX" ];
5759 rapidjson::Value& jsonPolyY = tree[" mPolyY" ];
5860 rapidjson::Value& jsonPolyZ = tree[" mPolyZ" ];
5961 rapidjson::Value& count = tree[" count" ];
6062 this ->mCharge = 0 ;
6163
62- this ->mSource = (o2::dataformats::GlobalTrackID::Source)tree[" source" ].GetInt ();
63- this ->mSource = o2::dataformats::GlobalTrackID::TPC; // temporary
64+ if (tree.HasMember (" source" )) {
65+ this ->mSource = (o2::dataformats::GlobalTrackID::Source)tree[" source" ].GetInt ();
66+ } else {
67+ this ->mSource = o2::dataformats::GlobalTrackID::TPC; // temporary
68+ }
6469 this ->mPID = (o2::dataformats::GlobalTrackID::Source)tree[" source" ].GetInt ();
6570 // this->mTime = (o2::dataformats::GlobalTrackID::Source)tree["time"].GetFloat();
6671 this ->mPolyX .reserve (count.GetInt ());
@@ -75,6 +80,14 @@ VisualisationTrack::VisualisationTrack(rapidjson::Value& tree)
7580 for (auto & v : jsonPolyZ.GetArray ()) {
7681 mPolyZ .push_back (v.GetDouble ());
7782 }
83+ if (tree.HasMember (" mClusters" )) {
84+ rapidjson::Value& jsonClusters = tree[" mClusters" ];
85+ auto jsonArray = jsonClusters.GetArray ();
86+ this ->mClusters .reserve (jsonArray.Size ());
87+ for (auto & v : jsonClusters.GetArray ()) {
88+ mClusters .emplace_back (v);
89+ }
90+ }
7891}
7992
8093rapidjson::Value VisualisationTrack::jsonTree (rapidjson::Document::AllocatorType& allocator)
@@ -83,12 +96,22 @@ rapidjson::Value VisualisationTrack::jsonTree(rapidjson::Document::AllocatorType
8396 rapidjson::Value jsonPolyX (rapidjson::kArrayType );
8497 rapidjson::Value jsonPolyY (rapidjson::kArrayType );
8598 rapidjson::Value jsonPolyZ (rapidjson::kArrayType );
99+ rapidjson::Value jsonStartCoordinates (rapidjson::kArrayType );
86100
87101 tree.AddMember (" count" , rapidjson::Value ().SetInt (this ->getPointCount ()), allocator);
88102 tree.AddMember (" source" , rapidjson::Value ().SetInt (this ->mSource ), allocator);
89- // tree.AddMember("time", rapidjson::Value().SetFloat(this->mTime), allocator);
103+ tree.AddMember (" time" , rapidjson::Value ().SetFloat (this ->mTime ), allocator);
104+ tree.AddMember (" charge" , rapidjson::Value ().SetInt (this ->mCharge ), allocator);
105+ tree.AddMember (" theta" , rapidjson::Value ().SetFloat (this ->mTheta ), allocator);
106+ tree.AddMember (" phi" , rapidjson::Value ().SetFloat (this ->mPhi ), allocator);
107+ tree.AddMember (" eta" , rapidjson::Value ().SetFloat (this ->mEta ), allocator);
90108 tree.AddMember (" PID" , rapidjson::Value ().SetInt (this ->mPID ), allocator);
91109
110+ jsonStartCoordinates.PushBack ((float )mStartCoordinates [0 ], allocator);
111+ jsonStartCoordinates.PushBack ((float )mStartCoordinates [1 ], allocator);
112+ jsonStartCoordinates.PushBack ((float )mStartCoordinates [2 ], allocator);
113+ tree.AddMember (" jsonStartingXYZ" , jsonStartCoordinates, allocator);
114+
92115 for (size_t i = 0 ; i < this ->getPointCount (); i++) {
93116 jsonPolyX.PushBack ((float )mPolyX [i], allocator);
94117 jsonPolyY.PushBack ((float )mPolyY [i], allocator);
@@ -98,8 +121,20 @@ rapidjson::Value VisualisationTrack::jsonTree(rapidjson::Document::AllocatorType
98121 tree.AddMember (" mPolyY" , jsonPolyY, allocator);
99122 tree.AddMember (" mPolyZ" , jsonPolyZ, allocator);
100123
124+ rapidjson::Value jsonClusters (rapidjson::kArrayType );
125+ for (size_t i = 0 ; i < this ->mClusters .size (); i++) {
126+ jsonClusters.PushBack (this ->mClusters [i].jsonTree (allocator), allocator);
127+ }
128+ tree.AddMember (" mClusters" , jsonClusters, allocator);
129+
101130 return tree;
102131}
103132
133+ VisualisationCluster& VisualisationTrack::addCluster (float pos[])
134+ {
135+ mClusters .emplace_back (pos, 0 );
136+ return mClusters .back ();
137+ }
138+
104139} // namespace event_visualisation
105140} // namespace o2
0 commit comments