////////////////////////////////////////////////////////// // This file has been automatically generated // (Tue Mar 20 13:09:57 2018 by ROOT version5.34/10) // from TTree save/save // found on file: datatuple.root // // DP data analysis // // Trigger Bits: // FPGA1 = mu+mu- (TB) FPGA1 = 1 // FPGA2 = mu+mu- (TT or BB) FPGA2 = 2 // FPGA3 = mu+mu+ or mu-mu- (TB) FPGA3 = 4 // FPGA4 = single mu+- FPGA4 = 8 // FPGA5 = single mu+- (high pT) FPGA = 16 // // NIM1 = mu+mu- () Bit = 32 // NIM2 = mu+mu- () ---> used as DP trigger for 2017 run, Bit =2^6 =64 // NIM3 = mu+mu- () Bit = 128 // // 03/20/2018 MXL ////////////////////////////////////////////////////////// #include #include #include #include #include #include #include using namespace std; void ana_DP(const char* inFile = "datatuple.root", const char* outFile = "ana_DP.root" ){ //Reset ROOT and connect tree file gROOT->Reset(); //--- input file TFile *inF = TFile::Open(inFile, "read"); TTree * save = (TTree *) inF->Get("save"); //--- analysis output file and analysis plots --- TFile *outF = new TFile(outFile,"recreate"); //Declaration of leaves types Int_t runID; Int_t spillID; Int_t eventID; Int_t triggerBits; Int_t nTracks; Int_t nHits1; Int_t nHits2; Double_t chisq1; Double_t chisq2; Double_t tx1_st1; Double_t tx1; Double_t ty1; Double_t x1_st1; Double_t x1; Double_t y1; Double_t tx2_st1; Double_t tx2; Double_t ty2; Double_t x2_st1; Double_t x2; Double_t y2; Double_t pz1; Double_t pz2; // Set branch addresses. save->SetBranchAddress("runID",&runID); save->SetBranchAddress("spillID",&spillID); save->SetBranchAddress("eventID",&eventID); save->SetBranchAddress("triggerBits",&triggerBits); save->SetBranchAddress("nTracks",&nTracks); save->SetBranchAddress("nHits1",&nHits1); save->SetBranchAddress("nHits2",&nHits2); save->SetBranchAddress("chisq1",&chisq1); save->SetBranchAddress("chisq2",&chisq2); save->SetBranchAddress("tx1_st1",&tx1_st1); save->SetBranchAddress("tx1",&tx1); save->SetBranchAddress("ty1",&ty1); save->SetBranchAddress("x1_st1",&x1_st1); save->SetBranchAddress("x1",&x1); save->SetBranchAddress("y1",&y1); save->SetBranchAddress("tx2_st1",&tx2_st1); save->SetBranchAddress("tx2",&tx2); save->SetBranchAddress("ty2",&ty2); save->SetBranchAddress("x2_st1",&x2_st1); save->SetBranchAddress("x2",&x2); save->SetBranchAddress("y2",&y2); save->SetBranchAddress("pz1",&pz1); save->SetBranchAddress("pz2",&pz2); //--- canvas & Histograms TCanvas * c1 = new TCanvas("c1", "c1: Single Tracks", 10, 20, 800, 800); TCanvas * c2 = new TCanvas("c2", "c2: Dimuon vtxZ", 200, 100, 800, 500); TCanvas * c3a = new TCanvas("c3a", "c3a: Proj. (X,Y)", 400, 200, 800, 500); TCanvas * c3b = new TCanvas("c3b", "c3b: DP Trig. Proj. (X,Y)", 600, 300, 800, 500); TH1F * h1Trig = new TH1F("h1Trig", "Trigger Bits", 130, 0, 130); TH1F * h1TrigDP = new TH1F("h1TrigDP", "Trigger Bits", 20, 60, 70); TH1F * h1Zvtx1 = new TH1F("h1Zvtx1", "Projected Z-vtx mu+", 100, -1000, 1000); // cm TH1F * h1Zvtx2 = new TH1F("h1Zvtx2", "Projected Z-vtx mu-", 100, -1000, 1000); // cm TH1F * h1ZvtxdZ = new TH1F("h1ZvtxdZ", "Projected dZvtx(mu+)-(mu-)", 100, -1000, 1000); // cm TH1F * h1Zvtx1a = new TH1F("h1Zvtx1a", "high pZ: Proj Z-vtx mu+", 100, -1000, 1000); // cm TH1F * h1Zvtx2a = new TH1F("h1Zvtx2a", "High pZ: Proj Z-vtx mu-", 100, -1000, 1000); // cm TH1F * h1ZvtxdZa = new TH1F("h1ZvtxdZa", "High pZ+/-: Projected dZvtx(mu+)-(mu-)", 100, -1000, 1000); // cm TH1F * h1pZ1 = new TH1F("h1pZ1", " pZ (mu+)", 100, 0, 100); // GeV TH1F * h1pZ2 = new TH1F("h1pZ2", " pZ (mu-)", 100, 0, 100); // GeV TH2F * h2Zvtx = new TH2F("h2Zvtx", "Z-vtx mu+ vs mu-", 100, -1000, 1000, 100, -1000, 1000); // cm //-- DP triggered samples , TriggerBits = 64 TH1F * h1Zvtx1DP = new TH1F("h1Zvtx1DP", "DP Trig. Projected Z-vtx mu+", 100, -1000, 1000); // cm TH1F * h1Zvtx2DP = new TH1F("h1Zvtx2DP", "DP Trig. Projected Z-vtx mu-", 100, -1000, 1000); // cm TH1F * h1ZvtxdZDP = new TH1F("h1ZvtxdZDP", "DP Trig. Projected dZ-vtx(mu+)-(mu-)", 100, -1000, 1000); // cm TH1F * h1pZ1DP = new TH1F("h1pZ1DP", " DP Trig. pZ (mu+)", 100, 0, 100); // GeV TH1F * h1pZ2DP = new TH1F("h1pZ2DP", " DP Trig. pZ (mu-)", 100, 0, 100); // GeV TH2F * h2ZvtxDP = new TH2F("h2ZvtxDP", "DP Trig.Z-vtx mu+ vs mu-", 100, -1000, 1000, 100, -1000, 1000); // cm //-- Projected hit (x,y) at ST1 and ST2 TH2F * h2St1XY1 = new TH2F("h2St1XY1", "Proj. mu+ (X,Y) at St1", 100, -100, 100, 100, -100, 100); // cm TH2F * h2St2XY1 = new TH2F("h2St2XY1", "Proj. mu+ (X,Y) at St2", 100, -100, 100, 100, -100, 100); // cm TH2F * h2St1XYDP1 = new TH2F("h2St1XYDP1", "DP Proj. mu+ (X,Y) at St1", 100, -100, 100, 100, -100, 100); // cm TH2F * h2St2XYDP1 = new TH2F("h2St2XYDP1", "DP Proj. mu+ (X,Y) at St2", 100, -100, 100, 100, -100, 100); // cm TH2F * h2St1XY2 = new TH2F("h2St1XY2", "Proj. mu- (X,Y) at St1", 100, -100, 100, 100, -100, 100); // cm TH2F * h2St2XY2 = new TH2F("h2St2XY2", "Proj. mu- (X,Y) at St2", 100, -100, 100, 100, -100, 100); // cm TH2F * h2St1XYDP2 = new TH2F("h2St1XYDP2", "DP Proj. mu- (X,Y) at St1", 100, -100, 100, 100, -100, 100); // cm TH2F * h2St2XYDP2 = new TH2F("h2St2XYDP2", "DP Proj. mu- (X,Y) at St2", 100, -100, 100, 100, -100, 100); // cm // Variables const Float_t m_mu = 0.1057; // muon_mass = 105.6583745(24) MeV/c2 const Float_t y_offset = 1.6; // beam y-off-set = 1.6 cm const Float_t PI = 3.1415926; const Float_t PIm = -3.1415926; const Float_t PI2 = 6.2831853; Double_t vZ1=-999, vZ2=-999, dZ=-999; Double_t mass=-999, mass_avgZ = -999; // raw dimuon mass, raw dimuon mass with recalcualted mean-Vz for opening angle Double_t St1X1, St1Y1, St2X1, St2Y1; // projected mu+ hit at St1 and St2 Double_t St1X2, St1Y2, St2X2, St2Y2; // projected mu- hit at St1 and St2 // This is the loop skeleton // To read only selected branches, Insert statements like: // save->SetBranchStatus("*",0); // disable all branches // TTreePlayer->SetBranchStatus("branchname",1); // activate branchname Long64_t nentries = save->GetEntries(); cout << "nentries =" << nentries << endl; Long64_t nbytes = 0; for (Long64_t i=0; iGetEntry(i); // //quality cuts // if (nHits1 < 10) continue; if (nHits2 < 10) continue; if (chisq1 > 20) continue; if (chisq2 > 20) continue; if (fabs(x1_st1) >100 || fabs(x2_st1) >100) continue; if (fabs(tx1_st1) >100 || fabs(tx2_st1) >100) continue; if (fabs(y1) >100 || fabs(y2) >100) continue; if (fabs(ty1) >100 || fabs(ty2) >100) continue; //vZ in Y-Z plane vZ1 = (y_offset - y1)/ty1; vZ2 = (y_offset - y2)/ty2; dZ = vZ1 - vZ2; if (fabs(vZ1) >1000 || fabs(vZ2) >1000) continue; //projected (X,Y) at St1(z=797cm) and St2(z1497cm) //mu+ St1X1 = x1_st1 + tx1_st1*797; St1Y1 = y1 + ty1*797; St2X1 = x1 + tx1*1497; St2Y1 = y1 + ty1*1497; //mu- St1X2 = x2_st1 + tx2_st1*797; St1Y2 = y2 + ty2*797; St2X2 = x2 + tx2*1497; St2Y2 = y2 + ty2*1497; // //loop events, fill histogram --- // h1Trig->Fill(triggerBits); h1Zvtx1->Fill(vZ1); h1Zvtx2->Fill(vZ2); h1ZvtxdZ->Fill(dZ); if (pz1 > 40){ h1Zvtx1a->Fill(vZ1); } if (pz2 > 40){ h1Zvtx2a->Fill(vZ2); } if (pz1 > 40 && pz2 > 40){ h1ZvtxdZa->Fill(dZ); } h1pZ1->Fill(pz1); h1pZ2->Fill(pz2); h2Zvtx->Fill(vZ1, vZ2); //-- proj (X,Y) //mu+ h2St1XY1->Fill(St1X1, St1Y1); h2St2XY1->Fill(St2X1, St2Y1); //mu- h2St1XY2->Fill(St1X2, St1Y2); h2St2XY2->Fill(St2X2, St2Y2); //Dark photon triggered events if (triggerBits >60 && triggerBits < 70 ){ h1TrigDP->Fill(triggerBits); h1Zvtx1DP->Fill(vZ1); h1Zvtx2DP->Fill(vZ2); h1ZvtxdZDP->Fill(dZ); h2ZvtxDP->Fill(vZ1, vZ2); h1pZ1DP->Fill(pz1); h1pZ2DP->Fill(pz2); //-- proj (X,Y) //mu+ h2St1XYDP1->Fill(St1X1, St1Y1); h2St2XYDP1->Fill(St2X1, St2Y1); //mu- h2St1XYDP2->Fill(St1X2, St1Y2); h2St2XYDP2->Fill(St2X2, St2Y2); }// DP trigered } // end of loop //--make plots //-- c1 c1->cd(); c1->Divide(2,2); c1->cd(1)->SetLogy(); h1Trig->Draw(); c1->cd(2)->SetLogy(); h1ZvtxdZ->Draw(); h1ZvtxdZDP->Draw("same"); c1->cd(3); h1Zvtx1->Draw(); h1Zvtx2->Draw("same"); c1->cd(4); h1ZvtxdZDP->Draw(); //-- c2 c2->cd(); c2->Divide(5,2); c2->cd(1)->SetLogy(); h1Trig->Draw(); c2->cd(2); h1Zvtx1->Draw(); h1Zvtx1a->Draw("same"); c2->cd(3); h1Zvtx2->Draw(); h1Zvtx2a->Draw("same"); c2->cd(4); h1ZvtxdZ->Draw(); h1ZvtxdZa->Draw("same"); c2->cd(5); // dimuon mass h2Zvtx->Draw("colz"); c2->cd(6); h1TrigDP->Draw(); c2->cd(7); h1Zvtx1DP->Draw(); c2->cd(8); h1Zvtx2DP->Draw(); c2->cd(9); h1ZvtxdZDP->Draw(); c2->cd(10); // dimuon mass h2ZvtxDP->Draw("colz"); //--- projt(x,y) c3a->cd(); c3a->Divide(3,2); c3a->cd(1); h2St1XY1->Draw("colz"); c3a->cd(2); h2St2XY1->Draw("colz"); c3a->cd(3); // h1Trig->Draw(); h1pZ1->Draw(); c3a->cd(4); h2St1XY2->Draw("colz"); c3a->cd(5); h2St2XY2->Draw("colz"); c3a->cd(6); // h1TrigDP->Draw(); h1pZ2->Draw(); //DP triggered c3b->cd(); c3b->Divide(3,2); c3b->cd(1); h2St1XYDP1->Draw("colz"); c3b->cd(2); h2St2XYDP1->Draw("colz"); c3b->cd(3); // h1TrigDP->Draw(); h1pZ1DP->Draw(); c3b->cd(4); h2St1XYDP2->Draw("colz"); c3b->cd(5); h2St2XYDP2->Draw("colz"); c3b->cd(6); // h1Trig->Draw(); h1pZ2DP->Draw(); //--- save output file outF->cd(); h1Trig->Write(); h1Zvtx1->Write(); h1Zvtx2->Write(); h1ZvtxdZ->Write(); h2Zvtx->Write(); h1TrigDP->Write(); h1Zvtx1DP->Write(); h1Zvtx2DP->Write(); h1ZvtxdZDP->Write(); h2ZvtxDP->Write(); // h*->Write(); c1->Write(); c2->Write(); c3a->Write(); c3b->Write(); // outF->Close(); c1->Draw(); c2->Draw(); c3a->Draw(); c3b->Draw(); // return 0; }