12 edm::SimTrackContainer::const_iterator itr = SimTk->end();;
14 edm::SimTrackContainer::const_iterator simTrkItr;
15 edm::SimVertexContainer::const_iterator simVtxItr;
19 std::vector<unsigned int> trkId, trkOcc;
23 std::vector<PSimHit> matchedSimIds = associate.
associateHit((**iTrkHit));
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] ) {
34 if (!found) { trkId.push_back(tkId); trkOcc.push_back(1); }
39 std::cout <<
"Reconstructed Track with " << i <<
" recHits.";
40 for (
unsigned int isim=0; isim<trkId.size(); isim++){
41 std::cout <<
"\n trkId " << trkId[isim] <<
" Occurance " << trkOcc[isim] <<
", ";
47 unsigned int matchSimTrk=0;
48 if (trkOcc.size() > 0) {
49 unsigned int maxTrkOcc=0, idxMax=0;
50 for(
unsigned int j=0;
j<trkOcc.size();
j++) {
51 if(trkOcc[
j] > maxTrkOcc ) { maxTrkOcc = trkOcc[
j]; idxMax =
j; }
53 matchSimTrk = trkId[idxMax];
54 for (simTrkItr = SimTk->begin(); simTrkItr!= SimTk->end(); simTrkItr++) {
55 if ( simTrkItr->trackId() == matchSimTrk ) {
56 matchedId = simTrkItr->type();
57 if (debug)
std::cout <<
"matched trackId (maximum occurance) " << matchSimTrk <<
" type " << matchedId << std::endl;
64 if (matchedId==0 && debug) {
65 std::cout <<
"Could not find matched SimTrk and track history now " << std::endl;
75 edm::SimTrackContainer::const_iterator trkInfo =
spr::matchedSimTrack(iEvent, SimTk, SimVtx, pTrack,associate, debug);
76 unsigned int matchSimTrk = trkInfo->trackId();
77 if (debug)
std::cout <<
"matchedSimTrackId finds the SimTrk ID of the current track to be " << matchSimTrk << std::endl;
79 std::vector<int> matchTkid;
80 if( trkInfo->type() != 0) {
81 edm::SimTrackContainer::const_iterator simTrkItr;
82 for(simTrkItr = SimTk->begin(); simTrkItr!= SimTk->end(); simTrkItr++){
83 if (
validSimTrack(matchSimTrk, simTrkItr, SimTk, SimVtx,
false))
84 matchTkid.push_back((
int)simTrkItr->trackId());
92 for (edm::SimTrackContainer::const_iterator simTrkItr=SimTk->begin();
93 simTrkItr!= SimTk->end(); simTrkItr++) {
94 if (simTkId == simTrkItr->trackId()) {
97 info.
pdgId = simTrkItr->type();
98 info.
charge = simTrkItr->charge();
100 edm::SimTrackContainer::const_iterator parentItr =
spr::parentSimTrack(simTrkItr, SimTk, SimVtx, debug);
102 if (parentItr != SimTk->end() )
std::cout <<
"original parent of " << simTrkItr->trackId() <<
" " << parentItr->trackId() <<
", " << parentItr->type() << std::endl;
103 else std::cout <<
"original parent of " << simTrkItr->trackId() <<
" not found" << std::endl;
105 if (parentItr != SimTk->end()) {
107 info.
pdgId = parentItr->type();
108 info.
charge = parentItr->charge();
120 if (debug)
std::cout <<
"Inside validSimTrack: trackId " << thisTrkItr->trackId() <<
" vtxIndex " << thisTrkItr->vertIndex() <<
" to be matched to " << simTkId << std::endl;
123 if (thisTrkItr->trackId() == simTkId)
return true;
126 int vertIndex = thisTrkItr->vertIndex();
127 if (vertIndex == -1 || vertIndex >= (
int)SimVtx->size())
return false;
129 edm::SimVertexContainer::const_iterator simVtxItr= SimVtx->begin();
130 for (
int iv=0; iv<vertIndex; iv++) simVtxItr++;
131 int parent = simVtxItr->parentIndex();
132 if (debug)
std::cout <<
"validSimTrack:: parent index " << parent <<
" ";
133 if (parent < 0 && simVtxItr != SimVtx->
begin()) {
135 for (simVtxItr=SimVtx->begin(); simVtxItr!=SimVtx->end(); ++simVtxItr) {
136 if (simVtxItr->parentIndex() > 0) {
138 double dist = pos2.P();
140 parent = simVtxItr->parentIndex();
146 if (debug)
std::cout <<
"final index " << parent << std::endl;;
147 for(edm::SimTrackContainer::const_iterator simTrkItr= SimTk->begin(); simTrkItr!= SimTk->end(); simTrkItr++){
148 if ((
int)simTrkItr->trackId() == parent && simTrkItr != thisTrkItr)
return validSimTrack(simTkId, simTrkItr, SimTk, SimVtx, debug) ;
158 edm::SimTrackContainer::const_iterator itr = SimTk->end();
160 int vertIndex = thisTrkItr->vertIndex();
161 int type = thisTrkItr->type();
int charge = (
int)thisTrkItr->charge();
162 if (debug)
std::cout <<
"SimTrackParent " << thisTrkItr->trackId() <<
" Vertex " << vertIndex <<
" Type " << type <<
" Charge " << charge << std::endl;
164 if( vertIndex == -1 )
return thisTrkItr;
165 else if (vertIndex >= (
int)SimVtx->size())
return itr;
167 edm::SimVertexContainer::const_iterator simVtxItr= SimVtx->begin();
168 for (
int iv=0; iv<vertIndex; iv++) simVtxItr++;
169 int parent = simVtxItr->parentIndex();
171 if (parent < 0 && simVtxItr != SimVtx->
begin()) {
173 for (simVtxItr=SimVtx->begin(); simVtxItr!=SimVtx->end(); ++simVtxItr) {
174 if (simVtxItr->parentIndex() > 0) {
176 double dist = pos2.P();
178 parent = simVtxItr->parentIndex();
184 for (edm::SimTrackContainer::const_iterator simTrkItr= SimTk->begin(); simTrkItr!= SimTk->end(); simTrkItr++){
185 if ((
int)simTrkItr->trackId() == parent && simTrkItr != thisTrkItr)
return parentSimTrack(simTrkItr, SimTk, SimVtx, debug);
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
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)
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
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)
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
edm::SimTrackContainer::const_iterator parentSimTrack(edm::SimTrackContainer::const_iterator thisTrkItr, edm::Handle< edm::SimTrackContainer > &SimTk, edm::Handle< edm::SimVertexContainer > &SimVtx, bool debug=false)
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.