8 #include <FairLogger.h>
9 #include <FairRootManager.h>
17 : FairTask(
"AtFissionTask"), fFissionEventArray(
"AtFissionEvent", 1), fLambda(lambda)
23 FairRootManager *ioMan = FairRootManager::Instance();
24 if (ioMan ==
nullptr) {
25 LOG(fatal) <<
"Cannot find RootManager!";
31 LOG(fatal) <<
"Cannot find AtPatternEvent array in branch " <<
fPatternBranch <<
"!";
36 LOG(fatal) <<
"Cannot find AtPatternEvent array in branch " <<
fEventBranch <<
"!";
50 auto beamHits =
event->GetBeamHitsCorr();
51 std::sort(beamHits.begin(), beamHits.end(),
52 [](
const AtHit *a,
const AtHit *b) { return a->GetHitID() < b->GetHitID(); });
58 auto hits =
event->GetFragHitsCorr(fragID);
59 std::sort(hits.begin(), hits.end(), [](
const AtHit *a,
const AtHit *b) { return a->GetHitID() < b->GetHitID(); });
67 if (fissionEvent ==
nullptr) {
68 LOG(fatal) <<
"Failed to create or load a fission event in the branch.";
73 if (patternEvent ==
nullptr) {
74 LOG(fatal) <<
"Failed to load an AtPatternEvent in the branch.";
79 if (event ==
nullptr) {
80 LOG(fatal) <<
"Failed to load an AtEvent in the branch.";
91 fissionEvent->SetLambda(
fLambda);
94 event->SortHitArrayID();
95 auto &uncorrHits =
event->GetHits();
99 fissionEvent->SetBeamHits(std::move(clonedHits));
102 for (
int i = 0; i < 2; ++i) {
104 fissionEvent->SetFragHits(i, std::move(clonedHits));
107 LOG(error) <<
"Failed to create a fission event for event " <<
event->GetEventID();
114 auto lastHit = hitsToClone.begin();
116 for (
auto hit : hitsToFind) {
117 auto hitIt = std::find_if(lastHit, hitsToClone.end(), [hit](
const std::unique_ptr<AtHit> &hit2) {
118 return hit->GetHitID() == hit2->GetHitID();
121 if (hitIt == hitsToClone.end())
124 ret.push_back(hitIt->get()->Clone());