90 : simTracks_(iConfig.getParameter<
edm::
InputTag>(
"simTracks")),
91 genParticles_(iConfig.getParameter<
edm::
InputTag>(
"genParticles")),
92 simVertices_(iConfig.getParameter<
edm::
InputTag>(
"simVertices")),
93 trackingParticles_(iConfig.getParameter<
edm::
InputTag>(
"trackingParticles")),
94 caloParticles_(iConfig.getParameter<
edm::
InputTag>(
"caloParticles")),
95 simClusters_(iConfig.getParameter<
edm::
InputTag>(
"simClusters")),
133 std::vector<int> sorted_tracks_idx(
tracks.size());
134 iota(begin(sorted_tracks_idx),
end(sorted_tracks_idx), 0);
135 sort(begin(sorted_tracks_idx),
end(sorted_tracks_idx), [&
tracks](
int i,
int j) {
141 std::vector<int> sorted_genParticles_idx(
genParticles.size());
142 iota(begin(sorted_genParticles_idx),
end(sorted_genParticles_idx), 0);
149 std::vector<int> sorted_vertices_idx(
vertices.size());
150 iota(begin(sorted_vertices_idx),
end(sorted_vertices_idx), 0);
151 sort(begin(sorted_vertices_idx),
end(sorted_vertices_idx), [&
vertices](
int i,
int j) {
156 auto const& trackingpart = *trackingParticlesH.
product();
157 std::vector<int> sorted_tp_idx(trackingpart.size());
158 iota(begin(sorted_tp_idx),
end(sorted_tp_idx), 0);
159 sort(begin(sorted_tp_idx),
end(sorted_tp_idx), [&trackingpart](
int i,
int j) {
160 return trackingpart[
i].eta() < trackingpart[
j].eta();
164 auto const& calopart = *caloParticlesH.
product();
165 std::vector<int> sorted_cp_idx(calopart.size());
166 iota(begin(sorted_cp_idx),
end(sorted_cp_idx), 0);
167 sort(begin(sorted_cp_idx),
end(sorted_cp_idx), [&calopart](
int i,
int j) {
168 return calopart[
i].eta() < calopart[
j].eta();
173 std::vector<int> sorted_simcl_idx(
simclusters.size());
174 iota(begin(sorted_simcl_idx),
end(sorted_simcl_idx), 0);
180 std::map<int, float> detIdToTotalSimEnergy;
185 std::map<int, int> trackid_to_track_index;
186 LogVerbatim(
"CaloParticleDebuggerSimTracks") <<
"\n\n**Printing SimTracks information **";
187 LogVerbatim(
"CaloParticleDebuggerSimTracks") <<
"IDX\tTrackId\tPDGID\tMOMENTUM(x,y,z,E)\tVertexIdx\tGenPartIdx";
188 for (
auto i : sorted_tracks_idx) {
190 LogVerbatim(
"CaloParticleDebuggerSimTracks") <<
idx <<
"\t" <<
t.trackId() <<
"\t" <<
t;
192 <<
"Crossed Boundary: " <<
t.crossedBoundary() <<
" Position Boundary: " <<
t.getPositionAtBoundary()
193 <<
" Momentum Boundary: " <<
t.getMomentumAtBoundary() <<
" Vtx: " <<
t.vertIndex()
194 <<
" Momemtum Origin: " <<
t.momentum();
195 trackid_to_track_index[
t.trackId()] =
idx;
199 LogVerbatim(
"CaloParticleDebuggerGenParticles") <<
"\n\n**Printing GenParticles information **";
200 LogVerbatim(
"CaloParticleDebuggerGenParticles") <<
"IDX\tPDGID\tMOMENTUM(x,y,z)\tVertex(x,y,z)";
201 for (
auto i : sorted_genParticles_idx) {
204 <<
i <<
"\t" <<
gp.pdgId() <<
"\t" <<
gp.momentum() <<
"\t" <<
gp.vertex();
207 LogVerbatim(
"CaloParticleDebuggerSimVertices") <<
"\n\n**Printing SimVertex information **";
208 LogVerbatim(
"CaloParticleDebuggerSimVertices") <<
"IDX\tPOSITION(x,y,z)\tPARENT_INDEX\tVERTEX_ID";
209 for (
auto i : sorted_vertices_idx) {
211 LogVerbatim(
"CaloParticleDebuggerSimVertices") <<
i <<
"\t" <<
v;
214 LogVerbatim(
"CaloParticleDebuggerTrackingParticles") <<
"\n\n**Printing TrackingParticles information **";
215 for (
auto i : sorted_tp_idx) {
216 auto const&
tp = trackingpart[
i];
217 LogVerbatim(
"CaloParticleDebuggerTrackingParticles") <<
i <<
"\t" <<
tp;
220 LogVerbatim(
"CaloParticleDebuggerCaloParticles") <<
"\n\n**Printing CaloParticles information **";
222 for (
auto i : sorted_cp_idx) {
223 auto const&
cp = calopart[
i];
226 <<
idx++ <<
" |Eta|: " <<
std::abs(
cp.momentum().eta()) <<
"\tType: " <<
cp.pdgId()
227 <<
"\tEnergy: " <<
cp.energy() <<
"\tIdx: " <<
cp.g4Tracks()[0].trackId();
228 double total_sim_energy = 0.;
229 double total_cp_energy = 0.;
230 LogVerbatim(
"CaloParticleDebuggerCaloParticles") <<
"--> Overall simclusters in CP: " <<
cp.simClusters().size();
232 auto const& simcs =
cp.simClusters();
233 std::vector<int> sorted_sc_idx(simcs.size());
234 iota(begin(sorted_sc_idx),
end(sorted_sc_idx), 0);
235 sort(begin(sorted_sc_idx),
end(sorted_sc_idx), [&simcs](
int i,
int j) {
236 return simcs[
i]->momentum().eta() < simcs[
j]->momentum().eta();
238 for (
auto i : sorted_sc_idx) {
239 LogVerbatim(
"CaloParticleDebuggerCaloParticles") << *(simcs[
i]);
242 for (
auto const& sc :
cp.simClusters()) {
243 for (
auto const&
cl : sc->hits_and_fractions()) {
244 total_sim_energy += detIdToTotalSimEnergy[
cl.first] *
cl.second;
245 total_cp_energy +=
cp.energy() *
cl.second;
249 <<
"--> Overall SC energy (sum using sim energies): " << total_sim_energy;
251 <<
"--> Overall SC energy (sum using CaloP energies): " << total_cp_energy;
255 LogVerbatim(
"CaloParticleDebuggerSimClusters") <<
"\n\n**Printing SimClusters information **";
256 for (
auto i : sorted_simcl_idx) {
260 <<
idx++ <<
" |Eta|: " <<
std::abs(simcl.momentum().eta()) <<
"\tType: " << simcl.pdgId()
261 <<
"\tEnergy: " << simcl.energy() <<
"\tKey: " <<
i;
262 auto const& simtrack = simcl.g4Tracks()[0];
263 LogVerbatim(
"CaloParticleDebuggerSimClusters") <<
" Crossed Boundary: " << simtrack.crossedBoundary()
264 <<
" Position Boundary: " << simtrack.getPositionAtBoundary()
265 <<
" Momentum Boundary: " << simtrack.getMomentumAtBoundary();
266 double total_sim_energy = 0.;
267 LogVerbatim(
"CaloParticleDebuggerSimClusters") <<
"--> Overall simclusters's size: " << simcl.numberOfRecHits();
268 for (
auto const&
cl : simcl.hits_and_fractions()) {
269 total_sim_energy += detIdToTotalSimEnergy[
cl.first] *
cl.second;
271 LogVerbatim(
"CaloParticleDebuggerSimClusters") << simcl;
273 <<
"--> Overall SimCluster energy (sum using sim energies): " << total_sim_energy;
308 hgtopo[0] = &(
eegeom->topology());
309 hgtopo[1] = &(fhgeom->topology());
311 hgtopo[2] = &(bhgeomnew->topology());
313 for (
unsigned i = 0;
i < 3; ++
i) {
325 const bool isHcal = (collectionTag.instance().find(
"HcalHits") != std::string::npos);
327 for (
auto const&
simHit : *hSimHits) {
329 const uint32_t simId =
simHit.id();
339 int subdet,
layer, cell,
sec, subsec, zp;
342 std::pair<int, int> recoLayerCell = ddd->
simToReco(cell,
layer,
sec, hgtopo[subdet - 3]->detectorType());
343 cell = recoLayerCell.first;
344 layer = recoLayerCell.second;
354 detIdToTotalSimEnergy[
id.rawId()] +=
simHit.energy();
368 desc.add<std::vector<edm::InputTag>>(
"collectionTags",
372 descriptions.
add(
"caloParticleDebugger",
desc);
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Log< level::Info, true > LogVerbatim
edm::EDGetTokenT< std::vector< TrackingParticle > > trackingParticlesToken_
T const * product() const
edm::InputTag simClusters_
edm::EDGetTokenT< std::vector< SimCluster > > simClustersToken_
CaloParticleDebugger(const edm::ParameterSet &)
constexpr HcalSubdetector subdet() const
get the subdetector
std::vector< edm::EDGetTokenT< std::vector< PCaloHit > > > collectionTagsToken_
edm::InputTag genParticles_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Abs< T >::type abs(const T &t)
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< std::vector< SimTrack > > simTracksToken_
DetId relabel(const uint32_t testId) const
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
edm::EDGetTokenT< std::vector< CaloParticle > > caloParticlesToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void fillSimHits(std::map< int, float > &, const edm::Event &, const edm::EventSetup &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< std::vector< reco::GenParticle > > genParticlesToken_
const HcalDDDRecConstants * dddConstants() const
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::InputTag trackingParticles_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
edm::InputTag caloParticles_
edm::InputTag simVertices_
const HGCalDDDConstants & dddConstants() const
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
std::vector< edm::InputTag > collectionTags_
const HcalTopology & topology() const
~CaloParticleDebugger() override
edm::EDGetTokenT< std::vector< SimVertex > > simVerticesToken_