diff --git a/reco/eventbuilder/digis/CbmBuildEventsQA.cxx b/reco/eventbuilder/digis/CbmBuildEventsQA.cxx index 9c3457dec1685da8d3e4e1f74b5845580a531542..2f81f4bed1c0e9de921cb074d41415e14ea8a64b 100644 --- a/reco/eventbuilder/digis/CbmBuildEventsQA.cxx +++ b/reco/eventbuilder/digis/CbmBuildEventsQA.cxx @@ -56,44 +56,57 @@ void CbmBuildEventsQA::Exec(Option_t*) { << ", links: " << event->GetMatch()->GetNofLinks() << ", matched MC event number " << mcEventNr; - // --- Counters - Int_t nDigis = event->GetNofData(ECbmDataType::kStsDigi); - Int_t nDigiCorrect = 0; - Int_t nLinks = 0; - Int_t nLinksCorrect = 0; nMCEvents += event->GetMatch()->GetNofLinks(); - // --- Loop over STS digis - for (Int_t iDigi = 0; iDigi < nDigis; iDigi++) { - UInt_t index = event->GetIndex(ECbmDataType::kStsDigi, iDigi); - const CbmStsDigi* digi = fDigiMan->Get<CbmStsDigi>(index); - const CbmMatch* digiMatch = fDigiMan->GetMatch(ECbmModuleId::kSts, index); - assert(digi); - assert(digiMatch); - - // --- Check MC event of digi match - if (digiMatch->GetMatchedLink().GetEntry() == mcEventNr) nDigiCorrect++; - - for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks(); iLink++) { - Int_t entry = digiMatch->GetLink(iLink).GetEntry(); - nLinks++; - if (entry == mcEventNr) nLinksCorrect++; - } //# links in digi - - } //# digis - - - // --- QA output - LOG(info) << GetName() << ": correct digis " << nDigiCorrect << " / " - << nDigis << " = " - << 100. * Double_t(nDigiCorrect) / Double_t(nDigis) - << " %, correct digi links " << nLinksCorrect << " / " << nLinks - << " = " << 100. * Double_t(nLinksCorrect) / Double_t(nLinks) - << " % "; - + // --- Loop over all detector systems + for (ECbmModuleId& system : fSystems) { + + // --- Skip system if no data branch or no match match present + if (!fDigiMan->IsPresent(system)) continue; + if (!fDigiMan->IsMatchPresent(system)) continue; + + // --- Counters + Int_t nDigis = event->GetNofData(GetDigiType(system)); + Int_t nDigiCorrect = 0; + Int_t nLinks = 0; + Int_t nLinksCorrect = 0; + + //LOG(info) << GetName() << ": Detector " + // << CbmModuleList::GetModuleNameCaps(system) + // << ", nDigis = " << nDigis; + + // --- Loop over digis + for (Int_t iDigi = 0; iDigi < nDigis; iDigi++) { + UInt_t index = event->GetIndex(GetDigiType(system), iDigi); + + const CbmMatch* digiMatch = fDigiMan->GetMatch(system, index); + assert(digiMatch); + + // --- Check MC event of digi match + if (digiMatch->GetMatchedLink().GetEntry() == mcEventNr) nDigiCorrect++; + + //if (system == ECbmModuleId::kTof){ dev + // LOG(info) << "index = " <<index; + //} + + for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks(); iLink++) { + Int_t entry = digiMatch->GetLink(iLink).GetEntry(); + nLinks++; + if (entry == mcEventNr) nLinksCorrect++; + } //# links in digi + } //# digis + + // --- QA output + LOG(info) << GetName() << ": Detector " + << CbmModuleList::GetModuleNameCaps(system) + << ", correct digis " << nDigiCorrect << " / " << nDigis + << " = " << 100. * Double_t(nDigiCorrect) / Double_t(nDigis) + << " %, correct digi links " << nLinksCorrect << " / " << nLinks + << " = " << 100. * Double_t(nLinksCorrect) / Double_t(nLinks) + << " % "; + } } //# events - // Timer and counters fNofEntries++; timer.Stop(); @@ -158,39 +171,43 @@ void CbmBuildEventsQA::MatchEvent(CbmEvent* event) { LOG(info) << "No match data found in event. Creating new."; match = new CbmMatch(); event->SetMatch(match); + } else { + LOG(info) << "Match data found in event. Clearing."; + match->ClearLinks(); } - - //else{ - // LOG(info) << "Match data found in event. Clearing."; - // match->ClearLinks(); - // } //? event has no match - // LOG(info) << GetName() << ": Event " << event->GetNumber() // << ", STS digis : " << event->GetNofData(ECbmDataType::kStsDigi); - // --- Loop over digis - for (Int_t iDigi = 0; - iDigi < event->GetNofData(GetDigiType(ECbmModuleId::kSts)); - iDigi++) { - Int_t index = event->GetIndex(GetDigiType(ECbmModuleId::kSts), iDigi); - //const CbmStsDigi* digi = fDigiMan->Get<CbmStsDigi>(index); not needed ? - const CbmMatch* digiMatch = fDigiMan->GetMatch(ECbmModuleId::kSts, index); - //assert(digi); - assert(digiMatch); - - // --- Update event match with digi links - // --- N.b.: The member "index" of CbmLink has here no meaning, since - // --- there is only one MC event per tree entry. - for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks(); iLink++) { - Int_t file = digiMatch->GetLink(iLink).GetFile(); - Int_t entry = digiMatch->GetLink(iLink).GetEntry(); - Double_t weight = digiMatch->GetLink(iLink).GetWeight(); - // LOG(info) << "Adding link (weight, entry, file): " << weight << " " - // << entry << " " << file; - match->AddLink(weight, 0, entry, file); - } //# links in digi - - } //#digis + // --- Loop over all detector systems + for (ECbmModuleId& system : fSystems) { + + // --- Skip system if no data branch or no match match present + if (!fDigiMan->IsPresent(system)) continue; + if (!fDigiMan->IsMatchPresent(system)) continue; + + //only use reference detector for matching to MC event + if (system != fRefDetector) continue; + + // --- Loop over digis + for (Int_t iDigi = 0; iDigi < event->GetNofData(GetDigiType(system)); + iDigi++) { + Int_t index = event->GetIndex(GetDigiType(system), iDigi); + const CbmMatch* digiMatch = fDigiMan->GetMatch(system, index); + assert(digiMatch); + + // --- Update event match with digi links + // --- N.b.: The member "index" of CbmLink has here no meaning, since + // --- there is only one MC event per tree entry. + for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks(); iLink++) { + Int_t file = digiMatch->GetLink(iLink).GetFile(); + Int_t entry = digiMatch->GetLink(iLink).GetEntry(); + Double_t weight = digiMatch->GetLink(iLink).GetWeight(); + // LOG(info) << "Adding link (weight, entry, file): " << weight << " " + // << entry << " " << file; + match->AddLink(weight, 0, entry, file); + } //# links in digi + } //#digis + } } // =========================================================================== diff --git a/reco/eventbuilder/digis/CbmBuildEventsQA.h b/reco/eventbuilder/digis/CbmBuildEventsQA.h index 346d1afaa1a797104b4a13a85fe25de923664acf..e146f36142b2d806200e385abee42d18f5f9659e 100644 --- a/reco/eventbuilder/digis/CbmBuildEventsQA.h +++ b/reco/eventbuilder/digis/CbmBuildEventsQA.h @@ -52,6 +52,8 @@ private: ECbmDataType GetDigiType(ECbmModuleId system); + ECbmModuleId fRefDetector = ECbmModuleId::kSts; + CbmBuildEventsQA(const CbmBuildEventsQA&); CbmBuildEventsQA& operator=(const CbmBuildEventsQA&);