213 unsigned int size = 0;
216 int evtIndex = 0, runIndex = 0;
217 std::map<std::pair<int, int>,
int> evtMap;
218 std::map<int, int> runMap;
219 std::map< std::pair<const PersistentAccessor*, int>,
int > evtAccMap;
221 cout <<
"Merging runs" << endl;
224 cout <<
"Cannot merge: one of the inputs is null!" << endl;
228 for (
unsigned int i = 0; i < accessor->nRuns(); i++) {
229 int run = accessor->runData(i)->run();
230 if (runMap.find(
run) != runMap.end())
continue;
231 runMap[
run] = runIndex;
239 cout <<
"Merging events" << endl;
240 unsigned int nEventsTotal = 0, iEvt = 0;
242 nEventsTotal += accessor->nEvents();
245 for (
unsigned int i = 0; i < accessor->nEvents(); i++) {
247 if (iEvt % 100000 == 0) cout <<
"Merging event " << iEvt <<
"/" << nEventsTotal << endl;
248 std::pair<int, int> evtId(accessor->eventData(i)->run(), accessor->eventData(i)->event());
249 std::pair<const PersistentAccessor*, int> evtAccId(accessor, i);
250 if (evtMap.find(evtId) != evtMap.end()) {
251 cout <<
"ERROR: Skipping duplicate entry for run " << accessor->eventData(i)->run() <<
", event " << accessor->eventData(i)->event() << endl;
254 evtAccMap[evtAccId] = evtIndex;
255 evtMap[evtId] = evtIndex;
256 std::map<int, int>::const_iterator idx = runMap.find(accessor->eventData(i)->run());
257 int newRunIndex = (idx == runMap.end() ? -999 : idx->second);
266 cout <<
"Merging cells" << endl;
268 if (i % 10000 == 0) {
269 cout <<
"Merging channel " << i <<
"/" <<
Definitions::nChannels <<
" (current size = " << size <<
")" << endl;
275 if (!history || !history->
isValid())
continue;
282 std::map<std::pair<const PersistentAccessor*, int>,
int>
::const_iterator newIndex
284 if (newIndex == evtAccMap.end()) cout <<
"Event not found for cell " << i <<
", data " << j <<
"." << endl;
285 newDC->
setEventIndex(newIndex != evtAccMap.end() ? newIndex->second : -1);
286 newHistory->
add(newDC);
296 newAcc->
add(newHistory);
301 cout <<
"Merging SC" << endl;
304 if (i % 10000 == 0) {
311 if (!history || !history->
isValid())
continue;
318 std::map<std::pair<const PersistentAccessor*, int>,
int>
::const_iterator newIndex
320 if (newIndex == evtAccMap.end()) cout <<
"Event not found for cell " << i <<
", data " << j <<
"." << endl;
321 newDC->
setEventIndex(newIndex != evtAccMap.end() ? newIndex->second : -1);
322 newHistory->
add(newDC);
332 newAcc->
addSC(newHistory);
337 cout <<
"Merging done, final size = " << size << endl;
void add(const DataContainer *data)
append data (takes ownership)
const CellInfo * cellInfo() const
unsigned int nDataContainers() const
const DataContainer * dataContainer(unsigned int i) const