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;
Log< level::Info, true > LogVerbatim
edm::EDGetTokenT< std::vector< TrackingParticle > > trackingParticlesToken_
T const * product() const
edm::EDGetTokenT< std::vector< SimCluster > > simClustersToken_
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< std::vector< SimTrack > > simTracksToken_
edm::EDGetTokenT< std::vector< CaloParticle > > caloParticlesToken_
auto const & tracks
cannot be loose
void fillSimHits(std::map< int, float > &, const edm::Event &, const edm::EventSetup &)
edm::EDGetTokenT< std::vector< reco::GenParticle > > genParticlesToken_
edm::EDGetTokenT< std::vector< SimVertex > > simVerticesToken_