当前位置: 首页>>代码示例>>C++>>正文


C++ TH2::GetNbinsX方法代码示例

本文整理汇总了C++中TH2::GetNbinsX方法的典型用法代码示例。如果您正苦于以下问题:C++ TH2::GetNbinsX方法的具体用法?C++ TH2::GetNbinsX怎么用?C++ TH2::GetNbinsX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TH2的用法示例。


在下文中一共展示了TH2::GetNbinsX方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: doSmooth

TH2* doSmooth (TH2* hRaw, bool useLog = true) {
    //
    // smooth histogram
    //
    TH2* hSmooth = (TH2*)hRaw->Clone("hSmooth");
    hSmooth->SetTitle("hSmooth");
    if ( useLog ) {
        for ( int ix=1; ix<=hSmooth->GetNbinsX(); ++ix ) {
            for ( int iy=1; iy<=hSmooth->GetNbinsY(); ++iy ) {
                double c = hSmooth->GetBinContent(ix,iy);
                c = c>0. ? log(c) : -100.;
                hSmooth->SetBinContent(ix,iy,c);
            }
        }
    }
    fitLinear(hSmooth,hRaw);

    if ( useLog ) {
        for ( int ix=1; ix<=hSmooth->GetNbinsX(); ++ix ) {
            for ( int iy=1; iy<=hSmooth->GetNbinsY(); ++iy ) {
                double craw = hRaw->GetBinContent(ix,iy);
                double c = hSmooth->GetBinContent(ix,iy);
                c = craw>0. ? exp(c) : 0.;
                hSmooth->SetBinContent(ix,iy,c);
            }
        }
    }
    hSmooth->SetName(hRaw->GetName());

    return hSmooth;
}
开发者ID:wa01,项目名称:Workspace,代码行数:31,代码来源:LimitSmoothing.C

示例2: abortException

void SF_TH2F_And_Eff::init(string filename,string effdata,string effmc,string errordata,string errormc)
{
    f = TFile::Open(filename.c_str() ) ;

    if (f == NULL){
        Log(__FUNCTION__,"ERROR","file '" + filename + "' does not exist");
        throw abortException() ;
    }

    TH2 * hDataEff = getHisto(effdata);
    TH2 * hDataErr = NULL;
    if (errordata != "" ) hDataErr = getHisto(errordata);
    TH2 * hMcEff = getHisto(effmc);
    TH2 * hMcErr = NULL;
    if (errormc != "" ) hMcErr = getHisto(errormc);


    for( int aetabin =1; aetabin <= hDataEff->GetNbinsX() ; ++aetabin)
    for( int ptbin =1; ptbin <= hDataEff->GetNbinsY() ; ++ptbin)
    {
        float ptmin = hDataEff->GetYaxis()->GetBinLowEdge(ptbin); 
        float ptmax = hDataEff->GetYaxis()->GetBinLowEdge(ptbin+1); 
        float aetamin = hDataEff->GetXaxis()->GetBinLowEdge(aetabin); 
        float aetamax = hDataEff->GetXaxis()->GetBinLowEdge(aetabin+1); 
        float effData = hDataEff->GetBinContent(aetabin,ptbin);
        float errData = 0.0 ;
        if (hDataErr) err=hDataErr->GetBinContent(aetabin,ptbin);
        else errData = hDataEff->GetBinError(aetabin,ptbin);

        float effMc = hMcEff->GetBinContent(aetabin,ptbin);
        float errMc = 0.0; 
        if (hMcEff) errMc = hMcEff->GetBinContent(aetabin,ptbin);
        else errMc = hMcEff->GetBinError(aetabin,ptbin);

        if (ptbin == hDataEff->GetNbinsY() ) ptmax = 8000.; // highest is open, current recommendation
        if (aetabin == hDataEff->GetNbinsX()  ) aetamax = aetamax+0.0001; // put it slightly larger  to get 2.4 as well
        add(ptmin,ptmax,aetamin,aetamax,effData,effMc,errData,errMc);
    }
    f->Close(); // delete?
    delete f;
    f = NULL;
}
开发者ID:amarini,项目名称:ChargedHiggs,代码行数:42,代码来源:SF.cpp

示例3: SetBorders

