52 edm::SimTrackContainer::const_iterator
parentSimTrack(edm::SimTrackContainer::const_iterator thisTrkItr);
53 bool validSimTrack(
unsigned int simTkId, edm::SimTrackContainer::const_iterator thisTrkItr);
108 for (
unsigned int i = 0;
i < 2; ++
i) {
114 std::string dets[7] = {
"EB",
"EE",
"ES",
"HB",
"HE",
"HO",
"HF"};
115 for (
unsigned int i = 0;
i < 7; ++
i) {
132 descriptions.
add(
"HitParentTest",
desc);
137 if (!
tfile.isAvailable()) {
138 edm::LogVerbatim(
"HitParentTest") <<
"TFileService unavailable: no histograms";
143 for (
unsigned int i = 0;
i < 7; ++
i) {
144 sprintf(
name,
"HitType%d",
i);
148 hitType[
i]->GetYaxis()->SetTitle(
"Hits");
149 sprintf(
name,
"RhoVertex%d",
i);
150 sprintf(
title,
"#rho of the vertex for %s Hits",
detector[
i].c_str());
153 hitRho[
i]->GetYaxis()->SetTitle(
"Hits");
154 sprintf(
name,
"ZVertex%d",
i);
155 sprintf(
title,
"z of the vertex for %s Hits",
detector[
i].c_str());
158 hitZ[
i]->GetYaxis()->SetTitle(
"Hits");
164 edm::LogVerbatim(
"HitParentTest") <<
"HitParentTes::Run = " <<
e.id().run() <<
" Event = " <<
e.id().event();
189 <<
" valid[EE]: " << caloHitEE.
isValid() <<
" valid[ES]: " << caloHitES.
isValid()
190 <<
" valid[HC]: " << caloHitHC.
isValid();
218 edm::LogVerbatim(
"HitParentTest") <<
"HitParentTest::Total number of APD hits seen: "
224 <<
" number of APD hits with zero geant track id: "
226 <<
"number of APD hits for which the parent simtrack was not found "
228 <<
"number of APD hits for which no generator particle was "
232 for (
unsigned int det = 0; det < 7; ++det) {
235 <<
"number of hits with zero geant track id: " <<
noParent[det] <<
"\n"
236 <<
"number of hits for which the parent simtrack was not found in "
237 <<
"the simtrack collection: " <<
noSimTrack[det] <<
"\n"
238 <<
"number of hits for which no generator particle was found: "
243 std::vector<int> sorted_pids;
245 sorted_pids.push_back(it->first);
251 edm::LogVerbatim(
"HitParentTest") <<
"HitParentTest::Frequency particle types through the APD "
252 <<
"(pid/frequency):";
253 for (
unsigned i = 0;
i < sorted_pids.size(); ++
i) {
254 int pid = sorted_pids[
i];
255 edm::LogVerbatim(
"HitParentTest") <<
" pid " << std::setw(6) << pid <<
": count " << std::setw(6)
261 for (std::vector<PCaloHit>::const_iterator hit_it =
hits.begin(); hit_it !=
hits.end(); ++hit_it) {
265 int subdet = id_.
subdet();
268 else if (subdet == static_cast<int>(
HcalOuter))
276 int hit_geant_track_id = hit_it->geantTrackId();
278 if (hit_geant_track_id <= 0) {
285 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end() && !
found;
287 if (hit_geant_track_id == (
int)(simTrkItr->trackId())) {
293 <<
"[" <<
detector[
type] <<
"] Match = " <<
match <<
" hit_geant_track_id=" << hit_geant_track_id
294 <<
" particle id=" << simTrkItr->type();
302 int pid = simTrkItr->type();
305 edm::SimTrackContainer::const_iterator oldest_parent_track =
parentSimTrack(simTrkItr);
308 <<
"[" <<
detector[
type] <<
"] Hit pid = " << pid <<
" hit track id = " << hit_geant_track_id
309 <<
" Oldest Parent's Vertex: " << oldest_parent_vertex <<
" rho = " << oldest_parent_vertex.Rho()
310 <<
" Oldest Parent's pid: " << oldest_parent_track->type()
311 <<
" Oldest Parent's track id: " << oldest_parent_track->trackId()
312 <<
"\nHit vertex index: " << simTrkItr->vertIndex() <<
" (tot #vertices: " <<
SimVtx->size() <<
")"
313 <<
"\nHit vertex parent track: " << (*SimVtx)[simTrkItr->vertIndex()].parentIndex()
316 hitRho[
id]->Fill(oldest_parent_vertex.Rho());
317 hitZ[
id]->Fill(oldest_parent_vertex.Z());
331 for (std::vector<PCaloHit>::const_iterator hit_it =
hits.begin(); hit_it !=
hits.end(); ++hit_it) {
332 if (hit_it->depth() ==
depth) {
336 int hit_geant_track_id = hit_it->geantTrackId();
338 if (hit_geant_track_id <= 0) {
343 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end() && !
found;
345 if (hit_geant_track_id == (
int)(simTrkItr->trackId())) {
350 <<
"APDHIT Match = " <<
match <<
" hit_geant_track_id = " << hit_geant_track_id
351 <<
" particle id=" << simTrkItr->type();
358 int apd_pid = simTrkItr->type();
371 edm::SimTrackContainer::const_iterator oldest_parent_track =
parentSimTrack(simTrkItr);
374 <<
"APD hit pid = " << apd_pid <<
" APD hit track id = " << hit_geant_track_id
375 <<
" depth = " << hit_it->depth() <<
" OLDEST PARENT'S VERTEX: " << oldest_parent_vertex
376 <<
" rho = " << oldest_parent_vertex.Rho() <<
" OLDEST PARENT'S PID: " << oldest_parent_track->type()
377 <<
" OLDEST PARENT'S track id: " << oldest_parent_track->trackId() <<
"\n"
378 <<
"APD hit vertex index: " << simTrkItr->vertIndex() <<
" (tot #vertices: " <<
SimVtx->size() <<
")"
380 <<
"APD hit vertex parent track: " << (*SimVtx)[simTrkItr->vertIndex()].parentIndex()
394 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end(); ++simTrkItr) {
395 if ((
int)(simTrkItr->trackId()) ==
id)
403 10000, 10000, 10000, 10000);
407 int vertex_index = oldest_parent_track->vertIndex();
410 if (vertex_index < 0 || vertex_index >= (
int)(
SimVtx->size()))
411 return invalid_vertex;
413 return (*
SimVtx)[vertex_index].position();
417 edm::SimTrackContainer::const_iterator
itr =
SimTk->end();
419 int vertIndex = thisTrkItr->vertIndex();
420 int type = thisTrkItr->type();
422 edm::LogVerbatim(
"HitParentTest") <<
"SimTrackParent:: " << thisTrkItr->trackId() <<
" Vertex " << vertIndex
427 else if (vertIndex >= (
int)
SimVtx->size())
430 edm::SimVertexContainer::const_iterator simVtxItr =
SimVtx->begin();
431 for (
int iv = 0; iv < vertIndex; iv++)
433 int parent = simVtxItr->parentIndex();
435 if (parent < 0 && simVtxItr != SimVtx->begin()) {
437 for (simVtxItr =
SimVtx->begin(); simVtxItr !=
SimVtx->end(); ++simVtxItr) {
438 if (simVtxItr->parentIndex() > 0) {
440 double dist = pos2.P();
442 parent = simVtxItr->parentIndex();
448 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end(); simTrkItr++) {
449 if ((
int)simTrkItr->trackId() ==
parent && simTrkItr != thisTrkItr)
457 edm::LogVerbatim(
"HitParentTest") <<
"Inside validSimTrack: trackId " << thisTrkItr->trackId() <<
" vtxIndex "
458 << thisTrkItr->vertIndex() <<
" to be matched to " << simTkId;
461 if (thisTrkItr->trackId() == simTkId)
465 int vertIndex = thisTrkItr->vertIndex();
466 if (vertIndex == -1 || vertIndex >= (
int)
SimVtx->size())
468 edm::SimVertexContainer::const_iterator simVtxItr =
SimVtx->begin();
469 for (
int iv = 0; iv < vertIndex; iv++)
471 int parent = simVtxItr->parentIndex();
473 if (parent < 0 && simVtxItr != SimVtx->begin()) {
475 for (simVtxItr =
SimVtx->begin(); simVtxItr !=
SimVtx->end(); ++simVtxItr) {
476 if (simVtxItr->parentIndex() > 0) {
478 double dist = pos2.P();
480 parent = simVtxItr->parentIndex();
487 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end(); simTrkItr++) {
488 if ((
int)simTrkItr->trackId() ==
parent && simTrkItr != thisTrkItr)