51 char const* kNameValueSep =
"=";
55 LogAbsolute(
"EventContent") << iIndent << iName << kNameValueSep
56 << *reinterpret_cast<T*>(iObject.address());
61 LogAbsolute(
"EventContent") << iIndent << iName << kNameValueSep
62 << static_cast<int>(*reinterpret_cast<char*>(iObject.address()));
66 void doPrint<unsigned char>(
std::string const& iName, ObjectWithDict
const& iObject,
std::string const& iIndent) {
67 LogAbsolute(
"EventContent") << iIndent << iName << kNameValueSep
68 << static_cast<unsigned int>(
69 *reinterpret_cast<unsigned char*>(iObject.address()));
74 LogAbsolute(
"EventContent") << iIndent << iName << kNameValueSep
75 << ((*reinterpret_cast<bool*>(iObject.address())) ?
"true" :
"false");
79 typedef std::map<std::string, FunctionType> TypeToPrintMap;
82 void addToMap(TypeToPrintMap& iMap) {
83 iMap[
typeid(
T).
name()] = doPrint<T>;
88 typedef std::map<std::string, FunctionType> TypeToPrintMap;
89 static TypeToPrintMap s_map;
92 addToMap<bool>(s_map);
93 addToMap<char>(s_map);
94 addToMap<short>(s_map);
96 addToMap<long>(s_map);
97 addToMap<unsigned char>(s_map);
98 addToMap<unsigned short>(s_map);
99 addToMap<unsigned int>(s_map);
100 addToMap<unsigned long>(s_map);
101 addToMap<float>(s_map);
102 addToMap<double>(s_map);
105 TypeToPrintMap::iterator itFound = s_map.find(iObject.typeOf().name());
106 if (itFound == s_map.end()) {
109 itFound->second(iName, iObject, iIndent);
114 ObjectWithDict
const& iObject,
119 ObjectWithDict
const& iObject,
123 const ObjectWithDict& objectToPrint = iObject;
125 if (iObject.typeOf().isPointer()) {
126 LogAbsolute(
"EventContent") << iIndent << iName << kNameValueSep << formatClassName(iObject.typeOf().name())
127 << std::hex << iObject.address() <<
std::dec;
128 TypeWithDict pointedType = iObject.typeOf().toType();
147 if (printAsBuiltin(printName, objectToPrint,
indent)) {
150 if (printAsContainer(printName, objectToPrint,
indent, iIndentDelta)) {
157 TypeDataMembers dataMembers(objectToPrint.typeOf());
158 for (
auto const& dataMember : dataMembers) {
159 MemberWithDict
const member(dataMember);
162 printObject(member.name(), member.get(objectToPrint),
indent, iIndentDelta);
164 LogAbsolute(
"EventContent") <<
indent << member.name() <<
" <exception caught(" << iEx.what() <<
")>\n";
170 ObjectWithDict
const& iObject,
173 ObjectWithDict sizeObj;
176 FunctionWithDict sizeFunc = iObject.typeOf().functionMemberByName(
"size");
177 assert(sizeFunc.finalReturnType() ==
typeid(size_t));
178 sizeObj = ObjectWithDict(TypeWithDict(
typeid(
size_t)), &
temp);
179 sizeFunc.invoke(iObject, &sizeObj);
181 size_t size = *reinterpret_cast<size_t*>(sizeObj.address());
182 FunctionWithDict atMember;
184 atMember = iObject.typeOf().functionMemberByName(
"at");
189 LogAbsolute(
"EventContent") << iIndent << iName << kNameValueSep <<
"[size=" <<
size <<
"]";
190 ObjectWithDict contained;
192 TypeWithDict atReturnType(atMember.finalReturnType());
199 bool const isRef = atReturnType.isReference();
200 void* refMemoryBuffer =
nullptr;
205 std::vector<void*>
args;
208 std::ostringstream sizeS;
209 sizeS <<
"[" <<
index <<
"]";
211 ObjectWithDict refObject(atReturnType, &refMemoryBuffer);
212 atMember.invoke(iObject, &refObject,
args);
215 contained = ObjectWithDict(atReturnType, refMemoryBuffer);
217 contained = atReturnType.construct();
218 atMember.invoke(iObject, &contained,
args);
222 printObject(sizeS.str(), contained, indexIndent, iIndentDelta);
224 LogAbsolute(
"EventContent") << indexIndent << iName <<
" <exception caught(" << iEx.what() <<
")>\n";
227 contained.destruct(
true);
248 LogAbsolute(
"EventContent") << iIndent <<
" \"" << iClassName <<
"\""
249 <<
" is an unknown type" << std::endl;
287 : indentation_(iConfig.getUntrackedParameter(
"indentation",
std::
string(
"++"))),
288 verboseIndentation_(iConfig.getUntrackedParameter(
"verboseIndentation",
std::
string(
" "))),
289 moduleLabels_(iConfig.getUntrackedParameter(
"verboseForModuleLabels",
std::
vector<
std::
string>())),
290 verbose_(iConfig.getUntrackedParameter(
"verbose",
false) || !moduleLabels_.
empty()),
291 getModuleLabels_(iConfig.getUntrackedParameter(
"getDataForModuleLabels",
std::
vector<
std::
string>())),
292 getData_(iConfig.getUntrackedParameter(
"getData",
false) || !getModuleLabels_.
empty()),
294 listContent_(iConfig.getUntrackedParameter(
"listContent",
true)),
295 listProvenance_(iConfig.getUntrackedParameter(
"listProvenance",
false)) {
303 const std::string kEndPathStatus(
"edm::EndPathStatus");
332 typedef std::vector<StableProvenance const*> Provenances;
333 Provenances provenances;
335 iEvent.getAllStableProvenance(provenances);
340 << provenances.size() <<
" product" << (provenances.size() == 1 ?
"" :
"s")
341 <<
" with friendlyClassName, moduleLabel, productInstanceName and processName:"
346 for (
auto const& provenance : provenances) {
349 const std::string kEndPathStatus(
"edm::EndPathStatus");
356 std::string const& modLabel = provenance->moduleLabel();
369 <<
" (productId = " << provenance->productID() <<
")" << std::endl;
372 const bool isAlias = provenance->branchDescription().isAlias();
376 aliasForModLabel =
iEvent.getStableProvenance(provenance->originalBranchID()).
moduleLabel();
377 LogAbsolute(
"EventContent") <<
"Is an alias for " << aliasForModLabel;
381 if (pc.processName() == provenance->processName()) {
417 <<
" is an unknown type" << std::endl;
431 typedef std::map<std::string, int> nameMap;
433 LogAbsolute(
"EventContent") <<
"\nSummary for key being the concatenation of friendlyClassName, moduleLabel, "
434 "productInstanceName and processName"
436 for (nameMap::const_iterator it =
cumulates_.begin(), itEnd =
cumulates_.end(); it != itEnd; ++it) {
437 LogAbsolute(
"EventContent") << std::setw(6) << it->second <<
" occurrences of key " << it->first << std::endl;
448 "This plugin will print a list of all products in the event "
449 "provenance. It also has options to print and/or get each product.");
457 np->setComment(
"This string is printed at the beginning of every line printed during event processing.");
459 np =
desc.addOptionalUntracked<
bool>(
"verbose",
false);
460 np->setComment(
"If true, the contents of products are printed.");
463 np =
desc.addOptionalUntracked<
std::string>(
"verboseIndentation", defaultString);
465 "This string is used to further indent lines when printing the contents of products in verbose mode.");
467 std::vector<std::string> defaultVString;
469 np =
desc.addOptionalUntracked<std::vector<std::string> >(
"verboseForModuleLabels", defaultVString);
470 np->setComment(
"If this vector is not empty, then only products with module labels on this list are printed.");
472 np =
desc.addOptionalUntracked<
bool>(
"getData",
false);
473 np->setComment(
"If true the products will be retrieved using getByLabel.");
475 np =
desc.addOptionalUntracked<std::vector<std::string> >(
"getDataForModuleLabels", defaultVString);
477 "If this vector is not empty, then only products with module labels on this list are retrieved by getByLabel.");
479 np =
desc.addOptionalUntracked<
bool>(
"listContent",
true);
480 np->setComment(
"If true then print a list of all the event content.");
482 np =
desc.addOptionalUntracked<
bool>(
"listProvenance",
false);
483 np->setComment(
"If true, and if listContent or verbose is true, print provenance information for each product");
485 descriptions.
add(
"printContent",
desc);