27 #include <boost/format.hpp>
56 edm::SimTrackContainer::const_iterator
parentSimTrack(edm::SimTrackContainer::const_iterator thisTrkItr);
57 bool validSimTrack(
unsigned int simTkId, edm::SimTrackContainer::const_iterator thisTrkItr);
112 for (
unsigned int i = 0;
i < 2; ++
i) {
118 std::string dets[7] = {
"EB",
"EE",
"ES",
"HB",
"HE",
"HO",
"HF"};
119 for (
unsigned int i = 0;
i < 7; ++
i) {
136 descriptions.
add(
"HitParentTest", desc);
141 if (!
tfile.isAvailable()) {
142 edm::LogVerbatim(
"HitParentTest") <<
"TFileService unavailable: no histograms";
147 for (
unsigned int i = 0;
i < 7; ++
i) {
148 sprintf(
name,
"HitType%d",
i);
152 hitType[
i]->GetYaxis()->SetTitle(
"Hits");
153 sprintf(
name,
"RhoVertex%d",
i);
154 sprintf(
title,
"#rho of the vertex for %s Hits",
detector[
i].c_str());
157 hitRho[
i]->GetYaxis()->SetTitle(
"Hits");
158 sprintf(
name,
"ZVertex%d",
i);
159 sprintf(
title,
"z of the vertex for %s Hits",
detector[
i].c_str());
162 hitZ[
i]->GetYaxis()->SetTitle(
"Hits");
168 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];
265 for (std::vector<PCaloHit>::const_iterator hit_it =
hits.begin(); hit_it !=
hits.end(); ++hit_it) {
269 int subdet = id_.
subdet();
272 else if (subdet == static_cast<int>(
HcalOuter))
280 int hit_geant_track_id = hit_it->geantTrackId();
282 if (hit_geant_track_id <= 0) {
289 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end() && !
found;
291 if (hit_geant_track_id == (
int)(simTrkItr->trackId())) {
297 <<
"[" <<
detector[
type] <<
"] Match = " <<
match <<
" hit_geant_track_id=" << hit_geant_track_id
298 <<
" particle id=" << simTrkItr->type();
306 int pid = simTrkItr->type();
309 edm::SimTrackContainer::const_iterator oldest_parent_track =
parentSimTrack(simTrkItr);
312 <<
"[" <<
detector[
type] <<
"] Hit pid = " << pid <<
" hit track id = " << hit_geant_track_id
313 <<
" Oldest Parent's Vertex: " << oldest_parent_vertex <<
" rho = " << oldest_parent_vertex.Rho()
314 <<
" Oldest Parent's pid: " << oldest_parent_track->type()
315 <<
" Oldest Parent's track id: " << oldest_parent_track->trackId()
316 <<
"\nHit vertex index: " << simTrkItr->vertIndex() <<
" (tot #vertices: " <<
SimVtx->size() <<
")"
317 <<
"\nHit vertex parent track: " << (*SimVtx)[simTrkItr->vertIndex()].parentIndex()
320 hitRho[
id]->Fill(oldest_parent_vertex.Rho());
321 hitZ[
id]->Fill(oldest_parent_vertex.Z());
335 for (std::vector<PCaloHit>::const_iterator hit_it =
hits.begin(); hit_it !=
hits.end(); ++hit_it) {
336 if (hit_it->depth() ==
depth) {
340 int hit_geant_track_id = hit_it->geantTrackId();
342 if (hit_geant_track_id <= 0) {
347 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end() && !
found;
349 if (hit_geant_track_id == (
int)(simTrkItr->trackId())) {
354 <<
"APDHIT Match = " <<
match <<
" hit_geant_track_id = " << hit_geant_track_id
355 <<
" particle id=" << simTrkItr->type();
362 int apd_pid = simTrkItr->type();
375 edm::SimTrackContainer::const_iterator oldest_parent_track =
parentSimTrack(simTrkItr);
378 <<
"APD hit pid = " << apd_pid <<
" APD hit track id = " << hit_geant_track_id
379 <<
" depth = " << hit_it->depth() <<
" OLDEST PARENT'S VERTEX: " << oldest_parent_vertex
380 <<
" rho = " << oldest_parent_vertex.Rho() <<
" OLDEST PARENT'S PID: " << oldest_parent_track->type()
381 <<
" OLDEST PARENT'S track id: " << oldest_parent_track->trackId() <<
"\n"
382 <<
"APD hit vertex index: " << simTrkItr->vertIndex() <<
" (tot #vertices: " <<
SimVtx->size() <<
")"
384 <<
"APD hit vertex parent track: " << (*SimVtx)[simTrkItr->vertIndex()].parentIndex()
398 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end(); ++simTrkItr) {
399 if ((
int)(simTrkItr->trackId()) ==
id)
407 10000, 10000, 10000, 10000);
411 int vertex_index = oldest_parent_track->vertIndex();
414 if (vertex_index < 0 || vertex_index >= (
int)(
SimVtx->size()))
415 return invalid_vertex;
417 return (*
SimVtx)[vertex_index].position();
421 edm::SimTrackContainer::const_iterator
itr =
SimTk->end();
423 int vertIndex = thisTrkItr->vertIndex();
424 int type = thisTrkItr->type();
426 edm::LogVerbatim(
"HitParentTest") <<
"SimTrackParent:: " << thisTrkItr->trackId() <<
" Vertex " << vertIndex
431 else if (vertIndex >= (
int)
SimVtx->size())
434 edm::SimVertexContainer::const_iterator simVtxItr =
SimVtx->begin();
435 for (
int iv = 0; iv < vertIndex; iv++)
437 int parent = simVtxItr->parentIndex();
439 if (parent < 0 && simVtxItr != SimVtx->
begin()) {
441 for (simVtxItr =
SimVtx->begin(); simVtxItr !=
SimVtx->end(); ++simVtxItr) {
442 if (simVtxItr->parentIndex() > 0) {
444 double dist = pos2.P();
446 parent = simVtxItr->parentIndex();
452 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end(); simTrkItr++) {
453 if ((
int)simTrkItr->trackId() ==
parent && simTrkItr != thisTrkItr)
461 edm::LogVerbatim(
"HitParentTest") <<
"Inside validSimTrack: trackId " << thisTrkItr->trackId() <<
" vtxIndex "
462 << thisTrkItr->vertIndex() <<
" to be matched to " << simTkId;
465 if (thisTrkItr->trackId() == simTkId)
469 int vertIndex = thisTrkItr->vertIndex();
470 if (vertIndex == -1 || vertIndex >= (
int)
SimVtx->size())
472 edm::SimVertexContainer::const_iterator simVtxItr =
SimVtx->begin();
473 for (
int iv = 0; iv < vertIndex; iv++)
475 int parent = simVtxItr->parentIndex();
477 if (parent < 0 && simVtxItr != SimVtx->
begin()) {
479 for (simVtxItr =
SimVtx->begin(); simVtxItr !=
SimVtx->end(); ++simVtxItr) {
480 if (simVtxItr->parentIndex() > 0) {
482 double dist = pos2.P();
484 parent = simVtxItr->parentIndex();
491 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end(); simTrkItr++) {
492 if ((
int)simTrkItr->trackId() ==
parent && simTrkItr != thisTrkItr)