58 edm::SimTrackContainer::const_iterator
track);
61 edm::SimTrackContainer::const_iterator thisTrkItr);
65 edm::SimTrackContainer::const_iterator thisTrkItr);
99 : sourceLabel(ps.getUntrackedParameter<
std::
string>(
"SourceLabel",
"VtxSmeared")),
100 g4Label_(ps.getUntrackedParameter<
std::
string>(
"ModuleLabel",
"g4SimHits")),
101 hitLabEB_(ps.getUntrackedParameter<
std::
string>(
"EBCollection",
"EcalHitsEB")),
102 hitLabEE_(ps.getUntrackedParameter<
std::
string>(
"EECollection",
"EcalHitsEE")),
103 hitLabES_(ps.getUntrackedParameter<
std::
string>(
"ESCollection",
"EcalHitsES")),
104 hitLabHC_(ps.getUntrackedParameter<
std::
string>(
"HCCollection",
"HcalHits")),
116 for (
unsigned int i = 0;
i < 2; ++
i) {
122 std::string dets[7] = {
"EB",
"EE",
"ES",
"HB",
"HE",
"HO",
"HF"};
123 for (
unsigned int i = 0;
i < 7; ++
i) {
140 descriptions.
add(
"HitParentTest",
desc);
145 if (!
tfile.isAvailable()) {
146 edm::LogVerbatim(
"HitParentTest") <<
"TFileService unavailable: no histograms";
151 for (
unsigned int i = 0;
i < 7; ++
i) {
152 sprintf(
name,
"HitType%d",
i);
156 hitType[
i]->GetYaxis()->SetTitle(
"Hits");
157 sprintf(
name,
"RhoVertex%d",
i);
158 sprintf(
title,
"#rho of the vertex for %s Hits",
detector[
i].c_str());
161 hitRho[
i]->GetYaxis()->SetTitle(
"Hits");
162 sprintf(
name,
"ZVertex%d",
i);
163 sprintf(
title,
"z of the vertex for %s Hits",
detector[
i].c_str());
166 hitZ[
i]->GetYaxis()->SetTitle(
"Hits");
172 edm::LogVerbatim(
"HitParentTest") <<
"HitParentTes::Run = " <<
e.id().run() <<
" Event = " <<
e.id().event();
193 <<
" valid[EE]: " << caloHitEE.
isValid() <<
" valid[ES]: " << caloHitES.
isValid()
194 <<
" valid[HC]: " << caloHitHC.
isValid();
222 edm::LogVerbatim(
"HitParentTest") <<
"HitParentTest::Total number of APD hits seen: " 228 <<
" number of APD hits with zero geant track id: " 230 <<
"number of APD hits for which the parent simtrack was not found " 232 <<
"number of APD hits for which no generator particle was " 236 for (
unsigned int det = 0; det < 7; ++det) {
239 <<
"number of hits with zero geant track id: " <<
noParent[det] <<
"\n" 240 <<
"number of hits for which the parent simtrack was not found in " 241 <<
"the simtrack collection: " <<
noSimTrack[det] <<
"\n" 242 <<
"number of hits for which no generator particle was found: " 247 std::vector<int> sorted_pids;
249 sorted_pids.push_back(
it->first);
255 edm::LogVerbatim(
"HitParentTest") <<
"HitParentTest::Frequency particle types through the APD " 256 <<
"(pid/frequency):";
257 for (
unsigned i = 0;
i < sorted_pids.size(); ++
i) {
258 int pid = sorted_pids[
i];
259 edm::LogVerbatim(
"HitParentTest") <<
" pid " << std::setw(6) << pid <<
": count " << std::setw(6)
268 for (std::vector<PCaloHit>::const_iterator hit_it =
hits.begin(); hit_it !=
hits.end(); ++hit_it) {
272 int subdet = id_.
subdet();
275 else if (subdet == static_cast<int>(
HcalOuter))
283 int hit_geant_track_id = hit_it->geantTrackId();
285 if (hit_geant_track_id <= 0) {
292 for (edm::SimTrackContainer::const_iterator simTrkItr = simTk->begin(); simTrkItr != simTk->end() && !
found;
294 if (hit_geant_track_id == (
int)(simTrkItr->trackId())) {
300 <<
"[" <<
detector[
type] <<
"] Match = " <<
match <<
" hit_geant_track_id=" << hit_geant_track_id
301 <<
" particle id=" << simTrkItr->type();
309 int pid = simTrkItr->type();
312 edm::SimTrackContainer::const_iterator oldest_parent_track =
parentSimTrack(simTk, simVtx, simTrkItr);
315 <<
"[" <<
detector[
type] <<
"] Hit pid = " << pid <<
" hit track id = " << hit_geant_track_id
316 <<
" Oldest Parent's Vertex: " << oldest_parent_vertex <<
" rho = " << oldest_parent_vertex.Rho()
317 <<
" Oldest Parent's pid: " << oldest_parent_track->type()
318 <<
" Oldest Parent's track id: " << oldest_parent_track->trackId()
319 <<
"\nHit vertex index: " << simTrkItr->vertIndex() <<
" (tot #vertices: " << simVtx->size() <<
")" 320 <<
"\nHit vertex parent track: " << (*simVtx)[simTrkItr->vertIndex()].parentIndex()
321 <<
" present=" <<
simTrackPresent(simTk, (*simVtx)[simTrkItr->vertIndex()].parentIndex());
323 hitRho[
id]->Fill(oldest_parent_vertex.Rho());
324 hitZ[
id]->Fill(oldest_parent_vertex.Z());
341 for (std::vector<PCaloHit>::const_iterator hit_it =
hits.begin(); hit_it !=
hits.end(); ++hit_it) {
342 if (hit_it->depth() ==
depth) {
346 int hit_geant_track_id = hit_it->geantTrackId();
348 if (hit_geant_track_id <= 0) {
353 for (edm::SimTrackContainer::const_iterator simTrkItr = simTk->begin(); simTrkItr != simTk->end() && !
found;
355 if (hit_geant_track_id == (
int)(simTrkItr->trackId())) {
360 <<
"APDHIT Match = " <<
match <<
" hit_geant_track_id = " << hit_geant_track_id
361 <<
" particle id=" << simTrkItr->type();
368 int apd_pid = simTrkItr->type();
381 edm::SimTrackContainer::const_iterator oldest_parent_track =
parentSimTrack(simTk, simVtx, simTrkItr);
384 <<
"APD hit pid = " << apd_pid <<
" APD hit track id = " << hit_geant_track_id
385 <<
" depth = " << hit_it->depth() <<
" OLDEST PARENT'S VERTEX: " << oldest_parent_vertex
386 <<
" rho = " << oldest_parent_vertex.Rho() <<
" OLDEST PARENT'S PID: " << oldest_parent_track->type()
387 <<
" OLDEST PARENT'S track id: " << oldest_parent_track->trackId() <<
"\n" 388 <<
"APD hit vertex index: " << simTrkItr->vertIndex() <<
" (tot #vertices: " << simVtx->size() <<
")" 390 <<
"APD hit vertex parent track: " << (*simVtx)[simTrkItr->vertIndex()].parentIndex()
391 <<
" present=" <<
simTrackPresent(simTk, (*simVtx)[simTrkItr->vertIndex()].parentIndex());
404 for (edm::SimTrackContainer::const_iterator simTrkItr = simTk->begin(); simTrkItr != simTk->end(); ++simTrkItr) {
405 if ((
int)(simTrkItr->trackId()) ==
id)
413 edm::SimTrackContainer::const_iterator
track) {
415 10000, 10000, 10000, 10000);
417 edm::SimTrackContainer::const_iterator oldest_parent_track =
parentSimTrack(simTk, simVtx,
track);
419 int vertex_index = oldest_parent_track->vertIndex();
422 if (vertex_index < 0 || vertex_index >= (
int)(simVtx->size()))
423 return invalid_vertex;
425 return (*simVtx)[vertex_index].position();
430 edm::SimTrackContainer::const_iterator thisTrkItr) {
431 edm::SimTrackContainer::const_iterator itr = simTk->end();
433 int vertIndex = thisTrkItr->vertIndex();
434 int type = thisTrkItr->type();
436 edm::LogVerbatim(
"HitParentTest") <<
"SimTrackParent:: " << thisTrkItr->trackId() <<
" Vertex " << vertIndex
441 else if (vertIndex >= (
int)simVtx->size())
444 edm::SimVertexContainer::const_iterator simVtxItr = simVtx->begin();
445 for (
int iv = 0;
iv < vertIndex;
iv++)
447 int parent = simVtxItr->parentIndex();
449 if (parent < 0 && simVtxItr != simVtx->begin()) {
451 for (simVtxItr = simVtx->begin(); simVtxItr != simVtx->end(); ++simVtxItr) {
452 if (simVtxItr->parentIndex() > 0) {
454 double dist = pos2.P();
456 parent = simVtxItr->parentIndex();
462 for (edm::SimTrackContainer::const_iterator simTrkItr = simTk->begin(); simTrkItr != simTk->end(); simTrkItr++) {
463 if ((
int)simTrkItr->trackId() ==
parent && simTrkItr != thisTrkItr)
472 unsigned int simTkId,
473 edm::SimTrackContainer::const_iterator thisTrkItr) {
474 edm::LogVerbatim(
"HitParentTest") <<
"Inside validSimTrack: trackId " << thisTrkItr->trackId() <<
" vtxIndex " 475 << thisTrkItr->vertIndex() <<
" to be matched to " << simTkId;
478 if (thisTrkItr->trackId() == simTkId)
482 int vertIndex = thisTrkItr->vertIndex();
483 if (vertIndex == -1 || vertIndex >= (
int)simVtx->size())
485 edm::SimVertexContainer::const_iterator simVtxItr = simVtx->begin();
486 for (
int iv = 0;
iv < vertIndex;
iv++)
488 int parent = simVtxItr->parentIndex();
490 if (parent < 0 && simVtxItr != simVtx->begin()) {
492 for (simVtxItr = simVtx->begin(); simVtxItr != simVtx->end(); ++simVtxItr) {
493 if (simVtxItr->parentIndex() > 0) {
495 double dist = pos2.P();
497 parent = simVtxItr->parentIndex();
504 for (edm::SimTrackContainer::const_iterator simTrkItr = simTk->begin(); simTrkItr != simTk->end(); simTrkItr++) {
505 if ((
int)simTrkItr->trackId() ==
parent && simTrkItr != thisTrkItr)
static const std::string kSharedResource
Log< level::Info, true > LogVerbatim
bool simTrackPresent(const edm::Handle< edm::SimTrackContainer > &, int id)
std::vector< PCaloHit > PCaloHitContainer
void analyzeHits(const std::vector< PCaloHit > &, const edm::Handle< edm::SimTrackContainer > &, const edm::Handle< edm::SimVertexContainer > &, int type)
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
edm::SimTrackContainer::const_iterator parentSimTrack(const edm::Handle< edm::SimTrackContainer > &, const edm::Handle< edm::SimVertexContainer > &, edm::SimTrackContainer::const_iterator thisTrkItr)
unsigned int noGenParticle[7]
bool operator()(int pid1, int pid2) const
bool validSimTrack(const edm::Handle< edm::SimTrackContainer > &, const edm::Handle< edm::SimVertexContainer > &, unsigned int simTkId, edm::SimTrackContainer::const_iterator thisTrkItr)
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_eb_
unsigned int num_apd_hits_no_simtrack[2]
const std::map< int, unsigned > & particle_type_count
unsigned int noSimTrack[7]
const std::string hitLabES_
constexpr HcalSubdetector subdet() const
get the subdetector
unsigned int num_apd_hits_no_gen_particle[2]
void analyze(const edm::Event &e, const edm::EventSetup &c) override
const std::string sourceLabel
const std::string hitLabEE_
const edm::EDGetTokenT< edm::SimVertexContainer > tok_vtx_
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_hc_
void endRun(edm::Run const &, edm::EventSetup const &) override
std::map< int, unsigned > particle_type_count
#define DEFINE_FWK_MODULE(type)
HitParentTest(const edm::ParameterSet &ps)
unsigned int num_apd_hits_no_parent[2]
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_es_
const edm::EDGetTokenT< edm::SimTrackContainer > tok_tk_
HitParentTestComparison(const std::map< int, unsigned > &_particle_type_count)
const std::string g4Label_
std::vector< SimVertex > SimVertexContainer
void beginRun(edm::Run const &, edm::EventSetup const &) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
unsigned int total_num_apd_hits_seen[2]
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_ee_
unsigned int totalHits[7]
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
math::XYZTLorentzVectorD getOldestParentVertex(const edm::Handle< edm::SimTrackContainer > &, const edm::Handle< edm::SimVertexContainer > &, edm::SimTrackContainer::const_iterator track)
~HitParentTest() override
std::vector< SimTrack > SimTrackContainer
const std::string hitLabHC_
void analyzeAPDHits(const std::vector< PCaloHit > &, const edm::Handle< edm::SimTrackContainer > &, const edm::Handle< edm::SimVertexContainer > &, int depth)
const std::string hitLabEB_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)