Skip to content

Commit

Permalink
Merge pull request #15 from FHead/BugFix20180405
Browse files Browse the repository at this point in the history
Bug fixes 20180405
  • Loading branch information
Alexx Perloff authored Apr 6, 2018
2 parents 2262545 + aac41ee commit 9ea9753
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 42 deletions.
8 changes: 7 additions & 1 deletion JetAnalyzers/bin/jet_synchfit_x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,10 @@ TF2 * doGraphFitting(TGraph2DErrors * graph, bool highPU, string functionType, i
//===========================================================================
// This method creates the txt file for the corrections
void createTxtFile(TString txtFilename, const vector<FitRes> & fitResults){


if(fitResults.size() == 0) // safety protection
return;

// Create the stream
ofstream outF(txtFilename.Data());

Expand Down Expand Up @@ -415,6 +418,9 @@ void createTxtFile(TString txtFilename, const vector<FitRes> & fitResults){
//===========================================================================
void createPDFFile(TFile* fout, TString pdfFilename, const vector<FitRes> & fitResults){

if(fitResults.size() == 0) // safety protection
return;

// The number of parameters in the fit.
// Assume all fitResults element have the same number
unsigned int nfitpars = fitResults[0].fit->GetNpar();
Expand Down
8 changes: 8 additions & 0 deletions JetAnalyzers/bin/jet_synchtest_x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ MatchEventsAndJets::MatchEventsAndJets() : algo1("ak5pf"), algo2("ak5pf"), iftes
algo2JetInfo = JetInfo(algo2);
getMaxDeltaR();
LumiWeightsSet_ = false;
recoJetIndexPU = NULL;
recoJetIndexNoPU = NULL;
jetMapTree = NULL;
fValue = NULL;
}

//______________________________________________________________________________
Expand All @@ -186,6 +190,10 @@ MatchEventsAndJets::MatchEventsAndJets(string algo1_, string algo2_, bool iftest
algo2JetInfo = JetInfo(algo2);
getMaxDeltaR();
LumiWeightsSet_ = false;
recoJetIndexPU = NULL;
recoJetIndexNoPU = NULL;
jetMapTree = NULL;
fValue = NULL;
}

//______________________________________________________________________________
Expand Down
79 changes: 40 additions & 39 deletions JetAnalyzers/src/JetResponseAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -442,47 +442,48 @@ void JetResponseAnalyzer::analyze(const edm::Event& iEvent,
}
}

// PFCANDIDATE INFORMATION
//Dual handle idea from https://github.com/aperloff/cmssw/blob/CMSSW_7_6_X/RecoJets/JetProducers/plugins/VirtualJetProducer.cc
//Random-Cone algo from https://github.com/cihar29/OffsetAnalysis/blob/master/run_offset.py
// and https://github.com/cihar29/OffsetAnalysis/blob/master/plugins/OffsetAnalysis.cc
if (saveCandidates_ && isPFJet_) {
bool isView = iEvent.getByToken(srcPFCandidates_, pfCandidates);
if ( isView ) {
for (auto i_pf=pfCandidates->begin(); i_pf != pfCandidates->end(); ++i_pf) {
auto i_pfc = (i_pf);
JRAEvent::Flavor pf_id = getFlavor( i_pfc->particleId() );
if (pf_id == JRAEvent::X) continue;
JRAEvt_->pfcand_px ->push_back(i_pfc->px());
JRAEvt_->pfcand_py ->push_back(i_pfc->py());
JRAEvt_->pfcand_pt ->push_back(i_pfc->pt());
JRAEvt_->pfcand_eta->push_back(i_pfc->eta());
JRAEvt_->pfcand_phi->push_back(i_pfc->phi());
JRAEvt_->pfcand_e ->push_back(i_pfc->energy());
JRAEvt_->pfcand_id ->push_back(pf_id);
}
}
else {
bool isPF = iEvent.getByToken(srcPFCandidatesAsFwdPtr_, pfCandidatesAsFwdPtr);
if ( isPF ) {
for (auto i_pf=pfCandidatesAsFwdPtr->begin(); i_pf != pfCandidatesAsFwdPtr->end(); ++i_pf) {
auto i_pfc = (*i_pf);
JRAEvent::Flavor pf_id = getFlavor( i_pfc->particleId() );
if (pf_id == JRAEvent::X) continue;
JRAEvt_->pfcand_px ->push_back(i_pfc->px());
JRAEvt_->pfcand_py ->push_back(i_pfc->py());
JRAEvt_->pfcand_pt ->push_back(i_pfc->pt());
JRAEvt_->pfcand_eta->push_back(i_pfc->eta());
JRAEvt_->pfcand_phi->push_back(i_pfc->phi());
JRAEvt_->pfcand_e ->push_back(i_pfc->energy());
JRAEvt_->pfcand_id ->push_back(pf_id);
}
}
}
}

JRAEvt_->nref++;
}

// PFCANDIDATE INFORMATION
//Dual handle idea from https://github.com/aperloff/cmssw/blob/CMSSW_7_6_X/RecoJets/JetProducers/plugins/VirtualJetProducer.cc
//Random-Cone algo from https://github.com/cihar29/OffsetAnalysis/blob/master/run_offset.py
// and https://github.com/cihar29/OffsetAnalysis/blob/master/plugins/OffsetAnalysis.cc
if (saveCandidates_ && isPFJet_) {
bool isView = iEvent.getByToken(srcPFCandidates_, pfCandidates);
if ( isView ) {
for (auto i_pf=pfCandidates->begin(); i_pf != pfCandidates->end(); ++i_pf) {
auto i_pfc = (i_pf);
JRAEvent::Flavor pf_id = getFlavor( i_pfc->particleId() );
if (pf_id == JRAEvent::X) continue;
JRAEvt_->pfcand_px ->push_back(i_pfc->px());
JRAEvt_->pfcand_py ->push_back(i_pfc->py());
JRAEvt_->pfcand_pt ->push_back(i_pfc->pt());
JRAEvt_->pfcand_eta->push_back(i_pfc->eta());
JRAEvt_->pfcand_phi->push_back(i_pfc->phi());
JRAEvt_->pfcand_e ->push_back(i_pfc->energy());
JRAEvt_->pfcand_id ->push_back(pf_id);
}
}
else {
bool isPF = iEvent.getByToken(srcPFCandidatesAsFwdPtr_, pfCandidatesAsFwdPtr);
if ( isPF ) {
for (auto i_pf=pfCandidatesAsFwdPtr->begin(); i_pf != pfCandidatesAsFwdPtr->end(); ++i_pf) {
auto i_pfc = (*i_pf);
JRAEvent::Flavor pf_id = getFlavor( i_pfc->particleId() );
if (pf_id == JRAEvent::X) continue;
JRAEvt_->pfcand_px ->push_back(i_pfc->px());
JRAEvt_->pfcand_py ->push_back(i_pfc->py());
JRAEvt_->pfcand_pt ->push_back(i_pfc->pt());
JRAEvt_->pfcand_eta->push_back(i_pfc->eta());
JRAEvt_->pfcand_phi->push_back(i_pfc->phi());
JRAEvt_->pfcand_e ->push_back(i_pfc->energy());
JRAEvt_->pfcand_id ->push_back(pf_id);
}
}
}
}


tree_->Fill();

Expand Down
4 changes: 2 additions & 2 deletions JetUtilities/interface/ProgressBar.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using std::remainder;
const int r = 100;

inline void loadbar2(unsigned int x, unsigned int n, unsigned int w = 50, string prefix = "") {
if ( (x != n) && (x % (n/100) != 0) ) return;
if ( (x != n) && ((n >= 100) && x % (n/100) != 0) ) return;

float ratio = x/(float)n;
int c = ratio * w;
Expand All @@ -25,7 +25,7 @@ inline void loadbar2(unsigned int x, unsigned int n, unsigned int w = 50, string
}

inline void loadbar3(unsigned int x, unsigned int n, unsigned int w = 50, string prefix = "") {
if ( (x != n) && (x % (n/10000) != 0) ) return;
if ( (x != n) && ((n >= 10000) && x % (n/10000) != 0) ) return;
//// round to nearest r
//unsigned int ntmp = n/10000;
//ntmp += r/2; // 1: Add r/2.
Expand Down

0 comments on commit 9ea9753

Please sign in to comment.