Std error when filling a histogram

Hello! I have the following piece of code (I put just a part of it)

  map< ObjectType, TH1F*> hisNumSeedCombinations_;

  if (settings_->useSeedFilter()) {
    hisNumSeedCombinations_.insert( pair< ObjectType, TH1F* > (HTrphiHis, dirs_.at(HTrphiHis).make<TH1F>("NumSeedCombinations_","; Number of seed combinations per track cand ", 50, -0.5 , 49.5)));
  }

   if (settings_->useSeedFilter()) {
       const vector<unsigned int>  numSeedComb = htPair.getRZfilters().numSeedCombsPerTrk();
       for (const unsigned int& num : numSeedComb) {
              hisNumSeedCombinations_.at(RZfilters)->Fill(num);
        }                    
   }

It compiles fine but when I run I get this

Exception Message:
A std::exception was thrown.
map::at

I figured out that it happens when I fill the histogram, but I don’t know why. Can somebody help me? Thank you!

Hi,
the error message is pretty clear, your std::map hisNumSeedCombinations_ does not have an element with the key you are using in the at method call, i.e. hisNumSeedCombinations_[RZfilters] does not exist, and the program throws an exception as a consequence.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.