#include "QFramework/TQSystematicsManager.h"
#include "QFramework/TQSystematics.h"
#include "QFramework/TQIterator.h"
#include "QFramework/TQHistogramUtils.h"
#include "QFramework/TQPathManager.h"

#include "TF1.h"
#include "TFitResult.h"
#include "TMath.h"

#define UNUSED(x) (void)(x)

#ifdef HAS_CommonSystSmoothingTool
#pragma message "enabling CommonSystSmoothingTool integration"
#include "SmoothSystematics/SmoothHist.h"
#else
#pragma message "disabling CommonSystSmoothingTool integration"
#endif

// #define _DEBUG_
#include "QFramework/TQLibrary.h"

//__________________________________________________________________________________|___________

bool TQSystematicsManager::HistogramVariationComputer::emitError(){
  return true;
}

bool TQSystematicsManager::emitError(){
  nErrors++;
  if(nErrors < nErrorThreshold) return true;
  else {
    if(nErrors == nErrorThreshold){
      WARNclass("more than %d errors encountered, suppressing further messages...",nErrorThreshold);
    }
    return false;
  }
}

//__________________________________________________________________________________|___________

void TQSystematicsManager::setSampleFolder(const TString& path, TQSampleFolder* sf){
  // register a sample folder to the given path
  _inputCache[path] = sf;
}

//__________________________________________________________________________________|___________

TQSampleFolder* TQSystematicsManager::getSampleFolder(TQTaggable* var){
  // retrieve the sample folder for the variation given
  if(!var) return NULL;
  TString name = var->getTagStringDefault("Variation","unknown");
  TString path = var->getTagStringDefault("~SampleFolder","");
  bool lazy = var->getTagBoolDefault("~lazy",false);  
  if(!path){
    ERROR("unable to find sample folder for variation '%s'",name.Data());
  }

  TQSampleFolder* sf = NULL;
  auto input = _inputCache.find(path);
  if(input == _inputCache.end()){
    info(TString::Format("loadSampleFolder('%s',%d) - opening...",path.Data(),(int)lazy));
    sf = TQSampleFolder::loadSampleFolder(path,lazy);
    if(sf){
      for(auto patch:var->getTagVString("~patches")){
        TString msg;
        if(!sf->importFromTextFile(TQPathManager::getPathManager()->findConfigPath(patch).c_str(),msg)){
          error(msg);
        }
      }
      sf->setTagBool(".autoLoaded",true);
      _inputCache[path] = sf;
    }
  } else {
    sf = input->second;
  }
  
  if(!sf){
    ERRORclass("unable to load sample folder from file '%s'",path.Data());
    return NULL;
  }
  return sf;
}


//__________________________________________________________________________________|___________

bool TQSystematicsManager::isBlacklistedSys(TQFolder* sys, const std::vector<TString>&  systBlacklist, const std::vector<TString>& types){
  // return true if a systematic matches the blacklist filter
  bool isBlacklisted = false;
  for (auto& s: systBlacklist) {
    for(auto& type:types){
      if( TQStringUtils::matches(sys->getName(),type+"."+s)){
        isBlacklisted = true;
      }
    }
  }
  return isBlacklisted;
}

