Skip to content

Commit 9ea9753

Browse files
author
Alexx Perloff
authored
Merge pull request #15 from FHead/BugFix20180405
Bug fixes 20180405
2 parents 2262545 + aac41ee commit 9ea9753

4 files changed

Lines changed: 57 additions & 42 deletions

File tree

JetAnalyzers/bin/jet_synchfit_x.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,10 @@ TF2 * doGraphFitting(TGraph2DErrors * graph, bool highPU, string functionType, i
378378
//===========================================================================
379379
// This method creates the txt file for the corrections
380380
void createTxtFile(TString txtFilename, const vector<FitRes> & fitResults){
381-
381+
382+
if(fitResults.size() == 0) // safety protection
383+
return;
384+
382385
// Create the stream
383386
ofstream outF(txtFilename.Data());
384387

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

421+
if(fitResults.size() == 0) // safety protection
422+
return;
423+
418424
// The number of parameters in the fit.
419425
// Assume all fitResults element have the same number
420426
unsigned int nfitpars = fitResults[0].fit->GetNpar();

JetAnalyzers/bin/jet_synchtest_x.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ MatchEventsAndJets::MatchEventsAndJets() : algo1("ak5pf"), algo2("ak5pf"), iftes
171171
algo2JetInfo = JetInfo(algo2);
172172
getMaxDeltaR();
173173
LumiWeightsSet_ = false;
174+
recoJetIndexPU = NULL;
175+
recoJetIndexNoPU = NULL;
176+
jetMapTree = NULL;
177+
fValue = NULL;
174178
}
175179

176180
//______________________________________________________________________________
@@ -186,6 +190,10 @@ MatchEventsAndJets::MatchEventsAndJets(string algo1_, string algo2_, bool iftest
186190
algo2JetInfo = JetInfo(algo2);
187191
getMaxDeltaR();
188192
LumiWeightsSet_ = false;
193+
recoJetIndexPU = NULL;
194+
recoJetIndexNoPU = NULL;
195+
jetMapTree = NULL;
196+
fValue = NULL;
189197
}
190198

191199
//______________________________________________________________________________

JetAnalyzers/src/JetResponseAnalyzer.cc

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -442,47 +442,48 @@ void JetResponseAnalyzer::analyze(const edm::Event& iEvent,
442442
}
443443
}
444444

