{ ////////////////////////////////////////////////////////// // Macro to analyze muon arm Si tracker ntuples // Steps : 1. Run Pisa // 2. Run pisaRootRead // 3. In root, run Track8.C (this macro) ////////////////////////////////////////////////////////// //Reset ROOT and connect tree file, set up for use from WINDOWS // gROOT->Reset(); #include TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("ancinr.root"); if (!f) { f = new TFile("ancinr.root"); } TTree *AncInr = (TTree*)gDirectory->Get("AncInr"); //Declaration of leaves types Float_t TRACK; Float_t NFILE; Float_t PTOT; Float_t PTHETA; Float_t PPHI; Float_t R_VERTEX; Float_t Z_VERTEX; Float_t THET_VER; Float_t PHI_VER; Float_t ITPARENT; Float_t IDPARENT; Float_t IDPART; Float_t ITORIGIN; Float_t IDORIGIN; Float_t IHIT; Float_t LAYER; Float_t THETA; Float_t PHI; Float_t XGLOBAL; Float_t YGLOBAL; Float_t ZGLOBAL; Float_t PMOMX; Float_t PMOMY; Float_t PMOMZ; Float_t IPC123; Float_t PC1THETA; Float_t PC1PHI; Float_t PC1RDIST; Float_t PC1ZDIST; Float_t PC2THETA; Float_t PC2PHI; Float_t PC2RDIST; Float_t PC2ZDIST; Float_t PC3THETA; Float_t PC3PHI; Float_t PC3RDIST; Float_t PC3ZDIST; Float_t NHIT; Float_t Z0_EVENT; Float_t B_IMPACT; Float_t EVENT; //Set branch addresses AncInr->SetBranchAddress("TRACK",&TRACK); AncInr->SetBranchAddress("NFILE",&NFILE); AncInr->SetBranchAddress("PTOT",&PTOT); AncInr->SetBranchAddress("PTHETA",&PTHETA); AncInr->SetBranchAddress("PPHI",&PPHI); AncInr->SetBranchAddress("R_VERTEX",&R_VERTEX); AncInr->SetBranchAddress("Z_VERTEX",&Z_VERTEX); AncInr->SetBranchAddress("THET_VER",&THET_VER); AncInr->SetBranchAddress("PHI_VER",&PHI_VER); AncInr->SetBranchAddress("ITPARENT",&ITPARENT); AncInr->SetBranchAddress("IDPARENT",&IDPARENT); AncInr->SetBranchAddress("IDPART",&IDPART); AncInr->SetBranchAddress("ITORIGIN",&ITORIGIN); AncInr->SetBranchAddress("IDORIGIN",&IDORIGIN); AncInr->SetBranchAddress("IHIT",&IHIT); AncInr->SetBranchAddress("LAYER",&LAYER); AncInr->SetBranchAddress("THETA",&THETA); AncInr->SetBranchAddress("PHI",&PHI); AncInr->SetBranchAddress("XGLOBAL",&XGLOBAL); AncInr->SetBranchAddress("YGLOBAL",&YGLOBAL); AncInr->SetBranchAddress("ZGLOBAL",&ZGLOBAL); AncInr->SetBranchAddress("PMOMX",&PMOMX); AncInr->SetBranchAddress("PMOMY",&PMOMY); AncInr->SetBranchAddress("PMOMZ",&PMOMZ); AncInr->SetBranchAddress("IPC123",&IPC123); AncInr->SetBranchAddress("PC1THETA",&PC1THETA); AncInr->SetBranchAddress("PC1PHI",&PC1PHI); AncInr->SetBranchAddress("PC1RDIST",&PC1RDIST); AncInr->SetBranchAddress("PC1ZDIST",&PC1ZDIST); AncInr->SetBranchAddress("PC2THETA",&PC2THETA); AncInr->SetBranchAddress("PC2PHI",&PC2PHI); AncInr->SetBranchAddress("PC2RDIST",&PC2RDIST); AncInr->SetBranchAddress("PC2ZDIST",&PC2ZDIST); AncInr->SetBranchAddress("PC3THETA",&PC3THETA); AncInr->SetBranchAddress("PC3PHI",&PC3PHI); AncInr->SetBranchAddress("PC3RDIST",&PC3RDIST); AncInr->SetBranchAddress("PC3ZDIST",&PC3ZDIST); AncInr->SetBranchAddress("NHIT",&NHIT); AncInr->SetBranchAddress("Z0_EVENT",&Z0_EVENT); AncInr->SetBranchAddress("B_IMPACT",&B_IMPACT); AncInr->SetBranchAddress("EVENT",&EVENT); // This is the loop skeleton Int_t nentries = AncInr->GetEntries(); // arrays of floats Float_t event[nentries]; Float_t track[nentries]; Float_t ptot[nentries]; Float_t ptheta[nentries]; Float_t pphi[nentries]; Float_t theta[nentries]; Float_t phi[nentries]; Float_t x[nentries]; Float_t y[nentries]; Float_t z[nentries]; Float_t px[nentries]; Float_t py[nentries]; Float_t pz[nentries]; Float_t layer[nentries]; Float_t id[nentries]; Int_t ievent[10001]; Int_t nbytes = 0; Float_t oldevent = 1.; Int_t iev = 0; ievent[1]=0; // Loop over all ntuple entries for (Int_t i=0; iGetEntry(i); // cout<oldevent) { oldevent=EVENT; iev=EVENT; ievent[iev]=i; } // fill hit arrays track[i]=TRACK; ptot[i]=PTOT; ptheta[i]=PTHETA; pphi[i]=PPHI; theta[i]=THETA; phi[i]=PHI; x[i]=XGLOBAL; y[i]=YGLOBAL; z[i]=ZGLOBAL; px[i]=PMOMX; py[i]=PMOMY; pz[i]=PMOMZ; layer[i]=LAYER; id[i]=IDPART; } // cout<GetEntry(ievent(ii)); // cout <<" number of hits on tracks "<2) break; // cout <<" track " <2.5) { goodtrk[i]=1; // cout<<"track "<Fill(xintercept[i]); if (idpart[i]==6) g3->Fill(xintercept[i]); if (idpart[i]==5) g5->Fill(xvtx); if (idpart[i]==6) g7->Fill(xvtx); if ((tracks[i][4][3]-tracks[i][3][3])!=0) yslope[i] = (tracks[i][4][2]-tracks[i][3][2]) / (tracks[i][4][3]-tracks[i][3][3]); // if ((tracks[i][6][3]-tracks[i][3][3])!=0) yslope[i] = (tracks[i][6][2]-tracks[i][3][2]) / (tracks[i][6][3]-tracks[i][3][3]); yintercept[i] = tracks[i][3][2] - yslope[i] * tracks[i][3][3]; yvtx = -999.; if (yslope[i]!=0.) yvtx = -yintercept[i]/yslope[i]; // cout<Fill(yintercept[i]); if (idpart[i]==6) g4->Fill(yintercept[i]); if (idpart[i]==5) g6->Fill(yvtx); if (idpart[i]==6) g8->Fill(yvtx); if (goodtrk[1]==1 && goodtrk[2]==1) { g24->Fill(xintercept[1],xintercept[2]); g25->Fill(yintercept[1],yintercept[2]); g26->Fill(xintercept[1],yintercept[1]); g27->Fill(xintercept[2],yintercept[2]); } // radial quantities // use xseg as radial segmentation, yseg as phi if ((tracks[i][6][3]-tracks[i][3][3])!=0) { radius[1] = (tracks[i][3][1]**2 + tracks[i][3][2]**2)**0.5; radius[2] = (tracks[i][4][1]**2 + tracks[i][4][2]**2)**0.5; radius[3] = (tracks[i][5][1]**2 + tracks[i][5][2]**2)**0.5; radius[4] = (tracks[i][6][1]**2 + tracks[i][6][2]**2)**0.5; phidet[1] = atan(tracks[i][3][2]/tracks[i][3][1]); phidet[2] = atan(tracks[i][4][2]/tracks[i][4][1]); phidet[3] = atan(tracks[i][5][2]/tracks[i][5][1]); phidet[4] = atan(tracks[i][6][2]/tracks[i][6][1]); // integerize radius rstrip = (radius[1]/xseg + 0.5); radius[1] = xseg*rstrip; rstrip = (radius[2]/xseg + 0.5); radius[2] = xseg*rstrip; rstrip = (radius[3]/xseg + 0.5); radius[3] = xseg*rstrip; rstrip = (radius[4]/xseg + 0.5); radius[4] = xseg*rstrip; // integerize phi using arc length phistrip = (phidet[1]*radius[1]/yseg + 0.5); phidet[1] = yseg*phistrip/radius[1]; phistrip = (phidet[2]*radius[2]/yseg + 0.5); phidet[2] = yseg*phistrip/radius[2]; phistrip = (phidet[3]*radius[3]/yseg + 0.5); phidet[3] = yseg*phistrip/radius[3]; phistrip = (phidet[4]*radius[4]/yseg + 0.5); phidet[4] = yseg*phistrip/radius[4]; rslope[i] = (radius[4]-radius[1]) / (tracks[i][6][3]-tracks[i][3][3]); rintercept[i] = radius[1] - rslope[i] * tracks[i][3][3]; if (rslope[i]!=0.) rvtx = -rintercept[i]/rslope[i]; vtxslope = ((vertex[i][4]**2+vertex[i][5]**2)**0.5)/vertex[i][6]; rmatch = radius[1] - vtxslope*tracks[i][3][3]; // rmatch = rmatch + (radius[2] - vtxslope*tracks[i][6][3]); // cout<Fill(rintercept[i]); g20->Fill(rvtx); g21->Fill(rmatch); radvtx = ((vertex[i][1]**2+vertex[i][2]**2)**0.5); //xxx note vertex[][1,2,3] are not set g22->Fill(radvtx); //xxx note radvtx is not set properly g23->Fill(vertex[i][3]); //xxx note vertex[][3] is not set // fit the radial intercept // fity[0]=radius[1]; // fity[1]=radius[2]; // fity[2]=radius[3]; // fity[3]=radius[4]; // gr = new TGraphErrors(4,fitx,fity,ex,ey); // gr->Fit("pol1"); // TF1 *fit = gr->GetFunction("pol1"); // Double_t chi2 = fit->GetChisquare(); // Double_t p0 = fit->GetParameter(0); // Double_t e0 = fit->GetParError(0); // cout << "intercept fit " << p0 << " chi2 "<< chi2 << endl; // g28->Fill(p0); } // calculate track match from MuTr to last silicon plane xmatch = tracks[i][11][1] - (tracks[i][11][4]/tracks[i][11][6])*(tracks[i][11][3]-tracks[i][6][3]) - tracks[i][6][1]; ymatch = tracks[i][11][2] - (tracks[i][11][5]/tracks[i][11][5])*(tracks[i][11][3]-tracks[i][6][3]) - tracks[i][6][2]; pzmatch = tracks[i][6][6]-tracks[i][11][6]; g13->Fill(xmatch); g14->Fill(ymatch); g15->Fill(pzmatch); // calculate bend in phi, due to magnetic field and multiple scattering if (tracks[i][6][1]!=0. && tracks[i][3][1]!=0.) { deltaphi = phidet[4] - phidet[1]; deltaphi = deltaphi/degtorad; if (idpart[i]==5) g16->Fill(deltaphi); if (idpart[i]==6) g17->Fill(deltaphi); deltaphi=deltaphi*tracks[i][6][6]; g18->Fill(deltaphi); } } } // calculate Z-vertex and kinematics for good track pairs if (goodtrk[1]==1&&goodtrk[2]==1) { cout<<"good pair \nl" if ((xslope[2]-xslope[1])!=0) xpairvtx = -(xintercept[2]-xintercept[1])/(xslope[2]-xslope[1]); if ((yslope[2]-yslope[1])!=0) ypairvtx = -(yintercept[2]-yintercept[1])/(yslope[2]-yslope[1]); rpairvtx = -(rintercept[1]/rslope[1] + rintercept[2]/rslope[2]) / 2. ; rpairint = (rintercept[1] + rintercept[2]) / 2. ; pairvtx = (xpairvtx+ypairvtx)/2.; // pairpt = (tracks[1][3][4] + tracks[2][3][4])**2 + (tracks[1][3][5] + tracks[2][3][5])**2; pairpt = (xslope[1]*tracks[1][3][6] + xslope[2]*tracks[2][3][6])**2 + (yslope[1]*tracks[1][3][6] + yslope[2]*tracks[2][3][6])**2; pairpt = pairpt**0.5; pairmom = (pairpt**2 + (tracks[1][3][6] + tracks[2][3][6])**2)**0.5; // etot[1] = (0.10566**2 + tracks[1][3][4]**2 + tracks[1][3][5]**2 + tracks[1][3][6]**2)**0.5; // etot[2] = (0.10566**2 + tracks[2][3][4]**2 + tracks[2][3][5]**2 + tracks[2][3][6]**2)**0.5; etot[1] = (0.10566**2 + (xslope[1]*tracks[1][3][6])**2 + (yslope[1]*tracks[1][3][6])**2 + tracks[1][3][6]**2)**0.5; etot[2] = (0.10566**2 + (xslope[2]*tracks[2][3][6])**2 + (yslope[2]*tracks[2][3][6])**2 + tracks[2][3][6]**2)**0.5; pairmass = ((etot[1]+etot[2])**2 - pairmom**2)**0.5; g9->Fill(xpairvtx); g10->Fill(ypairvtx); g11->Fill(pairvtx); g12->Fill(pairmass); g29->Fill(rpairvtx); g30->Fill(rpairint); } } // done }