Exemplo n.º 1
0
void makeTable(TString rootfilename, 
	       TString histname, char* tablefilename)
{

  TFile myhistos(rootfilename); 
  TH2F* h = (TH2F*) myhistos.Get(histname);
  int nX = h->GetNbinsX();
  int nY = h->GetNbinsY();


  FILE *file = fopen(tablefilename,"w+");


  for(int i=1; i<=nX; ++i) {
  
    Double_t pT0 = h->GetXaxis()->GetBinLowEdge(i);
    Double_t pT1 = h->GetXaxis()->GetBinLowEdge(i+1);

    for(int j=1; j<=nY; ++j) {
      Double_t x = h->GetBinContent(i,j);
      Double_t dx = 8.0 * h->GetBinError(i,j);
      if( dx > 1.0 ) dx = 1.0;
      Double_t eta0 = h->GetYaxis()->GetBinLowEdge(j);
      Double_t eta1 = h->GetYaxis()->GetBinLowEdge(j+1);

      fprintf( file ,"%4.1f  %4.1f   %+6.4f   %+6.4f  %6.4f   %6.4f \n", 
	       pT0, pT1, eta0, eta1, x, dx);
    }
  }

  fclose(file);
}
Exemplo n.º 2
0
void Apertures::PlotFrame(double xmin,double xmax,double ymin,double ymax)
{
  Int_t wtopx=500,wtopy=60; // hbu position on screen, a bit shifted to right
  // unsigned int kSizePt=700;
  unsigned int kSizePt=1000; // size in points   here used for both directions, to get square
  c2=new TCanvas("c2","PlotFrame",wtopx,wtopy,kSizePt,kSizePt); // kSizePt set in rootlogon.C

  Float_t xsize=20,ysize=20;	// standard 20 cm * 20 cm window
  c2->Size(xsize,ysize); // set size for Postscript

  gStyle->SetLabelSize(k12pt,"xyz");  // axis numbers text size

  // keep the frame boundaries for possible later use
  this->xmin=xmin;
  this->xmax=xmax;
  this->ymin=ymin;
  this->ymax=ymax;

  if(verbose>1) cout << "Apertures::Plot_tfs" << '\n';
  double xrange=500;
  TH2F* hpx = new TH2F("s","",10,xmin,xmax,10,ymin,ymax);
  hpx->SetStats(kFALSE); // no statistics
  hpx->GetXaxis()->SetTitleOffset(1.3); // more space between numbers and x-axis title
  hpx->GetYaxis()->SetTitleOffset(1.3); // more space between numbers and y-axis title
  hpx->GetXaxis()->SetTitle("z[m]");
  hpx->GetYaxis()->SetTitle("x,y[m]");  hpx->Draw(); // after this hpx not needed any more
  hpx->Draw();

  TLine* ZeroYLine=new TLine(-xrange,0,xrange,0); ZeroYLine->Draw(); // draw a horizontal line a y = 0
  TLine* ZeroXLine=new TLine(0,-0.01,0,0.01);     ZeroXLine->Draw(); // draw a vertical   line a x = 0
}
Exemplo n.º 3
0
//================================================
void DeltaZVsPt(const Int_t save = 0)
{
  THnSparseF *hn = (THnSparseF*)f->Get(Form("mhTrkDzDy_%s",trigName[kTrigType]));
  TH2F *hTrkDzVsPt = (TH2F*)hn->Projection(1,0);
  c = draw2D(hTrkDzVsPt,Form("%s: #Deltaz of matched track-hit pairs",trigName[kTrigType]));
  if(save) 
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_vs_pt_%s.pdf",run_type,trigName[kTrigType]));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_vs_pt_%s.png",run_type,trigName[kTrigType]));
    }

  Double_t pt_cut = 1;
  hTrkDzVsPt->GetXaxis()->SetRangeUser(pt_cut+0.1,100);
  TH1F *hMthDz = (TH1F*)hTrkDzVsPt->ProjectionY(Form("hTrkDzVsPt_%s_proj",trigName[kTrigType]));
  hMthDz->SetTitle(Form("%s: #Deltaz of matched track-hit pairs (p_{T}>%1.1f GeV/c);#Deltaz (cm)",trigName[kTrigType],pt_cut));
  TH1F *hClone = (TH1F*)hMthDz->Clone(Form("%s_clone",hMthDz->GetName()));
  c = draw1D(hClone,"",kFALSE,kFALSE);
  if(save) 
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_%s.pdf",run_type,trigName[kTrigType]));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_%s.png",run_type,trigName[kTrigType]));
    }

  Double_t range = 50;
  TF1 *func = new TF1("func","gaus(0)+gaus(3)",-1*range,range);
  func->SetParameters(10000,0,10,1000,0,40);
  c = FitDeltaZ(hMthDz,func,range,20.);
  if(save) 
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%s.pdf",run_type,pt_cut,trigName[kTrigType]));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%s.png",run_type,pt_cut,trigName[kTrigType]));
    }

  // pt dependence
  Double_t pt_cuts[5] = {1,2,3,5,20};
  for(Int_t i=0; i<4; i++)
    {
      hTrkDzVsPt->GetXaxis()->SetRangeUser(pt_cuts[i]+0.1,pt_cuts[i+1]-0.1);
      TH1F *htmp = (TH1F*)hTrkDzVsPt->ProjectionY(Form("hTrkDz_pt%1.0f-%1.0f_%s",pt_cuts[i],pt_cuts[i+1],trigName[kTrigType]));
      htmp->SetTitle(Form("%s: #Deltaz of matched track-hit pairs (%1.0f < p_{T} < %1.0f GeV/c);#Deltaz (cm)",trigName[kTrigType],pt_cuts[i],pt_cuts[i+1]));

      TF1 *func = new TF1(Form("func_pt%1.0f-%1.0f",pt_cuts[i],pt_cuts[i+1]),"gaus(0)+gaus(3)",-1*range,range);
      if(i==0) func->SetParameters(100,0,100,1000,0,10);
      if(i==1) func->SetParameters(1000,0,15,1000,0,60);
      if(i==2) func->SetParameters(1000,0,15,1000,0,60);
      if(i==3) func->SetParameters(1000,0,60,1000,0,15);
      c = FitDeltaZ(htmp,func,range,20.);
      if(save) 
	{
	  c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%1.0f_%s.pdf",run_type,pt_cuts[i],pt_cuts[i+1],trigName[kTrigType]));
	  c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%1.0f_%s.png",run_type,pt_cuts[i],pt_cuts[i+1],trigName[kTrigType]));
	}
    }
 
}
Exemplo n.º 4
0
TH2F* Bin2DTree::fillHistogram()
/*****************************************************************/
{
        if(!m_gridConstraint)
        {
            cerr<<"ERROR: Bin2DLeaf.fillHistogram(): Trying to fill histogram, but the binning is unknown. Define first the gridConstraint.\n";
            exit(1);
        }
        TH2F* histo = (TH2F*)m_gridConstraint->Clone("histoFromTree");
        int nbinsx = histo->GetNbinsX();
        int nbinsy = histo->GetNbinsY();
        map<Bin2DLeaf*, vector< pair<int,int> > > binsInLeaf;
        // First find the list of TH2 bins for each Bin2DLeaf bin
        for(int bx=1;bx<nbinsx+1;bx++) 
        {
            for(int by=1;by<nbinsy+1;by++)
            {
                histo->SetBinContent(bx,by,0);
                histo->SetBinError(bx,by,0);
                double x = histo->GetXaxis()->GetBinCenter(bx);
                double y = histo->GetYaxis()->GetBinCenter(by);
                Bin2DLeaf* leaf = getLeaf(x,y);
                if(binsInLeaf.find(leaf)==binsInLeaf.end())
                {
                    vector< pair<int,int> > empty;
                    binsInLeaf[leaf] = empty;
                }
                binsInLeaf[leaf].push_back(make_pair(bx,by));
            }
        }
        // Then all the TH2 bins are filled according to the entries in the Bin2DLeaf bins
        map<Bin2DLeaf*, vector< pair<int,int> > >::iterator it = binsInLeaf.begin();
        map<Bin2DLeaf*, vector< pair<int,int> > >::iterator itE = binsInLeaf.end();
        for(;it!=itE;++it)
        {
            Bin2DLeaf* leaf = it->first;
            vector< pair<int,int> > bins = it->second;
            vector< vector<double> > entries = leaf->getEntries();
            int nbins = bins.size();
            for(int b=0;b<nbins;b++)
            {
                int bx = bins[b].first;
                int by = bins[b].second;
                double x = histo->GetXaxis()->GetBinCenter(bx);
                double y = histo->GetYaxis()->GetBinCenter(by);
                for(unsigned int e=0;e<entries.size();e++)
                {
                    double value = entries[e][2]/(double)nbins;
                    histo->Fill(x,y,value);
                }
            }
        }
        return histo;
}
Exemplo n.º 5
0
//2d reweighting of rho and its sigma
void reweight_rhosigma(TH1F* weight_rho, TH1F* weight_rhoo,TH2F*weight_rhon,TH2F*weight_rho2o,TH2F* weight_rhonr, TH2F* weight_rho2,TH2F*weight_sigman,TH2F*weight_sigma2o,TH2F* weight_sigmanr, TH2F* weight_sigma2,RooDataSet **dset, RooDataSet *dsetdestination, bool deleteold){
  if (!(*dset)) return;
//  TH2F *hnum = new TH2F("hnum","hnum",n_rhobins_forreweighting,rhobins_forreweighting,n_sigmabins_forreweighting,sigmabins_forreweighting);
//  TH2F *hden = new TH2F("hden","hden",n_rhobins_forreweighting,rhobins_forreweighting,n_sigmabins_forreweighting,sigmabins_forreweighting);
  TH2F *hnum = new TH2F("hnum","hnum",100,0,100,20,0,20);
  TH2F *hden = new TH2F("hden","hden",100,0,100,20,0,20);
  hnum->Sumw2();
  hden->Sumw2();
  for (int i=0; i<(*dset)->numEntries(); i++){
    hden->Fill(fabs((*dset)->get(i)->getRealValue("roorho")),fabs((*dset)->get(i)->getRealValue("roosigma")),(*dset)->store()->weight(i));
  }
  for (int i=0; i<dsetdestination->numEntries(); i++){
    hnum->Fill(fabs(dsetdestination->get(i)->getRealValue("roorho")),fabs(dsetdestination->get(i)->getRealValue("roosigma")),dsetdestination->store()->weight(i));
  }

  hnum->Scale(1.0/hnum->Integral());
  hden->Scale(1.0/hden->Integral());
//data/MC
  hnum->Divide(hden);
  TH2F *h = hnum;

  RooDataSet *newdset = new RooDataSet(**dset,Form("%s_rhosigmarew",(*dset)->GetName()));
  newdset->reset();
  for (int i=0; i<(*dset)->numEntries(); i++){
    RooArgSet args = *((*dset)->get(i));
    float oldw = (*dset)->store()->weight(i);
    float rho = args.getRealValue("roorho");
    float sigma = args.getRealValue("roosigma");
    float neww = oldw*h->GetBinContent(h->FindBin(rho,sigma));
	if(debug){
		weight_rho->Fill(neww);
		weight_rhoo->Fill(oldw);
		weight_rho2o->Fill(h->GetXaxis()->FindBin(rho),oldw);	
		weight_rhon->Fill(h->GetXaxis()->FindBin(rho),neww);	
		if(oldw!=0)weight_rhonr->Fill(h->GetXaxis()->FindBin(rho),oldw/neww);
		else {weight_rhonr->Fill(-10,1);}//cout << "dipho weight old 0" << endl;}
		if(oldw!=0)weight_rho2->Fill(rho,oldw/neww);
		weight_sigma2o->Fill(h->GetYaxis()->FindBin(sigma),oldw);	
		weight_sigman->Fill(h->GetYaxis()->FindBin(sigma),neww);	
		if(oldw!=0)weight_sigmanr->Fill(h->GetYaxis()->FindBin(sigma),oldw/neww);
		else {weight_sigmanr->Fill(-10,1);}//cout << "dipho weight old 0" << endl;}
		if(oldw!=0)weight_sigma2->Fill(sigma,oldw/neww);
	}
		newdset->add(args,neww);
	  }
	  newdset->SetName((*dset)->GetName());
	  newdset->SetTitle((*dset)->GetTitle());
	  delete hnum; delete hden;
	  RooDataSet *old_dset = *dset;
	  *dset=newdset;
	  std::cout << "RhoSigma2D rew: norm from " << old_dset->sumEntries() << " to " << newdset->sumEntries() << std::endl;
	  if (deleteold) delete old_dset;
	};
