コード例 #1
0
ファイル: MCefficiency.C プロジェクト: boundino/DntupleVn
void MCefficiency(TString inputmc, TString outputfile, TString tfend, TString selmcgen, TString cut, TString weight, Float_t centmin, Float_t centmax)
{
  Float_t hiBinMin,hiBinMax;
  hiBinMin = centmin*2;
  hiBinMax = centmax*2;

  selmcgen = Form("%s&&hiBin>=%f&&hiBin<%f",selmcgen.Data(),hiBinMin,hiBinMax);
  cut = Form("%s&&hiBin>=%f&&hiBin<%f",cut.Data(),hiBinMin,hiBinMax);

  TFile* infMC = new TFile(inputmc.Data());
  TTree* ntMC = (TTree*)infMC->Get("ntDkpi");
  ntMC->AddFriend("ntHi");
  ntMC->AddFriend("ntSkim");
  TTree* ntGen = (TTree*)infMC->Get("ntGen");
  ntGen->AddFriend("ntHi");
  ntGen->AddFriend("ntSkim");

  TH1D* hPtMC = new TH1D("hPtMC","",nPtBins,ptBins);
  TH1D* hPtGen = new TH1D("hPtGen","",nPtBins,ptBins);

  ntMC->Project("hPtMC","Dpt",TCut(weight)*(TCut(cut.Data())&&"(Dgen==23333)"));
  divideBinWidth(hPtMC);
  ntGen->Project("hPtGen","Gpt",TCut(weight)*(TCut(selmcgen.Data())));
  divideBinWidth(hPtGen);
  TH1D* hEff = (TH1D*)hPtMC->Clone("hEff");
  hEff->Divide(hPtGen);

  TFile* fout=new TFile(Form("%s_cent_%.0f_%.0f_%s.root",outputfile.Data(),centmin,centmax,tfend.Data()),"recreate");
  fout->cd();
  hEff->Write();
  fout->Close();
}
コード例 #2
0
ファイル: weightMCPbPb.C プロジェクト: ginnocen/DntupleRunII
void weightPbPbvertex(){

TFile*fMC=new TFile("/data/HeavyFlavourRun2/MC2015/Dntuple/PbPb/ntD_EvtBase_20160513_DfinderMC_PbPb_20160502_dPt1tkPt0p5_D0_prompt_Dpt2Dy1p1tkPt0p7tkEta2Decay2p9Dalpha0p14Skim_pthatweight.root");
TTree *ntDkpiMC = (TTree*)fMC->Get("ntDkpi");
TTree *ntSkimMC = (TTree*)fMC->Get("ntSkim");
TTree *ntHiMC = (TTree*)fMC->Get("ntHi");
ntDkpiMC->AddFriend(ntSkimMC);
ntDkpiMC->AddFriend(ntHiMC);

TFile*fData=new TFile("/data/jisun/PbPb2015/HF2and_ncand_skim_Dntuple_crab_PbPb_HIMinimumBias1to7_ForestAOD_D0y1p1_tkpt0p7eta1p5_goldenjson_EvtPlaneCali_03182015.root");
TTree *ntDkpiData = (TTree*)fData->Get("ntDkpi");
TTree *ntSkimData = (TTree*)fData->Get("ntSkim");
TTree *ntHiData = (TTree*)fData->Get("ntHi");
TTree *ntHltData = (TTree*)fData->Get("ntHlt");
ntDkpiData->AddFriend(ntSkimData);
ntDkpiData->AddFriend(ntHiData);
ntDkpiData->AddFriend(ntHltData);

TH1F*hpzData=new TH1F("hpzData","hpzData",200,-15,15);
TH1F*hpzMC=new TH1F("hpzMC","hpzMC",200,-15,15);

TCut weighpthat="1";
TString cut="abs(PVz)<15&&pclusterCompatibilityFilter&&pprimaryVertexFilter&&phfCoincFilter3";
TString hlt="HLT_HIL1MinimumBiasHF2AND_part1_v1||HLT_HIL1MinimumBiasHF2AND_part2_v1||HLT_HIL1MinimumBiasHF2AND_part3_v1";

TCut weighttest="1";
//TCut weighttest="1.26077+PVz*(0.00887442)+PVz*PVz*(-0.00782056)+PVz*PVz*PVz*(-3.51063e-05)+PVz*PVz*PVz*PVz*(-3.51063e-05)";

ntDkpiMC->Project("hpzMC","PVz",TCut(weighpthat)*(TCut(cut.Data()*TCut(weighttest))));
ntDkpiData->Project("hpzData","PVz",(TCut(cut.Data())*TCut(hlt.Data())));

hpzMC->Scale(1./hpzMC->Integral(hpzMC->FindBin(-15.),hpzMC->FindBin(15)));
hpzData->Scale(1./hpzData->Integral(hpzMC->FindBin(-15.),hpzMC->FindBin(15)));

TCanvas*cRatioVtx=new TCanvas("cRatioVtx","cRatioVtx",500,500);
cRatioVtx->Divide(2,1);
cRatioVtx->cd(1);
hpzMC->SetLineColor(2);
hpzMC->Draw();
hpzData->Draw("same");
cRatioVtx->cd(2);
TH1D*hRatioVertex=(TH1D*)hpzData->Clone("hRatioVertex");
hRatioVertex->Divide(hpzMC);
hRatioVertex->Draw();


TF1 *myfit = new TF1("myfit","[0]+[1]*x+x*x*[2]+x*x*x*[3]+x*x*x*x*[4]", -15, 15);  
hRatioVertex->Fit("myfit","","",-15,15);
double par0=myfit->GetParameter(0);
double par1=myfit->GetParameter(1);
double par2=myfit->GetParameter(2);
double par3=myfit->GetParameter(3);
double par4=myfit->GetParameter(4);
std::cout<<"weight="<<par0<<"+PVz*("<<par1<<")+PVz*PVz*("<<par2<<")+PVz*PVz*PVz*("<<par3<<")+PVz*PVz*PVz*PVz*("<<par4<<")"<<endl;

}
コード例 #3
0
ファイル: fitBarea.C プロジェクト: KiSooLee/Bntuple
void fitBarea(TString infname="",bool doweight = 1)
{
  if (doweight==0) weight="1";
  if (infname=="") infname=inputdata.Data();
  TFile *inf = new TFile(infname.Data());
  TTree *nt = (TTree*) inf->Get("ntKp");

  TFile *infMC = new TFile(inputmc.Data());
  TTree *ntGen = (TTree*)infMC->Get("ntGen");
  TTree *ntGen2 = (TTree*)inf->Get("ntGen");
  TTree *ntMC = (TTree*)infMC->Get("ntKp");
    
  ntGen->AddFriend(ntMC);
  ntGen2->AddFriend(ntMC);
    
  const int nBins = 1;
  double ptBins[nBins+1] = {10,60};
//  const int nBins = 1;
//  double ptBins[nBins+1] = {10,60};
  TH1D *hPt = new TH1D("hPt","",nBins,ptBins);

  for (int i=0;i<nBins;i++)
    {
      TF1 *f = fit(nt,ntMC,ptBins[i],ptBins[i+1]);
      double yield = f->Integral(5,6)/0.02;
      double yieldErr = f->Integral(5,6)/0.02*f->GetParError(0)/f->GetParameter(0);
      hPt->SetBinContent(i+1,yield/(ptBins[i+1]-ptBins[i]));
      hPt->SetBinError(i+1,yieldErr/(ptBins[i+1]-ptBins[i]));
    }
  
}
コード例 #4
0
ファイル: buildAlg.C プロジェクト: shahor02/align
void ConnectFriends()
{
  // Connect the friends tree as soon as available.
  //
  // Handle the friends first
  //
  if (!esdTree->FindBranch("ESDfriend.")) {
    // Try to add ESDfriend. branch as friend
    TString esdFriendTreeFName;
    esdFriendTreeFName = (esdTree->GetCurrentFile())->GetName();    
    TString basename = gSystem->BaseName(esdFriendTreeFName);
    Int_t index = basename.Index("#")+1;
    basename.Remove(index);
    basename += "AliESDfriends.root";
    TString dirname = gSystem->DirName(esdFriendTreeFName);
    dirname += "/";
    esdFriendTreeFName = dirname + basename;
    //
    TTree* cTree = esdTree->GetTree();
    if (!cTree) cTree = esdTree;      
    cTree->AddFriend("esdFriendTree", esdFriendTreeFName.Data());
    cTree->SetBranchStatus("ESDfriend.", 1);
    esdFr = (AliESDfriend*)(esdEv->FindListObject("AliESDfriend"));
    if (esdFr) cTree->SetBranchAddress("ESDfriend.", &esdFr);
  }
}
コード例 #5
0
ファイル: treefriend.C プロジェクト: adevress/root-1
void DrawFriend() {
  // Draw a scatter plot of variable x in the parent TTree versus
  // the same variable in the subtree.
  // This should produce points along a straight line.
   
   TFile *f  = TFile::Open("treeparent.root");
   TTree *T  = (TTree*)f->Get("T");
   T->AddFriend("TF","treefriend.root");
   T->Draw("x:TF.x");
}
コード例 #6
0
ファイル: prescaleBrilCalc.C プロジェクト: boundino/Dntuple
void prescaleBrilCalc(TString inputMB, Float_t unprescale, Float_t unprescaleMB, TString eventfilter, Int_t isPbPb)
{
  TString tPbPb = (isPbPb>0)?"PbPb":"pp";
  cout<<"  -- Calculating lumi of "<<tPbPb<<endl;

  Double_t prescaleMB = unprescaleMB/unprescale;
  
  TFile* f = new TFile(inputMB);
  TTree* ntDkpi = (TTree*)f->Get("ntDkpi");
  ntDkpi->AddFriend("ntSkim");
  ntDkpi->AddFriend("ntHlt");
  ntDkpi->AddFriend("ntHi");
 
  TH1F* hcountsMB0100 = new TH1F("hcountsMB0100","",100,-2,2);
  TH1F* hcountsMB010 = new TH1F("hcountsMB010","",100,-2,2);
  
  //0-100%
  cout<<"  -- Processing 0-100%"<<endl;
  ntDkpi->Draw("1>>hcountsMB0100",Form("%s&&hiBin<180",eventfilter.Data()));
  Double_t ncountsMB0100 = hcountsMB0100->GetEntries()*10/9;
  cout<<"   - Number of MB events (0-90%): "<<ncountsMB0100<<endl;

  Double_t TAA0100 = 392.4/(70.*1e9);
  Double_t lumiMB0100 = TAA0100*ncountsMB0100;
  Double_t lumiHighpt0100 = lumiMB0100/prescaleMB;
  
  cout<<"   - Luminosity brilcalc low pt: "<<lumiMB0100<<endl;
  cout<<"   - Luminosity brilcalc high pt: "<<lumiHighpt0100<<endl;
  
  //0-10%
  cout<<"  -- Processing 0-10%"<<endl;  
  ntDkpi->Draw("1>>hcountsMB010",Form("%s&&hiBin<20",eventfilter.Data()));
  Double_t ncountsMB010 = hcountsMB010->GetEntries();
  cout<<"   - Number of MB events (0-10%): "<<ncountsMB010<<endl;
  
  Double_t TAA010 = (23.2/1e9);
  Double_t lumiMB010 = TAA010*ncountsMB010;
  Double_t lumiHighpt010 = lumiMB010/prescaleMB;      

  cout<<"   - Luminosity brilcalc low pt: "<<lumiMB010<<endl;
  cout<<"   - Luminosity brilcalc high pt: "<<lumiHighpt010<<endl;
}
コード例 #7
0
// inspired by ROOT-7007
int execNonExistingFriend() {
   TTree* a = new TTree("a", "a");
   auto fe = a->AddFriend("asfasf", "asfasgfags.root");
   if (!fe->IsZombie()){
      std::cerr << "The TFriendElement instance should be a zombie but it's not!\n";
   } else {
      std::cout << "The TFriendElement instance is a zombie.\n";
   }

   return 0;
}
コード例 #8
0
void extract(TString trigger="HLT_HIDmesonHITrackingGlobal_Dpt40_v1",double nbins=2,double minpt=2,double maxpt=2)
{
  TH1D* getYield(TTree* nt, TTree* ntMC, TString triggerpass, TString triggername, TString prescale, TString variable, TString varname, TString varlatex, Int_t BIN_NUM, Double_t BIN_MIN, Double_t BIN_MAX, TString addcut="");
  void plotTurnOn(TH1D* hnominator, TH1D* hdenominator, TString triggerlegend, TString triggername, TString varname, TString varlatex, Int_t BIN_NUM, Double_t BIN_MIN, Double_t BIN_MAX);

  TFile* infile = new TFile(infname);
  TTree* root = (TTree*)infile->Get("ntDkpi");
  root->AddFriend("ntHlt");
  TFile* infileMC = new TFile(infnameMC);
  TTree* rootMC = (TTree*)infileMC->Get("ntDkpi");
  rootMC->AddFriend("ntHlt");
  rootMC->AddFriend("ntGen");

  if(!isPbPb)
  {
    TH1D* hpp_pt = getYield(root,rootMC,"","","","Dpt","pt","p_{T} (GeV/c)",nbins,minpt,maxpt);
    TH1D* hpp_pt_Hlt = getYield(root,rootMC,Form("&&%s",trigger.Data()),Form("_%s",trigger.Data()),"","Dpt","pt","p_{T} (GeV/c)",nbins,minpt,maxpt);
    plotTurnOn(hpp_pt_Hlt,hpp_pt,trigger,Form("_%s",trigger.Data()),"pt","p_{T} (GeV/c)",nbins,minpt,maxpt);
  }
}
コード例 #9
0
void katieTest(int run) {
  gSystem->Load("libAnitaEvent.so");

  char eventName[100];//FILENAME_MAX];
  char headerName[100];//FILENAME_MAX];
  char hkName[100];//FILENAME_MAX];
  char gpsName[100];//FILENAME_MAX];
  sprintf(eventName,"/anitaStorage/antarctica14/root/run%d/eventFile%d.root",run,run);
  sprintf(headerName,"/anitaStorage/antarctica14/root/run%d/headFile%d.root",run,run);
  sprintf(hkName,"/anitaStorage/antarctica14/root/run%d/prettyHkFile%d.root",run,run);
  sprintf(gpsName,"/anitaStorage/antarctica14/root/run%d/gpsFile%d.root",run,run);
  
  TFile *fpEvent = new TFile(eventName);
  TTree *eventTree = (TTree*) fpEvent->Get("eventTree");
  eventTree->AddFriend("headTree",headerName);
  eventTree->AddFriend("prettyHkTree",hkName);
  eventTree->AddFriend("adu5PatTree",gpsName);

  eventTree->Draw("pressures[1]:altitude");

}
コード例 #10
0
ファイル: saveHist3pMinpt.C プロジェクト: boundino/Dntuple
void saveHist3pMinpt()
{
    real isMC=MC;
    TFile* infMCData = new TFile(infnameData3p[isMC].Data());
    TFile* infMCMC = new TFile(infnameMC3p[isMC].Data());
    TTree* ntMCData = (TTree*)infMCData->Get("ntDD0kpipi");
    TTree* ntMCMC = (TTree*)infMCMC->Get("ntDD0kpipi");

    ntMCData->AddFriend("ntHlt");
    if(isMC!=Data_MB||isMC!=Data) ntMCData->AddFriend("ntHi");
    ntMCMC->AddFriend("ntHlt");
    ntMCMC->AddFriend("ntHi");

    cout<<"  -- Filling histograms - MC"<<endl;
    cout<<"     "<<infnameData3p[isMC]<<endl;
    cout<<"     "<<infnameMC3p[isMC]<<endl;

    for(int i=0; i<nBins; i++)
    {
        cout<<setiosflags(ios::left)<<"   - Processing ptbin "<<setw(3)<<ptBins[i]<<endl;
        TH1D* h = new TH1D("h","",BINNUM,BINMIN,BINMAX);
        TH1D* hMCSignal = new TH1D("hMCSignal","",BINNUM,BINMIN,BINMAX);
        TH1D* hMCSwapped = new TH1D("hMCSwapped","",BINNUM,BINMIN,BINMAX);
        ntMCData->Project("h","Dmass-DtktkResmass",Form("%s*(%s&&%s&&Dpt>%f)",weightdata[isMC].Data(),seldata3p[isMC].Data(),triggerselectiondata[isMC].Data(),ptBins[i]));
        ntMCMC->Project("hMCSignal","Dmass-DtktkResmass",Form("%s*(%s&&%s&&Dpt>%f)",weightmc[isMC].Data(),selmc3p[isMC].Data(),triggerselectionmc[isMC].Data(),ptBins[i]));
        ntMCMC->Project("hMCSwapped","Dmass-DtktkResmass",Form("%s*(%s&&%s&&Dpt>%f)",weightmc[isMC].Data(),selswp3p[isMC].Data(),triggerselectionmc[isMC].Data(),ptBins[i]));
        TFile* outf = new TFile(Form("inputfiles/fmass_pp_3p_%s_%.0f.root",texData[isMC].Data(),ptBins[i]),"recreate");
        outf->cd();
        h->Write();
        hMCSignal->Write();
        hMCSwapped->Write();
        outf->Close();
        delete hMCSwapped;
        delete hMCSignal;
        delete h;
        delete outf;
    }
    cout<<endl;
}
コード例 #11
0
ファイル: runcircular.C プロジェクト: asmagina1995/roottest
int runcircular() {
   int i = 0;
   int j = 1;
   // int k = 2;;
   TTree *master = new TTree("master","master");
   master->Branch("i",&i);
   TTree *slave = new TTree("slave","slave");
   slave->Branch("j",&j);
   for(int s=0; s<10; ++s) master->Fill();
   for(int s=0; s<15; ++s) slave->Fill();
   cout << "Alone\n";
   cout << master->LoadTree(3) << endl;
   cout << master->LoadTree(12) << endl;
   cout << master->LoadTree(20) << endl;

   master->AddFriend(slave);
   cout << "Friend\n";
   cout << master->LoadTree(3) << endl;
   cout << master->LoadTree(12) << endl;
   cout << master->LoadTree(20) << endl;

   slave->AddFriend(master);
   cout << "Indirect Circular\n";
   cout << master->LoadTree(3) << endl;
   cout << master->LoadTree(12) << endl;
   cout << master->LoadTree(20) << endl;

   master->AddFriend(master);
   cout << "Direct Circular\n";
   cout << master->LoadTree(3) << endl;
   cout << master->LoadTree(12) << endl;
   cout << master->LoadTree(20) << endl;

   if (master->LoadTree(20) != -2) {
     cout << "A circular TTree friendship leads to LoadTree incorrectly returning: " << master->LoadTree(20) << " when it should return -2 (out of bound entry)\n";
     return 1;
   }
   return 0; 
}
コード例 #12
0
ファイル: triggerturnon.C プロジェクト: boundino/Dntuple
void triggerturnon()
{
  void plotTurnOn(TTree* inttree, TString triggerpass, TString variable, TString varname, TString varlatex, Int_t BIN_NUM, Double_t BIN_MIN, Double_t BIN_MAX, TString addcut="");
  void plotTurnOnNL1seed(TTree* inttree, TString triggerpass, Int_t BIN_NUM, Double_t BIN_MIN, Double_t BIN_MAX);
  TString infname;
  if(!isPbPb) infname = Form("/export/d00/scratch/jwang/Dmeson/ntD_20151115_DfinderMC_20151115_EvtMatching_Pythia_D0pt%.0fp0_Pthat%.0f_TuneZ2_5020GeV_GENSIM_75x_1015_20151110_ppGlobaTrackingPPmenuHFlowpuv11_MBseed_twang-Pythia_755patch2_v20_MBseed_1116.root",pthat,pthat);
  else infname = Form("/export/d00/scratch/jwang/Dmeson/ntD_20151110_DfinderMC_20151110_EvtMatching_Pyquen_D0tokaonpion_D0pt%.0fp0_Pthat%.0f_TuneZ2_Unquenched_5020GeV_GENSIM_75x_v2_20151110_50k_L1v4_v15_loosecuts_MBseed_1108.root",pthat,pthat);
  //infname = "/export/d00/scratch/jwang/Dmeson/nt_merged_dntuple.root";
  TFile* infile = new TFile(infname);
  TTree* root = (TTree*)infile->Get("ntDkpi");
  root->AddFriend("HltTree");

  if(!isPbPb)
    {
      plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt8_v1&&L1_SingleJet16_BptxAND","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt15_v1&&L1_SingleJet24_BptxAND","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt20_v1&&L1_SingleJet28_BptxAND","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt30_v1&&L1_SingleJet40_BptxAND","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt40_v1&&L1_SingleJet40_BptxAND","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt50_v1&&L1_SingleJet48_BptxAND","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt60_v1&&L1_SingleJet48_BptxAND","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      /*
      plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt10_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt20_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt30_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt40_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt50_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt60_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOnNL1seed(root,"HLT_DmesonPPTrackingGlobal_Dpt10_v1",16,0,80);
      plotTurnOnNL1seed(root,"HLT_DmesonPPTrackingGlobal_Dpt20_v1",16,0,80);
      plotTurnOnNL1seed(root,"HLT_DmesonPPTrackingGlobal_Dpt30_v1",16,0,80);
      plotTurnOnNL1seed(root,"HLT_DmesonPPTrackingGlobal_Dpt40_v1",16,0,80);
      plotTurnOnNL1seed(root,"HLT_DmesonPPTrackingGlobal_Dpt50_v1",16,0,80);
      plotTurnOnNL1seed(root,"HLT_DmesonPPTrackingGlobal_Dpt60_v1",16,0,80);
      */
    }
  else
    {
      plotTurnOn(root,"HLT_DmesonTrackingGlobalPt8_Dpt20_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOn(root,"HLT_DmesonTrackingGlobalPt8_Dpt30_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOn(root,"HLT_DmesonTrackingGlobalPt8_Dpt40_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOn(root,"HLT_DmesonTrackingGlobalPt8_Dpt50_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOn(root,"HLT_DmesonTrackingGlobalPt8_Dpt60_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
      plotTurnOnNL1seed(root,"HLT_DmesonTrackingGlobalPt8_Dpt20_v1",16,0,80);
      plotTurnOnNL1seed(root,"HLT_DmesonTrackingGlobalPt8_Dpt30_v1",16,0,80);
      plotTurnOnNL1seed(root,"HLT_DmesonTrackingGlobalPt8_Dpt40_v1",16,0,80);
      plotTurnOnNL1seed(root,"HLT_DmesonTrackingGlobalPt8_Dpt50_v1",16,0,80);
      plotTurnOnNL1seed(root,"HLT_DmesonTrackingGlobalPt8_Dpt60_v1",16,0,80);
    }
}
コード例 #13
0
ファイル: MillePedeTrees.C プロジェクト: ANSH0712/cmssw
TTree* MillePedeTrees::CreateTree(const char *fileName, const TString &treeNameAdd)
{
  TFile *file = TFile::Open(fileName);
  if (!file) return NULL;

  TString *allTreeNames[] = {&fOrgPos, &fPos, &fMisPos, &fMisPar, &fPar, &fMp};
  const unsigned int nTree = sizeof(allTreeNames) / sizeof(allTreeNames[0]);

  unsigned int iTree = 0;
  TTree *mainTree = NULL;
  do {
    file->GetObject(allTreeNames[iTree]->Data(), mainTree);
    if (!mainTree) {
      ::Error("MillePedeTrees::CreateTree",
              "no tree %s in %s", allTreeNames[iTree]->Data(), fileName);
    } 
    *(allTreeNames[iTree]) += treeNameAdd; // Yes, we really change the data members!
    if (mainTree && !treeNameAdd.IsNull()) {
      mainTree->SetName(*(allTreeNames[iTree]));
    }
    ++iTree;
  } while (!mainTree && iTree < nTree);

  if (mainTree) {
    for (unsigned int jTree = iTree; jTree < nTree; ++jTree) {
      const TString newName(*(allTreeNames[jTree]) + treeNameAdd);
// either by really renaming trees: 
//       TTree *tree = NULL;
//       file->GetObject(allTreeNames[jTree]->Data(), tree);
//       if (!tree) {
//         ::Error("MillePedeTrees::CreateTree",
//                 "no tree %s in %s", allTreeNames[jTree]->Data(), fileName);
//       } else {
//         tree->SetName(newName);
//         mainTree->AddFriend(tree, "", true); // no alias, but warn if different lengths
//       }
// or by setting an alias:
      TFriendElement *fEle = mainTree->AddFriend(newName + " = " + *(allTreeNames[jTree]));
      if (!fEle || !fEle->GetTree()) {
        ::Error("MillePedeTrees::CreateTree","no %s as friend tree",allTreeNames[jTree]->Data());
       } 
      *(allTreeNames[jTree]) = newName; // Yes, we really change the data members!
    }
    mainTree->SetEstimate(mainTree->GetEntries()); // for secure use of GetV1() etc.  
  }

  return mainTree;
}
コード例 #14
0
ファイル: triggerturnonFast.C プロジェクト: boundino/Dntuple
void triggerturnonFast(TString trigger="HLT_DmesonPPTrackingGlobal_Dpt20_v1")
{
  TH1D* getYield(TTree* nt, TString triggerpass, TString triggername, TString prescale, TString variable, TString varname, TString varlatex, Int_t BIN_NUM, Double_t BIN_MIN, Double_t BIN_MAX, TString addcut="");
  void plotTurnOn(TH1D* hnominator, TH1D* hdenominator, TString triggerlegend, TString triggername, TString varname, TString varlatex, Int_t BIN_NUM, Double_t BIN_MIN, Double_t BIN_MAX);

  TString infname;
  infname = "/data/dmeson2015/Dntuple/ntD_BigMergeExpressHiForest_run262163-run262252_match.root";
  //infname = "/data/dmeson2015/Dntuple/Dntuple_run262163_262165_262167_262172.root";
  TFile* infile = new TFile(infname);
  TTree* root = (TTree*)infile->Get("ntDkpi");
  root->AddFriend("HltTree",infname);

  TH1D* hpp_pt = getYield(root,"","","","Dpt","pt","p_{T} (GeV/c)",16,0,80);
  TH1D* hpp_pt_Hlt = getYield(root,Form("&&%s",trigger.Data()),Form("_%s",trigger.Data()),Form("*%s_Prescl",trigger.Data()),"Dpt","pt","p_{T} (GeV/c)",16,0,80);
  plotTurnOn(hpp_pt_Hlt,hpp_pt,trigger,Form("_%s",trigger.Data()),"pt","p_{T} (GeV/c)",16,0,80);
}
コード例 #15
0
void addDiMuMassPrimeBranchZPt(DiMuPlottingSystem* dps)
{
  TTree* newtree = new TTree("newtree", "new tree");
  newtree->AddFriend(dps->treename, dps->infilename);

  TBranch *newBranch = newtree->Branch("recoCandMassPrime",&dps->recoCandMassPrime,"recoCandMassPrime/F");

  Int_t nentries = dps->tree->GetEntries();
  std::cout << "nentries: " << nentries << std::endl;
  for (Int_t i = 0; i < nentries; i++)
    {
      dps->tree->GetEntry(i);
      if(dps->recoCandPt > 20 && dps->recoCandPt < 60) dps->recoCandMassPrime = dps->recoCandMass + 0.0000917686*(dps->recoCandPt*dps->recoCandPt)*TMath::Sin(-6.43015*TMath::Sqrt(dps->recoCandPt) + 0.210496);
      else dps->recoCandMassPrime = dps->recoCandMass;
      newBranch->Fill();
    }
  dps->tree = newtree;
}
コード例 #16
0
ファイル: zeeAna.C プロジェクト: CmsHI/CVS_SavedFMa
void zeeAnaDiff(TH1D* hsee, TCut addCut,TH1D* hseeMc) {
  
  TFile *f1=new TFile(fname1.Data());
  TTree *zp = (TTree*)f1->Get("tz");
  zp->AddFriend("yEvt=yongsunHiEvt"       ,fname1.Data());
  zp->AddFriend("ySkim=yongsunSkimTree"   ,fname1.Data());
  zp->AddFriend("yHlt=yongsunHltTree"     ,fname1.Data());
  zp->AddFriend("tgj",                     fname1.Data());
  
  TH1D* hmass = new TH1D("hmass",";inv. mass (GeV);event fraction",34,30,200);
  hmass->Sumw2();

  zp->Draw("invm>>hmass",addCut && "isEle1==1 && isEle2==1");
  TH1D* htemp = (TH1D*)hsee->Clone("htemp");   htemp->Reset();
  zp->Draw("see1>>htemp",addCut && "isEle1==1 && isEle2==1" && "invm>80 && invm<100" );
  hsee->Reset();
  hsee->Add(htemp);
  handsomeTH1(hmass,2);
  scaleInt(hmass);
  
  TH1D* htempMC;
  TFile *f1mc;
  TTree *zpmc ;
  f1mc=new TFile(fname1MC.Data());
  zpmc = (TTree*)f1mc->Get("tz");
  zpmc->AddFriend("yEvt=yongsunHiEvt"       ,fname1MC.Data());
  zpmc->AddFriend("ySkim=yongsunSkimTree"   ,fname1MC.Data());
  zpmc->AddFriend("yHlt=yongsunHltTree"     ,fname1MC.Data());
  zpmc->AddFriend("yPho=yongsunPhotonTree"     ,fname1MC.Data());
  zpmc->AddFriend("tgj",                     fname1MC.Data());
  hseeMc->Sumw2();
  htempMC = (TH1D*)hseeMc->Clone("htempMc");   htempMC->Reset();
  TH1D* hmassMC = new TH1D("hmassMC11",";inv. mass (GeV);event fraction",34,30,200);
  hmassMC->Sumw2();
  zpmc->Draw("invm>>hmassMC11",Form("(%s) *yPho.ncoll",addCut.GetTitle()));
  zpmc->Draw("see1>>htempMc",Form("(%s) *yPho.ncoll", (addCut && "invm>80 && invm<100").GetTitle()) );
  hseeMc->Reset();
  hseeMc->Add(htempMC);
  handsomeTH1(hmassMC,1);
  scaleInt(hmassMC);
  
  
  hmassMC->SetAxisRange(0,0.6,"Y");
  hmassMC->DrawCopy();
  hmass->DrawCopy("same");                                                                                             
  TLegend* leg1 =  new TLegend(0.5580645,0.5381356,0.8923387,0.7648305,NULL,"brNDC");
  easyLeg(leg1,"Z->ee mass");
  leg1->AddEntry(hmass,"DATA","pl");
  leg1->AddEntry(hmassMC,"MC","pl");
  leg1->Draw();
  
}
コード例 #17
0
ファイル: quickDphi.C プロジェクト: CmsHI/gammaJetAnalysis
void quickDphi()
{
  TH1::SetDefaultSumw2();
  
  TFile *pAFile = TFile::Open("gammaJets_pA_Data.root");
  TTree *jets = (TTree*)pAFile->Get("jetTree");
  jets->AddFriend("photonTree","gammaJets_pA_Data.root");

  TH1D *hfp20 = new TH1D("hfp20",";#Delta #phi_{J#gamma}", 50, 0, TMath::Pi());
  TH1D *hfl20 = (TH1D*)hfp20->Clone("hfl20");

  TCut anaCut = "photonTree.hadronicOverEm<0.1 && abs(photonTree.eta)<1.44 && abs(jetTree.eta)<1.6 && jetTree.pt>30 && photonTree.ecalRecHitSumEtConeDR04 <4.2  &&  photonTree.hcalTowerSumEtConeDR04 < 2.2  &&  photonTree.trkSumPtHollowConeDR04 < 2";

  // jets->Project("hfl20","dPhi",anaCut&&"(photonTree.HFplusEta4+photonTree.HFminusEta4 < 20)");
  // jets->Project("hfp20","dPhi",anaCut&&"(photonTree.HFplusEta4+photonTree.HFminusEta4 > 20)");
  jets->Project("hfl20","dPhi",anaCut&&"(photonTree.pt > 40)");
  jets->Project("hfp20","dPhi",anaCut&&"(photonTree.pt > 60)");
  
  hfp20->Scale(1./hfp20->GetEntries());
  hfl20->Scale(1./hfl20->GetEntries());

  TCanvas *c1 = new TCanvas();
  c1->SetLogy();

  // hfp20->Draw();
  // hfp20->GetXaxis()->CenterTitle();
  // hfl20->SetMarkerColor(kBlue);
  // hfl20->SetLineColor(kBlue);
  // hfl20->Draw("same");

  // TLegend *leg = new TLegend(0.15,0.5,0.5,0.8);
  // leg->SetFillColor(0);
  // // leg->AddEntry(hfp20,"E^{HF |#eta|>4} > 20","l");
  // // leg->AddEntry(hfl20,"E^{HF |#eta|>4} < 20","l");
  // leg->AddEntry(hfp20,"#gamma p_{T} > 60GeV","l");
  // leg->AddEntry(hfl20,"#gamma p_{T} > 40GeV","l");
  // leg->Draw();

  TH1D *ratio = (TH1D*)hfp20->Clone("ratio");
  //ratio->SetYTitle("(E^{HF |#eta|>4} > 20)/(E^{HF |#eta|>4} < 20)");
  ratio->Divide(hfp20,hfl20,1,1);
  ratio->Draw();
}
コード例 #18
0
ファイル: proc_6380.C プロジェクト: ktf/AliPhysics
void proc_6380()
{
  const std::vector<std::string> triggerNames{
    "c2TVX",
    "c2VBAandVBC",
    "c2UBAandUBC",

    "c2T0AandNotT0C",
    "c2T0CandNotT0A",

    "c2VBAandNotVBC",
    "c2VBCandNotVBA",

    "c2UBAandNotUBC",
    "c2UBCandNotUBA"
  };

  const AliVdMMetaData vdmMetaData(AliVdMMetaData::GetFileName("6380/6380.xml"));

  TFile::Open(AliVdMMetaData::GetFileName("6380/vdm_time_6380_5m11.5_11p17.5_1_v3.root"), "READ");
  gDirectory->ls();
  TTree * VdM = nullptr;
  gFile->GetObject("VdM", VdM);
  VdM->AddFriend("DDL2", AliVdMMetaData::GetFileName("6380/vdm_DDL2_6380-5m11.5_11p17.5_1_v3.root"));

  vdmScanData.FillDefaultBranches(vdmMetaData, VdM, triggerNames);
  proc(vdmMetaData, vdmScanData, triggerNames);

  // (3) determine pile-up
  proc_pileup(vdmMetaData, vdmScanData,
              "c2UBAandUBC", "c2UBAandNotUBC", "c2UBCandNotUBA",
              {0.49,0.17, 1.5e-5,1.5e-5});

  proc_pileup(vdmMetaData, vdmScanData,
              "c2VBAandVBC", "c2VBAandNotVBC", "c2VBCandNotVBA",
              {0.070,0.086, 4.2e-5,4.6e-5});

  proc_pileup(vdmMetaData, vdmScanData,
              "c2TVX", "c2T0AandNotT0C", "c2T0CandNotT0A",
              {0.57,0.63, 2.2e-5,3.8e-5});
}
コード例 #19
0
ファイル: treefriend.C プロジェクト: adevress/root-1
void CompareTrees() {
   // The two TTrees created above are compared.
   // The subset of entries in the small TTree must be identical
   // to the entries in the original TTree.
   
   TFile *f = new TFile("treeparent.root");
   TTree *T  = (TTree*)f->Get("T");
   TFile *ff = new TFile("treefriend.root");
   TTree *TF = (TTree*)ff->Get("TF");
   Int_t fRun,fEvent;
   Float_t fx,fy,fz;
   T->SetBranchAddress("Run",&Run);
   T->SetBranchAddress("Event",&Event);
   T->SetBranchAddress("x",&x);
   T->SetBranchAddress("y",&y);
   T->SetBranchAddress("z",&z);
   TF->SetBranchAddress("Run",&fRun);
   TF->SetBranchAddress("Event",&fEvent);
   TF->SetBranchAddress("x",&fx);
   TF->SetBranchAddress("y",&fy);
   TF->SetBranchAddress("z",&fz);
   T->AddFriend(TF);
   
   Long64_t nentries = T->GetEntries();
   Int_t nok = 0;
   for (Long64_t i=0;i<nentries;i++) {
      T->GetEntry(i);
      if (fRun == Run && fEvent==Event && x==fx && y==fy &&z==fz) {
         nok++;
      } else {
         if (TF->GetEntryWithIndex(Run,Event) > 0) {
            if (i <100) printf("i=%lld, Run=%d, Event=%d, x=%g, y=%g, z=%g,  : fRun=%d, fEvent=%d, fx=%g, fy=%g, fz=%g\n",i,Run,Event,x,y,z,fRun,fEvent,fx,fy,fz);
         } 
      } 
   }
   printf("nok = %d, fentries=%lld\n",nok,TF->GetEntries());

   delete f;
   delete ff;
}
コード例 #20
0
ファイル: CompareEff.C プロジェクト: CmsHI/CVS_SavedFMa
void CompareEff(TCut mycut = "etree.hiBin>=20",
                TString infdataname="/d01/velicanu/tmp/reprocessed-openhlt-182382.root",
                TString infrefname="/d01/velicanu/tmp/reprocessed-openhlt-181985.root",
                TString tag="182382v181985",
                TString newtitle="Run 182382",
                TString oldtitle="Run 181985"
                )
{
   TH1::SetDefaultSumw2();
   
   // inputs
   TFile * infdata = TFile::Open(infdataname);
   TFile * infref = TFile::Open(infrefname);
   
   TTree * tdata = (TTree*)infdata->Get("hltanalysis/HltTree");
   tdata->AddFriend("skim=skimanalysis/HltTree");
   tdata->AddFriend("etree=hiEvtAnalyzer/HiTree");
   tdata->AddFriend("icPu5=icPu5JetAnalyzer/t");
   TTree * tref = (TTree*)infref->Get("hltanalysis/HltTree");
   tref->AddFriend("skim=skimanalysis/HltTree");
   tref->AddFriend("etree=hiEvtAnalyzer/HiTree");
   tref->AddFriend("icPu5=icPu5JetAnalyzer/t");
   
   TCut sel="HLT_HIMinBiasHfOrBSC_v1&&skim.pcollisionEventSelection"&&mycut;
   TCut selref="HLT_HIMinBiasHfOrBSC_v1&&skim.pcollisionEventSelection"&&mycut;
   float nSel = tdata->GetEntries(sel);
   float nSelRef = tref->GetEntries(selref);
   cout << "Data: " << TString(sel) << " " << nSel << endl;
   cout << "Ref:  " << TString(selref) << " " << nSelRef << endl;

   TCanvas * c0 = new TCanvas("c0","c0",500,500);
   tdata->Draw("etree.hiBin",sel,"hist");
   tref->Draw("etree.hiBin",selref,"same hist");
   
   // histograms
   TCanvas * c2 = new TCanvas(tag+"c2","c2",500,500);
   Compare comp2("hL1Eff",tdata,tref,sel,selref);
   comp2.Init(40,10,90);
   tdata->Draw("L1_SingleJet36_BptxAND:icPu5.jtpt[0]",sel,"prof");
   comp2.Project("L1_SingleJet36_BptxAND:Max$(icPu5.jtpt*(abs(icPu5.jteta)<3&&icPu5.jtpt>25))>>","prof");
   comp2.Draw(";Reco Jet p_{T} (GeV)/c;#epsilon",0,1.2,newtitle,oldtitle);
   c2->Print("out/trigVal/trigeff"+tag+"_peri.gif");
   
   //PrintRateJet(infdataname);
}
コード例 #21
0
ファイル: fitBss.C プロジェクト: KiSooLee/Bntuple
void fitBss(TString infname="",bool doweight = 1)
{
  if (doweight==0) weight="1";
  if (infname=="") infname=inputdata.Data();
  TFile *inf = new TFile(infname.Data());
  TTree *nt = (TTree*) inf->Get("ntKp");

  TFile *infMC = new TFile(inputmc.Data());
  TTree *ntGen = (TTree*)infMC->Get("ntGen");
  TTree *ntGen2 = (TTree*)inf->Get("ntGen");
  TTree *ntMC = (TTree*)infMC->Get("ntKp");
    
  ntGen->AddFriend(ntMC);
  ntGen2->AddFriend(ntMC);
    
  const int nBins = 1;
  double ptBins[nBins+1] = {10,60};
  for (int i=0;i<nBins;i++)
    {
      TF1 *f = fit(nt,ntMC,ptBins[i],ptBins[i+1]);
    }
  
}
コード例 #22
0
void matching_l12forest()
{
  //const TString l1_input = "/export/d00/scratch/luck/L1Tree_minbias_chunk1.root";
  const TString l1_input = "/mnt/hadoop/cms/store/user/luck/L1Emulator/L1Tree_MinBiasSkim_v1.root";
  TFile *lFile = TFile::Open(l1_input);
  TTree *lTree = (TTree*)lFile->Get("l1ExtraTreeProducer/L1ExtraTree");
  TTree *lEvtTree = (TTree*)lFile->Get("l1NtupleProducer/L1Tree");

  l1ExtraTree *l1extra = new l1ExtraTree(lTree);
  l1Tree *l1 = new l1Tree(lEvtTree);

  //const TString forest_input = "/mnt/hadoop/cms/store/user/velicanu/HIMinBias2011_GR_R_53_LV6_CMSSW_5_3_16_Forest_Track8_Jet21/0.root";
  const TString forest_input = "/mnt/hadoop/cms/store/user/luck/L1Emulator/minbiasForest_merged/0.root";
  TFile *fFile = TFile::Open(forest_input);
  TTree *fTree = (TTree*)fFile->Get("anaTrack/trackTree");
  TTree *fEvtTree = (TTree*)fFile->Get("hiEvtAnalyzer/HiTree");
  fTree->AddFriend(fEvtTree);
  TTree *fSkimTree = (TTree*)fFile->Get("skimanalysis/HltTree");
  fTree->AddFriend(fSkimTree);

  Int_t f_evt, f_run, f_lumi, hiBin;
  fTree->SetBranchAddress("evt",&f_evt);
  fTree->SetBranchAddress("run",&f_run);
  fTree->SetBranchAddress("lumi",&f_lumi);
  fTree->SetBranchAddress("hiBin",&hiBin);

  Int_t pcollisionEventSelection, pHBHENoiseFilter;
  fTree->SetBranchAddress("pcollisionEventSelection",&pcollisionEventSelection);
  fTree->SetBranchAddress("pHBHENoiseFilter",&pHBHENoiseFilter);

  const unsigned int MAXTRACKS = 20000;
  Int_t nTrk;
  Float_t trkPt[MAXTRACKS], trkPtError[MAXTRACKS];
  Bool_t highPurity[MAXTRACKS];
  Float_t trkDxy1[MAXTRACKS], trkDxyError1[MAXTRACKS], trkDz1[MAXTRACKS], trkDzError1[MAXTRACKS];

  fTree->SetBranchAddress("nTrk",&nTrk);
  fTree->SetBranchAddress("trkPt",trkPt);
  fTree->SetBranchAddress("trkPtError",trkPtError);
  fTree->SetBranchAddress("highPurity",highPurity);
  fTree->SetBranchAddress("trkDxy1",trkDxy1);
  fTree->SetBranchAddress("trkDxyError1",trkDxyError1);
  fTree->SetBranchAddress("trkDz1",trkDz1);
  fTree->SetBranchAddress("trkDzError1",trkDzError1);

  TFile *outFile = new TFile("hist_out_tracks.root","RECREATE");

  map<long, int> kmap;
  int l_entries = lEvtTree->GetEntries();
  for(long j = 0; j < l_entries; ++j)
  {
    l1->GetEntry(j);
    long key = makeKey(l1->run, l1->lumi, l1->event);

    pair<long,int> p(key,j);
    kmap.insert(p);
  }

  outFile->cd();

  const int nBins = 150;
  const double maxPt = 300;

  TH1D *l1TrkPt = new TH1D("l1TrkPt",";L1 Trk p_{T} (GeV)",nBins,0,maxPt);
  TH1D *fTrkPt[2];
  fTrkPt[0] = new TH1D("fTrkPt_cen",";offline Trk p_{T}",nBins,0,maxPt);
  fTrkPt[1] = (TH1D*)fTrkPt[0]->Clone("fTrkPt_periph");
  TH1D *accepted[4][2];
  accepted[0][0] = new TH1D("accepted_pt0_cen",";offline Trk p_{T}",nBins,0,maxPt);
  accepted[1][0] = (TH1D*)accepted[0][0]->Clone("accepted_pt15_cen");
  accepted[2][0] = (TH1D*)accepted[0][0]->Clone("accepted_pt30_cen");
  accepted[3][0] = (TH1D*)accepted[0][0]->Clone("accepted_pt60_cen");
  accepted[0][1] = (TH1D*)accepted[0][0]->Clone("accepted_pt0_periph");
  accepted[1][1] = (TH1D*)accepted[0][0]->Clone("accepted_pt15_periph");
  accepted[2][1] = (TH1D*)accepted[0][0]->Clone("accepted_pt30_periph");
  accepted[3][1] = (TH1D*)accepted[0][0]->Clone("accepted_pt60_periph");
  TH2D *corr = new TH2D("corr","pt;l1 pt",nBins,0,maxPt,nBins,0,maxPt);

  int count = 0;

  int entries = fTree->GetEntries();
  for(long j = 0; j < entries; ++j)
  {
    if(j % 10000 == 0)
      printf("%ld / %d\n",j,entries);

    fTree->GetEntry(j);
    long key = makeKey(f_run, f_lumi, f_evt);

    map<long,int>::const_iterator got = kmap.find(key);
    if(got == kmap.end() ) {
      continue;
    } else {
      l1extra->GetEntry(got->second);
      kmap.erase(key);

      Float_t maxl1pt = 0;
      if(l1extra->nTauJets > 0)
	maxl1pt = l1extra->tauJetEt[0];

      Float_t maxtrkpt = 0;
      for(int i = 0; i < nTrk; ++i)
      {
	bool goodTrack = (highPurity[i] &&
			  TMath::Abs(trkDz1[i]/trkDzError1[i]) < 3 &&
			  TMath::Abs(trkDxy1[i]/trkDxyError1[i]) < 3 &&
			  trkPtError[i]/trkPt[i] < 0.05);

	if(goodTrack)
	{
	  if(trkPt[i] > maxtrkpt)
	    maxtrkpt = trkPt[i];
	}
      }

      l1TrkPt->Fill(maxl1pt);
      if((pcollisionEventSelection == 1) && (pHBHENoiseFilter == 1))
      {
	if(hiBin < 60)
	  fTrkPt[0]->Fill(maxtrkpt);
	else if (hiBin >= 100)
	  fTrkPt[1]->Fill(maxtrkpt);

	corr->Fill(maxtrkpt,maxl1pt);

	for(int k = 0; k < 4; ++k){
	  if(maxl1pt>L1_THRESHOLD[k])
	  {
	    if(hiBin < 60)
	      accepted[k][0]->Fill(maxtrkpt);
	    else if (hiBin >= 100)
	      accepted[k][1]->Fill(maxtrkpt);
	  }
	}

      }
      count++;
    }

    // for(std::vector<double>::const_iterator it = l1extra->cenTrkEt.begin(); it != l1extra->cenTrkEt.end(); ++it)
    // {
    //   printf("%lf\n",*it);
    // }
    // //printf("%d\n",l1_run);
    //if(j > 10) break;
  }

  TGraphAsymmErrors *a[4][2];
  for(int k = 0; k < 4; ++k){
    for(int l = 0; l < 2; ++l)
    {
      a[k][l] = new TGraphAsymmErrors();
      a[k][l]->BayesDivide(accepted[k][l],fTrkPt[l]);
    }
  }
  a[0][0]->SetName("asymm_pt_0_cen");
  a[1][0]->SetName("asymm_pt_15_cen");
  a[2][0]->SetName("asymm_pt_30_cen");
  a[3][0]->SetName("asymm_pt_60_cen");
  a[0][1]->SetName("asymm_pt_0_periph");
  a[1][1]->SetName("asymm_pt_15_periph");
  a[2][1]->SetName("asymm_pt_30_periph");
  a[3][1]->SetName("asymm_pt_60_periph");


  // TCanvas *c1 = new TCanvas();
  // l1TrkPt->Draw();
  // TCanvas *c2 = new TCanvas();
  // fTrkPt->Draw();
  // TCanvas *c3 = new TCanvas();
  // a->Draw("p A");

  //outFile->cd();
  l1TrkPt->Write();
  fTrkPt[0]->Write();
  fTrkPt[1]->Write();
  corr->Write();
  for(int k = 0; k < 4; ++k){
    for(int l = 0; l < 2; ++l)
    {
      accepted[k][l]->Write();
      a[k][l]->Write();
    }
  }

  printf("Matching entries: %d\n",count);

  lFile->Close();
  fFile->Close();
  outFile->Close();
}
コード例 #23
0
void MCefficiencyCent(int isPbPb=0,TString inputmc="/data/wangj/MC2015/Dntuple/pp/revised/ntD_pp_Dzero_kpi_prompt/ntD_EvtBase_20160303_Dfinder_20160302_pp_Pythia8_prompt_D0_dPt0tkPt0p5_pthatweight.root", TString selmcgen="((GisSignal==1||GisSignal==2)&&(Gy>-1&&Gy<1))",TString selmcgenacceptance="((GisSignal==1||GisSignal==2)&&(Gy>-1&&Gy<1))&&abs(Gtk1eta)<2.0&&abs(Gtk2eta)<2.0&&Gtk1pt>2.0&&Gtk2pt>2.0", TString cut_recoonly="Dy>-1.&&Dy<1.&&Dtrk1highPurity&&Dtrk2highPurity&&Dtrk1Pt>2.0&&Dtrk2Pt>2.0&&Dtrk1PtErr/Dtrk1Pt<0.1&&Dtrk2PtErr/Dtrk2Pt<0.1&&abs(Dtrk1Eta)<2.0&&abs(Dtrk2Eta)<2.0&&Dtrk1Algo>3&&Dtrk1Algo<8&&(Dtrk1PixelHit+Dtrk1StripHit)>=11", TString cut="Dy>-1.&&Dy<1.&&Dtrk1highPurity&&Dtrk2highPurity&&Dtrk1Pt>2.0&&Dtrk2Pt>2.0&&(DsvpvDistance/DsvpvDisErr)>3.5&&(DlxyBS/DlxyBSErr)>1.5&&Dchi2cl>0.05&&Dalpha<0.12&&Dtrk1PtErr/Dtrk1Pt<0.1&&Dtrk2PtErr/Dtrk2Pt<0.1&&abs(Dtrk1Eta)<2.0&&abs(Dtrk2Eta)<2.0&&Dtrk1Algo>3&&Dtrk1Algo<8&&Dtrk2Algo>3&&Dtrk2Algo<8&&(Dtrk1PixelHit+Dtrk1StripHit)>=11&&(Dtrk1Chi2ndf/(Dtrk1nStripLayer+Dtrk1nPixelLayer)<0.15)&&(Dtrk2Chi2ndf/(Dtrk2nStripLayer+Dtrk2nPixelLayer)<0.15)",TString label="PP",TString outputfile="test", int useweight=1,Float_t centmin=0., Float_t centmax=100.)
{ 
 
  hiBinMin = centmin*2;
  hiBinMax = centmax*2;
  centMin = centmin;
  centMax = centmax;
  
  if(isPbPb==1)
    {
      selmcgen = selmcgen+Form("&&hiBin>=%f&&hiBin<=%f",hiBinMin,hiBinMax);
      selmcgenacceptance=selmcgenacceptance+Form("&&hiBin>=%f&&hiBin<=%f",hiBinMin,hiBinMax);
      cut_recoonly=cut_recoonly+Form("&&hiBin>=%f&&hiBin<=%f",hiBinMin,hiBinMax);
      cut=cut+Form("&&hiBin>=%f&&hiBin<=%f",hiBinMin,hiBinMax);
    }

     std::cout<<"selmcgen="<<selmcgen<<std::endl;
     std::cout<<"selmcgenacceptance="<<selmcgenacceptance<<std::endl;
     std::cout<<"cut_recoonly"<<cut_recoonly<<std::endl;
     std::cout<<"cut="<<cut<<std::endl;

   std::cout<<"option="<<useweight<<std::endl;
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetEndErrorSize(0);
  gStyle->SetMarkerStyle(20);
 
  TFile* infMC = new TFile(inputmc.Data());
  TTree* ntMC = (TTree*)infMC->Get("ntKp");
  TTree* ntGen = (TTree*)infMC->Get("ntGen");
  TTree* ntSkim = (TTree*)infMC->Get("ntSkim");
  TTree* ntmvaTree = (TTree*)infMC->Get("mvaTree");
  TTree* ntHlt = (TTree*)infMC->Get("ntHlt");

  ntMC->AddFriend(ntmvaTree);
  ntMC->AddFriend(ntGen);
  ntMC->AddFriend(ntSkim);
  ntMC->AddFriend(ntHlt);

  TTree* nthi = (TTree*)infMC->Get("ntHi");
  ntGen->AddFriend(nthi);
  ntGen->AddFriend(ntSkim);
  ntGen->AddFriend(ntHlt);
  nthi->AddFriend(ntMC);
  ntMC->AddFriend(nthi);

  // optimal weigths
  TCut weighpthat = "1";
  TCut weightGpt = "1";
  TCut weightBgenpt = "1";
  TCut weightHiBin = "1";
  if(useweight==0) {
    weightfunctiongen="1";
    weightfunctionreco="1";
    weighpthat = "pthatweight";
    weightGpt = "(pow(10,-0.094152+0.008102*Gpt+Gpt*Gpt*0.000171+Gpt*Gpt*Gpt*-0.000005+Gpt*Gpt*Gpt*Gpt*-0.000000+Gpt*Gpt*Gpt*Gpt*Gpt*0.000000))";
    weightBgenpt = "(pow(10,-0.094152+0.008102*Bgenpt+Bgenpt*Bgenpt*0.000171+Bgenpt*Bgenpt*Bgenpt*-0.000005+Bgenpt*Bgenpt*Bgenpt*Bgenpt*-0.000000+Bgenpt*Bgenpt*Bgenpt*Bgenpt*Bgenpt*0.000000))";
    }
  
  if(useweight==1) {
    weightfunctiongen="6.08582+hiBin*(-0.155739)+hiBin*hiBin*(0.00149946)+hiBin*hiBin*hiBin*(-6.41629e-06)+hiBin*hiBin*hiBin*hiBin*(1.02726e-08)";
    weightfunctionreco="6.08582+hiBin*(-0.155739)+hiBin*hiBin*(0.00149946)+hiBin*hiBin*hiBin*(-6.41629e-06)+hiBin*hiBin*hiBin*hiBin*(1.02726e-08)";
    weighpthat = "pthatweight";
    weightGpt = "(pow(10,-0.107832+0.010248*Gpt+Gpt*Gpt*0.000079+Gpt*Gpt*Gpt*-0.000003+Gpt*Gpt*Gpt*Gpt*-0.000000+Gpt*Gpt*Gpt*Gpt*Gpt*0.000000))";
    weightBgenpt = "(pow(10,-0.107832+0.010248*Bgenpt+Bgenpt*Bgenpt*0.000079+Bgenpt*Bgenpt*Bgenpt*-0.000003+Bgenpt*Bgenpt*Bgenpt*Bgenpt*-0.000000+Bgenpt*Bgenpt*Bgenpt*Bgenpt*Bgenpt*0.000000))";
    weightHiBin = "(6.08582+hiBin*(-0.155739)+hiBin*hiBin*(0.00149946)+hiBin*hiBin*hiBin*(-6.41629e-06)+hiBin*hiBin*hiBin*hiBin*(1.02726e-08))";
    }

  std::cout<<"fit function parameters="<<weightfunctiongen<<std::endl;

  TH1D* hPtMC = new TH1D("hPtMC","",_nBins,_ptBins);
  TH1D* hPtMCrecoonly = new TH1D("hPtMCrecoonly","",_nBins,_ptBins);
  TH1D* hPtGen = new TH1D("hPtGen","",_nBins,_ptBins);
  TH1D* hPtGenAcc = new TH1D("hPtGenAcc","",_nBins,_ptBins);
  TH1D* hPtGenAccWeighted = new TH1D("hPtGenAccWeighted","",_nBins,_ptBins);
  TH1D* hPthat = new TH1D("hPthat","",100,0,500);
  TH1D* hPthatweight = new TH1D("hPthatweight","",100,0,500);

  //ntMC->Project("hPtMC","hiBin",TCut(weightfunctionreco)*(TCut(cut.Data())&&"(Bgen==23333)"));
  ntMC->Project("hPtMC","hiBin",TCut(weighpthat)*TCut(weightBgenpt)*TCut(weightHiBin)*(TCut(cut.Data())&&"(Bgen==23333)"));
  divideBinWidth(hPtMC);
  //ntMC->Project("hPtMCrecoonly","hiBin",TCut(weightfunctionreco)*(TCut(cut_recoonly.Data())&&"(Bgen==23333)"));
  ntMC->Project("hPtMCrecoonly","hiBin",TCut(weighpthat)*TCut(weightBgenpt)*TCut(weightHiBin)*(TCut(cut_recoonly.Data())&&"(Bgen==23333)"));
  divideBinWidth(hPtMCrecoonly);
  //ntGen->Project("hPtGen","hiBin",(TCut(selmcgen.Data())));
  ntGen->Project("hPtGen","hiBin",TCut(weighpthat)*TCut(weightGpt)*(TCut(selmcgen.Data())));
  divideBinWidth(hPtGen);
  //ntGen->Project("hPtGenAcc","hiBin",(TCut(selmcgenacceptance.Data())));
  ntGen->Project("hPtGenAcc","hiBin",TCut(weighpthat)*TCut(weightGpt)*(TCut(selmcgenacceptance.Data())));
  divideBinWidth(hPtGenAcc);
  //ntGen->Project("hPtGenAccWeighted","hiBin",TCut(weightfunctiongen)*(TCut(selmcgenacceptance.Data())));
  ntGen->Project("hPtGenAccWeighted","hiBin",TCut(weighpthat)*TCut(weightGpt)*TCut(weightHiBin)*(TCut(selmcgenacceptance.Data())));
  divideBinWidth(hPtGenAccWeighted);

  ntMC->Project("hPthat","pthat","1");
  ntMC->Project("hPthatweight","pthat",TCut("1"));

  hPtMC->Sumw2();
  hPtGenAcc->Sumw2();
  hPtMCrecoonly->Sumw2();
  //Acceptance
  TH1D* hEffAcc = (TH1D*)hPtGenAcc->Clone("hEffAcc");
  hEffAcc->Sumw2();
  hEffAcc->Divide(hEffAcc,hPtGen,1,1,"b");
  //Selection
  TH1D* hEffSelection = (TH1D*)hPtMC->Clone("hEffSelection");
  hEffSelection->Sumw2();
  hEffSelection->Divide(hEffSelection,hPtGenAccWeighted,1,1,"b");
  //Acc * Eff (one shot)
  TH1D* hEffReco = (TH1D*)hPtMCrecoonly->Clone("hEffReco");
  hEffReco->Sumw2();
  hEffReco->Divide(hEffReco,hPtGen,1,1,"b");
  //Acc * Eff
  TH1D* hEff = (TH1D*)hEffSelection->Clone("hEff");
  hEff->Sumw2();
  //hEff->Divide(hPtMC,hPtGen,1,1,"");
  hEff->Multiply(hEff,hEffAcc,1,1);

  TH2F* hemptyEff=new TH2F("hemptyEff","",50,_ptBins[0]-5.,_ptBins[_nBins]+5.,10.,0,1.0);  
  hemptyEff->GetXaxis()->CenterTitle();
  hemptyEff->GetYaxis()->CenterTitle();
  //hemptyEff->GetYaxis()->SetTitle("acceptance x #epsilon_{reco} x #epsilon_{sel} ");
  hemptyEff->GetYaxis()->SetTitle("#alpha x #epsilon");
  hemptyEff->GetXaxis()->SetTitle("Centrality");
  hemptyEff->GetXaxis()->SetTitleOffset(0.9);
  hemptyEff->GetYaxis()->SetTitleOffset(0.95);
  hemptyEff->GetXaxis()->SetTitleSize(0.05);
  hemptyEff->GetYaxis()->SetTitleSize(0.05);
  hemptyEff->GetXaxis()->SetTitleFont(42);
  hemptyEff->GetYaxis()->SetTitleFont(42);
  hemptyEff->GetXaxis()->SetLabelFont(42);
  hemptyEff->GetYaxis()->SetLabelFont(42);
  hemptyEff->GetXaxis()->SetLabelSize(0.035);
  hemptyEff->GetYaxis()->SetLabelSize(0.035);  
  hemptyEff->SetMaximum(2);
  hemptyEff->SetMinimum(0.);
  hemptyEff->Draw();

  TH2F* hemptyEffAcc=(TH2F*)hemptyEff->Clone("hemptyEffAcc");
  TH2F* hemptyEffReco=(TH2F*)hemptyEff->Clone("hemptyEffReco");
  TH2F* hemptyEffSelection=(TH2F*)hemptyEff->Clone("hemptyEffSelection");
 

  TCanvas*canvasEff=new TCanvas("canvasEff","canvasEff",1000.,500);
  canvasEff->Divide(2,1);
  canvasEff->cd(1);
  
  hemptyEffAcc->SetYTitle("#alpha");
  hemptyEffAcc->Draw();
  hEffAcc->Draw("same");
  canvasEff->cd(2);
  hemptyEff->Draw();
  hEff->Draw("same");
  canvasEff->SaveAs(Form("plotEff/canvasEff_study%s_Cent.pdf",Form(label.Data())));
  
  TH2F* hemptyPthat=new TH2F("hemptyPthat","",50,0.,500.,10,1e-5,1e9);  
  hemptyPthat->GetXaxis()->CenterTitle();
  hemptyPthat->GetYaxis()->CenterTitle();
  hemptyPthat->GetYaxis()->SetTitle("Entries");
  hemptyPthat->GetXaxis()->SetTitle("pthat");
  hemptyPthat->GetXaxis()->SetTitleOffset(0.9);
  hemptyPthat->GetYaxis()->SetTitleOffset(0.95);
  hemptyPthat->GetXaxis()->SetTitleSize(0.05);
  hemptyPthat->GetYaxis()->SetTitleSize(0.05);
  hemptyPthat->GetXaxis()->SetTitleFont(42);
  hemptyPthat->GetYaxis()->SetTitleFont(42);
  hemptyPthat->GetXaxis()->SetLabelFont(42);
  hemptyPthat->GetYaxis()->SetLabelFont(42);
  hemptyPthat->GetXaxis()->SetLabelSize(0.035);
  hemptyPthat->GetYaxis()->SetLabelSize(0.035);  
  hemptyPthat->SetMaximum(2);
  hemptyPthat->SetMinimum(0.);


  TH2F* hemptySpectra=new TH2F("hemptySpectra","",50,0.,130.,10,1,1e5);  
  hemptySpectra->GetXaxis()->CenterTitle();
  hemptySpectra->GetYaxis()->CenterTitle();
  hemptySpectra->GetYaxis()->SetTitle("Entries");
  hemptySpectra->GetXaxis()->SetTitle("Centrality");
  hemptySpectra->GetXaxis()->SetTitleOffset(0.9);
  hemptySpectra->GetYaxis()->SetTitleOffset(0.95);
  hemptySpectra->GetXaxis()->SetTitleSize(0.05);
  hemptySpectra->GetYaxis()->SetTitleSize(0.05);
  hemptySpectra->GetXaxis()->SetTitleFont(42);
  hemptySpectra->GetYaxis()->SetTitleFont(42);
  hemptySpectra->GetXaxis()->SetLabelFont(42);
  hemptySpectra->GetYaxis()->SetLabelFont(42);
  hemptySpectra->GetXaxis()->SetLabelSize(0.035);
  hemptySpectra->GetYaxis()->SetLabelSize(0.035);  

  TH2F* hemptyPthatWeighted=(TH2F*)hemptyPthat->Clone("hemptyPthatWeighted");
  hemptyPthatWeighted->GetXaxis()->SetTitle("pthat reweighted");
  
  TCanvas*canvasPthat=new TCanvas("canvasPthat","canvasPthat",1000.,500);
  canvasPthat->Divide(2,1);
  canvasPthat->cd(1);
  gPad->SetLogy();
  hemptyPthat->Draw("same");
  hPthat->Draw("same");
  canvasPthat->cd(2);
  gPad->SetLogy();
  hemptyPthatWeighted->Draw();
  hPthatweight->Draw("same");
  canvasPthat->SaveAs(Form("plotEff/canvasPthat_%s_Cent.pdf",Form(label.Data())));
  
  TCanvas*canvasSpectra=new TCanvas("canvasSpectra","canvasSpectra",1000.,500);
  canvasSpectra->Divide(2,1);
  canvasSpectra->cd(1);
  gPad->SetLogy();
  hemptySpectra->Draw();
  hPtMC->Draw("same");
  canvasSpectra->cd(2);
  gPad->SetLogy();
  hemptySpectra->Draw();
  hPtGen->Draw("same");
  canvasSpectra->SaveAs(Form("plotEff/canvasSpectra_%s_Cent.pdf",Form(label.Data())));

  //### 1D histogram
  //hEff = hPtMC / hPtGen
  //hEffReco = hPtMCrecoonly / hPtGen
  //hEffAcc = hPtGenAcc / hPtGen
  //hEffSelection = hPtMC / hPtMCrecoonly
 
/*
  ntMC->Project("hPtMC","hiBin",TCut(weightfunctionreco)*(TCut(cut.Data())&&"(Bgen==23333)"));
  ntMC->Project("hPtMCrecoonly","hiBin",TCut(weightfunctionreco)*(TCut(cut_recoonly.Data())&&"(Bgen==23333)"));
  ntGen->Project("hPtGen","hiBin",TCut(weightfunctiongen)*(TCut(selmcgen.Data())));
  ntGen->Project("hPtGenAcc","hiBin",TCut(weightfunctiongen)*(TCut(selmcgenacceptance.Data())));
*/  
  TCanvas*canvas1D=new TCanvas("canvas1D","",600,600);
  canvas1D->cd();
  gPad->SetLogy();
  hemptySpectra->SetYTitle("Entries of hPtMC");
  hemptySpectra->Draw(); 
  hPtMC->Draw("same");
  canvas1D->SaveAs(Form("plotEff/canvas1DhPtMC_%s_Cent.pdf",Form(label.Data())));
  canvas1D->Clear();

  canvas1D=new TCanvas("canvas1D","",600,600);
  canvas1D->cd();
  gPad->SetLogy();
  hemptySpectra->SetYTitle("Entries of hPtMCrecoonly");
  hemptySpectra->Draw(); 
  hPtMCrecoonly->Draw("same");
  canvas1D->SaveAs(Form("plotEff/canvas1DhPtMCrecoonly_%s_Cent.pdf",Form(label.Data())));
  canvas1D->Clear();

  canvas1D=new TCanvas("canvas1D","",600,600);
  canvas1D->cd();
  gPad->SetLogy();
  hemptySpectra->SetYTitle("Entries of hPtGen");
  hemptySpectra->Draw(); 
  hPtGen->Draw("same");
  canvas1D->SaveAs(Form("plotEff/canvas1DhPtGen_%s_Cent.pdf",Form(label.Data())));
  canvas1D->Clear();

  canvas1D=new TCanvas("canvas1D","",600,600);
  canvas1D->cd();
  gPad->SetLogy();
  hemptySpectra->SetYTitle("Entries of hPtGenAcc");
  hemptySpectra->Draw(); 
  hPtGenAcc->Draw("same");
  canvas1D->SaveAs(Form("plotEff/canvas1DhPtGenAcc_%s_Cent.pdf",Form(label.Data())));
  canvas1D->Clear();

  canvas1D=new TCanvas("canvas1D","",600,600);
  canvas1D->cd();
  gPad->SetLogy(0);
  hemptyEff->SetYTitle("hPtMC / hPtGen");
  hemptyEff->Draw(); 
  hEff->Draw("same");
  canvas1D->SaveAs(Form("plotEff/canvas1DhEff_%s_Cent.pdf",Form(label.Data())));
  canvas1D->Clear();

  canvas1D=new TCanvas("canvas1D","",600,600);
  canvas1D->cd();
  hemptyEff->SetYTitle("hPtMCrecoonly / hPtGen");
  hemptyEff->Draw(); 
  hEffReco->Draw("same");
  canvas1D->SaveAs(Form("plotEff/canvas1DhEffReco_%s_Cent.pdf",Form(label.Data())));
  canvas1D->Clear();

  canvas1D=new TCanvas("canvas1D","",600,600);
  canvas1D->cd();
  hemptyEff->SetYTitle("hPtGenAcc / hPtGen");
  hemptyEff->Draw(); 
  hEffAcc->Draw("same");
  canvas1D->SaveAs(Form("plotEff/canvas1DhEffAcc_%s_Cent.pdf",Form(label.Data())));
  canvas1D->Clear();

  canvas1D=new TCanvas("canvas1D","",600,600);
  canvas1D->cd();
  hemptyEff->SetYTitle("hPtMC / hPtGenAcc");
  hemptyEff->Draw(); 
  hEffSelection->Draw("same");
  canvas1D->SaveAs(Form("plotEff/canvas1DhEffSelection_%s_Cent.pdf",Form(label.Data())));
  canvas1D->Clear();

  gStyle->SetPalette(55);
  TCanvas* canvas2D=new TCanvas("canvas2D","",600,600);

  TFile *fout=new TFile(outputfile.Data(),"recreate");
  fout->cd();
  hPtGen->Write();
  hEffAcc->Write();
  hEffReco->Write();
  hEffSelection->Write();
  hEff->Write();
  hPtMC->Write();
  fout->Close();  

}
コード例 #24
0
ファイル: plotVariables.C プロジェクト: boundino/Dntuple
void plot(TString var, TString varlatex, TString varname, Int_t nbins, Double_t vmin, Double_t vmax)
{
  cout<<"---- Processing - "<<var<<endl;
  cout<<"  -- Fill histograms"<<endl;
  TFile* ifBkg = new TFile(infnameBkg[isChannel]);
  TTree* ntBkg = (TTree*)ifBkg->Get(texNtuple[isChannel]);
  ntBkg->AddFriend("ntHlt");
  TFile* ifSgl = new TFile(infnameSgl[isChannel]);
  TTree* ntSgl = (TTree*)ifSgl->Get(texNtuple[isChannel]);
  ntSgl->AddFriend("ntHlt");
  ntSgl->AddFriend("ntHi");

  TH1D* hBkg = new TH1D(Form("hBkg_%s",varname.Data()),"",nbins,vmin,vmax);
  TH1D* hSgl = new TH1D(Form("hSgl_%s",varname.Data()),"",nbins,vmin,vmax);

  ntBkg->Project(Form("hBkg_%s",varname.Data()),var,Form("%s&&%s",selTriggerBkg[isChannel].Data(),selBkg[isChannel].Data()));
  ntSgl->Project(Form("hSgl_%s",varname.Data()),var,TCut(weight[isChannel])*Form("%s&&%s",selTriggerSgl[isChannel].Data(),selSgl[isChannel].Data()));

  cout<<"  -- Calculate normalization"<<endl;
  Double_t normBkg=0,normSgl=0;
  //normBkg = hBkg->GetEntries();
  //normSgl = hSgl->GetEntries();
  normBkg = hBkg->Integral(vmin,vmax);
  normSgl = hSgl->Integral(vmin,vmax);
  cout<<"     normBkg: "<<normBkg<<" ;   normSgl: "<<normSgl<<endl;

  cout<<"  -- Normalize histograms"<<endl;
  hBkg->Scale(1./normBkg);
  hSgl->Scale(1./normSgl); 

  cout<<"  -- Plot"<<endl;
  hBkg->SetXTitle(varlatex);
  hBkg->SetYTitle("#Probability");
  hBkg->SetTitleOffset(1.5,"Y");
  Double_t hisMax = (hBkg->GetMaximum()>hSgl->GetMaximum())?hBkg->GetMaximum():hSgl->GetMaximum();
  hBkg->SetMaximum(hisMax*1.2);

  hBkg->SetLineColor(kBlue+1);
  hBkg->SetFillStyle(1001);
  hBkg->SetFillColor(kBlue-9);
  hBkg->SetLineWidth(3);
  hBkg->SetStats(0);

  TH1D* hSglplot = new TH1D(Form("hSglplot_%s",varname.Data()),"",nbins,vmin,vmax);
  for(int ib=0;ib<nbins;ib++) hSglplot->SetBinContent(ib+1,hSgl->GetBinContent(ib+1));
  hSglplot->SetLineColor(kRed);
  hSglplot->SetFillStyle(3004);
  hSglplot->SetFillColor(kRed);
  hSglplot->SetLineWidth(3);
  hSglplot->SetStats(0);

  TCanvas* c = new TCanvas(Form("c_%s",varname.Data()),"",600,600);
  hBkg->Draw();
  hSglplot->Draw("same");

  cout<<"  -- Plot legends"<<endl;
  TLatex* tex = new TLatex(0.18,0.935,Form("5.02TeV %s",texPP[isChannel].Data()));
  tex->SetNDC();
  tex->SetTextFont(42);
  tex->SetTextSize(0.055);
  tex->Draw();
  TLatex* texp;
  texp = new TLatex(0.68,0.935,texDecay[isChannel]);
  texp->SetNDC();
  texp->SetTextFont(42);
  texp->SetTextSize(0.055);
  texp->Draw();
  TLegend* leg = new TLegend(0.56,0.70,0.86,0.86);
  leg->AddEntry(hBkg,"Background","f");
  leg->AddEntry(hSglplot,"Signal","f");
  leg->SetBorderSize(0);
  leg->SetFillStyle(0);
  leg->Draw("same");

  cout<<"  -- Save plots"<<endl;
  c->SaveAs(Form("plots/%s_%s/c_%s.pdf",texPP[isChannel].Data(),texNtuple[isChannel].Data(),varname.Data()));
  cout<<endl;
}
コード例 #25
0
void dt_RunDrawTest(const char* from, Int_t mode = 0, Int_t verboseLevel = 0) {
  // This launch a test a TTree::Draw.
  // The mode currently available are:
  //    0: Do not load the shared library
  //    1: Load the shared library before opening the file
  //    2: Load the shared library after opening the file
  //    3: Simple TChain test with shared library
  //    4: Simple Friend test with shared library
  // The verboseLeve currently available:
  //    0: As silent as possible, only report errors and overall speed results.
  //    1: Output 0 + label for the start of each phase
  //    2: Output 1 + more details on the different phase being done
  //    3: Output 2 + stop at the first and draw a canvas showing the differences

   SetVerboseLevel(verboseLevel);

   if (mode == 1) {
      if (!TClassTable::GetDict("Event")) {
         gSystem->Load("libEvent");
     }     
      gHasLibrary = kTRUE;
   }

   TFile *hfile = 0;
   TTree *tree = 0;
   if (mode <3) {
      hfile = new TFile(from);
      tree = (TTree*)hfile->Get("T");
   }

   if (mode >= 2 && mode <= 4) {
      if (!TClassTable::GetDict("Event")) {
         gSystem->Load("libEvent");
      } else {
         cerr << "Since libEvent.so has already been loaded, mode 2 can not be tested!";
         cerr << endl;
      }
      gHasLibrary = kTRUE;
   }

   if (mode == 3) {
      // Test Chains.
      TChain * chain = new TChain("T");
      chain->Add(from);
      chain->Add(from);
      tree = chain;
   }

   if (mode == 4) {
      // Test friends.
      tree = new TTree("T","Base of friendship");
      tree->AddFriend("T",from);
   }

   if (gQuietLevel<2) cout << "Generating histograms from TTree::Draw" << endl;
   TDirectory* where = GenerateDrawHist(tree);
 
   if (gQuietLevel<2) cout << "Comparing histograms" << endl;
   if (Compare(where)>0) {
     cout << "DrawTest: Comparison failed" << endl;
     return;
   }
   DrawMarks();

   cout << "DrawTest: Comparison was successfull" << endl;
   if (hfile) delete hfile;
   else delete tree;
   gROOT->GetList()->Delete();

}   
コード例 #26
0
ファイル: VertexWeighting.C プロジェクト: XuQiao/HI
void VertexWeighting(){
TString Gen="Hijing";
//TString Gen="Epos";
if(Gen=="Hijing"){
TString Hijing_file="/store/user/tuos/pPb_MC_MinBiasTree_v4_Hijing_180k.root";
TFile *fin=TFile::Open(Hijing_file);
TFile *fout=TFile::Open("output/Hijing_vz.root","RECREATE");
}
else if(Gen=="Epos"){
TString Epos_file = "/store/user/tuos/pPb_MC_MinBiasTree_v4_Epos_189k.root";
TFile *fin=TFile::Open(Epos_file);
TFile *fout=TFile::Open("output/Epos_vz.root","RECREATE");
}

TH1F *hVz_MC=new TH1F("hVz_MC","Vz distribution",400, -20., 20.);	hVz_MC->Sumw2();
TH2F *hVzHF4=new TH2F("hVzHF4","Vz HF distribution",400,-20.,20, 500,0.,100.);	hVzHF4->Sumw2();
TH2F *hVzHFPlus4=new TH2F("hVzHFPlus4","Vz HF distribution",400,-20.,20, 500,0.,100.);	hVzHFPlus4->Sumw2();
TH2F *hVzHFPlus=new TH2F("hVzHFPlus","Vz HF distribution",400,-20.,20, 500,0.,100.);	hVzHFPlus->Sumw2();

TTree *tree;
fin->cd();
tree=(TTree*)hiEvtAnalyzer->Get("HiTree");
tree->AddFriend("skimTree=skimanalysis/HltTree");
tree->AddFriend("hltTree=hltanalysis/HltTree");

Float_t hiHF, vz, hiHFplus;
Float_t hiHFminusEta4, hiHFplusEta4;
Long_t Ev,Nevent, Nevent_counter, Nleft;
Int_t n, HLT_PAZeroBiasPixel_SingleTrack_v1, pprimaryvertexFilter, pVertexFilterCutGplus, pPAcollisionEventSelectionPA, pHBHENoiseFilter;
Nevent=tree->GetEntries();

tree->SetBranchAddress("hiHF",&hiHF);//HF energy
tree->SetBranchAddress("hiHFplus",&hiHFplus);//HF energy positive
tree->SetBranchAddress("hiHFplusEta4",&hiHFplusEta4);//HF energy positive 4 to 5
tree->SetBranchAddress("hiHFminusEta4",&hiHFminusEta4);//HF energy negative -5 to -4
tree->SetBranchAddress("vz",&vz);
tree->SetBranchAddress("HLT_PAZeroBiasPixel_SingleTrack_v1",&HLT_PAZeroBiasPixel_SingleTrack_v1);
tree->SetBranchAddress("pprimaryvertexFilter",&pprimaryvertexFilter);
tree->SetBranchAddress("pVertexFilterCutGplus",&pVertexFilterCutGplus);
//tree->SetBranchAddress("pHBHENoiseFilter",&pHBHENoiseFilter);
tree->SetBranchAddress("pPAcollisionEventSelectionPA",&pPAcollisionEventSelectionPA);

TF1 * fVz = new TF1("fVx","[0]+[1]*x+[2]*TMath::Power(x,2)+[3]*TMath::Power(x,3)+[4]*TMath::Power(x,4)", -15., 15.);
fVz->SetParameters(1.60182e+00,1.08425e-03,-1.29156e-02,-7.24899e-06,2.80750e-05);

for(Ev=0;Ev<Nevent;Ev++){
if(Ev%5000==0)
cout<<"Have run "<<Ev<<" Events"<<endl;

tree->GetEntry(Ev);
if(!(HLT_PAZeroBiasPixel_SingleTrack_v1 && pVertexFilterCutGplus && pPAcollisionEventSelectionPA && pprimaryvertexFilter && TMath::Abs(vz)<15)) continue;
hVz_MC->Fill(vz);
hVzHF4->Fill(vz,hiHFplusEta4+hiHFminusEta4);
hVzHFPlus4->Fill(vz,hiHFplusEta4);
hVzHFPlus->Fill(vz,hiHFplus);
}

fout->cd();
hVz_MC->Write();
hVzHF4->Write();
hVzHFPlus4->Write();
hVzHFPlus->Write();

fout->Close();
}
コード例 #27
0
ファイル: TrackSlurm.C プロジェクト: tuos/RpPb2015Analysis
void TrackSlurm::getHistograms(TString inFile, TString outFile)
{
TString inFileName;
inFileName = inFile;
const int nPtBin=34;
double ptBins[nPtBin+1]={0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.4,1.6,1.8,2.0,2.2,2.4,3.2,4.0,4.8,5.6,6.4,7.2,9.6,12.0,14.4,19.2,24.0,28.8,35.2,41.6,48.0,60.8,73.6,86.4,103.6,120.8};
TH1D *ptHist = new TH1D("pthist","generalTracks pT Distribution", nPtBin, ptBins);
TH1D *vzHist = new TH1D("vzhist","generalTracks pT Distribution", 100, -25,25);
TH1D *nVzHist = new TH1D("nvzhist","generalTracks pT Distribution", 10, 0,10);
TH1D *nVzHistSD = new TH1D("nvzhistsd","generalTracks pT Distribution", 10, 0,10);
TH1D *nVzHistDD = new TH1D("nvzhistdd","generalTracks pT Distribution", 10, 0,10);
TH1D *nVzHistND = new TH1D("nvzhistnd","generalTracks pT Distribution", 10, 0,10);
TH1D *nVzHistNoES = new TH1D("nvzhistnoes","generalTracks pT Distribution", 10, 0,10);
TH1D *nVz1PtHist = new TH1D("nvz1pthist","generalTracks pT Distribution", nPtBin, ptBins);
TH1D *vzHistNoES = new TH1D("vzhistnoes","generalTracks pT Distribution", 100, -25,25);
TH1D *vzHistnVz1 = new TH1D("vzhistnvz1","generalTracks pT Distribution", 100, -25,25);

TH1D *ptHistCalo = new TH1D("pthistcalo","generalTracks pT Distribution", nPtBin, ptBins);
TH1D *nVz1PtHistCalo = new TH1D("nvz1pthistcalo","generalTracks pT Distribution", nPtBin, ptBins);
TH1D *gPtVtxptHistCalo = new TH1D("gptvtxpthistcalo","generalTracks pT Distribution", nPtBin, ptBins);
TH1D *allVtxptHistCalo = new TH1D("allvtxpthistcalo","generalTracks pT Distribution", nPtBin, ptBins);
TH1D *allVtxptHistCaloSD = new TH1D("allvtxpthistcalosd","generalTracks pT Distribution", nPtBin, ptBins);
TH1D *allVtxptHistCaloDD = new TH1D("allvtxpthistcalodd","generalTracks pT Distribution", nPtBin, ptBins);
TH1D *allVtxptHistCaloND = new TH1D("allvtxpthistcalond","generalTracks pT Distribution", nPtBin, ptBins);
TH1D *allVtxptHistCaloEta1 = new TH1D("allvtxpthistcaloeta1","generalTracks pT Distribution", nPtBin, ptBins);
TH1D *allVtxptHistCaloSDEta1 = new TH1D("allvtxpthistcalosdeta1","generalTracks pT Distribution", nPtBin, ptBins);
TH1D *allVtxptHistCaloDDEta1 = new TH1D("allvtxpthistcaloddeta1","generalTracks pT Distribution", nPtBin, ptBins);
TH1D *allVtxptHistCaloNDEta1 = new TH1D("allvtxpthistcalondeta1","generalTracks pT Distribution", nPtBin, ptBins);

TH1D *proIDnVtx0Hist = new TH1D("proidnvtx0hist","process ID Distribution", 10, 100,110);
TH1D *proIDnVtxnHist = new TH1D("proidnvtxnhist","process ID Distribution", 10, 100,110);
TH1D *proIDAllHist = new TH1D("proidallhist","process ID Distribution", 10, 100,110);
TH1D *proIDESHist = new TH1D("proideshist","process ID Distribution", 10, 100,110);

TH1D *nVzHistNoESWithHLT = new TH1D("nvzhistnoeswithhlt","generalTracks pT Distribution", 10, 0,10);
TH1D *proIDnVtx0HLTHist = new TH1D("proidnvtx0hlthist","process ID Distribution", 10, 100,110);
TH1D *proIDnVtxnHLTHist = new TH1D("proidnvtxnhlthist","process ID Distribution", 10, 100,110);
TH1D *proIDHLTHist = new TH1D("proidhlthist","process ID Distribution", 10, 100,110);
TH1D *proIDHLTESHist = new TH1D("proidhlteshist","process ID Distribution", 10, 100,110);

TH1D *nMultHist = new TH1D("nmulthist","Multiplicity Distribution", 200, 0,200);
TH1D *nMultHistSD = new TH1D("nmulthistsd","Multiplicity Distribution", 200, 0,200);
TH1D *nMultHistDD = new TH1D("nmulthistdd","Multiplicity Distribution", 200, 0,200);
TH1D *nMultHistND = new TH1D("nmulthistnd","Multiplicity Distribution", 200, 0,200);
TH1D *nMultHistEta24 = new TH1D("nmulthisteta24","Multiplicity Distribution", 200, 0,200);
TH1D *nMultHistEta10 = new TH1D("nmulthisteta10","Multiplicity Distribution", 200, 0,200);
TH1D *nMultHistEta24SD = new TH1D("nmulthisteta24sd","Multiplicity Distribution", 200, 0,200);
TH1D *nMultHistEta10SD = new TH1D("nmulthisteta10sd","Multiplicity Distribution", 200, 0,200);
TH1D *nMultHistEta24DD = new TH1D("nmulthisteta24dd","Multiplicity Distribution", 200, 0,200);
TH1D *nMultHistEta10DD = new TH1D("nmulthisteta10dd","Multiplicity Distribution", 200, 0,200);
TH1D *nMultHistEta24ND = new TH1D("nmulthisteta24nd","Multiplicity Distribution", 200, 0,200);
TH1D *nMultHistEta10ND = new TH1D("nmulthisteta10nd","Multiplicity Distribution", 200, 0,200);
int nmult24, nmult10;
int nmult24sd, nmult10sd;
int nmult24dd, nmult10dd;
int nmult24nd, nmult10nd;

const Int_t maxn = 90000;
Float_t vz;
Int_t processid;
Int_t HLT_L1MinimumBiasHF1OR_v1;
Int_t nTrk;
Float_t trkPt[maxn], trkEta[maxn], trkPhi[maxn];
Bool_t highPurity[maxn];
Float_t trkDz1[maxn], trkDzError1[maxn],trkDxy1[maxn],trkDxyError1[maxn],trkPtError[maxn];
Int_t nTrkTimesnVtx;
Float_t trkDzOverDzError[maxn], trkDxyOverDxyError[maxn];


  long Nevt;
  int pVtx;
  int pBeamScrape;
  int nVtx;
  float trkMVA[maxn];
  unsigned char trkNHit[maxn]; 
  float pfEcal[maxn];
  float pfHcal[maxn];

  TFile * file = TFile::Open(inFileName);
  TTree * tree = (TTree *) file->Get("hiEvtAnalyzer/HiTree");
  tree->AddFriend("pptrack=ppTrack/trackTree");
  tree->AddFriend("skimTree=skimanalysis/HltTree");
  tree->AddFriend("hltTree=hltanalysis/HltTree");
  tree->AddFriend("genTree=HiGenParticleAna/hi");
     tree->SetBranchAddress("vz",&vz);
     tree->SetBranchAddress("processid",&processid);
     tree->SetBranchAddress("HLT_L1MinimumBiasHF1OR_v1",&HLT_L1MinimumBiasHF1OR_v1);
     tree->SetBranchAddress("nTrk",&nTrk);
     tree->SetBranchAddress("trkPt",&trkPt);
     tree->SetBranchAddress("trkEta",&trkEta);
     tree->SetBranchAddress("trkPhi",&trkPhi);
     tree->SetBranchAddress("trkDz1",&trkDz1);
     tree->SetBranchAddress("trkDzError1",&trkDzError1);
     tree->SetBranchAddress("trkDxy1",&trkDxy1);
     tree->SetBranchAddress("trkDxyError1",&trkDxyError1);
     tree->SetBranchAddress("nTrkTimesnVtx",&nTrkTimesnVtx);
     tree->SetBranchAddress("trkDzOverDzError",&trkDzOverDzError);
     tree->SetBranchAddress("trkDxyOverDxyError",&trkDxyOverDxyError);
     //tree->SetBranchAddress("",&);
     tree->SetBranchAddress("trkPtError",&trkPtError);
     tree->SetBranchAddress("highPurity",&highPurity);
     tree->SetBranchAddress("trkMVA",&trkMVA);
     tree->SetBranchAddress("trkNHit",&trkNHit);
     tree->SetBranchAddress("pfHcal",&pfHcal);
     tree->SetBranchAddress("pfEcal",&pfEcal);
     tree->SetBranchAddress("pPAprimaryVertexFilter",&pVtx);
     tree->SetBranchAddress("pBeamScrapingFilter",&pBeamScrape);
     tree->SetBranchAddress("nVtx",&nVtx);
     Nevt=tree->GetEntries();  cout<<"Entries= "<<Nevt<<endl;

     for(long ne=0; ne<Nevt; ne++){
     //for(long ne=0; ne<10000; ne++){
       if(ne%3000==0)  cout<<"Have run "<<ne<<" events. "<<endl;
       tree->GetEntry(ne);

       nmult24=0; nmult10=0;
       nmult24sd=0; nmult10sd=0;
       nmult24dd=0; nmult10dd=0;
       nmult24nd=0; nmult10nd=0;

       nVzHistNoES->Fill(nVtx*pVtx);
       if(HLT_L1MinimumBiasHF1OR_v1==1) 
         nVzHistNoESWithHLT->Fill(nVtx*pVtx);
       vzHistNoES->Fill(vz);    
       proIDAllHist->Fill(processid);
       if(nVtx*pVtx==0)
         proIDnVtx0Hist->Fill(processid);
       if(nVtx*pVtx==0 && HLT_L1MinimumBiasHF1OR_v1==1)
         proIDnVtx0HLTHist->Fill(processid);
       if(nVtx*pVtx>0)
         proIDnVtxnHist->Fill(processid);
       if(nVtx*pVtx>0 && HLT_L1MinimumBiasHF1OR_v1==1)
         proIDnVtxnHLTHist->Fill(processid);
       if(pVtx&&pBeamScrape)
         proIDESHist->Fill(processid); //only ES
       if(HLT_L1MinimumBiasHF1OR_v1==0) continue;
         proIDHLTHist->Fill(processid); //only HLT
       if(!(pVtx&&pBeamScrape)) continue;
         nVzHist->Fill(nVtx);
         vzHist->Fill(vz);
         proIDHLTESHist->Fill(processid);
         if(processid==103 || processid==104)
           nVzHistSD->Fill(nVtx);
         if(processid==105)
           nVzHistDD->Fill(nVtx);
         if(processid==101)
           nVzHistND->Fill(nVtx);      

         if(nVtx==1)
           vzHistnVz1->Fill(vz);

         nMultHist->Fill(nTrk);
         if(processid==103 || processid==104)
           nMultHistSD->Fill(nTrk);
         if(processid==105)
           nMultHistDD->Fill(nTrk);
         if(processid==101)
           nMultHistND->Fill(nTrk);

         for(int ni=0;ni<nTrk;ni++){

           if(!(highPurity[ni]&&trkPtError[ni]/trkPt[ni]<0.3&&trkPt[ni]>0.4&&trkPt[ni]<120.8&&fabs(trkEta[ni])<2.4)) continue;

           if(fabs(trkDz1[ni]/trkDzError1[ni])<3&&fabs(trkDxy1[ni]/trkDxyError1[ni])<3){
             ptHist->Fill(trkPt[ni]);
             if(nVtx==1)
               nVz1PtHist->Fill(trkPt[ni]);             
           }


           float Et = (pfHcal[ni]+pfEcal[ni])/TMath::CosH(trkEta[ni]);
           if(!(trkPt[ni]<20 || (Et>0.2*trkPt[ni] && Et>trkPt[ni]-80))) continue; //Calo Matching

           if(fabs(trkDz1[ni]/trkDzError1[ni])<3&&fabs(trkDxy1[ni]/trkDxyError1[ni])<3){
             ptHistCalo->Fill(trkPt[ni]);
             if(nVtx==1)
               nVz1PtHistCalo->Fill(trkPt[ni]);             
             gPtVtxptHistCalo->Fill(trkPt[ni]); 
           }

           bool isCompatibleWithVertex = false;
           for(int v = 0; v<nVtx; v++){
             if(TMath::Abs(trkDxyOverDxyError[ni*nVtx+v])<3 && TMath::Abs(trkDzOverDzError[ni*nVtx+v])<3){
               isCompatibleWithVertex = true;
               break;
             }
           }          
           if(!isCompatibleWithVertex) continue;
           allVtxptHistCalo->Fill(trkPt[ni]);
           if(fabs(trkEta[ni])<1.0) 
             allVtxptHistCaloEta1->Fill(trkPt[ni]);
           nmult24++;
           if(fabs(trkEta[ni])<1.0)
             nmult10++;

           if(processid==103 || processid==104){
             allVtxptHistCaloSD->Fill(trkPt[ni]);
             if(fabs(trkEta[ni])<1.0)
               allVtxptHistCaloSDEta1->Fill(trkPt[ni]);
             nmult24sd++;
             if(fabs(trkEta[ni])<1.0)
               nmult10sd++;
           }
           if(processid==105){
             allVtxptHistCaloDD->Fill(trkPt[ni]);
             if(fabs(trkEta[ni])<1.0)
               allVtxptHistCaloDDEta1->Fill(trkPt[ni]);
             nmult24dd++;
             if(fabs(trkEta[ni])<1.0)
               nmult10dd++;
           }
           if(processid==101){
             allVtxptHistCaloND->Fill(trkPt[ni]);
             if(fabs(trkEta[ni])<1.0)
               allVtxptHistCaloNDEta1->Fill(trkPt[ni]);
             nmult24nd++;
             if(fabs(trkEta[ni])<1.0)
               nmult10nd++;
           }

         }//end of ntrk
         nMultHistEta24->Fill(nmult24);
         nMultHistEta10->Fill(nmult10);
         nMultHistEta24SD->Fill(nmult24sd);
         nMultHistEta10SD->Fill(nmult10sd);
         nMultHistEta24DD->Fill(nmult24dd);
         nMultHistEta10DD->Fill(nmult10dd);
         nMultHistEta24ND->Fill(nmult24nd);
         nMultHistEta10ND->Fill(nmult10nd);
     }

//////
TString outFileName;
outFileName = outFile;
  TFile * outFiles = TFile::Open(outFileName,"recreate");
  outFiles->cd();
  vzHist->Write();
  ptHist->Write();
  nVzHistNoES->Write();
  nVzHist->Write();
  nVzHistSD->Write();
  nVzHistDD->Write();
  nVzHistND->Write();
  nVz1PtHist->Write();
  vzHistNoES->Write();
  vzHistnVz1->Write();
  ptHistCalo->Write();
  nVz1PtHistCalo->Write();
  gPtVtxptHistCalo->Write();
  allVtxptHistCalo->Write();
  allVtxptHistCaloSD->Write();
  allVtxptHistCaloDD->Write();
  allVtxptHistCaloND->Write();
  allVtxptHistCaloEta1->Write();
  allVtxptHistCaloSDEta1->Write();
  allVtxptHistCaloDDEta1->Write();
  allVtxptHistCaloNDEta1->Write();
  proIDnVtx0Hist->Write();
  proIDnVtxnHist->Write();
  proIDAllHist->Write();
  proIDESHist->Write();
  nVzHistNoESWithHLT->Write();
  proIDnVtx0HLTHist->Write();
  proIDnVtxnHLTHist->Write();
  proIDHLTHist->Write();
  proIDHLTESHist->Write();
  nMultHist->Write();
  nMultHistSD->Write();
  nMultHistDD->Write();
  nMultHistND->Write();
  nMultHistEta24->Write();
  nMultHistEta10->Write();
  nMultHistEta24SD->Write();
  nMultHistEta10SD->Write();
  nMultHistEta24DD->Write();
  nMultHistEta10DD->Write();
  nMultHistEta24ND->Write();
  nMultHistEta10ND->Write();
  outFiles->Close();

  delete vzHist;
  delete ptHist;
  delete nVzHistNoES;
  delete nVzHist;
  delete nVzHistSD;
  delete nVzHistDD;
  delete nVzHistND;
  delete nVz1PtHist;
  delete vzHistNoES;
  delete vzHistnVz1;
  delete ptHistCalo;
  delete nVz1PtHistCalo;
  delete gPtVtxptHistCalo;
  delete allVtxptHistCalo;
  delete allVtxptHistCaloSD;
  delete allVtxptHistCaloDD;
  delete allVtxptHistCaloND;
  delete allVtxptHistCaloEta1;
  delete allVtxptHistCaloSDEta1;
  delete allVtxptHistCaloDDEta1;
  delete allVtxptHistCaloNDEta1;
  delete proIDnVtx0Hist;
  delete proIDnVtxnHist;
  delete proIDAllHist;
  delete proIDESHist;
  delete nVzHistNoESWithHLT;
  delete proIDnVtx0HLTHist;
  delete proIDnVtxnHLTHist;
  delete proIDHLTHist;
  delete proIDHLTESHist;
  delete nMultHist;
  delete nMultHistSD;
  delete nMultHistDD;
  delete nMultHistND;
  delete nMultHistEta24;
  delete nMultHistEta10;
  delete nMultHistEta24SD;
  delete nMultHistEta10SD;
  delete nMultHistEta24DD;
  delete nMultHistEta10DD;
  delete nMultHistEta24ND;
  delete nMultHistEta10ND;

}
コード例 #28
0
void fitDstar5pMinpt(Bool_t genmatchpoint=true)
{
  gStyle->SetTextSize(0.05);
  gStyle->SetTextFont(42);
  gStyle->SetPadRightMargin(0.043);
  gStyle->SetPadLeftMargin(0.18);
  gStyle->SetPadTopMargin(0.1);
  gStyle->SetPadBottomMargin(0.145);
  gStyle->SetTitleX(.0f);

  void clean0(TH1D* h);  
  TF1* fitDstar(TTree* nt, TTree* ntMC, Float_t ptmin, Bool_t plotgenmatch);

  TFile* infData = new TFile(infnameData5p[isData].Data());
  TFile* infMC = new TFile(infnameMC5p[isData].Data());

  TTree* ntData = (TTree*)infData->Get("ntDD0kpipipipi");
  TTree* ntMC = (TTree*)infMC->Get("ntDD0kpipipipi");
  TTree* ntGen = (TTree*)infMC->Get("ntGen");
  
  ntData->AddFriend("ntHlt");
  if(isData!=Data_MB&&isData!=Data) ntData->AddFriend("ntHi");
  ntMC->AddFriend("ntHlt");
  ntMC->AddFriend("ntHi");
  ntGen->AddFriend("ntHlt");
  ntGen->AddFriend("ntHi");

  Float_t aZero[nBins];
  for(int i=0;i<nBins;i++) aZero[i]=0;
  Float_t aPt[nBins],aPtErr[nBins],aGen[nBins],aGenErr[nBins];
  TH1F* hPt = new TH1F("hPt","",nBins,ptBinsPlus);
  TH1F* hGen = new TH1F("hGen","",nBins,ptBinsPlus);

  for(int i=0;i<nBins;i++)
    {
      TF1* fData = fitDstar(ntData,ntMC,ptBins[i],genmatchpoint);
      Float_t yieldData = fData->Integral(BINMIN,BINMAX)/BINWID;
      Float_t yieldDataErr = fData->Integral(BINMIN,BINMAX)/BINWID*fData->GetParError(0)/fData->GetParameter(0);      
      aPt[i] = yieldData;
      aPtErr[i] = yieldDataErr;
      hPt->SetBinContent(i+1,aPt[i]);
      hPt->SetBinError(i+1,aPtErr[i]);
      TH1D* hGenFill = new TH1D(Form("hGenFill_%.0f",ptBins[i]),"",1,ptBins[i],1.e+3);
      hGenFill->Sumw2();
      ntGen->Project(Form("hGenFill_%.0f",ptBins[i]),"Gpt",TCut("%s",weightmc[isData].Data())*Form("%s&&%s",selgen5p.Data(),triggerselectionmc[isData].Data()));
      aGen[i] = hGenFill->GetBinContent(1);
      aGenErr[i] = hGenFill->GetBinError(1);
      hGen->SetBinContent(i+1,aGen[i]);
      hGen->SetBinError(i+1,aGenErr[i]);
    }

  TGraphErrors* gPt = new TGraphErrors(nBins,ptBins,aPt,aZero,aPtErr);
  gPt->SetName("gPt");
  TGraphErrors* gGen = new TGraphErrors(nBins,ptBins,aGen,aZero,aGenErr);
  gGen->SetName("gGen");

  TFile* outputfile = new TFile(Form("outputfiles/output_5p_%s_Minpt.root",texData[isData].Data()),"recreate");
  outputfile->cd();
  gPt->Write();
  gGen->Write();
  hPt->Write();
  hGen->Write();
  outputfile->Close();
}
コード例 #29
0
ファイル: savehisto.C プロジェクト: boundino/BntupleRunII
void savehisto(TString inputdata="",
                   TString inputmc="",
                   TString trgselection="",
                   TString cut="",
                   int isMC=0, int doweight=0, TString collsyst="pp",
		   float centMin=0,
                   float centMax=100,
	           TString outputfile="outHisto")
{

  collisionsystem=collsyst;
  centmin = centMin;
  centmax = centMax;
  hiBinMin = centMin*2;
  hiBinMax = centMax*2;

  isPbPb = true;
  if(collisionsystem=="pp") isPbPb = false;
  // if(!doweight) weight="1";

  TFile* inf = new TFile(inputdata.Data());
  TFile* infMC = new TFile(inputmc.Data());

  if(!isPbPb) seldata = Form("%s&&%s",trgselection.Data(),cut.Data());
  else seldata = Form("%s&&%s&&hiBin>=%f&&hiBin<=%f",trgselection.Data(),cut.Data(),hiBinMin,hiBinMax);
  selmc = Form("%s",cut.Data());  
  
  TTree* nt = (TTree*)inf->Get("ntKp");
  nt->AddFriend("ntHlt");
  nt->AddFriend("ntHi");
  nt->AddFriend("ntSkim");
  nt->AddFriend("bdtTree");

  TTree* ntGen = (TTree*)infMC->Get("ntGen");
  ntGen->AddFriend("ntHlt");
  ntGen->AddFriend("ntHi");

  TTree* ntMC = (TTree*)infMC->Get("ntKp");
  ntMC->AddFriend("ntHlt");
  ntMC->AddFriend("ntHi");
  ntMC->AddFriend("ntSkim");
  ntMC->AddFriend("bdtTree");
  ntMC->AddFriend(ntGen);

  if(!isPbPb) seldata = Form("%s&&%s",trgselection.Data(),cut.Data());
  else seldata = Form("%s&&%s&&hiBin>=%f&&hiBin<=%f",trgselection.Data(),cut.Data(),hiBinMin,hiBinMax);
  selmc = Form("%s",cut.Data());  
  
  cout<<"  -- Filling histograms"<<endl;
  cout<<"     "<<inputdata<<endl;
  cout<<"     "<<inputmc<<endl;
  for(int i=0;i<nBins;i++)
    {
      cout<<setiosflags(ios::left)<<"   - Processing ptbin "<<setw(3)<<ptBins[i]<<" "<<setw(3)<<ptBins[i+1]<<endl;
      TH1D* h = new TH1D("h","", nbinsmasshisto,minhisto,maxhisto);
      h->Sumw2();
      TH1D* hMCSignal = new TH1D("hMCSignal","",nbinsmasshisto,minhisto,maxhisto);
      hMCSignal->Sumw2();
      TH1D* hMCSwapped = new TH1D("hMCSwapped","",nbinsmasshisto,minhisto,maxhisto);
      hMCSwapped->Sumw2(); 

      if(isPbPb) nt->Project("h","Bmass",Form("%s*(%s&&Bpt>%f&&Bpt<%f&&hiBin>=%f&&hiBin<=%f)",weight.Data(),seldata.Data(),ptBins[i],ptBins[i+1],hiBinMin,hiBinMax));
      else nt->Project("h","Bmass",Form("%s*(%s&&Bpt>%f&&Bpt<%f)",weight.Data(),seldata.Data(),ptBins[i],ptBins[i+1]));
      ntMC->Project("hMCSignal","Bmass",Form("%s*(%s&&Bpt>%f&&Bpt<%f&&(Bgen==23333))",weightMC.Data(),selmc.Data(),ptBins[i],ptBins[i+1]));   
      ntMC->Project("hMCSwapped","Bmass",Form("%s*(%s&&Bpt>%f&&Bpt<%f&&(Bgen==23344))",weightMC.Data(),selmc.Data(),ptBins[i],ptBins[i+1])); 

      TFile* outf = new TFile(Form("%s/%s_%.0f_%.0f.root",outputfile.Data(),collisionsystem.Data(),ptBins[i],ptBins[i+1]),"recreate");
       
      outf->cd();
      h->Write();
      hMCSignal->Write();
      hMCSwapped->Write();
      outf->Close();
      delete h;
      delete hMCSignal;
      delete hMCSwapped;
    }

  cout<<endl;
}
コード例 #30
0
void projectPbPbMBMC()
{
  gStyle->SetTextSize(0.05);
  gStyle->SetTextFont(42);
  gStyle->SetPadRightMargin(0.043);
  gStyle->SetPadLeftMargin(0.18);
  gStyle->SetPadTopMargin(0.1);
  gStyle->SetPadBottomMargin(0.145);
  gStyle->SetTitleX(.0f);
  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);

  TFile* infMCP = new TFile("/data/HeavyFlavourRun2/MC2015/Dntuple/PbPb/ntD_EvtBase_20160513_DfinderMC_PbPb_20160502_dPt1tkPt0p5_D0_prompt_Dpt2Dy1p1tkPt0p7tkEta2Decay2p9Dalpha0p14Skim_pthatweight.root");
  TFile* infMCNP = new TFile("/data/HeavyFlavourRun2/MC2015/Dntuple/PbPb/ntD_EvtBase_20160513_DfinderMC_PbPb_20160502_dPt1tkPt0p5_D0_nonprompt_Dpt2Dy1p1tkPt0p7tkEta2Decay2p9Dalpha0p14Skim_pthatweight.root");
  
  TTree* tMCP = (TTree*)infMCP->Get("ntDkpi");
  TTree* tMCNP = (TTree*)infMCNP->Get("ntDkpi");
  TTree* tMCPHI = (TTree*)infMCP->Get("ntHi");
  TTree* tMCNPHI = (TTree*)infMCNP->Get("ntHi");
  TTree* tMCPSkim = (TTree*)infMCP->Get("ntSkim");
  TTree* tMCNPSkim = (TTree*)infMCNP->Get("ntSkim");
  tMCP->AddFriend(tMCPHI);
  tMCNP->AddFriend(tMCNPHI);
  tMCP->AddFriend(tMCPSkim);
  tMCNP->AddFriend(tMCNPSkim);
  
  TFile* outf = new TFile("bFeedDownPbPbMBMC.hist.root","recreate");
  
  TCut cutPbPbMB = "pclusterCompatibilityFilter&&pprimaryVertexFilter&&phfCoincFilter3&&Dy>-1.&&Dy<1.&&Dtrk1highPurity&&Dtrk2highPurity&&Dtrk1Pt>1.0&&Dtrk2Pt>1.0&&Dtrk1PtErr/Dtrk1Pt<0.3&&Dtrk2PtErr/Dtrk2Pt<0.3&&abs(Dtrk1Eta)<1.5&&abs(Dtrk2Eta)<1.5&&((DlxyBS/DlxyBSErr)>1.5&&Dalpha<0.12&&((Dpt>1&&Dpt<2&&(DsvpvDistance/DsvpvDisErr)>6.0&&Dchi2cl>0.25)||(Dpt>2&&Dpt<4&&(DsvpvDistance/DsvpvDisErr)>5.86&&Dchi2cl>0.224)||(Dpt>4&&Dpt<5&&(DsvpvDistance/DsvpvDisErr)>5.46&&Dchi2cl>0.196)||(Dpt>5&&Dpt<6&&(DsvpvDistance/DsvpvDisErr)>4.86&&Dchi2cl>0.170)||(Dpt>6&&Dpt<8&&(DsvpvDistance/DsvpvDisErr)>4.54&&Dchi2cl>0.125)||(Dpt>8&&Dpt<10&&(DsvpvDistance/DsvpvDisErr)>4.42&&Dchi2cl>0.091)||(Dpt>10&&Dpt<15&&(DsvpvDistance/DsvpvDisErr)>4.06&&Dchi2cl>0.069)||(Dpt>15&&Dpt<20&&(DsvpvDistance/DsvpvDisErr)>3.71&&Dchi2cl>0.056)||(Dpt>20&&Dpt<25&&(DsvpvDistance/DsvpvDisErr)>3.25&&Dchi2cl>0.054)||(Dpt>25&&(DsvpvDistance/DsvpvDisErr)>2.97&&Dchi2cl>0.050)))";

  TCut cutmc = "(Dgen==23333||Dgen==23344)";
  TCut cutmcSignal = "Dgen==23333";
  TCut cutmcSwapped = "Dgen==23344";
  TCut cutpt = "Dpt<20";
  TCut cutSignal = "abs(Dmass-1.8649)<0.025";
  TCut cutSideband = "abs(Dmass-1.8649)>0.075&&abs(Dmass-1.8649)<0.1";
  TCut cutPrompt = "DgenBAncestorpt<=0";
  TCut cutNonPrompt ="DgenBAncestorpt>0";
  TCut weightfunctionreco = "pthatweight";

  const int nBinX = 14;
  Float_t binsX[nBinX+1] = {2.,3.,4.,5.,6.,8.,10.,12.5,15.0,20.,25.,30.,40.,60.,100};

  const int nBinY = 20;
  Float_t binsY[nBinY+1];
  float firstBinYWidth = 0.001;
  float binYWidthRatio = 1.27;
  binsY[0]=0;
  for(int i=1; i<=nBinY; i++)
    binsY[i] = binsY[i-1]+firstBinYWidth*pow(binYWidthRatio,i-1);
  cout<<"last y bin: "<<binsY[nBinY]<<endl;

  const int nBinZ = 20;
  Float_t binsZ[nBinZ+1];
  float firstBinZ = 3.5;
  float binWidthZ = 5;
  for(int i=0; i<=nBinZ; i++)
    binsZ[i] = firstBinZ+binWidthZ*i;
  
  const int nBinM = 60;
  Float_t binsM[nBinM];
  float minMassBin = 1.7;
  float massBinWidth = 0.005;
  for(int i=0; i<=nBinM; i++)
    binsM[i] = minMassBin + massBinWidth*i;

  TH3D* hMCPSignal = new TH3D("hMCPSignal",";p_{T} (GeV/c);D0 DCA (cm);flight distance significance",nBinX,binsX,nBinY,binsY,nBinZ,binsZ);
  TH3D* hMCNPSignal = new TH3D("hMCNPSignal",";p_{T} (GeV/c);D0 DCA (cm);flight distance significance",nBinX,binsX,nBinY,binsY,nBinZ,binsZ);
  TH3D* hPtMD0DcaMCPSignal = new TH3D("hPtMD0DcaMCPSignal",";p_{T} (GeV/c);m (GeV/c^{2});D^{0} DCA (cm)",nBinX,binsX,nBinM,binsM,nBinY,binsY);
  TH3D* hPtMD0DcaMCPSwapped = new TH3D("hPtMD0DcaMCPSwapped",";p_{T} (GeV/c);m (GeV/c^{2});D^{0} DCA (cm)",nBinX,binsX,nBinM,binsM,nBinY,binsY);
  
  hMCPSignal->Sumw2();
  hMCNPSignal->Sumw2();
  hPtMD0DcaMCPSignal->Sumw2();
  hPtMD0DcaMCPSwapped->Sumw2();
  
  tMCP->Draw("DsvpvDistance/DsvpvDisErr:DsvpvDistance*sin(Dalpha):Dpt>>hMCPSignal",weightfunctionreco*(cutpt&&cutPbPbMB&&cutSignal&&cutmc&&cutPrompt));
  tMCNP->Draw("DsvpvDistance/DsvpvDisErr:DsvpvDistance*sin(Dalpha):Dpt>>hMCNPSignal",weightfunctionreco*(cutpt&&cutPbPbMB&&cutSignal&&cutmc&&cutNonPrompt));
  tMCP->Draw("DsvpvDistance*sin(Dalpha):Dmass:Dpt>>hPtMD0DcaMCPSignal",weightfunctionreco*(cutpt&&cutPbPbMB&&cutmcSignal&&cutPrompt));
  tMCP->Draw("DsvpvDistance*sin(Dalpha):Dmass:Dpt>>hPtMD0DcaMCPSwapped",weightfunctionreco*(cutpt&&cutPbPbMB&&cutmcSwapped&&cutPrompt));
  
  outf->Write();
}