Commit 863d70ed authored by Dominik Smith's avatar Dominik Smith
Browse files

CbmBuildEventsQA: Instead of a single detector a list of reference detectors...

CbmBuildEventsQA: Instead of a single detector a list of reference detectors can now be used to match raw events to MC events.
parent ee1492c7
......@@ -305,6 +305,7 @@ void run_reco(TString input = "",
}
// ------------------------------------------------------------------------
/*
// ----- Local reconstruction in MVD ----------------------------------
if (useMvd) {
......@@ -496,6 +497,7 @@ void run_reco(TString input = "",
} //? time-based reco
*/
// ----- Parameter database --------------------------------------------
std::cout << std::endl << std::endl;
std::cout << "-I- " << myName << ": Set runtime DB" << std::endl;
......
......@@ -34,8 +34,51 @@ CbmBuildEventsQA::~CbmBuildEventsQA() {}
// ===========================================================================
// ===== Task initialisation =============================================
InitStatus CbmBuildEventsQA::Init() {
// --- Get FairRootManager instance
FairRootManager* ioman = FairRootManager::Instance();
assert(ioman);
// --- Get input array (CbmEvent)
fEvents = dynamic_cast<TClonesArray*>(ioman->GetObject("CbmEvent"));
if (nullptr == fEvents) {
LOG(fatal) << "CbmBuildEventsQA::Init"
<< "No CbmEvent TClonesArray found!";
}
// --- DigiManager instance
fDigiMan = CbmDigiManager::Instance();
fDigiMan->Init();
// --- Check input data
for (ECbmModuleId system = ECbmModuleId::kMvd;
system < ECbmModuleId::kNofSystems;
++system) {
if (fDigiMan->IsMatchPresent(system)) {
LOG(info) << GetName() << ": Found match branch for "
<< CbmModuleList::GetModuleNameCaps(system);
fSystems.push_back(system);
}
}
if (fSystems.empty()) {
LOG(fatal) << GetName() << ": No match branch found!";
return kFATAL;
}
return kSUCCESS;
}
// ===========================================================================
// ===== Task execution ==================================================
void CbmBuildEventsQA::Exec(Option_t*) {
void CbmBuildEventsQA::Exec(Option_t*) { SurveyEvents(); }
// ===========================================================================
// ===== Event survey ====================================================
void CbmBuildEventsQA::SurveyEvents() {
// --- Time and counters
TStopwatch timer;
......@@ -126,50 +169,9 @@ void CbmBuildEventsQA::Exec(Option_t*) {
// ===========================================================================
// ===== Task initialisation =============================================
InitStatus CbmBuildEventsQA::Init() {
// --- Get FairRootManager instance
FairRootManager* ioman = FairRootManager::Instance();
assert(ioman);
// --- Get input array (CbmEvent)
fEvents = dynamic_cast<TClonesArray*>(ioman->GetObject("CbmEvent"));
if (nullptr == fEvents) {
LOG(fatal) << "CbmBuildEventsQA::Init"
<< "No CbmEvent TClonesArray found!";
}
// --- DigiManager instance
fDigiMan = CbmDigiManager::Instance();
fDigiMan->Init();
// --- Check input data
for (ECbmModuleId system = ECbmModuleId::kMvd;
system < ECbmModuleId::kNofSystems;
++system) {
if (fDigiMan->IsMatchPresent(system)) {
LOG(info) << GetName() << ": Found match branch for "
<< CbmModuleList::GetModuleNameCaps(system);
fSystems.push_back(system);
}
}
if (fSystems.empty()) {
LOG(fatal) << GetName() << ": No match branch found!";
return kFATAL;
}
return kSUCCESS;
}
// ===========================================================================
// ===== Match event =====================================================
void CbmBuildEventsQA::MatchEvent(CbmEvent* event) {
// TODO: This functionality should later be moved to the class
// CbmMatchRecoToMC
// --- Get event match object. If present, will be cleared first. If not,
// --- it will be created.
CbmMatch* match = event->GetMatch();
......@@ -184,25 +186,36 @@ void CbmBuildEventsQA::MatchEvent(CbmEvent* event) {
// LOG(info) << GetName() << ": Event " << event->GetNumber()
// << ", STS digis : " << event->GetNofData(ECbmDataType::kStsDigi);
// --- Loop over digis
Int_t iNbDigis = event->GetNofData(GetDigiType(fRefDetector));
for (Int_t iDigi = 0; iDigi < iNbDigis; iDigi++) {
Int_t index = event->GetIndex(GetDigiType(fRefDetector), iDigi);
const CbmMatch* digiMatch = fDigiMan->GetMatch(fRefDetector, 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
// --- Loop over all detector systems
for (ECbmModuleId& system : fSystems) {
//Skip if reference detectors exist and current system isn't one
if (!fRefDetectors.empty()
&& std::find(fRefDetectors.begin(), fRefDetectors.end(), system)
== fRefDetectors.end()) {
continue;
}
// --- Loop over digis in event
Int_t iNbDigis = event->GetNofData(GetDigiType(system));
for (Int_t iDigi = 0; iDigi < iNbDigis; 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
}
}
// ===========================================================================
......
......@@ -34,6 +34,10 @@ public:
/** Task execution **/
virtual void Exec(Option_t* opt);
/** Add a reference detector **/
void AddRefDetector(ECbmModuleId RefDetector) {
fRefDetectors.push_back(RefDetector);
}
private:
CbmDigiManager* fDigiMan = nullptr; //!
......@@ -50,9 +54,12 @@ private:
**/
void MatchEvent(CbmEvent* event);
/** Check if digis in reco events belong to correct MC event **/
void SurveyEvents();
ECbmDataType GetDigiType(ECbmModuleId system);
ECbmModuleId fRefDetector = ECbmModuleId::kSts;
std::vector<ECbmModuleId> fRefDetectors; // Detectors used for MC matching
CbmBuildEventsQA(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