void SetBorders( TH2 &hist, Double_t val=0 )
{
    int numx = hist.GetNbinsX();
    int numy = hist.GetNbinsY();

    for(int i=0; i <= numx+1 ; i++){
        hist.SetBinContent(i,0,val);
        hist.SetBinContent(i,numy+1,val);
    }
    for(int i=0; i <= numy+1 ; i++) {
        hist.SetBinContent(0,i,val);
        hist.SetBinContent(numx+1,i,val);
    }
}
开发者ID:lawrenceleejr,项目名称:ZeroLeptonAnalysis,代码行数:14,代码来源:SUSY_bRPV_m0_vs_m12_all_withBand_cls.C

示例4: normalizeMigMat

// normalize migmatrix column-wise
TH2* normalizeMigMat(TH2* h)
{
  TH2* hclone = (TH2*) h->Clone();
  const int xbins = hclone->GetNbinsX();
  const int ybins = hclone->GetNbinsY();
    
  for(int x=0; x<xbins; x++)  
  {
    double integ = hclone->Integral(x+1, x+1, 1, ybins);
    for(int y=0; y<ybins; y++)
    {
      hclone->SetBinContent(x+1,y+1, hclone->GetBinContent(x+1, y+1)/integ);
    }
  }
  
  return hclone;
}
开发者ID:fhoehle,项目名称:UnfoldingIPHC,代码行数:18,代码来源:helpers.hpp

示例5: MirrorBorders

void MirrorBorders( TH2& hist ) {
    int numx = hist.GetNbinsX();
    int numy = hist.GetNbinsY();

    Float_t val;
    // corner points
    hist.SetBinContent(0,0,hist.GetBinContent(1,1));
    hist.SetBinContent(numx+1,numy+1,hist.GetBinContent(numx,numy));
    hist.SetBinContent(numx+1,0,hist.GetBinContent(numx,1));
    hist.SetBinContent(0,numy+1,hist.GetBinContent(1,numy));

    for(int i=1; i<=numx; i++){
        hist.SetBinContent(i,0,	   hist.GetBinContent(i,1));
        hist.SetBinContent(i,numy+1, hist.GetBinContent(i,numy));
    }
    for(int i=1; i<=numy; i++) {
        hist.SetBinContent(0,i,      hist.GetBinContent(1,i));
        hist.SetBinContent(numx+1,i, hist.GetBinContent(numx,i));
    }
}
开发者ID:lawrenceleejr,项目名称:ZeroLeptonAnalysis,代码行数:20,代码来源:SUSY_bRPV_m0_vs_m12_all_withBand_cls.C

示例6: smoothHoles

TH2* smoothHoles(const TH2* originalHist)
{
  TH2* hist = (TH2*)originalHist->Clone("_smoothed");
  int xMax = hist->GetNbinsX();
  int yMax = hist->GetNbinsY();

  int xMin = 0;
  
  for(int xBin = 1; xBin <= xMax; xBin++)
    {
      for(int yBin = 1; yBin <= yMax; yBin++)
	{
	  if(hist->GetBinContent(xBin,yBin)>0)
	    {
	      xMin = xBin;
	      yBin = yMax+1;
	      xBin = xMax+1;
	    }
	}
    } 
  //  for(unsigned int i = 0; i< 1000; i++) smoothHistAcross(hist,xMin);
  for(unsigned int i = 0; i< 1000; i++) interpolateHistAcross(hist,xMin);
  return hist;
}
开发者ID:SusyRa2b,项目名称:NtupleTools,代码行数:24,代码来源:ExclusionPlot.C

示例7: TCanvas