namespace {
  double ratioError(double numerator, double denominator, double eNumerator, double eDenominator, double correlation = 0){
    // stolen from TQCounter::divide
    double eNumerator2 = eNumerator*eNumerator;
    double eDenominator2 = eDenominator*eDenominator;    
    return sqrt(TMath::Power(denominator,-2)*eNumerator2 + TMath::Power(numerator/TMath::Power(denominator,2),2)*eDenominator2 - 2 * correlation * numerator * TMath::Power(denominator,3) * TMath::Sqrt(eNumerator2*eDenominator2));
  }
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::includeOverallSys(TQFolder* sysConfig, TQFolder* sys, const TString& nameChannel, const TString& nameSample){
  // include a normalization systematic
  DEBUGclass("investigating systematic %s for channel %s in sample %s",sys->GetName(),nameChannel.Data(),nameSample.Data());    
  
  // get systematic + up/down variation names
  TString varUp = sysConfig->getTagStringDefault("Up","");
  TQFolder* computeFolder_Up = sysConfig->getFolder("Compute/Up");
  // get the variation histograms, compute if needed
  TH1* h_Up = varUp.IsNull() ? NULL : this->getVarHisto(varUp, nameChannel, nameSample,!computeFolder_Up);
  if(!h_Up && computeFolder_Up) {
    DEBUGclass("computing up variation from Compute folder");
    h_Up   = this->computeHistogramVariation(computeFolder_Up, nameChannel, nameSample);
    if (h_Up) storeVarHisto(h_Up, varUp, nameChannel);
  }
  // get systematic + up/down variation names
  TString varDown = sysConfig->getTagStringDefault("Down","");
  TQFolder* computeFolder_Down = sysConfig->getFolder("Compute/Down");
  // get the variation histograms, compute if needed
  TH1* h_Down = varDown.IsNull() ? NULL : this->getVarHisto(varDown, nameChannel, nameSample,!computeFolder_Down);
  if (!h_Down && computeFolder_Down) {
    DEBUGclass("computing down variation from Compute folder");    
    h_Down = this->computeHistogramVariation(computeFolder_Down, nameChannel, nameSample);
    if (h_Down) storeVarHisto(h_Down, varDown, nameChannel);
  } 

  // activate old-style assumpption of correlated statistical variations on systematics
  bool assumeCorrelated = sysConfig->getTagBoolDefault("assumeCorrelatedVariations",false);
  
  // get nominal histogram integral
  const TH1* h_Nominal = this->getVarHisto("Nominal", nameChannel, nameSample);
  Double_t norm_Nominal_err;
  Double_t norm_Nominal = TQHistogramUtils::getIntegralAndError(h_Nominal,norm_Nominal_err);
  
  // compute ratios
  int      nEntries       = sys->getTagIntegerDefault("Entries",0);
  Double_t ratio_Up	  = 1.;
  Double_t ratio_Down	  = 1.;
  Double_t ratio_Up_Err	  = 0.;
  Double_t ratio_Down_Err = 0.;

  if (h_Up || h_Down){
    if (norm_Nominal == 0.) {
      warn(TString::Format("includeSystematics('%s'): Normalization of Nominal histogram "
                           "of sample '%s' in channel '%s' is zero. Skipping ...",
                           sysConfig->GetName(), nameSample.Data(), nameChannel.Data()));
      return false;
    }
    if(h_Up){
      double norm_Up_Err = 0.;
      double norm_Up = TQHistogramUtils::getIntegralAndError(h_Up,norm_Up_Err);
      ratio_Up = norm_Up / norm_Nominal;
      DEBUGclass("derived systematic Up effect %.4f from proper histogram",ratio_Up);
      if(assumeCorrelated) ratio_Up_Err = norm_Up_Err / norm_Nominal;
      else                 ratio_Up_Err = ratioError(norm_Up,norm_Nominal,ratio_Up_Err,norm_Nominal_err);
      nEntries = std::max((int)h_Up->GetEntries(),nEntries);
    }
    if(h_Down){
      double norm_Down_Err = 0.;      
      double norm_Down = TQHistogramUtils::getIntegralAndError(h_Down,norm_Down_Err);
      ratio_Down = norm_Down / norm_Nominal;
      DEBUGclass("derived systematic Down effect %.4f from proper histogram",ratio_Down);
      if(assumeCorrelated) ratio_Down_Err = norm_Down_Err / norm_Nominal;
      else                 ratio_Down_Err = ratioError(norm_Down,norm_Nominal,ratio_Down_Err,norm_Nominal_err);      
      nEntries = std::max((int)h_Down->GetEntries(),nEntries);      
    }
    if(!h_Up){ // Then ratio_Down is available
      ratio_Up=2.-ratio_Down;
      DEBUGclass("derived systematic Up effect %.4f from symmetrization",ratio_Up);      
      ratio_Up_Err=ratio_Down_Err;
    }
    if(!h_Down){ // Then ratio_Up is available
      ratio_Down=2.-ratio_Up;
      DEBUGclass("derived systematic Down effect %.4f from symmetrization",ratio_Down);      
      ratio_Down_Err=ratio_Up_Err;
    }
  } else if(!sys->hasTagDouble("High") || !sys->hasTagDouble("Low")) {
    error(TString::Format("includeOverallSys(...): Systematic '%s' does not have variations assigned for sample '%s' in channel '%s'!",sysConfig->GetName(),nameSample.Data(),nameChannel.Data()));
    return false;
  }

  // magnify variation
  Double_t magnDefault	= sysConfig->getTagDoubleDefault("Magnification", 1.);
  Double_t magnOverallSys	= sysConfig->getTagDoubleDefault("OverallSysMagnification", magnDefault);
  if (magnOverallSys != 1.) {
    ratio_Up = TMath::Power(ratio_Up, magnOverallSys);
    ratio_Down = TMath::Power(ratio_Down, magnOverallSys);
  }

  // define OverallSys
  double low  = ratio_Down * sys->getTagDoubleDefault("Low", 1.);
  double high = ratio_Up   * sys->getTagDoubleDefault("High", 1.);
  double variation = std::max(fabs(low-1.),fabs(high-1.));  
  sys->setTagInteger("Status", TQSystematics::ACTIVE);
  sys->setTagInteger("Entries", nEntries);
  sys->setTagDouble("Low", low);
  sys->setTagDouble("High", high);
  sys->setTagDouble("LowErr", ratio_Down_Err);
  sys->setTagDouble("HighErr", ratio_Up_Err);
  sys->setTagDouble("Percent", variation*100);
                    
  // succesfully included OverallSys
  return true;
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::includeHistoSys(TQFolder* sysConfig, TQFolder* sys, const TString& nameChannel, const TString& nameSample){
  // include a histogram systematic

  // get systematic + up/down variation names
  TString varUp = sysConfig->getTagStringDefault("Up","");
  TQFolder* computeFolder_Up = sysConfig->getFolder("Compute/Up");
  // get the variation histograms, compute if needed
  TH1* h_Up = varUp.IsNull() ? NULL : this->getVarHisto(varUp, nameChannel, nameSample,!computeFolder_Up);
  if(!h_Up && computeFolder_Up) {
    h_Up   = this->computeHistogramVariation(computeFolder_Up, nameChannel, nameSample);
    if (h_Up){
      DEBUGclass("including up variaton for '%s",sysConfig->GetName());
      storeVarHisto(h_Up, varUp, nameChannel);
    }
  }
  // get systematic + up/down variation names
  TString varDown = sysConfig->getTagStringDefault("Down","");
  TQFolder* computeFolder_Down = sysConfig->getFolder("Compute/Down");
  // get the variation histograms, compute if needed
  TH1* h_Down = varDown.IsNull() ? NULL : this->getVarHisto(varDown, nameChannel, nameSample,!computeFolder_Down);
  if (!h_Down && computeFolder_Down) {
    h_Down = this->computeHistogramVariation(computeFolder_Down, nameChannel, nameSample);
    if (h_Down){
      DEBUGclass("including down variaton for '%s",sysConfig->GetName());  
      storeVarHisto(h_Down, varDown, nameChannel);
    }
  }

  if(!h_Up && !h_Down){
    if(emitError()) ERRORclass("unable to include HistoSys '%s': no variation found!",sysConfig->GetName());
    return false;
  }
  
  // magnify variations
  Double_t magnDefault	= sysConfig->getTagDoubleDefault("Magnification", 1.);
  Double_t magnHistoSys	= sysConfig->getTagDoubleDefault("HistoSysMagnification", magnDefault);

  // get nominal histogram
  const TH1* h_Nominal = this->getVarHisto("Nominal", nameChannel, nameSample);
  if(!h_Nominal){
    if(emitError()) ERRORclass("failed to obtain nominal variation for '%s'/'%s'",nameChannel.Data(),nameSample.Data());
    return false;
  }
  // normalize and/or symmetrize into shape variations

  #ifdef _DEBUG_
  for(size_t i=0; i< h_Up->GetNbinsX()+2; ++i){
    std::cout << h_Nominal->GetBinContent(i);
    if(h_Up) std::cout << " / " << h_Up->GetBinContent(i);
    if(h_Down) std::cout << " / " << h_Down->GetBinContent(i);
    std::cout << std::endl;
  }
  #endif
  
  // store systematic variations
  TString sysName(sysConfig->GetName());
  
  TH1* shape_Up = normalizeShapeVariation(h_Up, h_Nominal, h_Down);
  if(!shape_Up){
    if(emitError()) ERRORclass("failed to obtain normalized variation for 'Up'");
    return false;
  }
  if (magnHistoSys != 1.) {
    magnifyShapeVariation(shape_Up, h_Nominal, magnHistoSys);
  }
  TH1* shape_RelUp = TQHistogramUtils::copyHistogram(shape_Up);
  shape_RelUp->Divide(h_Nominal);
  TString histoPathHigh = storeSysHisto(shape_Up,   sysName, "Up",   nameChannel);
  TString histoPathRelHigh = storeSysHisto(shape_RelUp, sysName, "RelUp", nameChannel);  
  sys->setTagString("HistoHigh", histoPathHigh);
  sys->setTagString("HistoRelHigh", histoPathRelHigh);

  TH1* shape_Down = normalizeShapeVariation(h_Down, h_Nominal, h_Up);
  if(!shape_Down){
    if(emitError()) ERRORclass("failed to obtain normalized variation for 'Down'");
    return false;
  }
  if (magnHistoSys != 1.) {
    magnifyShapeVariation(shape_Down, h_Nominal, magnHistoSys);
  }
  TH1* shape_RelDown = TQHistogramUtils::copyHistogram(shape_Down);
  shape_RelDown->Divide(h_Nominal);
  TString histoPathLow = storeSysHisto(shape_Down,   sysName, "Down",   nameChannel);
  TString histoPathRelLow = storeSysHisto(shape_RelDown, sysName, "RelDown", nameChannel);      
  sys->setTagString("HistoLow", histoPathLow);
  sys->setTagString("HistoRelLow", histoPathRelLow);    
    
  if (magnHistoSys != 1.) {
    sys->setTagDouble("Magnification",magnHistoSys);
  }

  // successfully included HistoSys
  return true;
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::processHistoSys_smoothVariation(TQTaggable* parameters, TQFolder* sys, TH1* nom, TH1* up, TH1* down){
  // process a systematic by smoothing it
  // return true if a smoothing has been performed, false otherwise

  //@tag: [histoSys.smoothingMethod] choose the smoothing method to be used. "default" (default) uses TH1::Smooth, any other will be forwarded to CommonSystSmoothingTool SmoothHist::Smooth (https://gitlab.cern.ch/atlas-phys/exot/CommonSystSmoothingTool) if available - check there for possible values of smoothing methods
  TString alg = parameters->getTagStringDefault("histoSys.smoothingMethod","default");
  
  //@tag: [histoSys.smoothDirectionAndSymmetrize] Can be set to 'Up' or 'Down' to configure the smoothing so it is applied only to this variation followed by a symmetrization of the smoothed variation. This is useful for 2-point systematics.
  TString smoothDirection = parameters->getTagStringDefault("histoSys.smoothDirectionAndSymmetrize", "");
  
  bool smoothedUp = false;
  bool smoothedDown = false;
  
  if (smoothDirection.IsNull()) {
    smoothedUp = smoothHist(alg, nom, up);
    smoothedDown = smoothHist(alg, nom, down);
  } else {
    if (smoothDirection.EqualTo("Up"))  {
      smoothedUp = smoothHist(alg, nom, up);
      TH1* inverted = TQHistogramUtils::invertShiftWithoutError(up, nom);
      for (int i = 0; i < inverted->GetNbinsX()+1; i++) {
        down->SetBinContent(i, inverted->GetBinContent(i));
        down->SetBinError(i, inverted->GetBinError(i));
      }
      smoothedDown = true;
    } else if (smoothDirection.EqualTo("Down")) {
      smoothedDown = smoothHist(alg, nom, down);
      TH1* inverted = TQHistogramUtils::invertShiftWithoutError(down, nom);
      for (int i = 0; i < inverted->GetNbinsX()+1; i++) {
        up->SetBinContent(i, inverted->GetBinContent(i));
        up->SetBinError(i, inverted->GetBinError(i));
      }
      smoothedUp = true;
    } else {
      warn(TString::Format("The smoothing direction '%s' you specified with the tag 'smoothDirectionAndSymmetrize' is not supported. Please choose either 'Up' or 'Down'. Skipping smoothing in this run!", smoothDirection.Data()));
    }
  }

  bool smoothed = smoothedUp && smoothedDown;
  if (!smoothed)  warn(TString::Format("You specified smoothing for systematic with name '%s' but something went wrong in the smoothing tool", sys->GetName()));
  if ((smoothedUp && !smoothedDown) || (!smoothedUp && smoothedDown)) warn("A strange error occured where the up/down variation was successfully smoothed but the down/up variation was not. Please check your input uncertainties");
  return smoothed;
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::smoothHist(const TString& alg, TH1* nom, TH1* var){
  bool smoothed = false;
  if(alg=="default"){
    UNUSED(nom);
    UNUSED(var);
    // var->Smooth();
    if(emitError()) ERRORclass("You configured smoothing with the default ROOT algorithm. This is not yet supported");
  } else {
#ifdef HAS_CommonSystSmoothingTool
    SmoothHist smoother;
    // Note, SmoothHist::Smooth manipulates histogram inplace.
    TH1* newHist = smoother.Smooth(nom,var,alg.Data(), SmoothedHistErrors::Original);
    if(newHist != var){
      // combat temporary inconsistency of smoothing tool and set variation to new hist
      // for Kernel method where var is not manipulated inplace.
      if (alg.Contains("Kernel")) {
        var = newHist;
        smoothed = true;
      } else {
        if(emitError()) ERRORclass("Smoother created new histogram, but pointer feedback is not implemented!");
      }
    } else {
      smoothed = true;
    }
#else
    if(emitError()) ERRORclass("You configured smoothing algorithm '%s', but the CommonSystSmoothingTool is not available!", alg.Data());
    smoothed = false;
#endif
  }
  return smoothed;
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::processHistoSys_systsToSymmetrizeMaxBins(TQTaggable* parameters, TQFolder* sys, TH1* nom, TH1* up, TH1* down, bool force){
  // Fix shape by symmetrizing maximum relative variation in each bin
  // alternative to systsToSymmetrizeMaxBins
  // return true if a symmetrization has been performed, false otherwise  
  
  //@tag: [histoSys.systsToSymmetrizeMaxBins,histoSys.systsToForceSymmetrizeMaxBins] List of systematics to symmetrize when a one-sided bin is present. The new shape will be determined by symmetrizing the larger variation in each bin. This could lead to amplification of statistically fluctuating templates so use with caution. The tag 'histoSys.systsToForceSymmetrizeMaxBins' can be used to force certain systematics to be symmetrized even if they don't exhibit one-sided bins (might be useful in case of largely asymmetric variations). 

  bool symmetrizedBins = false;
  if (up && down) {
    int nBinGlobal = TQHistogramUtils::getNbinsGlobal(nom);
            
    bool forceSymmetrization = force;
    bool continueSymmetrizing = true;
    int loopCounter = 0;
    while (continueSymmetrizing) {
      bool oneSidedBinPresent = false;
      for(int i=0; i<nBinGlobal; ++i){
        double binUp = up->GetBinContent(i);
        double binDo = down->GetBinContent(i);
        double binNom = nom->GetBinContent(i);
        // if one-sided 
        if ( ((binUp > binNom) && (binDo > binNom)) || ( (binUp < binNom) && (binDo < binNom) ) ) {
          symmetrizedBins = true;
          oneSidedBinPresent = true;
        }
      }
      if (oneSidedBinPresent || forceSymmetrization) {
        symmetrizedBins = true;
        for(int i=0; i<nBinGlobal; ++i){
          double binUp = up->GetBinContent(i);
          double binDo = down->GetBinContent(i);
          double binNom = nom->GetBinContent(i);
          double relUp = std::abs(1 - binUp/binNom);
          double relDo = std::abs(1 - binDo/binNom);
          if ( relUp > relDo) {
            down->SetBinContent(i, 2*binNom-binUp);
          } else {
            up->SetBinContent(i, 2*binNom-binDo);
          }
          if ( relUp > 0.3 || relDo > 0.3 ) {
            if (parameters->getTagIntegerDefault("histoSys.symmetrizeMaxBinsPrintWarnings", true)) {
              WARNclass(TString::Format("You might artifically increase your shape uncertainty: A large relative variation (> 0.3) was found and symmetrized in bin '%d' for shape syst '%s', sample '%s', region '%s'.",i, sys->GetName(),sys->getBase()? sys->getBase()->GetName() : "<none>", sys->getBase() && sys->getBase()->getBase() ? sys->getBase()->getBase()->GetName() : "<none>").Data());
            }
          }
        }
        TQHistogramUtils::normalize(up, nom);
        TQHistogramUtils::normalize(down, nom);
      } else {
        continueSymmetrizing = false;
      }
      if (forceSymmetrization) break;
      loopCounter++;
      // @tag: [histoSys.symmetrizeMaxBinsIterations] This tag determines how many iterations of "symmetrizing bins" and "normalizing the histograms after symmetrizing" we allow before terminating the loop and throwing a warning
      if (loopCounter > parameters->getTagIntegerDefault("histoSys.symmetrizeMaxBinsIterations", 2)) {
        WARNclass(TString::Format("Jumping out of loop to symmetrize maximum bins with one-sided variations in shape syst '%s', sample '%s', region '%s'",sys->GetName() ,sys->getBase()? sys->getBase()->GetName() : "<none>", sys->getBase() && sys->getBase()->getBase() ? sys->getBase()->getBase()->GetName() : "<none>").Data());
        break;
      }
    }
  }
  
  return symmetrizedBins;
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::processHistoSys_checkCutoff(TQTaggable* parameters,  TH1* ratio){
  // Cut-off systs with artificially high bins
  // return true if histogram is found to violate the cutoff, false if it is found to be ok
  
  double cutOffHigh = parameters->getTagDoubleDefault("histoSys.cutOffHigh", 2);
  double cutOffLow = parameters->getTagDoubleDefault("histoSys.cutOffLow", 0.3);
  //@tag: [histoSys.cutOffHigh, histoSys.cutOffLow] The systematic is pruned if the variation / nominal ratio histogram has one or more bins above histoSys.cutOffHigh or below histoSys.cutOffLow.
  bool isCutOff = false;
  int nBinGlobal = TQHistogramUtils::getNbinsGlobal(ratio);
  for(int i=0; i<nBinGlobal; ++i){
    if (ratio->GetBinContent(i) > cutOffHigh || ratio->GetBinContent(i) < cutOffLow) {
      isCutOff = true;
    }
  }
  return isCutOff;
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::processHistoSys_isFlat(TQTaggable* parameters, TQFolder* sys, TH1* ratio){
  // Check flatness of a shape histogram using a chi2 fit of a flat line
  // return true if histogram is found to be flat, false otherwise
  double threshold = 0.;
  bool doSomething = parameters->getTagDouble("histoSys.flatChi2pValMin",threshold);
  //@tag: [histoSys.flatChi2pValMin] If set both relative up and down variation (w.r.t. the nominal histogram) are tested for being compatible with a flat ratio by performing a Chi2 fit to a polinomial of 0th order. The histoSys is pruned unless the probability to encounter a Chi2 value lower than the one found in the fit of the relative variation exceeds the threshold determined by this tag. I both, up and down variation histograms are found the systematic is kept if one of the variations is deemed significant by the afforementioned criterium.  
  if(!doSomething) return false;
  //print a warning if the threshold is high enough to prune anything
  if (! (threshold<1.) ) warn("Found high threshold ( >= 1.0 ) for histoSys pruning based on Chi2 p-Value of a flat-ratio hypothesis fit");
  bool verbose = parameters->getTagBoolDefault("verbose",false);
  
  TF1 *f = new TF1("f","pol0",ratio->GetXaxis()->GetBinLowEdge(ratio->GetXaxis()->GetFirst()),ratio->GetXaxis()->GetBinUpEdge(ratio->GetXaxis()->GetLast()));
  
  f->SetParameter(0,1.); //set a reasonable start value

  bool isFlat = false;
  auto resultptr = ratio->Fit(f,"SNRQ"); //options: do *N*ot store function internally, use *R*ange of f, *Q*uiet
  auto result = resultptr.Get();
  int status = result ? result->Status() : -1;
  if(status != 0){
    std::cout << "fit failed with status " << status << std::endl;
    int nBinGlobal = TQHistogramUtils::getNbinsGlobal(ratio);
    for(int i=0; i<nBinGlobal; ++i){
      std::cout << "bin " << i << ": " << ratio->GetBinContent(i) << " +- " << ratio->GetBinError(i) << ", ";
    }
    isFlat=false;
    std::cout << std::endl;
  } else {
    if ( (1.-f->GetProb()> threshold) && f->GetNDF()>0 ) {
      if (verbose) std::cout<<TString::Format("Found significant shape: %.4f > %.4f for syst '%s', sample '%s', region '%s'",1.-f->GetProb(), threshold, sys->GetName(),sys->getBase()? sys->getBase()->GetName() : "<none>", sys->getBase() && sys->getBase()->getBase() ? sys->getBase()->getBase()->GetName() : "<none>").Data()<<std::endl;
      isFlat=false;
    } else if (f->GetNDF() < 1) {
      if(verbose) std::cout<<TString::Format("Not enough information to consider as shape systematic (histoSys), NDF after fit of pol0 is %d for syst '%s', sample '%s', region '%s'", f->GetNDF(), sys->GetName(),sys->getBase()? sys->getBase()->GetName() : "<none>", sys->getBase() && sys->getBase()->getBase() ? sys->getBase()->getBase()->GetName() : "<none>").Data()<<std::endl;
      isFlat=true;      
    } else {
      if(verbose) std::cout<<TString::Format("Shape seems insignificant: %.4f < %.4f for syst '%s', sample '%s', region '%s'",1.-f->GetProb(), threshold, sys->GetName(),sys->getBase()? sys->getBase()->GetName() : "<none>", sys->getBase() && sys->getBase()->getBase() ? sys->getBase()->getBase()->GetName() : "<none>").Data()<<std::endl;
      isFlat=true;
    }
  }
  
  delete f; //remove function from memory
  return isFlat;
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::processHistoSys_systsToSymmetrizeBins(TQTaggable* parameters, TQFolder* sys, TH1* nom, TH1* up, TH1* down){
  // Fix shape by symmetrizing one-sided bins
  // return true if a symmetrization has been performed, false otherwise
  
  bool symmetrizedBins = false;
  
  double integral = TQHistogramUtils::getIntegral(nom);
  if (up && down) {
    int nBinGlobal = TQHistogramUtils::getNbinsGlobal(nom);
    bool continueSymmetrizing = true;
    int loopCounter = 0;
    while (continueSymmetrizing) {
      bool oneSidedBinPresent = false;
      for(int i=0; i<nBinGlobal; ++i){
        double binUp = up->GetBinContent(i);
        double binDo = down->GetBinContent(i);
        double binNom = nom->GetBinContent(i);
        // if one-sided 
        if ( ((binUp > binNom) && (binDo > binNom)) || ( (binUp < binNom) && (binDo < binNom) ) ) {
          symmetrizedBins = true;
          oneSidedBinPresent = true;
          // symmetrize smaller variation
          if ( (binUp > binDo && binUp > binNom) || (binUp < binDo && binUp < binNom) ) {
            down->SetBinContent(i,  2*binNom - binDo  ) ;
          } else {
            up->SetBinContent(i,  2*binNom - binUp  ) ;
          }
        }
      }
      if (oneSidedBinPresent) {
        symmetrizedBins = true;
        // normalizing variations after they have been massaged
        // only if norm is changed by > 0.01%
        double up_integral = TQHistogramUtils::getIntegral(up);
        double do_integral = TQHistogramUtils::getIntegral(down);
        if ( std::fabs(1 - up_integral/integral) > 0.0001 ) {
          TQHistogramUtils::normalize(up, nom);
        }
        if ( std::fabs(1 - do_integral/integral) > 0.0001 ) {
          TQHistogramUtils::normalize(down, nom);
        }
      } else {
        continueSymmetrizing = false;
      }
      loopCounter++;
      // @tag: [histoSys.symmetrizeBinsIterations] This tag determines how many iterations of "symmetrizing bins" and "normalizing the histograms after symmetrizing" we allow before terminating the loop and throwing a warning
      if (loopCounter > parameters->getTagIntegerDefault("histoSys.symmetrizeBinsIterations", 50)) {
        WARNclass(TString::Format("Jumping out of loop to symmetrize bins with one-sided variations in shape syst '%s', sample '%s', region '%s'",sys->GetName(),sys->getBase()? sys->getBase()->GetName() : "<none>", sys->getBase() && sys->getBase()->getBase() ? sys->getBase()->getBase()->GetName() : "<none>").Data());
        break;
      }
    }
  }
  return symmetrizedBins;
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::processHistoSys(TQTaggable* parameters, TQFolder* sys){
  // returns true if the systematic is kept, false causes the systematic to be dropped
  if (!parameters) return true; //no parameters for operation given, hence, don't touch the systematic
  if (!sys) return true;


  // --------------- Get All Tags ------------------
  bool doSomething = false;
  
  // prune based on different criteria
  //@tag: [histoSys.prune] Controls if pruning criteria based on a chi2 test should be applied to HistoSys ("shape") systematics/components (Default: false). The stringency of the pruning can be controlled with the tag 'histoSys.flatChi2pValMin'
  bool pruneBasedOnFlatness = parameters->getTagBoolDefault("histoSys.prune",false);
  
  //@tag: [histoSys.pruneBasedOnCutOff] Controls if pruning criteria based on a cut off should be applied to HistoSys ("shape") systematics/components (Default: false). Cut-off values can be controlled with tags 'histoSys.cutOffHight' and 'histoSys.cutOffLow'. 
  bool pruneBasedOnCutOff = parameters->getTagBoolDefault("histoSys.pruneBasedOnCutOff",false);


  //@tag: [histoSys.symmetrizeBins] Controls if shapes with one-sided bins should be symmetrized. If the up and down variation have the same sign in a given bin, the smaller of the two will be symmetrized, i.e. the sign of the smaller variation is swapped. 
  bool symmetrizeBins = parameters->getTagBoolDefault("histoSys.symmetrizeBins",false);
  
  //@tag: [histoSys.symmetrizeMaxBins,histoSys.forceSymmetrizeMaxBins] Symmetrize shape when a one-sided bin (up and down variation going in the same direction) is present. The new shape is determined by symmetrizing the larger variation (i.e. setting the smaller of the variations to the mirror image of the larger) in each bin. Warning: This could lead to amplification of statistically fluctuating templates so it should be used with caution. The tag 'histoSys.forceSymmetrizeMaxBins' can be used to force certain systematics to be symmetrized even if they don't exhibit one-sided bins (might be useful in case of largely asymmetric variations). 
  bool symmetrizeMaxBins = parameters->getTagBoolDefault("histoSys.symmetrizeMaxBins",false);
  bool forceSymmetrizeMaxBins = parameters->getTagBoolDefault("histoSys.forceSymmetrizeMaxBins",false);

  //@tag: [histoSys.smooth] activate smoothing of systematic variation (default: false). Choose a smoothing method with tat 'histoSys.smoothingMethod'
  bool smooth = parameters->getTagBoolDefault("histoSys.smooth",false);

  if (pruneBasedOnFlatness ||
      pruneBasedOnCutOff ||
      symmetrizeMaxBins ||
      symmetrizeBins ||
      forceSymmetrizeMaxBins ||
      smooth) {
    //if (parameters->countMatchingTags("histoSys.systsToSymmetrize*")>1){
     // if(emitError()) ERRORclass("Your configured two types of symmetrization methods in case of one-sided bins (histoSys.systsToSymmetrize*). Please choose one!");
    //} else if(parameters->countMatchingTags("histoSys.systsToSymmetrize*")>0){
      doSomething = true;
    //}
  }
  bool verbose = parameters->getTagBoolDefault("verbose",false);
  TQSystematics::Status status = TQSystematics::ACTIVE;
  
  if (!doSomething){
    return true;
  } else  {

    // ----------- Get Histograms -----------
    TString pathUp, pathDown, pathNom;
    bool hasUp   = sys->getTagString("HistoHigh",pathUp);
    bool hasDown = sys->getTagString("HistoLow",pathDown);
    bool hasNom  = sys->getBase() ? sys->getBase()->getTagString("Histo",pathNom) : false;
    if (!hasNom) warn(TString::Format("Failed to obtain path to nominal histogram for systematic '%s' for sample '%s'!", sys->GetName(), sys->getBase()? sys->getBase()->GetName() : "<none>"));
    if (! (hasDown || hasUp)) {
      warn(TString::Format("Failed to obtain path to both, up and down variation histogram for systematic '%s' for sample '%s'!", sys->GetName(), sys->getBase()? sys->getBase()->GetName() : "<none>")); 
    } else if (hasNom && (hasUp || hasDown)) {
      //obtaining the raw objects from the folders, ownership remains with the folders
      TH1* up   = hasUp   ?   dynamic_cast<TH1*>(this->getHisto(pathUp)   ) : nullptr;
      TH1* down = hasDown ?   dynamic_cast<TH1*>(this->getHisto(pathDown) ) : nullptr;
      TH1* nom  =             dynamic_cast<TH1*>(this->getHisto(pathNom)  ) ;
      //check if histograms were obtained as expected

      if (!up && hasUp) { throw std::runtime_error(TString::Format("Found path for up variation histogram but histogram itself could not be found at expected location '%s' for histoSys '%s' of sample '%s'",pathUp.Data(), sys->GetName(), sys->getBase()? sys->getBase()->GetName() : "<none>" ).Data()); return false; }

      if (!down && hasDown) { throw std::runtime_error(TString::Format("Found path for down variation histogram but histogram itself could not be found at expected location '%s' for histoSys '%s' of sample '%s'",pathDown.Data(), sys->GetName(), sys->getBase()? sys->getBase()->GetName() : "<none>" ).Data()); return false; }

      // -------------- Process HistoSys --------------
      bool isFlat = up || down; // if we have at least one variation we assume the histoSys is flat (i.e. to be pruned) until we find something exceeding the threshold
      bool isCutOff = false;
      bool isSymmetrizedBins = false;
      bool isSmoothed = false;
      if(nom->GetNbinsX() > 1){
        
        // 1. smoothing
        if (smooth) {
          isSmoothed = processHistoSys_smoothVariation(parameters, sys, nom, up, down);
        }

        // 2. symmetrization
        if (symmetrizeBins) {
          isSymmetrizedBins = processHistoSys_systsToSymmetrizeBins(parameters, sys, nom, up,down);
        }
        if (symmetrizeMaxBins) {
          isSymmetrizedBins = processHistoSys_systsToSymmetrizeMaxBins(parameters, sys, nom, up, down);
        }
        if (forceSymmetrizeMaxBins) {
          isSymmetrizedBins = processHistoSys_systsToSymmetrizeMaxBins(parameters, sys, nom, up, down, true);
        }

        // 3. pruning
        for (auto var: {up,down}) {
          if (!var) continue;
          // check for flatness and cut off
          TH1* ratio = TQHistogramUtils::getRelativeVariationHistogram(var, nom, 1e-9);
          if(ratio){
            if(!TQHistogramUtils::isEmpty(ratio,0.001,1.)){
              if (pruneBasedOnFlatness && isFlat) {
                isFlat = processHistoSys_isFlat(parameters, sys, ratio);
              }
              if (pruneBasedOnCutOff && !isCutOff) {
                isCutOff = processHistoSys_checkCutoff(parameters, ratio);
              }
            } 
            delete ratio;
          } else {
            if(verbose) std::cout<<TString::Format("Failed to obtain ratio histogram for histoSys '%s' of sample '%s'", sys->GetName(), sys->getBase()? sys->getBase()->GetName() : "<none>" ).Data()<<std::endl;
          }          
        }
      }

      // ---------------- Set Status ----------------------
      if (isSymmetrizedBins) {
        status = TQSystematics::SYMMETRIZED;
        if(verbose) std::cout<<TString::Format("Shape had bin with up and down variation going in the same direction for syst '%s', sample '%s', region '%s'",sys->GetName(),sys->getBase()? sys->getBase()->GetName() : "<none>", sys->getBase() && sys->getBase()->getBase() ? sys->getBase()->getBase()->GetName() : "<none>").Data()<<std::endl;
      }
      if (isSmoothed) {
        status = TQSystematics::SMOOTHED;
        if (verbose) std::cout<<TString::Format("Shape has been smoothed for syst '%s', sample '%s', region '%s'",sys->GetName(),sys->getBase()? sys->getBase()->GetName() : "<none>", sys->getBase() && sys->getBase()->getBase() ? sys->getBase()->getBase()->GetName() : "<none>").Data()<<std::endl;
      }       
      // need to add condition whether "flatness pruning" was considered because the default of isFlat is true;
      if (isFlat && pruneBasedOnFlatness) {
        if (verbose) std::cout<<TString::Format("Shape has been pruned because no significant shape was found: syst '%s', sample '%s', region '%s'",sys->GetName(),sys->getBase()? sys->getBase()->GetName() : "<none>", sys->getBase() && sys->getBase()->getBase() ? sys->getBase()->getBase()->GetName() : "<none>").Data()<<std::endl;
        status = TQSystematics::INSIGNIFICANT;
      }
      if (isCutOff) {
        status = TQSystematics::OVERSHOOT;
        if(verbose) std::cout<<TString::Format("Shape seems artifical for syst '%s', sample '%s', region '%s'",sys->GetName(),sys->getBase()? sys->getBase()->GetName() : "<none>", sys->getBase() && sys->getBase()->getBase() ? sys->getBase()->getBase()->GetName() : "<none>").Data()<<std::endl;
      }
    }
  }
  
  //after all pruning variants are done, check the systematic status
  sys->setTagInteger("Status",status);
  if (status == TQSystematics::INSIGNIFICANT || status == TQSystematics::OVERSHOOT || status == TQSystematics::DROPPED) {
    return false;
  }

  return true;
}

//__________________________________________________________________________________|___________

namespace {
  inline double sgn(double x){
    return x<0?-1:+1;
  }
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::isProtectedSys(TQFolder* sys, TQTaggable* parameters, const TString& prefix) const {
  // checks if a systematic should be extempt from some treatment
  // 'select.tag'/'select.name' specifies whitelist(s) for systematics that some treatment should be applied to
  // 'except.tag'/'except.name' specifies blacklist(s) for systematics that some treatment should NOT be applied to
  TQTaggable paramLocal;
  paramLocal.importTagsWithoutPrefix(parameters,prefix);
  bool passedWhiteList = true; //if no whitelisting is present this will stay unchanged
  bool failedBlackList = false;
  //check for whitelisted tags
  std::vector<TString> whiteListTags = paramLocal.getTagVString("select.tag");
  if (paramLocal.hasTag("select.tag")) whiteListTags.push_back(paramLocal.getTagStringDefault("select.tag"));
  for (auto key:whiteListTags) {
    passedWhiteList = sys->getTagBoolDefault(key,false); //unless we find a match this will not pass selection criteria
    if (passedWhiteList) break;
  }
  if (!passedWhiteList) return true; //if we didn't match any entry on the white list (given it exists) this systematic is not selected, i.e., protected

  //check for white listed names
  std::vector<TString> whiteListNames = paramLocal.getTagVString("select.name");
  if (paramLocal.hasTag("select.name")) whiteListNames.push_back(paramLocal.getTagStringDefault("select.name"));
  for (auto pattern:whiteListNames) {
    passedWhiteList = TQStringUtils::matches(sys->GetName(),pattern); //unless we find a match this will not pass selection criteria
    if (passedWhiteList) break;
  }
  if (!passedWhiteList) return true; //if we didn't match any entry on the white list (given it exists) this systematic is not selected, i.e., protected

  //check for black listed tags
  std::vector<TString> blackListTags = paramLocal.getTagVString("except.tag");
  if (paramLocal.hasTag("except.tag")) whiteListTags.push_back(paramLocal.getTagStringDefault("except.tag"));
  for (auto key:blackListTags) {
    failedBlackList = sys->getTagBoolDefault(key,false); //unless we find a match this will not pass selection criteria
    if (failedBlackList) return true; //if this systematic is black listed we can already say that it's proteced from the treatment
  }

  //check for black listed names
  std::vector<TString> blackListNames = paramLocal.getTagVString("except.name");
  if (paramLocal.hasTag("except.name")) whiteListNames.push_back(paramLocal.getTagStringDefault("except.name"));
  for (auto pattern:blackListNames) {
    failedBlackList = TQStringUtils::matches(sys->GetName(),pattern); //unless we find a match this will not pass selection criteria
    if (failedBlackList) return true;
  }

  //if neither black lists are matched nor (existing) whitelist are failed this systematic is eligible for the treatment, i.e., not protected
  return false;
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::processOverallSys(TQTaggable* parameters, TQFolder* sys){
  // process the overall systematics, applying pruning and symmetrization
  
  // retrieve some global parameters
  Double_t sysRelMin       = parameters->getTagDoubleDefault("SysRelMin", -1.);
  Double_t sysRelThreshold = parameters->getTagDoubleDefault("SysRelThreshold", -1.);
  Double_t sysRelCutoff    = parameters->getTagDoubleDefault("SysRelCutoff", -1.);
  Double_t sysRelCap       = parameters->getTagDoubleDefault("SysRelCap", -1.);
  Double_t sysRelZero      = parameters->getTagDoubleDefault("SysRelZero", 2*std::numeric_limits<double>::epsilon());
  Double_t sysSigMin       = parameters->getTagDoubleDefault("SysSigMin", -1.);
  Double_t sysAsymLimit    = -1.;
  bool hasSysAsymLimit     = parameters->getTagDouble("SysAsymLimit",sysAsymLimit);
  if (sysAsymLimit>=1.) throw std::runtime_error("Illegal value for tag 'SysAsymLimit', must be smaller than 1.0");

  double ratio_Down     = sys->getTagDoubleDefault("Low", 1);
  double ratio_Up       = sys->getTagDoubleDefault("High", 1);
  double ratio_Down_Err = sys->getTagDoubleDefault("LowErr", 0);
  double ratio_Up_Err   = sys->getTagDoubleDefault("HighErr", 0);

  const double signifUp   = fabs(ratio_Up-1.)/ratio_Up_Err;
  const double signifDown = fabs(ratio_Down-1.)/ratio_Down_Err;

  TString symmode = parameters->getTagStringDefault("SysSymmetrizationMode","envelope");
  bool verbose = parameters->getTagBoolDefault("verbose",
#ifdef _DEBUG_
                                               true
#else
                                               false
#endif
                                               );

  TString sysname,samplename,regionname;
  if(verbose){
    sysname    = sys->getTagStringDefault("~Systematic",sys->GetName());
    samplename = sys->getTagStringDefault("~Sample",sys->getBase() ? sys->getBase()->GetName() : "<none>");
    regionname = sys->getTagStringDefault("~Channel",sys->getBase() && sys->getBase()->getBase() ? sys->getBase()->getBase()->GetName() : "<none>");
  }

  Bool_t dropOverallSys = false;
  TQSystematics::Status status = TQSystematics::ACTIVE;
  
  // first process all fixes and then process the "drop" stati or symmetrize

  // @tag: [SysRelMin] Variations below a certain minimum (sysRelMin) are cast to 1.
  if (sysRelMin > 0. && TQHistogramUtils::isCloseToOneRel(ratio_Up, sysRelMin) && !isProtectedSys(sys,parameters,"SysRelMin.")) {
    if(verbose) std::cout<<"OverallSys '"<<sysname<<"' for sample '"<<samplename<<"' in region '"<<regionname<<"' is close to one for the up variation with sysRelMin threshold "<<sysRelMin<<" (up: "<<ratio_Up<<")"<<std::endl;
    ratio_Up = 1.;
    status = TQSystematics::FIXED;
  }
  if (sysRelMin > 0 && TQHistogramUtils::isCloseToOneRel(ratio_Down, sysRelMin) && !isProtectedSys(sys,parameters,"SysRelMin.") ) {
    if(verbose) std::cout<<"OverallSys '"<<sysname<<"' for sample '"<<samplename<<"' in region '"<<regionname<<"' is close to one for the down variation with sysRelMin threshold "<<sysRelMin<<" (down: "<<ratio_Down<<")"<<std::endl;
    ratio_Down = 1.;
    status = TQSystematics::FIXED;
  }
  // @tag: [SysRelCap] variations above a certain maximum (sysRelCap) are cast to maximum threshold.
  if ((sysRelCap > 0.)
      && !TQHistogramUtils::isCloseToOneRel(ratio_Up, sysRelCutoff)
      && !isProtectedSys(sys,parameters,"SysRelCap.")) {
    if(verbose) std::cout<<"OverallSys '"<<sysname<<"' for sample '"<<samplename<<"' in region '"<<regionname<<"' exceeds sysRelCap threshold "<<sysRelCap<<" (up: "<<ratio_Up<<")"<<std::endl;
    ratio_Up = ratio_Up > ratio_Down ? (1+sysRelCap) : (1/(1+sysRelCap));
    //if(verbose) std::cout<<"ratio_Up set to "<<ratio_Up<<" (ratio_Down="<<ratio_Down<<")"<<std::endl;
    status = TQSystematics::FIXED;
  }
  if ((sysRelCap > 0.)
      && !TQHistogramUtils::isCloseToOneRel(ratio_Down, sysRelCutoff)
      && !isProtectedSys(sys,parameters,"SysRelCap.")) {
    if(verbose) std::cout<<"OverallSys '"<<sysname<<"' for sample '"<<samplename<<"' in region '"<<regionname<<"' exceeds sysRelCap threshold "<<sysRelCap<<" (down: "<<ratio_Down<<")"<<std::endl;
    ratio_Down = ratio_Down > ratio_Up ? (1+sysRelCap) : (1/(1+sysRelCap));
    //if(verbose) std::cout<<"ratio_Down set to "<<ratio_Down<<" (ratio_Up="<<ratio_Up<<")"<<std::endl;
    status = TQSystematics::FIXED;
  }

  if((sysRelZero > 0.)
     && TQHistogramUtils::isCloseToOneRel(ratio_Up, sysRelZero)
     && TQHistogramUtils::isCloseToOneRel(ratio_Down, sysRelZero)
     && !isProtectedSys(sys,parameters,"SysRelZero.") ){
    // @tag: [SysRelZero] drop OverallSys if variation does NOT exceed a certain threshold (sysRelZero)
    if(verbose) std::cout<<"OverallSys '"<<sysname<<"' for sample '"<<samplename<<"' in region '"<<regionname<<"' is close to one with threshold "<<sysRelZero<<" (up: "<<ratio_Up<<", down: "<<ratio_Down<<")"<<std::endl;
    dropOverallSys = true;
    status = TQSystematics::ZERO;
  } else if((sysRelThreshold > 0.)
            && TQHistogramUtils::isCloseToOneRel(ratio_Up, sysRelThreshold)
            && TQHistogramUtils::isCloseToOneRel(ratio_Down, sysRelThreshold)
            && !isProtectedSys(sys,parameters,"SysRelThreshold.") ){
    // @tag: [SysRelThreshold] drop OverallSys if variation does NOT exceed a certain threshold (sysRelThreshold)
    if(verbose) std::cout<<"OverallSys '"<<sysname<<"' for sample '"<<samplename<<"' in region '"<<regionname<<"' is close to one with threshold "<<sysRelThreshold<<" (up: "<<ratio_Up<<", down: "<<ratio_Down<<")"<<std::endl;
    dropOverallSys = true;
    status = TQSystematics::DROPPED;
  } else if ((sysRelCutoff > 0.)
             && (!TQHistogramUtils::isCloseToOneRel(ratio_Up, sysRelCutoff)
                 || !TQHistogramUtils::isCloseToOneRel(ratio_Down, sysRelCutoff))
             && !isProtectedSys(sys,parameters,"SysRelCutoff.")) {
    // @tag: [SysRelCutoff] drop OverallSys if variation DOES exceed a certain threshold (sysRelCutoff)
    if(verbose) std::cout<<"OverallSys '"<<sysname<<"' for sample '"<<samplename<<"' in region '"<<regionname<<"' exceeds sysRelCutoff threshold "<<sysRelCutoff<<" (up: "<<ratio_Up<<", down: "<<ratio_Down<<")"<<std::endl;
    status = TQSystematics::OVERSHOOT;
    dropOverallSys = true;
  } else if ( sysSigMin>0.
              && ( ratio_Up_Err>0 && signifUp < sysSigMin )
              && ( ratio_Down_Err>0. && signifDown < sysSigMin )
              && !isProtectedSys(sys,parameters,"SysSigMin.")) {
    // @tag: [SysSigMin] ]drop OverallSys if error on variation DOES exceed a certain threshold (sysSigMin)
    if(verbose) std::cout<<"OverallSys '"<<sysname<<"' for sample '"<<samplename<<"' in region '"<<regionname<<"' has a variation uncertainty larger than SysSigMin  threshold "<<sysSigMin<<" (up_err: "<<ratio_Up_Err<<", down_err: "<<ratio_Down_Err<<")"<<std::endl;
    status = TQSystematics::INSIGNIFICANT;
    dropOverallSys = true;
  } else if (hasSysAsymLimit && !isProtectedSys(sys,parameters,"SysAsymLimit.")) {
    //symmetrize systematic if too asymmetric or even one-sided (only if limit is explicitly set!)
    double deltaUp = ratio_Up-1.;
    double deltaDown = ratio_Down-1.;
    double sign = sgn( signifUp > signifDown ? deltaUp : -deltaDown);//determine the sign of the systematic based on the most significant variation
    if ( (std::min( fabs(deltaUp/deltaDown), fabs(deltaDown/deltaUp)) < sysAsymLimit) || (deltaDown*deltaUp>0.) ){
      if(verbose) std::cout<<"OverallSys '"<<sysname<<"' for sample '"<<samplename<<"' in region '"<<regionname<<"' is being symmetrized with mode "<<symmode.Data()<<" (up: "<<ratio_Up<<", down: "<<ratio_Down<<")"<<std::endl;
      if(symmode.CompareTo("envelope",TString::kIgnoreCase) == 0){ //take the larger of the two variations, use it as a symmetric uncertainty
        // a.k.a. "Michael's method"
        double deltaSym = std::max(std::abs(deltaUp),std::abs(deltaDown));
        ratio_Up = 1 + sign*deltaSym;
        ratio_Down = 1 - sign*deltaSym;
        status = TQSystematics::SYMMETRIZED;
      } else if(symmode.CompareTo("drop",TString::kIgnoreCase) == 0){ //simply remove the too asymmetric (or one sided) systematic
        // drop all single sided
        dropOverallSys = true;
        status = TQSystematics::DROPPED;
      } else if(symmode.CompareTo("average",TString::kIgnoreCase) == 0){ //use the average deviation from unity
        // average
        double deltaSym = 0.5*(std::abs(deltaUp)+std::abs(deltaDown));
        ratio_Up = 1 + sign*deltaSym;
        ratio_Down = 1 - sign*deltaSym;
        status = TQSystematics::SYMMETRIZED;
      } else if(symmode.CompareTo("shift",TString::kIgnoreCase) == 0){ //shift up and down variations such that their avaerage is 1.0
        // a.k.a. "Monica's method"
        double mean = 0.5*(deltaUp+deltaDown);
        //"sign" is based on the more significant variation, here we only care about their nominal (original) value!
        ratio_Up = 1+deltaUp-mean;
        ratio_Down = 1+deltaDown-mean;
        status = TQSystematics::SYMMETRIZED;
      } else if(symmode.CompareTo("squaresum",TString::kIgnoreCase) == 0){
        // do we need this?
        double deltaSym = sqrt(std::pow(deltaUp,2.)+std::pow(deltaDown,2.));
        ratio_Up = 1 + sign*deltaSym;
        ratio_Down = 1 - sign*deltaSym;
        status = TQSystematics::SYMMETRIZED;
      } else {
        error(TString::Format("unknown symmetrization mode: '%s'",symmode.Data()));
      }
    }
  } else if(((ratio_Up < 1 && ratio_Down < 1) || (ratio_Up > 1 && ratio_Down > 1))){ //no protection here since only a label (enum) is asigned
    status = TQSystematics::ONESIDED;
  }

  if(verbose) std::cout<<"OverallSys '"<<sysname<<"' for sample '"<<samplename<<"' in region '"<<regionname<<"' done (up: "<<ratio_Up<<", down: "<<ratio_Down<<", status: "<<status<<")"<<std::endl;

  double variation = std::max(fabs(ratio_Up-1.),fabs(ratio_Down-1.));
  sys->setTagDouble("Low", ratio_Down);
  sys->setTagDouble("High", ratio_Up);
  sys->setTagDouble("LowErr", ratio_Down_Err);
  sys->setTagDouble("HighErr", ratio_Up_Err);
  sys->setTagInteger("Status", status);
  sys->setTagDouble("Percent", 100.*variation);
  return !dropOverallSys;
}


//__________________________________________________________________________________|___________

TH1 * TQSystematicsManager::getVarHisto(const TString& nameVariation, const TString& nameChannel, const TString& nameSample, bool verbose) {
  // attempt to obtain a histogram from the folder
  TH1* hist = dynamic_cast<TH1*>(this->repository()->getObject(nameSample,TQFolder::concatPaths(this->varPrefix, nameVariation, nameChannel)));
  if (verbose && !hist){
    error(TString::Format("getVarHisto(...): Failed to find histogram '%s' for variation '%s' in channel '%s'",nameSample.Data(),nameVariation.Data(),nameChannel.Data()));
  }
  return hist;  
}

//__________________________________________________________________________________|___________

TH1 * TQSystematicsManager::getVarHisto(const TString& path, bool verbose) {
  // attempt to obtain a histogram from the folder
  return this->getHisto(TQFolder::concatPaths(this->varPrefix, path),verbose);
}

//__________________________________________________________________________________|___________

TH1 * TQSystematicsManager::getSysHisto(const TString& path, bool verbose) {
  // attempt to obtain a histogram from the folder
  return this->getHisto(TQFolder::concatPaths(this->sysPrefix, path),verbose);
}

//__________________________________________________________________________________|___________

TH1 * TQSystematicsManager::getHisto(TString path, bool verbose) {
  // attempt to obtain a histogram from the folder  
  TString name = TQFolder::getPathTail(path);  
  TH1* hist = dynamic_cast<TH1*>(this->repository()->getObject(name,path));
  if (verbose && !hist){
    error(TString::Format("getHisto(...): Failed to find histogram '%s' in '%s'", name.Data(), path.Data()));
  }
  return hist;
}

//__________________________________________________________________________________|___________


bool TQSystematicsManager::isNegligibleSys(TQFolder * sys, TQTaggable* parameters){
  // Pruning based on contribution of sample in channel.
  // If a sample contributes less in the channel than 'threshold' percent of the specified total,
  // the systematic attached to that sample is pruned.
  if(!parameters) return false;
 
  bool verbose = parameters->getTagBoolDefault("verbose",false);
 
  bool prune = false;
  TQSystematics::Status status = TQSystematics::ACTIVE;

  //@tag: [pruneNegligibles.samples, pruneNegligibles.channelFilter] tags to specify which systematics for which samples in what channels should be considered for this contribution based pruning. 'pruneNegligibles.samples' are vectors of strings that correspond to filters samples to consider. The total contribution is calculated from summing up all the samples that match the 'sample' string. The channelFilter is a simple string that should match the channel names to consider (default is all channels). 
  //@tag: [pruneNegligibles.threshold] Threshold to apply for pruning. systematic is pruned if: "yields of single sample" < (threshold * "yields of all samples")
  
  // ----------  Preparation ----------
  double pruneThreshold = parameters->getTagDoubleDefault("pruneNegligibles.threshold", 0.01);
  std::vector<TString> samplesToPrune = parameters->getTagVString("pruneNegligibles.Samples");
  if (samplesToPrune.empty()) {
    ERRORclass("You configured pruning based on contribution but didn't provide any samples to be considered. Please specify a list of samples with the tag 'pruneNegligibles.Samples'");
  }
  TString channelFilter = parameters->getTagStringDefault("pruneNegligibles.channelFilter", "*");

//  std::cout << "==>> Pruning negligibles folder: " << sys->GetName() << std::endl;

  if(!(TQStringUtils::matches(sys->GetName(),"OverallSys*") || TQStringUtils::matches(sys->GetName(),"HistoSys*"))) {

    return prune;

  }

  // systematic that is looped over
  TString sysName = sys->getTagStringDefault("Systematic",sys->GetName());

  
 
//  TQStringUtils::removeLeadingText(sysName,"OverallSys.");
//  TQStringUtils::removeLeadingText(sysName,"HistoSys.");
  

  // sample that is looped over
  TString sampleName = sys->getBase()? sys->getBase()->GetName() : "";
  if (sampleName.IsNull()) {
    WARNclass("Pruning based on contribution has been configured but sample name of sample that is currently looped over couldn't be found! Skipping...");
    return false;
  } else {
    sampleName.ReplaceAll("Sample.", "");
  }
//  std::cout << "> Sample: " << sampleName <<  std::endl;
 
  // channel that is looped over
  TString channelName = sys->getBase()->getBase() ? sys->getBase()->getBase()->GetName() : "";
  if (channelName.IsNull()) {
    WARNclass("Pruning based on contribution has been configured but region name of channel that is currently looped over couldn't be found! Skipping...");
    return false;
  } else {
    channelName.ReplaceAll("Channel.", "");
  }

//  std::cout << "> Channel: " << channelName <<  std::endl;
  
  // check if channel that is looped over is configured for pruning
  if (!TQStringUtils::matches(channelName, channelFilter)) {
    return false;
  }

  for (auto sampleToPruneFilter : samplesToPrune) {
  
    // check if sample that is looped over is configured for pruning
    // prevents that syst is accidentally pruned based on contribution of completely independent samples
    if (!TQStringUtils::matches(sampleName, sampleToPruneFilter)) continue;
//    std::cout << "> Sample in pruning list, matches " << sampleToPruneFilter <<  std::endl; 
   
    // ----------  Get Histograms ----------
    // Get total yields based on sampleFilter
    double totalIntegral = 0;
    TQFolderIterator samplesToAddItr(sys->getBase()->getBase()->getListOfFolders("Sample."+sampleToPruneFilter));
    while(samplesToAddItr.hasNext()) {
      TQFolder* sample = samplesToAddItr.readNext();
      TString sampleToAddName = sample->GetName();
      sampleToAddName.ReplaceAll("Sample.", "");
      TString histPath = TQFolder::concatPaths("Nominal", channelName, sampleToAddName);
      TH1 *tmp_hist = dynamic_cast<TH1*>(this->repository()->getObject(histPath));
      if (tmp_hist) {
        totalIntegral += tmp_hist->Integral(0, tmp_hist->GetNbinsX()+1);
      } else {
        WARNclass("Couldn't find histogram with path '%s'", histPath.Data());
        continue;
      }
    }
    // Check contribution of currently looped over sample in region
    TString histPathSingle = TQFolder::concatPaths("Nominal", channelName, sampleName);
    TH1 *histSingle = dynamic_cast<TH1*>(this->repository()->getObject(histPathSingle));
    double singleIntegral;
    if (histSingle) {
      singleIntegral = histSingle->Integral(0, histSingle->GetNbinsX()+1);
    } else {
      WARNclass("Couldn't find histogram with path '%s'", histPathSingle.Data());
      continue;
    }

    if (totalIntegral > 0 && singleIntegral > 0) {
      if (singleIntegral < (pruneThreshold * totalIntegral) ) {
        // the channel that is looped over exhibits a negligible contribution from the current sample that is looped over and the systematic that is looped over is configured for pruning. So => prune this!
        status = TQSystematics::DROPPED;
        prune = true;
      }
      // }
    } 
  }

  sys->setTagInteger("Status", status);
  if (prune) {sys->setTagString("Message", "Pruned based on (negligible) contribution");}
  if(prune && verbose) {
      std::cout << "Pruning negligible: Systematic " << sys->GetName() << " for sample " << sampleName << " in channel " << channelName;
      std::cout << " is pruned" <<  std::endl;
  }
  return prune;
}


//__________________________________________________________________________________|___________

TH1* TQSystematicsManager::computeHistogramVariation(TQFolder* computeFolder, const TString& nameChannel, const TString& nameSample){
  // compute the variation based on the information in the computeFolder
  //@tag: [Mode] mode used for the computation of the Up/Down variations from the input variations. Possible values include: single,difference,minimum,maximum,envelope,stddev,hessian
  //@tag: [Variations] list of input variations to use for the computation of the Up/Down variations
  //@tag: [Baseline] baseline variation to be used (default: Nominal)
  //@tag: [StatError] stat error histogram to be used
  //@tag: [Direction] direction of this variation (+1 for Up, -1 for Down)
  //@tag: [Scale] scale up or down this variation by some arbitrary factor
  //@tag: [TransferRelative] transfer relative variation instead of absolute (default: true)
  /* @tag[Smoothing.SmoothBins]: A vector of integers specifying the bin boundaries to be used for
     calculating the relative variation between nominal and a variation. This relative variation
     is applied to the nominal histogram to get the smoothed variation.
     Example: Given a nominal histogram with 7 bins and the following tag applied Smoothing.SmoothBins={1, 2, 3, 5, 8} 
     means the relative variation would be calculated for the last 3 bins merged, that is, the sum of bin 5, 6, 7 
     for nominal (Nom_567) and the variation (Var_567) is taken and the smoothed variational histogram 
     bins will become:  Var_5 = Var_567/Nom_567*Nom_5, Var_6=Var_567/Nom_567*Nom_6, ... */
  
  TH1* hist = NULL;
  std::vector<TString> varList = computeFolder->getTagVString("Variations");
  const TH1* h_Nominal = this->getVarHisto("Nominal", nameChannel, nameSample);

  // mode  
  TString mode_Compute = computeFolder->getTagStringDefault("Mode","");

  // baseline histogram  
  TString varBaseline = computeFolder->getTagStringDefault("Baseline","Nominal");
  bool ownBaseline = false;
  if(varBaseline.IsNull() && emitError()){
    if(emitError()) ERRORclass("cannot compute variation '%s' without baseline!",computeFolder->getTagStringDefault("~Systematic","<unknown>").Data());
    return NULL;
  }
  const TH1* h_Baseline = this->getVarHisto(varBaseline, nameChannel, nameSample);
  DEBUGclass("obtained baseline histogram '%s' with integral '%g' for channel '%s' and sample '%s'",varBaseline.Data(),TQHistogramUtils::getIntegral(h_Baseline),nameChannel.Data(),nameSample.Data());

  std::vector<int>  smoothedBinning = computeFolder->getTagVInteger("~Smoothing.SmoothBins");
  if (!smoothedBinning.empty() && h_Baseline) {
    h_Baseline = TQHistogramUtils::getSmoothedManually(h_Baseline, smoothedBinning);
    ownBaseline = true;
  }

  // error histogram  
  TString nameError = computeFolder->getTagStringDefault("StatError","");
  TH1* h_StatError = nameError.IsNull() ? NULL : this->getVarHisto(nameError, nameChannel, nameSample);

  // +/- flip direction  
  int val_Direction = computeFolder->getTagIntegerDefault("Direction",1);
  bool relative = computeFolder->getTagBoolDefault("TransferRelative",true);
  if (abs(val_Direction)!=1) {
    WARNclass("Systematic variation direction must be +/-1, ignoring");
    val_Direction = 1;
  }
  // scale the computed variation by some amount (eg. 0.5 for alpha_s uncertainties)
  double val_Scale = fabs(computeFolder->getTagDoubleDefault("Scale",1.0));

  // perform computation  
  if (varList.size()) {
    TObjArray* hList_Var = new TObjArray();
    for (auto nameVar: varList) {
      if(nameVar.IsNull()){
        if(emitError()) ERRORclass("unable to obtain variation without name!");
        continue;
      }
      TH1* h = this->getVarHisto(nameVar, nameChannel, nameSample);
      if (!smoothedBinning.empty() && h) {
        h = TQHistogramUtils::getSmoothedManually(h, smoothedBinning);
      }
      if(h){
        DEBUGclass("obtained variation histogram '%s' with integral '%g' for channel '%s' and sample '%s'",nameVar.Data(),TQHistogramUtils::getIntegral(h),nameChannel.Data(),nameSample.Data());      
        hList_Var->Add(h);
      } else {
        if(emitError()) ERRORclass("failed to obtain variation histogram '%s' for channnel '%s' and sample '%s'",nameVar.Data(),nameChannel.Data(),nameSample.Data());
      }
    }
    
    // variation computer
    HistogramVariationComputer varsProcessor(h_Baseline);
    // check for consistency between variations & baseline
    for (int ivar=0 ; ivar<hList_Var->GetEntries() ; ++ivar) {
      TH1* h_Var = dynamic_cast<TH1*>(hList_Var->At(ivar));
      if(!TQHistogramUtils::checkConsistency(h_Var,h_Baseline)) {
        if(emitError()) ERRORclass("Inconsistent histograms between variation and baseline");
        return NULL;
      }
      if(h_Nominal && !TQHistogramUtils::checkConsistency(h_Var,h_Nominal)) {
        if(emitError()) ERRORclass("Inconsistent histograms between variation and nominal");
        return NULL;        
      }
    }
    bool computed = varsProcessor.computeVariation(hList_Var,mode_Compute);
    if (!computed) {
      if(emitError()) ERRORclass("Failed to compute '%s'",mode_Compute.Data());
      return NULL;      
    }
    // manually use errors from an existing variation
    if (h_StatError) varsProcessor.useStatError(h_StatError,relative);
    // set result
    hist = varsProcessor.applyVariation(h_Nominal,val_Scale*val_Direction,relative);

    delete hList_Var;
  } else {
    if(mode_Compute == "Slope"){
      hist = TQHistogramUtils::copyHistogram(h_Baseline);
      TQHistogramUtils::applySlopeToHistogram(hist,computeFolder->getTagDoubleDefault("slope",0.));
    } else if(mode_Compute == "Norm"){
      hist = TQHistogramUtils::copyHistogram(h_Baseline);
    }
    double randomness = 0.;
    hist->Scale(computeFolder->getTagDoubleDefault("scale",1.));
    if(computeFolder->getTagDouble("randomize",randomness)){
      TQHistogramUtils::rerollGauss(hist,randomness);
    }
  }
  if (ownBaseline) delete h_Baseline;
  
  return hist;
}

//__________________________________________________________________________________|___________

TH1* TQSystematicsManager::normalizeShapeVariation(const TH1* h_Var, const TH1* h_Nominal, const TH1* h_Sym) {
  // normalize histogram variation to get shape variation
  if(!h_Nominal) return NULL;
  TH1* shape_Var = NULL;
  if (h_Var) {
    shape_Var = TQHistogramUtils::copyHistogram(h_Var);
    TQHistogramUtils::normalize(shape_Var, h_Nominal, false);
  } else if(h_Sym){ // symmetrize if needed
    shape_Var = TQHistogramUtils::copyHistogram(h_Sym);
    TQHistogramUtils::normalize(shape_Var, h_Nominal, false);
    TQHistogramUtils::addHistogramWithoutError(shape_Var, h_Nominal, -2.);
    TQHistogramUtils::scaleHistogram(shape_Var, -1.);
    TQHistogramUtils::ensureMinimumBinContent(shape_Var, 1e-12, true);
    TQHistogramUtils::normalize(shape_Var, h_Nominal, false);
  }
  return shape_Var;
}

//__________________________________________________________________________________|___________

void TQSystematicsManager::setSystematicPrefix(const TString& prefix){
  // set the prefix of all systematics histogram to use in the repository
  this->sysPrefix = prefix;
}

//__________________________________________________________________________________|___________

void TQSystematicsManager::setVariationPrefix(const TString& prefix){
  // set the prefix of all variations histogram to use in the repository  
  this->varPrefix = prefix;
}

//__________________________________________________________________________________|___________

TString TQSystematicsManager::storeSysHisto(TH1 * histo, const TString& nameVariation, const TString& direction, const TString& nameChannel) {
  // store a variation (input) histogram  
  return this->storeSysHisto(histo,TQFolder::concatPaths(nameVariation, direction, nameChannel));
}


//__________________________________________________________________________________|___________

TString TQSystematicsManager::storeVarHisto(TH1 * histo, const TString& nameVariation, const TString& nameChannel) {
  // store a variation (input) histogram
  return this->storeVarHisto(histo,TQFolder::concatPaths(nameVariation,nameChannel));
}

//__________________________________________________________________________________|___________

TString TQSystematicsManager::storeSysHisto(TH1 * histo, const TString& path) {
  // store a systematic (output) histogram  
  if (!histo) return "";  
  if (!this->repository()->addObject(histo, TQFolder::concatPaths(this->sysPrefix,path) + "+")) {
    error(TString::Format("storeShapeVariation(...): Failed to set histogram '%s' in path '%s'", histo->GetName(),path.Data()));
    return "";
  }
  return TQFolder::concatPaths(this->sysPrefix, path, histo->GetName());
}

//__________________________________________________________________________________|___________

TString TQSystematicsManager::storeVarHisto(TH1 * histo, const TString& path) {
  // store a variation (input) histogram  
  if (!histo) return "";
  if (!this->repository()->addObject(histo, TQFolder::concatPaths(this->varPrefix,path) + "+")) {
    error(TString::Format("storeHistogramVariation(...): Failed to set histogram '%s' in path '%s'", histo->GetName(), path.Data()));
    return "";
  }
  return TQFolder::concatPaths(this->varPrefix, path, histo->GetName());
}

//__________________________________________________________________________________|___________

void TQSystematicsManager::magnifyShapeVariation(TH1*& shape_Var,  const TH1 * h_Nominal, Double_t magn) {
  // magnify a variation by an exponent
  TH1 * h_ratio = TQHistogramUtils::copyHistogram(shape_Var);
  h_ratio->Divide(h_Nominal);
  TQHistogramUtils::power(h_ratio, magn);
  h_ratio->Multiply(h_Nominal);
  delete shape_Var;
  shape_Var = h_ratio;
  TQHistogramUtils::normalize(shape_Var, h_Nominal);
}



//__________________________________________________________________________________|___________

void TQSystematicsManager::info(TString message) {
  // print an info message
  std::cout << "SFramework/TQSystematicsManager: " << message.Data() << std::endl;
}


//__________________________________________________________________________________|___________

void TQSystematicsManager::error(TString message) {
  // print a red error message
  info(TQStringUtils::makeBoldRed(TString("ERROR: ") + message));
}


//__________________________________________________________________________________|___________

void TQSystematicsManager::warn(TString message) {
  // print a yellow warning message
  info(TQStringUtils::makeBoldYellow(TString("WARNING: ") + message));
}

//__________________________________________________________________________________|___________

TQSystematicsManager::HistogramVariationComputer::HistogramVariationComputer(const TH1* base) :
  fBaseline(base) {}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::HistogramVariationComputer::computeVariation(TObjArray* vars, TString mode) {
  mode.ReplaceAll(" ","");
  mode.ToLower();
  bool deltaComputed = false;
  if (mode.EqualTo("single")) deltaComputed = computeSingle(vars);
  else if (mode.EqualTo("difference")) deltaComputed = computeDifference(vars);
  else if (mode.EqualTo("minimum")) deltaComputed = computeMinimum(vars);
  else if (mode.EqualTo("maximum")) deltaComputed = computeMaximum(vars);
  else if (mode.EqualTo("envelope")) deltaComputed = computeEnvelope(vars);
  else if (mode.EqualTo("stddev")) deltaComputed = computeStdDev(vars);
  else if (mode.EqualTo("hessian")) deltaComputed = computeHessian(vars);
  // if computation failed, set delta to be 0.0,
  // i.e. return exactly nominal
  if (!deltaComputed) {
    if(!fBaseline){
      if(emitError()) ERRORclass("cannot compute variation without baseline!");
      return false;
    }
    fDelta = TQHistogramUtils::copyHistogram(fBaseline);
    TQHistogramUtils::addHistogramWithoutError(fDelta,fBaseline,-1);
    fRelativeDelta = TQHistogramUtils::copyHistogram(fBaseline);
    TQHistogramUtils::divideHistogramWithoutError(fRelativeDelta,fBaseline);
  }
  return deltaComputed;
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::HistogramVariationComputer::computeSingle(TObjArray* vars) {
  if (vars->GetEntries()!=1) {
    if(emitError()) ERRORclass("Exactly 1 variation must be provided");
    return false;
  }
  if(!fBaseline){
    if(emitError()) ERRORclass("cannot compute Single baseline!");
    return false;
  }    
  TH1* var = dynamic_cast<TH1*>(vars->At(0));
  // make deltas

  fDelta = TQHistogramUtils::copyHistogram(var);
  TQHistogramUtils::addHistogramWithoutError(fDelta,fBaseline,-1.0);
  fRelativeDelta = TQHistogramUtils::copyHistogram(fDelta);
  TQHistogramUtils::divideHistogramWithoutError(fRelativeDelta,fBaseline);
  // TODO: Might be useful here to add a flag whether we want to propagate errors or not 
  // TQHistogramUtils::addHistogram(fDelta,fBaseline,-1.0);
  // fRelativeDelta->Divide(fBaseline);
  return true;
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::HistogramVariationComputer::computeDifference(TObjArray* vars) {
  if (vars->GetEntries()!=2) {
    if(emitError()) ERRORclass("Exactly 2 variations must be provided");
    return false;
  }
  TH1* varA = dynamic_cast<TH1*>(vars->At(0));
  TH1* varB = dynamic_cast<TH1*>(vars->At(1));
  // make deltas
  fDelta = TQHistogramUtils::copyHistogram(varA);
  TQHistogramUtils::addHistogram(fDelta,varB,-1.0);
  fRelativeDelta = TQHistogramUtils::copyHistogram(fDelta);
  TQHistogramUtils::divideHistogramWithoutError(fRelativeDelta,fBaseline);
  return true;
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::HistogramVariationComputer::computeMinimum(TObjArray* vars) {
  if(!fBaseline){
    if(emitError()) ERRORclass("cannot compute Minimum without baseline!");
    return false;
  }
  fDelta = TQHistogramUtils::copyHistogram(fBaseline);
  int numBins = TQHistogramUtils::getNbinsGlobal(fBaseline);
  int maxBin = numBins+1;
  int numVars = vars->GetEntries();
  fDelta->Reset();
  for (int ibin=0 ; ibin<maxBin ; ++ibin) {
    double binDelta = fDelta->GetBinContent(ibin);
    double binError = fDelta->GetBinError(ibin);
    for (int ivar=0 ; ivar<numVars ; ++ivar) {
      TH1* thisVar = TQHistogramUtils::copyHistogram(dynamic_cast<TH1*>(vars->At(ivar)));
      double thisBinDelta = thisVar->GetBinContent(ibin)-fBaseline->GetBinContent(ibin);
      if (thisBinDelta < binDelta) {
        binDelta = thisBinDelta;
        binError = thisVar->GetBinError(ibin);
      }
      delete thisVar;
    }
    fDelta->SetBinContent(ibin,binDelta);
    fDelta->SetBinError(ibin,binError);
  }
  fRelativeDelta = TQHistogramUtils::copyHistogram(fDelta);
  TQHistogramUtils::divideHistogramWithoutError(fRelativeDelta,fBaseline);
  return true;
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::HistogramVariationComputer::computeMaximum(TObjArray* vars) {
  if(!fBaseline){
    if(emitError()) ERRORclass("cannot compute Maximum without baseline!");
    return false;
  }
  fDelta = TQHistogramUtils::copyHistogram(fBaseline);
  int numBins = TQHistogramUtils::getNbinsGlobal(fBaseline);
  int maxBin = numBins+1;
  int numVars = vars->GetEntries();
  fDelta->Reset();
  for (int ibin=0 ; ibin<maxBin ; ++ibin) {
    double binDelta = fDelta->GetBinContent(ibin);
    double binError = fDelta->GetBinError(ibin);
    for (int ivar=0 ; ivar<numVars ; ++ivar) {
      TH1* thisVar = TQHistogramUtils::copyHistogram(dynamic_cast<TH1*>(vars->At(ivar)));
      double thisBinDelta = thisVar->GetBinContent(ibin)-fBaseline->GetBinContent(ibin);
      if (thisBinDelta > binDelta) {
        binDelta = thisBinDelta;
        binError = thisVar->GetBinError(ibin);
      }
      delete thisVar;
    }
    fDelta->SetBinContent(ibin,binDelta);
    fDelta->SetBinError(ibin,binError);
  }
  fRelativeDelta = TQHistogramUtils::copyHistogram(fDelta);
  TQHistogramUtils::divideHistogramWithoutError(fRelativeDelta,fBaseline);
  return true;
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::HistogramVariationComputer::computeEnvelope(TObjArray* vars) {
  if(!fBaseline){
    if(emitError()) ERRORclass("cannot compute Envelope without baseline!");
    return false;
  }
  fDelta = TQHistogramUtils::copyHistogram(fBaseline);
  int numBins = TQHistogramUtils::getNbinsGlobal(fBaseline);
  int maxBin = numBins+1;
  int numVars = vars->GetEntries();
  fDelta->Reset();
  for (int ibin=0 ; ibin<maxBin ; ++ibin) {
    double binDelta = 0;
    double binError = 0;
    for (int ivar=0 ; ivar<numVars ; ++ivar) {
      TH1* thisVar = dynamic_cast<TH1*>(vars->At(ivar));
      double thisBinDelta = fabs(thisVar->GetBinContent(ibin)-fBaseline->GetBinContent(ibin));
      if (thisBinDelta > binDelta) {
        binDelta = thisBinDelta;
        binError = thisVar->GetBinError(ibin);
      }
    }
    fDelta->SetBinContent(ibin,binDelta);
    fDelta->SetBinError(ibin,binError);
  }
  fRelativeDelta = TQHistogramUtils::copyHistogram(fDelta);
  TQHistogramUtils::divideHistogramWithoutError(fRelativeDelta,fBaseline);
  return true;
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::HistogramVariationComputer::computeStdDev(TObjArray* vars) {
  // +/- delta to apply to nominal
  if(!fBaseline){
    if(emitError()) ERRORclass("cannot compute StdDev without baseline!");
    return false;
  }  
  fDelta = TQHistogramUtils::copyHistogram(fBaseline);
  fDelta->Reset();
  TH1* iDelta = TQHistogramUtils::copyHistogram(fBaseline);
  iDelta->Reset();
  int numVars = vars->GetEntries();
  for (int ivar=0 ; ivar<numVars ; ++ivar) {
    iDelta->Reset();
    TQHistogramUtils::addHistogram(iDelta,dynamic_cast<TH1*>(vars->At(ivar)));
    TQHistogramUtils::addHistogram(iDelta,fBaseline,-1.0);
    TQHistogramUtils::addHistogramInQuadrature(fDelta,iDelta);
  }
  TQHistogramUtils::scaleHistogram(fDelta,1.0/TMath::Sqrt(numVars));
  fRelativeDelta = TQHistogramUtils::copyHistogram(fDelta);
  TQHistogramUtils::divideHistogramWithoutError(fRelativeDelta,fBaseline);
  return true;
}

//__________________________________________________________________________________|___________

bool TQSystematicsManager::HistogramVariationComputer::computeHessian(TObjArray* vars) {
  if(!fBaseline){
    if(emitError()) ERRORclass("cannot compute Hessian without baseline!");
    return false;
  }
  fDelta = TQHistogramUtils::copyHistogram(fBaseline);
  fDelta->Reset();
  TH1* iDelta = TQHistogramUtils::copyHistogram(fBaseline);
  iDelta->Reset();
  int numVars = vars->GetEntries();
  for (int ivar=0 ; ivar<numVars ; ++ivar) {
    iDelta->Reset();
    TQHistogramUtils::addHistogram(iDelta,dynamic_cast<TH1*>(vars->At(ivar)));
    TQHistogramUtils::addHistogram(iDelta,fBaseline,-1.0);
    TQHistogramUtils::addHistogramInQuadrature(fDelta,iDelta);
  }
  fRelativeDelta = TQHistogramUtils::copyHistogram(fDelta);
  TQHistogramUtils::divideHistogramWithoutError(fRelativeDelta,fBaseline);
  return true;
}

//__________________________________________________________________________________|___________

void TQSystematicsManager::HistogramVariationComputer::useStatError(TH1* error, bool relative) {
  TH1* tmpDelta = TQHistogramUtils::copyHistogram(error);
  if (relative) {
    // create unity histogram keeping relative errors
    TQHistogramUtils::divideHistogramWithoutError(tmpDelta,tmpDelta);
    // scale to get (1.0*rdel) +/- (rerr*rdel)
    TQHistogramUtils::multiplyHistogramWithoutError(tmpDelta,fRelativeDelta);
    // set result to be the newly-computed histogram taking errors
    fRelativeDelta = tmpDelta;
  } else {
    // create unity histogram keeping absolute errors
    TQHistogramUtils::addHistogramWithoutError(tmpDelta,tmpDelta,-1);
    // add to get (0.0 + delta) +/- error
    TQHistogramUtils::addHistogramWithoutError(tmpDelta,fDelta,+1);
    // set to be the new result
    fDelta = tmpDelta;
  }
}

//__________________________________________________________________________________|___________

TH1* TQSystematicsManager::HistogramVariationComputer::applyVariation(const TH1* nom, double c, bool relative) {
  if(!fBaseline){
    if(emitError()) ERRORclass("cannot apply variation without baseline!");
    return NULL;
  }  
  if (!nom) nom = fBaseline;
  TH1* absDelta;
  if (relative) {
    absDelta = TQHistogramUtils::copyHistogram(fRelativeDelta);
    TQHistogramUtils::scaleHistogram(absDelta,c);    
    TQHistogramUtils::multiplyHistogramWithoutError(absDelta,nom);
    TQHistogramUtils::addHistogramWithoutError(absDelta,nom);
    // TODO: Might be useful to add a flag whether we want to propagate errors or not
    // absDelta->Multiply(nom);
    //TQHistogramUtils::addHistogram(absDelta,nom);
  } else {
    absDelta = TQHistogramUtils::copyHistogram(fDelta);
    TQHistogramUtils::scaleHistogram(absDelta,c);
    TQHistogramUtils::addHistogramWithoutError(absDelta,nom);
  }
  return absDelta;
}

//__________________________________________________________________________________|___________

void TQSystematicsManager::setRepository(TQFolder* histos){
  this->histos = histos;
}

//__________________________________________________________________________________|___________

TQFolder* TQSystematicsManager::repository() {
  if(this->histos){
    return this->histos;
  } else {
    throw std::runtime_error("TQSystematicsManager: used without initialized repository!");
  }
}

//__________________________________________________________________________________|___________

TQSystematicsManager::~TQSystematicsManager(){
  for(auto sf:_inputCache){
    if(sf.second->getTagBoolDefault(".autoLoaded",false)){
      delete sf.second;
    }
  }
}
 TQSystematicsManager.cxx:1
 TQSystematicsManager.cxx:2
 TQSystematicsManager.cxx:3
 TQSystematicsManager.cxx:4
 TQSystematicsManager.cxx:5
 TQSystematicsManager.cxx:6
 TQSystematicsManager.cxx:7
 TQSystematicsManager.cxx:8
 TQSystematicsManager.cxx:9
 TQSystematicsManager.cxx:10
 TQSystematicsManager.cxx:11
 TQSystematicsManager.cxx:12
 TQSystematicsManager.cxx:13
 TQSystematicsManager.cxx:14
 TQSystematicsManager.cxx:15
 TQSystematicsManager.cxx:16
 TQSystematicsManager.cxx:17
 TQSystematicsManager.cxx:18
 TQSystematicsManager.cxx:19
 TQSystematicsManager.cxx:20
 TQSystematicsManager.cxx:21
 TQSystematicsManager.cxx:22
 TQSystematicsManager.cxx:23
 TQSystematicsManager.cxx:24
 TQSystematicsManager.cxx:25
 TQSystematicsManager.cxx:26
 TQSystematicsManager.cxx:27
 TQSystematicsManager.cxx:28
 TQSystematicsManager.cxx:29
 TQSystematicsManager.cxx:30
 TQSystematicsManager.cxx:31
 TQSystematicsManager.cxx:32
 TQSystematicsManager.cxx:33
 TQSystematicsManager.cxx:34
 TQSystematicsManager.cxx:35
 TQSystematicsManager.cxx:36
 TQSystematicsManager.cxx:37
 TQSystematicsManager.cxx:38
 TQSystematicsManager.cxx:39
 TQSystematicsManager.cxx:40
 TQSystematicsManager.cxx:41
 TQSystematicsManager.cxx:42
 TQSystematicsManager.cxx:43
 TQSystematicsManager.cxx:44
 TQSystematicsManager.cxx:45
 TQSystematicsManager.cxx:46
 TQSystematicsManager.cxx:47
 TQSystematicsManager.cxx:48
 TQSystematicsManager.cxx:49
 TQSystematicsManager.cxx:50
 TQSystematicsManager.cxx:51
 TQSystematicsManager.cxx:52
 TQSystematicsManager.cxx:53
 TQSystematicsManager.cxx:54
 TQSystematicsManager.cxx:55
 TQSystematicsManager.cxx:56
 TQSystematicsManager.cxx:57
 TQSystematicsManager.cxx:58
 TQSystematicsManager.cxx:59
 TQSystematicsManager.cxx:60
 TQSystematicsManager.cxx:61
 TQSystematicsManager.cxx:62
 TQSystematicsManager.cxx:63
 TQSystematicsManager.cxx:64
 TQSystematicsManager.cxx:65
 TQSystematicsManager.cxx:66
 TQSystematicsManager.cxx:67
 TQSystematicsManager.cxx:68
 TQSystematicsManager.cxx:69
 TQSystematicsManager.cxx:70
 TQSystematicsManager.cxx:71
 TQSystematicsManager.cxx:72
 TQSystematicsManager.cxx:73
 TQSystematicsManager.cxx:74
 TQSystematicsManager.cxx:75
 TQSystematicsManager.cxx:76
 TQSystematicsManager.cxx:77
 TQSystematicsManager.cxx:78
 TQSystematicsManager.cxx:79
 TQSystematicsManager.cxx:80
 TQSystematicsManager.cxx:81
 TQSystematicsManager.cxx:82
 TQSystematicsManager.cxx:83
 TQSystematicsManager.cxx:84
 TQSystematicsManager.cxx:85
 TQSystematicsManager.cxx:86
 TQSystematicsManager.cxx:87
 TQSystematicsManager.cxx:88
 TQSystematicsManager.cxx:89
 TQSystematicsManager.cxx:90
 TQSystematicsManager.cxx:91
 TQSystematicsManager.cxx:92
 TQSystematicsManager.cxx:93
 TQSystematicsManager.cxx:94
 TQSystematicsManager.cxx:95
 TQSystematicsManager.cxx:96
 TQSystematicsManager.cxx:97
 TQSystematicsManager.cxx:98
 TQSystematicsManager.cxx:99
 TQSystematicsManager.cxx:100
 TQSystematicsManager.cxx:101
 TQSystematicsManager.cxx:102
 TQSystematicsManager.cxx:103
 TQSystematicsManager.cxx:104
 TQSystematicsManager.cxx:105
 TQSystematicsManager.cxx:106
 TQSystematicsManager.cxx:107
 TQSystematicsManager.cxx:108
 TQSystematicsManager.cxx:109
 TQSystematicsManager.cxx:110
 TQSystematicsManager.cxx:111
 TQSystematicsManager.cxx:112
 TQSystematicsManager.cxx:113
 TQSystematicsManager.cxx:114
 TQSystematicsManager.cxx:115
 TQSystematicsManager.cxx:116
 TQSystematicsManager.cxx:117
 TQSystematicsManager.cxx:118
 TQSystematicsManager.cxx:119
 TQSystematicsManager.cxx:120
 TQSystematicsManager.cxx:121
 TQSystematicsManager.cxx:122
 TQSystematicsManager.cxx:123
 TQSystematicsManager.cxx:124
 TQSystematicsManager.cxx:125
 TQSystematicsManager.cxx:126
 TQSystematicsManager.cxx:127
 TQSystematicsManager.cxx:128
 TQSystematicsManager.cxx:129
 TQSystematicsManager.cxx:130
 TQSystematicsManager.cxx:131
 TQSystematicsManager.cxx:132
 TQSystematicsManager.cxx:133
 TQSystematicsManager.cxx:134
 TQSystematicsManager.cxx:135
 TQSystematicsManager.cxx:136
 TQSystematicsManager.cxx:137
 TQSystematicsManager.cxx:138
 TQSystematicsManager.cxx:139
 TQSystematicsManager.cxx:140
 TQSystematicsManager.cxx:141
 TQSystematicsManager.cxx:142
 TQSystematicsManager.cxx:143
 TQSystematicsManager.cxx:144
 TQSystematicsManager.cxx:145
 TQSystematicsManager.cxx:146
 TQSystematicsManager.cxx:147
 TQSystematicsManager.cxx:148
 TQSystematicsManager.cxx:149
 TQSystematicsManager.cxx:150
 TQSystematicsManager.cxx:151
 TQSystematicsManager.cxx:152
 TQSystematicsManager.cxx:153
 TQSystematicsManager.cxx:154
 TQSystematicsManager.cxx:155
 TQSystematicsManager.cxx:156
 TQSystematicsManager.cxx:157
 TQSystematicsManager.cxx:158
 TQSystematicsManager.cxx:159
 TQSystematicsManager.cxx:160
 TQSystematicsManager.cxx:161
 TQSystematicsManager.cxx:162
 TQSystematicsManager.cxx:163
 TQSystematicsManager.cxx:164
 TQSystematicsManager.cxx:165
 TQSystematicsManager.cxx:166
 TQSystematicsManager.cxx:167
 TQSystematicsManager.cxx:168
 TQSystematicsManager.cxx:169
 TQSystematicsManager.cxx:170
 TQSystematicsManager.cxx:171
 TQSystematicsManager.cxx:172
 TQSystematicsManager.cxx:173
 TQSystematicsManager.cxx:174
 TQSystematicsManager.cxx:175
 TQSystematicsManager.cxx:176
 TQSystematicsManager.cxx:177
 TQSystematicsManager.cxx:178
 TQSystematicsManager.cxx:179
 TQSystematicsManager.cxx:180
 TQSystematicsManager.cxx:181
 TQSystematicsManager.cxx:182
 TQSystematicsManager.cxx:183
 TQSystematicsManager.cxx:184
 TQSystematicsManager.cxx:185
 TQSystematicsManager.cxx:186
 TQSystematicsManager.cxx:187
 TQSystematicsManager.cxx:188
 TQSystematicsManager.cxx:189
 TQSystematicsManager.cxx:190
 TQSystematicsManager.cxx:191
 TQSystematicsManager.cxx:192
 TQSystematicsManager.cxx:193
 TQSystematicsManager.cxx:194
 TQSystematicsManager.cxx:195
 TQSystematicsManager.cxx:196
 TQSystematicsManager.cxx:197
 TQSystematicsManager.cxx:198
 TQSystematicsManager.cxx:199
 TQSystematicsManager.cxx:200
 TQSystematicsManager.cxx:201
 TQSystematicsManager.cxx:202
 TQSystematicsManager.cxx:203
 TQSystematicsManager.cxx:204
 TQSystematicsManager.cxx:205
 TQSystematicsManager.cxx:206
 TQSystematicsManager.cxx:207
 TQSystematicsManager.cxx:208
 TQSystematicsManager.cxx:209
 TQSystematicsManager.cxx:210
 TQSystematicsManager.cxx:211
 TQSystematicsManager.cxx:212
 TQSystematicsManager.cxx:213
 TQSystematicsManager.cxx:214
 TQSystematicsManager.cxx:215
 TQSystematicsManager.cxx:216
 TQSystematicsManager.cxx:217
 TQSystematicsManager.cxx:218
 TQSystematicsManager.cxx:219
 TQSystematicsManager.cxx:220
 TQSystematicsManager.cxx:221
 TQSystematicsManager.cxx:222
 TQSystematicsManager.cxx:223
 TQSystematicsManager.cxx:224
 TQSystematicsManager.cxx:225
 TQSystematicsManager.cxx:226
 TQSystematicsManager.cxx:227
 TQSystematicsManager.cxx:228
 TQSystematicsManager.cxx:229
 TQSystematicsManager.cxx:230
 TQSystematicsManager.cxx:231
 TQSystematicsManager.cxx:232
 TQSystematicsManager.cxx:233
 TQSystematicsManager.cxx:234
 TQSystematicsManager.cxx:235
 TQSystematicsManager.cxx:236
 TQSystematicsManager.cxx:237
 TQSystematicsManager.cxx:238
 TQSystematicsManager.cxx:239
 TQSystematicsManager.cxx:240
 TQSystematicsManager.cxx:241
 TQSystematicsManager.cxx:242
 TQSystematicsManager.cxx:243
 TQSystematicsManager.cxx:244
 TQSystematicsManager.cxx:245
 TQSystematicsManager.cxx:246
 TQSystematicsManager.cxx:247
 TQSystematicsManager.cxx:248
 TQSystematicsManager.cxx:249
 TQSystematicsManager.cxx:250
 TQSystematicsManager.cxx:251
 TQSystematicsManager.cxx:252
 TQSystematicsManager.cxx:253
 TQSystematicsManager.cxx:254
 TQSystematicsManager.cxx:255
 TQSystematicsManager.cxx:256
 TQSystematicsManager.cxx:257
 TQSystematicsManager.cxx:258
 TQSystematicsManager.cxx:259
 TQSystematicsManager.cxx:260
 TQSystematicsManager.cxx:261
 TQSystematicsManager.cxx:262
 TQSystematicsManager.cxx:263
 TQSystematicsManager.cxx:264
 TQSystematicsManager.cxx:265
 TQSystematicsManager.cxx:266
 TQSystematicsManager.cxx:267
 TQSystematicsManager.cxx:268
 TQSystematicsManager.cxx:269
 TQSystematicsManager.cxx:270
 TQSystematicsManager.cxx:271
 TQSystematicsManager.cxx:272
 TQSystematicsManager.cxx:273
 TQSystematicsManager.cxx:274
 TQSystematicsManager.cxx:275
 TQSystematicsManager.cxx:276
 TQSystematicsManager.cxx:277
 TQSystematicsManager.cxx:278
 TQSystematicsManager.cxx:279
 TQSystematicsManager.cxx:280
 TQSystematicsManager.cxx:281
 TQSystematicsManager.cxx:282
 TQSystematicsManager.cxx:283
 TQSystematicsManager.cxx:284
 TQSystematicsManager.cxx:285
 TQSystematicsManager.cxx:286
 TQSystematicsManager.cxx:287
 TQSystematicsManager.cxx:288
 TQSystematicsManager.cxx:289
 TQSystematicsManager.cxx:290
 TQSystematicsManager.cxx:291
 TQSystematicsManager.cxx:292
 TQSystematicsManager.cxx:293
 TQSystematicsManager.cxx:294
 TQSystematicsManager.cxx:295
 TQSystematicsManager.cxx:296
 TQSystematicsManager.cxx:297
 TQSystematicsManager.cxx:298
 TQSystematicsManager.cxx:299
 TQSystematicsManager.cxx:300
 TQSystematicsManager.cxx:301
 TQSystematicsManager.cxx:302
 TQSystematicsManager.cxx:303
 TQSystematicsManager.cxx:304
 TQSystematicsManager.cxx:305
 TQSystematicsManager.cxx:306
 TQSystematicsManager.cxx:307
 TQSystematicsManager.cxx:308
 TQSystematicsManager.cxx:309
 TQSystematicsManager.cxx:310
 TQSystematicsManager.cxx:311
 TQSystematicsManager.cxx:312
 TQSystematicsManager.cxx:313
 TQSystematicsManager.cxx:314
 TQSystematicsManager.cxx:315
 TQSystematicsManager.cxx:316
 TQSystematicsManager.cxx:317
 TQSystematicsManager.cxx:318
 TQSystematicsManager.cxx:319
 TQSystematicsManager.cxx:320
 TQSystematicsManager.cxx:321
 TQSystematicsManager.cxx:322
 TQSystematicsManager.cxx:323
 TQSystematicsManager.cxx:324
 TQSystematicsManager.cxx:325
 TQSystematicsManager.cxx:326
 TQSystematicsManager.cxx:327
 TQSystematicsManager.cxx:328
 TQSystematicsManager.cxx:329
 TQSystematicsManager.cxx:330
 TQSystematicsManager.cxx:331
 TQSystematicsManager.cxx:332
 TQSystematicsManager.cxx:333
 TQSystematicsManager.cxx:334
 TQSystematicsManager.cxx:335
 TQSystematicsManager.cxx:336
 TQSystematicsManager.cxx:337
 TQSystematicsManager.cxx:338
 TQSystematicsManager.cxx:339
 TQSystematicsManager.cxx:340
 TQSystematicsManager.cxx:341
 TQSystematicsManager.cxx:342
 TQSystematicsManager.cxx:343
 TQSystematicsManager.cxx:344
 TQSystematicsManager.cxx:345
 TQSystematicsManager.cxx:346
 TQSystematicsManager.cxx:347
 TQSystematicsManager.cxx:348
 TQSystematicsManager.cxx:349
 TQSystematicsManager.cxx:350
 TQSystematicsManager.cxx:351
 TQSystematicsManager.cxx:352
 TQSystematicsManager.cxx:353
 TQSystematicsManager.cxx:354
 TQSystematicsManager.cxx:355
 TQSystematicsManager.cxx:356
 TQSystematicsManager.cxx:357
 TQSystematicsManager.cxx:358
 TQSystematicsManager.cxx:359
 TQSystematicsManager.cxx:360
 TQSystematicsManager.cxx:361
 TQSystematicsManager.cxx:362
 TQSystematicsManager.cxx:363
 TQSystematicsManager.cxx:364
 TQSystematicsManager.cxx:365
 TQSystematicsManager.cxx:366
 TQSystematicsManager.cxx:367
 TQSystematicsManager.cxx:368
 TQSystematicsManager.cxx:369
 TQSystematicsManager.cxx:370
 TQSystematicsManager.cxx:371
 TQSystematicsManager.cxx:372
 TQSystematicsManager.cxx:373
 TQSystematicsManager.cxx:374
 TQSystematicsManager.cxx:375
 TQSystematicsManager.cxx:376
 TQSystematicsManager.cxx:377
 TQSystematicsManager.cxx:378
 TQSystematicsManager.cxx:379
 TQSystematicsManager.cxx:380
 TQSystematicsManager.cxx:381
 TQSystematicsManager.cxx:382
 TQSystematicsManager.cxx:383
 TQSystematicsManager.cxx:384
 TQSystematicsManager.cxx:385
 TQSystematicsManager.cxx:386
 TQSystematicsManager.cxx:387
 TQSystematicsManager.cxx:388
 TQSystematicsManager.cxx:389
 TQSystematicsManager.cxx:390
 TQSystematicsManager.cxx:391
 TQSystematicsManager.cxx:392
 TQSystematicsManager.cxx:393
 TQSystematicsManager.cxx:394
 TQSystematicsManager.cxx:395
 TQSystematicsManager.cxx:396
 TQSystematicsManager.cxx:397
 TQSystematicsManager.cxx:398
 TQSystematicsManager.cxx:399
 TQSystematicsManager.cxx:400
 TQSystematicsManager.cxx:401
 TQSystematicsManager.cxx:402
 TQSystematicsManager.cxx:403
 TQSystematicsManager.cxx:404
 TQSystematicsManager.cxx:405
 TQSystematicsManager.cxx:406
 TQSystematicsManager.cxx:407
 TQSystematicsManager.cxx:408
 TQSystematicsManager.cxx:409
 TQSystematicsManager.cxx:410
 TQSystematicsManager.cxx:411
 TQSystematicsManager.cxx:412
 TQSystematicsManager.cxx:413
 TQSystematicsManager.cxx:414
 TQSystematicsManager.cxx:415
 TQSystematicsManager.cxx:416
 TQSystematicsManager.cxx:417
 TQSystematicsManager.cxx:418
 TQSystematicsManager.cxx:419
 TQSystematicsManager.cxx:420
 TQSystematicsManager.cxx:421
 TQSystematicsManager.cxx:422
 TQSystematicsManager.cxx:423
 TQSystematicsManager.cxx:424
 TQSystematicsManager.cxx:425
 TQSystematicsManager.cxx:426
 TQSystematicsManager.cxx:427
 TQSystematicsManager.cxx:428
 TQSystematicsManager.cxx:429
 TQSystematicsManager.cxx:430
 TQSystematicsManager.cxx:431
 TQSystematicsManager.cxx:432
 TQSystematicsManager.cxx:433
 TQSystematicsManager.cxx:434
 TQSystematicsManager.cxx:435
 TQSystematicsManager.cxx:436
 TQSystematicsManager.cxx:437
 TQSystematicsManager.cxx:438
 TQSystematicsManager.cxx:439
 TQSystematicsManager.cxx:440
 TQSystematicsManager.cxx:441
 TQSystematicsManager.cxx:442
 TQSystematicsManager.cxx:443
 TQSystematicsManager.cxx:444
 TQSystematicsManager.cxx:445
 TQSystematicsManager.cxx:446
 TQSystematicsManager.cxx:447
 TQSystematicsManager.cxx:448
 TQSystematicsManager.cxx:449
 TQSystematicsManager.cxx:450
 TQSystematicsManager.cxx:451
 TQSystematicsManager.cxx:452
 TQSystematicsManager.cxx:453
 TQSystematicsManager.cxx:454
 TQSystematicsManager.cxx:455
 TQSystematicsManager.cxx:456
 TQSystematicsManager.cxx:457
 TQSystematicsManager.cxx:458
 TQSystematicsManager.cxx:459
 TQSystematicsManager.cxx:460
 TQSystematicsManager.cxx:461
 TQSystematicsManager.cxx:462
 TQSystematicsManager.cxx:463
 TQSystematicsManager.cxx:464
 TQSystematicsManager.cxx:465
 TQSystematicsManager.cxx:466
 TQSystematicsManager.cxx:467
 TQSystematicsManager.cxx:468
 TQSystematicsManager.cxx:469
 TQSystematicsManager.cxx:470
 TQSystematicsManager.cxx:471
 TQSystematicsManager.cxx:472
 TQSystematicsManager.cxx:473
 TQSystematicsManager.cxx:474
 TQSystematicsManager.cxx:475
 TQSystematicsManager.cxx:476
 TQSystematicsManager.cxx:477
 TQSystematicsManager.cxx:478
 TQSystematicsManager.cxx:479
 TQSystematicsManager.cxx:480
 TQSystematicsManager.cxx:481
 TQSystematicsManager.cxx:482
 TQSystematicsManager.cxx:483
 TQSystematicsManager.cxx:484
 TQSystematicsManager.cxx:485
 TQSystematicsManager.cxx:486
 TQSystematicsManager.cxx:487
 TQSystematicsManager.cxx:488
 TQSystematicsManager.cxx:489
 TQSystematicsManager.cxx:490
 TQSystematicsManager.cxx:491
 TQSystematicsManager.cxx:492
 TQSystematicsManager.cxx:493
 TQSystematicsManager.cxx:494
 TQSystematicsManager.cxx:495
 TQSystematicsManager.cxx:496
 TQSystematicsManager.cxx:497
 TQSystematicsManager.cxx:498
 TQSystematicsManager.cxx:499
 TQSystematicsManager.cxx:500
 TQSystematicsManager.cxx:501
 TQSystematicsManager.cxx:502
 TQSystematicsManager.cxx:503
 TQSystematicsManager.cxx:504
 TQSystematicsManager.cxx:505
 TQSystematicsManager.cxx:506
 TQSystematicsManager.cxx:507
 TQSystematicsManager.cxx:508
 TQSystematicsManager.cxx:509
 TQSystematicsManager.cxx:510
 TQSystematicsManager.cxx:511
 TQSystematicsManager.cxx:512
 TQSystematicsManager.cxx:513
 TQSystematicsManager.cxx:514
 TQSystematicsManager.cxx:515
 TQSystematicsManager.cxx:516
 TQSystematicsManager.cxx:517
 TQSystematicsManager.cxx:518
 TQSystematicsManager.cxx:519
 TQSystematicsManager.cxx:520
 TQSystematicsManager.cxx:521
 TQSystematicsManager.cxx:522
 TQSystematicsManager.cxx:523
 TQSystematicsManager.cxx:524
 TQSystematicsManager.cxx:525
 TQSystematicsManager.cxx:526
 TQSystematicsManager.cxx:527
 TQSystematicsManager.cxx:528
 TQSystematicsManager.cxx:529
 TQSystematicsManager.cxx:530
 TQSystematicsManager.cxx:531
 TQSystematicsManager.cxx:532
 TQSystematicsManager.cxx:533
 TQSystematicsManager.cxx:534
 TQSystematicsManager.cxx:535
 TQSystematicsManager.cxx:536
 TQSystematicsManager.cxx:537
 TQSystematicsManager.cxx:538
 TQSystematicsManager.cxx:539
 TQSystematicsManager.cxx:540
 TQSystematicsManager.cxx:541
 TQSystematicsManager.cxx:542
 TQSystematicsManager.cxx:543
 TQSystematicsManager.cxx:544
 TQSystematicsManager.cxx:545
 TQSystematicsManager.cxx:546
 TQSystematicsManager.cxx:547
 TQSystematicsManager.cxx:548
 TQSystematicsManager.cxx:549
 TQSystematicsManager.cxx:550
 TQSystematicsManager.cxx:551
 TQSystematicsManager.cxx:552
 TQSystematicsManager.cxx:553
 TQSystematicsManager.cxx:554
 TQSystematicsManager.cxx:555
 TQSystematicsManager.cxx:556
 TQSystematicsManager.cxx:557
 TQSystematicsManager.cxx:558
 TQSystematicsManager.cxx:559
 TQSystematicsManager.cxx:560
 TQSystematicsManager.cxx:561
 TQSystematicsManager.cxx:562
 TQSystematicsManager.cxx:563
 TQSystematicsManager.cxx:564
 TQSystematicsManager.cxx:565
 TQSystematicsManager.cxx:566
 TQSystematicsManager.cxx:567
 TQSystematicsManager.cxx:568
 TQSystematicsManager.cxx:569
 TQSystematicsManager.cxx:570
 TQSystematicsManager.cxx:571
 TQSystematicsManager.cxx:572
 TQSystematicsManager.cxx:573
 TQSystematicsManager.cxx:574
 TQSystematicsManager.cxx:575
 TQSystematicsManager.cxx:576
 TQSystematicsManager.cxx:577
 TQSystematicsManager.cxx:578
 TQSystematicsManager.cxx:579
 TQSystematicsManager.cxx:580
 TQSystematicsManager.cxx:581
 TQSystematicsManager.cxx:582
 TQSystematicsManager.cxx:583
 TQSystematicsManager.cxx:584
 TQSystematicsManager.cxx:585
 TQSystematicsManager.cxx:586
 TQSystematicsManager.cxx:587
 TQSystematicsManager.cxx:588
 TQSystematicsManager.cxx:589
 TQSystematicsManager.cxx:590
 TQSystematicsManager.cxx:591
 TQSystematicsManager.cxx:592
 TQSystematicsManager.cxx:593
 TQSystematicsManager.cxx:594
 TQSystematicsManager.cxx:595
 TQSystematicsManager.cxx:596
 TQSystematicsManager.cxx:597
 TQSystematicsManager.cxx:598
 TQSystematicsManager.cxx:599
 TQSystematicsManager.cxx:600
 TQSystematicsManager.cxx:601
 TQSystematicsManager.cxx:602
 TQSystematicsManager.cxx:603
 TQSystematicsManager.cxx:604
 TQSystematicsManager.cxx:605
 TQSystematicsManager.cxx:606
 TQSystematicsManager.cxx:607
 TQSystematicsManager.cxx:608
 TQSystematicsManager.cxx:609
 TQSystematicsManager.cxx:610
 TQSystematicsManager.cxx:611
 TQSystematicsManager.cxx:612
 TQSystematicsManager.cxx:613
 TQSystematicsManager.cxx:614
 TQSystematicsManager.cxx:615
 TQSystematicsManager.cxx:616
 TQSystematicsManager.cxx:617
 TQSystematicsManager.cxx:618
 TQSystematicsManager.cxx:619
 TQSystematicsManager.cxx:620
 TQSystematicsManager.cxx:621
 TQSystematicsManager.cxx:622
 TQSystematicsManager.cxx:623
 TQSystematicsManager.cxx:624
 TQSystematicsManager.cxx:625
 TQSystematicsManager.cxx:626
 TQSystematicsManager.cxx:627
 TQSystematicsManager.cxx:628
 TQSystematicsManager.cxx:629
 TQSystematicsManager.cxx:630
 TQSystematicsManager.cxx:631
 TQSystematicsManager.cxx:632
 TQSystematicsManager.cxx:633
 TQSystematicsManager.cxx:634
 TQSystematicsManager.cxx:635
 TQSystematicsManager.cxx:636
 TQSystematicsManager.cxx:637
 TQSystematicsManager.cxx:638
 TQSystematicsManager.cxx:639
 TQSystematicsManager.cxx:640
 TQSystematicsManager.cxx:641
 TQSystematicsManager.cxx:642
 TQSystematicsManager.cxx:643
 TQSystematicsManager.cxx:644
 TQSystematicsManager.cxx:645
 TQSystematicsManager.cxx:646
 TQSystematicsManager.cxx:647
 TQSystematicsManager.cxx:648
 TQSystematicsManager.cxx:649
 TQSystematicsManager.cxx:650
 TQSystematicsManager.cxx:651
 TQSystematicsManager.cxx:652
 TQSystematicsManager.cxx:653
 TQSystematicsManager.cxx:654
 TQSystematicsManager.cxx:655
 TQSystematicsManager.cxx:656
 TQSystematicsManager.cxx:657
 TQSystematicsManager.cxx:658
 TQSystematicsManager.cxx:659
 TQSystematicsManager.cxx:660
 TQSystematicsManager.cxx:661
 TQSystematicsManager.cxx:662
 TQSystematicsManager.cxx:663
 TQSystematicsManager.cxx:664
 TQSystematicsManager.cxx:665
 TQSystematicsManager.cxx:666
 TQSystematicsManager.cxx:667
 TQSystematicsManager.cxx:668
 TQSystematicsManager.cxx:669
 TQSystematicsManager.cxx:670
 TQSystematicsManager.cxx:671
 TQSystematicsManager.cxx:672
 TQSystematicsManager.cxx:673
 TQSystematicsManager.cxx:674
 TQSystematicsManager.cxx:675
 TQSystematicsManager.cxx:676
 TQSystematicsManager.cxx:677
 TQSystematicsManager.cxx:678
 TQSystematicsManager.cxx:679
 TQSystematicsManager.cxx:680
 TQSystematicsManager.cxx:681
 TQSystematicsManager.cxx:682
 TQSystematicsManager.cxx:683
 TQSystematicsManager.cxx:684
 TQSystematicsManager.cxx:685
 TQSystematicsManager.cxx:686
 TQSystematicsManager.cxx:687
 TQSystematicsManager.cxx:688
 TQSystematicsManager.cxx:689
 TQSystematicsManager.cxx:690
 TQSystematicsManager.cxx:691
 TQSystematicsManager.cxx:692
 TQSystematicsManager.cxx:693
 TQSystematicsManager.cxx:694
 TQSystematicsManager.cxx:695
 TQSystematicsManager.cxx:696
 TQSystematicsManager.cxx:697
 TQSystematicsManager.cxx:698
 TQSystematicsManager.cxx:699
 TQSystematicsManager.cxx:700
 TQSystematicsManager.cxx:701
 TQSystematicsManager.cxx:702
 TQSystematicsManager.cxx:703
 TQSystematicsManager.cxx:704
 TQSystematicsManager.cxx:705
 TQSystematicsManager.cxx:706
 TQSystematicsManager.cxx:707
 TQSystematicsManager.cxx:708
 TQSystematicsManager.cxx:709
 TQSystematicsManager.cxx:710
 TQSystematicsManager.cxx:711
 TQSystematicsManager.cxx:712
 TQSystematicsManager.cxx:713
 TQSystematicsManager.cxx:714
 TQSystematicsManager.cxx:715
 TQSystematicsManager.cxx:716
 TQSystematicsManager.cxx:717
 TQSystematicsManager.cxx:718
 TQSystematicsManager.cxx:719
 TQSystematicsManager.cxx:720
 TQSystematicsManager.cxx:721
 TQSystematicsManager.cxx:722
 TQSystematicsManager.cxx:723
 TQSystematicsManager.cxx:724
 TQSystematicsManager.cxx:725
 TQSystematicsManager.cxx:726
 TQSystematicsManager.cxx:727
 TQSystematicsManager.cxx:728
 TQSystematicsManager.cxx:729
 TQSystematicsManager.cxx:730
 TQSystematicsManager.cxx:731
 TQSystematicsManager.cxx:732
 TQSystematicsManager.cxx:733
 TQSystematicsManager.cxx:734
 TQSystematicsManager.cxx:735
 TQSystematicsManager.cxx:736
 TQSystematicsManager.cxx:737
 TQSystematicsManager.cxx:738
 TQSystematicsManager.cxx:739
 TQSystematicsManager.cxx:740
 TQSystematicsManager.cxx:741
 TQSystematicsManager.cxx:742
 TQSystematicsManager.cxx:743
 TQSystematicsManager.cxx:744
 TQSystematicsManager.cxx:745
 TQSystematicsManager.cxx:746
 TQSystematicsManager.cxx:747
 TQSystematicsManager.cxx:748
 TQSystematicsManager.cxx:749
 TQSystematicsManager.cxx:750
 TQSystematicsManager.cxx:751
 TQSystematicsManager.cxx:752
 TQSystematicsManager.cxx:753
 TQSystematicsManager.cxx:754
 TQSystematicsManager.cxx:755
 TQSystematicsManager.cxx:756
 TQSystematicsManager.cxx:757
 TQSystematicsManager.cxx:758
 TQSystematicsManager.cxx:759
 TQSystematicsManager.cxx:760
 TQSystematicsManager.cxx:761
 TQSystematicsManager.cxx:762
 TQSystematicsManager.cxx:763
 TQSystematicsManager.cxx:764
 TQSystematicsManager.cxx:765
 TQSystematicsManager.cxx:766
 TQSystematicsManager.cxx:767
 TQSystematicsManager.cxx:768
 TQSystematicsManager.cxx:769
 TQSystematicsManager.cxx:770
 TQSystematicsManager.cxx:771
 TQSystematicsManager.cxx:772
 TQSystematicsManager.cxx:773
 TQSystematicsManager.cxx:774
 TQSystematicsManager.cxx:775
 TQSystematicsManager.cxx:776
 TQSystematicsManager.cxx:777
 TQSystematicsManager.cxx:778
 TQSystematicsManager.cxx:779
 TQSystematicsManager.cxx:780
 TQSystematicsManager.cxx:781
 TQSystematicsManager.cxx:782
 TQSystematicsManager.cxx:783
 TQSystematicsManager.cxx:784
 TQSystematicsManager.cxx:785
 TQSystematicsManager.cxx:786
 TQSystematicsManager.cxx:787
 TQSystematicsManager.cxx:788
 TQSystematicsManager.cxx:789
 TQSystematicsManager.cxx:790
 TQSystematicsManager.cxx:791
 TQSystematicsManager.cxx:792
 TQSystematicsManager.cxx:793
 TQSystematicsManager.cxx:794
 TQSystematicsManager.cxx:795
 TQSystematicsManager.cxx:796
 TQSystematicsManager.cxx:797
 TQSystematicsManager.cxx:798
 TQSystematicsManager.cxx:799
 TQSystematicsManager.cxx:800
 TQSystematicsManager.cxx:801
 TQSystematicsManager.cxx:802
 TQSystematicsManager.cxx:803
 TQSystematicsManager.cxx:804
 TQSystematicsManager.cxx:805
 TQSystematicsManager.cxx:806
 TQSystematicsManager.cxx:807
 TQSystematicsManager.cxx:808
 TQSystematicsManager.cxx:809
 TQSystematicsManager.cxx:810
 TQSystematicsManager.cxx:811
 TQSystematicsManager.cxx:812
 TQSystematicsManager.cxx:813
 TQSystematicsManager.cxx:814
 TQSystematicsManager.cxx:815
 TQSystematicsManager.cxx:816
 TQSystematicsManager.cxx:817
 TQSystematicsManager.cxx:818
 TQSystematicsManager.cxx:819
 TQSystematicsManager.cxx:820
 TQSystematicsManager.cxx:821
 TQSystematicsManager.cxx:822
 TQSystematicsManager.cxx:823
 TQSystematicsManager.cxx:824
 TQSystematicsManager.cxx:825
 TQSystematicsManager.cxx:826
 TQSystematicsManager.cxx:827
 TQSystematicsManager.cxx:828
 TQSystematicsManager.cxx:829
 TQSystematicsManager.cxx:830
 TQSystematicsManager.cxx:831
 TQSystematicsManager.cxx:832
 TQSystematicsManager.cxx:833
 TQSystematicsManager.cxx:834
 TQSystematicsManager.cxx:835
 TQSystematicsManager.cxx:836
 TQSystematicsManager.cxx:837
 TQSystematicsManager.cxx:838
 TQSystematicsManager.cxx:839
 TQSystematicsManager.cxx:840
 TQSystematicsManager.cxx:841
 TQSystematicsManager.cxx:842
 TQSystematicsManager.cxx:843
 TQSystematicsManager.cxx:844
 TQSystematicsManager.cxx:845
 TQSystematicsManager.cxx:846
 TQSystematicsManager.cxx:847
 TQSystematicsManager.cxx:848
 TQSystematicsManager.cxx:849
 TQSystematicsManager.cxx:850
 TQSystematicsManager.cxx:851
 TQSystematicsManager.cxx:852
 TQSystematicsManager.cxx:853
 TQSystematicsManager.cxx:854
 TQSystematicsManager.cxx:855
 TQSystematicsManager.cxx:856
 TQSystematicsManager.cxx:857
 TQSystematicsManager.cxx:858
 TQSystematicsManager.cxx:859
 TQSystematicsManager.cxx:860
 TQSystematicsManager.cxx:861
 TQSystematicsManager.cxx:862
 TQSystematicsManager.cxx:863
 TQSystematicsManager.cxx:864
 TQSystematicsManager.cxx:865
 TQSystematicsManager.cxx:866
 TQSystematicsManager.cxx:867
 TQSystematicsManager.cxx:868
 TQSystematicsManager.cxx:869
 TQSystematicsManager.cxx:870
 TQSystematicsManager.cxx:871
 TQSystematicsManager.cxx:872
 TQSystematicsManager.cxx:873
 TQSystematicsManager.cxx:874
 TQSystematicsManager.cxx:875
 TQSystematicsManager.cxx:876
 TQSystematicsManager.cxx:877
 TQSystematicsManager.cxx:878
 TQSystematicsManager.cxx:879
 TQSystematicsManager.cxx:880
 TQSystematicsManager.cxx:881
 TQSystematicsManager.cxx:882
 TQSystematicsManager.cxx:883
 TQSystematicsManager.cxx:884
 TQSystematicsManager.cxx:885
 TQSystematicsManager.cxx:886
 TQSystematicsManager.cxx:887
 TQSystematicsManager.cxx:888
 TQSystematicsManager.cxx:889
 TQSystematicsManager.cxx:890
 TQSystematicsManager.cxx:891
 TQSystematicsManager.cxx:892
 TQSystematicsManager.cxx:893
 TQSystematicsManager.cxx:894
 TQSystematicsManager.cxx:895
 TQSystematicsManager.cxx:896
 TQSystematicsManager.cxx:897
 TQSystematicsManager.cxx:898
 TQSystematicsManager.cxx:899
 TQSystematicsManager.cxx:900
 TQSystematicsManager.cxx:901
 TQSystematicsManager.cxx:902
 TQSystematicsManager.cxx:903
 TQSystematicsManager.cxx:904
 TQSystematicsManager.cxx:905
 TQSystematicsManager.cxx:906
 TQSystematicsManager.cxx:907
 TQSystematicsManager.cxx:908
 TQSystematicsManager.cxx:909
 TQSystematicsManager.cxx:910
 TQSystematicsManager.cxx:911
 TQSystematicsManager.cxx:912
 TQSystematicsManager.cxx:913
 TQSystematicsManager.cxx:914
 TQSystematicsManager.cxx:915
 TQSystematicsManager.cxx:916
 TQSystematicsManager.cxx:917
 TQSystematicsManager.cxx:918
 TQSystematicsManager.cxx:919
 TQSystematicsManager.cxx:920
 TQSystematicsManager.cxx:921
 TQSystematicsManager.cxx:922
 TQSystematicsManager.cxx:923
 TQSystematicsManager.cxx:924
 TQSystematicsManager.cxx:925
 TQSystematicsManager.cxx:926
 TQSystematicsManager.cxx:927
 TQSystematicsManager.cxx:928
 TQSystematicsManager.cxx:929
 TQSystematicsManager.cxx:930
 TQSystematicsManager.cxx:931
 TQSystematicsManager.cxx:932
 TQSystematicsManager.cxx:933
 TQSystematicsManager.cxx:934
 TQSystematicsManager.cxx:935
 TQSystematicsManager.cxx:936
 TQSystematicsManager.cxx:937
 TQSystematicsManager.cxx:938
 TQSystematicsManager.cxx:939
 TQSystematicsManager.cxx:940
 TQSystematicsManager.cxx:941
 TQSystematicsManager.cxx:942
 TQSystematicsManager.cxx:943
 TQSystematicsManager.cxx:944
 TQSystematicsManager.cxx:945
 TQSystematicsManager.cxx:946
 TQSystematicsManager.cxx:947
 TQSystematicsManager.cxx:948
 TQSystematicsManager.cxx:949
 TQSystematicsManager.cxx:950
 TQSystematicsManager.cxx:951
 TQSystematicsManager.cxx:952
 TQSystematicsManager.cxx:953
 TQSystematicsManager.cxx:954
 TQSystematicsManager.cxx:955
 TQSystematicsManager.cxx:956
 TQSystematicsManager.cxx:957
 TQSystematicsManager.cxx:958
 TQSystematicsManager.cxx:959
 TQSystematicsManager.cxx:960
 TQSystematicsManager.cxx:961
 TQSystematicsManager.cxx:962
 TQSystematicsManager.cxx:963
 TQSystematicsManager.cxx:964
 TQSystematicsManager.cxx:965
 TQSystematicsManager.cxx:966
 TQSystematicsManager.cxx:967
 TQSystematicsManager.cxx:968
 TQSystematicsManager.cxx:969
 TQSystematicsManager.cxx:970
 TQSystematicsManager.cxx:971
 TQSystematicsManager.cxx:972
 TQSystematicsManager.cxx:973
 TQSystematicsManager.cxx:974
 TQSystematicsManager.cxx:975
 TQSystematicsManager.cxx:976
 TQSystematicsManager.cxx:977
 TQSystematicsManager.cxx:978
 TQSystematicsManager.cxx:979
 TQSystematicsManager.cxx:980
 TQSystematicsManager.cxx:981
 TQSystematicsManager.cxx:982
 TQSystematicsManager.cxx:983
 TQSystematicsManager.cxx:984
 TQSystematicsManager.cxx:985
 TQSystematicsManager.cxx:986
 TQSystematicsManager.cxx:987
 TQSystematicsManager.cxx:988
 TQSystematicsManager.cxx:989
 TQSystematicsManager.cxx:990
 TQSystematicsManager.cxx:991
 TQSystematicsManager.cxx:992
 TQSystematicsManager.cxx:993
 TQSystematicsManager.cxx:994
 TQSystematicsManager.cxx:995
 TQSystematicsManager.cxx:996
 TQSystematicsManager.cxx:997
 TQSystematicsManager.cxx:998
 TQSystematicsManager.cxx:999
 TQSystematicsManager.cxx:1000
 TQSystematicsManager.cxx:1001
 TQSystematicsManager.cxx:1002
 TQSystematicsManager.cxx:1003
 TQSystematicsManager.cxx:1004
 TQSystematicsManager.cxx:1005
 TQSystematicsManager.cxx:1006
 TQSystematicsManager.cxx:1007
 TQSystematicsManager.cxx:1008
 TQSystematicsManager.cxx:1009
 TQSystematicsManager.cxx:1010
 TQSystematicsManager.cxx:1011
 TQSystematicsManager.cxx:1012
 TQSystematicsManager.cxx:1013
 TQSystematicsManager.cxx:1014
 TQSystematicsManager.cxx:1015
 TQSystematicsManager.cxx:1016
 TQSystematicsManager.cxx:1017
 TQSystematicsManager.cxx:1018
 TQSystematicsManager.cxx:1019
 TQSystematicsManager.cxx:1020
 TQSystematicsManager.cxx:1021
 TQSystematicsManager.cxx:1022
 TQSystematicsManager.cxx:1023
 TQSystematicsManager.cxx:1024
 TQSystematicsManager.cxx:1025
 TQSystematicsManager.cxx:1026
 TQSystematicsManager.cxx:1027
 TQSystematicsManager.cxx:1028
 TQSystematicsManager.cxx:1029
 TQSystematicsManager.cxx:1030
 TQSystematicsManager.cxx:1031
 TQSystematicsManager.cxx:1032
 TQSystematicsManager.cxx:1033
 TQSystematicsManager.cxx:1034
 TQSystematicsManager.cxx:1035
 TQSystematicsManager.cxx:1036
 TQSystematicsManager.cxx:1037
 TQSystematicsManager.cxx:1038
 TQSystematicsManager.cxx:1039
 TQSystematicsManager.cxx:1040
 TQSystematicsManager.cxx:1041
 TQSystematicsManager.cxx:1042
 TQSystematicsManager.cxx:1043
 TQSystematicsManager.cxx:1044
 TQSystematicsManager.cxx:1045
 TQSystematicsManager.cxx:1046
 TQSystematicsManager.cxx:1047
 TQSystematicsManager.cxx:1048
 TQSystematicsManager.cxx:1049
 TQSystematicsManager.cxx:1050
 TQSystematicsManager.cxx:1051
 TQSystematicsManager.cxx:1052
 TQSystematicsManager.cxx:1053
 TQSystematicsManager.cxx:1054
 TQSystematicsManager.cxx:1055
 TQSystematicsManager.cxx:1056
 TQSystematicsManager.cxx:1057
 TQSystematicsManager.cxx:1058
 TQSystematicsManager.cxx:1059
 TQSystematicsManager.cxx:1060
 TQSystematicsManager.cxx:1061
 TQSystematicsManager.cxx:1062
 TQSystematicsManager.cxx:1063
 TQSystematicsManager.cxx:1064
 TQSystematicsManager.cxx:1065
 TQSystematicsManager.cxx:1066
 TQSystematicsManager.cxx:1067
 TQSystematicsManager.cxx:1068
 TQSystematicsManager.cxx:1069
 TQSystematicsManager.cxx:1070
 TQSystematicsManager.cxx:1071
 TQSystematicsManager.cxx:1072
 TQSystematicsManager.cxx:1073
 TQSystematicsManager.cxx:1074
 TQSystematicsManager.cxx:1075
 TQSystematicsManager.cxx:1076
 TQSystematicsManager.cxx:1077
 TQSystematicsManager.cxx:1078
 TQSystematicsManager.cxx:1079
 TQSystematicsManager.cxx:1080
 TQSystematicsManager.cxx:1081
 TQSystematicsManager.cxx:1082
 TQSystematicsManager.cxx:1083
 TQSystematicsManager.cxx:1084
 TQSystematicsManager.cxx:1085
 TQSystematicsManager.cxx:1086
 TQSystematicsManager.cxx:1087
 TQSystematicsManager.cxx:1088
 TQSystematicsManager.cxx:1089
 TQSystematicsManager.cxx:1090
 TQSystematicsManager.cxx:1091
 TQSystematicsManager.cxx:1092
 TQSystematicsManager.cxx:1093
 TQSystematicsManager.cxx:1094
 TQSystematicsManager.cxx:1095
 TQSystematicsManager.cxx:1096
 TQSystematicsManager.cxx:1097
 TQSystematicsManager.cxx:1098
 TQSystematicsManager.cxx:1099
 TQSystematicsManager.cxx:1100
 TQSystematicsManager.cxx:1101
 TQSystematicsManager.cxx:1102
 TQSystematicsManager.cxx:1103
 TQSystematicsManager.cxx:1104
 TQSystematicsManager.cxx:1105
 TQSystematicsManager.cxx:1106
 TQSystematicsManager.cxx:1107
 TQSystematicsManager.cxx:1108
 TQSystematicsManager.cxx:1109
 TQSystematicsManager.cxx:1110
 TQSystematicsManager.cxx:1111
 TQSystematicsManager.cxx:1112
 TQSystematicsManager.cxx:1113
 TQSystematicsManager.cxx:1114
 TQSystematicsManager.cxx:1115
 TQSystematicsManager.cxx:1116
 TQSystematicsManager.cxx:1117
 TQSystematicsManager.cxx:1118
 TQSystematicsManager.cxx:1119
 TQSystematicsManager.cxx:1120
 TQSystematicsManager.cxx:1121
 TQSystematicsManager.cxx:1122
 TQSystematicsManager.cxx:1123
 TQSystematicsManager.cxx:1124
 TQSystematicsManager.cxx:1125
 TQSystematicsManager.cxx:1126
 TQSystematicsManager.cxx:1127
 TQSystematicsManager.cxx:1128
 TQSystematicsManager.cxx:1129
 TQSystematicsManager.cxx:1130
 TQSystematicsManager.cxx:1131
 TQSystematicsManager.cxx:1132
 TQSystematicsManager.cxx:1133
 TQSystematicsManager.cxx:1134
 TQSystematicsManager.cxx:1135
 TQSystematicsManager.cxx:1136
 TQSystematicsManager.cxx:1137
 TQSystematicsManager.cxx:1138
 TQSystematicsManager.cxx:1139
 TQSystematicsManager.cxx:1140
 TQSystematicsManager.cxx:1141
 TQSystematicsManager.cxx:1142
 TQSystematicsManager.cxx:1143
 TQSystematicsManager.cxx:1144
 TQSystematicsManager.cxx:1145
 TQSystematicsManager.cxx:1146
 TQSystematicsManager.cxx:1147
 TQSystematicsManager.cxx:1148
 TQSystematicsManager.cxx:1149
 TQSystematicsManager.cxx:1150
 TQSystematicsManager.cxx:1151
 TQSystematicsManager.cxx:1152
 TQSystematicsManager.cxx:1153
 TQSystematicsManager.cxx:1154
 TQSystematicsManager.cxx:1155
 TQSystematicsManager.cxx:1156
 TQSystematicsManager.cxx:1157
 TQSystematicsManager.cxx:1158
 TQSystematicsManager.cxx:1159
 TQSystematicsManager.cxx:1160
 TQSystematicsManager.cxx:1161
 TQSystematicsManager.cxx:1162
 TQSystematicsManager.cxx:1163
 TQSystematicsManager.cxx:1164
 TQSystematicsManager.cxx:1165
 TQSystematicsManager.cxx:1166
 TQSystematicsManager.cxx:1167
 TQSystematicsManager.cxx:1168
 TQSystematicsManager.cxx:1169
 TQSystematicsManager.cxx:1170
 TQSystematicsManager.cxx:1171
 TQSystematicsManager.cxx:1172
 TQSystematicsManager.cxx:1173
 TQSystematicsManager.cxx:1174
 TQSystematicsManager.cxx:1175
 TQSystematicsManager.cxx:1176
 TQSystematicsManager.cxx:1177
 TQSystematicsManager.cxx:1178
 TQSystematicsManager.cxx:1179
 TQSystematicsManager.cxx:1180
 TQSystematicsManager.cxx:1181
 TQSystematicsManager.cxx:1182
 TQSystematicsManager.cxx:1183
 TQSystematicsManager.cxx:1184
 TQSystematicsManager.cxx:1185
 TQSystematicsManager.cxx:1186
 TQSystematicsManager.cxx:1187
 TQSystematicsManager.cxx:1188
 TQSystematicsManager.cxx:1189
 TQSystematicsManager.cxx:1190
 TQSystematicsManager.cxx:1191
 TQSystematicsManager.cxx:1192
 TQSystematicsManager.cxx:1193
 TQSystematicsManager.cxx:1194
 TQSystematicsManager.cxx:1195
 TQSystematicsManager.cxx:1196
 TQSystematicsManager.cxx:1197
 TQSystematicsManager.cxx:1198
 TQSystematicsManager.cxx:1199
 TQSystematicsManager.cxx:1200
 TQSystematicsManager.cxx:1201
 TQSystematicsManager.cxx:1202
 TQSystematicsManager.cxx:1203
 TQSystematicsManager.cxx:1204
 TQSystematicsManager.cxx:1205
 TQSystematicsManager.cxx:1206
 TQSystematicsManager.cxx:1207
 TQSystematicsManager.cxx:1208
 TQSystematicsManager.cxx:1209
 TQSystematicsManager.cxx:1210
 TQSystematicsManager.cxx:1211
 TQSystematicsManager.cxx:1212
 TQSystematicsManager.cxx:1213
 TQSystematicsManager.cxx:1214
 TQSystematicsManager.cxx:1215
 TQSystematicsManager.cxx:1216
 TQSystematicsManager.cxx:1217
 TQSystematicsManager.cxx:1218
 TQSystematicsManager.cxx:1219
 TQSystematicsManager.cxx:1220
 TQSystematicsManager.cxx:1221
 TQSystematicsManager.cxx:1222
 TQSystematicsManager.cxx:1223
 TQSystematicsManager.cxx:1224
 TQSystematicsManager.cxx:1225
 TQSystematicsManager.cxx:1226
 TQSystematicsManager.cxx:1227
 TQSystematicsManager.cxx:1228
 TQSystematicsManager.cxx:1229
 TQSystematicsManager.cxx:1230
 TQSystematicsManager.cxx:1231
 TQSystematicsManager.cxx:1232
 TQSystematicsManager.cxx:1233
 TQSystematicsManager.cxx:1234
 TQSystematicsManager.cxx:1235
 TQSystematicsManager.cxx:1236
 TQSystematicsManager.cxx:1237
 TQSystematicsManager.cxx:1238
 TQSystematicsManager.cxx:1239
 TQSystematicsManager.cxx:1240
 TQSystematicsManager.cxx:1241
 TQSystematicsManager.cxx:1242
 TQSystematicsManager.cxx:1243
 TQSystematicsManager.cxx:1244
 TQSystematicsManager.cxx:1245
 TQSystematicsManager.cxx:1246
 TQSystematicsManager.cxx:1247
 TQSystematicsManager.cxx:1248
 TQSystematicsManager.cxx:1249
 TQSystematicsManager.cxx:1250
 TQSystematicsManager.cxx:1251
 TQSystematicsManager.cxx:1252
 TQSystematicsManager.cxx:1253
 TQSystematicsManager.cxx:1254
 TQSystematicsManager.cxx:1255
 TQSystematicsManager.cxx:1256
 TQSystematicsManager.cxx:1257
 TQSystematicsManager.cxx:1258
 TQSystematicsManager.cxx:1259
 TQSystematicsManager.cxx:1260
 TQSystematicsManager.cxx:1261
 TQSystematicsManager.cxx:1262
 TQSystematicsManager.cxx:1263
 TQSystematicsManager.cxx:1264
 TQSystematicsManager.cxx:1265
 TQSystematicsManager.cxx:1266
 TQSystematicsManager.cxx:1267
 TQSystematicsManager.cxx:1268
 TQSystematicsManager.cxx:1269
 TQSystematicsManager.cxx:1270
 TQSystematicsManager.cxx:1271
 TQSystematicsManager.cxx:1272
 TQSystematicsManager.cxx:1273
 TQSystematicsManager.cxx:1274
 TQSystematicsManager.cxx:1275
 TQSystematicsManager.cxx:1276
 TQSystematicsManager.cxx:1277
 TQSystematicsManager.cxx:1278
 TQSystematicsManager.cxx:1279
 TQSystematicsManager.cxx:1280
 TQSystematicsManager.cxx:1281
 TQSystematicsManager.cxx:1282
 TQSystematicsManager.cxx:1283
 TQSystematicsManager.cxx:1284
 TQSystematicsManager.cxx:1285
 TQSystematicsManager.cxx:1286
 TQSystematicsManager.cxx:1287
 TQSystematicsManager.cxx:1288
 TQSystematicsManager.cxx:1289
 TQSystematicsManager.cxx:1290
 TQSystematicsManager.cxx:1291
 TQSystematicsManager.cxx:1292
 TQSystematicsManager.cxx:1293
 TQSystematicsManager.cxx:1294
 TQSystematicsManager.cxx:1295
 TQSystematicsManager.cxx:1296
 TQSystematicsManager.cxx:1297
 TQSystematicsManager.cxx:1298
 TQSystematicsManager.cxx:1299
 TQSystematicsManager.cxx:1300
 TQSystematicsManager.cxx:1301
 TQSystematicsManager.cxx:1302
 TQSystematicsManager.cxx:1303
 TQSystematicsManager.cxx:1304
 TQSystematicsManager.cxx:1305
 TQSystematicsManager.cxx:1306
 TQSystematicsManager.cxx:1307
 TQSystematicsManager.cxx:1308
 TQSystematicsManager.cxx:1309
 TQSystematicsManager.cxx:1310
 TQSystematicsManager.cxx:1311
 TQSystematicsManager.cxx:1312
 TQSystematicsManager.cxx:1313
 TQSystematicsManager.cxx:1314
 TQSystematicsManager.cxx:1315
 TQSystematicsManager.cxx:1316
 TQSystematicsManager.cxx:1317
 TQSystematicsManager.cxx:1318
 TQSystematicsManager.cxx:1319
 TQSystematicsManager.cxx:1320
 TQSystematicsManager.cxx:1321
 TQSystematicsManager.cxx:1322
 TQSystematicsManager.cxx:1323
 TQSystematicsManager.cxx:1324
 TQSystematicsManager.cxx:1325
 TQSystematicsManager.cxx:1326
 TQSystematicsManager.cxx:1327
 TQSystematicsManager.cxx:1328
 TQSystematicsManager.cxx:1329
 TQSystematicsManager.cxx:1330
 TQSystematicsManager.cxx:1331
 TQSystematicsManager.cxx:1332
 TQSystematicsManager.cxx:1333
 TQSystematicsManager.cxx:1334
 TQSystematicsManager.cxx:1335
 TQSystematicsManager.cxx:1336
 TQSystematicsManager.cxx:1337
 TQSystematicsManager.cxx:1338
 TQSystematicsManager.cxx:1339
 TQSystematicsManager.cxx:1340
 TQSystematicsManager.cxx:1341
 TQSystematicsManager.cxx:1342
 TQSystematicsManager.cxx:1343
 TQSystematicsManager.cxx:1344
 TQSystematicsManager.cxx:1345
 TQSystematicsManager.cxx:1346
 TQSystematicsManager.cxx:1347
 TQSystematicsManager.cxx:1348
 TQSystematicsManager.cxx:1349
 TQSystematicsManager.cxx:1350
 TQSystematicsManager.cxx:1351
 TQSystematicsManager.cxx:1352
 TQSystematicsManager.cxx:1353
 TQSystematicsManager.cxx:1354
 TQSystematicsManager.cxx:1355
 TQSystematicsManager.cxx:1356
 TQSystematicsManager.cxx:1357
 TQSystematicsManager.cxx:1358
 TQSystematicsManager.cxx:1359
 TQSystematicsManager.cxx:1360
 TQSystematicsManager.cxx:1361
 TQSystematicsManager.cxx:1362
 TQSystematicsManager.cxx:1363
 TQSystematicsManager.cxx:1364
 TQSystematicsManager.cxx:1365
 TQSystematicsManager.cxx:1366
 TQSystematicsManager.cxx:1367
 TQSystematicsManager.cxx:1368
 TQSystematicsManager.cxx:1369
 TQSystematicsManager.cxx:1370
 TQSystematicsManager.cxx:1371
 TQSystematicsManager.cxx:1372
 TQSystematicsManager.cxx:1373
 TQSystematicsManager.cxx:1374
 TQSystematicsManager.cxx:1375
 TQSystematicsManager.cxx:1376
 TQSystematicsManager.cxx:1377
 TQSystematicsManager.cxx:1378
 TQSystematicsManager.cxx:1379
 TQSystematicsManager.cxx:1380
 TQSystematicsManager.cxx:1381
 TQSystematicsManager.cxx:1382
 TQSystematicsManager.cxx:1383
 TQSystematicsManager.cxx:1384
 TQSystematicsManager.cxx:1385
 TQSystematicsManager.cxx:1386
 TQSystematicsManager.cxx:1387
 TQSystematicsManager.cxx:1388
 TQSystematicsManager.cxx:1389
 TQSystematicsManager.cxx:1390
 TQSystematicsManager.cxx:1391
 TQSystematicsManager.cxx:1392
 TQSystematicsManager.cxx:1393
 TQSystematicsManager.cxx:1394
 TQSystematicsManager.cxx:1395
 TQSystematicsManager.cxx:1396
 TQSystematicsManager.cxx:1397
 TQSystematicsManager.cxx:1398
 TQSystematicsManager.cxx:1399
 TQSystematicsManager.cxx:1400
 TQSystematicsManager.cxx:1401
 TQSystematicsManager.cxx:1402
 TQSystematicsManager.cxx:1403
 TQSystematicsManager.cxx:1404
 TQSystematicsManager.cxx:1405
 TQSystematicsManager.cxx:1406
 TQSystematicsManager.cxx:1407
 TQSystematicsManager.cxx:1408
 TQSystematicsManager.cxx:1409
 TQSystematicsManager.cxx:1410
 TQSystematicsManager.cxx:1411
 TQSystematicsManager.cxx:1412
 TQSystematicsManager.cxx:1413
 TQSystematicsManager.cxx:1414
 TQSystematicsManager.cxx:1415
 TQSystematicsManager.cxx:1416
 TQSystematicsManager.cxx:1417
 TQSystematicsManager.cxx:1418
 TQSystematicsManager.cxx:1419
 TQSystematicsManager.cxx:1420
 TQSystematicsManager.cxx:1421
 TQSystematicsManager.cxx:1422
 TQSystematicsManager.cxx:1423
 TQSystematicsManager.cxx:1424
 TQSystematicsManager.cxx:1425
 TQSystematicsManager.cxx:1426
 TQSystematicsManager.cxx:1427
 TQSystematicsManager.cxx:1428
 TQSystematicsManager.cxx:1429
 TQSystematicsManager.cxx:1430
 TQSystematicsManager.cxx:1431
 TQSystematicsManager.cxx:1432
 TQSystematicsManager.cxx:1433
 TQSystematicsManager.cxx:1434
 TQSystematicsManager.cxx:1435
 TQSystematicsManager.cxx:1436
 TQSystematicsManager.cxx:1437
 TQSystematicsManager.cxx:1438
 TQSystematicsManager.cxx:1439
 TQSystematicsManager.cxx:1440
 TQSystematicsManager.cxx:1441
 TQSystematicsManager.cxx:1442
 TQSystematicsManager.cxx:1443
 TQSystematicsManager.cxx:1444
 TQSystematicsManager.cxx:1445
 TQSystematicsManager.cxx:1446
 TQSystematicsManager.cxx:1447
 TQSystematicsManager.cxx:1448
 TQSystematicsManager.cxx:1449
 TQSystematicsManager.cxx:1450
 TQSystematicsManager.cxx:1451
 TQSystematicsManager.cxx:1452
 TQSystematicsManager.cxx:1453
 TQSystematicsManager.cxx:1454
 TQSystematicsManager.cxx:1455
 TQSystematicsManager.cxx:1456
 TQSystematicsManager.cxx:1457
 TQSystematicsManager.cxx:1458
 TQSystematicsManager.cxx:1459
 TQSystematicsManager.cxx:1460
 TQSystematicsManager.cxx:1461
 TQSystematicsManager.cxx:1462
 TQSystematicsManager.cxx:1463
 TQSystematicsManager.cxx:1464
 TQSystematicsManager.cxx:1465
 TQSystematicsManager.cxx:1466
 TQSystematicsManager.cxx:1467
 TQSystematicsManager.cxx:1468
 TQSystematicsManager.cxx:1469
 TQSystematicsManager.cxx:1470
 TQSystematicsManager.cxx:1471
 TQSystematicsManager.cxx:1472
 TQSystematicsManager.cxx:1473
 TQSystematicsManager.cxx:1474
 TQSystematicsManager.cxx:1475
 TQSystematicsManager.cxx:1476
 TQSystematicsManager.cxx:1477
 TQSystematicsManager.cxx:1478
 TQSystematicsManager.cxx:1479
 TQSystematicsManager.cxx:1480
 TQSystematicsManager.cxx:1481
 TQSystematicsManager.cxx:1482
 TQSystematicsManager.cxx:1483
 TQSystematicsManager.cxx:1484
 TQSystematicsManager.cxx:1485
 TQSystematicsManager.cxx:1486
 TQSystematicsManager.cxx:1487
 TQSystematicsManager.cxx:1488
 TQSystematicsManager.cxx:1489
 TQSystematicsManager.cxx:1490
 TQSystematicsManager.cxx:1491
 TQSystematicsManager.cxx:1492
 TQSystematicsManager.cxx:1493
 TQSystematicsManager.cxx:1494
 TQSystematicsManager.cxx:1495
 TQSystematicsManager.cxx:1496
 TQSystematicsManager.cxx:1497
 TQSystematicsManager.cxx:1498
 TQSystematicsManager.cxx:1499
 TQSystematicsManager.cxx:1500
 TQSystematicsManager.cxx:1501
 TQSystematicsManager.cxx:1502
 TQSystematicsManager.cxx:1503
 TQSystematicsManager.cxx:1504
 TQSystematicsManager.cxx:1505
 TQSystematicsManager.cxx:1506
 TQSystematicsManager.cxx:1507
 TQSystematicsManager.cxx:1508
 TQSystematicsManager.cxx:1509
 TQSystematicsManager.cxx:1510
 TQSystematicsManager.cxx:1511
 TQSystematicsManager.cxx:1512
 TQSystematicsManager.cxx:1513
 TQSystematicsManager.cxx:1514
 TQSystematicsManager.cxx:1515
 TQSystematicsManager.cxx:1516
 TQSystematicsManager.cxx:1517
 TQSystematicsManager.cxx:1518
 TQSystematicsManager.cxx:1519
 TQSystematicsManager.cxx:1520
 TQSystematicsManager.cxx:1521
 TQSystematicsManager.cxx:1522
 TQSystematicsManager.cxx:1523
 TQSystematicsManager.cxx:1524
 TQSystematicsManager.cxx:1525
 TQSystematicsManager.cxx:1526
 TQSystematicsManager.cxx:1527
 TQSystematicsManager.cxx:1528
 TQSystematicsManager.cxx:1529
 TQSystematicsManager.cxx:1530
 TQSystematicsManager.cxx:1531
 TQSystematicsManager.cxx:1532
 TQSystematicsManager.cxx:1533
 TQSystematicsManager.cxx:1534
 TQSystematicsManager.cxx:1535
 TQSystematicsManager.cxx:1536
 TQSystematicsManager.cxx:1537
 TQSystematicsManager.cxx:1538
 TQSystematicsManager.cxx:1539
 TQSystematicsManager.cxx:1540
 TQSystematicsManager.cxx:1541
 TQSystematicsManager.cxx:1542
 TQSystematicsManager.cxx:1543
 TQSystematicsManager.cxx:1544
 TQSystematicsManager.cxx:1545
 TQSystematicsManager.cxx:1546
 TQSystematicsManager.cxx:1547
 TQSystematicsManager.cxx:1548
 TQSystematicsManager.cxx:1549
 TQSystematicsManager.cxx:1550
 TQSystematicsManager.cxx:1551
 TQSystematicsManager.cxx:1552
 TQSystematicsManager.cxx:1553
 TQSystematicsManager.cxx:1554
 TQSystematicsManager.cxx:1555
 TQSystematicsManager.cxx:1556
 TQSystematicsManager.cxx:1557
 TQSystematicsManager.cxx:1558
 TQSystematicsManager.cxx:1559
 TQSystematicsManager.cxx:1560
 TQSystematicsManager.cxx:1561
 TQSystematicsManager.cxx:1562
 TQSystematicsManager.cxx:1563
 TQSystematicsManager.cxx:1564
 TQSystematicsManager.cxx:1565
 TQSystematicsManager.cxx:1566
 TQSystematicsManager.cxx:1567
 TQSystematicsManager.cxx:1568
 TQSystematicsManager.cxx:1569
 TQSystematicsManager.cxx:1570
 TQSystematicsManager.cxx:1571
 TQSystematicsManager.cxx:1572
 TQSystematicsManager.cxx:1573
 TQSystematicsManager.cxx:1574
 TQSystematicsManager.cxx:1575
 TQSystematicsManager.cxx:1576
 TQSystematicsManager.cxx:1577
 TQSystematicsManager.cxx:1578
 TQSystematicsManager.cxx:1579
 TQSystematicsManager.cxx:1580
 TQSystematicsManager.cxx:1581
 TQSystematicsManager.cxx:1582
 TQSystematicsManager.cxx:1583
 TQSystematicsManager.cxx:1584
 TQSystematicsManager.cxx:1585
 TQSystematicsManager.cxx:1586
 TQSystematicsManager.cxx:1587
 TQSystematicsManager.cxx:1588
 TQSystematicsManager.cxx:1589
 TQSystematicsManager.cxx:1590
 TQSystematicsManager.cxx:1591
 TQSystematicsManager.cxx:1592
 TQSystematicsManager.cxx:1593
 TQSystematicsManager.cxx:1594
 TQSystematicsManager.cxx:1595
 TQSystematicsManager.cxx:1596
 TQSystematicsManager.cxx:1597
 TQSystematicsManager.cxx:1598
 TQSystematicsManager.cxx:1599
 TQSystematicsManager.cxx:1600
 TQSystematicsManager.cxx:1601
 TQSystematicsManager.cxx:1602
 TQSystematicsManager.cxx:1603
 TQSystematicsManager.cxx:1604
 TQSystematicsManager.cxx:1605
 TQSystematicsManager.cxx:1606
 TQSystematicsManager.cxx:1607
 TQSystematicsManager.cxx:1608
 TQSystematicsManager.cxx:1609
 TQSystematicsManager.cxx:1610
 TQSystematicsManager.cxx:1611
 TQSystematicsManager.cxx:1612
 TQSystematicsManager.cxx:1613
 TQSystematicsManager.cxx:1614
 TQSystematicsManager.cxx:1615
 TQSystematicsManager.cxx:1616
 TQSystematicsManager.cxx:1617