23 edm::SimTrackContainer::const_iterator
itr = SimTk->end();
28 std::vector<unsigned int> trkId, trkOcc;
29 for (
auto const& trkHit : pTrack->
recHits()) {
30 std::vector<PSimHit> matchedSimIds = associate.
associateHit(*trkHit);
31 for (
unsigned int isim = 0; isim < matchedSimIds.size(); isim++) {
32 unsigned tkId = matchedSimIds[isim].trackId();
34 for (
unsigned int j = 0;
j < trkId.size();
j++) {
35 if (tkId == trkId[
j]) {
42 trkId.push_back(tkId);
50 for (
unsigned int isim = 0; isim < trkId.size(); isim++) {
51 std::cout <<
"\n trkId " << trkId[isim] <<
" Occurance " << trkOcc[isim] <<
", ";
58 unsigned int matchSimTrk = 0;
59 if (!trkOcc.empty()) {
60 unsigned int maxTrkOcc = 0, idxMax = 0;
61 for (
unsigned int j = 0;
j < trkOcc.size();
j++) {
62 if (trkOcc[
j] > maxTrkOcc) {
63 maxTrkOcc = trkOcc[
j];
67 matchSimTrk = trkId[idxMax];
68 for (
auto simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
69 if (simTrkItr->trackId() == matchSimTrk) {
71 matchedId = simTrkItr->type();
73 std::cout <<
"matched trackId (maximum occurance) " << matchSimTrk <<
" type " << matchedId << std::endl;
82 if (matchedId == 0 &&
debug) {
83 std::cout <<
"Could not find matched SimTrk and track history now " << std::endl;
97 edm::SimTrackContainer::const_iterator trkInfo =
99 unsigned int matchSimTrk = trkInfo->trackId();
102 std::cout <<
"matchedSimTrackId finds the SimTrk ID of the current track to be " << matchSimTrk << std::endl;
104 std::vector<int> matchTkid;
105 if (trkInfo->type() != 0) {
106 for (
auto simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
107 if (
validSimTrack(matchSimTrk, simTrkItr, SimTk, SimVtx,
false))
108 matchTkid.push_back((
int)simTrkItr->trackId());
119 for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
120 if (simTkId == simTrkItr->trackId()) {
123 info.pdgId = simTrkItr->type();
124 info.charge = simTrkItr->charge();
129 if (parentItr != SimTk->end())
130 std::cout <<
"original parent of " << simTrkItr->trackId() <<
" " << parentItr->trackId() <<
", "
131 << parentItr->type() << std::endl;
133 std::cout <<
"original parent of " << simTrkItr->trackId() <<
" not found" << std::endl;
136 if (parentItr != SimTk->end()) {
138 info.pdgId = parentItr->type();
139 info.charge = parentItr->charge();
150 edm::SimTrackContainer::const_iterator thisTrkItr,
156 std::cout <<
"Inside validSimTrack: trackId " << thisTrkItr->trackId() <<
" vtxIndex " << thisTrkItr->vertIndex()
157 <<
" to be matched to " << simTkId << std::endl;
160 if (thisTrkItr->trackId() == simTkId)
164 int vertIndex = thisTrkItr->vertIndex();
165 if (vertIndex == -1 || vertIndex >= (
int)SimVtx->size())
168 edm::SimVertexContainer::const_iterator simVtxItr = SimVtx->begin();
169 for (
int iv = 0; iv < vertIndex; iv++)
171 int parent = simVtxItr->parentIndex();
176 if (parent < 0 && simVtxItr != SimVtx->begin()) {
178 for (simVtxItr = SimVtx->begin(); simVtxItr != SimVtx->end(); ++simVtxItr) {
179 if (simVtxItr->parentIndex() > 0) {
181 double dist = pos2.P();
183 parent = simVtxItr->parentIndex();
194 for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
195 if ((
int)simTrkItr->trackId() ==
parent && simTrkItr != thisTrkItr)
203 edm::SimTrackContainer::const_iterator
parentSimTrack(edm::SimTrackContainer::const_iterator thisTrkItr,
207 edm::SimTrackContainer::const_iterator
itr = SimTk->end();
209 int vertIndex = thisTrkItr->vertIndex();
212 std::cout <<
"SimTrackParent " << thisTrkItr->trackId() <<
" Vertex " << vertIndex <<
" Type "
213 << thisTrkItr->type() <<
" Charge " << (
int)thisTrkItr->charge() << std::endl;
217 else if (vertIndex >= (
int)SimVtx->size())
220 edm::SimVertexContainer::const_iterator simVtxItr = SimVtx->begin();
221 for (
int iv = 0; iv < vertIndex; iv++)
223 int parent = simVtxItr->parentIndex();
225 if (parent < 0 && simVtxItr != SimVtx->begin()) {
227 for (simVtxItr = SimVtx->begin(); simVtxItr != SimVtx->end(); ++simVtxItr) {
228 if (simVtxItr->parentIndex() > 0) {
230 double dist = pos2.P();
232 parent = simVtxItr->parentIndex();
238 for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
239 if ((
int)simTrkItr->trackId() ==
parent && simTrkItr != thisTrkItr)