Fill map with PROOF


I am working with PROOF to read TTree, but I have bumped in to some problems. By parallel running my code in the process() the map is filled with the same key with different value, even though it should have an unique key with different values.

std::map< int,vector<double> > mymap;

int is the key and the vector holds the values.
It makes sense that it can’t hold unique key, when the events is run parallel.
A simple version of my code:

class Selector : public TSelector {
public :
	std::map< int,vector<double> > LYZ_Parameter_Q;
    	std::map< int,vector<double> > LYZ_Parameter_M;
    	:t(0),  // For tree
      { }
    virtual void Init(TTree* tree);
    virtual void Begin(TTree *tree);
    virtual void SlaveBegin(TTree*);
    virtual bool Process(Long64_t entry);
    virtual void Terminate(void);
    virtual int Version() const { return 2; }
    virtual Bool_t SetTree(TTree* tree);


void Selector::Begin(TTree *tree){    

void Selector::SlaveBegin(TTree* tree){
    v2_LYZ = new TH2F("v2_LYZ", "v_{2} Distribution", 100, 0, 150, 100, 0, 0.5);
    std::map< int,vector<double> > LYZ_Parameter_Q;
    std::map< int,vector<double> > LYZ_Parameter_M;
bool Selector::Process(Long64_t entry )
  	// Maps are filled for each event. 
 	map< int,vector<double> > LYZ_Parameter_Q
 	map< int,vector<double> > *LYZ_Parameter_M
 	int MapParameter; // Is an integer
 	vector<double> QContainer;
   	 vector<double> MContainer;
   	 if ( LYZ_Parameter_Q.find(MapParameter) == LYZ_Parameter_Q.end()){
       		LYZ_Parameter_Q[MapParameter] =  QContainer;
        	LYZ_Parameter_M[MapParameter] =  MContainer;
    else {


void Selector::SlaveTerminate(){
	LYZ(LYZ_Parameter_Q, LYZ_Parameter_M, v2_LYZ ); // This function analyse all the map entries

void Selector::Terminate()
    	TFile* output = TFile::Open("output.root","RECREATE");
    	v2_LYZ->Write(); // A histrogram is saved 

The problem could be solved by reading the map in the Terminate() even though it don’t have unique keys. I have tried to read the map in the Terminate part, but it couldn’t read it there…

Is there any way to read maps in the Terminate() ?


I found out that I can use TParameter to wrap std::map< int,vector<double> > mymap and access it in the Terminate(). Does anyone knows how to do it?