16 #include <calobase/RawTower.h>
17 #include <calobase/RawTowerContainer.h>
18 #include <calobase/RawTowerv1.h>
38 #include <TClonesArray.h>
57 , _out_file_name(filename)
66 std::cout <<
"PHG4DSTReader::destructor - Clean ups" << std::endl;
70 _T->ResetBranchAddresses();
78 const int arr_size = 100;
83 const char *class_name = hit_type::Class()->GetName();
85 std::string hname = Form(
"G4HIT_%s", nodenam.c_str());
89 std::cout <<
"PHG4DSTReader::Init - saving hits from node: " << hname <<
" - "
90 << class_name << std::endl;
96 rec.
_arr = boost::make_shared<TClonesArray>(class_name, arr_size);
107 std::cout <<
"PHG4DSTReader::Init - zero suppression for calorimeter towers = "
112 const char *class_name = RawTower_type::Class()->GetName();
114 std::string hname = Form(
"TOWER_%s", nodenam.c_str());
118 std::cout <<
"PHG4DSTReader::Init - saving raw tower info from node: " << hname
119 <<
" - " << class_name << std::endl;
124 rec.
_arr = boost::make_shared<TClonesArray>(class_name, arr_size);
135 const char *class_name = PHPyJet_type::Class()->GetName();
139 std::cout <<
"PHG4DSTReader::Init - saving jets from node: " << hname <<
" - "
140 << class_name << std::endl;
145 rec.
_arr = boost::make_shared<TClonesArray>(class_name, arr_size);
158 const char *class_name = part_type::Class()->GetName();
162 std::cout <<
"PHG4DSTReader::Init - saving Particles node:" << class_name
167 rec.
_name =
"PHG4Particle";
168 rec.
_arr = boost::make_shared<TClonesArray>(class_name, arr_size);
181 const char *class_name = vertex_type::Class()->GetName();
185 std::cout <<
"PHG4DSTReader::Init - saving vertex for particles under node:"
186 << class_name << std::endl;
190 rec.
_name =
"PHG4VtxPoint";
191 rec.
_arr = boost::make_shared<TClonesArray>(class_name, arr_size);
201 std::cout <<
"PHG4DSTReader::Init - requested " <<
nblocks <<
" nodes" << std::endl;
212 std::cout <<
"PHG4DSTReader::build_tree - output to " <<
_out_file_name << std::endl;
219 _T =
new TTree(
"T",
"PHG4DSTReader");
226 std::cout <<
"PHG4DSTReader::build_tree - Add " << rec._name << std::endl;
230 _T->Branch(name_cnt.c_str(), &(rec._cnt), name_cnt_desc.c_str(),
232 _T->Branch(rec._name.c_str(), &(rec._arr_ptr), BUFFER_SIZE, 99);
239 std::cout <<
"PHG4DSTReader::build_tree - added " <<
nblocks <<
" nodes" << std::endl;
241 _T->SetAutoSave(16000);
263 <<
"PHG4DSTReader::process_event - Error - can not find node G4TruthInfo. Quit processing!"
272 assert(rec._arr.get() == rec._arr_ptr);
280 std::cout <<
"PHG4DSTReader::process_event - processing " << rec._name
291 <<
"PHG4DSTReader::process_event - Error - can not find node "
292 << rec._name << std::endl;
301 std::cout <<
"PHG4DSTReader::process_event - processing "
302 << rec._name <<
" and received " << hits->
size() <<
" hits"
307 hit_iter != hit_range.second; hit_iter++)
309 PHG4Hit *hit = hit_iter->second;
315 new ((*(rec._arr.get()))[rec._cnt])
hit_type(hit);
318 dynamic_cast<hit_type *
>(rec._arr.get()->At(rec._cnt));
342 std::cout <<
"PHG4DSTReader::process_event - processing "
343 << rec._name <<
" and hit " << hit->
get_hit_id()
344 <<
" with track id " << hit->
get_trkid() << std::endl;
355 std::cout <<
"PHG4DSTReader::process_event - processing tower "
356 << rec._name << std::endl;
366 <<
"PHG4DSTReader::process_event - Error - can not find node "
367 << rec._name << std::endl;
376 std::cout <<
"PHG4DSTReader::process_event - processing "
377 << rec._name <<
" and received " << hits->
size()
378 <<
" tower hits" << std::endl;
382 hit_iter != hit_range.second; hit_iter++)
384 RawTower *hit_raw = hit_iter->second;
396 <<
"PHG4DSTReader::process_event - suppress low energy tower hit "
397 << rec._name <<
" @ ("
400 <<
"), Energy = " << hit->
get_energy() << std::endl;
411 <<
"PHG4DSTReader::process_event - processing Tower hit "
412 << rec._name <<
" @ ("
415 <<
"), Energy = " << hit->
get_energy() <<
" - "
416 << rec._arr.get()->At(rec._cnt)->ClassName() << std::endl;
451 std::cout <<
"PHG4DSTReader::process_event - processing jets "
452 << rec._name << std::endl;
455 JetContainer *hits = findNode::getClass<JetContainer>(topNode, rec._name);
461 <<
"PHG4DSTReader::process_event - Error - can not find node "
462 << rec._name << std::endl;
469 std::cout <<
"PHG4DSTReader::process_event - processing "
470 << rec._name <<
" and received " << hits->
size() <<
" jets"
475 for (
auto hit_raw : *hits)
481 std::cout <<
"PHG4DSTReader::process_event - processing jet "
482 << rec._name <<
" @ (" << hit_raw->get_eta() <<
", "
483 << hit_raw->get_phi() <<
"), pT = " << hit_raw->get_pt()
484 <<
" - with raw type " << hit_raw->ClassName() << std::endl;
494 dynamic_cast<PHPyJet_type *
>(rec._arr.get()->At(rec._cnt));
497 *new_hit = (
Jetv2) (*hit);
507 static bool once =
true;
511 <<
"PHG4DSTReader::process_event - will load all particle from G4TruthInfo"
517 for (
auto particle_iter : truthInfoList->
GetMap())
525 static bool once =
true;
530 std::cout <<
"PHG4DSTReader::process_event - will load primary particle from G4TruthInfo" << std::endl;
540 particle_iter != primary_range.second;
553 <<
"PHG4DSTReader::process_event - ERROR - can not find particle/track ID "
554 <<
i <<
" in G4TruthInfo" << std::endl;
565 static bool once =
true;
570 std::cout <<
"PHG4DSTReader::process_event - will load vertex from G4TruthInfo" << std::endl;
581 <<
"PHG4DSTReader::process_event - ERROR - can not find vertex ID "
582 <<
i <<
" in G4TruthInfo" << std::endl;
591 std::cout <<
"PHG4DSTReader::process_event - saving vertex id "
596 static_cast<vertex_type *
>(rec._arr.get()->At(rec._cnt));
658 std::cout <<
"PHG4DSTReader::End - Clean ups" << std::endl;
665 _T->ResetBranchAddresses();