445-
// PFCANDIDATE INFORMATION
446-
//Dual handle idea from https://github.com/aperloff/cmssw/blob/CMSSW_7_6_X/RecoJets/JetProducers/plugins/VirtualJetProducer.cc
447-
//Random-Cone algo from https://github.com/cihar29/OffsetAnalysis/blob/master/run_offset.py
448-
// and https://github.com/cihar29/OffsetAnalysis/blob/master/plugins/OffsetAnalysis.cc
449-
if (saveCandidates_ && isPFJet_) {
450-
bool isView = iEvent.getByToken(srcPFCandidates_, pfCandidates);
451-
if ( isView ) {
452-
for (auto i_pf=pfCandidates->begin(); i_pf != pfCandidates->end(); ++i_pf) {
453-
auto i_pfc = (i_pf);
454-
JRAEvent::Flavor pf_id = getFlavor( i_pfc->particleId() );
455-
if (pf_id == JRAEvent::X) continue;
456-
JRAEvt_->pfcand_px ->push_back(i_pfc->px());
457-
JRAEvt_->pfcand_py ->push_back(i_pfc->py());
458-
JRAEvt_->pfcand_pt ->push_back(i_pfc->pt());
459-
JRAEvt_->pfcand_eta->push_back(i_pfc->eta());
460-
JRAEvt_->pfcand_phi->push_back(i_pfc->phi());
461-
JRAEvt_->pfcand_e ->push_back(i_pfc->energy());
462-
JRAEvt_->pfcand_id ->push_back(pf_id);
463-
}
464-
}
465-
else {
466-
bool isPF = iEvent.getByToken(srcPFCandidatesAsFwdPtr_, pfCandidatesAsFwdPtr);
467-
if ( isPF ) {
468-
for (auto i_pf=pfCandidatesAsFwdPtr->begin(); i_pf != pfCandidatesAsFwdPtr->end(); ++i_pf) {
469-
auto i_pfc = (*i_pf);
470-
JRAEvent::Flavor pf_id = getFlavor( i_pfc->particleId() );
471-
if (pf_id == JRAEvent::X) continue;
472-
JRAEvt_->pfcand_px ->push_back(i_pfc->px());
473-
JRAEvt_->pfcand_py ->push_back(i_pfc->py());
474-
JRAEvt_->pfcand_pt ->push_back(i_pfc->pt());
475-
JRAEvt_->pfcand_eta->push_back(i_pfc->eta());
476-
JRAEvt_->pfcand_phi->push_back(i_pfc->phi());
477-
JRAEvt_->pfcand_e ->push_back(i_pfc->energy());
478-
JRAEvt_->pfcand_id ->push_back(pf_id);
479-
}
480-
}
481-
}
482-
}
483-
484445
JRAEvt_->nref++;
485446
}
447+
448+
// PFCANDIDATE INFORMATION
449+
//Dual handle idea from https://github.com/aperloff/cmssw/blob/CMSSW_7_6_X/RecoJets/JetProducers/plugins/VirtualJetProducer.cc
450+
//Random-Cone algo from https://github.com/cihar29/OffsetAnalysis/blob/master/run_offset.py
451+
// and https://github.com/cihar29/OffsetAnalysis/blob/master/plugins/OffsetAnalysis.cc
452+
if (saveCandidates_ && isPFJet_) {
453+
bool isView = iEvent.getByToken(srcPFCandidates_, pfCandidates);
454+
if ( isView ) {
455+
for (auto i_pf=pfCandidates->begin(); i_pf != pfCandidates->end(); ++i_pf) {
456+
auto i_pfc = (i_pf);
457+
JRAEvent::Flavor pf_id = getFlavor( i_pfc->particleId() );
458+
if (pf_id == JRAEvent::X) continue;
459+
JRAEvt_->pfcand_px ->push_back(i_pfc->px());
460+
JRAEvt_->pfcand_py ->push_back(i_pfc->py());
461+
JRAEvt_->pfcand_pt ->push_back(i_pfc->pt());
462+
JRAEvt_->pfcand_eta->push_back(i_pfc->eta());
463+
JRAEvt_->pfcand_phi->push_back(i_pfc->phi());
464+
JRAEvt_->pfcand_e ->push_back(i_pfc->energy());
465+
JRAEvt_->pfcand_id ->push_back(pf_id);
466+
}
467+
}
468+
else {
469+
bool isPF = iEvent.getByToken(srcPFCandidatesAsFwdPtr_, pfCandidatesAsFwdPtr);
470+
if ( isPF ) {
471+
for (auto i_pf=pfCandidatesAsFwdPtr->begin(); i_pf != pfCandidatesAsFwdPtr->end(); ++i_pf) {
472+
auto i_pfc = (*i_pf);
473+
JRAEvent::Flavor pf_id = getFlavor( i_pfc->particleId() );
474+
if (pf_id == JRAEvent::X) continue;
475+
JRAEvt_->pfcand_px ->push_back(i_pfc->px());
476+
JRAEvt_->pfcand_py ->push_back(i_pfc->py());
477+
JRAEvt_->pfcand_pt ->push_back(i_pfc->pt());
478+
JRAEvt_->pfcand_eta->push_back(i_pfc->eta());
479+
JRAEvt_->pfcand_phi->push_back(i_pfc->phi());
480+
JRAEvt_->pfcand_e ->push_back(i_pfc->energy());
481+
JRAEvt_->pfcand_id ->push_back(pf_id);
482+
}
483+
}
484+
}
485+
}
486+
486487

487488
tree_->Fill();
488489

JetUtilities/interface/ProgressBar.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ using std::remainder;
1313
const int r = 100;
1414

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

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

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

0 commit comments

Comments
 (0)