#include <FitHist.h>
Public Types | |
enum | EvalType { kStabilizedGauss, kHistogramMean, kMaximalValue, kQuantile } |
Public Member Functions | |
void | fillTargetHistograms () |
void | fitAndDrawEps () |
void | fitAndDrawPs () |
FitHist () | |
FitHist (bool verbose) | |
void | writeFitOutput () |
virtual | ~FitHist () |
Protected Member Functions | |
void | addBinLabelToFitHist (const TObjArray &, int &, TString &, TString &) |
void | addParLabelToFitHist (const TH1F &) |
bool | checkTargetHistList () |
void | configBlockFit (ConfigFile &) |
void | fillTargetHistogram (std::string &) |
void | fillTargetHistogramBin (TH1F &, TH1F &, int, TString &, HistogramMean &) |
void | fillTargetHistogramBin (TH1F &, TH1F &, int) |
void | fillTargetHistogramBin (TH1F &, TH1F &, int, TString &, Quantile &) |
void | fillTargetHistogramBin (TH1F &, TH1F &, int, TString &, MaximalValue &) |
void | fillTargetHistogramBin (TH1F &, TH1F &, int, TString &, StabilizedGauss &) |
TH1F & | findFitHistogram (const TObjArray &, TString &, TString &, int &) |
TH1F & | findTargetHistogram (const TObjArray &, TString &, TString &, TString &) |
bool | isInFitTargetList (std::string &) |
double | normalize (TString &, double) |
void | setFitHistogramAxes (TH1F &, int) |
Protected Attributes | |
std::vector< int > | axesIndex_ |
int | evalType_ |
double | fitFuncLowerBound_ |
std::string | fitFuncName_ |
std::string | fitFuncTitle_ |
int | fitFuncType_ |
double | fitFuncUpperBound_ |
std::vector< std::string > | targetHistList_ |
std::vector< std::string > | xAxesFit_ |
std::vector< std::string > | yAxesFit_ |
enum FitHist::EvalType |
FitHist::FitHist | ( | bool | verbose | ) | [inline] |
void FitHist::addBinLabelToFitHist | ( | const TObjArray & | hist, |
int & | bin, | ||
TString & | name, | ||
TString & | zip | ||
) | [protected] |
Definition at line 266 of file FitHist.cc.
References filterCSVwithJSON::target, and runonSM::text.
{ //--------------------------------------------- // add pave text to fitted histograms keeping // information of the corresponding bin edges //--------------------------------------------- TPaveText* text = new TPaveText(0.25, 0.85, 0.95, 0.95, "NDC"); text->SetBorderSize( 0 ); text->SetFillStyle( 4000 ); text->SetTextAlign( 12 ); text->SetTextSize ( 0.06 ); text->SetTextColor( 1 ); text->SetTextFont ( 62 ); char labelname[100]; TString buffer(targetHistList_[0]); buffer+="_"; TH1F& target = findTargetHistogram(hist, zip, name, buffer); double lowerEdge = target.GetBinLowEdge(bin+1); double upperEdge = target.GetBinLowEdge(bin+1)+target.GetBinWidth(bin+1); sprintf(labelname, "[%3.0f GeV; %3.0f GeV]", lowerEdge, upperEdge );//FIXME: this does not need to be GeV only text->AddText( labelname ); text->Draw(); }
void FitHist::addParLabelToFitHist | ( | const TH1F & | hist | ) | [protected] |
Definition at line 291 of file FitHist.cc.
{ if( hist.GetFunction(fitFuncName_.c_str()) ){ TPaveText* pars = new TPaveText(0.40, 0.55, 0.95, 0.70, "NDC"); pars->SetBorderSize( 0 ); pars->SetFillStyle( 4000 ); pars->SetTextAlign( 12 ); pars->SetTextSize ( 0.06 ); pars->SetTextColor( 1 ); pars->SetTextFont ( 62 ); char parstring[100]; if(fitFuncType_==0){ sprintf(parstring, "#mu=%3.2f ; #sigma=%3.2f", hist.GetFunction(fitFuncName_.c_str())->GetParameter( 1 ), hist.GetFunction(fitFuncName_.c_str())->GetParameter( 2 ) ); } pars->AddText( parstring ); pars->Draw(); } }
bool FitHist::checkTargetHistList | ( | ) | [protected] |
Definition at line 44 of file FitHist.cc.
{ //----------------------------------------------- // check list of target histogram labels, return // true if all elements are supported and false // otherwise //----------------------------------------------- bool statusOk=true; for(unsigned int idx=0; idx<targetHistList_.size(); ++idx){ if( statusOk ) statusOk=isInFitTargetList(targetHistList_[idx]); } return statusOk; }
void FitHist::configBlockFit | ( | ConfigFile & | cfg | ) | [protected] |
Definition at line 9 of file FitHist.cc.
References benchmark_cfg::cerr, cmsRelvalreport::exit, ConfigFile::read(), and readVector().
{ //----------------------------------------------- // read all configurables defined in FitHisto- // grams from config file. Throw human readable // exception when misspellings occure //----------------------------------------------- try{ //----------------------------------------------- // histogram steering //----------------------------------------------- readVector( cfg.read<std::string>( "titleIndex"), axesIndex_); readLabels( cfg.read<std::string>( "xAxesFit" ), xAxesFit_ ); readLabels( cfg.read<std::string>( "yAxesFit" ), yAxesFit_ ); //----------------------------------------------- // histogram manipulations //----------------------------------------------- readVector( cfg.read<std::string>( "targetLabel" ), targetHistList_); fitFuncName_ = cfg.read<std::string>( "fitFunctionName" ); fitFuncTitle_= cfg.read<std::string>( "fitFunctionTitle"); fitFuncType_ = cfg.read<int> ( "fitFunctionType" ); fitFuncLowerBound_= cfg.read<double>( "fitLowerBound" ); fitFuncUpperBound_= cfg.read<double>( "fitUpperBound" ); evalType_ = cfg.read<int>( "evalType" ); } catch(...){ std::cerr << "ERROR during reading of config file" << std::endl; std::cerr << " misspelled variables in cfg ?" << std::endl; std::cerr << " [--called in configBlockFit]" << std::endl; std::exit(1); } }
void FitHist::fillTargetHistogram | ( | std::string & | target | ) | [protected] |
Definition at line 523 of file FitHist.cc.
References estimatePileup::hist.
{ //--------------------------------------------- // loop array of samples via sampleList_, which // contains all histograms in TObjectArrays for // each sample //--------------------------------------------- std::vector<TObjArray>::const_iterator hist = sampleList_.begin(); for(; hist!=sampleList_.end(); ++hist){ //--------------------------------------------- // loop histograms & search for prefix target; // check if it's contained in list of valid // targets first //--------------------------------------------- TString buffer( target ); if( isInFitTargetList(target) ){ for(int jdx=0; jdx<(*hist).GetEntriesFast(); ++jdx){ TH1F& htarget = *((TH1F*)(*hist)[jdx]); // prepare compare string TString cmp( htarget.GetName() ); // chop off root directory and cmp.Remove(0, cmp.First('/')+1); // file from histogram name //prepare zip code TString zip( htarget.GetName() ); // chop off histogram name keep zip.Remove(zip.First('/'), zip.Length()); // file and directory if( cmp.BeginsWith( buffer ) ){ //found target hist //--------------------------------------------- // now fill the bins of the target hist //--------------------------------------------- for(int kdx=0; kdx<htarget.GetNbinsX(); ++kdx){ TH1F& hfit = findFitHistogram(*hist, zip, cmp, kdx); fillTargetHistogramBin(htarget, hfit, (kdx+1)); } } } } } }
void FitHist::fillTargetHistogramBin | ( | TH1F & | htarget, |
TH1F & | hfit, | ||
int | bin, | ||
TString & | buffer, | ||
HistogramMean & | func | ||
) | [protected] |
Definition at line 175 of file FitHist.cc.
References FitTarget::Cal, FitTarget::Mean, lumiNorm::norm, FitTarget::Res, FitTarget::Sigma, HistogramMean::spread(), HistogramMean::spreadError(), HistogramMean::value(), and HistogramMean::valueError().
{ if( !buffer.CompareTo(FitTarget::Cal) || !buffer.CompareTo(FitTarget::Mean ) ){ htarget.SetBinContent( bin, func.value( hfit ) ); htarget.SetBinError( bin, func.valueError( hfit ) ); } if( !buffer.CompareTo(FitTarget::Res) || !buffer.CompareTo(FitTarget::Sigma) ){ double norm=normalize(buffer, func.value( hfit )); htarget.SetBinContent( bin, norm*func.spread( hfit ) ); htarget.SetBinError ( bin, norm*func.spreadError( hfit ) ); } }
void FitHist::fillTargetHistogramBin | ( | TH1F & | htarget, |
TH1F & | hfit, | ||
int | bin, | ||
TString & | buffer, | ||
StabilizedGauss & | func | ||
) | [protected] |
Definition at line 187 of file FitHist.cc.
References FitTarget::Cal, FitTarget::Mean, lumiNorm::norm, FitTarget::Res, FitTarget::Sigma, StabilizedGauss::spread(), StabilizedGauss::spreadError(), StabilizedGauss::value(), and StabilizedGauss::valueError().
{ if( !buffer.CompareTo(FitTarget::Cal) || !buffer.CompareTo(FitTarget::Mean ) ){ htarget.SetBinContent( bin, func.value( hfit ) ); htarget.SetBinError( bin, func.valueError( hfit ) ); } if( !buffer.CompareTo(FitTarget::Res) || !buffer.CompareTo(FitTarget::Sigma) ){ double norm=normalize(buffer, func.value( hfit )); htarget.SetBinContent( bin, norm*func.spread( hfit ) ); htarget.SetBinError ( bin, norm*func.spreadError( hfit ) ); } }
void FitHist::fillTargetHistogramBin | ( | TH1F & | htarget, |
TH1F & | hfit, | ||
int | bin | ||
) | [protected] |
Definition at line 199 of file FitHist.cc.
{ if( !hfit.GetEntries()>0 ) return; //----------------------------------------------- // fill corresponding bin in target histogram //----------------------------------------------- TString buffer(htarget.GetName()); buffer.Remove(0, buffer.First('/')+1); buffer.Remove(buffer.First('_')+1, buffer.Length()); switch(evalType_){ case kStabilizedGauss: { StabilizedGauss func(fitFuncName_.c_str()); fillTargetHistogramBin(htarget, hfit, bin, buffer, func); break; } case kHistogramMean: { HistogramMean func; fillTargetHistogramBin(htarget, hfit, bin, buffer, func); break; } case kMaximalValue: { MaximalValue func(0.9, 0.05); fillTargetHistogramBin(htarget, hfit, bin, buffer, func); break; } case kQuantile: { Quantile func(0.5, 0.05); fillTargetHistogramBin(htarget, hfit, bin, buffer, func); break; } default: break; } }
void FitHist::fillTargetHistogramBin | ( | TH1F & | htarget, |
TH1F & | hfit, | ||
int | bin, | ||
TString & | buffer, | ||
Quantile & | func | ||
) | [protected] |
Definition at line 151 of file FitHist.cc.
References FitTarget::Cal, FitTarget::Mean, lumiNorm::norm, FitTarget::Res, FitTarget::Sigma, Quantile::spread(), Quantile::spreadError(), Quantile::value(), and Quantile::valueError().
{ if( !buffer.CompareTo(FitTarget::Cal) || !buffer.CompareTo(FitTarget::Mean ) ){ htarget.SetBinContent( bin, func.value( hfit ) ); htarget.SetBinError( bin, func.valueError( hfit ) ); } if( !buffer.CompareTo(FitTarget::Res) || !buffer.CompareTo(FitTarget::Sigma) ){ double norm=normalize(buffer, func.value( hfit )); htarget.SetBinContent( bin, norm*func.spread( hfit ) ); htarget.SetBinError ( bin, norm*func.spreadError( hfit ) ); } }
void FitHist::fillTargetHistogramBin | ( | TH1F & | htarget, |
TH1F & | hfit, | ||
int | bin, | ||
TString & | buffer, | ||
MaximalValue & | func | ||
) | [protected] |
Definition at line 163 of file FitHist.cc.
References FitTarget::Cal, FitTarget::Mean, lumiNorm::norm, FitTarget::Res, FitTarget::Sigma, MaximalValue::spread(), MaximalValue::spreadError(), MaximalValue::value(), and MaximalValue::valueError().
{ if( !buffer.CompareTo(FitTarget::Cal) || !buffer.CompareTo(FitTarget::Mean ) ){ htarget.SetBinContent( bin, func.value( hfit ) ); htarget.SetBinError( bin, func.valueError( hfit ) ); } if( !buffer.CompareTo(FitTarget::Res) || !buffer.CompareTo(FitTarget::Sigma) ){ double norm=normalize(buffer, func.value( hfit )); htarget.SetBinContent( bin, norm*func.spread( hfit ) ); htarget.SetBinError ( bin, norm*func.spreadError( hfit ) ); } }
void FitHist::fillTargetHistograms | ( | ) |
Definition at line 512 of file FitHist.cc.
Referenced by main().
{ //--------------------------------------------- // fill all target histograms //--------------------------------------------- for(unsigned int idx=0; idx<targetHistList_.size(); ++idx){ fillTargetHistogram(targetHistList_[idx]); } }
TH1F & FitHist::findFitHistogram | ( | const TObjArray & | hist, |
TString & | zip, | ||
TString & | name, | ||
int & | bin | ||
) | [protected] |
Definition at line 77 of file FitHist.cc.
References newFWLiteAna::bin, gather_cfg::cout, and FitTarget::Fit.
{ //--------------------------------------------- // returns fit histogram of bin 'bin'to // corresponding target histogram //--------------------------------------------- //prepare reference name TString refName( name ); refName+="_"; refName+=bin; refName.Remove(0, refName.First('_')+1); //chop of prefix //--------------------------------------------- // loop array of histograms & search for ref //--------------------------------------------- for(int idx=0; idx<hist.GetEntriesFast(); ++idx){ TH1F& cmp = *((TH1F*)(hist)[idx]); TString buffer( cmp.GetName() ); if( buffer.BeginsWith( zip ) ){ TString cmpName( cmp.GetName() ); // chop off root directory and cmpName.Remove(0, cmpName.First('/')+1); // file from histogram name if( cmpName.BeginsWith(FitTarget::Fit) && cmpName.Contains(refName) ){ return cmp; } } } std::cout << "WARNING: could not find required histogram fit_" << refName << "_x" << std::endl << " return reference to Null" << std::endl; return *(TH1F*)0; }
TH1F & FitHist::findTargetHistogram | ( | const TObjArray & | hist, |
TString & | zip, | ||
TString & | name, | ||
TString & | target | ||
) | [protected] |
Definition at line 111 of file FitHist.cc.
References gather_cfg::cout.
{ //--------------------------------------------- // returns target histogram to corresponding // fit histogram //--------------------------------------------- //prepare reference name TString refName( name ); refName.Remove(0, refName.First('_')+1); //chop of prefix refName.Remove(refName.Last('_'), refName.Length()); //chop of postfix //--------------------------------------------- // loop array of histograms & search for ref //--------------------------------------------- for(int idx=0; idx<hist.GetEntriesFast(); ++idx){ TH1F& cmp = *((TH1F*)(hist)[idx]); TString buffer( cmp.GetName() ); if( buffer.BeginsWith( zip ) ){ // prepare compare string TString cmpName( cmp.GetName() ); // chop off root directory and cmpName.Remove(0, cmpName.First('/')+1); // file from histogram name if( cmpName.BeginsWith(target) && cmpName.Contains(refName) ){ return cmp; } } } std::cout << "WARNING: could not find required histogram " << target << refName << std::endl << " return reference to Null" << std::endl; return *(TH1F*)0; }
void FitHist::fitAndDrawEps | ( | ) |
Definition at line 414 of file FitHist.cc.
References newFWLiteAna::bin, FitTarget::Fit, StabilizedGauss::fit(), estimatePileup::hist, label, MultipleCompare::legend, and convertSQLitetoXML_cfg::output.
Referenced by main().
{ //----------------------------------------------- // define canvas //----------------------------------------------- TCanvas *canv = new TCanvas("canv", "fit histograms", 600, 600); setCanvasStyle( *canv ); canv->SetGridx( 1 ); canv->SetLogx ( 0 ); canv->SetGridy( 1 ); canv->SetLogy ( 0 ); //----------------------------------------------- // loop histograms via the list of histogram // names stored in histList_, open a new page // for each histogram; open a new file for each // sample. //----------------------------------------------- std::vector<TObjArray>::const_iterator hist = sampleList_.begin(); for(int idx=0; hist!=sampleList_.end(); ++hist, ++idx){ //--------------------------------------------- // loop histograms via the list of histogram // names stored in histList_, open a new page // for each histogram; fit any histogram con- // taining the prefix 'fit' //--------------------------------------------- int label=0; for(int jdx=0; jdx<(*hist).GetEntriesFast(); ++jdx){ TH1F& hfit = *((TH1F*)(*hist)[jdx]); //recieve histogram // prepare compare string TString cmp( hfit.GetName() ); // chop off root directory and cmp.Remove(0, cmp.First('/')+1); // file from histogram name //prepare zip code TString zip( hfit.GetName() ); // chop off histogram name keep zip.Remove(zip.First('/'), zip.Length()); // file and directory if ( cmp.BeginsWith(FitTarget::Fit) ){ //search for prefix 'fit' //----------------------------------------------- // open output file //----------------------------------------------- TString output( writeTo_.c_str() ); output += "/"; output += histList_[ jdx ]; output += "_"; if(outputLabelList_.size()>=sampleList_.size()) output += outputLabelList_[idx]; else output == idx; output += ".eps"; TPostScript psFile( output, 113 ); psFile.NewPage(); //----------------------------------------------- // determine proper bin by choping off everything // bit the postfix which should correspond to the // bin of NameScheme //----------------------------------------------- TString buffer( cmp ); int bin = buffer.Remove(0, buffer.Last('_')+1).Atoi(); hfit.SetLineWidth( 5 ); hfit.SetLineColor( 4 ); hfit.SetLineStyle( 1 ); hfit.SetMarkerStyle( 20 ); hfit.SetMarkerSize( 2.0 ); hfit.SetMarkerColor( 4 ); setFitHistogramAxes( hfit, label++ ); //hfit.Fit( "gaus" ); //do stable fit StabilizedGauss func(fitFuncName_.c_str(), fitFuncType_, fitFuncLowerBound_, fitFuncUpperBound_); func.fit(hfit); hfit.Draw("esame"); //--------------------------------------------- // add TPaveLabel to keep info of binning // recieved from target hitogram //--------------------------------------------- addParLabelToFitHist( hfit ); addBinLabelToFitHist( *hist, bin, cmp, zip ); //--------------------------------------------- // add legend to fitted histogram //--------------------------------------------- TLegend* leg = new TLegend(0.25,0.70,0.95,0.87); setLegendStyle( *leg ); leg->AddEntry( &hfit, legend(idx).c_str(), "PL" ); leg->AddEntry( hfit.GetFunction(fitFuncName_.c_str()), fitFuncTitle_.c_str(), "L" ); leg->Draw( "same" ); canv->RedrawAxis( ); canv->Update( ); psFile.Close(); delete leg; } } } canv->Close(); delete canv; }
void FitHist::fitAndDrawPs | ( | ) |
Definition at line 314 of file FitHist.cc.
References newFWLiteAna::bin, gather_cfg::cout, FitTarget::Fit, StabilizedGauss::fit(), estimatePileup::hist, label, MultipleCompare::legend, and convertSQLitetoXML_cfg::output.
Referenced by main().
{ //----------------------------------------------- // define canvas //----------------------------------------------- TCanvas *canv = new TCanvas("canv", "fit histograms", 600, 600); setCanvasStyle( *canv ); canv->SetGridx( 1 ); canv->SetLogx ( 0 ); canv->SetGridy( 1 ); canv->SetLogy ( 0 ); //----------------------------------------------- // loop histograms via the list of histogram // names stored in histList_, open a new page // for each histogram; open a new file for each // sample. //----------------------------------------------- std::vector<TObjArray>::const_iterator hist = sampleList_.begin(); for(int idx=0; hist!=sampleList_.end(); ++hist, ++idx){ //----------------------------------------------- // open output file //----------------------------------------------- TString output( writeTo_.c_str() ); output += "/inspectFit_"; if(outputLabelList_.size()>=sampleList_.size()) output += outputLabelList_[idx]; else output == idx; output += ".ps"; TPostScript psFile( output, 111 ); //112 for portrat //--------------------------------------------- // loop histograms via the list of histogram // names stored in histList_, open a new page // for each histogram; fit any histogram con- // taining the prefix 'fit' //--------------------------------------------- int label=0; for(int jdx=0; jdx<(*hist).GetEntriesFast(); ++jdx){ TH1F& hfit = *((TH1F*)(*hist)[jdx]); //recieve histogram // prepare compare string TString cmp( hfit.GetName() ); // chop off root directory and cmp.Remove(0, cmp.First('/')+1); // file from histogram name //prepare zip code TString zip( hfit.GetName() ); // chop off histogram name keep zip.Remove(zip.First('/'), zip.Length()); // file and directory if ( cmp.BeginsWith(FitTarget::Fit) ){ //search for prefix 'fit' psFile.NewPage(); if(verbose_){ std::cout << std::endl << "about to fit histogram: " << hfit.GetName() << " as " << cmp << std::endl; } //----------------------------------------------- // determine proper bin by choping off everything // but the postfix which should correspond to the // bin of NameScheme //----------------------------------------------- TString buffer( cmp ); int bin = buffer.Remove(0, buffer.Last('_')+1).Atoi(); hfit.SetLineWidth( 5 ); hfit.SetLineColor( 4 ); hfit.SetLineStyle( 1 ); hfit.SetMarkerStyle( 20 ); hfit.SetMarkerSize( 2.0 ); hfit.SetMarkerColor( 4 ); hfit.SetMaximum(1.5*hfit.GetMaximum()); setFitHistogramAxes( hfit, label++ ); //hfit.Fit( "gaus" ); //do stable fit StabilizedGauss func(fitFuncName_.c_str(), fitFuncType_, fitFuncLowerBound_, fitFuncUpperBound_); func.fit(hfit); hfit.Draw("esame"); //--------------------------------------------- // add TPaveLabel to keep info of binning // recieved from target hitogram //--------------------------------------------- addParLabelToFitHist( hfit ); addBinLabelToFitHist(*hist, bin, cmp, zip); //--------------------------------------------- // add legend to fitted histogram //--------------------------------------------- TLegend* leg = new TLegend(0.25,0.70,0.95,0.87); setLegendStyle( *leg ); leg->AddEntry( &hfit, legend(idx).c_str(), "PL" ); leg->AddEntry( hfit.GetFunction(fitFuncName_.c_str()), fitFuncTitle_.c_str(), "L" ); leg->Draw( "same" ); canv->RedrawAxis( ); canv->Update( ); if(jdx<((*hist).GetEntriesFast()-1)) delete leg; } } psFile.Close(); } canv->Close(); delete canv; }
bool FitHist::isInFitTargetList | ( | std::string & | label | ) | [protected] |
Definition at line 59 of file FitHist.cc.
References FitTarget::Cal, benchmark_cfg::cerr, FitTarget::Mean, FitTarget::Res, FitTarget::Sigma, and filterCSVwithJSON::target.
{ //----------------------------------------------- // check if given target prefix is suported //----------------------------------------------- TString target(label); if( !(target.CompareTo(FitTarget::Cal ) || target.CompareTo(FitTarget::Res ) || target.CompareTo(FitTarget::Sigma ) || target.CompareTo(FitTarget::Mean ) )){ std::cerr << "ERROR while filling target histogram" << std::endl; std::cerr << " can't find prefix: " << target << std::endl; return false; } return true; }
double FitHist::normalize | ( | TString & | buffer, |
double | val | ||
) | [protected] |
Definition at line 145 of file FitHist.cc.
References FitTarget::Res.
{ return ( (!buffer.CompareTo(FitTarget::Res ) && val>0.) ) ? 1./val : 1.; }
void FitHist::setFitHistogramAxes | ( | TH1F & | hist, |
int | idx | ||
) | [protected] |
Definition at line 242 of file FitHist.cc.
{ //----------------------------------------------- // get proper axes label for fit histograms; get // the proper histogram idx from int the vector // axesIndex_, as the same label will be used // many times for each fit bin thi saves from // repeatedly passing the same labels. //----------------------------------------------- if(idx<(int)axesIndex_.size()){ int jdx = axesIndex_[idx]; if( jdx<(int)xAxesFit_.size() && jdx<(int)yAxesFit_.size() ){ setAxesStyle( hist, xAxesFit_[jdx].c_str(), yAxesFit_[jdx].c_str() ); } else if( jdx<(int)xAxesFit_.size() ){ setAxesStyle( hist, xAxesFit_[jdx].c_str(), "events" ); } } else{ setAxesStyle( hist, hist.GetName(), "events" ); } }
void FitHist::writeFitOutput | ( | ) |
Definition at line 562 of file FitHist.cc.
References mergeVDriftHistosByStation::file, estimatePileup::hist, estimatePileup::histFile, mergeVDriftHistosByStation::name, and dbtoconf::out.
Referenced by main().
{ //--------------------------------------------- // write filled target histogram to output file // if specified //--------------------------------------------- if( isOutputRequested() ){ //----------------------------------------------- // open hist file for book keeping of hist names //----------------------------------------------- TString name( output_ ); name.Remove(name.Last('.'), name.Length()); name+=".hist"; //replace .root by .hist ofstream histFile(name, std::ios::out); //----------------------------------------------- // open root output file and create directory // if necessary //----------------------------------------------- TFile file( output_.c_str(), "update" ); if( !file.GetDirectory(rootOutDir_.c_str()) ) // create new directory if it does not yet exist file.mkdir( rootOutDir_.c_str(), rootOutDir_.c_str() ); else // clean-up directory if it was existing already (file.GetDirectory(rootOutDir_.c_str()))->Delete("*;*"); file.cd(rootOutDir_.c_str()); // loop over requested target histogram labels if desired for(unsigned int jdx=0; jdx<targetHistList_.size(); ++jdx){ TString buffer( targetHistList_[jdx] ); //----------------------------------------------- // loop and write out histograms //----------------------------------------------- std::vector<TObjArray>::const_iterator hist = sampleList_.begin(); for( ;hist!=sampleList_.end(); ++hist){ for(int idx=0; idx<(int)histList_.size(); ++idx){ TString cmp( ((TH1F*)(*hist)[idx])->GetName() ); if( cmp.BeginsWith( buffer ) ){ //found target hist histFile << ((TH1F*)(*hist)[idx])->GetName() << "\n"; ((TH1F*)(*hist)[idx])->Write(); } } // end of histList_ loop } } // end of targetHistList_ loop file.Close(); } }
std::vector<int> FitHist::axesIndex_ [protected] |
int FitHist::evalType_ [protected] |
double FitHist::fitFuncLowerBound_ [protected] |
std::string FitHist::fitFuncName_ [protected] |
std::string FitHist::fitFuncTitle_ [protected] |
int FitHist::fitFuncType_ [protected] |
double FitHist::fitFuncUpperBound_ [protected] |
std::vector<std::string> FitHist::targetHistList_ [protected] |
std::vector<std::string> FitHist::xAxesFit_ [protected] |
std::vector<std::string> FitHist::yAxesFit_ [protected] |