Skip to content

Commit

Permalink
Fix missing return statement, add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jdbrice committed Dec 18, 2023
1 parent f1db5e8 commit 484fec8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions StRoot/StFwdUtils/StFwdAnalysisMaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,41 @@ class StFwdAnalysisMaker : public StMaker

protected:

/**
* @brief Map of <name (TString), histogram>
*
*/
std::map<TString, TH1*> mHists;

/**
* @brief Add a histogram to the map
*
* Convenience method to avoid duplicate typing name / possible mismatch
* @param h1 TH1* histogram object
* @return TH1* return the same object for ease of use
*/
TH1 * addHist( TH1 * h1){
mHists[h1->GetName()] = h1;
return h1;
}

/**
* @brief Get the Hist object from the map
* - Additional check and safety for missing histograms
* @param n Histogram name
* @return TH1* histogram if found, otherwise a 'nil' histogram with one bin
*/
TH1* getHist( TString n ){
if (mHists.count(n))
return mHists[n];
LOG_ERROR << "Attempting to access non-existing histogram" << endm;
return new TH1F( "NULL", "NULL", 1, 0, 1 ); // returning nullptr can lead to seg fault, this fails softly
}

/**
* @brief Control whether the analysis uses StEvent (default) or MuDst as input
*
*/
bool mAnalyzeMuDst = false;

ClassDef(StFwdAnalysisMaker, 0);
Expand Down

0 comments on commit 484fec8

Please sign in to comment.