CbmRoot
CbmRecEventHeaderConverter.cxx
Go to the documentation of this file.
1 #include "CbmVertex.h"
2 #include "FairMCEventHeader.h"
3 #include "FairRootManager.h"
4 #include "TClonesArray.h"
5 #include "cassert"
6 
8 
10 
11  void CbmRecEventHeaderConverter::Init(std::map<std::string, void*>&) {
12  assert(!in_branches_.empty() && !out_branch_.empty() && out_config_
13  && out_tree_);
14  auto* ioman = FairRootManager::Instance();
15  assert(ioman != nullptr);
16  cbm_header_ = (FairMCEventHeader*) ioman->GetObject(in_branches_[0].c_str());
17  cbm_prim_vertex_ = (CbmVertex*) ioman->GetObject(in_branches_[1].c_str());
18 
19  // ***** RecEventHeader *******
20  AnalysisTree::BranchConfig RecEventHeaderBranch(
21  "RecEventHeader", AnalysisTree::DetType::kEventHeader);
22  RecEventHeaderBranch.AddField<float>("psi_EP");
23  RecEventHeaderBranch.AddField<float>("vtx_chi2");
24  RecEventHeaderBranch.AddField<float>("Epsd");
25  RecEventHeaderBranch.AddField<int>("M");
26  RecEventHeaderBranch.AddField<int>("evt_id");
27  out_config_->AddBranchConfig(RecEventHeaderBranch);
28  rec_event_header_ = new AnalysisTree::EventHeader(out_config_->GetLastId());
29  rec_event_header_->Init(RecEventHeaderBranch);
30  out_tree_->Branch(
31  out_branch_.c_str(), "AnalysisTree::EventHeader", &rec_event_header_);
32 }
33 
35  const auto& conf = out_config_->GetBranchConfig(rec_event_header_->GetId());
36  if (!cbm_prim_vertex_) {
37  std::cout << "WARNING! No fPrimVtx!" << std::endl;
38 
39  rec_event_header_->SetVertexPosition3({-999., -999., -999.});
40  rec_event_header_->SetField(float(-999.), conf.GetFieldId("vtx_chi2"));
41  return;
42  }
43  rec_event_header_->SetVertexPosition3({cbm_prim_vertex_->GetX(),
46  // rec_event_header_ -> SetField(int(cbm_sts_tracks_->GetEntries()),
47  // config_.GetBranchConfig(rec_event_header_->GetId() ).GetFieldId("M"));
48  rec_event_header_->SetField(int(cbm_header_->GetEventID()),
49  conf.GetFieldId("evt_id"));
50  rec_event_header_->SetField(
52  conf.GetFieldId("vtx_chi2"));
53 }
CbmVertex.h
CbmRecEventHeaderConverter::cbm_prim_vertex_
CbmVertex * cbm_prim_vertex_
Definition: CbmRecEventHeaderConverter.h:28
CbmRecEventHeaderConverter.h
CbmVertex::GetX
Double_t GetX() const
Definition: CbmVertex.h:68
CbmVertex::GetChi2
Double_t GetChi2() const
Definition: CbmVertex.h:71
CbmRecEventHeaderConverter::cbm_header_
FairMCEventHeader * cbm_header_
Definition: CbmRecEventHeaderConverter.h:27
ClassImp
ClassImp(CbmRecEventHeaderConverter) void CbmRecEventHeaderConverter
Definition: CbmRecEventHeaderConverter.cxx:9
CbmVertex
Definition: CbmVertex.h:26
CbmRecEventHeaderConverter::rec_event_header_
AnalysisTree::EventHeader * rec_event_header_
Definition: CbmRecEventHeaderConverter.h:25
CbmVertex::GetZ
Double_t GetZ() const
Definition: CbmVertex.h:70
CbmVertex::GetY
Double_t GetY() const
Definition: CbmVertex.h:69
CbmRecEventHeaderConverter::Init
void Init(std::map< std::string, void * > &) final
CbmRecEventHeaderConverter::Exec
void Exec() final
Definition: CbmRecEventHeaderConverter.cxx:34
CbmRecEventHeaderConverter
Definition: CbmRecEventHeaderConverter.h:11
CbmVertex::GetNDF
Int_t GetNDF() const
Definition: CbmVertex.h:72