Exemplo n.º 1
0
void AnalysisWithChain()
{

  TCanvas* c1 = new TCanvas("c1","");

  TChain* chain = GetChainFromRunList("runs_groups12.txt");
  chain->SetAlias("Valid_HODO_HORIZONTAL","Sum$(abs(TOWER_CALIB_HODO_HORIZONTAL.energy)>30) > 0");
  chain->SetAlias("Valid_HODO_VERTICAL","Sum$(abs(TOWER_CALIB_HODO_VERTICAL.energy)>30) > 0");

  chain->Draw("TOWER_CALIB_TILE_MAPPER[4].energy>>h1(100,0,400)","Valid_HODO_VERTICAL && Valid_HODO_HORIZONTAL","");

  c1->Print("groups12.png");

}
Exemplo n.º 2
0
void plotdjr(const TString & infile, const TString & outfile) {
 
  gSystem->Load("libFWCoreFWLite.so");  
  AutoLibraryLoader::enable();  
  TH1::SetDefaultSumw2();
  
  TChain *tree = new TChain("Events");
  tree->Add(infile);
  
  tree->SetAlias("GenEvent","GenEventInfoProduct_generator__GEN.obj");
  tree->SetAlias("LHEEvent","LHEEventProduct_externalLHEProducer__LHE.obj");
 
  TCut weight = "GenEvent.weight()";
  int nbins = 50.;
  double djrmin = -0.5;
  double djrmax = 3.;
  //typeMC sets the kind of sample we are looking at: 
  //0 is for NLO with FXFX merging; 
  //1 is for LO with MLM; 
  //2 is for LO with MLM (plotting partons after excluding non-matched partons in wbb/vbf type processes)
  int typeMC = 2;
  
  TCanvas *c1 = new TCanvas("c1", "c1", 800, 600);
  TPad *pad[5];
  setcanvas(c1,pad);

  pad[0]->cd();
  makeplot("djr0",tree,weight,"log10(GenEvent.DJRValues_[0])","DJR 0->1",nbins,djrmin,djrmax,typeMC);
  pad[1]->cd();
  makeplot("djr1",tree,weight,"log10(GenEvent.DJRValues_[1])","DJR 1->2",nbins,djrmin,djrmax,typeMC);
  pad[2]->cd();
  makeplot("djr2",tree,weight,"log10(GenEvent.DJRValues_[2])","DJR 2->3",nbins,djrmin,djrmax,typeMC);
  pad[3]->cd();
  makeplot("djr3",tree,weight,"log10(GenEvent.DJRValues_[3])","DJR 3->4",nbins,djrmin,djrmax,typeMC);
  pad[4]->cd();
  makeplot("djr4",tree,weight,"log10(GenEvent.DJRValues_[4])","DJR 4->5",nbins,djrmin,djrmax,typeMC);


  c1->Print(outfile);
  return;  
}
Exemplo n.º 3
0
void plotdjr(TString filename, const char* outputbase) {
 
  TH1::SetDefaultSumw2();
  
  TChain *tree = new TChain("Events");
  tree->Add(filename);
  
  tree->SetAlias("LHEEvent","LHEEventProduct_source__GEN.obj");
  tree->SetAlias("GenEvent","GenEventInfoProduct_generator__GEN.obj");
  tree->SetAlias("GenParticles","recoGenParticles_genParticles__GEN.obj");
  tree->SetAlias("genJets","recoGenJets_ak4GenJets__GEN.obj");  
  
  tree->SetAlias("dr0","sqrt( (genJetsCleaned[0].eta()-promptPhotons[0].eta())^2 + atan2(sin(genJetsCleaned[0].phi()-promptPhotons[0].phi()),cos(genJetsCleaned[0].phi()-promptPhotons[0].phi()))^2 )");
  tree->SetAlias("dr1","sqrt( (genJetsCleaned[1].eta()-promptPhotons[0].eta())^2 + atan2(sin(genJetsCleaned[1].phi()-promptPhotons[0].phi()),cos(genJetsCleaned[1].phi()-promptPhotons[0].phi()))^2 )");
  tree->SetAlias("dr2","sqrt( (genJetsCleaned[2].eta()-promptPhotons[0].eta())^2 + atan2(sin(genJetsCleaned[2].phi()-promptPhotons[0].phi()),cos(genJetsCleaned[2].phi()-promptPhotons[0].phi()))^2 )");
  tree->SetAlias("dr3","sqrt( (genJetsCleaned[3].eta()-promptPhotons[0].eta())^2 + atan2(sin(genJetsCleaned[3].phi()-promptPhotons[0].phi()),cos(genJetsCleaned[3].phi()-promptPhotons[0].phi()))^2 )");
  
  TCut weight = "GenEvent.weight()";
  int nbins = 50.;
  double djrmin = -0.5;
  double djrmax = 4.;
  
  
  makeplot(TString::Format("%s_%s",outputbase,"djr0"),tree,weight,"log10(GenEvent.DJRValues_[0])","DJR 0->1",nbins,djrmin,djrmax);
  makeplot(TString::Format("%s_%s",outputbase,"djr1"),tree,weight,"log10(GenEvent.DJRValues_[1])","DJR 1->2",nbins,djrmin,djrmax);
  makeplot(TString::Format("%s_%s",outputbase,"djr2"),tree,weight,"log10(GenEvent.DJRValues_[2])","DJR 2->3",nbins,djrmin,djrmax);
  makeplot(TString::Format("%s_%s",outputbase,"djr3"),tree,weight,"log10(GenEvent.DJRValues_[3])","DJR 3->4",nbins,djrmin,djrmax);
  return;  
}
Exemplo n.º 4
0
void anaFragShapePtBinsDR(TString infile1="/net/hisrv0001/home/frankma/scratch01/ana/merge/dj_HCPR-J50U-JSON_hiGoodMergedTrksRuns152562to152643-v1_StdAna1204v2.root",
		  TString infile2="/net/hisrv0001/home/frankma/scratch01/ana/merge/dj_HCPR-GoodTrk1123_All0.root"
)
{
  gStyle->SetMarkerStyle(20);

  TChain * djcalo = new TChain("djcalo/djTree");
  djcalo->Add(infile1);
  djcalo->Add(infile2);
  aliases_dijet(djcalo);
  TString evtSel("(cent<10 && nljet>120 && abs(nljeta)<2 && aljet>50 && abs(aljeta)<2 && jdphi>2.5 && Aj>0.24)");
  TH1::SetDefaultSumw2();

  //cones reflected in eta. avoid jets *right* at mid-rapidity to avoid overlap
  djcalo->SetAlias("pndrrefl","(sqrt(pndphi*pndphi+(peta+nljeta)*(peta+nljeta)))");
  djcalo->SetAlias("padrrefl","(sqrt(padphi*padphi+(peta+aljeta)*(peta+aljeta)))");
  
  TString evtSelNS = evtSel + " && (abs(nljeta)>0.5)";
  TString evtSelAS = evtSel + " && (abs(aljeta)>0.5)";

  //jet energy imbalance
  TCanvas * c0 = new TCanvas("c0","c0",500,500);
  djcalo->Draw("Aj>>hAj(20,0,1)",evtSel);

  //back-to-back correlation
  TCanvas * c2 = new TCanvas("c2","c2",500,500);
  TH1D * hJDPhi = new TH1D("hJDPhi","hJDPhi",50,0,3.1416);
  TH1D * hJDPhi2 = new TH1D("hJDPhi2","hJDPhi",50,0,3.1416);
  Float_t numDJNS = djcalo->Draw("jdphi>>hJDPhi",evtSelNS);
  Float_t numDJAS = djcalo->Draw("jdphi>>hJDPhi",evtSelAS,"same");
  cout << "num djs: " << numDJNS << " (near-side) \t" << numDJAS << " (away-side)" << endl;

  //track energy density by dR in pt bins
  TString histtitle = ";R(trk,jet);1/N_{DJ} dp_{T}^{Trk}/dR";
  TH1D * hPNDRTrk0 = new TH1D("hPNDRTrk0",histtitle.Data(),10,0,TMath::PiOver2());
  TH1D * hPADRTrk0 = new TH1D("hPADRTrk0",histtitle.Data(),10,0,TMath::PiOver2());
  djcalo->Draw("pndr>>hPNDRTrk0",Form("(%s&&ppt<1.0)*ppt",evtSelNS.Data()),"goff");
  djcalo->Draw("padr>>hPADRTrk0",Form("(%s&&ppt<1.0)*ppt",evtSelAS.Data()),"goff");
  TH1D * hPNDRReflTrk0 = new TH1D("hPNDRReflTrk0",histtitle.Data(),10,0,TMath::PiOver2());
  TH1D * hPADRReflTrk0 = new TH1D("hPADRReflTrk0",histtitle.Data(),10,0,TMath::PiOver2());
  djcalo->Draw("pndrrefl>>hPNDRReflTrk0",Form("(%s&&ppt<1.0)*ppt",evtSelNS.Data()),"goff");
  djcalo->Draw("padrrefl>>hPADRReflTrk0",Form("(%s&&ppt<1.0)*ppt",evtSelAS.Data()),"goff");

  TH1D * hPNDRTrk1 = new TH1D("hPNDRTrk1",histtitle.Data(),10,0,TMath::PiOver2());
  TH1D * hPADRTrk1 = new TH1D("hPADRTrk1",histtitle.Data(),10,0,TMath::PiOver2());
  djcalo->Draw("pndr>>hPNDRTrk1",Form("(%s&&ppt<2.0&&ppt>=1.0)*ppt",evtSelNS.Data()),"goff");
  djcalo->Draw("padr>>hPADRTrk1",Form("(%s&&ppt<2.0&&ppt>=1.0)*ppt",evtSelAS.Data()),"goff");
  TH1D * hPNDRReflTrk1 = new TH1D("hPNDRReflTrk1",histtitle.Data(),10,0,TMath::PiOver2());
  TH1D * hPADRReflTrk1 = new TH1D("hPADRReflTrk1",histtitle.Data(),10,0,TMath::PiOver2());
  djcalo->Draw("pndrrefl>>hPNDRReflTrk1",Form("(%s&&ppt<2.0&&ppt>=1.0)*ppt",evtSelNS.Data()),"goff");
  djcalo->Draw("padrrefl>>hPADRReflTrk1",Form("(%s&&ppt<2.0&&ppt>=1.0)*ppt",evtSelAS.Data()),"goff");

  TH1D * hPNDRTrk2 = new TH1D("hPNDRTrk2",histtitle.Data(),10,0,TMath::PiOver2());
  TH1D * hPADRTrk2 = new TH1D("hPADRTrk2",histtitle.Data(),10,0,TMath::PiOver2());
  djcalo->Draw("pndr>>hPNDRTrk2",Form("(%s&&ppt<4.0&&ppt>=2.0)*ppt",evtSelNS.Data()),"goff");
  djcalo->Draw("padr>>hPADRTrk2",Form("(%s&&ppt<4.0&&ppt>=2.0)*ppt",evtSelAS.Data()),"goff");
  TH1D * hPNDRReflTrk2 = new TH1D("hPNDRReflTrk2",histtitle.Data(),10,0,TMath::PiOver2());
  TH1D * hPADRReflTrk2 = new TH1D("hPADRReflTrk2",histtitle.Data(),10,0,TMath::PiOver2());
  djcalo->Draw("pndrrefl>>hPNDRReflTrk2",Form("(%s&&ppt<4.0&&ppt>=2.0)*ppt",evtSelNS.Data()),"goff");
  djcalo->Draw("padrrefl>>hPADRReflTrk2",Form("(%s&&ppt<4.0&&ppt>=2.0)*ppt",evtSelAS.Data()),"goff");

  TH1D * hPNDRTrk4 = new TH1D("hPNDRTrk4",histtitle.Data(),10,0,TMath::PiOver2());
  TH1D * hPADRTrk4 = new TH1D("hPADRTrk4",histtitle.Data(),10,0,TMath::PiOver2());
  djcalo->Draw("pndr>>hPNDRTrk4",Form("(%s&&ppt<8.0&&ppt>=4.0)*ppt",evtSelNS.Data()),"goff");
  djcalo->Draw("padr>>hPADRTrk4",Form("(%s&&ppt<8.0&&ppt>=4.0)*ppt",evtSelAS.Data()),"goff");
  TH1D * hPNDRReflTrk4 = new TH1D("hPNDRReflTrk4",histtitle.Data(),10,0,TMath::PiOver2());
  TH1D * hPADRReflTrk4 = new TH1D("hPADRReflTrk4",histtitle.Data(),10,0,TMath::PiOver2());
  djcalo->Draw("pndrrefl>>hPNDRReflTrk4",Form("(%s&&ppt<8.0&&ppt>=4.0)*ppt",evtSelNS.Data()),"goff");
  djcalo->Draw("padrrefl>>hPADRReflTrk4",Form("(%s&&ppt<8.0&&ppt>=4.0)*ppt",evtSelAS.Data()),"goff");

  TH1D * hPNDRTrk8 = new TH1D("hPNDRTrk8",histtitle.Data(),10,0,TMath::PiOver2());
  TH1D * hPADRTrk8 = new TH1D("hPADRTrk8",histtitle.Data(),10,0,TMath::PiOver2());
  djcalo->Draw("pndr>>hPNDRTrk8",Form("(%s&&ppt>=8.0)*ppt",evtSelNS.Data()),"goff");
  djcalo->Draw("padr>>hPADRTrk8",Form("(%s&&ppt>=8.0)*ppt",evtSelAS.Data()),"goff");
  TH1D * hPNDRReflTrk8 = new TH1D("hPNDRReflTrk8",histtitle.Data(),10,0,TMath::PiOver2());
  TH1D * hPADRReflTrk8 = new TH1D("hPADRReflTrk8",histtitle.Data(),10,0,TMath::PiOver2());
  djcalo->Draw("pndrrefl>>hPNDRReflTrk8",Form("(%s&&ppt>=8.0)*ppt",evtSelNS.Data()),"goff");
  djcalo->Draw("padrrefl>>hPADRReflTrk8",Form("(%s&&ppt>=8.0)*ppt",evtSelAS.Data()),"goff");

  hPNDRTrk0->Scale(1./(numDJNS*hPNDRTrk0->GetBinWidth(1)));
  hPADRTrk0->Scale(1./(numDJAS*hPADRTrk0->GetBinWidth(1)));
  hPNDRReflTrk0->Scale(1./(numDJNS*hPNDRReflTrk0->GetBinWidth(1)));
  hPADRReflTrk0->Scale(1./(numDJAS*hPADRReflTrk0->GetBinWidth(1)));

  hPNDRTrk1->Scale(1./(numDJNS*hPNDRTrk1->GetBinWidth(1)));
  hPADRTrk1->Scale(1./(numDJAS*hPADRTrk1->GetBinWidth(1)));
  hPNDRReflTrk1->Scale(1./(numDJNS*hPNDRReflTrk1->GetBinWidth(1)));
  hPADRReflTrk1->Scale(1./(numDJAS*hPADRReflTrk1->GetBinWidth(1)));

  hPNDRTrk2->Scale(1./(numDJNS*hPNDRTrk2->GetBinWidth(1)));
  hPADRTrk2->Scale(1./(numDJAS*hPADRTrk2->GetBinWidth(1)));
  hPNDRReflTrk2->Scale(1./(numDJNS*hPNDRReflTrk2->GetBinWidth(1)));
  hPADRReflTrk2->Scale(1./(numDJAS*hPADRReflTrk2->GetBinWidth(1)));

  hPNDRTrk4->Scale(1./(numDJNS*hPNDRTrk4->GetBinWidth(1)));
  hPADRTrk4->Scale(1./(numDJAS*hPADRTrk4->GetBinWidth(1)));
  hPNDRReflTrk4->Scale(1./(numDJNS*hPNDRReflTrk4->GetBinWidth(1)));
  hPADRReflTrk4->Scale(1./(numDJAS*hPADRReflTrk4->GetBinWidth(1)));

  hPNDRTrk8->Scale(1./(numDJNS*hPNDRTrk8->GetBinWidth(1)));
  hPADRTrk8->Scale(1./(numDJAS*hPADRTrk8->GetBinWidth(1)));
  hPNDRReflTrk8->Scale(1./(numDJNS*hPNDRReflTrk8->GetBinWidth(1)));
  hPADRReflTrk8->Scale(1./(numDJAS*hPADRReflTrk8->GetBinWidth(1)));

  hPNDRTrk0->SetMinimum(0.1);
  hPNDRTrk0->SetMaximum(1.3*hPNDRTrk0->GetBinContent(1));
  hPNDRTrk0->SetMarkerStyle(kFullSquare);
  hPNDRTrk0->SetMarkerColor(kRed);
  hPADRTrk0->SetMarkerStyle(kOpenSquare);
  hPADRTrk0->SetMarkerColor(kBlue);
  hPNDRReflTrk0->SetLineColor(kRed);
  hPADRReflTrk0->SetLineColor(kBlue);

  hPNDRTrk1->SetMinimum(0.1);
  hPNDRTrk1->SetMaximum(1.3*hPNDRTrk1->GetBinContent(1));
  hPNDRTrk1->SetMarkerStyle(kFullSquare);
  hPNDRTrk1->SetMarkerColor(kRed);
  hPADRTrk1->SetMarkerStyle(kOpenSquare);
  hPADRTrk1->SetMarkerColor(kBlue);
  hPNDRReflTrk1->SetLineColor(kRed);
  hPADRReflTrk1->SetLineColor(kBlue);

  hPNDRTrk2->SetMinimum(0.1);
  hPNDRTrk2->SetMaximum(1.3*hPNDRTrk2->GetBinContent(1));
  hPNDRTrk2->SetMarkerStyle(kFullSquare);
  hPNDRTrk2->SetMarkerColor(kRed);
  hPADRTrk2->SetMarkerStyle(kOpenSquare);
  hPADRTrk2->SetMarkerColor(kBlue);
  hPNDRReflTrk2->SetLineColor(kRed);
  hPADRReflTrk2->SetLineColor(kBlue);

  hPNDRTrk4->SetMinimum(0.1);
  hPNDRTrk4->SetMaximum(1.3*hPNDRTrk4->GetBinContent(1));
  hPNDRTrk4->SetMarkerStyle(kFullSquare);
  hPNDRTrk4->SetMarkerColor(kRed);
  hPADRTrk4->SetMarkerStyle(kOpenSquare);
  hPADRTrk4->SetMarkerColor(kBlue);
  hPNDRReflTrk4->SetLineColor(kRed);
  hPADRReflTrk4->SetLineColor(kBlue);

  hPNDRTrk8->SetMinimum(0.1);
  hPNDRTrk8->SetMaximum(1.3*hPNDRTrk8->GetBinContent(1));
  hPNDRTrk8->SetMarkerStyle(kFullSquare);
  hPNDRTrk8->SetMarkerColor(kRed);
  hPADRTrk8->SetMarkerStyle(kOpenSquare);
  hPADRTrk8->SetMarkerColor(kBlue);
  hPNDRReflTrk8->SetLineColor(kRed);
  hPADRReflTrk8->SetLineColor(kBlue);

  TCanvas * c3 = new TCanvas("c3","c3",800,500);
  c3->Divide(3,2);
  c3->cd(1);
  hPNDRTrk0->Draw("E");
  hPADRTrk0->Draw("Esame");
  hPNDRReflTrk0->Draw("histsame");
  hPADRReflTrk0->Draw("histsame");
  c3->cd(2);
  hPNDRTrk1->Draw("E");
  hPADRTrk1->Draw("Esame");
  hPNDRReflTrk1->Draw("histsame");
  hPADRReflTrk1->Draw("histsame");
  c3->cd(3);
  hPNDRTrk2->Draw("E");
  hPADRTrk2->Draw("Esame");
  hPNDRReflTrk2->Draw("histsame");
  hPADRReflTrk2->Draw("histsame");
  c3->cd(4);
  hPNDRTrk4->Draw("E");
  hPADRTrk4->Draw("Esame");
  hPNDRReflTrk4->Draw("histsame");
  hPADRReflTrk4->Draw("histsame");
  c3->cd(5);
  hPNDRTrk8->Draw("E");
  hPADRTrk8->Draw("Esame");
  hPNDRReflTrk8->Draw("histsame");
  hPADRReflTrk8->Draw("histsame");

  TCanvas * c4 = new TCanvas("c4","c4",600,500);
  c4->Divide(3,2);
  c4->cd(1);
  TH1D* hPNDRSigTrk0 = (TH1D*) hPNDRTrk0->Clone("hPNDRSigTrk0");
  hPNDRSigTrk0->Add(hPNDRReflTrk0,-1);
  hPNDRSigTrk0->Draw("E");
  TH1D* hPADRSigTrk0 = (TH1D*) hPADRTrk0->Clone("hPADRSigTrk0");
  hPADRSigTrk0->Add(hPADRReflTrk0,-1);
  hPADRSigTrk0->Draw("Esame");
  c4->cd(2);
  TH1D* hPNDRSigTrk1 = (TH1D*) hPNDRTrk1->Clone("hPNDRSigTrk1");
  hPNDRSigTrk1->Add(hPNDRReflTrk1,-1);
  hPNDRSigTrk1->Draw("E");
  TH1D* hPADRSigTrk1 = (TH1D*) hPADRTrk1->Clone("hPADRSigTrk1");
  hPADRSigTrk1->Add(hPADRReflTrk1,-1);
  hPADRSigTrk1->Draw("Esame");
  c4->cd(3);
  TH1D* hPNDRSigTrk2 = (TH1D*) hPNDRTrk2->Clone("hPNDRSigTrk2");
  hPNDRSigTrk2->Add(hPNDRReflTrk2,-1);
  hPNDRSigTrk2->Draw("E");
  TH1D* hPADRSigTrk2 = (TH1D*) hPADRTrk2->Clone("hPADRSigTrk2");
  hPADRSigTrk2->Add(hPADRReflTrk2,-1);
  hPADRSigTrk2->Draw("Esame");
  c4->cd(4);
  TH1D* hPNDRSigTrk4 = (TH1D*) hPNDRTrk4->Clone("hPNDRSigTrk4");
  hPNDRSigTrk4->Add(hPNDRReflTrk4,-1);
  hPNDRSigTrk4->Draw("E");
  TH1D* hPADRSigTrk4 = (TH1D*) hPADRTrk4->Clone("hPADRSigTrk4");
  hPADRSigTrk4->Add(hPADRReflTrk4,-1);
  hPADRSigTrk4->Draw("Esame");
  c4->cd(5);
  TH1D* hPNDRSigTrk8 = (TH1D*) hPNDRTrk8->Clone("hPNDRSigTrk8");
  hPNDRSigTrk8->Add(hPNDRReflTrk8,-1);
  hPNDRSigTrk8->Draw("E");
  TH1D* hPADRSigTrk8 = (TH1D*) hPADRTrk8->Clone("hPADRSigTrk8");
  hPADRSigTrk8->Add(hPADRReflTrk8,-1);
  hPADRSigTrk8->Draw("Esame");

  TCanvas * c5 = new TCanvas("c5","c5",600,500);
  TH1D* hDiff0 = (TH1D*) hPADRSigTrk0->Clone("hDiff0");
  hDiff0->Add(hPNDRSigTrk0,-1);
  hDiff0->SetMarkerColor(kBlue);
  hDiff0->SetMarkerStyle(kFullSquare);
  hDiff0->SetMaximum(14);
  hDiff0->SetMinimum(-4);
  hDiff0->SetStats(0);
  TH1D* hDiff1 = (TH1D*) hPADRSigTrk1->Clone("hDiff1");
  hDiff1->Add(hPNDRSigTrk1,-1);
  hDiff1->SetMarkerColor(kGreen-2);
  hDiff1->SetMarkerStyle(kFullCircle);
  TH1D* hDiff2 = (TH1D*) hPADRSigTrk2->Clone("hDiff2");
  hDiff2->Add(hPNDRSigTrk2,-1);
  hDiff2->SetMarkerColor(kOrange-2);
  hDiff2->SetMarkerSize(1.3);
  hDiff2->SetMarkerStyle(kFullStar);
  TH1D* hDiff4 = (TH1D*) hPADRSigTrk4->Clone("hDiff4");
  hDiff4->Add(hPNDRSigTrk4,-1);
  hDiff4->SetMarkerColor(kOrange+8);
  hDiff4->SetMarkerStyle(kFullTriangleUp);
  TH1D* hDiff8 = (TH1D*) hPADRSigTrk8->Clone("hDiff8");
  hDiff8->Add(hPNDRSigTrk8,-1);
  hDiff8->SetMarkerColor(kRed);
  hDiff8->SetMarkerStyle(kFullTriangleDown);

  hDiff0->Draw("l");
  hDiff1->Draw("lsame");
  hDiff2->Draw("lsame");
  hDiff4->Draw("lsame");
  hDiff8->Draw("lsame");

  TFile *fout = new TFile("out.root","RECREATE");
  fout->cd();

  hPNDRSigTrk0->Write();
  hPADRSigTrk0->Write();
  hPNDRSigTrk1->Write();
  hPADRSigTrk1->Write();
  hPNDRSigTrk2->Write();
  hPADRSigTrk2->Write();
  hPNDRSigTrk4->Write();
  hPADRSigTrk4->Write();
  hPNDRSigTrk8->Write();
  hPADRSigTrk8->Write();

  /*
  hPNDRTrk0->Write();
  hPADRTrk0->Write();
  hPNDRReflTrk0->Write();
  hPADRReflTrk0->Write();
  hPNDRTrk1->Write();
  hPADRTrk1->Write();
  hPNDRReflTrk1->Write();
  hPADRReflTrk1->Write();
  hPNDRTrk2->Write();
  hPADRTrk2->Write();
  hPNDRReflTrk2->Write();
  hPADRReflTrk2->Write();
  hPNDRTrk4->Write();
  hPADRTrk4->Write();
  hPNDRReflTrk4->Write();
  hPADRReflTrk4->Write();
  hPNDRTrk8->Write();
  hPADRTrk8->Write();
  hPNDRReflTrk8->Write();
  hPADRReflTrk8->Write();
  */

  fout->Close();
}
Exemplo n.º 5
0
void BkgFluctuation(TString infname = "../ntv6_datambv3rand_djcalo_c0to30_offset0.root",
                    TCut myCut = "cent<30", char *title = "",bool drawLegend = false,
                    bool drawSys = true
		    )
{
  gStyle->SetHistLineWidth(2);
  // ===========================================================
  // Get Input
  // ===========================================================
  TChain* t = new TChain("ntjt");
  t->Add(infname);
  t->AddFriend("tcone",infname);
  cout << infname << ": " << t->GetEntries() << endl;
  t->SetAlias("cptsub0Merge0","cpt[0][1]+cpt[0][2]-(cptbg[0][1]+cptbg[0][2])");
  t->SetAlias("cptsub0Merge1","cpt[0][3]-(cptbg[0][3])");
  t->SetAlias("cptsub0Merge2","cpt[0][4]+cpt[0][5]-(cptbg[0][4]+cptbg[0][5])");
  t->SetAlias("cptsub0Merge3","(Sum$(cpt[0])-cpt[0][0])-(Sum$(cptbg[0])-cptbg[0][0])");

  // ===========================================================
  // Analysis Setup
  // ===========================================================
  TH1::SetDefaultSumw2();
   const int nBin = 3;
   double bins[nBin+1] = {1.,4,8,160};  
  TCut evtCut = "nljet>100&&abs(nljetacorr)<1.6&&aljet>50&&abs(aljetacorr)<1.6&&jdphi>2./3*TMath::Pi()&&!maskEvt";
  TCut exclusion = "abs(nljetacorr)>0.8"; //&&abs(aljetacorr)>0.8";
  evtCut = evtCut&&exclusion;
  //Int_t colors[7] = {kBlue, kCyan-3, kYellow+1, kOrange+1, kGreen+2, kMagenta, kRed };
  Int_t colors[7] = {kYellow+2, kGreen+2,kRed };
  
  // ===========================================================
  // Book Histograms
  // ===========================================================
  vector<TH1D*> vhBgSub;
  for (Int_t i=0; i<nBin+1; ++i) {
    vhBgSub.push_back(new TH1D(Form("hBgSub_%d"),";(Sig Cone #Sigma p_{T}) - (Bkg Cone #Sigma p_{T}) (GeV/c);fraction;",50,-300,300));
  }

  Float_t numEvt = t->GetEntries(evtCut&&myCut);
  cout << "Total Sel evt: " << numEvt << endl;
  for (Int_t i=0; i<nBin+1; ++i) {
    TString var(Form("cptsub0Merge%i",i));
    cout << "Sel evt: " << t->GetEntries(evtCut&&myCut&&var) << endl;
    cout << "var: " << t->GetAlias(var) << endl;
    t->Project(vhBgSub[i]->GetName(),var,(evtCut&&myCut&&var)*"weight");
    Float_t mean = vhBgSub[i]->GetMean();
    Float_t rms = vhBgSub[i]->GetRMS();
    cout << "bgsub mean: " << mean << " rms: " << rms << endl;
    vhBgSub[i]->Scale(1./numEvt);
    cout << "Bin " << i << " rms/sqrt(250): " << rms/sqrt(250)
      << " r=0: " << rms/sqrt(250.)*sqrt(fracArea(0))
      << " r=0.8: " << rms/sqrt(250.)*sqrt(fracArea(0.8)) << endl;
  }

  TCanvas * c2 = new TCanvas("c2","c2",600,600);
  c2->SetLogy();
  vhBgSub[nBin]->SetAxisRange(1e-5,5,"Y");
  vhBgSub[nBin]->Draw("E");
  for (Int_t i=0; i<nBin; ++i) {
    vhBgSub[i]->SetLineColor(colors[i]);
    vhBgSub[i]->Draw("same hist");
  }
  vhBgSub[nBin]->Draw("Esame");

  TLegend *leg = new TLegend(0.19,0.70,0.53,0.92);
  leg->SetFillStyle(0);
  leg->SetBorderSize(0);
  leg->SetTextSize(0.035);
  leg->AddEntry(vhBgSub[nBin],"CMS 0-30%","");
  leg->AddEntry(vhBgSub[nBin],"Random Cone (MB Sample)","");
  leg->AddEntry(vhBgSub[nBin],Form("> %.1f GeV/c",bins[0]),"pl");
  for (int i=0;i<nBin;++i) {
    if (i!=nBin-1){
      leg->AddEntry(vhBgSub[i],Form("%.1f - %.1f GeV/c",bins[i],bins[i+1]),"l");
    } else {
      leg->AddEntry(vhBgSub[i],Form("> %.1f GeV/c",bins[i]),"l");
    }
  }
  leg->Draw();
}
Exemplo n.º 6
0
void bambuAliases(Int_t type=0){

  TChain *ev = new TChain("Events");

  //data
  //ev->Add("/home/edwenger/123596-merged-emptytarget.root");
  //ev->Add("/home/edwenger/123596-merged-targettarget.root");
  //if(type==0) ev->Add("/home/edwenger/123596-mergetestv4.root");
  //if(type==0) ev->Add("/home/edwenger/123596v5-targettarget.root");
  //if(type==0) ev->Add("/home/edwenger/124120-merged.root");
  if(type==0) ev->Add("/d100/data/ZeroBias-rereco/124022a3a4_v2_1/bambu*.root");
  if(type==1) ev->Add("/home/edwenger/123596v5-emptytarget.root");

  //mc
  //ev->Add("/home/loizides/bambu-summer09-MinBias-GEN-SIM-RAW-STARTUP3X_V8I_900GeV-v2.root");
  //ev->Add("/d101/yetkin/mc/CMSSW_3_3_5/BSC_Tuned_v1/Pythia_MinBias_D6T_900GeV_d20091210/bambu/0024CE3C-56E5-DE11-ABDD-002618943930.root");
  if(type==2) ev->Add("/home/edwenger/merge_BSC_Tuned_v1_Pythia_MinBias_D6T_900GeV_d20091210.root");
  if(type==3) ev->Add("/home/edwenger/merge_BSC_Tuned_v1_Pythia_MinBias_ATLAS_900GeV_d20091208.root");

  // event-wide aliases
  ev->SetAlias("run","EventHeader.fRunNum");
  ev->SetAlias("evtno","EventHeader.fEvtNum");
  ev->SetAlias("bunch","EventHeader.fBunchCrossing");
  ev->SetAlias("npix","PixelHits.Entries()");
  ev->SetAlias("pxl","PixelHits.fArray");
  ev->SetAlias("npix1","Sum$(pxl.fType==1)");
  ev->SetAlias("npix2","Sum$(pxl.fType==2)");
  ev->SetAlias("npix3","Sum$(pxl.fType==3)");
  ev->SetAlias("bpix","Sum$(abs(pxl.fType)<10)");
  ev->SetAlias("fpix","Sum$(abs(pxl.fType)>10)");
  ev->SetAlias("nvtx","PrimaryVertexes.Entries()");
  ev->SetAlias("vtx","PrimaryVertexes.fArray");
  ev->SetAlias("avtx","Pixel3Vertexes.fArray");
  ev->SetAlias("tvtx","TrackletVertexes.fArray");
  ev->SetAlias("ntrk","Tracks.Entries()");
  ev->SetAlias("ngoodtrk","Sum$(Tracks.fArray.NHits()>9)");
  //ev->SetAlias("ngoodtrk","Sum$(Tracks.fArray.NHits()>3 && abs(Tracks.fArray.D0())<0.5)");

  ev->SetAlias("parasite","((bunch>=1830 && bunch<=1833) || bunch==3170)");
  ev->SetAlias("collision","(bunch==51 || bunch==2724)");

  // HLT bits
  ev->SetAlias("hlt","HLTBits.fMask");
  ev->SetAlias("hltBSC","hlt.TestBit(66)");     //HLT_MinBiasBSC
  ev->SetAlias("hltBSC_OR","hlt.TestBit(67)");  //HLT_MinBiasBSC_OR
  ev->SetAlias("hltBakBSC","hlt.TestBit(78)");  //HLT_BackwardBSC
  ev->SetAlias("hltForBSC","hlt.TestBit(79)");  //HLT_ForwardBSC
  ev->SetAlias("hltCSCHalo","hlt.TestBit(74)"); //HLT_CSCBeamHalo
  ev->SetAlias("hltPix1","hlt.TestBit(71)");    //HLT_MinBiasPixel_SingleTrack
  ev->SetAlias("hltPix2","hlt.TestBit(72)");    //HLT_MinBiasPixel_DoubleTrack
  ev->SetAlias("hltEG1","hlt.TestBit(64)");

  // l1 technical bits:  https://twiki.cern.ch/twiki/bin/viewauth/CMS/GlobalTriggerMenu_L1Menu_Commissioning2009_v8
  ev->SetAlias("l1t","L1TechBitsBeforeMask.fMask");
  ev->SetAlias("l1t32","l1t.TestBit(32)"); // th1 (inner)
  ev->SetAlias("l1t34","l1t.TestBit(34)"); // OR
  ev->SetAlias("l1t40","l1t.TestBit(40)"); // th1 (all)
  ev->SetAlias("l1t41","l1t.TestBit(41)"); // th2
  ev->SetAlias("l1t36","l1t.TestBit(36)"); // halo bits 36-39
  ev->SetAlias("l1t37","l1t.TestBit(37)"); // 
  ev->SetAlias("l1t38","l1t.TestBit(38)"); // 
  ev->SetAlias("l1t39","l1t.TestBit(39)"); // 
  ev->SetAlias("l1t35","l1t.TestBit(35)"); // high mult
  ev->SetAlias("l1t0","l1t.TestBit(0)");   // BPTX AND
  ev->SetAlias("l1t4","l1t.TestBit(4)");   // BPTX AND (instance 1)
  ev->SetAlias("l1a","L1AlgoBitsBeforeMask.fMask");
  ev->SetAlias("l1a45","l1a.TestBit(45)");

  ev->SetAlias("noHalo","(!l1t36 && !l1t37 && !l1t38 && !l1t39)");

  // bx info
  ev->SetAlias("bx","L1TechBitsBxs.fArray.fBx");
  ev->SetAlias("l1tbx","L1TechBitsBxs.fArray.fMask");
  ev->SetAlias("l1t0bx","l1tbx.TestBit(0)");   // BPTX AND
  ev->SetAlias("l1t4bx","l1tbx.TestBit(4)");   // prescaled (12x) BPTX AND
  ev->SetAlias("l1t34bx","l1tbx.TestBit(34)"); // BSC OR
  ev->SetAlias("l1t40bx","l1tbx.TestBit(40)"); // BSC coincidence threshold 1
  ev->SetAlias("l1t42bx","l1tbx.TestBit(42)"); // BSC splash beam 1
  ev->SetAlias("l1t43bx","l1tbx.TestBit(43)"); // BSC splash beam 2
  ev->SetAlias("l1t32bx","l1tbx.TestBit(32)"); // BSC coincidence inner threshold 1

  // krisztian's 28 events with good agglomerative pixel vertex
  ev->SetAlias("kk1","Entry$==4 || Entry$==5 || Entry$==12 || Entry$==25 || Entry$==28 || Entry$==46 || Entry$==55 || Entry$==77 || Entry$==86 || Entry$==102");
  ev->SetAlias("kk2","Entry$==116 || Entry$==126 || Entry$==138 || Entry$==144 || Entry$==168 || Entry$==187 || Entry$==188 || Entry$==189 || Entry$==195 || Entry$==199");
  ev->SetAlias("kk3","Entry$==200 || Entry$==226 || Entry$==230 || Entry$==244 || Entry$==247 || Entry$==254 || Entry$==258 || Entry$==261");

  // events that are 75ns apart
  ev->SetAlias("ev1","evtno==2265620 || evtno==2265621");
  ev->SetAlias("ev2","evtno==2991369 || evtno==2991370");

  // pixel hit positions
  ev->SetAlias("layer","pxl.fType");
  ev->SetAlias("x","pxl.X()");
  ev->SetAlias("y","pxl.Y()");
  ev->SetAlias("z","pxl.Z()");
  ev->SetAlias("phi","atan(y/x)");
  ev->SetAlias("rho","sqrt(x*x+y*y)*sign(y)");
  ev->SetAlias("fpixPLUS","Sum$(pxl.fType>10 )");
  ev->SetAlias("fpixMINUS","Sum$(pxl.fType<-10)");

  // CaloTowers
  ev->SetAlias("ct","CaloTowers.fArray");
  ev->SetAlias("cr","1100*abs(tan(ct.Theta()))");
  ev->SetAlias("cx","cr*cos(ct.Phi())");
  ev->SetAlias("cy","cr*sin(ct.Phi())");
  ev->SetAlias("HFneg","Sum$(ct.E()*(ct.Eta()<-3))");
  ev->SetAlias("HFpos","Sum$(ct.E()*(ct.Eta()>3))");
  ev->SetAlias("Eneg","Sum$(ct.E()*(ct.Eta()<0))");
  ev->SetAlias("Epos","Sum$(ct.E()*(ct.Eta()>0))");
  ev->SetAlias("HfPos","ct.Eta()>3 && ct.E()>3");
  ev->SetAlias("HfNeg","ct.Eta()<3 && ct.E()>3");
  ev->SetAlias("HfAll","abs(ct.Eta())>3 && ct.E()>3");
  
  // diffrative vars
  ev->SetAlias("ctEp","ct.E()*cos(ct.Theta())");
  ev->SetAlias("ctEsubEp","ct.E()-ctEp");
  ev->SetAlias("ctEaddEp","ct.E()+ctEp");
  ev->SetAlias("ctSumEsubEp","Sum$(ctEsubEp)");
  ev->SetAlias("ctSumEaddEp","Sum$(ctEsubEp)");
  // Christof's tips
  ev->SetAlias("Epzn","Sum$((ct.E()-ct.Mom().Pz())*(ct.E()>3&&ct.Eta()<-3))");
  ev->SetAlias("Epzp","Sum$((ct.E()+ct.Mom().Pz())*(ct.E()>3&&ct.Eta()>3))");
  ev->SetAlias("hltHF3","hlt.TestBit(106)");
  ev->SetAlias("hltTrk1","hlt.TestBit(73)");
  ev.Draw("ct.E()-ct.Mom().Pz()","hltTrk1&&l1t34");
  ev.Draw("Epzn:Epzp","hltTrk1&&l1t34","box");

  // MC event info
  ev->SetAlias("pid","MCEventInfo.fProcessId");
  ev->SetAlias("ND","pid==11 || pid==12 || pid==13 || pid==28 || pid==53 || pid==68 || pid==95");
  ev->SetAlias("SD","pid==92 || pid==93");
  ev->SetAlias("DD","pid==94");
  ev->SetAlias("NSD","pid!=92 && pid!=93");
  ev->SetAlias("inelastic","ND || DD || SD");
  ev->SetAlias("elastic","!(inelastic)");

  // Event selection
  ev->SetAlias("qual","EvtSelData.fClusVtxQual");
  ev->SetAlias("qualDiff","EvtSelData.fClusVtxDiff");
  ev->SetAlias("tHFpos","EvtSelData.fHfPosTime");
  ev->SetAlias("tHFneg","EvtSelData.fHfNegTime");
  ev->SetAlias("eHFpos","EvtSelData.fHfPos");
  ev->SetAlias("eHFneg","EvtSelData.fHfNeg");

  // beamspot------------------
  //ev->Draw("vtx.Y():vtx.X()>>h(50,-0.5,0.5,50,-0.5,0.5)","l1t40 && vtx.fZErr<3 && run==123592","colz");
  //ev->Draw("vtx.Z()>>h(50,-20,20)","l1t40 && vtx.fZErr<3 && run==123592");
  

  // print events-------------------------------------
  //ev->Scan("evtno:npix:hltBSC:hltBakBSC:hltForBSC","(kk1 || kk2 || kk3)");
  //ev->Scan("evtno:l1t40:l1t41","l1t40");
  //ev->Scan("evtno:bunch:bx:l1t0bx:l1t40bx:l1t43bx:l1t32bx","evtno==2265620 || evtno==2265621 || evtno==2991369 || evtno==2991370");
  //ev->Scan("EventHeader.fTimeStamp-54100060637e8","ev1");
  //ev->Scan("EventHeader.fBunchCrossing","ev1");


  //ev->Scan("evtno:ct.Eta():ct.Phi():ct.E():ct.Theta():cy:cx","abs(ct.Eta())>3 && evtno==1903639 && ct.E()>3");

  // draw hits throughout detector in a single event --------------------------------------
  // big events in run 123151: 2529237, 3177667, 1903639, 2449816, 1259548
  
  /*

  Int_t run=123592;
  Int_t evt=532528; //1712524, 105574, 532528, 632862

  TCanvas *c1 = new TCanvas("c1","c1",1200,300);
  c1->Divide(5,1);
  c1->cd(1);
  TH2F *dum1 = new TH2F("dum1",Form("Run %d Event %d HF-;x [cm]; y [cm]",run,evt),10,-150,150,10,-150,150);
  dum1->Draw();
  ev->Draw("cy:cx>>h1(20,-150,150,20,-150,150)",Form("ct.Eta()<3 && evtno==%d && ct.E()>1 && abs(cx)<100 && abs(cy)<100",evt),"goff");
  h1->Draw("same colz");
  c1->cd(2);
  TH2F *dum2 = new TH2F("dum2",Form("Run %d Event %d PXF-;x [cm]; y [cm]",run,evt),30,-15,15,30,-15,15);
  dum2->Draw();
  ev->Draw("y:x>>h2a(1000,-10,10,1000,-10,10)",Form("layer==-11 && evtno==%d",evt),"goff");
  h2a->SetMarkerColor(2); h2a->SetMarkerStyle(6);
  h2a->Draw("same");
  ev->Draw("y:x>>h2b(1000,-10,10,1000,-10,10)",Form("layer==-12 && evtno==%d",evt),"goff");
  h2b->SetMarkerColor(4); h2b->SetMarkerStyle(6);
  h2b->Draw("same");
  c1->cd(3);
  TH2F *dum3 = new TH2F("dum3",Form("Run %d Event %d PXB;x [cm]; y [cm]",run,evt),30,-15,15,30,-15,15);
  dum3->Draw();
  ev->Draw("y:x>>h3(1000,-10,10,1000,-10,10)",Form("abs(layer)<10 && evtno==%d",evt),"goff");
  h3->SetMarkerColor(4); h3->SetMarkerStyle(6);
  h3->Draw("same");
  c1->cd(4);
  TH2F *dum4 = new TH2F("dum4",Form("Run %d Event %d PXF+;x [cm]; y [cm]",run,evt),30,-15,15,30,-15,15);
  dum4->Draw();
  ev->Draw("y:x>>h4a(1000,-10,10,1000,-10,10)",Form("layer==11 && evtno==%d",evt),"goff");
  h4a->SetMarkerColor(2); h4a->SetMarkerStyle(6);
  h4a->Draw("same");
  ev->Draw("y:x>>h4b(1000,-10,10,1000,-10,10)",Form("layer==12 && evtno==%d",evt),"goff");
  h4b->SetMarkerColor(4); h4b->SetMarkerStyle(6);
  h4b->Draw("same");
  c1->cd(5);
  TH2F *dum5 = new TH2F("dum5",Form("Run %d Event %d HF+;x [cm]; y [cm]",run,evt),10,-150,150,10,-150,150);
  dum5->Draw();
  ev->Draw("cy:cx>>h5(20,-150,150,20,-150,150)","ct.Eta()>3 && evtno==1903639 && ct.E()>1 && abs(cx)<100 && abs(cy)<100","goff");
  h5->Draw("same colz");
  
  */
  
  Double_t x[5] = {130,25,25,95,200};
  Double_t y[5] = {200,95,25,25,130};
  TPolyLine *pline = new TPolyLine(5,x,y);
  pline->SetLineColor(2);
  pline->SetLineWidth(2);

  //ev->SetAlias("cuts","Eneg>25 && Epos>25 && abs(Epos-Eneg)<70");
  //ev->SetAlias("cuts","npix>0");
  //ev->SetAlias("cuts","noHalo && !parasite");
  
  /*
  TCanvas *c1 = new TCanvas("c1","c1",800,800);
  c1->Divide(2,2);
  c1->cd(1);
  ev->Draw("Eneg/Epos:npix>>hHF1(25,0,600,25,0,6)","SD","goff");
  hHF1->Draw("colz");
  //pline->Draw("same");
  c1->cd(2);
  ev->Draw("Eneg/Epos:npix>>hHF2(25,0,600,25,0,6)","DD","goff");
  hHF2->Draw("colz"); 
  //pline->Draw("same"); 
  c1->cd(3);
  ev->Draw("Eneg/Epos:npix>>hHF3(25,0,600,25,0,6)","ND","goff");
  hHF3->Draw("colz"); 
  //pline->Draw("same"); 
  c1->cd(4);
  ev->Draw("Eneg/Epos:npix>>hHF4(25,0,600,25,0,6)","NSD","goff");
  hHF4->Draw("colz");
  //pline->Draw("same");
  */

  //ev->Draw("Eneg/Epos:npix>>h(25,0,600,25,0,6)","l1t40 && l1t0 && noHalo && !parasite","colz");

  //ev->Scan("Eneg:Epos:evtno:npix:bunch:parasite:noHalo:l1t0","abs(Epos-Eneg)>250 && npix>100 && !parasite");
  //ev->Draw("Eneg:Epos>>hHF(25,0,400,25,0,400)","l1t40 && run==123592 && noHalo","colz");

  //ev->Draw("(Epos-Eneg)/(Epos+Eneg):npix","collision && noHalo && l1t0 && l1t40","colz");

  
  //ev->Draw("l1t34>>h(2,-0.5,1.5)","l1a45 && run==123592");
  //ev->Draw("l1a45>>h2(2,-0.5,1.5)","l1t34 && run==123592","l text");


  //ev->Draw("(noHalo && l1t0):parasite>>hEvtSel(2,-0.5,1.5,2,-0.5,1.5)","run==123592 && l1t40","goff");
  //hEvtSel->SetTitle(";parasitic bunch crossings;BPTX coincidence AND NOT BSC halo");
  //hEvtSel->Draw("colz text");

  //pline->Draw("same");


  //------L1

  //ev->Draw("l1t40:l1t0","","colz text");
   
  //ev->Draw("qual:bpix>>h(50,0,2000,50,0,10)","qual<10  && l1t34","colz");
  //ev->Draw("tHFpos:tHFneg>>h2(50,-20,60,50,-20,60","l1t34 && min(eHFpos,eHFneg)>25","colz");
  //ev->Draw("log10(eHFpos):log10(eHFneg)>>h3(50,-1,3,50,-1,3)","l1t34 && eHFpos!=0 && eHFneg!=0 && abs(tHFpos-21)<10 && abs(tHFneg-21)<10","colz");
  //ev->Draw("min(tHFneg,tHFpos):min(eHFneg,eHFpos)>>h4(100,-20,100,100,-400,200)","l1t34 && (bpix/200*(qual-1))>1 && abs(tHFpos-21)<10 && abs(tHFneg-21)<10 && min(eHFpos,eHFneg)>0");



  //-------BSC efficiency (Johannes-style)
  /*
  //ev->Draw("qual:npix>>h(50,0,2000,50,0,10)","vtx.fNTracks>=5 && vtx.fZErr<3 && abs(vtx.Z())<10 && abs(vtx.X())<0.5 && abs(vtx.Y())<0.5 && l1t34","goff");
  ev->Draw("qual:npix>>h(50,0,2000,50,0,10)","vtx.fNTracks>=5 && vtx.fZErr<3 && abs(vtx.Z())<10 && abs(vtx.X())<0.5 && abs(vtx.Y())<0.5 && l1t41 && inelastic","goff");
  //h->SetTitle("Run 123596: Cluster shape compatibility with primary vertex; # of pixel hits; vertex uniqueness");
  h->SetTitle("PYTHIA inelastic: Cluster shape compatibility with primary vertex; # of pixel hits; vertex uniqueness");
  h->Draw("colz");
  */


  //------BSC efficiency (Ferenc-style)

  ev->SetAlias("edscut","(qual>(0.5+0.0045*npix) || npix<150)");
  
  /*
  ev->Draw("ngoodtrk>>h34(10,0,40)","l1t34 && Pixel3Vertexes.GetEntries()>0 && edscut","goff");
  TH1F *h34 = gDirectory->Get("h34");
  h34->Sumw2();
  ev->Draw("ngoodtrk>>h40(10,0,40)","l1t40 && Pixel3Vertexes.GetEntries()>0 && edscut","goff");
  TH1F *h40 = gDirectory->Get("h40");
  h40->Sumw2();
  ev->Draw("ngoodtrk>>h41(10,0,40)","l1t41 && Pixel3Vertexes.GetEntries()>0 && edscut","goff");
  TH1F *h41 = gDirectory->Get("h41");
  h41->Sumw2();
  
  TFile *f;
  if(type==0) f = new TFile("coll.root","RECREATE");
  else if(type==1) f = new TFile("empty.root","RECREATE");
  else if(type==2) f = new TFile("d6t.root","RECREATE");
  else if(type==3) f = new TFile("atlas.root","RECREATE");
  f->cd();
  h34->Write();
  h40->Write();
  h41->Write();
  f->ls();
  f->Close();
  */

  //---------------Monster Cut---------------------
  
  Double_t x[3] = {150,150,1000};
  Double_t y[3] = {0,0.5+0.0045*150,0.5+0.0045*1000};
  TPolyLine *pline = new TPolyLine(3,x,y);
  pline->SetLineColor(2);
  pline->SetLineWidth(2);
  
  if(type==0) { 
    ev->Draw("qual:EvtSelData.Npix()>>h0(50,0,1000,50,0,10)","l1t40","goff");
    h0->SetTitle("Run 123596 -- bit 34; # of pixel hits; cluster-vertex compatibility");
    h0->Draw("colz");
  }

  if(type==1) { 
    ev->Draw("qual:EvtSelData.Npix()>>h1(50,0,1000,50,0,10)","l1t34","goff");
    h1->SetTitle("Run 123596 (empty bunches)  -- bit 34; # of pixel hits; cluster-vertex compatibility");
    h1->Draw("colz");
  }

  if(type==2) { 
    ev->Draw("qual:EvtSelData.Npix()>>h2(50,0,1000,50,0,10)","l1t34 && NSD","goff");
    h2->SetTitle("PYTHIA D6T tune  -- bit 34; # of pixel hits; cluster-vertex compatibility");
    h2->Draw("colz");
  }

  if(type==3) { 
    ev->Draw("qual:EvtSelData.Npix()>>h3(50,0,1000,50,0,10)","l1t34 && NSD","goff");
    h3->SetTitle("PYTHIA ATLAS tune  -- bit 34; # of pixel hits; cluster-vertex compatibility");
    h3->Draw("colz");
  }
  
  pline->Draw("same");
  


  //ev->Draw("qualDiff:npix","l1t34 && npix<200","colz");
  //ev->Scan("qualDiff:npix:avtx.Z()","l1t40 && qual==0");
  //ev->Draw("qualDiff:npix>>h","l1t40 && Pixel3Vertexes.GetEntries()","goff");
  //h->Draw("colz");


  //ev->Draw("npix","l1t34 && Pixel3Vertexes.Entries()");

  //ev->Scan("evtno:avtx.fNTracks:avtx.Z()","l1t40");


  //ev->Draw("tHFpos:tHFneg","l1t34 && min(eHFpos,eHFneg)>25","colz");
  //ev->Draw("log10(eHFpos):log10(eHFneg)>>HF(50,-1,3,50,-1,3)","l1t34","colz");
  //ev->Draw("min(tHFneg,tHFpos):min(eHFneg,eHFpos)","l1t34");
  //ev->Draw("qual:bpix","qual<10 && bpix<1000 && l1t34");
  
  //ev->Scan("evtno","l1t41 && SD");

  //ev->Draw("Pixel3Vertexes.fNTracks>>h(80,-0.5,79.5)","l1t40 && Pixel3Vertexes.Entries()>0");
}
Exemplo n.º 7
0
void FillHists(rt::TH1Container& hc, TChain& chain, const std::string& sample_name, long num_events = std::numeric_limits<long>::max())
{
    // number of events
    num_events = (chain.GetEntries() < num_events ? chain.GetEntries() : num_events);
    std::cout << "Beginning " << sample_name << " on " << num_events << " of " << chain.GetEntries() << " events..." << std::endl; 

     // scale the # of events
    const float nevts_aod   = chain.GetMaximum("evt_nEvts"); // # files in AOD
    const float nevts_file  = chain.GetEntries();            // # files in this sample
    const float nevts_scale = nevts_aod/nevts_file;          // scale factor to "fix" evt_scale1fb since we are using a subset of the data 

    // lumi
    static const float lumi = 0.082; //fb^-1

    // efficiency scale
    float eff_scale = 1.0;
    if (sample_name == "data"   ) {eff_scale = s_SDEfficiency[ 0];}
    if (sample_name == "dyll"   ) {eff_scale = s_SDEfficiency[ 1];}
    if (sample_name == "wjets"  ) {eff_scale = s_SDEfficiency[ 2];}
    if (sample_name == "ttdil"  ) {eff_scale = s_SDEfficiency[ 3];}
    if (sample_name == "ttslq"  ) {eff_scale = s_SDEfficiency[ 4];}
    if (sample_name == "tthad"  ) {eff_scale = s_SDEfficiency[ 5];}
    if (sample_name == "qcd"    ) {eff_scale = s_SDEfficiency[ 6];}
    if (sample_name == "ww"     ) {eff_scale = s_SDEfficiency[ 7];}
    if (sample_name == "wz2l2q" ) {eff_scale = s_SDEfficiency[ 8];}
    if (sample_name == "wz3l"   ) {eff_scale = s_SDEfficiency[ 9];}
    if (sample_name == "zz2l2q" ) {eff_scale = s_SDEfficiency[10];}
    if (sample_name == "zz2l2nu") {eff_scale = s_SDEfficiency[11];}
    if (sample_name == "zz4l"   ) {eff_scale = s_SDEfficiency[12];}

    // overall scale
    const float scale = lumi * eff_scale * nevts_scale; 
    std::cout << "scale factor = " << Form("%f * %f * %f = %f", lumi, eff_scale, nevts_scale, scale) << std::endl;

    // book hists
    hc.Add(new TH1F(Form("h_count_mm_%s", sample_name.c_str()), Form("Event ee count (%s)"                               , sample_name.c_str()), 3 , -0.5, 2.5));
    hc.Add(new TH1F(Form("h_count_ee_%s", sample_name.c_str()), Form("Event #mu#mu count (%s)"                           , sample_name.c_str()), 3 , -0.5, 2.5));
    hc.Add(new TH1F(Form("h_mee_%s"     , sample_name.c_str()), Form("Dimuon Electron (%s);m_{ee}(GeV);# Events Expected", sample_name.c_str()), 60,   60, 120));
    hc.Add(new TH1F(Form("h_mmm_%s"     , sample_name.c_str()), Form("Dimuon Mass (%s);m_{#mu#mu}(GeV);# Events Expected", sample_name.c_str()), 60,   60, 120));
    hc.Sumw2();

    // alias for dilepton mass
    chain.SetAlias("mass_mm_px", "Sum$(abs(genps_id)==13 && genps_status==3 ? genps_p4.Px() : 0.0)");
    chain.SetAlias("mass_mm_py", "Sum$(abs(genps_id)==13 && genps_status==3 ? genps_p4.Py() : 0.0)");
    chain.SetAlias("mass_mm_pz", "Sum$(abs(genps_id)==13 && genps_status==3 ? genps_p4.Pz() : 0.0)");
    chain.SetAlias("mass_mm_e" , "Sum$(abs(genps_id)==13 && genps_status==3 ? genps_p4.E()  : 0.0)");
    chain.SetAlias("mass_mm"   , "sqrt(mass_mm_e*mass_mm_e - mass_mm_px*mass_mm_px - mass_mm_py*mass_mm_py - mass_mm_pz*mass_mm_pz)");

    chain.SetAlias("mass_ee_px", "Sum$(abs(genps_id)==11 && genps_status==3 ? genps_p4.Px() : 0.0)");
    chain.SetAlias("mass_ee_py", "Sum$(abs(genps_id)==11 && genps_status==3 ? genps_p4.Py() : 0.0)");
    chain.SetAlias("mass_ee_pz", "Sum$(abs(genps_id)==11 && genps_status==3 ? genps_p4.Pz() : 0.0)");
    chain.SetAlias("mass_ee_e" , "Sum$(abs(genps_id)==11 && genps_status==3 ? genps_p4.E()  : 0.0)");
    chain.SetAlias("mass_ee"   , "sqrt(mass_ee_e*mass_ee_e - mass_ee_px*mass_ee_px - mass_ee_py*mass_ee_py - mass_ee_pz*mass_ee_pz)");

    // fill hist
    hc.SetDirectory(gDirectory);
    const TCut selection_ee = Form("%1.4f*evt_scale1fb*(Sum$(genps_status==3 && genps_id==11)>=1 && Sum$(genps_status==3 && genps_id==-11)>=1)", scale);
    chain.Draw(">>event_list_ee", selection_ee, "goff", num_events);
    TEventList * const event_list_ee = dynamic_cast<TEventList*>(gDirectory->Get("event_list_ee"));
    chain.SetEventList(event_list_ee);
    std::cout << "filling ee hists..." << std::endl;
    chain.Draw(Form("1>>h_count_ee_%s" , sample_name.c_str()), selection_ee, "goff", num_events);
    chain.Draw(Form("mass_ee>>h_mee_%s", sample_name.c_str()), selection_ee, "goff", num_events);

    const TCut selection_mm = Form("%1.4f*evt_scale1fb*(Sum$(genps_status==3 && genps_id==13)>=1 && Sum$(genps_status==3 && genps_id==-13)>=1)", scale);
    chain.SetEventList(NULL);
    chain.Draw(">>event_list_mm", selection_mm, "goff", num_events);
    TEventList * const event_list_mm = dynamic_cast<TEventList*>(gDirectory->Get("event_list_mm"));
    chain.SetEventList(event_list_mm);
    std::cout << "filling mm hists..." << std::endl;
    chain.Draw(Form("1>>h_count_mm_%s" , sample_name.c_str()), selection_mm, "goff", num_events);
    chain.Draw(Form("mass_mm>>h_mmm_%s", sample_name.c_str()), selection_mm, "goff", num_events);
    hc.SetDirectory(NULL);

    std::cout << "Complete " << sample_name  << ":  ";
    std::cout << "mm count = " << rt::Integral(hc["h_count_mm_"+sample_name]) << " (" << hc["h_count_mm_"+sample_name]->GetEntries() << ") : "; 
    std::cout << "ee count = " << rt::Integral(hc["h_count_ee_"+sample_name]) << " (" << hc["h_count_ee_"+sample_name]->GetEntries() << ")\n" << std::endl; 
   
    // done
    return;
}