32 FCN(
void* p) { ptr = p; }
38 void* _create(
const char*) {
48 void* ptr = PluginService::Create<void*>(
"DD4hep_DDEve_DDG4HitAccess",(
const char*)
"");
50 throw std::runtime_error(
"FATAL: Failed to access function pointer from factory DD4hep_DDEve_DDG4HitAccess");
52 m_simhitConverter = FCN(ptr).hits;
53 ptr = PluginService::Create<void*>(
"DD4hep_DDEve_DDG4ParticleAccess",(
const char*)
"");
55 throw std::runtime_error(
"FATAL: Failed to access function pointer from factory DD4hep_DDEve_DDG4ParticleAccess");
57 m_particleConverter = FCN(ptr).particles;
61 DDG4EventHandler::~DDG4EventHandler() {
88 return m_file.second->GetEntries();
96 return m_file.first->GetName();
103 Branches::const_iterator i =
m_branches.find(collection);
105 const char* cl = (*i).second.first->GetClassName();
119 typedef std::vector<void*> _P;
120 Branches::const_iterator i =
m_branches.find(collection);
122 const _P* data_ptr = (_P*)(*i).second.second;
125 actor.
setSize(data_ptr->size());
126 for(_P::const_iterator j=data_ptr->begin(); j!=data_ptr->end(); ++j) {
131 return data_ptr->size();
139 typedef std::vector<void*> _P;
140 Branches::const_iterator i =
m_branches.find(collection);
142 const _P* data_ptr = (_P*)(*i).second.second;
145 actor.
setSize(data_ptr->size());
146 for(_P::const_iterator j=data_ptr->begin(); j!=data_ptr->end(); ++j) {
151 return data_ptr->size();
162 if ( event_number >=
m_file.second->GetEntries() ) {
163 event_number =
m_file.second->GetEntries()-1;
164 printout(ERROR,
"DDG4EventHandler",
"+++ ReadEvent: Cannot read across End-of-file! Reading last event:%d.",event_number);
166 else if ( event_number < 0 ) {
168 printout(ERROR,
"DDG4EventHandler",
"+++ nextEvent: Cannot read across Start-of-file! Reading first event:%d.",event_number);
171 Int_t nbytes =
m_file.second->GetEntry(event_number);
173 printout(ERROR,
"DDG4EventHandler",
"+++ ReadEvent: Read %d bytes of event data for entry:%d",nbytes,event_number);
175 TBranch* b = (*i).second.first;
176 std::vector<void*>* ptr_data = *(std::vector<void*>**)b->GetAddress();
177 m_data[b->GetClassName()].emplace_back(b->GetName(),ptr_data->size());
182 printout(ERROR,
"DDG4EventHandler",
"+++ ReadEvent: Cannot read event data for entry:%d",event_number);
183 throw std::runtime_error(
"+++ EventHandler::readEvent: Failed to read event");
185 throw std::runtime_error(
"+++ EventHandler::readEvent: No file open!");
193 TFile* f = TFile::Open(name.c_str());
194 if ( f && !f->IsZombie() ) {
196 TTree* t = (TTree*)f->Get(
"EVENT");
198 TObjArray* br = t->GetListOfBranches();
202 for(Int_t i=0; i<br->GetSize(); ++i) {
203 TBranch* b = (TBranch*)br->At(i);
205 m_branches[b->GetName()] = std::make_pair(b,(
void*)0);
206 printout(INFO,
"DDG4EventHandler::open",
"+++ Branch %s has %ld entries.",b->GetName(),b->GetEntries());
208 for(Int_t i=0; i<br->GetSize(); ++i) {
209 TBranch* b = (TBranch*)br->At(i);
211 b->SetAddress(&
m_branches[b->GetName()].second);
216 throw std::runtime_error(
"+++ Failed to access tree EVENT in ROOT file:"+name);
218 throw std::runtime_error(
"+++ Failed to open ROOT file:"+name);