Skip to content

Commit f5ccf71

Browse files
committed
RNTuple requires MEtoEDM<long> have a dictionary
1 parent c67b5f9 commit f5ccf71

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

DataFormats/Histograms/interface/MEtoEDMFormat.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,56 @@ inline bool MEtoEDM<int>::mergeProduct(const MEtoEDM<int> &newMEtoEDM) {
263263
return true;
264264
}
265265

266+
/*NOTE: this is a temporary workaround for a ROOT RNTuple dictionary issue.
267+
Once ROOT has been updated with a fix this method will be removed*/
268+
template <>
269+
inline bool MEtoEDM<long>::mergeProduct(const MEtoEDM<long> &newMEtoEDM) {
270+
const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();
271+
const size_t nObjects = newMEtoEDMObject.size();
272+
// NOTE: we remember the present size since we will only add content
273+
// from newMEtoEDMObject after this point
274+
const size_t nOldObjects = MEtoEdmObject.size();
275+
276+
// if the old and new are not the same size, we want to report a problem
277+
if (nObjects != nOldObjects) {
278+
std::cout << "WARNING MEtoEDM::mergeProducts(): the lists of histograms to be merged have different sizes: new="
279+
<< nObjects << ", old=" << nOldObjects << std::endl;
280+
}
281+
282+
for (unsigned int i = 0; i < nObjects; ++i) {
283+
unsigned int j = 0;
284+
// see if the name is already in the old container up to the point where
285+
// we may have added new entries in the container
286+
const std::string &name = newMEtoEDMObject[i].name;
287+
if (i < nOldObjects && (MEtoEdmObject[i].name == name)) {
288+
j = i;
289+
} else {
290+
j = 0;
291+
while (j < nOldObjects && (MEtoEdmObject[j].name != name))
292+
++j;
293+
}
294+
if (j >= nOldObjects) {
295+
// this value is only in the new container, not the old one
296+
#if METOEDMFORMAT_DEBUG
297+
std::cout << "WARNING MEtoEDM::mergeProducts(): adding new histogram '" << name << "'" << std::endl;
298+
#endif
299+
MEtoEdmObject.push_back(newMEtoEDMObject[i]);
300+
} else {
301+
// this value is also in the new container: add the two
302+
if (MEtoEdmObject[j].name.find("EventInfo/processedEvents") != std::string::npos) {
303+
MEtoEdmObject[j].object += (newMEtoEDMObject[i].object);
304+
}
305+
if (MEtoEdmObject[j].name.find("EventInfo/iEvent") != std::string::npos ||
306+
MEtoEdmObject[j].name.find("EventInfo/iLumiSection") != std::string::npos) {
307+
if (MEtoEdmObject[j].object < newMEtoEDMObject[i].object) {
308+
MEtoEdmObject[j].object = (newMEtoEDMObject[i].object);
309+
}
310+
}
311+
}
312+
}
313+
return true;
314+
}
315+
266316
template <>
267317
inline bool MEtoEDM<long long>::mergeProduct(const MEtoEDM<long long> &newMEtoEDM) {
268318
const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();

DataFormats/Histograms/src/classes_def.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<class name="MEtoEDM<TProfile2D>"/>
3434
<class name="MEtoEDM<double>"/>
3535
<class name="MEtoEDM<int>"/>
36+
<class name="MEtoEDM<long>"/>
3637
<class name="MEtoEDM<long long>"/>
3738
<class name="MEtoEDM<TString>"/>
3839
<class name="MEtoEDM<TH1F>::MEtoEDMObject" rntupleStreamerMode="true"/>
@@ -49,6 +50,8 @@
4950
<class name="MEtoEDM<TProfile2D>::MEtoEDMObject" rntupleStreamerMode="true"/>
5051
<class name="MEtoEDM<double>::MEtoEDMObject" rntupleStreamerMode="true"/>
5152
<class name="MEtoEDM<int>::MEtoEDMObject" rntupleStreamerMode="true"/>
53+
<!--The following is a workaround for an RNTuple issue. Will be removed once ROOT fix exists. -->
54+
<class name="MEtoEDM<long>::MEtoEDMObject" rntupleStreamerMode="true"/>
5255
<class name="MEtoEDM<long long>::MEtoEDMObject" rntupleStreamerMode="true"/>
5356
<class name="MEtoEDM<TString>::MEtoEDMObject" rntupleStreamerMode="true"/>
5457
<class name="std::vector<MEtoEDM<TH1F>::MEtoEDMObject>"/>
@@ -81,6 +84,8 @@
8184
<class name="edm::Wrapper<MEtoEDM<TProfile2D> >"/>
8285
<class name="edm::Wrapper<MEtoEDM<double> >"/>
8386
<class name="edm::Wrapper<MEtoEDM<int> >"/>
87+
<!--The following is a workaround for an RNTuple issue. Will be removed once ROOT fix exists. -->
88+
<class name="edm::Wrapper<MEtoEDM<long> >"/>
8489
<class name="edm::Wrapper<MEtoEDM<long long> >"/>
8590
<class name="edm::Wrapper<MEtoEDM<TString> >"/>
8691

0 commit comments

Comments
 (0)