CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
CaloParticleDebugger Class Reference
Inheritance diagram for CaloParticleDebugger:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 CaloParticleDebugger (const edm::ParameterSet &)
 
 ~CaloParticleDebugger () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector
< ProductResolverIndexAndSkipBit >
const & 
itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 
void fillSimHits (std::map< int, float > &, const edm::Event &, const edm::EventSetup &)
 

Private Attributes

edm::InputTag caloParticles_
 
edm::EDGetTokenT< std::vector
< CaloParticle > > 
caloParticlesToken_
 
std::vector< edm::InputTagcollectionTags_
 
std::vector< edm::EDGetTokenT
< std::vector< PCaloHit > > > 
collectionTagsToken_
 
edm::InputTag genParticles_
 
edm::EDGetTokenT< std::vector
< reco::GenParticle > > 
genParticlesToken_
 
int geometryType_ = 0
 
edm::ESGetToken< CaloGeometry,
CaloGeometryRecord
geomToken_
 
edm::InputTag simClusters_
 
edm::EDGetTokenT< std::vector
< SimCluster > > 
simClustersToken_
 
edm::InputTag simTracks_
 
edm::EDGetTokenT< std::vector
< SimTrack > > 
simTracksToken_
 
edm::InputTag simVertices_
 
edm::EDGetTokenT< std::vector
< SimVertex > > 
simVerticesToken_
 
edm::InputTag trackingParticles_
 
edm::EDGetTokenT< std::vector
< TrackingParticle > > 
trackingParticlesToken_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 47 of file CaloParticleDebugger.cc.

Constructor & Destructor Documentation

CaloParticleDebugger::CaloParticleDebugger ( const edm::ParameterSet iConfig)
explicit

Definition at line 89 of file CaloParticleDebugger.cc.

