Skip to content

Commit

Permalink
Merge pull request #83 from kmcdermo/full-det-tracking
Browse files Browse the repository at this point in the history
Fixups for validation
  • Loading branch information
osschar authored Jul 3, 2017
2 parents 753f20c + 7eb9b84 commit fb9a398
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 25 deletions.
32 changes: 19 additions & 13 deletions TTreeValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ TTreeValidation::TTreeValidation(std::string fileName)
}
if (Config::fit_val)
{
for (int i = 0; i < nfvs_; ++i) fvs_[i].resize(Config::nTotalLayers);
TTreeValidation::initializeFitTree();
}
TTreeValidation::initializeConfigTree();
Expand Down Expand Up @@ -539,7 +540,7 @@ void TTreeValidation::mapSeedTkToRecoTk(const TrackVec& evt_tracks, const TrackE
}
}

int TTreeValidation::getLastGoodHit(const int trackMCHitID, const int mcTrackID, const Event& ev)
int TTreeValidation::getLastFoundHit(const int trackMCHitID, const int mcTrackID, const Event& ev)
{
int mcHitID = -1;
if (ev.simHitsInfo_[trackMCHitID].mcTrackID() == mcTrackID)
Expand Down Expand Up @@ -662,6 +663,8 @@ void TTreeValidation::fillEfficiencyTree(const Event& ev)
auto& evt_layer_hits = ev.layerHits_;
const auto& evt_sim_trackstates = ev.simTrackStates_;

const bool useSimTSInfo = (evt_sim_trackstates.size() > 0);

for (auto&& simtrack : evt_sim_tracks)
{
evtID_eff_ = ievt;
Expand All @@ -688,8 +691,8 @@ void TTreeValidation::fillEfficiencyTree(const Event& ev)
seedID_seed_eff_ = seedextra.seedID();

// use this to access correct sim track layer params
const int mcHitID = TTreeValidation::getLastGoodHit(seedtrack.getLastGoodMCHitID(evt_layer_hits),mcID_eff_,ev);
if (mcHitID >= 0)
const int mcHitID = TTreeValidation::getLastFoundHit(seedtrack.getLastFoundMCHitID(evt_layer_hits),mcID_eff_,ev);
if (mcHitID >= 0 && useSimTSInfo)
{
const TrackState & initLayTS = evt_sim_trackstates[mcHitID];

Expand Down Expand Up @@ -773,8 +776,8 @@ void TTreeValidation::fillEfficiencyTree(const Event& ev)
seedID_build_eff_ = buildextra.seedID();

// use this to access correct sim track layer params
const int mcHitID = TTreeValidation::getLastFoundHit(buildtrack.getLastGoodMCHitID(evt_layer_hits),mcID_eff_,ev);
if (mcHitID >= 0)
const int mcHitID = TTreeValidation::getLastFoundHit(buildtrack.getLastFoundMCHitID(evt_layer_hits),mcID_eff_,ev);
if (mcHitID >= 0 && useSimTSInfo)
{
const TrackState & initLayTS = evt_sim_trackstates[mcHitID];

Expand Down Expand Up @@ -857,8 +860,8 @@ void TTreeValidation::fillEfficiencyTree(const Event& ev)
seedID_fit_eff_ = fitextra.seedID();

// use this to access correct sim track layer params
const int mcHitID = TTreeValidation::getLastGoodHit(fittrack.getLastGoodMCHitID(evt_layer_hits),mcID_eff_,ev);
if (mcHitID >= 0)
const int mcHitID = TTreeValidation::getLastFoundHit(fittrack.getLastFoundMCHitID(evt_layer_hits),mcID_eff_,ev);
if (mcHitID >= 0 && useSimTSInfo)
{
const TrackState & initLayTS = evt_sim_trackstates[mcHitID];

Expand Down Expand Up @@ -951,6 +954,8 @@ void TTreeValidation::fillFakeRateTree(const Event& ev)
auto& evt_layer_hits = ev.layerHits_;
auto& evt_sim_trackstates = ev.simTrackStates_;

const bool useSimTSInfo = (evt_sim_trackstates.size() > 0);

for (auto&& seedtrack : evt_seed_tracks)
{
evtID_FR_ = ievt;
Expand Down Expand Up @@ -1004,8 +1009,8 @@ void TTreeValidation::fillFakeRateTree(const Event& ev)
{
auto& simtrack = evt_sim_tracks[mcID_seed_FR_];

const int mcHitID = TTreeValidation::getLastGoodHit(seedtrack.getLastGoodMCHitID(evt_layer_hits),mcID_seed_FR_,ev);
if (mcHitID >= 0)
const int mcHitID = TTreeValidation::getLastFoundHit(seedtrack.getLastFoundMCHitID(evt_layer_hits),mcID_seed_FR_,ev);
if (mcHitID >= 0 && useSimTSInfo)
{
const TrackState & initLayTS = evt_sim_trackstates[mcHitID];
pt_mc_seed_FR_ = initLayTS.pT();
Expand All @@ -1022,6 +1027,7 @@ void TTreeValidation::fillFakeRateTree(const Event& ev)
}

nHits_mc_seed_FR_ = simtrack.nFoundHits();

lastlyr_mc_seed_FR_ = simtrack.getLastFoundHitLyr();

duplmask_seed_FR_ = seedextra.isDuplicate();
Expand Down Expand Up @@ -1096,8 +1102,8 @@ void TTreeValidation::fillFakeRateTree(const Event& ev)
{
auto& simtrack = evt_sim_tracks[mcID_build_FR_];

const int mcHitID = TTreeValidation::getLastGoodHit(buildtrack.getLastGoodMCHitID(evt_layer_hits),mcID_build_FR_,ev);
if (mcHitID >= 0)
const int mcHitID = TTreeValidation::getLastFoundHit(buildtrack.getLastFoundMCHitID(evt_layer_hits),mcID_build_FR_,ev);
if (mcHitID >= 0 && useSimTSInfo)
{
const TrackState & initLayTS = evt_sim_trackstates[mcHitID];
pt_mc_build_FR_ = initLayTS.pT();
Expand Down Expand Up @@ -1227,8 +1233,8 @@ void TTreeValidation::fillFakeRateTree(const Event& ev)
{
auto& simtrack = evt_sim_tracks[mcID_fit_FR_];

const int mcHitID = TTreeValidation::getLastGoodHit(fittrack.getLastGoodMCHitID(evt_layer_hits),mcID_fit_FR_,ev); // only works for outward fit for now
if (mcHitID >= 0)
const int mcHitID = TTreeValidation::getLastFoundHit(fittrack.getLastFoundMCHitID(evt_layer_hits),mcID_fit_FR_,ev); // only works for outward fit for now
if (mcHitID >= 0 && useSimTSInfo)
{
const TrackState & initLayTS = evt_sim_trackstates[mcHitID];
pt_mc_fit_FR_ = initLayTS.pT();
Expand Down
21 changes: 13 additions & 8 deletions TTreeValidation.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class TTreeValidation : public Validation {
void makeSeedTkToRecoTkMaps(Event& ev) override;
void mapSeedTkToRecoTk(const TrackVec& evt_tracks, const TrackExtraVec& evt_extras, TkIDToTkIDMap& seedTkMap);

int getLastGoodHit(const int trackMCHitID, const int mcTrackID, const Event& ev);
int getLastFoundHit(const int trackMCHitID, const int mcTrackID, const Event& ev);

void fillEfficiencyTree(const Event& ev) override;
void fillFakeRateTree(const Event& ev) override;
Expand Down Expand Up @@ -160,13 +160,18 @@ class TTreeValidation : public Validation {
// Fit tree (for fine tuning z-phi windows and such --> MPlex Only
TTree* fittree_;
int ntotallayers_fit_=0,tkid_fit_=0,evtid_fit_=0;
float z_prop_fit_[Config::nTotalLayers],ez_prop_fit_[Config::nTotalLayers];
float z_hit_fit_[Config::nTotalLayers],ez_hit_fit_[Config::nTotalLayers],z_sim_fit_[Config::nTotalLayers],ez_sim_fit_[Config::nTotalLayers];
float pphi_prop_fit_[Config::nTotalLayers],epphi_prop_fit_[Config::nTotalLayers];
float pphi_hit_fit_[Config::nTotalLayers],epphi_hit_fit_[Config::nTotalLayers],pphi_sim_fit_[Config::nTotalLayers],epphi_sim_fit_[Config::nTotalLayers];
float pt_up_fit_[Config::nTotalLayers],ept_up_fit_[Config::nTotalLayers],pt_sim_fit_[Config::nTotalLayers],ept_sim_fit_[Config::nTotalLayers];
float mphi_up_fit_[Config::nTotalLayers],emphi_up_fit_[Config::nTotalLayers],mphi_sim_fit_[Config::nTotalLayers],emphi_sim_fit_[Config::nTotalLayers];
float meta_up_fit_[Config::nTotalLayers],emeta_up_fit_[Config::nTotalLayers],meta_sim_fit_[Config::nTotalLayers],emeta_sim_fit_[Config::nTotalLayers];

static const int nfvs_ = 24;
std::vector<float> fvs_[nfvs_];

// perl -pe 'BEGIN{$i=0} while (s/\(Config::nTotalLayers\)/ = fvs_[$i]/){++$i}' xxin
std::vector<float> &z_prop_fit_ = fvs_[0],&ez_prop_fit_ = fvs_[1];
std::vector<float> &z_hit_fit_ = fvs_[2],&ez_hit_fit_ = fvs_[3],&z_sim_fit_ = fvs_[4],&ez_sim_fit_ = fvs_[5];
std::vector<float> &pphi_prop_fit_ = fvs_[6],&epphi_prop_fit_ = fvs_[7];
std::vector<float> &pphi_hit_fit_ = fvs_[8],&epphi_hit_fit_ = fvs_[9],&pphi_sim_fit_ = fvs_[10],&epphi_sim_fit_ = fvs_[11];
std::vector<float> &pt_up_fit_ = fvs_[12],&ept_up_fit_ = fvs_[13],&pt_sim_fit_ = fvs_[14],&ept_sim_fit_ = fvs_[15];
std::vector<float> &mphi_up_fit_ = fvs_[16],&emphi_up_fit_ = fvs_[17],&mphi_sim_fit_ = fvs_[18],&emphi_sim_fit_ = fvs_[19];
std::vector<float> &meta_up_fit_ = fvs_[20],&emeta_up_fit_ = fvs_[21],&meta_sim_fit_ = fvs_[22],&emeta_sim_fit_ = fvs_[23];

std::mutex glock_;
};
Expand Down
4 changes: 2 additions & 2 deletions Track.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ void TrackExtra::setMCTrackIDInfoByLabel(const Track& trk, const std::vector<Hit
// Modify mcTrackID based on nMinHits
if (nCandHits < (Config::nMinFoundHits-Config::nlayers_per_seed))
{
if (mcTrackID_ = label) mcTrackID_ = -2;
else mcTrackID_ = -3;
if (mcTrackID_ == label) mcTrackID_ = -2;
else mcTrackID_ = -3;
}

nHitsMatched_ = nHitsMatched; // nHitsMatched + Config::nlayers_per_seed
Expand Down
2 changes: 1 addition & 1 deletion Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class Track
int getLastFoundHitIdx() const { return hitsOnTrk_[getLastFoundHitPos()].index; }
int getLastFoundHitLyr() const { return hitsOnTrk_[getLastFoundHitPos()].layer; }

int getLastGoodMCHitID(const std::vector<HitVec>& globalHitVec) const
int getLastFoundMCHitID(const std::vector<HitVec>& globalHitVec) const
{
HitOnTrack hot = getLastFoundHitOnTrack();
return globalHitVec[hot.layer][hot.index].mcHitID();
Expand Down
2 changes: 1 addition & 1 deletion mkFit/mkFit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ int main(int argc, const char *argv[])
" --silent suppress printouts inside event loop (def: %s)\n"
" --write write simulation to file and exit\n"
" --read read simulation from file\n"
" --skip-events <num> number of events to skip when reading from a file (def: %d)\n"
" --start-event <num> event number to start at when reading from a file (def: %d)\n"
" --file-name file name for write/read (def: %s)\n"
" --input-file file name for reading when converting formats (def: %s)\n"
"GPU specific options: \n"
Expand Down

0 comments on commit fb9a398

Please sign in to comment.