Skip to content
Snippets Groups Projects

fix crashes in CbmKFParticleFinderQa when no MC data is present. #3439

Merged Sergey Gorbunov requested to merge se.gorbunov/cbmroot:KfParticleQA into master
All threads resolved!
2 files
+ 31
8
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -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;
Loading