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)) {
154 LogAbsolute(
"EventContent") <<
indent << printName <<
" " << formatClassName(
typeName);
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 auto const& prov =
iEvent.getProvenance(provenance->branchID());
373 auto const* productProvenance = prov.productProvenance();
374 if (productProvenance) {
375 const bool isAlias = productProvenance->branchID() != provenance->branchID();
379 aliasForModLabel =
iEvent.getProvenance(productProvenance->branchID()).
moduleLabel();
380 LogAbsolute(
"EventContent") <<
"Is an alias for " << aliasForModLabel;
384 if (pc.processName() == prov.processName()) {
421 <<
" is an unknown type" << std::endl;
435 typedef std::map<std::string, int> nameMap;
437 LogAbsolute(
"EventContent") <<
"\nSummary for key being the concatenation of friendlyClassName, moduleLabel, "
438 "productInstanceName and processName"
440 for (nameMap::const_iterator it =
cumulates_.begin(), itEnd =
cumulates_.end(); it != itEnd; ++it) {
441 LogAbsolute(
"EventContent") << std::setw(6) << it->second <<
" occurrences of key " << it->first << std::endl;
452 "This plugin will print a list of all products in the event "
453 "provenance. It also has options to print and/or get each product.");
461 np->setComment(
"This string is printed at the beginning of every line printed during event processing.");
464 np->setComment(
"If true, the contents of products are printed.");
469 "This string is used to further indent lines when printing the contents of products in verbose mode.");
471 std::vector<std::string> defaultVString;
474 np->setComment(
"If this vector is not empty, then only products with module labels on this list are printed.");
477 np->setComment(
"If true the products will be retrieved using getByLabel.");
481 "If this vector is not empty, then only products with module labels on this list are retrieved by getByLabel.");
484 np->setComment(
"If true then print a list of all the event content.");
487 np->setComment(
"If true, and if listContent or verbose is true, print provenance information for each product");
489 descriptions.
add(
"printContent", desc);