// Funktion für den differentiellen Wirkungsquerschnitt (ausgerechnet bis auf nicht analytisch bestimmbare Parton-Parton-Prozesse)
inline double diffCrossSection(double* x,size_t numDim,void* params) {
	// Theta(x1*x2*s-m_h^2)
	if (x[0]*x[1]*S_PP*S_PP<M_H*M_H)
		return 0.0;
	
	// LHAPDF aus Parameter abfragen
	LHAPDF::PDF* pdf = (LHAPDF::PDF*)params;
	
	// Ergebnisvariable initialisieren
	double result = 0.0;
	
	// Alle möglichen Parton-Parton-Reaktionen durchgehen und zum Ergebnis summieren
	for (int i=1;i<7;i++) {
		result += pdf->xfxQ(i,x[0],M_H)/x[0]*pdf->xfxQ(-i,x[1],M_H)/x[1] 										/* f_q(x1)*f_qbar(x2) */
				  * COS2_THETA_W/144./M_PI													/* cos^2(theta_W)/(144 PI) */
				  * (x[0]*x[1]*S_PP*S_PP-M_H*M_H)*(x[0]*x[1]*S_PP*S_PP-M_H*M_H)*(x[0]*x[1]*S_PP*S_PP-M_H*M_H) 	/* (x1*x2*s-m_h^2)^3 */
				  / (x[0]*x[1]*S_PP*S_PP)/(x[0]*x[1]*S_PP*S_PP); 												/* (x1*x2*s)^2 */
				  
		result += pdf->xfxQ(-i,x[0],M_H)/x[0]*pdf->xfxQ(i,x[1],M_H)/x[1] 										/* f_qbar(x1)*f_q(x2) */
				  * COS2_THETA_W/144./M_PI													/* cos^2(theta_W)/(144 PI) */
				  * (x[0]*x[1]*S_PP*S_PP-M_H*M_H)*(x[0]*x[1]*S_PP*S_PP-M_H*M_H)*(x[0]*x[1]*S_PP*S_PP-M_H*M_H) 	/* (x1*x2*s-m_h^2)^3 */
				  / (x[0]*x[1]*S_PP*S_PP)/(x[0]*x[1]*S_PP*S_PP); 												/* (x1*x2*s)^2 */
	}
	
	// Ergebnis zurückgeben
	return result;
}
Exemplo n.º 2
0
void PDFHub::initialize_lha_pdf()
{
    vector<string> gridnames = determine_grids();
    LHAPDF::setVerbosity(LHAPDF::SILENT);
    
    for(unsigned grid=0; grid<gridnames.size(); ++grid)
        {
        //cout<<"\n[PDFHub] : initializing "<<gridnames[grid]<<endl;
        // initialise the LHAPDF set corresponding to grids[grid]
        int grid_number_for_lhapdf = grid+1;
        //LHAPDF::initPDFSet(grid_number_for_lhapdf,
        //                   gridnames[grid], LHAPDF::LHGRID);
        //lhapdf6 interface
        LHAPDF::PDF* pdf = LHAPDF::mkPDF(gridnames[grid], 0);
            
            
        //cout<<"\n[PDFHub] : pdf_error is "<<pdf_error_<<endl;
        // Using the LHAPDF-routine numberPDF, we can determine the number of members of the currently loaded set
        unsigned membernum;
        if (pdf_error_) membernum = LHAPDF::numberPDF()+1;
        else membernum = 1;
        
        // thank you, GJR, for this additional line of code
        if((provider_ == "GJR") && (pert_order_ == 0)) membernum=1;
        
        
        // loop over members:
        for (int member=0; member<membernum; member++)
            {
            // thank you, GJR, for this additional 2 lines of code
            if((provider_ == "GJR") && (pert_order_ == 0)) ++member;
            
            // initialise the correct member set
            LHAPDF::usePDFMember(grid_number_for_lhapdf,member);
            
            // retrieve the alpha_s of this member !!! hardcoded m_z ok?
            //_alpha_s_at_mz.push_back(LHAPDF::alphasPDF(91.1876));
            //lhapdf6 interface
            _alpha_s_at_mz.push_back(pdf->alphaS().alphasQ(91.1876));

                
                
            grids_->add(gridnames[grid],grid_number_for_lhapdf,member);
            
            }
        }

}
Exemplo n.º 3
0
//void acceptGenW(TString input="wellnu_ct10_wp_v2.root",
void acceptGenW(TString input="/afs/cern.ch/work/j/jlawhorn/theo-unc-06-10/WmJetsToLNu.root",
		TString outputDir="idfk/",
		//TString pdfName="NNPDF30_nlo_nf_5_pdfas",
		//TString pdfName="CT14nlo",
		TString pdfName="MMHT2014nlo68cl",
		Int_t setMin=0, 
		Int_t setMax=0,
		Int_t proc=2) {

  TString procName[4]={"wme", "wpe", "wmm", "wpm"};
  char output[150];
  sprintf(output, "%s%s_%s.root", outputDir.Data(), procName[proc].Data(), pdfName.Data());
  cout << "proc: " << procName[proc] << endl;
  TChain chain("Events");
  chain.Add(input);
  
  //PDF info
  Double_t id_1,      id_2,       x_1,        x_2;
  Double_t xPDF_1,    xPDF_2,     scalePDF,   weight;
  //Generator level V+l info
  Double_t genV_id,   genL1_id,   genL2_id;
  Double_t genV_pt,   genV_eta,   genV_phi,   genV_m;
  Double_t genVf_pt,  genVf_eta,  genVf_phi,  genVf_m;
  Double_t genL1_pt,  genL1_eta,  genL1_phi,  genL1_m;
  Double_t genL2_pt,  genL2_eta,  genL2_phi,  genL2_m;
  Double_t genL1f_pt, genL1f_eta, genL1f_phi, genL1f_m;
  Double_t genL2f_pt, genL2f_eta, genL2f_phi, genL2f_m;

  chain.SetBranchAddress("id_1",       &id_1);
  chain.SetBranchAddress("id_2",       &id_2);
  chain.SetBranchAddress("x_1",        &x_1);
  chain.SetBranchAddress("x_2",        &x_2);
  chain.SetBranchAddress("xPDF_1",     &xPDF_1);
  chain.SetBranchAddress("xPDF_2",     &xPDF_2);
  chain.SetBranchAddress("scalePDF",   &scalePDF);
  chain.SetBranchAddress("weight",     &weight);
  chain.SetBranchAddress("genV_pt",    &genV_pt);
  chain.SetBranchAddress("genV_eta",   &genV_eta);
  chain.SetBranchAddress("genV_phi",   &genV_phi);
  chain.SetBranchAddress("genV_m",     &genV_m);
  chain.SetBranchAddress("genV_id",    &genV_id);
  chain.SetBranchAddress("genVf_pt",   &genVf_pt);
  chain.SetBranchAddress("genVf_eta",  &genVf_eta);
  chain.SetBranchAddress("genVf_phi",  &genVf_phi);
  chain.SetBranchAddress("genVf_m",    &genVf_m);
  chain.SetBranchAddress("genL1_pt",   &genL1_pt);
  chain.SetBranchAddress("genL1_eta",  &genL1_eta);
  chain.SetBranchAddress("genL1_phi",  &genL1_phi);
  chain.SetBranchAddress("genL1_m",    &genL1_m);
  chain.SetBranchAddress("genL1_id",   &genL1_id);
  chain.SetBranchAddress("genL2_pt",   &genL2_pt);
  chain.SetBranchAddress("genL2_eta",  &genL2_eta);
  chain.SetBranchAddress("genL2_phi",  &genL2_phi);
  chain.SetBranchAddress("genL2_m",    &genL2_m);
  chain.SetBranchAddress("genL2_id",   &genL2_id);
  chain.SetBranchAddress("genL1f_pt",  &genL1f_pt);
  chain.SetBranchAddress("genL1f_eta", &genL1f_eta);
  chain.SetBranchAddress("genL1f_phi", &genL1f_phi);
  chain.SetBranchAddress("genL1f_m",   &genL1f_m);
  chain.SetBranchAddress("genL2f_pt",  &genL2f_pt);
  chain.SetBranchAddress("genL2f_eta", &genL2f_eta);
  chain.SetBranchAddress("genL2f_phi", &genL2f_phi);
  chain.SetBranchAddress("genL2f_m",   &genL2f_m);

  TFile *outFile = new TFile(output, "recreate");
  LHAPDF::PDF* nomPdf = LHAPDF::mkPDF(292200);
  //LHAPDF::PDF* nomPdf = LHAPDF::mkPDF(25100);
  //LHAPDF::PDF* nomPdf = LHAPDF::mkPDF(13100);
  //LHAPDF::PDF* nomPdf = LHAPDF::mkPDF(11000);

  for (Int_t iPdfSet=setMin; iPdfSet<setMax+1; iPdfSet++) {
    
    LHAPDF::PDF* testPdf = LHAPDF::mkPDF(pdfName.Data(),iPdfSet);
    
    char histname[100];
    sprintf(histname,"dEta_%s_%i",pdfName.Data(),iPdfSet);
    TH1D* dEta = new TH1D(histname, "", 20, -5, 5); dEta->Sumw2();
    sprintf(histname,"dPt_%s_%i",pdfName.Data(),iPdfSet);
    TH1D* dPt = new TH1D(histname, "", 25, 25, 100); dPt->Sumw2();
    
    sprintf(histname,"dPreB_%s_%i",pdfName.Data(),iPdfSet);
    TH1D* dPreB = new TH1D(histname, "", 1, 0, 2); dPreB->Sumw2();
    sprintf(histname,"dPreE_%s_%i",pdfName.Data(),iPdfSet);
    TH1D* dPreE = new TH1D(histname, "", 1, 0, 2); dPreE->Sumw2();
    
    sprintf(histname,"dPostB_%s_%i",pdfName.Data(),iPdfSet);
    TH1D* dPostB = new TH1D(histname, "", 1, 0, 2); dPostB->Sumw2();
    sprintf(histname,"dPostE_%s_%i",pdfName.Data(),iPdfSet);
    TH1D* dPostE = new TH1D(histname, "", 1, 0, 2); dPostE->Sumw2();
    
    sprintf(histname,"dTot_%s_%i",pdfName.Data(),iPdfSet);
    TH1D* dTot = new TH1D(histname, "", 1, 0, 2); dTot->Sumw2();
    
    for (Int_t i=0; i<chain.GetEntries(); i++) {
      chain.GetEntry(i);
      //cout  << genV_id << ", " << genL1_id << ", " << genL2_id << ", " << genL1f_pt << ", " << genL1f_eta << endl;
      if (!isProc(proc, genV_id, genV_m, genL1_id, genL2_id)) continue;
      if ((proc==0||proc==2) && genL2f_pt==0 && genL2f_eta==0) continue;
      if ((proc==1||proc==3) && genL1f_pt==0 && genL1f_eta==0) continue;

      Int_t fid_1 = ( id_1==0 ? 21 : id_1 );
      Int_t fid_2 = ( id_2==0 ? 21 : id_2 );
      //cout << genV_id << ", " << genL1f_pt << ", " << genL2f_pt << endl;
      Double_t newWeight = weight*testPdf->xfxQ(fid_1, x_1, scalePDF)*testPdf->xfxQ(fid_2, x_2, scalePDF)/(nomPdf->xfxQ(fid_1, x_1, scalePDF)*nomPdf->xfxQ(fid_2, x_2, scalePDF));
      if (newWeight < 3e-10) continue;

      dTot->Fill(1.0,newWeight);
      
      Bool_t passBar =acceptBarrel(proc, genV_id, genV_m, genL1_id, genL2_id, genL1_pt, genL1_eta, genL2_pt, genL2_eta);
      Bool_t passBarF=acceptBarrel(proc, genV_id, genV_m, genL1_id, genL2_id, genL1f_pt, genL1f_eta, genL2f_pt, genL2f_eta);
      Bool_t passEnd =acceptEndcap(proc, genV_id, genV_m, genL1_id, genL2_id, genL1_pt, genL1_eta, genL2_pt, genL2_eta);
      Bool_t passEndF=acceptEndcap(proc, genV_id, genV_m, genL1_id, genL2_id, genL1f_pt, genL1f_eta, genL2f_pt, genL2f_eta);
      
      if      (passBar) dPreB->Fill(1.0, newWeight);
      else if (passEnd) dPreE->Fill(1.0, newWeight);
      
      if      (passBarF) dPostB->Fill(1.0, newWeight);
      else if (passEndF) dPostE->Fill(1.0, newWeight);
      
      if (passBarF || passEndF) {
	if (proc==wme || proc==wmm) {
	  dEta->Fill(genL2f_eta, newWeight);  
	  dPt->Fill(genL2f_pt, newWeight);  
	}
	else {
	  dEta->Fill(genL1f_eta, newWeight);  
	  dPt->Fill(genL1f_pt, newWeight);        
	}
      }
    }

    Double_t acc=(dPreB->Integral()+dPreE->Integral())/(dTot->Integral());
    //cout << dPreB->Integral()/dTot->Integral() << endl;
    //cout << dPreE->Integral()/dTot->Integral() << endl;
    cout << "Pre-FSR acceptance: " << acc << " +/- " << sqrt(acc*(1-acc)/dTot->GetEntries()) << endl;
    acc=(dPostB->Integral()+dPostE->Integral())/(dTot->Integral());
    //cout << dPostB->Integral()/dTot->Integral() << endl;
    //cout << dPostE->Integral()/dTot->Integral() << endl;
    cout << "Post-FSR acceptance: " << acc << " +/- " << sqrt(acc*(1-acc)/dTot->GetEntries()) << endl;

    outFile->Write();

  }

  outFile->Close();
}
Exemplo n.º 4
0
void acceptGenZ(TString input="/afs/cern.ch/work/j/jlawhorn/theo-unc-06-10/DYJetsToLL.root",
//void acceptGenZ(TString input="dyellell_ct10_v2.root",
		TString outputDir="idfk/",
		//TString pdfName="NNPDF30_nlo_nf_5_pdfas",
		//TString pdfName="CT14nlo",
		TString pdfName="MMHT2014nlo68cl",
		Int_t setMin=0,
		Int_t setMax=0,
		Int_t proc=0) {
  
  TString procName[2]={"zee", "zmm"};
  char output[150];
  sprintf(output, "%s%s_%s.root", outputDir.Data(), procName[proc].Data(), pdfName.Data());
  cout << output << endl;
  TChain chain("Events");
  chain.Add(input);
  
  //PDF info
  Double_t id_1,      id_2,       x_1,        x_2;
  Double_t xPDF_1,    xPDF_2,     scalePDF,   weight;
  //Generator level V+l info
  Double_t genV_id,   genL1_id,   genL2_id;
  Double_t genV_pt,   genV_eta,   genV_phi,   genV_m;
  Double_t genVf_pt,  genVf_eta,  genVf_phi,  genVf_m;
  Double_t genL1_pt,  genL1_eta,  genL1_phi,  genL1_m;
  Double_t genL2_pt,  genL2_eta,  genL2_phi,  genL2_m;
  Double_t genL1f_pt, genL1f_eta, genL1f_phi, genL1f_m;
  Double_t genL2f_pt, genL2f_eta, genL2f_phi, genL2f_m;

  chain.SetBranchAddress("id_1",       &id_1);
  chain.SetBranchAddress("id_2",       &id_2);
  chain.SetBranchAddress("x_1",        &x_1);
  chain.SetBranchAddress("x_2",        &x_2);
  chain.SetBranchAddress("xPDF_1",     &xPDF_1);
  chain.SetBranchAddress("xPDF_2",     &xPDF_2);
  chain.SetBranchAddress("scalePDF",   &scalePDF);
  chain.SetBranchAddress("weight",     &weight);
  chain.SetBranchAddress("genV_pt",    &genV_pt);
  chain.SetBranchAddress("genV_eta",   &genV_eta);
  chain.SetBranchAddress("genV_phi",   &genV_phi);
  chain.SetBranchAddress("genV_m",     &genV_m);
  chain.SetBranchAddress("genV_id",    &genV_id);
  chain.SetBranchAddress("genVf_pt",   &genVf_pt);
  chain.SetBranchAddress("genVf_eta",  &genVf_eta);
  chain.SetBranchAddress("genVf_phi",  &genVf_phi);
  chain.SetBranchAddress("genVf_m",    &genVf_m);
  chain.SetBranchAddress("genL1_pt",   &genL1_pt);
  chain.SetBranchAddress("genL1_eta",  &genL1_eta);
  chain.SetBranchAddress("genL1_phi",  &genL1_phi);
  chain.SetBranchAddress("genL1_m",    &genL1_m);
  chain.SetBranchAddress("genL1_id",   &genL1_id);
  chain.SetBranchAddress("genL2_pt",   &genL2_pt);
  chain.SetBranchAddress("genL2_eta",  &genL2_eta);
  chain.SetBranchAddress("genL2_phi",  &genL2_phi);
  chain.SetBranchAddress("genL2_m",    &genL2_m);
  chain.SetBranchAddress("genL2_id",   &genL2_id);
  chain.SetBranchAddress("genL1f_pt",  &genL1f_pt);
  chain.SetBranchAddress("genL1f_eta", &genL1f_eta);
  chain.SetBranchAddress("genL1f_phi", &genL1f_phi);
  chain.SetBranchAddress("genL1f_m",   &genL1f_m);
  chain.SetBranchAddress("genL2f_pt",  &genL2f_pt);
  chain.SetBranchAddress("genL2f_eta", &genL2f_eta);
  chain.SetBranchAddress("genL2f_phi", &genL2f_phi);
  chain.SetBranchAddress("genL2f_m",   &genL2f_m);

  TFile *outFile = new TFile(output, "recreate");
  LHAPDF::PDF* nomPdf = LHAPDF::mkPDF(292200);
  //LHAPDF::PDF* nomPdf = LHAPDF::mkPDF(25100);
  //LHAPDF::PDF* nomPdf = LHAPDF::mkPDF(11000);
  //LHAPDF::PDF* nomPdf = LHAPDF::mkPDF(13100);

  for (Int_t iPdfSet=setMin; iPdfSet<setMax+1; iPdfSet++) {
    
    LHAPDF::PDF* testPdf = LHAPDF::mkPDF(pdfName.Data(),iPdfSet);
    
    char histname[100];
    sprintf(histname,"dEta_%s_%i",pdfName.Data(),iPdfSet);
    TH1D* dEta = new TH1D(histname, "", 20, -5, 5); dEta->Sumw2();
    sprintf(histname,"dPt_%s_%i",pdfName.Data(),iPdfSet);
    TH1D* dPt = new TH1D(histname, "", 25, 25, 100); dPt->Sumw2();

    sprintf(histname,"dPreBB_%s_%i",pdfName.Data(),iPdfSet);
    TH1D* dPreBB = new TH1D(histname, "", 1, 0, 2); dPreBB->Sumw2();
    sprintf(histname,"dPreBE_%s_%i",pdfName.Data(),iPdfSet);
    TH1D* dPreBE = new TH1D(histname, "", 1, 0, 2); dPreBE->Sumw2();
    sprintf(histname,"dPreEE_%s_%i",pdfName.Data(),iPdfSet);
    TH1D* dPreEE = new TH1D(histname, "", 1, 0, 2); dPreEE->Sumw2();

    sprintf(histname,"dPostBB_%s_%i",pdfName.Data(),iPdfSet);
    TH1D* dPostBB = new TH1D(histname, "", 1, 0, 2); dPostBB->Sumw2();
    sprintf(histname,"dPostBE_%s_%i",pdfName.Data(),iPdfSet);
    TH1D* dPostBE = new TH1D(histname, "", 1, 0, 2); dPostBE->Sumw2();
    sprintf(histname,"dPostEE_%s_%i",pdfName.Data(),iPdfSet);
    TH1D* dPostEE = new TH1D(histname, "", 1, 0, 2); dPostEE->Sumw2();
    
    sprintf(histname,"dTot_%s_%i",pdfName.Data(),iPdfSet);
    TH1D* dTot = new TH1D(histname, "", 1, 0, 2); dTot->Sumw2();

    Double_t nentries=0, nsel=0;

    for (Int_t i=0; i<chain.GetEntries(); i++) {
    //for (Int_t i=0; i<100; i++) {
      chain.GetEntry(i);

      if (!isProc(proc, genV_id, genV_m, genL1_id, genL2_id)) continue;

      Int_t fid_1 = id_1;//( id_1==0 ? 21 : id_1 );
      Int_t fid_2 = id_2;//( id_2==0 ? 21 : id_2 );
      Double_t newWeight = weight*testPdf->xfxQ(fid_1, x_1, scalePDF)*testPdf->xfxQ(fid_2, x_2, scalePDF)/(nomPdf->xfxQ(fid_1, x_1, scalePDF)*nomPdf->xfxQ(fid_2, x_2, scalePDF));
      if (fabs(nomPdf->xfxQ(fid_1, x_1, scalePDF)) < 1e-8 || fabs(nomPdf->xfxQ(fid_2, x_2, scalePDF)) < 1e-8 ) { 
	cout << "wtf: " << fid_1 << ", " << x_1 << ", " << scalePDF << " => " << nomPdf->xfxQ(fid_1, x_1, scalePDF) << "; ";
	cout << fid_2 << ", " << x_2 << ", " << scalePDF << " => " << nomPdf->xfxQ(fid_2, x_2, scalePDF) << "; ";
	cout << weight << ", " << newWeight << endl;
	continue;
      }

      nentries+=newWeight;

      dTot->Fill(1.0,newWeight);

      Bool_t passBB =acceptBB(proc, genV_id, genV_m, genL1_id, genL2_id, genL1_pt, genL1_eta, genL2_pt, genL2_eta);
      Bool_t passBBF=acceptBB(proc, genV_id, genVf_m, genL1_id, genL2_id, genL1f_pt, genL1f_eta, genL2f_pt, genL2f_eta);

      Bool_t passBE =acceptBE(proc, genV_id, genV_m, genL1_id, genL2_id, genL1_pt, genL1_eta, genL2_pt, genL2_eta);
      Bool_t passBEF=acceptBE(proc, genV_id, genVf_m, genL1_id, genL2_id, genL1f_pt, genL1f_eta, genL2f_pt, genL2f_eta);

      Bool_t passEE =acceptEE(proc, genV_id, genV_m, genL1_id, genL2_id, genL1_pt, genL1_eta, genL2_pt, genL2_eta);
      Bool_t passEEF=acceptEE(proc, genV_id, genVf_m, genL1_id, genL2_id, genL1f_pt, genL1f_eta, genL2f_pt, genL2f_eta);

      if      (passBB) dPreBB->Fill(1.0, newWeight);
      else if (passBE) dPreBE->Fill(1.0, newWeight);
      else if (passEE) dPreEE->Fill(1.0, newWeight);
      
      if      (passBBF) { dPostBB->Fill(1.0, newWeight); }
      else if (passBEF) { dPostBE->Fill(1.0, newWeight); }
      else if (passEEF) { dPostEE->Fill(1.0, newWeight); }
      
      if (passBBF || passBEF || passEEF) {
	//if (passBB || passBE || passEE) {
	dEta->Fill(genVf_eta, newWeight);
	dPt->Fill(genVf_pt, newWeight);        
	nsel+=newWeight;
      }
    }
    cout << "------------" << endl;
    Double_t acc=(dPreBB->Integral()+dPreBE->Integral()+dPreEE->Integral())/(dTot->Integral());

    cout << "Pre-FSR acceptance: " << dPreBB->Integral() + dPreBE->Integral() + dPreEE->Integral() << " / " << dTot->Integral() << " = " << acc << " +/- " << sqrt(acc*(1-acc)/dTot->GetEntries()) << endl;
 
    acc=(dPostBB->Integral()+dPostBE->Integral()+dPostEE->Integral())/(dTot->Integral());

    cout << "Post-FSR acceptance: " << dPostBB->Integral()+dPostBE->Integral()+dPostEE->Integral() << " / " << dTot->Integral() << " = " << acc << " +/- " << sqrt(acc*(1-acc)/dTot->GetEntries()) << endl;

    outFile->Write();
    
  }
  outFile->Close();
}