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;
288 : indentation_(iConfig.getUntrackedParameter<
std::
string>(
"indentation")),
289 verboseIndentation_(iConfig.getUntrackedParameter<
std::
string>(
"verboseIndentation")),
290 moduleLabels_(iConfig.getUntrackedParameter<
std::
vector<
std::
string>>(
"verboseForModuleLabels")),
291 verbose_(iConfig.getUntrackedParameter<
bool>(
"verbose") || !moduleLabels_.
empty()),
292 getModuleLabels_(iConfig.getUntrackedParameter<
std::
vector<
std::
string>>(
"getDataForModuleLabels")),
293 getData_(iConfig.getUntrackedParameter<
bool>(
"getData") || !getModuleLabels_.
empty()),
295 listContent_(iConfig.getUntrackedParameter<
bool>(
"listContent")),
296 listProvenance_(iConfig.getUntrackedParameter<
bool>(
"listProvenance")),
297 listPathStatus_(iConfig.getUntrackedParameter<
bool>(
"listPathStatus")) {
305 const std::string kEndPathStatus(
"edm::EndPathStatus");
334 typedef std::vector<StableProvenance const*> Provenances;
335 Provenances provenances;
337 iEvent.getAllStableProvenance(provenances);
342 << provenances.size() <<
" product" << (provenances.size() == 1 ?
"" :
"s")
343 <<
" with friendlyClassName, moduleLabel, productInstanceName and processName:" 351 const std::string kEndPathStatus(
"edm::EndPathStatus");
371 <<
" (productId = " <<
provenance->productID() <<
")" << std::endl;
374 const bool isAlias =
provenance->branchDescription().isAlias();
379 LogAbsolute(
"EventContent") <<
"Is an alias for " << aliasForModLabel;
383 if (pc.processName() ==
provenance->processName()) {
419 <<
" is an unknown type" << std::endl;
433 typedef std::map<std::string, int> nameMap;
435 LogAbsolute(
"EventContent") <<
"\nSummary for key being the concatenation of friendlyClassName, moduleLabel, " 436 "productInstanceName and processName" 439 LogAbsolute(
"EventContent") << std::setw(6) <<
it->second <<
" occurrences of key " <<
it->first << std::endl;
445 "This plugin will print a list of all products in the event " 446 "provenance. It also has options to print and/or get each product.");
454 np->setComment(
"This string is printed at the beginning of every line printed during event processing.");
456 np =
desc.addUntracked<
bool>(
"verbose",
false);
457 np->setComment(
"If true, the contents of products are printed.");
462 "This string is used to further indent lines when printing the contents of products in verbose mode.");
464 std::vector<std::string> defaultVString;
466 np =
desc.addUntracked<std::vector<std::string>>(
"verboseForModuleLabels", defaultVString);
467 np->setComment(
"If this vector is not empty, then only products with module labels on this list are printed.");
469 np =
desc.addUntracked<
bool>(
"getData",
false);
470 np->setComment(
"If true the products will be retrieved using getByLabel.");
472 np =
desc.addUntracked<std::vector<std::string>>(
"getDataForModuleLabels", defaultVString);
474 "If this vector is not empty, then only products with module labels on this list are retrieved by getByLabel.");
476 np =
desc.addUntracked<
bool>(
"listContent",
true);
477 np->setComment(
"If true then print a list of all the event content.");
479 np =
desc.addUntracked<
bool>(
"listProvenance",
false);
480 np->setComment(
"If true, and if listContent or verbose is true, print provenance information for each product");
482 desc.addUntracked<
bool>(
"listPathStatus",
false)
483 ->setComment(
"If true, also show PathStatus/EndPathStatus data products.");
484 descriptions.
add(
"printContent",
desc);
std::vector< std::string > getModuleLabels_
bool getMapped(key_type const &k, value_type &result) const
~EventContentAnalyzer() override
ParameterSet const & getParameterSet(std::string const &) const
TypeID unwrappedTypeID() const
std::string const & processName() const
std::string verboseIndentation_
std::map< std::string, int > cumulates_
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
TEMPL(T2) struct Divides void
static TypeWithDict byName(std::string const &name)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void analyze(Event const &, EventSetup const &) override
void addDefault(ParameterSetDescription const &psetDescription)
std::string friendlyName(std::string const &iFullName)
std::string const & className() const
std::string const & productInstanceName() const
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
key
prepare the HTCondor submission files and eventually submit them
#define DEFINE_FWK_MODULE(type)
void setComment(std::string const &value)
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
std::vector< std::string > moduleLabels_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool binary_search_all(ForwardSequence const &s, Datum const &d)
wrappers for std::binary_search
Log< level::System, true > LogAbsolute
T mod(const T &a, const T &b)
static const bool doPrint
std::string const & moduleLabel() const
EventContentAnalyzer(ParameterSet const &)
static Registry * instance()
std::string className(const T &t)