Hi,
for each event, I do the following:
for (Int_t k = 0; k < kalfit->GetEntriesFast(); k++) {
kalTrack = (PndTrack*) kalfit->At(k);
if (!kalTrack) continue;
if (kalTrack->GetFlag() < 0) continue;
where kalfit is the TClonesArray of PndTracks produced by the Kalman:
TClonesArray *kalfit = new TClonesArray("PndTrack");
reco->SetBranchAddress("SttMvdGenTrack", &kalfit);
Then, if the track is a primary track (I check the MCTrackId of the corresponding TrackCand), I fill the histogram of the momentum distribution:
hgen->Fill(kalTrack->GetParamFirst().GetMomentum().Mag());
Susanna