void readAllToysFromFile(TGraphErrors*tge, TFile*f, double d_quantile) { tge->Set(0); if (!f) throw std::logic_error("Cannot use readHypoTestResult: option toysFile not specified, or input file empty"); TDirectory *toyDir = f->GetDirectory(""); if (!toyDir) throw std::logic_error("Cannot use readHypoTestResult: empty toy dir in input file empty"); TIter next(toyDir->GetListOfKeys()); TKey *k; std::map<double, TTree*> gridCLsb; //r, <clsb, clserr> std::map<double, TTree*> gridCLb; //r, <clsb, clserr> std::map<double, double> gridQdata; //r, q_data bool bdata = false; while ((k = (TKey *) next()) != 0) { double rVal; TString name(k->GetName()); if(name.BeginsWith("SAMPLING_SB_TESTED_R")){ rVal = name.ReplaceAll("SAMPLING_SB_TESTED_R","").Atof(); TTree *t = dynamic_cast<TTree *>(toyDir->Get(k->GetName())); gridCLsb[rVal]=t; if (_debug > 2) std::cout << " Do " << k->GetName() << " -> " << name << " --> " << rVal << " tsb->entries= "<<t->GetEntries()<< std::endl; }else if(name.BeginsWith("SAMPLING_B_TESTED_R")){ rVal = name.ReplaceAll("SAMPLING_B_TESTED_R","").Atof(); TTree *t = dynamic_cast<TTree *>(toyDir->Get(k->GetName())); gridCLb[rVal]=t; if (_debug > 2) std::cout << " Do " << k->GetName() << " -> " << name << " --> " << rVal << " tb->entries= "<<t->GetEntries()<< std::endl; }else if(name.BeginsWith("DATA_R")){ name.ReplaceAll("DATA_R",""); TString tmp = name; rVal = tmp.Remove(tmp.Index("_"), tmp.Length()).Atof(); name.Remove(0,name.Index("_Q")+2); gridQdata[rVal]=name.Atof(); if (_debug > 2) std::cout << " Do " << k->GetName() << " -> " << tmp << " --> " << rVal << " Q_data ="<<name<<" --> "<<name.Atof()<< std::endl; bdata = true; }else if(!bdata && name.BeginsWith("TESTED_R")){ rVal = name.ReplaceAll("TESTED_R","").Atof(); TTree *t = dynamic_cast<TTree *>(toyDir->Get(k->GetName())); if(t!=NULL) { TBranch *brQ; double q; t->SetBranchAddress("brT", &q, &brQ); t->GetEntry(0); gridQdata[rVal]=q; if (_debug > 2) std::cout << " Do " << k->GetName() << " -> " << name << " --> " << rVal << " Q_data ="<<q<< std::endl; } } } int i = 0, n = gridCLsb.size(); if(_debug)cout<<" grid size = "<<n<<endl; int n_valid = 0; for (std::map<double, TTree *>::iterator itg = gridCLsb.begin(), edg = gridCLsb.end(); itg != edg; ++itg) { double cls, clserr; GetCLs(gridQdata[itg->first], itg->second, gridCLb[itg->first], cls, clserr, d_quantile); //if(itg->first != 1.74 && itg->first != 1.95) continue; if(cls!=1 and clserr==0)continue; if(cls>0.9) continue; if(cls<0.0001) continue; if(clserr>=cls)continue; if( scanRmin >= 0 && itg->first < scanRmin ) continue; if( scanRmax >= 0 && itg->first > scanRmax ) continue; n_valid+=1; tge->Set(n_valid); tge->SetPoint( n_valid-1, itg->first, cls ); tge->SetPointError(n_valid-1, 0, clserr); if(_debug)cout<<" input grid: r="<<itg->first<<" cls="<<cls<<"+/-"<<clserr<<endl; i++; } if(_debug)cout<<"tge->N = "<<tge->GetN()<<endl; }
void ReadTree_normDet(){ bool testrun = 0; const int norder_ = 2; const double vtxCut = 15.; const double ptMin = 0.3; const double ptMax = 3.00; const double etaMax = 1.0; static const int ptBinMin = 0; static const int ptBinMax = nptbinsDefault-1; static const int etaBinMin = 0; //0; static const int etaBinMax = netabinsDefault-1; TFile * fAna; TTree * tree; double centval; double vtx; TH2D * sumw; TH2D * sumwqx; TH2D * sumwqy; TH2I * hMult; TFile * fVNDet; TH1D * hVNDetX_0; TH1D * hVNDetY_0; TH1D * hVNDetX_1; TH1D * hVNDetY_1; TH1D * hVNDetX_full; TH1D * hVNDetY_full; TFile * fHists; TDirectory * qwebye; TH2D * hVn2Dfull[NCENT]; TH2D * hVn2Dsub0[NCENT]; TH2D * hVn2Dsub1[NCENT]; TH2D * hVn2D0v1[NCENT]; TH1D * hVnFull[NCENT]; TH1D * hVnSub0[NCENT]; TH1D * hVnSub1[NCENT]; TH1I * Mult[NCENT]; TH2D * h2Vn2D0v1[NCENT]; TH1D * h2Vn2D0v1Magnitude[NCENT]; double VnRaw_x_0; double VnRaw_y_0; double VnRaw_x_1; double VnRaw_y_1; double VnRaw_x_full; double VnRaw_y_full; double sumw_0; double sumw_1; double sumw_full; double VnCorrected_x_0; double VnCorrected_y_0; double VnCorrected_x_1; double VnCorrected_y_1; double VnCorrected_x_full; double VnCorrected_y_full; int evtMult_0; int evtMult_1; int evtMult_full; // // MAIN // setTDRStyle(); TH1D::SetDefaultSumw2(); TH2D::SetDefaultSumw2(); TH1I::SetDefaultSumw2(); //-- Set up analyzer objects fAna = new TFile("/rfs/jcastle/PbPb2015/PixelTracking_MB2/EbyETree_SMEARpt.root"); tree = (TTree *) fAna->Get("ebyeana/tree"); sumwqx = new TH2D(Form("sumwqx%i", norder_), Form("sumwqx%i", norder_), nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); sumwqy = new TH2D(Form("sumwqy%i", norder_), Form("sumwqy%i", norder_), nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); sumw = new TH2D("sumw", "sumw", nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); hMult = new TH2I("hMult", "hMult", nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); tree->SetBranchAddress("Cent", ¢val); tree->SetBranchAddress("Vtx", &vtx); tree->SetBranchAddress("mult", &hMult); tree->SetBranchAddress(Form("sumwqx%i", norder_), &sumwqx); tree->SetBranchAddress(Form("sumwqy%i", norder_), &sumwqy); tree->SetBranchAddress("sumw", &sumw); //-- Set up VN detector objects fVNDet = new TFile( Form("V%iDet.root", norder_ ) ); hVNDetX_0 = (TH1D*) fVNDet->Get("SubEvt_0/hVNDetX_0"); hVNDetY_0 = (TH1D*) fVNDet->Get("SubEvt_0/hVNDetY_0"); hVNDetX_1 = (TH1D*) fVNDet->Get("SubEvt_1/hVNDetX_1"); hVNDetY_1 = (TH1D*) fVNDet->Get("SubEvt_1/hVNDetY_1"); hVNDetX_full = (TH1D*) fVNDet->Get("FullEvt/hVNDetX_full"); hVNDetY_full = (TH1D*) fVNDet->Get("FullEvt/hVNDetY_full"); //-- Setup the output objects fHists = new TFile("CastleEbyE.root","recreate"); qwebye = (TDirectory*) fHists->mkdir("qwebye"); for(int icent = 0; icent < NCENT; icent++){ qwebye->cd(); hVn2Dfull[icent] = new TH2D(Form("hVn2Dfull_c%i", icent), Form("hVn2Dfull_c%i", icent), 2*NBins, -vnMax[norder_], vnMax[norder_], 2*NBins, -vnMax[norder_], vnMax[norder_] ); hVn2Dfull[icent]->SetOption("colz"); hVn2Dfull[icent]->GetXaxis()->SetTitle( Form("v_{%i,x}^{obs}", norder_) ); hVn2Dfull[icent]->GetYaxis()->SetTitle( Form("v_{%i,y}^{obs}", norder_) ); hVn2Dsub0[icent] = new TH2D( Form("hVn2Dsub0_c%i", icent), Form("hVn2Dsub0_c%i", icent), 2*NBins, -vnMax[norder_], vnMax[norder_], 2*NBins, -vnMax[norder_], vnMax[norder_] ); hVn2Dsub0[icent]->SetOption("colz"); hVn2Dsub0[icent]->GetXaxis()->SetTitle( Form("v_{%i,x}^{obs,a}", norder_) ); hVn2Dsub0[icent]->GetYaxis()->SetTitle( Form("v_{%i,y}^{obs,a}", norder_) ); hVn2Dsub1[icent] = new TH2D( Form("hVn2Dsub1_c%i", icent), Form("hVn2Dsub1_c%i", icent), 2*NBins, -vnMax[norder_], vnMax[norder_], 2*NBins, -vnMax[norder_], vnMax[norder_] ); hVn2Dsub1[icent]->SetOption("colz"); hVn2Dsub1[icent]->GetXaxis()->SetTitle( Form("v_{%i,x}^{obs,b}", norder_) ); hVn2Dsub1[icent]->GetYaxis()->SetTitle( Form("v_{%i,y}^{obs,b}", norder_) ); hVn2D0v1[icent] = new TH2D( Form("hVn2D0v1_c%i", icent), Form("hVn2D0v1_c%i", icent), 2*NBins, -vnMax[norder_], vnMax[norder_], 2*NBins, -vnMax[norder_], vnMax[norder_] ); hVn2D0v1[icent]->SetOption("colz"); hVn2D0v1[icent]->GetXaxis()->SetTitle( Form("v_{%i,x}^{obs,a} - v_{%i,x}^{obs,b}", norder_, norder_) ); hVn2D0v1[icent]->GetYaxis()->SetTitle( Form("v_{%i,y}^{obs,a} - v_{%i,y}^{obs,b}", norder_, norder_) ); hVnFull[icent] = new TH1D( Form("hVnFull_c%i", icent), Form("hVnFull_c%i", icent), NBins, 0., vnMax[norder_] ); hVnFull[icent]->GetXaxis()->SetTitle( Form("v_{%i}", norder_) ); hVnFull[icent]->GetYaxis()->SetTitle( "Events" ); hVnSub0[icent] = new TH1D( Form("hVnSub0_c%i", icent), Form("hVnSub0_c%i", icent), NBins, 0., vnMax[norder_] ); hVnSub0[icent]->GetXaxis()->SetTitle( Form("v_{%i}^{obs,a}", norder_) ); hVnSub1[icent] = new TH1D( Form("hVnSub1_c%i", icent), Form("hVnSub1_c%i", icent), NBins, 0., vnMax[norder_] ); hVnSub1[icent]->GetXaxis()->SetTitle( Form("v_{%i}^{obs,b}", norder_) ); Mult[icent] = new TH1I( Form("Mult_c%i", icent), Form("Mult_c%i", icent), 250, 1, 5000 ); Mult[icent]->GetXaxis()->SetTitle("Multiplicity"); h2Vn2D0v1[icent] = new TH2D( Form("h2Vn2D0v1_c%i", icent), Form("h2Vn2D0v1_c%i", icent), 2*NBins, -vnMax[norder_], vnMax[norder_], 2*NBins, -vnMax[norder_], vnMax[norder_] ); h2Vn2D0v1[icent]->GetXaxis()->SetTitle( Form("(v_{%i,x}^{obs,a} - v_{%i,x}^{obs,b})/2", norder_, norder_) ); h2Vn2D0v1[icent]->GetYaxis()->SetTitle( Form("(v_{%i,y}^{obs,a} - v_{%i,y}^{obs,b})/2", norder_, norder_) ); h2Vn2D0v1[icent]->SetOption("colz"); h2Vn2D0v1Magnitude[icent] = new TH1D( Form("h2Vn2D0v1Magnitude_c%i", icent), Form("h2Vn2D0v1Magnitude_c%i", icent), NBins, 0., vnMax[norder_] ); h2Vn2D0v1Magnitude[icent]->GetXaxis()->SetTitle( Form("|(v_{%i,x}^{obs,a} - v_{%i,x}^{obs,b})/2|", norder_, norder_) ); } // // Tree Loop // cout<<"Begin FINAL loop, contains "<<tree->GetEntries()<<" Events"<<endl; int N; if( testrun ) N = 10000; else N = tree->GetEntries(); for(int ievent = 0; ievent < N; ievent++) { if((ievent+1)% 500000 == 0) cout<<"Processing Event "<<ievent+1<<"\t"<<100.*(ievent+1)/(double)N<<"% Completed"<<endl; tree->GetEntry(ievent); //-- Vertex Cut if(TMath::Abs(vtx) > vtxCut) continue; //-- Calculate centbin if( centval > cent_max[NCENT-1]) continue; int icent = hCentBins.FindBin(centval)-1; //-- Reset raw and sumw values VnRaw_x_0 = 0; VnRaw_y_0 = 0; VnRaw_x_1 = 0; VnRaw_y_1 = 0; VnRaw_x_full = 0; VnRaw_y_full = 0; sumw_0 = 0; sumw_1 = 0; sumw_full = 0; evtMult_0 = 0; evtMult_1 = 0; evtMult_full = 0; //-- Begin analyzer histogram loops for(int ipt = ptBinMin; ipt <= ptBinMax; ipt++){ for(int ieta = etaBinMin; ieta <= etaBinMax; ieta++){ double pt = sumw->GetXaxis()->GetBinCenter(ipt+1); double eta = sumw->GetYaxis()->GetBinCenter(ieta+1); if( pt < ptMin || pt > ptMax ) continue; if( fabs( eta ) > etaMax ) continue; if(sumw->GetBinContent(ipt+1,ieta+1) !=0){ //-- Subevent 0 (eta >= 0) if(etabinsDefault[ieta] >= 0){ VnRaw_x_0 += sumwqx->GetBinContent(ipt+1,ieta+1); VnRaw_y_0 += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_0 += sumw->GetBinContent(ipt+1,ieta+1); evtMult_0 += hMult->GetBinContent(ipt+1,ieta+1); } //-- Subevent 1 (eta < 0) else{ VnRaw_x_1 += sumwqx->GetBinContent(ipt+1,ieta+1); VnRaw_y_1 += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_1 += sumw->GetBinContent(ipt+1,ieta+1); evtMult_1 += hMult->GetBinContent(ipt+1,ieta+1); } //-- Full Event VnRaw_x_full += sumwqx->GetBinContent(ipt+1,ieta+1); VnRaw_y_full += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_full += sumw->GetBinContent(ipt+1,ieta+1); evtMult_full += hMult->GetBinContent(ipt+1,ieta+1); } } //-- End eta loop } //-- End pt loop //-- Fill Histograms, only use events that have at least two tracks in each SE if(sumw_0 == 0 || sumw_1 == 0 || evtMult_1 < 2 || evtMult_full < 2) continue; VnRaw_x_full /= sumw_full; VnRaw_y_full /= sumw_full; VnRaw_x_0 /= sumw_0; VnRaw_y_0 /= sumw_0; VnRaw_x_1 /= sumw_1; VnRaw_y_1 /= sumw_1; //-- Full Tracker VnCorrected_x_full = VnRaw_x_full - hVNDetX_full->GetBinContent(icent+1); VnCorrected_y_full = VnRaw_y_full - hVNDetY_full->GetBinContent(icent+1); double vn_full = TMath::Sqrt( VnCorrected_x_full * VnCorrected_x_full + VnCorrected_y_full * VnCorrected_y_full); hVnFull[icent] -> Fill( vn_full ); hVn2Dfull[icent] -> Fill(VnCorrected_x_full, VnCorrected_y_full); Mult[icent]->Fill(evtMult_full); //-- SubEvt 0 (Eta > 0) VnCorrected_x_0 = VnRaw_x_0 - hVNDetX_0->GetBinContent(icent+1); VnCorrected_y_0 = VnRaw_y_0 - hVNDetY_0->GetBinContent(icent+1); double vn_0 = TMath::Sqrt( VnCorrected_x_0 * VnCorrected_x_0 + VnCorrected_y_0 * VnCorrected_y_0 ); hVnSub0[icent] -> Fill( vn_0 ); hVn2Dsub0[icent] -> Fill(VnCorrected_x_0, VnCorrected_y_0); //-- SubEvt 1 (Eta < 0) VnCorrected_x_1 = VnRaw_x_1 - hVNDetX_1->GetBinContent(icent+1); VnCorrected_y_1 = VnRaw_y_1 - hVNDetY_1->GetBinContent(icent+1); double vn_1 = TMath::Sqrt( VnCorrected_x_1 * VnCorrected_x_1 + VnCorrected_y_1 *VnCorrected_y_1 ); hVnSub1[icent] -> Fill( vn_1 ); hVn2Dsub1[icent] -> Fill(VnCorrected_x_1, VnCorrected_y_1); //-- SubEvt Difference double vn0m1_x = VnCorrected_x_0 - VnCorrected_x_1; double vn0m1_y = VnCorrected_y_0 - VnCorrected_y_1; hVn2D0v1[icent]->Fill(vn0m1_x, vn0m1_y); //-- SubEvt Difference for DD response double vn0m1_x2 = (VnCorrected_x_0 - VnCorrected_x_1) / 2.; double vn0m1_y2 = (VnCorrected_y_0 - VnCorrected_y_1) / 2.; h2Vn2D0v1[icent]->Fill(vn0m1_x2, vn0m1_y2); double vn0m12 = TMath::Sqrt( pow(vn0m1_x2, 2) + pow(vn0m1_y2, 2) ); h2Vn2D0v1Magnitude[icent]->Fill(vn0m12); } //-- End Event loop cout<<"End FINAL loop!"<<endl; fHists->Write(); cout<<"File written, process completed"<<endl; }
//int add_branch(TString particle,int energy_flag){ int main(){ TString particle; cerr<<"--- Particle (n or p)"; cin>>particle; Int_t energy_flag; cerr<<"--- Energy Flag (11 or 8)"; cin>>energy_flag; gStyle->SetOptStat(1); //const double Lumi = 1.0e36; // cm-2*s-1, for He3 nuclear not for nucleons //const double KHz = 1e-3; //const double nBcm2 = 1e-33; double hMass = 0.0; double EBeam = 0.0; TString Target = ""; TString TargetName = ""; TString Energy = ""; gRandom->SetSeed(0); /* Target and Energy variables{{{*/ if(particle=="p"){ TargetName = "Proton"; Target = "NH3"; hMass = 0.938272; if(energy_flag==11){ Energy = "11GeV"; EBeam = 11.0; } else if(energy_flag==8){ Energy = "8.8GeV"; EBeam = 8.80; } }else if(particle=="n"){ TargetName = "Neutron"; Target = "3he"; hMass = 0.939565; if(energy_flag==11){ Energy = "11GeV"; EBeam = 11.0; } else if(energy_flag==8){ Energy = "8.8GeV"; EBeam = 8.80; } }/*}}}*/ /*CLEO{{{*/ TCanvas *dummycavan = new TCanvas(); TFile *file_negative=new TFile("../acceptance/acceptance_solid_SIDIS_NH3_electron_output.root","r"); TFile *file_positive=new TFile("../acceptance/acceptance_solid_SIDIS_NH3_pionp_output.root","r"); TFile *file_photon =new TFile("../acceptance/acceptance_solid_SIDIS_NH3_photon_output.root","r"); //negative particle forward angle acceptance TH3F *accep_ele_forward=(TH3F*)file_negative->Get("acceptance_ThetaPhiP_forwardangle"); //negative particle large angle acceptance TH3F *accep_ele_large=(TH3F*)file_negative->Get("acceptance_ThetaPhiP_largeangle"); //neutral particle forward angle acceptance TH3F *accep_pho_forward=(TH3F*)file_photon->Get("acceptance_ThetaPhiP_forwardangle"); //neutral particle large angle acceptance TH3F *accep_pho_large=(TH3F*)file_photon->Get("acceptance_ThetaPhiP_largeangle"); TH3F *accep_had_forward; TH3F *accep_had_large; if(particle=="pim"){//pionm is the same as electron acceptance accep_had_forward=(TH3F*)accep_ele_forward->Clone("accep_had_forward"); accep_had_large =(TH3F*)accep_ele_large->Clone("accep_had_large"); } if(particle=="pip"){ // for positive pions accep_had_forward=(TH3F*)file_positive->Get("acceptance_ThetaPhiP_forwardangle"); accep_had_large=(TH3F*)file_positive->Get("acceptance_ThetaPhiP_largeangle"); } if(particle=="p"){ // for positive pions accep_had_forward=(TH3F*)file_positive->Get("acceptance_ThetaPhiP_forwardangle"); accep_had_large=(TH3F*)file_positive->Get("acceptance_ThetaPhiP_largeangle"); } if(particle=="n"){ // for positive pions // accep_had_forward=(TH3F*)file_photon->Get("acceptance_ThetaPhiP_forwardangle"); // accep_had_large=(TH3F*)file_photon->Get("acceptance_ThetaPhiP_largeangle"); accep_had_forward=(TH3F*)accep_pho_forward->Clone("accep_had_forward"); accep_had_large =(TH3F*)accep_pho_large->Clone("accep_had_large"); } /*}}}*/ /*Vectors & Variables{{{*/ TLorentzVector *P_E0 = new TLorentzVector();//incoming electron TLorentzVector *P_e_i = new TLorentzVector();//scattered electron TLorentzVector *P_e_f = new TLorentzVector();//scattered electron with Eloss TLorentzVector *P_g = new TLorentzVector();//photon TLorentzVector *P_h = new TLorentzVector();//proton or neutron TLorentzVector *P_t = new TLorentzVector();//target, either proton or neutron TLorentzVector *P_e_res = new TLorentzVector();//scattered electron with resolution TLorentzVector *P_g_res = new TLorentzVector();//photon with resolution Double_t vertexz, E0; Double_t ePx_ini, ePy_ini, ePz_ini; //Double_t hP_ini, hPx_ini, hPy_ini,hPz_ini,hTheta_ini,hPhi_ini; Double_t ePx, ePy, ePz, gPx, gPy, gPz, hPx, hPy, hPz; Double_t eP_ini,eP, gP,hP; Double_t Q2, x, t, phi, XS_P, XS_M, XS_BHp, XS_BHm, PSF; Double_t ePhi_ini, ePhi, gPhi,hPhi; Double_t eTheta_ini, eTheta, gTheta,hTheta; Int_t Ngen,Nacc; //Define new measured quantities that include detector resolutions double eE_i, eE_f, gE, hE; double eE_i_res, eE_f_res,eP_res, eTheta_res, ePhi_res, ePx_res, ePy_res, ePz_res; double gP_res, gTheta_res, gPhi_res, gPx_res, gPy_res, gPz_res; double MM = 0.0,MM_res = 0.0, W=0.0, Wp=0.0; int e_theta_bin= 0, e_phi_bin= 0, e_p_bin=0; int h_theta_bin= 0, h_phi_bin= 0, h_p_bin=0; int g_theta_bin= 0, g_phi_bin=0, g_p_bin=0; double e_acc_f= 0.0, e_acc_l= 0.0, g_acc_f=0, g_acc_l=0, h_acc_f=0, h_acc_l=0; /*}}}*/ /*DVCS: Define Rootfile and variables{{{*/ TString filename = ""; if(particle=="p"){ if(energy_flag==11) filename = "../DVCS_Proton_11GeV.root"; else if(energy_flag==8) filename = "../DVCS_Proton_8.8GeV.root"; }else if(particle=="n"){ if(energy_flag==11) filename = "../DVCS_Neutron_11GeV.root"; else if(energy_flag==8) filename = "../DVCS_Neutron_8.8GeV.root"; } TFile *file = new TFile(filename.Data(), "r"); TTree *T = (TTree*) file->Get("T"); T->SetBranchAddress("vertexz", &vertexz); T->SetBranchAddress("E0", &E0); T->SetBranchAddress("eP_ini", &eP_ini); T->SetBranchAddress("ePx_ini", &ePx_ini); T->SetBranchAddress("ePy_ini", &ePy_ini); T->SetBranchAddress("ePz_ini", &ePz_ini); T->SetBranchAddress("eTheta_ini",&eTheta_ini); T->SetBranchAddress("ePhi_ini",&ePhi_ini); T->SetBranchAddress("eP", &eP); T->SetBranchAddress("ePx", &ePx); T->SetBranchAddress("ePy", &ePy); T->SetBranchAddress("ePz", &ePz); T->SetBranchAddress("eTheta",&eTheta); T->SetBranchAddress("ePhi",&ePhi); T->SetBranchAddress("gP", &gP); T->SetBranchAddress("gPx", &gPx); T->SetBranchAddress("gPy", &gPy); T->SetBranchAddress("gPz", &gPz); T->SetBranchAddress("gTheta", &gTheta); T->SetBranchAddress("gPhi", &gPhi); T->SetBranchAddress("hP", &hP); T->SetBranchAddress("hPx", &hPx); T->SetBranchAddress("hPy", &hPy); T->SetBranchAddress("hPz", &hPz); T->SetBranchAddress("hTheta",&hTheta); T->SetBranchAddress("hPhi",&hPhi); T->SetBranchAddress("Q2", &Q2); T->SetBranchAddress("x", &x); T->SetBranchAddress("t", &t); T->SetBranchAddress("phi", &phi); T->SetBranchAddress("XS_P", &XS_P); T->SetBranchAddress("XS_M", &XS_M); T->SetBranchAddress("XS_BHp", &XS_BHp); T->SetBranchAddress("XS_BHm", &XS_BHm); T->SetBranchAddress("PSF", &PSF); T->SetBranchAddress("Ngen", &Ngen); T->SetBranchAddress("Nacc", &Nacc); Long64_t N_entries=T->GetEntries(); T->GetEntry(0); Long64_t N_gen = Ngen; cout<<"DVCS: total generated events number: "<<N_gen<<"--- and accepted: "<<N_entries<<endl; /*}}}*/ /*Add new branches{{{*/ filename.ReplaceAll(".root","_New0.root"); TFile *newfile = new TFile(filename.Data(), "recreate"); TTree *NewT = T->CloneTree(0);; NewT->Branch("W", &W, "W/D"); NewT->Branch("Wp", &Wp, "Wp/D"); NewT->Branch("MM", &MM, "MM/D"); NewT->Branch("MM_res", &MM_res, "MM_res/D"); NewT->Branch("e_acc_f", &e_acc_f, "e_acc_f/D"); NewT->Branch("e_acc_l", &e_acc_l, "e_acc_l/D"); NewT->Branch("g_acc_f", &g_acc_f, "g_acc_f/D"); NewT->Branch("g_acc_l", &g_acc_l, "g_acc_l/D"); NewT->Branch("h_acc_f", &h_acc_f, "h_acc_f/D"); NewT->Branch("h_acc_l", &h_acc_l, "h_acc_l/D"); NewT->Branch("eP_res", &eP_res, "eP_res/D"); NewT->Branch("ePx_res", &ePx_res, "ePx_res/D"); NewT->Branch("ePy_res", &ePy_res, "ePy_res/D"); NewT->Branch("ePz_res", &ePz_res, "ePz_res/D"); NewT->Branch("eTheta_res", &eTheta_res, "eTheta_res/D"); NewT->Branch("ePhi_res", &ePhi_res, "ePhi_res/D"); NewT->Branch("gP_res", &gP_res, "gP_res/D"); NewT->Branch("gPx_res", &gPx_res, "gPx_res/D"); NewT->Branch("gPy_res", &gPy_res, "gPy_res/D"); NewT->Branch("gPz_res", &gPz_res, "gPz_res/D"); NewT->Branch("gTheta_res", &gTheta_res, "gTheta_res/D"); NewT->Branch("gPhi_res", &gPhi_res, "gPhi_res/D"); Double_t tmin, BSA_L, TSA_L, DSA_L; Double_t Sigma_L, SigmaPP_L,SigmaPM_L, SigmaMP_L, SigmaMM_L; Double_t BSA_Tx, TSA_Tx, DSA_Tx; Double_t Sigma_Tx, SigmaPP_Tx,SigmaPM_Tx, SigmaMP_Tx, SigmaMM_Tx; Double_t BSA_Ty, TSA_Ty, DSA_Ty; Double_t Sigma_Ty, SigmaPP_Ty,SigmaPM_Ty, SigmaMP_Ty, SigmaMM_Ty; NewT->Branch("tmin", &tmin, "tmin/D"); NewT->Branch("Sigma_L", &Sigma_L, "Sigma_L/D"); NewT->Branch("SigmaPP_L", &SigmaPP_L, "SigmaPP_L/D"); NewT->Branch("SigmaPM_L", &SigmaPM_L, "SigmaPM_L/D"); NewT->Branch("SigmaMP_L", &SigmaMP_L, "SigmaMP_L/D"); NewT->Branch("SigmaMM_L", &SigmaMM_L, "SigmaMM_L/D"); NewT->Branch("BSA_L", &BSA_L, "BSA_L/D"); NewT->Branch("TSA_L", &TSA_L, "TSA_L/D"); NewT->Branch("DSA_L", &DSA_L, "DSA_L/D"); NewT->Branch("Sigma_Tx", &Sigma_Tx, "Sigma_Tx/D"); NewT->Branch("SigmaPP_Tx", &SigmaPP_Tx, "SigmaPP_Tx/D"); NewT->Branch("SigmaPM_Tx", &SigmaPM_Tx, "SigmaPM_Tx/D"); NewT->Branch("SigmaMP_Tx", &SigmaMP_Tx, "SigmaMP_Tx/D"); NewT->Branch("SigmaMM_Tx", &SigmaMM_Tx, "SigmaMM_Tx/D"); NewT->Branch("BSA_Tx", &BSA_Tx, "BSA_Tx/D"); NewT->Branch("TSA_Tx", &TSA_Tx, "TSA_Tx/D"); NewT->Branch("DSA_Tx", &DSA_Tx, "DSA_Tx/D"); NewT->Branch("Sigma_Ty", &Sigma_Ty, "Sigma_Ty/D"); NewT->Branch("SigmaPP_Ty", &SigmaPP_Ty, "SigmaPP_Ty/D"); NewT->Branch("SigmaPM_Ty", &SigmaPM_Ty, "SigmaPM_Ty/D"); NewT->Branch("SigmaMP_Ty", &SigmaMP_Ty, "SigmaMP_Ty/D"); NewT->Branch("SigmaMM_Ty", &SigmaMM_Ty, "SigmaMM_Ty/D"); NewT->Branch("BSA_Ty", &BSA_Ty, "BSA_Ty/D"); NewT->Branch("TSA_Ty", &TSA_Ty, "TSA_Ty/D"); NewT->Branch("DSA_Ty", &DSA_Ty, "DSA_Ty/D"); /*}}}*/ TString Data_Dir = "/work/halla/solid/yez/dvcs/DVCS_XS_Grid/"; TString TargetPol = ""; //Tx, Ty, L Int_t Debug = 0, err = 0; DVCSGrid *grid = new DVCSGrid(); grid->Init(EBeam,TargetName.Data(), Data_Dir.Data(), Debug); /*Loop DVCS Events{{{*/ for(int i=0;i<N_entries; i++){ T->GetEntry(i); grid->FindBin(Q2, x, -t, phi);// here -t was used instead of t //grid->PrintRanges(); tmin = grid->GetTMin(); /*Reading the Longitudinal Target Spin{{{*/ SigmaPP_L = 1e-36; SigmaPM_L = 1e-36; SigmaMP_L = 1e-36; SigmaMM_L = 1e-36; Sigma_L = 1e-36; BSA_L = 1e-36; TSA_L = 1e-36; DSA_L = 1e-36; TargetPol = "L"; err = grid->LoadXS(TargetPol); if(err>=0){ //grid->PrintXS(); SigmaPP_L = grid->GetSigmaPP();//++ SigmaPM_L = grid->GetSigmaPM();//+- SigmaMP_L = grid->GetSigmaMP();//-+ SigmaMM_L = grid->GetSigmaMM();//-- Sigma_L = grid->GetSigma();//average of four XSs above BSA_L = grid->GetBSA();//beam spin asym TSA_L = grid->GetTSA();//target spin asym DSA_L = grid->GetDSA();//double spin asym } /*Reading the Longitudinal Target Spin}}}*/ /*Reading the Transverse Target Spin on x{{{*/ SigmaPP_Tx = 1e-36;SigmaPM_Tx = 1e-36; SigmaMP_Tx = 1e-36; SigmaMM_Tx = 1e-36; Sigma_Tx = 1e-36; BSA_Tx = 1e-36;TSA_Tx = 1e-36;DSA_Tx = 1e-36; TargetPol = "Tx"; err = grid->LoadXS(TargetPol); if(err>=0){ //grid->PrintXS(); SigmaPP_Tx = grid->GetSigmaPP();//++ SigmaPM_Tx = grid->GetSigmaPM();//+- SigmaMP_Tx = grid->GetSigmaMP();//-+ SigmaMM_Tx = grid->GetSigmaMM();//-- Sigma_Tx = grid->GetSigma();//average of four XSs above BSA_Tx = grid->GetBSA();//beam spin asym TSA_Tx = grid->GetTSA();//target spin asym DSA_Tx = grid->GetDSA();//double spin asym // cerr<<Form("-Tx-- BS = %e (%e)", BSA_Tx, (SigmaPP_Tx+SigmaPM_Tx - SigmaMP_Tx-SigmaMM_Tx)/4. )<<endl; // cerr<<Form("-Tx-- TS = %e (%e)", TSA_Tx, (SigmaPP_Tx+SigmaMP_Tx - SigmaPM_Tx-SigmaMM_Tx)/4. )<<endl; // cerr<<Form("-Tx-- DS = %e (%e)", DSA_Tx, (SigmaPP_Tx+SigmaMM_Tx - SigmaPM_Tx-SigmaMP_Tx)/4. )<<endl; // cerr<<Form("-Tx-- AVG = %e ", Sigma_Tx)<<endl; } /*Reading the Transverse Target Spin on x}}}*/ /*Reading the Transverse Target Spin on y{{{*/ SigmaPP_Ty = 1e-36;SigmaPM_Ty = 1e-36; SigmaMP_Ty = 1e-36; SigmaMM_Ty = 1e-36; Sigma_Ty = 1e-36; BSA_Ty = 1e-36;TSA_Ty = 1e-36;DSA_Ty = 1e-36; TargetPol = "Ty"; err = grid->LoadXS(TargetPol); if(err>=0){ //grid->PrintXS(); SigmaPP_Ty = grid->GetSigmaPP();//++ SigmaPM_Ty = grid->GetSigmaPM();//+- SigmaMP_Ty = grid->GetSigmaMP();//-+ SigmaMM_Ty = grid->GetSigmaMM();//-- Sigma_Ty = grid->GetSigma();//average of four XSs above BSA_Ty = grid->GetBSA();//beam spin asym TSA_Ty = grid->GetTSA();//target spin asym DSA_Ty = grid->GetDSA();//double spin asym } /*Reading the Transverse Target Spin on y}}}*/ /*Acceptance{{{*/ e_theta_bin= 0; e_phi_bin=0;; e_p_bin=0; e_acc_f= -1e6; e_acc_l= -1e6; g_acc_f= -1e6; g_acc_l= -1e6; MM = -1e6; MM_res = -1e6; W = -1e6;; Wp = -1e6; eP_res = -1e6; ePx_res = -1e6; ePy_res = -1e6; ePz_res = -1e6; eTheta_res = -1e6; ePhi_res = -1e6; gP_res = -1e6; gPx_res = -1e6; gPy_res = -1e6; gPz_res = -1e6; gTheta_res = -1e6; gPhi_res = -1e6; e_theta_bin=int(eTheta/0.5)+1; //0.5 degree per bin e_phi_bin=int(ePhi/2.0)+1; //2 degree per bin e_p_bin=int(eP/0.1)+1; //0.1 GeV per bin for mom e_acc_f=accep_ele_forward->GetBinContent(e_theta_bin,e_phi_bin,e_p_bin); e_acc_l=accep_ele_large->GetBinContent(e_theta_bin,e_phi_bin,e_p_bin); if(eP<1.0||eTheta>14.5||eTheta<8.0)//GeV, CLEO e_acc_f=0.0;//Farward-Angle EC Cut at 1 GeV if(eP<1.0||eTheta<15.5||eTheta>24)//GeV,CLEO e_acc_l=0.0; //Larger-Angle EC Cut at 3 GeV if(e_acc_f>1.) e_acc_f=1.0; if(e_acc_l>1.) e_acc_l=1.0; h_theta_bin=int(hTheta/0.5)+1; //0.5 degree per bin h_phi_bin=int(hPhi/2.0)+1; //2 degree per bin h_p_bin=int(hP/0.1)+1; //0.1 GeV per bin h_acc_f=accep_had_forward->GetBinContent(h_theta_bin,h_phi_bin,h_p_bin); h_acc_l=accep_had_large->GetBinContent(h_theta_bin,h_phi_bin,h_p_bin); g_theta_bin=int(gTheta/0.5)+1; //0.5 degree per bin g_phi_bin=int(gPhi/2.0)+1; //2.0 degree per bin g_p_bin=int(gP/0.1)+1; //0.1 GeV per bin for mom g_acc_f=accep_pho_forward->GetBinContent(g_theta_bin,g_phi_bin,g_p_bin); g_acc_l=accep_pho_large->GetBinContent(g_theta_bin,g_phi_bin,g_p_bin); /*Additional cuts{{{*/ /* if(gTheta<=14.8&&gTheta>=8.0&&gP>=1.0&&gP<=11.){ g_acc_f=1.0; g_acc_l=0.0; } else if(gTheta<=24.0&&gTheta>=16.&&gP>=1.0&&gP<=11.){ g_acc_f=0.0; g_acc_l=1.0; }else{ g_acc_f=0.0; g_acc_l=0.0; } */ /*}}}*/ // double e_acceptance = e_acc_f+e_acc_l; // double g_acceptance = g_acc_f+g_acc_l; // double eg_acceptance = e_acceptance*g_acceptance; //double event_weight=(XS_P+XS_M)*PSF/N_gen*Lumi*nBcm2; //put into Hz, Note, XS in nb /*Acceptance}}}*/ /*Missing Mass w/o resolutions{{{*/ eE_i = sqrt(eP_ini*eP_ini + eMass*eMass); eE_f = sqrt(eP*eP + eMass*eMass); hE = sqrt(hP*hP + hMass*hMass); gE = gP; P_E0->SetPxPyPzE(0.,0.,E0, E0); P_t->SetPxPyPzE(0.,0.,0., hMass); P_e_i->SetPxPyPzE(ePx_ini, ePy_ini, ePz_ini, eE_i); P_e_f->SetPxPyPzE(ePx, ePy, ePz, eE_f); P_g->SetPxPyPzE(gPx, gPy, gPz, gE); P_h->SetPxPyPzE(hPx, hPy, hPz, hE); int err = CheckLaws(P_t, P_E0, P_e_i, P_g, P_h);//Check whether momentum and energy conserve first if (err < 1e-33){ cerr<<"---- Momentum and Energy Conservation Laws are broken!! Something is wrong!!!"<<endl; return -222; } MM = GetMM(P_t, P_E0, P_e_i, P_g); /*}}}*/ /*Missing Mass w resolutions{{{*/ ////////////////////////////////////////////////////////////////////////// //Now consider the detector resolution here ////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////// //Electron w/o E-loss eP_res = gRandom->Gaus(eP_ini, Sigma_EC_E*eP_ini);//GeV, for electron, E ~= P eTheta_res = gRandom->Gaus(eTheta_ini*Deg2Rad, Sigma_Theta_E);//rad ePhi_res = gRandom->Gaus(ePhi_ini*Deg2Rad, Sigma_Phi_E);//rad ePx_res = eP_res * sin(eTheta_res)*cos(ePhi_res); ePy_res = eP_res * sin(eTheta_res)*sin(ePhi_res); ePz_res = eP_res * cos(eTheta_res); eE_i_res = sqrt(eP_res*eP_res + eMass*eMass); P_e_res->SetPxPyPzE(ePx_res, ePy_res, ePz_res, eE_i_res); ///////////////////////////////////////// //Electron with E-loss /* eP_res = gRandom->Gaus(eP, Sigma_EC_E*sqrt(eP));//GeV, for electron, E ~= P eTheta_res = gRandom->Gaus(eTheta*Deg2Rad, Sigma_Theta_E);//rad ePhi_res = gRandom->Gaus(ePhi*Deg2Rad, Sigma_Phi_E);//rad ePx_res = eP_res * sin(eTheta_res)*cos(ePhi_res); ePy_res = eP_res * sin(eTheta_res)*sin(ePhi_res); ePz_res = eP_res * cos(eTheta_res); eE_f_res = sqrt(eP_res*eP_res + eMass*eMass); //P_e_res->SetPxPyPzE(ePx_res, ePy_res, ePz_res, eE_i_res); */ ///////////////////////////////////////// //Photon double gZ = Length-vertexz; double gX = gZ * tan(gTheta*Deg2Rad)*cos(gPhi*Deg2Rad); double gY = gZ * tan(gTheta*Deg2Rad)*sin(gPhi*Deg2Rad); double gX_res =gRandom->Gaus(gX, Sigma_X_G);//cm double gY_res =gRandom->Gaus(gY, Sigma_Y_G);//cm double gZ_res =gRandom->Gaus(gZ, Sigma_VZ);//cm gP_res = gRandom->Gaus(gP, Sigma_EC_G*sqrt(gP));//GeV, for photon, E = P gPhi_res = atan2(gY_res, gX_res); gTheta_res = atan2(sqrt(gX_res*gX_res+gY_res*gY_res), gZ_res); gPx_res = gP_res * sin(gTheta_res)*cos(gPhi_res); gPy_res = gP_res * sin(gTheta_res)*sin(gPhi_res); gPz_res = gP_res * cos(gTheta_res); P_g_res->SetPxPyPzE(gPx_res, gPy_res, gPz_res, gP_res); ///////////////////////////////////////// MM_res = GetMM(P_t, P_E0, P_e_res, P_g_res); ///////////////////////////////////////// /*}}}*/ W = (*P_E0 + *P_t - *P_e_i)*(*P_E0 + *P_t - *P_e_i); Wp = (*P_E0 + *P_t - *P_e_i - *P_h)*(*P_E0 + *P_t - *P_e_i - *P_h); W = sqrt(W); Wp = sqrt(Wp); if(!(i%1000)) cerr<<Form("--- Processing #event = %d/%d", i,(int)(N_entries) ) <<"\r"; NewT->Fill(); } /*}}}*/ /*Save and Free{{{*/ NewT->Write("",TObject::kOverwrite); newfile->Close(); file->Close(); delete grid; delete P_g; delete P_t; delete P_e_i; delete P_e_f; delete P_h; delete P_e_res; delete P_g_res; /*Save and Free}}}*/ }
//_________________________________________________________________________________________ Int_t checkPullTree(TString pathTree, TString pathNameThetaMap, TString pathNameSigmaMap, TString mapSuffix, const Int_t collType /*0: pp, 1: pPb, 2: PbPb*/, const Bool_t plotPull = kTRUE, const Double_t downScaleFactor = 1, TString pathNameSplinesFile = "", TString prSplinesName = "", TString fileNameTree = "bhess_PIDetaTree.root", TString treeName = "fTree") { const Bool_t isNonPP = collType != 0; const Double_t massProton = AliPID::ParticleMass(AliPID::kProton); Bool_t recalculateExpecteddEdx = pathNameSplinesFile != ""; TFile* f = 0x0; f = TFile::Open(Form("%s/%s", pathTree.Data(), fileNameTree.Data())); if (!f) { std::cout << "Failed to open tree file \"" << Form("%s/%s", pathTree.Data(), fileNameTree.Data()) << "\"!" << std::endl; return -1; } // Extract the data Tree TTree* tree = dynamic_cast<TTree*>(f->Get(treeName.Data())); if (!tree) { std::cout << "Failed to load data tree!" << std::endl; return -1; } // Extract the splines, if desired TSpline3* splPr = 0x0; if (recalculateExpecteddEdx) { std::cout << "Loading splines to recalculate expected dEdx!" << std::endl << std::endl; TFile* fSpl = TFile::Open(pathNameSplinesFile.Data()); if (!fSpl) { std::cout << "Failed to open spline file \"" << pathNameSplinesFile.Data() << "\"!" << std::endl; return 0x0; } TObjArray* TPCPIDResponse = (TObjArray*)fSpl->Get("TPCPIDResponse"); if (!TPCPIDResponse) { splPr = (TSpline3*)fSpl->Get(prSplinesName.Data()); // If splines are in file directly, without TPCPIDResponse object, try to load them if (!splPr) { std::cout << "Failed to load object array from spline file \"" << pathNameSplinesFile.Data() << "\"!" << std::endl; return 0x0; } } else { splPr = (TSpline3*)TPCPIDResponse->FindObject(prSplinesName.Data()); if (!splPr) { std::cout << "Failed to load splines from file \"" << pathNameSplinesFile.Data() << "\"!" << std::endl; return 0x0; } } } else std::cout << "Taking dEdxExpected from Tree..." << std::endl << std::endl; // Extract the correction maps TFile* fMap = TFile::Open(pathNameThetaMap.Data()); if (!fMap) { std::cout << "Failed to open thetaMap file \"" << pathNameThetaMap.Data() << "\"! Will not additionally correct data...." << std::endl; } TH2D* hMap = 0x0; if (fMap) { hMap = dynamic_cast<TH2D*>(fMap->Get(Form("hRefined%s", mapSuffix.Data()))); if (!hMap) { std::cout << "Failed to load theta map!" << std::endl; return -1; } } TFile* fSigmaMap = TFile::Open(pathNameSigmaMap.Data()); if (!fSigmaMap) { std::cout << "Failed to open simgaMap file \"" << pathNameSigmaMap.Data() << "\"!" << std::endl; return -1; } TH2D* hThetaMapSigmaPar1 = dynamic_cast<TH2D*>(fSigmaMap->Get("hThetaMapSigmaPar1")); if (!hThetaMapSigmaPar1) { std::cout << "Failed to load sigma map for par 1!" << std::endl; return -1; } Double_t c0 = -1; TNamed* c0Info = dynamic_cast<TNamed*>(fSigmaMap->Get("c0")); if (!c0Info) { std::cout << "Failed to extract c0 from file with sigma map!" << std::endl; return -1; } TString c0String = c0Info->GetTitle(); c0 = c0String.Atof(); printf("Loaded parameter 0 for sigma: %f\n\n", c0); if (plotPull) std::cout << "Plotting pull..." << std::endl << std::endl; else std::cout << "Plotting delta'..." << std::endl << std::endl; Long64_t nTreeEntries = tree->GetEntriesFast(); Double_t dEdx = 0.; // Measured dE/dx Double_t dEdxExpected = 0.; // Expected dE/dx according to parametrisation Double_t tanTheta = 0.; // Tangens of (local) theta at TPC inner wall Double_t pTPC = 0.; // Momentum at TPC inner wall UShort_t tpcSignalN = 0; // Number of clusters used for dEdx UChar_t pidType = 0; Int_t fMultiplicity = 0; //Double_t phiPrime = 0; // Only activate the branches of interest to save processing time tree->SetBranchStatus("*", 0); // Disable all branches tree->SetBranchStatus("pTPC", 1); tree->SetBranchStatus("dEdx", 1); tree->SetBranchStatus("dEdxExpected", 1); tree->SetBranchStatus("tanTheta", 1); tree->SetBranchStatus("tpcSignalN", 1); tree->SetBranchStatus("pidType", 1); //tree->SetBranchStatus("phiPrime", 1); if (isNonPP) tree->SetBranchStatus("fMultiplicity", 1); tree->SetBranchAddress("dEdx", &dEdx); tree->SetBranchAddress("dEdxExpected", &dEdxExpected); tree->SetBranchAddress("tanTheta", &tanTheta); tree->SetBranchAddress("tpcSignalN", &tpcSignalN); tree->SetBranchAddress("pTPC", &pTPC); tree->SetBranchAddress("pidType", &pidType); //tree->SetBranchAddress("phiPrime", &phiPrime); if (isNonPP) tree->SetBranchAddress("fMultiplicity", &fMultiplicity); // Output file TDatime daTime; TString savefileName = Form("%s%s_checkPullSigma_%04d_%02d_%02d__%02d_%02d.root", fileNameTree.ReplaceAll(".root", "").Data(), recalculateExpecteddEdx ? "_recalcdEdx" : "", daTime.GetYear(), daTime.GetMonth(), daTime.GetDay(), daTime.GetHour(), daTime.GetMinute()); TFile* fSave = TFile::Open(Form("%s/%s", pathTree.Data(), savefileName.Data()), "recreate"); if (!fSave) { std::cout << "Failed to open save file \"" << Form("%s/%s", pathTree.Data(), savefileName.Data()) << "\"!" << std::endl; return -1; } const Double_t pBoundLow = 0.1; const Double_t pBoundUp = 5; const Int_t nBins1 = TMath::Ceil(180 / downScaleFactor); const Int_t nBins2 = TMath::Ceil(100 / downScaleFactor); const Int_t nBins3 = TMath::Ceil(60 / downScaleFactor); const Int_t nPbinsForMap = nBins1 + nBins2 + nBins3; Double_t binsPforMap[nPbinsForMap + 1]; Double_t binWidth1 = (1.0 - pBoundLow) / nBins1; Double_t binWidth2 = (2.0 - 1.0 ) / nBins2; Double_t binWidth3 = (pBoundUp - 2.0) / nBins3; for (Int_t i = 0; i < nBins1; i++) { binsPforMap[i] = pBoundLow + i * binWidth1; } for (Int_t i = nBins1, j = 0; i < nBins1 + nBins2; i++, j++) { binsPforMap[i] = 1.0 + j * binWidth2; } for (Int_t i = nBins1 + nBins2, j = 0; i < nBins1 + nBins2 + nBins3; i++, j++) { binsPforMap[i] = 2.0 + j * binWidth3; } binsPforMap[nPbinsForMap] = pBoundUp; TH2D* hPull = new TH2D("hPull", "Pull vs. p_{TPC} integrated over tan(#Theta);p_{TPC} (GeV/c);Pull", nPbinsForMap, binsPforMap, plotPull ? 120 : 240, plotPull ? -6 : -0.6, plotPull ? 6 : 0.6); TH2D* hPullAdditionalCorr = (TH2D*)hPull->Clone("hPullAdditionalCorr"); hPullAdditionalCorr->SetTitle("Pull vs. p_{TPC} integrated over tan(#Theta) with additional dEdx correction w.r.t. tan(#Theta)"); /* const Int_t nThetaHistos = 3; TH2D* hPullTheta[nThetaHistos]; TH2D* hPullAdditionalCorrTheta[nThetaHistos]; Double_t tThetaLow[nThetaHistos] = { 0.0, 0.4, 0.9 }; Double_t tThetaHigh[nThetaHistos] = { 0.1, 0.5, 1.0 }; */ const Int_t nThetaHistos = 10; TH2D* hPullTheta[nThetaHistos]; TH2D* hPullAdditionalCorrTheta[nThetaHistos]; Double_t tThetaLow[nThetaHistos] = { 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9 }; Double_t tThetaHigh[nThetaHistos] = { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 }; for (Int_t i = 0; i < nThetaHistos; i++) { hPullTheta[i] = new TH2D(Form("hPullTheta_%d", i), Form("Pull vs. p_{TPC} for %.2f <= |tan(#Theta)| < %.2f;p_{TPC} (GeV/c);Pull", tThetaLow[i], tThetaHigh[i]), nPbinsForMap, binsPforMap, plotPull ? 120 : 240, plotPull ? -6 : -0.6, plotPull ? 6 : 0.6); hPullAdditionalCorrTheta[i] = new TH2D(Form("hPullAdditionalCorrTheta_%d", i), Form("Pull vs. p_{TPC} for %.2f <= |tan(#Theta)| < %.2f with additional dEdx correction w.r.t. tan(#Theta);p_{TPC} (GeV/c);Pull", tThetaLow[i], tThetaHigh[i]), nPbinsForMap, binsPforMap, plotPull ? 120 : 240, plotPull ? -6 : -0.6, plotPull ? 6 : 0.6); } TF1 corrFuncMult("corrFuncMult", "[0] + [1]*TMath::Max([4], TMath::Min(x, [3])) + [2] * TMath::Power(TMath::Max([4], TMath::Min(x, [3])), 2)", 0., 0.2); TF1 corrFuncMultTanTheta("corrFuncMultTanTheta", "[0] * (x -[2]) + [1] * (x * x - [2] * [2])", -1.5, 1.5); TF1 corrFuncSigmaMult("corrFuncSigmaMul", "TMath::Max(0, [0] + [1]*TMath::Min(x, [3]) + [2] * TMath::Power(TMath::Min(x, [3]), 2))", 0., 0.2); // LHC13b.pass2 if (isNonPP) printf("Using corr Parameters for 13b.pass2\n!"); corrFuncMult.SetParameter(0, -5.906e-06); corrFuncMult.SetParameter(1, -5.064e-04); corrFuncMult.SetParameter(2, -3.521e-02); corrFuncMult.SetParameter(3, 2.469e-02); corrFuncMult.SetParameter(4, 0); corrFuncMultTanTheta.SetParameter(0, -5.32e-06); corrFuncMultTanTheta.SetParameter(1, 1.177e-05); corrFuncMultTanTheta.SetParameter(2, -0.5); corrFuncSigmaMult.SetParameter(0, 0.); corrFuncSigmaMult.SetParameter(1, 0.); corrFuncSigmaMult.SetParameter(2, 0.); corrFuncSigmaMult.SetParameter(3, 0.); /* OK, but PID task was not very satisfying corrFuncMult.SetParameter(0, -6.27187e-06); corrFuncMult.SetParameter(1, -4.60649e-04); corrFuncMult.SetParameter(2, -4.26450e-02); corrFuncMult.SetParameter(3, 2.40590e-02); corrFuncMult.SetParameter(4, 0); corrFuncMultTanTheta.SetParameter(0, -5.338e-06); corrFuncMultTanTheta.SetParameter(1, 1.220e-05); corrFuncMultTanTheta.SetParameter(2, -0.5); corrFuncSigmaMult.SetParameter(0, 7.89237e-05); corrFuncSigmaMult.SetParameter(1, -1.30662e-02); corrFuncSigmaMult.SetParameter(2, 8.91548e-01); corrFuncSigmaMult.SetParameter(3, 1.47931e-02); */ /* // LHC11a10a if (isNonPP) printf("Using corr Parameters for 11a10a\n!"); corrFuncMult.SetParameter(0, 6.90133e-06); corrFuncMult.SetParameter(1, -1.22123e-03); corrFuncMult.SetParameter(2, 1.80220e-02); corrFuncMult.SetParameter(3, 0.1); corrFuncMult.SetParameter(4, 6.45306e-03); corrFuncMultTanTheta.SetParameter(0, -2.85505e-07); corrFuncMultTanTheta.SetParameter(1, -1.31911e-06); corrFuncMultTanTheta.SetParameter(2, -0.5); corrFuncSigmaMult.SetParameter(0, -4.29665e-05); corrFuncSigmaMult.SetParameter(1, 1.37023e-02); corrFuncSigmaMult.SetParameter(2, -6.36337e-01); corrFuncSigmaMult.SetParameter(3, 1.13479e-02); */ /* OLD without saturation and large error for negative slopes corrFuncSigmaMult.SetParameter(0, -4.79684e-05); corrFuncSigmaMult.SetParameter(1, 1.49938e-02); corrFuncSigmaMult.SetParameter(2, -7.15269e-01); corrFuncSigmaMult.SetParameter(3, 1.06855e-02); */ /* OLD very good try, but with fewer pBins for the fitting corrFuncMult.SetParameter(0, 6.88365e-06); corrFuncMult.SetParameter(1, -1.22324e-03); corrFuncMult.SetParameter(2, 1.81625e-02); corrFuncMult.SetParameter(3, 0.1); corrFuncMult.SetParameter(4, 6.36890e-03); corrFuncMultTanTheta.SetParameter(0, -2.85505e-07); corrFuncMultTanTheta.SetParameter(1, -1.31911e-06); corrFuncMultTanTheta.SetParameter(2, -0.5); corrFuncSigmaMult.SetParameter(0, -4.28401e-05); corrFuncSigmaMult.SetParameter(1, 1.24812e-02); corrFuncSigmaMult.SetParameter(2, -5.28531e-01); corrFuncSigmaMult.SetParameter(3, 1.25147e-02); */ /*OLD good try corrFuncMult.SetParameter(0, 7.50321e-06); corrFuncMult.SetParameter(1, -1.25250e-03); corrFuncMult.SetParameter(2, 1.85437e-02); corrFuncMult.SetParameter(3, 0.1); corrFuncMult.SetParameter(4, 6.21192e-03); corrFuncMultTanTheta.SetParameter(0, -1.43112e-07); corrFuncMultTanTheta.SetParameter(1, -1.53e-06); corrFuncMultTanTheta.SetParameter(2, 0.3); corrFuncSigmaMult.SetParameter(0, -2.54019e-05); corrFuncSigmaMult.SetParameter(1, 8.68883e-03); corrFuncSigmaMult.SetParameter(2, -3.36176e-01); corrFuncSigmaMult.SetParameter(3, 1.29230e-02); */ /* // LHC10h.pass2 if (isNonPP) printf("Using corr Parameters for 10h.pass2\n!"); corrFuncMult.SetParameter(0, 3.21636e-07); corrFuncMult.SetParameter(1, -6.65876e-04); corrFuncMult.SetParameter(2, 1.28786e-03); corrFuncMult.SetParameter(3, 1.47677e-02); corrFuncMult.SetParameter(4, 0.); corrFuncMultTanTheta.SetParameter(0, 7.23591e-08); corrFuncMultTanTheta.SetParameter(1, 2.7469e-06); corrFuncMultTanTheta.SetParameter(2, -0.5); corrFuncSigmaMult.SetParameter(0, -1.22590e-05); corrFuncSigmaMult.SetParameter(1, 6.88888e-03); corrFuncSigmaMult.SetParameter(2, -3.20788e-01); corrFuncSigmaMult.SetParameter(3, 1.07345e-02); */ /*OLD bad try corrFuncMult.SetParameter(0, 2.71514e-07); corrFuncMult.SetParameter(1, -6.92031e-04); corrFuncMult.SetParameter(2, 3.56042e-03); corrFuncMult.SetParameter(3, 1.47497e-02); corrFuncMult.SetParameter(4, 0.); corrFuncMultTanTheta.SetParameter(0, 8.53204e-08); corrFuncMultTanTheta.SetParameter(1, 2.85591e-06); corrFuncMultTanTheta.SetParameter(2, -0.5); corrFuncSigmaMult.SetParameter(0, -6.82477e-06); corrFuncSigmaMult.SetParameter(1, 4.97051e-03); corrFuncSigmaMult.SetParameter(2, -1.64954e-01); corrFuncSigmaMult.SetParameter(3, 9.21061e-03); */ //TODO NOW TF1* fShapeSmallP = new TF1("fShapeSmallP", "pol5", -0.4, 0.4); fShapeSmallP->SetParameters(1.01712, -0.0202725, -0.260692, 0.261623, 0.671854, -1.14014); for (Long64_t i = 0; i < nTreeEntries; i++) { tree->GetEntry(i); if (dEdx <= 0 || dEdxExpected <= 0 || tpcSignalN <= 10) continue; /* Double_t pT = pTPC*TMath::Sin(-TMath::ATan(tanTheta)+TMath::Pi()/2.0); if ((phiPrime > 0.072/pT+TMath::Pi()/18.0-0.035 && phiPrime < 0.07/pT/pT+0.1/pT+TMath::Pi()/18.0+0.035)) continue; */ if (pidType != kMCid) { if (pidType == kTPCid && pTPC > 0.6) continue; if (pidType == kTPCandTOFid && (pTPC < 0.6 || pTPC > 2.0)) continue; if ((collType == 2) && pidType == kTPCandTOFid && pTPC > 1.0) continue;// Only V0's in case of PbPb above 1.0 GeV/c if (pidType == kV0idPlusTOFrejected) //TODO NOW NEW continue; } if (recalculateExpecteddEdx) { dEdxExpected = 50. * splPr->Eval(pTPC / massProton); //WARNING: What, if MIP is different from 50.? Seems not to be used (tested for pp, MC_pp, PbPb and MC_PbPb), but can in principle happen } //TODO NOW /* if (TMath::Abs(tanTheta) <= 0.4) { Double_t p0 = fShapeSmallP->Eval(tanTheta) - 1.0; // Strength of the correction Double_t p1 = -9.0; // How fast the correction is turned off Double_t p2 = -0.209; // Turn off correction around 0.2 GeV/c Double_t p3 = 1.0; // Delta' for large p should be 1 Double_t corrFactor = TMath::Erf((pTPC + p2) * p1) * p0 + p3 + p0; // Add p0 to have 1 for p3 = 1 and large pTPC dEdxExpected *= corrFactor; }*/ /*TODO old unsuccessful try Double_t thetaGlobalTPC = -TMath::ATan(tanTheta) + TMath::Pi() / 2.; Double_t pTtpc = pTPC * TMath::Sin(thetaGlobalTPC); Double_t pTtpcInv = (pTtpc > 0) ? 1. / pTtpc : 0; Double_t p0 = 1.0; Double_t p1 = 1./ 0.5;//TODO 2.0; Double_t p2 = -0.2;//TODO 0.1 Double_t pTcorrFactor = p0 + (pTtpcInv > p1) * p2 * (pTtpcInv - p1); dEdxExpected *= pTcorrFactor; */ // From the momentum (via dEdxExpected) and the tanTheta of the track, the expected dEdx can be calculated (correctedDeDxExpected). // If the splines are correct, this should give in average the same value as dEdx. // Now valid: Maps created from corrected data with splines adopted to corrected data, so lookup should be for dEdxExpected=dEdxSplines (no further // eta correction) or the corrected dEdx from the track (which should ideally be = dEdxSplines) // Tested with corrected data for LHC10d.pass2: using dEdx for the lookup (which is the corrected value and should ideally be = dEdxSplines): // Results almost the same. Maybe slightly better for dEdxExpected. // No longer valid: Note that the maps take always the uncorrected dEdx w.r.t. // tanTheta, so that correctedDeDxExpected is needed here normally. However, the information for the correction will be lost at some point. // Therefore, dEdxExpected can be used instead and should provide a good approximation. Double_t c1FromSigmaMap = hThetaMapSigmaPar1->GetBinContent(getBinX(hThetaMapSigmaPar1, tanTheta), getBinY(hThetaMapSigmaPar1, 1./dEdxExpected)); Double_t expectedSigma = dEdxExpected * TMath::Sqrt( c0 * c0 + (c1FromSigmaMap * c1FromSigmaMap) / tpcSignalN); Double_t pull = (dEdx - dEdxExpected) / (plotPull ? expectedSigma: dEdxExpected); // Fill pull histo hPull->Fill(pTPC, pull); Double_t tanThetaAbs = TMath::Abs(tanTheta); for (Int_t j = 0; j < nThetaHistos; j++) { if (tanThetaAbs >= tThetaLow[j] && tanThetaAbs < tThetaHigh[j]) { hPullTheta[j]->Fill(pTPC, pull); } } if (!hMap) continue; Double_t correctionFactor = 1.; if (isNonPP) { // 1. Correct eta dependence correctionFactor = hMap->GetBinContent(getBinX(hMap, tanTheta), getBinY(hMap, 1./dEdxExpected)); // 2. Correct for multiplicity dependence: Double_t multCorrectionFactor = 1.; if (fMultiplicity > 0) { Double_t relSlope = corrFuncMult.Eval(1. / (dEdxExpected * correctionFactor)); relSlope += corrFuncMultTanTheta.Eval(tanTheta); multCorrectionFactor = 1. + relSlope * fMultiplicity; } c1FromSigmaMap = hThetaMapSigmaPar1->GetBinContent(getBinX(hThetaMapSigmaPar1, tanTheta), getBinY(hThetaMapSigmaPar1, 1./dEdxExpected)); // Multiplicity dependence of sigma depends on the real dEdx at zero multiplicity, i.e. the eta (only) corrected dEdxExpected value has to be used // since all maps etc. have been created for ~zero multiplicity Double_t relSigmaSlope = corrFuncSigmaMult.Eval(1. / (dEdxExpected * correctionFactor)); Double_t multSigmaCorrectionFactor = 1. + relSigmaSlope * fMultiplicity; dEdxExpected *= correctionFactor * multCorrectionFactor; expectedSigma = dEdxExpected * TMath::Sqrt( c0 * c0 + (c1FromSigmaMap * c1FromSigmaMap) / tpcSignalN); expectedSigma *= multSigmaCorrectionFactor; pull = (dEdx - dEdxExpected) / (plotPull ? expectedSigma: dEdxExpected); } else { correctionFactor = hMap->GetBinContent(getBinX(hMap, tanTheta), getBinY(hMap, 1./dEdxExpected)); c1FromSigmaMap = hThetaMapSigmaPar1->GetBinContent(getBinX(hThetaMapSigmaPar1, tanTheta), getBinY(hThetaMapSigmaPar1, 1./dEdxExpected)); dEdxExpected *= correctionFactor; // If data is not corrected, but the sigma map is for corrected data, re-do analysis with corrected dEdx expectedSigma = dEdxExpected * TMath::Sqrt( c0 * c0 + (c1FromSigmaMap * c1FromSigmaMap) / tpcSignalN); pull = (dEdx - dEdxExpected) / (plotPull ? expectedSigma: dEdxExpected); } pull = (dEdx - dEdxExpected) / (plotPull ? expectedSigma: dEdxExpected); hPullAdditionalCorr->Fill(pTPC, pull); for (Int_t j = 0; j < nThetaHistos; j++) { if (tanThetaAbs >= tThetaLow[j] && tanThetaAbs < tThetaHigh[j]) { hPullAdditionalCorrTheta[j]->Fill(pTPC, pull); } } } /* // Mean, Sigma, chi^2/NDF of pull of different theta bins and all in one plot TCanvas* canvPullMean = new TCanvas("canvPullMean", "canvPullMean", 100,10,1380,800); canvPullMean->SetLogx(kTRUE); canvPullMean->SetGridx(kTRUE); canvPullMean->SetGridy(kTRUE); TCanvas* canvPullSigma = new TCanvas("canvPullSigma", "canvPullSigma", 100,10,1380,800); canvPullSigma->SetLogx(kTRUE); canvPullSigma->SetGridx(kTRUE); canvPullSigma->SetGridy(kTRUE); TCanvas* canvPullChi2 = new TCanvas("canvPullChi2", "canvPullChi2", 100,10,1380,800); canvPullChi2->SetLogx(kTRUE); canvPullChi2->SetGridx(kTRUE); canvPullChi2->SetGridy(kTRUE); TCanvas* canvPull[nThetaHistos + 1]; for (Int_t i = 0, j = nThetaHistos; i < nThetaHistos + 1; i++, j--) { canvPull[i] = new TCanvas(Form("canvPull_%d", i), "canvPull", 100,10,1380,800); canvPull[i]->cd(); canvPull[i]->SetLogx(kTRUE); canvPull[i]->SetLogz(kTRUE); canvPull[i]->SetGrid(kTRUE, kTRUE); TH2D* hTemp = 0x0; TString thetaString = ""; if (i == nThetaHistos) { hTemp = hPull; thetaString = "tan(#Theta) integrated"; } else { hTemp = hPullTheta[i]; thetaString = Form("%.2f #leq |tan(#Theta)| < %.2f", tThetaLow[i], tThetaHigh[i]); } normaliseHisto(hTemp); hTemp->FitSlicesY(); hTemp->GetYaxis()->SetNdivisions(12); hTemp->GetXaxis()->SetMoreLogLabels(kTRUE); TH1D* hTempMean = (TH1D*)gDirectory->Get(Form("%s_1", hTemp->GetName())); hTempMean->SetTitle(Form("mean(pull), %s", thetaString.Data())); hTempMean->GetXaxis()->SetMoreLogLabels(kTRUE); hTempMean->SetLineWidth(2); hTempMean->SetMarkerStyle(20); TH1D* hTempSigma = (TH1D*)gDirectory->Get(Form("%s_2", hTemp->GetName())); hTempSigma->SetTitle(Form("#sigma(pull), %s", thetaString.Data())); hTempSigma->GetXaxis()->SetMoreLogLabels(kTRUE); hTempSigma->SetLineColor(kMagenta); hTempSigma->SetMarkerStyle(20); hTempSigma->SetMarkerColor(kMagenta); hTempSigma->SetLineWidth(2); TH1D* hTempChi2 = (TH1D*)gDirectory->Get(Form("%s_chi2", hTemp->GetName())); hTempChi2->SetTitle(Form("#chi^{2} / NDF (pull), %s", thetaString.Data())); hTempChi2->GetXaxis()->SetMoreLogLabels(kTRUE); hTempChi2->SetLineColor(kMagenta + 2); hTempChi2->SetMarkerStyle(20); hTempChi2->SetMarkerColor(kMagenta + 2); hTempChi2->SetLineWidth(2); hTemp->DrawCopy("colz"); hTempMean->DrawCopy("same"); hTempSigma->DrawCopy("same"); hTempChi2->Scale(-1./10.); hTempChi2->DrawCopy("same"); hTempChi2->Scale(-10.); canvPullMean->cd(); hTempMean->SetLineColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempMean->SetMarkerColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempMean->DrawCopy((i == 0 ? "" : "same")); canvPullSigma->cd(); hTempSigma->SetLineColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempSigma->SetMarkerColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempSigma->DrawCopy((i == 0 ? "" : "same")); canvPullChi2->cd(); hTempChi2->SetLineColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempChi2->SetMarkerColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempChi2->DrawCopy((i == 0 ? "" : "same")); } canvPullMean->BuildLegend(); canvPullSigma->BuildLegend(); canvPullChi2->BuildLegend(); */ // Histograms with additional correction TCanvas* canvPullMeanCorr = 0x0; TCanvas* canvPullSigmaCorr = 0x0; TCanvas* canvPullChi2Corr = 0x0; TCanvas* canvPullCorr[nThetaHistos + 1]; for (Int_t i = 0; i < nThetaHistos + 1; i++) canvPullCorr[i] = 0x0; if (hMap) { // Mean, Sigma, chi^2/NDF of pull of different theta bins and all in one plot canvPullMeanCorr = new TCanvas("canvPullMeanCorr", "canvPullMeanCorr", 100,10,1380,800); canvPullMeanCorr->SetLogx(kTRUE); canvPullMeanCorr->SetGridx(kTRUE); canvPullMeanCorr->SetGridy(kTRUE); canvPullSigmaCorr = new TCanvas("canvPullSigmaCorr", "canvPullSigmaCorr", 100,10,1380,800); canvPullSigmaCorr->SetLogx(kTRUE); canvPullSigmaCorr->SetGridx(kTRUE); canvPullSigmaCorr->SetGridy(kTRUE); canvPullChi2Corr = new TCanvas("canvPullChi2Corr", "canvPullChi2Corr", 100,10,1380,800); canvPullChi2Corr->SetLogx(kTRUE); canvPullChi2Corr->SetGridx(kTRUE); canvPullChi2Corr->SetGridy(kTRUE); for (Int_t i = 0, j = nThetaHistos; i < nThetaHistos + 1; i++, j--) { canvPullCorr[i] = new TCanvas(Form("canvPullCorr_%d", i), "canvPullCorr", 100,10,1380,800); canvPullCorr[i]->cd(); canvPullCorr[i]->SetLogx(kTRUE); canvPullCorr[i]->SetLogz(kTRUE); canvPullCorr[i]->SetGrid(kTRUE, kTRUE); TH2D* hTemp = 0x0; TString thetaString = ""; if (i == nThetaHistos) { hTemp = hPullAdditionalCorr; thetaString = "tan(#Theta) integrated"; } else { hTemp = hPullAdditionalCorrTheta[i]; thetaString = Form("%.2f #leq |tan(#Theta)| < %.2f", tThetaLow[i], tThetaHigh[i]); } normaliseHisto(hTemp); hTemp->FitSlicesY(); hTemp->GetYaxis()->SetNdivisions(12); hTemp->GetXaxis()->SetMoreLogLabels(kTRUE); TH1D* hTempMean = (TH1D*)gDirectory->Get(Form("%s_1", hTemp->GetName())); hTempMean->SetTitle(Form("mean(pull), %s", thetaString.Data())); hTempMean->GetXaxis()->SetMoreLogLabels(kTRUE); hTempMean->SetLineWidth(2); hTempMean->SetMarkerStyle(20); TH1D* hTempSigma = (TH1D*)gDirectory->Get(Form("%s_2", hTemp->GetName())); hTempSigma->SetTitle(Form("#sigma(pull), %s", thetaString.Data())); hTempSigma->GetXaxis()->SetMoreLogLabels(kTRUE); hTempSigma->SetLineColor(kMagenta); hTempSigma->SetMarkerStyle(20); hTempSigma->SetMarkerColor(kMagenta); hTempSigma->SetLineWidth(2); TH1D* hTempChi2 = (TH1D*)gDirectory->Get(Form("%s_chi2", hTemp->GetName())); hTempChi2->SetTitle(Form("#chi^{2} / NDF (pull), %s", thetaString.Data())); hTempChi2->GetXaxis()->SetMoreLogLabels(kTRUE); hTempChi2->SetLineColor(kMagenta + 2); hTempChi2->SetMarkerStyle(20); hTempChi2->SetMarkerColor(kMagenta + 2); hTempChi2->SetLineWidth(2); hTemp->DrawCopy("colz"); hTempMean->DrawCopy("same"); hTempSigma->DrawCopy("same"); hTempChi2->Scale(-1./10.); hTempChi2->DrawCopy("same"); hTempChi2->Scale(-10.); canvPullMeanCorr->cd(); hTempMean->SetLineColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempMean->SetMarkerColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempMean->DrawCopy((i == 0 ? "" : "same")); canvPullSigmaCorr->cd(); hTempSigma->SetLineColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempSigma->SetMarkerColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempSigma->DrawCopy((i == 0 ? "" : "same")); canvPullChi2Corr->cd(); hTempChi2->SetLineColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempChi2->SetMarkerColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempChi2->DrawCopy((i == 0 ? "" : "same")); } canvPullMeanCorr->BuildLegend(); canvPullSigmaCorr->BuildLegend(); canvPullChi2Corr->BuildLegend(); } fSave->cd(); /*canvPullMean->Write(); canvPullSigma->Write(); canvPullChi2->Write(); for (Int_t i = 0; i < nThetaHistos + 1; i++) { canvPull[i]->Write(); }*/ canvPullMeanCorr->Write(); canvPullSigmaCorr->Write(); canvPullChi2Corr->Write(); for (Int_t i = 0; i < nThetaHistos + 1; i++) { canvPullCorr[i]->Write(); } TNamed* info = new TNamed(Form("Theta map: %s\n\nSigma map: %s\n\nSplines file: %s\n\nSplines name: %s", pathNameThetaMap.Data(), pathNameSigmaMap.Data(), pathNameSplinesFile.Data(), prSplinesName.Data()), "info"); info->Write(); fSave->Close(); return 0; }
void execCheckErrors(bool what = 0) { TTree *tree = 0; TFile *file = 0; if (what == 0) { tree = new TTree("ntuple",""); float px = 0; tree->Branch("px",&px); TString str; tree->Branch("str",&str); tree->Fill(); tree->ResetBranchAddresses(); } else if (what == 1) { file = new TFile("hsimple.root"); tree = (TTree*)file->Get("ntuple"); } else { tree = new TChain("ntuple", "ntuple"); ((TChain*)tree)->Add("hsimple.root"); } // tree->SetBranchStatus("*", 1); // tree->SetBranchStatus("px", 1); // std::cout << "fTreeNumber = " << tree->GetTreeNumber() << std::endl; tree->LoadTree(0); // REQUIRED // std::cout << "fTreeNumber = " << tree->GetTreeNumber() << std::endl; TBranch *p = ((TBranch *)-1); Int_t r; Float_t px, fake_px; Float_t *pxp = new Float_t(); Float_t *fake_pxp = new Float_t(); Int_t ix; Int_t *ixp = new Int_t(); TString s; TString *sp = new TString(); TObjString os; TObjString *osp = new TObjString(); // Float_t ... (should be fine) std::cout << std::endl << "ALL should be FINE ... " << std::endl; p = ((TBranch *)-1); r = tree->SetBranchAddress("px", &px, &p); std::cout << "Float_t ... " << r << std::endl; if (p==((TBranch*)-1)) { std::cout << "p unchanged\n"; } else if (p==0) { std::cout << "p set to zero\n"; } else { std::cout << "p set to the branch address\n"; } r = tree->SetBranchAddress("px", &px); std::cout << "Float_t ... " << r << std::endl; r = tree->SetBranchAddress("px", pxp); std::cout << "Float_t ... " << r << std::endl; r = tree->SetBranchAddress("px", &pxp); std::cout << "Float_t ... " << r << std::endl; // Int_t ... (should fail) std::cout << std::endl << "ALL should FAIL ... " << std::endl; p = ((TBranch *)-1); r = tree->SetBranchAddress("px", &ix, &p); std::cout << "Int_t ... " << r << std::endl; if (p==((TBranch*)-1)) { std::cout << "p unchanged\n"; } else if (p==0) { std::cout << "p set to zero\n"; } else { std::cout << "p set to the branch address\n"; } r = tree->SetBranchAddress("px", &ix); std::cout << "Int_t ... " << r << std::endl; r = tree->SetBranchAddress("px", ixp); std::cout << "Int_t ... " << r << std::endl; r = tree->SetBranchAddress("px", &ixp); std::cout << "Int_t ... " << r << std::endl; // TString ... (should fail) std::cout << std::endl << "ALL should FAIL ... " << std::endl; p = ((TBranch *)-1); r = tree->SetBranchAddress("px", &s, &p); std::cout << "TString ... " << r << std::endl; if (p==((TBranch *)-1)) { std::cout << "p unchanged\n"; } else if (p==0) { std::cout << "p set to zero\n"; } else { std::cout << "p set to the branch address\n"; } r = tree->SetBranchAddress("px", sp); std::cout << "TString ... " << r << std::endl; r = tree->SetBranchAddress("px", &sp); std::cout << "TString ... " << r << std::endl; // TObjString ... (should fail) std::cout << std::endl << "ALL should FAIL ... " << std::endl; p = ((TBranch *)-1); r = tree->SetBranchAddress("px", &os, &p); std::cout << "TObjString ... " << r << std::endl; if (p==((TBranch*)-1)) { std::cout << "p unchanged\n"; } else if (p==0) { std::cout << "p set to zero\n"; } else { std::cout << "p set to the branch address\n"; } r = tree->SetBranchAddress("px", osp); std::cout << "TObjString ... " << r << std::endl; r = tree->SetBranchAddress("px", &osp); std::cout << "TObjString ... " << r << std::endl; // nonexistent branch ... (should fail) std::cout << std::endl << "ALL should FAIL ... " << std::endl; p = ((TBranch *)-1); r = tree->SetBranchAddress("fake_px", &fake_px, &p); std::cout << "nonexistent branch ... " << r << std::endl; if (p==((TBranch*)-1)) { std::cout << "p unchanged\n"; } else if (p==0) { std::cout << "p set to zero\n"; } else { std::cout << "p set to the branch address\n"; } r = tree->SetBranchAddress("fake_px", &fake_px); std::cout << "nonexistent branch ... " << r << std::endl; r = tree->SetBranchAddress("fake_px", fake_pxp); std::cout << "nonexistent branch ... " << r << std::endl; r = tree->SetBranchAddress("fake_px", &fake_pxp); std::cout << "nonexistent branch ... " << r << std::endl; // Float for TString ... (should fail) std::cout << std::endl << "ALL should FAIL ... " << std::endl; p = ((TBranch *)-1); r = tree->SetBranchAddress("str", &px, &p); std::cout << "Float ... " << r << std::endl; if (p==((TBranch*)-1)) { std::cout << "p unchanged\n"; } else if (p==0) { std::cout << "p set to zero\n"; } else { std::cout << "p set to the branch address\n"; } r = tree->SetBranchAddress("str", &px); std::cout << "Float ... " << r << std::endl; r = tree->SetBranchAddress("str", pxp); std::cout << "Float ... " << r << std::endl; r = tree->SetBranchAddress("str", &pxp); std::cout << "Float ... " << r << std::endl; TChain *ch = new TChain("MonoData"); ch->Add("memleak.root"); ch->LoadTree(0); r = ch->SetBranchAddress("mono", &sp, &p); std::cout << "From chain, TString ... " << r << std::endl; TTree *treech = ch; r = treech->SetBranchAddress("mono", &sp, &p); std::cout << "From tree, TString ... " << r << std::endl; }
void gastof_simple() { const unsigned int run_id = 725; TFile* f = new TFile(Form("../../gastof_inner_run%d.root", run_id)); //FIXME TTree* t = (TTree*)f->Get("tdc"); const unsigned int channels_to_probe = 32; //64; const double tot_min = 70., tot_max = -1.; const double lead_min = 6.8, lead_max = 6.95; // in \mus int num_hits; unsigned int ettt; double leading_edge[5000], tot[5000]; int channel_id[5000]; t->SetBranchStatus("*", 0); t->SetBranchStatus("num_measurements", 1); t->SetBranchAddress("num_measurements", &num_hits); t->SetBranchStatus("leading_edge", 1); t->SetBranchAddress("leading_edge", leading_edge); t->SetBranchStatus("channel_id", 1); t->SetBranchAddress("channel_id", channel_id); t->SetBranchStatus("tot", 1); t->SetBranchAddress("tot", tot); const unsigned int num_triggers = t->GetEntries(); TH1D* h_tot_all_channels = new TH1D("h_tot_all_channels", "", 250, 0., 1000.); TH1D* h_lead_all_channels = new TH1D("h_lead_all_channels", "", 500, 0., 10.); double last_ettt = -1.; unsigned int num_overfl = 0; unsigned int mult[channels_to_probe]; for (unsigned int i=0; i<num_triggers; i++) { t->GetEntry(i); for (unsigned int j=0; j<channels_to_probe; j++) { // lead[j].clear(); //lead[] not defined in gastof_simple mult[j] = 0; } if (i%10000==0) cerr << "Processing event " << i << " / " << num_triggers << endl; for (int j=0; j<num_hits; j++) { h_lead_all_channels->Fill(leading_edge[j]/1.e3, 1./num_triggers); if (leading_edge[j]<lead_min*1.e3 or leading_edge[j]>lead_max*1.e3) continue; h_tot_all_channels->Fill(tot[j]); } } GastofCanvas c_tot_all_chan("tot_all-channels", Form("Run %d, all channels", run_id)); h_tot_all_channels->Draw(); h_tot_all_channels->GetXaxis()->SetTitle("Time over threshold (ns)"); h_tot_all_channels->GetYaxis()->SetTitle("Hits"); { TPaveText* cuts = new TPaveText(0.4, 0.8, 0.5, 0.85, "ndc"); cuts->SetTextAlign(13); cuts->SetTextFont(43); cuts->SetTextSize(18); cuts->SetFillColor(kWhite); cuts->SetLineColor(kWhite); //cuts->AddText(Form("ToT > %.1f ns", tot_min)); cuts->AddText(Form("Lead. edge #in [%.1f-%.2f] #mus", lead_min, lead_max)); cuts->Draw("same"); } c_tot_all_chan.Pad()->SetLogy(); { TLine* line = new TLine(tot_min, 0., tot_min, h_tot_all_channels->GetMaximum()*0.8); //constructor for line: TLine( x1, y1, x2, y2) line->SetLineColor(kBlack); line->SetLineStyle(2); line->SetLineWidth(2); line->Draw("same"); } // if (tot_max>0.) { //<- condition never met in gastof_simple // TLine* line = new TLine(tot_max, 0., tot_max, h_tot_all_channels->GetMaximum()*0.8); // line->SetLineColor(kBlack); // line->SetLineStyle(2); // line->SetLineWidth(2); // line->Draw("same"); }
void top_extractor_all_variables_STS() { TFile *f = new TFile(source_file_path); TTree *t = (TTree *) f->Get("TopologicalVariables"); Double_t Centrality_AllJets; t->SetBranchAddress("Centrality_AllJets", &Centrality_AllJets); Double_t Cos_Jet1AllJets_AllJets; t->SetBranchAddress("Cos_Jet1AllJets_AllJets", &Cos_Jet1AllJets_AllJets); Double_t Cos_Jet1Lepton_Lab; t->SetBranchAddress("Cos_Jet1Lepton_Lab", &Cos_Jet1Lepton_Lab); Double_t Cos_Jet2AllJets_AllJets; t->SetBranchAddress("Cos_Jet2AllJets_AllJets", &Cos_Jet2AllJets_AllJets); Double_t Cos_Jet2Lepton_Lab; t->SetBranchAddress("Cos_Jet2Lepton_Lab", &Cos_Jet2Lepton_Lab); Double_t Cos_LightQuarkJetLepton_BTaggedTop; t->SetBranchAddress("Cos_LightQuarkJetLepton_BTaggedTop", &Cos_LightQuarkJetLepton_BTaggedTop); Double_t DeltaPhiJet1Jet2; t->SetBranchAddress("DeltaPhiJet1Jet2", &DeltaPhiJet1Jet2); Double_t DeltaPhiJet1MET; t->SetBranchAddress("DeltaPhiJet1MET", &DeltaPhiJet1MET); Double_t DeltaPhiJet2MET; t->SetBranchAddress("DeltaPhiJet2MET", &DeltaPhiJet2MET); Double_t DeltaPhiLeptonMET; t->SetBranchAddress("DeltaPhiLeptonMET", &DeltaPhiLeptonMET); Double_t DeltaRJet1Jet2; t->SetBranchAddress("DeltaRJet1Jet2", &DeltaRJet1Jet2); Double_t DeltaRMinLeptonJet; t->SetBranchAddress("DeltaRMinLeptonJet", &DeltaRMinLeptonJet); Double_t EventWeight; t->SetBranchAddress("EventWeight", &EventWeight); Double_t H_AllJets; t->SetBranchAddress("H_AllJets", &H_AllJets); Double_t H_Jet1Jet2; t->SetBranchAddress("H_Jet1Jet2", &H_Jet1Jet2); Double_t HT_AllJets; t->SetBranchAddress("HT_AllJets", &HT_AllJets); Double_t HT_AllJetsLeptonMET; t->SetBranchAddress("HT_AllJetsLeptonMET", &HT_AllJetsLeptonMET); Double_t HT_Jet1Jet2; t->SetBranchAddress("HT_Jet1Jet2", &HT_Jet1Jet2); Double_t HT_METlep; t->SetBranchAddress("HT_METlep", &HT_METlep); Double_t InstLumi; t->SetBranchAddress("InstLumi", &InstLumi); Double_t InvariantMass_AllJets; t->SetBranchAddress("InvariantMass_AllJets", &InvariantMass_AllJets); Double_t InvariantMass_Jet1Jet2; t->SetBranchAddress("InvariantMass_Jet1Jet2", &InvariantMass_Jet1Jet2); Double_t Jet1MuonPtRel; t->SetBranchAddress("Jet1MuonPtRel", &Jet1MuonPtRel); Double_t Jet2MuonPtRel; t->SetBranchAddress("Jet2MuonPtRel", &Jet2MuonPtRel); Double_t Jet3MuonPtRel; t->SetBranchAddress("Jet3MuonPtRel", &Jet3MuonPtRel); Double_t Jet4MuonPtRel; t->SetBranchAddress("Jet4MuonPtRel", &Jet4MuonPtRel); Double_t LeptonDCA; t->SetBranchAddress("LeptonDCA", &LeptonDCA); Double_t LeptonDCASig; t->SetBranchAddress("LeptonDCASig", &LeptonDCASig); Double_t LeptonDetEta; t->SetBranchAddress("LeptonDetEta", &LeptonDetEta); Double_t LeptonDetEtaCFT; t->SetBranchAddress("LeptonDetEtaCFT", &LeptonDetEtaCFT); Double_t LeptonE; t->SetBranchAddress("LeptonE", &LeptonE); Double_t LeptonEta; t->SetBranchAddress("LeptonEta", &LeptonEta); Double_t LeptonPhi; t->SetBranchAddress("LeptonPhi", &LeptonPhi); Double_t LeptonPt; t->SetBranchAddress("LeptonPt", &LeptonPt); Double_t METPhi; t->SetBranchAddress("METPhi", &METPhi); Double_t METPt; t->SetBranchAddress("METPt", &METPt); Double_t METPx; t->SetBranchAddress("METPx", &METPx); Double_t METPy; t->SetBranchAddress("METPy", &METPy); Double_t MetSig; t->SetBranchAddress("MetSig", &MetSig); Double_t Pt_Jet1Jet2; t->SetBranchAddress("Pt_Jet1Jet2", &Pt_Jet1Jet2); Double_t PVz; t->SetBranchAddress("PVz", &PVz); Double_t QTimesEta; t->SetBranchAddress("QTimesEta", &QTimesEta); Double_t TransverseMass_Jet1Jet2; t->SetBranchAddress("TransverseMass_Jet1Jet2", &TransverseMass_Jet1Jet2); Double_t weight_btag; t->SetBranchAddress("weight_btag", &weight_btag); Double_t weight_btagSF; t->SetBranchAddress("weight_btagSF", &weight_btagSF); Double_t weight_btagTaga; t->SetBranchAddress("weight_btagTaga", &weight_btagTaga); Double_t weight_Lumi; t->SetBranchAddress("weight_Lumi", &weight_Lumi); Double_t weight_Lumi2; t->SetBranchAddress("weight_Lumi2", &weight_Lumi2); Double_t weight_LeptonDetEta; t->SetBranchAddress("weight_LeptonDetEta", &weight_LeptonDetEta); Double_t weight_WPt; t->SetBranchAddress("weight_WPt", &weight_WPt); Double_t weight_VJets; t->SetBranchAddress("weight_VJets", &weight_VJets); Double_t weight_QCDshape; t->SetBranchAddress("weight_QCDshape", &weight_QCDshape); Double_t scale_HF; t->SetBranchAddress("scale_HF", &scale_HF); Double_t scale_MC; t->SetBranchAddress("scale_MC", &scale_MC); Double_t scale_MC2; t->SetBranchAddress("scale_MC2", &scale_MC2); Double_t scale_norm; t->SetBranchAddress("scale_norm", &scale_norm); Double_t weight_EMcorr; t->SetBranchAddress("weight_EMcorr", &weight_EMcorr); Double_t weight_Muon_ID; t->SetBranchAddress("weight_Muon_ID", &weight_Muon_ID); Double_t WPt; t->SetBranchAddress("WPt", &WPt); Double_t WTransverseMass; t->SetBranchAddress("WTransverseMass", &WTransverseMass); Double_t KS_LeptonPt; t->SetBranchAddress("KS_LeptonPt", &KS_LeptonPt); Double_t KS_METPt; t->SetBranchAddress("KS_METPt", &KS_METPt); Double_t KS_WTransverseMass; t->SetBranchAddress("KS_WTransverseMass", &KS_WTransverseMass); Double_t TrackQPt; t->SetBranchAddress("TrackQPt", &TrackQPt); Double_t TrackCurvSig; t->SetBranchAddress("TrackCurvSig", &TrackCurvSig); Double_t w_superOR_trig; t->SetBranchAddress("w_superOR_trig", &w_superOR_trig); Double_t w_singlelep_trig; t->SetBranchAddress("w_singlelep_trig", &w_singlelep_trig); Double_t w_ljets_trig; t->SetBranchAddress("w_ljets_trig", &w_ljets_trig); Double_t NuPz_S1; t->SetBranchAddress("NuPz_S1", &NuPz_S1); Double_t NuPz_S2; t->SetBranchAddress("NuPz_S2", &NuPz_S2); Double_t TopMassMinChiSqr; t->SetBranchAddress("TopMassMinChiSqr", &TopMassMinChiSqr); Double_t TopMassMinSig; t->SetBranchAddress("TopMassMinSig", &TopMassMinSig); Double_t SigTopMass; t->SetBranchAddress("SigTopMass", &SigTopMass); Double_t ChiTopMass; t->SetBranchAddress("ChiTopMass", &ChiTopMass); Int_t Is_W1c; t->SetBranchAddress("Is_W1c", &Is_W1c); Int_t Analysis; t->SetBranchAddress("Analysis", &Analysis); Int_t EventNumber; t->SetBranchAddress("EventNumber", &EventNumber); Int_t MCindex; t->SetBranchAddress("MCindex", &MCindex); Int_t FiredLepJetsTrigger; t->SetBranchAddress("FiredLepJetsTrigger", &FiredLepJetsTrigger); Int_t FiredSingleLepTrigger; t->SetBranchAddress("FiredSingleLepTrigger", &FiredSingleLepTrigger); Int_t Jet1MuonTagCharge; t->SetBranchAddress("Jet1MuonTagCharge", &Jet1MuonTagCharge); Int_t Jet1PartonMatch; t->SetBranchAddress("Jet1PartonMatch", &Jet1PartonMatch); Int_t Jet2MuonTagCharge; t->SetBranchAddress("Jet2MuonTagCharge", &Jet2MuonTagCharge); Int_t Jet2PartonMatch; t->SetBranchAddress("Jet2PartonMatch", &Jet2PartonMatch); Int_t Jet3MuonTagCharge; t->SetBranchAddress("Jet3MuonTagCharge", &Jet3MuonTagCharge); Int_t Jet3PartonMatch; t->SetBranchAddress("Jet3PartonMatch", &Jet3PartonMatch); Int_t Jet4MuonTagCharge; t->SetBranchAddress("Jet4MuonTagCharge", &Jet4MuonTagCharge); Int_t Jet4PartonMatch; t->SetBranchAddress("Jet4PartonMatch", &Jet4PartonMatch); Int_t LeptonCharge; t->SetBranchAddress("LeptonCharge", &LeptonCharge); Int_t LeptonNCFTHits; t->SetBranchAddress("LeptonNCFTHits", &LeptonNCFTHits); Int_t LeptonNSMTHits; t->SetBranchAddress("LeptonNSMTHits", &LeptonNSMTHits); Int_t NGoodJets; t->SetBranchAddress("NGoodJets", &NGoodJets); Int_t NAllPrimaryVertex; t->SetBranchAddress("NAllPrimaryVertex", &NAllPrimaryVertex); Int_t NTaggedJets; t->SetBranchAddress("NTaggedJets", &NTaggedJets); Int_t RunNumber; t->SetBranchAddress("RunNumber", &RunNumber); Double_t Jet1E; t->SetBranchAddress("Jet1E", &Jet1E); Double_t Jet1Pt; t->SetBranchAddress("Jet1Pt", &Jet1Pt); Double_t Jet1Phi; t->SetBranchAddress("Jet1Phi", &Jet1Phi); Double_t Jet1Eta; t->SetBranchAddress("Jet1Eta", &Jet1Eta); Double_t Jet1DetEta; t->SetBranchAddress("Jet1DetEta", &Jet1DetEta); Double_t Jet1Mass; t->SetBranchAddress("Jet1Mass", &Jet1Mass); Double_t Jet1BTagNN; t->SetBranchAddress("Jet1BTagNN", &Jet1BTagNN); Double_t Jet1LeptonDeltaPhi; t->SetBranchAddress("Jet1LeptonDeltaPhi", &Jet1LeptonDeltaPhi); Double_t Jet1LeptonDeltaR; t->SetBranchAddress("Jet1LeptonDeltaR", &Jet1LeptonDeltaR); Double_t Jet1QTimesEta; t->SetBranchAddress("Jet1QTimesEta", &Jet1QTimesEta); Double_t Jet1Taggability; t->SetBranchAddress("Jet1Taggability", &Jet1Taggability); Double_t Jet1Taggability_Error; t->SetBranchAddress("Jet1Taggability_Error", &Jet1Taggability_Error); Int_t Jet1HasMU; t->SetBranchAddress("Jet1HasMU", &Jet1HasMU); Int_t Jet1Flavor; t->SetBranchAddress("Jet1Flavor", &Jet1Flavor); Double_t Jet2E; t->SetBranchAddress("Jet2E", &Jet2E); Double_t Jet2Pt; t->SetBranchAddress("Jet2Pt", &Jet2Pt); Double_t Jet2Phi; t->SetBranchAddress("Jet2Phi", &Jet2Phi); Double_t Jet2Eta; t->SetBranchAddress("Jet2Eta", &Jet2Eta); Double_t Jet2DetEta; t->SetBranchAddress("Jet2DetEta", &Jet2DetEta); Double_t Jet2Mass; t->SetBranchAddress("Jet2Mass", &Jet2Mass); Double_t Jet2BTagNN; t->SetBranchAddress("Jet2BTagNN", &Jet2BTagNN); Double_t Jet2LeptonDeltaPhi; t->SetBranchAddress("Jet2LeptonDeltaPhi", &Jet2LeptonDeltaPhi); Double_t Jet2LeptonDeltaR; t->SetBranchAddress("Jet2LeptonDeltaR", &Jet2LeptonDeltaR); Double_t Jet2QTimesEta; t->SetBranchAddress("Jet2QTimesEta", &Jet2QTimesEta); Double_t Jet2Taggability; t->SetBranchAddress("Jet2Taggability", &Jet2Taggability); Double_t Jet2Taggability_Error; t->SetBranchAddress("Jet2Taggability_Error", &Jet2Taggability_Error); Int_t Jet2HasMU; t->SetBranchAddress("Jet2HasMU", &Jet2HasMU); Int_t Jet2Flavor; t->SetBranchAddress("Jet2Flavor", &Jet2Flavor); Double_t Jet3E; t->SetBranchAddress("Jet3E", &Jet3E); Double_t Jet3Pt; t->SetBranchAddress("Jet3Pt", &Jet3Pt); Double_t Jet3Phi; t->SetBranchAddress("Jet3Phi", &Jet3Phi); Double_t Jet3Eta; t->SetBranchAddress("Jet3Eta", &Jet3Eta); Double_t Jet3DetEta; t->SetBranchAddress("Jet3DetEta", &Jet3DetEta); Double_t Jet3Mass; t->SetBranchAddress("Jet3Mass", &Jet3Mass); Double_t Jet3BTagNN; t->SetBranchAddress("Jet3BTagNN", &Jet3BTagNN); Double_t Jet3LeptonDeltaPhi; t->SetBranchAddress("Jet3LeptonDeltaPhi", &Jet3LeptonDeltaPhi); Double_t Jet3LeptonDeltaR; t->SetBranchAddress("Jet3LeptonDeltaR", &Jet3LeptonDeltaR); Double_t Jet3QTimesEta; t->SetBranchAddress("Jet3QTimesEta", &Jet3QTimesEta); Double_t Jet3Taggability; t->SetBranchAddress("Jet3Taggability", &Jet3Taggability); Double_t Jet3Taggability_Error; t->SetBranchAddress("Jet3Taggability_Error", &Jet3Taggability_Error); Int_t Jet3HasMU; t->SetBranchAddress("Jet3HasMU", &Jet3HasMU); Int_t Jet3Flavor; t->SetBranchAddress("Jet3Flavor", &Jet3Flavor); Double_t Jet4E; t->SetBranchAddress("Jet4E", &Jet4E); Double_t Jet4Pt; t->SetBranchAddress("Jet4Pt", &Jet4Pt); Double_t Jet4Phi; t->SetBranchAddress("Jet4Phi", &Jet4Phi); Double_t Jet4Eta; t->SetBranchAddress("Jet4Eta", &Jet4Eta); Double_t Jet4DetEta; t->SetBranchAddress("Jet4DetEta", &Jet4DetEta); Double_t Jet4Mass; t->SetBranchAddress("Jet4Mass", &Jet4Mass); Double_t Jet4BTagNN; t->SetBranchAddress("Jet4BTagNN", &Jet4BTagNN); Double_t Jet4LeptonDeltaPhi; t->SetBranchAddress("Jet4LeptonDeltaPhi", &Jet4LeptonDeltaPhi); Double_t Jet4LeptonDeltaR; t->SetBranchAddress("Jet4LeptonDeltaR", &Jet4LeptonDeltaR); Double_t Jet4QTimesEta; t->SetBranchAddress("Jet4QTimesEta", &Jet4QTimesEta); Double_t Jet4Taggability; t->SetBranchAddress("Jet4Taggability", &Jet4Taggability); Double_t Jet4Taggability_Error; t->SetBranchAddress("Jet4Taggability_Error", &Jet4Taggability_Error); Int_t Jet4HasMU; t->SetBranchAddress("Jet4HasMU", &Jet4HasMU); Int_t Jet4Flavor; t->SetBranchAddress("Jet4Flavor", &Jet4Flavor); Double_t MostBLikeJetE; t->SetBranchAddress("MostBLikeJetE", &MostBLikeJetE); Double_t MostBLikeJetPt; t->SetBranchAddress("MostBLikeJetPt", &MostBLikeJetPt); Double_t MostBLikeJetPhi; t->SetBranchAddress("MostBLikeJetPhi", &MostBLikeJetPhi); Double_t MostBLikeJetEta; t->SetBranchAddress("MostBLikeJetEta", &MostBLikeJetEta); Double_t MostBLikeJetDetEta; t->SetBranchAddress("MostBLikeJetDetEta", &MostBLikeJetDetEta); Double_t MostBLikeJetMass; t->SetBranchAddress("MostBLikeJetMass", &MostBLikeJetMass); Double_t MostBLikeJetBTagNN; t->SetBranchAddress("MostBLikeJetBTagNN", &MostBLikeJetBTagNN); Double_t MostBLikeJetLeptonDeltaPhi; t->SetBranchAddress("MostBLikeJetLeptonDeltaPhi", &MostBLikeJetLeptonDeltaPhi); Double_t MostBLikeJetLeptonDeltaR; t->SetBranchAddress("MostBLikeJetLeptonDeltaR", &MostBLikeJetLeptonDeltaR); Double_t MostBLikeJetQTimesEta; t->SetBranchAddress("MostBLikeJetQTimesEta", &MostBLikeJetQTimesEta); Double_t LeadingBTaggedJetE; t->SetBranchAddress("LeadingBTaggedJetE", &LeadingBTaggedJetE); Double_t LeadingBTaggedJetPt; t->SetBranchAddress("LeadingBTaggedJetPt", &LeadingBTaggedJetPt); Double_t LeadingBTaggedJetPhi; t->SetBranchAddress("LeadingBTaggedJetPhi", &LeadingBTaggedJetPhi); Double_t LeadingBTaggedJetEta; t->SetBranchAddress("LeadingBTaggedJetEta", &LeadingBTaggedJetEta); Double_t LeadingBTaggedJetDetEta; t->SetBranchAddress("LeadingBTaggedJetDetEta", &LeadingBTaggedJetDetEta); Double_t LeadingBTaggedJetMass; t->SetBranchAddress("LeadingBTaggedJetMass", &LeadingBTaggedJetMass); Double_t LeadingBTaggedJetBTagNN; t->SetBranchAddress("LeadingBTaggedJetBTagNN", &LeadingBTaggedJetBTagNN); Double_t LeadingBTaggedJetLeptonDeltaPhi; t->SetBranchAddress("LeadingBTaggedJetLeptonDeltaPhi", &LeadingBTaggedJetLeptonDeltaPhi); Double_t LeadingBTaggedJetLeptonDeltaR; t->SetBranchAddress("LeadingBTaggedJetLeptonDeltaR", &LeadingBTaggedJetLeptonDeltaR); Double_t LeadingBTaggedJetQTimesEta; t->SetBranchAddress("LeadingBTaggedJetQTimesEta", &LeadingBTaggedJetQTimesEta); Double_t SecondBTaggedJetE; t->SetBranchAddress("SecondBTaggedJetE", &SecondBTaggedJetE); Double_t SecondBTaggedJetPt; t->SetBranchAddress("SecondBTaggedJetPt", &SecondBTaggedJetPt); Double_t SecondBTaggedJetPhi; t->SetBranchAddress("SecondBTaggedJetPhi", &SecondBTaggedJetPhi); Double_t SecondBTaggedJetEta; t->SetBranchAddress("SecondBTaggedJetEta", &SecondBTaggedJetEta); Double_t SecondBTaggedJetDetEta; t->SetBranchAddress("SecondBTaggedJetDetEta", &SecondBTaggedJetDetEta); Double_t SecondBTaggedJetMass; t->SetBranchAddress("SecondBTaggedJetMass", &SecondBTaggedJetMass); Double_t SecondBTaggedJetBTagNN; t->SetBranchAddress("SecondBTaggedJetBTagNN", &SecondBTaggedJetBTagNN); Double_t SecondBTaggedJetLeptonDeltaPhi; t->SetBranchAddress("SecondBTaggedJetLeptonDeltaPhi", &SecondBTaggedJetLeptonDeltaPhi); Double_t SecondBTaggedJetLeptonDeltaR; t->SetBranchAddress("SecondBTaggedJetLeptonDeltaR", &SecondBTaggedJetLeptonDeltaR); Double_t SecondBTaggedJetQTimesEta; t->SetBranchAddress("SecondBTaggedJetQTimesEta", &SecondBTaggedJetQTimesEta); Double_t LeadingLightQuarkJetE; t->SetBranchAddress("LeadingLightQuarkJetE", &LeadingLightQuarkJetE); Double_t LeadingLightQuarkJetPt; t->SetBranchAddress("LeadingLightQuarkJetPt", &LeadingLightQuarkJetPt); Double_t LeadingLightQuarkJetPhi; t->SetBranchAddress("LeadingLightQuarkJetPhi", &LeadingLightQuarkJetPhi); Double_t LeadingLightQuarkJetEta; t->SetBranchAddress("LeadingLightQuarkJetEta", &LeadingLightQuarkJetEta); Double_t LeadingLightQuarkJetDetEta; t->SetBranchAddress("LeadingLightQuarkJetDetEta", &LeadingLightQuarkJetDetEta); Double_t LeadingLightQuarkJetMass; t->SetBranchAddress("LeadingLightQuarkJetMass", &LeadingLightQuarkJetMass); Double_t LeadingLightQuarkJetBTagNN; t->SetBranchAddress("LeadingLightQuarkJetBTagNN", &LeadingLightQuarkJetBTagNN); Double_t LeadingLightQuarkJetLeptonDeltaPhi; t->SetBranchAddress("LeadingLightQuarkJetLeptonDeltaPhi", &LeadingLightQuarkJetLeptonDeltaPhi); Double_t LeadingLightQuarkJetLeptonDeltaR; t->SetBranchAddress("LeadingLightQuarkJetLeptonDeltaR", &LeadingLightQuarkJetLeptonDeltaR); Double_t LeadingLightQuarkJetQTimesEta; t->SetBranchAddress("LeadingLightQuarkJetQTimesEta", &LeadingLightQuarkJetQTimesEta); Double_t SecondLightQuarkJetE; t->SetBranchAddress("SecondLightQuarkJetE", &SecondLightQuarkJetE); Double_t SecondLightQuarkJetPt; t->SetBranchAddress("SecondLightQuarkJetPt", &SecondLightQuarkJetPt); Double_t SecondLightQuarkJetPhi; t->SetBranchAddress("SecondLightQuarkJetPhi", &SecondLightQuarkJetPhi); Double_t SecondLightQuarkJetEta; t->SetBranchAddress("SecondLightQuarkJetEta", &SecondLightQuarkJetEta); Double_t SecondLightQuarkJetDetEta; t->SetBranchAddress("SecondLightQuarkJetDetEta", &SecondLightQuarkJetDetEta); Double_t SecondLightQuarkJetMass; t->SetBranchAddress("SecondLightQuarkJetMass", &SecondLightQuarkJetMass); Double_t SecondLightQuarkJetBTagNN; t->SetBranchAddress("SecondLightQuarkJetBTagNN", &SecondLightQuarkJetBTagNN); Double_t SecondLightQuarkJetLeptonDeltaPhi; t->SetBranchAddress("SecondLightQuarkJetLeptonDeltaPhi", &SecondLightQuarkJetLeptonDeltaPhi); Double_t SecondLightQuarkJetLeptonDeltaR; t->SetBranchAddress("SecondLightQuarkJetLeptonDeltaR", &SecondLightQuarkJetLeptonDeltaR); Double_t SecondLightQuarkJetQTimesEta; t->SetBranchAddress("SecondLightQuarkJetQTimesEta", &SecondLightQuarkJetQTimesEta); //Int_t MCkeylength; t->SetBranchAddress("MCkeylength", &MCkeylength); //Char_t MCkey[MCkeylength]; t->SetBranchAddress("MCkey[MCkeylength]", &MCkey[MCkeylength]); Double_t DeltaPhiMinMETJet; t->SetBranchAddress("DeltaPhiMinMETJet", &DeltaPhiMinMETJet); Double_t LeptonChisq; t->SetBranchAddress("LeptonChisq", &LeptonChisq); Double_t LeptonChisqProb; t->SetBranchAddress("LeptonChisqProb", &LeptonChisqProb); Double_t PVx; t->SetBranchAddress("PVx", &PVx); Double_t PVy; t->SetBranchAddress("PVy", &PVy); Double_t weight_btagBLBCSF; t->SetBranchAddress("weight_btagBLBCSF", &weight_btagBLBCSF); Double_t scale_MM; t->SetBranchAddress("scale_MM", &scale_MM); Double_t weight_EMcorr_Plus; t->SetBranchAddress("weight_EMcorr_Plus", &weight_EMcorr_Plus); Double_t weight_EMcorr_Minus; t->SetBranchAddress("weight_EMcorr_Minus", &weight_EMcorr_Minus); Double_t weight_Muon_ID_Plus; t->SetBranchAddress("weight_Muon_ID_Plus", &weight_Muon_ID_Plus); Double_t weight_Muon_ID_Minus; t->SetBranchAddress("weight_Muon_ID_Minus", &weight_Muon_ID_Minus); Double_t weight_VC; t->SetBranchAddress("weight_VC", &weight_VC); Double_t weight_VC_Plus; t->SetBranchAddress("weight_VC_Plus", &weight_VC_Plus); Double_t weight_VC_Minus; t->SetBranchAddress("weight_VC_Minus", &weight_VC_Minus); Double_t weight_VCTaga; t->SetBranchAddress("weight_VCTaga", &weight_VCTaga); Double_t weight_VCTaga_Plus; t->SetBranchAddress("weight_VCTaga_Plus", &weight_VCTaga_Plus); Double_t weight_VCTaga_Minus; t->SetBranchAddress("weight_VCTaga_Minus", &weight_VCTaga_Minus); Double_t Jet1PtJES; t->SetBranchAddress("Jet1PtJES", &Jet1PtJES); Double_t Jet2PtJES; t->SetBranchAddress("Jet2PtJES", &Jet2PtJES); Double_t Jet3PtJES; t->SetBranchAddress("Jet3PtJES", &Jet3PtJES); Double_t Jet4PtJES; t->SetBranchAddress("Jet4PtJES", &Jet4PtJES); Int_t RunPeriod; t->SetBranchAddress("RunPeriod", &RunPeriod); Int_t FiredSuperORTrigger; t->SetBranchAddress("FiredSuperORTrigger", &FiredSuperORTrigger); Int_t FiredMegaORTrigger; t->SetBranchAddress("FiredMegaORTrigger", &FiredMegaORTrigger); Int_t Jet1IsZB; t->SetBranchAddress("Jet1IsZB", &Jet1IsZB); Int_t Jet2IsZB; t->SetBranchAddress("Jet2IsZB", &Jet2IsZB); Int_t Jet3IsZB; t->SetBranchAddress("Jet3IsZB", &Jet3IsZB); Int_t Jet4IsZB; t->SetBranchAddress("Jet4IsZB", &Jet4IsZB); Double_t Jet1BTagMVA; t->SetBranchAddress("Jet1BTagMVA", &Jet1BTagMVA); Double_t Jet1BTagMVABC; t->SetBranchAddress("Jet1BTagMVABC", &Jet1BTagMVABC); Double_t Jet1BTagMVABLBC; t->SetBranchAddress("Jet1BTagMVABLBC", &Jet1BTagMVABLBC); Double_t Jet1BTagMVAVBB; t->SetBranchAddress("Jet1BTagMVAVBB", &Jet1BTagMVAVBB); Double_t Jet2BTagMVA; t->SetBranchAddress("Jet2BTagMVA", &Jet2BTagMVA); Double_t Jet2BTagMVABC; t->SetBranchAddress("Jet2BTagMVABC", &Jet2BTagMVABC); Double_t Jet2BTagMVABLBC; t->SetBranchAddress("Jet2BTagMVABLBC", &Jet2BTagMVABLBC); Double_t Jet2BTagMVAVBB; t->SetBranchAddress("Jet2BTagMVAVBB", &Jet2BTagMVAVBB); Double_t Jet3BTagMVA; t->SetBranchAddress("Jet3BTagMVA", &Jet3BTagMVA); Double_t Jet3BTagMVABC; t->SetBranchAddress("Jet3BTagMVABC", &Jet3BTagMVABC); Double_t Jet3BTagMVABLBC; t->SetBranchAddress("Jet3BTagMVABLBC", &Jet3BTagMVABLBC); Double_t Jet3BTagMVAVBB; t->SetBranchAddress("Jet3BTagMVAVBB", &Jet3BTagMVAVBB); Double_t Jet4BTagMVA; t->SetBranchAddress("Jet4BTagMVA", &Jet4BTagMVA); Double_t Jet4BTagMVABC; t->SetBranchAddress("Jet4BTagMVABC", &Jet4BTagMVABC); Double_t Jet4BTagMVABLBC; t->SetBranchAddress("Jet4BTagMVABLBC", &Jet4BTagMVABLBC); Double_t Jet4BTagMVAVBB; t->SetBranchAddress("Jet4BTagMVAVBB", &Jet4BTagMVAVBB); Double_t MostBLikeJetBTagMVA; t->SetBranchAddress("MostBLikeJetBTagMVA", &MostBLikeJetBTagMVA); Double_t MostBLikeJetBTagMVABC; t->SetBranchAddress("MostBLikeJetBTagMVABC", &MostBLikeJetBTagMVABC); Double_t MostBLikeJetBTagMVABLBC; t->SetBranchAddress("MostBLikeJetBTagMVABLBC", &MostBLikeJetBTagMVABLBC); Double_t MostBLikeJetBTagMVAVBB; t->SetBranchAddress("MostBLikeJetBTagMVAVBB", &MostBLikeJetBTagMVAVBB); Double_t LeadingLightQuarkJetBTagMVA; t->SetBranchAddress("LeadingLightQuarkJetBTagMVA", &LeadingLightQuarkJetBTagMVA); Double_t LeadingLightQuarkJetBTagMVABC; t->SetBranchAddress("LeadingLightQuarkJetBTagMVABC", &LeadingLightQuarkJetBTagMVABC); Double_t LeadingLightQuarkJetBTagMVABLBC; t->SetBranchAddress("LeadingLightQuarkJetBTagMVABLBC", &LeadingLightQuarkJetBTagMVABLBC); Double_t LeadingLightQuarkJetBTagMVAVBB; t->SetBranchAddress("LeadingLightQuarkJetBTagMVAVBB", &LeadingLightQuarkJetBTagMVAVBB); Double_t SecondLightQuarkJetBTagMVA; t->SetBranchAddress("SecondLightQuarkJetBTagMVA", &SecondLightQuarkJetBTagMVA); Double_t SecondLightQuarkJetBTagMVABC; t->SetBranchAddress("SecondLightQuarkJetBTagMVABC", &SecondLightQuarkJetBTagMVABC); Double_t SecondLightQuarkJetBTagMVABLBC; t->SetBranchAddress("SecondLightQuarkJetBTagMVABLBC", &SecondLightQuarkJetBTagMVABLBC); Double_t SecondLightQuarkJetBTagMVAVBB; t->SetBranchAddress("SecondLightQuarkJetBTagMVAVBB", &SecondLightQuarkJetBTagMVAVBB); Double_t LeadingBTaggedJetBTagMVA; t->SetBranchAddress("LeadingBTaggedJetBTagMVA", &LeadingBTaggedJetBTagMVA); Double_t LeadingBTaggedJetBTagMVABC; t->SetBranchAddress("LeadingBTaggedJetBTagMVABC", &LeadingBTaggedJetBTagMVABC); Double_t LeadingBTaggedJetBTagMVABLBC; t->SetBranchAddress("LeadingBTaggedJetBTagMVABLBC", &LeadingBTaggedJetBTagMVABLBC); Double_t LeadingBTaggedJetBTagMVAVBB; t->SetBranchAddress("LeadingBTaggedJetBTagMVAVBB", &LeadingBTaggedJetBTagMVAVBB); Double_t SecondBTaggedJetBTagMVA; t->SetBranchAddress("SecondBTaggedJetBTagMVA", &SecondBTaggedJetBTagMVA); Double_t SecondBTaggedJetBTagMVABC; t->SetBranchAddress("SecondBTaggedJetBTagMVABC", &SecondBTaggedJetBTagMVABC); Double_t SecondBTaggedJetBTagMVABLBC; t->SetBranchAddress("SecondBTaggedJetBTagMVABLBC", &SecondBTaggedJetBTagMVABLBC); Double_t SecondBTaggedJetBTagMVAVBB; t->SetBranchAddress("SecondBTaggedJetBTagMVAVBB", &SecondBTaggedJetBTagMVAVBB); Double_t QTimesLeptonEta; t->SetBranchAddress("QTimesLeptonEta", &QTimesLeptonEta); Int_t nevents = t->GetEntries(); FILE *dest_file; dest_file = fopen(destination_path,"w"); // cout << "ok 1"; for (Int_t i = 0; i< nevents; i++) { t->GetEvent(i); fprintf(dest_file,"%30.25f",Centrality_AllJets); fprintf(dest_file,"%30.25f",Cos_Jet1AllJets_AllJets); fprintf(dest_file,"%30.25f",Cos_Jet1Lepton_Lab); fprintf(dest_file,"%30.25f",Cos_Jet2AllJets_AllJets); fprintf(dest_file,"%30.25f",Cos_Jet2Lepton_Lab); fprintf(dest_file,"%30.25f",Cos_LightQuarkJetLepton_BTaggedTop); fprintf(dest_file,"%30.25f",DeltaPhiJet1Jet2); fprintf(dest_file,"%30.25f",DeltaPhiJet1MET); fprintf(dest_file,"%30.25f",DeltaPhiJet2MET); fprintf(dest_file,"%30.25f",DeltaPhiLeptonMET); fprintf(dest_file,"%30.25f",DeltaRJet1Jet2); fprintf(dest_file,"%30.25f",DeltaRMinLeptonJet); //fprintf(dest_file,"%30.25f",EventWeight); fprintf(dest_file,"%30.25f",H_AllJets); fprintf(dest_file,"%30.25f",H_Jet1Jet2); fprintf(dest_file,"%30.25f",HT_AllJets); fprintf(dest_file,"%30.25f",HT_AllJetsLeptonMET); fprintf(dest_file,"%30.25f",HT_Jet1Jet2); fprintf(dest_file,"%30.25f",HT_METlep); fprintf(dest_file,"%30.25f",InstLumi); fprintf(dest_file,"%30.25f",InvariantMass_AllJets); fprintf(dest_file,"%30.25f",InvariantMass_Jet1Jet2); fprintf(dest_file,"%30.25f",Jet1MuonPtRel); fprintf(dest_file,"%30.25f",Jet2MuonPtRel); fprintf(dest_file,"%30.25f",Jet3MuonPtRel); fprintf(dest_file,"%30.25f",Jet4MuonPtRel); fprintf(dest_file,"%30.25f",LeptonDCA); fprintf(dest_file,"%30.25f",LeptonDCASig); fprintf(dest_file,"%30.25f",LeptonDetEta); fprintf(dest_file,"%30.25f",LeptonDetEtaCFT); fprintf(dest_file,"%30.25f",LeptonE); fprintf(dest_file,"%30.25f",LeptonEta); fprintf(dest_file,"%30.25f",LeptonPhi); fprintf(dest_file,"%30.25f",LeptonPt); fprintf(dest_file,"%30.25f",METPhi); fprintf(dest_file,"%30.25f",METPt); fprintf(dest_file,"%30.25f",METPx); fprintf(dest_file,"%30.25f",METPy); fprintf(dest_file,"%30.25f",MetSig); fprintf(dest_file,"%30.25f",Pt_Jet1Jet2); fprintf(dest_file,"%30.25f",PVz); fprintf(dest_file,"%30.25f",QTimesEta); fprintf(dest_file,"%30.25f",TransverseMass_Jet1Jet2); fprintf(dest_file,"%30.25f",weight_btag); fprintf(dest_file,"%30.25f",weight_btagSF); fprintf(dest_file,"%30.25f",weight_btagTaga); fprintf(dest_file,"%30.25f",weight_Lumi); fprintf(dest_file,"%30.25f",weight_Lumi2); fprintf(dest_file,"%30.25f",weight_LeptonDetEta); fprintf(dest_file,"%30.25f",weight_WPt); fprintf(dest_file,"%30.25f",weight_VJets); fprintf(dest_file,"%30.25f",weight_QCDshape); fprintf(dest_file,"%30.25f",scale_HF); fprintf(dest_file,"%30.25f",scale_MC); fprintf(dest_file,"%30.25f",scale_MC2); fprintf(dest_file,"%30.25f",scale_norm); fprintf(dest_file,"%30.25f",weight_EMcorr); fprintf(dest_file,"%30.25f",weight_Muon_ID); fprintf(dest_file,"%30.25f",WPt); fprintf(dest_file,"%30.25f",WTransverseMass); fprintf(dest_file,"%30.25f",KS_LeptonPt); fprintf(dest_file,"%30.25f",KS_METPt); fprintf(dest_file,"%30.25f",KS_WTransverseMass); fprintf(dest_file,"%30.25f",TrackQPt); fprintf(dest_file,"%30.25f",TrackCurvSig); fprintf(dest_file,"%30.25f",w_superOR_trig); fprintf(dest_file,"%30.25f",w_singlelep_trig); fprintf(dest_file,"%30.25f",w_ljets_trig); fprintf(dest_file,"%30.25f",NuPz_S1); fprintf(dest_file,"%30.25f",NuPz_S2); fprintf(dest_file,"%30.25f",TopMassMinChiSqr); fprintf(dest_file,"%30.25f",TopMassMinSig); fprintf(dest_file,"%30.25f",SigTopMass); fprintf(dest_file,"%30.25f",ChiTopMass); fprintf(dest_file,"%30i",Is_W1c); fprintf(dest_file,"%30i",Analysis); fprintf(dest_file,"%30i",EventNumber); fprintf(dest_file,"%30i",MCindex); fprintf(dest_file,"%30i",FiredLepJetsTrigger); fprintf(dest_file,"%30i",FiredSingleLepTrigger); fprintf(dest_file,"%30i",Jet1MuonTagCharge); fprintf(dest_file,"%30i",Jet1PartonMatch); fprintf(dest_file,"%30i",Jet2MuonTagCharge); fprintf(dest_file,"%30i",Jet2PartonMatch); fprintf(dest_file,"%30i",Jet3MuonTagCharge); fprintf(dest_file,"%30i",Jet3PartonMatch); fprintf(dest_file,"%30i",Jet4MuonTagCharge); fprintf(dest_file,"%30i",Jet4PartonMatch); fprintf(dest_file,"%30i",LeptonCharge); fprintf(dest_file,"%30i",LeptonNCFTHits); fprintf(dest_file,"%30i",LeptonNSMTHits); fprintf(dest_file,"%30i",NGoodJets); fprintf(dest_file,"%30i",NAllPrimaryVertex); fprintf(dest_file,"%30i",NTaggedJets); fprintf(dest_file,"%30i",RunNumber); fprintf(dest_file,"%30.25f",Jet1E); fprintf(dest_file,"%30.25f",Jet1Pt); fprintf(dest_file,"%30.25f",Jet1Phi); fprintf(dest_file,"%30.25f",Jet1Eta); fprintf(dest_file,"%30.25f",Jet1DetEta); fprintf(dest_file,"%30.25f",Jet1Mass); fprintf(dest_file,"%30.25f",Jet1BTagNN); fprintf(dest_file,"%30.25f",Jet1LeptonDeltaPhi); fprintf(dest_file,"%30.25f",Jet1LeptonDeltaR); fprintf(dest_file,"%30.25f",Jet1QTimesEta); fprintf(dest_file,"%30.25f",Jet1Taggability); fprintf(dest_file,"%30.25f",Jet1Taggability_Error); fprintf(dest_file,"%30i",Jet1HasMU); fprintf(dest_file,"%30i",Jet1Flavor); fprintf(dest_file,"%30.25f",Jet2E); fprintf(dest_file,"%30.25f",Jet2Pt); fprintf(dest_file,"%30.25f",Jet2Phi); fprintf(dest_file,"%30.25f",Jet2Eta); fprintf(dest_file,"%30.25f",Jet2DetEta); fprintf(dest_file,"%30.25f",Jet2Mass); fprintf(dest_file,"%30.25f",Jet2BTagNN); fprintf(dest_file,"%30.25f",Jet2LeptonDeltaPhi); fprintf(dest_file,"%30.25f",Jet2LeptonDeltaR); fprintf(dest_file,"%30.25f",Jet2QTimesEta); fprintf(dest_file,"%30.25f",Jet2Taggability); fprintf(dest_file,"%30.25f",Jet2Taggability_Error); fprintf(dest_file,"%30i",Jet2HasMU); fprintf(dest_file,"%30i",Jet2Flavor); fprintf(dest_file,"%30.25f",Jet3E); fprintf(dest_file,"%30.25f",Jet3Pt); fprintf(dest_file,"%30.25f",Jet3Phi); fprintf(dest_file,"%30.25f",Jet3Eta); fprintf(dest_file,"%30.25f",Jet3DetEta); fprintf(dest_file,"%30.25f",Jet3Mass); fprintf(dest_file,"%30.25f",Jet3BTagNN); fprintf(dest_file,"%30.25f",Jet3LeptonDeltaPhi); fprintf(dest_file,"%30.25f",Jet3LeptonDeltaR); fprintf(dest_file,"%30.25f",Jet3QTimesEta); fprintf(dest_file,"%30.25f",Jet3Taggability); fprintf(dest_file,"%30.25f",Jet3Taggability_Error); fprintf(dest_file,"%30i",Jet3HasMU); fprintf(dest_file,"%30i",Jet3Flavor); fprintf(dest_file,"%30.25f",Jet4E); fprintf(dest_file,"%30.25f",Jet4Pt); fprintf(dest_file,"%30.25f",Jet4Phi); fprintf(dest_file,"%30.25f",Jet4Eta); fprintf(dest_file,"%30.25f",Jet4DetEta); fprintf(dest_file,"%30.25f",Jet4Mass); fprintf(dest_file,"%30.25f",Jet4BTagNN); fprintf(dest_file,"%30.25f",Jet4LeptonDeltaPhi); fprintf(dest_file,"%30.25f",Jet4LeptonDeltaR); fprintf(dest_file,"%30.25f",Jet4QTimesEta); fprintf(dest_file,"%30.25f",Jet4Taggability); fprintf(dest_file,"%30.25f",Jet4Taggability_Error); fprintf(dest_file,"%30i",Jet4HasMU); fprintf(dest_file,"%30i",Jet4Flavor); fprintf(dest_file,"%30.25f",MostBLikeJetE); fprintf(dest_file,"%30.25f",MostBLikeJetPt); fprintf(dest_file,"%30.25f",MostBLikeJetPhi); fprintf(dest_file,"%30.25f",MostBLikeJetEta); fprintf(dest_file,"%30.25f",MostBLikeJetDetEta); fprintf(dest_file,"%30.25f",MostBLikeJetMass); fprintf(dest_file,"%30.25f",MostBLikeJetBTagNN); fprintf(dest_file,"%30.25f",MostBLikeJetLeptonDeltaPhi); fprintf(dest_file,"%30.25f",MostBLikeJetLeptonDeltaR); fprintf(dest_file,"%30.25f",MostBLikeJetQTimesEta); fprintf(dest_file,"%30.25f",LeadingBTaggedJetE); fprintf(dest_file,"%30.25f",LeadingBTaggedJetPt); fprintf(dest_file,"%30.25f",LeadingBTaggedJetPhi); fprintf(dest_file,"%30.25f",LeadingBTaggedJetEta); fprintf(dest_file,"%30.25f",LeadingBTaggedJetDetEta); fprintf(dest_file,"%30.25f",LeadingBTaggedJetMass); fprintf(dest_file,"%30.25f",LeadingBTaggedJetBTagNN); fprintf(dest_file,"%30.25f",LeadingBTaggedJetLeptonDeltaPhi); fprintf(dest_file,"%30.25f",LeadingBTaggedJetLeptonDeltaR); fprintf(dest_file,"%30.25f",LeadingBTaggedJetQTimesEta); fprintf(dest_file,"%30.25f",SecondBTaggedJetE); fprintf(dest_file,"%30.25f",SecondBTaggedJetPt); fprintf(dest_file,"%30.25f",SecondBTaggedJetPhi); fprintf(dest_file,"%30.25f",SecondBTaggedJetEta); fprintf(dest_file,"%30.25f",SecondBTaggedJetDetEta); fprintf(dest_file,"%30.25f",SecondBTaggedJetMass); fprintf(dest_file,"%30.25f",SecondBTaggedJetBTagNN); fprintf(dest_file,"%30.25f",SecondBTaggedJetLeptonDeltaPhi); fprintf(dest_file,"%30.25f",SecondBTaggedJetLeptonDeltaR); fprintf(dest_file,"%30.25f",SecondBTaggedJetQTimesEta); fprintf(dest_file,"%30.25f",LeadingLightQuarkJetE); fprintf(dest_file,"%30.25f",LeadingLightQuarkJetPt); fprintf(dest_file,"%30.25f",LeadingLightQuarkJetPhi); fprintf(dest_file,"%30.25f",LeadingLightQuarkJetEta); fprintf(dest_file,"%30.25f",LeadingLightQuarkJetDetEta); fprintf(dest_file,"%30.25f",LeadingLightQuarkJetMass); fprintf(dest_file,"%30.25f",LeadingLightQuarkJetBTagNN); fprintf(dest_file,"%30.25f",LeadingLightQuarkJetLeptonDeltaPhi); fprintf(dest_file,"%30.25f",LeadingLightQuarkJetLeptonDeltaR); fprintf(dest_file,"%30.25f",LeadingLightQuarkJetQTimesEta); fprintf(dest_file,"%30.25f",SecondLightQuarkJetE); fprintf(dest_file,"%30.25f",SecondLightQuarkJetPt); fprintf(dest_file,"%30.25f",SecondLightQuarkJetPhi); fprintf(dest_file,"%30.25f",SecondLightQuarkJetEta); fprintf(dest_file,"%30.25f",SecondLightQuarkJetDetEta); fprintf(dest_file,"%30.25f",SecondLightQuarkJetMass); fprintf(dest_file,"%30.25f",SecondLightQuarkJetBTagNN); fprintf(dest_file,"%30.25f",SecondLightQuarkJetLeptonDeltaPhi); fprintf(dest_file,"%30.25f",SecondLightQuarkJetLeptonDeltaR); fprintf(dest_file,"%30.25f",SecondLightQuarkJetQTimesEta); //fprintf(dest_file,"%30i",MCkeylength); //fprintf(dest_file,"%30s",MCkey[MCkeylength]); fprintf(dest_file,"%30.25f",DeltaPhiMinMETJet); fprintf(dest_file,"%30.25f",LeptonChisq); fprintf(dest_file,"%30.25f",LeptonChisqProb); fprintf(dest_file,"%30.25f",PVx); fprintf(dest_file,"%30.25f",PVy); fprintf(dest_file,"%30.25f",weight_btagBLBCSF); fprintf(dest_file,"%30.25f",scale_MM); fprintf(dest_file,"%30.25f",weight_EMcorr_Plus); fprintf(dest_file,"%30.25f",weight_EMcorr_Minus); fprintf(dest_file,"%30.25f",weight_Muon_ID_Plus); fprintf(dest_file,"%30.25f",weight_Muon_ID_Minus); fprintf(dest_file,"%30.25f",weight_VC); fprintf(dest_file,"%30.25f",weight_VC_Plus); fprintf(dest_file,"%30.25f",weight_VC_Minus); fprintf(dest_file,"%30.25f",weight_VCTaga); fprintf(dest_file,"%30.25f",weight_VCTaga_Plus); fprintf(dest_file,"%30.25f",weight_VCTaga_Minus); fprintf(dest_file,"%30.25f",Jet1PtJES); fprintf(dest_file,"%30.25f",Jet2PtJES); fprintf(dest_file,"%30.25f",Jet3PtJES); fprintf(dest_file,"%30.25f",Jet4PtJES); fprintf(dest_file,"%30i",RunPeriod); fprintf(dest_file,"%30i",FiredSuperORTrigger); fprintf(dest_file,"%30i",FiredMegaORTrigger); fprintf(dest_file,"%30i",Jet1IsZB); fprintf(dest_file,"%30i",Jet2IsZB); fprintf(dest_file,"%30i",Jet3IsZB); fprintf(dest_file,"%30i",Jet4IsZB); fprintf(dest_file,"%30.25f",Jet1BTagMVA); fprintf(dest_file,"%30.25f",Jet1BTagMVABC); fprintf(dest_file,"%30.25f",Jet1BTagMVABLBC); fprintf(dest_file,"%30.25f",Jet1BTagMVAVBB); fprintf(dest_file,"%30.25f",Jet2BTagMVA); fprintf(dest_file,"%30.25f",Jet2BTagMVABC); fprintf(dest_file,"%30.25f",Jet2BTagMVABLBC); fprintf(dest_file,"%30.25f",Jet2BTagMVAVBB); fprintf(dest_file,"%30.25f",Jet3BTagMVA); fprintf(dest_file,"%30.25f",Jet3BTagMVABC); fprintf(dest_file,"%30.25f",Jet3BTagMVABLBC); fprintf(dest_file,"%30.25f",Jet3BTagMVAVBB); fprintf(dest_file,"%30.25f",Jet4BTagMVA); fprintf(dest_file,"%30.25f",Jet4BTagMVABC); fprintf(dest_file,"%30.25f",Jet4BTagMVABLBC); fprintf(dest_file,"%30.25f",Jet4BTagMVAVBB); fprintf(dest_file,"%30.25f",MostBLikeJetBTagMVA); fprintf(dest_file,"%30.25f",MostBLikeJetBTagMVABC); fprintf(dest_file,"%30.25f",MostBLikeJetBTagMVABLBC); fprintf(dest_file,"%30.25f",MostBLikeJetBTagMVAVBB); fprintf(dest_file,"%30.25f",LeadingLightQuarkJetBTagMVA); fprintf(dest_file,"%30.25f",LeadingLightQuarkJetBTagMVABC); fprintf(dest_file,"%30.25f",LeadingLightQuarkJetBTagMVABLBC); fprintf(dest_file,"%30.25f",LeadingLightQuarkJetBTagMVAVBB); fprintf(dest_file,"%30.25f",SecondLightQuarkJetBTagMVA); fprintf(dest_file,"%30.25f",SecondLightQuarkJetBTagMVABC); fprintf(dest_file,"%30.25f",SecondLightQuarkJetBTagMVABLBC); fprintf(dest_file,"%30.25f",SecondLightQuarkJetBTagMVAVBB); fprintf(dest_file,"%30.25f",LeadingBTaggedJetBTagMVA); fprintf(dest_file,"%30.25f",LeadingBTaggedJetBTagMVABC); fprintf(dest_file,"%30.25f",LeadingBTaggedJetBTagMVABLBC); fprintf(dest_file,"%30.25f",LeadingBTaggedJetBTagMVAVBB); fprintf(dest_file,"%30.25f",SecondBTaggedJetBTagMVA); fprintf(dest_file,"%30.25f",SecondBTaggedJetBTagMVABC); fprintf(dest_file,"%30.25f",SecondBTaggedJetBTagMVABLBC); fprintf(dest_file,"%30.25f",SecondBTaggedJetBTagMVAVBB); fprintf(dest_file,"%30.25f",QTimesLeptonEta); fprintf(dest_file,"%30.25f\n",EventWeight); } fclose(dest_file); // dest_file = fopen(destination_path_variables,"w"); // // TObjArray *arr = t->GetListOfBranches(); // for (int i = 0; i < arr->GetSize(); i++) { // fprintf(dest_file,"%s\n", arr->At(i)->GetTitle() ); // } // fclose(dest_file); }
void draw_survey() { TFile * infile = new TFile("geotr.root","READ"); TTree * tr = (TTree*) infile->Get("geotr"); Int_t nstb,row,col; tr->SetBranchAddress("nstb",&nstb); tr->SetBranchAddress("row",&row); tr->SetBranchAddress("col",&col); const Double_t large_width = 58.0; // large cell width const Double_t small_width = 38.0; // small cell width Double_t x,y,z,x1,y1,x2,y2; Int_t it=0; Int_t color; TLine * cell[4][1264]; for(Int_t i=0; i<tr->GetEntries(); i++) { tr->GetEntry(i); switch(nstb) { case 1: x = -24.0 - 25.0 - 58.6 * col; y = 965.5 - 58.5 * row; z = 7208; color = (Int_t) kMagenta; break; case 2: x = -24.0 - 8.0 + 66.6 + 58.4 * col; //new position May 5 2015 y = 965.1 - 58.6 * row; z = 7188; color = (Int_t) kRed; break; case 3: if(row>16.5) { x = -22.0 - 17.7 - 38.2 * col; y = 422.7 - 37.9 * row; z = 7208; color = (Int_t) kBlue; } else { x = -22.0 - 17.7 - 38.2 * col; y = 4.75 + 438.9 - 39.0 * row; z = 7204; color = (Int_t) kCyan; }; break; case 4: x = -22.0 - 8.0 + 60. + 38.4 * col; // new position May 5 2015 y = 444. - 38.7 * row; z = 7188; color = (Int_t) kGreen+2; break; }; if(nstb<=2) { x1 = x - large_width/2.0; x2 = x + large_width/2.0; y1 = y - large_width/2.0; y2 = y + large_width/2.0; } else { x1 = x - small_width/2.0; x2 = x + small_width/2.0; y1 = y - small_width/2.0; y2 = y + small_width/2.0; }; cell[0][it] = new TLine(x1,y1,x2,y1); //t cell[1][it] = new TLine(x1,y2,x2,y2); //b cell[2][it] = new TLine(x1,y1,x1,y2); //l cell[3][it] = new TLine(x2,y1,x2,y2); //r for(Int_t j=0; j<4; j++) cell[j][it]->SetLineColor(color); it++; }; Double_t md = 1200; Int_t factor = 1; // bins per millimeter... set this too high and you'll get a memory leak! factor *= 2; TH2D * bg = new TH2D("survey","FMS cells survey [mm]",factor*md,-1*md,md,factor*md,-1*md,md); TCanvas * survey = new TCanvas("survey","survey",700,700); gStyle->SetOptStat(0); bg->Draw(); for(Int_t i=0; i<1264; i++) for(Int_t j=0; j<4; j++) cell[j][i]->Draw(); };
void reweightCheck(){ Bool_t debugInfo = false; Bool_t debugEventData = false; int libpdf_check = gSystem->Load("../libpdf.so"); int compiledrv_check = gSystem->CompileMacro("../higgs_drv.cc","0", "higgs_drv"); TFile *fin = TFile::Open("test_inputs/MG5_h0p_converted.root"); TTree *tin = (TTree*) fin->Get("Delphes"); Float_t elec_mass; Float_t elec_pt; Float_t elec_px; Float_t elec_py; Float_t elec_pz; Float_t elec_eta; Float_t elec_phi; Float_t elec_e; Int_t elec_pid; Float_t ve_mass; Float_t ve_pt; Float_t ve_px; Float_t ve_py; Float_t ve_pz; Float_t ve_eta; Float_t ve_phi; Float_t ve_e; Int_t ve_pid; Float_t mu_mass; Float_t mu_pt; Float_t mu_px; Float_t mu_py; Float_t mu_pz; Float_t mu_eta; Float_t mu_phi; Float_t mu_e; Int_t mu_pid; Float_t vm_mass; Float_t vm_pt; Float_t vm_px; Float_t vm_py; Float_t vm_pz; Float_t vm_eta; Float_t vm_phi; Float_t vm_e; Int_t vm_pid; Float_t g1_mass; Float_t g1_pt; Float_t g1_px; Float_t g1_py; Float_t g1_pz; Float_t g1_eta; Float_t g1_phi; Float_t g1_e; Int_t g1_pid; Float_t g2_mass; Float_t g2_pt; Float_t g2_px; Float_t g2_py; Float_t g2_pz; Float_t g2_eta; Float_t g2_phi; Float_t g2_e; Int_t g2_pid; Float_t h_mass; Float_t h_pt; Float_t h_px; Float_t h_py; Float_t h_pz; Float_t h_eta; Float_t h_phi; Float_t h_e; Int_t h_pid; // List of branches TBranch *b_elec_mass; //! TBranch *b_elec_pt; //! TBranch *b_elec_px; //! TBranch *b_elec_py; //! TBranch *b_elec_pz; //! TBranch *b_elec_eta; //! TBranch *b_elec_phi; //! TBranch *b_elec_e; //! TBranch *b_elec_pid; //! TBranch *b_ve_mass; //! TBranch *b_ve_pt; //! TBranch *b_ve_px; //! TBranch *b_ve_py; //! TBranch *b_ve_pz; //! TBranch *b_ve_eta; //! TBranch *b_ve_phi; //! TBranch *b_ve_e; //! TBranch *b_ve_pid; //! TBranch *b_mu_mass; //! TBranch *b_mu_pt; //! TBranch *b_mu_px; //! TBranch *b_mu_py; //! TBranch *b_mu_pz; //! TBranch *b_mu_eta; //! TBranch *b_mu_phi; //! TBranch *b_mu_e; //! TBranch *b_mu_pid; //! TBranch *b_vm_mass; //! TBranch *b_vm_pt; //! TBranch *b_vm_px; //! TBranch *b_vm_py; //! TBranch *b_vm_pz; //! TBranch *b_vm_eta; //! TBranch *b_vm_phi; //! TBranch *b_vm_e; //! TBranch *b_vm_pid; //! TBranch *b_g1_mass; //! TBranch *b_g1_pt; //! TBranch *b_g1_px; //! TBranch *b_g1_py; //! TBranch *b_g1_pz; //! TBranch *b_g1_eta; //! TBranch *b_g1_phi; //! TBranch *b_g1_e; //! TBranch *b_g1_pid; //! TBranch *b_g2_mass; //! TBranch *b_g2_pt; //! TBranch *b_g2_px; //! TBranch *b_g2_py; //! TBranch *b_g2_pz; //! TBranch *b_g2_eta; //! TBranch *b_g2_phi; //! TBranch *b_g2_e; //! TBranch *b_g2_pid; //! TBranch *b_h_mass; //! TBranch *b_h_pt; //! TBranch *b_h_px; //! TBranch *b_h_py; //! TBranch *b_h_pz; //! TBranch *b_h_eta; //! TBranch *b_h_phi; //! TBranch *b_h_e; //! TBranch *b_h_pid; //! tin->SetBranchAddress("elec_mass", &elec_mass, &b_elec_mass); tin->SetBranchAddress("elec_pt", &elec_pt, &b_elec_pt); tin->SetBranchAddress("elec_px", &elec_px, &b_elec_px); tin->SetBranchAddress("elec_py", &elec_py, &b_elec_py); tin->SetBranchAddress("elec_pz", &elec_pz, &b_elec_pz); tin->SetBranchAddress("elec_eta", &elec_eta, &b_elec_eta); tin->SetBranchAddress("elec_phi", &elec_phi, &b_elec_phi); tin->SetBranchAddress("elec_e", &elec_e, &b_elec_e); tin->SetBranchAddress("elec_pid", &elec_pid, &b_elec_pid); tin->SetBranchAddress("ve_mass", &ve_mass, &b_ve_mass); tin->SetBranchAddress("ve_pt", &ve_pt, &b_ve_pt); tin->SetBranchAddress("ve_px", &ve_px, &b_ve_px); tin->SetBranchAddress("ve_py", &ve_py, &b_ve_py); tin->SetBranchAddress("ve_pz", &ve_pz, &b_ve_pz); tin->SetBranchAddress("ve_eta", &ve_eta, &b_ve_eta); tin->SetBranchAddress("ve_phi", &ve_phi, &b_ve_phi); tin->SetBranchAddress("ve_e", &ve_e, &b_ve_e); tin->SetBranchAddress("ve_pid", &ve_pid, &b_ve_pid); tin->SetBranchAddress("mu_mass", &mu_mass, &b_mu_mass); tin->SetBranchAddress("mu_pt", &mu_pt, &b_mu_pt); tin->SetBranchAddress("mu_px", &mu_px, &b_mu_px); tin->SetBranchAddress("mu_py", &mu_py, &b_mu_py); tin->SetBranchAddress("mu_pz", &mu_pz, &b_mu_pz); tin->SetBranchAddress("mu_eta", &mu_eta, &b_mu_eta); tin->SetBranchAddress("mu_phi", &mu_phi, &b_mu_phi); tin->SetBranchAddress("mu_e", &mu_e, &b_mu_e); tin->SetBranchAddress("mu_pid", &mu_pid, &b_mu_pid); tin->SetBranchAddress("vm_mass", &vm_mass, &b_vm_mass); tin->SetBranchAddress("vm_pt", &vm_pt, &b_vm_pt); tin->SetBranchAddress("vm_px", &vm_px, &b_vm_px); tin->SetBranchAddress("vm_py", &vm_py, &b_vm_py); tin->SetBranchAddress("vm_pz", &vm_pz, &b_vm_pz); tin->SetBranchAddress("vm_eta", &vm_eta, &b_vm_eta); tin->SetBranchAddress("vm_phi", &vm_phi, &b_vm_phi); tin->SetBranchAddress("vm_e", &vm_e, &b_vm_e); tin->SetBranchAddress("vm_pid", &vm_pid, &b_vm_pid); tin->SetBranchAddress("g1_mass", &g1_mass, &b_g1_mass); tin->SetBranchAddress("g1_pt", &g1_pt, &b_g1_pt); tin->SetBranchAddress("g1_px", &g1_px, &b_g1_px); tin->SetBranchAddress("g1_py", &g1_py, &b_g1_py); tin->SetBranchAddress("g1_pz", &g1_pz, &b_g1_pz); tin->SetBranchAddress("g1_eta", &g1_eta, &b_g1_eta); tin->SetBranchAddress("g1_phi", &g1_phi, &b_g1_phi); tin->SetBranchAddress("g1_e", &g1_e, &b_g1_e); tin->SetBranchAddress("g1_pid", &g1_pid, &b_g1_pid); tin->SetBranchAddress("g2_mass", &g2_mass, &b_g2_mass); tin->SetBranchAddress("g2_pt", &g2_pt, &b_g2_pt); tin->SetBranchAddress("g2_px", &g2_px, &b_g2_px); tin->SetBranchAddress("g2_py", &g2_py, &b_g2_py); tin->SetBranchAddress("g2_pz", &g2_pz, &b_g2_pz); tin->SetBranchAddress("g2_eta", &g2_eta, &b_g2_eta); tin->SetBranchAddress("g2_phi", &g2_phi, &b_g2_phi); tin->SetBranchAddress("g2_e", &g2_e, &b_g2_e); tin->SetBranchAddress("g2_pid", &g2_pid, &b_g2_pid); tin->SetBranchAddress("h_mass", &h_mass, &b_h_mass); tin->SetBranchAddress("h_pt", &h_pt, &b_h_pt); tin->SetBranchAddress("h_px", &h_px, &b_h_px); tin->SetBranchAddress("h_py", &h_py, &b_h_py); tin->SetBranchAddress("h_pz", &h_pz, &b_h_pz); tin->SetBranchAddress("h_eta", &h_eta, &b_h_eta); tin->SetBranchAddress("h_phi", &h_phi, &b_h_phi); tin->SetBranchAddress("h_e", &h_e, &b_h_e); tin->SetBranchAddress("h_pid", &h_pid, &b_h_pid); afloat_t event_data[24]; TFile *fout = new TFile("MG5_h0p_NLO_to_h0m_histos.root", "RECREATE"); TH1F *h_mll = new TH1F("mll","mll", 20,0,100); TH1F *h_mll_rew03 = new TH1F("mllrew03","mllrew03", 20,0,100); TH1F *h_mll_rew0 = new TH1F("mllrew0","mllrew0", 20,0,100); TH1F *h_ptll = new TH1F("ptll","ptll", 20,0,120); TH1F *h_ptll_rew03 = new TH1F("ptllrew03","ptllrew03", 20,0,120); TH1F *h_ptll_rew0 = new TH1F("ptllrew0","ptllrew0", 20,0,120); TH1F *h_dphill = new TH1F("dphill","dphill", 16,0,3.2); TH1F *h_dphill_rew03 = new TH1F("dphillrew03","dphillrew03", 16,0,3.2); TH1F *h_dphill_rew0 = new TH1F("dphillrew0","dphillrew0", 16,0,3.2); TH1F *h_dpt = new TH1F("dpt","dpt", 20,0,60); TH1F *h_dpt_rew03 = new TH1F("dptrew03","dptrew03", 20,0,60); TH1F *h_dpt_rew0 = new TH1F("dptrew0","dptrew0", 20,0,60); TH1F *h_ratio = new TH1F("ratio","ratio", 100,0,10); TH1F *h_ME_ca1p = new TH1F("ME_ca1p", "ME_ca1p", 15,0, 0.0000015); TH1F *h_ME_ca1p_small = new TH1F("ME_ca1p_small", "ME_ca1p_small", 10,0, 0.000001); TH1F *h_ME_ca00 = new TH1F("ME_ca00", "ME_ca00", 15,0, 0.0000000015); TH1F *h_ME_ca00_small = new TH1F("ME_ca00_small", "ME_ca00_small", 10,0, 0.000000001); TH1F *h_ME_ca03p = new TH1F("ME_ca03p", "ME_ca03p", 15,0, 0.0000015); TH1F *h_logME_ca1p = new TH1F ("logME_ca1p", "logME_ca1p", 15, -30, 0); TH1F *h_logME_ca00 = new TH1F ("logME_ca00", "logME_ca00", 15, -30, 0); TH1F *h_ME_ca1p_weig = new TH1F("ME_ca1p_weig", "ME_ca1p_weig", 15,0, 0.0000015); TH1F *h_ME_ca00_weig = new TH1F("ME_ca00_weig", "ME_ca00_weig", 15,0, 0.0000000015); TH1F *h_ME_ca1p_weig_small = new TH1F("ME_ca1p_weig_small", "ME_ca1p_weig_small", 10,0, 0.000001); TH1F *h_ME_ca00_weig_small = new TH1F("ME_ca00_weig_small", "ME_ca00_weig_small", 10,0, 0.000000001); TH1F *h_logME_ca1p_weig = new TH1F ("logME_ca1p_weig", "logME_ca1p_weig", 15, -30, 0); TH1F *h_logME_ca00_weig = new TH1F ("logME_ca00_weig", "logME_ca00_weig", 15, -30, 0); h_mll->Sumw2(); h_mll_rew03->Sumw2(); h_mll_rew0->Sumw2(); h_ptll->Sumw2(); h_ptll_rew03->Sumw2(); h_ptll_rew0->Sumw2(); h_dphill->Sumw2(); h_dphill_rew03->Sumw2(); h_dphill_rew0->Sumw2(); h_dpt->Sumw2(); h_dpt_rew03->Sumw2(); h_dpt_rew0->Sumw2(); h_ME_ca1p->Sumw2(); h_ME_ca00->Sumw2(); h_ME_ca1p_small->Sumw2(); h_ME_ca00_small->Sumw2(); h_logME_ca1p->Sumw2(); h_logME_ca00->Sumw2(); h_ME_ca1p_weig->Sumw2(); h_ME_ca00_weig->Sumw2(); h_ME_ca1p_weig_small->Sumw2(); h_ME_ca00_weig_small->Sumw2(); h_logME_ca1p_weig->Sumw2(); h_logME_ca00_weig->Sumw2(); Float_t cthstar, cth1, cth2, phi; Long64_t nentries = tin->GetEntries(); for (Long64_t jentry=0; jentry<nentries;jentry++) { tin->GetEntry(jentry); if(jentry%10000==0) cout << jentry << endl; TLorentzVector lm, lp, vbar, v; TLorentzVector ga, gb; ga.SetPxPyPzE(g1_px, g1_py, g1_pz, g1_e); gb.SetPxPyPzE(g2_px, g2_py, g2_pz, g2_e); // in epmum electron is always -11 (positive charge) and muon 13 (negative charge) if(elec_pid>0){ lm.SetPxPyPzE(elec_px, elec_py, elec_pz, elec_e); vbar.SetPxPyPzE(ve_px, ve_py, ve_pz, ve_e); lp.SetPxPyPzE(mu_px, mu_py, mu_pz, mu_e); v.SetPxPyPzE(vm_px, vm_py, vm_pz, vm_e); }else{ lm.SetPxPyPzE(mu_px, mu_py, mu_pz, mu_e); vbar.SetPxPyPzE(vm_px, vm_py, vm_pz, vm_e); lp.SetPxPyPzE(elec_px, elec_py, elec_pz, elec_e); v.SetPxPyPzE(ve_px, ve_py, ve_pz, ve_e); } TLorentzVector particles[6]= {ga, gb, lp, v, lm, vbar}; // fill the event_data array for(int ip=0; ip<6; ++ip){ event_data[ip*4+0] = particles[ip].E(); event_data[ip*4+1] = particles[ip].Px(); event_data[ip*4+2] = particles[ip].Py(); event_data[ip*4+3] = particles[ip].Pz(); }//for ip // some selection cuts bool good_event = true; if(TMath::Abs(elec_eta)>2.47) good_event=false; if(TMath::Abs(elec_eta)<1.52 && TMath::Abs(elec_eta)>1.37) good_event=false; if(TMath::Abs(mu_eta)>2.5) good_event=false; if(elec_pt > mu_pt ){ if(elec_pt<22.) good_event=false; if(mu_pt<15.) good_event=false; } else{ if(elec_pt<15.) good_event=false; if(mu_pt<22.) good_event=false; } //if(!good_event){ // cout << elec_pt <<"\t" << mu_pt << "\t" << elec_eta <<"\t" << mu_eta << endl; //} if(!good_event) continue; TLorentzVector dilep; dilep = lp+lm; Float_t mll, ptll, dpt, dphill; mll=dilep.M(); ptll=dilep.Pt(); h_mll->Fill(mll); h_ptll->Fill(ptll); dpt=TMath::Abs(elec_pt-mu_pt); dphill=lp.DeltaPhi(lm); h_dpt->Fill(dpt); h_dphill->Fill(dphill); afloat_t result[1]; afloat_t result03[1]; afloat_t result00[1]; afloat_t ca = 1.0; afloat_t kSM = 1.0; afloat_t kHWW = 0.0; afloat_t kAWW = 0.0; afloat_t kHdw = 0.0; afloat_t Lambda = 1000.; quadme(result, event_data, 1,0,0,0,0,0,0,0,0,0,0, ca, kSM, kHWW, kAWW, kHdw, Lambda, -1); ca = 0.3; kSM = 1.0; kHWW = 2.0; kAWW = 2.0; kHdw = 1.0; Lambda = 125.5; quadme(result03, event_data, 1,0,0,0,0,0,0,0,0,0,0, ca, kSM, kHWW, kAWW, kHdw, Lambda, -1); ca = 0.0; kSM = 1.0; kHWW = 0.0; kAWW = 1.0; kHdw = 0.0; Lambda = 1000.; quadme(result00, event_data, 1,0,0,0,0,0,0,0,0,0,0, ca, kSM, kHWW, kAWW, kHdw, Lambda, -1); afloat_t norm = 1.9336535e-09; afloat_t reweight1p = (result03[0]/result[0]); afloat_t reweight0 = (result00[0]/result[0]); // cout << result00[0] << endl; //cout << result[0] << endl; h_ME_ca1p->Fill(result[0]); h_ME_ca00->Fill(result00[0]); h_ME_ca1p_small->Fill(result[0]); h_ME_ca00_small->Fill(result00[0]); h_mll_rew03->Fill(mll, reweight1p); h_mll_rew0->Fill(mll, reweight0); h_dphill_rew03->Fill(dphill, reweight1p); h_dphill_rew0->Fill(dphill, reweight0); h_ptll_rew03->Fill(ptll, reweight1p); h_ptll_rew0->Fill(ptll, reweight0); h_dpt_rew03->Fill(dpt, reweight1p); h_dpt_rew0->Fill(dpt, reweight0); h_ME_ca03p->Fill(result03[0]); h_logME_ca1p->Fill(TMath::Log(result[0])); h_logME_ca00->Fill(TMath::Log(result00[0])); h_ME_ca1p_weig->Fill(result[0], reweight1p); h_ME_ca00_weig->Fill(result00[0], reweight0); h_ME_ca1p_weig_small->Fill(result[0], reweight1p); h_ME_ca00_weig_small->Fill(result00[0], reweight0); h_logME_ca1p_weig->Fill(TMath::Log(result[0]), reweight1p); h_logME_ca00_weig->Fill(TMath::Log(result00[0]), reweight0); //h_ratio->Fill(reweight); /* // Now calculate some ZRF angles: TLorentzVector W1 = lp+v; TLorentzVector W2 = lm+vbar; const TLorentzVector H = W1+W2; TLorentzVector q; q.SetPxPyPzE(0,0, (H.E()+H.Pz())/2. , (H.E()+H.Pz())/2.); q.Boost(-(H.BoostVector())); const TVector3 parton = q.Vect().Unit(); W1.Boost(-(H.BoostVector())); W2.Boost(-(H.BoostVector())); const TVector3 w1 = W1.Vect().Unit(); const TVector3 w2 = W2.Vect().Unit(); //costh* cthstr = TMath::Cos(parton.Angle(w1)); TLorentzVector nlp(lp), nlm(lm), nv(v), nvbar(vbar); nlp.Boost(-(H.BoostVector())); nlm.Boost(-(H.BoostVector())); nv.Boost(-(H.BoostVector())); nvbar.Boost(-(H.BoostVector())); const TVector3 veclp = nlp.Vect(); const TVector3 veclm = nlm.Vect(); const TVector3 vecv = nv.Vect(); const TVector3 vecvbar = nvbar.Vect(); const TVector3 vecz(0.,0.,1.); //phi phi1 const TVector3 */ }//for nentries fout->cd(); h_ME_ca1p->Write(); h_ME_ca00->Write(); h_ME_ca1p_small->Write(); h_ME_ca00_small->Write(); h_mll->Write(); h_ptll->Write(); h_dphill->Write(); h_dpt->Write(); h_mll_rew03->Write(); h_mll_rew0->Write(); h_dphill_rew03->Write(); h_dphill_rew0->Write(); h_ptll_rew03->Write(); h_ptll_rew0->Write(); h_dpt_rew03->Write(); h_dpt_rew0->Write(); h_ME_ca03p->Write(); h_logME_ca1p->Write(); h_ME_ca1p_weig->Write(); h_ME_ca00_weig->Write(); h_ME_ca1p_weig_small->Write(); h_ME_ca00_weig_small->Write(); h_logME_ca1p_weig->Write(); h_logME_ca00_weig->Write(); // h_ratio->Write(); fout->Close(); // makeRatioPlot(h_ME_ca1p, h_ME_ca1p_weig, "0^{+}", "Same Reweig 0^{+}", "meorig", "merew", "me", "log(ME)", "Norm. Entries", "Orig/Rew","./"); }// end of script
int main(int argc, char* argv[]){ if(argc!=4){ cout<<"ERROR, need more arguments!"<<endl; return 1; } cout<<"started function"<<endl; gSystem->Load("libStoppedHSCPMuonNtuples"); cout<<"loaded library"<<endl; string file_dataset = "NoBPTX_Run2012B"; string bx_cut = "with_bx_cut"; string other_cut = "with_other_cut"; if(argc==4){ file_dataset = argv[1]; bx_cut = argv[2]; other_cut = argv[3]; cout<<"file_dataset is: "<<file_dataset<<endl; } bool do_bx_cut = false; if (bx_cut=="with_bx_cut") do_bx_cut = true; if (bx_cut=="without_bx_cut") do_bx_cut = false; cout<<"do_bx_cut is: "<<do_bx_cut<<endl; bool do_other_cut = false; if (other_cut=="with_other_cut") do_other_cut = true; if (other_cut=="without_other_cut") do_other_cut = false; cout<<"do_other_cut is: "<<do_other_cut<<endl; TString file = "blah"; //file = "root://eoscms//eos/cms/store/user/jalimena/Ntuples/" + file_dataset + "/stoppedHSCPMuonTree.root"; file = "/mnt/hadoop/users/alimena/CMS/Ntuples/" + file_dataset + "/stoppedHSCPMuonTree.root"; cout<<"file is: "<<file<<endl; TFile* f1 = TFile::Open(file); cout<<"opened input file"<<endl; TString new_file = "blah2"; //new_file = "/afs/cern.ch/user/j/jalimena/public/histos/TriggerTurnOnHistos_" + file_dataset + ".root"; //new_file = "/home/alimena/histos/TriggerTurnOnHistos_" + file_dataset + ".root"; new_file = "/home/alimena/histos/L1TriggerTurnOnHistos_" + file_dataset + ".root"; TFile* fnew = new TFile(new_file, "recreate"); cout<<"opened output file"<<endl; //get tree TTree* tree = (TTree*)f1->Get("stoppedHSCPMuonTree/StoppedHSCPMuonTree"); //tree->Print(); //tree->Show(0); //StoppedHSCPMuonEvent* events = new StoppedHSCPMuonEvent(); StoppedHSCPMuonEvent* events = 0; // Declaration of leaf types UInt_t rHadPdgId; Double_t rHadVtxX; Double_t rHadVtxY; Double_t rHadVtxZ; Double_t rHadVtxR; Double_t rHadVtxT; Double_t rHadE; Double_t rHadPx; Double_t rHadPy; Double_t rHadPz; Double_t rHadPt; UInt_t mc_N; vector<UInt_t> mcPDGid; vector<Double_t> mcVtxX; vector<Double_t> mcVtxY; vector<Double_t> mcVtxZ; vector<Double_t> mcVtxR; vector<Double_t> mcVtxT; vector<Double_t> mcE; vector<Double_t> mcPx; vector<Double_t> mcPy; vector<Double_t> mcPz; vector<Double_t> mcPt; ULong_t id; ULong_t bx; ULong_t orbit; ULong_t lb; ULong_t run; ULong_t fill; ULong_t fillFromL1; ULong64_t time; ULong64_t time2; ULong64_t time3; Long_t bxAfterCollision; Long_t bxBeforeCollision; Long_t bxWrtCollision; Long_t bxAfterBunch; Long_t bxBeforeBunch; Long_t bxWrtBunch; ULong64_t gtAlgoWord0; ULong64_t gtAlgoWord1; ULong64_t gtTechWord; vector<UInt_t> l1JetNoBptx; vector<UInt_t> l1JetNoBptxNoHalo; vector<UInt_t> l1Bptx; vector<UInt_t> l1MuBeamHalo; Bool_t hltJetNoBptx; Bool_t hltJetNoBptxNoHalo; Bool_t hltJetNoBptx3BXNoHalo; Bool_t hltJetE50NoBptx3BXNoHalo; Bool_t hltL2Mu20eta2p1NoVertex; Bool_t hltL2Mu10NoVertexNoBptx3BX; Bool_t hltL2Mu20NoVertexNoBptx3BX; Bool_t hltL2Mu30NoVertexNoBptx3BX; Bool_t hltL2Mu10NoVertexNoBptx3BXNoHalo; Bool_t hltL2Mu20NoVertexNoBptx3BXNoHalo; Bool_t hltL2Mu30NoVertexNoBptx3BXNoHalo; Bool_t hltL2Mu20NoVertex2ChaNoBptx3BXNoHalo; Bool_t hltL2Mu30NoVertex2ChaNoBptx3BXNoHalo; UInt_t l1Jet_N; vector<UInt_t> l1JetType; vector<Double_t> l1JetE; vector<Double_t> l1JetEt; vector<Double_t> l1JetEta; vector<Double_t> l1JetPhi; UInt_t hltJet_N; vector<UInt_t> hltJetType; vector<Double_t> hltJetE; vector<Double_t> hltJetEt; vector<Double_t> hltJetEta; vector<Double_t> hltJetPhi; UInt_t jet_N; vector<Double_t> jetE; vector<Double_t> jetEt; vector<Double_t> jetEta; vector<Double_t> jetPhi; vector<Double_t> jetEHad; vector<Double_t> jetEEm; vector<Double_t> jetEMaxEcalTow; vector<Double_t> jetEMaxHcalTow; vector<UInt_t> jetN60; vector<UInt_t> jetN90; vector<Double_t> jetFHPD; vector<UInt_t> jetN90Hits; UInt_t jetAK5_N; vector<Double_t> jetAK5E; vector<Double_t> jetAK5Et; vector<Double_t> jetAK5Eta; vector<Double_t> jetAK5Phi; vector<Double_t> jetAK5EHad; vector<Double_t> jetAK5EEm; vector<Double_t> jetAK5EMaxEcalTow; vector<Double_t> jetAK5EMaxHcalTow; vector<UInt_t> jetAK5N60; vector<UInt_t> jetAK5N90; vector<Double_t> jetAK5FHPD; vector<UInt_t> jetAK5N90Hits; UInt_t mu_N; vector<UInt_t> muType; vector<Double_t> muPt; vector<Double_t> muEta; vector<Double_t> muPhi; vector<Double_t> muHcalEta; vector<Double_t> muHcalPhi; vector<Double_t> muSumChargedHadronPt; vector<Double_t> muSumChargedParticlePt; vector<Double_t> muSumNeutralHadronEt; vector<Double_t> muSumPhotonEt; vector<Double_t> muSumNeutralHadronEtHighThreshold; vector<Double_t> muSumPhotonEtHighThreshold; vector<Double_t> muSumPUPt; vector<Double_t> muIso; UInt_t diMu_N; vector<Double_t> diMuMass; UInt_t mu_Cosmic_N; vector<UInt_t> muCosmicType; // type of muon (standalone/global/cosmic/regular) vector<Double_t> muCosmicPt; vector<Double_t> muCosmicEta; vector<Double_t> muCosmicPhi; vector<Double_t> muCosmicHcalEta; // track intersection with HCAL front-face (?) vector<Double_t> muCosmicHcalPhi; UInt_t mu_StandAlone_N; vector<Double_t> muStandAlonePt; vector<Double_t> muStandAloneEta; vector<Double_t> muStandAlonePhi; vector<Double_t> muStandAloneHcalEta; // track intersection with HCAL front-face (?) vector<Double_t> muStandAloneHcalPhi; vector<Double_t> muStandAloneTrackChi2; vector<Double_t> muStandAloneTrackNdof; vector<Double_t> muStandAloneTrackNormalizedChi2; vector<Double_t> muStandAloneTrackDxy; vector<Double_t> muStandAloneTrackDz; vector<Int_t> muStandAloneTrackNHits; vector<Int_t> muStandAloneTrackNLost; vector<Int_t> muStandAloneTrackNHitsMuon; vector<Int_t> muStandAloneTrackNHitsCsc; vector<Int_t> muStandAloneTrackNHitsDt; vector<Int_t> muStandAloneTrackNHitsRpc; vector<Int_t> muStandAloneTrackNStations; vector<Int_t> muStandAloneTrackNChambersCsc; vector<Int_t> muStandAloneTrackNChambersDt; vector<Int_t> muStandAloneTrackNChambersRpc; vector<Double_t> muStandAloneTrackP; vector<Int_t> muStandAloneTrackQuality; vector< vector<Int_t> > muStandAloneTrackCscSegEndcap; vector< vector<Int_t> > muStandAloneTrackCscSegRing; vector< vector<Int_t> > muStandAloneTrackCscSegStation; vector< vector<Int_t> > muStandAloneTrackCscSegChamber; vector< vector<Int_t> > muStandAloneTrackCscSegNHits; vector< vector<Double_t> > muStandAloneTrackCscSegPhi; vector< vector<Double_t> > muStandAloneTrackCscSegZ; vector< vector<Double_t> > muStandAloneTrackCscSegR; vector< vector<Double_t> > muStandAloneTrackCscSegDirPhi; vector< vector<Double_t> > muStandAloneTrackCscSegDirTheta; vector< vector<Double_t> > muStandAloneTrackCscSegTime; vector< vector<Double_t> > muStandAloneTrackRpcHitZ; vector< vector<Double_t> > muStandAloneTrackRpcHitRho; vector< vector<Double_t> > muStandAloneTrackRpcHitPhi; vector< vector<Int_t> > muStandAloneTrackRpcHitRegion; vector< vector<Int_t> > muStandAloneTrackRpcHitBx; UInt_t mu_RefittedStandAlone_N; vector<Double_t> muRefittedStandAlonePt; vector<Double_t> muRefittedStandAloneEta; vector<Double_t> muRefittedStandAlonePhi; vector<Double_t> muRefittedStandAloneHcalEta; // track intersection with HCAL front-face (?) vector<Double_t> muRefittedStandAloneHcalPhi; vector<Double_t> muRefittedStandAloneTrackChi2; vector<Double_t> muRefittedStandAloneTrackNdof; vector<Int_t> muRefittedStandAloneTrackNHits; vector<Int_t> muRefittedStandAloneTrackNLost; vector<Double_t> muRefittedStandAloneTrackP; vector<Int_t> muRefittedStandAloneTrackQuality; UInt_t nVtx; UInt_t vtx_N; vector<UInt_t> vtxNDOF; vector<Double_t> vtxZ; vector<Double_t> vtxRho; UInt_t track_N; Int_t muStandAloneTof_N; vector<Int_t> muStandAloneTofDirection; vector<Double_t> muStandAloneTofNDof; vector<Double_t> muStandAloneTofInverseBeta; vector<Double_t> muStandAloneTofInverseBetaErr; vector<Double_t> muStandAloneTofFreeInverseBeta; vector<Double_t> muStandAloneTofFreeInverseBetaErr; vector<Double_t> muStandAloneTofTimeAtIpInOut; vector<Double_t> muStandAloneTofTimeAtIpInOutErr; vector<Double_t> muStandAloneTofTimeAtIpOutIn; vector<Double_t> muStandAloneTofTimeAtIpOutInErr; Int_t muStandAloneDTTof_N; vector<Int_t> muStandAloneDTTofDirection; vector<Double_t> muStandAloneDTTofNDof; vector<Double_t> muStandAloneDTTofInverseBeta; vector<Double_t> muStandAloneDTTofInverseBetaErr; vector<Double_t> muStandAloneDTTofFreeInverseBeta; vector<Double_t> muStandAloneDTTofFreeInverseBetaErr; vector<Double_t> muStandAloneDTTofTimeAtIpInOut; vector<Double_t> muStandAloneDTTofTimeAtIpInOutErr; vector<Double_t> muStandAloneDTTofTimeAtIpOutIn; vector<Double_t> muStandAloneDTTofTimeAtIpOutInErr; Int_t muStandAloneCSCTof_N; vector<Int_t> muStandAloneCSCTofDirection; vector<Double_t> muStandAloneCSCTofNDof; vector<Double_t> muStandAloneCSCTofInverseBeta; vector<Double_t> muStandAloneCSCTofInverseBetaErr; vector<Double_t> muStandAloneCSCTofFreeInverseBeta; vector<Double_t> muStandAloneCSCTofFreeInverseBetaErr; vector<Double_t> muStandAloneCSCTofTimeAtIpInOut; vector<Double_t> muStandAloneCSCTofTimeAtIpInOutErr; vector<Double_t> muStandAloneCSCTofTimeAtIpOutIn; vector<Double_t> muStandAloneCSCTofTimeAtIpOutInErr; Int_t refitMuStandAloneTof_N; vector<Int_t> refitMuStandAloneTofDirection; vector<Double_t> refitMuStandAloneTofNDof; vector<Double_t> refitMuStandAloneTofInverseBeta; vector<Double_t> refitMuStandAloneTofInverseBetaErr; vector<Double_t> refitMuStandAloneTofFreeInverseBeta; vector<Double_t> refitMuStandAloneTofFreeInverseBetaErr; vector<Double_t> refitMuStandAloneTofTimeAtIpInOut; vector<Double_t> refitMuStandAloneTofTimeAtIpInOutErr; vector<Double_t> refitMuStandAloneTofTimeAtIpOutIn; vector<Double_t> refitMuStandAloneTofTimeAtIpOutInErr; Int_t refitMuStandAloneDTTof_N; vector<Int_t> refitMuStandAloneDTTofDirection; vector<Double_t> refitMuStandAloneDTTofNDof; vector<Double_t> refitMuStandAloneDTTofInverseBeta; vector<Double_t> refitMuStandAloneDTTofInverseBetaErr; vector<Double_t> refitMuStandAloneDTTofFreeInverseBeta; vector<Double_t> refitMuStandAloneDTTofFreeInverseBetaErr; vector<Double_t> refitMuStandAloneDTTofTimeAtIpInOut; vector<Double_t> refitMuStandAloneDTTofTimeAtIpInOutErr; vector<Double_t> refitMuStandAloneDTTofTimeAtIpOutIn; vector<Double_t> refitMuStandAloneDTTofTimeAtIpOutInErr; Int_t refitMuStandAloneCSCTof_N; vector<Int_t> refitMuStandAloneCSCTofDirection; vector<Double_t> refitMuStandAloneCSCTofNDof; vector<Double_t> refitMuStandAloneCSCTofInverseBeta; vector<Double_t> refitMuStandAloneCSCTofInverseBetaErr; vector<Double_t> refitMuStandAloneCSCTofFreeInverseBeta; vector<Double_t> refitMuStandAloneCSCTofFreeInverseBetaErr; vector<Double_t> refitMuStandAloneCSCTofTimeAtIpInOut; vector<Double_t> refitMuStandAloneCSCTofTimeAtIpInOutErr; vector<Double_t> refitMuStandAloneCSCTofTimeAtIpOutIn; vector<Double_t> refitMuStandAloneCSCTofTimeAtIpOutInErr; Bool_t beamHalo_CSCTight; Bool_t beamHalo_CSCLoose; Bool_t beamHalo_HcalTight; Bool_t beamHalo_HcalLoose; UInt_t nTowerSameiPhi; UInt_t nTowerLeadingIPhi; Double_t eHadLeadingIPhi; Double_t hfPlusTotalE; Double_t hfMinusTotalE; Double_t noiseMinE2Over10TS; Double_t noiseMaxE2Over10TS; Int_t noiseMaxHPDHits; Int_t noiseMaxRBXHits; Int_t noiseMaxHPDNoOtherHits; Int_t noiseMaxZeros; Double_t noiseMin25GeVHitTime; Double_t noiseMax25GeVHitTime; Double_t noiseMinRBXEMF; Bool_t noiseFilterResult; Float_t noiseEventEMEnergy; Float_t noiseEventHadEnergy; Float_t noiseEventTrackEnergy; Int_t noiseNumProblematicRBXs; vector<double> topHPD5TimeSamples; UInt_t topHPD5PeakSample; Double_t topHPD5Total; Double_t topHPD5R1; Double_t topHPD5R2; Double_t topHPD5RPeak; Double_t topHPD5ROuter; UInt_t hpd_N; vector<UInt_t> hpdId; vector<Double_t> hpdEta; vector<Double_t> hpdPhi; vector<UInt_t> hpdTotalZeros; vector<UInt_t> hpdMaxZeros; vector<UInt_t> hpdNJet; vector<Double_t> hpdFc0; vector<Double_t> hpdFc1; vector<Double_t> hpdFc2; vector<Double_t> hpdFc3; vector<Double_t> hpdFc4; vector<Double_t> hpdFc5; vector<Double_t> hpdFc6; vector<Double_t> hpdFc7; vector<Double_t> hpdFc8; vector<Double_t> hpdFc9; vector<Double_t> hpdFc5_0; vector<Double_t> hpdFc5_1; vector<Double_t> hpdFc5_2; vector<Double_t> hpdFc5_3; vector<Double_t> hpdFc5_4; vector<Double_t> hpdFc5_5; vector<Double_t> hpdFc5_6; vector<Double_t> hpdFc5_7; vector<Double_t> hpdFc5_8; vector<Double_t> hpdFc5_9; UInt_t tower_N; vector<Double_t> towerE; vector<Double_t> towerEt; vector<Double_t> towerEta; vector<Double_t> towerPhi; vector<Int_t> towerIEta; vector<Int_t> towerIPhi; vector<UInt_t> towerNJet; vector<Double_t> towerEHad; vector<Double_t> towerEtHad; vector<Double_t> towerEEm; vector<Double_t> towerEtEm; UInt_t recHit_N; vector<Double_t> recHitE; vector<Double_t> recHitTime; vector<UInt_t> recHitFlags; vector<UInt_t> recHitAux; vector<Double_t> recHitEta; vector<Double_t> recHitPhi; vector<Int_t> recHitIEta; vector<Int_t> recHitIPhi; vector<Int_t> recHitDepth; vector<Int_t> recHitRBXindex; vector<Int_t> recHitRMindex; UInt_t hfRecHit_N; vector<Double_t> hfRecHitE; UInt_t cscSeg_N; vector<Int_t> cscSegEndcap; vector<Int_t> cscSegRing; vector<Int_t> cscSegStation; vector<Int_t> cscSegChamber; vector<UInt_t> cscSegNHits; vector<Double_t> cscSegPhi; vector<Double_t> cscSegZ; vector<Double_t> cscSegR; vector<Double_t> cscSegDirPhi; vector<Double_t> cscSegDirTheta; UInt_t DTSegment_N; vector<Int_t> DTSegWheel; vector<Int_t> DTSegStation; vector<Int_t> DTSegSector; vector<Double_t> DTSegLocalX; vector<Double_t> DTSegLocalY; vector<Double_t> DTSegZ; vector<Double_t> DTSegRho; vector<Double_t> DTSegPhi; Int_t leadingDigiIEta; Int_t leadingDigiIPhi; vector<double> leadingDigiTimeSamples; UInt_t leadingDigiPeakSample; Double_t leadingDigiTotal; Double_t leadingDigiR1; Double_t leadingDigiR2; Double_t leadingDigiRPeak; Double_t leadingDigiROuter; vector<double> top5DigiTimeSamples; UInt_t top5DigiPeakSample; Double_t top5DigiTotal; Double_t top5DigiR1; Double_t top5DigiR2; Double_t top5DigiRPeak; Double_t top5DigiROuter; //set old branch address tree->SetBranchAddress("events",&events); //define histograms TH1D* id_hist = new TH1D("id_hist","Event Number",100000,0,100000); TH1D* run_hist = new TH1D("run_hist","Run Number",8000,192000,200000); TH1D* bx_hist = new TH1D("bx_hist","BX",8000,0,4000); TH1D* bxWrtCollision_hist = new TH1D("bxWrtCollision_hist","BX w.r.t. Collision",4000,-1000,1000); TH1D* bxWrtBunch_hist = new TH1D("bxWrtBunch_hist","BX w.r.t. Bunch",4000,-1000,1000); TH1D* muStandAlonePt_numerator_hist = new TH1D("muStandAlonePt_numerator_hist","StandAlone Muon p_{T}",200,0,200); TH1D* muStandAlonePt_denominator_hist = new TH1D("muStandAlonePt_denominator_hist","StandAlone Muon p_{T}",200,0,200); //get entries for data_tree (read in the old tree), set new variables, fill new tree Int_t nentries = tree->GetEntriesFast(); //Int_t nentries = tree->GetEntries(); cout<<"number of entries is: "<<nentries<<endl; int pass_bx_cut = 0; int pass_trigger_cut = 0; for (Int_t i=0; i<nentries; i++) { //for (Int_t i=0; i<2000; i++) { //for (Int_t i=0; i<100; i++) { tree->GetEntry(i); if ( (do_bx_cut && TMath::Abs(events->bxWrtCollision)>=2. && TMath::Abs(events->bxWrtBunch)>=2.) || (!do_bx_cut) ){ pass_bx_cut++; if(events->mu_StandAlone_N>0){ if(TMath::Abs(events->muStandAloneEta[0])<1.0){ if( (events->muStandAloneTrackNChambersDt[0] + events->muStandAloneTrackNChambersCsc[0])>1 ){ muStandAlonePt_denominator_hist->Fill(events->muStandAlonePt[0],1.0); //pass trigger //if ( (do_other_cut && (events->hltL2Mu20NoVertexNoBptx3BX || events->hltL2Mu30NoVertexNoBptx3BX || events->hltL2Mu20NoVertexNoBptx3BXNoHalo || events->hltL2Mu30NoVertexNoBptx3BXNoHalo || events->hltL2Mu20NoVertex2ChaNoBptx3BXNoHalo || events->hltL2Mu30NoVertex2ChaNoBptx3BXNoHalo ) ) || (!do_other_cut) ){ //hlt if ( (do_other_cut && events->l1SingleMu6NoBptx ) || (!do_other_cut) ){ //L1 pass_trigger_cut++; id_hist->Fill(events->id,1.0); run_hist->Fill(events->run,1.0); bx_hist->Fill(events->bx,1.0); bxWrtCollision_hist->Fill(events->bxWrtCollision,1.0); bxWrtBunch_hist->Fill(events->bxWrtBunch,1.0); muStandAlonePt_numerator_hist->Fill(events->muStandAlonePt[0],1.0); } //end of pass trigger }//end of noise cut }//end of eta<1 cut } //end of at least 1 SA muon }//end of bx_cut }//end of loop over entries cout<<endl; cout<<"number of events passing bx cut is: "<<pass_bx_cut<<endl; cout<<"number of events passing trigger cut is: "<<pass_trigger_cut<<endl; fnew->Write(); return(0); }
//------------------------------------------------------------------------------ // PlotHiggsRes_LP //------------------------------------------------------------------------------ void RunMakeRazorPlots ( string signalfile, string signalLabel, vector<string> bkgfiles,vector<string> bkgLabels, int boxOption = 0, int option = -1, string label = "", string latexlabel = "") { //-------------------------------------------------------------------------------------------------------------- // Settings //============================================================================================================== double intLumi = 2100; //in units of pb^-1 string Label = ""; if (label != "") Label = "_" + label; vector<string> inputfiles; vector<string> processLabels; bool hasSignal = false; if (signalfile != "") { hasSignal = true; inputfiles.push_back(signalfile); processLabels.push_back(signalLabel); } assert(bkgfiles.size() == bkgLabels.size()); for (int i=0; i < bkgfiles.size(); ++i) { inputfiles.push_back(bkgfiles[i]); processLabels.push_back(bkgLabels[i]); } //******************************************************************************************* //Define Histograms //******************************************************************************************* vector<TH1F*> histUnrolled; float MRBinLowEdges[] = {500, 600, 700, 900, 1200, 1600, 2500, 4000}; // Multijet Bins float RsqBinLowEdges[] = {0.25, 0.30, 0.41, 0.52, 0.64, 1.5}; // Multijet Bins const int nMRBins = 7; const int nRsqBins = 5; TH1F* histMRAllBkg = new TH1F( "MRAllBkg",";M_{R} [GeV/c^{2}];Number of Events", nMRBins, MRBinLowEdges); TH1F* histRsqAllBkg = new TH1F( "RsqAllBkg", ";R^{2};Number of Events", nRsqBins, RsqBinLowEdges); histMRAllBkg->SetStats(false); histRsqAllBkg->SetStats(false); histRsqAllBkg->Sumw2(); histMRAllBkg->Sumw2(); TH1F* histMRQCD = new TH1F( "MRQCD",";M_{R} [GeV/c^{2}];Number of Events", nMRBins, MRBinLowEdges); TH1F* histRsqQCD = new TH1F( "RsqQCD", ";R^{2};Number of Events", nRsqBins, RsqBinLowEdges); histMRQCD->SetStats(false); histRsqQCD->SetStats(false); histRsqQCD->Sumw2(); histMRQCD->Sumw2(); TH1F* histMRData = new TH1F( "MRData",";M_{R} [GeV/c^{2}];Number of Events", nMRBins, MRBinLowEdges); TH1F* histRsqData = new TH1F( "RsqData", ";R^{2};Number of Events", nRsqBins, RsqBinLowEdges); vector<TH1F*> histMR; vector<TH1F*> histRsq; vector<TH2F*> histMRRsq; histMRQCD->SetFillColor(kAzure+4); histMRAllBkg->SetFillColor(kMagenta); histMRQCD->SetFillStyle(1001); histMRAllBkg->SetFillStyle(1001); histMRQCD->SetLineColor(kAzure+4); histMRAllBkg->SetLineColor(kMagenta); assert (inputfiles.size() == processLabels.size()); for (int i=0; i < inputfiles.size(); ++i) { histMRRsq.push_back( new TH2F( Form("MRRsq_%s",processLabels[i].c_str()), ";M_{R} [GeV/c^{2}]; R^{2}", nMRBins, MRBinLowEdges, nRsqBins, RsqBinLowEdges)); if (!hasSignal || i != 0) histMRRsq[i]->SetFillColor(color[i]); if (hasSignal && i==0) histMRRsq[i]->SetLineWidth(3); histMRRsq[i]->SetLineColor(color[i]); histMRRsq[i]->SetStats(false); histMRRsq[i]->Sumw2(); histUnrolled.push_back( new TH1F( Form("Unrolled_%s",processLabels[i].c_str()), ";Bin Number ;Number of Events", nMRBins*nRsqBins, 0, nMRBins*nRsqBins)); if (!hasSignal || i != 0) histUnrolled[i]->SetFillColor(color[i]); if (hasSignal && i==0) histUnrolled[i]->SetLineWidth(3); histUnrolled[i]->SetLineColor(color[i]); histUnrolled[i]->SetStats(false); } THStack *stackUnrolled = new THStack(); //******************************************************************************************* //Define Counts //******************************************************************************************* //******************************************************************************************* //Read files //******************************************************************************************* for (uint i=0; i < inputfiles.size(); ++i) { TFile* inputFile = new TFile(inputfiles[i].c_str(),"READ"); assert(inputFile); TTree* tree = 0; tree = (TTree*)inputFile->Get("RazorInclusive"); // if (box == 0) { // tree = (TTree*)inputFile->Get("MultiJet"); // } else if (box == 1) { // tree = (TTree*)inputFile->Get("LooseLeptonMultiJet"); // } else if (box == 2) { // tree = (TTree*)inputFile->Get("MuMultiJet"); // } else if (box == 3) { // tree = (TTree*)inputFile->Get("EleMultiJet"); // } float weight = 0; int box = -1; int nBTaggedJets = 0; float dPhiRazor = 0; float MR = 0; float Rsq = 0; float mT = 0; tree->SetBranchAddress("weight",&weight); tree->SetBranchAddress("box",&box); tree->SetBranchAddress("nBTaggedJets",&nBTaggedJets); tree->SetBranchAddress("dPhiRazor",&dPhiRazor); tree->SetBranchAddress("MR",&MR); tree->SetBranchAddress("Rsq",&Rsq); tree->SetBranchAddress("mT",&mT); cout << "Process : " << processLabels[i] << " : Total Events: " << tree->GetEntries() << "\n"; for (int n=0;n<tree->GetEntries();n++) { // for (int n=0;n<1000;n++) { tree->GetEntry(n); if (n % 1000000 == 0) cout << "Processing Event " << n << "\n"; // if (intLumi*weight > 100) continue; //Box Options if (option == 0 ) { if (nBTaggedJets != 0) continue; } if (option == 1 ) { if (nBTaggedJets != 1) continue; } if (option == 2 ) { if (nBTaggedJets != 2) continue; } if (option == 3 ) { if (nBTaggedJets < 3) continue; } if (option == 4 ) { if (nBTaggedJets < 0) continue; // all b-tag categories combined } if (boxOption == 0) { // Multijet Box for Jamboree if( !(box == 11 || box == 12) ) continue; } if (boxOption == 1) { // LeptonJet Box for Jamboree if( !(box == 3 || box == 4 || box == 6 || box == 7) ) continue; } if (boxOption == 2) { // Multijet Box for Jamboree if( !(box == 14) ) continue; } //apply baseline cuts if (!(MR > 400 && Rsq > 0.25)) continue; // if (!(MR < 500 )) continue; // if (!(Rsq < 0.3)) continue; if (!(fabs(dPhiRazor) > 2.8)) continue; if (!hasSignal || i>1) { histMRAllBkg->Fill(MR, intLumi*weight); histRsqAllBkg->Fill(Rsq, intLumi*weight); histMRRsq[i]->Fill(MR, Rsq, intLumi*weight); } if(i==1){ if (intLumi*weight > 30) continue; float qcdweight = 1.56841; histMRQCD->Fill(MR, intLumi*weight*qcdweight); histRsqQCD->Fill(Rsq, intLumi*weight*qcdweight); histMRRsq[i]->Fill(MR, Rsq, intLumi*weight*qcdweight); } if (hasSignal && i==0) { histMRData->Fill(MR); histRsqData->Fill(Rsq); histMRRsq[i]->Fill(MR, Rsq); } } inputFile->Close(); delete inputFile; } std::cout<<"Data: "<<histMRData->Integral()<<", All Backgrounds: "<<histMRAllBkg->Integral()<<" , QCD: "<<histMRQCD->Integral()<<", Data2 "<< histMRRsq[0]->Integral() <<" QCD2 "<<histMRRsq[1]->Integral() <<std::endl; //******************************************************************************************* //Draw Plots //******************************************************************************************* // fill out the unrolled histograms std::cout<<"Rsq bins: "<<nRsqBins<<" "<<nMRBins<<std::endl; for (uint i=0; i < histMRRsq.size(); ++i) { int binN = 0; for(int ii = 0; ii<nMRBins; ii++) for (int jj = 0; jj<nRsqBins; jj++) { float value = (histMRRsq[i]->GetBinContent(ii+1, jj+1) > 0) ? histMRRsq[i]->GetBinContent(ii+1, jj+1) : 0. ; float Xrange = histMRRsq[i]->GetXaxis()->GetBinLowEdge(jj+2) - histMRRsq[i]->GetXaxis()->GetBinLowEdge(jj+1); float Yrange = histMRRsq[i]->GetYaxis()->GetBinLowEdge(ii+2) - histMRRsq[i]->GetYaxis()->GetBinLowEdge(ii+1); float area =1.; if(density) area = Xrange*Yrange; //normalize each bin by its area histUnrolled[i]->SetBinContent(binN+1, value/area); binN++; } histUnrolled[i]->SetMinimum(0.00001); if ( histUnrolled[i]->Integral() > 0) { if( !hasSignal || i > 0 ) stackUnrolled->Add(histUnrolled[i]); } cout << "Process : " << processLabels[i] << "\n"; } TCanvas *cv = 0; TLegend *legend = 0; TLatex *tex = 0; cv = new TCanvas("cv","cv", 800,600); legend = new TLegend(0.7,0.53,0.90,0.88); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->SetFillStyle(0); for (Int_t i = histMRRsq.size()-1 ; i >= 0; --i) { if (hasSignal && i==0) { legend->AddEntry(histMRRsq[i],processLabels[i].c_str(), "L"); } else { legend->AddEntry(histMRRsq[i],processLabels[i].c_str(), "F"); } } /// Unrolled plots in bins of R&MR TLatex t1(0.1,0.92, "CMS Preliminary"); TLatex t2(0.6,0.92, "#sqrt{s}=13 TeV, L = 2.1 fb^{-1}"); TLatex t3(0.4,0.92, Form("%s",latexlabel.c_str()) ); t1.SetNDC(); t2.SetNDC(); t3.SetNDC(); t1.SetTextSize(0.05); t2.SetTextSize(0.05); t3.SetTextSize(0.02); t1.SetTextFont(42); t2.SetTextFont(42); t3.SetTextFont(42); stackUnrolled->Draw(); stackUnrolled->SetMinimum(0.01); stackUnrolled->SetMaximum(1000); cv->SetLogy(); stackUnrolled->GetHistogram()->GetXaxis()->SetTitle(((TH1F*)(stackUnrolled->GetHists()->At(0)))->GetXaxis()->GetTitle()); stackUnrolled->GetHistogram()->GetYaxis()->SetTitle(((TH1F*)(stackUnrolled->GetHists()->At(0)))->GetYaxis()->GetTitle()); stackUnrolled->Draw(); if(hasSignal) histUnrolled[0]->Draw("same PE"); legend->Draw(); t1.Draw(); t2.Draw(); t3.Draw(); cv->SaveAs(Form("Unrolled_QCD%s.root",Label.c_str())); //// //******************************************************************************************* //MR //******************************************************************************************* cv = new TCanvas("cv","cv", 800,600); legend = new TLegend(0.50,0.54,0.90,0.84); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->SetFillStyle(0); tex = new TLatex(); tex->SetNDC(); tex->SetTextSize(0.030); tex->SetTextFont(42); tex->SetTextColor(kBlack); tex->DrawLatex(0.2, 0.92, Form("CMS Simulation #sqrt{s} = 13 TeV, #int L = %d fb^{-1}, %s",int(intLumi/1000), latexlabel.c_str())); THStack *stackMR = new THStack("stackMR", ""); THStack *stackRsq = new THStack(); //******************************************************************************************* //MR Before and After DPhi Cut //******************************************************************************************* ////////////////// stackMR->Add(histMRAllBkg); stackMR->Add(histMRQCD); cv = new TCanvas("cv","cv", 800,600); legend = new TLegend(0.50,0.54,0.90,0.84); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->SetFillStyle(0); stackMR->Draw(); stackMR->GetHistogram()->GetXaxis()->SetTitle(((TH1F*)(stackMR->GetHists()->At(0)))->GetXaxis()->GetTitle()); stackMR->GetHistogram()->GetYaxis()->SetTitle(((TH1F*)(stackMR->GetHists()->At(0)))->GetYaxis()->GetTitle()); stackMR->Draw(""); histMRData->Draw("same PE"); legend->Draw(); cv->SetLogy(); cv->SaveAs(Form("MRStack_QCD_%s.pdf",Label.c_str())); /////////////////////// cv = new TCanvas("cv","cv", 800,600); legend = new TLegend(0.50,0.54,0.90,0.84); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->SetFillStyle(0); histMRAllBkg->SetLineColor(kRed); histMRAllBkg->GetYaxis()->SetTitle("Number of Events"); histMRAllBkg->GetYaxis()->SetTitleOffset(1.2); histMRData->SetMarkerStyle(8); legend->AddEntry(histMRAllBkg, "All Backgrounds", "L"); legend->AddEntry(histMRData, "Data", "L"); histMRAllBkg->Add(histMRQCD, 1.0); histMRAllBkg->Draw("hist"); histMRData->Draw("PE same"); legend->Draw(); cv->SetLogy(); cv->SaveAs(Form("MR_QCD_%s.pdf",Label.c_str())); ////// cv = new TCanvas("cv","cv", 800,600); legend = new TLegend(0.50,0.54,0.90,0.84); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->SetFillStyle(0); histRsqAllBkg->SetLineColor(kRed); histRsqAllBkg->GetYaxis()->SetTitle("Number of Events"); histRsqAllBkg->GetYaxis()->SetTitleOffset(1.2); histRsqData->SetMarkerStyle(8); legend->AddEntry(histRsqAllBkg, "All Backgrounds", "L"); legend->AddEntry(histRsqData, "Data", "L"); histRsqAllBkg->Add(histRsqQCD, 1.0); histRsqAllBkg->Draw("hist"); histRsqData->Draw("PE same"); legend->Draw(); cv->SetLogy(); cv->SaveAs(Form("Rsq_QCD_%s.pdf",Label.c_str())); ////////////////// histRsqQCD->SetFillColor(kAzure+4); histRsqAllBkg->SetFillColor(kMagenta); stackRsq->Add(histRsqAllBkg); stackRsq->Add(histRsqQCD); cv = new TCanvas("cv","cv", 800,600); legend = new TLegend(0.50,0.54,0.90,0.84); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->SetFillStyle(0); stackRsq->Draw(); stackRsq->GetHistogram()->GetXaxis()->SetTitle(((TH1F*)(stackRsq->GetHists()->At(0)))->GetXaxis()->GetTitle()); stackRsq->GetHistogram()->GetYaxis()->SetTitle(((TH1F*)(stackRsq->GetHists()->At(0)))->GetYaxis()->GetTitle()); stackRsq->Draw(); histRsqData->Draw("same PE"); legend->Draw(); cv->SetLogy(); cv->SaveAs(Form("RsqStack_QCD_%s.pdf",Label.c_str())); //-------------------------------------------------------------------------------------------------------------- // Output //============================================================================================================== TFile *file = TFile::Open(("RazorPlots"+Label+".root").c_str(), "RECREATE"); file->cd(); for(int i=0; i<int(inputfiles.size()); i++) { file->WriteTObject(histMRRsq[i], Form("histMRRsq_%s",processLabels[i].c_str()), "WriteDelete"); histUnrolled[i]->Write(); } stackUnrolled->Write(); }
void ppEffJpsiSysSFsSTA__idx_() { double minRap = 1.6; double maxRap = 2.4; double minPt = 3.0; double maxPt = 30.0; for(int iCat_ = 0; iCat_ < 7; iCat_++){ if(iCat_ == 0) {minRap = 1.6; maxRap = 2.4; minPt = 3.0; maxPt = 30.0;} if(iCat_ == 1) {minRap = 1.6; maxRap = 2.4; minPt = 3.0; maxPt = 6.5;} if(iCat_ == 2) {minRap = 1.6; maxRap = 2.4; minPt = 6.5; maxPt = 30.0;} if(iCat_ == 3) {minRap = 0.0; maxRap = 2.4; minPt = 10.0; maxPt = 30.0;} if(iCat_ == 4) {minRap = 0.0; maxRap = 2.4; minPt = 6.5; maxPt = 30.0;} if(iCat_ == 5) {minRap = 1.6; maxRap = 2.4; minPt = 3.0; maxPt = 5.5;} if(iCat_ == 6) {minRap = 0.0; maxRap = 2.4; minPt = 6.5; maxPt = 8.5;} gROOT->SetStyle("Plain"); gStyle->SetPalette(1); gStyle->SetFrameBorderMode(0); gStyle->SetFrameFillColor(0); gStyle->SetCanvasColor(0); gStyle->SetTitleFillColor(0); gStyle->SetStatColor(0); gStyle->SetPadBorderSize(0); gStyle->SetCanvasBorderSize(0); gStyle->SetOptTitle(0); // at least most of the time gStyle->SetOptStat(0); // most of the time, sometimes "nemriou" might be useful to display name, //number of entries, mean, rms, integral, overflow and underflow gStyle->SetOptFit(0); // set to 1 only if you want to display fit results //==================================== Define Histograms==================================================== //==============================================Define Acc Eff Stuff here=========================================== // Pt bin sizes // 0-1.5, 1.5-3, 3-4.5, 4.5-6, 6-7.5... TFile *outfile; char tmp_output[512]; sprintf(tmp_output,"ppPrJpsi_pT_%0.1f_%0.1f_y_%0.1f_%0.1f_HighQ_tnpWgt.root", minPt, maxPt, minRap, maxRap); outfile =new TFile(tmp_output, "Recreate"); for(int iSpec = 0; iSpec < 1; iSpec++){ const int nPtBins = 1; const int nRapBins = 6; // 6 const int ndPhiBins = 4; double pt_bound[nPtBins+1]; pt_bound[0] = minPt; pt_bound[1] = maxPt; cout<<"Min y : "<<minRap<<", Max y : "<<maxRap<<endl; cout<<"Min pT : "<<minPt<<", Max pT : "<<maxPt<<endl; double xpt_bound[nPtBins] = {0.0}; //double rap_bound[nRapBins+1] = {0.0, 0.3, 0.6, 0.9, 1.2, 1.5, 1.8, 2.1, 2.4}; double rap_bound[nRapBins+1] = {0.0, 0.4, 0.8, 1.2, 1.6, 2.0, 2.4}; double xrap_bound[nRapBins] = {0.0}; double dphi_bound[ndPhiBins+1] = {0.0, TMath::Pi()/8, TMath::Pi()/4, 3*TMath::Pi()/8, TMath::Pi()/2}; double xdphi_bound[ndPhiBins] = {0.0}; const char *cSp[2] = {"Pts","Raps"}; char OutTextFile[100]; sprintf(OutTextFile,"ppPromp_eff_%s_pT_%0.1f_%0.1f_y_%0.1f_%0.1f_HighQ.tex", cSp[iSpec], minPt, maxPt, minRap, maxRap); ofstream dataFile(OutTextFile); //ofstream dataFile(Form(OutTextFile)); cout<< "%%%% Getting Efficiency starts : %s !!!!! %%%%%" << endl; //dataFile<< "%%%% Getting Efficiency starts : %s !!!!! %%%%%" << endl; // x, y, z - axis //dataFile<<""<<endl; //dataFile<<"xaxis of pT"<<endl; for(int i = 0; i < nPtBins; i++){ xpt_bound[i] = pt_bound[i] + (pt_bound[i+1]-pt_bound[i])/2; cout<<"xpt_bound["<<i<<"] : "<<xpt_bound[i]<<endl; //dataFile<<"xpt_bound["<<i<<"] : "<<xpt_bound[i]<<endl; } //dataFile<<""<<endl; //dataFile<<"xaxis of rap"<<endl; for(int i = 0; i < nRapBins; i++){ xrap_bound[i] = rap_bound[i] + (rap_bound[i+1]-rap_bound[i])/2; cout<<"xrap_bound["<<i<<"] : "<<xrap_bound[i]<<endl; //dataFile<<"xrap_bound["<<i<<"] : "<<xrap_bound[i]<<endl; } //dataFile<<""<<endl; //dataFile<<"xaxis of dphi"<<endl; for(int i = 0; i < ndPhiBins; i++){ xdphi_bound[i] = dphi_bound[i] + (dphi_bound[i+1]-dphi_bound[i])/2; cout<<"xdphi_bound["<<i<<"] : "<<xdphi_bound[i]<<endl; //dataFile<<"xdphi_bound["<<i<<"] : "<<xdphi_bound[i]<<endl; } int nBins_tmp = 0; if(iSpec == 0) { nBins_tmp = nPtBins; } if(iSpec == 1) { nBins_tmp = nRapBins; } const int nBins = nBins_tmp; TH1F *hTempMass = new TH1F("hTempMass","",100, 2.0, 4.0); TH1F *hGenDiMuon[nBins]; TH1F *hRecoDiMuon[nBins]; double genNo[nBins]; double genErr[nBins]; double recoNo[nBins]; double recoErr[nBins]; double eff[nBins]; double effErr[nBins]; for(int i = 0; i < nBins; i++){ hGenDiMuon[i] = (TH1F*)hTempMass->Clone(); hRecoDiMuon[i] = (TH1F*)hTempMass->Clone(); hGenDiMuon[i]->Sumw2(); hRecoDiMuon[i]->Sumw2(); } char fileName[10][512]; // loop for pT cout<<"==================Prompt PrJpsi================================================"<<endl; sprintf(fileName[0],"/Users/dmoon/Dropbox/Analysis/HiMC/EffStudy/gRpAngRootFiles_538_pp/HiDiMuonAna_538_pp_PromptJpsi_20140528_Trg21.root"); TFile *infile; TTree *tree; TTree *gentree; TTree *evttree; infile=new TFile(fileName[0],"R"); tree=(TTree*)infile->Get("SingleMuonTree"); gentree=(TTree*)infile->Get("SingleGenMuonTree"); evttree=(TTree*)infile->Get("EventTree"); //Event variables int eventNb,runNb,lumiBlock; int hbit1; //double vertexZ; //double GenvertexZ; //Jpsi Variables Double_t JpsiMass,JpsiPt,JpsiRap, JpsiCharge; Double_t JpsiVprob; Double_t JpsiPhi; Double_t JpsiEta; //2.) muon variables RECO double muPosPx, muPosPy, muPosPz, muPosEta, muPosPt, muPosP, muPosPhi; double muNegPx, muNegPy, muNegPz, muNegEta, muNegPt, muNegP, muNegPhi; //(1).Positive Muon double muPos_nchi2In, muPos_dxy, muPos_dz, muPos_nchi2Gl; int muPos_found, muPos_pixeLayers, muPos_nValidMuHits,muPos_arbitrated; bool muPos_matches,muPos_tracker; int muPos_Trigger10, muPos_Trigger2, muPos_Trigger21, muPos_Trigger22; //(2).Negative Muon double muNeg_nchi2In, muNeg_dxy, muNeg_dz, muNeg_nchi2Gl; int muNeg_found, muNeg_pixeLayers, muNeg_nValidMuHits,muNeg_arbitrated; bool muNeg_matches,muNeg_tracker; int muNeg_Trigger10, muNeg_Trigger2, muNeg_Trigger21, muNeg_Trigger22; //Gen Level variables //Gen PrJpsi Variables double GenJpsiMass, GenJpsiPt, GenJpsiRap; double GenJpsiPx, GenJpsiPy, GenJpsiPz; double GenJpsiPhi; double GenJpsiEta; //2.) Gen muon variables double GenmuPosPx, GenmuPosPy, GenmuPosPz, GenmuPosEta, GenmuPosPt, GenmuPosPhi; double GenmuNegPx, GenmuNegPy, GenmuNegPz, GenmuNegEta, GenmuNegPt, GenmuNegPhi; double zVtx; //Event variables tree->SetBranchAddress("eventNb",&eventNb); tree->SetBranchAddress("runNb",&runNb); tree->SetBranchAddress("lumiBlock",&lumiBlock); tree->SetBranchAddress("hbit1",&hbit1); tree->SetBranchAddress("zVtx",&zVtx); //tree->SetBranchAddress("vertexZ",&vertexZ); //Jpsi Variables tree->SetBranchAddress("JpsiCharge",&JpsiCharge); tree->SetBranchAddress("JpsiMass",&JpsiMass); tree->SetBranchAddress("JpsiPt",&JpsiPt); tree->SetBranchAddress("JpsiPhi",&JpsiPhi); tree->SetBranchAddress("JpsiEta",&JpsiEta); tree->SetBranchAddress("JpsiRap",&JpsiRap); tree->SetBranchAddress("JpsiVprob",&JpsiVprob); //muon variable tree->SetBranchAddress("muPosPx",&muPosPx); tree->SetBranchAddress("muPosPy",&muPosPy); tree->SetBranchAddress("muPosPz",&muPosPz); tree->SetBranchAddress("muPosEta",&muPosEta); tree->SetBranchAddress("muPosPhi",&muPosPhi); tree->SetBranchAddress("muNegPx", &muNegPx); tree->SetBranchAddress("muNegPy", &muNegPy); tree->SetBranchAddress("muNegPz", &muNegPz); tree->SetBranchAddress("muNegEta", &muNegEta); tree->SetBranchAddress("muNegPhi", &muNegPhi); //1). Positive Muon tree->SetBranchAddress("muPos_nchi2In", &muPos_nchi2In); tree->SetBranchAddress("muPos_dxy", &muPos_dxy); tree->SetBranchAddress("muPos_dz", &muPos_dz); tree->SetBranchAddress("muPos_nchi2Gl", &muPos_nchi2Gl); tree->SetBranchAddress("muPos_found", &muPos_found); tree->SetBranchAddress("muPos_pixeLayers", &muPos_pixeLayers); tree->SetBranchAddress("muPos_nValidMuHits", &muPos_nValidMuHits); tree->SetBranchAddress("muPos_matches", &muPos_matches); tree->SetBranchAddress("muPos_tracker", &muPos_tracker); tree->SetBranchAddress("muPos_arbitrated", &muPos_arbitrated); tree->SetBranchAddress("muPos_Trigger10", &muPos_Trigger10); tree->SetBranchAddress("muPos_Trigger2", &muPos_Trigger2); tree->SetBranchAddress("muPos_Trigger21", &muPos_Trigger21); tree->SetBranchAddress("muPos_Trigger22", &muPos_Trigger22); //2). Negative Muon tree->SetBranchAddress("muNeg_nchi2In", &muNeg_nchi2In); tree->SetBranchAddress("muNeg_dxy", &muNeg_dxy); tree->SetBranchAddress("muNeg_dz", &muNeg_dz); tree->SetBranchAddress("muNeg_nchi2Gl", &muNeg_nchi2Gl); tree->SetBranchAddress("muNeg_found", &muNeg_found); tree->SetBranchAddress("muNeg_pixeLayers", &muNeg_pixeLayers); tree->SetBranchAddress("muNeg_nValidMuHits", &muNeg_nValidMuHits); tree->SetBranchAddress("muNeg_matches", &muNeg_matches); tree->SetBranchAddress("muNeg_tracker", &muNeg_tracker); tree->SetBranchAddress("muNeg_arbitrated", &muNeg_arbitrated); tree->SetBranchAddress("muNeg_Trigger10", &muNeg_Trigger10); tree->SetBranchAddress("muNeg_Trigger2", &muNeg_Trigger2); tree->SetBranchAddress("muNeg_Trigger21", &muNeg_Trigger21); tree->SetBranchAddress("muNeg_Trigger22", &muNeg_Trigger22); //====================================Gen Variables========================================================= //Gen Jpsi Variables gentree->SetBranchAddress("GenJpsiMass", &GenJpsiMass); gentree->SetBranchAddress("GenJpsiPt", &GenJpsiPt); gentree->SetBranchAddress("GenJpsiPhi", &GenJpsiPhi); gentree->SetBranchAddress("GenJpsiRap", &GenJpsiRap); gentree->SetBranchAddress("GenJpsiEta", &GenJpsiEta); gentree->SetBranchAddress("GenJpsiPx", &GenJpsiPx); gentree->SetBranchAddress("GenJpsiPy", &GenJpsiPy); gentree->SetBranchAddress("GenJpsiPz", &GenJpsiPz); //muon variable gentree->SetBranchAddress("GenmuPosPx", &GenmuPosPx); gentree->SetBranchAddress("GenmuPosPy", &GenmuPosPy); gentree->SetBranchAddress("GenmuPosPz", &GenmuPosPz); gentree->SetBranchAddress("GenmuPosEta", &GenmuPosEta); gentree->SetBranchAddress("GenmuPosPhi", &GenmuPosPhi); gentree->SetBranchAddress("GenmuNegPx", &GenmuNegPx); gentree->SetBranchAddress("GenmuNegPy", &GenmuNegPy); gentree->SetBranchAddress("GenmuNegPz", &GenmuNegPz); gentree->SetBranchAddress("GenmuNegEta", &GenmuNegEta); gentree->SetBranchAddress("GenmuNegPhi", &GenmuNegPhi); //gentree->SetBranchAddress("GenvertexZ",&GenvertexZ); //====================================================== Gen tree loop ================================================ int NAccep=0; int nGenEntries=gentree->GetEntries(); cout<<" Total Entries in GenLevel Tree for pT range: "<<fileName[0]<<" "<< nGenEntries<< " ==============="<<endl; for(int i=0; i< nGenEntries; i++) { //cout<<"i : "<<i<<endl; if(!(gentree->GetEntry(i))) continue; //cout<<" gentree ("<<i<<")"<<endl; //Only printing if(i%1000000==0){ cout<<" processing record "<<i<<"/"<<nGenEntries<<endl; //cout<<" Mass "<< GenJpsiMass<< " pT "<< GenJpsiPt << " Y " <<GenJpsiRap<<endl; } bool GenPosIn=0, GenNegIn=0; GenmuPosPt= TMath::Sqrt(GenmuPosPx*GenmuPosPx + GenmuPosPy*GenmuPosPy); GenmuNegPt= TMath::Sqrt(GenmuNegPx*GenmuNegPx + GenmuNegPy*GenmuNegPy); if(IsAccept(GenmuPosPt, GenmuPosEta)) {GenPosIn=1;} if(IsAccept(GenmuNegPt, GenmuNegEta)) {GenNegIn=1;} int AccJpsi = 0; //if(GenJpsiPt < 6.5) continue; if((GenJpsiPt >= minPt && GenJpsiPt <= maxPt && fabs(GenJpsiRap) >= minRap && TMath::Abs(GenJpsiRap) <= maxRap && GenPosIn == 1 && GenNegIn == 1) && GenJpsiMass > 2.0 && GenJpsiMass < 4.0 ) {AccJpsi = 1;} if((GenPosIn ==1 && GenNegIn==1)) NAccep++; //cout<<"1. GenJpsiPt : "<<GenJpsiPt<<", GenJpsiEta : "<<GenJpsiEta<<", GenJpsiRap : "<<GenJpsiRap<<", |GenJpsiPsi| : "<<TMath::Abs(GenJpsiPsi)<<endl; //cout<<"1. GenPosIn : "<<GenPosIn<<", GenNegIn : "<<GenNegIn<<endl; double vars = 0.0, bin1 = 0.0, bin2 = 0.0; if(iSpec == 0) vars = GenJpsiPt; if(iSpec == 1) vars = fabs(GenJpsiRap); for(int j = 0; j < nBins; j++){ if(iSpec == 0){ bin1 = pt_bound[j]; bin2 = pt_bound[j+1]; if( (AccJpsi==1) && (vars >= bin1 && vars < bin2) && fabs(GenJpsiRap) >= minRap && TMath::Abs(GenJpsiRap) <= maxRap && TMath::Abs(GenJpsiRap) >= minRap) { hGenDiMuon[j]->Fill(GenJpsiMass); } } if(iSpec == 1){ bin1 = rap_bound[j]; bin2 = rap_bound[j+1]; if( (AccJpsi==1) && (vars >= bin1 && vars < bin2) && GenJpsiPt >= minPt && GenJpsiPt <= maxPt) { hGenDiMuon[j]->Fill(GenJpsiMass); } } } }//gen loop end //cout<<" accepted no "<< NAccep<<endl; //=============== Rec Tree Loop ============================================================================== int nRecEntries=tree->GetEntries(); cout<<"Total Entries in reconstructed Tree for pT range "<<fileName[0]<<" "<<nRecEntries<< "====="<<endl; for(int i=0; i<nRecEntries; i++) { tree->GetEntry(i); //Only printing if(i%1000000==0){ cout<<" processing record "<<i<<"/"<<nRecEntries<<endl; //cout<<" processing Run " <<runNb <<" event "<<eventNb<<" lum block "<<lumiBlock<<endl; //cout<<" Mass "<< JpsiMass<< " pT "<< JpsiPt << " Y " <<JpsiRap<<" "<<JpsiVprob<<" charge "<<JpsiCharge<<" rbin "<<rbin<<endl; } bool PosPass=0, NegPass=0, AllCut=0 ,PosIn=0, NegIn=0; muPosPt= TMath::Sqrt(muPosPx*muPosPx + muPosPy*muPosPy); muPosP = TMath::Sqrt(muPosPx*muPosPx + muPosPy*muPosPy+ muPosPz*muPosPz); muNegPt= TMath::Sqrt(muNegPx*muNegPx + muNegPy*muNegPy); muNegP = TMath::Sqrt(muNegPx*muNegPx + muNegPy*muNegPy +muNegPz*muNegPz); double tnpWgt1 = 0.0, tnpWgt2 = 0.0; double staWgt1 = 0.0, staWgt2 = 0.0; double x = 0.0; double xta = 0.0; // tnp MuonID X Trg if(fabs(muPosEta) < 0.9){ x = muPosPt; tnpWgt1 = tnpSF1->Eval(x); }else if(fabs(muPosEta) < 1.6){ x = muPosPt; tnpWgt1 = tnpSF2->Eval(x); }else if(fabs(muPosEta) < 2.1){ x = muPosPt; tnpWgt1 = tnpSF3->Eval(x); }else{ x = muPosPt; tnpWgt1 = tnpSF4->Eval(x); } if(fabs(muNegEta) < 0.9){ x = muNegPt; tnpWgt2 = tnpSF1->Eval(x); }else if(fabs(muNegEta) < 1.6){ x = muNegPt; tnpWgt2 = tnpSF2->Eval(x); }else if(fabs(muNegEta) < 2.1){ x = muNegPt; tnpWgt2 = tnpSF3->Eval(x); }else{ x = muNegPt; tnpWgt2 = tnpSF4->Eval(x); } // tnp STA if(fabs(muPosEta) < 1.6){ xta = muPosPt; staWgt1 = fun1->Eval(xta); }else{ xta = muPosPt; staWgt1 = fun2->Eval(xta); } if(fabs(muNegEta) < 1.6){ xta = muNegPt; staWgt2 = fun1->Eval(xta); }else{ xta = muNegPt; staWgt2 = fun2->Eval(xta); } double RecWeight = 1.0; RecWeight = tnpWgt1*tnpWgt2*staWgt1*staWgt2; if(IsAccept(muPosPt, muPosEta)){PosIn=1;} if(IsAccept(muNegPt, muNegEta)){NegIn=1;} int AccJpsi = 0; //if(JpsiPt < 6.5) continue; if((JpsiPt >= minPt && JpsiPt <= maxPt && fabs(JpsiRap) >= minRap && TMath::Abs(JpsiRap) <= maxRap && PosIn == 1 && NegIn == 1) && (JpsiMass >= 2.95 && JpsiMass < 3.25) ) {AccJpsi = 1;} bool mu_Global = ((muPos_nchi2Gl >=0) && (muNeg_nchi2Gl >=0)); bool mu_Tracker = ((muPos_tracker==1) && (muNeg_tracker==1)); if(muPos_found > 10 && muPos_pixeLayers > 0 && muPos_nchi2In < 4.0 && TMath::Abs(muPos_dxy) < 3 && TMath::Abs(muPos_dz) < 15 && muPos_nchi2Gl < 20 && muPos_arbitrated==1 && muPos_tracker==1){PosPass=1;} if(muNeg_found > 10 && muNeg_pixeLayers > 0 && muNeg_nchi2In < 4.0 && TMath::Abs(muNeg_dxy) < 3 && TMath::Abs(muNeg_dz) < 15 && muNeg_nchi2Gl < 20 && muNeg_arbitrated==1 && muNeg_tracker==1){NegPass=1;} // Trigger10 : HLT_PAL2DoubleMu3_v1, Trigger 2 : HLT_PAL1DoubleMu0_HighQ_v1, Trigger 1 : HLT_PAL1DoubleMu0_v1 // muPos_matches : HLT_PAL1DoubleMuOpen_v1 //if((muPos_Trigger21==1 && muNeg_Trigger21==1) && (PosIn==1 && NegIn==1) && (PosPass==1 && NegPass==1)&& mu_Global && mu_Tracker){AllCut=1;} if(hbit1 == 1 && (muPos_Trigger22==1 && muNeg_Trigger22==1) && (PosIn==1 && NegIn==1) && (PosPass==1 && NegPass==1)&& mu_Global && mu_Tracker){AllCut=1;} //if(hbit1 == 1 && (muPos_Trigger2==1 && muNeg_Trigger2==1) && (PosIn==1 && NegIn==1) && (PosPass==1 && NegPass==1)&& mu_Global && mu_Tracker){AllCut=1;} //if((muPos_matches==1 && muNeg_matches==1) && (PosIn==1 && NegIn==1) && (PosPass==1 && NegPass==1)&& mu_Global && mu_Tracker){AllCut=1;} //if((muPos_Trigger10==1 && muNeg_Trigger10==1) && (PosIn==1 && NegIn==1) && (PosPass==1 && NegPass==1)&& mu_Global && mu_Tracker){AllCut=1;} // without trigger matched // if((PosIn==1 && NegIn==1) && (PosPass==1 && NegPass==1)&& mu_Global && mu_Tracker){AllCut=1;} //Eff loop for reco double vars = 0.0, bin1 = 0.0, bin2 = 0.0; if(iSpec == 0) vars = JpsiPt; if(iSpec == 1) vars = fabs(JpsiRap); if((JpsiCharge == 0) && (JpsiVprob > 0.01)) { for(int j = 0; j < nBins; j++){ if(iSpec == 0){ bin1 = pt_bound[j]; bin2 = pt_bound[j+1]; if( AccJpsi == 1 && (AllCut == 1) && (vars >= bin1 && vars < bin2) && TMath::Abs(JpsiRap) <= maxRap && TMath::Abs(JpsiRap) >= minRap) { hRecoDiMuon[j]->Fill(JpsiMass,RecWeight); } } if(iSpec == 1){ bin1 = rap_bound[j]; bin2 = rap_bound[j+1]; if( AccJpsi == 1 && (AllCut == 1) && (vars >= bin1 && vars < bin2) && JpsiPt >= minPt && JpsiPt <= maxPt) { hRecoDiMuon[j]->Fill(JpsiMass,RecWeight); } } } } } //rec tree loop ends //====================== File loop Starts ============================ /////////////////////////////////////////////////////////////////// cout<< " adding "<<endl; char gtmp[512], gtmp1[512]; char rtmp[512], rtmp1[512]; for(int i = 0; i < nBins; i++){ if(iSpec == 1) sprintf(gtmp,"hGenDiMuon_Pt_%0.1f_%0.1f",pt_bound[i],pt_bound[i+1]); if(iSpec == 2) sprintf(gtmp,"hGenDiMuon_Rap_%0.1f_%0.1f",rap_bound[i],rap_bound[i+1]); if(iSpec == 1) sprintf(gtmp1,"plots/Gen/hGenDiMuon_Pt_%0.1f_%0.1f.png",pt_bound[i],pt_bound[i+1]); if(iSpec == 2) sprintf(gtmp1,"plots/Gen/hGenDiMuon_Rap_%0.1f_%0.1f.png",rap_bound[i],rap_bound[i+1]); if(iSpec == 1) sprintf(rtmp,"hRecDiMuon_Pt_%0.1f_%0.1f",pt_bound[i],pt_bound[i+1]); if(iSpec == 2) sprintf(rtmp,"hRecDiMuon_Rap_%0.1f_%0.1f",rap_bound[i],rap_bound[i+1]); if(iSpec == 1) sprintf(rtmp1,"plots/Rec/hRecDiMuon_Pt_%0.1f_%0.1f.png",pt_bound[i],pt_bound[i+1]); if(iSpec == 2) sprintf(rtmp1,"plots/Rec/hRecDiMuon_Rap_%0.1f_%0.1f.png",rap_bound[i],rap_bound[i+1]); hGenDiMuon[i]->SetName(gtmp); hRecoDiMuon[i]->SetName(rtmp); } cout<<"Starts to calculate efficiency"<<endl; //dataFile<<""<<endl; //=====================Loop for eff========================================================================================// //define stuff here for error on weighted samples for(int i = 0; i < nBins; i++){ int Gbinlow =hGenDiMuon[i]->GetXaxis()->FindBin(2.0);//2.95 int Gbinhi=hGenDiMuon[i]->GetXaxis()->FindBin(4.0);//2.95 int Rbinlow =hRecoDiMuon[i]->GetXaxis()->FindBin(2.95);//2.95 int Rbinhi=hRecoDiMuon[i]->GetXaxis()->FindBin(3.25);//2.95 genNo[i] = hGenDiMuon[i]->IntegralAndError(Gbinlow, Gbinhi, genErr[i]); recoNo[i] = hRecoDiMuon[i]->IntegralAndError(Rbinlow, Rbinhi, recoErr[i]); //calculate Eff if(genNo[i] == 0 || recoNo[i] == 0) { eff[i] = 0; effErr[i] = 0; }else{ eff[i] = recoNo[i]/genNo[i]; effErr[i] = recoNo[i]/genNo[i]*TMath::Sqrt(genErr[i]*genErr[i]/(genNo[i]*genNo[i]) + recoErr[i]*recoErr[i]/(recoNo[i]*recoNo[i])); //error without weight //dataFile<<" Bin ["<<i<<"] - "<< " Reco Jpsi : "<< recoNo[i] <<", Gen Jpsi : "<< genNo[i] <<endl; //dataFile<<" Eff ["<<i<<"] - "<< eff[i] <<" Error "<< effErr[i] <<endl; cout<<" Bin ["<<i<<"] - "<< " Reco Jpsi : "<< recoNo[i] <<", Gen Jpsi : "<< genNo[i] <<endl; cout<<" Eff ["<<i<<"] - "<< eff[i] <<" Error "<< effErr[i] <<endl; } } TH1F *hEff = new TH1F(); int nEffBins = 0; if(iSpec == 0) {hEff = new TH1F("hEff","hEff;p_{T} GeV/c;Efficiency",nPtBins,pt_bound); nEffBins = nPtBins;} if(iSpec == 1) {hEff = new TH1F("hEff","hEff;y;Efficiency",nRapBins,rap_bound); nEffBins = nRapBins;} //dataFile<<"Efficiency"<<endl; for(int i = 0; i < nEffBins; i++){ hEff->SetBinContent(i+1,eff[i]); hEff->SetBinError(i+1,effErr[i]); cout<<"Trying to measure eff vs "<<cSp[iSpec]<<endl; cout<<"Eff : "<<eff[i]<<", err : "<<effErr[i]<<endl; dataFile<<eff[i]<<endl; } //dataFile<<""<<endl; //dataFile<<"Errors"<<endl; for(int i = 0; i < nEffBins; i++){ hEff->SetBinContent(i+1,eff[i]); hEff->SetBinError(i+1,effErr[i]); cout<<"Trying to measure eff vs "<<cSp[iSpec]<<endl; cout<<"Eff : "<<eff[i]<<", err : "<<effErr[i]<<endl; //dataFile<<effErr[i]<<endl; } outfile->cd(); hEff->Draw(); char tmp_histo[512]; sprintf(tmp_histo,"hEff_%s",cSp[iSpec]); hEff->SetName(tmp_histo); hEff->Write(); //dataFile<<""<<endl; //dataFile.close(); } outfile->Write(); } }
void pbpbEffJpsiSFSysSTA__idx_(double minPt = 6.5, double maxPt = 30.0) { int Prompt =1; int PutWeight = 1; int JpsiCat_ = 1; // 1 : prompt, 2 : non-prompt double minRap = 0.0; double maxRap = 2.4; minPt = 6.5; maxPt = 30.0; bool bDefault = true; // true : default, false : sailor or cowboy char cCd[512]; if(bDefault) sprintf(cCd, "default"); gROOT->SetStyle("Plain"); gStyle->SetPalette(1); gStyle->SetFrameBorderMode(0); gStyle->SetFrameFillColor(0); gStyle->SetCanvasColor(0); gStyle->SetTitleFillColor(0); gStyle->SetStatColor(0); gStyle->SetPadBorderSize(0); gStyle->SetCanvasBorderSize(0); gStyle->SetOptTitle(0); // at least most of the time gStyle->SetOptStat(0); // most of the time, sometimes "nemriou" might be useful to display name, //number of entries, mean, rms, integral, overflow and underflow gStyle->SetOptFit(0); // set to 1 only if you want to display fit results //==================================== Define Histograms==================================================== //==============================================Define Acc Eff Stuff here=========================================== // Pt bin sizes // 0-1.5, 1.5-3, 3-4.5, 4.5-6, 6-7.5... const char *cTrg[5] = {"Bit1", "L1DM0HighQ", "L2Mu3NHitQ", "L3Mu3", "L3DMOpen"}; //int iTrg = 0; TFile *outfile; char tmp_output[512]; if(JpsiCat_ == 1) sprintf(tmp_output,"pbpbPrJpsi_y_%0.1f_%0.1f_pT_%0.1f_%0.1f_HighQ_tnpWgt_pr2.root", minRap, maxRap, minPt, maxPt); if(JpsiCat_ == 2) sprintf(tmp_output,"pbpbPrJpsi_y_%0.1f_%0.1f_pT_%0.1f_%0.1f_HighQ_tnpWgt_npr2.root", minRap, maxRap, minPt, maxPt); outfile =new TFile(tmp_output, "Recreate"); TH1F *hGenCent = new TH1F("hGenCent",";Centrality (%);Weighted Counts",40,0,40); TH1F *hRecCent = new TH1F("hRecCent",";Centrality (%);Weighted Counts",40,0,40); hGenCent->Sumw2(); hRecCent->Sumw2(); for(int iSpec = 0; iSpec < 3; iSpec++){ const int nCentBins = 12; // Non-prompt (60-100) const int nPtBins = 4; const int nRapBins = 3; const int ndPhiBins = 8; //const int ndPhiBins = 4; const int ndPhi2Bins = 8; const int nPhiBins = 8; const int nFiles = 6; //if(JpsiCat_ == 2) nCentBins = 11; // more bins 0-10,10-20,20-30,30-40,40-50,50-70,70-100 // cent bins : 0-5, 5-10, 10-15, 15-20, 20-25, 25-30, 30-35, 35-40, 40-45, 45-50, 50-60, 60-100 double ct_bound[nCentBins+1] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 24, 40}; // Prompt (60-100) double ct_bound2[nCentBins+1] = {0.0}; for(int ict = 0; ict < nCentBins+1; ict++){ ct_bound2[ict] = ct_bound[ict]*2.5; } double xct_bound[nCentBins] = {0.0}; //double pt_bound[nPtBins+1] = {0.0, 3.0, 6.5}; // pT bins : 6.5-7.5, 7.5-8.5, 8.5-9.5, 9.5-10.5, 10.5-11.5, 11.5-12.5, 12.5-14.5, 14.5-16.5, 16.5-20.0, 20.0-30.0 double pt_bound[nPtBins+1] = {6.5, 8.0, 10.0, 13.0, 30.0}; double xpt_bound[nPtBins] = {0.0}; // rap bins : 0.0-0.3, 0.3-0.6, 0.6-0.9, 0.9-1.2, 1.2-1.5, 1.5-1.8, 1.8-2.1, 2.1-2.4 double rap_bound[nRapBins+1] = {0.0, 1.2, 1.6, 2.4}; double xrap_bound[nRapBins] = {0.0}; double dphi_bound[ndPhiBins+1] = {0.0, TMath::Pi()/16, 2*TMath::Pi()/16, 3*TMath::Pi()/16, 4*TMath::Pi()/16, 5*TMath::Pi()/16, 6*TMath::Pi()/16, 7*TMath::Pi()/16, 8*TMath::Pi()/16}; double xdphi_bound[ndPhiBins] = {0.0}; double phi_bound[nPhiBins+1] = {-4*TMath::Pi()/4, -3*TMath::Pi()/4, -2*TMath::Pi()/4, -1*TMath::Pi()/4,0.0, TMath::Pi()/4, 2*TMath::Pi()/4, 3*TMath::Pi()/4, TMath::Pi()}; double xphi_bound[nPhiBins] = {0.0}; double dphi2_bound[ndPhi2Bins+1] = {0.0, TMath::Pi()/16, 2*TMath::Pi()/16, 3*TMath::Pi()/16, 4*TMath::Pi()/16, 5*TMath::Pi()/16, 6*TMath::Pi()/16, 7*TMath::Pi()/16, 8*TMath::Pi()/16}; double xdphi2_bound[ndPhi2Bins] = {0.0}; const char *cSp[6] = {"Cents","Pts","Raps","Phi","dPhi","gdPhi"}; char OutTextFile[100]; if(JpsiCat_ == 1) sprintf(OutTextFile,"eff_HighPt_%s_%s_%s_y_%0.1f_%0.1f_pT_%0.1f_%0.1f_pr.tex", cSp[iSpec], cCd, cTrg[0], minRap, maxRap, minPt, maxPt); if(JpsiCat_ == 2) sprintf(OutTextFile,"eff_HighPt_%s_%s_%s_y_%0.1f_%0.1f_pT_%0.1f_%0.1f_npr.tex", cSp[iSpec], cCd, cTrg[0], minRap, maxRap, minPt, maxPt); //sprintf(OutTextFile,"eff_HighPt_%s_%s_%s.tex", cSp[iSpec], cCd, cTrg[iCat]); ofstream dataFile(Form(OutTextFile)); char tmp_start[512]; sprintf(tmp_start,"%%%% Getting Efficiency starts, Category : %s !!!!! %%%%%", cCd); cout<< tmp_start << endl; //dataFile<< tmp_start << endl; // x, y, z - axis //dataFile<<""<<endl; //dataFile<<"xaxis of Cent"<<endl; for(int i = 0; i < nCentBins; i++){ if(i == (nCentBins-1)){ xct_bound[i] = ct_bound[i-4] + (ct_bound[i-1]-ct_bound[i-4])/2; //cout<<"xct_bound["<<i<<"] : "<<xct_bound[i]<<endl; //dataFile<<"xct_bound["<<i<<"] : "<<xct_bound[i]<<endl; }else{ xct_bound[i] = ct_bound[i] + (ct_bound[i+1]-ct_bound[i])/2; //cout<<"xct_bound["<<i<<"] : "<<xct_bound[i]<<endl; //dataFile<<"xct_bound["<<i<<"] : "<<xct_bound[i]<<endl; } } //dataFile<<""<<endl; //dataFile<<"xaxis of pT"<<endl; for(int i = 0; i < nPtBins; i++){ xpt_bound[i] = pt_bound[i] + (pt_bound[i+1]-pt_bound[i])/2; //cout<<"xpt_bound["<<i<<"] : "<<xpt_bound[i]<<endl; //dataFile<<"xpt_bound["<<i<<"] : "<<xpt_bound[i]<<endl; } //dataFile<<""<<endl; //dataFile<<"xaxis of rap"<<endl; for(int i = 0; i < nRapBins; i++){ xrap_bound[i] = rap_bound[i] + (rap_bound[i+1]-rap_bound[i])/2; //cout<<"xrap_bound["<<i<<"] : "<<xrap_bound[i]<<endl; //dataFile<<"xrap_bound["<<i<<"] : "<<xrap_bound[i]<<endl; } //dataFile<<""<<endl; //dataFile<<"xaxis of dphi"<<endl; for(int i = 0; i < ndPhiBins; i++){ xdphi_bound[i] = dphi_bound[i] + (dphi_bound[i+1]-dphi_bound[i])/2; //cout<<"xdphi_bound["<<i<<"] : "<<xdphi_bound[i]<<endl; //dataFile<<"xdphi_bound["<<i<<"] : "<<xdphi_bound[i]<<endl; } //dataFile<<""<<endl; //dataFile<<"xaxis of phi"<<endl; for(int i = 0; i < nPhiBins; i++){ xphi_bound[i] = phi_bound[i] + (phi_bound[i+1]-phi_bound[i])/2; //cout<<"xphi_bound["<<i<<"] : "<<xphi_bound[i]<<endl; //dataFile<<"xphi_bound["<<i<<"] : "<<xphi_bound[i]<<endl; } //dataFile<<""<<endl; //dataFile<<"xaxis of dphi2"<<endl; for(int i = 0; i < ndPhi2Bins; i++){ xdphi2_bound[i] = dphi2_bound[i] + (dphi2_bound[i+1]-dphi2_bound[i])/2; //cout<<"xdphi2_bound["<<i<<"] : "<<xdphi2_bound[i]<<endl; //dataFile<<"xdphi2_bound["<<i<<"] : "<<xdphi2_bound[i]<<endl; } int nBins_tmp = 0; if(iSpec == 0) { nBins_tmp = nCentBins; } if(iSpec == 1) { nBins_tmp = nPtBins; } if(iSpec == 2) { nBins_tmp = nRapBins; } if(iSpec == 3) { nBins_tmp = nPhiBins; } if(iSpec == 4) { nBins_tmp = ndPhiBins; } if(iSpec == 5) { nBins_tmp = ndPhi2Bins; } const int nBins = nBins_tmp; TH1F *hTempMass = new TH1F("hTempMass","",100, 2.0, 4.0); TH1F *hGenDiMuonf[nFiles][nBins]; TH1F *hRecoDiMuonf[nFiles][nBins]; TH1F *hGenDiMuon[nBins]; TH1F *hRecoDiMuon[nBins]; double genNo[nBins]; double genErr[nBins]; double recoNo[nBins]; double recoErr[nBins]; double eff[nBins]; double effErr[nBins]; for(int fl = 0; fl < nFiles; fl++){ for(int i = 0; i < nBins; i++){ hGenDiMuonf[fl][i] = (TH1F*)hTempMass->Clone(); hRecoDiMuonf[fl][i] = (TH1F*)hTempMass->Clone(); hGenDiMuon[i] = (TH1F*)hTempMass->Clone(); hRecoDiMuon[i] = (TH1F*)hTempMass->Clone(); hGenDiMuonf[fl][i]->Sumw2(); hRecoDiMuonf[fl][i]->Sumw2(); hGenDiMuon[i]->Sumw2(); hRecoDiMuon[i]->Sumw2(); } } char fileName[10][512]; //scales for different pT bins double scale[6]={5.83233e-06, 8.13987e-06, 3.64971e-06, 1.13816e-06, 3.50384e-07, 2.1568e-07}; if(PutWeight==0){scale[0]=(1);scale[1]=(1);scale[2]=(1);scale[3]=(1);scale[4]=(1);scale[5]=(1);} // loop for pT cout<<"================================="<<endl; sprintf(fileName[0],"/Users/dmoon/Dropbox/Analysis/HiMC/EffStudy/gRpAngRootFiles_Regit_NonPro/HiDiMuonAna_NonPrompt_RegIt_MC_20131006_Pt_0003.root"); sprintf(fileName[1],"/Users/dmoon/Dropbox/Analysis/HiMC/EffStudy/gRpAngRootFiles_Regit_NonPro/HiDiMuonAna_NonPrompt_RegIt_MC_20131006_Pt_0306.root"); sprintf(fileName[2],"/Users/dmoon/Dropbox/Analysis/HiMC/EffStudy/gRpAngRootFiles_Regit_NonPro/HiDiMuonAna_NonPrompt_RegIt_MC_20131006_Pt_0609.root"); sprintf(fileName[3],"/Users/dmoon/Dropbox/Analysis/HiMC/EffStudy/gRpAngRootFiles_Regit_NonPro/HiDiMuonAna_NonPrompt_RegIt_MC_20131006_Pt_0912.root"); sprintf(fileName[4],"/Users/dmoon/Dropbox/Analysis/HiMC/EffStudy/gRpAngRootFiles_Regit_NonPro/HiDiMuonAna_NonPrompt_RegIt_MC_20131006_Pt_1215.root"); sprintf(fileName[5],"/Users/dmoon/Dropbox/Analysis/HiMC/EffStudy/gRpAngRootFiles_Regit_NonPro/HiDiMuonAna_NonPrompt_RegIt_MC_20131006_Pt_1530.root"); TFile *infile; TTree *tree; TTree *gentree; for(int ifile = 0; ifile < nFiles; ifile++){ infile=new TFile(fileName[ifile],"R"); tree=(TTree*)infile->Get("SingleMuonTree"); gentree=(TTree*)infile->Get("SingleGenMuonTree"); //Event variables int eventNb,runNb,lumiBlock, gbin, rbin; int hbit1; double zVtx; //Jpsi Variables Double_t JpsiMass,JpsiPt,JpsiRap, JpsiCharge; Double_t JpsiVprob; Double_t JpsiPhi; Double_t JpsiEta; Double_t JpsiPsi[38]; Double_t JpsiGenPsi; //2.) muon variables RECO double muPosPx, muPosPy, muPosPz, muPosEta, muPosPt, muPosP, muPosPhi; double muNegPx, muNegPy, muNegPz, muNegEta, muNegPt, muNegP, muNegPhi; //(1).Positive Muon double muPos_nchi2In, muPos_dxy, muPos_dz, muPos_nchi2Gl; int muPos_found, muPos_pixeLayers, muPos_nValidMuHits,muPos_arbitrated,muPos_TMOneST,muPos_trkLayMeas; bool muPos_matches,muPos_tracker; int muPos_Trigger2, muPos_Trigger10; int muPos_Trigger4, muPos_Trigger12, muPos_Trigger13; int muPos_Trigger21, muPos_Trigger22; //(2).Negative Muon double muNeg_nchi2In, muNeg_dxy, muNeg_dz, muNeg_nchi2Gl; int muNeg_found, muNeg_pixeLayers, muNeg_nValidMuHits,muNeg_arbitrated,muNeg_TMOneST,muNeg_trkLayMeas; bool muNeg_matches,muNeg_tracker; int muNeg_Trigger2, muNeg_Trigger10; int muNeg_Trigger4, muNeg_Trigger12, muNeg_Trigger13; int muNeg_Trigger21, muNeg_Trigger22; //Gen Level variables //Gen PrJpsi Variables double GenJpsiMass, GenJpsiPt, GenJpsiRap; double GenJpsiPx, GenJpsiPy, GenJpsiPz; double GenJpsiPhi; double GenJpsiEta; double GenJpsiPsi; //2.) Gen muon variables double GenmuPosPx, GenmuPosPy, GenmuPosPz, GenmuPosEta, GenmuPosPt, GenmuPosPhi; double GenmuNegPx, GenmuNegPy, GenmuNegPz, GenmuNegEta, GenmuNegPt, GenmuNegPhi; //Event variables tree->SetBranchAddress("eventNb",&eventNb); tree->SetBranchAddress("runNb",&runNb); tree->SetBranchAddress("lumiBlock",&lumiBlock); tree->SetBranchAddress("hbit1",&hbit1); tree->SetBranchAddress("zVtx",&zVtx); //Jpsi Variables tree->SetBranchAddress("JpsiCharge",&JpsiCharge); tree->SetBranchAddress("JpsiMass",&JpsiMass); tree->SetBranchAddress("JpsiPt",&JpsiPt); tree->SetBranchAddress("JpsiPhi",&JpsiPhi); tree->SetBranchAddress("JpsiEta",&JpsiEta); tree->SetBranchAddress("JpsiPsi",&JpsiPsi); tree->SetBranchAddress("JpsiGenPsi",&JpsiGenPsi); tree->SetBranchAddress("JpsiRap",&JpsiRap); tree->SetBranchAddress("JpsiVprob",&JpsiVprob); tree->SetBranchAddress("rbin",&rbin); //muon variable tree->SetBranchAddress("muPosPx",&muPosPx); tree->SetBranchAddress("muPosPy",&muPosPy); tree->SetBranchAddress("muPosPz",&muPosPz); tree->SetBranchAddress("muPosEta",&muPosEta); tree->SetBranchAddress("muPosPhi",&muPosPhi); tree->SetBranchAddress("muNegPx", &muNegPx); tree->SetBranchAddress("muNegPy", &muNegPy); tree->SetBranchAddress("muNegPz", &muNegPz); tree->SetBranchAddress("muNegEta", &muNegEta); tree->SetBranchAddress("muNegPhi", &muNegPhi); //1). Positive Muon tree->SetBranchAddress("muPos_nchi2In", &muPos_nchi2In); tree->SetBranchAddress("muPos_dxy", &muPos_dxy); tree->SetBranchAddress("muPos_dz", &muPos_dz); tree->SetBranchAddress("muPos_nchi2Gl", &muPos_nchi2Gl); tree->SetBranchAddress("muPos_found", &muPos_found); tree->SetBranchAddress("muPos_pixeLayers", &muPos_pixeLayers); tree->SetBranchAddress("muPos_nValidMuHits", &muPos_nValidMuHits); tree->SetBranchAddress("muPos_matches", &muPos_matches); tree->SetBranchAddress("muPos_tracker", &muPos_tracker); tree->SetBranchAddress("muPos_arbitrated", &muPos_arbitrated); tree->SetBranchAddress("muPos_TMOneST", &muPos_TMOneST); tree->SetBranchAddress("muPos_trkLayMeas", &muPos_trkLayMeas); tree->SetBranchAddress("muPos_Trigger2", &muPos_Trigger2); tree->SetBranchAddress("muPos_Trigger21", &muPos_Trigger21); tree->SetBranchAddress("muPos_Trigger22", &muPos_Trigger22); tree->SetBranchAddress("muPos_Trigger4", &muPos_Trigger4); tree->SetBranchAddress("muPos_Trigger10", &muPos_Trigger10); tree->SetBranchAddress("muPos_Trigger12", &muPos_Trigger12); tree->SetBranchAddress("muPos_Trigger13", &muPos_Trigger13); //2). Negative Muon tree->SetBranchAddress("muNeg_nchi2In", &muNeg_nchi2In); tree->SetBranchAddress("muNeg_dxy", &muNeg_dxy); tree->SetBranchAddress("muNeg_dz", &muNeg_dz); tree->SetBranchAddress("muNeg_nchi2Gl", &muNeg_nchi2Gl); tree->SetBranchAddress("muNeg_found", &muNeg_found); tree->SetBranchAddress("muNeg_pixeLayers", &muNeg_pixeLayers); tree->SetBranchAddress("muNeg_nValidMuHits", &muNeg_nValidMuHits); tree->SetBranchAddress("muNeg_matches", &muNeg_matches); tree->SetBranchAddress("muNeg_tracker", &muNeg_tracker); tree->SetBranchAddress("muNeg_arbitrated", &muNeg_arbitrated); tree->SetBranchAddress("muNeg_TMOneST", &muNeg_TMOneST); tree->SetBranchAddress("muNeg_trkLayMeas", &muNeg_trkLayMeas); tree->SetBranchAddress("muNeg_Trigger2", &muNeg_Trigger2); tree->SetBranchAddress("muNeg_Trigger21", &muNeg_Trigger21); tree->SetBranchAddress("muNeg_Trigger22", &muNeg_Trigger22); tree->SetBranchAddress("muNeg_Trigger4", &muNeg_Trigger4); tree->SetBranchAddress("muNeg_Trigger10", &muNeg_Trigger10); tree->SetBranchAddress("muNeg_Trigger12", &muNeg_Trigger12); tree->SetBranchAddress("muNeg_Trigger13", &muNeg_Trigger13); //====================================Gen Variables========================================================= //Gen Jpsi Variables gentree->SetBranchAddress("GenJpsiMass", &GenJpsiMass); gentree->SetBranchAddress("GenJpsiPt", &GenJpsiPt); gentree->SetBranchAddress("GenJpsiPhi", &GenJpsiPhi); gentree->SetBranchAddress("GenJpsiPsi", &GenJpsiPsi); gentree->SetBranchAddress("GenJpsiRap", &GenJpsiRap); gentree->SetBranchAddress("GenJpsiEta", &GenJpsiEta); gentree->SetBranchAddress("GenJpsiPx", &GenJpsiPx); gentree->SetBranchAddress("GenJpsiPy", &GenJpsiPy); gentree->SetBranchAddress("GenJpsiPz", &GenJpsiPz); gentree->SetBranchAddress("gbin", &gbin); //muon variable gentree->SetBranchAddress("GenmuPosPx", &GenmuPosPx); gentree->SetBranchAddress("GenmuPosPy", &GenmuPosPy); gentree->SetBranchAddress("GenmuPosPz", &GenmuPosPz); gentree->SetBranchAddress("GenmuPosEta", &GenmuPosEta); gentree->SetBranchAddress("GenmuPosPhi", &GenmuPosPhi); gentree->SetBranchAddress("GenmuNegPx", &GenmuNegPx); gentree->SetBranchAddress("GenmuNegPy", &GenmuNegPy); gentree->SetBranchAddress("GenmuNegPz", &GenmuNegPz); gentree->SetBranchAddress("GenmuNegEta", &GenmuNegEta); gentree->SetBranchAddress("GenmuNegPhi", &GenmuNegPhi); //====================================================== Gen tree loop ================================================ int NAccep=0; int nGenEntries=gentree->GetEntries(); cout<<" Total Entries in GenLevel Tree for pT range: "<<fileName[ifile]<<" "<< nGenEntries<< " ==============="<<endl; for(int iGen=0; iGen< nGenEntries; iGen++) { //cout<<"i : "<<i<<endl; if(!(gentree->GetEntry(iGen))) continue; //cout<<" gentree ("<<i<<")"<<endl; //Only printing if(iGen%10000==0){ //cout<<" processing record "<<iGen<<"/"<<nGenEntries<<endl; //cout<<" Mass "<< GenJpsiMass<< " pT "<< GenJpsiPt << " Y " <<GenJpsiRap<<endl; } bool GenPosIn=0, GenNegIn=0; GenmuPosPt= TMath::Sqrt(GenmuPosPx*GenmuPosPx + GenmuPosPy*GenmuPosPy); GenmuNegPt= TMath::Sqrt(GenmuNegPx*GenmuNegPx + GenmuNegPy*GenmuNegPy); if(IsAccept(GenmuPosPt, GenmuPosEta)) {GenPosIn=1;} if(IsAccept(GenmuNegPt, GenmuNegEta)) {GenNegIn=1;} double GenCenWeight =0, GenWeight =0; GenCenWeight=FindCenWeight(gbin); GenWeight=GenCenWeight*scale[ifile]; hGenCent->Fill(gbin,GenWeight); int AccJpsi = 0; //if(GenJpsiPt < 6.5) continue; if((GenJpsiPt >= minPt && GenJpsiPt <= maxPt && fabs(GenJpsiRap) >= minRap && fabs(GenJpsiRap) <= maxRap && GenPosIn == 1 && GenNegIn == 1 && GenJpsiMass > 2.0 && GenJpsiMass < 4.0)) {AccJpsi = 1;} if((GenPosIn ==1 && GenNegIn==1)) NAccep++; if(PutWeight==0) GenWeight=1; //adding pT of all pt bins to see diss is cont //cout<<"1. GenJpsiPt : "<<GenJpsiPt<<", GenJpsiEta : "<<GenJpsiEta<<", GenJpsiRap : "<<GenJpsiRap<<", |GenJpsiPsi| : "<<TMath::Abs(GenJpsiPsi)<<endl; //cout<<"1. GenPosIn : "<<GenPosIn<<", GenNegIn : "<<GenNegIn<<endl; double vars = 0.0, bin1 = 0.0, bin2 = 0.0; if(iSpec == 0) vars = gbin; if(iSpec == 1) vars = GenJpsiPt; if(iSpec == 2) vars = fabs(GenJpsiRap); if(iSpec == 3) vars = GenJpsiPhi; if(iSpec == 4) vars = fabs(GenJpsiPsi); if(iSpec == 5) vars = fabs(GenJpsiPsi); for(int i = 0; i < nBins; i++){ if(iSpec == 0){ bin1 = ct_bound[i]; bin2 = ct_bound[i+1]; if( (AccJpsi==1) && (vars >= bin1 && vars < bin2) && GenJpsiPt >= minPt && GenJpsiPt <= maxPt && fabs(GenJpsiRap) >= minRap && fabs(GenJpsiRap) < maxRap ) { hGenDiMuonf[ifile][i]->Fill(GenJpsiMass,GenWeight); } } if(iSpec == 1){ bin1 = pt_bound[i]; bin2 = pt_bound[i+1]; if( (AccJpsi==1) && (vars >= bin1 && vars < bin2) && gbin >= 0 && gbin <= 40 && fabs(GenJpsiRap) >= minRap && fabs(GenJpsiRap) < maxRap ) { hGenDiMuonf[ifile][i]->Fill(GenJpsiMass,GenWeight); } } if(iSpec == 2){ bin1 = rap_bound[i]; bin2 = rap_bound[i+1]; if( (AccJpsi==1) && (vars >= bin1 && vars < bin2) && gbin >= 0 && gbin <= 40 && GenJpsiPt >= minPt && GenJpsiPt < maxPt) { hGenDiMuonf[ifile][i]->Fill(GenJpsiMass,GenWeight); } } if(iSpec == 3){ bin1 = phi_bound[i]; bin2 = phi_bound[i+1]; if( (AccJpsi==1) && (vars >= bin1 && vars < bin2) && gbin >= 0 && gbin <= 40 && GenJpsiPt >= minPt && GenJpsiPt < maxPt && fabs(GenJpsiRap) < maxRap) { hGenDiMuonf[ifile][i]->Fill(GenJpsiMass,GenWeight); } } if(iSpec == 4){ bin1 = dphi_bound[i]; bin2 = dphi_bound[i+1]; if( (AccJpsi==1) && (vars >= bin1 && vars < bin2) && gbin >= 0 && gbin <= 40 && GenJpsiPt >= minPt && GenJpsiPt < maxPt && fabs(GenJpsiRap) < maxRap) { hGenDiMuonf[ifile][i]->Fill(GenJpsiMass,GenWeight); } } if(iSpec == 5){ bin1 = dphi2_bound[i]; bin2 = dphi2_bound[i+1]; if( (AccJpsi==1) && (vars >= bin1 && vars < bin2) && gbin >= 0 && gbin <= 40 && GenJpsiPt >= minPt && GenJpsiPt < maxPt && fabs(GenJpsiRap) < maxRap) { hGenDiMuonf[ifile][i]->Fill(GenJpsiMass,GenWeight); } } } }//gen loop end //cout<<" accepted no "<< NAccep<<endl; //=============== Rec Tree Loop ============================================================================== int nRecEntries=tree->GetEntries(); cout<<"Total Entries in reconstructed Tree for pT range "<<fileName[ifile]<<" "<<nRecEntries<< "====="<<endl; for(int iRec=0; iRec<nRecEntries; iRec++) { tree->GetEntry(iRec); //Only printing if(iRec%10000==0){ //cout<<" processing record "<<iRec<<"/"<<nRecEntries<<endl; //cout<<" processing Run " <<runNb <<" event "<<eventNb<<" lum block "<<lumiBlock<<endl; //cout<<" Mass "<< JpsiMass<< " pT "<< JpsiPt << " Y " <<JpsiRap<<" "<<JpsiVprob<<" charge "<<JpsiCharge<<" rbin "<<rbin<<endl; } bool PosPass=0, NegPass=0, AllCut=0 ,PosIn=0, NegIn=0; muPosPt= TMath::Sqrt(muPosPx*muPosPx + muPosPy*muPosPy); muPosP = TMath::Sqrt(muPosPx*muPosPx + muPosPy*muPosPy+ muPosPz*muPosPz); muNegPt= TMath::Sqrt(muNegPx*muNegPx + muNegPy*muNegPy); muNegP = TMath::Sqrt(muNegPx*muNegPx + muNegPy*muNegPy +muNegPz*muNegPz); double tnpWgt1 = 0.0, tnpWgt2 = 0.0; double staWgt1 = 0.0, staWgt2 = 0.0; double x = 0.0; if(fabs(muPosEta) < 0.9){ x = muPosPt; tnpWgt1 = tnpSF1->Eval(x); }else if(fabs(muPosEta) < 1.6){ x = muPosPt; tnpWgt1 = tnpSF2->Eval(x); }else if(fabs(muPosEta) < 2.1){ x = muPosPt; tnpWgt1 = tnpSF3->Eval(x); }else{ x = muPosPt; tnpWgt1 = tnpSF4->Eval(x); } if(fabs(muNegEta) < 0.9){ x = muNegPt; tnpWgt2 = tnpSF1->Eval(x); }else if(fabs(muNegEta) < 1.6){ x = muNegPt; tnpWgt2 = tnpSF2->Eval(x); }else if(fabs(muNegEta) < 2.1){ x = muNegPt; tnpWgt2 = tnpSF3->Eval(x); }else{ x = muNegPt; tnpWgt2 = tnpSF4->Eval(x); } double xta = 0.0; if(fabs(muPosEta) < 1.6){ xta = muPosPt; staWgt1 = fun1->Eval(xta); }else{ xta = muPosPt; staWgt1 = fun2->Eval(xta); } if(fabs(muNegEta) < 1.6){ xta = muNegPt; staWgt2 = fun1->Eval(xta); }else{ xta = muNegPt; staWgt2 = fun2->Eval(xta); } double RecCenWeight=0,RecWeight=0; RecCenWeight=FindCenWeight(rbin); RecWeight=RecCenWeight*scale[ifile]*tnpWgt1*tnpWgt2*staWgt1*staWgt2; hRecCent->Fill(gbin,RecWeight); if(IsAccept(muPosPt, muPosEta)){PosIn=1;} if(IsAccept(muNegPt, muNegEta)){NegIn=1;} int AccJpsi = 0; if((JpsiPt >= minPt && JpsiPt <= maxPt && fabs(JpsiRap) >= minRap && fabs(JpsiRap) <= maxRap && PosIn == 1 && NegIn == 1)) {AccJpsi = 1;} /* cout<<"muPos_pixeLayers : "<<muPos_pixeLayers<<" muPos_nchi2In : "<<muPos_nchi2In <<" TMath::Abs(muPos_dxy) : "<<TMath::Abs(muPos_dxy)<<" TMath::Abs(muPos_dz) : "<<TMath::Abs(muPos_dz) <<" muPos_trkLayMeas : "<<muPos_trkLayMeas <<" muPos_arbitrated : "<<muPos_arbitrated<<" muPos_TMOneST : "<<muPos_TMOneST<<" muPos_tracker : "<<muPos_tracker<<endl; cout<<"muNeg_pixeLayers : "<<muNeg_pixeLayers<<" muNeg_nchi2In : "<<muNeg_nchi2In <<" TMath::Abs(muNeg_dxy) : "<<TMath::Abs(muNeg_dxy)<<" TMath::Abs(muNeg_dz) : "<<TMath::Abs(muNeg_dz) <<" muNeg_trkLayMeas : "<<muNeg_trkLayMeas <<" muNeg_arbitrated : "<<muNeg_arbitrated<<" muNeg_TMOneST : "<<muNeg_TMOneST<<" muNeg_tracker : "<<muNeg_tracker<<endl; */ bool mu_Global = ((muPos_nchi2Gl >=0) && (muNeg_nchi2Gl >=0)); bool mu_Tracker = ((muPos_tracker==1) && (muNeg_tracker==1)); if(muPos_found > 10 && muPos_pixeLayers > 0 && muPos_nchi2In < 4.0 && TMath::Abs(muPos_dxy) < 3 && TMath::Abs(muPos_dz) < 15 && muPos_nchi2Gl < 20 && muPos_arbitrated==1 && muPos_tracker==1){ PosPass=1; } if(muNeg_found > 10 && muNeg_pixeLayers > 0 && muNeg_nchi2In < 4.0 && TMath::Abs(muNeg_dxy) < 3 && TMath::Abs(muNeg_dz) < 15 && muNeg_nchi2Gl < 20 && muNeg_arbitrated==1 && muNeg_tracker==1){ NegPass=1; } if(hbit1 == 1 && (muPos_Trigger22==1 && muNeg_Trigger22==1) && (PosIn==1 && NegIn==1) && (PosPass==1 && NegPass==1) && mu_Global && mu_Tracker ){AllCut=1;} if(PutWeight==0)RecWeight=1; double JpsidPhi = JpsiGenPsi; //Eff loop for reco double vars = 0.0, bin1 = 0.0, bin2 = 0.0; if(iSpec == 0) vars = rbin; if(iSpec == 1) vars = JpsiPt; if(iSpec == 2) vars = fabs(JpsiRap); if(iSpec == 3) vars = JpsiPhi; if(iSpec == 4) vars = fabs(JpsidPhi); if(iSpec == 5) vars = fabs(JpsiGenPsi); if((JpsiCharge == 0) && (JpsiVprob > 0.01) && (JpsiMass >= 2.95 && JpsiMass < 3.25)) { for(int i = 0; i < nBins; i++){ if(iSpec == 0){ bin1 = ct_bound[i]; bin2 = ct_bound[i+1]; if( AccJpsi == 1 && (AllCut == 1) && (vars >= bin1 && vars < bin2) && JpsiPt >= minPt && JpsiPt <= maxPt && fabs(JpsiRap) >= minRap && fabs(JpsiRap) <= maxRap ) { hRecoDiMuonf[ifile][i]->Fill(JpsiMass,RecWeight); } } if(iSpec == 1){ bin1 = pt_bound[i]; bin2 = pt_bound[i+1]; if( AccJpsi == 1 && (AllCut == 1) && (vars >= bin1 && vars < bin2) && rbin >= 0 && rbin <= 40 && fabs(JpsiRap) >= minRap && fabs(JpsiRap) <= maxRap ) { hRecoDiMuonf[ifile][i]->Fill(JpsiMass,RecWeight); } } if(iSpec == 2){ bin1 = rap_bound[i]; bin2 = rap_bound[i+1]; if( AccJpsi == 1 && (AllCut == 1) && (vars >= bin1 && vars < bin2) && rbin >= 0 && rbin <= 40 && JpsiPt >= minPt && JpsiPt <= maxPt) { hRecoDiMuonf[ifile][i]->Fill(JpsiMass,RecWeight); } } if(iSpec == 3){ bin1 = phi_bound[i]; bin2 = phi_bound[i+1]; if( AccJpsi == 1 && (AllCut == 1) && (vars >= bin1 && vars < bin2) && rbin >= 0 && rbin <= 40 && JpsiPt >= minPt && JpsiPt <= maxPt && fabs(JpsiRap) <=maxRap) { hRecoDiMuonf[ifile][i]->Fill(JpsiMass,RecWeight); } } if(iSpec == 4){ bin1 = dphi_bound[i]; bin2 = dphi_bound[i+1]; if( AccJpsi == 1 && (AllCut == 1) && (vars >= bin1 && vars < bin2) && rbin >= 0 && rbin <= 40 && JpsiPt >= minPt && JpsiPt <= maxPt && fabs(JpsiRap) <=maxRap) { hRecoDiMuonf[ifile][i]->Fill(JpsiMass,RecWeight); } } if(iSpec == 5){ bin1 = dphi2_bound[i]; bin2 = dphi2_bound[i+1]; if( AccJpsi == 1 && (AllCut == 1) && (vars >= bin1 && vars < bin2) && rbin >= 0 && rbin <= 40 && JpsiPt >= minPt && JpsiPt <= maxPt && fabs(JpsiRap) <=maxRap) { hRecoDiMuonf[ifile][i]->Fill(JpsiMass,RecWeight); } } } } } //rec tree loop ends } // file loop ends //====================== File loop Starts ============================ /////////////////////////////////////////////////////////////////// cout<< " adding "<<endl; TCanvas *c1 = new TCanvas(); char gtmp[512], gtmp1[512]; char rtmp[512], rtmp1[512]; for(int i = 0; i < nBins; i++){ for(int ifile = 0; ifile < nFiles; ifile++){ hGenDiMuon[i]->Add(hGenDiMuonf[ifile][i],1); hRecoDiMuon[i]->Add(hRecoDiMuonf[ifile][i],1); } if(iSpec == 0) sprintf(gtmp,"hGenDiMuon_Cent_%1.f_%1.f",ct_bound[i],ct_bound[i+1]); if(iSpec == 1) sprintf(gtmp,"hGenDiMuon_Pt_%0.1f_%0.1f",pt_bound[i],pt_bound[i+1]); if(iSpec == 2) sprintf(gtmp,"hGenDiMuon_Rap_%0.1f_%0.1f",rap_bound[i],rap_bound[i+1]); if(iSpec == 0) sprintf(gtmp1,"plots/Gen/hGenDiMuon_Cent_%1.f_%1.f_%s.png",ct_bound[i],ct_bound[i+1],cCd); if(iSpec == 1) sprintf(gtmp1,"plots/Gen/hGenDiMuon_Pt_%0.1f_%0.1f_%s.png",pt_bound[i],pt_bound[i+1],cCd); if(iSpec == 2) sprintf(gtmp1,"plots/Gen/hGenDiMuon_Rap_%0.1f_%0.1f_%s.png",rap_bound[i],rap_bound[i+1],cCd); if(iSpec == 0) sprintf(rtmp,"hRecDiMuon_Cent_%1.f_%1.f",ct_bound[i],ct_bound[i+1]); if(iSpec == 1) sprintf(rtmp,"hRecDiMuon_Pt_%0.1f_%0.1f",pt_bound[i],pt_bound[i+1]); if(iSpec == 2) sprintf(rtmp,"hRecDiMuon_Rap_%0.1f_%0.1f",rap_bound[i],rap_bound[i+1]); if(iSpec == 0) sprintf(rtmp1,"plots/Rec/hRecDiMuon_Cent_%1.f_%1.f_%s.png",ct_bound[i],ct_bound[i+1],cCd); if(iSpec == 1) sprintf(rtmp1,"plots/Rec/hRecDiMuon_Pt_%0.1f_%0.1f_%s.png",pt_bound[i],pt_bound[i+1],cCd); if(iSpec == 2) sprintf(rtmp1,"plots/Rec/hRecDiMuon_Rap_%0.1f_%0.1f_%s.png",rap_bound[i],rap_bound[i+1],cCd); hGenDiMuon[i]->SetName(gtmp); //hGenDiMuon[i]->Write(); //hGenDiMuon[ipt][irap][idphi]->Draw(); //c1->SaveAs(gtmp1); hRecoDiMuon[i]->SetName(rtmp); //hRecoDiMuon[i]->Write(); //hRecoDiMuon[ipt][irap][idphi]->Draw(); //c1->SaveAs(rtmp1); } TH1F *hReco = new TH1F(); TH1F *hGen = new TH1F(); hReco->Sumw2(); hGen->Sumw2(); int nRecoBins; int nGenBins; if(iSpec == 0) {hReco = new TH1F("hReco","hReco;Centrality (%);Weighted Yields",nCentBins,ct_bound2); nRecoBins = nCentBins;} if(iSpec == 1) {hReco = new TH1F("hReco","hReco;p_{T} GeV/c;Weighted Yields",nPtBins,pt_bound); nRecoBins = nPtBins;} if(iSpec == 2) {hReco = new TH1F("hReco","hReco;y;Weighted Yields",nRapBins,rap_bound); nRecoBins = nRapBins;} if(iSpec == 3) {hReco = new TH1F("hReco","hReco;#phi;Weighted Yields",nPhiBins,phi_bound); nRecoBins = nPhiBins;} if(iSpec == 4) {hReco = new TH1F("hReco","hReco;d#phi;Weighted Yields",ndPhiBins,dphi_bound); nRecoBins = ndPhiBins;} if(iSpec == 5) {hReco = new TH1F("hReco","hReco;d#phi;Weighted Yields",ndPhi2Bins,dphi2_bound); nRecoBins = ndPhi2Bins;} if(iSpec == 0) {hGen = new TH1F("hGen","hGen;Centrality (%);Weighted Yields",nCentBins,ct_bound2); nGenBins = nCentBins;} if(iSpec == 1) {hGen = new TH1F("hGen","hGen;p_{T} GeV/c;Weighted Yields",nPtBins,pt_bound); nGenBins = nPtBins;} if(iSpec == 2) {hGen = new TH1F("hGen","hGen;y;Weighted Yields",nRapBins,rap_bound); nGenBins = nRapBins;} if(iSpec == 3) {hGen = new TH1F("hGen","hGen;#phi;Weighted Yields",nPhiBins,phi_bound); nGenBins = nPhiBins;} if(iSpec == 4) {hGen = new TH1F("hGen","hGen;d#phi;Weighted Yields",ndPhiBins,dphi_bound); nGenBins = ndPhiBins;} if(iSpec == 5) {hGen = new TH1F("hGen","hGen;d#phi;Weighted Yields",ndPhi2Bins,dphi2_bound); nGenBins = ndPhi2Bins;} cout<<"Starts to calculate efficiency"<<endl; //dataFile<<""<<endl; //=====================Loop for eff========================================================================================// //define stuff here for error on weighted samples for(int i = 0; i < nBins; i++){ int Gbinlow =hGenDiMuon[i]->GetXaxis()->FindBin(2.0);//2.95 int Gbinhi=hGenDiMuon[i]->GetXaxis()->FindBin(4.0);//2.95 //int Gbinlow =hGenDiMuon[i]->GetXaxis()->FindBin(2.95);//2.95 //int Gbinhi=hGenDiMuon[i]->GetXaxis()->FindBin(3.25);//2.95 int Rbinlow =hRecoDiMuon[i]->GetXaxis()->FindBin(2.95);//2.95 int Rbinhi=hRecoDiMuon[i]->GetXaxis()->FindBin(3.25);//2.95 cout<<"Gbinlow : "<<Gbinlow<<", Gbinhi : "<<Gbinhi<<endl; cout<<"Rbinlow : "<<Rbinlow<<", Rbinhi : "<<Rbinhi<<endl; genNo[i] = hGenDiMuon[i]->IntegralAndError(Gbinlow, Gbinhi, genErr[i]); recoNo[i] = hRecoDiMuon[i]->IntegralAndError(Rbinlow, Rbinhi, recoErr[i]); //calculate Eff if(genNo[i] == 0 || recoNo[i] == 0) { cout<<"No Gen or Reco, # of Gen : "<<genNo[i] <<", # of Reco : "<<recoNo[i]<<endl; eff[i] = 0; effErr[i] = 0; }else{ eff[i] = recoNo[i]/genNo[i]; double tmpGenNo = genNo[i]; double tmpGenErr = genErr[i]; double tmpRecNo = recoNo[i]; double tmpRecErr = recoErr[i]; double tmpEff = eff[i]; double tmpEffErr = 0.0; hReco->SetBinContent(i+1,tmpRecNo); hReco->SetBinError(i+1,tmpRecErr); hGen->SetBinContent(i+1,tmpGenNo); hGen->SetBinError(i+1,tmpGenErr); //error double tmp_err_s1_1 = (tmpEff * tmpEff)/(tmpGenNo * tmpGenNo); double tmp_err_s1_2 = (tmpRecErr * tmpRecErr); double tmp_err_cat_s1 = tmp_err_s1_1 * tmp_err_s1_2; double tmp_err_s2_1 = ( (1 - tmpEff)*(1 - tmpEff) ) / (tmpGenNo * tmpGenNo); double tmp_err_s2_2 = TMath::Abs(( tmpGenErr*tmpGenErr ) - ( tmpRecErr * tmpRecErr)); double tmp_err_cat_s2 = tmp_err_s2_1 * tmp_err_s2_2; tmpEffErr = sqrt( tmp_err_cat_s1 + tmp_err_cat_s2 ); effErr[i] = tmpEffErr; //error without weight //dataFile<<" Bin ["<<i<<"] - "<< " Reco Jpsi : "<< tmpRecNo <<", Gen Jpsi : "<< tmpGenNo <<endl; //dataFile<<" Eff ["<<i<<"] - "<< tmpEff <<" Error "<< tmpEffErr <<endl; cout<<" Bin ["<<i<<"] - "<< " Reco Jpsi : "<< tmpRecNo <<", Gen Jpsi : "<< tmpGenNo <<endl; cout<<" Eff ["<<i<<"] - "<< tmpEff <<" Error "<< tmpEffErr <<endl; } } TH1F *hEff = new TH1F(); hEff->Sumw2(); int nEffBins = 0; if(iSpec == 0) {hEff = new TH1F("hEff","hEff;Centrality (%);Efficiency",nCentBins,ct_bound2); nEffBins = nCentBins;} if(iSpec == 1) {hEff = new TH1F("hEff","hEff;p_{T} GeV/c;Efficiency",nPtBins,pt_bound); nEffBins = nPtBins;} if(iSpec == 2) {hEff = new TH1F("hEff","hEff;y;Efficiency",nRapBins,rap_bound); nEffBins = nRapBins;} if(iSpec == 3) {hEff = new TH1F("hEff","hEff;#phi;Efficiency",nPhiBins,phi_bound); nEffBins = nPhiBins;} if(iSpec == 4) {hEff = new TH1F("hEff","hEff;d#phi;Efficiency",ndPhiBins,dphi_bound); nEffBins = ndPhiBins;} if(iSpec == 5) {hEff = new TH1F("hEff","hEff;d#phi;Efficiency",ndPhi2Bins,dphi2_bound); nEffBins = ndPhi2Bins;} for(int i = 0; i < nEffBins; i++){ hEff->SetBinContent(i+1,eff[i]); hEff->SetBinError(i+1,effErr[i]); cout<<"Trying to measure Reconstruction eff vs "<<cSp[iSpec]<<endl; cout<<"Eff : "<<eff[i]<<", err : "<<effErr[i]<<endl; dataFile<<eff[i]<<endl; //dataFile<<"Eff : "<<eff[i]<<", err : "<<effErr[i]<<endl; } outfile->cd(); hEff->Draw(); char tmp_histo[512]; sprintf(tmp_histo,"hEff_%s",cSp[iSpec]); char tmp_histo_reco[512]; sprintf(tmp_histo_reco,"hReco_%s",cSp[iSpec]); char tmp_histo_gen[512]; sprintf(tmp_histo_gen,"hGen_%s",cSp[iSpec]); hEff->SetName(tmp_histo); hEff->Write(); hReco->SetName(tmp_histo_reco); hReco->Write(); hGen->SetName(tmp_histo_gen); hGen->Write(); //c1->SaveAs("eff_3D_default_etHFm.png"); //outfile->Close(); dataFile<<""<<endl; dataFile.close(); } hGenCent->Write(); hRecCent->Write(); outfile->Write(); }
void readBacon(){ TFile* fIn = new TFile("ntuple.root"); TTree* tree = (TTree*) fIn->Get("Events"); TClonesArray *fPFPart = new TClonesArray("baconhep::TPFPart"); TClonesArray *fGenPart = new TClonesArray("baconhep::TGenParticle"); TClonesArray *fVertex = new TClonesArray("baconhep::TVertex"); tree->SetBranchAddress("PFPart", &fPFPart); tree->SetBranchAddress("GenParticle", &fGenPart); tree->SetBranchAddress("PV",&fVertex); for(int i0 = 0; i0 <tree->GetEntriesFast(); i0++) { //1, event loop tree->GetEntry(i0); std::vector<fastjet::PseudoJet> particles; particles.clear(); for( int i1 = 0; i1 < fPFPart->GetEntriesFast(); i1++){//2,entries loop,fill the vector particles with PF particles baconhep::TPFPart *pPartTmp = (baconhep::TPFPart*)((*fPFPart)[i1]); double Px=pPartTmp->pt*cos(pPartTmp->phi); double Py= pPartTmp->pt*sin(pPartTmp->phi); double theta = 2*atan(exp(-pPartTmp->eta)); //eta = -ln(tan(theta/2)) double Pz = pPartTmp->pt/tan(theta); double E = pPartTmp->e; double pdgId = pPartTmp->pfType; int charge = pPartTmp->q; fastjet::PseudoJet tmp_psjet(Px, Py, Pz, E); tmp_psjet.set_user_info( new PseudoJetUserInfo(pdgId, charge) ); particles.push_back(tmp_psjet); }//2,entries loop ,fill the vector particles with PFparticles double rhoEtaMax=4.4; fastjet::GridMedianBackgroundEstimator* mBgeGrid; fastjet::Subtractor* subtractor; subtractor=NULL; mBgeGrid= new fastjet::GridMedianBackgroundEstimator(rhoEtaMax, 0.55); mBgeGrid->set_particles(particles); if(subtractor) delete subtractor; subtractor= new fastjet::Subtractor(mBgeGrid); double rhoVal_grid=mBgeGrid->rho(); fastjet::GhostedAreaSpec fjActiveArea(ghostEtaMax,activeAreaRepeats,ghostArea); fjActiveArea.set_fj2_placement(true); fastjet::AreaDefinition *mAreaDefinition; mAreaDefinition =new fastjet::AreaDefinition( fastjet::active_area_explicit_ghosts, fjActiveArea ); fastjet::Selector selected_eta = fastjet::SelectorAbsEtaMax(2.4); double R=0.8;//define the jet cone radius to use std::string JetAlgorithm = "AK"; //choose which jet algo to use , write AK for antikt, CA for Cambridge/Achen, KT for kt algo JetDefinition jet_def(antikt_algorithm,R); if (JetAlgorithm == "AK")jet_def.set_jet_algorithm( fastjet::antikt_algorithm ); else if (JetAlgorithm == "CA")jet_def.set_jet_algorithm( fastjet::cambridge_algorithm ); else if (JetAlgorithm == "KT")jet_def.set_jet_algorithm( fastjet::kt_algorithm ); //else throw << " unknown jet algorithm " << std::endl; fastjet::ClusterSequenceArea thisClustering_area(particles, jet_def, *mAreaDefinition); fastjet::ClusterSequence thisClustering_basic(particles, jet_def); std::vector<fastjet::PseudoJet> out_jets = sorted_by_pt( selected_eta(thisClustering_area.inclusive_jets(15.0)) ); std::vector<fastjet::PseudoJet> out_jets_basic = sorted_by_pt( selected_eta(thisClustering_basic.inclusive_jets(15.0)) ); //Now you can print the jet momentum , mass , pt etc like the following for(int j=0;j<out_jets.size();j++){ cout<<"jet pt = "<<out_jets.at(j).pt()<<endl; cout<<"jet eta = "<<out_jets.at(j).eta()<<endl; cout<<"jet phi = "<<out_jets.at(j).phi()<<endl; } }//1 event loop }
int main(int argc, char* argv[]) { TFile* f = new TFile("example/ntuple.root","READ"); TTree* t = (TTree*) f->Get("EleTauKinFit"); TH1F* h_mH = new TH1F("h_mH", "distribution of mH_{fit};mH_{fit} [GeV];entries/5GeV", 40,200,400); TH1F* h_chi2 = new TH1F("h_chi2", "distribution of #chi^{2}_{fit};#chi^{2}_{fit};entries/1", 100,0,25); TH1F* h_prob = new TH1F("h_prob", "distribution of fit probability;P_{fit};entries/0.05", 100,0,1); TH1F* h_pull1 = new TH1F("h_pull1","pull distribution E_{b1};pull;entries/0.25", 20,-5,5); TH1F* h_pull2 = new TH1F("h_pull2","pull distribution E_{b2};pull;entries/0.25", 20,-5,5); TH1F* h_pullB = new TH1F("h_pullB","pull distribution balance;pull;entries/0.25", 20,-5,5); Int_t max_nevent = t->GetEntriesFast(); //Leaf types Int_t njets; Double_t b1_dR; Double_t b1_csv; Double_t b1_px; Double_t b1_py; Double_t b1_pz; Double_t b1_E; Double_t b2_dR; Double_t b2_csv; Double_t b2_px; Double_t b2_py; Double_t b2_pz; Double_t b2_E; Double_t tauvis1_dR; Double_t tauvis1_px; Double_t tauvis1_py; Double_t tauvis1_pz; Double_t tauvis1_E; Double_t tauvis2_dR; Double_t tauvis2_px; Double_t tauvis2_py; Double_t tauvis2_pz; Double_t tauvis2_E; Double_t met_pt; Double_t met_px; Double_t met_py; Double_t met_cov00; Double_t met_cov10; Double_t met_cov01; Double_t met_cov11; // List of branches TBranch *b_njets; TBranch *b_b1_dR; TBranch *b_b1_csv; TBranch *b_b1_px; TBranch *b_b1_py; TBranch *b_b1_pz; TBranch *b_b1_E; TBranch *b_b2_dR; TBranch *b_b2_csv; TBranch *b_b2_px; TBranch *b_b2_py; TBranch *b_b2_pz; TBranch *b_b2_E; TBranch *b_tauvis1_dR; TBranch *b_tauvis1_px; TBranch *b_tauvis1_py; TBranch *b_tauvis1_pz; TBranch *b_tauvis1_E; TBranch *b_tauvis2_dR; TBranch *b_tauvis2_px; TBranch *b_tauvis2_py; TBranch *b_tauvis2_pz; TBranch *b_tauvis2_E; TBranch *b_met_pt; TBranch *b_met_px; TBranch *b_met_py; TBranch *b_met_cov00; TBranch *b_met_cov10; TBranch *b_met_cov01; TBranch *b_met_cov11; t->SetBranchAddress("Njets", &njets, &b_njets); t->SetBranchAddress("b1_dR", &b1_dR, &b_b1_dR); t->SetBranchAddress("b1_csv", &b1_csv, &b_b1_csv); t->SetBranchAddress("b1_px", &b1_px, &b_b1_px); t->SetBranchAddress("b1_py", &b1_py, &b_b1_py); t->SetBranchAddress("b1_pz", &b1_pz, &b_b1_pz); t->SetBranchAddress("b1_E", &b1_E, &b_b1_E); t->SetBranchAddress("b2_dR", &b2_dR, &b_b2_dR); t->SetBranchAddress("b2_csv", &b2_csv, &b_b2_csv); t->SetBranchAddress("b2_px", &b2_px, &b_b2_px); t->SetBranchAddress("b2_py", &b2_py, &b_b2_py); t->SetBranchAddress("b2_pz", &b2_pz, &b_b2_pz); t->SetBranchAddress("b2_E", &b2_E, &b_b2_E); t->SetBranchAddress("tauvis1_dR", &tauvis1_dR, &b_tauvis1_dR); t->SetBranchAddress("tauvis1_px", &tauvis1_px, &b_tauvis1_px); t->SetBranchAddress("tauvis1_py", &tauvis1_py, &b_tauvis1_py); t->SetBranchAddress("tauvis1_pz", &tauvis1_pz, &b_tauvis1_pz); t->SetBranchAddress("tauvis1_E", &tauvis1_E, &b_tauvis1_E); t->SetBranchAddress("tauvis2_dR", &tauvis2_dR, &b_tauvis2_dR); t->SetBranchAddress("tauvis2_px", &tauvis2_px, &b_tauvis2_px); t->SetBranchAddress("tauvis2_py", &tauvis2_py, &b_tauvis2_py); t->SetBranchAddress("tauvis2_pz", &tauvis2_pz, &b_tauvis2_pz); t->SetBranchAddress("tauvis2_E", &tauvis2_E, &b_tauvis2_E); t->SetBranchAddress("met_pt", &met_pt, &b_met_pt); t->SetBranchAddress("met_px", &met_px, &b_met_px); t->SetBranchAddress("met_py", &met_py, &b_met_py); t->SetBranchAddress("met_cov00", &met_cov00, &b_met_cov00); t->SetBranchAddress("met_cov10", &met_cov10, &b_met_cov10); t->SetBranchAddress("met_cov01", &met_cov01, &b_met_cov01); t->SetBranchAddress("met_cov11", &met_cov11, &b_met_cov11); //define the testd hypotheses std::vector<Int_t> hypo_mh1; hypo_mh1.push_back(125); std::vector<Int_t> hypo_mh2; hypo_mh2.push_back(125); // event loop for (int i = 0; i < max_nevent; i++) { t->GetEntry(i); //use only btaged jets and check for correct gen match if (b1_csv<0.681 || b2_csv<0.681 || njets < 2 || b1_dR > 0.2 || b2_dR > 0.2 || tauvis1_dR > 0.1 || tauvis2_dR > 0.1) continue; //define input vectors TLorentzVector b1 = TLorentzVector(b1_px,b1_py,b1_pz,b1_E); TLorentzVector b2 = TLorentzVector(b2_px,b2_py,b2_pz,b2_E); TLorentzVector tau1vis = TLorentzVector(tauvis1_px,tauvis1_py,tauvis1_pz,tauvis1_E); TLorentzVector tau2vis = TLorentzVector(tauvis2_px,tauvis2_py,tauvis2_pz,tauvis2_E); TLorentzVector ptmiss = TLorentzVector(met_px,met_py,0,met_pt); TMatrixD metcov(2,2); metcov(0,0)=met_cov00; metcov(1,0)=met_cov10; metcov(0,1)=met_cov01; metcov(1,1)=met_cov11; //intance of fitter master class HHKinFitMaster kinFits = HHKinFitMaster(&b1,&b2,&tau1vis,&tau2vis); kinFits.setAdvancedBalance(&ptmiss,metcov); //kinFits.setSimpleBalance(ptmiss.Pt(),10); //alternative which uses only the absolute value of ptmiss in the fit kinFits.addMh1Hypothesis(hypo_mh1); kinFits.addMh2Hypothesis(hypo_mh2); kinFits.doFullFit(); //obtain results from different hypotheses Double_t chi2_best = kinFits.getBestChi2FullFit(); Double_t mh_best = kinFits.getBestMHFullFit(); std::pair<Int_t, Int_t> bestHypo = kinFits.getBestHypoFullFit(); std::map< std::pair<Int_t, Int_t>, Double_t> fit_results_chi2 = kinFits.getChi2FullFit(); std::map< std::pair<Int_t, Int_t>, Double_t> fit_results_fitprob = kinFits.getFitProbFullFit(); std::map< std::pair<Int_t, Int_t>, Double_t> fit_results_mH = kinFits.getMHFullFit(); std::map< std::pair<Int_t, Int_t>, Double_t> fit_results_pull_b1 = kinFits.getPullB1FullFit(); std::map< std::pair<Int_t, Int_t>, Double_t> fit_results_pull_b2 = kinFits.getPullB2FullFit(); std::map< std::pair<Int_t, Int_t>, Double_t> fit_results_pull_balance = kinFits.getPullBalanceFullFit(); std::map< std::pair<Int_t, Int_t>, Int_t> fit_convergence = kinFits.getConvergenceFullFit(); std::cout << "#############################" << std::endl; std::cout << "EVENT" << i << std::endl; std::cout << "#############################" << std::endl; std::cout << "=====================================" << std::endl; std::cout << "event: " << i << std::endl; std::cout << "best chi2: " << chi2_best << std::endl; std::cout << "best hypothesis: " << bestHypo.first << " " << bestHypo.second << std::endl; std::cout << "best mH= " << mh_best << std::endl; std::cout << "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*" << std::endl; //individual loop over results for (std::vector<Int_t>::iterator mh2 = hypo_mh2.begin(); mh2 != hypo_mh2.end(); mh2++){ for (std::vector<Int_t>::iterator mh1 = hypo_mh1.begin(); mh1 != hypo_mh1.end(); mh1++){ std::pair< Int_t, Int_t > hypo(*mh1,*mh2); //sanity cuts: use only converged fits and events with chi2<25 and make sure used cov was positive definit (this needs to be fixed!) if (fit_convergence.at(hypo)>0 && fit_results_chi2.at(hypo)<25 && fit_results_pull_balance.at(hypo)>0){ std::cout << *mh1 << " " << *mh2 << " " << "chi2_fit: " << fit_results_chi2.at(hypo) << std::endl; std::cout << *mh1 << " " << *mh2 << " " << "prob_fit: " << fit_results_fitprob.at(hypo) << std::endl; std::cout << *mh1 << " " << *mh2 << " " << "mH_fit= " << fit_results_mH.at(hypo) << std::endl; std::cout << "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*" << std::endl; h_mH->Fill(fit_results_mH.at(hypo)); h_chi2->Fill(fit_results_chi2.at(hypo)); h_prob->Fill(fit_results_fitprob.at(hypo)); h_pull1->Fill(fit_results_pull_b1.at(hypo)); h_pull2->Fill(fit_results_pull_b2.at(hypo)); h_pullB->Fill(fit_results_pull_balance.at(hypo)); } } } } TFile fout("result.root","RECREATE"); h_mH->Write(); h_chi2->Write(); h_prob->Write(); h_pull1->Write(); h_pull2->Write(); h_pullB->Write(); return (0); }
void FillHistos(TString FileName, bool UseWeights) { TFile *inf,*outf; TTree *tr; cout<<"Reading File: "<<FileName<<endl; inf = TFile::Open("data/"+FileName); outf = new TFile("Histo_"+FileName,"RECREATE"); //----- booking histograms ---------------------- double PT_MAX[8] = {1200,1200,1200,1200,1200,1200,1200,130}; TH1F *hBDT = new TH1F("BDT","BDT",100,-1,1); TH1F *hMLP_demo = new TH1F("MLP_demo","MLP_demo",65,-0.2,1.1); TH1F *hMLP = new TH1F("MLP","MLP",20,0.6,1.0001); TH1F *hMLP_JESlo = new TH1F("MLP_JESlo","MLP_JESlo",20,0.6,1.0001); TH1F *hMLP_JESup = new TH1F("MLP_JESup","MLP_JESup",20,0.6,1.0001); TH1F *hCos = new TH1F("Cos","Cos",100,-1,1); TH1F *hHT = new TH1F("HT","HT",42,750,2850); TH1F *hHT_JESlo = new TH1F("HT_JESlo","HT_JESlo",42,750,2850); TH1F *hHT_JESup = new TH1F("HT_JESup","HT_JESup",42,750,2850); TH1F *hM8J = new TH1F("M8J","M8J",70,0,7000); TH1F *hM4J = new TH1F("M4J","M4J",300,0,3000); TH1F *hHT4J = new TH1F("HT4J","HT4J",100,0,2000); TH1F *hPT4J = new TH1F("PT4J","PT4J",60,0,1500); TH1F *hEta4J = new TH1F("Eta4J","Eta4J",50,-5,5); TH1F *hM2J = new TH1F("M2J","M2J",200,0,1000); TH1F *hB4J = new TH1F("B4J","B4J",200,0,2); TH1F *hB2J = new TH1F("B2J","B2J",200,0,2); TH1F *hPtAll = new TH1F("JetPt","JetPt",240,0,1200); TH1F *hEtaAll = new TH1F("JetEta","JetEta",50,-5,5); TH1F *hPhiAll = new TH1F("JetPhi","JetPhi",100,-3.15,3.15); TH1F *hBetaAll = new TH1F("JetBeta","JetBeta",100,0,1.0001); TH1F *hChfAll = new TH1F("JetChf","JetChf",100,0,1.0001); TH1F *hNhfAll = new TH1F("JetNhf","JetNhf",100,0,1.0001); TH1F *hPhfAll = new TH1F("JetPhf","JetPhf",100,0,1.0001); TH1F *hMufAll = new TH1F("JetMuf","JetMuf",100,0,1.0001); TH1F *hElfAll = new TH1F("JetElf","JetElf",100,0,1.0001); TH1F *hPt[8],*hPt_JESlo[8],*hPt_JESup[8],*hEta[8],*hPhi[8],*hBeta[8],*hChf[8],*hNhf[8],*hPhf[8],*hMuf[8],*hElf[8]; char name[1000]; for(int i=0;i<8;i++) { sprintf(name,"JetPt%d",i); hPt[i] = new TH1F(name,name,(PT_MAX[i]-30)/5,30,PT_MAX[i]); hPt[i]->Sumw2(); sprintf(name,"JetPt%d_JESlo",i); hPt_JESlo[i] = new TH1F(name,name,(PT_MAX[i]-30)/5,30,PT_MAX[i]); hPt_JESlo[i]->Sumw2(); sprintf(name,"JetPt%d_JESup",i); hPt_JESup[i] = new TH1F(name,name,(PT_MAX[i]-30)/5,30,PT_MAX[i]); hPt_JESup[i]->Sumw2(); sprintf(name,"JetEta%d",i); hEta[i] = new TH1F(name,name,50,-5,5); hEta[i]->Sumw2(); sprintf(name,"JetPhi%d",i); hPhi[i] = new TH1F(name,name,100,-3.15,3.15); hPhi[i]->Sumw2(); sprintf(name,"JetBeta%d",i); hBeta[i] = new TH1F(name,name,100,0,1.0001); hBeta[i]->Sumw2(); sprintf(name,"JetChf%d",i); hChf[i] = new TH1F(name,name,100,0,1.0001); hChf[i]->Sumw2(); sprintf(name,"JetNhf%d",i); hNhf[i] = new TH1F(name,name,100,0,1.0001); hNhf[i]->Sumw2(); sprintf(name,"JetPhf%d",i); hPhf[i] = new TH1F(name,name,100,0,1.0001); hPhf[i]->Sumw2(); sprintf(name,"JetMuf%d",i); hMuf[i] = new TH1F(name,name,100,0,1.0001); hMuf[i]->Sumw2(); sprintf(name,"JetElf%d",i); hElf[i] = new TH1F(name,name,100,0,1.0001); hElf[i]->Sumw2(); } hBDT->Sumw2(); hMLP->Sumw2(); hMLP_demo->Sumw2(); hMLP_JESlo->Sumw2(); hMLP_JESup->Sumw2(); hCos->Sumw2(); hHT->Sumw2(); hHT_JESlo->Sumw2(); hHT_JESup->Sumw2(); hM8J->Sumw2(); hM4J->Sumw2(); hHT4J->Sumw2(); hPT4J->Sumw2(); hEta4J->Sumw2(); hM2J->Sumw2(); hB4J->Sumw2(); hB2J->Sumw2(); hPtAll->Sumw2(); hEtaAll->Sumw2(); hPhiAll->Sumw2(); hBetaAll->Sumw2(); hChfAll->Sumw2(); hNhfAll->Sumw2(); hPhfAll->Sumw2(); hMufAll->Sumw2(); hElfAll->Sumw2(); //----- tree variables ---------------------- float BDT,MLP,BDT_JESlo,MLP_JESlo,BDT_JESup,MLP_JESup,m2jAve,m2jSig,m4jAve,m4jBalance,m8j,ht,cosThetaStar,wt(1.0); float ht4j[2],pt4j[2],eta4j[2]; float pt[8],eta[8],phi[8],beta[8],chf[8],nhf[8],phf[8],muf[8],elf[8],unc[8]; //----- tree branches ----------------------- tr = (TTree*)inf->Get("multijets/events"); tr->SetBranchAddress("BDT",&BDT); tr->SetBranchAddress("MLP",&MLP); tr->SetBranchAddress("MLP_JESlo",&MLP_JESlo); tr->SetBranchAddress("MLP_JESup",&MLP_JESup); tr->SetBranchAddress("ht",&ht); tr->SetBranchAddress("m8j",&m8j); tr->SetBranchAddress("m4jAve",&m4jAve); tr->SetBranchAddress("m4jBalance",&m4jBalance); tr->SetBranchAddress("m2jAve",&m2jAve); tr->SetBranchAddress("m2jSig",&m2jSig); tr->SetBranchAddress("cosThetaStar",&cosThetaStar); tr->SetBranchAddress("ht4j",&ht4j); tr->SetBranchAddress("pt4j",&pt4j); tr->SetBranchAddress("eta4j",&eta4j); tr->SetBranchAddress("pt",&pt); tr->SetBranchAddress("eta",&eta); tr->SetBranchAddress("phi",&phi); tr->SetBranchAddress("beta",&beta); tr->SetBranchAddress("chf",&chf); tr->SetBranchAddress("nhf",&nhf); tr->SetBranchAddress("phf",&phf); tr->SetBranchAddress("muf",&muf); tr->SetBranchAddress("elf",&elf); tr->SetBranchAddress("unc",&unc); if (UseWeights) { tr->SetBranchAddress("wt",&wt); } //----- loop over tree entries ---------------- for(int iev=0;iev<tr->GetEntries();iev++) { tr->GetEntry(iev); bool preselection = (ht > 750 && pt[7] > 30); if (!preselection) continue; hBDT->Fill(BDT,wt); hMLP->Fill(MLP,wt); hMLP_demo->Fill(MLP,wt); hMLP_JESlo->Fill(MLP_JESlo,wt); hMLP_JESup->Fill(MLP_JESup,wt); hHT->Fill(ht,wt); hM8J->Fill(m8j,wt); hM4J->Fill(m4jAve,wt); hM2J->Fill(m2jAve,wt); hHT4J->Fill(ht4j[0],wt); hHT4J->Fill(ht4j[1],wt); hPT4J->Fill(pt4j[0],wt); hPT4J->Fill(pt4j[1],wt); hEta4J->Fill(eta4j[0],wt); hEta4J->Fill(eta4j[1],wt); hCos->Fill(cosThetaStar,wt); hB4J->Fill(m4jBalance,wt); hB2J->Fill(m2jSig/m2jAve,wt); float htlo(0.0),htup(0.0); for(int j=0;j<8;j++) { hPtAll->Fill(pt[j],wt); hPt[j]->Fill(pt[j],wt); hPt_JESlo[j]->Fill((1-unc[j])*pt[j],wt); hPt_JESup[j]->Fill((1+unc[j])*pt[j],wt); htlo += (1-unc[j])*pt[j]; htup += (1+unc[j])*pt[j]; hEtaAll->Fill(eta[j],wt); hEta[j]->Fill(eta[j],wt); hPhiAll->Fill(phi[j],wt); hPhi[j]->Fill(phi[j],wt); hBetaAll->Fill(beta[j],wt); hBeta[j]->Fill(beta[j],wt); hChfAll->Fill(chf[j],wt); hChf[j]->Fill(chf[j],wt); hNhfAll->Fill(nhf[j],wt); hNhf[j]->Fill(nhf[j],wt); hPhfAll->Fill(phf[j],wt); hPhf[j]->Fill(phf[j],wt); hMufAll->Fill(muf[j],wt); hMuf[j]->Fill(muf[j],wt); hElfAll->Fill(elf[j],wt); hElf[j]->Fill(elf[j],wt); }// jet loop hHT_JESlo->Fill(htlo,wt); hHT_JESup->Fill(htup,wt); }// tree loop outf->Write(); }
void cut_eff2() { // TString inputpath = "/afs/cern.ch/work/m/mwang/public/EDBR/trees/productionv1_1130/fullrange/"; TString inputpath = "/afs/cern.ch/work/m/mwang/public/EDBR/trees/productionv1_1206/fullrange/"; TString cut = "btag_eff"; vector<TString> dataSamples; vector<TString> bkgSamples; vector<TString> sigSamples; /* dataSamples.push_back("data_xwh"); bkgSamples.push_back("TTBARpowheg_xwh"); bkgSamples.push_back("VV_xwh"); bkgSamples.push_back("WJetsPt180_xwh"); bkgSamples.push_back("DYJets_xwh"); bkgSamples.push_back("SingleTop_xwh"); sigSamples.push_back("MWp_1000_gg_xwh"); sigSamples.push_back("MWp_1500_gg_xwh"); sigSamples.push_back("MWp_2000_gg_xwh"); sigSamples.push_back("MWp_1000_cc_xwh"); sigSamples.push_back("MWp_1500_cc_xwh"); sigSamples.push_back("MWp_2000_cc_xwh"); sigSamples.push_back("MWp_1000_bb_xwh"); sigSamples.push_back("MWp_1500_bb_xwh"); sigSamples.push_back("MWp_2000_bb_xwh"); sigSamples.push_back("MWp_1000_xwh"); sigSamples.push_back("MWp_1500_xwh"); sigSamples.push_back("MWp_2000_xwh"); */ dataSamples.push_back(""); bkgSamples.push_back("TTBARmadgraph_xwh"); bkgSamples.push_back("WJetsPt180_xwh"); sigSamples.push_back("MWp_1000_gg_xwh"); sigSamples.push_back("MWp_1000_cc_xwh"); sigSamples.push_back("MWp_1000_bb_xwh"); sigSamples.push_back("MWp_1000_xwh"); sigSamples.push_back("MWp_1500_gg_xwh"); sigSamples.push_back("MWp_1500_cc_xwh"); sigSamples.push_back("MWp_1500_bb_xwh"); sigSamples.push_back("MWp_1500_xwh"); sigSamples.push_back("MWp_2000_gg_xwh"); sigSamples.push_back("MWp_2000_cc_xwh"); sigSamples.push_back("MWp_2000_bb_xwh"); sigSamples.push_back("MWp_2000_xwh"); int ndata = 0;//dataSamples.size(); int nbkg = bkgSamples.size(); int nsig = sigSamples.size(); cout<<"data samples "<<ndata<<" bkg samples "<<nbkg<<" signal samples "<<nsig<<endl; //TH1F * h1 = new TH1F (cut,cut,ndata+nbkg+nsig+1,0,ndata+nbkg+nsig+1); TH1F * h1 = new TH1F (cut,cut,14 ,0,14);// number of samples //h1->GetYaxis()->SetRangeUser(0,1); h1->SetBit(TH1::kCanRebin); h1->SetStats(0); gStyle->SetPaintTextFormat("1.4f"); //h1->Sumw2(); TH1F *h2 = (TH1F*)h1->Clone(cut+"_2"); TH1F *h3 = (TH1F*)h1->Clone(cut+"_3"); TH1F *h4 = (TH1F*)h1->Clone(cut+"_4"); TH1F *h5 = (TH1F*)h1->Clone(cut+"_5"); TH1F *h6 = (TH1F*)h1->Clone(cut+"_6"); TH1F *h7 = (TH1F*)h1->Clone(cut+"_7"); TH1F *h8 = (TH1F*)h1->Clone(cut+"_8"); TH1F *h9 = (TH1F*)h1->Clone(cut+"_9"); TH1F *h10 = (TH1F*)h1->Clone(cut+"_10"); TH1F *h11 = (TH1F*)h1->Clone(cut+"_11"); TH1F *h12 = (TH1F*)h1->Clone(cut+"_12"); TH1F *h13 = (TH1F*)h1->Clone(cut+"_13"); TH1F *h14 = (TH1F*)h1->Clone(cut+"_14"); TH1F *h15 = (TH1F*)h1->Clone(cut+"_15"); TH1F *h16 = (TH1F*)h1->Clone(cut+"_16"); TH1F *h17 = (TH1F*)h1->Clone(cut+"_17"); TH1F *h18 = (TH1F*)h1->Clone(cut+"_18"); TCanvas * c1 = new TCanvas(); for(int i =0; i<ndata+nbkg+nsig; i++ ) { TString filename; TString samplename; if(i<ndata) { filename = "treeEDBR_"+dataSamples.at(i)+".root"; samplename = dataSamples.at(i);//data_xwh samplename.Remove(samplename.Length()-4,4);//data //samplename.Remove(0,12);//2012A_13Jul2012 } else if(i>=ndata&&i<(ndata+nbkg)) { filename = "treeEDBR_"+bkgSamples.at(i-ndata)+".root"; samplename = bkgSamples.at(i-ndata);//TTBAR_xwh samplename.Remove(samplename.Length()-4,4);//TTBAR } else if(i>=(ndata+nbkg)) { filename = "treeEDBR_"+sigSamples.at(i-ndata-nbkg)+".root"; samplename = sigSamples.at(i-ndata-nbkg);//MWp_1000_gg_xwh //RSG_WW_lvjj_c0p2_M1500_xww,BulkG_WW_lvjj_c1p0_M1500_xww samplename.Remove(samplename.Length()-4,4);//MWp_1000_gg // RSG_WW_lvjj_c0p2_M1500,BulkG_WW_lvjj_c1p0_M1500 if(samplename.Contains("RSG"))samplename.Remove(4,8);//RSG_c0p2_M1500 if(samplename.Contains("BulkG"))samplename.Remove(6,8);//BulkG_c1p0_M1500 } cout<<filename<<endl; cout<<samplename<<endl; TFile *fp = new TFile(inputpath+"/"+filename); TTree * tree = (TTree *) fp->Get("SelectedCandidates"); int entries = tree->GetEntries(); cout<<"entries: "<<entries<<endl; double pass1=0; double pass2=0; double pass3=0; double pass4=0; double pass5=0; double pass6=0; double pass7=0; double pass8=0; double pass9=0; double pass10=0; double pass11=0; double pass12=0; double pass13=0; double pass14=0; double pass15=0; double pass16=0; double pass17=0; double pass18=0; double total=0; int nLooseEle; int nLooseMu; float nsubjetbtagL[99]; float nsubjetbtagM[99]; float nsubjetbtagT[99]; float nfatjetbtagL[99]; float nfatjetbtagM[99]; float nfatjetbtagT[99]; //to make cuts double met; double ptlep1[99]; double ptZll[99]; double ptZjj[99]; double lep[99]; int nCands; int nXjets[99]; double region[99]; // event weight double weight=-1; tree->SetBranchAddress("nLooseMu", &nLooseMu); tree->SetBranchAddress("nLooseEle",&nLooseEle); tree->SetBranchAddress("nsubjetbtagL",nsubjetbtagL); tree->SetBranchAddress("nsubjetbtagM",nsubjetbtagM); tree->SetBranchAddress("nsubjetbtagT",nsubjetbtagT); tree->SetBranchAddress("nfatjetbtagL",nfatjetbtagL); tree->SetBranchAddress("nfatjetbtagM",nfatjetbtagM); tree->SetBranchAddress("nfatjetbtagT",nfatjetbtagT); tree->SetBranchAddress("ptlep1", ptlep1); tree->SetBranchAddress("ptZll", ptZll); tree->SetBranchAddress("ptZjj", ptZjj); tree->SetBranchAddress("met", &met); tree->SetBranchAddress("nXjets", nXjets); tree->SetBranchAddress("lep", lep); tree->SetBranchAddress("nCands", &nCands); tree->SetBranchAddress("region", ®ion); tree->SetBranchAddress("weight", &weight); bool filled = 0; for(int j=0;j<entries;j++) { tree->GetEntry(j); //per event weight double actualWeight = weight*19538.85; if(i<ndata) actualWeight =1; //for data //cout<<actualWeight<<endl; filled = 0; //if(nCands==0)continue; for(int ivec=0;ivec<nCands;ivec++){ if(filled==0) { //cout<<nXjets[ivec]<<endl; //make cuts if((nLooseEle+nLooseMu)!=1)continue; //if(met<80)continue; if(lep[ivec]!=1.)continue;//mu if(nXjets[ivec]!=1)continue; if(region[ivec]!=1)continue; total = total + actualWeight; if(nsubjetbtagL[ivec]>=1&&nfatjetbtagL[ivec]>=1)pass1=pass1+actualWeight; if(nsubjetbtagM[ivec]>=1&&nfatjetbtagL[ivec]>=1)pass2=pass2+actualWeight; if(nsubjetbtagT[ivec]>=1&&nfatjetbtagL[ivec]>=1)pass3=pass3+actualWeight; if(nsubjetbtagL[ivec]>=2&&nfatjetbtagL[ivec]>=1)pass4=pass4+actualWeight; if(nsubjetbtagM[ivec]>=2&&nfatjetbtagL[ivec]>=1)pass5=pass5+actualWeight; if(nsubjetbtagT[ivec]>=2&&nfatjetbtagL[ivec]>=1)pass6=pass6+actualWeight; if(nsubjetbtagL[ivec]>=1&&nfatjetbtagM[ivec]>=1)pass7=pass7+actualWeight; if(nsubjetbtagM[ivec]>=1&&nfatjetbtagM[ivec]>=1)pass8=pass8+actualWeight; if(nsubjetbtagT[ivec]>=1&&nfatjetbtagM[ivec]>=1)pass9=pass9+actualWeight; if(nsubjetbtagL[ivec]>=2&&nfatjetbtagM[ivec]>=1)pass10=pass10+actualWeight; if(nsubjetbtagM[ivec]>=2&&nfatjetbtagM[ivec]>=1)pass11=pass11+actualWeight; if(nsubjetbtagT[ivec]>=2&&nfatjetbtagM[ivec]>=1)pass12=pass12+actualWeight; if(nsubjetbtagL[ivec]>=1&&nfatjetbtagT[ivec]>=1)pass13=pass13+actualWeight; if(nsubjetbtagM[ivec]>=1&&nfatjetbtagT[ivec]>=1)pass14=pass14+actualWeight; if(nsubjetbtagT[ivec]>=1&&nfatjetbtagT[ivec]>=1)pass15=pass15+actualWeight; if(nsubjetbtagL[ivec]>=2&&nfatjetbtagT[ivec]>=1)pass16=pass16+actualWeight; if(nsubjetbtagM[ivec]>=2&&nfatjetbtagT[ivec]>=1)pass17=pass17+actualWeight; if(nsubjetbtagT[ivec]>=2&&nfatjetbtagT[ivec]>=1)pass18=pass18+actualWeight; filled =1; } }//end of candidates loop }//end of tree loop double eff1=0; double eff2=0; double eff3=0; double eff4=0; double eff5=0; double eff6=0; double eff7=0; double eff8=0; double eff9=0; double eff10=0; double eff11=0; double eff12=0; double eff13=0; double eff14=0; double eff15=0; double eff16=0; double eff17=0; double eff18=0; if(total!=0) { eff1 = (double)pass1/(double)total; eff2 = (double)pass2/(double)total; eff3 = (double)pass3/(double)total; eff4 = (double)pass4/(double)total; eff5 = (double)pass5/(double)total; eff6 = (double)pass6/(double)total; eff7 = (double)pass7/(double)total; eff8 = (double)pass8/(double)total; eff9 = (double)pass9/(double)total; eff10 = (double)pass10/(double)total; eff11 = (double)pass11/(double)total; eff12 = (double)pass12/(double)total; eff13 = (double)pass13/(double)total; eff14 = (double)pass14/(double)total; eff15 = (double)pass15/(double)total; eff16 = (double)pass16/(double)total; eff17 = (double)pass17/(double)total; eff18 = (double)pass18/(double)total; } cout<<"total: "<<total<<" pass1: "<<pass1<<" eff: "<<eff1<<endl; cout<<"total: "<<total<<" pass2: "<<pass2<<" eff: "<<eff2<<endl; cout<<"total: "<<total<<" pass3: "<<pass3<<" eff: "<<eff3<<endl; cout<<"total: "<<total<<" pass4: "<<pass4<<" eff: "<<eff4<<endl; cout<<"total: "<<total<<" pass5: "<<pass5<<" eff: "<<eff5<<endl; cout<<"total: "<<total<<" pass6: "<<pass6<<" eff: "<<eff6<<endl; cout<<"total: "<<total<<" pass7: "<<pass7<<" eff: "<<eff7<<endl; cout<<"total: "<<total<<" pass8: "<<pass8<<" eff: "<<eff8<<endl; cout<<"total: "<<total<<" pass9: "<<pass9<<" eff: "<<eff9<<endl; cout<<"total: "<<total<<" pass10: "<<pass10<<" eff: "<<eff10<<endl; cout<<"total: "<<total<<" pass11: "<<pass11<<" eff: "<<eff11<<endl; cout<<"total: "<<total<<" pass12: "<<pass12<<" eff: "<<eff12<<endl; cout<<"total: "<<total<<" pass13: "<<pass13<<" eff: "<<eff13<<endl; cout<<"total: "<<total<<" pass14: "<<pass14<<" eff: "<<eff14<<endl; cout<<"total: "<<total<<" pass15: "<<pass15<<" eff: "<<eff15<<endl; cout<<"total: "<<total<<" pass16: "<<pass16<<" eff: "<<eff16<<endl; cout<<"total: "<<total<<" pass17: "<<pass17<<" eff: "<<eff17<<endl; cout<<"total: "<<total<<" pass18: "<<pass18<<" eff: "<<eff18<<endl; h1->Fill(samplename,eff1); h2->Fill(samplename,eff2); h3->Fill(samplename,eff3); h4->Fill(samplename,eff4); h5->Fill(samplename,eff5); h6->Fill(samplename,eff6); h7->Fill(samplename,eff7); h8->Fill(samplename,eff8); h9->Fill(samplename,eff9); h10->Fill(samplename,eff10); h11->Fill(samplename,eff11); h12->Fill(samplename,eff12); h13->Fill(samplename,eff13); h14->Fill(samplename,eff14); h15->Fill(samplename,eff15); h16->Fill(samplename,eff16); h17->Fill(samplename,eff17); h18->Fill(samplename,eff18); }//end of sample loop c1->SetGridy(1); h1->SetTitle(cut+"_subL1fatL1"); h1->Draw(); h1->Draw("TEXT0same"); c1->SaveAs(cut+"_subL1fatL1.png"); h2->SetTitle(cut+"_subM1fatL1"); h2->Draw(); h2->Draw("TEXT0same"); c1->SaveAs(cut+"_subM1fatL1.png"); h3->SetTitle(cut+"_subT1fatL1"); h3->Draw(); h3->Draw("TEXT0same"); c1->SaveAs(cut+"_subT1fatL1.png"); h4->SetTitle(cut+"_subL2fatL1"); h4->Draw(); h4->Draw("TEXT0same"); c1->SaveAs(cut+"_subL2fatL1.png"); h5->SetTitle(cut+"_subM2fatL1"); h5->Draw(); h5->Draw("TEXT0same"); c1->SaveAs(cut+"_subM2fatL1.png"); h6->SetTitle(cut+"_subT2fatL1"); h6->Draw(); h6->Draw("TEXT0same"); c1->SaveAs(cut+"_subT2fatL1.png"); h7->SetTitle(cut+"_subL1fatM1"); h7->Draw(); h7->Draw("TEXT0same"); c1->SaveAs(cut+"_subL1fatM1.png"); h8->SetTitle(cut+"_subM1fatM1"); h8->Draw(); h8->Draw("TEXT0same"); c1->SaveAs(cut+"_subM1fatM1.png"); h9->SetTitle(cut+"_subT1fatM1"); h9->Draw(); h9->Draw("TEXT0same"); c1->SaveAs(cut+"_subT1fatM1.png"); h10->SetTitle(cut+"_subL2fatM1"); h10->Draw(); h10->Draw("TEXT0same"); c1->SaveAs(cut+"_subL2fatM1.png"); h11->SetTitle(cut+"_subM2fatM1"); h11->Draw(); h11->Draw("TEXT0same"); c1->SaveAs(cut+"_subM2fatM1.png"); h12->SetTitle(cut+"_subT2fatM1"); h12->Draw(); h12->Draw("TEXT0same"); c1->SaveAs(cut+"_subT2fatM1.png"); h13->SetTitle(cut+"_subL1fatT1"); h13->Draw(); h13->Draw("TEXT0same"); c1->SaveAs(cut+"_subL1fatT1.png"); h14->SetTitle(cut+"_subM1fatT1"); h14->Draw(); h14->Draw("TEXT0same"); c1->SaveAs(cut+"_subM1fatT1.png"); h15->SetTitle(cut+"_subT1fatT1"); h15->Draw(); h15->Draw("TEXT0same"); c1->SaveAs(cut+"_subT1fatT1.png"); h16->SetTitle(cut+"_subL2fatT1"); h16->Draw(); h16->Draw("TEXT0same"); c1->SaveAs(cut+"_subL2fatT1.png"); h17->SetTitle(cut+"_subM2fatT1"); h17->Draw(); h17->Draw("TEXT0same"); c1->SaveAs(cut+"_subM2fatT1.png"); h18->SetTitle(cut+"_subT2fatT1"); h18->Draw(); h18->Draw("TEXT0same"); c1->SaveAs(cut+"_subT2fatT1.png"); }
void selectProbesEleEff(const TString infilename, // input ntuple const TString outputDir, // output directory const Int_t effType, // type of efficiency to compute const Bool_t doGenMatch = kFALSE, // match to generator leptons const Bool_t doWeighted = kFALSE, // store events with weights const UInt_t desiredrunNum = 0 // select a specific run (0 for all runs) ) { gBenchmark->Start("selectProbesEleEff"); //-------------------------------------------------------------------------------------------------------------- // Settings //============================================================================================================== const Double_t TAG_PT_CUT = 25; //-------------------------------------------------------------------------------------------------------------- // Main analysis code //============================================================================================================== enum { eHLTEff, eL1Eff, eSelEff, eGsfEff, eGsfSelEff, eSCEff, eIDEff, eIsoEff }; // efficiency type enum if(effType > eIsoEff) { cout << "Invalid effType option! Exiting..." << endl; return; } enum { eEleEle2HLT=1, eEleEle1HLT1L1, eEleEle1HLT, eEleEleNoSel, eEleSC, eTrkSC, eTrkNoSC, eEleIso, eEleNoIso }; // event category enum Double_t nProbes = 0; // // Set up output ntuple // gSystem->mkdir(outputDir,kTRUE); TFile *outFile = new TFile(outputDir+TString("/probes.root"),"RECREATE"); TTree *outTree = new TTree("Events","Events"); //EffData data; //outTree->Branch("Events",&data.mass,"mass/F:pt:eta:phi:weight:q/I:npv/i:npu:pass:runNum:lumiSec:evtNum"); Float_t mass, pt, eta, phi; Double_t weight; Int_t q; UInt_t npv, npu, passes, runNum, lumiSec, evtNum; outTree->Branch("mass", &mass, "mass/F"); outTree->Branch("pt", &pt, "pt/F"); outTree->Branch("eta", &eta, "eta/F"); outTree->Branch("phi", &phi, "phi/F"); outTree->Branch("weight", &weight, "weight/D"); outTree->Branch("q", &q, "q/I"); outTree->Branch("npv", &npv, "npv/i"); outTree->Branch("npu", &npu, "npu/i"); outTree->Branch("pass", &passes, "pass/i"); outTree->Branch("runNum", &runNum, "runNum/i"); outTree->Branch("lumiSec",&lumiSec,"lumiSec/i"); outTree->Branch("evtNum", &evtNum, "evtNum/i"); // // Declare input ntuple variables // //UInt_t runNum, lumiSec, evtNum; UInt_t matchGen, matchGenSCEff; UInt_t category; //UInt_t npv, npu; Float_t scale1fb; Float_t genWeight, PUWeight; Float_t met, metPhi, sumEt, u1, u2; Int_t q1, q2; TLorentzVector *dilep=0, *lep1=0, *lep2=0; TLorentzVector *sc1=0, *sc2=0; // Read input file and get the TTrees cout << "Processing " << infilename << "..." << endl; TFile *infile = new TFile(infilename); assert(infile); TTree *intree = (TTree*)infile->Get("Events"); assert(intree); intree->SetBranchAddress("runNum", &runNum); // event run number intree->SetBranchAddress("lumiSec", &lumiSec); // event lumi section intree->SetBranchAddress("evtNum", &evtNum); // event number intree->SetBranchAddress("matchGen", &matchGen); // event has both leptons matched to MC Z->ll if(effType==eSCEff) intree->SetBranchAddress("matchGenSCEff", &matchGenSCEff); intree->SetBranchAddress("category", &category); // dilepton category intree->SetBranchAddress("npv", &npv); // number of primary vertices intree->SetBranchAddress("npu", &npu); // number of in-time PU events (MC) intree->SetBranchAddress("genWeight", &genWeight); intree->SetBranchAddress("PUWeight", &PUWeight); intree->SetBranchAddress("scale1fb", &scale1fb); // event weight per 1/fb (MC) intree->SetBranchAddress("met", &met); // MET intree->SetBranchAddress("metPhi", &metPhi); // phi(MET) intree->SetBranchAddress("sumEt", &sumEt); // Sum ET intree->SetBranchAddress("u1", &u1); // parallel component of recoil intree->SetBranchAddress("u2", &u2); // perpendicular component of recoil intree->SetBranchAddress("q1", &q1); // charge of tag lepton intree->SetBranchAddress("q2", &q2); // charge of probe lepton intree->SetBranchAddress("dilep", &dilep); // dilepton 4-vector intree->SetBranchAddress("lep1", &lep1); // tag lepton 4-vector intree->SetBranchAddress("lep2", &lep2); // probe lepton 4-vector intree->SetBranchAddress("sc1", &sc1); // tag Supercluster 4-vector intree->SetBranchAddress("sc2", &sc2); // probe Supercluster 4-vector // // loop over events // for(UInt_t ientry=0; ientry<intree->GetEntries(); ientry++) { //for(UInt_t ientry=0; ientry<15; ientry++) { intree->GetEntry(ientry); if(desiredrunNum!=0 && runNum!=desiredrunNum) continue; if(lep1->Pt() < TAG_PT_CUT) continue; // check GEN match if necessary if(effType==eSCEff) { if(doGenMatch && !matchGenSCEff) continue; } else { if(doGenMatch && !matchGen) continue; } Bool_t pass=kFALSE; if(effType==eHLTEff) { // // probe = electron passing selection // pass = matched to HLT // * EleEle2HLT event means a passing probe, EleEle1HLT(1L1) event means a failing probe // all other categories do not satisfy probe requirements // if (category==eEleEle2HLT) { pass=kTRUE; } else if(category==eEleEle1HLT1L1) { pass=kFALSE; } else if(category==eEleEle1HLT) { pass=kFALSE; } else if(category==eEleEleNoSel) { continue; } else { continue; } } else if(effType==eL1Eff) { // // probe = electron passing selection // pass = matched to L1 // * EleEle2HLT, EleEle1HLT1L1 event means a passing probe, EleEle1HLT event means a failing probe // all other categories do not satisfy probe requirements // if (category==eEleEle2HLT) { pass=kTRUE; } else if(category==eEleEle1HLT1L1) { pass=kTRUE; } else if(category==eEleEle1HLT) { pass=kFALSE; } else if(category==eEleEleNoSel) { continue; } else { continue; } } else if(effType==eSelEff) { // // probe = electron // pass = passing selection // * EleEle2HLT, EleEle1HLT(1L1) event means a passing probe, EleEleNoSel event means a failing probe, // EleSC event does not satisfy probe requirements // if (category==eEleEle2HLT) { pass=kTRUE; } else if(category==eEleEle1HLT1L1) { pass=kTRUE; } else if(category==eEleEle1HLT) { pass=kTRUE; } else if(category==eEleEleNoSel) { pass=kFALSE; } else { continue; } } else if(effType==eIDEff) { // // probe = electron // pass = passing selection without isolation requirement // * EleIso, EleNoIso event means a passing probe, EleEleNoSel event means a failing probe, // EleSC event does not satisfy probe requirements // if (category==eEleIso) { pass=kTRUE; } else if(category==eEleNoIso) { pass=kTRUE; } else if(category==eEleEleNoSel) { pass=kFALSE; } else { continue; } } else if(effType==eIsoEff) { // // probe = electron passing selection without the isolation requirement // pass = passing the isolation requirement // * EleIso event means a passing probe, EleNoIso event means a failing probe, // EleEleNoSel, EleSC event does not satisfy probe requirements // if (category==eEleIso) { pass=kTRUE; } else if(category==eEleNoIso) { pass=kFALSE; } else { continue; } } else if(effType==eGsfEff) { // // probe = supercluster // pass = passing selection // * EleEle2HLT, EleEle1HLT(1L1), EleEleNoSel event means a passing probe, // EleSC event means a failing probe // if (category==eEleEle2HLT) { pass=kTRUE; } else if(category==eEleEle1HLT1L1) { pass=kTRUE; } else if(category==eEleEle1HLT) { pass=kTRUE; } else if(category==eEleEleNoSel) { pass=kTRUE; } else { pass=kFALSE; } } else if(effType==eGsfSelEff) { // // probe = supercluster // pass = passing selection // * EleEle2HLT, EleEle1HLT(1L1), EleEleNoSel event means a passing probe, // EleSC event means a failing probe // if (category==eEleEle2HLT) { pass=kTRUE; } else if(category==eEleEle1HLT1L1) { pass=kTRUE; } else if(category==eEleEle1HLT) { pass=kTRUE; } else if(category==eEleEleNoSel) { pass=kFALSE; } else { pass=kFALSE; } } else if(effType==eSCEff) { // // probe = supercluster // pass = passing selection // * EleEle2HLT, EleEle1HLT(1L1), EleEleNoSel event means a passing probe, // EleSC event means a failing probe // if (category==eTrkSC) { pass=kTRUE; } else if(category==eTrkNoSC) { pass=kFALSE; } else { continue; } } nProbes += doWeighted ? genWeight*PUWeight/std::abs(genWeight) : 1; // Fill tree mass = dilep->M(); pt = (effType==eGsfSelEff && !pass) ? sc2->Pt() : lep2->Pt(); eta = (effType==eGsfSelEff && !pass) ? sc2->Eta() : lep2->Eta(); phi = (effType==eGsfSelEff && !pass) ? sc2->Phi() : lep2->Phi(); weight = doWeighted ? genWeight*PUWeight/std::abs(genWeight) : 1; q = q2; npv = npv; npu = npu; passes = (pass) ? 1 : 0; runNum = runNum; lumiSec = lumiSec; evtNum = evtNum; outTree->Fill(); if(category==eEleEle2HLT) { if(lep2->Pt() < TAG_PT_CUT) continue; nProbes += doWeighted ? genWeight*PUWeight/std::abs(genWeight) : 1; mass = dilep->M(); pt = lep1->Pt(); eta = lep1->Eta(); phi = (effType==eGsfEff) ? sc1->Phi() : lep1->Phi(); weight = doWeighted ? genWeight*PUWeight/std::abs(genWeight) : 1; q = q1; npv = npv; npu = npu; passes = 1; runNum = runNum; lumiSec = lumiSec; evtNum = evtNum; outTree->Fill(); } } delete infile; infile=0, intree=0; //-------------------------------------------------------------------------------------------------------------- // Output //============================================================================================================== cout << "*" << endl; cout << "* SUMMARY" << endl; cout << "*--------------------------------------------------" << endl; cout << endl; cout << " Number of probes selected: " << nProbes << endl; outFile->Write(); outFile->Close(); delete outFile; cout << endl; cout << " <> Output saved in " << outputDir << "/" << endl; cout << endl; gBenchmark->Show("selectProbesEleEff"); }
void TMVARegressionApplication( TString myMethodList = "" ) { //--------------------------------------------------------------- // This loads the library TMVA::Tools::Instance(); // Default MVA methods to be trained + tested std::map<std::string,int> Use; // --- Mutidimensional likelihood and Nearest-Neighbour methods Use["PDERS"] = 0; Use["PDEFoam"] = 1; Use["KNN"] = 1; // // --- Linear Discriminant Analysis Use["LD"] = 1; // // --- Function Discriminant analysis Use["FDA_GA"] = 1; Use["FDA_MC"] = 0; Use["FDA_MT"] = 0; Use["FDA_GAMT"] = 0; // // --- Neural Network Use["MLP"] = 1; // // --- Support Vector Machine Use["SVM"] = 0; // // --- Boosted Decision Trees Use["BDT"] = 0; Use["BDTG"] = 1; // --------------------------------------------------------------- std::cout << std::endl; std::cout << "==> Start TMVARegressionApplication" << std::endl; // Select methods (don't look at this code - not of interest) if (myMethodList != "") { for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0; std::vector<TString> mlist = gTools().SplitString( myMethodList, ',' ); for (UInt_t i=0; i<mlist.size(); i++) { std::string regMethod(mlist[i]); if (Use.find(regMethod) == Use.end()) { std::cout << "Method \"" << regMethod << "\" not known in TMVA under this name. Choose among the following:" << std::endl; for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) std::cout << it->first << " "; std::cout << std::endl; return; } Use[regMethod] = 1; } } // -------------------------------------------------------------------------------------------------- // --- Create the Reader object TMVA::Reader *reader = new TMVA::Reader( "!Color:!Silent" ); // Create a set of variables and declare them to the reader // - the variable names MUST corresponds in name and type to those given in the weight file(s) used Float_t var1, var2; reader->AddVariable( "var1", &var1 ); reader->AddVariable( "var2", &var2 ); // Spectator variables declared in the training have to be added to the reader, too Float_t spec1,spec2; reader->AddSpectator( "spec1:=var1*2", &spec1 ); reader->AddSpectator( "spec2:=var1*3", &spec2 ); // --- Book the MVA methods TString dir = "weights/"; TString prefix = "TMVARegression"; // Book method(s) for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) { if (it->second) { TString methodName = it->first + " method"; TString weightfile = dir + prefix + "_" + TString(it->first) + ".weights.xml"; reader->BookMVA( methodName, weightfile ); } } // Book output histograms TH1* hists[100]; Int_t nhists = -1; for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) { TH1* h = new TH1F( it->first.c_str(), TString(it->first) + " method", 100, -100, 600 ); if (it->second) hists[++nhists] = h; } nhists++; // Prepare input tree (this must be replaced by your data source) // in this example, there is a toy tree with signal and one with background events // we'll later on use only the "signal" events for the test in this example. // TFile *input(0); TString fname = "./tmva_reg_example.root"; if (!gSystem->AccessPathName( fname )) { input = TFile::Open( fname ); // check if file in local directory exists } else { input = TFile::Open( "http://root.cern.ch/files/tmva_reg_example.root" ); // if not: download from ROOT server } if (!input) { std::cout << "ERROR: could not open data file" << std::endl; exit(1); } std::cout << "--- TMVARegressionApp : Using input file: " << input->GetName() << std::endl; // --- Event loop // Prepare the tree // - here the variable names have to corresponds to your tree // - you can use the same variables as above which is slightly faster, // but of course you can use different ones and copy the values inside the event loop // TTree* theTree = (TTree*)input->Get("TreeR"); std::cout << "--- Select signal sample" << std::endl; theTree->SetBranchAddress( "var1", &var1 ); theTree->SetBranchAddress( "var2", &var2 ); std::cout << "--- Processing: " << theTree->GetEntries() << " events" << std::endl; TStopwatch sw; sw.Start(); for (Long64_t ievt=0; ievt<theTree->GetEntries();ievt++) { if (ievt%1000 == 0) { std::cout << "--- ... Processing event: " << ievt << std::endl; } theTree->GetEntry(ievt); // Retrieve the MVA target values (regression outputs) and fill into histograms // NOTE: EvaluateRegression(..) returns a vector for multi-target regression for (Int_t ih=0; ih<nhists; ih++) { TString title = hists[ih]->GetTitle(); Float_t val = (reader->EvaluateRegression( title ))[0]; hists[ih]->Fill( val ); } } sw.Stop(); std::cout << "--- End of event loop: "; sw.Print(); // --- Write histograms TFile *target = new TFile( "TMVARegApp.root","RECREATE" ); for (Int_t ih=0; ih<nhists; ih++) hists[ih]->Write(); target->Close(); std::cout << "--- Created root file: \"" << target->GetName() << "\" containing the MVA output histograms" << std::endl; delete reader; std::cout << "==> TMVARegressionApplication is done!" << std::endl << std::endl; }
void LYZ::calcv(TString res, int way, int isample){ //way=0: product way=1: sum TComplex g0[ntheta], dDsum[ntheta], dNsum[ntheta][nvv]; TVectorD* r0res[nbin]; //TVectorD* Vres[nbin]; TVectorD* chires[nbin]; TFile *fres = TFile::Open(res); for(int ibin=0;ibin<nbin;ibin++){ if(isample>=0) r0res[ibin] = (TVectorD*)fres->Get(Form("s_%d/D_%d/r0",isample,ibin)); else if(isample==-1) r0res[ibin] = (TVectorD*)fres->Get(Form("D_%d/r0",ibin)); else r0res[ibin] = (TVectorD*)fres->Get(Form("D_%d/r02",ibin)); } int mult, ntrk; Float_t phi[10000], eta[10000], pt[10000]; TFile *infile = TFile::Open(filename); TTree* t = (TTree*)infile->Get("tree"); t->SetBranchAddress("n",&mult); t->SetBranchAddress("ptg",pt); t->SetBranchAddress("phig",phi); t->SetBranchAddress("etag",eta); int nevent = t->GetEntries(); for(int ievt=0; ievt<nevent; ievt++){ t->GetEntry(ievt); // if(ievt%100==0) cout<<"has processed "<<ievt<<" events"<<endl; for(int ivbin=0; ivbin<nvv;ivbin++) for(int itheta=0;itheta<ntheta;itheta++) dNsum[itheta][ivbin]=0.; for(int itheta=0;itheta<ntheta;itheta++){ if(way==0) g0[itheta]=1.; else g0[itheta]=0.; dDsum[itheta]=0.; } ntrk = mult; int nTracks = ntrk; int xbin=-1; for(int j=0;j<nbin;j++) if(nTracks<trkbin[j]&&nTracks>=trkbin[j+1]) xbin=j; if(xbin<0 || xbin == nbin) continue; tottrk[xbin]+=ntrk; for(int imult=0;imult<mult;imult++){ if(eta[imult]<-2.40||eta[imult]>2.40) continue; if(pt[imult]<ptmin||pt[imult]>ptmax) continue; //event selection int xv=-1; for(int ivbin=0;ivbin<nvv; ivbin++){ if(ispt && pt[imult]>binv[ivbin] && pt[imult]<=binv[ivbin+1]) xv = ivbin; if((!ispt) && eta[imult]>binv[ivbin] && eta[imult]<=binv[ivbin+1]) xv = ivbin; } if(xv<0 || xv==nvv) continue; totptv[xbin][xv]+=pt[imult]; totetav[xbin][xv]+=eta[imult]; totmultv[xbin][xv]++; for(int itheta=0;itheta<ntheta;itheta++){ Double_t temp=TMath::Cos(nn*(phi[imult]-theta[itheta])); TComplex temp1(1.,(*r0res[xbin])[itheta]*temp); if(way==0) g0[itheta]*=temp1; else g0[itheta]+=temp; dDsum[itheta]+=temp/temp1; dNsum[itheta][xv]+=TMath::Cos(mm*nn*(phi[imult]-theta[itheta]))/temp1; } totmultall[xbin]++; } for(int itheta=0;itheta<ntheta;itheta++){ dDRe[xbin][itheta]+=(g0[itheta]*dDsum[itheta]).Re(); dDIm[xbin][itheta]+=(g0[itheta]*dDsum[itheta]).Im(); for(int ivbin=0;ivbin<nvv; ivbin++){ dNRe[xbin][itheta][ivbin]+=(g0[itheta]*dNsum[itheta][ivbin]).Re(); dNIm[xbin][itheta][ivbin]+=(g0[itheta]*dNsum[itheta][ivbin]).Im(); } } Nevent[xbin]++; } fres->Close(); infile->Close(); }
void Fitting(){ TString RootFile_Name; TString Target, Arm; gSystem->Exec("ls -l *.root"); cerr<<" --- Target (H2,He3,He4) = "; cin >> Target; cerr<<" --- Arm (L, R) = "; cin >> Arm; RootFile_Name = Form("%s_Yield_%s_All.root",Target.Data(),Arm.Data()); TFile *f1 = new TFile(RootFile_Name.Data(),"r"); TTree *T = (TTree*) gDirectory->Get("T"); TString OutFile_Name = RootFile_Name; OutFile_Name.ReplaceAll(".root",".out"); ofstream outfile(OutFile_Name); TString File_Name1 = RootFile_Name; TString File_Name2 = RootFile_Name; TString File_Name3 = RootFile_Name; TString File_Name4 = RootFile_Name; File_Name1.ReplaceAll(".root",".png"); File_Name2.ReplaceAll(".root",".pdf"); File_Name3.ReplaceAll(".root","_0.png"); File_Name4.ReplaceAll(".root","_0.pdf"); double VZ, I, Y, Y_Err; int size, runno, Bin; T->SetBranchAddress("runsize",&size); T->SetBranchAddress("Bin",&Bin); T->SetBranchAddress("RunNo",&runno); T->SetBranchAddress("I",&I); T->SetBranchAddress("Y",&Y); T->SetBranchAddress("Y_Err",&Y_Err); T->SetBranchAddress("VZ",&VZ); int N = T->GetEntries(); T->GetEntry(0); const int Size = size; int temp=20; if(Target=="C12"||Target=="Ca40"||Target=="Ca48") temp=1; const int Bin_Size = temp; /*Read Root File{{{*/ cerr<<" @@@ Reading Root File ..."<<endl; double vI[Bin_Size][Size]; double vI_Err[Bin_Size][Size]; double vY[Bin_Size][Size]; double vY_Err[Bin_Size][Size]; double vVZ[Bin_Size]; double Y_Max=-1e32,Y_Min=1e32, X_Max=-1000,X_Min=1000; int k=0; for(int j=0;j<Bin_Size; j++){ k=0; for(int i=0;i<N;i++){ T->GetEntry(i); if(Y>-0.5 && Bin==j){ vI[j][k]=I; vI_Err[j][k]=0.; vY[j][k]=Y; vY_Err[j][k]=Y_Err; vVZ[j] = VZ; if(X_Max<vI[j][k]) X_Max = vI[j][k]; if(X_Min>vI[j][k]) X_Min = vI[j][k]; if(Y_Max<vY[j][k]) Y_Max = vY[j][k]; if(Y_Min>vY[j][k]) Y_Min = vY[j][k]; // Y_Max = Y_Max?vY[j][k]:Y_Max<vY[j][k]; // Y_Min = Y_Min?vY[j][k]:Y_Min>vY[j][k]; // X_Max = X_Max?vI[j][k]:X_Max<vI[j][k]; // X_Min = X_Min?vI[j][k]:X_Min>vI[j][k]; cerr<<Form("--- Bin = %d, VZ=%6.4f, I=%6.4f, Y=%e", Bin, VZ, I, Y)<<endl; k++; if(k>Size) cerr<<"*** Something wrong?!"<<endl; } } } /*}}}*/ /*Plot and Fit{{{*/ cerr<<" @@@ Making Plots and Fitting ..."<<endl; cerr<<Form(" ---- X_Min=%f, X_Max=%f, Y_Min=%e, Y_Max=%e",X_Min,X_Max, Y_Min, Y_Max)<<endl; TCanvas *c3 = new TCanvas("c3","c3",1200,700); c3->cd(); TH2F *h3 = new TH2F("h3","",300,X_Min-2.0,X_Max+2.0,300,0.0,Y_Max/Y_Min*1.12); h3->SetStats(kFALSE); h3->SetXTitle("I (uA)"); h3->GetXaxis()->CenterTitle(1); h3->GetXaxis()->SetTitleFont(32); h3->GetXaxis()->SetTitleSize(0.06); h3->GetYaxis()->SetTitleOffset(0.8); h3->SetYTitle("Yield_{normalized}"); h3->GetYaxis()->CenterTitle(1); h3->GetYaxis()->SetTitleFont(32); h3->GetYaxis()->SetTitleSize(0.06); h3->GetYaxis()->SetTitleOffset(0.8); gStyle->SetOptStat(1); gStyle->SetOptFit(1); double S[Bin_Size],S_Err[Bin_Size]; double Y0[Bin_Size],Y0_Err[Bin_Size]; double BF[Bin_Size],BF_Err[Bin_Size]; double Zero[Bin_Size]; for(int l=0; l<Bin_Size; l++){ for(int m=0; m<Size; m++){ vY[l][m]/=Y_Min; vY_Err[l][m]/=Y_Min; } } TLatex *tex; outfile<<Form("%12s %12s %12s %12s %12s", "VZ","Y0","Y0_Err","BF","BF_Err")<<endl; Y_Max=-1e32,Y_Min=1e32; for(int l=0; l<Bin_Size; l++){ h3->Draw(); for(int m=0;m<Size;m++) cerr<<Form(" VZ=%6.4f, I = %6.3f, Y = %e", vVZ[l], vI[l][m],vY[l][m])<<endl; TGraphErrors *ex = new TGraphErrors(Size, vI[l], vY[l], vI_Err[l], vY_Err[l]); ex->SetMarkerStyle(25); ex->SetMarkerColor(4); ex->SetLineColor(4); ex->Draw("P"); ex->Fit("pol1","IM","",X_Min,X_Max); if(l==0){//For C12 only // if(l==30){ tex=new TLatex(0.25, 0.6, Form("%s Boiling Effect Fit at z_{react} = %4.2f cm on HRS-%s",Target.Data(), vVZ[l]*100, Arm.Data())); tex->SetNDC(); tex->SetTextFont(32); tex->SetTextSize(0.05); tex->Draw(); c3->Print(File_Name3.Data()); c3->Print(File_Name4.Data()); } Y0[l] = ex->GetFunction("pol1")->GetParameter(0) ; Y0_Err[l] = ex->GetFunction("pol1")->GetParError(0) ; S[l] = ex->GetFunction("pol1")->GetParameter(1); S_Err[l] = ex->GetFunction("pol1")->GetParError(1); BF[l] = S[l]/Y0[l]; BF_Err[l] = BF[l] * sqrt( pow(Y0_Err[l]/Y0[l],2) + pow(S_Err[l]/S[l],2) ); Zero[l] = 0.0; if(Y_Max<S[l]) Y_Max = S[l]; if(Y_Min>S[l]) Y_Min = S[l]; cerr<<Form(" VZ=%f, Slop=%f",vVZ[l],S[l])<<endl; outfile<<Form(" %12.8f %12.8f %12.8f %12.8f %12.8f",vVZ[l],Y0[l], Y0_Err[l], BF[l],BF_Err[l])<<endl; c3->Clear(); } c3->Close(); TCanvas *c4 = new TCanvas("c4","c4",1200,700); c4->cd(); TH2F *h4 = new TH2F("h4","",300, -0.14, 0.14, 300, -0.011, 0.001); h4->SetStats(kFALSE); h4->SetXTitle("z_{react} (m)"); h4->GetXaxis()->CenterTitle(1); h4->GetXaxis()->SetTitleFont(32); h4->GetXaxis()->SetTitleSize(0.06); h4->GetXaxis()->SetTitleOffset(0.7); h4->SetYTitle("BF"); h4->GetYaxis()->CenterTitle(1); h4->GetYaxis()->SetTitleFont(32); h4->GetYaxis()->SetTitleSize(0.04); h4->GetYaxis()->SetTitleOffset(1.2); h4->Draw(); TGraphErrors *ex1 = new TGraphErrors(Bin_Size, vVZ, BF, Zero, BF_Err); ex1->SetMarkerStyle(20); ex1->SetMarkerColor(4); ex1->SetLineColor(4); ex1->Draw("P"); tex=new TLatex(0.3, 0.2, Form("%s Boiling Effect on HRS-%s",Target.Data(), Arm.Data())); tex->SetNDC(); tex->SetTextFont(32); tex->SetTextSize(0.05); tex->Draw(); c4->Print(File_Name1.Data()); c4->Print(File_Name2.Data()); /*}}}*/ }
// ------------ method called for each event ------------ void LYZ::calcV(int way) //way=0: Prod way=1: Sum { using namespace std; TComplex g[ntheta][nstepr]; double Q[ntheta]; double Qx; double Qy; int mult, ntrk; Float_t phi[10000], eta[10000], pt[10000]; TFile *infile = TFile::Open(filename); TTree* t = (TTree*)infile->Get("tree"); t->SetBranchAddress("n",&mult); t->SetBranchAddress("ptg",pt); t->SetBranchAddress("phig",phi); t->SetBranchAddress("etag",eta); int nevent = t->GetEntries(); for(int ievt=0; ievt<nevent; ievt++){ t->GetEntry(ievt); // if(ievt%10000==0) cout<<"has processed "<<ievt<<" events"<<endl; for(int itheta=0;itheta<ntheta;itheta++){ Q[itheta]=0; for(int ir=0; ir<nstepr; ir++) if(way==0) g[itheta][ir]=1.; else g[itheta][ir]=0.; } Qx=0,Qy=0; ntrk = mult; int nTracks = ntrk; int xbin=-1; for(int j=0;j<nbin;j++) if(nTracks<trkbin[j]&&nTracks>=trkbin[j+1]) xbin=j; if(xbin<0 || xbin==nbin) continue; tottrk[xbin]+=ntrk; for(int imult=0;imult<mult;imult++){ // if(eta[imult]<-2.40||eta[imult]>2.40) continue; // if(pt[imult]<ptmin||pt[imult]>ptmax) continue; //event selection Qx+=1.*cos(nn*phi[imult]); Qy+=1.*sin(nn*phi[imult]); for(int itheta=0;itheta<ntheta;itheta++){ double temp=TMath::Cos(nn*(phi[imult]-theta[itheta])); for(int ir=0; ir<nstepr; ir++) if(way==0){ g[itheta][ir]*=TComplex(1.,r[xbin][ir]*temp); } // else // g[itheta][0]+=temp; } totptall[xbin]+=pt[imult]; totetaall[xbin]+=eta[imult]; totmultall[xbin]++; } Qx1[xbin]+=Qx; Qy1[xbin]+=Qy; Qx2[xbin]+=Qx*Qx; Qy2[xbin]+=Qy*Qy; for(int itheta=0;itheta<ntheta;itheta++){ Q[itheta]=Qx*TMath::Cos(nn*theta[itheta])+Qy*TMath::Sin(nn*theta[itheta]); for(int ir=0; ir<nstepr; ir++){ if(way!=0) g[itheta][ir]=TComplex::Exp(TComplex(0,r[xbin][ir]*Q[itheta]));//g[itheta][0] GRe[xbin][itheta][ir]+=g[itheta][ir].Re(); GIm[xbin][itheta][ir]+=g[itheta][ir].Im(); } } Nevent[xbin]++; } infile->Close(); }
void plotResolution (TString inputFile) { // init tree and basic vars // ---- ---- ---- ---- ---- ---- ---- int fNtowersOnSide = 49 ; float maxEnergy = 1. ; // gev float towerSideLength = 2 ; // mm float totalSideLength = towerSideLength * fNtowersOnSide ; int fNtowersOnSideSQ = fNtowersOnSide * fNtowersOnSide ; float LY = 10000000 ; // photons per GeV float acceptance = 0.1 ; float efficiency = 0.1 ; TFile * f = new TFile (inputFile) ; TTree * t = (TTree *) f->Get ("tree") ; // prepare input variables // ---- ---- ---- ---- ---- ---- ---- double depositedEnergy ; t->Branch ("depositedEnergy", &depositedEnergy, "depositedEnergy/D") ; std::vector<float> * depositedEnergies = new std::vector<float> (fNtowersOnSideSQ) ; t->SetBranchAddress ("depositedEnergies", &depositedEnergies) ; std::vector<float> * totalEnergies = new std::vector<float> (fNtowersOnSideSQ) ; t->SetBranchAddress ("totalEnergies", &totalEnergies) ; std::vector<float> * inputMomentum = new std::vector<float> (4) ; t->SetBranchAddress ("inputMomentum", &inputMomentum) ; std::vector<float> * inputInitialPosition = new std::vector<float> (3) ; t->SetBranchAddress ("inputInitialPosition", &inputInitialPosition) ; // output histograms // ---- ---- ---- ---- ---- ---- ---- // distributions for the energy response and calibration // .... .... .... .... .... .... .... TH1F h_ErecoOverEgen ("h_ErecoOverEgen", "ErecoOverEgen", 400, 0, 0.2) ; TH2F h_ErecoOverEgen_vs_Ebeam ("h_ErecoOverEgen_vs_Ebeam", "h_ErecoOverEgen_vs_Ebeam", 45, 5, 50, 200, 0, 0.002) ; TH3F h_ErecoOverEgen_vs_impact ("h_ErecoOverEgen_vs_impact", "h_ErecoOverEgen_vs_impact", 40, -2., 2., 40, -2., 2., 400, 0, 0.2) ; // distributions for the energy containment // .... .... .... .... .... .... .... // total deposited energy in the calorimeter, with the poissonian smearing TH1F h_EdepOverEgen ("h_EdepOverEgen", "EdepOverEgen", 100, 0, 1) ; TH2F h_EdepOverEgen_vs_Ebeam ("h_EdepOverEgen_vs_Ebeam", "h_EdepOverEgen_vs_Ebeam", 45, 5, 50, 100, 0, 1) ; TH3F h_EdepOverEgen_vs_impact ("h_EdepOverEgen_vs_impact", "h_EdepOverEgen_vs_impact", 40, -2., 2., 40, -2., 2., 400, 0, 0.002) ; // distributions for the energy resolution // .... .... .... .... .... .... .... // energy resolution, with the poissonian smearing TH1F h_sigmaEoverE ("sigmaEoverE", "sigmaEoverE", 100, -1., 1.) ; TH2F h_sigmaEoverE_vs_Ebeam ("sigmaEoverE_vs_Ebeam", "sigmaEoverE_vs_Ebeam", 45, 5, 50, 100, -1., 1.) ; // distributions for the Moliere radius // .... .... .... .... .... .... .... TH2F h_Edep_vs_R ("h_Edep_vs_R", "h_Edep_vs_R", 150, 0., 15., 500, 0., 50.) ; TH3F h_Edep_vs_impact ("h_Edep_vs_impact", "h_Edep_vs_impact", 100, -5., 5., 100, -5., 5., 500, 0., 50.) ; // events analysis // ---- ---- ---- ---- ---- ---- ---- Int_t nentries = tree->GetEntries () ; cout << "found " << nentries << " events\n" ; float x = 0. ; float y = 0. ; for (Int_t iEntry = 0 ; iEntry < nentries ; ++iEntry) { if (iEntry % 100 == 0) cout << "reading event " << iEntry << endl ; t->GetEvent (iEntry) ; float observedEnergy = 0. ; float fullEnergy = 0. ; //PG loop over fibres // loop on the towers composing the calorimeter for (int j = 0 ; j < fNtowersOnSideSQ ; ++j) { // removing the poisson smearing to check the stochastic term behaviour w/o that // float result = gRandom->Poisson (floor ( // depositedEnergies->at (j) * acceptance * efficiency * LY)) ; // result /= LY * acceptance * efficiency ; // observedEnergy += result ; observedEnergy += depositedEnergies->at (j) ; fullEnergy += totalEnergies->at (j) ; y = (j % fNtowersOnSide + 0.5) * towerSideLength - 0.5 * totalSideLength ; x = (j / fNtowersOncSide + 0.5) * towerSideLength - 0.5 * totalSideLength ; float radius = sqrt ( (x - inputInitialPosition->at (0)) * (x - inputInitialPosition->at (0)) + (y - inputInitialPosition->at (1)) * (y - inputInitialPosition->at (1)) ) ; h_Edep_vs_R.Fill (radius, totalEnergies->at (j)) ; h_Edep_vs_impact.Fill ( x - inputInitialPosition->at (0), y - inputInitialPosition->at (1), totalEnergies->at (j)) ; } // loop on the towers composing the calorimeter float beamEnergy = inputMomentum->at (3) ; float ErecoOverEgen = observedEnergy / beamEnergy ; h_ErecoOverEgen.Fill (ErecoOverEgen) ; h_ErecoOverEgen_vs_Ebeam.Fill (beamEnergy, ErecoOverEgen) ; h_ErecoOverEgen_vs_impact.Fill (inputInitialPosition->at (0), inputInitialPosition->at (1), ErecoOverEgen) ; float EdepOverEgen = fullEnergy / beamEnergy ; h_EdepOverEgen.Fill (EdepOverEgen) ; h_EdepOverEgen_vs_Ebeam.Fill (beamEnergy, EdepOverEgen) ; h_EdepOverEgen_vs_impact.Fill (inputInitialPosition->at (0), inputInitialPosition->at (1), EdepOverEgen) ; // if (EdepOverEgen < 0.7) continue ; // 1/3.75307e-02 = 26.6448534133 W, 3 degrees tilt // float sigmaEoverE = (observedEnergy * 26.6448534133 - beamEnergy) / beamEnergy ; float sigmaEoverE = (observedEnergy * 18.9533936051 - beamEnergy) / beamEnergy ; //1/5.27610e-02 = 18.9533936051 Pb, 3 degrees tilt h_sigmaEoverE.Fill (sigmaEoverE) ; h_sigmaEoverE_vs_Ebeam.Fill (beamEnergy, sigmaEoverE) ; } //PG loop over events TFile outfile ("plotResolution.root", "recreate") ; outfile.cd () ; h_ErecoOverEgen.Write () ; h_ErecoOverEgen_vs_Ebeam.Write () ; h_ErecoOverEgen_vs_impact.Write () ; h_EdepOverEgen.Write () ; h_EdepOverEgen_vs_Ebeam.Write () ; h_sigmaEoverE.Write () ; h_sigmaEoverE_vs_Ebeam.Write () ; h_Edep_vs_R.Write () ; h_Edep_vs_impact.Write () ; outfile.Close () ; return ; }
plot_warnmap2D( string warnmapfile , bool writeplots = true ) { gStyle->SetOptStat(0); /* Read warnmap as tree */ TTree *twarn = new TTree(); twarn->ReadFile( warnmapfile.c_str(), "sector/I:y:z:status" ); // Declaration of leaf types Int_t sector; Int_t y; Int_t z; Int_t status; // List of branches TBranch *b_sector; //! TBranch *b_y; //! TBranch *b_z; //! TBranch *b_status; //! twarn->SetBranchAddress("sector", §or, &b_sector); twarn->SetBranchAddress("y", &y, &b_y); twarn->SetBranchAddress("z", &z, &b_z); twarn->SetBranchAddress("status", &status, &b_status); /* Create 2D histograms to visualize warnmap */ TH2I* h_warnmap[8]; int zbins = 0; int ybins = 0; /* Create histogram for each sector */ for( int sector = 0; sector < 8; sector++ ) { if(sector <6) // PbSc sector { zbins = 72; ybins = 36; } else // PbGl sector { zbins = 96; ybins = 48; } TString name("h_warnmap_sector_"); name += sector; TString title("Warnmap sector "); title += sector; cout << name <<endl; cout << title <<endl; h_warnmap[sector] = new TH2I( name, title, zbins, 0, zbins, ybins, 0, ybins ); h_warnmap[sector]->GetXaxis()->SetTitle("z [cm]"); h_warnmap[sector]->GetYaxis()->SetTitle("y [cm]"); } //sector /* Loop over warnmap and fill status of towers into map */ Long64_t nentries = twarn->GetEntriesFast(); for ( Long64_t jentry = 0; jentry < nentries; jentry++ ) { twarn->GetEntry(jentry); //cout << sector << " " << y << " " << z << " " << status << endl; // if status > 50 (e.g. 'dead' or 'uncalibrated', set it to 39 for nicer plotting if ( status > 50 ) status = 39; h_warnmap[sector]->Fill( z , y , status ); } /* build base filename for plots */ std::size_t pos = warnmapfile.find("/"); string filename_cut = warnmapfile.substr( pos+1 ); (filename_cut.erase( filename_cut.length()-4 ,4 ));//.erase(0,25); /* plot warnmaps */ for( int sector = 0; sector < 8; sector++ ) { TCanvas *c1 = new TCanvas(); (h_warnmap[sector])->Draw("colz"); if ( writeplots ) { TString filename("plots-warnmap-2D/warnmap2D_"); filename+=filename_cut; filename+="_sector_"; filename+=sector; filename+=".eps"; TString filenamep("plots-warnmap-2D/warnmap2D_"); filenamep+=filename_cut; filenamep+="_sector_"; filenamep+=sector; filenamep+=".png"; c1->Print( filename ); c1->Print( filenamep ); } } /* Draw combined canvas with all sectors */ TCanvas *c2 = new TCanvas(); c2->SetCanvasSize( 1000, 500 ); c2->SetWindowSize( 1000, 500 ); c2->Divide(4,2); for( int sector = 0; sector < 8; sector++ ) { c2->cd(sector+1); (h_warnmap[sector])->Draw("colz"); } TString filenameAll("plots-warnmap-2D/warnmap2D_"); filenameAll+=filename_cut; filenameAll+="_sector_all.eps"; TString filenameAllp("plots-warnmap-2D/warnmap2D_"); filenameAllp+=filename_cut; filenameAllp+="_sector_all.eps"; c2->Print( filenameAll ); c2->Print( filenameAllp ); // h_warnmap_[sect]->Fill(z, y, warnmap_[sect][z][y]); // for(int y=0; y<48; y++) //{ // if(sect<6 && y>35) continue; // for(int z=0; z<96; z++) //{ // if(sect<6 && z>71) continue; // // id = anatools::TowerID(sect, y, z); // for(int erng=0; erng<6; erng++) //{ // if(hotmap_[erng][sect][z][y] == 100) continue; // h_counts_hot[erng]->Fill(id, hitmap_[erng][sect][z][y]); // }//erng // }//z // }//y // h_warnmap_[sect]->Write(); // }//sect return; }
void mk_tree(const char * acc_file="datfiles/acc.dat") { // read acc file into tree TTree * acc = new TTree("acc","counts tree from acc.dat"); char cols[2048]; char bbc_cols[256]; char zdc_cols[256]; char vpd_cols[256]; for(Int_t i=0; i<=7; i++) { if(i==0) { sprintf(bbc_cols,"bbc_%d/D",i); sprintf(zdc_cols,"zdc_%d/D",i); sprintf(vpd_cols,"vpd_%d/D",i); } else { sprintf(bbc_cols,"%s:bbc_%d/D",bbc_cols,i); sprintf(zdc_cols,"%s:zdc_%d/D",zdc_cols,i); sprintf(vpd_cols,"%s:vpd_%d/D",vpd_cols,i); }; }; sprintf(cols,"i/I:runnum/I:fi/I:fill/I:t/D:bx/I:%s:%s:%s:tot_bx/D:blue/I:yell/I",bbc_cols,zdc_cols,vpd_cols); printf("%s\n",cols); acc->ReadFile(acc_file,cols); acc->Print(); Int_t IMAX_tmp = acc->GetMaximum("i"); const Int_t IMAX = IMAX_tmp; // set branch addresses to read through acc tree Int_t index,runnum,fill_index,fill,bx; Double_t bbc[8]; Double_t zdc[8]; Double_t vpd[8]; Double_t time; Double_t tot_bx; Int_t blue,yell; acc->SetBranchAddress("i",&index); acc->SetBranchAddress("runnum",&runnum); acc->SetBranchAddress("fi",&fill_index); acc->SetBranchAddress("fill",&fill); acc->SetBranchAddress("t",&time); acc->SetBranchAddress("bx",&bx); char str[16]; for(Int_t i=0; i<8; i++) { sprintf(str,"bbc_%d",i); acc->SetBranchAddress(str,&bbc[i]); }; for(Int_t i=0; i<8; i++) { sprintf(str,"zdc_%d",i); acc->SetBranchAddress(str,&zdc[i]); }; for(Int_t i=0; i<8; i++) { sprintf(str,"vpd_%d",i); acc->SetBranchAddress(str,&vpd[i]); }; acc->SetBranchAddress("tot_bx",&tot_bx); acc->SetBranchAddress("blue",&blue); acc->SetBranchAddress("yell",&yell); // build arrays for restructuring; arrays are needed so that // we can implement bXing shift corrections Double_t bbce_arr[IMAX][120]; Double_t bbcw_arr[IMAX][120]; Double_t bbcx_arr[IMAX][120]; Double_t zdce_arr[IMAX][120]; Double_t zdcw_arr[IMAX][120]; Double_t zdcx_arr[IMAX][120]; Double_t vpde_arr[IMAX][120]; Double_t vpdw_arr[IMAX][120]; Double_t vpdx_arr[IMAX][120]; Int_t runnum_arr[IMAX]; Int_t fi_arr[IMAX]; Int_t fill_arr[IMAX]; Double_t time_arr[IMAX]; Double_t tot_bx_arr[IMAX][120]; Int_t blue_arr[IMAX][120]; Int_t yell_arr[IMAX][120]; Bool_t kicked_arr[IMAX][120]; // restructure tree into one suitable for analysis TTree * sca = new TTree("sca","restructured tree"); Double_t bbce,bbcw,bbcx; // e=east, w=west, x=coincidence Double_t zdce,zdcw,zdcx; Double_t vpde,vpdw,vpdx; Bool_t okEntry,kicked; sca->Branch("i",&index,"i/I"); sca->Branch("runnum",&runnum,"runnum/I"); sca->Branch("fi",&fill_index,"fi/I"); sca->Branch("fill",&fill,"fill/I"); sca->Branch("t",&time,"t/D"); sca->Branch("bx",&bx,"bx/I"); sca->Branch("bbce",&bbce,"bbce/D"); sca->Branch("bbcw",&bbcw,"bbcw/D"); sca->Branch("bbcx",&bbcx,"bbcx/D"); sca->Branch("zdce",&zdce,"zdce/D"); sca->Branch("zdcw",&zdcw,"zdcw/D"); sca->Branch("zdcx",&zdcx,"zdcx/D"); sca->Branch("vpde",&vpde,"vpde/D"); sca->Branch("vpdw",&vpdw,"vpdw/D"); sca->Branch("vpdx",&vpdx,"vpdx/D"); sca->Branch("tot_bx",&tot_bx,"tot_bx/D"); sca->Branch("blue",&blue,"blue/I"); sca->Branch("yell",&yell,"yell/I"); sca->Branch("kicked",&kicked,"kicked/O"); // read kicked bunches tree from "kicked" file TTree * kicked_tr = new TTree(); kicked_tr->ReadFile("kicked","fill/I:bx/I:spinbit/I"); Int_t kicked_fill,kicked_bx,kicked_spinbit; kicked_tr->SetBranchAddress("fill",&kicked_fill); kicked_tr->SetBranchAddress("bx",&kicked_bx); kicked_tr->SetBranchAddress("spinbit",&kicked_spinbit); for(Int_t q=0; q<acc->GetEntries(); q++) { acc->GetEntry(q); // -- see doc for bit details // BBC, ZDC, VPD bits: [ x w e ] bbce = bbc[1] + bbc[3] + bbc[5] + bbc[7]; // e + we + xe + xwe bbcw = bbc[2] + bbc[3] + bbc[6] + bbc[7]; // w + we + xw + xwe bbcx = bbc[3] + bbc[7]; // we + xwe zdce = zdc[1] + zdc[3] + zdc[5] + zdc[7]; // e + we + xe + xwe zdcw = zdc[2] + zdc[3] + zdc[6] + zdc[7]; // w + we + xw + xwe zdcx = zdc[3] + zdc[7]; // we + xwe vpde = vpd[1] + vpd[3] + vpd[5] + vpd[7]; // e + we + xe + xwe vpdw = vpd[2] + vpd[3] + vpd[6] + vpd[7]; // w + we + xw + xwe vpdx = vpd[3] + vpd[7]; // we + xwe // KICKED BUNCHES // manually omit empty bunches documented in pathologies.dat -- CLEAN UP PROCEDURE // (see 09.01.14 log entry) okEntry=true; // kicked bunches (presumably empty) /* if(fill==17384 && (bx==29 || bx==30 || bx==117)) okEntry=false; if(fill==17416 && bx==79) okEntry=false; if(fill==17491 && bx==105) okEntry=false; if(fill==17519 && (bx==94 || bx==109)) okEntry=false; if(fill==17520 && bx==0) okEntry=false; if(fill==17529 && bx==97) okEntry=false; if(fill==17534 && bx==112) okEntry=false; if(fill==17553 && bx==73) okEntry=false; if(fill==17554 && (bx==7 || bx==14)) okEntry=false; if(fill==17555 && bx==61) okEntry=false; if(fill==17576 && bx==94) okEntry=false; // afterpulse-like bunches -- remove 1st 2 bunches after abort gaps //if(fill==17512 && (bx>=40 && bx<=59)) okEntry=false; //if((fill>=17513 && fill<=17520) && ((bx>=0 && bx<=19) || (bx>=40 && bx<=59))) okEntry=false; */ for(Int_t kk=0; kk<kicked_tr->GetEntries(); kk++) { kicked_tr->GetEntry(kk); if(fill==kicked_fill && bx==kicked_bx) okEntry=false; }; kicked=!okEntry; // cleaned up analysis //kicked=0; // take all bXings // store data into arrays, implementing bXing shift corrections on scalers if(fill==16570 || fill==16567) { bbce_arr[index-1][(bx+113)%120] = bbce; // shift down 7 bXings bbcw_arr[index-1][(bx+113)%120] = bbcw; bbcx_arr[index-1][(bx+113)%120] = bbcx; zdce_arr[index-1][(bx+113)%120] = zdce; // shift down 7 bXings zdcw_arr[index-1][(bx+113)%120] = zdcw; zdcx_arr[index-1][(bx+113)%120] = zdcx; vpde_arr[index-1][(bx+113)%120] = vpde; // shift down 7 bXings vpdw_arr[index-1][(bx+113)%120] = vpdw; vpdx_arr[index-1][(bx+113)%120] = vpdx; } else if(fill == 16582 || fill == 16586 || fill == 16587 || fill == 16592 || fill == 16593 || fill == 16594 || fill == 16597 || fill == 16602) { bbce_arr[index-1][bx] = bbce; // no shift bbcw_arr[index-1][bx] = bbcw; bbcx_arr[index-1][bx] = bbcx; zdce_arr[index-1][bx] = zdce; // no shift zdcw_arr[index-1][bx] = zdcw; zdcx_arr[index-1][bx] = zdcx; vpde_arr[index-1][(bx+1)%120] = vpde; // shift up 1 bXings vpdw_arr[index-1][(bx+1)%120] = vpdw; vpdx_arr[index-1][(bx+1)%120] = vpdx; } else { bbce_arr[index-1][bx] = bbce; bbcw_arr[index-1][bx] = bbcw; bbcx_arr[index-1][bx] = bbcx; zdce_arr[index-1][bx] = zdce; zdcw_arr[index-1][bx] = zdcw; zdcx_arr[index-1][bx] = zdcx; vpde_arr[index-1][bx] = vpde; vpdw_arr[index-1][bx] = vpdw; vpdx_arr[index-1][bx] = vpdx; }; runnum_arr[index-1] = runnum; fi_arr[index-1] = fill_index; fill_arr[index-1] = fill; time_arr[index-1] = time; tot_bx_arr[index-1][bx] = tot_bx; blue_arr[index-1][bx] = blue; yell_arr[index-1][bx] = yell; kicked_arr[index-1][bx] = kicked; }; // fill restructured tree for(Int_t i=0; i<IMAX; i++) { index = i+1; runnum = runnum_arr[i]; fill_index = fi_arr[i]; fill = fill_arr[i]; time = time_arr[i]; for(Int_t b=0; b<120; b++) { bx = b; bbce = bbce_arr[i][b]; bbcw = bbcw_arr[i][b]; bbcx = bbcx_arr[i][b]; zdce = zdce_arr[i][b]; zdcw = zdcw_arr[i][b]; zdcx = zdcx_arr[i][b]; vpde = vpde_arr[i][b]; vpdw = vpdw_arr[i][b]; vpdx = vpdx_arr[i][b]; tot_bx = tot_bx_arr[i][b]; blue = blue_arr[i][b]; yell = yell_arr[i][b]; kicked = kicked_arr[i][b]; sca->Fill(); }; }; TFile * outfile = new TFile("counts.root","RECREATE"); acc->Write("acc"); sca->Write("sca"); printf("counts.root written\n"); };
void MakeTree_2012(){ //gROOT->LoadMacro("setTDRStyle_modified.C"); //setTDRStyle(); TFile *f = TFile::Open("Upsilon_Histos_191212_FULL.root"); //TFile *f = TFile::Open("/castor/cern.ch/user/t/tdahms/Jpsi_Histos_ppReReco.root"); TTree *t =(TTree*)f->Get("myTree"); Long64_t nentries = t->GetEntries(); const int NMAX=100; UInt_t eventNb; UInt_t runNb; Int_t Centrality; Int_t HLTriggers; Int_t Reco_QQ_size; Int_t Reco_QQ_trig[NMAX]; Int_t Reco_QQ_type[NMAX]; Int_t Reco_QQ_sign[NMAX]; Float_t Reco_QQ_VtxProb[NMAX]; TClonesArray *Reco_QQ_4mom; TClonesArray *Reco_QQ_mupl_4mom; TClonesArray *Reco_QQ_mumi_4mom; Int_t Reco_mu_size; Int_t Reco_mu_type[NMAX]; Int_t Reco_mu_charge[NMAX]; TClonesArray *Reco_mu_4mom; int nPlusMu; int nMinusMu; float muPt[NMAX]; float muEta[NMAX]; float muPhi[NMAX]; //Int_t nReco_QQ; Float_t invariantMass; Int_t QQtrig; Int_t QQsign; float weight; float weight2; Float_t upsPt; Float_t upsEta; Float_t upsRapidity; Float_t vProb; Float_t muPlusPt; Float_t muMinusPt; Float_t muPlusEta; Float_t muMinusEta; Float_t muPlusPhi; Float_t muMinusPhi; Float_t RmuPlusPhi = 0; Float_t RmuMinusPhi = 0; //float theta_HX; //float phi_HX; //float theta_CS; //float phi_CS; float QQmuPlusDxy[100]; float QQmuPlusDz[100]; int QQmuPlusNhits[100]; int QQmuPlusNPixelhits[100]; int QQmuPlusNPxlLayers[100]; float QQmuPlusInnerChi[100]; float QQmuPlusGlobalChi[100]; int QQmuPlusNMuonhits[100]; float QQmuPlusDB[100]; float QQmuMinusDxy[100]; float QQmuMinusDz[100]; int QQmuMinusNhits[100]; int QQmuMinusNPixelhits[100]; int QQmuMinusNPxlLayers[100]; float QQmuMinusInnerChi[100]; float QQmuMinusGlobalChi[100]; int QQmuMinusNMuonhits[100]; float QQmuMinusDB[100]; float muPlusDxy; float muPlusDz; int muPlusNhits; int muPlusNPixelhits; int muPlusNPxlLayers; float muPlusInnerChi; float muPlusGlobalChi; int muPlusNMuonhits; float muPlusDB; float muMinusDxy; float muMinusDz; int muMinusNhits; int muMinusNPixelhits; int muMinusNPxlLayers; float muMinusInnerChi; float muMinusGlobalChi; int muMinusNMuonhits; float muMinusDB; t->SetBranchAddress("Centrality", &Centrality ); t->SetBranchAddress("eventNb", &eventNb ); t->SetBranchAddress("runNb", &runNb ); t->SetBranchAddress("HLTriggers", &HLTriggers ); t->SetBranchAddress("Reco_QQ_size", &Reco_QQ_size ); t->SetBranchAddress("Reco_QQ_trig", &Reco_QQ_trig ); t->SetBranchAddress("Reco_QQ_type", Reco_QQ_type ); t->SetBranchAddress("Reco_QQ_sign", Reco_QQ_sign ); t->SetBranchAddress("Reco_QQ_VtxProb", Reco_QQ_VtxProb); t->SetBranchAddress("Reco_QQ_4mom", &Reco_QQ_4mom ); t->SetBranchAddress("Reco_QQ_mupl_4mom", &Reco_QQ_mupl_4mom); t->SetBranchAddress("Reco_QQ_mumi_4mom", &Reco_QQ_mumi_4mom); /* t->SetBranchAddress("muPlusDxy",QQmuPlusDxy); t->SetBranchAddress("muPlusDz",QQmuPlusDz); t->SetBranchAddress("muPlusNhits",QQmuPlusNhits); t->SetBranchAddress("muPlusNPixelhits",QQmuPlusNPixelhits); t->SetBranchAddress("muPlusNPxlLayers",QQmuPlusNPxlLayers); t->SetBranchAddress("muPlusInnerChi",QQmuPlusInnerChi); t->SetBranchAddress("muPlusGlobalChi",QQmuPlusGlobalChi); t->SetBranchAddress("muPlusNMuonhits",QQmuPlusNMuonhits); t->SetBranchAddress("muPlusDB",QQmuPlusDB); t->SetBranchAddress("muMinusDxy",QQmuMinusDxy); t->SetBranchAddress("muMinusDz",QQmuMinusDz); t->SetBranchAddress("muMinusNhits",QQmuMinusNhits); t->SetBranchAddress("muMinusNPixelhits",QQmuMinusNPixelhits); t->SetBranchAddress("muMinusNPxlLayers",QQmuMinusNPxlLayers); t->SetBranchAddress("muMinusInnerChi",QQmuMinusInnerChi); t->SetBranchAddress("muMinusGlobalChi",QQmuMinusGlobalChi); t->SetBranchAddress("muMinusNMuonhits",QQmuMinusNMuonhits); t->SetBranchAddress("muMinusDB",QQmuMinusDB); */ t->SetBranchAddress("Reco_mu_size", &Reco_mu_size ); t->SetBranchAddress("Reco_mu_type", Reco_mu_type ); t->SetBranchAddress("Reco_mu_charge",Reco_mu_charge ); t->SetBranchAddress("Reco_mu_4mom", &Reco_mu_4mom); TH1F *h_QQ_mass = new TH1F("h_QQ_mass","",70,7,14); TH1F *h_QQ_mass_1 = new TH1F("h_QQ_mass_1","",70,7,14); TH1F *h_QQ_mass_2 = new TH1F("h_QQ_mass_2","",70,7,14); TFile *f1 = new TFile("dimuonTree_fullFiltered.root","RECREATE"); TTree *MuTree = new TTree("MuTree","MuTree"); TTree *UpsilonTree = new TTree("UpsilonTree","UpsilonTree"); TTree *UpsilonTree_allsign = new TTree("UpsilonTree_allsign","UpsilonTree_allsign"); TTree *UpsilonTree_trkRot = new TTree("UpsilonTree_trkRot","UpsilonTree_trkRot"); MuTree->Branch("Reco_mu_size", &Reco_mu_size, "Reco_mu_size/I"); MuTree->Branch("nPlusMu", &nPlusMu, "nPlusMu/I"); MuTree->Branch("nMinusMu", &nMinusMu, "nMinusMu/I"); MuTree->Branch("muPt", &muPt, "muPt[Reco_mu_size]/F"); MuTree->Branch("muEta", &muEta, "muEta[Reco_mu_size]/F"); MuTree->Branch("muPhi", &muPhi, "muPhi[Reco_mu_size]/F"); MuTree->Branch("Reco_mu_type", Reco_mu_type, "Reco_mu_type[Reco_mu_size]/I"); MuTree->Branch("Reco_mu_charge", Reco_mu_charge, "Reco_mu_charge[Reco_mu_size]/I" ); MuTree->Branch("eventNb", &eventNb, "eventNb/I"); MuTree->Branch("runNb", &runNb, "runNb/I"); //UpsilonTree->Branch("nReco_QQ", &nReco_QQ, "nReco_QQ/I"); UpsilonTree->Branch("Centrality", &Centrality, "Centrality/I"); UpsilonTree->Branch("HLTriggers", &HLTriggers, "HLTriggers/I"); UpsilonTree->Branch("QQtrig", &QQtrig, "QQtrig/I"); UpsilonTree->Branch("QQsign", &QQsign, "QQsign/I"); UpsilonTree->Branch("vProb", &vProb, "vProb/F"); UpsilonTree->Branch("eventNb", &eventNb, "eventNb/I"); UpsilonTree->Branch("runNb", &runNb, "runNb/I"); UpsilonTree->Branch("invariantMass", &invariantMass, "invariantMass/F"); UpsilonTree->Branch("upsPt", &upsPt, "upsPt/F"); UpsilonTree->Branch("upsEta", &upsEta, "upsEta/F"); UpsilonTree->Branch("upsRapidity", &upsRapidity, "upsRapidity/F"); UpsilonTree->Branch("muPlusPt", &muPlusPt, "muPlusPt/F"); UpsilonTree->Branch("muMinusPt", &muMinusPt, "muMinusPt/F"); UpsilonTree->Branch("muPlusEta", &muPlusEta, "muPlusEta/F"); UpsilonTree->Branch("muMinusEta", &muMinusEta, "muMinusEta/F"); UpsilonTree->Branch("muPlusPhi", &muPlusPhi, "muPlusPhi/F"); UpsilonTree->Branch("muMinusPhi", &muMinusPhi, "muMinusPhi/F"); // UpsilonTree->Branch("theta_HX", &theta_HX, "theta_HX/F"); // UpsilonTree->Branch("phi_HX", &phi_HX, "phi_HX/F"); // UpsilonTree->Branch("theta_CS", &theta_CS, "theta_CS/F"); // UpsilonTree->Branch("phi_CS", &phi_CS, "phi_CS/F"); /* UpsilonTree->Branch("muPlusDxy", &muPlusDxy,"muPlusDxy/F"); UpsilonTree->Branch("muPlusDz", &muPlusDz,"muPlusDz/F"); UpsilonTree->Branch("muPlusNhits", &muPlusNhits,"muPlusNhits/I"); UpsilonTree->Branch("muPlusNPixelhits", &muPlusNPixelhits,"muPlusNPixelhits/I"); UpsilonTree->Branch("muPlusNPxlLayers", &muPlusNPxlLayers,"muPlusNPxlLayers/I"); UpsilonTree->Branch("muPlusInnerChi", &muPlusInnerChi,"muPlusInnerChi/F"); UpsilonTree->Branch("muPlusGlobalChi", &muPlusGlobalChi,"muPlusGlobalChi/F"); UpsilonTree->Branch("muPlusNMuonhits", &muPlusNMuonhits,"muPlusNMuonhits/I"); UpsilonTree->Branch("muPlusDB", &muPlusDB,"muPlusDB/F"); UpsilonTree->Branch("muMinusDxy", &muMinusDxy,"muMinusDxy/F"); UpsilonTree->Branch("muMinusDz", &muMinusDz,"muMinusDz/F"); UpsilonTree->Branch("muMinusNhits", &muMinusNhits,"muMinusNhits/I"); UpsilonTree->Branch("muMinusNPixelhits", &muMinusNPixelhits,"muMinusNPixelhits/I"); UpsilonTree->Branch("muMinusNPxlLayers", &muMinusNPxlLayers,"muMinusNPxlLayers/I"); UpsilonTree->Branch("muMinusInnerChi", &muMinusInnerChi,"muMinusInnerChi/F"); UpsilonTree->Branch("muMinusGlobalChi", &muMinusGlobalChi,"muMinusGlobalChi/F"); UpsilonTree->Branch("muMinusNMuonhits", &muMinusNMuonhits,"muMinusNMuonhits/I"); UpsilonTree->Branch("muMinusDB", &muMinusDB,"muMinusDB/F"); */ UpsilonTree_allsign->Branch("Centrality", &Centrality, "Centrality/I"); UpsilonTree_allsign->Branch("HLTriggers", &HLTriggers, "HLTriggers/I"); UpsilonTree_allsign->Branch("QQtrig", &QQtrig, "QQtrig/I"); UpsilonTree_allsign->Branch("QQsign", &QQsign, "QQsign/I"); UpsilonTree_allsign->Branch("weight", &weight, "weight/F"); UpsilonTree_allsign->Branch("weight2", &weight2, "weight2/F"); UpsilonTree_allsign->Branch("vProb", &vProb, "vProb/F"); UpsilonTree_allsign->Branch("eventNb", &eventNb, "eventNb/I"); UpsilonTree_allsign->Branch("runNb", &runNb, "runNb/I"); UpsilonTree_allsign->Branch("invariantMass", &invariantMass, "invariantMass/F"); UpsilonTree_allsign->Branch("upsPt", &upsPt, "upsPt/F"); UpsilonTree_allsign->Branch("upsEta", &upsEta, "upsEta/F"); UpsilonTree_allsign->Branch("upsRapidity", &upsRapidity, "upsRapidity/F"); UpsilonTree_allsign->Branch("muPlusPt", &muPlusPt, "muPlusPt/F"); UpsilonTree_allsign->Branch("muMinusPt", &muMinusPt, "muMinusPt/F"); UpsilonTree_allsign->Branch("muPlusEta", &muPlusEta, "muPlusEta/F"); UpsilonTree_allsign->Branch("muMinusEta", &muMinusEta, "muMinusEta/F"); UpsilonTree_allsign->Branch("muPlusPhi", &muPlusPhi, "muPlusPhi/F"); UpsilonTree_allsign->Branch("muMinusPhi", &muMinusPhi, "muMinusPhi/F"); // UpsilonTree_allsign->Branch("theta_HX", &theta_HX, "theta_HX/F"); // UpsilonTree_allsign->Branch("phi_HX", &phi_HX, "phi_HX/F"); // UpsilonTree_allsign->Branch("theta_CS", &theta_CS, "theta_CS/F"); // UpsilonTree_allsign->Branch("phi_CS", &phi_CS, "phi_CS/F"); UpsilonTree_trkRot->Branch("Centrality", &Centrality, "Centrality/I"); UpsilonTree_trkRot->Branch("HLTriggers", &HLTriggers, "HLTriggers/I"); UpsilonTree_trkRot->Branch("QQtrig", &QQtrig, "QQtrig/I"); UpsilonTree_trkRot->Branch("QQsign", &QQsign, "QQsign/I"); UpsilonTree_trkRot->Branch("weight", &weight, "weight/F"); UpsilonTree_trkRot->Branch("weight2", &weight2, "weight2/F"); UpsilonTree_trkRot->Branch("vProb", &vProb, "vProb/F"); UpsilonTree_trkRot->Branch("eventNb", &eventNb, "eventNb/I"); UpsilonTree_trkRot->Branch("runNb", &runNb, "runNb/I"); UpsilonTree_trkRot->Branch("invariantMass", &invariantMass, "invariantMass/F"); UpsilonTree_trkRot->Branch("upsPt", &upsPt, "upsPt/F"); UpsilonTree_trkRot->Branch("upsEta", &upsEta, "upsEta/F"); UpsilonTree_trkRot->Branch("upsRapidity", &upsRapidity, "upsRapidity/F"); UpsilonTree_trkRot->Branch("muPlusPt", &muPlusPt, "muPlusPt/F"); UpsilonTree_trkRot->Branch("muMinusPt", &muMinusPt, "muMinusPt/F"); UpsilonTree_trkRot->Branch("muPlusEta", &muPlusEta, "muPlusEta/F"); UpsilonTree_trkRot->Branch("muMinusEta", &muMinusEta, "muMinusEta/F"); UpsilonTree_trkRot->Branch("muPlusPhi", &muPlusPhi, "muPlusPhi/F"); UpsilonTree_trkRot->Branch("muMinusPhi", &muMinusPhi, "muMinusPhi/F"); for (int i=0; i<nentries; i++) { t->GetEntry(i); //nReco_QQ=0; if (i%1000==0) cout<<i<<endl; nPlusMu=0; nMinusMu=0; for(int iMu = 0; iMu < Reco_mu_size; iMu++){ if (Reco_mu_charge[iMu] == 1) nPlusMu++; else nMinusMu++; TLorentzVector *Reco_mu = (TLorentzVector *) Reco_mu_4mom->At(iMu); muPt[iMu]=Reco_mu->Pt(); muEta[iMu]=Reco_mu->Eta(); muPhi[iMu]=Reco_mu->Phi(); } MuTree->Fill(); for(int iQQ = 0; iQQ < Reco_QQ_size; iQQ++){ //eventNb=eventNb[iQQ]; //runNb=runNb[iQQ]; vProb = Reco_QQ_VtxProb[iQQ]; QQtrig = Reco_QQ_trig[iQQ]; QQsign = Reco_QQ_sign[iQQ]; if (Reco_QQ_sign[iQQ] == 0) { weight = 1; weight2 = 1; } else { weight = -1; float likesign_comb = (float)nPlusMu*(nPlusMu-1.0)/2.0+(float)nMinusMu*(nMinusMu-1.0)/2.0; float unlikesign_bkgd_comb = (float)nPlusMu*nMinusMu - (nPlusMu>nMinusMu?nMinusMu:nPlusMu); weight2 = -1.0 * unlikesign_bkgd_comb/likesign_comb; } TLorentzVector *Reco_QQ = (TLorentzVector *) Reco_QQ_4mom->At(iQQ); TLorentzVector *Reco_QQ_mupl = (TLorentzVector *) Reco_QQ_mupl_4mom->At(iQQ); TLorentzVector *Reco_QQ_mumi = (TLorentzVector *) Reco_QQ_mumi_4mom->At(iQQ); invariantMass=Reco_QQ->M(); upsPt=Reco_QQ->Pt(); upsEta=Reco_QQ->Eta(); upsRapidity=Reco_QQ->Rapidity(); muMinusPt=Reco_QQ_mumi->Pt(); muMinusEta=Reco_QQ_mumi->Eta(); muMinusPhi=Reco_QQ_mumi->Phi(); muPlusPt=Reco_QQ_mupl->Pt(); muPlusEta=Reco_QQ_mupl->Eta(); muPlusPhi=Reco_QQ_mupl->Phi(); // theta_HX = GetAngles_HX(*Reco_QQ_mupl,*Reco_QQ_mumi).first; // phi_HX = GetAngles_HX(*Reco_QQ_mupl,*Reco_QQ_mumi).second; // theta_CS = GetAngles_CS(*Reco_QQ_mupl,*Reco_QQ_mumi).first; // phi_CS = GetAngles_CS(*Reco_QQ_mupl,*Reco_QQ_mumi).second; muPlusDxy=QQmuPlusDxy[iQQ]; muPlusDz=QQmuPlusDz[iQQ]; muPlusNhits=QQmuPlusNhits[iQQ]; muPlusNPixelhits=QQmuPlusNPixelhits[iQQ]; muPlusNPxlLayers=QQmuPlusNPxlLayers[iQQ]; muPlusInnerChi=QQmuPlusInnerChi[iQQ]; muPlusGlobalChi=QQmuPlusGlobalChi[iQQ]; muPlusNMuonhits=QQmuPlusNMuonhits[iQQ]; muPlusDB=QQmuPlusDB[iQQ]; muMinusDxy=QQmuMinusDxy[iQQ]; muMinusDz=QQmuMinusDz[iQQ]; muMinusNhits=QQmuMinusNhits[iQQ]; muMinusNPixelhits=QQmuMinusNPixelhits[iQQ]; muMinusNPxlLayers=QQmuMinusNPxlLayers[iQQ]; muMinusInnerChi=QQmuMinusInnerChi[iQQ]; muMinusGlobalChi=QQmuMinusGlobalChi[iQQ]; muMinusNMuonhits=QQmuMinusNMuonhits[iQQ]; muMinusDB=QQmuMinusDB[iQQ]; /* if (fabs(muPlusDxy)<3 && fabs(muPlusDz)<15 && muPlusNhits>10 && muPlusNPxlLayers>0 && muPlusNMuonhits>6 && muPlusInnerChi<4 && muPlusGlobalChi<6 && fabs(muMinusDxy)<3 && fabs(muMinusDz)<15 && muMinusNhits>10 && muMinusNPxlLayers>0 && muMinusNMuonhits>6 && muMinusInnerChi<4 && muMinusGlobalChi<6 && vProb>0.01) if (fabs(muPlusDxy)<3 && fabs(muPlusDz)<15 && muPlusNhits>10 && muPlusNPxlLayers>0 && muPlusNMuonhits>12 && muPlusInnerChi<2.1 && muPlusGlobalChi<2.7 && fabs(muMinusDxy)<3 && fabs(muMinusDz)<15 && muMinusNhits>10 && muMinusNPxlLayers>0 && muMinusNMuonhits>12 && muMinusInnerChi<2.1 && muMinusGlobalChi<2.7 && vProb>0.19) */ if ((HLTriggers&1)==1 && (Reco_QQ_trig[iQQ]&1)==1 && (Reco_QQ_type[iQQ]<3) ) { UpsilonTree_allsign->Fill(); if (Reco_QQ_sign[iQQ]==0) { UpsilonTree->Fill(); if (Reco_QQ->M()>8.5 && Reco_QQ->M()<11.5) { h_QQ_mass->Fill(Reco_QQ->M()); } if (Reco_QQ_mupl->Pt()>=ptcut && Reco_QQ_mumi->Pt()>=ptcut && Reco_QQ->M()>8.5 && Reco_QQ->M()<11.5) { h_QQ_mass_1->Fill(Reco_QQ->M()); } } else if (Reco_QQ_mupl->Pt()>=ptcut && Reco_QQ_mumi->Pt()>=ptcut && Reco_QQ->M()>8.5 && Reco_QQ->M()<11.5) { h_QQ_mass_2->Fill(Reco_QQ->M()); } //track rotation Double_t ran = gRandom->Rndm(); if(ran < 0.5 ) RmuPlusPhi = muPlusPhi + TMath::Pi(); else RmuMinusPhi = muMinusPhi + TMath::Pi(); TLorentzVector mu1; mu1.SetPtEtaPhiM( muPlusPt, muPlusEta, RmuPlusPhi, 0.105); TLorentzVector mu2; mu2.SetPtEtaPhiM( muMinusPt, muMinusEta, RmuMinusPhi, 0.105); TLorentzVector dimuon; dimuon = mu1 + mu2; invariantMass=dimuon.M(); upsPt=dimuon.Pt(); upsEta=dimuon.Eta(); upsRapidity=dimuon.Rapidity(); if ((HLTriggers&1)==2 && (Reco_QQ_trig[iQQ]&1)==1 && (Reco_QQ_type[iQQ]==0) ) { UpsilonTree_trkRot->Fill(); } /* for (int k=0;k<10;k++){ //track rotation //if(ran < 0.5 ) RmuPlusPhi = muPlusPhi + TMath::Pi(); //else RmuMinusPhi = muMinusPhi + TMath::Pi(); Double_t ran = gRandom->Rndm(); if (k<5) { muMinusPhi = muMinusPhi + TMath::Pi()*ran; } else { muPlusPhi = muPlusPhi + TMath::Pi()*ran; } TLorentzVector mu1; mu1.SetPtEtaPhiM( muPlusPt, muPlusEta, muPlusPhi, 0.105); TLorentzVector mu2; mu2.SetPtEtaPhiM( muMinusPt, muMinusEta, muMinusPhi, 0.105); TLorentzVector dimuon; dimuon = mu1 + mu2; invariantMass=dimuon.M(); upsPt=dimuon.Pt(); upsEta=dimuon.Eta(); upsRapidity=dimuon.Rapidity(); UpsilonTree_trkRot->Fill(); } */ } } // UpsilonTree->Fill(); } gROOT->SetStyle("Plain"); gStyle->SetPalette(1); gStyle->SetFrameBorderMode(0); gStyle->SetFrameFillColor(0); gStyle->SetCanvasColor(0); gStyle->SetTitleFillColor(0); gStyle->SetStatColor(0); gStyle->SetPadBorderSize(0); gStyle->SetCanvasBorderSize(0); gStyle->SetOptTitle(0); // at least most of the time gStyle->SetOptStat(0); // most of the time, sometimes "nemriou" might be useful to display name, number of entries, mean, rms, integral, overflow and underflow gStyle->SetOptFit(0); // set to 1 only if you want to display fit results TCanvas *c1 = new TCanvas("c1","c1"); //h_QQ_mass->GetYaxis()->SetRangeUser(0,180); h_QQ_mass->SetMarkerColor(kRed); h_QQ_mass->SetMarkerStyle(22); h_QQ_mass->SetXTitle("m_{#mu#mu} (GeV/c^{2})"); h_QQ_mass->SetYTitle("Events/(0.1 GeV/c^{2})"); h_QQ_mass->Draw("PE"); h_QQ_mass_1->SetMarkerColor(kBlue); h_QQ_mass_1->SetMarkerStyle(20); h_QQ_mass_1->GetXaxis()->CenterTitle(kTRUE); h_QQ_mass_1->SetXTitle("m_{#mu#mu} (GeV/c^{2})"); h_QQ_mass_1->SetYTitle("Events/(0.1 GeV/c^{2})"); h_QQ_mass_1->Draw("PEsame"); //h_QQ_mass_2->GetYaxis()->SetRangeUser(0,400); h_QQ_mass_2->SetMarkerColor(kRed); h_QQ_mass_2->SetMarkerStyle(24); h_QQ_mass_2->GetXaxis()->CenterTitle(kTRUE); h_QQ_mass_2->SetXTitle("m_{#mu#mu} (GeV/c^{2})"); h_QQ_mass_2->SetYTitle("Events/(0.1 MeV/c^{2})"); h_QQ_mass_2->Draw("PEsame"); TLegend *legend = new TLegend(.5,.7,.9,.9); legend->AddEntry(h_QQ_mass,"N_{#mu^{+}#mu^{-}} acceptance cut","P"); legend->AddEntry(h_QQ_mass_1,"Unlike-Sign, N_{#mu^{+}#mu^{-}}","P"); legend->AddEntry(h_QQ_mass_2,"Like-sign, N_{#mu^{+}#mu^{+}}+N_{#mu^{-}#mu^{-}}","P"); legend->AddEntry((TObject*)0,"#mu p_{T} > 3 GeV/c",""); legend->Draw(); h_QQ_mass->Write(); h_QQ_mass_1->Write(); h_QQ_mass_2->Write(); c1->SaveAs("dimuon_likesign_pt4.pdf"); c1->SaveAs("dimuon_likesign_pt4.gif"); c1->Write(); f1->Write(); }
void cutFlowStudyMu( TString weightFile = "TMVAClassificationPtOrd_qqH115vsWZttQCD_Cuts.weights.xml", Double_t effS_ = 0.3) { ofstream out("cutFlow-MuTauStream.txt"); out.precision(4); TMVA::Tools::Instance(); TMVA::Reader *reader = new TMVA::Reader( "!Color:!Silent" ); Float_t pt1, pt2; Float_t Deta, Mjj; Float_t eta1,eta2; reader->AddVariable( "pt1", &pt1); reader->AddVariable( "pt2", &pt2); reader->AddVariable( "Deta",&Deta); reader->AddVariable( "Mjj", &Mjj); reader->AddSpectator("eta1",&eta1); reader->AddSpectator("eta2",&eta2); reader->BookMVA( "Cuts", TString("/home/llr/cms/lbianchini/CMSSW_3_9_9/src/Bianchi/TauTauStudies/test/Macro/weights/")+weightFile ); TFile *fFullSignalVBF = new TFile("/data_CMS/cms/lbianchini//MuTauStream2011/treeMuTauStream_VBFH115-Mu-powheg-PUS1.root","READ"); TFile *fFullSignalGGH = new TFile("/data_CMS/cms/lbianchini//MuTauStream2011/treeMuTauStream_GGFH115-Mu-powheg-PUS1.root","READ"); TFile *fFullBackgroundDYTauTau = new TFile("/data_CMS/cms/lbianchini//MuTauStream2011/treeMuTauStream_DYToTauTau-Mu-20-PUS1.root","READ"); TFile *fFullBackgroundDYMuMu = new TFile("/data_CMS/cms/lbianchini//MuTauStream2011/treeMuTauStream_DYToMuMu-20-PUS1.root","READ"); TFile *fFullBackgroundWJets = new TFile("/data_CMS/cms/lbianchini//MuTauStream2011/treeMuTauStream_WJets-Mu-madgraph-PUS1.root","READ"); TFile *fFullBackgroundQCD = new TFile("/data_CMS/cms/lbianchini//MuTauStream2011/treeMuTauStream_QCDmu.root","READ"); TFile *fFullBackgroundTTbar = new TFile("/data_CMS/cms/lbianchini//MuTauStream2011/treeMuTauStream_TTJets-Mu-madgraph-PUS1.root","READ"); TFile *fFullBackgroundDiBoson = new TFile("/data_CMS/cms/lbianchini//MuTauStream2011/treeMuTauStream_DiBoson-Mu.root","READ"); // OpenNTuples TString fSignalNameVBF = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011/v2/nTupleVBFH115-Mu-powheg-PUS1_Open_MuTauStream.root"; TString fSignalNameGGH = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011/v2/nTupleGGFH115-Mu-powheg-PUS1_Open_MuTauStream.root"; TString fBackgroundNameDYTauTau = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011/v2/nTupleDYToTauTau-Mu-20-PUS1_Open_MuTauStream.root"; TString fBackgroundNameDYMuMu = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011/v2/nTupleDYToMuMu-20-PUS1_Open_MuTauStream.root"; TString fBackgroundNameWJets = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011/v2/nTupleWJets-Mu-madgraph-PUS1_Open_MuTauStream.root"; TString fBackgroundNameQCD = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011/v2/nTupleQCDmu_Open_MuTauStream.root"; TString fBackgroundNameTTbar = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011/v2/nTupleTTJets-Mu-madgraph-PUS1_Open_MuTauStream.root"; TString fBackgroundNameDiBoson = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011/v2/nTupleDiBoson-Mu_Open_MuTauStream.root"; TFile *fSignalVBF(0); TFile *fSignalGGH(0); TFile *fBackgroundDYTauTau(0); TFile *fBackgroundDYMuMu(0); TFile *fBackgroundWJets(0); TFile *fBackgroundQCD(0); TFile *fBackgroundTTbar(0); TFile *fBackgroundDiBoson(0); fSignalVBF = TFile::Open( fSignalNameVBF ); fSignalGGH = TFile::Open( fSignalNameGGH ); fBackgroundDYTauTau = TFile::Open( fBackgroundNameDYTauTau ); fBackgroundDYMuMu = TFile::Open( fBackgroundNameDYMuMu ); fBackgroundWJets = TFile::Open( fBackgroundNameWJets ); fBackgroundQCD = TFile::Open( fBackgroundNameQCD ); fBackgroundTTbar = TFile::Open( fBackgroundNameTTbar ); fBackgroundDiBoson = TFile::Open( fBackgroundNameDiBoson ); if(!fSignalVBF || !fBackgroundDYTauTau || !fBackgroundWJets || !fBackgroundQCD || !fBackgroundTTbar || !fSignalGGH || !fBackgroundDYMuMu || !fBackgroundDiBoson ){ std::cout << "ERROR: could not open files" << std::endl; exit(1); } TString tree = "outTreePtOrd"; TTree *signalVBF = (TTree*)fSignalVBF->Get(tree); TTree *signalGGH = (TTree*)fSignalGGH->Get(tree); TTree *backgroundDYTauTau = (TTree*)fBackgroundDYTauTau->Get(tree); TTree *backgroundDYMuMu = (TTree*)fBackgroundDYMuMu->Get(tree); TTree *backgroundWJets = (TTree*)fBackgroundWJets->Get(tree); TTree *backgroundQCD = (TTree*)fBackgroundQCD->Get(tree); TTree *backgroundTTbar = (TTree*)fBackgroundTTbar->Get(tree); TTree *backgroundDiBoson = (TTree*)fBackgroundDiBoson->Get(tree); // here I define the map between a sample name and its tree std::map<std::string,TTree*> tMap; tMap["ggH115"]=signalGGH; tMap["qqH115"]=signalVBF; tMap["Ztautau"]=backgroundDYTauTau; tMap["Zmumu"]=backgroundDYMuMu; tMap["Wjets"]=backgroundWJets; tMap["QCD"]=backgroundQCD; tMap["TTbar"]=backgroundTTbar; tMap["DiBoson"]=backgroundDiBoson; std::map<std::string,TTree*>::iterator jt; Float_t pt1_, pt2_; Float_t Deta_, Mjj_; Float_t Dphi,diTauSVFitPt,diTauSVFitEta,diTauVisMass,diTauSVFitMass,ptL1,ptL2,etaL1,etaL2,diTauCharge,MtLeg1,numPV,combRelIsoLeg1,sampleWeight,ptVeto,HLT; Int_t tightestHPSWP; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// // here I choose the order in the stack std::vector<string> samples; samples.push_back("ggH115"); samples.push_back("qqH115"); samples.push_back("DiBoson"); samples.push_back("TTbar"); samples.push_back("Wjets"); samples.push_back("Zmumu"); samples.push_back("Ztautau"); samples.push_back("QCD"); std::map<std::string,float> crossSec; crossSec["ggH115"]=( 7.65e-02 * 18.13 ); crossSec["qqH115"]=( 0.1012); crossSec["DiBoson"]=( -1 ); crossSec["TTbar"]=( 157.5 ); crossSec["Wjets"]=( 31314.0); crossSec["Zmumu"]=( 1666 ); crossSec["Ztautau"]=( 1666 ); crossSec["QCD"]=( 296600000*0.0002855 ); float Lumi = 1000; // here I choose the order in the stack std::vector<string> filters; filters.push_back("total"); filters.push_back("vertex"); filters.push_back("1-mu"); filters.push_back("0-e"); filters.push_back("mu-ID"); filters.push_back("tau-ID"); filters.push_back("Delta R mu-tau"); filters.push_back("mu-iso"); filters.push_back("tau-iso"); filters.push_back("Mt"); filters.push_back("OS"); filters.push_back("2-jets"); filters.push_back("VBF cuts"); filters.push_back("jet-veto"); filters.push_back("HLT"); // here I define the map between a sample name and its file ptr std::map<std::string,TFile*> fullMap; fullMap["ggH115"] = fFullSignalGGH; fullMap["qqH115"] = fFullSignalVBF; fullMap["Ztautau"] = fFullBackgroundDYTauTau; fullMap["Zmumu"] = fFullBackgroundDYMuMu; fullMap["Wjets"] = fFullBackgroundWJets; fullMap["QCD"] = fFullBackgroundQCD; fullMap["TTbar"] = fFullBackgroundTTbar; fullMap["DiBoson"] = fFullBackgroundDiBoson; std::map<std::string,TFile*>::iterator it; std::map<std::string,float> cutMap_allEventsFilter; std::map<std::string,float> cutMap_allEventsFilterE; for(it = fullMap.begin(); it != fullMap.end(); it++){ TH1F* allEvents = (TH1F*)(it->second)->Get("allEventsFilter/totalEvents"); float totalEvents = allEvents->GetBinContent(1); float totalEquivalentEvents = allEvents->GetEffectiveEntries(); float tot = totalEvents; if(crossSec[it->first]>0) tot *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; cutMap_allEventsFilter[it->first] = tot; cutMap_allEventsFilterE[it->first] = totalEquivalentEvents>0 ? sqrt(totalEquivalentEvents)*(tot/totalEquivalentEvents) : 0; } std::map<std::string,float> cutMap_vertexScrapingFilter; std::map<std::string,float> cutMap_vertexScrapingFilterE; for(it = fullMap.begin(); it != fullMap.end(); it++){ TH1F* allEvents = (TH1F*)(it->second)->Get("allEventsFilter/totalEvents"); float totalEvents = allEvents->GetBinContent(1); allEvents = (TH1F*)(it->second)->Get("vertexScrapingFilter/totalEvents"); float tot = allEvents->GetBinContent(1); float totalEquivalentEvents = allEvents->GetEffectiveEntries(); if(crossSec[it->first]>0){ tot *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; //totalEquivalentEvents *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; } cutMap_vertexScrapingFilter[it->first] = tot; cutMap_vertexScrapingFilterE[it->first] = totalEquivalentEvents>0 ? sqrt(totalEquivalentEvents)*(tot/totalEquivalentEvents) : 0; } std::map<std::string,float> cutMap_oneElectronFilter; std::map<std::string,float> cutMap_oneElectronFilterE; for(it = fullMap.begin(); it != fullMap.end(); it++){ TH1F* allEvents = (TH1F*)(it->second)->Get("allEventsFilter/totalEvents"); float totalEvents = allEvents->GetBinContent(1); allEvents = (TH1F*)(it->second)->Get("oneMuonFilter/totalEvents"); float tot = allEvents->GetBinContent(1); float totalEquivalentEvents = allEvents->GetEffectiveEntries(); if(crossSec[it->first]>0){ tot *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; //totalEquivalentEvents *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; } cutMap_oneElectronFilter[it->first] = tot; cutMap_oneElectronFilterE[it->first] = totalEquivalentEvents>0 ? sqrt(totalEquivalentEvents)*(tot/totalEquivalentEvents) : 0; } std::map<std::string,float> cutMap_noMuonFilter; std::map<std::string,float> cutMap_noMuonFilterE; for(it = fullMap.begin(); it != fullMap.end(); it++){ TH1F* allEvents = (TH1F*)(it->second)->Get("allEventsFilter/totalEvents"); float totalEvents = allEvents->GetBinContent(1); allEvents = (TH1F*)(it->second)->Get("noElecFilter/totalEvents"); float tot = allEvents->GetBinContent(1); float totalEquivalentEvents = allEvents->GetEffectiveEntries(); if(crossSec[it->first]>0){ tot *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; //totalEquivalentEvents *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; } cutMap_noMuonFilter[it->first] = tot; cutMap_noMuonFilterE[it->first] = totalEquivalentEvents>0 ? sqrt(totalEquivalentEvents)*(tot/totalEquivalentEvents) : 0; } std::map<std::string,float> cutMap_electronLegFilter; std::map<std::string,float> cutMap_electronLegFilterE; for(it = fullMap.begin(); it != fullMap.end(); it++){ TH1F* allEvents = (TH1F*)(it->second)->Get("allEventsFilter/totalEvents"); float totalEvents = allEvents->GetBinContent(1); allEvents = (TH1F*)(it->second)->Get("muonLegFilter/totalEvents"); float tot = allEvents->GetBinContent(1); float totalEquivalentEvents = allEvents->GetEffectiveEntries(); if(crossSec[it->first]>0){ tot *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; //totalEquivalentEvents *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; } cutMap_electronLegFilter[it->first] = tot; cutMap_electronLegFilterE[it->first] = totalEquivalentEvents>0 ? sqrt(totalEquivalentEvents)*(tot/totalEquivalentEvents) : 0; } std::map<std::string,float> cutMap_tauLegFilter; std::map<std::string,float> cutMap_tauLegFilterE; for(it = fullMap.begin(); it != fullMap.end(); it++){ TH1F* allEvents = (TH1F*)(it->second)->Get("allEventsFilter/totalEvents"); float totalEvents = allEvents->GetBinContent(1); allEvents = (TH1F*)(it->second)->Get("tauLegFilter/totalEvents"); float tot = allEvents->GetBinContent(1); float totalEquivalentEvents = allEvents->GetEffectiveEntries(); if(crossSec[it->first]>0){ tot *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; //totalEquivalentEvents *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; } cutMap_tauLegFilter[it->first] = tot; cutMap_tauLegFilterE[it->first] = totalEquivalentEvents>0 ? sqrt(totalEquivalentEvents)*(tot/totalEquivalentEvents) : 0; } std::map<std::string,float> cutMap_atLeastOneDiTauFilter; std::map<std::string,float> cutMap_atLeastOneDiTauFilterE; for(it = fullMap.begin(); it != fullMap.end(); it++){ TH1F* allEvents = (TH1F*)(it->second)->Get("allEventsFilter/totalEvents"); float totalEvents = allEvents->GetBinContent(1); allEvents = (TH1F*)(it->second)->Get("atLeastOneDiTauFilter/totalEvents"); float tot = allEvents->GetBinContent(1); float totalEquivalentEvents = allEvents->GetEffectiveEntries(); if(crossSec[it->first]>0){ tot *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; //totalEquivalentEvents *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; } cutMap_atLeastOneDiTauFilter[it->first] = tot; cutMap_atLeastOneDiTauFilterE[it->first] = totalEquivalentEvents>0 ? sqrt(totalEquivalentEvents)*(tot/totalEquivalentEvents) : 0; } std::map<std::string,float> cutMap_ElecIso; std::map<std::string,float> cutMap_ElecIsoE; for(it = fullMap.begin(); it != fullMap.end(); it++){ cout<<it->first<<endl; TH1F* allEvents = (TH1F*)(it->second)->Get("allEventsFilter/totalEvents"); float totalEvents = allEvents->GetBinContent(1); TH1F* h1 = new TH1F("h1","",1,-10,10); TCut cut = (crossSec[it->first]>0) ? "(chIsoLeg1+nhIsoLeg1+phIsoLeg1)/diTauLegsP4[0].Pt()<0.1" : "weight*((chIsoLeg1+nhIsoLeg1+phIsoLeg1)/diTauLegsP4[0].Pt()<0.1)"; ((TTree*) (it->second->Get("muTauStreamAnalyzer/tree")) )->Draw("diTauLegsP4[0].Eta()>>h1",cut); float tot = h1->Integral(); float totalEquivalentEvents = h1->GetEffectiveEntries(); if(crossSec[it->first]>0){ tot *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; //totalEquivalentEvents *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; } cutMap_ElecIso[it->first] = tot; cutMap_ElecIsoE[it->first] = totalEquivalentEvents>0 ? sqrt(totalEquivalentEvents)*(tot/totalEquivalentEvents) : 0; delete h1; } std::map<std::string,float> cutMap_TauIso; std::map<std::string,float> cutMap_TauIsoE; for(it = fullMap.begin(); it != fullMap.end(); it++){ cout<<it->first<<endl; TH1F* allEvents = (TH1F*)(it->second)->Get("allEventsFilter/totalEvents"); float totalEvents = allEvents->GetBinContent(1); TH1F* h1 = new TH1F("h1","",1,-10,10); TCut cut = (crossSec[it->first]>0) ? "(chIsoLeg1+nhIsoLeg1+phIsoLeg1)/diTauLegsP4[0].Pt()<0.1 && tightestHPSWP>0" : "weight*((chIsoLeg1+nhIsoLeg1+phIsoLeg1)/diTauLegsP4[0].Pt()<0.1 && tightestHPSWP>0)"; ((TTree*) (it->second->Get("muTauStreamAnalyzer/tree")) )->Draw("diTauLegsP4[0].Eta()>>h1",cut); float tot = h1->Integral(); float totalEquivalentEvents = h1->GetEffectiveEntries(); if(crossSec[it->first]>0){ tot *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; //totalEquivalentEvents *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; } cutMap_TauIso[it->first] = tot; cutMap_TauIsoE[it->first] = totalEquivalentEvents>0 ? sqrt(totalEquivalentEvents)*(tot/totalEquivalentEvents) : 0; delete h1; } std::map<std::string,float> cutMap_Mt; std::map<std::string,float> cutMap_MtE; for(it = fullMap.begin(); it != fullMap.end(); it++){ cout<<it->first<<endl; TH1F* allEvents = (TH1F*)(it->second)->Get("allEventsFilter/totalEvents"); float totalEvents = allEvents->GetBinContent(1); TH1F* h1 = new TH1F("h1","",1,-10,10); TCut cut = (crossSec[it->first]>0) ? "(chIsoLeg1+nhIsoLeg1+phIsoLeg1)/diTauLegsP4[0].Pt()<0.1 && tightestHPSWP>0 && MtLeg1<40" : "weight*((chIsoLeg1+nhIsoLeg1+phIsoLeg1)/diTauLegsP4[0].Pt()<0.1 && tightestHPSWP>0 && MtLeg1<40)"; ((TTree*) (it->second->Get("muTauStreamAnalyzer/tree")) )->Draw("diTauLegsP4[0].Eta()>>h1",cut); float tot = h1->Integral(); float totalEquivalentEvents = h1->GetEffectiveEntries(); if(crossSec[it->first]>0){ tot *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; //totalEquivalentEvents *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; } cutMap_Mt[it->first] = tot; cutMap_MtE[it->first] = totalEquivalentEvents>0 ? sqrt(totalEquivalentEvents)*(tot/totalEquivalentEvents) : 0; delete h1; } std::map<std::string,float> cutMap_OS; std::map<std::string,float> cutMap_OSE; for(it = fullMap.begin(); it != fullMap.end(); it++){ cout<<it->first<<endl; TH1F* allEvents = (TH1F*)(it->second)->Get("allEventsFilter/totalEvents"); float totalEvents = allEvents->GetBinContent(1); TH1F* h1 = new TH1F("h1","",1,-10,10); TCut cut = (crossSec[it->first]>0) ? "(chIsoLeg1+nhIsoLeg1+phIsoLeg1)/diTauLegsP4[0].Pt()<0.1 && tightestHPSWP>0 && diTauCharge==0 && MtLeg1<40" : "weight*((chIsoLeg1+nhIsoLeg1+phIsoLeg1)/diTauLegsP4[0].Pt()<0.1 && tightestHPSWP>0 && diTauCharge==0 && MtLeg1<40)"; ((TTree*) (it->second->Get("muTauStreamAnalyzer/tree")) )->Draw("diTauLegsP4[0].Eta()>>h1",cut); float tot = h1->Integral(); float totalEquivalentEvents = h1->GetEffectiveEntries(); if(crossSec[it->first]>0){ tot *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; //totalEquivalentEvents *= (Lumi/ (totalEvents/crossSec[it->first]) ) ; } cutMap_OS[it->first] = tot; cutMap_OSE[it->first] = totalEquivalentEvents>0 ? sqrt(totalEquivalentEvents)*(tot/totalEquivalentEvents) : 0; delete h1; } std::map<std::string,float> cutMap_VBFPre; std::map<std::string,float> cutMap_VBFPreE; for(jt = tMap.begin(); jt != tMap.end(); jt++){ cout<<jt->first<<endl; TH1F* h1 = new TH1F("h1","",1,-10,10); TCut cut = "sampleWeight*(pt1>0 && combRelIsoLeg1<0.1 && tightestHPSWP>0 && diTauCharge==0 && MtLeg1<40)"; jt->second->Draw("etaL1>>h1",cut); float tot = h1->Integral(); float totalEquivalentEvents = h1->GetEffectiveEntries(); cutMap_VBFPre[jt->first] = tot; cutMap_VBFPreE[jt->first] = totalEquivalentEvents>0 ? sqrt(totalEquivalentEvents)*(tot/totalEquivalentEvents) : 0; delete h1; } std::map<std::string,float> cutMap_VBF; std::map<std::string,float> cutMap_VBFE; std::map<std::string,float> cutMap_JetVeto; std::map<std::string,float> cutMap_JetVetoE; std::map<std::string,float> cutMap_HLT; std::map<std::string,float> cutMap_HLTE; for(jt = tMap.begin(); jt != tMap.end(); jt++){ cout<<jt->first<<endl; TCut cut = "(pt1>0 && combRelIsoLeg1<0.1 && tightestHPSWP>0 && diTauCharge==0 && MtLeg1<40)"; TFile* dummy = new TFile("dummy.root","RECREATE"); TTree* currentTree = (TTree*)(jt->second)->CopyTree(cut); float tot = 0; int counter = 0; float tot2 = 0; int counter2 = 0; float tot3 = 0; int counter3 = 0; currentTree->SetBranchAddress( "pt1", &pt1_ ); currentTree->SetBranchAddress( "pt2", &pt2_ ); currentTree->SetBranchAddress( "Deta",&Deta_ ); currentTree->SetBranchAddress( "Mjj", &Mjj_ ); currentTree->SetBranchAddress( "diTauSVFitPt",&diTauSVFitPt); //currentTree->SetBranchAddress( "diTauSVFitEta",&diTauSVFitEta); currentTree->SetBranchAddress( "diTauSVFitMass",&diTauSVFitMass); currentTree->SetBranchAddress( "diTauVisMass",&diTauVisMass); currentTree->SetBranchAddress( "ptL1", &ptL1 ); currentTree->SetBranchAddress( "ptL2", &ptL2 ); currentTree->SetBranchAddress( "etaL1", &etaL1 ); currentTree->SetBranchAddress( "etaL2", &etaL2 ); currentTree->SetBranchAddress( "combRelIsoLeg1",&combRelIsoLeg1); currentTree->SetBranchAddress( "tightestHPSWP",&tightestHPSWP); currentTree->SetBranchAddress( "diTauCharge",&diTauCharge); currentTree->SetBranchAddress( "MtLeg1",&MtLeg1); currentTree->SetBranchAddress( "numPV",&numPV); currentTree->SetBranchAddress( "sampleWeight",&sampleWeight); currentTree->SetBranchAddress( "ptVeto",&ptVeto); currentTree->SetBranchAddress( "HLT",&HLT); for (Long64_t ievt=0; ievt<currentTree->GetEntries();ievt++) { currentTree->GetEntry(ievt); if (ievt%10000 == 0){ std::cout << (jt->first) << " ---> processing event: " << ievt << " ..." <<std::endl; } pt1 = pt1_; pt2 = pt2_; Deta = Deta_; Mjj = Mjj_; bool pass = effS_>0 ? reader->EvaluateMVA( "Cuts", effS_ ) : (pt1>0); if(pass){ tot+=sampleWeight; counter++; if(ptVeto<20){ tot2+=sampleWeight; counter2++; if(HLT>0.5 && HLT<1.5){ tot3+=sampleWeight; counter3++; } } } }// end loop cutMap_VBF[jt->first] = tot; cutMap_VBFE[jt->first] = counter>0 ? sqrt(counter)*tot/counter : 0; cutMap_JetVeto[jt->first] = tot2; cutMap_JetVetoE[jt->first] = counter2>0 ? sqrt(counter2)*tot2/counter2 : 0; cutMap_HLT[jt->first] = tot3; cutMap_HLTE[jt->first] = counter3>0 ? sqrt(counter3)*tot3/counter3 : 0; } std::vector< std::map<std::string,float> > allFilters; allFilters.push_back(cutMap_allEventsFilter); allFilters.push_back(cutMap_vertexScrapingFilter); allFilters.push_back(cutMap_oneElectronFilter); allFilters.push_back(cutMap_noMuonFilter); allFilters.push_back(cutMap_electronLegFilter); allFilters.push_back(cutMap_tauLegFilter); allFilters.push_back(cutMap_atLeastOneDiTauFilter); allFilters.push_back(cutMap_ElecIso); allFilters.push_back(cutMap_TauIso); allFilters.push_back(cutMap_Mt); allFilters.push_back(cutMap_OS); allFilters.push_back(cutMap_VBFPre); allFilters.push_back(cutMap_VBF); allFilters.push_back(cutMap_JetVeto); allFilters.push_back(cutMap_HLT); std::vector< std::map<std::string,float> > allFiltersE; allFiltersE.push_back(cutMap_allEventsFilterE); allFiltersE.push_back(cutMap_vertexScrapingFilterE); allFiltersE.push_back(cutMap_oneElectronFilterE); allFiltersE.push_back(cutMap_noMuonFilterE); allFiltersE.push_back(cutMap_electronLegFilterE); allFiltersE.push_back(cutMap_tauLegFilterE); allFiltersE.push_back(cutMap_atLeastOneDiTauFilterE); allFiltersE.push_back(cutMap_ElecIsoE); allFiltersE.push_back(cutMap_TauIsoE); allFiltersE.push_back(cutMap_MtE); allFiltersE.push_back(cutMap_OSE); allFiltersE.push_back(cutMap_VBFPreE); allFiltersE.push_back(cutMap_VBFE); allFiltersE.push_back(cutMap_JetVetoE); allFiltersE.push_back(cutMap_HLTE); //out<<"\\begin{center}"<<endl; out<<"\\begin{tabular}[!htbp]{|c"; for(int k = 0 ; k < samples.size(); k++) out<<"|c"; out<<"|} \\hline"<<endl; out<< "Cut & "; for(int k = 0 ; k < samples.size(); k++){ out << (fullMap.find(samples[k]))->first; if(k!=samples.size()-1) out <<" & " ; else out << " \\\\ " << endl; } out << " \\hline" << endl; for(int i = 0; i < allFilters.size(); i++){ out << filters[i] << " & "; for(int k = 0 ; k < samples.size(); k++){ out << (allFilters[i].find(samples[k]))->second << " $\\pm$ " << (allFiltersE[i].find(samples[k]))->second; if(k!=samples.size()-1) out <<" & " ; else out << " \\\\ " << endl; } out << " \\hline" << endl; } out<<"\\end{tabular}"<<endl; //out<<"\\end{center}"<<endl; return; }
double TrimEventContent(Int_t iRapBin = 1, Int_t iPTBin = 1, Double_t fracL = 0.5, Double_t nSigma = 2., Int_t nUpsState=0,//[0]... 1S, [1]... 2S, [2]... 3S bool UpsMC=false, bool f_BG_zero=false, bool ProjectLSBdata=false, bool ProjectRSBdata=false, bool CombineSignalPeaks=false, bool Y1Sto2S_SB=false, bool LeftSided=false, bool RightSided=false, bool MassScan=false, bool adjustOverlapBorders=true ){ printf("\n\n\nfracL = %1.3f, nSigma = %1.1f, iState = %d, rap %d, pT %d\n", fracL, nSigma, nUpsState, iRapBin, iPTBin); Char_t name[100], title[100]; Char_t fileNameIn[100]; sprintf(fileNameIn, "tmpFiles/data_Ups_rap%d_pT%d.root", iRapBin, iPTBin); //============================== //read inputs from input file: TFile *fIn = new TFile(fileNameIn); TLorentzVector *lepP; TLorentzVector *lepN; TTree *treeIn = (TTree *) gDirectory->Get("selectedData"); if(gDirectory->Get("selectedData")==NULL){ printf("\n\n\nskip processing this bin.\n\n\n"); return -999.; } TH2D *hBG_cosThetaPhiLR[onia::kNbFrames][2]; for(int iFrame = 0; iFrame < onia::kNbFrames; iFrame++){ sprintf(name, "hBG_cosThetaPhi_%s_L", onia::frameLabel[iFrame]); hBG_cosThetaPhiLR[iFrame][L] = (TH2D *) gDirectory->Get(name); sprintf(name, "hBG_cosThetaPhi_%s_R", onia::frameLabel[iFrame]); hBG_cosThetaPhiLR[iFrame][R] = (TH2D *) gDirectory->Get(name); } //============================== //definition of output variables Char_t fileNameOut[100]; sprintf(fileNameOut, "AllStates_%1.2fSigma_FracLSB%dPercent/data_%dSUps_rap%d_pT%d.root", nSigma, int(fracL*100), nUpsState+1, iRapBin, iPTBin); TFile *fOut = new TFile(fileNameOut, "RECREATE"); gStyle->SetPadRightMargin(0.2); TTree *treeOut = treeIn->CloneTree(0); // treeOut->SetName("data"); TH2D *hBG_cosThetaPhi[onia::kNbFrames]; // TH2D *hBG_cosThetaPhiSignal[onia::kNbFrames]; for(int iFrame = 0; iFrame < onia::kNbFrames; iFrame++){ // //book the histo for the signal // sprintf(name, "total_%s", onia::frameLabel[iFrame]); // sprintf(title, ";cos#theta_{%s};#phi_{%s} [deg]", onia::frameLabel[iFrame], onia::frameLabel[iFrame]); // hBG_cosThetaPhiSignal[iFrame] = new TH2D(name, title, onia::kNbBinsCosT, onia::cosTMin, onia::cosTMax, // onia::kNbBinsPhiPol, onia::phiPolMin, onia::phiPolMax); // hBG_cosThetaPhiSignal[iFrame]->Sumw2(); //copy the L and R sideband histos into one output BG histogram hBG_cosThetaPhiLR[iFrame][L]->Scale(fracL/hBG_cosThetaPhiLR[iFrame][L]->Integral()); hBG_cosThetaPhiLR[iFrame][R]->Scale((1.-fracL)/hBG_cosThetaPhiLR[iFrame][R]->Integral()); sprintf(name, "background_costhphi%s", onia::frameLabel[iFrame]); hBG_cosThetaPhi[iFrame] = (TH2D *) hBG_cosThetaPhiLR[iFrame][L]->Clone(name); hBG_cosThetaPhi[iFrame]->Add(hBG_cosThetaPhiLR[iFrame][R]); } //========================================================== //reading fit parameters to establish signal mass window //as well as the L and R sideband window for the 3D BG histo //========================================================== fIn->cd(); TTree *treeFitPar = (TTree *) gDirectory->Get("massFitParameters"); TF1 *fUps[kNbSpecies], *fBG = 0; fUps[0] = 0, fUps[1] = 0, fUps[2] = 0; treeFitPar->SetBranchAddress("fUps1S", &fUps[0]); treeFitPar->SetBranchAddress("fUps2S", &fUps[1]); treeFitPar->SetBranchAddress("fUps3S", &fUps[2]); treeFitPar->SetBranchAddress("fBG", &fBG); treeFitPar->LoadTree(0); treeFitPar->GetEntry(0); Double_t mass[kNbSpecies], sigma[kNbSpecies]; for(int iState = 0; iState < kNbSpecies; iState++){ mass[iState] = fUps[iState]->GetParameter(1); sigma[iState] = fUps[iState]->GetParameter(2); } printf("1S: mass = %1.3f GeV, sigma = %1.3f GeV\n", mass[UPS1S], sigma[UPS1S]); printf("2S: mass = %1.3f GeV, sigma = %1.3f GeV\n", mass[UPS2S], sigma[UPS2S]); printf("3S: mass = %1.3f GeV, sigma = %1.3f GeV\n", mass[UPS3S], sigma[UPS3S]); Double_t poleMass = mass[nUpsState], massMin, massMax; massMin = poleMass - nSigma*sigma[nUpsState]; massMax = poleMass + nSigma*sigma[nUpsState]; if(LeftSided){ massMin = poleMass - nSigma*sigma[nUpsState]; massMax = poleMass; } if(RightSided){ massMin = poleMass; massMax = poleMass + nSigma*sigma[nUpsState]; } // massMin = poleMass - 3.*sigma[nUpsState]; // massMax = poleMass - 1.*sigma[nUpsState]; // massMin = poleMass + 1.*sigma[nUpsState]; // massMax = poleMass + 3.*sigma[nUpsState]; cout<<"massMin = "<<massMin<<endl; cout<<"massMax = "<<massMax<<endl; if(adjustOverlapBorders){ if( nUpsState==2 && mass[2]-nSigma*sigma[2]<mass[1]+nSigma*sigma[1] ){ cout<<"adjusting lower border of Y(3S) mass window due to overlap"<<endl; massMin=(sigma[2]*mass[1]+sigma[1]*mass[2])/(sigma[1]+sigma[2]); } if( nUpsState==1 && mass[1]-nSigma*sigma[1]<mass[0]+nSigma*sigma[0] ){ cout<<"adjusting lower border of Y(2S) mass window due to overlap"<<endl; massMin=(sigma[1]*mass[0]+sigma[0]*mass[1])/(sigma[1]+sigma[0]); } if( nUpsState==1 && mass[2]-nSigma*sigma[2]<mass[1]+nSigma*sigma[1] ){ cout<<"adjusting upper border of Y(2S) mass window due to overlap"<<endl; massMax=(sigma[2]*mass[1]+sigma[1]*mass[2])/(sigma[1]+sigma[2]); } if( nUpsState==0 && mass[1]-nSigma*sigma[1]<mass[0]+nSigma*sigma[0] ){ cout<<"adjusting upper border of Y(1S) mass window due to overlap"<<endl; massMax=(sigma[1]*mass[0]+sigma[0]*mass[1])/(sigma[1]+sigma[0]); } } if( nUpsState==0){ contamination2Sin1S=fUps[1]->Integral(massMin, massMax)/(fUps[0]->Integral(massMin, massMax)+fUps[1]->Integral(massMin, massMax)); cout<<"Contamination of the 1S sample by 2S events = "<<contamination2Sin1S*100<<" %"<<endl; } if( nUpsState==1){ contamination1Sin2S=fUps[0]->Integral(massMin, massMax)/(fUps[0]->Integral(massMin, massMax)+fUps[1]->Integral(massMin, massMax)); contamination3Sin2S=fUps[2]->Integral(massMin, massMax)/(fUps[2]->Integral(massMin, massMax)+fUps[1]->Integral(massMin, massMax)); cout<<"Contamination of the 2S sample by 1S events = "<<contamination1Sin2S*100<<" %"<<endl; cout<<"Contamination of the 2S sample by 3S events = "<<contamination3Sin2S*100<<" %"<<endl; } if( nUpsState==2){ contamination2Sin3S=fUps[1]->Integral(massMin, massMax)/(fUps[2]->Integral(massMin, massMax)+fUps[1]->Integral(massMin, massMax)); cout<<"Contamination of the 3S sample by 2S events = "<<contamination2Sin3S*100<<" %"<<endl; } if(CombineSignalPeaks) { massMin=9.15; massMax=10.65; } if(Y1Sto2S_SB){ massMin = mass[0] + 3.*sigma[0]; massMax = mass[1] - 4.*sigma[1]; } ////////////////// Background mass scan const int nMassScan=12; int nMassScanCurrent; //double MassScanBorders[nMassScan+1] = {8.6, 8.95, 9.3, 9.45, 9.6, 9.85, 10.0125, 10.175, 10.3425, 10.51, 10.8, 11.1, 11.4}; double MassScanBorders[nMassScan+1] = {8.6, 8.95, 9.3, 9.45, 9.6, 9.85, 10.0125, 10.175, 10.3425, 10.51, 10.8, 11.1, 11.4}; for(int i=1;i<nMassScan+1;i++){ if(nSigma<i+0.5) {nMassScanCurrent=i; break;} } double BuffMinL=onia::massMinL; double BuffMaxL=mass[UPS1S] - onia::nSigmaL*sigma[UPS1S]; double BuffMinR=mass[UPS3S] + onia::nSigmaR*sigma[UPS3S]; double BuffMaxR=onia::massMaxR; double MassScanMin=MassScanBorders[nMassScanCurrent-1]; double MassScanMax=MassScanBorders[nMassScanCurrent]; if(nSigma==1){ MassScanMin=BuffMinL; MassScanMax=BuffMinL+1./3.*(BuffMaxL-BuffMinL); } if(nSigma==2){ MassScanMin=BuffMinL+1./3.*(BuffMaxL-BuffMinL); MassScanMax=BuffMinL+2./3.*(BuffMaxL-BuffMinL); } if(nSigma==3){ MassScanMin=BuffMinL+2./3.*(BuffMaxL-BuffMinL); MassScanMax=BuffMaxL; } if(nSigma==4){ MassScanMin=BuffMinL; MassScanMax=BuffMaxL; } if(nSigma==5){ MassScanMin=BuffMinR; MassScanMax=BuffMinR+1./3.*(BuffMaxR-BuffMinR); } if(nSigma==6){ MassScanMin=BuffMinR+1./3.*(BuffMaxR-BuffMinR); MassScanMax=BuffMinR+2./3.*(BuffMaxR-BuffMinR); } if(nSigma==7){ MassScanMin=BuffMinR+2./3.*(BuffMaxR-BuffMinR); MassScanMax=BuffMaxR; } if(nSigma==8){ MassScanMin=BuffMinR; MassScanMax=BuffMaxR; } if(nSigma>8){ BuffMaxL=mass[UPS1S] - 7*sigma[UPS1S]; BuffMinR=mass[UPS3S] + onia::nSigmaR*sigma[UPS3S]; } if(nSigma==9){ MassScanMin=BuffMinL; MassScanMax=BuffMinL+1./3.*(BuffMaxL-BuffMinL); } if(nSigma==10){ MassScanMin=BuffMinL+1./3.*(BuffMaxL-BuffMinL); MassScanMax=BuffMinL+2./3.*(BuffMaxL-BuffMinL); } if(nSigma==11){ MassScanMin=BuffMinL+2./3.*(BuffMaxL-BuffMinL); MassScanMax=BuffMaxL; } if(nSigma==12){ MassScanMin=BuffMinL; MassScanMax=BuffMaxL; } if(MassScan){ massMin=MassScanMin; massMax=MassScanMax; } ///////////////////////////////////// printf("--> signal mass window: %1.3f < M < %1.3f GeV\n", massMin, massMax); //calculate the fraction of BG under the signal mass window Double_t nBG = fBG->Integral(massMin, massMax); // Double_t nSignal = fUps[nUpsState]->Integral(massMin, massMax); Double_t nSignal = fUps[0]->Integral(massMin, massMax)+fUps[1]->Integral(massMin, massMax)+fUps[2]->Integral(massMin, massMax); Double_t fracBG = nBG / (nBG + nSignal); sprintf(name, ";;fraction of BG in %1.1f sigma window", nSigma); TH1D *hFracBG = new TH1D("background_fraction", name, 1, 0., 1.); if(!UpsMC&&!f_BG_zero) hFracBG->SetBinContent(1, fracBG); if(UpsMC||f_BG_zero) hFracBG->SetBinContent(1, 0.001); /* fBG->ReleaseParameter(1); cout<<"fBG "<<fBG->Integral(massMin, massMax) / (fBG->Integral(massMin, massMax) + fUps[nUpsState]->Integral(massMin, massMax))<<endl; double fBGPar0=fBG->GetParameter(1); double err_fBGPar0=fBG->GetParError(1); cout<<"fBGPar0 "<<fBGPar0<<endl; cout<<"err_fBGPar0 "<<err_fBGPar0<<endl; fBG->FixParameter(1,fBGPar0+100*err_fBGPar0); cout<<"fBGPar0 "<<fBG->GetParameter(1)<<endl; cout<<"fBG "<<fBG->Integral(massMin, massMax) / (fBG->Integral(massMin, massMax) + fUps[nUpsState]->Integral(massMin, massMax))<<endl; fBG->SetParameter(1,fBGPar0); cout<<"fBG "<<fBG->Integral(massMin, massMax) / (fBG->Integral(massMin, massMax) + fUps[nUpsState]->Integral(massMin, massMax))<<endl; */ if(Y1Sto2S_SB){ cout<<"Y1Sto2S_SB fBG = "<<fBG->Integral(massMin, massMax) / (fBG->Integral(massMin, massMax) + fUps[0]->Integral(massMin, massMax)+fUps[1]->Integral(massMin, massMax))<<endl; } backgroundFrac=fracBG; //calculate the L and R mass windows: Double_t massMinBG[2], massMaxBG[2]; massMinBG[L] = onia::massMinL; massMaxBG[L] = mass[UPS1S] - onia::nSigmaL*sigma[UPS1S]; massMinBG[R] = mass[UPS3S] + onia::nSigmaR*sigma[UPS3S]; massMaxBG[R] = onia::massMaxR; printf("--> L mass window: %1.3f < M < %1.3f GeV\n", massMinBG[L], massMaxBG[L]); printf("--> R mass window: %1.3f < M < %1.3f GeV\n", massMinBG[R], massMaxBG[R]); //cout<<"here?"<<endl; bool PseudoBin=false; if(CombineSignalPeaks) { massMin=9.15; massMax=10.65; } if(!UpsMC){ if(massMaxBG[L] > massMin){ printf("the right sideband window is LARGER than the left signal window!!!!\n\n\n\n"); massMaxBG[L]=9.; massMinBG[L]=8.6; massMin=9.; PseudoBin=true; // exit(0); } if(massMinBG[R] < massMax){ printf("the left sideband window is SMALLER than the right signal window!!!!\n\n\n\n"); massMaxBG[R]=11.4; massMinBG[R]=11.; massMax=10.; PseudoBin=true; // exit(0); } } if(ProjectLSBdata){ massMin=massMinBG[L]; massMax=massMaxBG[L]; } if(ProjectRSBdata){ massMin=massMinBG[R]; massMax=massMaxBG[R]; } if(CombineSignalPeaks) { massMin=9.15; massMax=10.65; } double meanMass=0; double MassDistCurrent=0.001; TH1D *hMassScanInfo = new TH1D("hMassScanInfo", "hMassScanInfo", 2, 0., 1.); if(MassScan){ massMin=MassScanMin; massMax=MassScanMax; double IntCurrent = fBG->Integral(massMin, massMax); for(int i=1;i<1000000;i++){ if(fBG->Integral(massMin, massMin+i*MassDistCurrent)>IntCurrent/2.) {meanMass=massMin+i*MassDistCurrent; break;} } hMassScanInfo->SetBinContent(1,meanMass); hMassScanInfo->SetBinContent(2,1-fracBG); } if(Y1Sto2S_SB){ massMin = mass[0] + 3.*sigma[0]; massMax = mass[1] - 4.*sigma[1]; double IntCurrent = fBG->Integral(massMin, massMax); for(int i=1;i<1000000;i++){ if(fBG->Integral(massMin, massMin+i*MassDistCurrent)>IntCurrent/2.) {meanMass=massMin+i*MassDistCurrent; break;} } hMassScanInfo->SetBinContent(1,meanMass); hMassScanInfo->SetBinContent(2,1-fracBG); } if(UpsMC&&iPTBin>5&&fracL<0.35){ cout<<"using exact mass window definition of data"<<endl; Double_t massMinUps1S_1sigma[3][10] = { {0,0,0,0,0, 0,0,0,0,0}, {0,0,0,0,0, 9.38372, 9.38435, 9.38425, 9.38487, 9.38326}, {0,0,0,0,0, 9.35644, 9.3574, 9.35555, 9.35522, 9.34896}}; Double_t massMaxUps1S_1sigma[3][10] = { {0,0,0,0,0, 0,0,0,0,0}, {0,0,0,0,0, 9.518, 9.51711, 9.51826, 9.51701, 9.51941}, {0,0,0,0,0, 9.53728, 9.53853, 9.5394, 9.54169, 9.54538}}; Double_t massMinUps2S_1sigma[3][10] = { {0,0,0,0,0, 0,0,0,0,0}, {0,0,0,0,0, 9.94218, 9.94285, 9.94275, 9.9434, 9.94169}, {0,0,0,0,0, 9.91328, 9.91429, 9.91234, 9.91198, 9.90535}}; Double_t massMaxUps2S_1sigma[3][10] = { {0,0,0,0,0, 0,0,0,0,0}, {0,0,0,0,0, 10.0844, 10.0835, 10.0847, 10.0834, 10.086}, {0,0,0,0,0, 10.1049, 10.1062, 10.1071, 10.1096, 10.1135}}; Double_t massMinUps3S_1sigma[3][10] = { {0,0,0,0,0, 0,0,0,0,0}, {0,0,0,0,0, 10.2715, 10.2722, 10.2721, 10.2728, 10.271}, {0,0,0,0,0, 10.2416, 10.2427, 10.2407, 10.2403, 10.2335}}; Double_t massMaxUps3S_1sigma[3][10] = { {0,0,0,0,0, 0,0,0,0,0}, {0,0,0,0,0, 10.4185, 10.4175, 10.4188, 10.4174, 10.42}, {0,0,0,0,0, 10.4396, 10.441, 10.4419, 10.4444, 10.4485}}; //============================= Double_t massMinUps1S_3sigma[3][10] = { {0,0,0,0,0, 0,0,0,0,0}, {0,0,0,0,0, 9.24945, 9.2516, 9.25025, 9.25273, 9.24711}, {0,0,0,0,0, 9.1756, 9.17626, 9.17171, 9.16874, 9.15253}}; Double_t massMaxUps1S_3sigma[3][10] = { {0,0,0,0,0, 0,0,0,0,0}, {0,0,0,0,0, 9.65227, 9.64987, 9.65227, 9.64915, 9.65557}, {0,0,0,0,0, 9.71811, 9.71966, 9.72048, 9.72149, 9.72017}}; Double_t massMinUps2S_3sigma[3][10] = { {0,0,0,0,0, 0,0,0,0,0}, {0,0,0,0,0, 9.79992, 9.80219, 9.80076, 9.80339, 9.79744}, {0,0,0,0,0, 9.72168, 9.72238, 9.72048, 9.72149, 9.72017}}; Double_t massMaxUps2S_3sigma[3][10] = { {0,0,0,0,0, 0,0,0,0,0}, {0,0,0,0,0, 10.1765, 10.1763, 10.1769, 10.1765, 10.177}, {0,0,0,0,0, 10.1721, 10.1733, 10.1728, 10.1739, 10.1725}}; Double_t massMinUps3S_3sigma[3][10] = { {0,0,0,0,0, 0,0,0,0,0}, {0,0,0,0,0, 10.1765, 10.1763, 10.1769, 10.1765, 10.177}, {0,0,0,0,0, 10.1721, 10.1733, 10.1728, 10.1739, 10.1725}}; Double_t massMaxUps3S_3sigma[3][10] = { {0,0,0,0,0, 0,0,0,0,0}, {0,0,0,0,0, 10.5655, 10.5628, 10.5655, 10.562, 10.5691}, {0,0,0,0,0, 10.6375, 10.6392, 10.6432, 10.6485, 10.6635}}; if(nSigma==1){ if(nUpsState==0){ massMin=massMinUps1S_1sigma[iRapBin][iPTBin-1]; massMax=massMaxUps1S_1sigma[iRapBin][iPTBin-1]; } if(nUpsState==1){ massMin=massMinUps2S_1sigma[iRapBin][iPTBin-1]; massMax=massMaxUps2S_1sigma[iRapBin][iPTBin-1]; } if(nUpsState==2){ massMin=massMinUps3S_1sigma[iRapBin][iPTBin-1]; massMax=massMaxUps3S_1sigma[iRapBin][iPTBin-1]; } } if(nSigma==3){ if(nUpsState==0){ massMin=massMinUps1S_3sigma[iRapBin][iPTBin-1]; massMax=massMaxUps1S_3sigma[iRapBin][iPTBin-1]; } if(nUpsState==1){ massMin=massMinUps2S_3sigma[iRapBin][iPTBin-1]; massMax=massMaxUps2S_3sigma[iRapBin][iPTBin-1]; } if(nUpsState==2){ massMin=massMinUps3S_3sigma[iRapBin][iPTBin-1]; massMax=massMaxUps3S_3sigma[iRapBin][iPTBin-1]; } } if(nSigma==0.5){ if(nUpsState==0){ massMin=massMinUps1S_1sigma[iRapBin][iPTBin-1]+(massMaxUps1S_1sigma[iRapBin][iPTBin-1]-massMinUps1S_1sigma[iRapBin][iPTBin-1])/4.; massMax=massMaxUps1S_1sigma[iRapBin][iPTBin-1]-(massMaxUps1S_1sigma[iRapBin][iPTBin-1]-massMinUps1S_1sigma[iRapBin][iPTBin-1])/4.; } if(nUpsState==1){ massMin=massMinUps2S_1sigma[iRapBin][iPTBin-1]+(massMaxUps2S_1sigma[iRapBin][iPTBin-1]-massMinUps2S_1sigma[iRapBin][iPTBin-1])/4.; massMax=massMaxUps2S_1sigma[iRapBin][iPTBin-1]-(massMaxUps2S_1sigma[iRapBin][iPTBin-1]-massMinUps2S_1sigma[iRapBin][iPTBin-1])/4.; } if(nUpsState==2){ massMin=massMinUps3S_1sigma[iRapBin][iPTBin-1]+(massMaxUps3S_1sigma[iRapBin][iPTBin-1]-massMinUps3S_1sigma[iRapBin][iPTBin-1])/4.; massMax=massMaxUps3S_1sigma[iRapBin][iPTBin-1]-(massMaxUps3S_1sigma[iRapBin][iPTBin-1]-massMinUps3S_1sigma[iRapBin][iPTBin-1])/4.; } } if(nSigma==0.1){ if(nUpsState==0){ massMin=massMinUps1S_1sigma[iRapBin][iPTBin-1]+(massMaxUps1S_1sigma[iRapBin][iPTBin-1]-massMinUps1S_1sigma[iRapBin][iPTBin-1])/20.; massMax=massMaxUps1S_1sigma[iRapBin][iPTBin-1]-(massMaxUps1S_1sigma[iRapBin][iPTBin-1]-massMinUps1S_1sigma[iRapBin][iPTBin-1])/20.; } if(nUpsState==1){ massMin=massMinUps2S_1sigma[iRapBin][iPTBin-1]+(massMaxUps2S_1sigma[iRapBin][iPTBin-1]-massMinUps2S_1sigma[iRapBin][iPTBin-1])/20.; massMax=massMaxUps2S_1sigma[iRapBin][iPTBin-1]-(massMaxUps2S_1sigma[iRapBin][iPTBin-1]-massMinUps2S_1sigma[iRapBin][iPTBin-1])/20.; } if(nUpsState==2){ massMin=massMinUps3S_1sigma[iRapBin][iPTBin-1]+(massMaxUps3S_1sigma[iRapBin][iPTBin-1]-massMinUps3S_1sigma[iRapBin][iPTBin-1])/20.; massMax=massMaxUps3S_1sigma[iRapBin][iPTBin-1]-(massMaxUps3S_1sigma[iRapBin][iPTBin-1]-massMinUps3S_1sigma[iRapBin][iPTBin-1])/20.; } } if(nSigma==9){ if(nUpsState==0){ massMin=massMinUps1S_1sigma[iRapBin][iPTBin-1]; massMax=massMaxUps1S_1sigma[iRapBin][iPTBin-1]-(massMaxUps1S_1sigma[iRapBin][iPTBin-1]-massMinUps1S_1sigma[iRapBin][iPTBin-1])/2.; } if(nUpsState==1){ massMin=massMinUps2S_1sigma[iRapBin][iPTBin-1]; massMax=massMaxUps2S_1sigma[iRapBin][iPTBin-1]-(massMaxUps2S_1sigma[iRapBin][iPTBin-1]-massMinUps2S_1sigma[iRapBin][iPTBin-1])/2.; } if(nUpsState==2){ massMin=massMinUps3S_1sigma[iRapBin][iPTBin-1]; massMax=massMaxUps3S_1sigma[iRapBin][iPTBin-1]-(massMaxUps3S_1sigma[iRapBin][iPTBin-1]-massMinUps3S_1sigma[iRapBin][iPTBin-1])/2.; } } if(nSigma==10){ if(nUpsState==0){ massMax=massMaxUps1S_1sigma[iRapBin][iPTBin-1]; massMin=massMaxUps1S_1sigma[iRapBin][iPTBin-1]-(massMaxUps1S_1sigma[iRapBin][iPTBin-1]-massMinUps1S_1sigma[iRapBin][iPTBin-1])/2.; } if(nUpsState==1){ massMax=massMaxUps2S_1sigma[iRapBin][iPTBin-1]; massMin=massMaxUps2S_1sigma[iRapBin][iPTBin-1]-(massMaxUps2S_1sigma[iRapBin][iPTBin-1]-massMinUps2S_1sigma[iRapBin][iPTBin-1])/2.; } if(nUpsState==2){ massMax=massMaxUps3S_1sigma[iRapBin][iPTBin-1]; massMin=massMaxUps3S_1sigma[iRapBin][iPTBin-1]-(massMaxUps3S_1sigma[iRapBin][iPTBin-1]-massMinUps3S_1sigma[iRapBin][iPTBin-1])/2.; } } } ActualMassMin=massMin; ActualMassMax=massMax; //calculate central fracL double fracLCentral; if(!f_BG_zero){ double mean_LSB; double mean_RSB; double mean_nS; double MassDist=0.001; double IntLSB = fBG->Integral(massMinBG[L], massMaxBG[L]); for(int i=1;i<1000000;i++){ if(fBG->Integral(massMinBG[L], massMinBG[L]+i*MassDist)>IntLSB/2.) {mean_LSB=massMinBG[L]+i*MassDist; break;} } double IntRSB = fBG->Integral(massMinBG[R], massMaxBG[R]); for(int i=1;i<1000000;i++){ if(fBG->Integral(massMinBG[R], massMinBG[R]+i*MassDist)>IntRSB/2.) {mean_RSB=massMinBG[R]+i*MassDist; break;} } double IntSig = fBG->Integral(massMin, massMax); for(int i=1;i<1000000;i++){ if(fBG->Integral(massMin, massMin+i*MassDist)>IntSig/2.) {mean_nS=massMin+i*MassDist; break;} } fracLCentral=1-(mean_nS-mean_LSB)/(mean_RSB-mean_LSB); cout<<"Median LSB: "<<mean_LSB<<endl; cout<<"Median RSB: "<<mean_RSB<<endl; cout<<"Median signal region: "<<mean_nS<<endl; cout<<"Central FracL: "<<fracLCentral<<endl; } //build the 3D (pT, |y|, M) histos for the L and R mass sideband TH3D *hBG_pTRapMass[2]; hBG_pTRapMass[L] = new TH3D("hBG_pTRapMass_L", ";p_{T} [GeV/c]; |y|; M [GeV]", 7, onia::pTRange[iRapBin][iPTBin-1], onia::pTRange[iRapBin][iPTBin], 2, onia::rapForPTRange[iRapBin-1], onia::rapForPTRange[iRapBin], 7, massMin, massMax);//*signal* mass window! hBG_pTRapMass[L]->Sumw2(); // hBG_pTRapMass[R] = new TH3D("hBG_pTRapMass_R", ";p_{T} [GeV/c]; |y|; M [GeV]", 7, onia::pTRange[iRapBin][iPTBin-1], onia::pTRange[iRapBin][iPTBin], 2, onia::rapForPTRange[iRapBin-1], onia::rapForPTRange[iRapBin], 7, massMin, massMax);//*signal* mass window! hBG_pTRapMass[R]->Sumw2(); lepP = 0; lepN = 0; treeIn->SetBranchAddress("lepP", &lepP); treeIn->SetBranchAddress("lepN", &lepN); TLorentzVector *onia = new TLorentzVector(); Double_t onia_mass; for(int iEn = 0; iEn < treeIn->GetEntries(); iEn++){ Long64_t iEntry = treeIn->LoadTree(iEn); treeIn->GetEntry(iEntry); if(iEn % 10000 == 0) cout << "entry " << iEntry << " out of " << treeIn->GetEntries() << endl; *onia = *(lepP) + *(lepN); onia_mass = onia->M(); if(UpsMC||f_BG_zero) hBG_pTRapMass[L]->Fill(onia->Pt(), TMath::Abs(onia->Rapidity()), gRandom->Uniform(massMin, massMax)); if(UpsMC||f_BG_zero) hBG_pTRapMass[R]->Fill(onia->Pt(), TMath::Abs(onia->Rapidity()), gRandom->Uniform(massMin, massMax)); if(!UpsMC&&!f_BG_zero){ if(onia_mass > massMinBG[L] && onia_mass < massMaxBG[L]) hBG_pTRapMass[L]->Fill(onia->Pt(), TMath::Abs(onia->Rapidity()), fBG->GetRandom(massMin, massMax)); else if(onia_mass > massMinBG[R] && onia_mass < massMaxBG[R]) hBG_pTRapMass[R]->Fill(onia->Pt(), TMath::Abs(onia->Rapidity()), fBG->GetRandom(massMin, massMax)); } if(onia_mass > massMin && onia_mass < massMax){ treeOut->Fill(); //stores TLorenzVectors of the two muons // //store now the cosTheta and phi distributions of the signal window: // calcPol(*lepP, *lepN); // for(int iFrame = 0; iFrame < onia::kNbFrames; iFrame++) // hCosThetaPhiSignal[iFrame]->Fill(thisCosTh[iFrame], thisPhi[iFrame]); } } /* Char_t name2[100]; sprintf(name2, "Reco_Onia_mass_rap%d_pT%d", iRapBin, iPTBin); TH1F* hMass = (TH1F*) gDirectory->Get(name2); hMass->Rebin(2); double binWidth = hMass->GetBinWidth(1); //valid only for an equal bin histogram! printf("binwidth = %1.2e\n", binWidth); */ double nY[3]; double nBG_; double binWidth = 0.02; //You have to manually change that parameter from the mass fit!!! nY[2] = fUps[2]->Integral(massMin, massMax)/binWidth; nY[1] = fUps[1]->Integral(massMin, massMax)/binWidth; nY[0] = fUps[0]->Integral(massMin, massMax)/binWidth; nBG_ = fBG->Integral(massMin, massMax)/binWidth; double nAll=nY[0]+nY[1]+nY[2]+nBG_; printf("1 sigma region num background = %1.3f\n",nBG_); printf("1 sigma region num 1S = %1.3f\n",nY[0]); printf("1 sigma region num 2S = %1.3f\n",nY[1]); printf("1 sigma region num 3S = %1.3f\n",nY[2]); printf("1 sigma region num all = %1.3f\n",nAll); printf("1 sigma region calcNumAll - numEventsInDataSet = %1.3f\n",nAll-treeOut->GetEntries()); double tempBfrac=nBG_/(treeOut->GetEntries()); printf("1 sigma region background fraction = %1.3f\n",tempBfrac); printf("Used background fraction = %1.3f\n",backgroundFrac); SignalEvents=nY[nUpsState]; double BackgroundEvents=SignalEvents*(1-backgroundFrac)/backgroundFrac; err_backgroundFrac=TMath::Power(SignalEvents*BackgroundEvents,0.5)/TMath::Power(SignalEvents+BackgroundEvents,1.5); //now, add the L and R 3D (pT, |y|, M) histos TH3D *hBG_pTRapMassSum; hBG_pTRapMass[L]->Scale(fracL/hBG_pTRapMass[L]->Integral()); hBG_pTRapMass[R]->Scale((1.-fracL)/hBG_pTRapMass[R]->Integral()); sprintf(name, "background_pTrapMass"); hBG_pTRapMassSum = (TH3D*) hBG_pTRapMass[L]->Clone(name); hBG_pTRapMassSum->Add(hBG_pTRapMass[R]); //write the output fOut->cd(); treeOut->Write(); for(int iFrame = 0; iFrame < onia::kNbFrames; iFrame++){ hBG_cosThetaPhi[iFrame]->Write(); hBG_cosThetaPhiLR[iFrame][L]->Write(); hBG_cosThetaPhiLR[iFrame][R]->Write(); // hCosThetaPhiSignal[iFrame]->Write(); } hBG_pTRapMassSum->Write(); hFracBG->Write(); if(MassScan){ hMassScanInfo->Write(); } fOut->Close(); fIn->Close(); return fracLCentral; }
void absorbedSubtraction (char* bkgndTreeName, char* absTreeName, char* outHistName, int numberOfSlices,float sliceWidth ,int extent, float modifier,TFile* backgroundFile, TFile* inFile, TFile* outFile,float startY, int nBinsX, int nBinsZ,float xMax, float xMin,float zMax, float zMin) { // ******************** absorbed muon tree double xCut, xGrad, zCut, zGrad; TTree* abs = (TTree*) inFile->Get(absTreeName); abs->SetBranchAddress("xCut",&xCut); abs->SetBranchAddress("yCut",&zCut); abs->SetBranchAddress("xGrad",&xGrad); abs->SetBranchAddress("yGrad",&zGrad); int nEntriesS = abs->GetEntries(); // ******************** background absorbed muon tree double xCutB, xGradB, zCutB, zGradB; TTree* absB = (TTree*) backgroundFile->Get(bkgndTreeName); absB->SetBranchAddress("xCut",&xCutB); absB->SetBranchAddress("yCut",&zCutB); absB->SetBranchAddress("xGrad",&xGradB); absB->SetBranchAddress("yGrad",&zGradB); int nEntriesB = absB->GetEntries(); // ******************** calculate the threshold and similar float vol = std::pow ((float) (2*extent+1),3); float threshold = modifier; float scalingConstant = ((float) nEntriesS) / ((float)nEntriesB); // ******************** run for each slice for (int j = 0; j < numberOfSlices; j++) { double y = (j*sliceWidth + startY); // the 'real' value of y char name [25]; char nameS [25]; char nameB [25]; char yVal [5]; sprintf (yVal, "%d",(int)y); strcpy (name,outHistName); strcat (name, yVal); strcpy (nameB, outHistName); strcat (nameB, "B"); strcat (nameB, yVal); strcpy (nameS, outHistName); strcat (nameS, "S"); strcat (nameS, yVal); TH2D* out = new TH2D (name, name, nBinsX,xMin,xMax, nBinsZ,zMin,zMax); TH2D* outS = new TH2D (nameS,nameS, nBinsX,xMin,xMax, nBinsZ,zMin,zMax); TH2D* outB = new TH2D (nameB,nameB, nBinsX,xMin,xMax, nBinsZ,zMin,zMax); // ******************** create the source histo for (int entry = 0; entry < nEntriesS; entry++) { abs->GetEntry(entry); if(xGrad == 0 || zGrad == 0) continue; // if there is null gradient ignore and continue double x = (y - xCut)/ xGrad; // calculate x and z positions using the y value (x = (y-cut)/grad) double z = (y - zCut)/ zGrad; outS->Fill (x,z,1); } outFile->Add(outS); // ******************** create background histo for (int entryB = 0; entryB < nEntriesB; entryB++) { absB->GetEntry(entryB); if(xGradB == 0 || zGradB == 0) continue; // if there is null gradient ignore and continue double x = (y - xCutB)/ xGradB; // calculate x and z positions using the y value (x = (y-cut)/grad) double z = (y - zCutB)/ zGradB; outB->Fill (x,z,1); } outFile->Add(outB); // ******************** test the source density against background density for (int i =0; i < nBinsX; i++) { for (int k = 0; k < nBinsZ; k++) { float bkgnd = 0; float test = 0; for (int io = -extent; io <= extent; io++) { for (int ko = -extent; ko <= extent; ko++) { test += outS->GetBinContent ((i+io),(k+ko)); bkgnd += outB->GetBinContent ((i+io),(k+ko)); } } test = (test/vol) /scalingConstant; // ensures that the densities are comparable bkgnd = (bkgnd/vol)*scalingConstant; if (std::fabs (test-bkgnd) > threshold) { out->SetBinContent (i,k,1); } } if (!(i%10)) std::cout<<(j*nBinsX)+ i<<" of "<<(numberOfSlices*nBinsX)<<std::endl; } outFile->Add(out); } std::cout<<vol<<" "<<threshold<<std::endl; }
void computeSummary(string fileName_="",string payloadName_=""){ if (fileName_==""){cout<<"No file specified."<<endl; return;} TFile * f = new TFile(saveFile.c_str(),"UPDATE"); TTree * t = (TTree*)f->Get("payloadSummary"); if (!t)return; float MPV[5]; float Gain[5]; gROOT->ProcessLine("#include <iostream>"); string *payloadName = new string; payloadName->assign(payloadName_); t->SetBranchAddress("MPV" ,&MPV[0] ); t->SetBranchAddress("Gain" ,&Gain[0] ); t->SetBranchAddress("MPV_TIB" ,&MPV[1] ); t->SetBranchAddress("MPV_TID" ,&MPV[2] ); t->SetBranchAddress("MPV_TOB" ,&MPV[3] ); t->SetBranchAddress("MPV_TEC" ,&MPV[4] ); t->SetBranchAddress("Gain_TIB" ,&Gain[1] ); t->SetBranchAddress("Gain_TID" ,&Gain[2] ); t->SetBranchAddress("Gain_TOB" ,&Gain[3] ); t->SetBranchAddress("Gain_TEC" ,&Gain[4] ); t->SetBranchAddress("PayloadName",&payloadName ); float NAPV[5]; for(int i=0; i<5; i++){MPV[i]=0; Gain[i]=0; NAPV[i]=0;} TFile * f2 = new TFile(fileName_.c_str()); TTree * t2 = (TTree*) f2->Get("SiStripCalib/APVGain"); float MPV_origin; double Gain_origin; UChar_t subDet; bool isMasked; t2->SetBranchAddress("FitMPV" ,&MPV_origin ); t2->SetBranchAddress("Gain" ,&Gain_origin); t2->SetBranchAddress("SubDet" ,&subDet ); t2->SetBranchAddress("isMasked",&isMasked ); //Looping over tree... printf("Progressing Bar :0%% 20%% 40%% 60%% 80%% 100%%\n"); printf("Looping on the Tree :"); int TreeStep = t2->GetEntries()/50;if(TreeStep==0)TreeStep=1; for (unsigned int ientry = 0; ientry < t2->GetEntries(); ientry++) { if(ientry%TreeStep==0){printf(".");fflush(stdout);} t2->GetEntry(ientry); if(subDet>2 && Gain_origin > 0 && MPV_origin > 0 && ! isMasked){ NAPV[subDet-2]++; NAPV[0]++; Gain[0]+=Gain_origin; MPV[0]+=MPV_origin; Gain[subDet-2]+=Gain_origin; MPV [subDet-2]+=MPV_origin; } } cout<<endl; f2->Close(); for (int i=0; i<5; i++){MPV[i]/=NAPV[i]; Gain[i]/=NAPV[i];} f->cd(); t->Fill(); t->Write(); f->Save(); delete payloadName; f->Close(); }