9#include "FairRootManager.h"
22 new TH1F(
"fhLinkedMCEventsPerTrigger",
"Linked MC events per trigger (=0 for pure noise)", 5, -1.5, 3.5);
31 fhCorrectDigiRatio =
new TH1F(
"fhCorrectDigiRatio",
"Correct digis per seed [pct]", 416, -2, 102);
33 new TH1F(
"fhCorrectDigiRatioNoNoise",
"Correct digis per seed [pct], disregarding noise", 416, -2, 102);
34 fhNoiseDigiRatio =
new TH1F(
"fhNoiseDigiRatio",
"Noise digis per seed [pct]", 416, -2, 102);
35 fhFoundDigiRatio =
new TH1F(
"fhFoundDigiRatio",
"Found digis per seed [pct]", 416, -2, 102);
36 fhCorrectVsFound =
new TH2I(
"fhCorrectVsFound",
"Correct digis [pct] vs. Found digis [pct]; Correct; Found ", 110,
37 -5., 105., 110, -5., 105.);
39 new TH2I(
"fhCorrectVsFoundNoNoise",
"Correct digis [pct] vs. Found digis [pct], no noise; Correct; Found ", 110,
40 -5., 105., 110, -5., 105.);
42 fhTimeOffset =
new TH1F(
"fhTimeOffsetMatched",
"tSeed - tMCMatched [ns]", 20, -5, 5);
45 fhTimeOffsetSingletOnly =
new TH1F(
"fhTimeOffsetSingletOnly",
"tSeed - tMCMatched [ns], one-to-one only", 20, -5, 5);
48 fhTimeOffsetClosest =
new TH1F(
"fhTimeOffsetClosest",
"tSeed - tMCClosest [ns]", 20, -5, 5);
87 if (!FairRootManager::Instance() || !FairRootManager::Instance()->GetObject(
"MCEventList.")) {
88 LOG(error) <<
"No MC event list found";
101 const std::vector<CbmMatch>* vDigiMatch,
const double seedTime)
106 int32_t digiCount = 0;
107 int32_t noiseDigiCount = 0;
108 int32_t correctDigiCount = 0;
109 int32_t matchedEventDigiCount = 0;
112 for (int32_t iDigi = WinStart; iDigi <= WinEnd; iDigi++) {
113 const CbmMatch* digiMatch = &(vDigiMatch->at(iDigi));
126 for (int32_t iLink = 0; iLink < digiMatch->
GetNofLinks(); iLink++) {
133 const double weight =
137 seedMatch.
AddLink(weight, 0, entry, file);
146 seedMatch.
AddLink(1.0, 0, -1, 0);
154 fvTimeOffset.push_back(std::numeric_limits<double>::quiet_NaN());
163 for (int32_t iDigi = WinStart; iDigi <= WinEnd; iDigi++) {
164 const CbmMatch* digiMatch = &(vDigiMatch->at(iDigi));
176 const double correctDigiRatio = (double) correctDigiCount / digiCount;
179 const double correctDigiRatioNoNoise = (double) correctDigiCount / (digiCount - noiseDigiCount);
183 for (uint32_t iDigi = 0; iDigi < vDigiMatch->size(); iDigi++) {
184 const CbmMatch* digiMatch = &(vDigiMatch->at(iDigi));
190 matchedEventDigiCount++;
193 const double foundDigiRatio = (double) correctDigiCount / matchedEventDigiCount;
209 std::vector<uint32_t> vLinkedTriggersPerMCEvent;
210 std::vector<uint32_t> vMatchedTriggersPerMCEvent;
211 vLinkedTriggersPerMCEvent.resize(nEvents, 0);
212 vMatchedTriggersPerMCEvent.resize(nEvents, 0);
221 for (int32_t iLink = 0; iLink < eventMatch.
GetNofLinks(); iLink++) {
242 for (
const auto& value : vLinkedTriggersPerMCEvent) {
245 for (
const auto& value : vMatchedTriggersPerMCEvent) {
250 std::vector<double> vMCEventTimes;
251 for (uint32_t iEvent = 0; iEvent < nEvents; iEvent++) {
254 std::sort(std::begin(vMCEventTimes), std::end(vMCEventTimes));
257 auto minElem = vMCEventTimes.begin();
259 auto comp = [&, seedTime](
double val1,
double val2) {
return fabs(seedTime -
val1) < fabs(seedTime -
val2); };
260 minElem = std::min_element(minElem, vMCEventTimes.end(), comp);
267 for (uint32_t iEvent = 0; iEvent <
fvEventMatches.size(); iEvent++) {
280 const double noiseDigisPercent = 100. * (double) noiseCount / digiCount;
295 for (uint32_t iEvent = 0; iEvent <
fvEventMatches.size(); iEvent++) {
299 std::cout <<
"QA for seed # " << iEvent << std::endl;
301 std::cout <<
"Links to MC events: " << match->
GetNofLinks() <<
", matched MC event number " << mcEventNr
303 if (mcEventNr == -1) {
304 std::cout <<
"Warning: Seed was constructed from noise digis only (MC event = -1)!" << std::endl;
305 std::cout <<
" Please increase your noise threshold!" << std::endl;
307 std::cout <<
"Total digis in seed window: " <<
fvFullDigiCount.at(iEvent);
308 std::cout <<
", Noise digis in seed window: " <<
fvNoiseDigiCount.at(iEvent) << std::endl;
309 std::cout <<
"Fraction of correctly matched digis in seed window: " <<
fvCorrectDigiRatio.at(iEvent) << std::endl;
310 std::cout <<
"Fraction of correctly matched digis in seed window (disregarding noise): "
312 std::cout <<
"Fraction of digis of matched event found in seed window: " <<
fvFoundDigiRatio.at(iEvent);
313 std::cout <<
" (only from this timeslice)" << std::endl;
357 FairSink* sink = FairRootManager::Instance()->GetSink();
Definition of the CbmQaCanvas class.
Class for sliding window seed finder.
Container class for MC events with number, file and start time.
double GetEventTimeByIndex(uint32_t index)
Event time by index @value Event time for event at given index in list.
Int_t GetEventIndex(UInt_t event, UInt_t file)
Event index.
std::size_t GetNofEvents() const
Number of events in the list @value Number of events.
double GetEventTime(uint32_t event, uint32_t file)
Event start time.
const CbmLink & GetLink(int32_t i) const
int32_t GetNofLinks() const
void AddLink(const CbmLink &newLink)
const CbmLink & GetMatchedLink() const
void Divide2D(int nPads)
Divide canvas into nPads in 2D in a nice way.
void FillQaSeedInfo(const int32_t WinStart, const int32_t WinEnd, const std::vector< CbmMatch > *vDigiMatch, const double seedTime)
Gather QA Information. @params WinStart Starting position of seed window. @params WinStart End positi...
std::vector< double > fvCorrectDigiRatio
Ratio of digis from matched MC event.
std::vector< uint32_t > fvLinkedMCEventsCount
Counts how many MC events contributed to a seed.
void Init()
Initialize communication with FairRootManager (needed for MC events).
TH2I * fhCorrectVsFound
digis found per event
void FillHistos()
Fill output histograms with data from current timeslice.
TH1F * fhFoundDigiRatio
noise digis per event
CbmQaCanvas * fCanv
difference between true event time and seed time for one-to-one matched cases
void WriteHistos()
Finalize histograms and canvases and write to file.
void OutputQa()
Output QA Information.
TH1F * fhTimeOffset
correct digis per event vs found digis per event, disregarding noise
std::vector< double > fvCorrectDigiRatioNoNoise
Ratio of digis from matched MC event (disregarding noise).
TH1F * fhNoiseDigiRatio
correct digis per event, disregarding noise
TFolder fOutFolder
subfolder for histograms
CbmSeedFinderQa()
Create the CbmSeedFinderQa object.
std::vector< double > fvSeedTimesFull
Full vector of all event seeds that is not cleared at the end of a timeslice.
TH1F * fhTimeOffsetClosest
difference between true event time and seed time
TH1F * fhCorrectDigiRatioNoNoise
correct digis per event
std::vector< int32_t > fvNoiseDigiCount
Counts how many noise digis contributed to a seed.
TH1F * fhCorrectDigiRatio
linked MC events per trigger
std::vector< CbmMatch > fvEventMatchesPerTs
Matches that link constructed event seeds to MC events, current timeslice only.
void ResetPerTsStorage()
Reset containers that are persistent for one TS.
std::vector< double > fvTimeOffset
Difference between true event time and seed time.
std::vector< double > fvSeedTimesPerTs
Vector of event seeds, current TS only.
TH1F * fhMatchedTriggersPerMCEvent
linked triggers per MC event
CbmMCEventList * fEventList
summary canvas
std::vector< CbmMatch > fvEventMatches
Matches that link constructed event seeds to MC events.
TH1F * fhTimeOffsetSingletOnly
difference between seed time and closest MC event time
~CbmSeedFinderQa()
Destructor.
std::vector< int32_t > fvFullDigiCount
Counts how many digis contributed to a seed.
TH1F * fhLinkedMCEventsPerTrigger
matchted triggers per MC event
TH1F * fhLinkedTriggersPerMCEvent
output folder with histos and canvases
void FillQaMCInfo()
Fill QA Information that uses the full list of MC events per TS.
std::vector< double > fvFoundDigiRatio
Ratio of digis of matched events that were included in event seed.
TH2I * fhCorrectVsFoundNoNoise
correct digis per event vs found digis per event