#include "QFramework/TQNFTop0jetEstimator.h"
#include "QFramework/TQIterator.h"
#include "QFramework/TQCounter.h"
#include "QFramework/TQUtils.h"
#include "QFramework/TQStringUtils.h"
#include "QFramework/TQLibrary.h"
#include "QFramework/TQNFChainloader.h"

ClassImp(TQNFTop0jetEstimator)

#define NaN std::numeric_limits<double>::quiet_NaN()

////////////////////////////////////////////////////////////////////////////////////////////////
//
// TQNFTop0jetEstimator
//
// (to be written)
// note: uncertainties of counters in the jet efficiency correction region are considered
// partially correlated within one sample
//
////////////////////////////////////////////////////////////////////////////////////////////////

TQNFTop0jetEstimator::TQNFTop0jetEstimator() : TQNFBase("TOP0JET"),
  fResult(NaN)
{
  // default constructor
}

TQNFTop0jetEstimator::TQNFTop0jetEstimator(TQSampleDataReader* rd) : 
  TQNFBase("TOP0JET"),
  fResult(NaN)
{
  // constructor on reader
  this->setReader(rd);
}

TQNFTop0jetEstimator::TQNFTop0jetEstimator(TQSampleFolder* sf) : 
  TQNFBase("TOP0JET"),
  fResult(NaN)
{
  // constructor on reader
  this->setSampleFolder(sf);
}

TQNFTop0jetEstimator::~TQNFTop0jetEstimator(){
  // default destructor
  this->finalize();
}

void TQNFTop0jetEstimator::setControlRegion(const TString& region){
  // set the control region
  this->fCutCR = region;
}

void TQNFTop0jetEstimator::setJetEffNumerator(const TString& region){
  // set the numerator region for calculation of the jet efficiency correction
  // (e.g. name (not expression!) of the cut to select "no additional jets")
  this->fCutJetEffNumerator = region;
}

void TQNFTop0jetEstimator::setJetEffDenominator(const TString& region){
  // set the denominator region for calculation of the jet efficiency correction
  // (e.g. name (not expression!) of the cut to select "at least one b-jet")
  this->fCutJetEffDenominator = region;
}

TString TQNFTop0jetEstimator::getControlRegion(){
  // get the control region
  return this->fCutCR;
}

TString TQNFTop0jetEstimator::getJetEffNumerator(){
  // get the numerator region for calculation of the jet efficiency correction
  return this->fCutJetEffNumerator;
}

TString TQNFTop0jetEstimator::getJetEffDenominator(){
  // get the denominator region for calculation of the jet efficiency correction
  return this->fCutJetEffDenominator;
}

TString TQNFTop0jetEstimator::getPathMC(){
  // return the (MC)-Path from which the information is retrieved
  return this->fPath;
}

TString TQNFTop0jetEstimator::getPathData(){
  // return the (MC)-Path from which the information is retrieved
  return this->fPathData;
}

void TQNFTop0jetEstimator::setPathMC(const TString& path){
  // set/change the MC path from which the information is retrieved
  this->fPath = path;
}

void TQNFTop0jetEstimator::setPathData(const TString& path){
  // set/change the data path from which the information is retrieved
  this->fPathData = path;
}


bool TQNFTop0jetEstimator::readConfiguration(TQFolder*f){
  // read a configuration from a TQFolder
  // the following tags are read and interpreted:
  // - verbosity: integer, increasing number increases verbosity
  // - cutCR: string, name of cut for the control region
  // - cutJetEffNumerator: string, name of cut for the jet efficiency correction region (nominator, e.g. selecting "no additional jets")
  // - cutJetEffDenominator: string, name of cut for the jet efficiency correction region (denominator, e.g. selecting "at least 1 b-jet")
  // - path: the path to be used for the MC sample to be estimated
  // all tags are copied to the calculator
  if(!f){
    if(verbosity > 0) messages.sendMessage(TQMessageStream::ERROR,"unable to configure from NULL folder");
    return false;
  }
  this->importTags(f);
  //@tag:[verbosity] This object tag sets the objects verbosity. Imported from argument in TQNFTop1jetEstimator::readConfiguration unless already present.
  this->getTagInteger("verbosity",this->verbosity);
  TString cutname;
  int n = 0;
  //@tag:[pathMC] This argument tag sets the path to retrieve MC counters from. This tag is obligatory!
  if(!f->getTagString("pathMC",this->fPath)){
    if(verbosity > 0) messages.sendMessage(TQMessageStream::ERROR,"unable to retrieve MC path");
    return false;
  }
  //@tag:[pathData] This argument tag sets the path to retrieve data counters from. This tag is obligatory!
  if (!f->getTagString("pathData",this->fPathData)) {
    if(verbosity > 0) messages.sendMessage(TQMessageStream::ERROR,"unable to retrieve data path");
    return false;
  }
  //@tag:[cutCR,cutJetEffNumberator,cutJetEffDenominator] These argument tags set the cut names for the different control regions used in the calculation. These tags are obligatory!
  if(f->getTagString("cutCR",cutname)){
    this->setControlRegion(cutname);
    n++;
  } else {
    if(verbosity > 0) messages.sendMessage(TQMessageStream::ERROR,"unable to retrieve cut name for cutCR");
  }
  if(f->getTagString("cutJetEffNumerator",cutname)){
    this->setJetEffNumerator(cutname);
    n++;
  } else {
    if(verbosity > 0) messages.sendMessage(TQMessageStream::ERROR,"unable to retrieve cut name for cutJetEffNumerator");
  }
  if(f->getTagString("cutJetEffDenominator",cutname)){
    this->setJetEffDenominator(cutname);
    n++;
  } else {
    if(verbosity > 0) messages.sendMessage(TQMessageStream::ERROR,"unable to retrieve cut name for cutJetEffDenominator");
  }
  if(n!=3){
    std::cout << "Only found "<<n<<" out of 3 required regions!"<< std::endl;
    messages.activeStream().flush();
    return false;
  }
  
  //read list of background paths to be subtracted from data before the actual calculation is done
  vBkgPaths.clear();
  TQFolderIterator sitr(f->getListOfFolders("samples/?"),true);
  while(sitr.hasNext()){
    TQFolder* sample = sitr.readNext();
    if(!sample) continue;
    //@tag:[name,path] These sub-folder argument tags determine the name and path of background samples which are to be subtracted from data. "name" defaults to the sample name and serves itself as a fallback for the "path" tag.
    TString name = sample->getTagStringDefault("name",sample->getName());
    TString path = sample->getTagStringDefault("path",name);
    vBkgPaths.push_back(path);
  }
  
  return true;
}

double TQNFTop0jetEstimator::getResult(int mode){
  // retrieve the Result
  switch(mode) {
    case 0:
      return this->fResult;
    case 1:
      return this->fResultXSec;
    case 2:
      return this->fResultExtrapolation;
    case 3:
      return this->fResultAlphaMC;
    case 4:
      return this->fResultAlphaData;
  }
  ERRORclass("Invalid mode '%d', returning NaN.",mode);
  return NaN;
}

