Skip to content

Commit

Permalink
Merge pull request cms-sw#162 from areinsvo/CCCv2
Browse files Browse the repository at this point in the history
Cluster charge cut, take two
  • Loading branch information
kmcdermo committed Sep 17, 2018
2 parents 908e3a4 + 9453a9e commit 6dfdc46
Show file tree
Hide file tree
Showing 12 changed files with 606 additions and 162 deletions.
20 changes: 18 additions & 2 deletions README.md
Expand Up @@ -158,6 +158,8 @@ This script will run the validation on the building tests specified by the ```${

It should be mentioned that each of these scripts within ```./xeon_scripts/runBenchmark.sh``` can be launched on their own, as again, they each set the environment and run tests and/or plot making. However, for simplicity's sake, it is easiest when prepping for a PR to just run the master ```./xeon_scripts/runBenchmark.sh```. If you want to test locally, it is of course possible to launch the scripts one at a time.

Note that you need to have SSH-forwarding set up to avoid having to type your password every time ```./xeon_scripts/runBenchmark.sh``` needs to copy files back and forth.

After running the full suite, there is an additional set of scripts within the ```web/``` directory for organizing the output plots and text files for viewing them on the web. The main script is:

```
Expand Down Expand Up @@ -278,21 +280,34 @@ There are some sections of code that are not in use anymore and/or are not regul
Given that this is a living repository, the comments in the code may not always be enough. Here are some useful other README's within this repo:
- afer compiling the code, do: ```./mkFit/mkFit --help``` : Describes the full list of command line options, inputs, and defaults when running mkFit. The list can also be seen in the code in mkFit/mkFit.cc, although the defaults are hidden behind Config.[h,cc], as well as mkFit.cc.
- cmssw-trackerinfo-desc.txt : Describes the structure of the CMS Phase-I geometry as represented within this repo.
- index-desc.txt : Desribes the various hit and track indices used by different sets of tracks throughout the different stages of the read in, seeding, building, fitting, and validation.
- validation-desc.txt : The validation manifesto: (somewhat) up-to-date description of the full physics validation suite. It is complemented by a somewhat out-of-date code flow diagram, found here: https://indico.cern.ch/event/656884/contributions/2676532/attachments/1513662/2363067/validation_flow_diagram-v4.pdf
- web/README_WEBPLOTS.txt : A short text file on how to setup a website with an AFS or EOS directory on LXPLUS.

## Section 9: Other useful links and information

### Useful Links
- Main development GitHub: https://github.com/cerati/mictest
- Our project website: https://trackreco.github.io
- Out-of-date and longer used twiki: https://twiki.cern.ch/twiki/bin/viewauth/CMS/MicTrkRnD
- Indico meeting page: https://indico.cern.ch/category/8433
- Vidyo room: Parallel_Kalman_Filter_Tracking
- Email list-serv: mic-trk-rd@cern.ch

Acronyms/Abbreviations:
- AVX: Advanced Vector Extensions
### Tips and Tricks: Missing Libraries and Debugging

When sourcing the environment on phi3 via ```source xeon_scripts/init-env.sh```, some paths will be unset and access to local binaries may be lost. For example, since we source ROOT (and its many dependencies) over CVMFS, there may be some conflicts in loading some applications. In fact, the shell may complain about missing environment variables (emacs loves to complain about TIFF). The best way around this is to simply use CVMFS as a crutch to load in what you need.

This is particularly noticeable when trying to run a debugger. To compile the code, at a minimum, we must source icc + toolkits that give us libraries for c++14. We achieve this through the dependency loading of ROOT through CVMFS (previously, we sourced devtoolset-N to grab c++14 libraries).

After sourcing and compiling and then running only to find out there is some crash, when trying to load ```mkFit``` into ``gdb`` via ```gdb ./mkFit/mkFit```, it gives rather opaque error messages about missing Python paths.

This can be overcome by loading ```gdb``` over CVMFS: ```source /cvmfs/cms.cern.ch/slc7_amd64_gcc630/external/gdb/7.12.1-omkpbe2/etc/profile.d/init.sh```. At this point, the application will run normally and debugging can commence.

