void Drawbbcntrk(){ TFile *f = new TFile("merged.root"); TCanvas *c1; TCanvas *c2; TLegend *leg = new TLegend(0.5,0.7,0.7,0.85); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextSize(0.048); TH2F* bbcsntrk = (TH2F*)f->Get(Form("bbcsntrk_0")); TH2F* bbcnntrk = (TH2F*)f->Get(Form("bbcnntrk_0")); for(int xcent=1; xcent < 6; xcent++){ TH2F* bbcsntrkdis_t = (TH2F*)f->Get(Form("bbcsntrk_%d",xcent)); bbcsntrk->Add(bbcsntrkdis_t); TH2F* bbcnntrkdis_t = (TH2F*)f->Get(Form("bbcnntrk_%d",xcent)); bbcnntrk->Add(bbcnntrkdis_t); } c1= new TCanvas(); c1->cd(); c1->SetLogz(); SetTitle(*bbcsntrk,"bbc charge south","N_{trk}",""); SetRange(*bbcsntrk,0,0,100,15); bbcsntrk->Draw("colz"); c1->Print(Form("bbcsntrk.png")); c2= new TCanvas(); c2->cd(); c2->SetLogz(); SetTitle(*bbcnntrk,"bbc charge north","N_{trk}",""); SetRange(*bbcnntrk,0,0,100,15); bbcnntrk->Draw("colz"); c2->Print("bbcnntrk.png"); }
TH2F* getTrigsAndMerge(TFile* fa,char* hname,const int nTCombData,string tCombData[]) { TH2F* theData[nTCombData]; if (fa == NULL) { std::cout << "getTrigsAndMerge: no hfile opened" << std::endl; return NULL; } std::cout << "getTrigsAndMerge: hname=" << hname << std::endl; for (int iTCombData=0; iTCombData<nTCombData; ++iTCombData) { // std::cout << "getTrigsAndMerge: iTCombData= " << iTCombData << " tCombData=" << tCombData[iTCombData] << std::endl; theData[iTCombData] = (TH2F*) fa->Get(Form("%s%s",hname,tCombData[iTCombData].c_str())); if (theData[iTCombData] == NULL) { std::cout << "getTrigsAndMerge: histogram " << Form("%s%s",hname,tCombData[iTCombData].c_str()) << " not found" << std::endl; return 0; } } string theName( hname ); // strip off any path in histogram name long unsigned int nsl = theName.find_last_of('/'); if (nsl != theName.npos) { theName = theName.substr(nsl+1,theName.size()-nsl-1); } string theTitle( theData[0]->GetTitle() ); TH2F* mergedData = new TH2F( *theData[0] ); for (int iTCombData=0; iTCombData<nTCombData; ++iTCombData) { theName += tCombData[iTCombData]; if (iTCombData != 0) theTitle += tCombData[iTCombData]; } mergedData->SetName( theName.c_str() ); for (int iTCombData=1; iTCombData<nTCombData; ++iTCombData) { mergedData->Add( theData[iTCombData] ); } std::cout << "getTrigsAndMerge: new name: " << mergedData->GetName() << std::endl; return mergedData; }
TH2F* loadHistogram2D( const std::vector<std::string>& fileList, const std::string& histName, const std::string& sys, double scale, int rebinX, int rebinY ) { TH2F* result = nullptr; for (const std::string& file: fileList) { TFile input(file.c_str(),"r"); TH2F* hist=nullptr; if ((sys=="") and input.FindKey(histName.c_str())) { hist = static_cast<TH2F*>(input.Get(histName.c_str())); } else if (input.FindKey((histName+"__"+sys).c_str())) { hist = static_cast<TH2F*>(input.Get((histName+"__"+sys).c_str())); } else if (input.FindKey((histName+"__nominal").c_str())) { log(WARNING,"using fallback '%s' for '%s'\n",(histName+"__nominal").c_str(),(histName+"__"+sys).c_str()); hist = static_cast<TH2F*>(input.Get((histName+"__nominal").c_str())); } else { log(ERROR,"neither '%s', '%s' nor '%s' found in file '%s'\n",histName.c_str(),(histName+"__nominal").c_str(),(histName+"__"+sys).c_str(),file.c_str()); continue; } hist->Scale(scale); hist->Rebin2D(hist->GetNbinsX()/rebinX,hist->GetNbinsY()/rebinY); if (!result) { result = new TH2F(*hist); result->Sumw2(); result->SetDirectory(0); } else { result->Add(hist); } } if (!result) { log(CRITICAL,"Error while finding histogram '"+histName+"' with sys '"+sys+"' in given files"); throw std::string("Error while finding histogram '"+histName+"' with sys '"+sys+"' in given files"); } return result; }
void k_Vs_relIso() { TFile* file1 = TFile::Open("outputFile_Mu_Run2010A_Sep17thReReco.root"); TH2F* obs = static_cast<TH2F*>(file1->Get("relIso_Vs_d0_tagRateObs")); TH2F* pred = static_cast<TH2F*>(file1->Get("relIso_Vs_d0_tagRatePred")); TFile* file2 = TFile::Open("outputFile_Mu_Run2010B_PromptReco_Part1.root"); obs->Add(static_cast<TH2F*>(file2->Get("relIso_Vs_d0_tagRateObs"))); pred->Add(static_cast<TH2F*>(file2->Get("relIso_Vs_d0_tagRatePred"))); TFile* file3 = TFile::Open("outputFile_Mu_Run2010B_PromptReco_Part2.root"); obs->Add(static_cast<TH2F*>(file3->Get("relIso_Vs_d0_tagRateObs"))); pred->Add(static_cast<TH2F*>(file3->Get("relIso_Vs_d0_tagRatePred"))); TFile* file4 = TFile::Open("outputFile_Mu_Run2010B_PromptReco_Part3.root"); obs->Add(static_cast<TH2F*>(file4->Get("relIso_Vs_d0_tagRateObs"))); pred->Add(static_cast<TH2F*>(file4->Get("relIso_Vs_d0_tagRatePred"))); TH2F* k = new TH2F("k", "k Factor vs relIso", 100, 0.0, 0.25, 100, 0.0, 5.0); k->Divide(obs, pred); k->ProfileY()->Draw(); /*file1->Close();*/ /*delete file1;*/ /*file2->Close();*/ /*delete file2;*/ /*file3->Close();*/ /*delete file3;*/ /*file4->Close();*/ /*delete file4;*/ }
void Drawbbc(){ TFile *f = new TFile("merged.root"); TH1D* hbbcs; TH1D* hbbcn; TCanvas *c1; TCanvas *c2; TLegend *leg = new TLegend(0.5,0.7,0.7,0.85); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextSize(0.048); TH2F* bbcsbbcn = (TH2F*)f->Get(Form("bbcsbbcn_0")); for(int xcent=1; xcent < 6; xcent++){ TH1F* bbcsbbcndis_t = (TH1F*)f->Get(Form("bbcsbbcn_%d",xcent)); bbcsbbcn->Add(bbcsbbcndis_t); } hbbcs = (TH1D*)bbcsbbcn->ProjectionX("bbcs",0,-1); hbbcn = (TH1D*)bbcsbbcn->ProjectionY("bbcn",0,-1); hbbcs->Rebin(4); hbbcn->Rebin(4); c1= new TCanvas(); c1->cd(); c1->SetLogy(); SetTitle(*hbbcs,"bbc charge","# of events",""); SetRange(*hbbcs,0,1e-1,100,hbbcn->GetMaximum()*5); SetStyle(*hbbcs,1.2,1,20,0,0); SetStyle(*hbbcn,1.2,2,24,0,0); hbbcs->Draw("P"); hbbcn->Draw("Psame"); leg->AddEntry(hbbcs,"bbc south"); leg->AddEntry(hbbcn,"bbc north"); leg->Draw("same"); c1->Print(Form("bbcdis.png")); c2= new TCanvas(); c2->cd(); c2->SetLogy(); hbbcs_norm = (TH1D*)hbbcs->Clone("hbbcs_norm"); hbbcn_norm = (TH1D*)hbbcn->Clone("hbbcn_norm"); hbbcs_norm->Scale(1./hbbcs_norm->Integral()); hbbcn_norm->Scale(1./hbbcn_norm->Integral()); SetRange(*hbbcs_norm,0,1e-9,100,1); hbbcs_norm->Draw("P"); hbbcn_norm->Draw("Psame"); leg->Draw("same"); c2->Print(Form("bbcdis_norm.png")); c3= new TCanvas(); c3->cd(); c3->SetLogz(); SetTitle(*bbcsbbcn,"bbc charge south","bbc charge north","# of events"); SetRange(*bbcsbbcn,0,0,100,100); bbcsbbcn->Draw("colz"); c3->Print("bbcsbbcn.png"); }
void DrawRunQA(){ TFile *f = TFile::Open("merged_Anappmb.root"); TH2F* hrunbbcs = (TH2F*)f->Get("hrunbbcs"); TH2F* hrunbbcn = (TH2F*)f->Get("hrunbbcn"); TH2F* hrunntrack[4]; TH2F* hrunntracktot; TProfile* hQAntrack[4]; TProfile* hQAntracktot; hrunntrack[0] = (TH2F*)f->Get(Form("hrunntrack_arm0_pos")); hrunntrack[1] = (TH2F*)f->Get(Form("hrunntrack_arm0_neg")); hrunntrack[2] = (TH2F*)f->Get(Form("hrunntrack_arm1_pos")); hrunntrack[3] = (TH2F*)f->Get(Form("hrunntrack_arm1_neg")); hrunntracktot = (TH2F*)hrunntrack[0]->Clone("hrunntrack_tot"); for(int i=0;i<4;i++){ hQAntrack[i] = (TProfile*)hrunntrack[i]->ProfileX(Form("hQAntrack_%d",i)); if(i!=0) hrunntracktot->Add(hrunntrack[i]); } hQAntracktot = (TProfile*)hrunntracktot->ProfileX(Form("hQAntracktot")); TProfile* hQAbbcs = hrunbbcs->ProfileX("hQAbbcs"); TProfile* hQAbbcn = hrunbbcn->ProfileX("hQAbbcn"); TCanvas *c1 = new TCanvas(); SetTitle(*hQAbbcs,"run Number","bbc south charge average",""); SetYRange(*hQAbbcs,3,8); SetStyle(*hQAbbcs,0.8,1,20,0,0); hQAbbcs->Draw("P"); c1->Print("fig/RunQA/hrunbbcs.png"); TCanvas *c2 = new TCanvas(); SetTitle(*hQAbbcn,"run Number","bbc north charge average",""); SetYRange(*hQAbbcn,3,8); SetStyle(*hQAbbcn,0.8,1,20,0,0); hQAbbcn->Draw("P"); c2->Print("fig/RunQA/hrunbbcn.png"); TCanvas *c3 = new TCanvas(); TString title[4] = {"East arm positive","East arm negative","West arm positive","West arm negative"}; for(int i=0;i<4;i++){ SetTitle(*hQAntrack[i],"run Number","# of tracks average",title[i]); SetYRange(*hQAntrack[i],0.45,0.60); SetStyle(*hQAntrack[i],0.8,1,20,0,0); hQAntrack[i]->Draw("P"); c3->Print(Form("fig/RunQA/hrunntrack_%d.png",i)); } TCanvas *c4 = new TCanvas(); SetTitle(*hQAntracktot,"run Number","# of tracks average","track 0.2<p_{T}<5.0"); SetYRange(*hQAntracktot,0,5); SetStyle(*hQAntracktot,0.8,1,20,0,0); hQAntracktot->Draw("P"); c4->Print(Form("fig/RunQA/hrunntracktot.png")); }
void combineBins(int mass, double scale_factor = 1.0){ //mass = mass of tprime quark //define some parameters //char fname[100]={"data/mujets_821/tprime_mujets_2D_821ipb.root"}; //input file name char fname[100]={"data/ejets_3560/tprime_ejets_2D_3560ipb.root"}; //input file name char oname[256]; //output file name char sname[100]; //name of signal histogram //sprintf(oname,"data/mujets_821/tprime_%i_mujets_2D_821ipb_merged_15jul2011test.root",mass); sprintf(oname,"data/mujets_821/tprime_%i_mujets_2D_821ipb_merged_test.root",mass); sprintf(sname,"TPrime%i_HtvsMfit",mass); char bname[20][100]={ //array of data and background histograms "Data_HtvsMfit", //data histogram must be first in this list "TTjets_HtvsMfit", "Ewk_HtvsMfit", "TPrime%i_HtvsMfit_JESup", "TPrime%i_HtvsMfit_JESdown", "TTjets_HtvsMfit_JESup", "TTjets_HtvsMfit_JESdown", "Ewk_HtvsMfit_JESup", "Ewk_HtvsMfit_JESdown" }; int nb=9; //number of histograms in list int n_skip=3; // starting with this index, do not consider for background normalization float femax=0.20; //max fractional error in each bin of background histogram TFile *f = TFile::Open(fname); if (f==NULL) { printf("Cannot open file '%s'\n",fname); return; } TH2F* hs; f->GetObject(sname,hs); // Gena: scale signal template to proper cross section hs->Scale(scale_factor); if (hs==NULL) { printf("Cannot find histogram '%s' in '%s'\n",sname,fname); return; } //figure out the binning int nx = hs->GetNbinsX()+2; int ny = hs->GetNbinsY()+2; // cross check printout std::cout << "2D hist name: " << hs->GetName() << std::endl; std::cout << "Integral with overflow: " << hs->Integral(0,nx-1,0,ny-1) << std::endl; std::cout << "Integral no overflow: " << hs->Integral(1,nx-2,1,ny-2) << std::endl << std::endl; TH2F *hb = (TH2F*)hs->Clone(); hb->SetName("hb"); hb->Reset(); TH2F *hX[20]; for (int i=0;i<nb;i++){ std::string sBName(bname[i]); // GENA: get names for signal JES histos if (sBName.find("TPrime")!=std::string::npos || sBName.find("Tprime")!=std::string::npos || sBName.find("tprime")!=std::string::npos){ sprintf(bname[i],sBName.c_str(),mass); std::cout << bname[i] << std::endl; } f->GetObject(bname[i],hX[i]); // GENA: scale JES signal templates to proper cross section if (sBName.find("TPrime")!=std::string::npos || sBName.find("Tprime")!=std::string::npos || sBName.find("tprime")!=std::string::npos){ hX[i]->Scale(scale_factor); } if (hX[i]==NULL) { printf("Cannot find histogram '%s' in '%s'\n",bname[i],fname); return; } //hX[i]->Print("base"); std::cout << "2D hist name: " << hX[i]->GetName() << std::endl; std::cout << "Integral with overflow: " << hX[i]->Integral(0,nx-1,0,ny-1) << std::endl; std::cout << "Integral no overflow: " << hX[i]->Integral(1,nx-2,1,ny-2) << std::endl << std::endl; //sum all background histograms into hb; do not add the data histogram if (i>0 && i<n_skip) hb->Add(hX[i]); } //figure out the binning //int nx = hs->GetNbinsX()+2; //int ny = hs->GetNbinsY()+2; int nbin=nx*ny; std::cout << "number of bins: x="<<nx<<", y="<<ny<<std::endl; //book some 1d histograms with the same number of bins for diagnostics TH1F *h1sb = new TH1F("h1sb","h1sb",nbin,0,nbin); TH1F *h1s = new TH1F("h1s","h1s",nbin,0,nbin); TH1F *h1b = new TH1F("h1b","h1b",nbin,0,nbin); // GENA: vector to create 2D->1D bin map std::vector<std::vector<int> > vMap(nbin); float xs,xb; //xsb holds the s/b values for each bin //xx are the histogram contents //(0=signal, 1=total background, 2=data, 3...nb-1=individual backgrounds) GENA: nb+1 ? float xsb[30000],xx[30000][20],xe[30000][20]; int ibin; double _sum = 0.0; for (int i=0;i<nx;i++){ for (int j=0;j<ny;j++){ ibin=hs->GetBin(i,j); // GENA: Will fill each bin with its original index vMap[ibin].push_back(ibin); xs=hs->GetBinContent(ibin); xb=hb->GetBinContent(ibin); //compute signal/background if (xb>0) { xsb[ibin]=xs/xb; }else{ if (xs>0){ xsb[ibin]=999; }else{ xsb[ibin]=0; } } xx[ibin][0]=xs; xe[ibin][0]=hs->GetBinError(ibin); xx[ibin][1]=xb; xe[ibin][1]=hb->GetBinError(ibin); for (int k=0;k<nb;k++){ xx[ibin][k+2]=hX[k]->GetBinContent(ibin); xe[ibin][k+2]=hX[k]->GetBinError(ibin); } if (xb>0) h1sb->SetBinContent(ibin,xs/xb); h1s->SetBinContent(ibin,xx[ibin][0]); h1s->SetBinError(ibin,xe[ibin][0]); h1b->SetBinContent(ibin,xx[ibin][1]); h1b->SetBinError(ibin,xe[ibin][1]); _sum += xx[ibin][0]; } } std::cout << "SUM: " << _sum << std::endl; //sort all histogram bins in decreasing s/b int nswap=1; float xtmp; // GENA: for bin map int ibin_tmp; while (nswap>0) { nswap=0; for (int i=0;i<nbin-1;i++) { if (xsb[i]<xsb[i+1]){ xtmp=xsb[i]; xsb[i]=xsb[i+1]; xsb[i+1]=xtmp; // GENA: for bin map ibin_tmp = vMap[i][0]; vMap[i][0] = vMap[i+1][0]; vMap[i+1][0] = ibin_tmp; for (int j=0;j<nb+2;j++){ xtmp=xx[i][j]; xx[i][j]=xx[i+1][j]; xx[i+1][j]=xtmp; xtmp=xe[i][j]; xe[i][j]=xe[i+1][j]; xe[i+1][j]=xtmp; } nswap=nswap+1; } } } //these histograms have the bins ordered in decrerasing s/b for diagnostics TH1F *h1sb1 = new TH1F("h1sb1","h1sb1",nbin,0,nbin); TH1F *h1fe1 = new TH1F("h1fe1","h1fe1",nbin,0,nbin); TH1F *h1s1 = new TH1F("h1s1","h1s1",nbin,0,nbin); TH1F *h1b1 = new TH1F("h1b1","h1b1",nbin,0,nbin); for (int i=0;i<nbin;i++){ h1sb1->SetBinContent(i+1,xsb[i]); if (xx[i][1]>0) h1fe1->SetBinContent(i+1,xe[i][1]/xx[i][1]); h1s1->SetBinContent(i+1,xx[i][0]); h1s1->SetBinError(i+1,xe[i][0]); h1b1->SetBinContent(i+1,xx[i][1]); h1b1->SetBinError(i+1,xe[i][1]); } //combine bins starting with the highest s/b until the fractional error in //the total backround in every bin is smaller than femax int ncomb=1; //float xtmp; float fe=0; while (ncomb>0) { ncomb=0; for (int i=0;i<nbin-1;i++){ if (xx[i][1]>0){ fe=xe[i][1]/xx[i][1]; //fractional error in background }else{ fe=1; } if (fe>femax){ // GENA: write down bin for (std::vector<int>::const_iterator vi=vMap[i+1].begin(); vi != vMap[i+1].end(); ++vi){ vMap[i].push_back(*vi); } //move all successive bins up vMap.erase(vMap.begin()+i+1); for (int k=0;k<nb+2;k++){ //add the next bin xx[i][k]=xx[i][k]+xx[i+1][k]; xe[i][k]=sqrt(xe[i][k]*xe[i][k]+xe[i+1][k]*xe[i+1][k]); for (int j=i+1;j<nbin-1;j++){ //move all successive bins up xx[j][k]=xx[j+1][k]; xe[j][k]=xe[j+1][k]; } } ncomb++; nbin=nbin-1; //decrease the total number of bins } } } //GENA: open the map file std::ofstream mapFile; mapFile.open("bin.map"); int bin_count = 0; for (std::vector<std::vector<int> >::const_iterator i=vMap.begin(); i != vMap.end(); ++i){ mapFile << " " << i-vMap.begin()+1 << ":"; for(std::vector<int>::const_iterator j=i->begin(); j != i->end(); ++j){ mapFile << " " << *j; ++bin_count; } mapFile << std::endl; } //GENA: close the map file mapFile.close(); //these are the output histograms TFile *f2 = TFile::Open(oname,"recreate"); TH1F *h1feb2 = new TH1F("h1fe2","h1fe2",nbin,0,nbin); TH1F *h1s2 = new TH1F(sname,sname,nbin,0,nbin); TH1F *h1b2 = new TH1F("h1b2","h1b2",nbin,0,nbin); TH1F *h1X2[20]; for (int i=0;i<nb;i++){ h1X2[i] = new TH1F(bname[i],bname[i],nbin,0,nbin); } for (int i=0;i<nbin;i++){ h1feb2->SetBinContent(i+1,xe[i][1]/xx[i][1]); h1s2->SetBinContent(i+1,xx[i][0]); h1s2->SetBinError(i+1,xe[i][0]); h1b2->SetBinContent(i+1,xx[i][1]); h1b2->SetBinError(i+1,xe[i][1]); for (int j=0;j<nb;j++){ h1X2[j]->SetBinContent(i+1,xx[i][j+2]); h1X2[j]->SetBinError(i+1,xe[i][j+2]); } } std::cout << "Merged 1D hist name: " << h1s2->GetName() << std::endl; std::cout << "Integral with overflow: " << h1s2->Integral(0,nbin+1) << std::endl; std::cout << "Integral no overflow: " << h1s2->Integral(1,nbin) << std::endl << std::endl; h1s2->Write(); for (int j=0;j<nb;j++){ std::cout << "Merged 1D hist name: " << h1X2[j]->GetName() << std::endl; std::cout << "Integral with overflow: " << h1X2[j]->Integral(0,nbin+1) << std::endl; std::cout << "Integral no overflow: " << h1X2[j]->Integral(1,nbin) << std::endl << std::endl; h1X2[j]->Write(); } h1s2->Print("base"); f2->Close(); f->Close(); std::cout << "map size: " << vMap.size() << " combined bins" << std::endl; std::cout << "total bins merged: " << bin_count << std::endl; }
int cleanData(TString rawdatafiles="files.txt",TString keyfilename = "keys.txt", TString cleandir="./clean/") { TString key = "clean"; const int nreqmod = 0; TString reqmod[nreqmod]; bool pass; DmtpcKeys k(keyfilename,rawdatafiles,key,cleandir,nreqmod,reqmod,pass); if(!pass) return -1; TCanvas* c = new TCanvas("c","c",0,0,1000,1000); c->Divide(2,2); c->cd(1); TFile* routfile; TTree* cleantree; TClonesArray* cleanimage; TH2F* tempimg; for(int f=0; f<k.getNFiles(); f++) { cout << k.getFile(f) << endl; //Create DMPTC Database and draw out tree DmtpcDataset d; d.openRootFile(k.getRootDirName()+k.getFile(f)); TTree* rawtree = d.tree(); //Add friends k.addFriends(rawtree,f); //name outputfile, open up outputfile TString routfilename = k.getFile(f); routfilename.ReplaceAll(".root",key+".root"); routfile = new TFile(cleandir+routfilename,"CREATE"); if(routfile->IsOpen()) { routfile->cd(); } else { cout << "Output file already exists; Aborting!" << endl; return -1; } d.getEvent(0); const int ncamera = d.event()->ccdData()->GetEntries(); const int nbinsx = d.event()->ccdData(0)->GetNbinsX(); const int nbinsy = d.event()->ccdData(0)->GetNbinsY(); //create tree to store clean images and sparking data cleantree = new TTree(key,"Cleaned Images"); cleanimage = new TClonesArray("TH2F",ncamera); Bool_t spark[ncamera]; double integral[ncamera]; //Add branches cleantree->Branch("cleanimage","TClonesArray",&cleanimage,128000,0); cleantree->Branch("spark",&spark,"spark[2]/O"); cleantree->Branch("integral",&integral,"integral[2]/D"); gROOT->cd(); //open up file for bias frame saving TString biasoutfilename = routfilename; biasoutfilename.ReplaceAll(key+".root","bias.root"); TFile* biasoutfile = new TFile(cleandir+biasoutfilename,"RECREATE"); TH2F* biasframe = d.event()->ccdData(0); TTree* biastree = new TTree("bias","Bias Information"); biastree->Branch("biasframe","TH2F",&biasframe,128000,0); gROOT->cd(); double threshhold[ncamera]; int nframes[ncamera]; for(int i=0; i<ncamera; i++){threshhold[i]=200; nframes[i]=0;} TH2F* secondarybias[ncamera]; //find the spark cut const int nev = rawtree->GetEntries(); double countthresh[nev]; double sparkcut[ncamera]; for(int j=0; j<ncamera; j++) { cout << j << ":" << endl; countthresh[j] =d.getBiasFrame(j+1)->Integral()/(65536); sparkcut[j] = MaxCamImageTools::countPixelsAboveThreshold(d.getBiasFrame(j+1),countthresh[j])-2000; cout << "count: " << countthresh[j] << "\t cut: " << sparkcut[j] << endl; } //Grab every 100th image to make bias frame; must check for sparks for(int i=0; i<nev; i=i+100) { cout << i << endl; d.getEvent(i); for(int u=0; u<ncamera; u++) { tempimg = (TH2F*)d.event()->ccdData(u)->Clone("backimg"); // MaxCamImageTools::killLonePixels2(tempimg,1300); int nabove = MaxCamImageTools::countPixelsAboveThreshold(tempimg,countthresh[u]); if(nabove<sparkcut[u]) { if(nframes[u]==0) { secondarybias[u]=(TH2F*)tempimg->Clone("average"); } else { secondarybias[u]->Add(tempimg,1); } nframes[u]++; } } } gROOT->Delete("backimg;*"); for(int i=0; i<ncamera; i++) { secondarybias[i]->Scale(1/double(nframes[i])); biasframe = secondarybias[i]; biasoutfile->cd(); biastree->Fill(); gROOT->cd(); } cout << "All preclean activities done" << endl; c->Update(); //cleaning should go here for(int i = 0; i<nev; i++) // for(int i = 0; i<100; i++) //For testing { cout << i << endl; d.getEvent(i); for(int u=0; u<ncamera; u++) { // c->cd(u+1); //create cloned image tempimg = (TH2F*)d.event()->ccdData(u); //check for sparking int nabove = MaxCamImageTools::countPixelsAboveThreshold(tempimg,countthresh[u]); if(nabove < sparkcut[u]) spark[u]=0; else spark[u]=1; if(spark[u] == 1) cout << "SPARK!" << endl; //subtract of temp bias tempimg->Add(secondarybias[u],-1); //kill lone pixels MaxCamImageTools::killLonePixels2(tempimg,threshhold[u]); //additionally correct double perpx = tempimg->Integral()/(nbinsx*nbinsy); if(spark[u]==0) MaxCamImageTools::subtractPedestal(tempimg,perpx); integral[u] = tempimg->Integral(); //add to TClonesArray new((*cleanimage)[u]) TH2F(*tempimg); } routfile->cd(); cleantree->Fill(); gROOT->cd(); } routfile->cd(); cleantree->Write(); delete cleantree; routfile->Close(); biasoutfile->cd(); biastree->Write(); delete biastree; biasoutfile->Close(); } return 0; }
void Getdphi(int ihar=0, int iangle1=0, int iangle2=0, bool usingCNTEP=0){ TString str; int nrun = GetTotalRun(); std::cout<<"Totally we have "<<nrun<<" runs/segments!"<<std::endl; FillGoodRun(ihar); std::cout<<"Filling Good run finished!"<<std::endl; float pi = acos(-1.0); if(nrun<0) exit(1); int iharE=0; if(nhar==1 || nhar ==2) iharE=1; TFile *fin; int n = ihar+1.0+iharE; cout<<"iangle1 = "<<iangle1<<" iangle2 = "<<iangle2<<endl; TFile *fout = new TFile(Form("dphiv%d.root",n),"recreate"); for(int icent=0;icent<ncent;icent++){ // for(int ihar=0;ihar<nhar;ihar++){ // if(ihar!=1) continue; for(int isub=0;isub<nsub;isub++){ str = choosesub(isub); TString UseCNTEP; if(str=="ABORT") continue; if(usingCNTEP) UseCNTEP = "UseCNTEP"; else UseCNTEP = "NoUseCNTEP"; std::cout<<UseCNTEP<<std::endl; std::cout<<"starting doing "<<str<<" v"<<n<<" analysis!"<<std::endl; // float reso = GetReso(iangle1, iangle2, icent,ihar,isub,usingCNTEP); // if(reso<=0) {std::cout<<"resolution is wrong!"<<std::endl; reso = 1.0;} TH2F* hvall = new TH2F(Form("hdphiall_%d%d_%d_%d_%d",iangle1,iangle2,icent,ihar,isub),Form("hdphiall_%d%d_%d_%d_%d",iangle1,iangle2,icent,ihar,isub),60,0,6,200,-pi,pi); TH2F* hvnall = new TH2F(Form("hdphinall_%d%d_%d_%d_%d",iangle1,iangle2,icent,ihar,isub),Form("hdphinall_%d%d_%d_%d_%d",iangle1,iangle2,icent,ihar,isub),60,0,6,100,-pi/2,pi/2); for(int iphi=0;iphi<nphi+1;iphi++){ TH2F* hv = new TH2F(Form("hdphi_%d%d_%d_%d_%d_%d",iangle1,iangle2,icent,ihar,isub,iphi),Form("hdphi_%d%d_%d_%d_%d_%d",iangle1,iangle2,icent,ihar,isub,iphi),60,0,6,200,-pi,pi); TH2F* hvn = new TH2F(Form("hdphin_%d%d_%d_%d_%d_%d",iangle1,iangle2,icent,ihar,isub,iphi),Form("hdphin_%d%d_%d_%d_%d_%d",iangle1,iangle2,icent,ihar,isub,iphi),60,0,6,100,-pi/2,pi/2); string phistr = (iphi==0)?"_east":"_west"; if(iphi==nphi) phistr = ""; if(iphi<nphi){ for(int irun=0;irun<nrun;irun++){ fin = TFile::Open(Form("/gpfs/mnt/gpfs02/phenix/plhf/plhf1/xuq/phenix/flow/Run16dAu/work/39GeV/treeout/%s",GetRun(irun).Data())); if(!(GoodRunFit[icent][ihar][isub][irun]>0.2 && GoodRunFit[icent][ihar][isub][irun]<3.0)){ std::cout<<"cent = "<<icent<<"; n = "<<n<<" ;isub = "<<str<<" ;run = "<<GetRun(irun)<<" is bad run!"<<std::endl; fin->Close(); continue; } TH2F *hvtemp; TH2F *hvsqtemp; hvtemp = (TH2F*)fin->Get(Form("v%s_%d_%d_%d_%d_%d",str.Data(),iangle1,iangle2,icent,ihar,iphi)); hvntemp = (TH2F*)fin->Get(Form("vn%s_%d_%d_%d_%d_%d",str.Data(),iangle1,iangle2,icent,ihar,iphi)); hv->Add(hvtemp); hvn->Add(hvntemp); fin->Close(); } } hvall->Add(hv); hvnall->Add(hvn); if(iphi==nphi){ hv = hvall; hvn = hvnall; } fout->cd(); hv->Write(); hvn->Write(); for(int ipt=0;ipt<npt-1;ipt++){ int xbinmin = hv->GetXaxis()->FindBin(ptbin[ipt]+eps); int xbinmax = hv->GetXaxis()->FindBin(ptbin[ipt+1]-eps); // std::cout<<xbinmin<<" "<<xbinmax<<std::endl; // std::cout<<ptbin[ipt]<<" "<<ptbin[ipt+1]<<std::endl; TH1F* hvProj = (TH1F*)hv->ProjectionY(Form("hvProj_%d",ipt),xbinmin,xbinmax); TH1F* hvnProj = (TH1F*)hvn->ProjectionY(Form("hvnProj_%d",ipt),xbinmin,xbinmax); } } } // } } fout->Close(); }
void twoDlinearcombination(TH2F* first, int firsttype, TH2F* second, int secondtype, TH2F* input, int inputtype, TH2F* finaloutput, int outputtype, TH2F* finaloutput2, int output2type){ TH2F* output = (TH2F*) input->Clone(); TH2F* output2 = (TH2F*) output->Clone(); if(outputtype==kIntHist || outputtype==kSigHist){ if(inputtype==kBSI25Hist && firsttype==kSigHist && secondtype==kBkgHist){ output->Add(first, -25.0); output->Add(second, -1.0); output->Scale(0.2); if (outputtype == kSigHist){ delete output; output = (TH2F*) first->Clone(); } output2->Add(first, -25.0); output2->Add(second, -1.0); output2->Scale(0.2); if (output2type == kSigHist){ delete output2; output2 = (TH2F*) first->Clone(); } } if(inputtype==kBSI25Hist && firsttype==kBSIHist && secondtype==kBkgHist){ for (int binx = 1; binx <= output->GetNbinsX(); binx++){ for (int biny = 1; biny <= output->GetNbinsY(); biny++){ double bsi = first->GetBinContent(binx,biny); double bkg = second->GetBinContent(binx,biny); double bsi25 = output->GetBinContent(binx,biny); double weight=doLinearCombination(bsi25,25,bsi,1,bkg,outputtype); output->SetBinContent(binx,biny,weight); if (finaloutput2 != 0){ double weight2 = doLinearCombination(bsi25, 25, bsi, 1, bkg, output2type); output2->SetBinContent(binx, biny, weight2); } } } } if(inputtype==kBSI25Hist && firsttype==kBSI10Hist && secondtype==kBkgHist){ //double scaleval = 1./(-50. + 25.*sqrt(10.)); for (int binx = 1; binx <= output->GetNbinsX(); binx++){ for (int biny = 1; biny <= output->GetNbinsY(); biny++){ double bsi10 = first->GetBinContent(binx,biny); double bkg = second->GetBinContent(binx,biny); double bsi25 = output->GetBinContent(binx,biny); double weight=doLinearCombination(bsi25,25,bsi10,10,bkg,outputtype); output->SetBinContent(binx,biny,weight); if (finaloutput2 != 0){ double weight2 = doLinearCombination(bsi25, 25, bsi10, 10, bkg, output2type); output2->SetBinContent(binx, biny, weight2); } } } } if(inputtype==kBSI10Hist && firsttype==kBSIHist && secondtype==kBkgHist){ //double scaleval = 1./(10 - sqrt(10)); for (int binx = 1; binx <= output->GetNbinsX(); binx++){ for (int biny = 1; biny <= output->GetNbinsY(); biny++){ double bsi = first->GetBinContent(binx,biny); double bkg = second->GetBinContent(binx,biny); double bsi10 = output->GetBinContent(binx,biny); double weight=doLinearCombination(bsi10,10,bsi,1,bkg,outputtype); output->SetBinContent(binx,biny,weight); if (finaloutput2 != 0){ double weight2 = doLinearCombination(bsi10, 10, bsi, 1, bkg, output2type); output2->SetBinContent(binx, biny, weight2); } } } } for (int binx = 1; binx <= output->GetNbinsX(); binx++){ for (int biny = 1; biny <= output->GetNbinsY(); biny++){ finaloutput->SetBinContent(binx, biny, output->GetBinContent(binx, biny)); if (finaloutput2 != 0) finaloutput2->SetBinContent(binx,biny,output2->GetBinContent(binx,biny)); } } } else{cout<<"Option not yet supported. Exiting..."<<endl; assert(0);}; delete output; delete output2; }
void Getvn(){ TString str; TFile *fin; int nrun = GetTotalRun(); if(nrun<0) exit("Empty run list file!"); ofstream fout, fout1, fout2; int iharE=0; if(nhar==1) iharE=1; for(int icent=0;icent<ncent;icent++){ for(int ihar=0;ihar<nhar;ihar++){ for(int isub=0;isub<nsub;isub++){ int n = ihar+1.0+iharE; if(isub==1) str = "FVTX1S"; else if(isub==2) str = "FVTX2S"; else continue; fout1.open(Form("Run15pAu200MinBias/res%d_%d_%s.dat",n,icent,str.Data())); //using str as event plane detector fout2.open(Form("Run15pAu200MinBias/psi%d_%d_%s.dat",n,icent,str.Data())); //using str as event plane detector float reso = 1.;//GetReso(icent,ihar,isub); fout1<<reso<<endl; TH2F* hvobs = new TH2F(Form("hvobs_%d_%d_%d",icent,ihar,isub),Form("hvobs_%d_%d_%d",icent,ihar,isub),60,0,6,220,-1.1,1.1); TH2F* hvobssq = new TH2F(Form("hvobssq_%d_%d_%d",icent,ihar,isub),Form("hvobssq_%d_%d_%d",icent,ihar,isub),60,0,6,220,-1.1,1.1); for(int irun=0;irun<nrun;irun++){ fout2<<GetRun(irun)<<" "<<GoodRun(icent,ihar,isub,irun)<<endl; } for(int iphi=0;iphi<nphi;iphi++){ string phistr = (iphi==0)?"east":"west"; fout.open(Form("Run15pAu200MinBias/v%d_%d_%s_%s.dat",n,icent,phistr.c_str(),str.Data())); //using str as event plane detector for(int irun=0;irun<nrun;irun++){ // cout<<"cent = "<<icent<<"; n = "<<n<<" ;isub = "<<str<<" ;run = "<<irun<<endl; fin = TFile::Open(Form("Run15pAu200MinBias/output_fvtxwithcntEP_%d.root",GetRun(irun))); if(!(GoodRun(icent,ihar,isub,irun)>0.2 && GoodRun(icent,ihar,isub,irun)<3.0)){ cout<<"cent = "<<icent<<"; n = "<<n<<" ;isub = "<<str<<" ;run = "<<GetRun(irun)<<" is bad run!"<<endl; continue; } TH2F* hvobstemp = (TH2F*)fin->Get(Form("vobs%s_%d_%d_%d",str.Data(),icent,ihar,iphi)); TH2F* hvobssqtemp = (TH2F*)fin->Get(Form("vobs%ssq_%d_%d_%d",str.Data(),icent,ihar,iphi)); hvobs->Add(hvobstemp); hvobssq->Add(hvobssqtemp); fin->Close(); } TH1F* ptProj = (TH1F*)hvobs->ProjectionX(Form("hptProj"),0,-1); for(int ipt=0;ipt<npt-1;ipt++){ TH1F* hvobsProj = (TH1F*)hvobs->ProjectionY(Form("hvobsProj_%d",ipt),hvobs->GetXaxis()->FindBin(ptbin[ipt]),hvobs->GetXaxis()->FindBin(ptbin[ipt+1])); TH1F* hvobssqProj = (TH1F*)hvobssq->ProjectionY(Form("hvobssqProj_%d",ipt),hvobs->GetXaxis()->FindBin(ptbin[ipt]),hvobs->GetXaxis()->FindBin(ptbin[ipt+1])); float vobs = hvobsProj->GetMean(); float Ntracks = hvobsProj->GetEntries(); float vobssq = hvobsProj->GetMean(); float v = vobs/reso; float verr = sqrt(vobssq/reso/reso-(v*v))/sqrt(Ntracks); ptProj->GetXaxis()->SetRangeUser(ptbin[ipt],ptbin[ipt+1]); float pt = ptProj->GetMean(); fout<<pt<<" "<<v<<" "<<" "<<verr<<endl; } fout.close(); } fout1.close(); fout2.close(); } } } }
void v_beam_asymmetry(){ TString Q2 = "1.0"; int HeRunNumberL = 1686; int endHeRunNumberL = 1958; int HeRunNumberR = 20596; int endHeRunNumberR = 20789; // NOTE: There is a problem with the charge scalar in runs 20812-20879. When this is fixed, // uncomment the line below. Until then, we stop at run 20789. // int endHeRunNumberR = 20879; double bins = 50; double xmin = 0.6; double xmax = 1.6; // Defines Right Arm Cuts TCut cutR = ""; TCut kinematicsR = "PriKineR.Q2<10 && GoodElectron==1 && PriKineR.nu<10"; TCut eventtypeR = "(D.evtypebits&2)==2"; TCut goldR = "ExTgtCor_R.dp>-0.04 && ExTgtCor_R.dp<0.053"; TCut targetR = "ReactPt_R.z>-0.17 && ReactPt_R.z<0.175"; TCut thetaphiR = "abs(ExTgtCor_R.ph)<0.03 && abs(ExTgtCor_R.th)<0.06"; TCut cutsR = cutR && kinematicsR && eventtypeR && goldR && targetR && thetaphiR; // Defines Left Arm Cuts TCut cutL = ""; TCut kinematicsL = "PriKineL.Q2<10 && GoodElectron==1 && PriKineL.nu<10"; // TCut eventtypeL = "(D.evtypebits&2)==2"; TCut eventtypeL = ""; TCut goldL = "ExTgtCor_L.dp>-0.04 && ExTgtCor_L.dp<0.053"; TCut targetL = "ReactPt_L.z>-0.17 && ReactPt_L.z<0.175"; TCut thetaphiL = "abs(ExTgtCor_L.ph)<0.03 && abs(ExTgtCor_L.th)<0.06"; TCut cutsL = cutL && kinematicsL && eventtypeL && goldL && targetL && thetaphiL; TChain* chainHeR = new TChain("T"); TChain* chainHeL = new TChain("T"); TString filenameHeR; TString filenameHeL; // ******************* The section below adds files to the Right arm chain from the RHRS ******************** for (int thisHeRunNumberR=HeRunNumberR; thisHeRunNumberR<(endHeRunNumberR+1); thisHeRunNumberR++) { // Skipping Vertical Carbon & Deuterium Runs if(thisHeRunNumberR==20591){thisHeRunNumberR=20596;} if(thisHeRunNumberR==20731){thisHeRunNumberR=20738;} if(thisHeRunNumberR==20732){thisHeRunNumberR=20738;} if(thisHeRunNumberR==20733){thisHeRunNumberR=20738;} if(thisHeRunNumberR==20734){thisHeRunNumberR=20738;} if(thisHeRunNumberR==20736){thisHeRunNumberR=20738;} if(thisHeRunNumberR==20737){thisHeRunNumberR=20738;} if(thisHeRunNumberR==20762){thisHeRunNumberR=20789;} if(thisHeRunNumberR==20763){thisHeRunNumberR=20789;} if(thisHeRunNumberR==20764){thisHeRunNumberR=20789;} if(thisHeRunNumberR==20791){thisHeRunNumberR=20814;} if(thisHeRunNumberR==20792){thisHeRunNumberR=20814;} // Skipping Longitudinal Carbon Runs if(thisHeRunNumberR==22380){thisHeRunNumberR=22393;} if(thisHeRunNumberR==22389){thisHeRunNumberR=22393;} if(thisHeRunNumberR==22425){thisHeRunNumberR=22436;} if(thisHeRunNumberR==22426){thisHeRunNumberR=22436;} // Skipping Transverse Carbon Runs if(thisHeRunNumberR==22461){thisHeRunNumberR=22465;} // Adds runs to the chain for (int t=0; t<1000; t++) { filenameHeR = "/home/ellie/physics/e05-102/terabyte/ROOTfiles/e05102_R_"; filenameHeR += thisHeRunNumberR; if (t != 0) { filenameHeR += "_"; filenameHeR += t; } filenameHeR += ".root"; ifstream ifileHeR(filenameHeR); if (ifileHeR) { cout << "Adding file to chainHeR: " << filenameHeR << endl; chainHeR->Add(filenameHeR); } else { cout << "File " << filenameHeR << " does not exist. Ending here." << endl; t=999999999; } } // Use the line below only for debugging purposes. It will only add the first file. // thisHeRunNumberR=999999; } // *********************************************************************************************************** // ************************** The section below adds files to the Left arm chain from the LHRS *************** for (int thisHeRunNumberL=HeRunNumberL; thisHeRunNumberL<(endHeRunNumberL+1); thisHeRunNumberL++) { // Skipping Vertical Carbon and Deuterium Runs if(thisHeRunNumberL==1699){thisHeRunNumberL=1705;} if(thisHeRunNumberL==1825){thisHeRunNumberL=1832;} if(thisHeRunNumberL==1826){thisHeRunNumberL=1832;} if(thisHeRunNumberL==1827){thisHeRunNumberL=1832;} if(thisHeRunNumberL==1828){thisHeRunNumberL=1832;} if(thisHeRunNumberL==1830){thisHeRunNumberL=1832;} if(thisHeRunNumberL==1831){thisHeRunNumberL=1832;} if(thisHeRunNumberL==1884){thisHeRunNumberL=1905;} if(thisHeRunNumberL==1885){thisHeRunNumberL=1905;} // Skipping Longitudinal Carbon Runs if(thisHeRunNumberL==22380){thisHeRunNumberL=22393;} if(thisHeRunNumberL==22389){thisHeRunNumberL=22393;} if(thisHeRunNumberL==22425){thisHeRunNumberL=22436;} if(thisHeRunNumberL==22426){thisHeRunNumberL=22436;} // Skipping Transverse Carbon Runs if(thisHeRunNumberL==22461){thisHeRunNumberL=22465;} // Adds runs to the chain for (int t=0; t<1000; t++) { filenameHeL = "/home/ellie/physics/e05-102/terabyte/ROOTfiles/e05102_L_"; filenameHeL += thisHeRunNumberL; if (t != 0) { filenameHeL += "_"; filenameHeL += t; } filenameHeL += ".root"; ifstream ifileHeL(filenameHeL); if (ifileHeL) { cout << "Adding file to chainHeL: " << filenameHeL << endl; chainHeL->Add(filenameHeL); } else { cout << "File " << filenameHeL << " does not exist. Ending here." << endl; t=999999999; } } // Use the line below only for debugging purposes. It will only add the first file. // thisHeRunNumberL=999999; } // **************************************************************************************************************** gStyle->SetPalette(1); // Defines Canvas TCanvas *c1 = new TCanvas("c1","Asymmetry",1360,810); //x,y pad1 = new TPad("pad1","pad1",0.0000,0.6666,0.2500,1.0000,0,0,0); pad2 = new TPad("pad2","pad2",0.2500,0.6666,0.5000,1.0000,0,0,0); pad3 = new TPad("pad3","pad3",0.5000,0.6666,0.7500,1.0000,0,0,0); pad4 = new TPad("pad4","pad4",0.7500,0.6666,1.0000,1.0000,0,0,0); pad5 = new TPad("pad5","pad5",0.0000,0.3333,0.2000,0.6666,0,0,0); pad6 = new TPad("pad6","pad6",0.2000,0.3333,0.4000,0.6666,0,0,0); pad7 = new TPad("pad7","pad7",0.4000,0.3333,0.6000,0.6666,0,0,0); pad8 = new TPad("pad8","pad8",0.6000,0.3333,0.8000,0.6666,0,0,0); pad9 = new TPad("pad9","pad9",0.8000,0.3333,1.0000,0.6666,0,0,0); pad10 = new TPad("pad10","pad10",0.0000,0.0000,0.5000,0.3333,0,0,0); pad11 = new TPad("pad11","pad11",0.5000,0.0000,1.0000,0.3333,0,0,0); pad1->Draw();pad2->Draw();pad3->Draw();pad4->Draw();pad5->Draw();pad6->Draw();pad7->Draw();pad8->Draw();pad9->Draw();pad10->Draw();pad11->Draw(); // Everything below here makes graphs for each section of the canvas pad1->cd(); TString titledp = "dp Cut"; cout << "Drawing " << titledp << "..." << endl; TH1F *HedpNoCut = new TH1F("HedpNoCut",titledp,400,-0.08,0.08); TH1F *HedpCut = new TH1F("HedpCut",titledp,400,-0.08,0.08); chainHeR->Draw("ExTgtCor_R.dp>>HedpNoCutR(400,-0.08,0.08)", "", ""); chainHeR->Draw("ExTgtCor_R.dp>>HedpCutR(400,-0.08,0.08)", goldR, ""); chainHeL->Draw("ExTgtCor_L.dp>>HedpNoCutL(400,-0.08,0.08)", "", ""); chainHeL->Draw("ExTgtCor_L.dp>>HedpCutL(400,-0.08,0.08)", goldL, ""); HedpNoCut->Add(HedpNoCutR,HedpNoCutL); HedpNoCut->SetTitle(titledp); HedpNoCut->Draw(); HedpCut->Add(HedpCutR,HedpCutL); HedpCut->SetLineColor(kBlack); HedpCut->SetFillColor(kViolet); HedpCut->Draw("same"); pad2->cd(); cout << "Drawing Target Cut..." << endl; TString titleTarget = "Target Cut"; TH1F *HeReactZNoCut = new TH1F("HeReactZNoCut",titleTarget,400,-0.3,0.3); TH1F *HeReactZCut = new TH1F("HeReactZCut",titleTarget,400,-0.3,0.3); chainHeR->Draw("ReactPt_R.z>>HeReactZNoCutR(400,-0.3,0.3)", "", ""); chainHeR->Draw("ReactPt_R.z>>HeReactZCutR(400,-0.3,0.3)", targetR, ""); chainHeL->Draw("ReactPt_L.z>>HeReactZNoCutL(400,-0.3,0.3)", "", ""); chainHeL->Draw("ReactPt_L.z>>HeReactZCutL(400,-0.3,0.3)", targetL, ""); HeReactZNoCut->Add(HeReactZNoCutR,HeReactZNoCutL); HeReactZNoCut->SetTitle(titleTarget); HeReactZNoCut->Draw(); HeReactZCut->Add(HeReactZCutR,HeReactZCutL); HeReactZCut->SetLineColor(kBlack); HeReactZCut->SetFillColor(kViolet); HeReactZCut->Draw("same"); pad3->cd(); cout << "Drawing Theta and Phi..." << endl; TString titleThetaPhiNoCut = "Theta and Phi, No Cut"; TH2F *HeThetaPhiNoCut = new TH2F("HeThetaPhiNoCut",titleThetaPhiNoCut,100,-0.05,0.05,100,-0.1,0.1); chainHeR->Draw("ExTgtCor_R.th:ExTgtCor_R.ph>>HeThetaPhiNoCutR(100,-0.05,0.05,100,-0.1,0.1)", targetR, ""); chainHeL->Draw("ExTgtCor_L.th:ExTgtCor_L.ph>>HeThetaPhiNoCutL(100,-0.05,0.05,100,-0.1,0.1)", targetL, ""); HeThetaPhiNoCut->Add(HeThetaPhiNoCutR,HeThetaPhiNoCutL); HeThetaPhiNoCut->SetTitle(titleThetaPhiNoCut); HeThetaPhiNoCut->SetStats(kFALSE); HeThetaPhiNoCut->Draw("COLZ"); pad4->cd(); cout << "Drawing Theta and Phi Cut..." << endl; TString titleThetaPhi = "Theta and Phi Cut"; TH2F *HeThetaPhiCut = new TH2F("HeThetaPhiCut",titleThetaPhi,100,-0.05,0.05,100,-0.1,0.1); chainHeR->Draw("ExTgtCor_R.th:ExTgtCor_R.ph>>HeThetaPhiCutR(100,-0.05,0.05,100,-0.1,0.1)", targetR && thetaphiR, ""); chainHeL->Draw("ExTgtCor_L.th:ExTgtCor_L.ph>>HeThetaPhiCutL(100,-0.05,0.05,100,-0.1,0.1)", targetL && thetaphiL, ""); HeThetaPhiCut->Add(HeThetaPhiCutR,HeThetaPhiCutL); HeThetaPhiCut->SetTitle(titleThetaPhi); HeThetaPhiCut->SetStats(kFALSE); HeThetaPhiCut->Draw("COLZ"); pad5->cd(); TString titleQ2 = "Q2"; TH1F *histQ2 = new TH1F("histQ2",titleQ2,400,0,1.6); cout << "Drawing " << titleQ2 << "..." << endl; chainHeR->Draw("PriKineR.Q2>>histQ2R(400,0,1.6)", cutsR, ""); chainHeL->Draw("PriKineL.Q2>>histQ2L(400,0,1.6)", cutsL, ""); histQ2->Add(histQ2R,histQ2L); histQ2->SetTitle(titleQ2); histQ2->SetStats(kFALSE); histQ2->Draw(); pad6->cd(); TString titleNu = "Nu"; cout << "Drawing " << titleNu << "..." << endl; TH1F *histNu = new TH1F("histNu",titleNu,100,0.3,0.8); chainHeR->Draw("PriKineR.nu>>histNuR(100,0.3,0.8)", cutsR, ""); chainHeL->Draw("PriKineL.nu>>histNuL(100,0.3,0.8)", cutsL, ""); histNu->Add(histNuR,histNuL); histNu->SetTitle(titleNu); histNu->SetStats(kFALSE); histNu->Draw(); pad7->cd(); TString titleHel = "Helicity vs. Bjorken x"; cout << "Drawing " << titleHel << "..." << endl; TH2F *histHelR = new TH2F("histHelR",titleHel,bins,xmin,xmax,7,-2,2); TH2F *histHelL = new TH2F("histHelL",titleHel,bins,xmin,xmax,7,-2,2); TH2F *histHel = new TH2F("histHel",titleHel,bins,xmin,xmax,7,-2,2); chainHeR->Draw("g0hel.R.helicity:(PriKineR.Q2 / (PriKineR.nu * 2 * 0.9315))>>histHelR", cutsR, ""); chainHeL->Draw("g0hel.L.helicity:(PriKineL.Q2 / (PriKineL.nu * 2 * 0.9315))>>histHelL", cutsL, ""); histHel->Add(histHelR,histHelL); histHel->Draw("COLZ"); // Note: For all plots below, Positive Helicity is defined as g0hel.R.helicity==1 when the BHWP is In // and g0hel.R.helicity==-1 when the BHWP is Out pad8->cd(); TString titlePosHelx = "# of Positive Helicity Events vs. Bjorken x"; cout << "Drawing " << titlePosHelx << "..." << endl; TH1F *histPosHelxIn1R = new TH1F("histPosHelxIn1R",titlePosHelx,bins,xmin,xmax); TH1F *histPosHelxIn2R = new TH1F("histPosHelxIn2R",titlePosHelx,bins,xmin,xmax); TH1F *histPosHelxInR = new TH1F("histPosHelxInR",titlePosHelx,bins,xmin,xmax); TH1F *histPosHelxOut1R = new TH1F("histPosHelxOut1R",titlePosHelx,bins,xmin,xmax); TH1F *histPosHelxOut2R = new TH1F("histPosHelxOut2R",titlePosHelx,bins,xmin,xmax); TH1F *histPosHelxOutR = new TH1F("histPosHelxOutR",titlePosHelx,bins,xmin,xmax); TH1F *histPosHelxIn1L = new TH1F("histPosHelxIn1L",titlePosHelx,bins,xmin,xmax); TH1F *histPosHelxIn2L = new TH1F("histPosHelxIn2L",titlePosHelx,bins,xmin,xmax); TH1F *histPosHelxInL = new TH1F("histPosHelxInL",titlePosHelx,bins,xmin,xmax); TH1F *histPosHelxOut1L = new TH1F("histPosHelxOut1L",titlePosHelx,bins,xmin,xmax); TH1F *histPosHelxOut2L = new TH1F("histPosHelxOut2L",titlePosHelx,bins,xmin,xmax); TH1F *histPosHelxOutL = new TH1F("histPosHelxOutL",titlePosHelx,bins,xmin,xmax); TH1F *histPosHelxR = new TH1F("histPosHelxL",titlePosHelx,bins,xmin,xmax); TH1F *histPosHelxL = new TH1F("histPosHelxR",titlePosHelx,bins,xmin,xmax); TH1F *histPosHelx = new TH1F("histPosHelx",titlePosHelx,bins,xmin,xmax); chainHeR->Draw("(PriKineR.Q2 / (PriKineR.nu * 2 * 0.9315))>>histPosHelxIn1R", cutsR && "g0hel.R.helicity==1" && "fEvtHdr.fRun>20576" && "fEvtHdr.fRun<20684", ""); chainHeR->Draw("(PriKineR.Q2 / (PriKineR.nu * 2 * 0.9315))>>histPosHelxIn2R", cutsR && "g0hel.R.helicity==1" && "fEvtHdr.fRun>20728" && "fEvtHdr.fRun<20813", ""); chainHeR->Draw("(PriKineR.Q2 / (PriKineR.nu * 2 * 0.9315))>>histPosHelxOut1R", cutsR && "g0hel.R.helicity==-1" && "fEvtHdr.fRun>20683" && "fEvtHdr.fRun<20728", ""); chainHeR->Draw("(PriKineR.Q2 / (PriKineR.nu * 2 * 0.9315))>>histPosHelxOut2R", cutsR && "g0hel.R.helicity==-1" && "fEvtHdr.fRun>20813" && "fEvtHdr.fRun<20879", ""); chainHeL->Draw("(PriKineL.Q2 / (PriKineL.nu * 2 * 0.9315))>>histPosHelxIn1L", cutsL && "g0hel.L.helicity==1" && "fEvtHdr.fRun>1685" && "fEvtHdr.fRun<1778", ""); chainHeL->Draw("(PriKineL.Q2 / (PriKineL.nu * 2 * 0.9315))>>histPosHelxIn2L", cutsL && "g0hel.L.helicity==1" && "fEvtHdr.fRun>1822" && "fEvtHdr.fRun<1905", ""); chainHeL->Draw("(PriKineL.Q2 / (PriKineL.nu * 2 * 0.9315))>>histPosHelxOut1L", cutsL && "g0hel.L.helicity==-1" && "fEvtHdr.fRun>1777" && "fEvtHdr.fRun<1823", ""); chainHeL->Draw("(PriKineL.Q2 / (PriKineL.nu * 2 * 0.9315))>>histPosHelxOut2L", cutsL && "g0hel.L.helicity==-1" && "fEvtHdr.fRun>1905" && "fEvtHdr.fRun<1960", ""); histPosHelxInR->Add(histPosHelxIn1R,histPosHelxIn2R); histPosHelxOutR->Add(histPosHelxOut1R,histPosHelxOut2R); histPosHelxR->Add(histPosHelxInR,histPosHelxOutR); histPosHelxInL->Add(histPosHelxIn1L,histPosHelxIn2L); histPosHelxOutL->Add(histPosHelxOut1L,histPosHelxOut2L); histPosHelxL->Add(histPosHelxInL,histPosHelxOutL); histPosHelx->Add(histPosHelxR,histPosHelxL); histPosHelx->Draw(); pad9->cd(); TString titleNegHelx = "# of Negative Helicity Events vs. Bjorken x"; cout << "Drawing " << titleNegHelx << "..." << endl; TH1F *histNegHelxIn1R = new TH1F("histNegHelxIn1R",titleNegHelx,bins,xmin,xmax); TH1F *histNegHelxIn2R = new TH1F("histNegHelxIn2R",titleNegHelx,bins,xmin,xmax); TH1F *histNegHelxInR = new TH1F("histNegHelxInR",titleNegHelx,bins,xmin,xmax); TH1F *histNegHelxOut1R = new TH1F("histNegHelxOut1R",titleNegHelx,bins,xmin,xmax); TH1F *histNegHelxOut2R = new TH1F("histNegHelxOut2R",titleNegHelx,bins,xmin,xmax); TH1F *histNegHelxOutR = new TH1F("histNegHelxOutR",titleNegHelx,bins,xmin,xmax); TH1F *histNegHelxR = new TH1F("histNegHelxR",titleNegHelx,bins,xmin,xmax); TH1F *histNegHelxIn1L = new TH1F("histNegHelxIn1L",titleNegHelx,bins,xmin,xmax); TH1F *histNegHelxIn2L = new TH1F("histNegHelxIn2L",titleNegHelx,bins,xmin,xmax); TH1F *histNegHelxInL = new TH1F("histNegHelxInL",titleNegHelx,bins,xmin,xmax); TH1F *histNegHelxOut1L = new TH1F("histNegHelxOut1L",titleNegHelx,bins,xmin,xmax); TH1F *histNegHelxOut2L = new TH1F("histNegHelxOut2L",titleNegHelx,bins,xmin,xmax); TH1F *histNegHelxOutL = new TH1F("histNegHelxOutL",titleNegHelx,bins,xmin,xmax); TH1F *histNegHelxL = new TH1F("histNegHelxL",titleNegHelx,bins,xmin,xmax); TH1F *histNegHelx = new TH1F("histNegHelx",titleNegHelx,bins,xmin,xmax); chainHeR->Draw("(PriKineR.Q2 / (PriKineR.nu * 2 * 0.9315))>>histNegHelxIn1R", cutsR && "g0hel.R.helicity==-1" && "fEvtHdr.fRun>20576" && "fEvtHdr.fRun<20684", ""); chainHeR->Draw("(PriKineR.Q2 / (PriKineR.nu * 2 * 0.9315))>>histNegHelxIn2R", cutsR && "g0hel.R.helicity==-1" && "fEvtHdr.fRun>20728" && "fEvtHdr.fRun<20813", ""); chainHeR->Draw("(PriKineR.Q2 / (PriKineR.nu * 2 * 0.9315))>>histNegHelxOut1R", cutsR && "g0hel.R.helicity==1" && "fEvtHdr.fRun>20683" && "fEvtHdr.fRun<20728", ""); chainHeR->Draw("(PriKineR.Q2 / (PriKineR.nu * 2 * 0.9315))>>histNegHelxOut2R", cutsR && "g0hel.R.helicity==1" && "fEvtHdr.fRun>20813" && "fEvtHdr.fRun<20879", ""); chainHeL->Draw("(PriKineL.Q2 / (PriKineL.nu * 2 * 0.9315))>>histNegHelxIn1L", cutsL && "g0hel.L.helicity==-1" && "fEvtHdr.fRun>1685" && "fEvtHdr.fRun<1778", ""); chainHeL->Draw("(PriKineL.Q2 / (PriKineL.nu * 2 * 0.9315))>>histNegHelxIn2L", cutsL && "g0hel.L.helicity==-1" && "fEvtHdr.fRun>1822" && "fEvtHdr.fRun<1905", ""); chainHeL->Draw("(PriKineL.Q2 / (PriKineL.nu * 2 * 0.9315))>>histNegHelxOut1L", cutsL && "g0hel.L.helicity==1" && "fEvtHdr.fRun>1777" && "fEvtHdr.fRun<1823", ""); chainHeL->Draw("(PriKineL.Q2 / (PriKineL.nu * 2 * 0.9315))>>histNegHelxOut2L", cutsL && "g0hel.L.helicity==1" && "fEvtHdr.fRun>1905" && "fEvtHdr.fRun<1960", ""); histNegHelxInR->Add(histNegHelxIn1R,histNegHelxIn2R); histNegHelxInL->Add(histNegHelxIn1L,histNegHelxIn2L); histNegHelxOutR->Add(histNegHelxOut1R,histNegHelxOut2R); histNegHelxOutL->Add(histNegHelxOut1L,histNegHelxOut2L); histNegHelxR->Add(histNegHelxInR,histNegHelxOutR); histNegHelxL->Add(histNegHelxInL,histNegHelxOutL); histNegHelx->Add(histNegHelxR,histNegHelxL); histNegHelx->Draw(); pad10->cd(); TString titlex = "Bjorken x "; titlex += " (x=Q^2/[2m*nu])"; cout << "Drawing " << titlex << "..." << endl; TH1F *histxR = new TH1F("histxR",titlex,bins,xmin,xmax); TH1F *histxL = new TH1F("histxL",titlex,bins,xmin,xmax); TH1F *histx = new TH1F("histx",titlex,bins,xmin,xmax); histx->Sumw2(); chainHeR->Draw("(PriKineR.Q2 / (PriKineR.nu * 2 * 0.9315))>>histxR", cutsR, "E"); chainHeL->Draw("(PriKineL.Q2 / (PriKineL.nu * 2 * 0.9315))>>histxL", cutsL, "E"); histx->Add(histxR,histxL); histx->Draw(); // Note: Asymmetry is defined as (Pos - Neg)/(Pos + Neg) pad11->cd(); TString titleAsym = "Beam Asymmetry (%) vs. Bjorken x for Q2 of "; titleAsym += Q2; cout << "Drawing " << titleAsym << "..." << endl; histAsym = histPosHelx->GetAsymmetry(histNegHelx); histAsym->Scale(100); histAsym->SetTitle(titleAsym); histAsym->Draw(); TString imagename = "Asymmetries/Vertical_Beam_Asymmetry_for_Q2_of_"; imagename += Q2; imagename += ".png"; c1->Print(imagename); cout << "All done!" << endl; }
//______________________________________________________________________________ void processJpsi2eeQAplots(const Char_t* filename="jpsi_Default.root", TString suffix = "eps", const Char_t* outfile="Jpsi2eeQAplots_output.root") { // // TFile* file = TFile::Open(filename); // event wise histograms TH1F* zDistrib = (TH1F*)GetHistogram(file, "default", "Event", "Z"); // electron candidate histograms TH2F* tpcDedx = (TH2F*)GetHistogram(file, "default", "Track_ev1+", "P_InnerParam_TPC_signal"); tpcDedx->Add((TH2F*)GetHistogram(file, "default", "Track_ev1-", "P_InnerParam_TPC_signal")); TH2F* tpcNsigmaEle = (TH2F*)GetHistogram(file, "default", "Track_ev1+", "P_InnerParam_TPC_nSigma_Electrons"); tpcNsigmaEle->Add((TH2F*)GetHistogram(file, "default", "Track_ev1-", "P_InnerParam_TPC_nSigma_Electrons")); // pair candidate histograms TH1F* invmass_pp = (TH1F*)GetHistogram(file, "default", "Pair_ev1+_ev1+", "pM"); TH1F* invmass_pm = (TH1F*)GetHistogram(file, "default", "Pair_ev1+_ev1-", "pM"); TH1F* invmass_mm = (TH1F*)GetHistogram(file, "default", "Pair_ev1-_ev1-", "pM"); // draw stuff TLatex* latex=new TLatex(); latex->SetNDC(); latex->SetTextSize(0.04); latex->SetTextFont(42); TCanvas* c1=new TCanvas("fig_dq_tpcDedx", ""); if(tpcDedx) { tpcDedx->SetStats(kFALSE); tpcDedx->GetXaxis()->SetRangeUser(0.0,10.0); tpcDedx->GetYaxis()->SetRangeUser(40.0,120.0); tpcDedx->SetTitle(""); tpcDedx->Draw("colz"); latex->DrawLatex(0.12, 0.83, "J/#psi electron candidates"); } TCanvas* c2=new TCanvas("fig_dq_tpcNsigmaElectron", ""); if(tpcNsigmaEle) { tpcNsigmaEle->SetStats(kFALSE); tpcNsigmaEle->GetYaxis()->SetRangeUser(-5.0,5.0); tpcNsigmaEle->GetXaxis()->SetRangeUser(0.0,10.0); tpcNsigmaEle->SetTitle(""); tpcNsigmaEle->Draw("colz"); latex->DrawLatex(0.12, 0.83, "J/#psi electron candidates"); } TCanvas* c3=new TCanvas("fig_dq_eeInvMass", ""); if(invmass_pm) { invmass_pm->SetStats(kFALSE); invmass_pm->SetTitle(""); invmass_pm->SetLineColor(1); invmass_pm->GetYaxis()->SetTitle(Form("Pairs per %.0f MeV/c^{2}", 1000.0*invmass_pm->GetXaxis()->GetBinWidth(1))); invmass_pm->GetXaxis()->SetTitle("m_{e^{+}e^{-}} (GeV/c^{2})"); invmass_pm->Draw(); } if(invmass_pp) { invmass_pp->SetLineColor(2); invmass_pp->Draw((invmass_pm ? "same" : "")); } if(invmass_mm) { invmass_mm->SetLineColor(4); invmass_mm->Draw((invmass_mm ? "same" : "")); } if(invmass_pm || invmass_mm || invmass_pp) latex->DrawLatex(0.12, 0.85, "J/#psi candidates"); if(invmass_pm && zDistrib && zDistrib->Integral()>1.); latex->DrawLatex(0.12, 0.80, Form("candidates / event = %.3f", invmass_pm->Integral() / zDistrib->Integral())); TLegend* legend=new TLegend(0.7,0.7,0.89,0.89); legend->SetTextFont(42); legend->SetBorderSize(0); legend->SetFillColor(0); if(invmass_pm) legend->AddEntry(invmass_pm, "+- pairs", "l"); if(invmass_pp) legend->AddEntry(invmass_pp, "++ pairs", "l"); if(invmass_mm) legend->AddEntry(invmass_mm, "-- pairs", "l"); if(invmass_mm || invmass_pm || invmass_pp) legend->Draw(); c1->SaveAs(Form("fig_dq_tpcDedx.%s",suffix.Data())); c2->SaveAs(Form("fig_dq_tpcNsigmaElectron.%s",suffix.Data())); c3->SaveAs(Form("fig_dq_eeInvMass.%s",suffix.Data())); // TFile* save=new TFile(outputName, "RECREATE"); // c1->Write(); // c2->Write(); // c3->Write(); // save->Close(); // Added by jsatya TFile *fout = TFile::Open(outfile,"UPDATE"); fout->ls(); TDirectoryFile *cdd = NULL; cdd = (TDirectoryFile*)fout->Get("DQ"); if(!cdd) { Printf("Warning: DQ <dir> doesn't exist, creating a new one"); cdd = (TDirectoryFile*)fout->mkdir("DQ"); } cdd->cd(); cdd->ls(); if (invmass_pp){ invmass_pp->SetName(Form("fig_dq_%s_pp", invmass_pp->GetName())); invmass_pp->Write(); } if (invmass_pm){ invmass_pm->SetName(Form("fig_dq_%s_pm", invmass_pm->GetName())); invmass_pm->Write(); } if (invmass_mm){ invmass_mm->SetName(Form("fig_dq_%s_mm", invmass_mm->GetName())); invmass_mm->Write(); } tpcNsigmaEle->SetName(Form("fig_dq_%s", tpcNsigmaEle->GetName())); tpcNsigmaEle->Write(); tpcDedx->SetName(Form("fig_dq_%s", tpcDedx->GetName())); tpcDedx->Write(); fout->cd(); fout->Close(); }
void v_src_fit(){ /* int CRunNumberR=20602; int endCRunNumberR=20603; int HeRunNumberR=999999; int endHeRunNumberR=999999; */ int CRunNumberR=20591; int endCRunNumberR=22462; int CRunNumberL=1699; int endCRunNumberL=1829; int HeRunNumberR=20579; int endHeRunNumberR=20790; int HeRunNumberL=1686; int endHeRunNumberL=1883; // NOTE: There is a problem with the BCM values. When fixed, swap below and above lines. // int endHeRunNumberR=20879; // int endHeRunNumberL=1958; TString Q2 = "1.0"; double bins = 50; double plotmin = 0.5; double plotmax = 2.0; TString title = "12C/3He x with Target cut, Run # "; title += CRunNumberR; title += " & "; title += HeRunNumberR; // Defines Right Arm Cuts TCut cutR = ""; TCut kinematicsR = "PriKineR.Q2<10 && GoodElectron==1 && PriKineR.nu<10"; // TCut eventtypeR = "D.evtypebits&(1<<1)>0"; TCut eventtypeR = "(D.evtypebits&2)==2"; TCut goldR = "ExTgtCor_R.dp>-0.04 && ExTgtCor_R.dp<0.058"; TCut targetR = "ReactPt_R.z>-0.155 && ReactPt_R.z<0.175"; TCut sieveR = "abs(ExTgtCor_R.ph)<0.03 && abs(ExTgtCor_R.th)<0.06"; TCut cutsR = kinematicsR && targetR && sieveR && goldR && eventtypeR; // Defines Left Arm Cuts TCut cutL = ""; TCut kinematicsL = "PriKineL.Q2<10 && GoodElectron==1 && PriKineL.nu<10"; // TCut eventtypeL = "D.evtypebits&(1<<1)>0"; // TCut eventtypeL = "(D.evtypebits&2)==2"; TCut eventtypeL = ""; TCut goldL = "ExTgtCor_L.dp>-0.04 && ExTgtCor_L.dp<0.058"; TCut targetL = "ReactPt_L.z>-0.155 && ReactPt_L.z<0.175"; TCut sieveL = "abs(ExTgtCor_L.ph)<0.03 && abs(ExTgtCor_L.th)<0.06"; TCut cutsL = kinematicsL && targetL && sieveL && goldL && eventtypeL; // Makes right and left chains that will contain all the data TChain* chainCR = new TChain("T"); TChain* chainHeR = new TChain("T"); TChain* chainCL = new TChain("T"); TChain* chainHeL = new TChain("T"); gStyle->SetErrorX(.25); gStyle->SetEndErrorSize(.25); ifstream inp; ofstream out; TString filenameCR; TString filenameHeR; TString filenameCL; TString filenameHeL; // Below is the loop for adding chains for the Right Carbon runs for (int thisCRunNumberR=CRunNumberR; thisCRunNumberR<(endCRunNumberR+1); thisCRunNumberR++) { if(thisCRunNumberR==20592){thisCRunNumberR=20731;} if(thisCRunNumberR==20735){thisCRunNumberR=22380;} if(thisCRunNumberR==22381){thisCRunNumberR=22389;} if(thisCRunNumberR==22390){thisCRunNumberR=22425;} if(thisCRunNumberR==22427){thisCRunNumberR=22461;} if(thisCRunNumberR==22462){thisCRunNumberR=99999;} for (int t=0; t<1000;t++) { filenameCR = "/home/ellie/physics/e05-102/terabyte/ROOTfiles/e05102_R_"; filenameCR += thisCRunNumberR; if (t!=0) { filenameCR += "_"; filenameCR += t; } filenameCR += ".root"; ifstream ifileCR(filenameCR); if (ifileCR) { cout << "Adding file to chainCR: " << filenameCR << endl; chainCR->Add(filenameCR); } else { cout << "File " << filenameCR << " does not exist. Ending here." << endl; t=9999999; } } // Uncommenting the line below will let the code only go through one run (Good for debugging purposes) // thisCRunNumberR = 99999999; } // Below is the loop for adding chains for the Left Carbon runs for (int thisCRunNumberL=CRunNumberL; thisCRunNumberL<(endCRunNumberL+1); thisCRunNumberL++) { if(thisCRunNumberL==1700){thisCRunNumberL=1825;} if(thisCRunNumberL==1829){thisCRunNumberL=9999;} for (int t=0; t<1000;t++) { filenameCL = "/home/ellie/physics/e05-102/terabyte/ROOTfiles/e05102_L_"; filenameCL += thisCRunNumberL; if (t!=0) { filenameCL += "_"; filenameCL += t; } filenameCL += ".root"; ifstream ifileCL(filenameCL); if (ifileCL) { cout << "Adding file to chainCL: " << filenameCL << endl; chainCL->Add(filenameCL); } else { cout << "File " << filenameCL << " does not exist. Ending here." << endl; t=9999999; } } // Uncommenting the line below will let the code only go through one run (Good for debugging purposes) // thisCRunNumberL = 99999999; } // Below is the loop for adding chains for the Right 3He runs for (int thisHeRunNumberR=HeRunNumberR;thisHeRunNumberR<(endHeRunNumberR+1); thisHeRunNumberR++) { // Skipping Vertical Carbon Runs if(thisHeRunNumberR==20591){thisHeRunNumberR=20596;} if(thisHeRunNumberR==20731){thisHeRunNumberR=20738;} if(thisHeRunNumberR==20732){thisHeRunNumberR=20738;} if(thisHeRunNumberR==20733){thisHeRunNumberR=20738;} if(thisHeRunNumberR==20734){thisHeRunNumberR=20738;} if(thisHeRunNumberR==20736){thisHeRunNumberR=20738;} if(thisHeRunNumberR==20737){thisHeRunNumberR=20738;} if(thisHeRunNumberR==20791){thisHeRunNumberR=20814;} if(thisHeRunNumberR==20792){thisHeRunNumberR=20814;} // Skipping Longitudinal Carbon Runs if(thisHeRunNumberR==22380){thisHeRunNumberR=22393;} if(thisHeRunNumberR==22389){thisHeRunNumberR=22393;} if(thisHeRunNumberR==22425){thisHeRunNumberR=22436;} if(thisHeRunNumberR==22426){thisHeRunNumberR=22436;} // Skipping Transverse Carbon Runs if(thisHeRunNumberR==22461){thisHeRunNumberR=22465;} for (int t=0; t<1000;t++) { filenameHeR = "/home/ellie/physics/e05-102/terabyte/ROOTfiles/e05102_R_"; filenameHeR += thisHeRunNumberR; if (t!=0) { filenameHeR += "_"; filenameHeR += t; } filenameHeR += ".root"; ifstream ifileHeR(filenameHeR); if (ifileHeR) { cout << "Adding file to chainHeR: " << filenameHeR << endl; chainHeR->Add(filenameHeR); } else { cout << "File " << filenameHeR << " does not exist. Ending here." << endl; t=9999999; } } // Uncommenting the line below will let the code only go through one run (Good for debugging purposes) // thisHeRunNumberR = 999999999; } // Below is the loop for adding chains for the Left 3He runs for (int thisHeRunNumberL=HeRunNumberL;thisHeRunNumberL<(endHeRunNumberL+1); thisHeRunNumberL++) { // Skipping Vertical Carbon Runs if(thisHeRunNumberL==1699){thisHeRunNumberL=1704;} if(thisHeRunNumberL==1825){thisHeRunNumberL=1832;} if(thisHeRunNumberL==1826){thisHeRunNumberL=1832;} if(thisHeRunNumberL==1827){thisHeRunNumberL=1832;} if(thisHeRunNumberL==1828){thisHeRunNumberL=1832;} if(thisHeRunNumberL==1830){thisHeRunNumberL=1832;} if(thisHeRunNumberL==1831){thisHeRunNumberL=1832;} if(thisHeRunNumberL==1884){thisHeRunNumberL=1906;} if(thisHeRunNumberL==1885){thisHeRunNumberL=1906;} for (int t=0; t<1000;t++) { filenameHeL = "/home/ellie/physics/e05-102/terabyte/ROOTfiles/e05102_L_"; filenameHeL += thisHeRunNumberL; if (t!=0) { filenameHeL += "_"; filenameHeL += t; } filenameHeL += ".root"; ifstream ifileHeL(filenameHeL); if (ifileHeL) { cout << "Adding file to chainHeL: " << filenameHeL << endl; chainHeL->Add(filenameHeL); } else { cout << "File " << filenameHeL << " does not exist. Ending here." << endl; t=9999999; } } // Uncommenting the line below will let the code only go through one run (Good for debugging purposes) // thisHeRunNumberL = 999999999; } gStyle->SetPalette(1); gStyle->SetOptFit(0001); // Defines Canvas TCanvas *c1 = new TCanvas("c1","x of 12C and 3He",1360,800);//x,y pad01 = new TPad("pad01","pad01",0.0000,0.8333,0.2000,1.0000,0,0,0); pad02 = new TPad("pad02","pad02",0.2000,0.8333,0.4000,1.0000,0,0,0); pad03 = new TPad("pad03","pad03",0.4000,0.8333,0.6000,1.0000,0,0,0); pad04 = new TPad("pad04","pad04",0.6000,0.8333,0.8000,1.0000,0,0,0); pad05 = new TPad("pad05","pad05",0.0000,0.6666,0.2000,0.8333,0,0,0); pad06 = new TPad("pad06","pad06",0.2000,0.6666,0.4000,0.8333,0,0,0); pad07 = new TPad("pad07","pad07",0.4000,0.6666,0.6000,0.8333,0,0,0); pad08 = new TPad("pad08","pad08",0.6000,0.6666,0.8000,0.8333,0,0,0); pad09 = new TPad("pad09","pad09",0.0000,0.3333,0.3333,0.6666,0,0,0); pad10 = new TPad("pad10","pad10",0.3333,0.3333,0.6666,0.6666,0,0,0); pad11 = new TPad("pad11","pad11",0.6666,0.3333,1.0000,0.6666,0,0,0); pad12 = new TPad("pad12","pad12",0.0000,0.0000,0.3333,0.3333,0,0,0); pad13 = new TPad("pad13","pad13",0.3333,0.0000,0.6666,0.3333,0,0,0); pad14 = new TPad("pad14","pad14",0.6666,0.0000,1.0000,0.3333,0,0,0); pad15 = new TPad("pad15","pad15",0.8000,0.8333,1.0000,1.0000,0,0,0); pad16 = new TPad("pad16","pad16",0.8000,0.6666,1.0000,0.8333,0,0,0); pad01->Draw();pad02->Draw();pad03->Draw();pad04->Draw();pad05->Draw();pad06->Draw();pad07->Draw();pad08->Draw();pad09->Draw();pad10->Draw();pad11->Draw();pad12->Draw();pad13->Draw();pad14->Draw();pad15->Draw();pad16->Draw(); // Everything below here makes graphs for each section of the canvas pad01->cd(); TString titledpHe = "dp Cut from 3He Runs"; cout << "Drawing " << titledpHe << "..." << endl; TH1F *HedpNoCut = new TH1F("HedpNoCut",titledpHe,400,-0.08,0.08); TH1F *HedpCut = new TH1F("HedpCut",titledpHe,400,-0.08,0.08); chainHeR->Draw("ExTgtCor_R.dp>>HedpNoCutR(400,-0.08,0.08)", "", ""); chainHeR->Draw("ExTgtCor_R.dp>>HedpCutR(400,-0.08,0.08)", goldR, ""); chainHeL->Draw("ExTgtCor_L.dp>>HedpNoCutL(400,-0.08,0.08)", "", ""); chainHeL->Draw("ExTgtCor_L.dp>>HedpCutL(400,-0.08,0.08)", goldL, ""); HedpNoCut->Add(HedpNoCutR,HedpNoCutL); HedpNoCut->SetTitle(titledpHe); HedpNoCut->Draw(); HedpCut->Add(HedpCutR,HedpCutL); HedpCut->SetLineColor(kBlack); HedpCut->SetFillColor(kViolet); HedpCut->Draw("same"); pad05->cd(); TString titledpC = "dp Cut from 12C Runs"; cout << "Drawing " << titledpC << "..." << endl; TH1F *CdpNoCut = new TH1F("CdpNoCut",titledpC,400,-0.8,0.8); TH1F *CdpCut = new TH1F("CdpCut",titledpC,400,-0.8,0.8); chainCR->Draw("ExTgtCor_R.dp>>CdpNoCutR(400,-0.08,0.08)", "", ""); chainCR->Draw("ExTgtCor_R.dp>>CdpCutR(400,-0.08,0.08)", goldR, ""); chainCL->Draw("ExTgtCor_L.dp>>CdpNoCutL(400,-0.08,0.08)", "", ""); chainCL->Draw("ExTgtCor_L.dp>>CdpCutL(400,-0.08,0.08)", goldL, ""); CdpNoCut->Add(CdpNoCutR,CdpNoCutL); CdpNoCut->SetTitle(titledpC); CdpNoCut->Draw(); CdpCut->Add(CdpCutR,CdpCutL); CdpCut->SetLineColor(kBlack); CdpCut->SetFillColor(kViolet); CdpCut->Draw("same"); pad02->cd(); TString titleTargetHe = "Target Cut for 3He Runs"; cout << "Drawing " << titleTargetHe << "..." << endl; TH1F *HeReactZNoCut = new TH1F("HeReactZNoCut",titleTargetHe,400,-0.3,0.3); TH1F *HeReactZCut = new TH1F("HeReactZCut",titleTargetHe,400,-0.3,0.3); chainHeR->Draw("ReactPt_R.z>>HeReactZNoCutR(400,-0.3,0.3)", "", ""); chainHeR->Draw("ReactPt_R.z>>HeReactZCutR(400,-0.3,0.3)", targetR, ""); chainHeL->Draw("ReactPt_L.z>>HeReactZNoCutL(400,-0.3,0.3)", "", ""); chainHeL->Draw("ReactPt_L.z>>HeReactZCutL(400,-0.3,0.3)", targetL, ""); HeReactZNoCut->Add(HeReactZNoCutR,HeReactZNoCutL); HeReactZNoCut->SetTitle(titleTargetHe); HeReactZNoCut->Draw(); HeReactZCut->Add(HeReactZCutR,HeReactZCutL); HeReactZCut->SetLineColor(kBlack); HeReactZCut->SetFillColor(kViolet); HeReactZCut->Draw("same"); pad06->cd(); TString titleTargetC = "Target Cut for 12C Runs"; cout << "Drawing " << titleTargetC << "..." << endl; TH1F *CReactZNoCut = new TH1F("CReactZNoCut",titleTargetC,400,-0.3,0.3); TH1F *CReactZCut = new TH1F("CReactZCut",titleTargetC,400,-0.3,0.3); chainCR->Draw("ReactPt_R.z>>CReactZNoCutR(400,-0.3,0.3)", "", ""); chainCR->Draw("ReactPt_R.z>>CReactZCutR(400,-0.3,0.3)", targetR, ""); chainCL->Draw("ReactPt_L.z>>CReactZNoCutL(400,-0.3,0.3)", "", ""); chainCL->Draw("ReactPt_L.z>>CReactZCutL(400,-0.3,0.3)", targetL, ""); CReactZNoCut->Add(CReactZNoCutR,CReactZNoCutL); CReactZNoCut->SetTitle(titleTargetC); CReactZNoCut->Draw(); CReactZCut->Add(CReactZCutR,CReactZCutL); CReactZCut->SetLineColor(kBlack); CReactZCut->SetFillColor(kViolet); CReactZCut->Draw("same"); pad03->cd(); TString titleThetaPhiHe = "Theta and Phi, No Cut, for 3He"; cout << "Drawing " << titleThetaPhiHe << "..." << endl; TH2F *HeThetaPhiNoCut = new TH2F("HeThetaPhiNoCut",titleThetaPhiHe,100,-0.05,0.05,100,-0.1,0.1); chainHeR->Draw("ExTgtCor_R.th:ExTgtCor_R.ph>>HeThetaPhiNoCutR(100,-0.05,0.05,100,-0.1,0.1)", targetR, ""); chainHeL->Draw("ExTgtCor_L.th:ExTgtCor_L.ph>>HeThetaPhiNoCutL(100,-0.05,0.05,100,-0.1,0.1)", targetL, ""); HeThetaPhiNoCut->Add(HeThetaPhiNoCutR,HeThetaPhiNoCutL); HeThetaPhiNoCut->SetTitle(titleThetaPhiHe); HeThetaPhiNoCut->SetStats(kFALSE); HeThetaPhiNoCut->Draw("COLZ"); pad07->cd(); TString titleThetaPhiC = "Theta and Phi, No Cut, for 12C"; cout << "Drawing " << titleThetaPhiC << "..." << endl; TH2F *CThetaPhiNoCut = new TH2F("CThetaPhiNoCut",titleThetaPhiC,100,-0.05,0.05,100,-0.1,0.1); chainCR->Draw("ExTgtCor_R.th:ExTgtCor_R.ph>>CThetaPhiNoCutR(100,-0.05,0.05,100,-0.1,0.1)", targetR, ""); chainCL->Draw("ExTgtCor_L.th:ExTgtCor_L.ph>>CThetaPhiNoCutL(100,-0.05,0.05,100,-0.1,0.1)", targetL, ""); CThetaPhiNoCut->Add(CThetaPhiNoCutR,CThetaPhiNoCutL); CThetaPhiNoCut->SetTitle(titleThetaPhiC); CThetaPhiNoCut->SetStats(kFALSE); CThetaPhiNoCut->Draw("COLZ"); pad04->cd(); TString titleThetaCutHe = "Theta and Phi Cut for 3He"; cout << "Drawing " << titleThetaCutHe << "..." << endl; TH2F *HeThetaPhiCut = new TH2F("HeThetaPhiCut",titleThetaCutHe,100,-0.05,0.05,100,-0.1,0.1); chainHeR->Draw("ExTgtCor_R.th:ExTgtCor_R.ph>>HeThetaPhiCutR(100,-0.05,0.05,100,-0.1,0.1)", targetR && sieveR, ""); chainHeL->Draw("ExTgtCor_L.th:ExTgtCor_L.ph>>HeThetaPhiCutL(100,-0.05,0.05,100,-0.1,0.1)", targetL && sieveL, ""); HeThetaPhiCut->Add(HeThetaPhiCutR,HeThetaPhiCutL); HeThetaPhiCut->SetTitle(titleThetaCutHe); HeThetaPhiCut->SetStats(kFALSE); HeThetaPhiCut->Draw("COLZ"); pad08->cd(); TString titleThetaCutC = "Theta and Phi Cut for 12C"; cout << "Drawing " << titleThetaCutC << "..." << endl; TH2F *CThetaPhiCut = new TH2F("CThetaPhiCut",titleThetaCutC,100,-0.05,0.05,100,-0.1,0.1); chainCR->Draw("ExTgtCor_R.th:ExTgtCor_R.ph>>CThetaPhiCutR(100,-0.05,0.05,100,-0.1,0.1)", targetR && sieveR, ""); chainCL->Draw("ExTgtCor_L.th:ExTgtCor_L.ph>>CThetaPhiCutL(100,-0.05,0.05,100,-0.1,0.1)", targetL && sieveL, ""); CThetaPhiCut->Add(CThetaPhiCutR,CThetaPhiCutL); CThetaPhiCut->SetTitle(titleThetaCutC); CThetaPhiCut->SetStats(kFALSE); CThetaPhiCut->Draw("COLZ"); pad15->cd(); TString titleQ2WHe = "Q2 v. Omega for 3He"; cout << "Drawing " << titleQ2WHe << "..." << endl; TH2F *Q2WHe = new TH2F("Q2WHe",titleQ2WHe,100,0.3,0.8,400,0,1.6); chainHeR->Draw("PriKineR.Q2:PriKineR.nu>>Q2WHeR(100,0.3,0.8,400,0,1.6)", cutsR, ""); chainHeL->Draw("PriKineL.Q2:PriKineL.nu>>Q2WHeL(100,0.3,0.8,400,0,1.6)", cutsL, ""); Q2WHe->Add(Q2WHeR,Q2WHeL); Q2WHe->SetTitle(titleQ2WHe); Q2WHe->SetStats(kFALSE); Q2WHe->Draw("COLZ"); pad16->cd(); TString titleQ2WC = "Q2 v. Omega for 12C"; cout << "Drawing " << titleQ2WC << "..." << endl; TH2F *Q2WC = new TH2F("Q2WC",titleQ2WC,100,0.3,0.8,400,0,1.6); chainCR->Draw("PriKineR.Q2:PriKineR.nu>>Q2WCR(100,0.3,0.8,400,0,1.6,100)", cutsR, ""); chainCL->Draw("PriKineL.Q2:PriKineL.nu>>Q2WCL(100,0.3,0.8,400,0,1.6,100)", cutsL, ""); Q2WC->Add(Q2WCR,Q2WCL); Q2WC->SetTitle(titleQ2WC); Q2WC->SetStats(kFALSE); Q2WC->Draw("COLZ"); pad09->cd(); TString titleC = "x for 12C at Q2 of "; titleC += Q2; // titleC += " and Target Cut of "; // titleC += target; cout << "Drawing " << titleC << "..." << endl; TH1F *histC = new TH1F("histC",titleC,bins,plotmin,plotmax); TH1F *histCR = new TH1F("histCR",titleC,bins,plotmin,plotmax); TH1F *histCL = new TH1F("histCL",titleC,bins,plotmin,plotmax); histC->Sumw2(); histCR->Sumw2(); histCL->Sumw2(); chainCR->Draw("PriKineR.Q2 / (PriKineR.nu * 2 * 0.9315)>>histCR", cutsR, "E"); chainCL->Draw("PriKineL.Q2 / (PriKineL.nu * 2 * 0.9315)>>histCL", cutsL, "E"); histCR->Scale(1/0.0161297); histCL->Scale(1/0.0063175); histC->Add(histCR,histCL); histC->Draw(); TF1 *fitC1 = new TF1("fitC1","[0]*exp(-x*[1])",1.45,1.6); fitC1->SetParNames("C Red p1","C Red p2"); Double_t fitC1const = fitC1->GetParameter(0); Double_t fitC1expconst = fitC1->GetParameter(1); // Double_t fitC1exp = fitC1->GetParameter(2); Double_t fitC1consterror = fitC1->GetParError(0); Double_t fitC1expconsterror = fitC1->GetParError(1); // Double_t fitC1experror = fitC1->GetParError(2); fitC1->SetLineColor(kRed); TF1 *fit2 = new TF1("fitC2","[0]*exp(-x*[1])",1.6,1.8); fitC2->SetParNames("C Blue p1","C Blue p2"); Double_t fitC2const = fitC2->GetParameter(0); Double_t fitC2expconst = fitC2->GetParameter(1); // Double_t fitC2exp = fitC2->GetParameter(2); Double_t fitC2consterror = fitC2->GetParError(0); Double_t fitC2expconsterror = fitC2->GetParError(1); // Double_t fitC2experror = fitC2->GetParError(2); fitC2->SetLineColor(kBlue); // TF1 *fitC3 = new TF1("fitC3","[0]*exp(-x*[1])",1.35,1.45); // fitC3->SetParNames("C Green p1","C Green p2"); // Double_t fitC3const = fitC3->GetParameter(0); // Double_t fitC3expconst = fitC3->GetParameter(1); // Double_t fitC3exp = fitC3->GetParameter(2); // Double_t fitC3consterror = fitC3->GetParError(0); // Double_t fitC3expconsterror = fitC3->GetParError(1); // Double_t fitC3experror = fitC3->GetParError(2); // fitC3->SetLineColor(kGreen); // // histC.Fit("fitC2","R"); // histC.Fit("fitC3","R+"); // histC.Fit("fitC1","R+"); pad12->cd(); pad12->SetLogy(); cout << "Drawing " << titleC << " in log scale..." << endl; TH1F *histC = new TH1F("histC",titleC,bins,plotmin,plotmax); TH1F *histCR = new TH1F("histCR",titleC,bins,plotmin,plotmax); TH1F *histCL = new TH1F("histCL",titleC,bins,plotmin,plotmax); histC->Sumw2(); histCR->Sumw2(); histCL->Sumw2(); chainCR->Draw("PriKineR.Q2 / (PriKineR.nu * 2 * 0.9315)>>histCR", cutsR, "E"); chainCL->Draw("PriKineL.Q2 / (PriKineL.nu * 2 * 0.9315)>>histCL", cutsL, "E"); histC->Add(histCR,histCL); histC->Draw(); // histC.Fit("fitC1","R"); // histC.Fit("fitC3","R+"); // histC.Fit("fitC2","R+"); pad10->cd(); TString titleHe = "x for 3He at Q2 of "; titleHe += Q2; // titleHe += " and Target Cut of "; // titleHe += target; cout << "Drawing " << titleHe << "..." << endl; TH1F *histHe = new TH1F("histHe",titleHe,bins,plotmin,plotmax); TH1F *histHeR = new TH1F("histHeR",titleHe,bins,plotmin,plotmax); TH1F *histHeL = new TH1F("histHeL",titleHe,bins,plotmin,plotmax); histHe->Sumw2(); histHeR->Sumw2(); histHeL->Sumw2(); chainHeR->Draw("PriKineR.Q2 / (PriKineR.nu * 2 * 0.9315)>>histHeR", cutsR, "E"); chainHeL->Draw("PriKineL.Q2 / (PriKineL.nu * 2 * 0.9315)>>histHeL", cutsL, "E"); histHeR->Scale(1/2.409416); histHeL->Scale(1/2.407866); histHe->Add(histHeR,histHeL); histHe->Draw(); TF1 *fitHe1 = new TF1("fitHe1","[0]*exp(-x*[1])",1.45,1.6); fitHe1->SetParNames("He Red p1", "He Red p2"); Double_t fitHe1const = fitHe1->GetParameter(0); Double_t fitHe1expconst = fitHe1->GetParameter(1); // Double_t fitHe1exp = fitHe1->GetParameter(2); Double_t fitHe1consterror = fitHe1->GetParError(0); Double_t fitHe1expconsterror = fitHe1->GetParError(1); // Double_t fitHe1experror = fitHe1->GetParError(2); fitHe1->SetLineColor(kRed); TF1 *fitHe2 = new TF1("fitHe2","[0]*exp(-x*[1])",1.6,1.8); fitHe2->SetParNames("He Blue p1","He Blue p2"); Double_t fitHe2const = fitHe2->GetParameter(0); Double_t fitHe2expconst = fitHe2->GetParameter(1); // Double_t fitHe2exp = fitHe2->GetParameter(2); Double_t fitHe2consterror = fitHe2->GetParError(0); Double_t fitHe2expconsterror = fitHe2->GetParError(1); // Double_t fitHe2experror = fitHe2->GetParError(2); fitHe2->SetLineColor(kBlue); // TF1 *fitHe3 = new TF1("fitHe3","[0]*exp(-x*[1])",1.35,1.45); // fitHe3->SetParNames("He Green p1","He Green p2"); // Double_t fitHe3const = fitHe3->GetParameter(0); // Double_t fitHe3expconst = fitHe3->GetParameter(1); // Double_t fitHe3exp = fitHe3->GetParameter(2); // Double_t fitHe3consterror = fitHe3->GetParError(0); // Double_t fitHe3expconsterror = fitHe3->GetParError(1); // Double_t fitHe3experror = fitHe3->GetParError(2); // fitHe3->SetLineColor(kGreen); // histHe.Fit("fitHe2","R"); // histHe.Fit("fitHe3","R+"); // histHe.Fit("fitHe1","R+"); pad13->cd(); pad13->SetLogy(); cout << "Drawing " << titleHe << " in log scale..." << endl; TH1F *histHe = new TH1F("histHe",titleHe,bins,plotmin,plotmax); TH1F *histHeR = new TH1F("histHeR",titleHe,bins,plotmin,plotmax); TH1F *histHeL = new TH1F("histHeL",titleHe,bins,plotmin,plotmax); histHe->Sumw2(); histHeR->Sumw2(); histHeL->Sumw2(); chainHeR->Draw("PriKineR.Q2 / (PriKineR.nu * 2 * 0.9315)>>histHeR", cutsR, "E"); chainHeL->Draw("PriKineL.Q2 / (PriKineL.nu * 2 * 0.9315)>>histHeL", cutsR, "E"); histHe->Add(histHeR,histHeL); histHe->Draw(); // histHe.Fit("fitHe1","R"); // histHe.Fit("fitHe3","R+"); // histHe.Fit("fitHe2","R+"); pad11->cd(); TString titleCoverHe = "12C/3He for Q2 of "; titleCoverHe += Q2; // titleCoverHe += " and Target Cut of "; // titleCoverHe += target; cout << "Drawing " << titleCoverHe << "..." << endl; TH1F *histCoverHe = new TH1F("histCoverHe",titleCoverHe,bins,plotmin,plotmax); histCoverHe->Sumw2(); histCoverHe->Divide(histC,histHe,1,0.0918143); histCoverHe->Draw("E"); pad14->cd(); pad14->SetLogy(); cout << "Drawing " << titleCoverHe << " in log scale..." << endl; TH1F *histCoverHe = new TH1F("histCoverHe",titleCoverHe,bins,plotmin,plotmax); histCoverHe->Sumw2(); histCoverHe->Divide(histC,histHe,1,0.0918143); histCoverHe->Draw("E"); TString imagename = "xbj_scaling_plots/Vertical_xbj_scaling_plots_all_at_Q2_of_"; imagename += Q2; imagename += ".png"; c1->Print(imagename); cout << "All done!" << endl; }
int ScanChain( TChain* chain, bool fast = true, int nEvents = -1, string skimFilePrefix = "test") { //load PUweights TFile *fPU = new TFile("puWeights.root","READ"); TH1D *puWeight = (TH1D*)fPU->Get("puWeight"); TH1D *puWeightUp = (TH1D*)fPU->Get("puWeightUp"); TH1D *puWeightDown = (TH1D*)fPU->Get("puWeightDown"); TFile *fxsec = new TFile("xsec_stop_13TeV.root","READ"); TH1D *hxsec = (TH1D*)fxsec->Get("stop"); TFile *f_el_SF = new TFile("lepsf/kinematicBinSFele.root", "read"); TFile *f_mu_SF_id = new TFile("lepsf/TnP_MuonID_NUM_MediumID_DENOM_generalTracks_VAR_map_pt_eta.root", "read"); TFile *f_mu_SF_iso = new TFile("lepsf/TnP_MuonID_NUM_MiniIsoTight_DENOM_LooseID_VAR_map_pt_eta.root"); TFile *f_mu_SF_veto_id = new TFile("lepsf/TnP_MuonID_NUM_LooseID_DENOM_generalTracks_VAR_map_pt_eta.root", "read"); TFile *f_mu_SF_veto_iso = new TFile("lepsf/TnP_MuonID_NUM_MiniIsoTight_DENOM_LooseID_VAR_map_pt_eta.root"); //TFile *f_mu_SF_veto_iso = new TFile("lepsf/TnP_MuonID_NUM_MiniIsoLoose_DENOM_LooseID_VAR_map_pt_eta.root"); //TFile *f_vetoLep_eff = new TFile("lepsf/lepeff__ttbar_powheg_pythia8_25ns.root", "read"); TFile *f_vetoLep_eff = new TFile("lepsf/lepeff__ttbar_powheg_pythia8_25ns__SRcuts.root", "read"); TH2D *h_el_SF_id_temp = (TH2D*)f_el_SF->Get("CutBasedMedium"); TH2D *h_el_SF_iso_temp = (TH2D*)f_el_SF->Get("MiniIso0p1_vs_AbsEta"); TH2D *h_el_SF_veto_id_temp = (TH2D*)f_el_SF->Get("CutBasedVeto"); TH2D *h_el_SF_veto_iso_temp = (TH2D*)f_el_SF->Get("MiniIso0p4_vs_AbsEta"); TH2D *h_mu_SF_id_temp = (TH2D*)f_mu_SF_id->Get("pt_abseta_PLOT_pair_probeMultiplicity_bin0_&_tag_combRelIsoPF04dBeta_bin0_&_tag_pt_bin0_&_tag_IsoMu20_pass"); TH2D *h_mu_SF_iso_temp = (TH2D*)f_mu_SF_iso->Get("pt_abseta_PLOT_pair_probeMultiplicity_bin0_&_tag_combRelIsoPF04dBeta_bin0_&_tag_pt_bin0_&_PF_pass_&_tag_IsoMu20_pass"); TH2D *h_mu_SF_veto_id_temp = (TH2D*)f_mu_SF_veto_id->Get("pt_abseta_PLOT_pair_probeMultiplicity_bin0_&_tag_combRelIsoPF04dBeta_bin0_&_tag_pt_bin0_&_tag_IsoMu20_pass"); TH2D *h_mu_SF_veto_iso_temp = (TH2D*)f_mu_SF_veto_iso->Get("pt_abseta_PLOT_pair_probeMultiplicity_bin0_&_tag_combRelIsoPF04dBeta_bin0_&_tag_pt_bin0_&_PF_pass_&_tag_IsoMu20_pass"); //TH2D *h_el_vetoLepEff_temp = (TH2D*)f_vetoLep_eff->Get("h2_lepEff_vetoSel_Eff_el"); //TH2D *h_mu_vetoLepEff_temp = (TH2D*)f_vetoLep_eff->Get("h2_lepEff_vetoSel_Eff_mu"); TH2D *h_el_vetoLepEff_temp = (TH2D*)f_vetoLep_eff->Get("h2_lepEff_vetoSel_rebin_Eff_el"); TH2D *h_mu_vetoLepEff_temp = (TH2D*)f_vetoLep_eff->Get("h2_lepEff_vetoSel_rebin_Eff_mu"); TH2D *h_el_SF_id = (TH2D*)h_el_SF_id_temp->Clone("h_el_SF_id"); TH2D *h_el_SF_iso = (TH2D*)h_el_SF_iso_temp->Clone("h_el_SF_iso"); TH2D *h_mu_SF_id = (TH2D*)h_mu_SF_id_temp->Clone("h_mu_SF_id"); TH2D *h_mu_SF_iso = (TH2D*)h_mu_SF_iso_temp->Clone("h_mu_SF_iso"); TH2D *h_el_SF_veto_id = (TH2D*)h_el_SF_veto_id_temp->Clone("h_el_SF_veto_id"); TH2D *h_el_SF_veto_iso = (TH2D*)h_el_SF_veto_iso_temp->Clone("h_el_SF_veto_iso"); TH2D *h_mu_SF_veto_id = (TH2D*)h_mu_SF_veto_id_temp->Clone("h_mu_SF_veto_id"); TH2D *h_mu_SF_veto_iso = (TH2D*)h_mu_SF_veto_iso_temp->Clone("h_mu_SF_veto_iso"); //This is are the important ones TH2D *h_el_vetoLepEff = (TH2D*)h_el_vetoLepEff_temp->Clone("h_el_vetoLepEff"); TH2D *h_mu_vetoLepEff = (TH2D*)h_mu_vetoLepEff_temp->Clone("h_mu_vetoLepEff"); TH2D *h_el_SF = (TH2D*)h_el_SF_id->Clone("h_el_SF"); h_el_SF->Multiply(h_el_SF_iso); TH2D *h_el_SF_veto = (TH2D*)h_el_SF_veto_id->Clone("h_el_SF_veto"); TH2D *h_mu_SF = (TH2D*)h_mu_SF_id->Clone("h_mu_SF"); h_mu_SF->Multiply(h_mu_SF_iso); TH2D *h_mu_SF_veto = (TH2D*)h_mu_SF_veto_id->Clone("h_mu_SF_veto"); h_mu_SF_veto->Multiply(h_mu_SF_veto_iso); TFile *f_el_FS_ID = new TFile("lepsf/sf_el_mediumCB.root", "read"); TFile *f_el_FS_Iso = new TFile("lepsf/sf_el_mini01.root", "read"); TFile *f_mu_FS_ID = new TFile("lepsf/sf_mu_mediumID.root", "read"); TFile *f_mu_FS_Iso = new TFile("lepsf/sf_mu_mini02.root", "read"); TH2D *h_el_FS_ID_temp = (TH2D*)f_el_FS_ID ->Get("histo2D"); //TH2D *h_el_FS_ID = (TH2D*)h_el_FS_ID_temp ->Clone("h_el_FS_ID"); TH2D *h_el_FS = (TH2D*)h_el_FS_ID_temp ->Clone("h_el_FS"); TH2D *h_el_FS_Iso_temp = (TH2D*)f_el_FS_Iso->Get("histo2D"); //TH2D *h_el_FS_Iso = (TH2D*)h_el_FS_Iso_temp->Clone("h_el_FS_Iso"); h_el_FS->Multiply(h_el_FS_Iso_temp); TH2D *h_mu_FS_ID_temp = (TH2D*)f_mu_FS_ID ->Get("histo2D"); //TH2D *h_mu_FS_ID = (TH2D*)h_mu_FS_ID_temp ->Clone("h_mu_FS_ID"); TH2D *h_mu_FS = (TH2D*)h_mu_FS_ID_temp ->Clone("h_mu_FS"); TH2D *h_mu_FS_Iso_temp = (TH2D*)f_mu_FS_Iso->Get("histo2D"); //TH2D *h_mu_FS_Iso = (TH2D*)h_mu_FS_Iso_temp->Clone("h_mu_FS_ID"); h_mu_FS->Multiply(h_mu_FS_Iso_temp); // Benchmark TBenchmark *bmark = new TBenchmark(); bmark->Start("benchmark"); // Example Histograms TDirectory *rootdir = gDirectory->GetDirectory("Rint:"); map<string, TH3D*> histos;//use D histos as weights can vary a lot among the signal vector<string> histonames; histonames.clear(); // vector<int> hbins; hbins.clear(); // vector<float> hlow; hlow.clear(); // vector<float> hup; hup.clear(); //lumi, trigger, stats done histonames.push_back("SRyield"); histonames.push_back("SR_Bup_HF");//done histonames.push_back("SR_Bdown_HF"); histonames.push_back("SR_Bup_LF");//done histonames.push_back("SR_Bdown_LF"); histonames.push_back("SR_JESup"); histonames.push_back("SR_JESdown"); histonames.push_back("SR_muRFup"); histonames.push_back("SR_muRFdown"); //histonames.push_back("SR_PDFup"); //histonames.push_back("SR_PDFdown"); histonames.push_back("SR_ISRup");//done preliminary histonames.push_back("SR_ISRdown"); histonames.push_back("SR_PUup");//done preliminary histonames.push_back("SR_PUdown"); histonames.push_back("SR_LepEffup");//done - I guess we need no renormalization - no fastsim in, no vetoSF histonames.push_back("SR_LepEffdown"); histonames.push_back("SR_LepEffFSup");//done - I guess we need no renormalization - no fastsim in, no vetoSF histonames.push_back("SR_LepEffFSdown"); histonames.push_back("SR_Xsecup");//done histonames.push_back("SR_Xsecdown"); histonames.push_back("CR1l_sigcontamination");//scaled to signalreg yield histonames.push_back("CR2l_sigcontamination");//scaled to signalreg yield /* histonames.push_back("eventsum"); histonames.push_back("rawweightsum"); histonames.push_back("totweightsum"); histonames.push_back("ISRsum"); histonames.push_back("BSFsum"); histonames.push_back("PUweightsum"); histonames.push_back("xsecsum"); histonames.push_back("nevtsum"); histonames.push_back("lepsum"); histonames.push_back("lepSFsum"); */ for(unsigned int i = 0; i<histonames.size(); ++i){ string mapname = histonames[i]; if(histos.count(mapname) == 0 ) histos[mapname] = new TH3D(mapname.c_str(), "", 37,99,1024, 19,-1,474, 13, -0.5,12.5); //mStop 100-1000, mLSP 0-450, SR 1-12, 9200 bins, SR 0 is non-SR - in case it it needed!! histos[mapname]->Sumw2(); histos[mapname]->SetDirectory(rootdir); } // Loop over events to Analyze unsigned int nEventsTotal = 0; unsigned int nEventsChain = chain->GetEntries(); if( nEvents >= 0 ) nEventsChain = nEvents; TObjArray *listOfFiles = chain->GetListOfFiles(); TIter fileIter(listOfFiles); TFile *currentFile = 0; //get the reweighting histograms TIter fileIterFirst(listOfFiles); TFile *currentFileFirst = 0; TH3D* counterhistSig; TH2F* histNEvts; bool thisisfirst = true; // File Loop for adding correct histograms while ( (currentFileFirst = (TFile*)fileIterFirst.Next()) ) { TFile *file = new TFile( currentFileFirst->GetTitle() ); file->cd(); if(thisisfirst){ counterhistSig = (TH3D*)file->Get("h_counterSMS"); counterhistSig->SetDirectory(0); histNEvts = (TH2F*)file->Get("histNEvts"); histNEvts->SetDirectory(0); thisisfirst = false; } else { TH3D *tempcounterhistSig = (TH3D*)file->Get("h_counterSMS"); tempcounterhistSig->SetDirectory(0); TH2F *temphistNEvts = (TH2F*)file->Get("histNEvts"); temphistNEvts->SetDirectory(0); counterhistSig->Add(tempcounterhistSig); histNEvts->Add(temphistNEvts); tempcounterhistSig->Delete(); temphistNEvts->Delete(); } file->Close(); delete file; } // File Loop while ( (currentFile = (TFile*)fileIter.Next()) ) { // Get File Content TFile *file = new TFile( currentFile->GetTitle() ); TTree *tree = (TTree*)file->Get("t"); if(fast) TTreeCache::SetLearnEntries(10); if(fast) tree->SetCacheSize(128*1024*1024); cms3.Init(tree); // Loop over Events in current file if( nEventsTotal >= nEventsChain ) continue; unsigned int nEventsTree = tree->GetEntriesFast(); for( unsigned int event = 0; event < nEventsTree; ++event) { // Get Event Content if( nEventsTotal >= nEventsChain ) continue; if(fast) tree->LoadTree(event); cms3.GetEntry(event); ++nEventsTotal; // Progress CMS3::progress( nEventsTotal, nEventsChain ); // Analysis Code float mStop = mass_stop(); float mLSP = mass_lsp(); float mCharg = mass_chargino(); //float xVal = mass_lsp(); int Nevts = histNEvts->GetBinContent(histNEvts->FindBin(mStop,mLSP)); double nevts = double(Nevts); //float weight = cms3.scale1fb()*2.11; double PUweight = puWeight ->GetBinContent(puWeight ->FindBin(pu_ntrue() ) ); double PUweightUp = puWeightUp ->GetBinContent(puWeightUp ->FindBin(pu_ntrue() ) ); double PUweightDown = puWeightDown->GetBinContent(puWeightDown->FindBin(pu_ntrue() ) ); PUweightUp = 1; PUweightDown = PUweight; PUweight = 1; //now PU syst is applying vs not applying double ISRnorm = counterhistSig->GetBinContent(counterhistSig->FindBin(mStop,mLSP,19)); double ISRnormup = counterhistSig->GetBinContent(counterhistSig->FindBin(mStop,mLSP,20)); double ISRnormdown = counterhistSig->GetBinContent(counterhistSig->FindBin(mStop,mLSP,21)); double ISRweight = weight_ISR(); double BSFnorm = counterhistSig->GetBinContent(counterhistSig->FindBin(mStop,mLSP,14)); double BSFnormHup = counterhistSig->GetBinContent(counterhistSig->FindBin(mStop,mLSP,15)); double BSFnormLup = counterhistSig->GetBinContent(counterhistSig->FindBin(mStop,mLSP,16)); double BSFnormHdown = counterhistSig->GetBinContent(counterhistSig->FindBin(mStop,mLSP,17)); double BSFnormLdown = counterhistSig->GetBinContent(counterhistSig->FindBin(mStop,mLSP,18)); double BSFweight = weight_btagsf(); double muRFnorm = counterhistSig->GetBinContent(counterhistSig->FindBin(mStop,mLSP,1)); double muRFnormup = counterhistSig->GetBinContent(counterhistSig->FindBin(mStop,mLSP,5)); double muRFnormdown = counterhistSig->GetBinContent(counterhistSig->FindBin(mStop,mLSP,9)); if(ISRnorm>0) ISRweight*=nevts/ISRnorm; if(ISRnorm<=0||ISRnormup<=0||ISRnormdown<=0){ ISRnormdown=1.; ISRnormup=1.; ISRnorm=1.;} if(ISRweight!=weight_ISR()) cout << "ISRw " << ISRweight << " wISR " << weight_ISR() << " nevts " << nevts << " ISRn " << ISRnorm << endl; if(BSFnorm>0) BSFweight *=nevts/BSFnorm; if(BSFnorm<=0||BSFnormHup<=0||BSFnormLup<=0||BSFnormHdown<=0||BSFnormLdown<=0){ BSFnorm=1; BSFnormHup=1; BSFnormLup=1; BSFnormHdown=1; BSFnormLdown=1; } if(muRFnorm<=0||muRFnormup<=0||muRFnormdown<=0){ muRFnormdown=1; muRFnormup=1; muRFnorm=1; } //lepSF is done below double xsection = hxsec->GetBinContent(hxsec->FindBin(mStop)); double xsectionerr = hxsec->GetBinError(hxsec->FindBin(mStop)); //double rawweight = xsec()*2260./nevts; //double weight = xsec()*2260./nevts*PUweight*ISRweight*BSFweight;//xsec given in pb double rawweight = xsection*2260./nevts; double weight = xsection*2260./nevts*PUweight*ISRweight*BSFweight;//xsec given in pb //did put ISRweight which should be ==1 if(ISRweight!=1) cout << "ISRw " << ISRweight << endl; if(event==0) cout << "weight " << weight << " nEvents " << nEventsTree << " filename " << currentFile->GetTitle() << endl; int NSLeps = 0; int NAddVetoLeps = 0; if(lep1_is_mu()){ if(lep1_pt()>20&&fabs(lep1_eta())<2.4) {++NSLeps;} } else if (lep1_is_el()){ if(lep1_pt()>20&&fabs(lep1_eta())<1.4442) {++NSLeps; } } if(lep2_is_mu()){ if(lep2_pt()>20&&fabs(lep2_eta())<2.4) {++NSLeps;} } else if (lep2_is_el()){ if(lep2_pt()>20&&fabs(lep2_eta())<1.4442) {++NSLeps; } } if(lep2_is_mu()){ if(lep2_pt()>10&&fabs(lep2_eta())<2.4) {++NAddVetoLeps;} } else if (lep2_is_el()){ if(lep2_pt()>10&&fabs(lep2_eta())<2.4) {++NAddVetoLeps; } } if(NSLeps<1) continue;//temp float lepSF_pt_cutoff = 100.0; float lepSF_pt_min = 10.0; double lepSF = 1.0; double lepSF_Up = 1.0; double lepSF_Dn = 1.0; float lepSF_FS_pt_cutoff = 200.0; double lepSF_FS = 1.0; double lepSF_FS_Up = 1.0; double lepSF_FS_Dn = 1.0; if(lep1_is_el()){ int binX = h_el_SF->GetXaxis()->FindBin( std::min(lepSF_pt_cutoff, (float)lep1_p4().Pt()) ); int binY = h_el_SF->GetYaxis()->FindBin( fabs(lep1_p4().Eta()) ); lepSF = h_el_SF->GetBinContent( binX, binY ); lepSF_Up = lepSF + h_el_SF->GetBinError( binX, binY ); lepSF_Dn = lepSF - h_el_SF->GetBinError( binX, binY ); int bin = h_el_FS->FindBin( std::min(lepSF_FS_pt_cutoff, (float)lep1_p4().Pt()), fabs(lep1_p4().Eta()) ); lepSF_FS = h_el_FS->GetBinContent(bin); lepSF_FS_Up = lepSF_FS + h_el_FS->GetBinError(bin); lepSF_FS_Dn = lepSF_FS + h_el_FS->GetBinError(bin); } if(lep1_is_mu()){ int binX = h_mu_SF->GetXaxis()->FindBin( std::min(lepSF_pt_cutoff, (float)lep1_p4().Pt()) ); int binY = h_mu_SF->GetYaxis()->FindBin( fabs(lep1_p4().Eta()) ); lepSF = h_mu_SF->GetBinContent( binX, binY ); lepSF_Up = lepSF + h_mu_SF->GetBinError( binX, binY ); lepSF_Dn = lepSF - h_mu_SF->GetBinError( binX, binY ); int bin = h_mu_FS->FindBin( std::min(lepSF_FS_pt_cutoff, (float)lep1_p4().Pt()), fabs(lep1_p4().Eta()) ); lepSF_FS = h_mu_FS->GetBinContent(bin); lepSF_FS_Up = lepSF_FS + h_mu_FS->GetBinError(bin); lepSF_FS_Dn = lepSF_FS + h_mu_FS->GetBinError(bin); } weight *= (lepSF*lepSF_FS); if(nvtxs()<0) continue; if(ngoodleps()<1) continue;//accomodate 2l-CR if(nvetoleps()<1) continue;//accomodate 2l-CR //if(!PassTrackVeto_v3()) continue;//accomodate 2l-CR //if(!PassTauVeto()) continue;//accomodate 2l-CR if(ngoodjets()<2) continue; if(ngoodbtags()<0) continue;//accomodate 1l-CR if(pfmet()<250) continue; if(mt_met_lep()<150) continue; if(mindphi_met_j1_j2()<0.8) continue; int SR = -1; int compressedSR = -1; if(ngoodleps()==1&&nvetoleps()==1&&PassTrackVeto_v3()&&PassTauVeto()&&ngoodbtags()>=1){//basis for SR 1l, >=1b if(ngoodjets()>=4){ if(MT2W()<=200){ if(pfmet()>325) SR = 2; else SR = 1; } else { //high MT2W if(pfmet()>450) SR = 5; else if(pfmet()>350) SR = 4; else SR = 3; } } else if(ngoodjets()==3 && MT2W()>200 && pfmet()>350) { SR = 6; } else if(MT2W()>200&&topnessMod()>(-3)) { //2 or 3 jets if(ngoodbtags()==1){ if(pfmet()>400) SR = 8; else SR = 7; } else {//ge2 jets if(pfmet()>400) SR = 10; else SR = 9; } } //compressed region (jets are sorted by pt if(ngoodjets()>=5&&ak4pfjets_passMEDbtag()[0]==false&&ak4pfjets_pt()[0]>200.){ if(MT2W()<=200) compressedSR = 11; else compressedSR = 12; } } //CR-1l int CR1l = -1; if(ngoodleps()==1&&nvetoleps()==1&&PassTrackVeto_v3()&&PassTauVeto()&&ngoodbtags()==0&&ngoodjets()>=3&&MT2W()>200){ if(ngoodjets()==3){ CR1l = 1; } else { CR1l = 2; } } //CR1l 1 --> SR 6 //CR1l 2 --> SR 3-5 float CR1l_1_6 = 0.37*0.18; float CR1l_2_3 = 0.55*0.15; float CR1l_2_4 = 0.25*0.29; float CR1l_2_5 = 0.20*0.40; //CR2l = -1; int lepind = -1; if(ngoodleps()>=2&&NSLeps==2) lepind = 5; else if(ngoodleps()==2&&NSLeps==2) lepind = 4;//exactly two leptons,CR4 else if(ngoodleps()==1&&NSLeps==1&&NAddVetoLeps>=1) lepind = 3;//one lepton, but more than 1 add. loose,1l,>2l //else if(ngoodleps()==1&&NSLeps==1&&nvetoleps()==2) lepind = 2;//one lepton + 1 add. loose,CR5 else if(ngoodleps()==1&&NSLeps==1&&nvetoleps()==0&&(!PassTrackVeto_v3()||!PassTauVeto())) lepind = 1;//exactly one lepton, but do not pass track/tau veto - i.e. one additional track or tau, CR6 int CR2l = -1; if((lepind==4||lepind==3||lepind==1)&&ngoodjets()>=3&&ngoodbtags()>=1){ if(MT2W()<=200) CR2l = 1; else CR2l = 2; } float CR2l_1_1 = 0.61*0.48; float CR2l_1_2 = 0.61*0.19; float CR2l_2_3 = 0.44*0.39; float CR2l_2_4 = 0.44*0.11; float CR2l_2_5 = 0.44*0.07; float CR2l_2_6 = 0.44*0.11; if(SR==(-1)&&CR1l==(-1)&&CR2l==(-1)&&compressedSR==(-1)) continue; //implement some sanity checks if(CR1l!=(-1)&&CR2l!=(-1)) cout << "WTF CR1l " << CR1l << " CR2l " << CR2l << endl; if(SR!=(-1)&&CR1l!=(-1)) cout << "WTF SR " << SR << " CR1l " << CR1l << endl; if(SR!=(-1)&&CR2l!=(-1)) cout << "WTF SR " << SR << " CR2l " << CR2l << endl; //ISR reweighting, get stop pair using last copy: double ISRup = weight_ISRup()/weight_ISR()*ISRnorm/ISRnormup; double ISRdown = weight_ISRdown()/weight_ISR()*ISRnorm/ISRnormdown; //double XSup = (xsec()+xsec_uncert())/xsec(); //double XSdown = (xsec()-xsec_uncert())/xsec(); double XSup = (xsection+xsectionerr)/xsection; double XSdown = (xsection-xsectionerr)/xsection; double PUup = PUweightUp/PUweight; double PUdown = PUweightDown/PUweight; double lEffup = lepSF_Up/lepSF; double lEffdown = lepSF_Dn/lepSF; double lEffFSup = lepSF_FS_Up/lepSF_FS; double lEffFSdown = lepSF_FS_Dn/lepSF_FS; double BSFHup = weight_btagsf_heavy_UP()/weight_btagsf()*BSFnorm/BSFnormHup; double BSFLup = weight_btagsf_light_UP()/weight_btagsf()*BSFnorm/BSFnormHup; double BSFHdown = weight_btagsf_heavy_DN()/weight_btagsf()*BSFnorm/BSFnormHup; double BSFLdown = weight_btagsf_light_DN()/weight_btagsf()*BSFnorm/BSFnormHup; double muRFup = genweights().at(4)/genweights().at(0)*muRFnorm/muRFnormup; double muRFdown = genweights().at(8)/genweights().at(0)*muRFnorm/muRFnormdown; //cout << genweights().at(0) << " " << genweights().at(4) << " " << genweights().at(8) << " " << mStop << " " << mLSP << endl; if(CR1l>0){ if(ngoodleps()!=1) cout << __LINE__ << " " << ngoodleps() << endl; if(NSLeps!=1) cout << __LINE__ << " " << NSLeps << endl; if(nvetoleps()!=1) cout << __LINE__ << " " << nvetoleps() << endl; if(ngoodbtags()>=1) cout << __LINE__ << " " << ngoodbtags() << endl; //signal contamination in 0b control region, do correlations later during datacard making if(CR1l==1){ histos["CR1l_sigcontamination"]->Fill(mStop,mLSP,6,weight*CR1l_1_6); } else if(CR1l==2){ histos["CR1l_sigcontamination"]->Fill(mStop,mLSP,3,weight*CR1l_2_3); histos["CR1l_sigcontamination"]->Fill(mStop,mLSP,4,weight*CR1l_2_4); histos["CR1l_sigcontamination"]->Fill(mStop,mLSP,5,weight*CR1l_2_5); } } else if(CR2l>0){ if(nvetoleps()<=1||(nvetoleps()==1&&(!PassTrackVeto_v3()||!PassTauVeto()))) cout << __LINE__ << " " << nvetoleps() << " " << PassTrackVeto_v3() << " " << PassTauVeto() << endl; if(ngoodbtags()<1) cout << __LINE__ << " " << ngoodbtags() << endl; //signal contamination in 2l control region, do correlations later during datacard making if(CR2l==1){ histos["CR2l_sigcontamination"]->Fill(mStop,mLSP,1,weight*CR2l_1_1); histos["CR2l_sigcontamination"]->Fill(mStop,mLSP,2,weight*CR2l_1_2); } else if(CR2l==2){ histos["CR2l_sigcontamination"]->Fill(mStop,mLSP,3,weight*CR2l_2_3); histos["CR2l_sigcontamination"]->Fill(mStop,mLSP,4,weight*CR2l_2_4); histos["CR2l_sigcontamination"]->Fill(mStop,mLSP,5,weight*CR2l_2_5); histos["CR2l_sigcontamination"]->Fill(mStop,mLSP,6,weight*CR2l_2_6); } } else if(SR>0){ if(ngoodleps()!=1) cout << __LINE__ << " " << ngoodleps() << endl; if(NSLeps!=1) cout << __LINE__ << " " << NSLeps << endl; if(nvetoleps()!=1) cout << __LINE__ << " " << nvetoleps() << endl; if(!PassTrackVeto_v3()) cout << __LINE__ << endl; if(!PassTauVeto()) cout << __LINE__ << endl; if(SR<=6&&ngoodjets()<3) cout << __LINE__ << " " << ngoodjets() << endl; if(ngoodbtags()<1) cout << __LINE__ << " " << ngoodbtags() << endl; /* histos["eventsum"]->Fill(mStop,mLSP,SR,1.); histos["rawweightsum"]->Fill(mStop,mLSP,SR,rawweight); histos["totweightsum"]->Fill(mStop,mLSP,SR,weight); histos["ISRsum"]->Fill(mStop,mLSP,SR,ISRweight); histos["BSFsum"]->Fill(mStop,mLSP,SR,BSFweight); histos["PUweightsum"]->Fill(mStop,mLSP,SR,PUweight); histos["xsecsum"]->Fill(mStop,mLSP,SR,xsection); histos["nevtsum"]->Fill(mStop,mLSP,SR,nevts); histos["lepsum"]->Fill(mStop,mLSP,SR,lepSF); histos["lepSFsum"]->Fill(mStop,mLSP,SR,lepSF_FS); */ //finally - do signal regions! histos["SRyield"]->Fill(mStop,mLSP,SR,weight); histos["SR_ISRup"]->Fill(mStop,mLSP,SR,weight*ISRup); histos["SR_ISRdown"]->Fill(mStop,mLSP,SR,weight*ISRdown); histos["SR_Xsecup"]->Fill(mStop,mLSP,SR,weight*XSup); histos["SR_Xsecdown"]->Fill(mStop,mLSP,SR,weight*XSdown); histos["SR_PUup"]->Fill(mStop,mLSP,SR,weight*PUup); histos["SR_PUdown"]->Fill(mStop,mLSP,SR,weight*PUdown); histos["SR_Bup_HF"]->Fill(mStop,mLSP,SR,weight*BSFHup); histos["SR_Bup_LF"]->Fill(mStop,mLSP,SR,weight*BSFLup); histos["SR_Bdown_HF"]->Fill(mStop,mLSP,SR,weight*BSFHdown); histos["SR_Bdown_LF"]->Fill(mStop,mLSP,SR,weight*BSFLdown); histos["SR_LepEffup"]->Fill(mStop,mLSP,SR,weight*lEffup); histos["SR_LepEffdown"]->Fill(mStop,mLSP,SR,weight*lEffdown); histos["SR_LepEffFSup"]->Fill(mStop,mLSP,SR,weight*lEffFSup); histos["SR_LepEffFSdown"]->Fill(mStop,mLSP,SR,weight*lEffFSdown); histos["SR_muRFup"]->Fill(mStop,mLSP,SR,weight*muRFup); histos["SR_muRFdown"]->Fill(mStop,mLSP,SR,weight*muRFdown); } if(compressedSR>0){ if(compressedSR<=6) cout << __LINE__ << " " << compressedSR << endl; //compressedSR is defined to not overlap with SR - can use same histogram! histos["SRyield"]->Fill(mStop,mLSP,compressedSR,weight); histos["SR_ISRup"]->Fill(mStop,mLSP,compressedSR,weight*ISRup); histos["SR_ISRdown"]->Fill(mStop,mLSP,compressedSR,weight*ISRdown); histos["SR_Xsecup"]->Fill(mStop,mLSP,compressedSR,weight*XSup); histos["SR_Xsecdown"]->Fill(mStop,mLSP,compressedSR,weight*XSdown); histos["SR_PUup"]->Fill(mStop,mLSP,compressedSR,weight*PUup); histos["SR_PUdown"]->Fill(mStop,mLSP,compressedSR,weight*PUdown); histos["SR_Bup_HF"]->Fill(mStop,mLSP,compressedSR,weight*BSFHup); histos["SR_Bup_LF"]->Fill(mStop,mLSP,compressedSR,weight*BSFLup); histos["SR_Bdown_HF"]->Fill(mStop,mLSP,compressedSR,weight*BSFHdown); histos["SR_Bdown_LF"]->Fill(mStop,mLSP,compressedSR,weight*BSFLdown); histos["SR_LepEffup"]->Fill(mStop,mLSP,compressedSR,weight*lEffup); histos["SR_LepEffdown"]->Fill(mStop,mLSP,compressedSR,weight*lEffdown); histos["SR_LepEffFSup"]->Fill(mStop,mLSP,compressedSR,weight*lEffFSup); histos["SR_LepEffFSdown"]->Fill(mStop,mLSP,compressedSR,weight*lEffFSdown); histos["SR_muRFup"]->Fill(mStop,mLSP,compressedSR,weight*muRFup); histos["SR_muRFdown"]->Fill(mStop,mLSP,compressedSR,weight*muRFdown); } }//event loop // Clean Up delete tree; file->Close(); delete file; }//file loop if ( nEventsChain != nEventsTotal ) { cout << Form( "ERROR: number of events from files (%d) is not equal to total number of events (%d)", nEventsChain, nEventsTotal ) << endl; } // Example Histograms // samplehisto->Draw(); /* for(map<string,TH3D*>::iterator h=histos.begin(); h!=histos.end();++h){ //add overflow //h->second->SetBinContent(h->second->GetNbinsX(), h->second->GetBinContent(h->second->GetNbinsX() )+ h->second->GetBinContent(h->second->GetNbinsX()+1) ); //h->second->SetBinError(h->second->GetNbinsX(), sqrt(pow(h->second->GetBinError(h->second->GetNbinsX() ),2)+pow(h->second->GetBinError(h->second->GetNbinsX()+1),2) ) ); //add underfloe //h->second->SetBinContent(1, h->second->GetBinContent(1)+ h->second->GetBinContent(0) ); //h->second->SetBinError(1, sqrt(pow(h->second->GetBinError(1),2)+pow(h->second->GetBinError(0),2) ) ); } */ string filename = "rootfiles/signalyields/Histos_"+skimFilePrefix+".root"; TFile *f = new TFile(filename.c_str(),"RECREATE"); f->cd(); for(map<string,TH3D*>::iterator h= histos.begin(); h!= histos.end();++h) h->second->Write(); f->Close(); cout << "Saved histos in " << f->GetName() << endl; f_el_SF->Close(); f_mu_SF_id->Close(); f_mu_SF_iso->Close(); f_mu_SF_veto_id->Close(); f_mu_SF_veto_iso->Close(); f_vetoLep_eff->Close(); f_el_FS_ID->Close(); f_el_FS_Iso->Close(); f_mu_FS_ID->Close(); f_mu_FS_Iso->Close(); // return bmark->Stop("benchmark"); cout << endl; cout << nEventsTotal << " Events Processed" << endl; cout << "------------------------------" << endl; cout << "CPU Time: " << Form( "%.01f", bmark->GetCpuTime("benchmark") ) << endl; cout << "Real Time: " << Form( "%.01f", bmark->GetRealTime("benchmark") ) << endl; cout << endl; delete bmark; delete fPU;//delete PU file delete f_el_SF; delete f_mu_SF_id; delete f_mu_SF_iso; delete f_mu_SF_veto_id; delete f_mu_SF_veto_iso; delete f_vetoLep_eff; delete f_el_FS_ID; delete f_el_FS_Iso; delete f_mu_FS_ID; delete f_mu_FS_Iso; return 0; }
void Getvn2D(bool usingCNTEP=0){ TString str; TFile *fin; int nrun = GetTotalRun(); std::cout<<"Totally we have "<<nrun<<" runs/segments!"<<std::endl; FillGoodRun(); std::cout<<"Filling Good run finished!"<<std::endl; if(nrun<0) exit(1); ofstream fout, foutraw, fout1, fout2; int iharE=0; if(nhar==1||nhar==2) iharE=1; for(int icent=0;icent<ncent;icent++){ for(int ihar=0;ihar<nhar;ihar++){ if(icent!=0) continue; for(int isub=0;isub<nsub;isub++){ int n = ihar+1.0+iharE; str = choosesub(isub); TString UseCNTEP; if(str=="ABORT") continue; if(usingCNTEP) UseCNTEP = "UseCNTEP"; else UseCNTEP = "NoUseCNTEP"; std::cout<<UseCNTEP<<std::endl; std::cout<<"starting doing "<<str<<" v"<<n<<" analysis!"<<std::endl; cout<<Form("Result/%s/res%d_%d_%s.dat",UseCNTEP.Data(),n,icent,str.Data())<<endl; fout1.open(Form("Result/%s/res%d_%d_%s.dat",UseCNTEP.Data(),n,icent,str.Data())); //using str as event plane detector fout2.open(Form("Result/%s/psi%d_%d_%s.dat",UseCNTEP.Data(),n,icent,str.Data())); //using str as event plane detector float reso = GetReso(icent,ihar,isub,usingCNTEP); fout1<<reso<<std::endl; if(reso<0) {std::cout<<"resolution is wrong!"<<std::endl; reso = -9999;} for(int irun=0;irun<nrun;irun++){ fout2<<GetRun(irun)<<" "<<GoodRunFit[icent][ihar][isub][irun]<<std::endl; } TH2F* hvobsall = new TH2F(Form("hvobs_%d_%d_%d",icent,ihar,isub),Form("hvobs_%d_%d_%d",icent,ihar,isub),60,0,6,220,-1.1,1.1); // TH2F* hvobsallsq = new TH2F(Form("hvobssq_%d_%d_%d",icent,ihar,isub),Form("hvobssq_%d_%d_%d",icent,ihar,isub),60,0,6,220,-1.1,1.1); for(int iphi=0;iphi<nphi+1;iphi++){ TH2F* hvobs = new TH2F(Form("hvobs_%d_%d_%d_%d",icent,ihar,isub,iphi),Form("hvobs_%d_%d_%d_%d",icent,ihar,isub,iphi),60,0,6,220,-1.1,1.1); // TH2F* hvobssq = new TH2F(Form("hvobssq_%d_%d_%d_%d",icent,ihar,isub,iphi),Form("hvobssq_%d_%d_%d_%d",icent,ihar,isub,iphi),60,0,6,220,-1.1,1.1); string phistr = (iphi==0)?"_east":"_west"; if(iphi==nphi) phistr = ""; cout<<"open v2 file"<<endl; fout.open(Form("Result/%s/v%d_%d%s_%s.dat",UseCNTEP.Data(),n,icent,phistr.c_str(),str.Data())); //using str as event plane detector cout<<"open v2raw file"<<endl; foutraw.open(Form("Result/%s/v%draw_%d%s_%s.dat",UseCNTEP.Data(),n,icent,phistr.c_str(),str.Data())); //using str as event plane detector if(iphi<nphi){ for(int irun=0;irun<nrun;irun++){ //std::cout<<"cent = "<<icent<<"; n = "<<n<<" ;isub = "<<str<<" ;run = "<<irun<<" "<<phistr<<std::endl; //fin = TFile::Open(Form("/phenix/plhf/xuq/taxi/%s%s/%d/data/%s.root",dataset.Data(),pro.Data(),taxi,GetRun(irun).Data())); //fin = TFile::Open(Form("/gpfs/mnt/gpfs02/phenix/plhf/plhf1/xuq/phenix/flow/Run16dAu/work/39GeV/output/%s",GetRun(irun).Data())); fin = TFile::Open(Form("/gpfs/mnt/gpfs02/phenix/plhf/plhf1/xuq/phenix/flow/Run16dAu/work/39GeV/treeout/%s",GetRun(irun).Data())); if(!(GoodRunFit[icent][ihar][isub][irun]>0.2 && GoodRunFit[icent][ihar][isub][irun]<3.0)){ std::cout<<"cent = "<<icent<<"; n = "<<n<<" ;isub = "<<str<<" ;run = "<<GetRun(irun)<<" is bad run!"<<std::endl; fin->Close(); continue; } TH2F* hvobstemp = (TH2F*)fin->Get(Form("vobs%s_0_0_%d_%d_%d",str.Data(),icent,ihar,iphi)); //TH2F* hvobssqtemp = (TH2F*)fin->Get(Form("vobs%ssq_%d_%d_%d",str.Data(),icent,ihar,iphi)); hvobs->Add(hvobstemp); //hvobssq->Add(hvobssqtemp); fin->Close(); } } hvobsall->Add(hvobs); //hvobsallsq->Add(hvobssq); if(iphi==nphi){ hvobs = hvobsall; //hvobssq = hvobsallsq; } TH1F* ptProj = (TH1F*)hvobs->ProjectionX(Form("hptProj"),0,-1); for(int ipt=0;ipt<npt-1;ipt++){ int xbinmin = hvobs->GetXaxis()->FindBin(ptbin[ipt]+eps); int xbinmax = hvobs->GetXaxis()->FindBin(ptbin[ipt+1]-eps); // std::cout<<xbinmin<<" "<<xbinmax<<std::endl; // std::cout<<ptbin[ipt]<<" "<<ptbin[ipt+1]<<std::endl; TH1F* hvobsProj = (TH1F*)hvobs->ProjectionY(Form("hvobsProj_%d",ipt),xbinmin,xbinmax); // TH1F* hvobssqProj = (TH1F*)hvobssq->ProjectionY(Form("hvobssqProj_%d",ipt),xbinmin,xbinmax); float vobs = hvobsProj->GetMean(); float Ntracks = hvobsProj->Integral(); // float vobssq = hvobssqProj->GetMean(); float v = vobs/reso; if(Ntracks>0) float verr = hvobsProj->GetRMS()/reso/sqrt(Ntracks); else verr = -9999; // float verr = sqrt(vobssq/reso/reso-(v*v))/sqrt(Ntracks); ptProj->GetXaxis()->SetRangeUser(ptbin[ipt]+eps,ptbin[ipt+1]-eps); float pt = ptProj->GetMean(); fout<<pt<<" "<<v<<" "<<verr<<" "<<std::endl; foutraw<<pt<<" "<<vobs<<" "<<verr*reso<<" "<<std::endl; } fout.close(); foutraw.close(); } fout1.close(); fout2.close(); } } } }
int main(){ BaBarStyle p; p.SetBaBarStyle(); //gROOT->SetStyle("Plain"); Bool_t doNorm = kTRUE; Bool_t doComparison = kFALSE; Bool_t doFract = kFALSE; Bool_t doFit = kFALSE; Bool_t doPlots = kFALSE; //define DalitzSpace for generation EvtPDL pdl; pdl.readPDT("evt.pdl"); EvtDecayMode mode("D0 -> K- pi+ pi0"); EvtDalitzPlot dalitzSpace(mode); RooRealVar m2Kpi_d0mass("m2Kpi_d0mass","m2Kpi_d0mass",1.,dalitzSpace.qAbsMin(EvtCyclic3::AB),dalitzSpace.qAbsMax(EvtCyclic3::AB)); RooRealVar m2Kpi0_d0mass("m2Kpi0_d0mass","m2Kpi0_d0mass",1.,dalitzSpace.qAbsMin(EvtCyclic3::AC),dalitzSpace.qAbsMax(EvtCyclic3::AC)); RooRealVar m2pipi0_d0mass("m2pipi0_d0mass","m2pipi0_d0mass",1.,dalitzSpace.qAbsMin(EvtCyclic3::BC),dalitzSpace.qAbsMax(EvtCyclic3::BC)); RooCategory D0flav("D0flav","D0flav"); D0flav.defineType("D0",-1); D0flav.defineType("antiD0",1); //this is just to plot the m23 pdf Float_t total = pow(dalitzSpace.bigM(),2) + pow(dalitzSpace.mA(),2) + pow(dalitzSpace.mB(),2) + pow(dalitzSpace.mC(),2); RooRealVar totalm("totalm","totalm",total); RooFormulaVar mass13a("mass13a","@0-@1-@2",RooArgSet(totalm,m2Kpi_d0mass,m2pipi0_d0mass)); cout << "read the dataset" << endl; TFile hello("DataSet_out_tmp.root"); gROOT->cd(); RooDataSet *data = (RooDataSet*)hello.Get("fulldata"); RooDataSet *data_1 = (RooDataSet*)data->reduce("D0flav == 1 && isWS == 0 && d0LifetimeErr < 0.5 && d0Lifetime > -2. && d0Lifetime < 4."); RooDataSet *finaldata = (RooDataSet*)data_1->reduce("deltaMass > 0.1449 && deltaMass < 0.1459 && d0Mass > 1.8495 && d0Mass < 1.8795"); RooDataSet *leftdata = (RooDataSet*)(RooDataSet*)data_1->reduce("d0Mass > 1.74 && d0Mass < 1.79"); RooDataSet *rightdata = (RooDataSet*)data_1->reduce("d0Mass > 1.94 && d0Mass < 1.99"); //here we set the weights for the dataset finaldata->setWeightVar(0); leftdata->setWeightVar(0); rightdata->setWeightVar(0); //if you want to have a little dataset to test, uncomment next line and rename finaldata above //RooDataSet *finaldata = finaldata_1->reduce(EventRange(1,1000)); cout << "*************************************************************" << endl; cout << "The final data entry " << finaldata->numEntries() << endl; cout << "*************************************************************" << endl; //Construct signal pdf string dirname = "configmaps/effmapping_RS_CP/"; RooKpipi0pdf *D0pdf = new RooKpipi0pdf("D0pdf","D0pdf",m2Kpi_d0mass,m2Kpi0_d0mass,&dalitzSpace,dirname,1); RooKpipi0pdf *D0pdf23 = new RooKpipi0pdf("D0pdf23","D0pdf23",m2Kpi_d0mass,mass13a,&dalitzSpace,dirname,1); if(doNorm) D0pdf->getManager()->calNorm(); //When we plot the 1D projection, need to calculate the 1D integral //set the precision here //cout << "config integrator " << endl; RooNumIntConfig *cfg = RooAbsReal::defaultIntegratorConfig(); cfg->setEpsAbs(1E-3); cfg->setEpsRel(1E-3); cfg->method1D().setLabel("RooSegmentedIntegrator1D"); //cfg.getConfigSection("RooSegmentedIntegrator1D").setRealValue("numSeg",3); //cfg->method1D()->Print("v"); D0pdf->setIntegratorConfig(*cfg); D0pdf23->setIntegratorConfig(*cfg); cout << "about to init" << endl; m2Kpi_d0mass.setBins(150); m2Kpi0_d0mass.setBins(150); m2pipi0_d0mass.setBins(150); //background description //RooBkg combdalitz("combdalitz","combdalitz",m2Kpi_d0mass,m2Kpi0_d0mass,&dalitzSpace); //RooBkg combdalitz23("combdalitz23","combdalitz23",m2Kpi_d0mass,mass13a,&dalitzSpace); RooRealVar Nsig("Nsig","Nsig", 653962. + 2218.); RooRealVar Nbkg("Nbkg","Nbkg", 2255. + 551.); RooDataHist* dbdalitz = new RooDataHist("dbdalitz","dbdalitz",RooArgSet(m2Kpi_d0mass,m2Kpi0_d0mass),*finaldata); RooDataHist* dbdalitz23 = new RooDataHist("dbdalitz23","dbdalitz23",RooArgSet(m2Kpi_d0mass,m2pipi0_d0mass),*finaldata); //////////////////////////////////////// //background parametrization using sidebands histograms //////////////////////////////////////// TH2F *lefth = m2Kpi_d0mass.createHistogram("lefth",m2Kpi0_d0mass); leftdata->fillHistogram(lefth,RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass)); TH2F *righth = m2Kpi_d0mass.createHistogram("righth",m2Kpi0_d0mass); rightdata->fillHistogram(righth,RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass)); TH2F *lefth23 = m2Kpi_d0mass.createHistogram("lefth23",m2pipi0_d0mass); leftdata->fillHistogram(lefth23,RooArgList(m2Kpi_d0mass,m2pipi0_d0mass)); TH2F *righth23 = m2Kpi_d0mass.createHistogram("righth23",m2pipi0_d0mass); rightdata->fillHistogram(righth23,RooArgList(m2Kpi_d0mass,m2pipi0_d0mass)); righth->Scale(lefth->Integral()/righth->Integral()); lefth->Sumw2(); righth->Sumw2(); righth23->Scale(lefth23->Integral()/righth23->Integral()); lefth23->Sumw2(); righth23->Sumw2(); RooDataHist *lefthist = new RooDataHist("lefthist","lefthist",RooArgSet(m2Kpi_d0mass,m2Kpi0_d0mass),lefth); RooDataHist *righthist = new RooDataHist("righthist","righthist",RooArgSet(m2Kpi_d0mass,m2Kpi0_d0mass),righth); RooDataHist *lefthist23 = new RooDataHist("lefthist23","lefthist23",RooArgSet(m2Kpi_d0mass,m2pipi0_d0mass),lefth23); RooDataHist *righthist23 = new RooDataHist("righthist23","righthist23",RooArgSet(m2Kpi_d0mass,m2pipi0_d0mass),righth23); RooHistPdf leftpdf("leftpdf","leftpdf",RooArgSet(m2Kpi_d0mass,m2Kpi0_d0mass),*lefthist,4); RooHistPdf rightpdf("rightpdf","rightpdf",RooArgSet(m2Kpi_d0mass,m2Kpi0_d0mass),*righthist,4); RooHistPdf leftpdf23("leftpdf23","leftpdf23",RooArgSet(m2Kpi_d0mass,m2pipi0_d0mass),*lefthist23,4); RooHistPdf rightpdf23("rightpdf23","rightpdf23",RooArgSet(m2Kpi_d0mass,m2pipi0_d0mass),*righthist23,4); RooRealVar fcomb("fcomb","fcomb",0.738); RooAddPdf combdalitz("combdalitz","combdalitz",RooArgList(leftpdf,rightpdf),RooArgList(fcomb)); RooAddPdf combdalitz23("combdalitz23","combdalitz23",RooArgList(leftpdf23,rightpdf23),RooArgList(fcomb)); /////////////////////////////////////// RooAddPdf totpdf("totpdf","totpdf",RooArgList(*D0pdf,combdalitz),RooArgList(Nsig,Nbkg)); RooAddPdf totpdf23("totpdf23","totpdf23",RooArgList(*D0pdf23,combdalitz23),RooArgList(Nsig,Nbkg)); if(doFit){ // Start Minuit session on Chi2 RooChi2Var chi2("chi2","chi2",totpdf,*dbdalitz); RooMinuit m2(chi2); m2.migrad(); m2.hesse(); RooFitResult* fitRes = m2.save(); fitRes->Print("v"); RooArgSet results(fitRes->floatParsFinal()); RooArgSet conresults(fitRes->constPars()); results.add(conresults); results.writeToFile("fit_isobar_RS.txt"); //save the stupid result TFile f("fit_RSDalitz_result.root","RECREATE"); fitRes->Write(); f.Close(); } if(doFract) { cout << "Calculating fit fractions" << endl; TFile f("fit_RSDalitz_result.root"); RooFitResult* fitRes = (RooFitResult*)f.Get("chi2"); //now calculate the fit fractions const Int_t nRes = D0pdf->getManager()->getnRes(); //recalculate the normalization if necessary D0pdf->getManager()->calNorm(); EvtComplex normarray[nRes][nRes]; const Int_t myRes = 12; TH1F fitty[myRes]; //read the integral value from the cache file. //In this way we don't need to compute the normalization everytime during MIGRAD char int_name[50]; D0pdf->getManager()->getFileName(int_name); ifstream f1; f1.open(int_name); if (!f1){ cout << "Error opening file " << endl; assert(0); } Double_t re=0.,im=0.; //Read in the cache file and store back to array for(Int_t j=0;j<nRes;j++) { char thname[100]; sprintf(thname,"thname_%d",j); if(j < myRes) fitty[j] = TH1F(thname,thname,30,0.,1.); for(Int_t k=0;k<nRes;k++){ f1 >> re >> im; normarray[j][k] = EvtComplex(re,im); } } EvtComplex mynorm[myRes][myRes]; Int_t m = 0, l = 0; for(Int_t i=0;i<myRes;i++){ for(Int_t j=0;j<myRes;j++){ if(i==0) l = 7; else if(i==1) l = 6; else if(i==2) l = 11; else if(i==3) l = 4; else if(i==4) l = 5; else if(i==5) l = 3; else if(i==6) l = 9; else if(i==7) l = 10; else if(i==8) l = 12; else if(i==9) l = 8; else if(i==10) l = 2; else if(i==11) l = 0; if(j==0) m = 7; else if(j==1) m = 6; else if(j==2) m = 11; else if(j==3) m = 4; else if(j==4) m = 5; else if(j==5) m = 3; else if(j==6) m = 9; else if(j==7) m = 10; else if(j==8) m = 12; else if(j==9) m = 8; else if(j==10) m = 2; else if(j==11) m = 0; mynorm[i][j] = normarray[l][m]; } } //do 100 experiments and extract parameters using covariance matrix for(Int_t l=0;l<300;l++){ RooArgList listpar = fitRes->randomizePars(); if(l==0) listpar.Print(); Double_t mynormD0 = 0.; EvtComplex coeff_i(0.,0.), coeff_j(0.,0.); for(Int_t i=0;i<2*myRes;i++){ for(Int_t j=0;j<2*myRes;j++){ if(i==(2*myRes - 2)) coeff_i = EvtComplex(1.,0.); else coeff_i = EvtComplex(((RooAbsReal*)listpar.at(i))->getVal()*cos(((RooAbsReal*)listpar.at(i+1))->getVal()), ((RooAbsReal*)listpar.at(i))->getVal()*sin(((RooAbsReal*)listpar.at(i+1))->getVal())); if(j==(2*myRes - 2)) coeff_j = EvtComplex(1.,0.); else coeff_j = EvtComplex(((RooAbsReal*)listpar.at(j))->getVal()*cos(((RooAbsReal*)listpar.at(j+1))->getVal()), ((RooAbsReal*)listpar.at(j))->getVal()*sin(((RooAbsReal*)listpar.at(j+1))->getVal())); mynormD0 += real(coeff_i*conj(coeff_j)*(mynorm[i/2][j/2])); j++; } i++; } //now calculate the fit fractions for(Int_t i=0;i<2*myRes;i++){ Double_t fitfrac = 0.; if(i==(2*myRes - 2)) fitfrac = abs(mynorm[i/2][i/2])/mynormD0; else fitfrac = abs2( ((RooAbsReal*)listpar.at(i))->getVal())*abs(mynorm[i/2][i/2])/mynormD0; fitty[i/2].Fill(fitfrac); i++; } }// nexperiments Double_t tot_frac = 0.; for(Int_t i=0;i<myRes;i++){ tot_frac += fitty[i].GetMean(); cout << "Resonance " << i << ": fit fraction = " << fitty[i].GetMean() << " +/- " << fitty[i].GetRMS() << endl; } cout << "Total fit fraction = " << tot_frac << endl; cout << "///////////////////////////" << endl; } if(doPlots){ //Make the plots // REMEBER: if you want roofit to consider the reweighted errors, you must put DataError(RooAbsData::SumW2)) //****************************************************** RooPlot* xframe = m2Kpi_d0mass.frame(); dbdalitz->plotOn(xframe,MarkerSize(0.1),DrawOption("z")); totpdf.plotOn(xframe); xframe->getAttLine()->SetLineWidth(1); xframe->getAttLine()->SetLineStyle(1); xframe->SetTitle(""); xframe->GetXaxis()->SetTitle("s_{12} [GeV^{2}/c^{4}]"); xframe->GetYaxis()->SetTitle("Events/4 MeV^{2}/c^{4}"); Double_t chi2Kpi = xframe->chiSquare(); RooPlot* yframe = m2Kpi0_d0mass.frame(); dbdalitz->plotOn(yframe,MarkerSize(0.1),DrawOption("z")); totpdf.plotOn(yframe); yframe->getAttLine()->SetLineWidth(1); yframe->getAttLine()->SetLineStyle(1); yframe->SetTitle(""); yframe->GetXaxis()->SetTitle("s_{13} [GeV^{2}/c^{4}]"); yframe->GetYaxis()->SetTitle("Events/5 MeV^{2}/c^{4}"); Double_t chi2Kpi0 = yframe->chiSquare(); /* RooPlot* zframe = m2pipi0_d0mass.frame(0.,2.3); dbdalitz23->plotOn(zframe,MarkerSize(0.1),DrawOption("z")); totpdf23.plotOn(zframe); zframe->getAttLine()->SetLineWidth(1); zframe->getAttLine()->SetLineStyle(1); zframe->SetTitle(""); zframe->GetXaxis()->SetTitle("m^{2}_{#pi^{+}#pi^{0}}"); Double_t chi2pipi0 = zframe->chiSquare(); cout << "Chi2 for Kpi = " << chi2Kpi << endl; cout << "Chi2 for Kpi0 = " << chi2Kpi0 << endl; cout << "Chi2 for pipi0 = " << chi2pipi0 << endl; RooPlot* pullFramem12 = m2Kpi_d0mass.frame() ; pullFramem12->SetTitle(""); pullFramem12->GetXaxis()->SetTitle(""); pullFramem12->addPlotable(xframe->pullHist()) ; pullFramem12->SetMaximum(5.); pullFramem12->SetMinimum(-5.); RooPlot* pullFramem13 = m2Kpi0_d0mass.frame() ; pullFramem13->SetTitle(""); pullFramem13->GetXaxis()->SetTitle(""); pullFramem13->addPlotable(yframe->pullHist()) ; pullFramem13->SetMaximum(5.); pullFramem13->SetMinimum(-5.); RooPlot* pullFramem23 = m2pipi0_d0mass.frame() ; pullFramem23->SetTitle(""); pullFramem23->GetXaxis()->SetTitle(""); pullFramem23->addPlotable(zframe->pullHist()) ; pullFramem23->SetMaximum(5.); pullFramem23->SetMinimum(-5.); TCanvas *c2 = new TCanvas("c2","residuals",1200,200); c2->Divide(3,1); c2->cd(1);pullFramem12->Draw(); c2->cd(2);pullFramem13->Draw(); c2->cd(3);pullFramem23->Draw(); c2->SaveAs("RSresiduals.eps"); */ totpdf.plotOn(xframe,Project(m2Kpi0_d0mass),Components(RooArgSet(combdalitz)),DrawOption("F"),FillColor(kRed)); totpdf.plotOn(yframe,Project(m2Kpi_d0mass),Components(RooArgSet(combdalitz)),DrawOption("F"),FillColor(kRed)); //totpdf23.plotOn(zframe,Project(m2Kpi_d0mass),Components(RooArgSet(combdalitz23)),DrawOption("F"),FillColor(kRed)); TPaveText *box_m12 = new TPaveText(2.5,2.5,2.7,2.7,""); box_m12->AddText("(b)"); box_m12->SetFillColor(10); TPaveText *box_m13 = new TPaveText(2.5,2.5,2.7,2.7,""); box_m13->AddText("(c)"); box_m13->SetFillColor(10); TCanvas c1("c1","c1",600,600); c1.cd(); xframe->Draw();box_m12->Draw("SAME"); c1.SaveAs("RSfit_m2Kpi.eps"); TCanvas c2("c2","c2",600,600); c2.cd(); yframe->Draw();box_m13->Draw("SAME"); c2.SaveAs("RSfit_m2Kpi0.eps"); /* TCanvas *c1 = new TCanvas("c1","allevents",1200,400); c1->Divide(3,1); c1->cd(1);xframe->Draw(); //p.SetBaBarLabel(-1,-1,-1,"preliminary"); c1->cd(2);yframe->Draw(); //p.SetBaBarLabel(-1,-1,-1,"preliminary"); c1->cd(3);zframe->Draw(); //p.SetBaBarLabel(-1,-1,-1,"preliminary"); c1->SaveAs("RSsigfit.eps"); */ } if(doComparison){ RooDataSet *littledata = (RooDataSet*)finaldata->reduce(EventRange(1,70000)); RooArgSet VarList1(m2Kpi_d0mass,m2Kpi0_d0mass); Int_t num_entries = littledata->numEntries(); RooDataSet* genpdf = D0pdf->generate(VarList1,num_entries); Int_t nbinx = 20; Int_t nbiny = 20; m2Kpi_d0mass.setBins(nbinx); m2Kpi0_d0mass.setBins(nbiny); TH2F* pdfhist = new TH2F("pdfhist","pdfhist",nbinx,0.39,3.,nbiny,0.39,3.); TH2F* datahist = new TH2F("datahist","datahist",nbinx,0.39,3.,nbiny,0.39,3.); pdfhist = genpdf->createHistogram(m2Kpi_d0mass,m2Kpi0_d0mass); datahist = finaldata->createHistogram(m2Kpi_d0mass,m2Kpi0_d0mass); pdfhist->GetXaxis()->SetTitle("m_{K#pi}^{2}"); pdfhist->GetYaxis()->SetTitle("m_{K#pi^{0}}^{2}"); pdfhist->Scale(datahist->Integral()/pdfhist->Integral()); pdfhist->Add(datahist,-1.); TCanvas c2; c2.cd();pdfhist->Draw("LEGO2Z"); c2.SaveAs("RSsigdiff.eps"); TFile ftmp("prova.root","RECREATE"); ftmp.cd();pdfhist->Write(); ftmp.Close(); } return 0; }//end of the macro
Float_t doCoinc(const char *fileIn="coincCERN_0102n.root",TCanvas *cout=NULL,Float_t &rate,Float_t &rateErr){ // Print settings printf("SETTINGS\nAnalyze output from new Analyzer\n"); printf("Input file = %s\n",fileIn); printf("School distance = %f m, angle = %f deg\n",distance,angle); printf("School orientation: tel1=%f deg, tel2=%f deg\n",phi1Corr,phi2Corr); printf("Max Chi2 = %f\n",maxchisquare); printf("Theta Rel Range = %f - %f deg\n",minthetarel,maxthetarel); printf("Range for N sattellite in each run = (tel1) %f - %f, (tel2) %f - %f \n",minAvSat[0],maxAvSat[0],minAvSat[1],maxAvSat[1]); printf("Min N satellite in a single event = %i\n",satEventThr); Int_t adayMin = (yearRange[0]-2014) * 1000 + monthRange[0]*50 + dayRange[0]; Int_t adayMax = (yearRange[1]-2014) * 1000 + monthRange[1]*50 + dayRange[1]; Float_t nsigPeak=0; Float_t nbackPeak=0; angle *= TMath::DegToRad(); // define some histos TH1F *hDeltaTheta = new TH1F("hDeltaTheta","#Delta#theta below the peak (500 ns);#Delta#theta (#circ)",100,-60,60); TH1F *hDeltaPhi = new TH1F("hDeltaPhi","#Delta#phi below the peak (500 ns);#Delta#phi (#circ)",200,-360,360); TH1F *hDeltaThetaBack = new TH1F("hDeltaThetaBack","#Delta#theta out of the peak (> 1000 ns) - normalized;#Delta#theta (#circ)",100,-60,60); TH1F *hDeltaPhiBack = new TH1F("hDeltaPhiBack","#Delta#phi out of the peak (> 1000 ns) - normalized;#Delta#phi (#circ)",200,-360,360); TH1F *hThetaRel = new TH1F("hThetaRel","#theta_{rel} below the peak (500 ns);#theta_{rel} (#circ)",100,0,120); TH1F *hThetaRelBack = new TH1F("hThetaRelBack","#theta_{rel} out of the peak (> 1000 ns) - normalized;#theta_{rel} (#circ)",100,0,120); TH2F *hAngle = new TH2F("hAngle",";#Delta#theta (#circ);#Delta#phi (#circ}",20,-60,60,20,-360,360); TH2F *hAngleBack = new TH2F("hAngleBack",";#Delta#theta (#circ);#Delta#phi (#circ}",20,-60,60,20,-360,360); TProfile *hModulation = new TProfile("hModulation","#theta^{rel} < 10#circ;#phi - #alpha;dist (m)",50,0,360); TProfile *hModulation2 = new TProfile("hModulation2","#theta^{rel} < 10#circ;#phi - #alpha;dist (m)",50,0,360); TProfile *hModulationAv = new TProfile("hModulationAv","#theta^{rel} < 10#circ;#phi - #alpha;dist (m)",50,0,360); TProfile *hModulationAvCorr = new TProfile("hModulationAvCorr","#theta^{rel} < 10#circ;#phi - #alpha;diff (ns)",50,0,360); TH1F *hnsigpeak = new TH1F("hnsigpeak","",50,0,360); TH1F *hnbackpeak = new TH1F("hnbackpeak","",50,0,360); TProfile *hSinTheta = new TProfile("hSinTheta",";#phi - #alpha;sin(#theta)",50,0,360); TProfile *hSinTheta2 = new TProfile("hSinTheta2",";#phi - #alpha;sin(#theta)",50,0,360); TH1F *hRunCut[2]; hRunCut[0] = new TH1F("hRunCut1","Reason for Run Rejection Tel-1;Reason;runs rejected",11,0,11); hRunCut[1] = new TH1F("hRunCut2","Reason for Run Rejection Tel-2;Reason;runs rejected",11,0,11); for(Int_t i=0;i<2;i++){ hRunCut[i]->Fill("DateRange",0); hRunCut[i]->Fill("LowFractionGT",0); hRunCut[i]->Fill("TimeDuration",0); hRunCut[i]->Fill("rateGT",0); hRunCut[i]->Fill("RunNumber",0); hRunCut[i]->Fill("MissingHitFrac",0); hRunCut[i]->Fill("DeadStripBot",0); hRunCut[i]->Fill("DeadStripMid",0); hRunCut[i]->Fill("DeadStripTop",0); hRunCut[i]->Fill("NSatellites",0); hRunCut[i]->Fill("NoGoodWeather",0); } TFile *f = new TFile(fileIn); TTree *t = (TTree *) f->Get("tree"); TTree *tel[2]; tel[0] = (TTree *) f->Get("treeTel1"); tel[1] = (TTree *) f->Get("treeTel2"); TTree *telC = (TTree *) f->Get("treeTimeCommon"); // quality info of runs const Int_t nyearmax = 5; Bool_t runstatus[2][nyearmax][12][31][500]; //#telescope, year-2014, month, day, run Float_t effTel[2][nyearmax][12][31][500]; Int_t nStripDeadBot[2][nyearmax][12][31][500]; Int_t nStripDeadMid[2][nyearmax][12][31][500]; Int_t nStripDeadTop[2][nyearmax][12][31][500]; Float_t nstripDeadB[2]={0,0},nstripDeadM[2]={0,0},nstripDeadT[2]={0,0}; // sat info Float_t NsatAv[2][nyearmax][12][31][500]; // weather info Float_t pressureTel[2][nyearmax][12][31][500]; Float_t TempInTel[2][nyearmax][12][31][500]; Float_t TempOutTel[2][nyearmax][12][31][500]; Float_t timeWeath[2][nyearmax][12][31][500]; Float_t rateGT; Float_t phirelative; Float_t phirelative2; Float_t phirelativeAv; printf("Check Run quality\n"); if(tel[0] && tel[1]){ for(Int_t i=0;i < 2;i++){ // loop on telescopes printf("Tel-%i\n",i+1); for(Int_t j=0;j < tel[i]->GetEntries();j++){ // loop on runs tel[i]->GetEvent(j); rateGT = tel[i]->GetLeaf("FractionGoodTrack")->GetValue()*tel[i]->GetLeaf("rateHitPerRun")->GetValue(); Int_t aday = (tel[i]->GetLeaf("year")->GetValue()-2014) * 1000 + tel[i]->GetLeaf("month")->GetValue()*50 + tel[i]->GetLeaf("day")->GetValue(); if(i==1) printf("%f %f\n",rateGT , rateMin[i]); if(aday < adayMin || aday > adayMax){ hRunCut[i]->Fill("DateRange",1); continue;} if(tel[i]->GetLeaf("FractionGoodTrack")->GetValue() < fracGT[i]){ hRunCut[i]->Fill("LowFractionGT",1); continue;} // cut on fraction of good track if(tel[i]->GetLeaf("timeduration")->GetValue()*tel[i]->GetLeaf("rateHitPerRun")->GetValue() < hitevents[i]){ hRunCut[i]->Fill("TimeDuration",1); continue;} // cut on the number of event if(rateGT < rateMin[i] || rateGT > rateMax[i]){ hRunCut[i]->Fill("rateGT",1); continue;} // cut on the rate if(tel[i]->GetLeaf("run")->GetValue() > 499){ hRunCut[i]->Fill("RunNumber",1); continue;} // run < 500 if(i==1) printf("GR\n"); Float_t missinghitfrac = (tel[i]->GetLeaf("ratePerRun")->GetValue()-tel[i]->GetLeaf("rateHitPerRun")->GetValue()-2)/(tel[i]->GetLeaf("ratePerRun")->GetValue()-2); if(missinghitfrac < minmissingHitFrac[i] || missinghitfrac > maxmissingHitFrac[i]){ hRunCut[i]->Fill("MissingHitFrac",1); continue;} // active strip maps if(tel[i]->GetLeaf("maskB")) nStripDeadBot[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = countBits(Int_t(tel[i]->GetLeaf("maskB")->GetValue())); if(tel[i]->GetLeaf("maskM")) nStripDeadMid[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = countBits(Int_t(tel[i]->GetLeaf("maskM")->GetValue())); if(tel[i]->GetLeaf("maskT")) nStripDeadTop[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = countBits(Int_t(tel[i]->GetLeaf("maskT")->GetValue())); if(nStripDeadBot[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] > ndeadBotMax[i] || nStripDeadBot[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] < ndeadBotMin[i]) { hRunCut[i]->Fill("DeadStripBot",1); continue;} if(nStripDeadMid[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] > ndeadMidMax[i] || nStripDeadMid[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] < ndeadMidMin[i]){ hRunCut[i]->Fill("DeadStripMid",1); continue;} if(nStripDeadTop[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] > ndeadTopMax[i] || nStripDeadTop[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] < ndeadTopMin[i]){ hRunCut[i]->Fill("DeadStripTop",1); continue;} // nsat averaged per run if(tel[i]->GetLeaf("nSat")) NsatAv[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = tel[i]->GetLeaf("nSat")->GetValue(); if(NsatAv[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] < minAvSat[i] || NsatAv[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] > maxAvSat[i]){ hRunCut[i]->Fill("NSatellites",1); continue;} // weather info if(tel[i]->GetLeaf("Pressure")) pressureTel[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = tel[i]->GetLeaf("Pressure")->GetValue(); if(tel[i]->GetLeaf("IndoorTemperature")) TempInTel[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = tel[i]->GetLeaf("IndoorTemperature")->GetValue(); if(tel[i]->GetLeaf("OutdoorTemperature")) TempOutTel[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = tel[i]->GetLeaf("OutdoorTemperature")->GetValue(); if(tel[i]->GetLeaf("TimeWeatherUpdate")) timeWeath[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = tel[i]->GetLeaf("TimeWeatherUpdate")->GetValue(); if(timeWeath[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] < minWeathTimeDelay[i] || timeWeath[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] > maxWeathTimeDelay[i]){ hRunCut[i]->Fill("NoGoodWeather",1); continue; } // Set good runs runstatus[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = kTRUE; effTel[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = 1;//rateGT/refRate[i]; } } } else{ telC = NULL; } printf("Start to process correlations\n"); Int_t n = t->GetEntries(); // counter for seconds Int_t nsec = 0; Int_t nsecGR = 0; // for good runs Int_t isec = -1; // used only in case the tree with time info is not available Float_t neventsGR = 0; Float_t neventsGRandSat = 0; if(telC){ for(Int_t i=0; i < telC->GetEntries();i++){ telC->GetEvent(i); nsec += telC->GetLeaf("timeduration")->GetValue(); if(telC->GetLeaf("run")->GetValue() > 499 || telC->GetLeaf("run2")->GetValue() > 499) continue; if(!runstatus[0][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())]) continue; if(!runstatus[1][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run2")->GetValue())]) continue; nsecGR += telC->GetLeaf("timeduration")->GetValue(); nstripDeadB[0] += countBits(nStripDeadBot[0][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); nstripDeadM[0] += countBits(nStripDeadMid[0][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); nstripDeadT[0] += countBits(nStripDeadTop[0][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); nstripDeadB[1] += countBits(nStripDeadBot[1][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); nstripDeadM[1] += countBits(nStripDeadMid[1][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); nstripDeadT[1] += countBits(nStripDeadTop[1][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); } nstripDeadB[0] /= nsecGR; nstripDeadM[0] /= nsecGR; nstripDeadT[0] /= nsecGR; nstripDeadB[1] /= nsecGR; nstripDeadM[1] /= nsecGR; nstripDeadT[1] /= nsecGR; printf("Dead channel tel1 = %f - %f - %f\n",nstripDeadB[0],nstripDeadM[0],nstripDeadT[0]); printf("Dead channel tel2 = %f - %f - %f\n",nstripDeadB[1],nstripDeadM[1],nstripDeadT[1]); } char title[300]; TH1F *h; sprintf(title,"correction assuming #Delta#phi = %4.2f, #DeltaL = %.1f m;#Deltat (ns);entries",angle,distance); h = new TH1F("hCoinc",title,nbint,tmin,tmax); Float_t DeltaT; Float_t phiAv,thetaAv,corr; Float_t Theta1,Theta2; Float_t Phi1,Phi2; Int_t nsatel1cur,nsatel2cur,ntrack1,ntrack2; Float_t v1[3],v2[3],vSP; // variable to recompute ThetaRel on the fly Float_t eff = 1; for(Int_t i=0;i<n;i++){ t->GetEvent(i); if(t->GetLeaf("RunNumber1") && (t->GetLeaf("RunNumber1")->GetValue() > 499 || t->GetLeaf("RunNumber2")->GetValue() > 499)) continue; if(tel[0] && !runstatus[0][Int_t(t->GetLeaf("year")->GetValue())-2014][Int_t(t->GetLeaf("month")->GetValue())][Int_t(t->GetLeaf("day")->GetValue())][Int_t(t->GetLeaf("RunNumber1")->GetValue())]) continue; if(tel[1] && !runstatus[1][Int_t(t->GetLeaf("year")->GetValue())-2014][Int_t(t->GetLeaf("month")->GetValue())][Int_t(t->GetLeaf("day")->GetValue())][Int_t(t->GetLeaf("RunNumber2")->GetValue())]) continue; eff = effTel[0][Int_t(t->GetLeaf("year")->GetValue())-2014][Int_t(t->GetLeaf("month")->GetValue())][Int_t(t->GetLeaf("day")->GetValue())][Int_t(t->GetLeaf("RunNumber1")->GetValue())]; eff *= effTel[1][Int_t(t->GetLeaf("year")->GetValue())-2014][Int_t(t->GetLeaf("month")->GetValue())][Int_t(t->GetLeaf("day")->GetValue())][Int_t(t->GetLeaf("RunNumber2")->GetValue())]; Int_t timec = t->GetLeaf("ctime1")->GetValue(); if(! telC){ if(isec == -1) isec = timec; if(timec != isec){ if(timec - isec < 20){ // printf("diff = %i\n",timec-isec); nsec +=(timec - isec); nsecGR +=(timec - isec); } isec = timec; } } Float_t thetarel = t->GetLeaf("ThetaRel")->GetValue(); Theta1 = (t->GetLeaf("Theta1")->GetValue())*TMath::DegToRad(); Theta2 = t->GetLeaf("Theta2")->GetValue()*TMath::DegToRad(); Phi1 = t->GetLeaf("Phi1")->GetValue()*TMath::DegToRad(); Phi2 = t->GetLeaf("Phi2")->GetValue()*TMath::DegToRad(); nsatel1cur = t->GetLeaf("Nsatellite1")->GetValue(); nsatel2cur = t->GetLeaf("Nsatellite2")->GetValue(); ntrack1 = t->GetLeaf("Ntracks1")->GetValue(); ntrack2 = t->GetLeaf("Ntracks2")->GetValue(); if(recomputeThetaRel){ // recompute ThetaRel applying corrections Phi1 += phi1Corr*TMath::DegToRad(); Phi2 += phi2Corr*TMath::DegToRad(); if(Phi1 > 2*TMath::Pi()) Phi1 -= 2*TMath::Pi(); if(Phi1 < 0) Phi1 += 2*TMath::Pi(); if(Phi2 > 2*TMath::Pi()) Phi2 -= 2*TMath::Pi(); if(Phi2 < 0) Phi2 += 2*TMath::Pi(); v1[0] = TMath::Sin(Theta1)*TMath::Cos(Phi1); v1[1] = TMath::Sin(Theta1)*TMath::Sin(Phi1); v1[2] = TMath::Cos(Theta1); v2[0] = TMath::Sin(Theta2)*TMath::Cos(Phi2); v2[1] = TMath::Sin(Theta2)*TMath::Sin(Phi2); v2[2] = TMath::Cos(Theta2); v1[0] *= v2[0]; v1[1] *= v2[1]; v1[2] *= v2[2]; vSP = v1[0] + v1[1] + v1[2]; thetarel = TMath::ACos(vSP)*TMath::RadToDeg(); } // cuts if(thetarel < minthetarel) continue; if(thetarel > maxthetarel) continue; if(t->GetLeaf("ChiSquare1")->GetValue() > maxchisquare) continue; if(t->GetLeaf("ChiSquare2")->GetValue() > maxchisquare) continue; neventsGR++; // reject events with not enough satellites if(nsatel1cur < satEventThr || nsatel1cur < satEventThr) continue; neventsGRandSat++; DeltaT = t->GetLeaf("DiffTime")->GetValue(); // get primary direction if(TMath::Abs(Phi1-Phi2) < TMath::Pi()) phiAv = (Phi1+Phi2)*0.5; else phiAv = (Phi1+Phi2)*0.5 + TMath::Pi(); thetaAv = (Theta1+Theta2)*0.5; // extra cuts if needed // if(TMath::Cos(Phi1-Phi2) < 0.) continue; Float_t resFactor = 1; if(thetarel > 10 ) resFactor *= 0.5; if(thetarel > 20 ) resFactor *= 0.5; if(thetarel > 30 ) resFactor *= 0.5; corr = distance * TMath::Sin(thetaAv)*TMath::Cos(phiAv-angle)/2.99792458000000039e-01 + deltatCorr; phirelative = (Phi1-angle)*TMath::RadToDeg(); if(phirelative < 0) phirelative += 360; if(phirelative < 0) phirelative += 360; if(phirelative > 360) phirelative -= 360; if(phirelative > 360) phirelative -= 360; phirelative2 = (Phi2-angle)*TMath::RadToDeg(); if(phirelative2 < 0) phirelative2 += 360; if(phirelative2 < 0) phirelative2 += 360; if(phirelative2 > 360) phirelative2 -= 360; if(phirelative2 > 360) phirelative2 -= 360; phirelativeAv = (phiAv-angle)*TMath::RadToDeg(); if(phirelativeAv < 0) phirelativeAv += 360; if(phirelativeAv < 0) phirelativeAv += 360; if(phirelativeAv > 360) phirelativeAv -= 360; if(phirelativeAv > 360) phirelativeAv -= 360; // if(TMath::Abs(DeltaT- deltatCorr) < windowAlignment){ // } if(thetarel < 10){//cos(thetarel*TMath::DegToRad())>0.98 && sin(thetaAv)>0.1){ if(TMath::Abs(DeltaT- corr) < windowAlignment) hModulationAvCorr->Fill(phirelativeAv,DeltaT-corr); if(TMath::Abs(DeltaT- deltatCorr) < windowAlignment){ hModulation->Fill(phirelative,(DeltaT-deltatCorr)/sin(thetaAv)*2.99792458000000039e-01); hModulation2->Fill(phirelative2,(DeltaT-deltatCorr)/sin(thetaAv)*2.99792458000000039e-01); hModulationAv->Fill(phirelativeAv,(DeltaT-deltatCorr)/sin(thetaAv)*2.99792458000000039e-01); hSinTheta->Fill(phirelative,sin(thetaAv)); hSinTheta2->Fill(phirelative2,sin(thetaAv)); nsigPeak++; hnsigpeak->Fill(phirelativeAv); } else if(TMath::Abs(DeltaT- deltatCorr) < windowAlignment*10){ nbackPeak++; hnbackpeak->Fill(phirelativeAv); } } h->Fill(DeltaT-corr,1./eff); if(TMath::Abs(DeltaT-corr) < windowAlignment){ hDeltaTheta->Fill((Theta1-Theta2)*TMath::RadToDeg()); hDeltaPhi->Fill((Phi1-Phi2)*TMath::RadToDeg()); hThetaRel->Fill(thetarel); hAngle->Fill((Theta1-Theta2)*TMath::RadToDeg(),(Phi1-Phi2)*TMath::RadToDeg()); } else if(TMath::Abs(DeltaT-corr) > windowAlignment*2 && TMath::Abs(DeltaT-corr) < windowAlignment*12){ hDeltaThetaBack->Fill((Theta1-Theta2)*TMath::RadToDeg()); hDeltaPhiBack->Fill((Phi1-Phi2)*TMath::RadToDeg()); hThetaRelBack->Fill(thetarel); hAngleBack->Fill((Theta1-Theta2)*TMath::RadToDeg(),(Phi1-Phi2)*TMath::RadToDeg()); } } // compute (S+B)/S for(Int_t i=1;i<=50;i++){ Float_t corrfactorPeak = 1; if(nsigPeak-nbackPeak*0.1 > 0) corrfactorPeak = hnsigpeak->GetBinContent(i)/(hnsigpeak->GetBinContent(i)-hnbackpeak->GetBinContent(i)*0.1); else printf("bin %i) not enough statistics\n",i); hnsigpeak->SetBinContent(i,corrfactorPeak); } TF1 *fpol0 = new TF1("fpol0","pol0"); hnsigpeak->Fit(fpol0); hModulation->Scale(fpol0->GetParameter(0)); hModulation2->Scale(fpol0->GetParameter(0)); hModulationAv->Scale(fpol0->GetParameter(0)); hModulationAvCorr->Scale(fpol0->GetParameter(0)); TF1 *fmod = new TF1("fmod","[0] + [1]*cos((x-[2])*TMath::DegToRad())"); hModulationAv->Fit(fmod); printf("Estimates from time delay: Distance = %f +/- %f m -- Angle = %f +/- %f deg\n",fmod->GetParameter(1),fmod->GetParError(1),fmod->GetParameter(2),fmod->GetParError(2)); h->SetStats(0); hDeltaThetaBack->Sumw2(); hDeltaPhiBack->Sumw2(); hThetaRelBack->Sumw2(); hDeltaThetaBack->Scale(0.1); hDeltaPhiBack->Scale(0.1); hThetaRelBack->Scale(0.1); hAngleBack->Scale(0.1); hAngle->Add(hAngleBack,-1); printf("bin counting: SIGNAL = %f +/- %f\n",hDeltaPhi->Integral()-hDeltaPhiBack->Integral(),sqrt(hDeltaPhi->Integral())); rate = (hDeltaPhi->Integral()-hDeltaPhiBack->Integral())/nsecGR*86400; rateErr = sqrt(hDeltaPhi->Integral())/nsecGR*86400; Float_t val,eval; TCanvas *c1=new TCanvas(); TF1 *ff = new TF1("ff","[0]*[4]/[2]/sqrt(2*TMath::Pi())*TMath::Exp(-(x-[1])*(x-[1])*0.5/[2]/[2]) + [3]*[4]/6/[2]"); ff->SetParName(0,"signal"); ff->SetParName(1,"mean"); ff->SetParName(2,"sigma"); ff->SetParName(3,"background"); ff->SetParName(4,"bin width"); ff->SetParameter(0,42369); ff->SetParameter(1,0); ff->SetParLimits(2,10,maxwidth); ff->SetParameter(2,350); // fix witdh if needed ff->SetParameter(3,319); ff->FixParameter(4,(tmax-tmin)/nbint); // bin width ff->SetNpx(1000); if(cout) cout->cd(); h->Fit(ff,"EI","",-10000,10000); val = ff->GetParameter(2); eval = ff->GetParError(2); printf("significance = %f\n",ff->GetParameter(0)/sqrt(ff->GetParameter(0) + ff->GetParameter(3))); h->Draw(); new TCanvas; TF1 *func1 = (TF1 *) h->GetListOfFunctions()->At(0); func1->SetLineColor(2); h->SetLineColor(4); TPaveText *text = new TPaveText(1500,(h->GetMinimum()+(h->GetMaximum()-h->GetMinimum())*0.6),9500,h->GetMaximum()); text->SetFillColor(0); sprintf(title,"width = %5.1f #pm %5.1f",func1->GetParameter(2),func1->GetParError(2)); text->AddText(title); sprintf(title,"signal (S) = %5.1f #pm %5.1f",func1->GetParameter(0),func1->GetParError(0)); text->AddText(title); sprintf(title,"background (B) (3#sigma) = %5.1f #pm %5.1f",func1->GetParameter(3),func1->GetParError(3)); text->AddText(title); sprintf(title,"significance (S/#sqrt{S+B}) = %5.1f",func1->GetParameter(0)/sqrt(func1->GetParameter(0)+func1->GetParameter(3))); text->AddText(title); text->SetFillStyle(0); text->SetBorderSize(0); text->Draw("SAME"); // correct nsecGR for the event rejected because of the number of satellites (event by event cut) nsecGR *= neventsGRandSat/neventsGR; printf("n_day = %f\nn_dayGR = %f\n",nsec*1./86400,nsecGR*1./86400); text->AddText(Form("rate = %f #pm %f per day",func1->GetParameter(0)*86400/nsecGR,func1->GetParError(0)*86400/nsecGR)); TFile *fo = new TFile("outputCERN-01-02.root","RECREATE"); h->Write(); hDeltaTheta->Write(); hDeltaPhi->Write(); hThetaRel->Write(); hDeltaThetaBack->Write(); hDeltaPhiBack->Write(); hThetaRelBack->Write(); hAngle->Write(); hModulation->Write(); hModulation2->Write(); hModulationAv->Write(); hModulationAvCorr->Write(); hSinTheta->Write(); hSinTheta2->Write(); hnsigpeak->Write(); hRunCut[0]->Write(); hRunCut[1]->Write(); fo->Close(); return nsecGR*1./86400; }
void plotsAfterCuts_OneLeg(){ gStyle->SetOptStat(); gROOT->SetStyle("Plain"); using namespace std; // #include <exception>; // TFile *file = TFile::Open("rfio:/castor/cern.ch/user/d/degrutto/incl15WithBsPv/NtupleLoose_test_inclu15_1_2.root"); // TFile *file = TFile::Open("../NutpleLooseTestNew_oneshot_all_10_1.root"); //TFile *file = TFile::Open("rfio:/castor/cern.ch/user/d/degrutto/zmmWithBsPv/NtupleLoose_test.root"); // TTree * Events = dynamic_cast< TTree *> (file->Get("Events")); TChain Events("Events"); // one need 130 events... each file has 1000 ev Events.Add("../zmmNtuple/NtupleLooseTestNew.root"); /* Events.Add("../zmmNtuple/NtupleLooseTestNew_oneshot_all_Test_1_None.root"); Events.Add("../zmmNtuple/NtupleLooseTestNew_oneshot_all_Test_2_None.root"); Events.Add("../zmmNtuple/NtupleLooseTestNew_oneshot_all_Test_3_None.root"); Events.Add("../zmmNtuple/NtupleLooseTestNew_oneshot_all_Test_4_None.root"); Events.Add("../zmmNtuple/NtupleLooseTestNew_oneshot_all_Test_5_None.root"); Events.Add("../zmmNtuple/NtupleLooseTestNew_oneshot_all_Test_6_None.root"); Events.Add("../zmmNtuple/NtupleLooseTestNew_oneshot_all_Test_7_None.root"); Events.Add("../zmmNtuple/NtupleLooseTestNew_oneshot_all_Test_8_None.root"); Events.Add("../zmmNtuple/NtupleLooseTestNew_oneshot_all_Test_9_None.root"); Events.Add("../zmmNtuple/NtupleLooseTestNew_oneshot_all_Test_10_None.root"); Events.Add("../zmmNtuple/NtupleLooseTestNew_oneshot_all_Test_11_None.root"); Events.Add("../zmmNtuple/NtupleLooseTestNew_oneshot_all_Test_12_None.root"); Events.Add("../zmmNtuple/NtupleLooseTestNew_oneshot_all_Test_13_None.root"); */ TFile * output_file = TFile::Open("histoZmm_OneCut.root", "RECREATE"); // TFile * output_file = TFile::Open("histo_test.root", "RECREATE"); // zGolden plots TCut cut_zGolden("zGoldenMass>60 && zGoldenMass<120 && zGoldenDau1Pt> 20 && zGoldenDau2Pt>20 && zGoldenDau1TrkIso< 3.0 && zGoldenDau2TrkIso < 3.0 && abs(zGoldenDau1Eta)<2.1 && abs(zGoldenDau2Eta)<2.1 && (zGoldenDau1Chi2<10 || zGoldenDau2Chi2<10) && abs(zGoldenDau1dxyFromBS)<0.2 && abs(zGoldenDau2dxyFromBS)<0.2 && ((zGoldenDau1NofStripHits + zGoldenDau1NofPixelHits)>=10 || (zGoldenDau2NofStripHits + zGoldenDau2NofPixelHits)>=10) && (zGoldenDau1NofMuonHits>0 || zGoldenDau2NofMuonHits>0) && (zGoldenDau1HLTBit==1 || zGoldenDau2HLTBit==1) "); TDirectory * dir = output_file->mkdir("goodZToMuMuPlots"); dir->cd(); TH1F * zMass = new TH1F("zMass", "zMass", 200, 0, 200); // Events.Draw("zGoldenMass"); Events.Project("zMass", "zGoldenMass", cut_zGolden ); cout<<"Number of zGoldenAA : "<<zMass->GetEntries()<<endl; setGraphics(zMass); zMass->Write(); delete zMass; TCut cut_zGoldenPt15("zGoldenMass>20 && zGoldenDau1Pt> 15 && zGoldenDau2Pt>15 && zGoldenDau1TrkIso< 3.0 && zGoldenDau2TrkIso < 3.0 && abs(zGoldenDau1Eta)<2.1 && abs(zGoldenDau2Eta)<2.1 && (zGoldenDau1Chi2<10 || zGoldenDau2Chi2<10) && abs(zGoldenDau1dxyFromBS)<0.2 && abs(zGoldenDau2dxyFromBS)<0.2 && ((zGoldenDau1NofStripHits + zGoldenDau1NofPixelHits)>=10 || (zGoldenDau2NofStripHits + zGoldenDau2NofPixelHits)>=10) && (zGoldenDau1NofMuonHits>0 || zGoldenDau2NofMuonHits>0) && (zGoldenDau1HLTBit==1 || zGoldenDau2HLTBit==1)"); dir->cd(); TH1F * zMassPt15 = new TH1F("zMassPt15", "zMassPt15", 200, 0, 200); Events.Project("zMassPt15", "zGoldenMass", cut_zGoldenPt15 ); setGraphics(zMassPt15); cout<<"Number of zGoldenPt15 : "<<zMassPt15->GetEntries()<<endl; zMassPt15->Write(); delete zMassPt15; output_file->cd("/"); TCut cut2_zGolden1HLT("zGoldenMass>60 && zGoldenMass<120 && zGoldenDau1Pt> 20 && zGoldenDau2Pt>20 && zGoldenDau1TrkIso< 3.0 && zGoldenDau2TrkIso < 3.0 && abs(zGoldenDau1Eta)<2.1 && abs(zGoldenDau2Eta)<2.1 && (zGoldenDau1Chi2<10 || zGoldenDau2Chi2<10) && abs(zGoldenDau1dxyFromBS)<0.2 && abs(zGoldenDau2dxyFromBS)<0.2 && ( (zGoldenDau1NofStripHits + zGoldenDau1NofPixelHits)>=10 || ((zGoldenDau2NofStripHits + zGoldenDau2NofPixelHits)>=10)) && (zGoldenDau1NofMuonHits>0 || zGoldenDau2NofMuonHits>0) && ( zGoldenDau1HLTBit ==0 || zGoldenDau2HLTBit ==0)"); TDirectory * dir = output_file->mkdir("goodZToMuMu1HLTPlots"); dir->cd(); TH1F * zMass = new TH1F("zMass", "zMass", 200, 0, 200); Events.Project("zMass", "zGoldenMass", cut2_zGolden1HLT ); cout<<"Number of zGolden1HLT : "<<zMass->GetEntries()<<endl; zMass->Write(); delete zMass; //zMass2->Write(); output_file->cd("/"); output_file->cd("/"); TCut cut2_zGoldenAB1HLT("zGoldenMass>60 && zGoldenMass<120 && zGoldenDau1Pt> 20 && zGoldenDau2Pt>20 && zGoldenDau1TrkIso< 3.0 && zGoldenDau2TrkIso < 3.0 && ( abs(zGoldenDau1Eta)>2.1 || abs(zGoldenDau2Eta)>2.1 ) && (zGoldenDau1Chi2<10 || zGoldenDau2Chi2<10) && abs(zGoldenDau1dxyFromBS)<0.2 && abs(zGoldenDau2dxyFromBS)<0.2 && ((zGoldenDau1NofStripHits + zGoldenDau1NofPixelHits)>=10 || (zGoldenDau2NofStripHits + zGoldenDau2NofPixelHits)>=10) && (zGoldenDau1NofMuonHits>0 || zGoldenDau2NofMuonHits>0) && ( zGoldenDau1HLTBit ==1 || zGoldenDau2HLTBit ==1)"); TDirectory * dir = output_file->mkdir("goodZToMuMuAB1HLTPlots"); dir->cd(); TH1F * zMass = new TH1F("zMass", "zMass", 200, 0, 200); Events.Project("zMass", "zGoldenMass", cut2_zGoldenAB1HLT ); cout<<"Number of zGoldenAB1HLT : "<<zMass->GetEntries()<<endl; zMass->Write(); delete zMass; //zMass2->Write(); output_file->cd("/"); TCut cut2_zGolden2HLT("zGoldenMass>60 && zGoldenMass<120 && zGoldenDau1Pt> 20 && zGoldenDau2Pt>20 && zGoldenDau1TrkIso< 3.0 && zGoldenDau2TrkIso < 3.0 && abs(zGoldenDau1Eta)<2.1 && abs(zGoldenDau2Eta)<2.1 && (zGoldenDau1Chi2<10 || zGoldenDau2Chi2<10) && abs(zGoldenDau1dxyFromBS)<0.2 && abs(zGoldenDau2dxyFromBS)<0.2 && ((zGoldenDau1NofStripHits + zGoldenDau1NofPixelHits)>=10 || (zGoldenDau2NofStripHits + zGoldenDau2NofPixelHits)>=10) && (zGoldenDau1NofMuonHits>0 || zGoldenDau2NofMuonHits>0) && ( zGoldenDau1HLTBit ==1 && zGoldenDau2HLTBit ==1)"); TDirectory * dir = output_file->mkdir("goodZToMuMu2HLTPlots"); dir->cd(); TH1F * zMass = new TH1F("zMass", "zMass", 200, 0, 200); Events.Project("zMass", "zGoldenMass", cut2_zGolden2HLT ); zMass->Write(); cout<<"Number of zGolden2HLT : "<<zMass->GetEntries()<<endl; delete zMass; output_file->cd("/"); // zGoldenOneNotIso plots TCut cut_zGoldenOneNotIso("zGoldenMass>60 && zGoldenMass<120 && zGoldenDau1Pt> 20 && zGoldenDau2Pt>20 && ( (zGoldenDau1TrkIso> 3.0 && zGoldenDau2TrkIso < 3.0) || (zGoldenDau2TrkIso> 3.0 && zGoldenDau1TrkIso < 3.0)) && abs(zGoldenDau1Eta)<2.1 && abs(zGoldenDau2Eta)<2.1 && (zGoldenDau1Chi2<10 || zGoldenDau2Chi2<10) && abs(zGoldenDau1dxyFromBS)<0.2 && abs(zGoldenDau2dxyFromBS)<0.2 && ((zGoldenDau1NofStripHits + zGoldenDau1NofPixelHits)>=10 || (zGoldenDau2NofStripHits + zGoldenDau2NofPixelHits)>=10) && (zGoldenDau1NofMuonHits>0 || zGoldenDau2NofMuonHits>0) && ( zGoldenDau1HLTBit ==1 || zGoldenDau2HLTBit ==1)"); TDirectory * dir = output_file->mkdir("oneNonIsolatedZToMuMuPlots"); dir->cd(); TH1F * zMass = new TH1F("zMass", "zMass", 200, 0, 200); Events.Project("zMass", "zGoldenMass", cut_zGoldenOneNotIso ); zMass->Write(); cout<<"Number of zGoldenOneNotIso : "<<zMass->GetEntries()<<endl; delete zMass; output_file->cd("/"); // // zGoldenTwoNotIso plots TCut cut_zGoldenTwoNotIso("zGoldenMass>60 && zGoldenMass<120 && zGoldenDau1Pt> 20 && zGoldenDau2Pt>20 && (zGoldenDau1TrkIso> 3.0 && zGoldenDau2TrkIso > 3.0) && abs(zGoldenDau1Eta)<2.1 && abs(zGoldenDau2Eta)<2.1 && (zGoldenDau1Chi2<10 || zGoldenDau2Chi2<10) && abs(zGoldenDau1dxyFromBS)<0.2 && abs(zGoldenDau2dxyFromBS)<0.2 && ((zGoldenDau1NofStripHits + zGoldenDau1NofPixelHits)>=10 || (zGoldenDau2NofStripHits + zGoldenDau2NofPixelHits)>=10) && (zGoldenDau1NofMuonHits>0 || zGoldenDau2NofMuonHits>0) && ( zGoldenDau1HLTBit ==1 || zGoldenDau2HLTBit ==1)"); TDirectory * dir = output_file->mkdir("twoNonIsolatedZToMuMuPlots"); dir->cd(); TH1F * zMass = new TH1F("zMass", "zMass", 200, 0, 200); Events.Project("zMass","zGoldenMass", cut_zGoldenTwoNotIso ); zMass->Write(); cout<<"Number of zGoldenTwoNotIso : "<<zMass->GetEntries()<<endl; delete zMass; output_file->cd("/"); // zGoldenNotIso plots TCut cut_zGoldenNotIso("zGoldenMass>60 && zGoldenMass<120 && zGoldenDau1Pt> 20 && zGoldenDau2Pt>20 && (zGoldenDau1TrkIso> 3.0 || zGoldenDau2TrkIso > 3.0) && abs(zGoldenDau1Eta)<2.1 && abs(zGoldenDau2Eta)<2.1 && (zGoldenDau1Chi2<10 || zGoldenDau2Chi2<10) && abs(zGoldenDau1dxyFromBS)<0.2 && abs(zGoldenDau2dxyFromBS)<0.2 && ((zGoldenDau1NofStripHits + zGoldenDau1NofPixelHits)>=10 || (zGoldenDau2NofStripHits + zGoldenDau2NofPixelHits)>=10) && (zGoldenDau1NofMuonHits>0 || zGoldenDau2NofMuonHits>0) && ( zGoldenDau1HLTBit ==1 || zGoldenDau2HLTBit ==1)"); TDirectory * dir = output_file->mkdir("nonIsolatedZToMuMuPlots"); dir->cd(); TH1F * zMass = new TH1F("zMass", "zMass", 200, 0, 200); Events.Project("zMass", "zGoldenMass", cut_zGoldenNotIso ); zMass->Write() ; cout<<"Number of zGoldenNotIso : "<<zMass->GetEntries()<<endl; delete zMass; output_file->cd("/"); // zGoldenSameCharge plots........ TCut cut_zSameCharge("zSameChargeMass>60 && zSameChargeMass<120 && zSameChargeDau1Pt> 20 && zSameChargeDau2Pt>20 && zSameChargeDau1TrkIso< 3.0 && zSameChargeDau2TrkIso < 3.0 && abs(zSameChargeDau1Eta)<2.1 && abs(zSameChargeDau2Eta)<2.1 && zSameChargeDau1Chi2<10 && zSameChargeDau2Chi2<10 && abs(zSameChargeDau1dxyFromBS)<0.2 && abs(zSameChargeDau2dxyFromBS)<0.2 && ((zSameChargeDau1NofStripHits + zSameChargeDau1NofPixelHits)>=10 || (zSameChargeDau2NofStripHits + zSameChargeDau2NofPixelHits)>=10) && (zSameChargeDau1NofMuonHits>0 || zSameChargeDau2NofMuonHits>0) && (zSameChargeDau1HLTBit==1 || zSameChargeDau2HLTBit==1) "); TDirectory * dir = output_file->mkdir("goodZToMuMuSameChargePlots"); dir->cd(); TH1F * zMass = new TH1F("zMass", "zMass", 200, 0, 200); Events.Project("zMass", "zSameChargeMass", cut_zSameCharge ); zMass->Write(); cout<<"Number of zGoldenSameCharge : "<<zMass->GetEntries()<<endl; delete zMass; output_file->cd("/"); // zGoldenSameChargeNotIso plots........ TCut cut_zSameChargeNotIso("zSameChargeMass>60 && zSameChargeMass<120 && zSameChargeDau1Pt> 20 && zSameChargeDau2Pt>20 && ( zSameChargeDau1TrkIso> 3.0 || zSameChargeDau2TrkIso > 3.0) && abs(zSameChargeDau1Eta)<2.1 && abs(zSameChargeDau2Eta)<2.1 && zSameChargeDau1Chi2<10 && zSameChargeDau2Chi2<10 && abs(zSameChargeDau1dxyFromBS)<0.2 && abs(zSameChargeDau2dxyFromBS)<0.2 && ( (zSameChargeDau1NofStripHits + zSameChargeDau1NofPixelHits)>=10 || (zSameChargeDau2NofStripHits + zSameChargeDau2NofPixelHits)>=10) && (zSameChargeDau1NofMuonHits>0 || zSameChargeDau2NofMuonHits>0) && (zSameChargeDau1HLTBit==1 || zSameChargeDau2HLTBit==1) "); TDirectory * dir = output_file->mkdir("goodZToMuMuSameChargeNotIsoPlots"); dir->cd(); TH1F * zMass = new TH1F("zMass", "zMass", 200, 0, 200); Events.Project("zMass", "zSameChargeMass", cut_zSameChargeNotIso ); zMass->Write(); cout<<"Number of zGoldenSameChargeNotIso : "<<zMass->GetEntries()<<endl; delete zMass; output_file->cd("/"); // zMuTrk plots TCut cut_zMuTrk("zMuTrkMass>60 && zMuTrkMass<120 && zMuTrkDau1Pt> 20 && zMuTrkDau2Pt>20 && zMuTrkDau1TrkIso< 3.0 && zMuTrkDau2TrkIso < 3.0 && abs(zMuTrkDau1Eta)<2.1 && abs(zMuTrkDau2Eta)<2.1 && (zMuTrkDau1Chi2<10) && abs(zMuTrkDau1dxyFromBS)<0.2 && abs(zMuTrkDau2dxyFromBS)<0.2 && ((zMuTrkDau1TrkNofStripHits + zMuTrkDau1TrkNofPixelHits)>=10) && (zMuTrkDau1NofMuonHits>0) && (zMuTrkDau1HLTBit==1) "); TDirectory * dir = output_file->mkdir("goodZToMuMuOneTrackPlots"); dir->cd(); TH1F * zMass = new TH1F("zMass", "zMass", 200, 0, 200); Events.Project("zMass", "zMuTrkMass", cut_zMuTrk ); zMass->Write(); cout<<"Number of zMuTrk : "<<zMass->GetEntries()<<endl; delete zMass; output_file->cd("/"); // zMuTrkMu plots TCut cut_zMuTrkMu("zMuTrkMuMass>60 && zMuTrkMuMass<120 && zMuTrkMuDau1Pt>20 && zMuTrkMuDau2Pt>20 && zMuTrkMuDau1TrkIso< 3.0 && zMuTrkMuDau2TrkIso<3.0 && abs(zMuTrkMuDau1Eta)<2.1 && abs(zMuTrkMuDau2Eta)<2.1 && (( zMuTrkMuDau1Chi2<10 && zMuTrkMuDau1GlobalMuonBit==1 ) || ( zMuTrkMuDau2Chi2<10 && zMuTrkMuDau2GlobalMuonBit==1)) && abs(zMuTrkMuDau1dxyFromBS)<0.2 && abs(zMuTrkMuDau2dxyFromBS)<0.2 && (( zMuTrkMuDau1GlobalMuonBit==1 && (zMuTrkMuDau1TrkNofStripHits + zMuTrkMuDau1TrkNofPixelHits)>=10) || ( zMuTrkMuDau2GlobalMuonBit==1 && (zMuTrkMuDau2TrkNofStripHits + zMuTrkMuDau2TrkNofPixelHits)>=10) ) && (( zMuTrkMuDau1GlobalMuonBit==1 && zMuTrkMuDau1NofMuonHits>0) || ( zMuTrkMuDau2GlobalMuonBit==1 && zMuTrkMuDau2NofMuonHits>0 )) && ( (zMuTrkMuDau1HLTBit==1 && zMuTrkMuDau1GlobalMuonBit==1 ) || (zMuTrkMuDau2HLTBit==1 && zMuTrkMuDau2GlobalMuonBit==1 )) "); TDirectory * dir = output_file->mkdir("goodZToMuMuOneTrackerMuonPlots"); dir->cd(); TH1F * zMass = new TH1F("zMass", "zMass", 200, 0, 200); Events.Project("zMass", "zMuTrkMuMass", cut_zMuTrkMu ); zMass->Write(); cout<<"Number of zMuTrkMu : "<<zMass->GetEntries()<<endl; delete zMass; output_file->cd("/"); // zMuSta plots TCut cut_zMuSta("zMuStaMass>60 && zMuStaMass<120 && zMuStaDau1Pt>20 && zMuStaDau2Pt>20 && zMuStaDau1TrkIso< 3.0 && zMuStaDau2TrkIso<3.0 && abs(zMuStaDau1Eta)<2.1 && abs(zMuStaDau2Eta)<2.1 && (( zMuStaDau1Chi2<10 && zMuStaDau1GlobalMuonBit==1 ) || ( zMuStaDau2Chi2<10 && zMuStaDau2GlobalMuonBit==1)) && abs(zMuStaDau1dxyFromBS)<0.2 && abs(zMuStaDau2dxyFromBS)<0.2 && (( zMuStaDau1GlobalMuonBit==1 && (zMuStaDau1TrkNofStripHits + zMuStaDau1TrkNofPixelHits)>=10) || ( zMuStaDau2GlobalMuonBit==1 && (zMuStaDau2TrkNofStripHits + zMuStaDau2TrkNofPixelHits)>=10) ) && (( zMuStaDau1GlobalMuonBit==1 && zMuStaDau1NofMuonHits>0) || ( zMuStaDau2GlobalMuonBit==1 && zMuStaDau2NofMuonHits>0 )) && ( (zMuStaDau1HLTBit==1 && zMuStaDau1GlobalMuonBit==1 ) || (zMuStaDau2HLTBit==1 && zMuStaDau2GlobalMuonBit==1 )) "); TDirectory * dir = output_file->mkdir("goodZToMuMuOneStandAloneMuonPlots"); dir->cd(); TH1F * zMass = new TH1F("zMass", "zMass", 200, 0, 200); Events.Project("zMass", "zMuStaMass", cut_zMuSta ); zMass->Write(); cout<<"Number of zMuSta : "<<zMass->GetEntries()<<endl; delete zMass; output_file->cd("/"); // zMuSta plots TCut cut_zMuMuSta("zGoldenDau1Pt> 20 && zGoldenDau2Pt>20 && zGoldenDau1TrkIso< 3.0 && zGoldenDau2TrkIso < 3.0 && zGoldenDau1Eta<2.1 && zGoldenDau2Eta<2.1 && (zGoldenDau1Chi2<10 || zGoldenDau2Chi2<10) && zGoldenDau1dxyFromBS<0.02 && zGoldenDau2dxyFromBS<0.02"); TDirectory * dir = output_file->mkdir("zmumuSaMassHistogram"); dir->cd(); TH1F * zMass = new TH1F("zMass", "zMass", 200, 0, 200); Events.Project("zMass", "zGoldenMassSa", cut_zMuMuSta ); zMass->Write(); delete zMass; output_file->cd("/"); TDirectory * dir = output_file->mkdir("zPlots"); dir->cd(); TH1F * zGoldenPt = new TH1F("zGoldenPt", "zGoldenPt", 200, 0, 200); Events.Project("zGoldenPt", "zGoldenPt", cut_zGolden ); zGoldenPt->Write(); delete zGoldenPt; TH1F * zGoldenY = new TH1F("zGoldenY", "zGoldenY", 200, -5, 5); Events.Project("zGoldenY", "zGoldenY", cut_zGolden ); zGoldenY->Write(); delete zGoldenY; output_file->cd("/"); TDirectory * dir = output_file->mkdir("MuPlots"); dir->cd(); TH1F * muNotTriggeredEta = new TH1F("muNotTriggeredEta", "muNotTriggeredEta", 240, -6, 6.); TH1F * h2 = new TH1F("h2", "h2", 240, -6, 6.); Events.Project("muNotTriggeredEta","zGoldenDau1Eta", "zGoldenDau1HLTBit==0"); Events.Project("h2","zGoldenDau2Eta", "zGoldenDau2HLTBit==0"); muNotTriggeredEta->Add(h2); muNotTriggeredEta->Write(); delete muNotTriggeredEta; delete h2; TH1F * zGoldenDauHighPt = new TH1F("zGoldenDauHighPt", "zGoldenDauHighPt", 200, 0, 200); Events.Project("zGoldenDauHighPt", "max(zGoldenDau1Pt, zGoldenDau2Pt)", cut_zGolden ); zGoldenDauHighPt->Write(); delete zGoldenDauHighPt; TH1F * zGoldenDauLowPt = new TH1F("zGoldenDauLowPt", "zGoldenDauLowPt", 200, 0, 200); Events.Project("zGoldenDauLowPt", "min(zGoldenDau1Pt, zGoldenDau2Pt)", cut_zGolden ); zGoldenDauLowPt->Write(); delete zGoldenDauLowPt; //(mu1.phi -mu2.phi) TH1F * deltaPhi = new TH1F("deltaPhi", "deltaPhi", 120, 0, 6.); TH1F * h2 = new TH1F("h2", "h2", 120, 0, 6. ); TH1F * h3 = new TH1F("h3", "h3", 120, 0, 6. ); /* result = phi1 - phi2; 040 while (result > M_PI) result -= 2*M_PI; 041 while (result <= -M_PI) result += 2*M_PI; 042 return result; */ Events.Project("deltaPhi", "abs(zGoldenDau1Phi - zGoldenDau2Phi)", "-TMath::Pi() < (zGoldenDau1Phi - zGoldenDau2Phi) < TMath::Pi()" , "zGoldenDau1Pt>20 && zGoldenDau2Pt >20" + cut_zGolden); Events.Project("h2", "abs(zGoldenDau1Phi - zGoldenDau2Phi - 2 * TMath::Pi())", "(zGoldenDau1Phi - zGoldenDau2Phi) > TMath::Pi()" , "zGoldenDau1Pt>20 && zGoldenDau2Pt >20" + + cut_zGolden); Events.Project("h3", "abs(zGoldenDau1Phi - zGoldenDau2Phi + 2 * TMath::Pi())", "(zGoldenDau1Phi - zGoldenDau2Phi) <= -TMath::Pi()", "zGoldenDau1Pt>20 && zGoldenDau2Pt >20" + cut_zGolden ); deltaPhi->Add(h2, h3); deltaPhi->Write(); delete deltaPhi;; delete h2; delete h3; // mu1.eta -mu2.eta TH1F * deltaEta = new TH1F("deltaEta", "deltaEta", 120, 0, 6.); Events.Project("deltaEta", "abs(zGoldenDau1Eta - zGoldenDau2Eta)", cut_zGolden ); deltaEta->Write(); delete deltaEta; TH1F * dua1Phi = new TH1F("dau1Phi", "dau1Phi", 120, -6, 6.); Events.Project("dau1Phi", "zGoldenDau1Phi" , cut_zGolden); dau1Phi->Write(); delete dau1Phi; TH1F * dua2Phi = new TH1F("dau2Phi", "dau2Phi", 120, -6, 6.); Events.Project("dau2Phi", "zGoldenDau2Phi" , cut_zGolden); dau2Phi->Write(); delete dau2Phi; TH1F * dau1Eta = new TH1F("dua1Eta", "dau1Eta", 120, -6, 6.); Events.Project("dau1Eta", "zGoldenDau1Eta", cut_zGolden ); dau1Eta->Write(); delete dau1Eta; TH1F * dau2Eta = new TH1F("dua2Eta", "dau2Eta", 120, -6, 6.); Events.Project("dau2Eta", "zGoldenDau2Eta" , cut_zGolden); dau2Eta->Write(); delete dau2Eta; // quality variables // caveat: I'm requiring isolations TH1F * dau1Chi2 = new TH1F("dua1Chi2", "dau1Chi2", 1000, 0, 100); Events.Project("dua1Chi2", "zGoldenDau1Chi2", cut_zGolden ); dau1Chi2->Write(); delete dau1Chi2; TH1F * dau2Chi2 = new TH1F("dua2Chi2", "dau2Chi2", 1000, 0, 100); Events.Project("dau2Chi2", "zGoldenDau2Chi2", cut_zGolden ); dau2Chi2->Write(); delete dau2Chi2; TH1F * dau1Dxy = new TH1F("dua1Dxy", "dau1Dxy", 500, 0, 5); Events.Project("dua1Dxy", "zGoldenDau1dxyFromBS", cut_zGolden ); dau1Dxy->Write(); delete dau1Dxy; TH1F * dau2Dxy = new TH1F("dua2Dxy", "dau2Dxy", 500, 0, 5); Events.Project("dua2Dxy", "zGoldenDau2dxyFromBS", cut_zGolden ); dau2Dxy->Write(); delete dau2Dxy; TH1F * dau1Dz= new TH1F("dua1Dz", "dau1Dz", 500, 0, 20); Events.Project("dua1Dz", "zGoldenDau1dzFromBS", cut_zGolden ); dau1Dz->Write(); delete dau1Dz; TH1F * dau2Dz = new TH1F("dua2Dz", "dau2Dz", 500, 0, 20); Events.Project("dua2Dz", "zGoldenDau2dzFromBS", cut_zGolden); dau2Dz->Write(); delete dau2Dz; /* TH1F * dau1NofHit = new TH1F("dua1NofHit", "dau1NofHit", 100, -0.5, 99.5); Events.Project("dua1NofHit", "zGoldenDau1NofHit", cut_zGolden ); dau1NofHit->Write(); delete dau1NofHit; TH1F * dau2NofHit = new TH1F("dua2NofHit", "dau2NofHit", 100, -0.5, 99.5); Events.Project("dua2NofHit", "zGoldenDau2NofHit", cut_zGolden ); dau2NofHit->Write(); delete dau2NofHit; */ TH1F * dau1NofMuCh = new TH1F("dua1NofMuCh", "dau1NofMuCh", 20, -0.5, 19.5); Events.Project("dua1NofMuCh", "zGoldenDau1NofMuChambers", cut_zGolden ); dau1NofMuCh->Write(); delete dau1NofMuCh; TH1F * dau2NofMuCh = new TH1F("dua2NofMuCh", "dau2NofMuCh", 20, -0.5, 19.5); Events.Project("dua2NofMuCh", "zGoldenDau2NofMuChambers", cut_zGolden ); dau2NofMuCh->Write(); delete dau2NofMuCh; TH1F * dau1NofMuMatches = new TH1F("dua1NofMuMatches", "dau1NofMuMatches", 20, -0.5, 19.5); Events.Project("dua1NofMuMatches", "zGoldenDau1NofMuMatches", cut_zGolden ); dau1NofMuMatches->Write(); delete dau1NofMuMatches; TH1F * dau2NofMuMatches = new TH1F("dua2NofMuMatches", "dau2NofMuMatches", 20, -0.5, 19.5); Events.Project("dua2NofMuMatches", "zGoldenDau2NofMuMatches", cut_zGolden ); dau2NofMuMatches->Write(); delete dau2NofMuMatches; TH1F * dau1EmEnergy = new TH1F("dua1EmEnergy", "dau1EmEnergy", 200, -0.1, 19.9); Events.Project("dua1EmEnergy", "zGoldenDau1MuEnergyEm", cut_zGolden ); dau1EmEnergy->Write(); delete dau1EmEnergy; TH1F * dau2EmEnergy = new TH1F("dua2EmEnergy", "dau2EmEnergy", 200, -0.1, 19.9); Events.Project("dua2EmEnergy", "zGoldenDau2MuEnergyEm", cut_zGolden ); dau2EmEnergy->Write(); delete dau2EmEnergy; TH1F * dau1HadEnergy = new TH1F("dua1HadEnergy", "dau1HadEnergy", 200, -0.1, 19.9); Events.Project("dua1HadEnergy", "zGoldenDau1MuEnergyHad", cut_zGolden ); dau1HadEnergy->Write(); delete dau1HadEnergy; TH1F * dau2HadEnergy = new TH1F("dua2HadEnergy", "dau2HadEnergy", 200, -0.1, 19.9); Events.Project("dua2HadEnergy", "zGoldenDau2MuEnergyHad", cut_zGolden ); dau2HadEnergy->Write(); delete dau2HadEnergy; TH2F * MuChambersVsMuMatches = new TH2F("MuChambersVsMuMatches", "MuChambersVsMuMatches", 21, -0.5, 20.5, 21, -0.5, 20.5); TH2F * hh2= new TH2F("hh2", "hh2", 21, -0.5, 20.5, 21, -0.5, 20.5); Events.Project("MuChambersVsMuMatches", "zGoldenDau1NofMuChambers:zGoldenDau1NofMuMatches", cut_zGolden); Events.Project("hh2", "zGoldenDau2NofMuChambers:zGoldenDau2NofMuMatches", cut_zGolden); MuChambersVsMuMatches->Add(hh2); MuChambersVsMuMatches->Write(); MuChambersVsMuMatches->SetDrawOption("Box"); // MuChambersVsMuMatches->Draw("BOX"); delete MuChambersVsMuMatches; delete hh2; output_file->cd("/"); TDirectory * dir = output_file->mkdir("TrkPlots"); dir->cd(); /* TH1F * nofHitTrk = new TH1F("nofHitTrk", "nofHitTrk", 100, -0.5, 99.5); Events.Project("nofHitTrk", "zMuTrkDau2NofHitTk", cut_zMuTrk ); nofHitTrk->Write(); delete nofHitTrk; */ TH1F * trkChi2 = new TH1F("trkChi2", "trkChi2", 100, -0.5, 99.5); Events.Project("trkChi2", "zMuTrkDau2Chi2", cut_zMuTrk ); trkChi2->Write(); delete trkChi2; output_file->cd("/"); TDirectory * dir = output_file->mkdir("StaPlots"); dir->cd(); // sta as zDaudxyFromBS=-1 by construction.... TH1F * staNofMuCh = new TH1F("staNofMuCh", "staNofMuCh", 20, -0.5, 19.5); TH1F * h2 = new TH1F("h2", "h2", 20, -0.5, 19.5); Events.Project("staNofMuCh", "zMuStaDau1NofMuChambers", cut_zMuSta + "zMuStaDau1dxyFromBS==-1" ); Events.Project("h2", "zMuStaDau2NofMuChambers", cut_zMuSta + "zMuStaDau2dxyFromBS==-1" ); staNofMuCh->Add(h2); staNofMuCh->Write(); delete staNofMuCh; delete h2; TH1F * staNofMuMatches = new TH1F("staNofMuMatches", "staNofMuMatches", 20, -0.5, 19.5); TH1F * h2 = new TH1F("h2", "h2", 20, -0.5, 19.5); Events.Project("staNofMuMatches", "zMuStaDau1NofMuMatches", cut_zMuSta + "zMuStaDau1dxyFromBS==-1" ); Events.Project("h2", "zMuStaDau2NofMuMatches", cut_zMuSta + "zMuStaDau2dxyFromBS==-1" ); staNofMuMatches->Add(h2); staNofMuMatches->Write(); delete staNofMuMatches; delete h2; TH2F * MuChambersVsMuMatches= new TH2F("MuChambersVsMuMatches", "MuChambersVsMuMatches", 21, -0.5, 20.5, 21, -0.5, 20.5); TH2F * hh2= new TH2F("hh2", "hh2", 21, -0.5, 20.5, 21, -0.5, 20.5); Events.Project("MuChambersVsMuMatches", "zMuStaDau1NofMuChambers:zMuStaDau1NofMuMatches", cut_zMuSta); Events.Project("hh2", "zMuStaDau2NofMuChambers:zMuStaDau2NofMuMatches", cut_zMuSta); MuChambersVsMuMatches->Add(hh2); MuChambersVsMuMatches->SetDrawOption("Box"); MuChambersVsMuMatches->Write(); delete MuChambersVsMuMatches; delete hh2; output_file->cd("/"); // isolations... TDirectory * dir = output_file->mkdir("IsoPlots"); dir->cd(); TH1F * TrkIsoPt20= new TH1F("TrkIsoPt20", "TrkIsoPt20", 200, 0, 20); TH1F * h2 = new TH1F("h2", "h2", 200, 0, 20); Events.Project("TkIsoPt20", "zGoldenDau1TrkIso" , "zGoldenDau2Pt>20"); Events.Project("h2", "zGoldenDau2TrkIso", "zGoldenDau2Pt>20" ); TrkIsoPt20->Add(h2); TrkIsoPt20->Write(); delete TrkIsoPt20; delete h2; TH1F * EcalIsoPt20 = new TH1F("EcalIsoPt20", "EcalIsoPt20", 200, 0, 20); TH1F * h2 = new TH1F("h2", "h2", 200, 0, 20); Events.Project("TkIsoPt20", "zGoldenDau1EcalIso" , "zGoldenDau1Pt>20"); Events.Project("h2", "zGoldenDau2EcalIso", "zGoldenDau2Pt>20" ); EcalIsoPt20->Add(h2); EcalIsoPt20->Write(); delete EcalIsoPt20; delete h2; TH1F * HcalIsoPt20 = new TH1F("HcalIsoPt20", "HcalIsoPt20", 200, 0, 20); TH1F * h2 = new TH1F("h2", "h2", 200, 0, 20); Events.Project("TkIsoPt20", "zGoldenDau1HcalIso" , "zGoldenDau1Pt>20" ); Events.Project("h2", "zGoldenDau2HcalIso" , "zGoldenDau2Pt>20"); HcalIsoPt20->Add(h2); HcalIsoPt20->Write(); delete HcalIsoPt20; delete h2; TH1F * TrkIsoPt15= new TH1F("TrkIsoPt15", "TrkIsoPt15", 200, 0, 20); TH1F * h2 = new TH1F("h2", "h2", 200, 0, 20); Events.Project("TkIsoPt15", "zGoldenDau1TrkIso" , "zGoldenDau1Pt>20"); Events.Project("h2", "zGoldenDau2TrkIso", "zGoldenDau2Pt>15" ); TrkIsoPt15->Add(h2); TrkIsoPt15->Write(); delete TrkIsoPt15; delete h2; TH1F * EcalIsoPt15 = new TH1F("EcalIsoPt15", "EcalIsoPt15", 200, 0, 20); TH1F * h2 = new TH1F("h2", "h2", 200, 0, 20); Events.Project("TkIsoPt15", "zGoldenDau1EcalIso" , "zGoldenDau1Pt>20"); Events.Project("h2", "zGoldenDau2EcalIso", "zGoldenDau2Pt>15" ); EcalIsoPt15->Add(h2); EcalIsoPt15->Write(); delete EcalIsoPt15; delete h2; TH1F * HcalIsoPt15 = new TH1F("HcalIsoPt15", "HcalIsoPt15", 200, 0, 20); TH1F * h2 = new TH1F("h2", "h2", 200, 0, 20); Events.Project("TkIsoPt15", "zGoldenDau1HcalIso" , "zGoldenDau1Pt>20" ); Events.Project("h2", "zGoldenDau2HcalIso" , "zGoldenDau2Pt>15"); HcalIsoPt15->Add(h2); HcalIsoPt15->Write(); delete HcalIsoPt15; delete h2; output_file->cd("/"); output_file->Close(); }
void makeValidationPlots(TTree* tree, sel_t type,bool isMC) { SelectionStrings strings; TString tag=""; TString lowString="",midString="",highString=""; switch(type) { case kReal: tag = "_realselection"; break; case kShift: tag = "_side"; break; case kSingleIso: tag = "_singleIso"; break; } if(isMC) { tag+="__DiPhotonJets"; } Double_t Red[] = {0.00, 0.70, 0.90, 1.00, 1.00, 1.00, 1.00}; Double_t Green[] ={0.00, 0.70, 0.90, 1.00, 0.90, 0.70, 0.00}; Double_t Blue[] = {1.00, 1.00, 1.00, 1.00, 0.90, 0.70, 0.00}; Double_t Length[] = {0.00, 0.20, 0.35, 0.50, 0.65, 0.8, 1.00}; TCanvas cv; std::vector<TH2F*> nSigs; std::vector<TH2F*> nSigs_gauss; cv.SetLogx(); for(int iBox=0; iBox<SigRegionBinning::nBoxes; iBox++) { TString boxName = SigRegionBinning::getRegionName(static_cast<SigRegionBinning::BinningRegion>(iBox)); switch(type) { case kReal: lowString = strings.baseSelection+" && mgg>103 && mgg<120"; midString = strings.baseSelection+" && "+strings.mggSigRegion[iBox]; highString = strings.baseSelection+" && mgg>131 && mgg<160"; break; case kShift: lowString = strings.baseSelection+" && mgg>130 && mgg<140"; midString = strings.baseSelection+" && mgg>140 && mgg<150"; highString = strings.baseSelection+" && mgg>150 && mgg<160"; break; case kSingleIso: lowString = TString("(pho1_pt>40 && pho2_pt>25 && abs(pho1_eta)<1.48 && abs(pho2_eta)<1.48 && (pho1_pass_iso || pho2_pass_iso) && !(pho1_pass_iso && pho2_pass_iso))")+" && mgg>103 && mgg<120"; midString = TString("(pho1_pt>40 && pho2_pt>25 && abs(pho1_eta)<1.48 && abs(pho2_eta)<1.48 && (pho1_pass_iso || pho2_pass_iso) && !(pho1_pass_iso && pho2_pass_iso))")+" && "+strings.mggSigRegion[iBox]; highString = TString("(pho1_pt>40 && pho2_pt>25 && abs(pho1_eta)<1.48 && abs(pho2_eta)<1.48 && (pho1_pass_iso || pho2_pass_iso) && !(pho1_pass_iso && pho2_pass_iso))")+" && mgg>131 && mgg<160"; break; } TH2F* low = SigRegionBinning::makeHistogram(static_cast<SigRegionBinning::BinningRegion>(iBox),"low"); TH2F* mid = SigRegionBinning::makeHistogram(static_cast<SigRegionBinning::BinningRegion>(iBox),"mid"); TH2F* high = SigRegionBinning::makeHistogram(static_cast<SigRegionBinning::BinningRegion>(iBox),"high"); TH2F* nsig = SigRegionBinning::makeHistogram(static_cast<SigRegionBinning::BinningRegion>(iBox),"nsig_"+boxName); TH2F* nsig_gauss = SigRegionBinning::makeHistogram(static_cast<SigRegionBinning::BinningRegion>(iBox),"nsig_gauss_"+boxName); low->SetMinimum(0.1); mid->SetMinimum(0.1); high->SetMinimum(0.1); tree->Project("low","Rsq:MR",lowString+" && "+strings.boxDefs[iBox]); tree->Project("mid","Rsq:MR",midString+" && "+strings.boxDefs[iBox]); tree->Project("high","Rsq:MR",highString+" && "+strings.boxDefs[iBox]); //SigRegionBinning::formatSigRegionPlot(low); //SigRegionBinning::formatSigRegionPlot(mid); //SigRegionBinning::formatSigRegionPlot(high); //get the difference in the prediction TH2F* low_norm = (TH2F*)low->Clone("low_norm"); TH2F* high_norm = (TH2F*)high->Clone("high_norm"); low_norm->Scale(1./low_norm->Integral()); high_norm->Scale(1./high_norm->Integral()); TH2F* pred_diff = (TH2F*)high_norm->Clone("pred_diff"); pred_diff->Add(low_norm,-1); TH2F* norm_av = (TH2F*)low_norm->Clone("norm_av"); norm_av->Add(high_norm); norm_av->Scale(0.5); TH2F* pred_per_diff = (TH2F*)pred_diff->Clone("pred_per_diff"); pred_per_diff->Divide(norm_av); cv.SetLogx(1); cv.SetLogy(0); pred_per_diff->Draw("COLZ TEXT"); cv.SaveAs("RsqMR_high_minus_low_div_av_"+boxName+tag+".png"); cv.SetLogx(1); cv.SetLogy(0); TH1D* low_1D = SigRegionBinning::make1DProj(low); TH1D* high_1D = SigRegionBinning::make1DProj(high); pred_per_diff->SetYTitle("high - low / (high+low/2)"); TH1D* pred_per_diff_1D = SigRegionBinning::make1DProj(pred_per_diff); cv.SetLogx(0); cv.SetLogy(0); pred_per_diff_1D->Draw(); cv.SaveAs("RsqMR_1D_high_minus_low_div_av_"+boxName+tag+".png"); cv.SetLogx(1); cv.SetLogy(0); TFile out("RsqMR_1D_high_minus_low_div_av_"+boxName+tag+".root","RECREATE"); low->Write(); high->Write(); low_1D->Write(); high_1D->Write(); pred_per_diff_1D->Write(); pred_per_diff->Write(); out.Close(); TH2F* sideband_tot = (TH2F*)low->Clone("sideband_tot"); sideband_tot->Add(high); sideband_tot->Draw("COLZ TEXT"); cv.SetLogz(); cv.SaveAs("RsqMR_low_plus_high_"+boxName+tag+".png"); cv.SetLogz(0); float sf = mid->Integral()/sideband_tot->Integral(); std::cout << "sf: " << sf << std::endl; TH2F* sideband_pred = (TH2F*)sideband_tot->Clone("sideband_pred"); sideband_pred->Scale(sf); sideband_pred->Draw("COLZ TEXT"); cv.SetLogz(); cv.SaveAs("RsqMR_sideband_pred_"+boxName+tag+".png"); cv.SetLogz(0); mid->Draw("COLZ TEXT"); cv.SetLogz(); cv.SaveAs("RsqMR_mid_"+boxName+tag+".png"); cv.SetLogz(0); TH1D* pred_1D = SigRegionBinning::make1DProj(sideband_pred,true,sf); TH1D* mid_1D = SigRegionBinning::make1DProj(mid); cv.SetLogx(0); cv.SetLogy(); mid_1D->SetMarkerStyle(20); mid_1D->SetMarkerColor(kBlack); mid_1D->SetMarkerSize(1.4); pred_1D->SetFillColor(kRed); pred_1D->SetFillStyle(3001); pred_1D->SetLineColor(kRed); pred_1D->SetLineWidth(2); pred_1D->SetMarkerSize(0); pred_1D->Draw("L E2"); pred_1D->Draw("LSAME"); mid_1D->Draw("PSAME"); cv.SaveAs("RsqMR_1D_obs_sideband_pred_"+boxName+tag+".png"); cv.SetLogx(1); cv.SetLogy(0); TH2F* perdiff = (TH2F*)mid->Clone("perdiff"); perdiff->Add(sideband_pred,-1); perdiff->Divide(perdiff); perdiff->Draw("COLZ TEXT"); cv.SaveAs("RsqMR_percentDiff_"+boxName+tag+".png"); for(int iXbin=1; iXbin<=sideband_pred->GetNbinsX(); iXbin++) { for(int iYbin=1; iYbin<=sideband_pred->GetNbinsY(); iYbin++) { float obs = mid->GetBinContent(iXbin,iYbin); float exp = sideband_pred->GetBinContent(iXbin,iYbin); float err = TMath::Sqrt(sideband_tot->GetBinContent(iXbin,iYbin))*sf; float ns = fabs(TMath::NormQuantile(SigRegionBinning::pValue(obs,exp,err/exp)/2)); if(obs<exp) ns*=-1; nsig->SetBinContent(iXbin,iYbin,ns); std::cout << "\t" << iXbin << " " << iYbin << " " << nsig->GetBinContent(iXbin,iYbin) << std::endl; float gauss_err = TMath::Sqrt(TMath::Power(err,2)+exp); if(gauss_err==0) gauss_err=1; nsig_gauss->SetBinContent(iXbin,iYbin,(obs-exp)/gauss_err); } } SigRegionBinning::formatSigRegionPlot(nsig); SigRegionBinning::formatSigRegionPlot(nsig_gauss); //cv.SetLogx(); nSigs.push_back(nsig); nSigs_gauss.push_back(nsig_gauss); delete low; delete mid; delete high; delete sideband_tot; delete sideband_pred; } for(int iBox=0; iBox<SigRegionBinning::nBoxes; iBox++) { TString boxName = SigRegionBinning::getRegionName(static_cast<SigRegionBinning::BinningRegion>(iBox)); TColor::CreateGradientColorTable(7,Length,Red,Green,Blue,999); TH2F* nsig = nSigs.at(iBox); nsig->SetMaximum(5.1); nsig->SetMinimum(-5.1); nsig->SetContour(999); nsig->Draw("COLZ TEXT0"); cv.SaveAs("RsqMR_low_plus_high_RAWSUM_NSIGMA_"+boxName+tag+".png"); TH2F* nsig_gauss = nSigs_gauss.at(iBox); nsig_gauss->SetMaximum(5.1); nsig_gauss->SetMinimum(-5.1); nsig_gauss->SetContour(999); nsig_gauss->Draw("COLZ"); cv.SaveAs("RsqMR_low_plus_high_RAWSUM_NSIGMAGAUSS_"+boxName+tag+".png"); TH1D* nsig_gauss_1D = SigRegionBinning::make1DProj(nsig_gauss); nsig_gauss_1D->SetLineColor(kBlack); nsig_gauss_1D->SetLineWidth(1.5); nsig_gauss_1D->SetMinimum(-5.1); nsig_gauss_1D->SetMaximum(5.1); nsig_gauss_1D->SetYTitle("Number of Sigma"); cv.SetLogx(0); cv.SetLogy(0); nsig_gauss_1D->Draw(); cv.SaveAs("RsqMR_low_plus_high_1D_RAWSUM_NSIGMAGAUSS_"+boxName+tag+".png"); cv.SetLogx(1); } }
void Getdphi(int icent=0, int ihar=0, bool usingCNTEP=0, int isub=0){ TString str; int nrun = GetTotalRun(); std::cout<<"Totally we have "<<nrun<<" runs/segments!"<<std::endl; FillGoodRun(icent,ihar,isub); std::cout<<"Filling Good run finished!"<<std::endl; if(nrun<0) exit(1); int iharE=0; if(nhar==1 || nhar ==2) iharE=1; TFile *fin; int n = ihar+1.0+iharE; TFile *fout = TFile::Open(Form("dphiv%d.root",n),"Update"); str = choosesub(isub); TString UseCNTEP; if(str=="ABORT") exit(0); if(usingCNTEP) UseCNTEP = "UseCNTEP"; else UseCNTEP = "NoUseCNTEP"; std::cout<<UseCNTEP<<std::endl; std::cout<<"starting doing "<<str<<" v"<<n<<" analysis!"<<std::endl; TH2F* hvall = new TH2F(Form("hdphiall_%d_%d_%d",icent,ihar,isub),Form("hdphiall_%d_%d_%d",icent,ihar,isub),60,0,6,200,-4,4); TH2F* hvnall = new TH2F(Form("hdphinall_%d_%d_%d",icent,ihar,isub),Form("hdphinall_%d_%d_%d",icent,ihar,isub),60,0,6,100,-2,2); for(int iphi=0;iphi<nphi+1;iphi++){ // TH2F* hv = new TH2F(Form("hdphi_%d_%d_%d_%d",icent,ihar,isub,iphi),Form("hdphi_%d_%d_%d_%d",icent,ihar,isub,iphi),60,0,6,200,-4,4); TH2F* hvn = new TH2F(Form("hdphin_%d_%d_%d_%d",icent,ihar,isub,iphi),Form("hdphin_%d_%d_%d_%d",icent,ihar,isub,iphi),60,0,6,100,-2,2); string phistr = (iphi==0)?"_east":"_west"; if(iphi==nphi) phistr = ""; if(iphi<nphi){ for(int irun=0;irun<nrun;irun++){ fin = TFile::Open(Form("/phenix/plhf/xuq/taxi/Run15pAu200FVTXClusAna503/10242/data/%s",GetRun(irun).Data())); if(!(GoodRunFit[icent][ihar][isub][irun]>0.2 && GoodRunFit[icent][ihar][isub][irun]<3.0)){ std::cout<<"cent = "<<icent<<"; n = "<<n<<" ;isub = "<<str<<" ;run = "<<GetRun(irun)<<" is bad run!"<<std::endl; fin->Close(); continue; } TH2F *hvtemp; TH2F *hvntemp; //hvtemp = (TH2F*)fin->Get(Form("v%s_%d_%d_%d",str.Data(),icent,ihar,iphi)); hvntemp = (TH2F*)fin->Get(Form("vn%s_%d_%d_%d",str.Data(),icent,ihar,iphi)); //hv->Add(hvtemp); hvn->Add(hvntemp); fin->Close(); } } //hvall->Add(hv); hvnall->Add(hvn); if(iphi==nphi){ //hv = hvall; hvn = hvnall; } fout->cd(); //hv->Write(); hvn->Write(); /* for(int ipt=0;ipt<npt-1;ipt++){ int xbinmin = hv->GetXaxis()->FindBin(ptbin[ipt]+eps); int xbinmax = hv->GetXaxis()->FindBin(ptbin[ipt+1]-eps); // std::cout<<xbinmin<<" "<<xbinmax<<std::endl; // std::cout<<ptbin[ipt]<<" "<<ptbin[ipt+1]<<std::endl; // TH1F* hvProj = (TH1F*)hv->ProjectionY(Form("hvProj_%d",ipt),xbinmin,xbinmax); // TH1F* hvnProj = (TH1F*)hvn->ProjectionY(Form("hvnProj_%d",ipt),xbinmin,xbinmax); } */ } fout->Close(); }
TH2F* mergeBackground(TFile* fa,const char* pattern,const char * theSbtag,const char* newname,const string scenario) { std::cout << "mergeBackground: newname = " << newname << std::endl; const int nTrig=4; const int nfc=3; const int ncateg=3; string sfc[nfc] = { "q", "c", "b" }; TH2F* theData[nTrig][nfc][ncateg]; if (fa == NULL) { std::cout << "mergeBackground: no hfile opened" << std::endl; return NULL; } int nTrigUse = 4; if (scenario == "LowMass2011") { nTrigUse = 3; } std::cout << " mergeBackground: nTrigUse=" << nTrigUse << std::endl; // no weights for (int iTrig=0; iTrig<nTrigUse; ++iTrig) { for (int ifc=0; ifc<nfc; ++ifc) { for (int icateg=0; icateg<ncateg; ++icateg) { //string sname( Form(Form("%sTrig%d",pattern,iTrig),sfc[ifc].c_str(),theSbtag,icateg,icateg) ); string sname( Form("bgPredict/MassBTagPred_%s_%s_Cat%dTpat%dTrig%d", sfc[ifc].c_str(),theSbtag,icateg,icateg,iTrig) ); theData[iTrig][ifc][icateg] = (TH2F*) fa->Get( sname.c_str()); if (theData[iTrig][ifc][icateg] == NULL) { std::cout << "mergeBackground: histogram " << sname << " not found" << std::endl; return 0; } //theData[ii]->Draw(); } } } TH2F* mergedData = new TH2F( *theData[0][0][0] ); mergedData->SetName( newname ); mergedData->SetTitle( newname ); for (int iTrig=0; iTrig<nTrigUse; ++iTrig) { for (int ifc=0; ifc<nfc; ++ifc) { for (int icateg=0; icateg<ncateg; ++icateg) { if (! ((iTrig == 0) && (ifc == 0) && (icateg == 0) )) { mergedData->Add( theData[iTrig][ifc][icateg] ); std::cout << "mergeBackground: adding " << theData[iTrig][ifc][icateg]->GetName() << std::endl; } } } } std::cout << "mergeBackground: newname(4) = " << newname << std::endl; // cross check total weight double tw = 0; for (int iTrig=0; iTrig<nTrigUse; ++iTrig) { for (int ifc=0; ifc<nfc; ++ifc) { for (int icateg=0; icateg<ncateg; ++icateg) { tw += theData[iTrig][ifc][icateg]->GetSum(); } } } std::cout << newname << " Sum = " << tw << " mergedData = " << mergedData->GetSum() << std::endl; std::cout << mergedData->GetName() << std::endl; // final normalization (from control region) double wScale = 1; string sb( theSbtag ); if (scenario == "LowMass2011") { { if ( sb == "CSVT" ) { wScale = 1.07817; } else if ( sb == "TCHPT" ) { wScale = 0.970401; } } } else if (scenario == "MediumMass2011") { { if ( sb == "CSVT" ) { wScale = 0.9505; } else if ( sb == "TCHPT" ) { wScale = 0.874897; } } } else { std::cout << "merge background: bad scenario " << scenario << std::endl; return 0; } std::cout << "Use expected background scale factor of " << wScale << " for " << theSbtag << " scenario " << scenario << std::endl; mergedData->Scale( wScale ); std::cout << newname << " After final normalization: " << mergedData->GetSum() << std::endl; return mergedData; }
void handmerge(){ TString dir = "/scratch/xuq7/phenix/pAu/Perform/AnapAumbst_"; TH2F* hcentcnteta; TH2F* hcentcnteta1; TH2F* hcentcnteta11; TH2F* hcentcnteta12; TH2F* hcentcnteta21; TH2F* hcentcnteta22; TH2F* hcentcntpt; TH2F* hcentntrk; TH2F* hcentntrk1; TFile *f[1513]; for(int j=5;j<10;j++){ for(int i=0;i<153;i++){ cout<<i<<endl; if(j*153+i>=1513) continue; f[j*153+i] = TFile::Open(Form("%s%d.root",dir.Data(),j*153+i)); //try{ /* TH2F* hcentcnteta_tmp = (TH2F*)f[i]->Get("hcentcnteta"); TH2F* hcentcntpt_tmp = (TH2F*)f[i]->Get("hcentcntpt"); TH2F* hcentntrk_tmp = (TH2F*)f[i]->Get("hcentntrk"); */ TH2F* hcentcnteta_tmp = (TH2F*)f[j*153+i]->Get("hcentbbct0fracsouth_4"); TH2F* hcentcnteta_tmp1 = (TH2F*)f[j*153+i]->Get("hcentbbcmixt0fracsouth_4"); TH2F* hcentcnteta_tmp11 = (TH2F*)f[j*153+i]->Get("hcentbbct0fracsouth_7"); TH2F* hcentcnteta_tmp12 = (TH2F*)f[j*153+i]->Get("hcentbbcmixt0fracsouth_7"); TH2F* hcentcnteta_tmp21 = (TH2F*)f[j*153+i]->Get("hcentbbct0fracsouth_0"); TH2F* hcentcnteta_tmp22 = (TH2F*)f[j*153+i]->Get("hcentbbcmixt0fracsouth_0"); TH2F* hcentcntpt_tmp = (TH2F*)f[j*153+i]->Get("hcent1cent2_0"); TH2F* hcentntrk_tmp = (TH2F*)f[j*153+i]->Get("hcent1cent2_4"); TH2F* hcentntrk_tmp1 = (TH2F*)f[j*153+i]->Get("hcent1cent2_9"); // } // catch( const std::exception& e){ // cout<<e.what()<<endl; // continue; // } if(i==0){ hcentcnteta = (TH2F*)hcentcnteta_tmp->Clone("hcentcnteta_add"); hcentcnteta1 = (TH2F*)hcentcnteta_tmp1->Clone("hcentcnteta_add1"); hcentcnteta11 = (TH2F*)hcentcnteta_tmp11->Clone("hcentcnteta_add11"); hcentcnteta12 = (TH2F*)hcentcnteta_tmp12->Clone("hcentcnteta_add12"); hcentcnteta21 = (TH2F*)hcentcnteta_tmp11->Clone("hcentcnteta_add21"); hcentcnteta22 = (TH2F*)hcentcnteta_tmp12->Clone("hcentcnteta_add22"); hcentcntpt = (TH2F*)hcentcntpt_tmp->Clone("hcentcntpt_add"); hcentntrk = (TH2F*)hcentntrk_tmp->Clone("hcentntrk_add"); hcentntrk1 = (TH2F*)hcentntrk_tmp1->Clone("hcentntrk_add1"); } else{ hcentcnteta->Add(hcentcnteta_tmp); hcentcnteta1->Add(hcentcnteta_tmp1); hcentcnteta11->Add(hcentcnteta_tmp11); hcentcnteta12->Add(hcentcnteta_tmp12); hcentcnteta21->Add(hcentcnteta_tmp21); hcentcnteta22->Add(hcentcnteta_tmp22); hcentcntpt->Add(hcentcntpt_tmp); hcentntrk->Add(hcentntrk_tmp); hcentntrk1->Add(hcentntrk_tmp1); } // f[i]->Close(); } TFile *fout = new TFile(Form("merged_AnapAumbst%d.root",j),"Update"); fout->cd(); hcentcnteta->Write("hcentbbct0fracsouth_4",TObject::kOverwrite); hcentcnteta1->Write("hcentbbcmixt0fracsouth_4",TObject::kOverwrite); hcentcnteta11->Write("hcentbbct0fracsouth_7",TObject::kOverwrite); hcentcnteta12->Write("hcentbbcmixt0fracsouth_7",TObject::kOverwrite); hcentcnteta21->Write("hcentbbct0fracsouth_0",TObject::kOverwrite); hcentcnteta22->Write("hcentbbcmixt0fracsouth_0",TObject::kOverwrite); hcentcntpt->Write("hcent1cent2_0",TObject::kOverwrite); hcentntrk->Write("hcent1cent2_4",TObject::kOverwrite); hcentntrk1->Write("hcent1cent2_9",TObject::kOverwrite); fout->Close(); } }