void TQNFTop0jetEstimator::printResult(int mode){
  // print the result to the console
  if(TQUtils::isNum(this->getResult(mode))){
    std::cout << this->getResult(mode) << std::endl;
    return;
  }
  std::cout << "<invalid result>" << std::endl;
}

bool TQNFTop0jetEstimator::finalizeSelf(){
  if(this->cnt_mc_cr){ delete cnt_mc_cr; this->cnt_mc_cr = NULL; }
  if(this->cnt_data_cr){ delete cnt_data_cr; this->cnt_data_cr = NULL; }
  if(this->cnt_mc_numerator){ delete cnt_mc_numerator; this->cnt_mc_numerator = NULL; }
  if(this->cnt_data_numerator){ delete cnt_data_numerator; this->cnt_data_numerator = NULL; }
  if(this->cnt_mc_denominator){ delete cnt_mc_denominator; this->cnt_mc_denominator = NULL; }
  if(this->cnt_data_denominator){ delete cnt_data_denominator; this->cnt_data_denominator = NULL; }
  for (size_t i=0; i< this->vBkgCountersCR.size(); ++i) {
    if (this->vBkgCountersCR.at(i)) { delete this->vBkgCountersCR.at(i); this->vBkgCountersCR.at(i) = NULL; }
  }
  this->vBkgCountersCR.clear();
  for (size_t i=0; i< this->vBkgCountersNumerator.size(); ++i) {
    if (this->vBkgCountersNumerator.at(i)) { delete this->vBkgCountersNumerator.at(i); this->vBkgCountersNumerator.at(i) = NULL; }
  }
  this->vBkgCountersNumerator.clear();
  for (size_t i=0; i< this->vBkgCountersDenominator.size(); ++i) {
    if (this->vBkgCountersDenominator.at(i)) { delete this->vBkgCountersDenominator.at(i); this->vBkgCountersDenominator.at(i) = NULL; }
  }
  this->vBkgCountersDenominator.clear();
  return true;
}

bool TQNFTop0jetEstimator::initializeSelf(){
  // actually perform the calculation and save the results
  // return true if everything went file, false if an error occured
  if(!this->fReader || !this->fReader->getSampleFolder()){
    messages.sendMessage(TQMessageStream::ERROR,"cannot perform calculation without valid sample folder!");
    return false;
  }
  if(fPath.IsNull()){
    messages.sendMessage(TQMessageStream::ERROR,"cannot perform calculation without valid path!");
    return false;
  }
  TQTaggable tmp;
  //@tag:[readScaleScheme] This object tag determines which scale scheme is used when retrieving values entering the NF calculation (e.g. to include results from previous NF calculation steps). Default: ".top0jet.read"
  tmp.setTagString("scaleScheme",this->getTagStringDefault("readScaleScheme",".top0jet.read"));
  this->cnt_mc_cr = this->fReader->getCounter(fPath,fCutCR ,&tmp);
  this->cnt_mc_numerator = this->fReader->getCounter(fPath,fCutJetEffNumerator ,&tmp);
  this->cnt_mc_denominator = this->fReader->getCounter(fPath,fCutJetEffDenominator ,&tmp);
  this->cnt_data_cr = this->fReader->getCounter(fPathData,fCutCR ,&tmp);
  this->cnt_data_numerator = this->fReader->getCounter(fPathData,fCutJetEffNumerator ,&tmp);
  this->cnt_data_denominator = this->fReader->getCounter(fPathData,fCutJetEffDenominator ,&tmp);
  if(!(cnt_mc_cr && cnt_mc_numerator && cnt_mc_denominator && cnt_data_cr && cnt_data_numerator && cnt_data_denominator)){
    if(cnt_mc_cr) {delete cnt_mc_cr; cnt_mc_cr=NULL;}
    else if(verbosity > 0) messages.sendMessage(TQMessageStream::ERROR,"unable to obtain counter '%s' for control region from path '%s'",fCutCR.Data(),fPath.Data());
    if(cnt_mc_numerator) {delete cnt_mc_numerator; cnt_mc_numerator=NULL;}
    else if(verbosity > 0) messages.sendMessage(TQMessageStream::ERROR,"unable to obtain counter '%s' for jet efficiency numerator region from path '%s'",fCutJetEffNumerator.Data(),fPath.Data());
    if(cnt_mc_denominator) {delete cnt_mc_denominator; cnt_mc_denominator=NULL;}
    else if(verbosity > 0) messages.sendMessage(TQMessageStream::ERROR,"unable to obtain counter '%s' for jet efficiency denominator region from path '%s'",fCutJetEffDenominator.Data(),fPath.Data());
    if(cnt_data_cr) {delete cnt_data_cr; cnt_data_cr=NULL;}
    else if(verbosity > 0) messages.sendMessage(TQMessageStream::ERROR,"unable to obtain counter '%s' for control region from path '%s'",fCutCR.Data(),fPathData.Data());
    if(cnt_data_numerator) {delete cnt_data_numerator; cnt_data_numerator=NULL;}
    else if(verbosity > 0) messages.sendMessage(TQMessageStream::ERROR,"unable to obtain counter '%s' for jet efficiency numerator region from path '%s'",fCutJetEffNumerator.Data(),fPathData.Data());
    if(cnt_data_denominator) {delete cnt_data_denominator; cnt_data_denominator=NULL;}
    else if(verbosity > 0) messages.sendMessage(TQMessageStream::ERROR,"unable to obtain counter '%s' for jet efficiency denominator region from path '%s'",fCutJetEffDenominator.Data(),fPathData.Data());
    return false;
  }
  vBkgCountersCR.clear();
  vBkgCountersNumerator.clear();
  vBkgCountersDenominator.clear();
  for (uint i=0; i<vBkgPaths.size(); ++i) {
    vBkgCountersCR.push_back(this->fReader->getCounter(vBkgPaths.at(i),fCutCR ,&tmp));
    vBkgCountersNumerator.push_back(this->fReader->getCounter(vBkgPaths.at(i),fCutJetEffNumerator ,&tmp));
    vBkgCountersDenominator.push_back(this->fReader->getCounter(vBkgPaths.at(i),fCutJetEffDenominator ,&tmp));
  }
  
  
  return true;
}

