27 : m_cellTree(&cellTree), m_eventTree(&eventTree), m_runTree(runTree),
m_file(
file),
28 m_historyCont(nullptr), m_eventData(nullptr), m_runData(nullptr)
35 cout <<
"WARNING: could not load all the baskets of the event tree into memory -- processing will be very slow." << endl;
36 cout <<
"Please check if the file you are loading is too large or corrupted." << endl;
46 : m_cellTree(nullptr), m_eventTree(nullptr), m_runTree(nullptr),
m_file(nullptr),
47 m_historyCont(nullptr), m_eventData(nullptr), m_runData(nullptr)
68 if (!
file)
return nullptr;
69 if (!
file->IsOpen()) {
delete file;
return nullptr; }
124 if (
i >=
nRuns())
return nullptr;
125 std::map<unsigned int, const RunData*>::const_iterator cache =
m_runCache.find(
i);
126 if (cache !=
m_runCache.end())
return cache->second;
169 cout <<
"Writing " <<
m_runTree->GetEntries() <<
" run(s)..." << endl;
171 cout <<
"Writing " <<
m_eventTree->GetEntries() <<
" event(s)..." << endl;
173 cout <<
"Writing " <<
m_cellTree->GetEntries() <<
" cell(s)..." << endl;
176 cout <<
"Writing done!" << endl;
185 unsigned int size = 0;
188 int evtIndex = 0, runIndex = 0;
189 std::map<std::pair<int, int>,
int> evtMap;
190 std::map<int, int> runMap;
191 std::map< std::pair<const PersistentAccessor*, int>,
int > evtAccMap;
193 cout <<
"Merging runs" << endl;
196 cout <<
"Cannot merge: one of the inputs is null!" << endl;
200 for (
unsigned int i = 0;
i <
accessor->nRuns();
i++) {
202 if (runMap.find(
run) != runMap.end())
continue;
203 runMap[
run] = runIndex;
211 cout <<
"Merging events" << endl;
212 unsigned int nEventsTotal = 0, iEvt = 0;
214 nEventsTotal +=
accessor->nEvents();
217 for (
unsigned int i = 0;
i <
accessor->nEvents();
i++) {
219 if (iEvt % 100000 == 0) cout <<
"Merging event " << iEvt <<
"/" << nEventsTotal << endl;
220 std::pair<int, int> evtId(
accessor->eventData(
i)->run(),
accessor->eventData(
i)->event());
221 std::pair<const PersistentAccessor*, int> evtAccId(
accessor,
i);
222 if (evtMap.find(evtId) != evtMap.end()) {
223 cout <<
"ERROR: Skipping duplicate entry for run " <<
accessor->eventData(
i)->run() <<
", event " <<
accessor->eventData(
i)->event() << endl;
226 evtAccMap[evtAccId] = evtIndex;
227 evtMap[evtId] = evtIndex;
228 std::map<int, int>::const_iterator
idx = runMap.find(
accessor->eventData(
i)->run());
229 int newRunIndex = (
idx == runMap.end() ? -999 :
idx->second);
239 if (
i % 10000 == 0) {
246 if (!history || !history->
isValid())
continue;
253 std::map<std::pair<const PersistentAccessor*, int>,
int>::const_iterator newIndex
255 if (newIndex == evtAccMap.end()) cout <<
"Event not found for cell " <<
i <<
", data " << j <<
"." << endl;
256 newDC->
setEventIndex(newIndex != evtAccMap.end() ? newIndex->second : -1);
257 newHistory->
add(newDC);
261 cout <<
"Shape not filled for hash = " <<
i <<
", index = " << j <<
", gain = " << history->
dataContainer(j)->
gain() << endl;
267 newAcc->
add(newHistory);
271 cout <<
"Merging done, final size = " <<
size << endl;
279 std::vector<const PersistentAccessor*>
accessors;
283 cout <<
"ERROR : could not open file " <<
inputFile << endl;