16 edm::SimTrackContainer::const_iterator itr = SimTk->end();
21 std::vector<unsigned int> trkId, trkOcc;
22 for (
auto const& trkHit : pTrack->
recHits()) {
23 std::vector<PSimHit> matchedSimIds = associate.
associateHit(*trkHit);
24 for (
unsigned int isim = 0; isim < matchedSimIds.size(); isim++) {
25 unsigned tkId = matchedSimIds[isim].trackId();
27 for (
unsigned int j = 0;
j < trkId.size();
j++) {
28 if (tkId == trkId[
j]) {
35 trkId.push_back(tkId);
42 std::ostringstream st1;
43 for (
unsigned int isim = 0; isim < trkId.size(); isim++) {
44 st1 <<
"\n trkId " << trkId[isim] <<
" Occurance " << trkOcc[isim] <<
", ";
50 unsigned int matchSimTrk = 0;
51 if (!trkOcc.empty()) {
52 unsigned int maxTrkOcc = 0, idxMax = 0;
53 for (
unsigned int j = 0;
j < trkOcc.size();
j++) {
54 if (trkOcc[
j] > maxTrkOcc) {
55 maxTrkOcc = trkOcc[
j];
59 matchSimTrk = trkId[idxMax];
60 for (
auto simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
61 if (simTrkItr->trackId() == matchSimTrk) {
62 matchedId = simTrkItr->type();
64 edm::LogVerbatim(
"IsoTrack") <<
"matched trackId (maximum occurance) " << matchSimTrk <<
" type " 72 if (matchedId == 0 &&
debug) {
73 edm::LogVerbatim(
"IsoTrack") <<
"Could not find matched SimTrk and track history now ";
86 edm::SimTrackContainer::const_iterator trkInfo =
88 unsigned int matchSimTrk = trkInfo->trackId();
90 edm::LogVerbatim(
"IsoTrack") <<
"matchedSimTrackId finds the SimTrk ID of the current track to be " 92 std::vector<int> matchTkid;
93 if (trkInfo->type() != 0) {
94 for (
auto simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
95 if (
validSimTrack(matchSimTrk, simTrkItr, SimTk, SimVtx,
false))
96 matchTkid.push_back(static_cast<int>(simTrkItr->trackId()));
107 for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
108 if (simTkId == simTrkItr->trackId()) {
111 info.pdgId = simTrkItr->type();
112 info.charge = simTrkItr->charge();
116 if (parentItr != SimTk->end())
117 edm::LogVerbatim(
"IsoTrack") <<
"original parent of " << simTrkItr->trackId() <<
" " 118 << parentItr->trackId() <<
", " << parentItr->type();
120 edm::LogVerbatim(
"IsoTrack") <<
"original parent of " << simTrkItr->trackId() <<
" not found";
122 if (parentItr != SimTk->end()) {
124 info.pdgId = parentItr->type();
125 info.charge = parentItr->charge();
136 edm::SimTrackContainer::const_iterator thisTrkItr,
141 edm::LogVerbatim(
"IsoTrack") <<
"Inside validSimTrack: trackId " << thisTrkItr->trackId() <<
" vtxIndex " 142 << thisTrkItr->vertIndex() <<
" to be matched to " << simTkId;
145 if (thisTrkItr->trackId() == simTkId)
149 int vertIndex = thisTrkItr->vertIndex();
150 if (vertIndex == -1 || vertIndex >= static_cast<int>(SimVtx->size()))
153 edm::SimVertexContainer::const_iterator simVtxItr = SimVtx->begin();
154 for (
int iv = 0;
iv < vertIndex;
iv++)
156 int parent = simVtxItr->parentIndex();
160 if (parent < 0 && simVtxItr != SimVtx->begin()) {
162 for (simVtxItr = SimVtx->begin(); simVtxItr != SimVtx->end(); ++simVtxItr) {
163 if (simVtxItr->parentIndex() > 0) {
165 double dist = pos2.P();
167 parent = simVtxItr->parentIndex();
176 for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
177 if (static_cast<int>(simTrkItr->trackId()) ==
parent && simTrkItr != thisTrkItr)
185 edm::SimTrackContainer::const_iterator
parentSimTrack(edm::SimTrackContainer::const_iterator thisTrkItr,
189 edm::SimTrackContainer::const_iterator itr = SimTk->end();
191 int vertIndex = thisTrkItr->vertIndex();
193 edm::LogVerbatim(
"IsoTrack") <<
"SimTrackParent " << thisTrkItr->trackId() <<
" Vertex " << vertIndex <<
" Type " 194 << thisTrkItr->type() <<
" Charge " <<
static_cast<int>(thisTrkItr->charge());
197 else if (vertIndex >= static_cast<int>(SimVtx->size()))
200 edm::SimVertexContainer::const_iterator simVtxItr = SimVtx->begin();
201 for (
int iv = 0;
iv < vertIndex;
iv++)
203 int parent = simVtxItr->parentIndex();
205 if (parent < 0 && simVtxItr != SimVtx->begin()) {
207 for (simVtxItr = SimVtx->begin(); simVtxItr != SimVtx->end(); ++simVtxItr) {
208 if (simVtxItr->parentIndex() > 0) {
210 double dist = pos2.P();
212 parent = simVtxItr->parentIndex();
218 for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
219 if (static_cast<int>(simTrkItr->trackId()) ==
parent && simTrkItr != thisTrkItr)
Log< level::Info, true > LogVerbatim
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
auto recHits() const
Access to reconstructed hits on the track.
std::vector< PSimHit > associateHit(const TrackingRecHit &thit) const
edm::SimTrackContainer::const_iterator matchedSimTrack(const edm::Event &iEvent, edm::Handle< edm::SimTrackContainer > &SimTk, edm::Handle< edm::SimVertexContainer > &SimVtx, const reco::Track *pTrack, TrackerHitAssociator &associate, bool debug=false)
simTkInfo matchedSimTrackInfo(unsigned int simTkId, edm::Handle< edm::SimTrackContainer > &SimTk, edm::Handle< edm::SimVertexContainer > &SimVtx, bool debug=false)
std::vector< int > matchedSimTrackId(const edm::Event &, edm::Handle< edm::SimTrackContainer > &SimTk, edm::Handle< edm::SimVertexContainer > &SimVtx, const reco::Track *pTrack, TrackerHitAssociator &associate, bool debug=false)
bool validSimTrack(unsigned int simTkId, edm::SimTrackContainer::const_iterator thisTrkItr, edm::Handle< edm::SimTrackContainer > &SimTk, edm::Handle< edm::SimVertexContainer > &SimVtx, bool debug=false)
edm::SimTrackContainer::const_iterator parentSimTrack(edm::SimTrackContainer::const_iterator thisTrkItr, edm::Handle< edm::SimTrackContainer > &SimTk, edm::Handle< edm::SimVertexContainer > &SimVtx, bool debug=false)