Skip to content
Snippets Groups Projects
Commit 8ea06885 authored by Sergey Gorbunov's avatar Sergey Gorbunov
Browse files

fix crashes in CbmKFParticleFinderQa when no MC data is presnt

parent c1e386b5
No related branches found
No related tags found
1 merge request!1954fix crashes in CbmKFParticleFinderQa when no MC data is present. #3439
Pipeline #31619 passed
......@@ -84,6 +84,8 @@ CbmKFParticleFinderQa::~CbmKFParticleFinderQa()
InitStatus CbmKFParticleFinderQa::Init()
{
fIsInitialized = false;
//Get ROOT Manager
FairRootManager* ioman = FairRootManager::Instance();
......@@ -92,6 +94,8 @@ InitStatus CbmKFParticleFinderQa::Init()
return kERROR;
}
fIsInitialized = false;
// check the mode
fLegacyEventMode = 0;
if (!ioman->CheckBranch("CbmEvent") && ioman->CheckBranch("MCTrack")) {
......@@ -100,10 +104,10 @@ InitStatus CbmKFParticleFinderQa::Init()
// MC Tracks
if (!fLegacyEventMode) {
FairRootManager* fManger = FairRootManager::Instance();
CbmMCDataManager* mcManager = (CbmMCDataManager*) fManger->GetObject("MCDataManager");
CbmMCDataManager* mcManager = (CbmMCDataManager*) ioman->GetObject("MCDataManager");
if (mcManager == nullptr) {
Error("CbmKFParticleFinderQa::Init", "MC Data Manager not found!");
return kSUCCESS;
}
fMCTrackArray = mcManager->InitBranch("MCTrack");
......@@ -126,13 +130,17 @@ InitStatus CbmKFParticleFinderQa::Init()
}
else {
fMCTrackArrayEvent = (TClonesArray*) ioman->GetObject("MCTrack");
if (fMCTrackArrayEvent == nullptr) {
Error("CbmKFParticleFinderQa::Init", "mc track array not found!");
return kSUCCESS;
}
}
// Track match
fTrackMatchArray = (TClonesArray*) ioman->GetObject("StsTrackMatch");
if (fTrackMatchArray == nullptr) {
Error("CbmKFParticleFinderQa::Init", "track match array not found!");
return kERROR;
return kSUCCESS;
}
if (fSaveParticles) {
......@@ -151,11 +159,18 @@ InitStatus CbmKFParticleFinderQa::Init()
ioman->Register("KFParticleMatch", "KFParticle", fMatchParticles, IsOutputBranchPersistent("KFParticleMatch"));
}
fIsInitialized = true;
return kSUCCESS;
}
void CbmKFParticleFinderQa::Exec(Option_t* /*opt*/)
{
if (!fIsInitialized) {
LOG(warning) << GetName() << " The task can not run! Some data is missing.";
return;
}
if (fSuperEventAnalysis) {
LOG(error) << GetName() << " SuperEventAnalysis option currently doesn't work";
return;
......@@ -169,20 +184,23 @@ void CbmKFParticleFinderQa::Exec(Option_t* /*opt*/)
fMatchParticles->Delete();
}
if (!fMcEventList) {
return;
}
// make sure that the number of events in time slice is 1
int nRecoEvents = 1;
int nMCEvents = 1;
if (!fLegacyEventMode) {
if (fRecoEvents) {
nRecoEvents = fRecoEvents->GetEntriesFast();
}
nMCEvents = fMcEventList->GetNofEvents();
nRecoEvents = (fRecoEvents) ? fRecoEvents->GetEntriesFast() : 0;
nMCEvents = (fMcEventList) ? fMcEventList->GetNofEvents() : 0;
}
if (nMCEvents != 1 || nRecoEvents != 1) {
LOG(warning) << GetName() << " the task doesn't properly work with more than one event in the time slice";
LOG(warning) << GetName() << " The task currently doesn't work with more than one event in the time slice";
return;
}
vector<KFMCTrack> mcTracks;
......
......@@ -57,6 +57,11 @@ class CbmKFParticleFinderQa : public FairTask {
void FitDecayQAHistograms(float sigma[14], const bool saveReferenceResults = false) const;
void CheckDecayQA();
// Data members -----------------------
bool fIsInitialized{false}; // flag for initialization
//input branches
TClonesArray* fRecoEvents{nullptr}; //! Array of CbmEvent objects
CbmMCDataArray* fMCTrackArray{nullptr}; //mc tracks
......
  • Reporter

    Please check https://redmine.cbm.gsi.de/issues/3439 The code runs without problems, but only for event-by-event reconstruction with MC the histograms are filled

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment