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


C++ TChain::Project方法代码示例

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


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

示例1: draw_reflections

void draw_reflections(TString infile)
{
	gStyle->SetOptStat(0);
	
	TChain *data = new TChain("data");
	data->Add(infile);

	
	TH2D *direct = new TH2D("d","d",250,-50,200,200,-100,100);
	TH2D *left = new TH2D("l","l",250,-50,200,200,-100,100);
	TH2D *bottom = new TH2D("b","b",250,-50,200,200,-100,100);
   	TH2D *right = new TH2D("r","r",250,-50,200,200,-100,100);
	right->SetTitle(0);
	

	data->Project("r","fHitArray.fGlobalPos.y():fHitArray.fGlobalPos.x()","fHitArray.fPathInPrizm==4");
	data->Project("b","fHitArray.fGlobalPos.y():fHitArray.fGlobalPos.x()","fHitArray.fPathInPrizm==3");
	data->Project("l","fHitArray.fGlobalPos.y():fHitArray.fGlobalPos.x()","fHitArray.fPathInPrizm==2");
	data->Project("d","fHitArray.fGlobalPos.y():fHitArray.fGlobalPos.x()","fHitArray.fPathInPrizm==0");

	direct->SetMarkerColor(kGray+1);
	left->SetMarkerColor(kGreen+2);
	bottom->SetMarkerColor(kBlue);
	right->SetMarkerColor(kMagenta+2);

	TCanvas *canv = new TCanvas();
	right->Draw();
	bottom->Draw("same");
	left->Draw("same");
	direct->Draw("same");
}
开发者ID:hyperbolee,项目名称:prtdirc,代码行数:31,代码来源:draw_reflections.C

示例2: Draw_KL_Test

void Draw_KL_Test(){

  TChain* ch = new TChain("Tree");
  TChain* ch1 = new TChain("Tree");
  
  TH1D* his  = new TH1D("Klong6g","Klong6g",20,450,550);
  TH1D* his1 = new TH1D("Klong4g","Klong4g",20,450,550);
  TH1D* his2 = new TH1D("Klong4gAll","Klong4gAll",60,250,550);

  for( int i = 0; i< 68; i++){
    ch->Add(Form("klongRootFile/kl%d.root" ,4162+i));
    ch1->Add(Form("klongRootFile/ks%d.root",4162+i));
  }
  ch->Project(his->GetName()  ,"KlongMass[0]","CutCondition==0");
  ch1->Project(his1->GetName(),"KlongMass[0]","CutCondition==0");
  ch1->Project(his2->GetName(),"KlongMass[0]","CutCondition==0");
  
  TF1* func = new TF1("func","gaus(0)+expo(3)",0,550);
  func->SetParameter(1,498);
  func->SetParameter(2,5);
  TF1* func2 = new TF1("func2","gaus(0)",0,550);
  func2->SetParameter(1,498);
  func2->SetParameter(2,5);



  TCanvas* can = new TCanvas("can","",1200,600);
  can->Divide(2,1);
  can->cd(1);
  his2->Fit(func->GetName(),"","",450,550);
  his2->Draw();
  TF1* func1 = new TF1("Test","gaus",450,550);
  func1->SetParameter(0,func->GetParameter(0));
  func1->SetParameter(1,func->GetParameter(1));
  func1->SetParameter(2,func->GetParameter(2));

  can->cd(2);
  his1->SetLineColor(2);  
  his->Draw();
  his->Fit(func2->GetName(),"","",450,550);
  func->Draw("same");
  his1->Draw("same");

  std::cout<< func2->GetParameter(0) << " " 
	   << func->GetParameter(0)  << " " 
	   << func->GetParameter(0)/func2->GetParameter(0)<< std::endl;
  std::cout<< func2->Integral(450,550) << " " 
	   << func1->Integral(450,550)  << " " 
	   << func1->Integral(450,550)/func2->Integral(450,550)
	   << std::endl;
  //ch->Draw("KlongPt[0]:KlongMass[0]>>(400,200,600,50,0,20)","(CutCondition&(1|2|4|8))==0","colz");
  gPad->SetLogz();
  TText* text = new TText(0.5,0.5,"");
  TText* text1 = new TText(0.5,0.5,"");
  text->DrawTextNDC(0.5,0.5,Form("Integral:%2.3lf",func1->Integral(450,550)));
  text1->DrawTextNDC(0.5,0.6,Form("Integral:%2.3lf",func2->Integral(450,550)));
  
}
开发者ID:laerad84,项目名称:Analysis,代码行数:58,代码来源:Draw_KL_Test.C

示例3: mc_xyzratio

void mc_xyzratio(const char *fname = NULL)
{
	TH1D *hA[3];
	TH1D *hB[3];
	TH1D *hR[3];
	int i;
	char str[256];
	const int Color[] = {kRed, kBlue, kGreen};
	TCut cut;

	TChain *tMC = make_mc_tree(fname);
	if (!tMC) {
		printf("DanssPair tree not found\n");
		return;
	}

	gROOT->cd();
	for (i=0; i<3; i++) {
		sprintf(str, "hMCgt3P%c", 'X'+i);
		hA[i] = new TH1D(str, "MC gt 3 MeV", 25, 0, 100);
		sprintf(str, "hMClt3P%c", 'X'+i);
		hB[i] = new TH1D(str, "MC lt 3 MeV", 25, 0, 100);
		sprintf(str, "PositronX[%d]+%4.1f", i, (i==2) ? 0.5 : 2.0);
		switch (i) {
		case 0:
			cut = cY && "PositronX[0]>=0" && cZ && cR && c20 && cGamma && cGammaMax && cPe && cN;
			break;
		case 1:
			cut = cX && "PositronX[1]>=0" && cZ && cR && c20 && cGamma && cGammaMax && cPe && cN;
			break;
		default:
			cut = cX && cY && cR && c20 && cGamma && cGammaMax && cPe && cN;
		}
		gROOT->cd();
		tMC->Project(hA[i]->GetName(), str, cut && "PositronEnergy > 3");
		tMC->Project(hB[i]->GetName(), str, cut && "PositronEnergy < 3");
		hA[i]->Sumw2();
		hB[i]->Sumw2();
		sprintf(str, "hRatioMCP%c", 'X'+i);
		hR[i] = (TH1D*) hA[i]->Clone(str);
		hR[i]->Divide(hA[i], hB[i]);
		hR[i]->SetTitle("MC Ratio (PE gt 3 MeV) / (PE lt 3 MeV);cm;Ratio");
		hR[i]->SetLineColor(Color[i]);
		hR[i]->SetStats(0);
	}
	TCanvas *cv = new TCanvas("CV", "CV", 1200, 900);
	for (i=0; i<3; i++) hR[i]->Draw((i) ? "same" : "");
	TLegend *lg = new TLegend(0.12, 0.73, 0.2, 0.87);
	for (i=0; i<3; i++) {
		sprintf(str, "%c", 'X'+i);
		lg->AddEntry(hR[i], str, "LE");
	}
	lg->Draw();
	cv->SaveAs("XYZ-ratioMC.pdf");
}
开发者ID:lab305itep,项目名称:digi,代码行数:55,代码来源:mc2ibd.C

示例4: sigHist

