35 template<
class Map>
void printMap(
const Map&
m) {
36 std::cout<<
"printMap(): [";
37 for (
typename Map::const_iterator
i=
m.begin();
i!=
m.end(); ++
i) {
38 std::cout<<
"("<<
i->first<<
","<<
i->second<<
"), ";
40 std::cout<<
"]"<<std::endl;
47 SubDetPRDs& operator+=(SubDetPRDs&
a,
const SubDetPRDs&
b) {
49 const std::set<Identifier>& bset =
b.subDetHits[
i];
50 for (std::set<Identifier>::const_iterator
pb=bset.begin();
pb!=bset.end(); ++
pb) {
51 a.subDetHits[
i].insert(*
pb);
66 class Sprout :
public std::list<HepMC::ConstGenParticlePtr> {
87 return StatusCode::SUCCESS;
94 const std::vector<const PRD_MultiTruthCollection*>& prdTruth,
95 const EventContext& ctx)
const
97 ATH_MSG_VERBOSE(
"DetailedTrackTruthBuilder::buildDetailedTrackTruth() ");
109 if (!(prdTruthColl)->
empty()) {
115 orderedPRD_Truth[subdet] = prdTruthColl;
131 for (
unsigned itrack=0; itrack<tracks.
size(); ++itrack) {
139 " Entries with TruthTrajectories of more then one particle shown at the DEBUG level.\n"
140 " Use VERBOSE level for complete dump.");
142 for (DetailedTrackTruthCollection::const_iterator
i=
output->begin();
i!=
output->end(); ++
i) {
143 bool interesting = (
i->second.trajectory().size() > 1);
146 <<
"out: trk="<<
i->first.index()<<
" => "<<
i->second<<
endmsg;
151 for (
unsigned k=0;
k<
t.size(); ++
k) {
195 class ExtendedEventIndex {
202 m_eventIndex =
source.getEventPositionInCollection(
proxy);
219 const std::vector<const PRD_MultiTruthCollection*>& orderedPRD_Truth,
221 const EventContext& ctx
225 std::map<HepMcParticleLink,SubDetPRDs> pairStat;
250 if (orderedPRD_Truth[subdet]) {
254 using iprdt = PRD_MultiTruthCollection::const_iterator;
255 std::pair<iprdt, iprdt>
range = orderedPRD_Truth[subdet]->equal_range(
id);
261 if (!pa) {
continue; }
263 if (!
i->second.isValid()) {
264 ATH_MSG_WARNING(
"Unexpected invalid HepMcParticleLink in PRD_MultiTruthCollection");
267 pairStat[
i->second].subDetHits[subdet].insert(
id);
269 ATH_MSG_VERBOSE(
"PRD-ID:"<<
id<<
" subdet:"<<subdet<<
" number:"<<
n<<
" particle link:"<<
i->second);
273 ATH_MSG_VERBOSE(
"--> no link, noise ? PRD-ID:"<<
id<<
" subdet:"<<subdet);
290 for (std::map<HepMcParticleLink,SubDetPRDs>::const_iterator
i=pairStat.begin();
i!=pairStat.end(); ++
i) {
300 std::set<HepMcParticleLink> seeds;
301 for (std::map<HepMcParticleLink,SubDetPRDs>::const_iterator
i=pairStat.begin();
i!=pairStat.end(); ++
i) {
302 if (
i->first.isValid()) {
303 seeds.insert(
i->first);
309 traj.push_back(
i->first);
310 ATH_MSG_VERBOSE(
"addTrack(): add id 0 hits (noise ?) to DetailedTrackTruthCollection.");
327 using SproutMap = std::map<HepMcParticleLink, Sprout>;
329 while (!seeds.empty()) {
331 Sprout current_sprout;
332 std::queue<HepMC::ConstGenParticlePtr>
tmp;
340 seeds.erase(curlink);
344 if (p_old != sprouts.end()) {
346 current_sprout.splice(current_sprout.end(), p_old->second);
347 current_sprout.stat += p_old->second.stat;
349 sprouts.erase(p_old);
358 current_sprout.push_back(
current);
361 if (p_newstat != pairStat.end()) {
362 current_sprout.stat += p_newstat->second;
369 sprouts.insert(std::make_pair(link, current_sprout));
398 for (Sprout::const_iterator ppart=
s->second.begin(); ppart!=
s->second.end(); ++ppart) {
408 makeSubDetHitStatistics(
s->second.stat),
422 for (
const auto&
i : rec2truth ) {
425 auto pa =
i.second.cptr();
426 if ( !pa ) {
continue; }
428 result.insert(std::make_pair(
i.second,
i.first));
441 for (TruthTrajectory::const_iterator
p = traj.begin();
p != traj.end(); ++
p) {
447 ATH_MSG_WARNING(
"HepMcParticleLink " << *
p <<
" in truth trajectory does not point to a valid GenParticle.");
451 using iter = PRD_InverseTruth::const_iterator;
452 std::pair<iter,iter>
range = inverseTruth.equal_range(*
p);
460 return makeSubDetHitStatistics(prds);