92 : simTracks_(iConfig.getParameter<
edm::
InputTag>(
"simTracks")),
93 genParticles_(iConfig.getParameter<
edm::
InputTag>(
"genParticles")),
94 genBarcodes_(iConfig.getParameter<
edm::
InputTag>(
"genBarcodes")),
95 simVertices_(iConfig.getParameter<
edm::
InputTag>(
"simVertices")),
96 trackingParticles_(iConfig.getParameter<
edm::
InputTag>(
"trackingParticles")),
97 caloParticles_(iConfig.getParameter<
edm::
InputTag>(
"caloParticles")),
98 simClusters_(iConfig.getParameter<
edm::
InputTag>(
"simClusters")),
141 auto const& genBarcodes = *genBarcodesH.
product();
147 auto const& trackingpart = *trackingParticlesH.
product();
150 auto const& calopart = *caloParticlesH.
product();
156 std::map<int, float> detIdToTotalSimEnergy;
159 std::map<int, int> trackid_to_track_index;
160 LogVerbatim(
"CaloParticleDebuggerSimTracks") <<
"\n\n**Printing SimTracks information **";
161 LogVerbatim(
"CaloParticleDebuggerSimTracks") <<
"IDX\tTrackId\tPDGID\tMOMENTUM(x,y,z,E)\tVertexIdx\tGenPartIdx";
162 for (
size_t i = 0;
i <
tracks.size(); ++
i) {
165 <<
i <<
"\t" <<
t.trackId() <<
"\t" <<
t <<
" Crossed Boundary: " <<
t.crossedBoundary()
166 <<
" Position Boundary: " <<
t.getPositionAtBoundary() <<
" Momentum Boundary: " <<
t.getMomentumAtBoundary()
167 <<
" Vtx: " <<
t.vertIndex() <<
" Momemtum Origin: " <<
t.momentum();
168 trackid_to_track_index[
t.trackId()] =
i;
171 LogVerbatim(
"CaloParticleDebuggerGenParticles") <<
"\n\n**Printing GenParticles information **";
172 LogVerbatim(
"CaloParticleDebuggerGenParticles") <<
"BARCODE\tPDGID\tMOMENTUM(x,y,z)\tVertex(x,y,z)";
176 << genBarcodes[
i] <<
"\t" <<
gp.pdgId() <<
"\t" <<
gp.momentum() <<
"\t" <<
gp.vertex();
179 LogVerbatim(
"CaloParticleDebuggerSimVertices") <<
"\n\n**Printing SimVertex information **";
180 LogVerbatim(
"CaloParticleDebuggerSimVertices") <<
"IDX\tPOSITION(x,y,z)\tPARENT_INDEX\tVERTEX_ID";
183 LogVerbatim(
"CaloParticleDebuggerSimVertices") <<
i <<
"\t" <<
v;
186 LogVerbatim(
"CaloParticleDebuggerTrackingParticles") <<
"\n\n**Printing TrackingParticles information **";
187 for (
size_t i = 0;
i < trackingpart.size(); ++
i) {
188 auto const&
tp = trackingpart[
i];
189 LogVerbatim(
"CaloParticleDebuggerTrackingParticles") <<
i <<
"\t" <<
tp;
192 LogVerbatim(
"CaloParticleDebuggerCaloParticles") <<
"\n\n**Printing CaloParticles information **";
193 for (
size_t i = 0;
i < calopart.size(); ++
i) {
194 auto const&
cp = calopart[
i];
195 LogVerbatim(
"CaloParticleDebuggerCaloParticles") <<
"\n\n" 196 <<
i <<
"\tType: " <<
cp.pdgId() <<
"\tEnergy: " <<
cp.energy()
197 <<
"\tBarcode: " <<
cp.g4Tracks()[0].genpartIndex()
198 <<
" G4_trackID: " <<
cp.g4Tracks()[0].trackId();
199 double total_sim_energy = 0.;
200 double total_cp_energy = 0.;
201 LogVerbatim(
"CaloParticleDebuggerCaloParticles") <<
"--> Overall simclusters in CP: " <<
cp.simClusters().size();
203 auto const& simcs =
cp.simClusters();
204 for (
size_t j = 0;
j < simcs.size(); ++
j) {
205 LogVerbatim(
"CaloParticleDebuggerCaloParticles") << *(simcs[
j]);
208 for (
auto const& sc :
cp.simClusters()) {
209 for (
auto const&
cl : sc->hits_and_fractions()) {
210 total_sim_energy += detIdToTotalSimEnergy[
cl.first] *
cl.second;
211 total_cp_energy +=
cp.energy() *
cl.second;
215 <<
"--> Overall SC energy (sum using sim energies): " << total_sim_energy;
217 <<
"--> Overall SC energy (sum using CaloP energies): " << total_cp_energy;
220 LogVerbatim(
"CaloParticleDebuggerSimClusters") <<
"\n\n**Printing SimClusters information **";
225 <<
i <<
"\tType: " << simcl.pdgId() <<
"\tEnergy: " << simcl.energy() <<
"\tKey: " <<
i;
226 auto const& simtrack = simcl.g4Tracks()[0];
227 LogVerbatim(
"CaloParticleDebuggerSimClusters") <<
" Crossed Boundary: " << simtrack.crossedBoundary()
228 <<
" Position Boundary: " << simtrack.getPositionAtBoundary()
229 <<
" Momentum Boundary: " << simtrack.getMomentumAtBoundary();
230 double total_sim_energy = 0.;
231 LogVerbatim(
"CaloParticleDebuggerSimClusters") <<
"--> Overall simclusters's size: " << simcl.numberOfRecHits();
232 for (
auto const&
cl : simcl.hits_and_fractions()) {
233 total_sim_energy += detIdToTotalSimEnergy[
cl.first] *
cl.second;
235 LogVerbatim(
"CaloParticleDebuggerSimClusters") << simcl;
237 <<
"--> Overall SimCluster energy (sum using sim energies): " << total_sim_energy;
272 hgtopo[0] = &(
eegeom->topology());
273 hgtopo[1] = &(fhgeom->topology());
275 hgtopo[2] = &(bhgeomnew->topology());
279 for (
unsigned i = 0;
i < 3; ++
i) {
291 const bool isHcal = (collectionTag.instance().find(
"HcalHits") != std::string::npos);
293 for (
auto const&
simHit : *hSimHits) {
295 const uint32_t simId =
simHit.id();
305 int subdet,
layer, cell,
sec, subsec, zp;
308 std::pair<int, int> recoLayerCell = ddd->
simToReco(cell,
layer,
sec, hgtopo[subdet - 3]->detectorType());
309 cell = recoLayerCell.first;
310 layer = recoLayerCell.second;
320 detIdToTotalSimEnergy[
id.rawId()] +=
simHit.energy();
335 desc.add<std::vector<edm::InputTag>>(
"collectionTags",
339 descriptions.
add(
"caloParticleDebugger",
desc);
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Log< level::Info, true > LogVerbatim
edm::InputTag genBarcodes_
edm::EDGetTokenT< std::vector< TrackingParticle > > trackingParticlesToken_
T const * product() const
edm::InputTag simClusters_
edm::EDGetTokenT< std::vector< int > > genBarcodesToken_
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.
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_