CbmRoot
CbmSimEventHeaderConverter.cxx
Go to the documentation of this file.
1 #include "FairMCEventHeader.h"
2 #include "FairRootManager.h"
3 #include "TClonesArray.h"
4 #include "cassert"
5 
7 
9 
10  void CbmSimEventHeaderConverter::Init(std::map<std::string, void*>&) {
11  assert(!in_branches_.empty() && !out_branch_.empty() && out_config_
12  && out_tree_);
13  auto* ioman = FairRootManager::Instance();
14  assert(ioman != nullptr);
15  cbm_header_ = (FairMCEventHeader*) ioman->GetObject(in_branches_[0].c_str());
16 
17  // ***** SimEventHeader *******
18  AnalysisTree::BranchConfig SimEventHeaderBranch(
19  "SimEventHeader", AnalysisTree::DetType::kEventHeader);
20  SimEventHeaderBranch.AddField<float>("psi_RP");
21  SimEventHeaderBranch.AddField<float>("b");
22  out_config_->AddBranchConfig(SimEventHeaderBranch);
23  sim_event_header_ = new AnalysisTree::EventHeader(out_config_->GetLastId());
24  sim_event_header_->Init(SimEventHeaderBranch);
25 
26  out_tree_->Branch(
27  out_branch_.c_str(), "AnalysisTree::EventHeader", &sim_event_header_);
28 }
29 
31  if (!cbm_header_) {
32  throw std::runtime_error(
33  "CbmSimEventHeaderConverter::Exec - ERROR! No fHeader!");
34  }
35 
36  TVector3 pos = {
37  cbm_header_->GetX(), cbm_header_->GetY(), cbm_header_->GetZ()};
38  sim_event_header_->SetVertexPosition3(pos);
39  sim_event_header_->SetField(
40  float(cbm_header_->GetRotZ()),
41  out_config_->GetBranchConfig(sim_event_header_->GetId())
42  .GetFieldId("psi_RP"));
43  sim_event_header_->SetField(
44  float(cbm_header_->GetB()),
45  out_config_->GetBranchConfig(sim_event_header_->GetId()).GetFieldId("b"));
46 }
CbmSimEventHeaderConverter::cbm_header_
FairMCEventHeader * cbm_header_
Definition: CbmSimEventHeaderConverter.h:25
ClassImp
ClassImp(CbmSimEventHeaderConverter) void CbmSimEventHeaderConverter
Definition: CbmSimEventHeaderConverter.cxx:8
CbmSimEventHeaderConverter
Definition: CbmSimEventHeaderConverter.h:11
CbmSimEventHeaderConverter::Exec
void Exec() final
Definition: CbmSimEventHeaderConverter.cxx:30
CbmSimEventHeaderConverter.h
CbmSimEventHeaderConverter::Init
void Init(std::map< std::string, void * > &) final
CbmSimEventHeaderConverter::sim_event_header_
AnalysisTree::EventHeader * sim_event_header_
Definition: CbmSimEventHeaderConverter.h:24
pos
TVector3 pos
Definition: CbmMvdSensorDigiToHitTask.cxx:60