TH1 *
UnfoldMe_MB2(const Char_t *data, const Char_t *mc, const Char_t *anatag, Int_t bin, Bool_t useMBcorr , Bool_t usecorrfit , Bool_t ismc , Float_t smooth , Int_t iter , Int_t regul , Float_t weight , Bool_t bayesian , Int_t nloop )
{

  // MF comments:
  // usedMBcorr: changes the matrix used for unfonding, from effMatrix to bin matrix (I think this is just to use mult dependent v s mb correction_)
  // usecorrfit: if I understand correctly, fits the response matrix and uses fit to extrapolate it

  
  TFile *fdt =0;
  if (ismc)
    fdt =  TFile::Open(data);
  else
    fdt = TFile::Open(data);
  TFile *fmc = TFile::Open(mc);

  TList *ldt = (TList *)fdt->Get(Form("%s", anatag));
  TList *lmc = (TList *)fmc->Get(Form("%s", anatag));
  
  TH2 *hmatdt = (TH2 *)ldt->FindObject(Form(responseMatrix, bin));
  TH2 *hmatmc = 0;
  if (useMBcorr){
     hmatmc = (TH2 *)lmc->FindObject("effMatrix");
     std::cout << "USING MB" << std::endl;
     
  }
  else {
    hmatmc = (TH2 *)lmc->FindObject(Form(responseMatrix, bin));
  }

  TH1 *hdata = hmatdt->ProjectionY("hdata");
//  TH1 *hdata = hmatdt->ProjectionY("htrue");  // For truth Only Calculations

  hdata->Sumw2();
  hdata->SetBinContent(1, 0.);
  hdata->SetBinError(1, 0.);
  //  hdata->Scale(1. / hdata->Integral());
  hdata->SetMarkerStyle(25);
  TH1 *htrue = hmatdt->ProjectionX("htrue");
  htrue->Sumw2();
  //  htrue->Scale(1. / htrue->Integral());
  htrue->SetMarkerStyle(7);
  htrue->SetMarkerColor(2);
  htrue->SetBinContent(1, 0.);
  htrue->SetBinError(1, 0.);

  TH2 *hcorr = (TH2 *)hmatmc->Clone("hcorr");
  TH1 *hinit = (TH1 *)hdata->Clone("hinit");
  TH1 *hresu = (TH1 *)hdata->Clone("hresu");
  TH1 *hbias = (TH1 *)hdata->Clone("hbias");
  hresu->SetMarkerStyle(20);
  hresu->SetMarkerColor(4);
  hresu->Reset();

  TH1 *hnum = hcorr->ProjectionY("hnum");
  TH1 *hden = hcorr->ProjectionY("hden");
  TH1 *heff = hcorr->ProjectionY("heff");
  hnum->Reset();
  hnum->Sumw2();
  hden->Reset();
  hden->Sumw2();
  heff->Reset();
  for (Int_t i = 0; i < heff->GetNbinsX(); i++) {
    Float_t int1 = hcorr->Integral(i + 1, i + 1, 0, -1);
    if (int1 <= 0.) continue;
    Float_t int2 = hcorr->Integral(i + 1, i + 1, 2, -1);
    hnum->SetBinContent(i + 1, int2);
    hnum->SetBinError(i + 1, TMath::Sqrt(int2));
    hden->SetBinContent(i + 1, int1);
    hden->SetBinError(i + 1, TMath::Sqrt(int1));
  }
  TCanvas *cEfficiency = new TCanvas("cEfficiency", "cEfficiency");
  cEfficiency->SetLogx();
  cEfficiency->SetLogy();

  heff->Divide(hnum, hden, 1., 1., "B");
  heff->Draw();
#if 0
  for (Int_t ii = 0; ii < heff->GetNbinsX(); ii++) {
    heff->SetBinContent(ii + 1, 1.);
    heff->SetBinError(ii + 1, 0.);
  }
#endif

  for (Int_t i = 0; i < hcorr->GetNbinsX(); i++) {
    hcorr->SetBinContent(i + 1, 1, 0.);
    hcorr->SetBinError(i + 1, 1, 0.);
  }
  for (Int_t i = 0; i < hcorr->GetNbinsY(); i++) {
    hcorr->SetBinContent(1, i + 1, 0.);
    hcorr->SetBinError(1, i + 1, 0.);
  }
  TH2 *hcorrfit = ReturnCorrFromFit(hcorr);
  // Docs from AliUnfolding
  //Int_t AliUnfolding::Unfold(TH2* correlation, TH1* efficiency, TH1* measured, TH1* initialConditions, TH1* result, Bool_t check)
  // unfolds with unfolding method fgMethodType
  //
  // parameters:
  //  correlation: response matrix as measured vs. generated
  //  efficiency:  (optional) efficiency that is applied on the unfolded spectrum, i.e. it has to be in unfolded variables. If 0 no efficiency is applied.
//.........这里部分代码省略.........
开发者ID:ktf,项目名称:AliPhysics,代码行数:101,代码来源:playV0M.C

示例8: TCanvas

TH1 *
UnfoldMe(Char_t *data, Char_t *mc, Char_t *anatag, Int_t bin, Bool_t useMBcorr = kTRUE, Bool_t usecorrfit = kFALSE, Bool_t ismc = kFALSE, Float_t smooth = 0.001, Int_t iter = 50, Int_t regul = AliUnfolding::kPowerLaw, Float_t weight = 100., Bool_t bayesian = kTRUE, Int_t nloop = 1)
{

  if (ismc)
    TFile *fdt = TFile::Open(data);
  else
    TFile *fdt = TFile::Open(data);
  TFile *fmc = TFile::Open(mc);
  
  TList *ldt = (TList *)fdt->Get(Form("clist_%s", anatag));
  TList *lmc = (TList *)fmc->Get(Form("clist_%s", anatag));
  
  TH2 *hmatdt = (TH2 *)ldt->FindObject(Form("b%d_corrMatrix", bin));
  if (useMBcorr)
    TH2 *hmatmc = (TH2 *)lmc->FindObject("effMatrix");
  else
    TH2 *hmatmc = (TH2 *)lmc->FindObject(Form("b%d_corrMatrix", bin));
 
  TH1 *hdata = hmatdt->ProjectionY("hdata");
  hdata->Sumw2();
  hdata->SetBinContent(1, 0.);
  hdata->SetBinError(1, 0.);
  //  hdata->Scale(1. / hdata->Integral());
  hdata->SetMarkerStyle(25);
  TH1 *htrue = hmatdt->ProjectionX("htrue");
  htrue->Sumw2();
  //  htrue->Scale(1. / htrue->Integral());
  htrue->SetMarkerStyle(7);
  htrue->SetMarkerColor(2);
  htrue->SetBinContent(1, 0.);
  htrue->SetBinError(1, 0.);
  TH2 *hcorr = (TH2 *)hmatmc->Clone("hcorr");
  TH1 *hinit = (TH1 *)hdata->Clone("hinit");
  TH1 *hresu = (TH1 *)hdata->Clone("hresu");
  TH1 *hbias = (TH1 *)hdata->Clone("hbias");
  hresu->SetMarkerStyle(20);
  hresu->SetMarkerColor(4);
  hresu->Reset();

  TH1 *hnum = hcorr->ProjectionY("hnum");
  TH1 *hden = hcorr->ProjectionY("hden");
  TH1 *heff = hcorr->ProjectionY("heff");
  hnum->Reset();
  hnum->Sumw2();
  hden->Reset();
  hden->Sumw2();
  heff->Reset();
  for (Int_t i = 0; i < heff->GetNbinsX(); i++) {
    Float_t int1 = hcorr->Integral(i + 1, i + 1, 0, -1);
    if (int1 <= 0.) continue;
    Float_t int2 = hcorr->Integral(i + 1, i + 1, 2, -1);
    hnum->SetBinContent(i + 1, int2);
    hnum->SetBinError(i + 1, TMath::Sqrt(int2));
    hden->SetBinContent(i + 1, int1);
    hden->SetBinError(i + 1, TMath::Sqrt(int1));
  }
  new TCanvas("cEfficiency");
  heff->Divide(hnum, hden, 1., 1., "B");
  heff->Draw();
#if 0
  for (Int_t ii = 0; ii < heff->GetNbinsX(); ii++) {
    heff->SetBinContent(ii + 1, 1.);
    heff->SetBinError(ii + 1, 0.);
  }
#endif
  
  for (Int_t i = 0; i < hcorr->GetNbinsX(); i++) {
    hcorr->SetBinContent(i + 1, 1, 0.);
    hcorr->SetBinError(i + 1, 1, 0.);
  }
  for (Int_t i = 0; i < hcorr->GetNbinsY(); i++) {
    hcorr->SetBinContent(1, i + 1, 0.);
    hcorr->SetBinError(1, i + 1, 0.);
  }
  TH2 *hcorrfit = ReturnCorrFromFit(hcorr);

  for (Int_t iloop = 0; iloop < nloop; iloop++) {
    if (bayesian) {
      AliUnfolding::SetUnfoldingMethod(AliUnfolding::kBayesian);
      AliUnfolding::SetBayesianParameters(smooth, iter);
    } else {
      AliUnfolding::SetUnfoldingMethod(AliUnfolding::kChi2Minimization);
      AliUnfolding::SetChi2Regularization(regul, weight);
    }
    AliUnfolding::SetSkip0BinInChi2(kTRUE);
    AliUnfolding::SetSkipBinsBegin(1);
    AliUnfolding::SetNbins(150, 150);
    AliUnfolding::Unfold(usecorrfit ? hcorrfit : hcorr, heff, hdata, hinit, hresu);
    hinit = (TH1 *)hresu->Clone(Form("hinit_%d", iloop));
  }

  printf("hdata->Integral(2, -1) = %f\n", hdata->Integral(2, -1));
  printf("hresu->Integral(2, -1) = %f\n", hresu->Integral(2, -1));
  
  
  TCanvas *cUnfolded = new TCanvas ("cUnfolded", "", 400, 800);
  cUnfolded->Divide(1, 2);
  cUnfolded->cd(1)->SetLogx();
  cUnfolded->cd(1)->SetLogy();
//.........这里部分代码省略.........
开发者ID:ktf,项目名称:AliPhysics,代码行数:101,代码来源:UnfoldMe.C

示例9: Warning

void
TestSPD(const TString& which, Double_t nVar=2)
{
  TFile* file = TFile::Open("forward.root", "READ");
  if (!file) return;

  Bool_t spd = which.EqualTo("spd", TString::kIgnoreCase);
  
  TList* l = 0;
  if (spd) l = static_cast<TList*>(file->Get("CentralSums"));
  else     l = static_cast<TList*>(file->Get("ForwardSums"));
  if (!l) { 
    Warning("", "%sSums not found", spd ? "Central" : "Forward");
    return;
  }

  TList* ei = static_cast<TList*>(l->FindObject("fmdEventInspector"));
  if (!l) { 
    Warning("", "fmdEventInspector not found");
    return;
  }
  
  TObject* run = ei->FindObject("runNo");
  if (!run) 
    Warning("", "No run number found");
  ULong_t runNo = run ? run->GetUniqueID() : 0;

  TH2* h = 0;
  if (spd) h = static_cast<TH2*>(l->FindObject("nClusterVsnTracklet"));
  else { 
    TList* den = static_cast<TList*>(l->FindObject("fmdDensityCalculator"));
    if (!den) { 
      Error("", "fmdDensityCalculator not found");
      return;
    }
    TList* rng = static_cast<TList*>(den->FindObject(which));
    if (!rng) { 
      Error("", "%s not found", which.Data());
      return;
    }
    h = static_cast<TH2*>(rng->FindObject("elossVsPoisson"));
  }
  if (!h) { 
    Warning("", "%s not found", spd ? nClusterVsnTracklet : "elossVsPoisson");
    return;
  }

  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(0);
  TCanvas* c = new TCanvas("c", Form("Run %u", runNo));
  c->Divide(2,2);
  
  TVirtualPad* p = c->cd(1);
  if (spd) {
    p->SetLogx();
    p->SetLogy();
  }
  p->SetLogz();
  h->Draw("colz");

  TObjArray* fits = new TObjArray;
  h->FitSlicesY(0, 1, -1, 0, "QN", fits);

  TF1* mean = new TF1("mean", "pol1");
  TF1* var  = new TF1("var", "pol1");
  // mean->FixParameter(0, 0);
  // var->FixParameter(0, 0);
  for (Int_t i = 0; i < 3; i++) { 
    p = c->cd(2+i);
    if (spd) { 
      p->SetLogx();
      p->SetLogy();
    }
    TH1* hh = static_cast<TH1*>(fits->At(i));
    hh->Draw();

    if (i == 0) continue;
    
    hh->Fit((i == 1? mean : var), "+Q");
    
  }

  TGraphErrors* g1 = new TGraphErrors(h->GetNbinsX());
  g1->SetFillColor(kBlue-10);
  g1->SetFillStyle(3001);
  g1->SetLineStyle(1);
  TGraph* u1 = new TGraph(h->GetNbinsX());
  TGraph* l1 = new TGraph(h->GetNbinsX());
  u1->SetLineColor(kBlue+1);
  l1->SetLineColor(kBlue+1);
  u1->SetName("u1");
  l1->SetName("l1");
  TGraphErrors* g2 = new TGraphErrors(h->GetNbinsX());
  g2->SetFillColor(kRed-10);
  g2->SetFillStyle(3001);
  g2->SetLineStyle(2);
  TGraph* u2 = new TGraph(h->GetNbinsX());
  TGraph* l2 = new TGraph(h->GetNbinsX());
  u2->SetLineColor(kRed+1);
  l2->SetLineColor(kRed+1);
//.........这里部分代码省略.........
开发者ID:ktf,项目名称:AliPhysics,代码行数:101,代码来源:Outliers.C

示例10: fitQuadratic

//
// fill missing bins in histogram h fitting a plane to the
//   surrounding bins
//
void fitQuadratic (TH2* h, TH2* refHisto, int nmin=9, int nmin2=12) {
    //
    // prepare histogram
    //
    TH2* hOrig = (TH2*)h->Clone();
    int nbx = hOrig->GetNbinsX();
    int nby = hOrig->GetNbinsY();
    //
    // matrix and vector for fit
    //
    TMatrixD mat(6,6);
    TVectorD cvec(6);
    //
    // loop over histogram
    //
    for ( int ix=1; ix<=nbx; ++ix ) {
        for ( int iy=1; iy<=nby; ++iy ) {
            // clear matrix and vector used for fit
            int nn(0);
            for ( int i=0; i<6; ++i ) {
                cvec(i) = 0.;
                for ( int j=0; j<6; ++j ) mat(i,j) = 0.;
            }
            // loop over neighbours
            for ( int jx=-1; jx<2; ++jx ) {
                for ( int jy=-1; jy<2; ++jy ) {
                    if ( (ix+jx)<1 || (ix+jx)>nbx )  continue;
                    if ( (iy+jy)<1 || (iy+jy)>nby )  continue;
                    // fill vector and matrix
                    fillForQuadFit(hOrig,refHisto,ix,iy,jx,jy,nn,mat,cvec);
                }
            }
            for ( int jx=1; jx<6; ++jx ) {
                for ( int jy=0; jy<jx; ++jy )  mat(jx,jy) = mat(jy,jx);
            }
            // if < nmin neighbours in delta_i==1: try to add delta_i==2
            if ( nn<nmin ) {
                // loop over neighbours
                for ( int jx=-2; jx<3; ++jx ) {
                    for ( int jy=-2; jy<3; ++jy ) {
                        // skip the central bin (the one to be filled)
                        if ( abs(jx)<2 && abs(jy)<2 )  continue;
                        if ( (ix+jx)<1 || (ix+jx)>nbx )  continue;
                        if ( (iy+jy)<1 || (iy+jy)>nby )  continue;
                        // fill vector and matrix
                        fillForQuadFit(hOrig,refHisto,ix,iy,jx,jy,nn,mat,cvec);
                    }
                }
                for ( int jx=1; jx<6; ++jx ) {
                    for ( int jy=0; jy<jx; ++jy )  mat(jx,jy) = mat(jy,jx);
                }
                // drop bin if <nmin2 in 5x5 area
                if ( nn<nmin2 ) continue;
            }
//       cout << "x / y = " << h->GetXaxis()->GetBinCenter(ix) << " "
//                          << h->GetYaxis()->GetBinCenter(iy) << endl;
            //
            // linear 2D fit to neighbours (in units of bin number):
            //   par(0)*(x-ix)+par(1)*(y-iy)+par(2)
            //
            double det = mat.Determinant();
            if ( det < 1.e-6 )  std::cout << "************* " << det << std::endl;
            if ( det < 1.e-6 )  continue;
//       TMatrixD mat1(mat);
            mat.Invert(&det);
            TVectorD par = mat*cvec;
//       TVectorD tmp = mat1*par;
            h->SetBinContent(ix,iy,par(5));
        }
    }
    delete hOrig;
}
开发者ID:wa01,项目名称:Workspace,代码行数:76,代码来源:LimitSmoothing.C

示例11: fullPedestalAnalysis


//.........这里部分代码省略.........
  TH1F* randomHisto = NULL;
  TFitResultPtr result;
  for(auto file : fileList){
    cout<<"input file: "<<file<<endl;
    TFile* inputFile = TFile::Open(file.c_str(),"READ");
    inputFile->cd();
    // take into account that the DQM file structure for strips is always the same --> use cabling map to browse the histograms
    reader.SetEntry(0);
    TH2* histoNoise = NULL;
    long int iChannel = 0;
    int noFitResult = 0;
    while(reader.Next()){
      cout.flush();
      if(iChannel %10 == 0) cout<<"\r"<<"iChannel "<<100*double(iChannel)/(readoutMap->GetEntries()/reductionFactor)<<" % ";
      if(iChannel > double(readoutMap->GetEntries())/reductionFactor) break;
      iChannel++;
      TString objName;
      uint32_t fedKey =  SiStripFedKey(*fedId,SiStripFedKey::feUnit(*fedCh),SiStripFedKey::feChan(*fedCh)).key();
      std::stringstream stream;
      stream << std::hex << fedKey;
      string fedKeyStr = stream.str();
      if(fedKeyStr.size() == 4)
	objName = Form("DQMData/SiStrip/ControlView/FecCrate%d/FecSlot%d/FecRing%d/CcuAddr%d/CcuChan%d/ExpertHisto_PedsFullNoise_FedKey0x0000%s_LldChannel%d_Noise2D",*fecCrate,*fecSlot,*fecRing,*ccuAdd,*ccuChan,fedKeyStr.c_str(),*lldChannel);      
      else if(fedKeyStr.size() == 5)
	objName = Form("DQMData/SiStrip/ControlView/FecCrate%d/FecSlot%d/FecRing%d/CcuAddr%d/CcuChan%d/ExpertHisto_PedsFullNoise_FedKey0x000%s_LldChannel%d_Noise2D",*fecCrate,*fecSlot,*fecRing,*ccuAdd,*ccuChan,fedKeyStr.c_str(),*lldChannel);      
      else
	cerr<<"hex number to short "<<fedKeyStr<<" --> please check "<<endl;

      inputFile->GetObject(objName.Data(),histoNoise);
      // extract single strip noise histogram --> loop on the y-axis
      uint16_t apvID = 0;
      uint16_t stripID = 0;       
      if(histoNoiseStrip == 0 or histoNoiseStrip == NULL){
	histoNoiseStrip = new TH1F ("histoNoiseStrip","",histoNoise->GetNbinsX(),histoNoise->GetXaxis()->GetXmin(),histoNoise->GetXaxis()->GetXmax());
	histoNoiseStrip->Sumw2();
      }
      for(int iBinY = 0; iBinY < histoNoise->GetNbinsY(); iBinY++){
	histoNoiseStrip->Reset();
	histoNoiseStrip->SetDirectory(0);
	// two multiplexed APV per line
	if(iBinY < histoNoise->GetNbinsY()/2) apvID = 1;
	else apvID = 2;
	// strip id
	stripID++;
	if(stripID > 128) stripID = 1;
	// loop on x-axis bin
	for(int iBinX = 0; iBinX < histoNoise->GetNbinsX(); iBinX++){
	  histoNoiseStrip->SetBinContent(iBinX+1,histoNoise->GetBinContent(iBinX+1,iBinY+1));
	  histoNoiseStrip->SetBinError(iBinX+1,histoNoise->GetBinError(iBinX+1,iBinY+1));	    
	}
     	
	// to initialize branches
	detid_ = 0; fedKey_ = 0; fecCrate_ = 0; fecSlot_ = 0; fecRing_ = 0; ccuAdd_ = 0; ccuChan_ = 0; lldChannel_ = 0; fedId_ = 0; fedCh_ = 0; apvId_ = 0; stripId_ = 0; 
	noiseMean_ = 0.; noiseRMS_ =  0.; noiseSkewness_ = 0.; noiseKurtosis_ = 0.; 
	fitGausMean_ = 0.; fitGausSigma_ = 0.;fitGausNormalization_ = 0.;
	fitGausMeanError_ = 0.; fitGausSigmaError_ = 0.;fitGausNormalizationError_ = 0.;	  	  
	fitChi2_ = 0.; fitChi2Probab_ = 0.; fitStatus_ = -1.; 
	noiseIntegral3Sigma_ = 0.; noiseIntegral3SigmaFromFit_ = 0.; 
	noiseIntegral4Sigma_ = 0.; noiseIntegral4SigmaFromFit_ = 0.; 
	noiseIntegral5Sigma_ = 0.; noiseIntegral5SigmaFromFit_ = 0.; 
	kSProbab_ = 0.; jBProbab_ = 0.;
	kSValue_ = 0.; jBValue_ = 0.; 
	aDValue_= 0.; aDProbab_ = 0.;
	nBin_ = 0.; xMin_ = 0.; xMax_ = 0.;
	
	// basic info
开发者ID:rgerosa,项目名称:TrackerDAQAnalysis,代码行数:67,代码来源:fullPedestalAnalysis.C


注:本文中的TH2::GetNbinsX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。