51 edm::SimTrackContainer::const_iterator
parentSimTrack(edm::SimTrackContainer::const_iterator thisTrkItr);
52 bool validSimTrack(
unsigned int simTkId, edm::SimTrackContainer::const_iterator thisTrkItr);
107 for (
unsigned int i = 0;
i < 2; ++
i) {
113 std::string dets[7] = {
"EB",
"EE",
"ES",
"HB",
"HE",
"HO",
"HF"};
114 for (
unsigned int i = 0;
i < 7; ++
i) {
131 descriptions.
add(
"HitParentTest",
desc);
136 if (!
tfile.isAvailable()) {
137 edm::LogVerbatim(
"HitParentTest") <<
"TFileService unavailable: no histograms";
142 for (
unsigned int i = 0;
i < 7; ++
i) {
143 sprintf(
name,
"HitType%d",
i);
147 hitType[
i]->GetYaxis()->SetTitle(
"Hits");
148 sprintf(
name,
"RhoVertex%d",
i);
149 sprintf(
title,
"#rho of the vertex for %s Hits",
detector[
i].c_str());
152 hitRho[
i]->GetYaxis()->SetTitle(
"Hits");
153 sprintf(
name,
"ZVertex%d",
i);
154 sprintf(
title,
"z of the vertex for %s Hits",
detector[
i].c_str());
157 hitZ[
i]->GetYaxis()->SetTitle(
"Hits");
163 edm::LogVerbatim(
"HitParentTest") <<
"HitParentTes::Run = " <<
e.id().run() <<
" Event = " <<
e.id().event();
188 <<
" valid[EE]: " << caloHitEE.
isValid() <<
" valid[ES]: " << caloHitES.
isValid()
189 <<
" valid[HC]: " << caloHitHC.
isValid();
217 edm::LogVerbatim(
"HitParentTest") <<
"HitParentTest::Total number of APD hits seen: "
223 <<
" number of APD hits with zero geant track id: "
225 <<
"number of APD hits for which the parent simtrack was not found "
227 <<
"number of APD hits for which no generator particle was "
231 for (
unsigned int det = 0; det < 7; ++det) {
234 <<
"number of hits with zero geant track id: " <<
noParent[det] <<
"\n"
235 <<
"number of hits for which the parent simtrack was not found in "
236 <<
"the simtrack collection: " <<
noSimTrack[det] <<
"\n"
237 <<
"number of hits for which no generator particle was found: "
242 std::vector<int> sorted_pids;
244 sorted_pids.push_back(it->first);
250 edm::LogVerbatim(
"HitParentTest") <<
"HitParentTest::Frequency particle types through the APD "
251 <<
"(pid/frequency):";
252 for (
unsigned i = 0;
i < sorted_pids.size(); ++
i) {
253 int pid = sorted_pids[
i];
254 edm::LogVerbatim(
"HitParentTest") <<
" pid " << std::setw(6) << pid <<
": count " << std::setw(6)
260 for (std::vector<PCaloHit>::const_iterator hit_it =
hits.begin(); hit_it !=
hits.end(); ++hit_it) {
264 int subdet = id_.
subdet();
267 else if (subdet == static_cast<int>(
HcalOuter))
275 int hit_geant_track_id = hit_it->geantTrackId();
277 if (hit_geant_track_id <= 0) {
284 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end() && !
found;
286 if (hit_geant_track_id == (
int)(simTrkItr->trackId())) {
292 <<
"[" <<
detector[
type] <<
"] Match = " <<
match <<
" hit_geant_track_id=" << hit_geant_track_id
293 <<
" particle id=" << simTrkItr->type();
301 int pid = simTrkItr->type();
304 edm::SimTrackContainer::const_iterator oldest_parent_track =
parentSimTrack(simTrkItr);
307 <<
"[" <<
detector[
type] <<
"] Hit pid = " << pid <<
" hit track id = " << hit_geant_track_id
308 <<
" Oldest Parent's Vertex: " << oldest_parent_vertex <<
" rho = " << oldest_parent_vertex.Rho()
309 <<
" Oldest Parent's pid: " << oldest_parent_track->type()
310 <<
" Oldest Parent's track id: " << oldest_parent_track->trackId()
311 <<
"\nHit vertex index: " << simTrkItr->vertIndex() <<
" (tot #vertices: " <<
SimVtx->size() <<
")"
312 <<
"\nHit vertex parent track: " << (*SimVtx)[simTrkItr->vertIndex()].parentIndex()
315 hitRho[
id]->Fill(oldest_parent_vertex.Rho());
316 hitZ[
id]->Fill(oldest_parent_vertex.Z());
330 for (std::vector<PCaloHit>::const_iterator hit_it =
hits.begin(); hit_it !=
hits.end(); ++hit_it) {
331 if (hit_it->depth() ==
depth) {
335 int hit_geant_track_id = hit_it->geantTrackId();
337 if (hit_geant_track_id <= 0) {
342 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end() && !
found;
344 if (hit_geant_track_id == (
int)(simTrkItr->trackId())) {
349 <<
"APDHIT Match = " <<
match <<
" hit_geant_track_id = " << hit_geant_track_id
350 <<
" particle id=" << simTrkItr->type();
357 int apd_pid = simTrkItr->type();
370 edm::SimTrackContainer::const_iterator oldest_parent_track =
parentSimTrack(simTrkItr);
373 <<
"APD hit pid = " << apd_pid <<
" APD hit track id = " << hit_geant_track_id
374 <<
" depth = " << hit_it->depth() <<
" OLDEST PARENT'S VERTEX: " << oldest_parent_vertex
375 <<
" rho = " << oldest_parent_vertex.Rho() <<
" OLDEST PARENT'S PID: " << oldest_parent_track->type()
376 <<
" OLDEST PARENT'S track id: " << oldest_parent_track->trackId() <<
"\n"
377 <<
"APD hit vertex index: " << simTrkItr->vertIndex() <<
" (tot #vertices: " <<
SimVtx->size() <<
")"
379 <<
"APD hit vertex parent track: " << (*SimVtx)[simTrkItr->vertIndex()].parentIndex()
393 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end(); ++simTrkItr) {
394 if ((
int)(simTrkItr->trackId()) ==
id)
402 10000, 10000, 10000, 10000);
406 int vertex_index = oldest_parent_track->vertIndex();
409 if (vertex_index < 0 || vertex_index >= (
int)(
SimVtx->size()))
410 return invalid_vertex;
412 return (*
SimVtx)[vertex_index].position();
416 edm::SimTrackContainer::const_iterator itr =
SimTk->end();
418 int vertIndex = thisTrkItr->vertIndex();
419 int type = thisTrkItr->type();
421 edm::LogVerbatim(
"HitParentTest") <<
"SimTrackParent:: " << thisTrkItr->trackId() <<
" Vertex " << vertIndex
426 else if (vertIndex >= (
int)
SimVtx->size())
429 edm::SimVertexContainer::const_iterator simVtxItr =
SimVtx->begin();
430 for (
int iv = 0;
iv < vertIndex;
iv++)
432 int parent = simVtxItr->parentIndex();
434 if (parent < 0 && simVtxItr != SimVtx->begin()) {
436 for (simVtxItr =
SimVtx->begin(); simVtxItr !=
SimVtx->end(); ++simVtxItr) {
437 if (simVtxItr->parentIndex() > 0) {
439 double dist = pos2.P();
441 parent = simVtxItr->parentIndex();
447 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end(); simTrkItr++) {
448 if ((
int)simTrkItr->trackId() ==
parent && simTrkItr != thisTrkItr)
456 edm::LogVerbatim(
"HitParentTest") <<
"Inside validSimTrack: trackId " << thisTrkItr->trackId() <<
" vtxIndex "
457 << thisTrkItr->vertIndex() <<
" to be matched to " << simTkId;
460 if (thisTrkItr->trackId() == simTkId)
464 int vertIndex = thisTrkItr->vertIndex();
465 if (vertIndex == -1 || vertIndex >= (
int)
SimVtx->size())
467 edm::SimVertexContainer::const_iterator simVtxItr =
SimVtx->begin();
468 for (
int iv = 0;
iv < vertIndex;
iv++)
470 int parent = simVtxItr->parentIndex();
472 if (parent < 0 && simVtxItr != SimVtx->begin()) {
474 for (simVtxItr =
SimVtx->begin(); simVtxItr !=
SimVtx->end(); ++simVtxItr) {
475 if (simVtxItr->parentIndex() > 0) {
477 double dist = pos2.P();
479 parent = simVtxItr->parentIndex();
486 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end(); simTrkItr++) {
487 if ((
int)simTrkItr->trackId() ==
parent && simTrkItr != thisTrkItr)