Histograms and multithreaded programs

Hello!

Are the TH histogram classes thread safe? I’m thinking about a threaded program like this (just using root as libraries for c++):

#pragma omp parallel for firstprivate (localdata)
    for(int i=0; i<entries; i++){ // entryloop start
#pragma omp critical 
      { 
        chain->GetEntry(i);
        localdata.setData(*data); // makes a copy of the data
      }

     histogram->Fill(localdata.GetCharge());
    } // entryloop end

My main concern is that I might run into some hard to debug race conditions…

Thanks in advance!

Apparently the histograms are not thread safe so I implemented a non blocking OpenMP capable wrapper. In case anyone wants to do something similar I’ll attach the codes to this post.
OMPwrappers_template_defintions.cc (1.05 KB)
OMPwrappers.cc (2.11 KB)
OMPwrappers.hh (3.95 KB)

I found some bugs in the files posted above, so please find a corrected version here
histogramwrappers.tar.gz (1.95 KB)