Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MEIF with ROOT validation + CCC cut #1

Merged
merged 3 commits into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,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: [email protected]

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 @@ -303,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class Track
int getLastFoundHitPos() const
{
int hi = lastHitIdx_;
while (hitsOnTrk_[hi].index < 0 && hitsOnTrk_[hi].index != -9) --hi;
while (hitsOnTrk_[hi].index < 0) --hi;
return hi;
}

Expand Down
Loading