33 present(other.present.
load()),
34 empty(other.empty.
load()),
35 min(other.min.
load()),
36 max(other.max.
load()),
37 total(other.total.
load()) {}
44 auto previousMin = min.load();
45 while( previousMin > size and not min.compare_exchange_weak(previousMin, size) ) {}
46 auto previousMax = max.load();
47 while( previousMax < size and not max.compare_exchange_weak(previousMax, size) ) {}
55 perEvent_(iConfig.getUntrackedParameter<
bool>(
"perEvent",
false)),
56 perJob_(iConfig.getUntrackedParameter<
bool>(
"perJob",
true)),
57 self_(iConfig.getParameter<
std::
string>(
"@module_label")),
58 logName_(iConfig.getUntrackedParameter<
std::
string>(
"logName")),
59 dumpItems_(iConfig.getUntrackedParameter<
bool>(
"dumpItems",
false)),
61 const std::vector<edm::InputTag>& tags = iConfig.
getParameter<std::vector<edm::InputTag> >(
"candidates");
62 for(
const auto&
tag : tags ) {
63 collections_.emplace_back(
tag );
82 return std::make_unique<pathelpers::RecordCache>(conf);
90 std::vector<std::pair<edm::InputTag,edm::EDGetTokenT<edm::View<reco::Candidate> > > >
srcTokens;
95 const std::vector<edm::InputTag>&
inputs = iConfig.
getParameter<std::vector<edm::InputTag> >(
"candidates");
96 for (std::vector<edm::InputTag>::const_iterator it = inputs.begin(); it != inputs.end(); ++it) {
107 using std::setw;
using std::left;
using std::right;
using std::setprecision;
110 if (globalCache()->perEvent_) {
111 LogInfo(globalCache()->logName_) <<
"Per Event Table " << globalCache()->logName_
112 <<
" (" << globalCache()->self_ <<
", run:event " 113 << iEvent.
id().
run() <<
":" << iEvent.
id().
event() <<
")";
115 ++(globalCache()->totalEvents_);
116 auto& collections = globalCache()->collections_;
117 auto tags = srcTokens.cbegin();
118 for (
auto it = collections.begin(), ed = collections.end(); it != ed; ++it, ++tags) {
120 if (!candidates.
failedToGet()) it->update(*candidates);
121 if (globalCache()->perEvent_) {
122 LogVerbatim(globalCache()->logName_) <<
" " << setw(30) << left << it->src.encode() << right;
123 if (globalCache()->dumpItems_) {
125 std::ostringstream oss;
127 oss <<
" [" << setw(3) << i <<
"]" <<
128 " pt " << setw(7) << setprecision(5) <<
cand->pt() <<
129 " eta " << setw(7) << setprecision(5) <<
cand->eta() <<
130 " phi " << setw(7) << setprecision(5) <<
cand->phi() <<
131 " et " << setw(7) << setprecision(5) <<
cand->et() <<
132 " phi " << setw(7) << setprecision(5) <<
cand->phi() <<
133 " charge " << setw(2) <<
cand->charge() <<
134 " id " << setw(7) <<
cand->pdgId() <<
135 " st " << setw(7) <<
cand->status() <<
"\n";
141 if (globalCache()->perEvent_)
LogInfo(globalCache()->logName_) <<
"" ;
147 using std::setw;
using std::left;
using std::right;
using std::setprecision;
149 std::ostringstream oss;
152 oss <<
" " << setw(30) << left << it->src.encode() << right <<
153 " present " << setw(7) << it->present <<
" (" << setw(4) << setprecision(3) << (it->present*100.0/rcd->
totalEvents_) <<
"%)" <<
154 " empty " << setw(7) << it->empty <<
" (" << setw(4) << setprecision(3) << (it->empty*100.0/rcd->
totalEvents_) <<
"%)" <<
155 " min " << setw(7) << it->min <<
156 " max " << setw(7) << it->max <<
157 " total " << setw(7) << it->total <<
158 " avg " << setw(5) << setprecision(3) << (it->total/double(rcd->
totalEvents_)) <<
"\n";
std::vector< Record > collections_
T getParameter(std::string const &) const
EventNumber_t event() const
static std::unique_ptr< pathelpers::RecordCache > initializeGlobalCache(edm::ParameterSet const &conf)
const std::string logName_
CandidateSummaryTable(const edm::ParameterSet &iConfig, const pathelpers::RecordCache *)
std::atomic< size_t > total
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
Record(const Record &other)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Record(const edm::InputTag &tag)
#define DEFINE_FWK_MODULE(type)
std::atomic< size_t > totalEvents_
std::vector< std::pair< edm::InputTag, edm::EDGetTokenT< edm::View< reco::Candidate > > > > srcTokens
RecordCache(const edm::ParameterSet &iConfig)
Produce a summary table of some candidate collections.
static void globalEndJob(const pathelpers::RecordCache *)
std::atomic< size_t > empty
~CandidateSummaryTable() override
std::atomic< size_t > present
std::atomic< size_t > max
void update(const edm::View< reco::Candidate > &items) const
virtual example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
std::atomic< size_t > min