bool TQNFTop0jetEstimator::calculate(){
  if (!this->chainLoader) iterationNumber = -1;
  //double zratio = 0;
  
  //OLD:
  /*
  double mc_cr = this->cnt_mc_cr->getCounter() * (iterationNumber < 0 ? 1. : this->chainLoader->getRelVariation((this->fPath+":"+this->fCutCR),this->cnt_mc_cr->getCounter() ,this->cnt_mc_cr->getError() ) );
  zratio = (iterationNumber < 0 || this->cnt_mc_denominator->getError() == 0) ? 0. : (this->chainLoader->getRelVariation((this->fPath+":"+this->fCutJetEffDenominator),this->cnt_mc_denominator->getCounter() ,this->cnt_mc_denominator->getError() ) -1) * this->cnt_mc_denominator->getCounter() / this->cnt_mc_denominator->getError() ;
  double mc_numerator = this->cnt_mc_numerator->getCounter() + zratio * this->cnt_mc_numerator->getError() ;
  double mc_denominator = this->cnt_mc_denominator->getCounter() + zratio * this->cnt_mc_denominator->getError();
  */
  
  //more correct correlation treatment: in order to get relative variations we don't pass the full count to the chain loader, but reduce the more inclusive regions by the counts in the less inclusive ones. Effectively this creates event counts from orthogonal (i.e. statistically independent) regions, which we later recombine.
  double val_num = this->cnt_mc_numerator->getCounter();
  double err2_num = this->cnt_mc_numerator->getErrorSquared(); //here, we don't have to change anything
  double val_den = this->cnt_mc_denominator->getCounter() - val_num; //remove the sub region
  double err2_den = this->cnt_mc_denominator->getErrorSquared() - err2_num; //adjust uncertainty for removal
  double val_cr = this->cnt_mc_cr->getCounter() - val_num - val_den; //as before
  double err2_cr = this->cnt_mc_cr->getErrorSquared() - err2_num - err2_den;
  //only apply variations if running toys (and chainloader present)
  val_num *= iterationNumber<0 ? 1. : this->chainLoader->getRelVariation((this->fPath+":"+this->fCutJetEffNumerator), val_num, sqrt(err2_num) );
  val_den *= iterationNumber<0 ? 1. : this->chainLoader->getRelVariation((this->fPath+":"+this->fCutJetEffDenominator), val_den, sqrt(err2_den) );
  val_cr *= iterationNumber<0 ? 1. : this->chainLoader->getRelVariation((this->fPath+":"+this->fCutCR), val_cr, sqrt(err2_cr) );
  
  //store in "final" variables for the actual calculation later
  double mc_numerator = val_num;
  double mc_denominator = val_num + val_den;
  double mc_cr = val_num + val_den + val_cr;
  
  //OLD:
  /*
  double data_cr = this->cnt_data_cr->getCounter() * ( iterationNumber < 0 ? 1. : this->chainLoader->getRelVariation((this->fPathData+":"+this->fCutCR),this->cnt_data_cr->getCounter() ,this->cnt_data_cr->getError() ) );
  zratio = (iterationNumber < 0 || this->cnt_data_denominator->getError() == 0) ? 0. : (this->chainLoader->getRelVariation((this->fPathData+":"+this->fCutJetEffDenominator),this->cnt_data_denominator->getCounter() ,this->cnt_data_denominator->getError() )-1) * this->cnt_data_denominator->getCounter() / this->cnt_data_denominator->getError() ;
  double data_numerator = this->cnt_data_numerator->getCounter() + zratio * this->cnt_data_numerator->getError() ;
  double data_denominator = this->cnt_data_denominator->getCounter() + zratio * this->cnt_data_denominator->getError();
  */
  
  //same trick for data
  val_num = this->cnt_data_numerator->getCounter();
  err2_num = this->cnt_data_numerator->getErrorSquared(); //here, we don't have to change anything
  val_den = this->cnt_data_denominator->getCounter() - val_num; //remove the sub region
  err2_den = this->cnt_data_denominator->getErrorSquared() - err2_num; //adjust uncertainty for removal
  val_cr = this->cnt_data_cr->getCounter() - val_num - val_den; //as before
  err2_cr = this->cnt_data_cr->getErrorSquared() - err2_num - err2_den;
  //only apply variations if running toys (and chainloader present)
  val_num *= iterationNumber<0 ? 1. : this->chainLoader->getRelVariation((this->fPathData+":"+this->fCutJetEffNumerator), val_num, sqrt(err2_num) );
  val_den *= iterationNumber<0 ? 1. : this->chainLoader->getRelVariation((this->fPathData+":"+this->fCutJetEffDenominator), val_den, sqrt(err2_den) );
  val_cr *= iterationNumber<0 ? 1. : this->chainLoader->getRelVariation((this->fPathData+":"+this->fCutCR), val_cr, sqrt(err2_cr) );
  
  //store in "final" variables for the actual calculation later
  double data_numerator = val_num;
  double data_denominator = val_num + val_den;
  double data_cr = val_num + val_den + val_cr;


  //subtract other backgrounds
  for (uint i=0; i<vBkgPaths.size(); ++i) {
    //OLD:
    /*
    data_cr -= vBkgCountersCR.at(i) ? vBkgCountersCR.at(i)->getCounter() * (iterationNumber < 0 ? 1. : this->chainLoader->getRelVariation((vBkgPaths.at(i)+":"+fCutCR),vBkgCountersCR.at(i)->getCounter() ,vBkgCountersCR.at(i)->getError() ) ) : 0.;
    if (!vBkgCountersNumerator.at(i) || !vBkgCountersDenominator.at(i) ) continue;
    zratio = iterationNumber < 0 || this->vBkgCountersDenominator.at(i)->getError() == 0 ? 0. : (this->chainLoader->getRelVariation((this->vBkgPaths.at(i)+":"+this->fCutJetEffDenominator),this->vBkgCountersDenominator.at(i)->getCounter() ,this->vBkgCountersDenominator.at(i)->getError() ) -1) * this->vBkgCountersDenominator.at(i)->getCounter() / this->vBkgCountersDenominator.at(i)->getError() ;
    data_numerator -= vBkgCountersNumerator.at(i) ? vBkgCountersNumerator.at(i)->getCounter() + zratio * vBkgCountersNumerator.at(i)->getError() : 0.;
    data_denominator -= vBkgCountersDenominator.at(i) ? vBkgCountersDenominator.at(i)->getCounter() + zratio * vBkgCountersDenominator.at(i)->getError()  : 0.;
    */
    
    if (! (this->vBkgCountersNumerator.at(i) && this->vBkgCountersDenominator.at(i) && this->vBkgCountersCR.at(i)) ) {
      ERRORclass("Missing counter for subtraction of process '%s' from data in at least one of the control regions",this->vBkgPaths.at(i).Data());
      throw std::runtime_error("Failed to calculate top0jet NF! Check your configuration files and input sample folder!");
    }
    //same trick for subtracted backgrounds (some counters might not be available, e.g. if no event survived the selection for these regions)
    val_num = this->vBkgCountersNumerator.at(i)->getCounter();
    err2_num = this->vBkgCountersNumerator.at(i)->getErrorSquared(); //here, we don't have to change anything
    val_den = this->vBkgCountersDenominator.at(i)->getCounter() - val_num; //remove the sub region
    err2_den = this->vBkgCountersDenominator.at(i)->getErrorSquared() - err2_num; //adjust uncertainty for removal
    val_cr = this->vBkgCountersCR.at(i)->getCounter() - val_num - val_den; //as before
    err2_cr = this->vBkgCountersCR.at(i)->getErrorSquared() - err2_num - err2_den;
    //only apply variations if running toys (and chainloader present)
    val_num *= iterationNumber<0 ? 1. : this->chainLoader->getRelVariation((this->vBkgPaths.at(i)+":"+this->fCutJetEffNumerator), val_num, sqrt(err2_num) );
    val_den *= iterationNumber<0 ? 1. : this->chainLoader->getRelVariation((this->vBkgPaths.at(i)+":"+this->fCutJetEffDenominator), val_den, sqrt(err2_den) );
    val_cr *= iterationNumber<0 ? 1. : this->chainLoader->getRelVariation((this->vBkgPaths.at(i)+":"+this->fCutCR), val_cr, sqrt(err2_cr) );
    
    //store in "final" variables for the actual calculation later. here, we need to subtract all regions from the original data count:
    data_numerator -= val_num;
    data_denominator -= (val_num + val_den);
    data_cr -= (val_num + val_den + val_cr);
    
  }
  
  this->fResult = data_cr/mc_cr * pow( data_numerator*mc_denominator/(data_denominator*mc_numerator) ,2);
  this->fResultXSec = data_cr/mc_cr;
  this->fResultExtrapolation = pow( data_numerator*mc_denominator/(data_denominator*mc_numerator) ,2);
  this->fResultAlphaMC = mc_numerator / mc_denominator;
  this->fResultAlphaData = data_numerator / data_denominator;
  messages.sendMessage(TQMessageStream::VERBOSE,"calculated Top0jetEstimator NF: %g ",this->fResult);
  return true;
}

