CbmRoot
CbmEvent.cxx
Go to the documentation of this file.
1 
6 #include "CbmEvent.h"
7 
8 #include <iostream> // for operator<<, basic_ostream
9 #include <sstream> // for stringstream
10 #include <string> // for char_traits
11 #include <utility> // for pair
12 
13 
14 // ----- Add data to event ---------------------------------------------
15 void CbmEvent::AddData(ECbmDataType type, UInt_t index) {
16 
17  fIndexMap[type].push_back(index);
18  fNofData++;
19 }
20 // -------------------------------------------------------------------------
21 
22 
23 // ----- Get a data index ----------------------------------------------
24 UInt_t CbmEvent::GetIndex(ECbmDataType type, UInt_t iData) {
25 
26  if (fIndexMap.find(type) == fIndexMap.end()) return -1;
27  if (fIndexMap[type].size() <= iData) return -2;
28  return fIndexMap.at(type)[iData];
29 }
30 // -------------------------------------------------------------------------
31 
32 
33 // ----- Get number of data of a type in this event --------------------
35 
36  if (fIndexMap.find(type) == fIndexMap.end())
37  return -1;
38  else
39  return fIndexMap.at(type).size();
40 }
41 // -------------------------------------------------------------------------
42 
43 
44 // ----- Set the vertex parameters -------------------------------------
45 void CbmEvent::SetVertex(Double_t x,
46  Double_t y,
47  Double_t z,
48  Double_t chi2,
49  Int_t ndf,
50  Int_t nTracks,
51  const TMatrixFSym& covMat) {
52  fVertex.SetVertex(x, y, z, chi2, ndf, nTracks, covMat);
53 }
54 // -------------------------------------------------------------------------
55 
56 
57 // ----- String output -------------------------------------------------
58 std::string CbmEvent::ToString() const {
59  std::stringstream ss;
60  ss << "Event " << fNumber << " at t = " << fTimeStart
61  << " ns. Registered data types: " << fIndexMap.size()
62  << ", data objects: " << fNofData
63  << (nullptr != fMatch ? ", with matches" : ", without matches") << "\n";
64  for (auto it = fIndexMap.begin(); it != fIndexMap.end(); it++) {
65  ss << " -- Data type " << it->first << ", number of data "
66  << it->second.size() << "\n";
67  }
68  return ss.str();
69 }
70 // -------------------------------------------------------------------------
71 
72 
CbmVertex::SetVertex
void SetVertex(Double_t x, Double_t y, Double_t z, Double_t chi2, Int_t ndf, Int_t nTracks, const TMatrixFSym &covMat)
Definition: CbmVertex.cxx:129
CbmEvent::GetIndex
UInt_t GetIndex(ECbmDataType type, UInt_t iData)
Definition: CbmEvent.cxx:24
CbmEvent::fIndexMap
std::map< ECbmDataType, std::vector< UInt_t > > fIndexMap
Definition: CbmEvent.h:202
CbmEvent::fTimeStart
Double_t fTimeStart
Event start time [ns].
Definition: CbmEvent.h:195
CbmEvent::ToString
std::string ToString() const
Definition: CbmEvent.cxx:58
CbmEvent::AddData
void AddData(ECbmDataType type, UInt_t index)
Definition: CbmEvent.cxx:15
CbmEvent::fMatch
CbmMatch * fMatch
Match object to MCEvent.
Definition: CbmEvent.h:199
CbmEvent::fNofData
Int_t fNofData
Number of data objects in the event.
Definition: CbmEvent.h:197
CbmEvent.h
CbmEvent::fVertex
CbmVertex fVertex
Primary Vertex.
Definition: CbmEvent.h:198
ECbmDataType
ECbmDataType
Definition: CbmDefs.h:76
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmEvent::GetNofData
Int_t GetNofData() const
Definition: CbmEvent.h:90
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmEvent::fNumber
Int_t fNumber
Event number.
Definition: CbmEvent.h:194
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmEvent::SetVertex
void SetVertex(Double_t x, Double_t y, Double_t z, Double_t chi2, Int_t ndf, Int_t nTracks, const TMatrixFSym &covMat)
Definition: CbmEvent.cxx:45
CbmEvent
Class characterising one event by a collection of links (indices) to data objects,...
Definition: CbmEvent.h:30