Skip to content

Commit

Permalink
bugfix for ROC plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
jkiesele committed Apr 26, 2017
1 parent a3840e4 commit 45bedfb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
3 changes: 2 additions & 1 deletion modules/interface/rocCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class rocCurve{
const TH1D* getProbHisto()const{return &probh_;}
const TH1D* getVetoProbHisto()const{return &vetoh_;}
const TH1D* getInvalidatedHisto()const{return &invalidate_;}
const TH1D* getInvalidatedVetoHisto()const{return &invalidate_veto_;}


private:
Expand All @@ -84,7 +85,7 @@ class rocCurve{

TH1D probh_;
TH1D vetoh_;
TH1D invalidate_;
TH1D invalidate_,invalidate_veto_;

TGraph roc_;
int linecol_,linewidth_,linestyle_;
Expand Down
20 changes: 14 additions & 6 deletions modules/src/rocCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ void rocCurve::process(TChain *c){
probstr.Remove(probstr.Length()-1);

TString allcuts=truthstr;
TString allinvalid=makeinvalidif_;
if(allinvalid.Length()<1){
allinvalid=probstr+"<-10000"; //false
TString allinvalid_truth=makeinvalidif_;
if(allinvalid_truth.Length()<1){
allinvalid_truth=probstr+"<-10000"; //false
}

allinvalid+="&&"+truthstr;
TString allinvalid_veto=allinvalid_truth+"&&"+vetostr;
allinvalid_truth+="&&"+truthstr;

if(cuts_.Length()){
if(allcuts.Length())
Expand All @@ -96,7 +97,8 @@ void rocCurve::process(TChain *c){
else
vetostr=cuts_;

allinvalid=allinvalid+"&&"+cuts_;
allinvalid_truth=allinvalid_truth+"&&"+cuts_;
allinvalid_veto+="&&"+cuts_;
}


Expand All @@ -106,21 +108,25 @@ void rocCurve::process(TChain *c){
probh_=TH1D("prob","prob",nbins_,0,1);
vetoh_=TH1D("veto","veto",nbins_,0,1);
invalidate_=TH1D("invalid","invalid",nbins_,0,1);
invalidate_veto_=TH1D("invalid_veto","invalid_veto",nbins_,0,1);


c->Draw(probstr+">>prob",allcuts);//probcuts);
c->Draw(probstr+">>veto",vetostr);
c->Draw(probstr+">>invalid",allinvalid);
c->Draw(probstr+">>invalid",allinvalid_truth);
c->Draw(probstr+">>invalid_veto",allinvalid_veto);


//remove from mem list
probh_.SetDirectory(0);
vetoh_.SetDirectory(0);
invalidate_.SetDirectory(0);
invalidate_veto_.SetDirectory(0);

probh_.SetName("probh_");
vetoh_.SetName("vetoh_");
invalidate_.SetName("invalidate_");
invalidate_veto_.SetName("invalidate_veto_");

std::vector<double> p(nbins_),v(nbins_);

Expand All @@ -129,6 +135,8 @@ void rocCurve::process(TChain *c){
// double invalidintegral=invalid.Integral(0,nbins_);

probh_.Add(&invalidate_,-1.);
vetoh_.Add(&invalidate_veto_,-1.);

for(int i=0;i<=probh_.GetNbinsX();i++){
if(probh_.GetBinContent(i)<0)probh_.SetBinContent(i,0);//just safety measure
}
Expand Down
6 changes: 5 additions & 1 deletion modules/src/rocCurveCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void rocCurveCollection::printRocs(TChain* c, const TString& outpdf,
createFile=true;
}
size_t count=0;
std::vector<TH1D*> probhistos,vetohistos,invalidhistos;
std::vector<TH1D*> probhistos,vetohistos,invalidhistos,invalidvetohistos;
for(auto& rc:roccurves_){
rc.setNBins(200);
rc.process(c);
Expand All @@ -67,6 +67,8 @@ void rocCurveCollection::printRocs(TChain* c, const TString& outpdf,
tempname+=count;
TH1D* hc=(TH1D*)rc.getInvalidatedHisto()->Clone(tempname);
invalidhistos.push_back(hc);
TH1D* hd=(TH1D*)rc.getInvalidatedHisto()->Clone(tempname);
invalidvetohistos.push_back(hd);
}


Expand Down Expand Up @@ -136,6 +138,8 @@ void rocCurveCollection::printRocs(TChain* c, const TString& outpdf,
probhistos.at(count)->Write();
invalidhistos.at(count)->SetName((TString)g->GetTitle()+"_invalid");
invalidhistos.at(count)->Write();
invalidvetohistos.at(count)->SetName((TString)g->GetTitle()+"_invalid_veto");
invalidvetohistos.at(count)->Write();
count++;
}

Expand Down

0 comments on commit 45bedfb

Please sign in to comment.