Beispiel #1
0
//------------------------------------------------------------//
// Fit for radiation length
//------------------------------------------------------------//
pair<float,float> getRadLength(TProfile* prof, TF1* &fit, int color)
{
  
  // Must pass the distance travelled vs the average energy.
  // Fit for the radiation length following:
  // <E> = E0 e^{-x/chi_0)

  //TF1 func = TF1("radLength","[0]*TMath::Exp(-x/[1]) + [2]",0,200);
  TF1 func = TF1("radLength","[0]*TMath::Exp(-x/[1])",0,200);
  func.SetParameter(0,0.5);
  func.SetParameter(1,4.0);

  
  // Fit
  prof->Fit("radLength","RQ");

  fit = prof->GetFunction("radLength");
  fit->SetLineColor(color);

  // Print info
  float E0 = fit->GetParameter(0);
  float radLength = fit->GetParameter(1);
  float radErr = fit->GetParError(1);

  cout<<"E0: "<<E0<<" chi: "<<radLength<<" +/- "<<radErr<<endl;

  //delete fit;

  pair<float,float> radPair (radLength, radErr);

  return radPair;

}
void BTagCalibrationReader::BTagCalibrationReaderImpl::load(
                                             const BTagCalibration & c,
                                             BTagEntry::JetFlavor jf,
                                             std::string measurementType)
{
  if (!tmpData_[jf].empty()) {
std::cerr << "ERROR in BTagCalibration: "
          << "Data for this jet-flavor is already loaded: "
          << jf;
throw std::exception();
  }

  BTagEntry::Parameters params(op_, measurementType, sysType_);
  const std::vector<BTagEntry> &entries = c.getEntries(params);

  for (const auto &be : entries) {
    if (be.params.jetFlavor != jf) {
      continue;
    }

    TmpEntry te;
    te.etaMin = be.params.etaMin;
    te.etaMax = be.params.etaMax;
    te.ptMin = be.params.ptMin;
    te.ptMax = be.params.ptMax;
    te.discrMin = be.params.discrMin;
    te.discrMax = be.params.discrMax;

    if (op_ == BTagEntry::OP_RESHAPING) {
      te.func = TF1("", be.formula.c_str(),
                    be.params.discrMin, be.params.discrMax);
    } else {
      te.func = TF1("", be.formula.c_str(),
                    be.params.ptMin, be.params.ptMax);
    }

    tmpData_[be.params.jetFlavor].push_back(te);
    if (te.etaMin < 0) {
      useAbsEta_[be.params.jetFlavor] = false;
    }
  }

  for (auto & p : otherSysTypeReaders_) {
    p.second->load(c, jf, measurementType);
  }
}
int RawConverter::CompareTwoRawDerVhf( const string& src1,
                                       const string& src2 )
{
    std::cout << "Comparing two raw+derivatives+vhf" << endl;
    unsigned  w1,  h1,  d1;
    unsigned  w2,  h2,  d2;
    float    sw1, sh1, sd1;
    float    sw2, sh2, sd2;

    vector< unsigned char > TF1( 256*4, 0 );
    vector< unsigned char > TF2( 256*4, 0 );

    //reading headers
    string configFileName = src1;
    hFile info( fopen( configFileName.append( ".vhf" ).c_str(), "rb" ) );
    FILE* file = info.f;

    if( file==NULL ) return lFailed( "Can't open first header file" );

    //reading dimensions
    readDimensionsFromSav( file,  w1,  h1,  d1 );
    if( readScalesFormSav( file, sw1, sh1, sd1 ) )
        lFailed( "Wrong format of the first header file" );

    //reading transfer function
    const size_t tfSize1 = readTransferFunction( file, TF1 );

    configFileName = src2;
    hFile info2( fopen( configFileName.append( ".vhf" ).c_str(), "rb" ) );
    file = info2.f;

    if( file==NULL ) return lFailed( "Can't open first header file" );

    readDimensionsFromSav( file,  w2,  h2,  d2 );
    if( readScalesFormSav( file, sw2, sh2, sd2 ) )
        lFailed( "Wrong format of the second header file" );

    //reading transfer function
    const size_t tfSize2 = readTransferFunction( file, TF2 );

    //comparing headers
    if( w1!=w2 ) return lFailed(" Widths are not equal ");
    if( h1!=h2 ) return lFailed(" Heights are not equal ");
    if( d1!=d2 ) return lFailed(" Depths are not equal ");

    if( sw1!=sw2 ) std::cout << " Widths'  scales are not equal " << endl;
    if( sh1!=sh2 ) std::cout << " Heights' scales are not equal " << endl;
    if( sd1!=sd2 ) std::cout << " Depths'  scales are not equal " << endl;

    if( tfSize1!=tfSize2 ) std::cout << " TF sizes are not equal" << endl;

    std::cout << "done" << endl;
    return 0;
}
Beispiel #4
0
int main()
{
  TraceToConsole();

  TF0("This to output.");

  char fileName[] = "log.txt";
  TraceToFile(fileName);

  TF1("Tracing was switched to file %s", fileName); 

  TraceToConsole();

  TraceExclude("test.cpp");

  TF0("This won't be seen, test.cpp was excluded");
}
Beispiel #5
0
void test_TF1_FitErr2(){

  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(0);

   histgen();
   TFile *f = new TFile("background.root");
   background = (TH1F*)f->Get("background"); //pointer used in ftotal
   TH1F *result = (TH1F*)f->Get("result");
   TF1 *ftot = new TF1("ftot",ftotal,0,10,5);
   Double_t norm = result->GetMaximum();
//   ftot->SetParameters(0.5*norm,5,.2,norm);
   ftot->SetParameters(0.5*norm,6,.5,5,-0.5);
   ftot->SetParLimits(0,.3*norm,norm);
//	 ftot->FixParameter(1,6);
//	 ftot->FixParameter(2,0.5);
	 ftot->SetParLimits(1,5.5,6.5);
	 ftot->SetParLimits(2,0.25,1);
//	 ftot->SetParLimits(4,-0.01,-50);
   result->Fit("ftot","b");
   result->Fit("ftot","b");
   result->Fit("ftot","b");
   result->Fit("ftot");
   result->Fit("ftot");
   result->Fit("ftot");

	 TFitResult fitResult=result->Fit("ftot");

	 double 


	 TF1 *bgf = TF1("bgf","pol1",0,10);
	 



}