int TQNFTop0jetEstimator::deployResult(const std::vector<TString>& startAtCutNames, const std::vector<TString>& stopAtCutNames, int doOverwrite, bool applyToStopCut){
  // public interface to deploy calculated NFs.
  int retval = 0;
  //set the "regular" (full=XSecCorr*extrapolation) NF (mode=0):
  retval += this->deployResultInternal(startAtCutNames, stopAtCutNames, doOverwrite, applyToStopCut, 0);
  if (this->hasTag("applyToCut.XSec") || this->hasTag("applyToCut.XSec.0")) {
    //if there's an additional tag present to deploy the XSec correction seperatelly, we do so (mode = 1):
    retval += this->deployResultInternal(this->getTagVString("applyToCut.XSec"), this->getTagVString("stopAtCut.XSec"), this->getTagBoolDefault("overwrite.XSec",doOverwrite), this->getTagBoolDefault("applyToStopCut.XSec",applyToStopCut), 1);
  }
  if (this->hasTag("applyToCut.aux") || this->hasTag("applyToCut.aux.0")) {
    //if there's an additional tag present to deploy extrapolation factor seperatelly, we do so (mode = 2,3,4):
    retval += this->deployResultInternal(this->getTagVString("applyToCut.aux"), this->getTagVString("stopAtCut.aux"), this->getTagBoolDefault("overwrite.aux",doOverwrite), this->getTagBoolDefault("applyToStopCut.aux",applyToStopCut), 2);
    retval += this->deployResultInternal(this->getTagVString("applyToCut.aux"), this->getTagVString("stopAtCut.aux"), this->getTagBoolDefault("overwrite.aux",doOverwrite), this->getTagBoolDefault("applyToStopCut.aux",applyToStopCut), 3);
    retval += this->deployResultInternal(this->getTagVString("applyToCut.aux"), this->getTagVString("stopAtCut.aux"), this->getTagBoolDefault("overwrite.aux",doOverwrite), this->getTagBoolDefault("applyToStopCut.aux",applyToStopCut), 4);
  }
  return retval;
}


int TQNFTop0jetEstimator::deployResultInternal(const std::vector<TString>& startAtCutNames, const std::vector<TString>& stopAtCutNames, int doOverwrite, bool applyToStopCut, int mode){
  // set the NF according to the desired scale scheme
  // the NF will be deployed at the given path
  // modes: 0 = deploy full result, 1 = deploy XSec correction only (data/MC in CR), 2 = deploy extrapolation factor (JVSP)
  if(!TQUtils::isNum(this->fResult)) return false;
  bool overwrite = (doOverwrite == 1);
  // set the NF according to the desired scale scheme(s)
  //@tag:[writeScaleScheme] This object tag determines the list of scale schemes the results of the NF calculation are written to. Default: ".default"
  TString postfix =  this->getPostfix(mode);
  
  std::vector<TString> writeScaleSchemes = this->getTagVString(TString::Format("writeScaleScheme%s",postfix.Data() ) );
  //we might run on mode != 0, so we use the default (mode == 0) tag version as a fall back:
  if(writeScaleSchemes.size() < 1){
    if (mode <= 1) {
      writeScaleSchemes = this->getTagVString("writeScaleScheme");  
    } else { //if we're not deploying the standard result or the pure CR NF, we should not use the default schemes but tell the user to specify a dedicated scale scheme for the auxilary results.
      WARNclass("No output scale scheme defined for auxilary results, please fix your config (needs writeScaleScheme.aux, writeScaleScheme.aux.MC, writeScaleScheme.aux.Data)! Skipping this variant...");
      return 0;
    }
  }
  if(writeScaleSchemes.size() < 1){
    writeScaleSchemes.push_back(this->getTagStringDefault("writeScaleScheme",".default"));
  }
  
  int retval = 0;
  //@tag:[targetPath] This object tag determines the TQFolder path(s) the result of the NF calculation is written to. Multiple folders can be specified using the TQFolder path arithmetics ("path1+path2")
  TString path = this->getTagStringDefault("targetPath",this->fPath);
  std::vector<TString> targets = this->getTargetCuts(startAtCutNames,stopAtCutNames,applyToStopCut);
  for (size_t c=0; c<targets.size(); ++c) {
    TString cutName = targets.at(c);
    TQSampleFolderIterator itr(this->fReader->getListOfSampleFolders(path),true);
    while(itr.hasNext()){
      TQSampleFolder* sf = itr.readNext();
      if(!sf) continue;
      for(size_t k=0; k<writeScaleSchemes.size(); k++){
        int n = sf->setScaleFactor(writeScaleSchemes[k]+":"+cutName+(overwrite?"":"<<"), this->getResult(mode), 0.);
        //INFOclass("Set top0jet NF at '%s' to value '%.2f' (mode = %d)",TString(writeScaleSchemes[k]+":"+cutName+(overwrite?"":"<<")).Data(), this->getResult(mode), mode );
        this->addNFPath(sf->getPath(),cutName,writeScaleSchemes[k]);
        if(n == 0){
          ERRORclass("unable to set scale factor for cut '%s' on path '%s' with scheme '%s'",cutName.Data(),sf->getPath().Data(),writeScaleSchemes[k].Data());
        }
        retval += n;
      }
    }
    // if the info folder is set and valid, we should keep track of all the processes that have NFs applied
    if(this->infoFolder){
      // get the folder which contains the list of processes for which we have NFs
      //@tag:[nfListPattern] This object tag determines the format how the existence of NFs for the target paths/cuts is written to the info folder (if present). Default: ".cut.%s+"
      TQFolder * sfProcessList = this->infoFolder->getFolder(TString::Format(this->getTagStringDefault("nfListPattern",".cut.%s+").Data(),cutName.Data()));
      // get the sample folder which contains the samples for this process
      TList* sflist = this->fReader->getListOfSampleFolders(path);
      TQSampleFolder * processSampleFolder = ( sflist && sflist->GetEntries() > 0 ) ? (TQSampleFolder*)(sflist->First()) : NULL;
      if(sflist) delete sflist;
      // retrieve the correct title of the process from this folder
      // if there is no process title set, we will use the process name instead
      TString processTitle = path;
      if (processSampleFolder)
        //@tag:[processTitleKey] This object tag determines the name of the process tag used to retrieve the process title from. Default: "style.default.title".
        processSampleFolder->getTagString(this->getTagStringDefault("processTitleKey","style.default.title"), processTitle);
      // after we have aquired all necessary information, we add a new entry 
      // to the list of processes to which NFs have been applied
      sfProcessList->setTagString(TQFolder::makeValidIdentifier(processTitle),processTitle);
    }
  }
  
  return retval;
}

