void pgsAnalysis::Loop() { double tHrec, tZ1m, tZ2m, tcosthetaStar, tPhi, tPhi1, tcostheta1, tcostheta2,tHrec_constr,tZ1m_constr, tZ2m_constr; string ttype; hists->Branch("Hrec", &tHrec); hists->Branch("Z1m", &tZ1m); hists->Branch("Z2m", &tZ2m); hists->Branch("costhetaStar", &tcosthetaStar); hists->Branch("Phi", &tPhi); hists->Branch("Phi1", &tPhi1); hists->Branch("costheta1", &tcostheta1); hists->Branch("costheta2", &tcostheta2); hists->Branch("type", &ttype); //event type!! int eeee, xxxx, eexx, xxee; double Zmass = 91.19; double vZmass; if (pairing == 0){ vZmass = 91.19; } else{ vZmass = 45.; } TVectorT<double> elSum(4); TVectorT<double> muSum(4); //electrons array vector<int> el; int elC = 0; //muons array vector<int> mu; int muC = 0; //antielectrons array vector<int> antiel; int antielC = 0; //antimuons array vector<int> antimu; int antimuC = 0; vector<TVector3> leptons; TVector3 lep1,lep2,lep3,lep4; TVector3 Za, Zb, Zc, Zd, H; int lCounter = 0; int totaLlCounter = 0; int goodEventCounter = 0; int histCounter = 0; if (fChain == 0) return; int nentries = n; // cout << " nentries are "<<nentries<<endl; Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; el.clear(); antiel.clear(); mu.clear(); antimu.clear(); lCounter = 0; eeee = 0; xxxx = 0; eexx = 0; xxee = 0; //particles identified by type, ntrk for (int inst = 0; inst < npart; inst++){ // inst from "instance" on the scan tree // cout<< " instance "<< inst <<endl; // cout<< pT[inst]<< endl; //fill el mu vectors if ( typ[inst] == 1 && ntrk[inst] == -1){ el.push_back(inst); elC++; lCounter++; totaLlCounter++; } if ( typ[inst] == 1 && ntrk[inst] == 1){ antiel.push_back(inst); antielC++; lCounter++; totaLlCounter++; } if ( typ[inst] == 2 && ntrk[inst] == -1){ mu.push_back(inst); muC++; lCounter++; totaLlCounter++; } if ( typ[inst] == 2 && ntrk[inst] == 1){ antimu.push_back(inst); antimuC++; lCounter++; totaLlCounter++; } if ( (typ[inst] == 4 && jmas[inst] > 10. )|| (typ[inst] == 6 && pT[inst] > 10. )){ lCounter = 0; //dont count the event } }//end instance loop (particles in an event // cout<< "leptons in the event are "<< lCounter<<endl; // if (lCounter == 4) { fillFlag = false; // If else if loops reconstructing the particles according to the type 4e,4mu, 2e2mu if (el.size() == 1 && mu.size() == 1 && antiel.size() == 1 && antimu.size() == 1){ //2e2m goodEventCounter++; lep1.SetPtEtaPhi( pT[el[0]], eta[el[0]] , phi[el[0]]); //set up of lepton four-vectors lep2.SetPtEtaPhi( pT[antiel[0]], eta[antiel[0]] , phi[antiel[0]]); lep3.SetPtEtaPhi( pT[mu[0]], eta[mu[0]] , phi[mu[0]]); lep4.SetPtEtaPhi( pT[antimu[0]], eta[antimu[0]] , phi[antimu[0]]); Za = lep1 + lep2; Zb = lep3 + lep4; mZ1 = sqrt(pow(lep1.Mag()+lep2.Mag(),2)-Za.Mag2()); // reconstruct z masses mZ2 = sqrt(pow(lep3.Mag()+lep4.Mag(),2)-Zb.Mag2()); //select leading Z if(mZ1 > mZ2) { Z1.SetVectM( Za, mZ1); Z2.SetVectM(Zb,mZ2); lep_min1.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus1.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag()); lep_min2.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus2.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag());eexx++;} //to set the highest mass the z else { Z2.SetVectM( Za, mZ1); Z1.SetVectM(Zb,mZ2); lep_min2.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus2.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag()); lep_min1.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus1.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag());xxee++;} fillFlag = true; } else if (el.size() == 2 && mu.size() == 0 && antiel.size() == 2 && antimu.size() == 0){ //4e goodEventCounter++; lep1.SetPtEtaPhi( pT[el[0]], eta[el[0]] , phi[el[0]]); lep2.SetPtEtaPhi( pT[antiel[0]], eta[antiel[0]] , phi[antiel[0]]); lep3.SetPtEtaPhi( pT[el[1]], eta[el[1]] , phi[el[1]]); lep4.SetPtEtaPhi( pT[antiel[1]], eta[antiel[1]] , phi[antiel[1]]); Za = lep1 + lep2; Zb = lep3 + lep4; Zc = lep1 + lep4; Zd = lep3 + lep2; double mZa = sqrt(pow(lep1.Mag()+lep2.Mag(),2)-Za.Mag2()); double mZb = sqrt(pow(lep3.Mag()+lep4.Mag(),2)-Zb.Mag2()); double mZc = sqrt(pow(lep1.Mag()+lep4.Mag(),2)-Zc.Mag2()); double mZd = sqrt(pow(lep2.Mag()+lep3.Mag(),2)-Zd.Mag2()); double s1a; double s1b; double s2a; double s2b; if ( pairing == 0){ s1a = pow(mZa-vZmass,2) + pow(mZb-Zmass,2); s1b = pow(mZa-Zmass,2) + pow(mZb-vZmass,2); s2a = pow(mZc-vZmass,2) + pow(mZd-Zmass,2); s2b = pow(mZc-Zmass,2) + pow(mZd-vZmass,2); } else{ s1a = fabs(mZb-Zmass); s1b = fabs(mZa-Zmass); s2a = fabs(mZd-Zmass); s2b = fabs(mZc-Zmass); } elSum[0] = s1a; elSum[1] = s1b; elSum[2] = s2a; elSum[3] = s2b; int min = TMath::LocMin(4, &elSum[0]); if( (min == 0 || min == 1) ){ if(mZa > mZb) { Z1.SetVectM( Za, mZa); Z2.SetVectM(Zb,mZb); lep_min1.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus1.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag()); lep_min2.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus2.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag());} //to set the highest mass the z else { Z2.SetVectM( Za, mZa); Z1.SetVectM(Zb,mZb); lep_min2.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus2.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag()); lep_min1.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus1.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag());} } else if( (min == 2 || min == 3) ){ if(mZc > mZd) { Z1.SetVectM( Zc, mZc); Z2.SetVectM(Zd,mZd); lep_min1.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus1.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag()); lep_min2.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus2.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag());} //to set the highest mass the z else { Z2.SetVectM( Zc, mZc); Z1.SetVectM(Zd,mZd); lep_min2.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus2.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag()); lep_min1.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus1.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag());} } eeee++; fillFlag = true; } else if(el.size() == 0 && mu.size() == 2 && antiel.size() == 0 && antimu.size() == 2 ) { //4m goodEventCounter++; lep1.SetPtEtaPhi( pT[mu[0]], eta[mu[0]] , phi[mu[0]]); lep2.SetPtEtaPhi( pT[antimu[0]], eta[antimu[0]] , phi[antimu[0]]); lep3.SetPtEtaPhi( pT[mu[1]], eta[mu[1]] , phi[mu[1]]); lep4.SetPtEtaPhi( pT[antimu[1]], eta[antimu[1]] , phi[antimu[1]]); Za = lep1 + lep2; Zb = lep3 + lep4; Zc = lep1 + lep4; Zd = lep3 + lep2; double mZa = sqrt(pow(lep1.Mag()+lep2.Mag(),2)-Za.Mag2()); double mZb = sqrt(pow(lep3.Mag()+lep4.Mag(),2)-Zb.Mag2()); double mZc = sqrt(pow(lep1.Mag()+lep4.Mag(),2)-Zc.Mag2()); double mZd = sqrt(pow(lep2.Mag()+lep3.Mag(),2)-Zd.Mag2()); double s1a; double s1b; double s2a; double s2b; if ( pairing == 0){ s1a = pow(mZa-vZmass,2) + pow(mZb-Zmass,2); s1b = pow(mZa-Zmass,2) + pow(mZb-vZmass,2); s2a = pow(mZc-vZmass,2) + pow(mZd-Zmass,2); s2b = pow(mZc-Zmass,2) + pow(mZd-vZmass,2); } else{ s1a = fabs(mZb-Zmass); s1b = fabs(mZa-Zmass); s2a = fabs(mZd-Zmass); s2b = fabs(mZc-Zmass); } muSum[0] = s1a; muSum[1] = s1b; muSum[2] = s2a; muSum[3] = s2b; int min = TMath::LocMin(4, &muSum[0]); if( (min == 0 || min == 1) ){ if(mZa > mZb) { Z1.SetVectM( Za, mZa); Z2.SetVectM(Zb,mZb); lep_min1.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus1.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag()); lep_min2.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus2.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag());} //to set the highest mass the z else { Z2.SetVectM( Za, mZa); Z1.SetVectM(Zb,mZb); lep_min2.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus2.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag()); lep_min1.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus1.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag());} } else if( (min == 2 || min == 3) ){ if(mZc > mZd) { Z1.SetVectM( Zc, mZc); Z2.SetVectM(Zd,mZd); lep_min1.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus1.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag()); lep_min2.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus2.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag());} //to set the highest mass the z else { Z2.SetVectM( Zc, mZc); Z1.SetVectM(Zd,mZd); lep_min2.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus2.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag()); lep_min1.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus1.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag());} } xxxx++; fillFlag = true; } if ( fillFlag == true && goodEventCounter < 25001) { //if it fullfills the specs then fill and find angles rec_H = Z1 + Z2; double Hmass = rec_H.M(); tHrec = Hmass; // cout<<tHrec<<endl; double Z1mass = Z1.M(); tZ1m = Z1mass; double Z2mass = Z2.M(); tZ2m = Z2mass; double ptlepp1 = lep_plus1.Pt(); double ptlepm1 = lep_min1.Pt(); double ptlepp2 = lep_plus2.Pt(); double ptlepm2 = lep_min2.Pt(); double dR1 = sqrt(pow(fabs(lep_min1.Eta() - lep_plus1.Eta()),2)+pow(fabs(lep_min1.DeltaPhi(lep_plus1)),2)); double dR2 = sqrt(pow(fabs(lep_min2.Eta() - lep_plus2.Eta()),2)+pow(fabs(lep_min2.DeltaPhi(lep_plus2)),2)); // if ( /*Hmass<120 || Hmass>130 || */Z1mass < 49 || Z1mass>107 || Z2mass < 12 || Z2mass> 115 ){continue;} //constrains //filling the simple histogram values h_Z1_m -> Fill(Z1.M()); h_Z1_E -> Fill(Z1.E()); h_Z1_Pt -> Fill(Z1.Pt()); h_Z1_eta -> Fill(Z1.Eta()); h_Z1_phi -> Fill(Z1.Phi()); h_Z2_m -> Fill(Z2.M()); h_Z2_E -> Fill(Z2.E()); h_Z2_Pt -> Fill(Z2.Pt()); h_Z2_eta -> Fill(Z2.Eta()); h_Z2_phi -> Fill(Z2.Phi()); h_rec_H_m -> Fill(Hmass); h_rec_H_E -> Fill(rec_H.E()); h_rec_H_Pt -> Fill(rec_H.Pt()); h_rec_H_eta -> Fill(rec_H.Eta()); h_rec_H_phi -> Fill(rec_H.Phi()); h_lep_plus1_E -> Fill(lep_plus1.E()); h_lep_plus1_Pt -> Fill(ptlepp1); h_lep_plus1_eta -> Fill(lep_plus1.Eta()); h_lep_plus1_phi -> Fill(lep_plus1.Phi()); h_lep_min1_E -> Fill(lep_min1.E()); h_lep_min1_Pt -> Fill(ptlepm1); h_lep_min1_eta -> Fill(lep_min1.Eta()); h_lep_min1_phi -> Fill(lep_min1.Phi()); h_lep_plus2_E -> Fill(lep_plus2.E()); h_lep_plus2_Pt -> Fill(ptlepp2); h_lep_plus2_eta -> Fill(lep_plus2.Eta()); h_lep_plus2_phi -> Fill(lep_plus2.Phi()); h_lep_min2_E -> Fill(lep_min2.E()); h_lep_min2_Pt -> Fill(ptlepm2); h_lep_min2_eta -> Fill(lep_min2.Eta()); h_lep_min2_phi -> Fill(lep_min2.Phi()); //reconstructing the two lepton pairs Lorentz vectors lpair1 = lep_plus1 + lep_min1; lpair2 = lep_plus2 + lep_min2; //constructing 3-vectors in the lab frame lep_plus1_lab = lep_plus1.Vect(); lep_plus2_lab = lep_plus2.Vect(); //.Vect() gives 3 vector from 4vector lep_min1_lab = lep_min1.Vect(); lep_min2_lab = lep_min2.Vect(); lpair1_lab = lep_plus1_lab.Cross(lep_min1_lab); lpair2_lab = lep_plus2_lab.Cross(lep_min2_lab); // cout << " pt of lepton pair1 on rest frame is: "<< lpair1.Perp()<<endl; //Filling up Histograms with angles defined in the lab frame h_angle_lab_pair1 -> Fill(lep_plus1_lab.Angle(lep_min1_lab)); h_angle_lab_pair2 -> Fill(lep_plus2_lab.Angle(lep_min2_lab)); //Filling up histograms with variables from articles h_angle_lab_deleta1 -> Fill(fabs(lep_min1.Eta() - lep_plus1.Eta())); h_angle_lab_delphi1 -> Fill(fabs(lep_min1.DeltaPhi(lep_plus1))); h_angle_lab_deleta2 -> Fill(fabs(lep_min2.Eta() - lep_plus2.Eta())); h_angle_lab_delphi2 -> Fill(fabs(lep_min2.DeltaPhi(lep_plus2))); //Looking at the Higgs rest frame TVector3 boost_rH = -rec_H.BoostVector(); //NOTE the minus sign! WHY - sign??? TVector3 boost_rZ1 = -Z1.BoostVector(); TVector3 boost_rZ2 = -Z2.BoostVector(); Higgs_rest = rec_H; Z1_rH = Z1; Z2_rH = Z2; lep_p1_rH = lep_plus1; // lep_m1_rH = lep_min1; lep_p2_rH = lep_plus2; lep_m2_rH = lep_min2; lep_p1_rZ1 = lep_plus1; lep_m2_rZ2 = lep_min2; lep_p2_rZ2 = lep_plus2; lep_m1_rZ1 = lep_min1; //Boosting vectors to the Higgs rest frame Higgs_rest.Boost(boost_rH); Z1_rH.Boost(boost_rH); Z2_rH.Boost(boost_rH); lep_p1_rH.Boost(boost_rH); lep_m1_rH.Boost(boost_rH); lep_p2_rH.Boost(boost_rH); lep_m2_rH.Boost(boost_rH); //Boosting leptons to Z rest frames lep_p1_rZ1.Boost(boost_rZ1); lep_m1_rZ1.Boost(boost_rZ1); lep_p2_rZ2.Boost(boost_rZ2); lep_m2_rZ2.Boost(boost_rZ2); //Setting 3Vectors in Higgs rest frame Z3_1_rH = Z1_rH.Vect(); Z3_2_rH = Z2_rH.Vect(); lep3_plus1_rH = lep_p1_rH.Vect(); lep3_min1_rH = lep_m1_rH.Vect(); lep3_plus2_rH = lep_p2_rH.Vect(); lep3_min2_rH = lep_m2_rH.Vect(); TVector3 Z3_1plane_rH = lep3_plus1_rH.Cross(lep3_min1_rH); //wrong? TVector3 Z3_2plane_rH = lep3_plus2_rH.Cross(lep3_min2_rH); //Setting 3Vectors in Z1/Z2 rest frame lep3_plus1_rZ1 = lep_p1_rZ1.Vect(); lep3_plus2_rZ2 = lep_p2_rZ2.Vect(); lep3_min1_rZ1 = lep_m1_rZ1.Vect(); lep3_min2_rZ2 = lep_m2_rZ2.Vect(); //Filling up histogram for the phi angle distribution //pairnoume ta monadiaia dianysmata twn kathetwn pediwn, prwta ypologizoume to metro tous, meta eswteriko ginomeno, meta tokso tou costheta tous double metro1 = sqrt((pow(Z3_1plane_rH.X(),2))+(pow(Z3_1plane_rH.Y(),2))+(pow(Z3_1plane_rH.Z(),2))); double metro2 = sqrt((pow(Z3_2plane_rH.X(),2))+(pow(Z3_2plane_rH.Y(),2))+(pow(Z3_2plane_rH.Z(),2))); TVector3 Z3_1plane_rH_un = Z3_1plane_rH.Unit(); TVector3 Z3_2plane_rH_un = Z3_2plane_rH.Unit(); TVector3 drtPlane = Z3_1plane_rH_un.Cross(Z3_2plane_rH_un); double phi = acos(-Z3_1plane_rH_un.Dot(Z3_2plane_rH_un))*(Z3_1_rH.Dot(skata))/fabs(Z3_1_rH.Dot(skata)); h_angle_rH_phi -> Fill( phi ); tPhi = phi; //****Phi one angle , same procedure as before. Now the plane is the first Z boson vector with beam axis, so they form a plane, phi1 is angle between this plane and the Z1 plane (apo to decay twn 2 leptoniwn) TVector3 niScatter_un = (beamAxis.Cross(Z3_1_rH)).Unit(); TVector3 drtPlane2 = Z3_1plane_rH_un.Cross(niScatter_un); double phiOne = acos(Z3_1plane_rH_un.Dot(niScatter_un))*(Z3_1_rH.Dot(skata2))/fabs(Z3_1_rH.Dot(skata2)); h_angle_rH_phiOne -> Fill( phiOne ); tPhi1 = phiOne; //Filling up histogram for theta* angle: Z1/Z2 with Higgs boost vector h_angle_rH_thetaZ2 -> Fill(Z3_2_rH.CosTheta()); double cosThetaStar = Z3_1_rH.CosTheta(); h_angle_rH_thetaZ1 -> Fill(cosThetaStar); tcosthetaStar = cosThetaStar; // boosting the z to the other z frame TLorentzVector Z_1_rZ2 = Z1; Z_1_rZ2.Boost(boost_rZ2); TVector3 Z3_1_rZ2 = Z_1_rZ2.Vect(); TLorentzVector Z_2_rZ1 = Z2; Z_2_rZ1.Boost(boost_rZ1); TVector3 Z3_2_rZ1 = Z_2_rZ1.Vect(); double cosTheta1 = cos(lep3_min1_rZ1.Angle(-Z3_2_rZ1)); double cosTheta2 = cos(lep3_min2_rZ2.Angle(-Z3_1_rZ2)); h_angle_rZ1_lp1Z1 -> Fill(cos(lep3_plus1_rZ1.Angle(-Z3_2_rZ1))); h_angle_rZ1_lm1Z1 -> Fill(cosTheta1); // theta1 h_angle_rZ2_lp2Z2 -> Fill(cos(lep3_plus2_rZ2.Angle(-Z3_1_rZ2))); h_angle_rZ2_lm2Z2 -> Fill(cosTheta2); // theta2 tcostheta1 = cosTheta1; tcostheta2 = cosTheta2; h_angle_rH_delphi1 -> Fill(fabs(lep_p1_rH.DeltaPhi(lep_m1_rH))); h_angle_rH_delphi2 -> Fill(fabs(lep_p2_rH.DeltaPhi(lep_m2_rH))); h_mZ1mZ2 -> Fill(Z1.M(),Z2.M()); h_mVsPtZ1 -> Fill(Z1.M(),Z1.Pt()); h_delphi1VsPtZ1_lab -> Fill(Z1.Pt(),fabs(lep_min1.DeltaPhi(lep_plus1))); h_delphi2VsPtZ2_lab -> Fill(Z2.Pt(),fabs(lep_min2.DeltaPhi(lep_plus2))); if (eexx ==1){ttype = "eexx";} else if(xxee ==1){ttype = "xxee";} else if(eeee ==1){ttype = "eeee";} else if(xxxx ==1){ttype = "xxxx";} hists->Fill(); histCounter++; hists->Close(); } //end if fill ////////////// fill out the decay type // filling the TTree }//end entries loop (events) //some regular reports cout<<endl; cout<<" good events are "<<goodEventCounter<<endl; cout<<" we see % "<< (double) goodEventCounter/n <<endl; cout<<endl; cout<<" histogram fills are "<<histCounter<<endl; // cout<<" we see % "<< (double) goodEventCounter/n <<endl; }//end loop void
void compare_wls1(TString filename="../p15m_nwls/wcsim.root",TString histoname="p15m_nwls", Int_t *flag, TString rootfile = "temp.root") { TFile *file1; if (*flag!=0) { //file1 = new TFile(rootfile,"Update"); file1 = new TFile(rootfile,"RECREATE"); } else { file1 = new TFile(rootfile,"RECREATE"); } TString filename1; filename1 = histoname + "_digi"; TTree *T = new TTree(filename1,filename1); T->SetDirectory(file1); Double_t diginpe,digitime,cor_digitime,digitheta,dis_digihit; Int_t neve; Double_t mom; Double_t pos_x,pos_y,pos_z; Double_t dir_x,dir_y,dir_z; Double_t tube_x,tube_y,tube_z; Double_t totankdis; Double_t vertex[3],dir[3]; Double_t tube_pos[3]; T->Branch("digi_eve",&neve,"data/I"); T->Branch("diginpe",&diginpe,"data/D"); T->Branch("digitime",&digitime,"data/D"); T->Branch("cor_digitime",&cor_digitime,"data/D"); T->Branch("digitheta",&digitheta,"data/D"); T->Branch("dis_dighit",&dis_digihit,"data/D"); T->Branch("mom",&mom,"data/D"); T->Branch("totankdis",&totankdis,"data/D"); T->Branch("pos_x",&vertex[0],"data/D"); T->Branch("pos_y",&vertex[1],"data/D"); T->Branch("pos_z",&vertex[2],"data/D"); T->Branch("dir_x",&dir[0],"data/D"); T->Branch("dir_y",&dir[1],"data/D"); T->Branch("dir_z",&dir[2],"data/D"); T->Branch("tube_x",&tube_pos[0],"data/D"); T->Branch("tube_y",&tube_pos[1],"data/D"); T->Branch("tube_z",&tube_pos[2],"data/D"); filename1 = histoname + "_hit"; TTree *t1 = new TTree(filename1,filename1); t1->SetDirectory(file1); Double_t wavelength, truetime, corr_time,theta,distance,index; Int_t qe_flag,parentid,tubeid,totalpe; Int_t ntracks; t1->Branch("ntracks",&ntracks,"data/I"); t1->Branch("neve",&neve,"data/I"); t1->Branch("wavelength",&wavelength,"data/D"); t1->Branch("truetime",&truetime,"data/D"); t1->Branch("corr_time",&corr_time,"data/D"); t1->Branch("theta",&theta,"data/D"); t1->Branch("distance",&distance,"data/D"); t1->Branch("index",&index,"data/D"); t1->Branch("mom",&mom,"data/D"); t1->Branch("totankdis",&totankdis,"data/D"); t1->Branch("pos_x",&vertex[0],"data/D"); t1->Branch("pos_y",&vertex[1],"data/D"); t1->Branch("pos_z",&vertex[2],"data/D"); t1->Branch("dir_x",&dir[0],"data/D"); t1->Branch("dir_y",&dir[1],"data/D"); t1->Branch("dir_z",&dir[2],"data/D"); t1->Branch("tube_x",&tube_pos[0],"data/D"); t1->Branch("tube_y",&tube_pos[1],"data/D"); t1->Branch("tube_z",&tube_pos[2],"data/D"); // t1->Branch("pos_x",&pos_x,"data/D"); // t1->Branch("pos_y",&pos_y,"data/D"); // t1->Branch("pos_z",&pos_z,"data/D"); // t1->Branch("dir_x",&dir_x,"data/D"); // t1->Branch("dir_y",&dir_y,"data/D"); // t1->Branch("dir_z",&dir_z,"data/D"); // t1->Branch("tube_x",&tube_x,"data/D"); // t1->Branch("tube_y",&tube_y,"data/D"); // t1->Branch("tube_z",&tube_z,"data/D"); t1->Branch("qe_flag",&qe_flag,"data/I"); t1->Branch("parentid",&parentid,"data/I"); t1->Branch("tubeid",&tubeid,"data/I"); t1->Branch("totalpe",&totalpe,"data/I"); TFile *file = new TFile(filename); TTree *wcsimT = file->Get("wcsimT"); WCSimRootEvent *wcsimrootsuperevent = new WCSimRootEvent(); wcsimT->SetBranchAddress("wcsimrootevent",&wcsimrootsuperevent); wcsimT->GetBranch("wcsimrootevent")->SetAutoDelete(kTRUE); TTree *gtree = file->Get("wcsimGeoT"); WCSimRootGeom *wcsimrootgeom = new WCSimRootGeom(); gbranch = gtree->GetBranch("wcsimrootgeom"); gbranch->SetAddress(&wcsimrootgeom); gtree->GetEntry(0); WCSimRootPMT *pmt; Double_t pmt_pos[500000][3]; for (Int_t i=0; i!=wcsimrootgeom->GetWCNumPMT(); i++) { pmt_pos[i][0] = (wcsimrootgeom->GetPMT(i)).GetPosition(0); pmt_pos[i][1] = (wcsimrootgeom->GetPMT(i)).GetPosition(1); pmt_pos[i][2] = (wcsimrootgeom->GetPMT(i)).GetPosition(2); } //in terms of wavelength (total NPE) real hit filename1 = histoname + "_total_wl"; TH1F *hqx = new TH1F(filename1,filename1,600,200,800); //NPE in each event sum over digi hit filename1 = histoname + "_total_npe"; TH1F *hqx2 = new TH1F(filename1,filename1,1000,0.,10000); //digitized hit time filename1 = histoname + "_digitime"; TH1F *hqx1 = new TH1F(filename1,filename1,500,900,1400); //corrected digitized hit time filename1 = histoname + "_cor_digitime"; TH1F *hqx4 = new TH1F(filename1,filename1,1000,400,1400); //digitized hit angle filename1 = histoname + "_digitheta"; TH1F *hqx5 = new TH1F(filename1,filename1,180,0,180); //TH2F *h1 = new TH2F("h1","h1",100,1000,20000,100,90000,140000); Double_t index = 1.333; neve = *flag; cout << histoname << "\t" << wcsimT->GetEntries() << endl; for (Int_t j=0; j!=wcsimT->GetEntries(); j++) { //for (Int_t j=0;j!=90;j++){ // cout << j << endl; wcsimT->GetEvent(j); neve ++; WCSimRootTrigger *wcsimrootevent = wcsimrootsuperevent->GetTrigger(0); temp = (TClonesArray*)wcsimrootevent->GetTracks(); Int_t ntrack = wcsimrootevent->GetNtrack(); //cout << ntrack << endl; ntracks = ntrack; mom = ((WCSimRootTrack*)temp->At(ntrack-1))->GetP(); //get the vertex information vertex[0] = ((WCSimRootTrack*)temp->At(ntrack-1))->GetStart(0); vertex[1] = ((WCSimRootTrack*)temp->At(ntrack-1))->GetStart(1); vertex[2] = ((WCSimRootTrack*)temp->At(ntrack-1))->GetStart(2); //get position information dir[0] = ((WCSimRootTrack*)temp->At(ntrack-1))->GetDir(0); dir[1] = ((WCSimRootTrack*)temp->At(ntrack-1))->GetDir(1); dir[2] = ((WCSimRootTrack*)temp->At(ntrack-1))->GetDir(2); totankdis=ToTankDistance(vertex,dir); TVector3 vertex3(vertex[0],vertex[1],vertex[2]); TVector3 dir3(dir[0],dir[1],dir[2]); //loop through digi hit int max = wcsimrootevent->GetNcherenkovdigihits(); double sum = 0; for (int i=0; i<max; i++) { // cout << max << "\t" << i << endl; WCSimRootCherenkovDigiHit *cDigiHit = ((WCSimRootCherenkovDigiHit*)wcsimrootevent->GetCherenkovDigiHits()->At(i)); hqx1->Fill(cDigiHit->GetT()); tube_pos[0] = pmt_pos[(cDigiHit->GetTubeId()-1)][0]; tube_pos[1] = pmt_pos[(cDigiHit->GetTubeId()-1)][1]; tube_pos[2] = pmt_pos[(cDigiHit->GetTubeId()-1)][2]; TVector3 hit3(tube_pos[0],tube_pos[1],tube_pos[2]); TVector3 dis = hit3-vertex3; diginpe = cDigiHit->GetQ(); digitime = cDigiHit->GetT(); cor_digitime = digitime-dis.Mag()/299792458.*1.333*1.e7; digitheta = dis.Angle(dir3)/3.1415926*180.; dis_digihit = dis.Mag(); hqx4->Fill(cor_digitime,diginpe); hqx5->Fill(digitheta,diginpe); sum += diginpe; T->Fill(); } hqx2->Fill(sum); //loop through real hit //loop through PMT hit first max = wcsimrootevent-> GetNcherenkovhits(); //cout << max << endl; if (max ==0) { t1->Fill(); } for (int i=0; i<max; i++) { WCSimRootCherenkovHit* wcsimrootcherenkovhit = dynamic_cast<WCSimRootCherenkovHit*>((wcsimrootevent->GetCherenkovHits())->At(i)); totalpe = wcsimrootcherenkovhit->GetTotalPe(1); tubeid = wcsimrootcherenkovhit->GetTubeID() ; //loop through hit time etc for (int k=0; k<totalpe; k++) { TObject *element2 = (wcsimrootevent->GetCherenkovHitTimes())-> At(wcsimrootcherenkovhit->GetTotalPe(0)+k); WCSimRootCherenkovHitTime *wcsimrootcherenkovhittime = dynamic_cast<WCSimRootCherenkovHitTime*>(element2); wavelength =wcsimrootcherenkovhittime->GetWavelength(); qe_flag = wcsimrootcherenkovhittime->GetQe_flag(); truetime = wcsimrootcherenkovhittime->GetTruetime(); parentid = wcsimrootcherenkovhittime->GetParentID(); pos_x = wcsimrootcherenkovhittime->GetPosX() ; pos_y = wcsimrootcherenkovhittime->GetPosY() ; pos_z = wcsimrootcherenkovhittime->GetPosZ() ; dir_x = wcsimrootcherenkovhittime->GetDirX() ; dir_y = wcsimrootcherenkovhittime->GetDirY() ; dir_z = wcsimrootcherenkovhittime->GetDirZ() ; tube_pos[0] = pmt_pos[tubeid-1][0]; tube_pos[1] = pmt_pos[tubeid-1][1]; tube_pos[2] = pmt_pos[tubeid-1][2]; tube_x = tube_pos[0]; tube_y = tube_pos[1]; tube_z = tube_pos[2]; TVector3 hit3(tube_pos[0],tube_pos[1],tube_pos[2]); TVector3 dis = hit3-vertex3; distance = dis.Mag(); theta = dis.Angle(dir3)/3.1415926*180.; //index = index(wavelength); index = 1.34; corr_time = truetime - distance/299792458.*1e7*index; if (qe_flag==1) { hqx->Fill(wavelength); } t1->Fill(); } } } if (flag==1) { hqx->SetDirectory(file1); hqx2->SetDirectory(file1); hqx1->SetDirectory(file1); hqx4->SetDirectory(file1); hqx5->SetDirectory(file1); file1->Write(); file1->Close(); } else { hqx->SetDirectory(file1); hqx2->SetDirectory(file1); hqx1->SetDirectory(file1); hqx4->SetDirectory(file1); hqx5->SetDirectory(file1); file1->Write(); file1->Close(); } *flag = neve; }
void gravitonPythia(){ gStyle->SetOptStat(0); TreeReader data("pythia8_RS_WW.root"); TH1F* h_cosTh = new TH1F("h_cosTh","RS Graviton by Pythia8",100,-1,1); h_cosTh->SetMinimum(0); h_cosTh->Sumw2(); TH1F *h_cosThStar = (TH1F*)h_cosTh->Clone("h_cosThStar"); for(Long64_t ev = 0 ; ev < data.GetEntriesFast(); ev++){ data.GetEntry(ev); Int_t nGenPar = data.GetInt("nGenPar"); Int_t* genParId = data.GetPtrInt("genParId"); Int_t* genParSt = data.GetPtrInt("genParSt"); Float_t* genParPt = data.GetPtrFloat("genParPt"); Float_t* genParEta = data.GetPtrFloat("genParEta"); Float_t* genParPhi = data.GetPtrFloat("genParPhi"); Float_t* genParM = data.GetPtrFloat("genParM"); // cos#theta_1 in the W rest frame Int_t chgLepID = -1; Int_t neuLepID = -1; TLorentzVector chgLep(0,0,0,0); TLorentzVector neuLep(0,0,0,0); for(Int_t i = 0; i < nGenPar; i++){ if( genParSt[i] != 23 ) continue; if( abs(genParId[i]) == 11 || abs(genParId[i]) == 13 || abs(genParId[i]) == 15 ) chgLepID = i; if( abs(genParId[i]) == 12 || abs(genParId[i]) == 14 || abs(genParId[i]) == 16 ) neuLepID = i; } chgLep.SetPtEtaPhiM(genParPt[chgLepID], genParEta[chgLepID], genParPhi[chgLepID], genParM[chgLepID]); neuLep.SetPtEtaPhiM(genParPt[neuLepID], genParEta[neuLepID], genParPhi[neuLepID], genParM[neuLepID]); TLorentzVector Wb = chgLep + neuLep; TVector3 WbP = Wb.Vect(); TVector3 bv = -Wb.BoostVector(); chgLep.Boost(bv); TVector3 chgLepP = chgLep.Vect(); Double_t cosTh = TMath::Cos(chgLepP.Angle(WbP)); h_cosTh->Fill(cosTh); // cos#theta* in the RSG rest frame Int_t WplusID = -1; Int_t WminusID = -1; TLorentzVector Wplus(0,0,0,0); TLorentzVector Wminus(0,0,0,0); for(Int_t i = 0; i < nGenPar; i++){ if( genParSt[i] != 22 ) continue; if( genParId[i] == +24 ) WplusID = i; if( genParId[i] == -24 ) WminusID = i; } Wplus.SetPtEtaPhiM(genParPt[WplusID], genParEta[WplusID], genParPhi[WplusID], genParM[WplusID]); Wplus.SetPtEtaPhiM(genParPt[WminusID], genParEta[WminusID], genParPhi[WminusID], genParM[WminusID]); TLorentzVector RSG = Wplus + Wminus; TVector3 RSGP = RSG.Vect(); TVector3 gv = -RSG.BoostVector(); Wplus.Boost(gv); TVector3 WplusP = Wplus.Vect(); Double_t cosThStar = TMath::Cos(WplusP.Angle(RSGP)); h_cosThStar->Fill(cosThStar); } TCanvas* c[2]; c[0] = new TCanvas("c0","",0,0,800,600); c[1] = new TCanvas("c1","",0,0,800,600); c[0]->cd(); h_cosTh->SetXTitle("cos#theta_1 in the W rest frame"); h_cosTh->Draw(); c[1]->cd(); h_cosThStar->SetXTitle("cos#theta* in the RSG rest frame"); h_cosThStar->Draw(); c[0]->Print("RSgravitonPythia.pdf("); c[1]->Print("RSgravitonPythia.pdf)"); }
//! main program int main (int argc, char** argv) { std::string outputRootName = "matchDistance.root" ; std::string fileName (argv[1]) ; boost::shared_ptr<edm::ProcessDesc> processDesc = edm::readConfigFile (fileName) ; boost::shared_ptr<edm::ParameterSet> parameterSet = processDesc->getProcessPSet () ; std::cout << parameterSet->dump () << std::endl ; //PG for testing edm::ParameterSet subPSetSelections = parameterSet->getParameter<edm::ParameterSet> ("selections") ; //cuts on SC Energy double EnergyMaxSC = subPSetSelections.getParameter<double> ("EnergyMaxSC") ; double EnergyMinSC = subPSetSelections.getParameter<double> ("EnergyMinSC") ; //cuts on Angle Muon / SCdirection double angleMAX = subPSetSelections.getParameter<double> ("angleMAX") ; double angleMIN = subPSetSelections.getParameter<double> ("angleMIN") ; //cuts on Xtal Energy double XtalMaxEnergyMin = subPSetSelections.getParameter<double> ("XtalMaxEnergyMin") ; double XtalMaxEnergyMax = subPSetSelections.getParameter<double> ("XtalMaxEnergyMax") ; double XtalMinEnergy = subPSetSelections.getParameter<double> ("XtalMinEnergy") ; //cuts on Windows double phiWINDOW = subPSetSelections.getParameter<double> ("phiWINDOW") ; double ietaMAX = subPSetSelections.getUntrackedParameter<int> ("ietaMAX",85) ; edm::ParameterSet subPSetInput = parameterSet->getParameter<edm::ParameterSet> ("inputNtuples") ; std::vector<std::string> inputFiles = subPSetInput.getParameter<std::vector<std::string> > ("inputFiles") ; std::cout << "reading : " ; TChain *chain = new TChain ("EcalCosmicsAnalysis") ; EcalCosmicsTreeContent treeVars ; setBranchAddresses (chain, treeVars) ; for (std::vector<std::string>::const_iterator listIt = inputFiles.begin () ; listIt != inputFiles.end () ; ++listIt) { std::cout << *listIt << " " << std::endl ; chain->Add (listIt->c_str ()) ; } TProfile2D aveEoxMap ("aveEoxMap","aveEoxMap",360,1.,361.,172,-86.,86.); int nEntries = chain->GetEntries () ; std::cout << "FOUND " << nEntries << " ENTRIES\n" ; //PG loop over entries for (int entry = 0 ; entry < nEntries ; ++entry) { chain->GetEntry (entry) ; if (entry % 100000 == 0) std::cout << "reading entry " << entry << std::endl ; std::vector<ect::association> associations ; ect::fillAssocVector (associations, treeVars) ; ect::selectOnDR (associations, treeVars, 0.3) ; //PG loop on associations vector for (unsigned int i = 0 ; i < associations.size () ; ++i) { int MUindex = associations.at (i).first ; int SCindex = associations.at (i).second ; TVector3 SC0_pos (treeVars.superClusterX[SCindex], treeVars.superClusterY[SCindex], treeVars.superClusterZ[SCindex]) ; TVector3 MuonDir (treeVars.muonPx[MUindex], treeVars.muonPy[MUindex], treeVars.muonPz[MUindex]) ; float dummyEmax = 0.; float dummyLmax = 0.; int numCrystalEMax = -1; int numCrystalLMax = -1; bool SclOk = false; double dummyLength = 0; for (int XTLindex = treeVars.xtalIndexInSuperCluster[SCindex] ; XTLindex < treeVars.xtalIndexInSuperCluster[SCindex] + treeVars.nXtalsInSuperCluster[SCindex] ; ++XTLindex) { if(treeVars.xtalTkLength[XTLindex] == -1) continue; dummyLength+= treeVars.xtalTkLength[XTLindex]; //---- check the link Xtal with max energy == Xtal with max length ---- if (treeVars.xtalEnergy[XTLindex] > dummyEmax) numCrystalEMax = XTLindex; if(treeVars.xtalTkLength[XTLindex] > dummyLmax) numCrystalLMax = XTLindex; } // if( abs(treeVars.muonTkLengthInEcalDetail[associations.at(i).first] - dummyLength) > 0.5) continue; if ( (numCrystalEMax != numCrystalLMax) && (numCrystalEMax != -1) && (numCrystalLMax != -1)) { if ( 3.*treeVars.xtalEnergy[numCrystalLMax] < treeVars.xtalTkLength[numCrystalLMax] * 0.0125) SclOk = false; } else SclOk = true; if ((numCrystalEMax == -1) || (numCrystalLMax == -1)) SclOk = false; if(SclOk == false) continue; double SCphi = fabs(SC0_pos.Phi()) / 3.1415 * 180. ; if ( (SCphi < 90. - phiWINDOW/2) || (SCphi > 90. + phiWINDOW/2) ) continue; double SCieta = SC0_pos.Eta () / 0.0175 ; if (fabs (SCieta) > ietaMAX) continue ; double angle = MuonDir.Angle ( SC0_pos ) ; if( angle > 3.1415/2. ) angle = 3.1415 - angle; // angle belongs to [0:90] if ((angle < angleMIN) || (angle >= angleMAX)) continue ; if ((treeVars.superClusterRawEnergy[SCindex] >= EnergyMaxSC) || (treeVars.superClusterRawEnergy[SCindex] < EnergyMinSC)) continue ; std::pair <int,int> maxima = findMaxXtalsInSC (treeVars, SCindex) ; double XtalEnergyMax = treeVars.xtalEnergy[maxima.first] ; if ((XtalEnergyMax < XtalMaxEnergyMin) || (XtalEnergyMax >= XtalMaxEnergyMax)) continue ; //loop su cristalli di Supercluster Associato for (int XTLindex = treeVars.xtalIndexInSuperCluster[SCindex] ; XTLindex < treeVars.xtalIndexInSuperCluster[SCindex] + treeVars.nXtalsInSuperCluster[SCindex] ; ++XTLindex) { if (treeVars.xtalEnergy[XTLindex] < XtalMinEnergy) continue ; if (treeVars.xtalTkLength[XTLindex] <= 0.) continue ; double eox = treeVars.xtalEnergy[XTLindex] / treeVars.xtalTkLength[XTLindex] ; EBDetId dummy = EBDetId::unhashIndex (treeVars.xtalHashedIndex[XTLindex]) ; aveEoxMap.Fill (dummy.iphi (), dummy.ieta (), eox) ; } } } //PG loop over entries TH1F aveEoxDistr ("aveEoxDistr","aveEoxDistr",500,0,0.5) ; for (int phiIndex = 1 ; phiIndex < 361 ; ++phiIndex) for (int etaIndex = 1 ; etaIndex < 173 ; ++etaIndex) aveEoxDistr.Fill (aveEoxMap.GetBinContent (phiIndex,etaIndex)) ; TFile saving ("singleXtalEox.root","recreate") ; saving.cd () ; aveEoxMap.Write () ; aveEoxDistr.Write () ; saving.Close () ; return 0 ; }
void npol::Loop() { if (fChain == 0) return; TVector3 CalculateScatVec(TVector3 income,TVector3 ScatLab); //think this is wrong TVector3 zprime; TVector3 yprime; TVector3 xprime; TVector3 income; TVector3 xlab(1,0,0); TVector3 ylab(0,1,0); TVector3 zlab(0,0,1); TVector3 ScatP; TVector3 ScatN; Double_t Nmomentum; Double_t RotM[3][3]; Long64_t nentries = fChain->GetEntriesFast(); //File to write to TFile* file0 = TFile::Open("./output/ForReport.root","RECREATE"); TTree* tree0 = new TTree("All","tree title"); Double_t PSFrameAngleThetaDeg; Double_t PSFrameAnglePhiDeg; Double_t NSFrameAngleThetaDeg; Double_t NSFrameAnglePhiDeg; //Branches to be saved to the tree primes will be same everytime due to function so remove not true see position of loop. TBranch *branchZP = tree0->Branch("ZPrime.", &zprime,8000,0); TBranch *branchYP = tree0->Branch("YPrime.", &yprime,8000,0); TBranch *branchXP = tree0->Branch("XPrime.", &xprime,8000,0); TBranch *branchSPATD = tree0->Branch("PSFrameAngleThetaDeg", &PSFrameAngleThetaDeg,"PSFrameAngleThetaDeg/D"); TBranch *branchSPAPD = tree0->Branch("PSFrameAnglePhiDeg", &PSFrameAnglePhiDeg,"PSFrameAnglePhiDeg/D"); TBranch *branchOP = tree0->Branch("ScatP", &ScatP,8000,0); TBranch *branchSNATD = tree0->Branch("NSFrameAngleThetaDeg", &NSFrameAngleThetaDeg,"NSFrameAngleThetaDeg/D"); TBranch *branchSNAPD = tree0->Branch("NSFrameAnglePhiDeg", &NSFrameAnglePhiDeg,"NSFrameAnglePhiDeg/D"); TBranch *branchON = tree0->Branch("ScatN", &ScatN,8000,0); Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; //Getting the lab vectors income = Inc->Vect(); ScatP = SP->Vect(); ScatN = SN->Vect(); TVector3 ProtonSFrame = CalculateScatVec(income,ScatP); TVector3 NeutronSFrame = CalculateScatVec(income,ScatN); // Getting the momentum of the neutron Nmomentum = SN->Rho(); // Nenergy = Sn->(Energy); PSFrameAngleThetaDeg = ProtonSFrame.Angle(zprime)*TMath::RadToDeg(); PSFrameAnglePhiDeg = ProtonSFrame.Angle(xprime)*TMath::RadToDeg(); NSFrameAngleThetaDeg = NeutronSFrame.Angle(zprime)*TMath::RadToDeg(); NSFrameAnglePhiDeg = NeutronSFrame.Angle(xprime)*TMath::RadToDeg(); std::cout << zprime(0) << " " << zprime(1) << " " << zprime(2) <<" Z" <<std::endl; std::cout << yprime(0) << " " << yprime(1) << " " << yprime(2) <<" Y" << std::endl; std::cout << xprime(0) << " " << xprime(1) << " " << xprime(2) <<" X" <<std::endl; std::cout << zprime.Angle(xprime) << " " << zprime.Angle(yprime) <<" YX " << yprime.Angle(xprime)*TMath::RadToDeg() << std::endl; if (Nmomentum > 0){ tree0->Fill(); } }//end of entries loop tree0->Write(); file0->Close(); }//end of npol::Loop()