Exemplo n.º 6
0
Arquivo: Draw.C Projeto: XuQiao/HI
void Draw(){
    gStyle->SetOptStat(kFALSE);
    TFile *f = TFile::Open(Form("Anav3_merged.root"));
    int xbin=0;
    TH2F* hr = (TH2F*)f->Get(Form("D_%d/hr",xbin));
    TH2F* s = (TH2F*)f->Get(Form("D_%d/s",xbin));
    TH2F* b = (TH2F*)f->Get(Form("D_%d/b",xbin));
    TVectorD* vavgtrk = (TVectorD*)f->Get(Form("avgtrk"));
    hr->SetTitle("");
    hr->GetXaxis()->SetRangeUser(-4,4);
    hr->GetYaxis()->SetRangeUser(-1.5,4);
 //   hr->GetZaxis()->SetRangeUser(0,3e6);
    hr->GetXaxis()->SetTitle("#Delta#eta");
    hr->GetXaxis()->CenterTitle();
    hr->GetYaxis()->SetTitle("#Delta#phi");
    hr->GetYaxis()->CenterTitle();
    hr->GetZaxis()->SetTitle("#frac{1}{N_{trig}}#frac{d^{2}N^{pair}}{d#Delta#eta d#Delta#phi}");
    TCanvas *c1 = new TCanvas();
    hr->Draw("surf1");
    TLatex l;
    l.SetNDC();
    l.SetTextSize(0.04);
    l.DrawLatex(0.1,0.9,Form("%d < N_{trk}^{offline} <%d",trkbin[xbin],trkbin[xbin+1]));
    l.DrawLatex(0.5,0.9,Form("Average N_{trk}^{offline} = %.1f",(*vavgtrk)[xbin]));
    l.DrawLatex(0.1,0.85,Form("%.1f < p_{T}^{trig} < %.1f",pttrigmin,pttrigmax));
    l.DrawLatex(0.5,0.85,Form("%.1f < #eta^{trig} < %.1f",etatrigmin,etatrigmax));
    l.DrawLatex(0.1,0.80,Form("%.1f < p_{T}^{ass} < %.1f",ptassmin,ptassmax));
    l.DrawLatex(0.5,0.80,Form("%.1f < #eta^{ass} < %.1f",etaassmin,etaassmax));
    c1->Print("ridgev3.png");
    TCanvas *c2 = new TCanvas();
    s->SetTitle("");
    s->GetXaxis()->SetRangeUser(-4,4);
    s->GetYaxis()->SetRangeUser(-1.5,4);
  //  s->GetZaxis()->SetRangeUser(0,3e6);
    s->GetXaxis()->SetTitle("#Delta#eta");
    s->GetXaxis()->CenterTitle();
    s->GetYaxis()->SetTitle("#Delta#phi");
    s->GetYaxis()->CenterTitle();
    s->GetZaxis()->SetTitle("#frac{1}{N_{trig}}#frac{d^{2}N^{pair}}{d#Delta#eta d#Delta#phi}");
    s->Draw("surf1");
    l.DrawLatex(0.5,0.80,Form("signal"));
    c2->Print("signal_v3.png");
    TCanvas *c3 = new TCanvas();
    b->SetTitle("");
    b->GetXaxis()->SetRangeUser(-4,4);
    b->GetYaxis()->SetRangeUser(-1.5,4);
  //  b->GetZaxis()->SetRangeUser(0,3e9);
    b->GetXaxis()->SetTitle("#Delta#eta");
    b->GetXaxis()->CenterTitle();
    b->GetYaxis()->SetTitle("#Delta#phi");
    b->GetYaxis()->CenterTitle();
    b->GetZaxis()->SetTitle("#frac{1}{N_{trig}}#frac{d^{2}N^{pair}}{d#Delta#eta d#Delta#phi}");
    b->Draw("surf1");
    l.DrawLatex(0.5,0.80,Form("background"));
    c3->Print("background_v3.png");
}
Exemplo n.º 7
0
void draw_mvd_xy_delta()
{
   TString fileName = "/lustre/cbm/user/ebelolap/aug11/25gev/70field/deltasource/mc.delta.root";
   TFile *file = new TFile(fileName);

   gStyle->SetCanvasColor(kWhite);
   gStyle->SetFrameFillColor(kWhite);
   gStyle->SetPadColor(kWhite);
   gStyle->SetStatColor(kWhite);
   gStyle->SetTitleFillColor(kWhite);
   gStyle->SetPalette(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);

   TString fileName= "delta_xy_mvd1_70";
   TString fileNameGif = fileName + ".png";
   TString fileNameEps = fileName + ".eps";

   cbmsim->Draw("MvdPoint.fY:MvdPoint.fX", "MvdPoint.fZ<6","COLZ");
   TH2F* htemp = (TH2F*)gPad->GetPrimitive("htemp"); // empty, but has axes
   htemp->GetXaxis()->SetTitle("X [cm]");
   htemp->GetYaxis()->SetTitle("Y [cm]");
   htemp->SetMaximum(250);
   gPad->SetGridx(true);
   gPad->SetGridy(true);

   c1->SaveAs(fileNameGif);
   c1->SaveAs(fileNameEps);
}
Exemplo n.º 8
0
void plotDeltaT()
{
  Double_t nTopOfIce=1.4;
  Double_t ant1[3]={8,-5,-25};
  Double_t ant2[3]={8,5,-30};
  Double_t rho1=TMath::Sqrt(ant1[0]*ant1[0]+ant1[1]*ant1[1]);
  Double_t rho2=TMath::Sqrt(ant2[0]*ant2[0]+ant2[1]*ant2[1]);
  Double_t phi1=TMath::ATan2(ant1[1],ant1[0]);
  Double_t phi2=TMath::ATan2(ant2[1],ant2[0]);
  std::cout << phi1*TMath::RadToDeg() << "\t" << phi2*TMath::RadToDeg() << "\n";
  TH2F *histDt = new TH2F("histDt","histDt",360,-180,180,180,-90,90);
  for(int binx=1;binx<=histDt->GetNbinsX();binx++) {
    Double_t phiWaveDeg=histDt->GetXaxis()->GetBinCenter(binx);
    for(int biny=1;biny<=histDt->GetNbinsY();biny++) {
      Double_t thetaWaveDeg=histDt->GetYaxis()->GetBinCenter(biny);
      Double_t phiWave=phiWaveDeg*TMath::DegToRad();
      Double_t thetaWave=thetaWaveDeg*TMath::DegToRad();
      
      Double_t d1=TMath::Cos(thetaWave)*(ant1[2]*TMath::Tan(thetaWave)+rho1*TMath::Cos(phi1-phiWave));
      Double_t d2=TMath::Cos(thetaWave)*(ant2[2]*TMath::Tan(thetaWave)+rho2*TMath::Cos(phi2-phiWave));
      Double_t t2t1=(d1-d2)*nTopOfIce/TMath::C();
      t2t1*=1e9;
      histDt->Fill(phiWaveDeg,thetaWaveDeg,t2t1);
    }
  }
  histDt->Draw("colz");

}
Exemplo n.º 9
0
bool TMRCScanner::PlotRatevsDAC(int xmin,int xmax,int ymax)
{
  int channel = 0;

// Read channel range from configuration
	
  ffile = new TFile(foutfile);
  if (ffile->IsOpen()){		
    ftree = (TTree*) ffile->Get("T"); 
    //ftree->SetMarkerStyle(23);
    //ftree->SetLineColor(kRed);
     ftree->Draw("(HITEntries[0]/Duration):DAC>>hDAC(1024,0,1023,2001,0,2000)","HITEntries!=0","L");
		TH2F *h = (TH2F*)gPad->GetPrimitive("hDAC");
		TAxis *xaxis = h->GetXaxis();
		xaxis->SetTitle("Threshold [DAC unit]");
		xaxis->SetRange(xmin,xmax);
		TAxis *yaxis = h->GetYaxis();
		yaxis->SetTitle("Rate [Hz]");
		yaxis->SetRange(0,ymax);		
		h->SetTitle("Pulse Amplitude Integral Distribution");
		for (int i = 2048; i<(2048+128); i++) {
			ftree->Draw(Form("(HITEntries[%d]/Duration):DAC",channel+i),"HITEntries!=0","SAME,L");
			printf("%d\n",i);
		}
		ftree->SetLineColor(kRed);
		ftree->Draw("Rate:DAC","","SAME,L");
	}else {
		printf("File %s not opened \n",foutfile);
		return false;
	}
	delete ffile;
	return true;
}
Exemplo n.º 10
0
void quickWorldModelTest() {
    gSystem->Load("lib/libPropagation.so");
//    BedmapTable *iceTable = new BedmapTable (RyansCons::kBathymetry);
    WorldModel *myWorld = new WorldModel();
    TH2F *iceHist = new TH2F("iceHist","Ice Thickness",1000,-3e6,3e6,1000,-3e6,3e6);
    TH2F *iceHist2 = new TH2F("iceHist2","Ice Thickness (Bedmap)",1000,-3e6,3e6,1000,-3e6,3e6);
    TH2F *surfaceHist = new TH2F("surfaceHist","Surface",1000,-3e6,3e6,1000,-3e6,3e6);
//    int goodFlag;
    for(int binx=1;binx<=iceHist->GetNbinsX();binx++) {
	Double_t x=iceHist->GetXaxis()->GetBinCenter(binx);
	for(int biny=1;biny<=iceHist->GetNbinsY();biny++) {
	    Double_t y=iceHist->GetYaxis()->GetBinCenter(biny);
	    Double_t value=myWorld->getCrust2Data(x,y,RyansCons::kThicknessOfIce);
	    iceHist->SetBinContent(binx,biny,value);
	    value=myWorld->getIceThickness(x,y);
	    iceHist2->SetBinContent(binx,biny,value);
	    value=myWorld->getSurface(x,y);
	    surfaceHist->SetBinContent(binx,biny,value/1e6);
	    if(value>1e7 || value<1e6) cout << x << "\t" << y << "\t" << value << endl;
	}
    }
    TCanvas *can = new TCanvas("can","can");
    can->Divide(1,2);
    can->cd(1);
    iceHist->Draw("colz");
    can->cd(2);
    iceHist2->Draw("colz");
	
    TCanvas *can2 = new TCanvas("can2","can2");
    surfaceHist->Draw("colz");
    
}
void ECALEndcapCorrectionFactorCalculator()
{
    std::string detectorModel("90");
    std::string recoVar("71");

    TString rootFilesToCompare("/r04/lc/sg568/HCAL_Optimisation_Studies/Calibration/Detector_Model_" + detectorModel + "/Reco_Stage_" + recoVar + "/MuonCalibration/RootFiles/*Photon*.root");
    std::string resultsFileName("ECALEndcapCorrectionFactorCalculator_DetectorModel" + detectorModel + "_RecoStage" + recoVar + ".txt");

    std::ofstream resultsFile;
    resultsFile.open (resultsFileName.c_str());

    float ecalTotalCaloHitEnergy(-1.f);
    std::vector<float> *pPfoTargetCosTheta(NULL);

    TChain *pTChain = new TChain("PfoAnalysisTree");
    pTChain->Add(rootFilesToCompare);
    pTChain->SetBranchAddress("ECalTotalCaloHitEnergy",&ecalTotalCaloHitEnergy);
    pTChain->SetBranchAddress("pfoTargetCosTheta",&pPfoTargetCosTheta);

    TCanvas *pTCanvas = new TCanvas("PhotonDistPic", "PhotonDistPic");
    TH2F *pPhotonDist = new TH2F("PhotonDist","PhotonDist",100,0,1,150,0,15);
    pPhotonDist->GetXaxis()->SetTitle("abs( cos (#theta_{#gamma}) )");
    pPhotonDist->GetYaxis()->SetTitle("ECal Calo Hit Energy [GeV]");

    for (int entry = 0; entry < pTChain->GetEntries(); entry++)
    {
//        std::cout << "Reading entry " << entry << std::endl;
        pTChain->GetEvent(entry);

        if (!pPfoTargetCosTheta->empty())
        {
//            std::cout << "Target cos theta : " << pPfoTargetCosTheta.at(0) << std::endl;
            pPhotonDist->Fill(TMath::Abs(pPfoTargetCosTheta->at(0)),ecalTotalCaloHitEnergy);
        }
    }

    TF1 *barrelFit = new TF1("BarrelFit","[0]",0.1,0.7);
    barrelFit->SetLineColor(kGray);
    barrelFit->SetLineWidth(4);

    TF1 *endcapFit = new TF1("EndcapFit","[0]",0.85,0.95);
    endcapFit->SetLineColor(kGray);
    endcapFit->SetLineWidth(4);

    pTCanvas->cd();
    pPhotonDist->Draw("COLZ");

    pPhotonDist->Fit(barrelFit,"QR+");
    pPhotonDist->Fit(endcapFit,"QR+");

    resultsFile << "For the barrel the best fit is : " << barrelFit->GetParameter(0) << std::endl;
    resultsFile << "For the endcap the best fit is : " << endcapFit->GetParameter(0) << std::endl;
    resultsFile << "ECALEndcapCorrectionFactorCalculator -> " << (barrelFit->GetParameter(0))/(endcapFit->GetParameter(0)) << std::endl;
    resultsFile.close();

    TString picName = "ECALEndcapCorrectionFactorCalculator_DetectorModel" + detectorModel + "_RecoStage" + recoVar + ".pdf";
    pTCanvas->SaveAs(picName);   
}
Exemplo n.º 12
0
TCanvas *PlotDataMC2D(TChain *data, TChain *mc, TString branchname, TString binning, 
		      TCut selection, 
		      TString dataLabel, TString mcLabel, 
		      TString xLabel, TString yLabel, 
		      int type=2, TString opt="colz", bool usePU=true, bool smear=false, bool scale=false){
  //type == 0: data only
  //type == 1: MC only
  //type == 2: data/MC
   
  TCanvas *c = new TCanvas("c","");
  TString weightVar;
  if(branchname.Contains("map")){
    weightVar=branchname.ReplaceAll("_map","").ReplaceAll("map","");
    branchname="seedXSCEle:seedYSCEle";
    binning="(361,-0.5,360.5,171,-85.5,85.5)";
    yLabel="iEta";
    xLabel="iPhi";
    c->SetGridx();
  }
  if(weightVar!="") selection+="*"+weightVar;
  data->Draw(branchname+">>data_hist"+binning, selection,opt);
  if(usePU)  mc->Draw(branchname+">>mc_hist"+binning, selection *"puWeight",opt);
  else  mc->Draw(branchname+">>mc_hist"+binning, selection,opt);

  c->Clear();
  
  TH2F *d = (TH2F *) gROOT->FindObject("data_hist");
  TH2F *s = (TH2F *) gROOT->FindObject("mc_hist");

  if(type==0) d->Draw(opt);
  else if(type==1) s->Draw(opt);
  else if(type==3){
    s->Scale(d->Integral()/s->Integral());
    d->Divide(s);
    d->Draw(opt);
  }

  d->GetXaxis()->SetTitle(xLabel);
  s->GetXaxis()->SetTitle(xLabel);
  d->GetYaxis()->SetTitle(yLabel);
  s->GetYaxis()->SetTitle(yLabel);
  c->SetRightMargin(0.2);
  return c;
  
}
Exemplo n.º 13
0
void Plotcolz(){
  if(StopMass.size() == 0) GetAllMasses();
	TCanvas *c1 = new TCanvas("c1","c1",600,400);
	TH2F* hist = new TH2F("hist", "nEvents for the different mass points", 40, 12.5, 1000+12.5, 24, -12.5, 600-12.5);
	for(int k = 0; k < StopMass.size(); k++){
		hist->SetBinContent(hist->FindBin(StopMass[k], NeutralinoMass[k]), Events[k]);
	}
	hist -> SetStats(0);
  hist->GetXaxis()->SetTitle("Stop Mass [GeV]");
  hist->GetYaxis()->SetTitle("Neutralino Mass [GeV]");
  hist->GetXaxis()->SetNdivisions(40308);
  hist->GetYaxis()->SetNdivisions(40306);
  c1->SetGrid();
	hist->Draw("colz");
  c1 -> Print(outputdir + "MassPointsEvents.pdf", "pdf");
  c1 -> Print(outputdir + "MassPointsEvents.png", "png");

}
Exemplo n.º 14
0
void Correlation::DrawMatrix(){

  map<TString, map<TString,double> >::iterator it1 = results.begin();
  map<TString, double>::iterator it2 = ((*it1).second).begin();

  int nvars = (int) results.size();
  TH2F* hmatrix = new TH2F("matrix","",nvars,0,nvars,nvars,0,nvars);
  hmatrix->SetStats(0);

  int counter1= 1;
  for(it1 = results.begin(); it1!= results.end(); ++it1){

    TString var1 = (*it1).first;
    var1.ReplaceAll("_both_mix_merge","");
    hmatrix->GetXaxis()->SetBinLabel(counter1,var1);
    counter1++;

    int counter2=1;
    map<TString, double> results2 = (*it1).second;
    map<TString, double>::iterator it2 = results2.begin();

    for(it2 = results2.begin(); it2!=results2.end(); ++it2){
      TString var2 = (*it2).first;
      var2.ReplaceAll("_both_mix_merge","");
      //cout << counter2 << " " << var2 << endl;
      if ( counter1==1) hmatrix->GetYaxis()->SetBinLabel(counter2,var2);
      counter2++;
      double value = abs((*it2).second);
      //cout << var1 << " " << var2 << " " << value << endl;
      hmatrix->Fill(var1,var2,value);
      if(var1!=var2) hmatrix->Fill(var2,var1,value);
    }
  }

  TCanvas* c = new TCanvas("c","",700,700);
  hmatrix->GetXaxis()->SetLabelSize(0.03);
  hmatrix->GetYaxis()->SetLabelSize(0.03);
  c->SetLeftMargin(0.2);
  c->SetBottomMargin(0.2);
  hmatrix->Draw("colz");
  c->SaveAs("results/matrix.pdf");
  c->SaveAs("results/matrix.eps");

}
TH2F* RemoveHistoDiagonal(TH2F *hold){
  int nbinsX = hold->GetNbinsX();
  int nbinsY = hold->GetNbinsY();
  TString name = hold->GetName();
  name.ReplaceAll("_x","");
  TH2F *h = (TH2F*)hold->Clone(name);

  for(int x = 1; x<=h->GetNbinsX(); ++x){
    for(int y = 1; y<=h->GetNbinsY(); ++y){
      float xlow = h->GetXaxis()->GetBinLowEdge(x);
      float xup  = xlow + h->GetXaxis()->GetBinWidth(x);
      float ylow = h->GetYaxis()->GetBinLowEdge(y);
      float yup  = ylow + h->GetYaxis()->GetBinWidth(y);
      //if(name=="hExp") cout << "xlow " << xlow << " xup " << xup << " ylow " << ylow << " yup " << yup << endl;
      if(((xlow-ylow)>=172.5&&((xlow-ylow)<=175))||((xup-yup)>=172.5&&(xup-yup)<=175.) ) //continue;
      h->SetBinContent(x,y,0);
    }
  }
  return h;
}
Exemplo n.º 16
0
Arquivo: Draw.C Projeto: XuQiao/HI
void Draw(){
    gStyle->SetOptStat(kFALSE);
    TFile *f = TFile::Open(Form("correlationSTEG.root"));
    TH2F* hr = (TH2F*)f->Get(Form("correlation"));
    hr->SetTitle("");
    hr->GetXaxis()->SetRangeUser(-4,4);
    hr->GetYaxis()->SetRangeUser(-1.5,4);
 //   hr->GetZaxis()->SetRangeUser(0,3e6);
    hr->GetXaxis()->SetTitle("#Delta#eta");
    hr->GetXaxis()->CenterTitle();
    hr->GetYaxis()->SetTitle("#Delta#phi");
    hr->GetYaxis()->CenterTitle();
    hr->GetZaxis()->SetTitle("#frac{1}{N_{trig}}#frac{d^{2}N^{pair}}{d#Delta#eta d#Delta#phi}");
    TCanvas *c1 = new TCanvas();
    hr->Draw("surf1");
    TLatex l;
    l.SetNDC();
    l.SetTextSize(0.04);
    c1->Print("ridge.png");
}
Exemplo n.º 17
0
void doPlot2dSym(TTree *t, std::string hname, std::string todraw, 
	std::vector<double> bins, std::string title, std::string titleX, std::string titleY, std::string unit)
{
    TH2F *h = new TH2F(hname.c_str(),title.c_str(),bins.size()-1,&bins[0],bins.size()-1,&bins[0]);
    const std::string plotstring = todraw + ">>" + hname;
    cout << plotstring << endl;
    t->Draw(plotstring.c_str(),"","COLZTEXT");
    h->GetXaxis()->SetTitle(unit.size()>0 ? (titleX+" / "+unit).c_str() : titleX.c_str());
    h->GetYaxis()->SetTitle(unit.size()>0 ? (titleY+" / "+unit).c_str() : titleY.c_str());
    return; 
}
Exemplo n.º 18
0
void plot(){

  ifstream file1("R_Scin_Eff.txt");
  
  const int NUMR = 40;
  float rnum[NUMR] ; 
  float T1eff[NUMR], T6eff[NUMR];

  int i=0,j=0;
  while(!(file1.eof())){
    file1 >> rnum[i] >> T1eff[i] >> T6eff[i];
    i++;
  }
 
  const int TTT1 = jj;
  gStyle->SetOptStat(0);
  TCanvas *cc = new TCanvas("cc","Trigger 1",1200,800);
  // cc->Divide(1,2);cc->cd(1);
  TH2F *hh = new TH2F("hh","",TTT1,3500,4300,TTT1,-10.0,110.0);
  hh->GetXaxis()->SetTitle("Run Number");
  hh->GetXaxis()->CenterTitle();
  hh->GetYaxis()->SetTitle("HRS-R Scintillator Efficiency (%)");
  hh->GetYaxis()->CenterTitle();
  hh->Draw();
  
  TGraph *t1 = new TGraph(TTT1,rnum,T1eff);
  t1->SetMarkerStyle(20);
  t1->SetMarkerColor(2);
  t1->Draw("P");
  
  TGraph *t6 = new TGraph(TTT1,rnum,T6eff);
  t6->SetMarkerStyle(21);
  t6->SetMarkerColor(4);
  t6->Draw("P");
  
  TLegend *l1 = new TLegend(0.4,0.4,0.6,0.6);
  l1->AddEntry(t1,"T1/(T1+T2)","p");
  l1->AddEntry(t6,"T6/(T6+T2)","p");
  l1->Draw();

}
Exemplo n.º 19
0
void AliITSLegoPlot(Float_t nchtheta, Float_t nchphi, const char *inFile = "galice.root") {
// macro to visualize the lego plots generated by gAlive->RunLego
   
   gROOT->Reset();
   TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(inFile);
   if (!file->IsOpen()) {
       cerr<<"Can't open "<<inFile<<" !" << endl;
       return 1;
   } // end if !file
    

   Float_t theta = 10;
   Float_t phi   = 170;
   Int_t ncont   = 50;

   TCanvas *cradl = new TCanvas("cradl","radl",10,10,800,600);
   cradl->SetTheta(theta);
   cradl->SetPhi(phi);
   TH2F *hradl = (TH2F*)file->Get("hradl");
   hradl->SetStats(kFALSE);
   hradl->GetXaxis()->SetTitle("Phi (degrees)");
   hradl->GetYaxis()->SetTitle("Theta (degrees)");
   hradl->SetFillColor(2);
   hradl->SetContour(ncont);
   hradl->Draw("colz");


   TCanvas *cradlx = new TCanvas("cradl1","radl",50,50,800,600);
   hradl->ProjectionX();
   hradl_px->SetStats(kFALSE);
//   hradl_px->SetOptLogY();
//   hradl_px->SetMinimum(0.001);   
//   hradl_px->SetMaximum(1);
   hradl_px->Scale(1./nchtheta);   
   hradl_px->GetXaxis()->SetTitle("Phi (degrees)");
   hradl_px->GetYaxis()->SetTitle("X/X0");
   hradl_px->Draw();
//   cout << "Average over Phi: " << hradl_px->GetSumOfWeights()/nchphi << " X/X0" << endl;
   
   
   TCanvas *cradly = new TCanvas("cradl2","radl",100,100,800,600);
   hradl->ProjectionY();
   hradl_py->SetStats(kFALSE);
//   hradl_py->SetOptLogY();
//   hradl_py->SetMinimum(0.001);   
//   hradl_py->SetMaximum(1);   
   hradl_py->Scale(1./nchphi);
   hradl_py->GetXaxis()->SetTitle("Theta (degrees)");
   hradl_py->GetYaxis()->SetTitle("X/X0");
   hradl_py->Draw();   
//   cout << "Average over Theta: " << hradl_py->GetSumOfWeights()/nchtheta << " X/X0" << endl;  
   cout << "Average: " << hradl_py->GetSumOfWeights()/nchtheta << " X/X0" << endl;     
}   
Exemplo n.º 20
0
TH2F* ZMassVsDRHist2D(TString name, TString bininfo, DiMuPlottingSystem* dps)
{
  // Plot a 2D hist of the dimuon mass vs ZPt for either positive or negative reco muons. 
  // This function uses the DiMuonPlottingSystem class which facilitates the application of cuts. 

  // Get the titles and units straight.
  TString xtitle = TString("dR");

  TString title = TString ("Z Mass vs ");
  title+=xtitle;
  xtitle+= TString("");

  TString ytitle = TString("Z Mass (GeV)");

  // Initialize some pointers to be filled. h2 takes in reco2 info which will be added to reco1 info in order to get
  // all of the positive or all of the negative reco muons.
  TH2F* h = 0;

  TString dR = TString("((reco1.phi - reco2.phi)**2 + (reco1.eta - reco2.eta)**2 )**0.5");

  h = dps->hist2D("recoCandMass:"+dR, bininfo, "");

  // Print out the number of muons in the different histograms to make sure they add up right.
  std::cout << "nentries: " << h->GetEntries() << std::endl;

  // Set the title info for the histogram.
  h->SetTitle(title);
  h->GetXaxis()->SetTitle(xtitle);
  h->GetYaxis()->SetTitle(ytitle);
  h->SetName(name);
  std::cout << "xtitle: " << h->GetXaxis()->GetTitle() << std::endl;
  std::cout << "title: " << h->GetTitle() << std::endl;

  h->Draw("colz");
  std::cout << "nxbins: " << h->GetXaxis()->GetNbins() << std::endl;
  std::cout << "nybins: " << h->GetYaxis()->GetNbins() << std::endl;
  std::cout << "nbinsx: " << h->GetNbinsX() << std::endl;

  return h;
}
Exemplo n.º 21
0
TH2F *plotEff2D(RooDataSet *a, TString b) {
    const RooArgSet *set = a->get();
    RooRealVar *yAx = (RooRealVar*)set->find("pt");
    RooRealVar *xAx = (RooRealVar*)set->find("eta");
    RooRealVar *eff = (RooRealVar*)set->find("efficiency");

//    const int xnbins = xAx->getBinning().numBins();
//    const int ynbins = yAx->getBinning().numBins();

    //double xbins[] = {-2.4, -1.6, -0.8, 0.0, 0.8, 1.6, 2.4};
    //double ybins[] = {0, 2, 3, 5, 8, 10, 20};

    const double *xvbins = xAx->getBinning().array();
    const double *yvbins = yAx->getBinning().array();

    TH2F* h = new TH2F(b, "", xAx->getBinning().numBins(), xvbins, yAx->getBinning().numBins(), yvbins);

    gStyle->SetPaintTextFormat("5.2f");
    gStyle->SetPadRightMargin(0.12);
    gStyle->SetPalette(1);
    h->SetOption("colztexte");
    h->GetZaxis()->SetRangeUser(-0.001,1.001);
    h->SetStats(kFALSE);
    h->GetYaxis()->SetTitle("p_{T} [GeV/c]");
    h->GetXaxis()->SetTitle("#eta");
    h->GetXaxis()->CenterTitle();
    h->GetYaxis()->CenterTitle();
    h->GetXaxis()->SetTitleSize(0.05);
    h->GetYaxis()->SetTitleSize(0.05);
    h->GetYaxis()->SetTitleOffset(0.8);
    h->GetXaxis()->SetTitleOffset(0.9);
    for(int i=0; i<a->numEntries(); i++) {
        a->get(i);
        h->SetBinContent(h->FindBin(xAx->getVal(), yAx->getVal()), eff->getVal());
        h->SetBinError(h->FindBin(xAx->getVal(), yAx->getVal()), (eff->getErrorHi()-eff->getErrorLo())/2.);
    }

    return h;

}
Exemplo n.º 22
0
drawMyPlot(TString nom, TString title){
	/*UInt_t Number = 2;
	Double_t Red[2]    = { 1.00, 0.00};
	Double_t Green[2]  = { 1.00, 0.00};
	Double_t Blue[2]   = { 1.00, 1.00};
	Double_t Length[2] = { 0.00, 1.0};
	Int_t nb=50;
	TColor::CreateGradientColorTable(Number,Length,Red,Green,Blue,nb);*/
    
	TH2F *theHisto = (TH2F*) myFile->Get(nom);
	
	TCanvas *c0 = new TCanvas("c0","coucou",600,600);
	c0->SetFillColor(0);
    theHisto->SetTitle(title);
	theHisto->GetXaxis()->SetTitle("#mu_{1} p_{T} (GeV/c)");
	theHisto->GetXaxis()->SetNoExponent();
	theHisto->GetXaxis()->SetMoreLogLabels();
    theHisto->GetYaxis()->SetNoExponent();
	theHisto->GetYaxis()->SetMoreLogLabels();
	theHisto->GetYaxis()->SetTitle("#mu_{2} p_{T} (GeV/c)");
	theHisto->GetZaxis()->SetTitle("");
	theHisto->GetZaxis()->SetLabelSize(0.01);
	theHisto->SetAxisRange(0.5,1.5,"Z");
	theHisto->SetMarkerSize(1.7);
	theHisto->SetMarkerColor(kBlack);
	theHisto->Draw("COLZTEXTE");
    
    /*TLatex t;
    t.SetNDC();
    t.SetTextSize(0.04);
    t.DrawLatex(0.3,0.93,title);*/
	
	//c0->Print("effPlots/"+nom+".pdf");
	
	c0->SetLogy();
	c0->SetLogx();
    c0->Print("SFplots/"+nom+"_log.pdf");
    
	
}
Exemplo n.º 23
0
pair<TH2F*,TH2F*> Bin2DTree::fillWidths()
/*****************************************************************/
{
        if(!m_gridConstraint)
        {
            cerr<<"ERROR: Bin2DLeaf.fillWidths(): Trying to fill histogram, but the binning is unknown. Define first the gridConstraint.\n";
            exit(1);
        }
        TH2F* hWidthX = (TH2F*)m_gridConstraint->Clone("widthXFromTree");
        TH2F* hWidthY = (TH2F*)m_gridConstraint->Clone("widthYFromTree");
        int nbinsx = hWidthX->GetNbinsX();
        int nbinsy = hWidthX->GetNbinsY();
        map<Bin2DLeaf*, vector< pair<int,int> > > binsInLeaf;
        for(int bx=1;bx<nbinsx+1;bx++) 
        {
            for(int by=1;by<nbinsy+1;by++)
            {
                double x = hWidthX->GetXaxis()->GetBinCenter(bx);
                double y = hWidthX->GetYaxis()->GetBinCenter(by);
                Bin2DLeaf* leaf = getLeaf(x, y);
                vector<Bin2DLeaf*> neighborLeaves = findNeighborLeaves(leaf);
                neighborLeaves.push_back(leaf);
                vector<Bin2DLeaf*>::iterator itLeaf = neighborLeaves.begin();
                vector<Bin2DLeaf*>::iterator itELeaf = neighborLeaves.end();
                double sumw = 0.;
                double sumwx = 0.;
                double sumwy = 0.;
                for(;itLeaf!=itELeaf;++itLeaf)
                {
                    double xi = (*itLeaf)->getXCenter();
                    double yi = (*itLeaf)->getYCenter();
                    double dx = xi-x;
                    double dy = yi-y;
                    double wxi = (*itLeaf)->getXWidth();
                    double wyi = (*itLeaf)->getYWidth();
                    if(dx<0.05*wxi) dx = 0.05*wxi;
                    if(dy<0.05*wyi) dy = 0.05*wyi;
                    double dr2 = dx*dx+dy*dy;
                    sumw += 1./dr2;
                    sumwx += wxi/dr2;
                    sumwy += wyi/dr2;
                }
                double widthx = sumwx/sumw;
                double widthy = sumwy/sumw;
                hWidthX->SetBinContent(bx,by,widthx);
                hWidthY->SetBinContent(bx,by,widthy);
                hWidthX->SetBinError(bx,by,0.);
                hWidthY->SetBinError(bx,by,0.);
            }
        }
        return make_pair(hWidthX, hWidthY);
}
Exemplo n.º 24
0
TGraph* ContourGraph( TH2F* hist,double xmin=16, double xmax=90) {

    //temporary canvas
    TCanvas* MOO = new TCanvas( TString::Format("dummy_canvas_%s", hist->GetName()), "A scan of m_{0} versus m_{12}", 0, 0, 650,640);
    MOO->cd();

    TGraph* gr0 = new TGraph();
    TH2F* h = (TH2F*)hist->Clone();
    TGraph* gr = (TGraph*)gr0->Clone(TString::Format("gr_%s", h->GetName()));

    cout << "==> Will dumb histogram: " << h->GetName() << " into a graph" <<endl;

    h->SetContour( 1 );
    //h->GetXaxis()->SetRangeUser(250,1200);
    h->GetXaxis()->SetRangeUser(xmin, xmax);
    //h->GetYaxis()->SetRangeUser(2,50);

    double pval = CombinationGlob::cl_percent[1];
    std::cout << pval << std::endl; 
    double signif = TMath::NormQuantile(1-pval);
    h->SetContourLevel( 0, signif );
    h->Draw("CONT LIST");
    h->SetDirectory(0);
    gPad->Update();

    TObjArray *contours = (TObjArray*) gROOT->GetListOfSpecials()->FindObject("contours");
    Int_t ncontours     = contours->GetSize();
    cout << "Found " << ncontours << " contours " << endl;

    TList *list = (TList*)contours->At(0);
    contours->Print("v");
    if(!list) return NULL;

    gr = (TGraph*)list->First();
    if(!gr) return NULL;

    gr->SetName(TString::Format("gr_%s", hist->GetName()));
    //gr->SetName(hist->GetName());
    int N = gr->GetN();
    double x0, y0;
    for(int j=0; j<N; j++) {
        gr->GetPoint(j,x0,y0);
        cout << j << " : " << x0 << " : "<<y0 << endl;
    }
    //  //  gr->SetMarkerSize(2.0);    
    //gr->Draw("ALP");

    delete MOO;

    cout << "Generated graph " << gr << " with name " << gr->GetName() << endl;
    return gr;
}
Exemplo n.º 25
0
void drawLoad(TString infile="../build/hits.root"){
  gStyle->SetOptStat(0);
  fSavePath = "load";
  
  PrtInit(infile,0); //digi
  
  TH2F* hHits = new TH2F("hHits",";x, [mm];y, [mm]",500,-40,350,500,-100,100);
  Int_t angle(0), step(0);
  Double_t test(0);
  PrtHit fHit;
  for (Int_t ievent=0; ievent<fCh->GetEntries(); ievent++){
    PrtNextEvent(ievent,1000);
    if(ievent==0){
      angle = fEvent->GetAngle() + 0.01;
      test = fEvent->GetTest1();
      fInfo +=  fEvent->PrintInfo();
    }
    for(Int_t h=0; h<fEvent->GetHitSize(); h++){
      fHit = fEvent->GetHit(h);
      Int_t mcpid = fHit.GetMcpId();
      Int_t pixid = fHit.GetPixelId()-1;
      TVector3 pos = fHit.GetGlobalPos();
      
      Double_t time = fHit.GetLeadTime();
      hHits->Fill(pos.X(),pos.Y());
    }
  }
  
  canvasAdd(Form("load_%d",angle),800,500);
  hHits->SetStats(0);
  hHits->GetXaxis()->SetTitleOffset(0.85);
  hHits->GetYaxis()->SetTitleOffset(0.85);
  hHits->GetXaxis()->SetTitleSize(0.05);
  hHits->GetYaxis()->SetTitleSize(0.05);
  //hHits->SetTitle(Form("#theta_{track} = %d#circ",angle));
  hHits->Draw("colz");
  drawPrism(prismShift,0);
  canvasSave(1,0);
}
Exemplo n.º 26
0
TH1D * getSpectrum(TFile * f, char * type, int minCent, int maxCent, double etaMin, double etaMax )
{
  TH3F *h = (TH3F*) f->Get(Form("%s",type));
  h->GetZaxis()->SetRangeUser( minCent+0.001, maxCent-0.001);
  TH2F * ch = (TH2F*) h->Project3D("yxe");

  TH1D* hPt;
  TH1D* hPtN;
  Int_t etabin10m=ch->GetXaxis()->FindBin(etaMin+0.01);
  Int_t etabin10p=ch->GetXaxis()->FindBin(etaMax-0.01);
  Int_t Netabin10p=ch->GetXaxis()->FindBin(-etaMin-0.01);
  Int_t Netabin10m=ch->GetXaxis()->FindBin(-etaMax+0.01);
  hPt = (TH1D*) ch->ProjectionY(Form("hPt_%d",rand()),etabin10m,etabin10p,"e");
  hPtN = (TH1D*) ch->ProjectionY("hPtN",Netabin10m,Netabin10p,"e");
  hPt->Add( hPtN, 1.0);

  delete h;
  delete ch;
  delete hPtN;

  return hPt;
}
Exemplo n.º 27
0
void CreateHistogram(const char* name,   const char* title,
					 const char* xTitle, const char* yTitle,
					 Int_t nBinsX, Double_t xLow, Double_t xUp,
					 Int_t nBinsY,Double_t yLow, Double_t yUp)
{
	TH2F* h = new TH2F(name, title, nBinsX, xLow,xUp,nBinsY, yLow,yUp);
	
	h->GetXaxis()->SetTitle(xTitle);
	h->GetYaxis()->SetTitle(yTitle);
	
	h->Sumw2();
	
	hName2D[name] = h;
}
Exemplo n.º 28
0
TH2F* XsecThisHistogram(TH2F *hold, TH1D *hxsec){
  TString name = hold->GetName() + (TString)"Xsec";
  TH2F *hnew = (TH2F*)hold->Clone(name);
  for(int x = 1; x<=hnew->GetNbinsX(); ++x){
    for(int y = 1; y<=hnew->GetNbinsY(); ++y){
      float val = hnew->GetBinContent(x,y);
      float mstop = hnew->GetXaxis()->GetBinLowEdge(x);
      //cout << "check " << "bin " << x << " gets me mstop " << mstop << endl;
      float xsec = hxsec->GetBinContent(hxsec->FindBin(mstop));
      hnew->SetBinContent(x,y,val*xsec);
    }
  }
  return hnew;
}
Exemplo n.º 29
0
double
SimpleTrackCorrector::getWeight(double pT, double eta, double occ ) 
{

  double eff = reff2D->GetBinContent(
                  reff2D->GetXaxis()->FindBin(eta),
                  reff2D->GetYaxis()->FindBin(pT) );
  if( eff >= 0.9999 || eff <= 0.0001) eff = 1;

  double sec = rsec2D->GetBinContent(
              rsec2D->GetXaxis()->FindBin(eta),
              rsec2D->GetYaxis()->FindBin(pT));
  if( sec >= 0.9999 || sec <= 0.0001) sec = 0;
  double fak = rfak2D->GetBinContent(
              rfak2D->GetXaxis()->FindBin(eta),
              rfak2D->GetYaxis()->FindBin(pT));
  if( fak >= 0.9999 || fak <= 0.0001) fak = 0;
  double mul = rmul2D->GetBinContent(
              rmul2D->GetXaxis()->FindBin(eta),
              rmul2D->GetYaxis()->FindBin(pT));
  if( mul >= 0.9999 || mul <= 0.0001) mul = 0;

  return (1. - fak ) * ( 1. - sec ) / eff  / (1. + mul );
}
Exemplo n.º 30
0
void doPlot2d(TTree *t, std::string hname, std::string todraw, 
	std::vector<double> binsX, std::vector<double> binsY,
        std::string title, std::string titleX, std::string titleY,
	std::string unitX, std::string unitY)
{
    TH2F *h = new TH2F(hname.c_str(),title.c_str(),binsX.size()-1,&binsX[0],binsY.size()-1,&binsY[0]);
    const std::string plotstring = todraw + ">>" + hname;
    cout << plotstring << endl;
    t->Draw(plotstring.c_str(),"","COLZTEXT");
    h->GetXaxis()->SetTitle(unitX.size()>0 ? (titleX+" / "+unitX).c_str() : titleX.c_str());
    h->GetYaxis()->SetTitle(unitY.size()>0 ? (titleY+" / "+unitY).c_str() : titleY.c_str());
    //const double binsize = (max-min)/nBins;
    //h->GetYaxis()->SetTitle(("entries per "+toString(binsize)+" "+unitX).c_str());
    return; 
}