References caloParticles_, caloParticlesToken_, collectionTags_, collectionTagsToken_, edm::ConsumesCollector::consumes(), edm::EDConsumerBase::consumesCollector(), edm::ConsumesCollector::esConsumes(), genParticles_, genParticlesToken_, geomToken_, simClusters_, simClustersToken_, simTracks_, simTracksToken_, simVertices_, simVerticesToken_, trackingParticles_, and trackingParticlesToken_.

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")),
96  collectionTags_(iConfig.getParameter<std::vector<edm::InputTag>>("collectionTags")) {
98  simTracksToken_ = iC.consumes<std::vector<SimTrack>>(simTracks_);
99  genParticlesToken_ = iC.consumes<std::vector<reco::GenParticle>>(genParticles_);
100  simVerticesToken_ = iC.consumes<std::vector<SimVertex>>(simVertices_);
101  trackingParticlesToken_ = iC.consumes<std::vector<TrackingParticle>>(trackingParticles_);
102  caloParticlesToken_ = iC.consumes<std::vector<CaloParticle>>(caloParticles_);
103  simClustersToken_ = iC.consumes<std::vector<SimCluster>>(simClusters_);
104  for (auto const& collectionTag : collectionTags_) {
105  collectionTagsToken_.push_back(iC.consumes<std::vector<PCaloHit>>(collectionTag));
106  }
108 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< std::vector< TrackingParticle > > trackingParticlesToken_
edm::EDGetTokenT< std::vector< SimCluster > > simClustersToken_
std::vector< edm::EDGetTokenT< std::vector< PCaloHit > > > collectionTagsToken_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::EDGetTokenT< std::vector< SimTrack > > simTracksToken_
edm::EDGetTokenT< std::vector< CaloParticle > > caloParticlesToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< std::vector< reco::GenParticle > > genParticlesToken_
edm::InputTag trackingParticles_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
std::vector< edm::InputTag > collectionTags_
edm::EDGetTokenT< std::vector< SimVertex > > simVerticesToken_
CaloParticleDebugger::~CaloParticleDebugger ( )
override

Definition at line 110 of file CaloParticleDebugger.cc.

110 {}

Member Function Documentation

void CaloParticleDebugger::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 117 of file CaloParticleDebugger.cc.

References funct::abs(), SplitLinear::begin, caloParticlesToken_, haddnano::cl, CommonMethods::cp(), dataset::end, fillSimHits(), genParticleCandidates2GenParticles_cfi::genParticles, runTauDisplay::genParticlesH, genParticlesToken_, edm::Event::getByToken(), runTauDisplay::gp, mps_fire::i, dqmiolumiharvest::j, SimTracksters_cff::simclusters, simClustersToken_, simTracksToken_, simVerticesToken_, submitPVValidationJobs::t, cmsswSequenceInfo::tp, trackingParticlesToken_, tracks, findQualityFiles::v, and beam_dqm_sourceclient-live_cfg::vertices.

117  {
118  using namespace edm;
119  using std::begin;
120  using std::end;
121  using std::iota;
122  using std::sort;
123 
127  edm::Handle<std::vector<TrackingParticle>> trackingParticlesH;
130 
131  iEvent.getByToken(simTracksToken_, simTracksH);
132  auto const& tracks = *simTracksH.product();
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) {
136  return tracks[i].momentum().eta() < tracks[j].momentum().eta();
137  });
138 
140  auto const& genParticles = *genParticlesH.product();
141  std::vector<int> sorted_genParticles_idx(genParticles.size());
142  iota(begin(sorted_genParticles_idx), end(sorted_genParticles_idx), 0);
143  sort(begin(sorted_genParticles_idx), end(sorted_genParticles_idx), [&genParticles](int i, int j) {
144  return genParticles[i].momentum().eta() < genParticles[j].momentum().eta();
145  });
146 
147  iEvent.getByToken(simVerticesToken_, simVerticesH);
148  auto const& vertices = *simVerticesH.product();
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) {
152  return vertices[i].vertexId() < vertices[j].vertexId();
153  });
154 
155  iEvent.getByToken(trackingParticlesToken_, trackingParticlesH);
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();
161  });
162 
163  iEvent.getByToken(caloParticlesToken_, caloParticlesH);
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();
169  });
170 
171  iEvent.getByToken(simClustersToken_, simClustersH);
172  auto const& simclusters = *simClustersH.product();
173  std::vector<int> sorted_simcl_idx(simclusters.size());
174  iota(begin(sorted_simcl_idx), end(sorted_simcl_idx), 0);
175  sort(begin(sorted_simcl_idx), end(sorted_simcl_idx), [&simclusters](int i, int j) {
176  return simclusters[i].eta() < simclusters[j].eta();
177  });
178 
179  // Let's first fill in hits information
180  std::map<int, float> detIdToTotalSimEnergy;
181  fillSimHits(detIdToTotalSimEnergy, iEvent, iSetup);
182 
183  int idx = 0;
184 
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) {
189  auto const& t = tracks[i];
190  LogVerbatim("CaloParticleDebuggerSimTracks") << idx << "\t" << t.trackId() << "\t" << t;
191  LogVerbatim("CaloParticleDebuggerSimTracks")
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;
196  idx++;
197  }
198 
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) {
202  auto const& gp = genParticles[i];
203  LogVerbatim("CaloParticleDebuggerGenParticles")
204  << i << "\t" << gp.pdgId() << "\t" << gp.momentum() << "\t" << gp.vertex();
205  }
206 
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) {
210  auto const& v = vertices[i];
211  LogVerbatim("CaloParticleDebuggerSimVertices") << i << "\t" << v;
212  }
213 
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;
218  }
219 
220  LogVerbatim("CaloParticleDebuggerCaloParticles") << "\n\n**Printing CaloParticles information **";
221  idx = 0;
222  for (auto i : sorted_cp_idx) {
223  auto const& cp = calopart[i];
224  LogVerbatim("CaloParticleDebuggerCaloParticles")
225  << "\n\n"
226  << idx++ << " |Eta|: " << std::abs(cp.momentum().eta()) << "\tType: " << cp.pdgId()
227  << "\tEnergy: " << cp.energy() << "\tIdx: " << cp.g4Tracks()[0].trackId(); // << cp ;
228  double total_sim_energy = 0.;
229  double total_cp_energy = 0.;
230  LogVerbatim("CaloParticleDebuggerCaloParticles") << "--> Overall simclusters in CP: " << cp.simClusters().size();
231  // All the next mess just to print the simClusters ordered
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();
237  });
238  for (auto i : sorted_sc_idx) {
239  LogVerbatim("CaloParticleDebuggerCaloParticles") << *(simcs[i]);
240  }
241 
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;
246  }
247  }
248  LogVerbatim("CaloParticleDebuggerCaloParticles")
249  << "--> Overall SC energy (sum using sim energies): " << total_sim_energy;
250  LogVerbatim("CaloParticleDebuggerCaloParticles")
251  << "--> Overall SC energy (sum using CaloP energies): " << total_cp_energy;
252  }
253 
254  idx = 0;
255  LogVerbatim("CaloParticleDebuggerSimClusters") << "\n\n**Printing SimClusters information **";
256  for (auto i : sorted_simcl_idx) {
257  auto const& simcl = simclusters[i];
258  LogVerbatim("CaloParticleDebuggerSimClusters")
259  << "\n\n"
260  << idx++ << " |Eta|: " << std::abs(simcl.momentum().eta()) << "\tType: " << simcl.pdgId()
261  << "\tEnergy: " << simcl.energy() << "\tKey: " << i; // << simcl ;
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;
270  }
271  LogVerbatim("CaloParticleDebuggerSimClusters") << simcl;
272  LogVerbatim("CaloParticleDebuggerSimClusters")
273  << "--> Overall SimCluster energy (sum using sim energies): " << total_sim_energy;
274  }
275 }
Log< level::Info, true > LogVerbatim
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::EDGetTokenT< std::vector< TrackingParticle > > trackingParticlesToken_
auto const & tracks
cannot be loose
tuple cl
Definition: haddnano.py:49
edm::EDGetTokenT< std::vector< SimCluster > > simClustersToken_
tuple genParticlesH
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< std::vector< SimTrack > > simTracksToken_
edm::EDGetTokenT< std::vector< CaloParticle > > caloParticlesToken_
void fillSimHits(std::map< int, float > &, const edm::Event &, const edm::EventSetup &)
edm::EDGetTokenT< std::vector< reco::GenParticle > > genParticlesToken_
string end
Definition: dataset.py:937
edm::EDGetTokenT< std::vector< SimVertex > > simVerticesToken_
void CaloParticleDebugger::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 278 of file CaloParticleDebugger.cc.

