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 std::cout <<
"Reconstructed Track with " <<
i <<
" recHits.";
51 for (
unsigned int isim = 0; isim < trkId.size(); isim++) {
52 std::cout <<
"\n trkId " << trkId[isim] <<
" Occurance " << trkOcc[isim] <<
", ";
59 unsigned int matchSimTrk = 0;
60 if (!trkOcc.empty()) {
61 unsigned int maxTrkOcc = 0, idxMax = 0;
62 for (
unsigned int j = 0;
j < trkOcc.size();
j++) {
63 if (trkOcc[
j] > maxTrkOcc) {
64 maxTrkOcc = trkOcc[
j];
68 matchSimTrk = trkId[idxMax];
69 for (
auto simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
70 if (simTrkItr->trackId() == matchSimTrk) {
72 matchedId = simTrkItr->type();
74 std::cout <<
"matched trackId (maximum occurance) " << matchSimTrk <<
" type " << matchedId << std::endl;
83 if (matchedId == 0 &&
debug) {
84 std::cout <<
"Could not find matched SimTrk and track history now " << std::endl;
98 edm::SimTrackContainer::const_iterator trkInfo =
100 unsigned int matchSimTrk = trkInfo->trackId();
103 std::cout <<
"matchedSimTrackId finds the SimTrk ID of the current track to be " << matchSimTrk << std::endl;
105 std::vector<int> matchTkid;
106 if (trkInfo->type() != 0) {
107 for (
auto simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
108 if (
validSimTrack(matchSimTrk, simTrkItr, SimTk, SimVtx,
false))
109 matchTkid.push_back((
int)simTrkItr->trackId());
120 for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
121 if (simTkId == simTrkItr->trackId()) {
124 info.
pdgId = simTrkItr->type();
125 info.
charge = simTrkItr->charge();
127 edm::SimTrackContainer::const_iterator parentItr =
spr::parentSimTrack(simTrkItr, SimTk, SimVtx, debug);
130 if (parentItr != SimTk->end())
131 std::cout <<
"original parent of " << simTrkItr->trackId() <<
" " << parentItr->trackId() <<
", " 132 << parentItr->type() << std::endl;
134 std::cout <<
"original parent of " << simTrkItr->trackId() <<
" not found" << std::endl;
137 if (parentItr != SimTk->end()) {
139 info.
pdgId = parentItr->type();
140 info.
charge = parentItr->charge();
151 edm::SimTrackContainer::const_iterator thisTrkItr,
157 std::cout <<
"Inside validSimTrack: trackId " << thisTrkItr->trackId() <<
" vtxIndex " << thisTrkItr->vertIndex()
158 <<
" to be matched to " << simTkId << std::endl;
161 if (thisTrkItr->trackId() == simTkId)
165 int vertIndex = thisTrkItr->vertIndex();
166 if (vertIndex == -1 || vertIndex >= (
int)SimVtx->size())
169 edm::SimVertexContainer::const_iterator simVtxItr = SimVtx->begin();
170 for (
int iv = 0; iv < vertIndex; iv++)
172 int parent = simVtxItr->parentIndex();
175 std::cout <<
"validSimTrack:: parent index " << parent <<
" ";
177 if (parent < 0 && simVtxItr != SimVtx->
begin()) {
179 for (simVtxItr = SimVtx->begin(); simVtxItr != SimVtx->end(); ++simVtxItr) {
180 if (simVtxItr->parentIndex() > 0) {
182 double dist = pos2.P();
184 parent = simVtxItr->parentIndex();
192 std::cout <<
"final index " << parent << std::endl;
195 for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
196 if ((
int)simTrkItr->trackId() == parent && simTrkItr != thisTrkItr)
197 return validSimTrack(simTkId, simTrkItr, SimTk, SimVtx, debug);
204 edm::SimTrackContainer::const_iterator
parentSimTrack(edm::SimTrackContainer::const_iterator thisTrkItr,
208 edm::SimTrackContainer::const_iterator itr = SimTk->end();
210 int vertIndex = thisTrkItr->vertIndex();
213 std::cout <<
"SimTrackParent " << thisTrkItr->trackId() <<
" Vertex " << vertIndex <<
" Type " 214 << thisTrkItr->type() <<
" Charge " << (
int)thisTrkItr->charge() << std::endl;
218 else if (vertIndex >= (
int)SimVtx->size())
221 edm::SimVertexContainer::const_iterator simVtxItr = SimVtx->begin();
222 for (
int iv = 0; iv < vertIndex; iv++)
224 int parent = simVtxItr->parentIndex();
226 if (parent < 0 && simVtxItr != SimVtx->
begin()) {
228 for (simVtxItr = SimVtx->begin(); simVtxItr != SimVtx->end(); ++simVtxItr) {
229 if (simVtxItr->parentIndex() > 0) {
231 double dist = pos2.P();
233 parent = simVtxItr->parentIndex();
239 for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
240 if ((
int)simTrkItr->trackId() == parent && simTrkItr != thisTrkItr)
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.
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)
std::vector< PSimHit > associateHit(const TrackingRecHit &thit) const
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)