92{
93
94 string subdir;
95 for (map<string, map<string, map<int, TH1*>>>::iterator is =
96 m_subdir.begin(); is != m_subdir.end(); ++is) {
97 map<string, map<int, TH1*>>& dirlist = is->second;
98 map<string, TH1*>& mergelist = m_mergedir[is->first];
99
100
101 if (m_memfile->GetMemFile() == NULL) exit(-99);
102 (m_memfile->GetMemFile())->cd();
103
104 subdir = is->first;
105
106
107
108
109
110
111
112
113
114
115 for (map<string, std::map<int, TH1*> >::iterator it = dirlist.begin();
116 it != dirlist.end(); ++it) {
117 string name = it->first;
118 map<int, TH1*>& hmap = it->second;
119 if (mergelist[name] != NULL) {
120 TH1* merge_hist = mergelist[name];
121 merge_hist->Reset();
122
123 }
124
125 for (map<int, TH1*>::iterator ih = hmap.begin(); ih != hmap.end();
126 ++ih) {
127
128 TH1* hist = ih->second;
129
130
131
132 if (mergelist[name] == NULL) {
133
134
135 string newname;
136 if (subdir != "")
137 newname = subdir + "/" + string(hist->GetName());
138 else
139 newname = string(hist->GetName());
140 hist->SetName(newname.c_str());
141 TH1* mhist = (TH1*)hist->Clone();
142 mergelist[name] = mhist;
143
144
145
146 }
147
148 else {
149 TH1* merge_hist = mergelist[name];
150 merge_hist->Add(hist);
151 merge_hist->SetTitle(hist->GetTitle());
152 }
153 }
154 }
155 }
156
157 m_memfile->UpdateSharedMem();
158
159
160
161 return true;
162}