void sigHist(TChain & EventsVBF, TChain & EventsGF, string variable, string title, int nBins, float min, float max, float GF, float VBF ){

  TCanvas c("");
  TH1F *hVBF = new TH1F("hVBF","hVBF", nBins, min, max);
  TH1F *hGF = new TH1F("hGF","hGF", nBins, min, max);
  EventsVBF.Project("hVBF",variable.c_str() );
  EventsGF.Project("hGF",variable.c_str() );
  //hVBF->Draw();
  EventsVBF.Draw("h.mass()");
  TH1F * h = new TH1F(title.c_str(),title.c_str(), nBins, min,max);

  
  h->Add(hVBF,hGF,VBF,GF);

    h->SetLineColor(kBlue+1);
    h->SetFillColor(kAzure+7);

  //h->SetLineColor(kMagenta+3);
  //h->SetFillColor(kMagenta-3);

  //    h->SetLineColor(kTeal+3);
  //  h->SetFillColor(kTeal+2);

  //  h->SetLineColor(kOrange+7);
  //  h->SetFillColor(kYellow-9);

  h->SetMarkerStyle(0);
  h->SetTitle( ("H350, "+title).c_str() );
  h->SetXTitle("m_{H} (GeV/c^{2})");
  //h->hGF->GetXaxis()->SeXmin();
  //h->Scale(1/h->GetEntries());
  h->Draw("HIST");

  h->Write();
  //c.SaveAs( (title+".eps").c_str() );
  delete hVBF;
  delete hGF;
  delete h;

}
开发者ID:decosa,项目名称:usercode,代码行数:40,代码来源:plots.cpp

示例5: ecalSpectra

void ecalSpectra()
{
  TH1::SetDefaultSumw2();

  //const Double_t PTBINS[] = {0,2.5,5,7.5,10,12.5,15,17.5, 20,25, 30,35, 40, 50, 60, 80, 120, 300};
  //const Int_t nPTBINS = 5;
  //const Int_t nPTBINS = sizeof(PTBINS)/sizeof(Double_t) -1;

  TChain *ecalTree = new TChain("ecalTree");
  ecalTree->Add("pA_promptRECO/*.root");
  //ecalTree->Add("pA_promptRECO/89.root");
  //TH1D *ecalSpectra = new TH1D("ecalSpectra","ecalSpectra", nPTBINS, PTBINS);
  TH1D *ecalSpectra = new TH1D("ecalSpectra","ecalSpectra",300,0,300);

  // const TCut ecalEtaCut = "abs(ecalTree.eta) < 1.44";
  // const TCut isoCut = "ecalRecHitSumEtConeDR04 < 4.2  &&  hcalTowerSumEtConeDR04 < 2.2  &&  trkSumPtHollowConeDR04 < 2 && hadronicOverEm<0.1";
  // const TCut genCut = "genCalIsoDR04<5 && abs(genMomId)<=22";
  // const TCut sbCut = "(cc4+cr4+ct4PtCut20>10) && (cc4+cr4+ct4PtCut20<20) && hadronicOverEm<0.1";
  // const TCut candidateCut = "sigmaIetaIeta<0.01";
  // const TCut decayCut = "(sigmaIetaIeta>0.011) && (sigmaIetaIeta<0.017)";

  //TCut ecalPtCut = "ecalTree.corrPt>40 && ecalTree.corrPt<300";

  //const TCut triggerCut = "HLT_PAPhoton10_NoCaloIdVL_v1 && HLT_PAPhoton10_NoCaloIdVL_v1_Prescl==1 && L1_SingleEG5_BptxAND_Prescl==1";
  const TCut triggerCut = "HLT_PAPhoton10_NoCaloIdVL_v1";
  const TCut showerCut = "sigmaIetaIeta > 0.011";
  const TCut etaCut = "abs(eta) < 1.44";
  //const TCut trackerIso = "trkSumPtHollowConeDR04 > 2";
  const TCut ecalIso = "ecalRecHitSumEtConeDR04 > 4.2";
  //const TCut hcalIso
  Int_t count = ecalTree->Project(ecalSpectra->GetName(),"pt", triggerCut && showerCut && etaCut && ecalIso);
  printf("Num events: %i\n", count);

  TCanvas *c1 = new TCanvas();
  ecalSpectra->Draw();
  // correctedEcalSpectra->Draw("same");
  c1->SetLogy();

  // TFile *outFile = new TFile("ecalSpectra.root", "RECREATE");
  // outFile->cd();
  // ecalSpectra->Write();
  // correctedEcalSpectra->Write();
  // outFile->Close();
}
开发者ID:richard-cms,项目名称:ecalClusterAnalysis,代码行数:44,代码来源:ecalSpectra.C

示例6: addTreeToFile


//.........这里部分代码省略.........

        if( iEntry==0 ) { // initialize stuff

            if( id<100 ) {
                egcor.doScale=true;
                egcor.doSmearings=false;
            } else {
                egcor.doScale=false;
                egcor.doSmearings=true;
            }

        }



        if( event == DEBUG_EVENT ) {
            std::cout << "++++ STARTING DEBUG COUT FOR: " << std::endl;
            std::cout << "    Run: " << run << std::endl;
            std::cout << "    LS : " << lumi << std::endl;
            std::cout << "    Event : " << event << std::endl;
        }

        bool doSystForThisSample =  doSyst && (id==851 || id==852 || id==4301 || id==4302);

        if( iEntry==0 && doSystForThisSample ) { // allocate all of the PDF stuff

            for( int i=0; i<myTree.nLHEweight; ++i ) {
                pdf_num.push_back(0.);
                std::cout << "[PDF Systematics] Allocating stuff for LHE weight: " << myTree.LHEweight_id[i] << " (" << i << "/" << myTree.nLHEweight << ")" << std::endl;
                bool goodIndex = (myTree.LHEweight_id[i]>=2000 && myTree.LHEweight_id[i]<=3000);
                if( goodIndex ) {
                    TH1D* h1_tmp = new TH1D("pdf_tmp", "", 100, 0., 10000. );
                    h1_tmp->Sumw2();
                    tree->Project( "pdf_tmp", "met_pt", Form("LHEweight_wgt[%d]", i) );
                    pdf_denom.push_back( h1_tmp->Integral() );
                    delete h1_tmp;
                } else {
                    pdf_denom.push_back( 1. );
                }
            }

        } // if first entry


        // remove overlap from DY:
        if( id>=700 && id<710 ) {
            if( myTree.ngamma>0 && myTree.gamma_mcMatchId[0]==22 ) continue;
            //if( myTree.ngamma>0 ) {
            //  bool isFake = myTree.gamma_mcMatchId[0]!=22;
            //  bool okFromDY = isFake || (!isFake && myTree.gamma_drMinParton[0]<0.05);
            //  if( !okFromDY ) continue;
            //}
        }


        if( myTree.nVert==0 ) continue;
        nVert = myTree.nVert;


        // filters
        if( myTree.isData ) {
            if( !myTree.passFilters() ) continue;
        }

        isGolden = myTree.isGolden;
        isSilver = myTree.isSilver;
开发者ID:pandolf,项目名称:ZGAnalysis,代码行数:67,代码来源:runZGAnalysis.cpp

示例7: drawQGFraction