### Acronyms/Abbreviations:
- AVX: Advanced Vector Extensions [flavors of AVX: AVX, AVX2, AVX512]
- BH: Best Hit
- CCC: Charge Cluster Cut
- CE: Clone Engine
- CMS: Compact Muon Solenoid
- CMSSW: CMS Software
Expand All @@ -301,6 +316,7 @@ Acronyms/Abbreviations:
- GH: GitHub
- GUI: Graphical User Interface
- MEIF: Multiple-Events-In-Flight
- MP: Multi-Processing
- N^2: Local seed cleaning algorithm developed by Mario and Slava
- PR: Pull Request
- Reco: Reconstruction
Expand Down
67 changes: 36 additions & 31 deletions TTreeValidation.cc
Expand Up @@ -10,7 +10,14 @@ TTreeValidation::TTreeValidation(std::string fileName)
{
std::lock_guard<std::mutex> locker(glock_);
gROOT->ProcessLine("#include <vector>");
f_ = TFile::Open(fileName.c_str(), "recreate");

// KPM via DSR's ROOT wizardry: ROOT's context management implicitly assumes that a file is opened and
// closed on the same thread. To avoid the problem, we declare a local
// TContext object; when it goes out of scope, its destructor unregisters
// the context, guaranteeing the context is unregistered in the same thread
// it was registered in. (do this for tfiles and trees
TDirectory::TContext contextEraser;
f_ = std::unique_ptr<TFile>(TFile::Open(fileName.c_str(), "recreate"));

if (Config::sim_val_for_cmssw || Config::sim_val)
{
Expand All @@ -30,30 +37,12 @@ TTreeValidation::TTreeValidation(std::string fileName)
TTreeValidation::initializeConfigTree();
}

TTreeValidation::~TTreeValidation()
{
if (Config::sim_val_for_cmssw || Config::sim_val)
{
delete efftree_;
delete frtree_;
}
if (Config::cmssw_val)
{
delete cmsswefftree_;
delete cmsswfrtree_;
}
if (Config::fit_val)
{
delete fittree_;
}
delete configtree_;
delete f_;
}

void TTreeValidation::initializeEfficiencyTree()
{
{
// efficiency validation
efftree_ = new TTree("efftree","efftree");
efftree_ = std::make_unique<TTree>("efftree","efftree");
efftree_->SetDirectory(0);

efftree_->Branch("evtID",&evtID_eff_);
efftree_->Branch("mcID",&mcID_eff_);

Expand Down Expand Up @@ -176,8 +165,9 @@ void TTreeValidation::initializeEfficiencyTree()
void TTreeValidation::initializeFakeRateTree()
{
// fake rate validation
frtree_ = new TTree("frtree","frtree");

frtree_ = std::make_unique<TTree>("frtree","frtree");
frtree_->SetDirectory(0);

frtree_->Branch("evtID",&evtID_FR_);
frtree_->Branch("seedID",&seedID_FR_);

Expand Down Expand Up @@ -312,7 +302,8 @@ void TTreeValidation::initializeFakeRateTree()
void TTreeValidation::initializeConfigTree()
{
// include config ++ real seeding parameters ...
configtree_ = new TTree("configtree","configtree");
configtree_ = std::make_unique<TTree>("configtree","configtree");
configtree_->SetDirectory(0);

configtree_->Branch("Ntracks",&Ntracks_);
configtree_->Branch("Nevents",&Nevents_);
Expand Down Expand Up @@ -364,7 +355,9 @@ void TTreeValidation::initializeConfigTree()
void TTreeValidation::initializeCMSSWEfficiencyTree()
{
// cmssw reco track efficiency validation
cmsswefftree_ = new TTree("cmsswefftree","cmsswefftree");
cmsswefftree_ = std::make_unique<TTree>("cmsswefftree","cmsswefftree");
cmsswefftree_->SetDirectory(0);

cmsswefftree_->Branch("evtID",&evtID_ceff_);
cmsswefftree_->Branch("cmsswID",&cmsswID_ceff_);
cmsswefftree_->Branch("seedID_cmssw",&seedID_cmssw_ceff_);
Expand Down Expand Up @@ -473,7 +466,8 @@ void TTreeValidation::initializeCMSSWEfficiencyTree()
void TTreeValidation::initializeCMSSWFakeRateTree()
{
// cmssw reco track efficiency validation
cmsswfrtree_ = new TTree("cmsswfrtree","cmsswfrtree");
cmsswfrtree_ = std::make_unique<TTree>("cmsswfrtree","cmsswfrtree");
cmsswfrtree_->SetDirectory(0);

cmsswfrtree_->Branch("evtID",&evtID_cFR_);
cmsswfrtree_->Branch("seedID",&seedID_cFR_);
Expand Down Expand Up @@ -589,9 +583,10 @@ void TTreeValidation::initializeCMSSWFakeRateTree()

void TTreeValidation::initializeFitTree()
{
fittree_ = std::make_unique<TTree>("fittree","fittree");
fittree_->SetDirectory(0);

ntotallayers_fit_ = Config::nTotalLayers;

fittree_ = new TTree("fittree","fittree");

fittree_->Branch("ntotallayers",&ntotallayers_fit_,"ntotallayers_fit_/I");
fittree_->Branch("tkid",&tkid_fit_,"tkid_fit_/I");
Expand Down Expand Up @@ -2797,24 +2792,34 @@ void TTreeValidation::fillCMSSWFakeRateTree(const Event& ev)
}
}

void TTreeValidation::saveTTrees()
void TTreeValidation::saveTTrees()
{
std::lock_guard<std::mutex> locker(glock_);
f_->cd();

if (Config::sim_val_for_cmssw || Config::sim_val)
{
efftree_->SetDirectory(f_.get());
efftree_->Write();

frtree_->SetDirectory(f_.get());
frtree_->Write();
}
if (Config::cmssw_val)
{
cmsswefftree_->SetDirectory(f_.get());
cmsswefftree_->Write();

cmsswfrtree_->SetDirectory(f_.get());
cmsswfrtree_->Write();
}
if (Config::fit_val)
{
fittree_->SetDirectory(f_.get());
fittree_->Write();
}

configtree_->SetDirectory(f_.get());
configtree_->Write();
}

Expand Down
16 changes: 8 additions & 8 deletions TTreeValidation.h
Expand Up @@ -27,7 +27,7 @@ typedef std::unordered_map<int, FitValLayMap> TkIDtoFitValLayMapMap;
class TTreeValidation : public Validation {
public:
TTreeValidation(std::string fileName);
~TTreeValidation();
~TTreeValidation() {}

void initializeEfficiencyTree();
void initializeFakeRateTree();
Expand Down Expand Up @@ -75,7 +75,7 @@ class TTreeValidation : public Validation {
void saveTTrees() override;

private:
TFile* f_; // output file!
std::unique_ptr<TFile> f_; // output file!

TkIDtoFitValLayMapMap fitValTkMapMap_; // map used for fit validation in mplex

Expand Down Expand Up @@ -108,7 +108,7 @@ class TTreeValidation : public Validation {
TkIDToTkIDMap fitToSeedMapDumbCMSSW_;

// Efficiency Tree
TTree* efftree_;
std::unique_ptr<TTree> efftree_;
int evtID_eff_=0,mcID_eff_=0;
int mcmask_seed_eff_=0,mcmask_build_eff_=0,mcmask_fit_eff_=0;
int seedID_seed_eff_=0,seedID_build_eff_=0,seedID_fit_eff_=0;
Expand Down Expand Up @@ -154,7 +154,7 @@ class TTreeValidation : public Validation {
std::vector<int> hitidxs_mc_eff_,hitidxs_seed_eff_,hitidxs_build_eff_,hitidxs_fit_eff_;

// Fake Rate tree and variables
TTree* frtree_;
std::unique_ptr<TTree> frtree_;
int evtID_FR_=0,seedID_FR_=0;

int seedmask_seed_FR_=0,seedmask_build_FR_=0,seedmask_fit_FR_=0;
Expand Down Expand Up @@ -199,7 +199,7 @@ class TTreeValidation : public Validation {
std::vector<int> hitidxs_seed_FR_,hitidxs_build_FR_,hitidxs_fit_FR_,hitidxs_mc_seed_FR_,hitidxs_mc_build_FR_,hitidxs_mc_fit_FR_;

// Configuration tree
TTree* configtree_;
std::unique_ptr<TTree> configtree_;
int Ntracks_=0,Nevents_=0;
int nLayers_=0;
float fRadialSpacing_=0.,fRadialExtent_=0.,fInnerSensorSize_=0.,fOuterSensorSize_=0.;
Expand All @@ -215,7 +215,7 @@ class TTreeValidation : public Validation {
float ptinverr049_=0.,phierr049_=0.,thetaerr049_=0.,ptinverr012_=0.,phierr012_=0.,thetaerr012_=0.;

// CMSSW Efficiency tree
TTree* cmsswefftree_;
std::unique_ptr<TTree> cmsswefftree_;
int evtID_ceff_=0,cmsswID_ceff_=0,seedID_cmssw_ceff_=0;

float x_cmssw_ceff_=0.,y_cmssw_ceff_=0.,z_cmssw_ceff_=0.;
Expand Down Expand Up @@ -271,7 +271,7 @@ class TTreeValidation : public Validation {
std::vector<int> hitidxs_cmssw_ceff_,hitidxs_build_ceff_,hitidxs_mc_build_ceff_,hitidxs_fit_ceff_,hitidxs_mc_fit_ceff_;

// CMSSW FakeRate tree
TTree* cmsswfrtree_;
std::unique_ptr<TTree> cmsswfrtree_;
int evtID_cFR_=0,seedID_cFR_=0,mcTrackID_cFR_=0;

// build info
Expand Down Expand Up @@ -332,7 +332,7 @@ class TTreeValidation : public Validation {
std::vector<int> hitidxs_mc_cFR_,hitidxs_build_cFR_,hitidxs_cmssw_build_cFR_,hitidxs_fit_cFR_,hitidxs_cmssw_fit_cFR_;

// Fit tree (for fine tuning z-phi windows and such --> MPlex Only
TTree* fittree_;
std::unique_ptr<TTree> fittree_;
int ntotallayers_fit_=0,tkid_fit_=0,evtid_fit_=0;

static const int nfvs_ = 24;
Expand Down
12 changes: 6 additions & 6 deletions Track.h
Expand Up @@ -226,14 +226,14 @@ class Track
if (lastHitIdx_ < Config::nMaxTrkHits - 1)
{
hitsOnTrk_[++lastHitIdx_] = { hitIdx, hitLyr };
if (hitIdx >= 0) { ++nFoundHits_; chi2_+=chi2; }
if (hitIdx >= 0 || hitIdx == -9) { ++nFoundHits_; chi2_+=chi2; }
}
else
{
// printf("WARNING Track::addHitIdx hit-on-track limit reached for label=%d\n", label_);
// print("Track", -1, *this, true);

if (hitIdx >= 0)
if (hitIdx >= 0 || hitIdx == -9)
{
++nFoundHits_;
chi2_ += chi2;
Expand Down Expand Up @@ -320,7 +320,7 @@ class Track
void setNFoundHits() {
nFoundHits_=0;
for (int i = 0; i <= lastHitIdx_; i++) {
if (hitsOnTrk_[i].index >= 0) nFoundHits_++;
if (hitsOnTrk_[i].index >= 0 || hitsOnTrk_[i].index == -9) nFoundHits_++;
}
}

Expand All @@ -338,7 +338,7 @@ class Track
{
int n = 0;
for (int i = 0; i <= lastHitIdx_; ++i)
if (hitsOnTrk_[i].index >= 0) ++n;
if (hitsOnTrk_[i].index >= 0 || hitsOnTrk_[i].index == -9) ++n;
return n;
}

Expand All @@ -364,7 +364,7 @@ class Track
{
int h_lyr = hitsOnTrk_[ihit].layer;
if (skipSeedLyrs && Config::TrkInfo.is_seed_lyr(h_lyr)) continue;
if (h_lyr >= 0 && hitsOnTrk_[ihit].index >= 0 && h_lyr != prev_lyr)
if (h_lyr >= 0 && (hitsOnTrk_[ihit].index >= 0 || hitsOnTrk_[ihit].index == -9) && h_lyr != prev_lyr)
{
++lyr_cnt;
prev_lyr = h_lyr;
Expand All @@ -377,7 +377,7 @@ class Track
{
std::vector<int> layers;
for (int ihit = 0; ihit <= lastHitIdx_; ++ihit) {
if (hitsOnTrk_[ihit].index >= 0) {
if (hitsOnTrk_[ihit].index >= 0 || hitsOnTrk_[ihit].index == -9) {
layers.push_back( hitsOnTrk_[ihit].layer );
}
}
Expand Down

0 comments on commit 6dfdc46

Please sign in to comment.