278 {}
void CaloParticleDebugger::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 281 of file CaloParticleDebugger.cc.

281 {}
void CaloParticleDebugger::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 360 of file CaloParticleDebugger.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, and HLT_FULL_cff::InputTag.

360  {
362  desc.add<edm::InputTag>("simTracks", edm::InputTag("g4SimHits"));
363  desc.add<edm::InputTag>("genParticles", edm::InputTag("genParticles"));
364  desc.add<edm::InputTag>("simVertices", edm::InputTag("g4SimHits"));
365  desc.add<edm::InputTag>("trackingParticles", edm::InputTag("mix", "MergedTrackTruth"));
366  desc.add<edm::InputTag>("caloParticles", edm::InputTag("mix", "MergedCaloTruth"));
367  desc.add<edm::InputTag>("simClusters", edm::InputTag("mix", "MergedCaloTruth"));
368  desc.add<std::vector<edm::InputTag>>("collectionTags",
369  {edm::InputTag("g4SimHits", "HGCHitsEE"),
370  edm::InputTag("g4SimHits", "HGCHitsHEfront"),
371  edm::InputTag("g4SimHits", "HcalHits")});
372  descriptions.add("caloParticleDebugger", desc);
373 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void CaloParticleDebugger::fillSimHits ( std::map< int, float > &  detIdToTotalSimEnergy,
const edm::Event iEvent,
const edm::EventSetup iSetup 
)
private

Definition at line 283 of file CaloParticleDebugger.cc.

References cms::cuda::assert(), collectionTags_, collectionTagsToken_, HGCalTopology::dddConstants(), HcalTopology::dddConstants(), EcalMappingRecord_cfi::eegeom, DetId::Forward, ForwardEmpty, relativeConstraints::geom, geometryType_, geomToken_, edm::Event::getByToken(), edm::EventSetup::getHandle(), DetId::Hcal, HcalEndcap, DetId::HGCalEE, DetId::HGCalHSc, DetId::HGCalHSi, HGCEE, HGCHEF, mps_fire::i, gpuClustering::id, phase1PixelTopology::layer, HcalHitRelabeller::relabel(), HGCalDDDConstants::simToReco(), HcalDetId::subdet(), unpackBuffers-CaloStage2::token, HcalGeometry::topology(), HGCalGeometry::topology(), and HGCalTestNumbering::unpackHexagonIndex().

Referenced by analyze().

285  {
286  // Taken needed quantities from the EventSetup
287  const auto& geom = iSetup.getHandle(geomToken_);
288  const HGCalGeometry *eegeom = nullptr, *fhgeom = nullptr, *bhgeomnew = nullptr;
289  const HcalGeometry* bhgeom = nullptr;
290  const HGCalDDDConstants* hgddd[3];
291  const HGCalTopology* hgtopo[3];
292  const HcalDDDRecConstants* hcddd = nullptr;
293  eegeom =
294  static_cast<const HGCalGeometry*>(geom->getSubdetectorGeometry(DetId::HGCalEE, ForwardSubdetector::ForwardEmpty));
295  //check if it's the new geometry
296  if (eegeom) {
297  geometryType_ = 1;
298  fhgeom = static_cast<const HGCalGeometry*>(
299  geom->getSubdetectorGeometry(DetId::HGCalHSi, ForwardSubdetector::ForwardEmpty));
300  bhgeomnew = static_cast<const HGCalGeometry*>(
301  geom->getSubdetectorGeometry(DetId::HGCalHSc, ForwardSubdetector::ForwardEmpty));
302  } else {
303  geometryType_ = 0;
304  eegeom = static_cast<const HGCalGeometry*>(geom->getSubdetectorGeometry(DetId::Forward, HGCEE));
305  fhgeom = static_cast<const HGCalGeometry*>(geom->getSubdetectorGeometry(DetId::Forward, HGCHEF));
306  bhgeom = static_cast<const HcalGeometry*>(geom->getSubdetectorGeometry(DetId::Hcal, HcalEndcap));
307  }
308  hgtopo[0] = &(eegeom->topology());
309  hgtopo[1] = &(fhgeom->topology());
310  if (bhgeomnew)
311  hgtopo[2] = &(bhgeomnew->topology());
312 
313  for (unsigned i = 0; i < 3; ++i) {
314  if (hgtopo[i])
315  hgddd[i] = &(hgtopo[i]->dddConstants());
316  }
317 
318  if (bhgeom)
319  hcddd = bhgeom->topology().dddConstants();
320 
321  // loop over the collections
322  int token = 0;
323  for (auto const& collectionTag : collectionTags_) {
325  const bool isHcal = (collectionTag.instance().find("HcalHits") != std::string::npos);
326  iEvent.getByToken(collectionTagsToken_[token++], hSimHits);
327  for (auto const& simHit : *hSimHits) {
328  DetId id(0);
329  const uint32_t simId = simHit.id();
330  if (geometryType_ == 1) {
331  //no test numbering in new geometry
332  id = simId;
333  } else if (isHcal) {
334  assert(hcddd);
335  HcalDetId hid = HcalHitRelabeller::relabel(simId, hcddd);
336  if (hid.subdet() == HcalEndcap)
337  id = hid;
338  } else {
339  int subdet, layer, cell, sec, subsec, zp;
340  HGCalTestNumbering::unpackHexagonIndex(simId, subdet, zp, layer, sec, subsec, cell);
341  const HGCalDDDConstants* ddd = hgddd[subdet - 3];
342  std::pair<int, int> recoLayerCell = ddd->simToReco(cell, layer, sec, hgtopo[subdet - 3]->detectorType());
343  cell = recoLayerCell.first;
344  layer = recoLayerCell.second;
345  // skip simhits with bad barcodes or non-existant layers
346  if (layer == -1 || simHit.geantTrackId() == 0)
347  continue;
348  id = HGCalDetId((ForwardSubdetector)subdet, zp, layer, subsec, sec, cell);
349  }
350 
351  if (DetId(0) == id)
352  continue;
353 
354  detIdToTotalSimEnergy[id.rawId()] += simHit.energy();
355  }
356  } // end of loop over InputTags
357 }
const HcalDDDRecConstants * dddConstants() const
Definition: HcalTopology.h:164
uint16_t *__restrict__ id
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
ForwardSubdetector
assert(be >=bs)
constexpr std::array< uint8_t, layerIndexSize > layer
const HcalTopology & topology() const
Definition: HcalGeometry.h:111
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
std::vector< edm::EDGetTokenT< std::vector< PCaloHit > > > collectionTagsToken_
const HGCalTopology & topology() const
Definition: DetId.h:17
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
DetId relabel(const uint32_t testId) const
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
std::vector< edm::InputTag > collectionTags_

Member Data Documentation

edm::InputTag CaloParticleDebugger::caloParticles_
private

Definition at line 63 of file CaloParticleDebugger.cc.

Referenced by CaloParticleDebugger().

edm::EDGetTokenT<std::vector<CaloParticle> > CaloParticleDebugger::caloParticlesToken_
private

Definition at line 70 of file CaloParticleDebugger.cc.

Referenced by analyze(), and CaloParticleDebugger().

std::vector<edm::InputTag> CaloParticleDebugger::collectionTags_
private

Definition at line 65 of file CaloParticleDebugger.cc.

Referenced by CaloParticleDebugger(), and fillSimHits().

std::vector<edm::EDGetTokenT<std::vector<PCaloHit> > > CaloParticleDebugger::collectionTagsToken_
private

Definition at line 72 of file CaloParticleDebugger.cc.

Referenced by CaloParticleDebugger(), and fillSimHits().

edm::InputTag CaloParticleDebugger::genParticles_
private

Definition at line 60 of file CaloParticleDebugger.cc.

Referenced by CaloParticleDebugger().

edm::EDGetTokenT<std::vector<reco::GenParticle> > CaloParticleDebugger::genParticlesToken_
private

Definition at line 67 of file CaloParticleDebugger.cc.

Referenced by analyze(), and CaloParticleDebugger().

int CaloParticleDebugger::geometryType_ = 0
private

Definition at line 74 of file CaloParticleDebugger.cc.

Referenced by fillSimHits().

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> CaloParticleDebugger::geomToken_
private

Definition at line 73 of file CaloParticleDebugger.cc.

Referenced by CaloParticleDebugger(), and fillSimHits().

edm::InputTag CaloParticleDebugger::simClusters_
private

Definition at line 64 of file CaloParticleDebugger.cc.

Referenced by CaloParticleDebugger().

edm::EDGetTokenT<std::vector<SimCluster> > CaloParticleDebugger::simClustersToken_
private

Definition at line 71 of file CaloParticleDebugger.cc.

Referenced by analyze(), and CaloParticleDebugger().

edm::InputTag CaloParticleDebugger::simTracks_
private

Definition at line 59 of file CaloParticleDebugger.cc.

Referenced by CaloParticleDebugger().

edm::EDGetTokenT<std::vector<SimTrack> > CaloParticleDebugger::simTracksToken_
private

Definition at line 66 of file CaloParticleDebugger.cc.

Referenced by analyze(), and CaloParticleDebugger().

edm::InputTag CaloParticleDebugger::simVertices_
private

Definition at line 61 of file CaloParticleDebugger.cc.

Referenced by CaloParticleDebugger().

edm::EDGetTokenT<std::vector<SimVertex> > CaloParticleDebugger::simVerticesToken_
private

Definition at line 68 of file CaloParticleDebugger.cc.

Referenced by analyze(), and CaloParticleDebugger().

edm::InputTag CaloParticleDebugger::trackingParticles_
private

Definition at line 62 of file CaloParticleDebugger.cc.

Referenced by CaloParticleDebugger().

edm::EDGetTokenT<std::vector<TrackingParticle> > CaloParticleDebugger::trackingParticlesToken_
private

Definition at line 69 of file CaloParticleDebugger.cc.

Referenced by analyze(), and CaloParticleDebugger().