void drawQGFraction(){

	const double PI = 3.14159;

	TChain *mix = new TChain("mixing_tree");
	mix->Add("/data/kurtjung/JetTrackCorr_skims/2p76TeV_MC_Pythia6/MergedPythia_withPartonFlavor.root");
	//mix->Add("/data/kurtjung/JetTrackCorr_skims/5TeV_MC_Pythia6/*");

	//double xsecs[11] = {5.335E-01, 3.378E-02, 3.778E-03, 4.412E-04, 6.147E-05, 1.018E-05, 2.477E-06, 6.160E-07, 1.088E-07, 3.216E-08, 0}; //pythia6 5.02 tev weights
    double xsecs[11] = {2.043e-01, 1.075E-02, 1.025E-03, 9.865E-05, 1.129E-05, 1.465E-06, 2.837E-07, 5.323E-08, 5.934e-09, 8.125e-10, 0}; //2.76 tev weights
	int recalculatedEntries[10] = {0,0,0,0,0,0,0,0,0,0};
	double pthatbins[11] = {15,30,50,80,120,170,220,280,370,460,9999};

	TFile *fout = new TFile("QGFrac_pythia6_2p76TeV.root","recreate");

	TH1D *quarkFracIncl = new TH1D("quarkFracIncl","",20,120,500); quarkFracIncl->Sumw2();
	TH1D *glueFracIncl = new TH1D("glueFracIncl","",20,120,500); glueFracIncl->Sumw2();
	TH1D *inclJets = new TH1D("inclJets","",20,120,500); inclJets->Sumw2();

	TH1D *quarkFracLead = new TH1D("quarkFracLead","",20,120,500); quarkFracLead->Sumw2();
	TH1D *glueFracLead = new TH1D("glueFracLead","",20,120,500); glueFracLead->Sumw2();
	TH1D *leadJets = new TH1D("leadJets","",20,120,500); leadJets->Sumw2();


	Int_t HBHENoiseFilterResultRun2Loose, pPAprimaryVertexFilter;
	vector<float> *calo_corrpt=0, *calo_jtphi=0;
	vector<int> *calo_refparton_flavor=0;
	float pthat;

	mix->SetBranchAddress("calo_corrpt",&calo_corrpt);
	mix->SetBranchAddress("calo_jtphi",&calo_jtphi);
	mix->SetBranchAddress("calo_refparton_flavor",&calo_refparton_flavor);
	mix->SetBranchAddress("pthat",&pthat);

	mix->SetBranchAddress("HBHENoiseFilterResultRun2Loose",&HBHENoiseFilterResultRun2Loose);
	mix->SetBranchAddress("pPAprimaryVertexFilter",&pPAprimaryVertexFilter);


	TH1D *pthatHisto = new TH1D("pthatHisto","",10,pthatbins);
	mix->Project("pthatHisto","pthat");
	for(int i=0; i<10; i++){
		recalculatedEntries[i] = pthatHisto->GetBinContent(i+1);
		cout << "entries between pthat " << pthatbins[i] << " and " << pthatbins[i+1] << ": " << recalculatedEntries[i] << endl;
		cout << "weight: " << (xsecs[i]-xsecs[i+1])/recalculatedEntries[i] <<endl;
	}

	int totEntries = mix->GetEntries();
	cout << "entries: "<< totEntries << endl;
	totEntries=100000;
	for(int ievt=0; ievt<totEntries; ievt++){
		mix->GetEntry(ievt);
		if(ievt && ievt%10000==0) cout << "entry: " << ievt << endl;

		//if(!HBHENoiseFilterResultRun2Loose || !pPAprimaryVertexFilter) continue;

		int ibin=0;
		double weight=0.;
		while(pthat>pthatbins[ibin]) ibin++;
		ibin--;
		weight = (xsecs[ibin]-xsecs[ibin+1])/recalculatedEntries[ibin];
		if(weight>1){ 
			cout << "xsec: "<< xsecs[ibin]-xsecs[ibin+1] << " entries: " << recalculatedEntries[ibin] << endl;
			cout << "pthat: "<< pthat << " bin " << ibin << endl;
		}
		
		for(unsigned int ijet=0; ijet<calo_corrpt->size(); ijet++){
			
			if(abs(calo_refparton_flavor->at(ijet))>0 && abs(calo_refparton_flavor->at(ijet))<6) quarkFracIncl->Fill(calo_corrpt->at(ijet), weight);
			if(abs(calo_refparton_flavor->at(ijet))==21){ glueFracIncl->Fill(calo_corrpt->at(ijet), weight); }
			inclJets->Fill(calo_corrpt->at(ijet), weight);

			if(ijet==0 && calo_corrpt->size()>1){
				double dphi = abs(calo_jtphi->at(0) - calo_jtphi->at(1));
				if(dphi>(7*PI/8.) && dphi<(9*PI/8.) && calo_corrpt->at(1)>50) {

					if(abs(calo_refparton_flavor->at(ijet))>0 && abs(calo_refparton_flavor->at(ijet))<6) quarkFracLead->Fill(calo_corrpt->at(ijet), weight);
					if(abs(calo_refparton_flavor->at(ijet))==21) glueFracLead->Fill(calo_corrpt->at(ijet), weight);
					leadJets->Fill(calo_corrpt->at(ijet), weight);

				}
			}
		}
	}

	//quarkFracLead->Divide(leadJets);
	//glueFracLead->Divide(leadJets);

	//quarkFracIncl->Divide(inclJets);
	//glueFracIncl->Divide(inclJets);

	fout->cd();

	formatHisto(quarkFracLead,1);
	formatHisto(glueFracLead,2);
	formatHisto(quarkFracIncl,4);
	formatHisto(glueFracIncl,8);

	quarkFracLead->Write();
	glueFracLead->Write();
	quarkFracIncl->Write();
//.........这里部分代码省略.........
开发者ID:kurtejung,项目名称:JetTrackCorrelations,代码行数:101,代码来源:drawQGFraction.C

示例8: makeSamePhiPlots

void makeSamePhiPlots() 
{
   gSystem->AddIncludePath("-I${EVENT_READER_DIR}");
   gSystem->AddIncludePath("-I${PLOTTER_DIR}");
   //  cout << gSystem->GetIncludePath() <<endl;
   
   gSystem->Load("libMathMore.so");
   gSystem->Load("/usr/lib64/libfftw3.so");
   gSystem->Load("libAnitaEvent.so");
   gSystem->Load("libAnitaCorrelator.so");
   TChain *deltaTTree = new TChain("deltaTTree");
   //   TFile *fp = new TFile("deltaTFile1027.root");
   //   TTree *deltaTTree = (TTree*) fp->Get("deltaTTree");
   deltaTTree->Add("deltaTFileClock*.root");
   
   AnitaGeomTool *fGeomTool = AnitaGeomTool::Instance();



   char plotCond[180];
   char plotTitle[180];
   char histName[180];
   TF1 *fitty = new TF1("fitty","gaus",-1,1);

   TH1F *histMeanDiff = new TH1F("histMeanDiff","histMeanDiff",100,-1,1);
   TH1F *histChiSq = new TH1F("histChiSq","histChiSq",100,0,3);
   TH1F *histSigma = new TH1F("histSigma","histSigma",100,0,10);
   TH1F *histConstant = new TH1F("histConstant","histConstant",100,0,100);

   ofstream Output("diffsDown.txt");

   for(int ant=0;ant<16;ant++) {
      TCanvas *can = new TCanvas();//"can","can");
      can->Divide(2,2);
      int topAnt=ant; 
      int bottomAnt=fGeomTool->getAzimuthPartner(topAnt); 
      for(int chip=0;chip<4;chip++) {
	 fitty->SetParameters(10,0,0.05);
	 //	 fitty->SetParLimits(2,0,0.1);

	 can->cd(chip+1);
	 sprintf(plotCond,"((firstAnt==%d && secondAnt==%d))  && labChip==%d && (corPeak/corRMS)>6",topAnt,bottomAnt,chip);	 
	 sprintf(plotTitle,"Ant %d -  Ant %d (Chip %d)",topAnt,bottomAnt,chip);
	 sprintf(histName,"histDt_%d_%d",ant,chip);
	 TH1F *histDt11 = new TH1F(histName,plotTitle,40,-0.5,0.5);

	 deltaTTree->Project(histName,"deltaT-deltaTExpected",plotCond);
	 //	 cout << plotCond << endl;
	 histDt11->Draw();
	 histDt11->Fit("fitty","Q");
	 Int_t numUnder= histDt11->GetBinContent(0);
	 Int_t numOver =histDt11->GetBinContent(1+histDt11->GetNbinsX());
// 	 cout << topAnt << "\t" << bottomAnt << "\t" << chip << "\t" << histDt11->GetEntries() << "\t"
// 	      << (histDt11->GetEntries()-(numOver+numUnder)) << "\t" << histDt11->GetMean() << "\t" << histDt11->GetRMS() << "\t"
// 	      << fitty->GetParameter(1) << "\t" << fitty->GetParError(1) << "\t" << fitty->GetParameter(2) << "\t"
// 	      << fitty->GetParError(2)  << "\t" << fitty->GetChisquare() << "\t" << fitty->GetNDF() << "\n";
	 histMeanDiff->Fill(fitty->GetParameter(1));
	 histChiSq->Fill(fitty->GetChisquare()/Double_t(fitty->GetNDF()));
	 histSigma->Fill(fitty->GetParameter(2));
	 histConstant->Fill(fitty->GetParameter(0));


	 Double_t constant=histDt11->GetMean();
	 Double_t error=0;
	 if(histDt11->GetEntries())
	    error=histDt11->GetRMS()/TMath::Sqrt(histDt11->GetEntries());
	 Int_t entries=(histDt11->GetEntries()-(numOver+numUnder));

	 if(TMath::Abs(fitty->GetParameter(1)-histDt11->GetMean())<0.01 || (entries>=20 && fitty->GetParError(1)<0.08)) {
	    constant=fitty->GetParameter(1);
	    error=fitty->GetParError(1);
	 }
	 else {
	    cout << topAnt << "\t" << bottomAnt << "\t" << chip << "\n";
	 }
	 Output << topAnt << "\t" << bottomAnt << "\t" << chip << "\t" << constant << "\t" << error << "\t"
		<< entries << "\n";
      }
	 
   }
   TCanvas *canSum = new TCanvas();
   canSum->Divide(2,2);
   canSum->cd(1);
   histChiSq->Draw();
   canSum->cd(2);
   histConstant->Draw();
   canSum->cd(3);
   histMeanDiff->Draw();
   canSum->cd(4);
   histSigma->Draw();    

      
}
开发者ID:anitaNeutrino,项目名称:anitaEventCorrelator,代码行数:93,代码来源:makeSamePhiPlots.C

示例9: plotLHCPPZHproj

void plotLHCPPZHproj(variables var=km) {

  RooRealVar* costheta1 = new RooRealVar("costheta1","cos#theta_{1}",-1.,1.);
  RooRealVar* costheta2 = new RooRealVar("costheta2","cos#theta_{2}",-1.,1.);
  RooRealVar* phi = new RooRealVar("phi","#Phi",-TMath::Pi(),TMath::Pi());
  RooRealVar* m= new RooRealVar("m","m_{VH} [GeV]", 200, 1000);
  RooRealVar* Y= new RooRealVar("Y","Rapidity (VH)", -4, 4);
  // additional variables
  // event weight
  RooRealVar* wt = new RooRealVar("wt", "wt", 0.0, 50);

  vector<RooRealVar*> meas;
  meas.push_back(costheta1);
  meas.push_back(costheta2);
  meas.push_back(phi);
  meas.push_back(m);
  meas.push_back(Y);
  meas.push_back(wt);

  
  int parameterization = 1; 

  RooRealVar* mH = new RooRealVar("mH","m_{H}",125.);
  ScalarPdfFactoryPPZH SMHiggs(costheta1,costheta2,phi,m,Y,mH,parameterization,false);

  ScalarPdfFactoryPPZH psScalar(costheta1,costheta2,phi,m,Y,mH,parameterization,false);
  psScalar.g1Val->setVal(0.0);
  psScalar.g4Val->setVal(1.0);

  ScalarPdfFactoryPPZH f3p5Scalar(costheta1,costheta2,phi,m,Y,mH,parameterization,false);
  f3p5Scalar.g1Val->setVal(1.0);
  f3p5Scalar.g4Val->setVal(0.144708);

  ScalarPdfFactoryPPZH f3p5_90_Scalar(costheta1,costheta2,phi,m,Y,mH,parameterization,false);
  f3p5_90_Scalar.g1Val->setVal(1.0);
  f3p5_90_Scalar.g4ValIm->setVal(0.144708);


  //
  //  Read datasets
  // 
  TChain* SMHtree = new TChain("SelectedTree");
  SMHtree->Add("samples/pp_ZH/pp_ZH_llbb_g1_1M_false.root");
  RooDataSet dataTMPSMH("dataTMPSMH","dataTMPSMH", SMHtree, RooArgSet(*costheta1,*costheta2,*phi,*m,*Y, *wt));
  RooDataSet SMHdata = RooDataSet("SMHData","SMHData",RooArgList(*costheta1,*costheta2,*phi,*m, *Y, *wt), WeightVar("wt"), Import(dataTMPSMH));

  TChain* PStree = new TChain("SelectedTree");
  PStree->Add("samples/pp_ZH/pp_ZH_llbb_g4_1M_false.root");
  RooDataSet dataTMPPS("dataTMPPS","dataTMPPS", PStree, RooArgSet(*costheta1,*costheta2,*phi,*m,*Y, *wt));
  RooDataSet PSdata = RooDataSet("PSData","PSData",RooArgList(*costheta1,*costheta2,*phi,*m, *Y, *wt), WeightVar("wt"), Import(dataTMPPS));

  TChain* f3p5tree = new TChain("SelectedTree");
  f3p5tree->Add("samples/pp_ZH/pp_ZH_llbb_g1_p_g4_1M_false.root");
  RooDataSet dataTMPf3p5("dataTMPf3p5","dataTMPf3p5", f3p5tree, RooArgSet(*costheta1,*costheta2,*phi,*m,*Y, *wt));
  RooDataSet f3p5data = RooDataSet("f3p5Data","f3p5Data",RooArgList(*costheta1,*costheta2,*phi,*m, *Y, *wt), WeightVar("wt"), Import(dataTMPf3p5));

  TChain* f3p5_90_tree = new TChain("SelectedTree");
  f3p5_90_tree->Add("samples/pp_ZH/pp_ZH_llbb_g1_p_ig4_1M_false.root");
  RooDataSet dataTMPf3p5_90("dataTMPf3p5_90","dataTMPf3p5_90", f3p5_90_tree, RooArgSet(*costheta1,*costheta2,*phi,*m,*Y, *wt));
  RooDataSet f3p5_90_data = RooDataSet("f3p5_90Data","f3p5_90Data",RooArgList(*costheta1,*costheta2,*phi,*m, *Y, *wt), WeightVar("wt"), Import(dataTMPf3p5_90));
  
  TString varName = "costheta1";
  const int nbins = 20;
  double xMin =  -1; 
  double xMax = 1.;
  
  if ( var == kcostheta2 ) {
    varName = "costheta2";
  } else if( var == kphi)  {
    varName = "phi";
    xMin = -TMath::Pi();
    xMax = TMath::Pi();
  } else if ( var == km)   {
    varName = "m";
    xMin = 200;
    xMax = 1000.;
  } else if ( var == kY)  {
    varName = "Y";
    xMin = -4;
    xMax = 4;
  }
  // 
  // Do some gymnastics about the plots
  // normalize to 1
  // 
  
  TH1F *h_0p = new TH1F("h_0p", "h_0p", nbins, xMin, xMax);
  SMHtree->Project("h_0p", varName,"wt");
  double rescale_0p = 1./h_0p->Integral();
  h_0p->Scale(rescale_0p);
  // std::cout << "rescale_0p = " << rescale_0p << "\n";
  double ymax = h_0p->GetMaximum();
  
  TH1F *h_0m = new TH1F("h_0m", "h_0m", nbins, xMin, xMax); 
  PStree->Project("h_0m", varName,"wt");
  double rescale_0m = 1./h_0m->Integral();
  // std::cout << "rescale_0m = " << rescale_0m << "\n";
  h_0m->Scale(rescale_0m);
  ymax = h_0m->GetMaximum() > ymax ? h_0m->GetMaximum() : ymax;

//.........这里部分代码省略.........
开发者ID:awhitbeck,项目名称:usercode,代码行数:101,代码来源:plotLHCPPZHproj.C

示例10: TChain

make_complete_histo(){

	
	TChain* genie = new TChain("MasterTree");
	genie->Add("Level7_genie_ic.1460.0000XX_LowE.root");

	//change these 3 numbers for the amount of bins: Warning, there is a n^2 efficiency so be careful 
	const int nbins_en = 10; 
	const int nbins_cos_theta = 10; 
	const int nbins_phi =4; 

	const int nbins_total = nbins_en*nbins_cos_theta*nbins_phi;
	double binedges_en[nbins_en+1];
	double binedges_cos_theta[nbins_cos_theta+1];
	double binedges_phi[nbins_phi+1];


	//The final matrix histogram
	TH2D* matrix_histo = new TH2D("matrix_histo","matrix_histo",nbins_total,0,nbins_total,nbins_total,0,nbins_total);


	//Initialise the bin edges
	binedges_en[0]=0.0;
	for (int i = 1; i < nbins_en+1; ++i){ binedges_en[i]= binedges_en[i-1] + 200/(double)nbins_en; }
	binedges_cos_theta[0]=-1.0;
	for (int i = 1; i < nbins_cos_theta+1; ++i){ binedges_cos_theta[i]= binedges_cos_theta[i-1] + 2/(double)nbins_cos_theta; }
	binedges_phi[0]=0.0;
	for (int i = 1; i < nbins_phi+1; ++i){ binedges_phi[i]= binedges_phi[i-1] + (2*TMath::Pi())/(double)nbins_phi; }	


	//Fill each bin with the # recon(ij) in true(mn)
	for (int true_e = 0; true_e < nbins_en; ++true_e){ //true energy bin loop
		for (int recon_e = 0; recon_e < nbins_en; ++recon_e){ //recon energy bin loop
			cout << endl<< true_e << " " << recon_e << endl;
			for (int true_theta = 0; true_theta < nbins_cos_theta; ++true_theta){
				for (int recon_theta = 0; recon_theta < nbins_cos_theta; ++recon_theta)
				{
					//create the histogram to read values from, setting energy cuts and theta bins
					TH2D* firstrun = new TH2D("firstrun","firstrun",nbins_phi,binedges_phi,nbins_phi,binedges_phi);
					//create the stupidly long cut 
					char* cut_e = Form("(MCMuon.energy >%8.7f && MultiNest8D_Track.energy >%8.7f && MCMuon.energy <=%8.7f && MultiNest8D_Track.energy <=%8.7f", binedges_en[true_e],binedges_en[recon_e], binedges_en[true_e+1], binedges_en[recon_e+1]);
					char* cut_theta = Form(" && TMath::Cos(MCMuon.zenith) >%8.7f && TMath::Cos(MultiNest8D_Track.zenith) >%8.7f && TMath::Cos(MCMuon.zenith) <=%8.7f && TMath::Cos(MultiNest8D_Track.zenith) <=%8.7f)", binedges_cos_theta[true_theta], binedges_cos_theta[recon_theta], binedges_cos_theta[true_theta+1], binedges_cos_theta[recon_theta+1] );
					char* cut_total[9999];	
					strcpy(cut_total, cut_e);


					//project all azimuth values for this cut
					genie->Project("firstrun","MCMuon.azimuth:MultiNest8D_Track.azimuth",strcat(cut_total, cut_theta));

					//move values into matrix_histo
					for (int t_bin = 0; t_bin < nbins_phi; ++t_bin){	
						for (int r_bin = 0; r_bin < nbins_phi; ++r_bin){
							//read for all azimuth angles for specific energy and zenith
							double tempval = firstrun->GetBinContent(r_bin+1,t_bin+1);
							matrix_histo->SetBinContent((recon_e*nbins_cos_theta*nbins_phi)+(true_theta*nbins_phi)+r_bin+1,(true_e*nbins_cos_theta*nbins_phi)+(recon_theta*nbins_phi)+t_bin+1, tempval);
						}
					}

					//delete histogram to free space for next loop
					delete firstrun;
					cout << true_theta << " " << recon_theta << endl;
				}
			}
		}
	}
	//save the histogram for later use
	matrix_histo->SaveAs(Form("icecube_energy_%d_cos_%d_phi_%d.root",nbins_en,nbins_cos_theta,nbins_phi));

}
开发者ID:rlh1994,项目名称:DCS-Calculating,代码行数:69,代码来源:make_complete_histo.cpp

示例11: ootpu_comparison

void ootpu_comparison(TString files, TString var, TString title, int nbins, float low, float high, TString comments="") {

  TChain* chain = new TChain("reduced_tree");
  chain->Add(files);

  TH1::SetDefaultSumw2();

  TH1F* hA = new TH1F("hA",title, nbins, low, high);
  TH1F* hB = new TH1F("hB",title, nbins, low, high);
  TH1F* hC = new TH1F("hC",title, nbins, low, high);
  TH1F* hD = new TH1F("hD",title, nbins, low, high);

  TH1F* hA_l = new TH1F("hA_l",title, nbins, low, high);
  TH1F* hB_l = new TH1F("hB_l",title, nbins, low, high);
  TH1F* hC_l = new TH1F("hC_l",title, nbins, low, high);
  TH1F* hD_l = new TH1F("hD_l",title, nbins, low, high);
  hA->SetStats(0);
  hA->GetYaxis()->SetLabelSize(0.04);
  //hA->GetYaxis()->SetTitleOffset(1.3);
  hA->GetXaxis()->SetTitleOffset(1.1);
  hA->GetXaxis()->SetTitleFont(132);
  hA->GetXaxis()->SetTitleSize(0.042);
  hA->GetXaxis()->SetLabelSize(0.04);
  hA->SetLineWidth(2);

  //  hA->StatOverflows(true);
  //  hB->StatOverflows(true);
  //  hC->StatOverflows(true);
  //  hD->StatOverflows(true);

  int n1(0), n2(0), n3(0), n4(0), n5(0);
  if (files.Contains("20bx25")) {
    n1=5;
    n2=17;
    n3=21;
    n4=25;
    n5=40;
  }
  else if (files.Contains("S14")) {
    n1=0;
    n2=25;
    n3=40;
    n4=55;
    n5=120;
  }
  else { // default: 8 TeV scenario
    n1=0;
    n2=15;
    n3=22;
    n4=32;
    n5=70;
  }


  TString mu("num_gen_muons==1&&muon_reco_match>=0");
  //if (files.Contains("PU_S10")) {
  TString cuts = Form("(%s)&&(eoot_pu>=%d&&eoot_pu<%d)",mu.Data(),n1,n2);
  cout << "Cuts: " << cuts.Data() << endl;
  chain->Project("hA", var, cuts);
  cuts = Form("(%s)&&(loot_pu>=%d&&loot_pu<%d)",mu.Data(),n1,n2);
  chain->Project("hA_l", var, cuts);
  cuts = Form("(%s)&&(eoot_pu>=%d&&eoot_pu<%d)",mu.Data(),n2,n3);
  cout << "Cuts: " << cuts.Data() << endl;
  chain->Project("hB", var, cuts);
  cuts = Form("(%s)&&(loot_pu>=%d&&loot_pu<%d)",mu.Data(),n2,n3);
  chain->Project("hB_l", var, cuts);
  cuts = Form("(%s)&&(eoot_pu>=%d&&eoot_pu<%d)",mu.Data(),n3,n4);
  cout << "Cuts: " << cuts.Data() << endl;
  chain->Project("hC", var, cuts);
  cuts = Form("(%s)&&(loot_pu>=%d&&loot_pu<%d)",mu.Data(),n3,n4);
  chain->Project("hC_l", var, cuts);
  cuts = Form("(%s)&&(eoot_pu>=%d)",mu.Data(),n4);
  cout << "Cuts: " << cuts.Data() << endl;
  chain->Project("hD", var, cuts);
  cuts = Form("(%s)&&(loot_pu>=%d)",mu.Data(),n4);
  chain->Project("hD_l", var, cuts);
  // }
  // else {
  //  }
  
  float avg1(hA->GetMean());
  float avg2(hB->GetMean());
  float avg3(hC->GetMean());
  float avg4(hD->GetMean());

  hA->Scale(1/hA->Integral());
  hB->Scale(1/hB->Integral());
  hC->Scale(1/hC->Integral());
  hD->Scale(1/hD->Integral());

  hA->SetLineColor(1);
  hB->SetLineColor(2);
  hC->SetLineColor(3);
  hD->SetLineColor(4);

  hA->SetLineWidth(2);
  hB->SetLineWidth(2);
  hC->SetLineWidth(2);
  hD->SetLineWidth(2);

//.........这里部分代码省略.........
开发者ID:ald77,项目名称:csa14,代码行数:101,代码来源:compare_OOTPU_dists.C

示例12: GetCombinedEfficiency

TGraphAsymmErrors* GetCombinedEfficiency(const TString cut = "min_delta_phi_met_N>4.", const TString preselection="")
{ 
  
  TH1::SetDefaultSumw2();

  const int nbins=16;
  const double varbins[nbins+1]={0,20,40,60,80,100,125,150,175,200,250,300,400,500,600,800,1000};


    
  TCut all(preselection);
  TCut ccut(cut);
  TCut pass(all+ccut);


  TFile *fout = new TFile("macros/qcd_control/output.root", "recreate");
  fout->cd();

  cout << "Denom. cuts: " << (string)all << endl;
  cout << "Num. cuts: " << (string)pass << endl;

  TList* pList=new TList();
  vector<TH1D> v_all, v_pass;

  for (unsigned int sample(0); sample<nSamples; sample++) {
      
    TChain * ch = new TChain();
    ch->Add(qcd_files[sample]+"/reduced_tree");


    TH1D* hMETall = new TH1D(Form("hMETall_%d",sample),"hMETall",nbins,varbins);
    TH1D* hMETpass = new TH1D(Form("hMETpass_%d",sample),"hMETpass",nbins,varbins);

    ch->Project(hMETall->GetName(),"met",all);
    ch->Project(hMETpass->GetName(),"met",pass);

    Double_t e_overflow(0.), i_overflow(0.);
    i_overflow=hMETall->IntegralAndError(nbins,nbins+1,e_overflow);
    hMETall->SetBinContent(nbins, i_overflow);
    hMETall->SetBinError(nbins, e_overflow);
    i_overflow=hMETpass->IntegralAndError(nbins,nbins+1,e_overflow);
    hMETpass->SetBinContent(nbins, i_overflow);
    hMETpass->SetBinError(nbins, e_overflow);

    printf("Sample %d: hMETpass/hMETall=%.1f/%.1f\n",sample, hMETpass->Integral(),hMETall->Integral());

      
    delete ch;

    v_all.push_back(*hMETall);
    v_pass.push_back(*hMETpass);

    delete hMETall;
    delete hMETpass;

  }

  for (unsigned int sample(0); sample<nSamples; sample++) {
    cout << "Found hist " << v_all[sample].GetName() << endl;
    v_all[sample].Write();
    v_pass[sample].Write();
    TEfficiency* pEff = new TEfficiency(v_pass[sample],v_all[sample]);
    pList->Add(pEff);
  }

  TGraphAsymmErrors* gr = TEfficiency::Combine(pList,"v,mode",nSamples,weights);
  return gr;
}
开发者ID:ald77,项目名称:csa14,代码行数:68,代码来源:mdpRatios.C

示例13: TriggerStudy

void TriggerStudy(int initialRunNumber){
  gStyle->SetOptStat("neMRIuo");
  gSystem->Load("../E14_ANA_COSMIC/lib/libtest.so");
  IDHandler* handler = new IDHandler(" ../E14_ANA_COSMIC/Data/crystal.txt");
  CsIImage*  image[4];
  for( int i = 0; i< 4; i++){
    image[i] = new CsIImage(handler);
  }

  const Int_t nRUN     = 4;
  char* name[4]        ={"Double_et","4Cluster_200MeV","4Cluster_160MeV","3Cluster_370MeV"};
  Int_t RunNumber[4]={3969,4089,4094,4097};
  Double_t SECValue[4] ={257727,327229,286614,303859};
  Double_t Spill[4]    ={145,184,162,172}; 
  
  TH1D* hisKLMass[4];
  TH1D* hisKLMom[4];
  TH1D* TextMassEntries[4];
  TH1D* TextMomEntries[4];
  
  TChain* ch[4];
  for( int i =0 ;i< 4; i++){
    ch[i] = new TChain("Tree");
    ch[i]->Add(Form("klongRootFile/kl%04d.root",RunNumber[i]));
  };
  
  TH1D* hisKLMass[3];
  TH1D* hisKLMom[2];
  TText* textMassEntries[3];
  TText* textMomEntries[2];
  


  hisKLMass[0] = new TH1D("hisKLMassWithNOCut",Form("KLMass%06d;Mass[MeV];N/5MeV"          ,initialRunNumber),80,400,800);
  hisKLMass[1] = new TH1D("hisKLMassCutSome"  ,Form("KLMassWithCut%06d;Mass[MeV];N/5MeV"   ,initialRunNumber),80,400,800);
  hisKLMass[2] = new TH1D("hisKLMassCutFull"  ,Form("KLMassWithAllCut%06d;Mass[MeV];N/5MeV",initialRunNumber),80,400,800);
  hisKLMass[0]->SetLineColor(1);
  hisKLMass[1]->SetLineColor(2);
  hisKLMass[2]->SetLineColor(3);
  hisKLMom[0] = new TH1D("hisKLMomWithNOCut","KLMomentum;Momentum[MeV];N/20MeV",300,0,6000);
  hisKLMom[1] = new TH1D("hisKLMomCut0x00F" ,"KLMomentum;Momentum[MeV];N/20MeV",300,0,6000);
  hisKLMom[1]->SetLineColor(2);
  
  TChain* ch  = new TChain("Tree");
  ch->Add(Form("klongRootFile/kl%04d.root",initialRunNumber));
  
  ch->Project(hisKLMass[0]->GetName(),"KlongMass[0]");
  ch->Project(hisKLMass[1]->GetName(),"KlongMass[0]" ,"(CutCondition & (8))==0 && TMath::Abs(KlongMass[0]-498) < 10");
  ch->Project(hisKLMass[2]->GetName(),"KlongMass[0]" ,"(CutCondition & (1+2+4+8))==0 && TMath::Abs(KlongMass[0]-498)<10");
  ch->Project(hisKLMom[0]->GetName() ,"KlongMom[0][2]");
  ch->Project(hisKLMom[1]->GetName() ,"KlongMom[0][2]","(CutCondition & (1+2+4+8))==0");  
  TCanvas* can = new TCanvas("can","",1200,600);
  can->Divide(2,1);

  std::cout << hisKLMass[0]->GetEntries() << std::endl;
  std::cout << hisKLMass[1]->GetEntries() << std::endl;
  
  can->cd(1);
  gPad->SetLogy();
  hisKLMass[0]->Draw();
  hisKLMass[1]->Draw("same");
  hisKLMass[2]->Draw("same");
  textMassEntries[0] = new TText(0.5,0.5,"");
  textMassEntries[1] = new TText(0.5,0.5,"");
  textMassEntries[2] = new TText(0.5,0.5,"");
  textMassEntries[0]->SetTextSize(0.04);
  textMassEntries[1]->SetTextSize(0.04);
  textMassEntries[2]->SetTextSize(0.04);
  textMassEntries[0]->SetTextColor(1);
  textMassEntries[1]->SetTextColor(2);
  textMassEntries[2]->SetTextColor(3);
  textMassEntries[0]->DrawTextNDC(0.5,0.6,Form("#of Klong(NoCut):%d",(int)hisKLMass[0]->GetEntries()));
  textMassEntries[1]->DrawTextNDC(0.5,0.55,Form("#of Klong(SumeCut):%d",(int)hisKLMass[1]->GetEntries()));
  textMassEntries[2]->DrawTextNDC(0.5,0.5,Form("#of Klong(FullCut):%d",(int)hisKLMass[2]->GetEntries()));

  can->cd(2);
  gPad->SetLogy();
  hisKLMom[0]->Draw();
  hisKLMom[1]->Draw("same");
  can->SaveAs(Form("Image/KLong_%06d.gif",initialRunNumber));
}
开发者ID:laerad84,项目名称:Analysis,代码行数:81,代码来源:TriggerStudy.C

示例14: optimize_n_jets

void optimize_n_jets(const TString sigName = "reduced_trees/SMS-T1tttt_2J_mGl-1500_mLSP-100*v75*.root", const TString bgName = "all", const TString plotNote="T1tttt_1500_100_met_200_ht40_1000", const TCut cuts="") 
{
  set_plot_style();
  TH1::StatOverflows(true);
  TH1::SetDefaultSumw2(); //trick to turn on Sumw2 for all histos
  //TH1::SetStats(0);

  const unsigned int nbins = 16;

  TH1D* h_n30sig = new TH1D("h_n30sig",";n_{jets};Events after cut (#int L dt = 5 fb^{-1})",nbins,0.,16.);
  TH1D* h_n30bg = new TH1D("h_n30bg","",nbins,0.,16.);
  TH1D* h_n40sig = new TH1D("h_n40sig","",nbins,0.,16.);
  TH1D* h_n40bg = new TH1D("h_n40bg","",nbins,0.,16.);
  TH1D* h_n50sig = new TH1D("h_n50sig","",nbins,0.,16.);
  TH1D* h_n50bg = new TH1D("h_n50bg","",nbins,0.,16.);
  TH1D* h_n70sig = new TH1D("h_n70sig","",nbins,0.,16.);
  TH1D* h_n70bg = new TH1D("h_n70bg","",nbins,0.,16.);
  TH1D* h_n100sig = new TH1D("h_n100sig","",nbins,0.,16.);
  TH1D* h_n100bg = new TH1D("h_n100bg","",nbins,0.,16.);

  // TH1D* h_n30sig_pass = new TH1D("h_n30sig_pass",";n_{jets};EventsPassing cut",nbins,0.,16.);
  // TH1D* h_n40sig_pass = new TH1D("h_n40sig_pass","",nbins,0.,16.);
  // TH1D* h_n50sig_pass = new TH1D("h_n50sig_pass","",nbins,0.,16.);
  // TH1D* h_n70sig_pass = new TH1D("h_n70sig_pass","",nbins,0.,16.);
  // TH1D* h_n100sig_pass = new TH1D("h_n100sig_pass","",nbins,0.,16.);

  TH1D* h_n30s_over_sqrt_b = new TH1D("h_n30s_over_sqrt_b",";n_{jets} cut;S/#sqrt{B}",nbins,0.,16.);
  TH1D* h_n40s_over_sqrt_b = new TH1D("h_n40s_over_sqrt_b","",nbins,0.,16.);
  TH1D* h_n50s_over_sqrt_b = new TH1D("h_n50s_over_sqrt_b","",nbins,0.,16.);
  TH1D* h_n70s_over_sqrt_b = new TH1D("h_n70s_over_sqrt_b","",nbins,0.,16.);
  TH1D* h_n100s_over_sqrt_b = new TH1D("h_n100s_over_sqrt_b","",nbins,0.,16.);

  h_n30sig->SetStats(0);
  h_n30s_over_sqrt_b->SetStats(0);


  TCut start(cuts+"met>200&&ht40>500&&num_csvm_jets30>1&&min_delta_phi_met_N>4&&num_reco_veto_muons==0&&num_reco_veto_electrons==0");
  TCut weighted_selection(start*"(weightppb*5000.)");

  TChain * bg = new TChain("reduced_tree");
  TChain * sig = new TChain("reduced_tree");
  if (!bgName.EqualTo("all")) bg->Add(bgName);// treestring is passed as an argument
  else {
    bg->Add("reduced_trees/skimmed/TTJets*v75*.root");
    bg->Add("reduced_trees/skimmed/QCD*v75*.root");
    bg->Add("reduced_trees/skimmed/WJets*v75*.root");
    bg->Add("reduced_trees/skimmed/ZJets*v75*.root");
    bg->Add("reduced_trees/skimmed/TTo*v75*.root");
    bg->Add("reduced_trees/skimmed/TBarTo*v75*.root");
    bg->Add("reduced_trees/skimmed/*tW*v75*.root");
    bg->Add("reduced_trees/skimmed/*HToBB*v75*.root");
    bg->Add("reduced_trees/skimmed/TTbarH*v75*.root");
  }
  sig->Add(sigName);

  TCanvas * thecanvas= new TCanvas("thecanvas","the canvas",800,1600);
  TPad* pad1 = new TPad("pad1","This is pad1",0.,0.5,1,1);
  TPad* pad2 = new TPad("pad1","This is pad2",0.,0.,1,0.5);
  pad1->Draw();
  pad2->Draw();

  sig->Project("h_n30sig","num_jets_pt30",weighted_selection);
  bg->Project("h_n30bg","num_jets_pt30",weighted_selection);
  sig->Project("h_n40sig","num_jets_pt40",weighted_selection);
  bg->Project("h_n40bg","num_jets_pt40",weighted_selection);
  sig->Project("h_n50sig","num_jets_pt50",weighted_selection);
  bg->Project("h_n50bg","num_jets_pt50",weighted_selection);
  sig->Project("h_n70sig","num_jets_pt70",weighted_selection);
  bg->Project("h_n70bg","num_jets_pt70",weighted_selection);
  sig->Project("h_n100sig","num_jets_pt100",weighted_selection);
  bg->Project("h_n100bg","num_jets_pt100",weighted_selection);

  convert_to_int(h_n30sig);
  convert_to_int(h_n40sig);
  convert_to_int(h_n50sig);
  convert_to_int(h_n70sig);
  convert_to_int(h_n100sig);
  convert_to_int(h_n30bg);
  convert_to_int(h_n40bg);
  convert_to_int(h_n50bg);
  convert_to_int(h_n70bg);
  convert_to_int(h_n100bg);

  for (unsigned int bin(0); bin<nbins+1; bin++) {
    if (h_n30bg->GetBinContent(bin+1)>0) h_n30s_over_sqrt_b->SetBinContent(bin+1, h_n30sig->GetBinContent(bin+1)/sqrt(h_n30bg->GetBinContent(bin+1)));
    else h_n30s_over_sqrt_b->SetBinContent(bin+1,100.);
    if (h_n40bg->GetBinContent(bin+1)>0) h_n40s_over_sqrt_b->SetBinContent(bin+1, h_n40sig->GetBinContent(bin+1)/sqrt(h_n40bg->GetBinContent(bin+1)));
    else h_n40s_over_sqrt_b->SetBinContent(bin+1,100.);
    if (h_n50bg->GetBinContent(bin+1)>0) h_n50s_over_sqrt_b->SetBinContent(bin+1, h_n50sig->GetBinContent(bin+1)/sqrt(h_n50bg->GetBinContent(bin+1)));
    else h_n50s_over_sqrt_b->SetBinContent(bin+1,100.);
    if (h_n70bg->GetBinContent(bin+1)>0) h_n70s_over_sqrt_b->SetBinContent(bin+1, h_n70sig->GetBinContent(bin+1)/sqrt(h_n70bg->GetBinContent(bin+1)));
    else h_n70s_over_sqrt_b->SetBinContent(bin+1,100.);
    if (h_n100bg->GetBinContent(bin+1)>0) h_n100s_over_sqrt_b->SetBinContent(bin+1, h_n100sig->GetBinContent(bin+1)/sqrt(h_n100bg->GetBinContent(bin+1)));
    else h_n100s_over_sqrt_b->SetBinContent(bin+1,100.);
   
    // h_n30sig_pass->SetBinContent(bin+1, h_n30sig->Integral(bin+1,nbins+1));
    // h_n40sig_pass->SetBinContent(bin+1, h_n40sig->Integral(bin+1,nbins+1));
    // h_n50sig_pass->SetBinContent(bin+1, h_n50sig->Integral(bin+1,nbins+1));
    // h_n70sig_pass->SetBinContent(bin+1, h_n70sig->Integral(bin+1,nbins+1));
    // h_n100sig_pass->SetBinContent(bin+1, h_n100sig->Integral(bin+1,nbins+1));
//.........这里部分代码省略.........
开发者ID:ald77,项目名称:csa14,代码行数:101,代码来源:optimize_n_jets.C

示例15: plot

void plot(){
	gStyle->SetOptStat(0);

	int run_number = 4085; cerr<<"---- Run Number = "; cin >> run_number;
	TString SAMC_File = "";cerr<<"---- SAMC File = "; cin >> SAMC_File;
    TString Target = ""; cerr<<"---- Target = "; cin >> Target;
	TString Kin = ""; cerr<<"---- Kin = "; cin >> Kin;

	/*Ploting EX Data{{{*/
	TString GeneralCut = "L.tr.n==1";//&&abs(L.tr.x)<0.75 && abs(L.tr.y)<0.55 && abs(L.tr.th)<0.15 && abs(L.tr.ph)<0.045";
	TString TriggerCut3 = "((DBB.evtypebits>>3)&1)";
	TString TriggerCut7 = "((DBB.evtypebits>>7)&1)";
	Double_t y_cut = 0.170;
	TString Acc_real = Form("abs(ExTgtL.th)<0.03&&abs(ExTgtL.ph)<0.02&&abs(ExTgtL.y)<%f&&abs(ExTgtL.dp)<0.04&&abs(RctPtL.z)<0.070",y_cut);
	TString Cut_All = GeneralCut+"&&"+TriggerCut3+"&&"+Acc_real
		+"&&L.cer.asum_c>=50.&&L.prl2.e>=100.&&(L.prl1.e+L.prl2.e)/L.tr.p/1000.>=0.5";
	//TString Cut_All ="1";

	double scale;  int norm = 100000;

	TString filename=Form("/work/halla/e08014/disk1/Rootfiles/e08014_%d.root",run_number);
	TChain *T = new TChain("T");
	T->Add(filename);

	/*Focal Plane{{{*/
	//X_fp
	TH1F *h_xfp = new TH1F("h_xfp","", 100, -1.15,1.15);
	h_xfp->SetXTitle("x_{fp}");
	h_xfp->SetLineColor(2); 
	h_xfp->SetLineWidth(1.1);
	h_xfp->GetXaxis()->SetTitleSize(0.08);
	h_xfp->GetXaxis()->SetTitleOffset(0.7);
	h_xfp->GetXaxis()->CenterTitle(1);
	T->Project("h_xfp","L.tr.r_x",Cut_All);
	scale = norm/h_xfp->Integral(); h_xfp->Scale(scale);
	//Y_fp
	TH1F *h_yfp = new TH1F("h_yfp","", 100, -0.05,0.05);
	h_yfp->SetXTitle("y_{fp}");
	h_yfp->SetLineColor(2); 
	h_yfp->SetLineWidth(1.1);
	h_yfp->GetXaxis()->SetTitleSize(0.08);
	h_yfp->GetXaxis()->SetTitleOffset(0.7);
	h_yfp->GetXaxis()->CenterTitle(1);
	T->Project("h_yfp","L.tr.r_y",Cut_All);
	scale = norm/h_yfp->Integral(); h_yfp->Scale(scale);
	//Th_fp
	TH1F *h_tfp = new TH1F("h_tfp","", 100, -0.02,0.02);
	h_tfp->SetXTitle("#theta_{fp}");
	h_tfp->SetLineColor(2); 
	h_tfp->SetLineWidth(1.1);
	h_tfp->GetXaxis()->SetTitleSize(0.08);
	h_tfp->GetXaxis()->SetTitleOffset(0.7);
	h_tfp->GetXaxis()->CenterTitle(1);
	T->Project("h_tfp","L.tr.r_th",Cut_All);
	scale = norm/h_tfp->Integral(); h_tfp->Scale(scale);
	//Ph_fp
	TH1F *h_pfp = new TH1F("h_pfp","", 100, -0.05,0.05);
	h_pfp->SetXTitle("#phi_{fp}");
	h_pfp->SetLineColor(2); 
	h_pfp->SetLineWidth(1.1);
	h_pfp->GetXaxis()->SetTitleSize(0.08);
	h_pfp->GetXaxis()->SetTitleOffset(0.7);
	h_pfp->GetXaxis()->CenterTitle(1);
	T->Project("h_pfp","L.tr.r_ph",Cut_All);
	scale = norm/h_pfp->Integral(); h_pfp->Scale(scale);
	/*}}}*/

	/*Target Plane{{{*/
	//DeltaP
	TH1F *h_dtg = new TH1F("h_dtg","", 100, -0.07,0.07);
	h_dtg->SetXTitle("#delta P");
	h_dtg->SetLineColor(2); 
	h_dtg->SetLineWidth(1.1);
	h_dtg->GetXaxis()->SetTitleSize(0.08);
	h_dtg->GetXaxis()->SetTitleOffset(0.7);
	h_dtg->GetXaxis()->CenterTitle(1);
	T->Project("h_dtg","ExTgtL.dp",Cut_All);
	scale = norm/h_dtg->Integral(); h_dtg->Scale(scale);
	//Y_tg  
	TH1F *h_ytg = new TH1F("h_ytg","", 100, -0.07,0.07);
	h_ytg->SetXTitle("y_{tg}");
	h_ytg->SetLineColor(2); 
	h_ytg->SetLineWidth(1.1);
	h_ytg->GetXaxis()->SetTitleSize(0.08);
	h_ytg->GetXaxis()->SetTitleOffset(0.7);
	h_ytg->GetXaxis()->CenterTitle(1);
	T->Project("h_ytg","ExTgtL.y",Cut_All);
	scale = norm/h_ytg->Integral(); h_ytg->Scale(scale);
	//Z_react
	TH1F *h_ztg = new TH1F("h_ztg","", 100, -0.12,0.12);
	h_ztg->SetXTitle("z_{react}");
	h_ztg->SetLineColor(2); 
	h_ztg->SetLineWidth(1.1);
	h_ztg->GetXaxis()->SetTitleSize(0.08);
	h_ztg->GetXaxis()->SetTitleOffset(0.7);
	h_ztg->GetXaxis()->CenterTitle(1);
	T->Project("h_ztg","RctPtL.z",Cut_All);
	scale = norm/h_ztg->Integral(); h_ztg->Scale(scale);
	//Th_tg  
	TH1F *h_ttg = new TH1F("h_ttg","", 100, -0.05,0.05);
//.........这里部分代码省略.........
开发者ID:TJHague,项目名称:XGT2,代码行数:101,代码来源:Cryo_Cut.C


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