int TQNFTop0jetEstimator::execute(int itrNumber) {
  this->iterationNumber = itrNumber;
  fSuccess = this->calculate();
  if (fSuccess) return 0;
  return -1;
}

bool TQNFTop0jetEstimator::success () {
  return fSuccess;
}

TString TQNFTop0jetEstimator::getPostfix(int mode) {

  switch (mode) {
    case 0:
      return TString(""); 
    case 1:
      return TString(".XSec"); 
    case 2:
      return TString(".aux"); 
    case 3:
      return TString(".aux.MC"); 
    case 4:
      return TString(".aux.Data"); 
  }
  WARN("Requested postfix for unsuported mode %d",mode);
  return TString("");
}  

 TQNFTop0jetEstimator.cxx:1
 TQNFTop0jetEstimator.cxx:2
 TQNFTop0jetEstimator.cxx:3
 TQNFTop0jetEstimator.cxx:4
 TQNFTop0jetEstimator.cxx:5
 TQNFTop0jetEstimator.cxx:6
 TQNFTop0jetEstimator.cxx:7
 TQNFTop0jetEstimator.cxx:8
 TQNFTop0jetEstimator.cxx:9
 TQNFTop0jetEstimator.cxx:10
 TQNFTop0jetEstimator.cxx:11
 TQNFTop0jetEstimator.cxx:12
 TQNFTop0jetEstimator.cxx:13
 TQNFTop0jetEstimator.cxx:14
 TQNFTop0jetEstimator.cxx:15
 TQNFTop0jetEstimator.cxx:16
 TQNFTop0jetEstimator.cxx:17
 TQNFTop0jetEstimator.cxx:18
 TQNFTop0jetEstimator.cxx:19
 TQNFTop0jetEstimator.cxx:20
 TQNFTop0jetEstimator.cxx:21
 TQNFTop0jetEstimator.cxx:22
 TQNFTop0jetEstimator.cxx:23
 TQNFTop0jetEstimator.cxx:24
 TQNFTop0jetEstimator.cxx:25
 TQNFTop0jetEstimator.cxx:26
 TQNFTop0jetEstimator.cxx:27
 TQNFTop0jetEstimator.cxx:28
 TQNFTop0jetEstimator.cxx:29
 TQNFTop0jetEstimator.cxx:30
 TQNFTop0jetEstimator.cxx:31
 TQNFTop0jetEstimator.cxx:32
 TQNFTop0jetEstimator.cxx:33
 TQNFTop0jetEstimator.cxx:34
 TQNFTop0jetEstimator.cxx:35
 TQNFTop0jetEstimator.cxx:36
 TQNFTop0jetEstimator.cxx:37
 TQNFTop0jetEstimator.cxx:38
 TQNFTop0jetEstimator.cxx:39
 TQNFTop0jetEstimator.cxx:40
 TQNFTop0jetEstimator.cxx:41
 TQNFTop0jetEstimator.cxx:42
 TQNFTop0jetEstimator.cxx:43
 TQNFTop0jetEstimator.cxx:44
 TQNFTop0jetEstimator.cxx:45
 TQNFTop0jetEstimator.cxx:46
 TQNFTop0jetEstimator.cxx:47
 TQNFTop0jetEstimator.cxx:48
 TQNFTop0jetEstimator.cxx:49
 TQNFTop0jetEstimator.cxx:50
 TQNFTop0jetEstimator.cxx:51
 TQNFTop0jetEstimator.cxx:52
 TQNFTop0jetEstimator.cxx:53
 TQNFTop0jetEstimator.cxx:54
 TQNFTop0jetEstimator.cxx:55
 TQNFTop0jetEstimator.cxx:56
 TQNFTop0jetEstimator.cxx:57
 TQNFTop0jetEstimator.cxx:58
 TQNFTop0jetEstimator.cxx:59
 TQNFTop0jetEstimator.cxx:60
 TQNFTop0jetEstimator.cxx:61
 TQNFTop0jetEstimator.cxx:62
 TQNFTop0jetEstimator.cxx:63
 TQNFTop0jetEstimator.cxx:64
 TQNFTop0jetEstimator.cxx:65
 TQNFTop0jetEstimator.cxx:66
 TQNFTop0jetEstimator.cxx:67
 TQNFTop0jetEstimator.cxx:68
 TQNFTop0jetEstimator.cxx:69
 TQNFTop0jetEstimator.cxx:70
 TQNFTop0jetEstimator.cxx:71
 TQNFTop0jetEstimator.cxx:72
 TQNFTop0jetEstimator.cxx:73
 TQNFTop0jetEstimator.cxx:74
 TQNFTop0jetEstimator.cxx:75
 TQNFTop0jetEstimator.cxx:76
 TQNFTop0jetEstimator.cxx:77
 TQNFTop0jetEstimator.cxx:78
 TQNFTop0jetEstimator.cxx:79
 TQNFTop0jetEstimator.cxx:80
 TQNFTop0jetEstimator.cxx:81
 TQNFTop0jetEstimator.cxx:82
 TQNFTop0jetEstimator.cxx:83
 TQNFTop0jetEstimator.cxx:84
 TQNFTop0jetEstimator.cxx:85
 TQNFTop0jetEstimator.cxx:86
 TQNFTop0jetEstimator.cxx:87
 TQNFTop0jetEstimator.cxx:88
 TQNFTop0jetEstimator.cxx:89
 TQNFTop0jetEstimator.cxx:90
 TQNFTop0jetEstimator.cxx:91
 TQNFTop0jetEstimator.cxx:92
 TQNFTop0jetEstimator.cxx:93
 TQNFTop0jetEstimator.cxx:94
 TQNFTop0jetEstimator.cxx:95
 TQNFTop0jetEstimator.cxx:96
 TQNFTop0jetEstimator.cxx:97
 TQNFTop0jetEstimator.cxx:98
 TQNFTop0jetEstimator.cxx:99
 TQNFTop0jetEstimator.cxx:100
 TQNFTop0jetEstimator.cxx:101
 TQNFTop0jetEstimator.cxx:102
 TQNFTop0jetEstimator.cxx:103
 TQNFTop0jetEstimator.cxx:104
 TQNFTop0jetEstimator.cxx:105
 TQNFTop0jetEstimator.cxx:106
 TQNFTop0jetEstimator.cxx:107
 TQNFTop0jetEstimator.cxx:108
 TQNFTop0jetEstimator.cxx:109
 TQNFTop0jetEstimator.cxx:110
 TQNFTop0jetEstimator.cxx:111
 TQNFTop0jetEstimator.cxx:112
 TQNFTop0jetEstimator.cxx:113
 TQNFTop0jetEstimator.cxx:114
 TQNFTop0jetEstimator.cxx:115
 TQNFTop0jetEstimator.cxx:116
 TQNFTop0jetEstimator.cxx:117
 TQNFTop0jetEstimator.cxx:118
 TQNFTop0jetEstimator.cxx:119
 TQNFTop0jetEstimator.cxx:120
 TQNFTop0jetEstimator.cxx:121
 TQNFTop0jetEstimator.cxx:122
 TQNFTop0jetEstimator.cxx:123
 TQNFTop0jetEstimator.cxx:124
 TQNFTop0jetEstimator.cxx:125
 TQNFTop0jetEstimator.cxx:126
 TQNFTop0jetEstimator.cxx:127
 TQNFTop0jetEstimator.cxx:128
 TQNFTop0jetEstimator.cxx:129
 TQNFTop0jetEstimator.cxx:130
 TQNFTop0jetEstimator.cxx:131
 TQNFTop0jetEstimator.cxx:132
 TQNFTop0jetEstimator.cxx:133
 TQNFTop0jetEstimator.cxx:134
 TQNFTop0jetEstimator.cxx:135
 TQNFTop0jetEstimator.cxx:136
 TQNFTop0jetEstimator.cxx:137
 TQNFTop0jetEstimator.cxx:138
 TQNFTop0jetEstimator.cxx:139
 TQNFTop0jetEstimator.cxx:140
 TQNFTop0jetEstimator.cxx:141
 TQNFTop0jetEstimator.cxx:142
 TQNFTop0jetEstimator.cxx:143
 TQNFTop0jetEstimator.cxx:144
 TQNFTop0jetEstimator.cxx:145
 TQNFTop0jetEstimator.cxx:146
 TQNFTop0jetEstimator.cxx:147
 TQNFTop0jetEstimator.cxx:148
 TQNFTop0jetEstimator.cxx:149
 TQNFTop0jetEstimator.cxx:150
 TQNFTop0jetEstimator.cxx:151
 TQNFTop0jetEstimator.cxx:152
 TQNFTop0jetEstimator.cxx:153
 TQNFTop0jetEstimator.cxx:154
 TQNFTop0jetEstimator.cxx:155
 TQNFTop0jetEstimator.cxx:156
 TQNFTop0jetEstimator.cxx:157
 TQNFTop0jetEstimator.cxx:158
 TQNFTop0jetEstimator.cxx:159
 TQNFTop0jetEstimator.cxx:160
 TQNFTop0jetEstimator.cxx:161
 TQNFTop0jetEstimator.cxx:162
 TQNFTop0jetEstimator.cxx:163
 TQNFTop0jetEstimator.cxx:164
 TQNFTop0jetEstimator.cxx:165
 TQNFTop0jetEstimator.cxx:166
 TQNFTop0jetEstimator.cxx:167
 TQNFTop0jetEstimator.cxx:168
 TQNFTop0jetEstimator.cxx:169
 TQNFTop0jetEstimator.cxx:170
 TQNFTop0jetEstimator.cxx:171
 TQNFTop0jetEstimator.cxx:172
 TQNFTop0jetEstimator.cxx:173
 TQNFTop0jetEstimator.cxx:174
 TQNFTop0jetEstimator.cxx:175
 TQNFTop0jetEstimator.cxx:176
 TQNFTop0jetEstimator.cxx:177
 TQNFTop0jetEstimator.cxx:178
 TQNFTop0jetEstimator.cxx:179
 TQNFTop0jetEstimator.cxx:180
 TQNFTop0jetEstimator.cxx:181
 TQNFTop0jetEstimator.cxx:182
 TQNFTop0jetEstimator.cxx:183
 TQNFTop0jetEstimator.cxx:184
 TQNFTop0jetEstimator.cxx:185
 TQNFTop0jetEstimator.cxx:186
 TQNFTop0jetEstimator.cxx:187
 TQNFTop0jetEstimator.cxx:188
 TQNFTop0jetEstimator.cxx:189
 TQNFTop0jetEstimator.cxx:190
 TQNFTop0jetEstimator.cxx:191
 TQNFTop0jetEstimator.cxx:192
 TQNFTop0jetEstimator.cxx:193
 TQNFTop0jetEstimator.cxx:194
 TQNFTop0jetEstimator.cxx:195
 TQNFTop0jetEstimator.cxx:196
 TQNFTop0jetEstimator.cxx:197
 TQNFTop0jetEstimator.cxx:198
 TQNFTop0jetEstimator.cxx:199
 TQNFTop0jetEstimator.cxx:200
 TQNFTop0jetEstimator.cxx:201
 TQNFTop0jetEstimator.cxx:202
 TQNFTop0jetEstimator.cxx:203
 TQNFTop0jetEstimator.cxx:204
 TQNFTop0jetEstimator.cxx:205
 TQNFTop0jetEstimator.cxx:206
 TQNFTop0jetEstimator.cxx:207
 TQNFTop0jetEstimator.cxx:208
 TQNFTop0jetEstimator.cxx:209
 TQNFTop0jetEstimator.cxx:210
 TQNFTop0jetEstimator.cxx:211
 TQNFTop0jetEstimator.cxx:212
 TQNFTop0jetEstimator.cxx:213
 TQNFTop0jetEstimator.cxx:214
 TQNFTop0jetEstimator.cxx:215
 TQNFTop0jetEstimator.cxx:216
 TQNFTop0jetEstimator.cxx:217
 TQNFTop0jetEstimator.cxx:218
 TQNFTop0jetEstimator.cxx:219
 TQNFTop0jetEstimator.cxx:220
 TQNFTop0jetEstimator.cxx:221
 TQNFTop0jetEstimator.cxx:222
 TQNFTop0jetEstimator.cxx:223
 TQNFTop0jetEstimator.cxx:224
 TQNFTop0jetEstimator.cxx:225
 TQNFTop0jetEstimator.cxx:226
 TQNFTop0jetEstimator.cxx:227
 TQNFTop0jetEstimator.cxx:228
 TQNFTop0jetEstimator.cxx:229
 TQNFTop0jetEstimator.cxx:230
 TQNFTop0jetEstimator.cxx:231
 TQNFTop0jetEstimator.cxx:232
 TQNFTop0jetEstimator.cxx:233
 TQNFTop0jetEstimator.cxx:234
 TQNFTop0jetEstimator.cxx:235
 TQNFTop0jetEstimator.cxx:236
 TQNFTop0jetEstimator.cxx:237
 TQNFTop0jetEstimator.cxx:238
 TQNFTop0jetEstimator.cxx:239
 TQNFTop0jetEstimator.cxx:240
 TQNFTop0jetEstimator.cxx:241
 TQNFTop0jetEstimator.cxx:242
 TQNFTop0jetEstimator.cxx:243
 TQNFTop0jetEstimator.cxx:244
 TQNFTop0jetEstimator.cxx:245
 TQNFTop0jetEstimator.cxx:246
 TQNFTop0jetEstimator.cxx:247
 TQNFTop0jetEstimator.cxx:248
 TQNFTop0jetEstimator.cxx:249
 TQNFTop0jetEstimator.cxx:250
 TQNFTop0jetEstimator.cxx:251
 TQNFTop0jetEstimator.cxx:252
 TQNFTop0jetEstimator.cxx:253
 TQNFTop0jetEstimator.cxx:254
 TQNFTop0jetEstimator.cxx:255
 TQNFTop0jetEstimator.cxx:256
 TQNFTop0jetEstimator.cxx:257
 TQNFTop0jetEstimator.cxx:258
 TQNFTop0jetEstimator.cxx:259
 TQNFTop0jetEstimator.cxx:260
 TQNFTop0jetEstimator.cxx:261
 TQNFTop0jetEstimator.cxx:262
 TQNFTop0jetEstimator.cxx:263
 TQNFTop0jetEstimator.cxx:264
 TQNFTop0jetEstimator.cxx:265
 TQNFTop0jetEstimator.cxx:266
 TQNFTop0jetEstimator.cxx:267
 TQNFTop0jetEstimator.cxx:268
 TQNFTop0jetEstimator.cxx:269
 TQNFTop0jetEstimator.cxx:270
 TQNFTop0jetEstimator.cxx:271
 TQNFTop0jetEstimator.cxx:272
 TQNFTop0jetEstimator.cxx:273
 TQNFTop0jetEstimator.cxx:274
 TQNFTop0jetEstimator.cxx:275
 TQNFTop0jetEstimator.cxx:276
 TQNFTop0jetEstimator.cxx:277
 TQNFTop0jetEstimator.cxx:278
 TQNFTop0jetEstimator.cxx:279
 TQNFTop0jetEstimator.cxx:280
 TQNFTop0jetEstimator.cxx:281
 TQNFTop0jetEstimator.cxx:282
 TQNFTop0jetEstimator.cxx:283
 TQNFTop0jetEstimator.cxx:284
 TQNFTop0jetEstimator.cxx:285
 TQNFTop0jetEstimator.cxx:286
 TQNFTop0jetEstimator.cxx:287
 TQNFTop0jetEstimator.cxx:288
 TQNFTop0jetEstimator.cxx:289
 TQNFTop0jetEstimator.cxx:290
 TQNFTop0jetEstimator.cxx:291
 TQNFTop0jetEstimator.cxx:292
 TQNFTop0jetEstimator.cxx:293
 TQNFTop0jetEstimator.cxx:294
 TQNFTop0jetEstimator.cxx:295
 TQNFTop0jetEstimator.cxx:296
 TQNFTop0jetEstimator.cxx:297
 TQNFTop0jetEstimator.cxx:298
 TQNFTop0jetEstimator.cxx:299
 TQNFTop0jetEstimator.cxx:300
 TQNFTop0jetEstimator.cxx:301
 TQNFTop0jetEstimator.cxx:302
 TQNFTop0jetEstimator.cxx:303
 TQNFTop0jetEstimator.cxx:304
 TQNFTop0jetEstimator.cxx:305
 TQNFTop0jetEstimator.cxx:306
 TQNFTop0jetEstimator.cxx:307
 TQNFTop0jetEstimator.cxx:308
 TQNFTop0jetEstimator.cxx:309
 TQNFTop0jetEstimator.cxx:310
 TQNFTop0jetEstimator.cxx:311
 TQNFTop0jetEstimator.cxx:312
 TQNFTop0jetEstimator.cxx:313
 TQNFTop0jetEstimator.cxx:314
 TQNFTop0jetEstimator.cxx:315
 TQNFTop0jetEstimator.cxx:316
 TQNFTop0jetEstimator.cxx:317
 TQNFTop0jetEstimator.cxx:318
 TQNFTop0jetEstimator.cxx:319
 TQNFTop0jetEstimator.cxx:320
 TQNFTop0jetEstimator.cxx:321
 TQNFTop0jetEstimator.cxx:322
 TQNFTop0jetEstimator.cxx:323
 TQNFTop0jetEstimator.cxx:324
 TQNFTop0jetEstimator.cxx:325
 TQNFTop0jetEstimator.cxx:326
 TQNFTop0jetEstimator.cxx:327
 TQNFTop0jetEstimator.cxx:328
 TQNFTop0jetEstimator.cxx:329
 TQNFTop0jetEstimator.cxx:330
 TQNFTop0jetEstimator.cxx:331
 TQNFTop0jetEstimator.cxx:332
 TQNFTop0jetEstimator.cxx:333
 TQNFTop0jetEstimator.cxx:334
 TQNFTop0jetEstimator.cxx:335
 TQNFTop0jetEstimator.cxx:336
 TQNFTop0jetEstimator.cxx:337
 TQNFTop0jetEstimator.cxx:338
 TQNFTop0jetEstimator.cxx:339
 TQNFTop0jetEstimator.cxx:340
 TQNFTop0jetEstimator.cxx:341
 TQNFTop0jetEstimator.cxx:342
 TQNFTop0jetEstimator.cxx:343
 TQNFTop0jetEstimator.cxx:344
 TQNFTop0jetEstimator.cxx:345
 TQNFTop0jetEstimator.cxx:346
 TQNFTop0jetEstimator.cxx:347
 TQNFTop0jetEstimator.cxx:348
 TQNFTop0jetEstimator.cxx:349
 TQNFTop0jetEstimator.cxx:350
 TQNFTop0jetEstimator.cxx:351
 TQNFTop0jetEstimator.cxx:352
 TQNFTop0jetEstimator.cxx:353
 TQNFTop0jetEstimator.cxx:354
 TQNFTop0jetEstimator.cxx:355
 TQNFTop0jetEstimator.cxx:356
 TQNFTop0jetEstimator.cxx:357
 TQNFTop0jetEstimator.cxx:358
 TQNFTop0jetEstimator.cxx:359
 TQNFTop0jetEstimator.cxx:360
 TQNFTop0jetEstimator.cxx:361
 TQNFTop0jetEstimator.cxx:362
 TQNFTop0jetEstimator.cxx:363
 TQNFTop0jetEstimator.cxx:364
 TQNFTop0jetEstimator.cxx:365
 TQNFTop0jetEstimator.cxx:366
 TQNFTop0jetEstimator.cxx:367
 TQNFTop0jetEstimator.cxx:368
 TQNFTop0jetEstimator.cxx:369
 TQNFTop0jetEstimator.cxx:370
 TQNFTop0jetEstimator.cxx:371
 TQNFTop0jetEstimator.cxx:372
 TQNFTop0jetEstimator.cxx:373
 TQNFTop0jetEstimator.cxx:374
 TQNFTop0jetEstimator.cxx:375
 TQNFTop0jetEstimator.cxx:376
 TQNFTop0jetEstimator.cxx:377
 TQNFTop0jetEstimator.cxx:378
 TQNFTop0jetEstimator.cxx:379
 TQNFTop0jetEstimator.cxx:380
 TQNFTop0jetEstimator.cxx:381
 TQNFTop0jetEstimator.cxx:382
 TQNFTop0jetEstimator.cxx:383
 TQNFTop0jetEstimator.cxx:384
 TQNFTop0jetEstimator.cxx:385
 TQNFTop0jetEstimator.cxx:386
 TQNFTop0jetEstimator.cxx:387
 TQNFTop0jetEstimator.cxx:388
 TQNFTop0jetEstimator.cxx:389
 TQNFTop0jetEstimator.cxx:390
 TQNFTop0jetEstimator.cxx:391
 TQNFTop0jetEstimator.cxx:392
 TQNFTop0jetEstimator.cxx:393
 TQNFTop0jetEstimator.cxx:394
 TQNFTop0jetEstimator.cxx:395
 TQNFTop0jetEstimator.cxx:396
 TQNFTop0jetEstimator.cxx:397
 TQNFTop0jetEstimator.cxx:398
 TQNFTop0jetEstimator.cxx:399
 TQNFTop0jetEstimator.cxx:400
 TQNFTop0jetEstimator.cxx:401
 TQNFTop0jetEstimator.cxx:402
 TQNFTop0jetEstimator.cxx:403
 TQNFTop0jetEstimator.cxx:404
 TQNFTop0jetEstimator.cxx:405
 TQNFTop0jetEstimator.cxx:406
 TQNFTop0jetEstimator.cxx:407
 TQNFTop0jetEstimator.cxx:408
 TQNFTop0jetEstimator.cxx:409
 TQNFTop0jetEstimator.cxx:410
 TQNFTop0jetEstimator.cxx:411
 TQNFTop0jetEstimator.cxx:412
 TQNFTop0jetEstimator.cxx:413
 TQNFTop0jetEstimator.cxx:414
 TQNFTop0jetEstimator.cxx:415
 TQNFTop0jetEstimator.cxx:416
 TQNFTop0jetEstimator.cxx:417
 TQNFTop0jetEstimator.cxx:418
 TQNFTop0jetEstimator.cxx:419
 TQNFTop0jetEstimator.cxx:420
 TQNFTop0jetEstimator.cxx:421
 TQNFTop0jetEstimator.cxx:422
 TQNFTop0jetEstimator.cxx:423
 TQNFTop0jetEstimator.cxx:424
 TQNFTop0jetEstimator.cxx:425
 TQNFTop0jetEstimator.cxx:426
 TQNFTop0jetEstimator.cxx:427
 TQNFTop0jetEstimator.cxx:428
 TQNFTop0jetEstimator.cxx:429
 TQNFTop0jetEstimator.cxx:430
 TQNFTop0jetEstimator.cxx:431
 TQNFTop0jetEstimator.cxx:432
 TQNFTop0jetEstimator.cxx:433
 TQNFTop0jetEstimator.cxx:434
 TQNFTop0jetEstimator.cxx:435
 TQNFTop0jetEstimator.cxx:436
 TQNFTop0jetEstimator.cxx:437
 TQNFTop0jetEstimator.cxx:438
 TQNFTop0jetEstimator.cxx:439
 TQNFTop0jetEstimator.cxx:440
 TQNFTop0jetEstimator.cxx:441
 TQNFTop0jetEstimator.cxx:442
 TQNFTop0jetEstimator.cxx:443
 TQNFTop0jetEstimator.cxx:444
 TQNFTop0jetEstimator.cxx:445
 TQNFTop0jetEstimator.cxx:446
 TQNFTop0jetEstimator.cxx:447
 TQNFTop0jetEstimator.cxx:448
 TQNFTop0jetEstimator.cxx:449
 TQNFTop0jetEstimator.cxx:450
 TQNFTop0jetEstimator.cxx:451
 TQNFTop0jetEstimator.cxx:452
 TQNFTop0jetEstimator.cxx:453
 TQNFTop0jetEstimator.cxx:454
 TQNFTop0jetEstimator.cxx:455
 TQNFTop0jetEstimator.cxx:456
 TQNFTop0jetEstimator.cxx:457
 TQNFTop0jetEstimator.cxx:458
 TQNFTop0jetEstimator.cxx:459
 TQNFTop0jetEstimator.cxx:460
 TQNFTop0jetEstimator.cxx:461
 TQNFTop0jetEstimator.cxx:462
 TQNFTop0jetEstimator.cxx:463
 TQNFTop0jetEstimator.cxx:464
 TQNFTop0jetEstimator.cxx:465
 TQNFTop0jetEstimator.cxx:466
 TQNFTop0jetEstimator.cxx:467
 TQNFTop0jetEstimator.cxx:468
 TQNFTop0jetEstimator.cxx:469
 TQNFTop0jetEstimator.cxx:470
 TQNFTop0jetEstimator.cxx:471
 TQNFTop0jetEstimator.cxx:472
 TQNFTop0jetEstimator.cxx:473
 TQNFTop0jetEstimator.cxx:474
 TQNFTop0jetEstimator.cxx:475
 TQNFTop0jetEstimator.cxx:476
 TQNFTop0jetEstimator.cxx:477
 TQNFTop0jetEstimator.cxx:478
 TQNFTop0jetEstimator.cxx:479
 TQNFTop0jetEstimator.cxx:480
 TQNFTop0jetEstimator.cxx:481