Commit 5797f383 authored by Dominik Smith's avatar Dominik Smith
Browse files

CbmBuildEventsQA now supports detectors other than STS.

parent 7d0d69b6
...@@ -56,44 +56,57 @@ void CbmBuildEventsQA::Exec(Option_t*) { ...@@ -56,44 +56,57 @@ void CbmBuildEventsQA::Exec(Option_t*) {
<< ", links: " << event->GetMatch()->GetNofLinks() << ", links: " << event->GetMatch()->GetNofLinks()
<< ", matched MC event number " << mcEventNr; << ", 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(); nMCEvents += event->GetMatch()->GetNofLinks();
// --- Loop over STS digis // --- Loop over all detector systems
for (Int_t iDigi = 0; iDigi < nDigis; iDigi++) { for (ECbmModuleId& system : fSystems) {
UInt_t index = event->GetIndex(ECbmDataType::kStsDigi, iDigi);
const CbmStsDigi* digi = fDigiMan->Get<CbmStsDigi>(index); // --- Skip system if no data branch or no match match present
const CbmMatch* digiMatch = fDigiMan->GetMatch(ECbmModuleId::kSts, index); if (!fDigiMan->IsPresent(system)) continue;
assert(digi); if (!fDigiMan->IsMatchPresent(system)) continue;
assert(digiMatch);
// --- Counters
// --- Check MC event of digi match Int_t nDigis = event->GetNofData(GetDigiType(system));
if (digiMatch->GetMatchedLink().GetEntry() == mcEventNr) nDigiCorrect++; Int_t nDigiCorrect = 0;
Int_t nLinks = 0;
for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks(); iLink++) { Int_t nLinksCorrect = 0;
Int_t entry = digiMatch->GetLink(iLink).GetEntry();
nLinks++; //LOG(info) << GetName() << ": Detector "
if (entry == mcEventNr) nLinksCorrect++; // << CbmModuleList::GetModuleNameCaps(system)
} //# links in digi // << ", nDigis = " << nDigis;
} //# digis // --- Loop over digis
for (Int_t iDigi = 0; iDigi < nDigis; iDigi++) {
UInt_t index = event->GetIndex(GetDigiType(system), iDigi);
// --- QA output
LOG(info) << GetName() << ": correct digis " << nDigiCorrect << " / " const CbmMatch* digiMatch = fDigiMan->GetMatch(system, index);
<< nDigis << " = " assert(digiMatch);
<< 100. * Double_t(nDigiCorrect) / Double_t(nDigis)
<< " %, correct digi links " << nLinksCorrect << " / " << nLinks // --- Check MC event of digi match
<< " = " << 100. * Double_t(nLinksCorrect) / Double_t(nLinks) 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 } //# events
// Timer and counters // Timer and counters
fNofEntries++; fNofEntries++;
timer.Stop(); timer.Stop();
...@@ -158,39 +171,43 @@ void CbmBuildEventsQA::MatchEvent(CbmEvent* event) { ...@@ -158,39 +171,43 @@ void CbmBuildEventsQA::MatchEvent(CbmEvent* event) {
LOG(info) << "No match data found in event. Creating new."; LOG(info) << "No match data found in event. Creating new.";
match = new CbmMatch(); match = new CbmMatch();
event->SetMatch(match); 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() // LOG(info) << GetName() << ": Event " << event->GetNumber()
// << ", STS digis : " << event->GetNofData(ECbmDataType::kStsDigi); // << ", STS digis : " << event->GetNofData(ECbmDataType::kStsDigi);
// --- Loop over digis // --- Loop over all detector systems
for (Int_t iDigi = 0; for (ECbmModuleId& system : fSystems) {
iDigi < event->GetNofData(GetDigiType(ECbmModuleId::kSts));
iDigi++) { // --- Skip system if no data branch or no match match present
Int_t index = event->GetIndex(GetDigiType(ECbmModuleId::kSts), iDigi); if (!fDigiMan->IsPresent(system)) continue;
//const CbmStsDigi* digi = fDigiMan->Get<CbmStsDigi>(index); not needed ? if (!fDigiMan->IsMatchPresent(system)) continue;
const CbmMatch* digiMatch = fDigiMan->GetMatch(ECbmModuleId::kSts, index);
//assert(digi); //only use reference detector for matching to MC event
assert(digiMatch); if (system != fRefDetector) continue;
// --- Update event match with digi links // --- Loop over digis
// --- N.b.: The member "index" of CbmLink has here no meaning, since for (Int_t iDigi = 0; iDigi < event->GetNofData(GetDigiType(system));
// --- there is only one MC event per tree entry. iDigi++) {
for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks(); iLink++) { Int_t index = event->GetIndex(GetDigiType(system), iDigi);
Int_t file = digiMatch->GetLink(iLink).GetFile(); const CbmMatch* digiMatch = fDigiMan->GetMatch(system, index);
Int_t entry = digiMatch->GetLink(iLink).GetEntry(); assert(digiMatch);
Double_t weight = digiMatch->GetLink(iLink).GetWeight();
// LOG(info) << "Adding link (weight, entry, file): " << weight << " " // --- Update event match with digi links
// << entry << " " << file; // --- N.b.: The member "index" of CbmLink has here no meaning, since
match->AddLink(weight, 0, entry, file); // --- there is only one MC event per tree entry.
} //# links in digi for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks(); iLink++) {
Int_t file = digiMatch->GetLink(iLink).GetFile();
} //#digis 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
}
} }
// =========================================================================== // ===========================================================================
......
...@@ -52,6 +52,8 @@ private: ...@@ -52,6 +52,8 @@ private:
ECbmDataType GetDigiType(ECbmModuleId system); ECbmDataType GetDigiType(ECbmModuleId system);
ECbmModuleId fRefDetector = ECbmModuleId::kSts;
CbmBuildEventsQA(const CbmBuildEventsQA&); CbmBuildEventsQA(const CbmBuildEventsQA&);
CbmBuildEventsQA& operator=(const CbmBuildEventsQA&); CbmBuildEventsQA& operator=(const CbmBuildEventsQA&);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment