コード例 #1
0
ファイル: ADDON3_LAC.C プロジェクト: dertexaner/LQ3
// // //
double analysisClass::METlepDeltaPhi(TString Lep, int iLep){
  TLorentzVector lep;
  lep.SetPtEtaPhiM( 0, 0, 0, 0 );
  TLorentzVector met;
  met.SetPtEtaPhiM( METcorr("Pt"), 0, METcorr("Phi"), 0 );
  //std::cout<< "analysisClass::METlepDeltaPhi  iLep: "<<iLep<<std::endl;
  //
  if( Lep != "Mu" && Lep != "Tau" ){ cout<<" WRONG LEPTON TYPE SPECIFIED!! analysisClass::METlepDeltaPhi(TString Lep, int iLep) "<<endl; return 0; }
  //
  if( iLep>-1 ){
    if( Lep=="Mu" ) lep.SetPtEtaPhiM( muPtcorr(iLep), MuonEta->at(iLep), MuonPhi->at(iLep), 0 );
    if( Lep=="Tau") lep.SetPtEtaPhiM( tauPtcorr(iLep), HPSTauEta->at(iLep), HPSTauPhi->at(iLep), 0 );
  }
  //
  if( iLep==-1 ){
    if( Lep=="Mu"){
      for(unsigned int iMuR=0;  iMuR<MuonPt->size();     iMuR++){
	if(!muRisoCheck(iMuR))continue;
	if( lep.Pt()<muPtcorr(iMuR)     ) lep.SetPtEtaPhiM( muPtcorr(iMuR), MuonEta->at(iMuR), MuonPhi->at(iMuR), 0 );
      }
    }
    //------ ------
    if( Lep=="Tau"){
      for(unsigned int iTauR=0; iTauR<HPSTauPt->size(); iTauR++){
	if(!tauRisoCheck(iTauR))continue;
	if( lep.Pt()<tauPtcorr(iTauR)  ) lep.SetPtEtaPhiM( tauPtcorr(iTauR), HPSTauEta->at(iTauR), HPSTauPhi->at(iTauR), 0 );
      }
    }
  }
  //
  return fabs(met.DeltaPhi(lep));
}
コード例 #2
0
// This is the pt corrected delta phi between the 2 leptons
// P and L2 are the 4-vectors for the 2 hemispheres, or in you case,
// the two leptons - setting mass to 0 should be fine
// MET is the MET 3 vector (don't forget to set the z-component of
// MET to 0)
// This function will do the correct Lorentz transformations of the 
// leptons for you
double HWWKinematics::CalcDeltaPhiRFRAME(){
  // first calculate pt-corrected MR
  float mymrnew = CalcMRNEW();
  
  // Now, boost lepton system to rest in z
  // (approximate accounting for longitudinal boost)
  TVector3 BL = L1.Vect()+L2.Vect();
  BL.SetX(0.0);
  BL.SetY(0.0);
  BL = (1./(L1.P()+L2.P()))*BL;
  L1.Boost(-BL);
  L2.Boost(-BL);
  
  // Next, calculate the transverse Lorentz transformation
  // to go to Higgs approximate rest frame
  TVector3 B = L1.Vect()+L2.Vect()+MET;
  B.SetZ(0.0);
  B = (-1./(sqrt(4.*mymrnew*mymrnew+B.Dot(B))))*B;
  
  L1.Boost(B);
  L2.Boost(B);
  
  //Now, re-calculate the delta phi
  // in the new reference frame:
  return L1.DeltaPhi(L2);
  
}
コード例 #3
0
ファイル: SUSYLooperHists.C プロジェクト: mstoye/loopCode
double SUSYLooperHists::DiTau_InvMass( TLorentzVector Met, TLorentzVector L1, TLorentzVector L2, float Al ){   
  TLorentzVector T1,T2;
  double DiTauMass; 
  TMatrixF A(2,2); 
  TVectorF C(2),X(2); 
  A(0,0)=L1.Px();
  A(0,1)=L2.Px();
  A(1,0)=L1.Py();
  A(1,1)=L2.Py();
  A=A.Invert();
  C(0)=(Met+L1+L2).Px();
  C(1)=(Met+L1+L2).Py();
  X=A*C;// double X0i=X(0), X1i=X(1);
  //---------------[ MET ReAlignement subsection ]------------------------------
  if(X(0)<0||X(1)<0){ 
    if     ( fabs(L1.DeltaPhi(Met))>Al && fabs(L2.DeltaPhi(Met))>Al                                                  ) {/*DO NOTHING just normaly a non-Z event!*/}
    else if( fabs(L1.DeltaPhi(Met))<Al && fabs(L2.DeltaPhi(Met))>Al                                                  ) Met.SetPtEtaPhiM(Met.Pt(),0,L1.Phi(),0);
    else if( fabs(L2.DeltaPhi(Met))<Al && fabs(L1.DeltaPhi(Met))>Al                                                  ) Met.SetPtEtaPhiM(Met.Pt(),0,L2.Phi(),0);
    else if( fabs(L1.DeltaPhi(Met))<Al && fabs(L2.DeltaPhi(Met))<Al && fabs(L1.DeltaPhi(Met))<fabs(L2.DeltaPhi(Met)) ) Met.SetPtEtaPhiM(Met.Pt(),0,L1.Phi(),0);
    else if( fabs(L1.DeltaPhi(Met))<Al && fabs(L2.DeltaPhi(Met))<Al && fabs(L1.DeltaPhi(Met))>fabs(L2.DeltaPhi(Met)) ) Met.SetPtEtaPhiM(Met.Pt(),0,L2.Phi(),0);
  }//---------------------------------------------------------------------------
  C(0)=(Met+L1+L2).Px(); C(1)=(Met+L1+L2).Py(); X=A*C;
  T1.SetPxPyPzE( L1.Px()*X(0), L1.Py()*X(0), L1.Pz()*X(0), sqrt( 3.1571 +L1.P()*L1.P()*X(0)*X(0) ) );
  T2.SetPxPyPzE( L2.Px()*X(1), L2.Py()*X(1), L2.Pz()*X(1), sqrt( 3.1571 +L2.P()*L2.P()*X(1)*X(1) ) );
  if( X(0)>0 && X(1)>0 ) DiTauMass=(T1+T2).M();  else DiTauMass=-(T1+T2).M();  return DiTauMass;
  //if((X(0)!=X0i||X(1)!=X1i))std::cout<<X(0)<<" "<<X(1)<<" <--"<<X0i<<" "<<X1i<<" RMETal.phi="<<(T1+T2-L1-L2).Phi()<<" RMETal.eta"<<(T1+T2-L1-L2).Eta()<<" MZ="<<DiTauMass<<endl; 
}
コード例 #4
0
ファイル: DiTauMass.C プロジェクト: agapitos/SOS8
//___________________[ TAUS RECONSTRUCTION AND INVMASS CALCULATION ]_________________________________________
double SUSYLooperHistsSoftBase::DiTau_InvMass( TLorentzVector Met, TLorentzVector L1, TLorentzVector L2, float Al ) {

    TLorentzVector T1,T2;    double DiTauMass;    TMatrixF A(2,2);    TVectorF C(2),X(2);
    A(0,0)=L1.Px();
    A(0,1)=L2.Px();
    A(1,0)=L1.Py();
    A(1,1)=L2.Py();
    A=A.Invert();
    C(0)=(Met+L1+L2).Px();
    C(1)=(Met+L1+L2).Py();
    X=A*C;
    //double X0i=X(0), X1i=X(1);
    if ( (X(0)<0.||X(1)<0.) && Al>0. ) {//---[MET Alignement subsection]--------------------------------------------------------------------------------------------
        if      ( fabs(L1.DeltaPhi(Met))>Al && fabs(L2.DeltaPhi(Met))>Al                                                  ) {}//{DO NOTHING just normaly a non-Z event!}
        else if ( fabs(L1.DeltaPhi(Met))<Al && fabs(L2.DeltaPhi(Met))>Al                                                  ) Met.SetPtEtaPhiM(Met.Pt(),0,L1.Phi(),0);
        else if ( fabs(L2.DeltaPhi(Met))<Al && fabs(L1.DeltaPhi(Met))>Al                                                  ) Met.SetPtEtaPhiM(Met.Pt(),0,L2.Phi(),0);
        else if ( fabs(L1.DeltaPhi(Met))<Al && fabs(L2.DeltaPhi(Met))<Al && fabs(L1.DeltaPhi(Met))<fabs(L2.DeltaPhi(Met)) ) Met.SetPtEtaPhiM(Met.Pt(),0,L1.Phi(),0);
        else if ( fabs(L1.DeltaPhi(Met))<Al && fabs(L2.DeltaPhi(Met))<Al && fabs(L1.DeltaPhi(Met))>fabs(L2.DeltaPhi(Met)) ) Met.SetPtEtaPhiM(Met.Pt(),0,L2.Phi(),0);
    }//-------------------------------------------------------------------------------------------------------------------------------------------------------------
    C(0)=(Met+L1+L2).Px();
    C(1)=(Met+L1+L2).Py();
    X=A*C;
    T1.SetPxPyPzE( L1.Px()*X(0), L1.Py()*X(0), L1.Pz()*X(0), sqrt( 3.1571 +L1.P()*L1.P()*X(0)*X(0) ) );
    T2.SetPxPyPzE( L2.Px()*X(1), L2.Py()*X(1), L2.Pz()*X(1), sqrt( 3.1571 +L2.P()*L2.P()*X(1)*X(1) ) );
    if (  X(0)>0.  &&  X(1)>0.   )   DiTauMass=(T1+T2).M();
    //if (  (X(0)>0. && 0.<X(1)&&X(1)<1.)  ||  (X(1)>0. && 0.<X(0)&&X(0)<1.)  )  DiTauMass=(T1+T2).M(); // B
    //if (  (X(0)>1.&& X(1)<0.) || (X(1)>1.&& X(0)<0.)    )  DiTauMass=(T1+T2).M(); // C
    //if (  X(0)<0.  &&  X(1)<0.   )  DiTauMass=(T1+T2).M(); //  D    
    else DiTauMass=-(T1+T2).M();
    return DiTauMass;
}//-----------------------------------------------------------------------------------------------------------
コード例 #5
0
// This is the pt corrected delta phi between the 2 mega-jets
// P and Q are the 4-vectors for the 2 hemispheres 
// M is the MET 3 vector (don't forget to set the z-component of
// MET to 0)
// This function will do the correct Lorentz transformations of the 
// leptons for you
double HWWKinematics::CalcDeltaPhiNEW(TLorentzVector P, TLorentzVector Q, TVector3 M){
    // first calculate pt-corrected MR
 float mymrnew = CalcMRNEW(L1,L2,MET);

    //Next, calculate the transverse Lorentz transformation
 TVector3 B = P.Vect()+Q.Vect()+MET;
 B.SetZ(0.0);
 B = (-1./(sqrt(4.*mymrnew*mymrnew+B.Dot(B))))*B;

 P.Boost(B);
 Q.Boost(B);

    //Now, re-calculate the delta phi
    // in the new reference frame:

 return P.DeltaPhi(Q);

}
コード例 #6
0
ファイル: ADDON3_LAC.C プロジェクト: dertexaner/LQ3
// // //
double analysisClass::METlepMT(TString Lep, int iLep){
  TLorentzVector MET;
  TLorentzVector lep;
  MET.SetPtEtaPhiM( 0 , 0 , 0 , 0 );
  lep.SetPtEtaPhiM( 0 , 0 , 0 , 0 );
  double maxPt=0;
  //std::cout<< "analysisClass::METlepMT  iLep: "<<iLep<<std::endl;
  //
  if( Lep != "Mu" && Lep != "Tau" ){ cout<<" WRONG LEPTON TYPE SPECIFIED!! analysisClass::METlepMT(TString Lep, int iLep) "<<endl; return 0; }
  //
  if( iLep>-1 ){
    if( Lep == "Mu"  ) lep.SetPtEtaPhiM( muPtcorr(iLep), MuonEta->at(iLep), MuonPhi->at(iLep), 0 );
    if( Lep == "Tau" ) lep.SetPtEtaPhiM( tauPtcorr(iLep), HPSTauEta->at(iLep), HPSTauPhi->at(iLep), 0 );
  }
  if( iLep==-1){
    if( Lep == "Mu"  ){
      maxPt=0;
      for(unsigned int iMuR=0; iMuR<MuonPt->size(); iMuR++){
	if(!muRisoCheck(iMuR))continue;
	if( muPtcorr(iMuR)>maxPt ){ maxPt=muPtcorr(iMuR);  lep.SetPtEtaPhiM( muPtcorr(iMuR), MuonEta->at(iMuR), MuonPhi->at(iMuR), 0 ); }
      }
    }
    //------- -------
    if( Lep == "Tau" ){ 
      maxPt=0;
      for(unsigned int iTauR=0; iTauR<HPSTauPt->size(); iTauR++){
	if(!tauRisoCheck(iTauR))continue;
	if( tauPtcorr(iTauR)>maxPt ){ maxPt=tauPtcorr(iTauR);  lep.SetPtEtaPhiM( tauPtcorr(iTauR), HPSTauEta->at(iTauR), HPSTauPhi->at(iTauR), 0 ); }
      }
    }
  }
  //
  MET.SetPtEtaPhiM( METcorr("Pt"), 0 , METcorr("Phi") , 0 );
  double M_T=TMath::Sqrt(2*fabs(MET.Pt())*fabs(lep.Pt())*(1-TMath::Cos(MET.DeltaPhi(lep))));
  //
  return M_T;
}
コード例 #7
0
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
コード例 #8
0
void QCDAnalysis(
 Int_t nsel = 0,
 Int_t typeSel = 4,
 Int_t applyPrescale = 1,
 TString typeLepSel = "medium"
 ){

  Int_t period = 1;
  TString filesPath  = "/scratch5/ceballos/ntuples_weights/qcd_";
  Double_t lumi = 0.0715;
  if(period == 1) lumi = 2.2;

  Double_t prescale[5];

  double denFRDA[5][5] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  double numFRDA[5][5] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  double denFRBG[5][5] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  double numFRBG[5][5] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

  //*******************************************************
  //Input Files
  //*******************************************************
  vector<TString> infilenamev;  
  vector<Int_t> infilecatv;  

  TString puPath = "";
  if     (period==0){
  }
  else if(period==1){
  if     (typeSel == 11) {prescale[0]=0.00000;prescale[1]=0.00859;prescale[2]=0.00520;prescale[3]=0.00750;prescale[4]=0.00956;}
  else if(typeSel == 13) {prescale[0]=0.00250;prescale[1]=0.07087;prescale[2]=0.09861;prescale[3]=0.09744;prescale[4]=0.09616;}
  puPath = "/home/ceballos/cms/cmssw/042/CMSSW_7_4_6/src/MitAnalysisRunII/data/puWeights_13TeV_25ns.root";
  infilenamev.push_back(Form("%sdata_AOD_Run2015C1_25ns.root",filesPath.Data())); 												  infilecatv.push_back(0);
  infilenamev.push_back(Form("%sdata_AOD_Run2015D3_25ns.root",filesPath.Data())); 												  infilecatv.push_back(0);
  infilenamev.push_back(Form("%sdata_AOD_Run2015D4_25ns.root",filesPath.Data())); 												  infilecatv.push_back(0);
  infilenamev.push_back(Form("%sWWTo2L2Nu_13TeV-powheg+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));					          infilecatv.push_back(1);
  infilenamev.push_back(Form("%sGluGluWWTo2L2Nu_MCFM_13TeV+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));                                          infilecatv.push_back(1);
  infilenamev.push_back(Form("%sDYJetsToLL_M-10to50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));         infilecatv.push_back(2);
  infilenamev.push_back(Form("%sDYJetsToLL_M-50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v3+AODSIM.root",filesPath.Data()));	          infilecatv.push_back(2);
  infilenamev.push_back(Form("%sTT_TuneCUETP8M1_13TeV-powheg-pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v2+AODSIM.root",filesPath.Data()));				  infilecatv.push_back(3); // tt->X (not tt->2l)
  infilenamev.push_back(Form("%sST_tW_top_5f_inclusiveDecays_13TeV-powheg-pythia8_TuneCUETP8M1+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));      infilecatv.push_back(3);
  infilenamev.push_back(Form("%sST_tW_antitop_5f_inclusiveDecays_13TeV-powheg-pythia8_TuneCUETP8M1+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));  infilecatv.push_back(3);
  infilenamev.push_back(Form("%sZZTo2L2Nu_13TeV_powheg_pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));				          infilecatv.push_back(4);
  infilenamev.push_back(Form("%sZZTo2L2Q_13TeV_amcatnloFXFX_madspin_pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));		          infilecatv.push_back(4);
  infilenamev.push_back(Form("%sZZTo4L_13TeV_powheg_pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));				          infilecatv.push_back(4);
  infilenamev.push_back(Form("%sGluGluToZZTo2e2mu_BackgroundOnly_13TeV_MCFM+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));			  infilecatv.push_back(4);
  infilenamev.push_back(Form("%sGluGluToZZTo2e2tau_BackgroundOnly_13TeV_MCFM+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));			  infilecatv.push_back(4);
  infilenamev.push_back(Form("%sGluGluToZZTo2mu2tau_BackgroundOnly_13TeV_MCFM+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));			  infilecatv.push_back(4);
  infilenamev.push_back(Form("%sGluGluToZZTo4e_BackgroundOnly_13TeV_MCFM+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));  			  infilecatv.push_back(4);
  infilenamev.push_back(Form("%sGluGluToZZTo4mu_BackgroundOnly_13TeV_MCFM+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data())); 			  infilecatv.push_back(4);
  infilenamev.push_back(Form("%sGluGluToZZTo4tau_BackgroundOnly_13TeV_MCFM+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));			  infilecatv.push_back(4);
  infilenamev.push_back(Form("%sWZTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));		          infilecatv.push_back(4);
  infilenamev.push_back(Form("%sWZTo2L2Q_13TeV_amcatnloFXFX_madspin_pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v2+AODSIM.root",filesPath.Data()));		          infilecatv.push_back(4);
  infilenamev.push_back(Form("%sWZTo3LNu_TuneCUETP8M1_13TeV-powheg-pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));                          infilecatv.push_back(4);
  infilenamev.push_back(Form("%sWWZ_TuneCUETP8M1_13TeV-amcatnlo-pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));			          infilecatv.push_back(4);
  infilenamev.push_back(Form("%sWZZ_TuneCUETP8M1_13TeV-amcatnlo-pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));			          infilecatv.push_back(4);
  infilenamev.push_back(Form("%sZZZ_TuneCUETP8M1_13TeV-amcatnlo-pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v2+AODSIM.root",filesPath.Data()));			          infilecatv.push_back(4);
  infilenamev.push_back(Form("%sTTWJetsToLNu_TuneCUETP8M1_13TeV-amcatnloFXFX-madspin-pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));        infilecatv.push_back(4);
  infilenamev.push_back(Form("%sTTWJetsToQQ_TuneCUETP8M1_13TeV-amcatnloFXFX-madspin-pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));         infilecatv.push_back(4);
  infilenamev.push_back(Form("%sTTZToLLNuNu_M-10_TuneCUETP8M1_13TeV-amcatnlo-pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));	          infilecatv.push_back(4);
  infilenamev.push_back(Form("%sTTZToQQ_TuneCUETP8M1_13TeV-amcatnlo-pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));		          infilecatv.push_back(4);
  infilenamev.push_back(Form("%sTTGJets_TuneCUETP8M1_13TeV-amcatnloFXFX-madspin-pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));	          infilecatv.push_back(4);
  infilenamev.push_back(Form("%sWJetsToLNu_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));	          infilecatv.push_back(5);
  infilenamev.push_back(Form("%sWGToLNuG_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));  		  infilecatv.push_back(6);
  //infilenamev.push_back(Form("%sZGTo2LG_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));		          infilecatv.push_back(6);
  infilenamev.push_back(Form("%sGluGluHToWWTo2L2Nu_M125_13TeV_powheg_JHUgen_pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v3+AODSIM.root",filesPath.Data()));	          infilecatv.push_back(7);
  infilenamev.push_back(Form("%sVBFHToWWTo2L2Nu_M125_13TeV_powheg_JHUgen_pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));  	          infilecatv.push_back(7);
  infilenamev.push_back(Form("%sGluGluHToTauTau_M125_13TeV_powheg_pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data())); 		          infilecatv.push_back(7);
  infilenamev.push_back(Form("%sVBFHToTauTau_M125_13TeV_powheg_pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data()));			          infilecatv.push_back(7);
  /////infilenamev.push_back(Form("%sVHToNonbb_M125_13TeV_amcatnloFXFX_madspin_pythia8+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data())); 		  infilecatv.push_back(7);
  /////infilenamev.push_back(Form("%sttHJetToNonbb_M125_13TeV_amcatnloFXFX_madspin_pythia8_mWCutfix+RunIISpring15DR74-Asympt25ns_MCRUN2_74_V9-v1+AODSIM.root",filesPath.Data())); infilecatv.push_back(7);
  }

  //infilenamev.push_back(Form("nero.root"));     infilecatv.push_back(0);

  if(infilenamev.size() != infilecatv.size()) assert(0);

  Float_t fMVACut[4][4];
  InitializeJetIdCuts(fMVACut);
 
  TFile *fPUFile = TFile::Open(Form("%s",puPath.Data()));
  TH1D *fhDPU = (TH1D*)(fPUFile->Get("puWeights"));
  assert(fhDPU);
  fhDPU->SetDirectory(0);
  delete fPUFile;

  double xmin = 0.0;
  double xmax = 1.0;
  int nBinPlot      = 200;
  double xminPlot   = 0.0;
  double xmaxPlot   = 200.0;
  const int allPlots = 11;
  const int histBins = 8;
  TH1D* histo[allPlots][histBins];

  for(int thePlot=0; thePlot<allPlots; thePlot++){
    if     (thePlot >=  0 && thePlot <=  5) {nBinPlot = 200; xminPlot = 0.0; xmaxPlot = 200.0;}
    else if(thePlot >=  6 && thePlot <=  6) {nBinPlot =   7; xminPlot =-0.5; xmaxPlot =   6.5;}
    else if(thePlot >=  7 && thePlot <=  7) {nBinPlot =  40; xminPlot = 0.0; xmaxPlot =  40.0;}
    else if(thePlot >=  8 && thePlot <=  8) {nBinPlot =  40; xminPlot =-0.5; xmaxPlot =  39.5;}
    else if(thePlot >=  9 && thePlot <=  9) {nBinPlot =  50; xminPlot = 0.0; xmaxPlot =  50.0;}
    else if(thePlot >= 10 && thePlot <= 10) {nBinPlot =  50; xminPlot = 0.0; xmaxPlot =   2.5;}
    TH1D* histos = new TH1D("histos", "histos", nBinPlot, xminPlot, xmaxPlot);
    histos->Sumw2();
    for(int i=0; i<histBins; i++) histo[thePlot][i] = (TH1D*) histos->Clone(Form("histo%d",i));
    histos->Clear();
  }

  //*******************************************************
  // Chain Loop
  //*******************************************************
  for(UInt_t ifile=0; ifile<infilenamev.size(); ifile++) {

    TFile the_input_file(infilenamev[ifile]);
    TTree *the_input_tree = (TTree*)the_input_file.FindObjectAny("events");
    //TTree *the_input_all  = (TTree*)the_input_file.FindObjectAny("all");

    BareMonteCarlo eventMonteCarlo;
    eventMonteCarlo.setBranchAddresses(the_input_tree);

    BareEvent eventEvent;
    eventEvent.setBranchAddresses(the_input_tree);

    BareJets eventJets;
    eventJets.setBranchAddresses(the_input_tree);

    BareLeptons eventLeptons;
    eventLeptons.setBranchAddresses(the_input_tree);

    BareTaus eventTaus;
    eventTaus.setBranchAddresses(the_input_tree);

    BareMet eventMet;
    eventMet.SetExtend();
    eventMet.setBranchAddresses(the_input_tree);

    BareTrigger eventTrigger;
    eventTrigger.setBranchAddresses(the_input_tree);

    BareVertex eventVertex;
    eventVertex.setBranchAddresses(the_input_tree);

    TNamed *triggerNames = (TNamed*)the_input_file.FindObjectAny("triggerNames");
    char **tokens;
    size_t numtokens;
    tokens = strsplit(triggerNames->GetTitle(), ",", &numtokens);
    if(infilecatv[ifile] == 0){
      for (int i = 0; i < (int)numtokens; i++) {
        printf("triggerNames(%2d): \"%s\"\n",(int)i,tokens[i]);
      }
    }
    else {
      printf("sampleNames(%d): %s\n",ifile,infilenamev[ifile].Data());
    }

    Int_t nPassTrigger[12] = {0,0,0,0,0,0,0,0,0,0,0,0};

    Int_t nPassCuts[10] = {0,0,0,0,0,0,0,0,0,0};
    double theMCPrescale = mcPrescale;
    if(infilecatv[ifile] == 0) theMCPrescale = 1.0;
    for (int i=0; i<int(the_input_tree->GetEntries()/theMCPrescale); ++i) {
      the_input_tree->GetEntry(i);
      if(i%100000==0) printf("event %d out of %d\n",i,(int)the_input_tree->GetEntries());

      if(typeSel != 11 && typeSel != 13) assert(0);

      Bool_t passFilter = kFALSE;
      Bool_t passTrigger = kFALSE;
      for (int nt = 0; nt < (int)numtokens; nt++) {
	if(typeSel == 11 &&
          (strcmp(tokens[nt],"HLT_Ele12_CaloIdL_TrackIdL_IsoVL_PFJet30_v*") == 0 ||
           strcmp(tokens[nt],"HLT_Ele18_CaloIdL_TrackIdL_IsoVL_PFJet30_v*") == 0 ||
           strcmp(tokens[nt],"HLT_Ele23_CaloIdL_TrackIdL_IsoVL_PFJet30_v*") == 0 ||
           strcmp(tokens[nt],"HLT_Ele33_CaloIdL_TrackIdL_IsoVL_PFJet30_v*") == 0) &&
	  (*eventTrigger.triggerFired)[nt] == 1) passTrigger = kTRUE;
	if(typeSel == 13 &&
	  (strcmp(tokens[nt],"HLT_Mu8_TrkIsoVVL_v*")  == 0 ||              
	   strcmp(tokens[nt],"HLT_Mu17_TrkIsoVVL_v*") == 0 ||              
	   strcmp(tokens[nt],"HLT_Mu24_TrkIsoVVL_v*") == 0 ||              
	   strcmp(tokens[nt],"HLT_Mu34_TrkIsoVVL_v*") == 0) &&           
	  (*eventTrigger.triggerFired)[nt] == 1) passTrigger = kTRUE;
      }
      if(passTrigger == kTRUE &&
         eventLeptons.p4->GetEntriesFast() >= 1 &&
         ((TLorentzVector*)(*eventLeptons.p4)[0])->Pt() > 10 && 
	 (double)((TLorentzVector*)(*eventMet.p4)[0])->Pt() < 30.0) passFilter = kTRUE;

      if(passTrigger == kTRUE) nPassCuts[0]++;
      if(passFilter  == kTRUE) nPassCuts[1]++;
      if(passFilter == kFALSE) continue;

      Bool_t passSel = kFALSE;
      TLorentzVector dilep;double deltaPhiDileptonMet = -999.0; double mtW = -999.0;
      vector<int> idLep; vector<int> idTight;
      for(int nlep=0; nlep<eventLeptons.p4->GetEntriesFast(); nlep++) {
        if(selectIdIsoCut(typeLepSel.Data(),TMath::Abs((int)(*eventLeptons.pdgId)[nlep]),TMath::Abs(((TLorentzVector*)(*eventLeptons.p4)[nlep])->Pt()),
	   TMath::Abs(((TLorentzVector*)(*eventLeptons.p4)[nlep])->Eta()),(double)(*eventLeptons.iso)[nlep],(int)(*eventLeptons.selBits)[nlep]))
	                                                                                               {idTight.push_back(1); idLep.push_back(nlep);}
        else if(((int)(*eventLeptons.selBits)[nlep] & BareLeptons::LepFake)  == BareLeptons::LepFake ) {idTight.push_back(0); idLep.push_back(nlep);}
      }

      vector<int> isGenLep;
      for(unsigned nl=0; nl<idLep.size(); nl++){
        bool isGenLepton = false;
        for(int ngen=0; ngen<eventMonteCarlo.p4->GetEntriesFast(); ngen++) {
          if(TMath::Abs((int)(*eventLeptons.pdgId)[idLep[nl]]) == TMath::Abs((int)(*eventMonteCarlo.pdgId)[ngen]) &&
	    ((TLorentzVector*)(*eventLeptons.p4)[idLep[nl]])->DeltaR(*((TLorentzVector*)(*eventMonteCarlo.p4)[ngen])) < 0.1) {
	    isGenLepton = true;
	    break;
	  }
	}
	if(isGenLepton == true) isGenLep.push_back(nl);
      }
      
      vector<int> idJet20,idJet30;
      for(int nj=0; nj<eventJets.p4->GetEntriesFast(); nj++){
        if(((TLorentzVector*)(*eventJets.p4)[nj])->Pt() < 10) continue;
        bool passId = passJetId(fMVACut, (float)(*eventJets.puId)[nj], ((TLorentzVector*)(*eventJets.p4)[nj])->Pt(), TMath::Abs(((TLorentzVector*)(*eventJets.p4)[nj])->Eta()));
        //if(passId == false) continue;        

        Bool_t isLepton = kFALSE;
        for(unsigned int nl=0; nl<idLep.size(); nl++){
          if(((TLorentzVector*)(*eventJets.p4)[nj])->DeltaR(*((TLorentzVector*)(*eventLeptons.p4)[idLep[nl]])) < 0.3) isLepton = kTRUE;
	}
	if(isLepton == kTRUE) continue;

        if(((TLorentzVector*)(*eventJets.p4)[nj])->Pt() > 20)  idJet20.push_back(nj);
        if(((TLorentzVector*)(*eventJets.p4)[nj])->Pt() > 30)  idJet30.push_back(nj);
      }

      if     (nsel == 0){ // Z->ll
        if(idLep.size() == 2) nPassCuts[2]++;
	if(idLep.size() == 2 &&
     	  ((TLorentzVector*)(*eventLeptons.p4)[idLep[0]])->Pt() > 10 && 
     	  ((TLorentzVector*)(*eventLeptons.p4)[idLep[1]])->Pt() > 10) nPassCuts[3]++;
        if(idLep.size() == 2 &&
     	  ((TLorentzVector*)(*eventLeptons.p4)[idLep[0]])->Pt() > 10 && 
     	  ((TLorentzVector*)(*eventLeptons.p4)[idLep[1]])->Pt() > 10 &&
          (int)(*eventLeptons.pdgId)[idLep[0]]*(int)(*eventLeptons.pdgId)[idLep[1]] < 0 &&
	  TMath::Abs((int)(*eventLeptons.pdgId)[idLep[0]]) == TMath::Abs((int)(*eventLeptons.pdgId)[idLep[1]]) &&
	  TMath::Abs((int)(*eventLeptons.pdgId)[idLep[0]]) == typeSel &&
	 (infilecatv[ifile] == 0 || isGenLep.size() == 2)) {
          nPassCuts[4]++;
          dilep = ( ( *(TLorentzVector*)(eventLeptons.p4->At(idLep[0])) ) + ( *(TLorentzVector*)(eventLeptons.p4->At(idLep[1])) ) ); 
          if(TMath::Abs(dilep.M()-91.1876)<15.0) passSel = kTRUE;	
	}
      }
      else if(nsel == 1){ // fake
        if(idLep.size() == 1) nPassCuts[2]++;
	if(idLep.size() == 1 &&
     	  ((TLorentzVector*)(*eventLeptons.p4)[idLep[0]])->Pt() > 10) nPassCuts[3]++;
        if(idLep.size() == 1 &&
     	  ((TLorentzVector*)(*eventLeptons.p4)[idLep[0]])->Pt() > 10 &&
	  ((typeSel == 11 && idJet30.size() >= 1) ||(typeSel == 13 && idJet20.size() >= 1)) &&
	  TMath::Abs((int)(*eventLeptons.pdgId)[idLep[0]]) == typeSel &&
	 (infilecatv[ifile] == 0 || isGenLep.size() == 1)) {
          dilep = ( *(TLorentzVector*)(eventLeptons.p4->At(idLep[0])) );
          nPassCuts[4]++;
          deltaPhiDileptonMet = TMath::Abs(dilep.DeltaPhi(*((TLorentzVector*)(*eventMet.p4)[0])));
          mtW = TMath::Sqrt(2.0*dilep.Pt()*((TLorentzVector*)(*eventMet.p4)[0])->Pt()*(1.0 - cos(deltaPhiDileptonMet)));
	  if(mtW < 20) passSel = kTRUE;
	}
      }
      else if(nsel == 2){ // W->ln
        if(idLep.size() == 1 && idTight[0] == 1) nPassCuts[2]++;
	if(idLep.size() == 1 && idTight[0] == 1 &&
     	  ((TLorentzVector*)(*eventLeptons.p4)[idLep[0]])->Pt() > 10) nPassCuts[3]++;
        if(idLep.size() == 1 && idTight[0] == 1 &&
     	  ((TLorentzVector*)(*eventLeptons.p4)[idLep[0]])->Pt() > 10 &&
	  TMath::Abs((int)(*eventLeptons.pdgId)[idLep[0]]) == typeSel &&
	 (infilecatv[ifile] == 0 || isGenLep.size() == 1)) {
          dilep = ( *(TLorentzVector*)(eventLeptons.p4->At(idLep[0])) );
          nPassCuts[4]++;
          deltaPhiDileptonMet = TMath::Abs(dilep.DeltaPhi(*((TLorentzVector*)(*eventMet.p4)[0])));
          mtW = TMath::Sqrt(2.0*dilep.Pt()*((TLorentzVector*)(*eventMet.p4)[0])->Pt()*(1.0 - cos(deltaPhiDileptonMet)));
	  if(mtW > 50) passSel = kTRUE;
	}
      }

      if(passSel == kTRUE) nPassCuts[5]++;
      if(passSel == kFALSE) continue;

      if(mtW < 0){
        deltaPhiDileptonMet = TMath::Abs(dilep.DeltaPhi(*((TLorentzVector*)(*eventMet.p4)[0])));
        mtW = TMath::Sqrt(2.0*dilep.Pt()*((TLorentzVector*)(*eventMet.p4)[0])->Pt()*(1.0 - cos(deltaPhiDileptonMet)));
      }

      double mcWeight = eventMonteCarlo.mcWeight;
      if(infilecatv[ifile] == 0) mcWeight = 1.0;
      double theLumi = lumi; if(infilecatv[ifile] == 0) theLumi = 1.0;
      double puWeight = nPUScaleFactor(fhDPU, (double)eventVertex.npv); if(infilecatv[ifile] == 0) puWeight = 1.0;
      double effSF = 1.0;
      if(infilecatv[ifile] != 0){
        for(unsigned int nl=0; nl<idLep.size(); nl++){
          effSF = effSF * effScaleFactor(((TLorentzVector*)(*eventLeptons.p4)[idLep[nl]])->Pt(),TMath::Abs(((TLorentzVector*)(*eventLeptons.p4)[idLep[nl]])->Eta()),TMath::Abs((int)(*eventLeptons.pdgId)[idLep[nl]]),period,typeLepSel);
        }
      }
      
      int iPt = -1;
      if     (((TLorentzVector*)(*eventLeptons.p4)[idLep[0]])->Pt() < 15){
        iPt = 0;
      }
      else if(((TLorentzVector*)(*eventLeptons.p4)[idLep[0]])->Pt() < 20){
        iPt = 1;
      }
      else if(((TLorentzVector*)(*eventLeptons.p4)[idLep[0]])->Pt() < 25){
        iPt = 2;
      }
      else if(((TLorentzVector*)(*eventLeptons.p4)[idLep[0]])->Pt() < 30){
        iPt = 3;
      }
      else {
        iPt = 4;
      }
      int iEta = -1;
      if     (TMath::Abs(((TLorentzVector*)(*eventLeptons.p4)[idLep[0]])->Eta()) < 0.5){
         iEta = 0;
      }
      else if(TMath::Abs(((TLorentzVector*)(*eventLeptons.p4)[idLep[0]])->Eta()) < 1.0){
         iEta = 1;
      }
      else if(TMath::Abs(((TLorentzVector*)(*eventLeptons.p4)[idLep[0]])->Eta()) < 1.5){
         iEta = 2;
      }
      else if(TMath::Abs(((TLorentzVector*)(*eventLeptons.p4)[idLep[0]])->Eta()) < 2.0){
         iEta = 3;
      }
      else {
         iEta = 4;
      }
      if(nsel == 0) iEta = 0;

      double thePrescale = 1.0;
      if(infilecatv[ifile] != 0 && applyPrescale == 1) thePrescale = prescale[iPt];

      double totalWeight = mcWeight*theLumi*puWeight*effSF*thePrescale*theMCPrescale;

      if(infilecatv[ifile] == 0) {
                            denFRDA[iPt][iEta] = denFRDA[iPt][iEta] + totalWeight;
        if(idTight[0] == 1) numFRDA[iPt][iEta] = numFRDA[iPt][iEta] + totalWeight;
      }
      else {
                            denFRBG[iPt][iEta] = denFRBG[iPt][iEta] + totalWeight;
        if(idTight[0] == 1) numFRBG[iPt][iEta] = numFRBG[iPt][iEta] + totalWeight;
      }

      for(int thePlot=0; thePlot<allPlots; thePlot++){
        double theVar = 0.0;
        if     (thePlot ==  0) theVar = TMath::Min(dilep.M(),199.999);
        else if(thePlot ==  1) theVar = TMath::Min((double)((TLorentzVector*)(*eventMet.p4)[0])->Pt(),199.999);
        else if(thePlot ==  2) theVar = TMath::Min((double)eventMet.metNoMu->Pt(),199.999);
        else if(thePlot ==  3) theVar = TMath::Min((double)((TLorentzVector*)(*eventMet.p4)[0])->Pt(),199.999);
        else if(thePlot ==  4) theVar = TMath::Min(dilep.Pt(),199.999);
        else if(thePlot ==  5) theVar = TMath::Min(mtW,199.999);
        else if(thePlot ==  6) theVar = TMath::Min((double)0.0,6.499);
        else if(thePlot ==  7) theVar = TMath::Min((double)eventEvent.rho,39.999);
        else if(thePlot ==  8) theVar = TMath::Min((double)eventVertex.npv,39.499);
        else if(thePlot ==  9) theVar = TMath::Min(((TLorentzVector*)(*eventLeptons.p4)[idLep[0]])->Pt(),49.999);
        else if(thePlot == 10) theVar = TMath::Min(TMath::Abs(((TLorentzVector*)(*eventLeptons.p4)[idLep[0]])->Eta()),2.499);
        histo[thePlot][infilecatv[ifile]]->Fill(theVar,totalWeight);
      }

    }

    printf("eff_cuts: ");
    for(int nc=0; nc<6; nc++){
      double nminusone = the_input_tree->GetEntries();
      if(nc>0) nminusone = nPassCuts[nc-1];
      printf("(%d): %8.5f(%8.5f) | ",nc,100*(double)nPassCuts[nc]/the_input_tree->GetEntries(),100*(double)nPassCuts[nc]/nminusone);
    }
    printf("\n");
  } // end of chain

  for(int nc=0; nc<8; nc++){
    printf("(%d): %5.2f | ",nc,histo[0][nc]->GetSumOfWeights());
  }
  double sumTot[2] = {0.,0.};
  printf("totalMC: %5.2f\n",histo[0][1]->GetSumOfWeights()+histo[0][2]->GetSumOfWeights()+histo[0][3]->GetSumOfWeights()+
                            histo[0][4]->GetSumOfWeights()+histo[0][5]->GetSumOfWeights()+histo[0][6]->GetSumOfWeights()+histo[0][7]->GetSumOfWeights());
  for(int iEta=0; iEta<5; iEta++){
    for(int iPt=0; iPt<5; iPt++){
      sumTot[0] = sumTot[0] + denFRDA[iPt][iEta];
      sumTot[1] = sumTot[1] + denFRBG[iPt][iEta];
      printf("(%d,%d): (%6.1f-%6.1f)/(%6.1f-%6.1f)=%4.3f | ",iPt,iEta,numFRDA[iPt][iEta],numFRBG[iPt][iEta] , denFRDA[iPt][iEta],denFRBG[iPt][iEta],
                                                                     (numFRDA[iPt][iEta]-numFRBG[iPt][iEta])/(denFRDA[iPt][iEta]-denFRBG[iPt][iEta]));
      if(iPt==4) printf("\n");
    }
  }
  printf("sumTot(da/bg) = %f / %f = %f\n",sumTot[0],sumTot[1],sumTot[0]/sumTot[1]);
  if(nsel == 0){
    for(int iEta=0; iEta<5; iEta++){
      for(int iPt=0; iPt<5; iPt++){
        printf("(%d,%d): (%6.1f)/(%6.1f)=%7.5f | ",iPt,iEta,denFRDA[iPt][iEta],denFRBG[iPt][iEta],denFRDA[iPt][iEta]/denFRBG[iPt][iEta]);
        if(iPt==4) printf("\n");
      }
    }
  }
  else {
    for(int iEta=0; iEta<5; iEta++){
      for(int iPt=0; iPt<5; iPt++){
        printf("(%d,%d): (%6.1f)/(%6.1f)=%4.3f | ",iPt,iEta,numFRDA[iPt][iEta] , denFRDA[iPt][iEta],
                                                           (numFRDA[iPt][iEta])/(denFRDA[iPt][iEta]));
        if(iPt==4) printf("\n");
      }
    }
  }

  if(typeSel == 11) printf("double fake_rate_e[%d][%d] = {\n",5,5);
  else              printf("double fake_rate_m[%d][%d] = {\n",5,5);
  for(int iEta=0; iEta<5; iEta++){
    for(int iPt=0; iPt<5; iPt++){
      printf("%4.3f",TMath::Abs((numFRDA[iPt][iEta]-numFRBG[iPt][iEta])/(denFRDA[iPt][iEta]-denFRBG[iPt][iEta])));
      if(iPt!=4||iEta!=4) printf(",");
      if(iPt==4) printf("\n");
    }
  }
  printf("};\n");
  
  for(int thePlot=0; thePlot<allPlots; thePlot++){
    char output[200];
    sprintf(output,"histo_fake_%d_%d_%d.root",thePlot,nsel,typeSel);	  
    TFile* outFilePlotsNote = new TFile(output,"recreate");
    outFilePlotsNote->cd();
    for(int np=0; np<histBins; np++) histo[thePlot][np]->Write();
    outFilePlotsNote->Close();
  }

}
コード例 #9
0
ファイル: SUSYLooperHists.C プロジェクト: mstoye/loopCode
TFile* SUSYLooperHists::Loop()
{
//   In a ROOT session, you can do:
//      Root > .L SUSYLooperHists.C
//      Root > SUSYLooperHists t
//      Root > t.GetEntry(12); // Fill t data members with entry number 12
//      Root > t.Show();       // Show values of entry 12
//      Root > t.Show(16);     // Read and show values of entry 16
//      Root > t.Loop();       // Loop on all entries
//

//     This is the loop skeleton where:
//    jentry is the global entry number in the chain
//    ientry is the entry number in the current Tree
//  Note that the argument to GetEntry must be:
//    jentry for TChain::GetEntry
//    ientry for TTree::GetEntry and TBranch::GetEntry
//
//       To read only selected branches, Insert statements like:
// METHOD1:
//    fChain->SetBranchStatus("*",0);  // disable all branches
//    fChain->SetBranchStatus("branchname",1);  // activate branchname
// METHOD2: replace line
//    fChain->GetEntry(jentry);       //read all branches
//by  b_branchname->GetEntry(ientry); //read only this branch


   if (fChain == 0) return NULL;
   Long64_t nentries = fChain->GetEntriesFast();
  
   TFile* myFile = new TFile(outputFileName,"recreate");
   // checks the Mtt mass ++ simple plot example ++
   TH1D* LepTwoZmass= new TH1D("LepTwoZmass",";approximate Z(#tau#tau) mass [GeV];",100,0,2000);
   LepTwoZmass->Sumw2();

   // baseline plots +++++++++++++++++++++
   // allow to fill cutflow to sychronize to others
   TH1D* CutFlow = new TH1D("CutFlow",";CutFlow [unweighted];",20,-0.5,19.5);
   CutFlow->Sumw2();

   TH1D* Sig = new TH1D("Sig",";3DSig;",25,-0.,50);
   Sig->Sumw2();
   TH1D* Dxy = new TH1D("Dxy",";Dxy;",50,-0.,0.2);
   Dxy->Sumw2();
   TH1D* Dz = new TH1D("Dz",";Dz;",50,-0.,0.2);
   Dz->Sumw2();
   TH2D* DxyDz = new TH2D("DxyDz",";3DSig;",100,-0.,0.2,100,-0.,0.2);
   DxyDz->Sumw2();


   TH1D* IP3D = new TH1D("IP3D",";IP3D;",500,-0.,.5);
   IP3D->Sumw2();
   TH1D* Sig0 = new TH1D("Sig0",";3DSig;",50,-0.,50);
   Sig0->Sumw2();
   TH1D* Pt = new TH1D("Pt",";Pt;",200,-0.,25);
   Pt->Sumw2();
   TH1D* Iso = new TH1D("Is",";Is;",200,-0.,5);
   Iso->Sumw2();
   TH1D* LooseBPt = new TH1D("LooseBPt",";Pt;",200,-0.,500);
   LooseBPt->Sumw2();



 // a scan should be filled without weight*puWeights before any cut to get the efficiency. The reason is that for a scan each points have different x-section, which are not accessable during the loop
   TH2D* scan = new TH2D("scan","scan",8,112.5,312.5,40,112.5,312.5);
   // fill after some cuts the scans to get efficiency, i.e. ->Divide(scan) after the loop
   TH2D* scanA = new TH2D("scanA","scan",8,112.5,312.5,40,112.5,312.5);
   TH2D* scanB = new TH2D("scanB","scan",8,112.5,312.5,40,112.5,312.5);
   TH2D* scanC = new TH2D("scanC","scan",8,112.5,312.5,40,112.5,312.5);

   // plot a mass
   TH1D* GenMll = new TH1D("GenMll",";GenMll;",200,-0,200);
   GenMll->Sumw2();

   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(jentry%100000==0) cout << "Event: "<<jentry <<endl;
      scan->Fill(GenSusyMStop,GenSusyMNeutralino);
      // select lepton and put it into TLorentzvector 


      TLorentzVector lep;
      TLorentzVector met;
      vector <TLorentzVector> lepVec;
      for(int i =0;i<nLepGood;i++)
	{
	  TLorentzVector aLep;
	  aLep.SetPtEtaPhiM(LepGood_pt[i],LepGood_eta[i],LepGood_phi[i],0.1);
	  lepVec.push_back(aLep);
	}
      if(nLepGood>0) lep.SetPtEtaPhiM(LepGood_pt[0],LepGood_eta[0],LepGood_phi[0],0.1);
      else lep.SetPtEtaPhiM(0,0,0,0.1);
      met.SetPtEtaPhiM(met_pt,0.,met_phi,0);
      float MT =  sqrt(lep.Pt()*2*met.Pt()*(1-cos(lep.DeltaPhi(met))));
      TLorentzVector jetSum;
      vector <TLorentzVector> myVecJets;
      jetSum.SetPtEtaPhiM(0,0,0,0);
      unsigned int nb40=0;
      unsigned int nb30L=0;



      float HT30 = 0;
      for (int i=0;i<nJet;i++)
	{
	  TLorentzVector myjet;
	  //cout <<" pt: " << Jet_pt[i] <<  " "<< Jet_eta[i]<< " "<<  Jet_phi[i]<< " QG "<< Jet_quarkGluonID[i] <<endl;
	  myjet.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]);
	  jetSum=jetSum+myjet;
	  myVecJets.push_back(myjet);
	  if(Jet_btagCSV[i]>0.679) {
	   
	                      nb40++;
	  }

	  if(Jet_btagCSV[i]>0.244) {
	  
	    nb30L++;
	  }

	  if(fabs(Jet_eta[i])<4.5&&Jet_pt[i]>30) HT30=HT30+Jet_pt[i];

	  //	   QG->Fill(Jet_quarkGluonID[i]);
	}

      // preselection syncronizd to Antonis ++++++++++++++++++++
      if( nLepGood == 0  ) continue;
      CutFlow->Fill(0.);
      if(HLT_MetTrigger!=1)  continue;
      if(met.Pt()<200) continue;
      if(nLepGood<2)  continue;
      if(nJet==0)  continue;
      if(nTauGood!=0)  continue;
      CutFlow->Fill(1.);
      // if(fabs(LepGood_pdgId[0]* LepGood_pdgId[1])<122)   continue;
      CutFlow->Fill(2.);
      if(lep.Pt()<5||fabs(lep.Eta())>1.5||lep.Pt()>60) continue;
      CutFlow->Fill(3.);
      if(fabs(LepGood_pdgId[0])==11&&lep.Pt()<7) continue;
      CutFlow->Fill(4.);
      // check that a cut was ahead in nLepton !!!!!!!!
      TLorentzVector secondLep;
      secondLep.SetPtEtaPhiM(LepGood_pt[1], LepGood_eta[1], LepGood_phi[1],0.1);
      if(secondLep.Pt()<3||fabs(secondLep.Eta())>1.5||secondLep.Pt()>60) continue;
      CutFlow->Fill(5.);
      // lepton cuts
      if(LepGood_relIso[0]*lep.Pt()>10.) continue;
      if(LepGood_relIso[1]*secondLep.Pt()>5.) continue;
      if(LepGood_relIso[1]>.5) continue;
      CutFlow->Fill(6.);
      // JET CUTS
      if(nJet>0){
	if (Jet_pt[0] < 150) continue;
	if(fabs(Jet_eta[0]) > 2.4) continue;
      }
      if(nJet>2){
	if (Jet_pt[2] > 60) continue;
      }
      CutFlow->Fill(7.);
      if(met.Pt()/HT30<2./3.) continue;
      if(nb40!=0) continue;    
      CutFlow->Fill(9.);
    // preselection syncronized to  ++++++++++++++++++++

      if(MT>60&&MT<100) continue;
 
      if (weight==1) puWeight=1; // to not effect data
      float pairmass = DiTau_InvMass(met,lep,secondLep,0);     
      if(lep.Pt()>25||secondLep.Pt()>15) continue;

      if(fabs(LepGood_dz[1]) > 0.02||fabs(LepGood_dz[0]) > 0.02 ||fabs(LepGood_dxy[1])> 0.02  || fabs(LepGood_dxy[0])> 0.02 ) continue;


      // define some over and underflow 
      if (pairmass>2000) pairmass=1999.;
      if (pairmass<0) pairmass=0.;

      LepTwoZmass->Fill(pairmass,weight*puWeight);
      //      cout << LepGood_pdgId[0]* LepGood_pdgId[1] << " Ids "<<endl;

      if(LepGood_pdgId[0]*LepGood_pdgId[1]>121) //same sign
	  {
	 
	      if((pairmass>160||pairmass<20)){
	        
	    
	      CutFlow->Fill(10., weight*puWeight);
	      scanB->Fill(GenSusyMStop,GenSusyMNeutralino);
	      // if (weight<0) weight=1;
	      Sig->Fill(LepGood_sip3d[1],weight*puWeight);
	      Sig0->Fill(LepGood_sip3d[0],weight*puWeight);
	      IP3D->Fill(LepGood_ip3d[0],weight*puWeight);
	      Pt->Fill(secondLep.Pt(),weight*puWeight);
	      Iso->Fill(LepGood_relIso[1]*secondLep.Pt(),weight*puWeight);
	      Dxy->Fill(fabs(LepGood_dxy[1]),weight*puWeight);
	      Dz->Fill(fabs(LepGood_dz[1]),weight*puWeight);
	      DxyDz->Fill(fabs(LepGood_dxy[1]),fabs(LepGood_dz[1]),weight*puWeight);

	      if(nb30L==0)
		{	
		  scanC->Fill(GenSusyMStop,GenSusyMNeutralino);
		}
	      for (int i=0;i<nJet;i++)
		{
		  if(Jet_btagCSV[i]>0.244 ) {
		   LooseBPt->Fill(Jet_pt[i],weight*puWeight );		    
		  }
		  //	   QG->Fill(Jet_quarkGluonID[i]);
		}

	  }


	else // same sign leptons
	  {	  
	   
	  }
      }
          
   }


   scanA->Divide(scan);
   scanB->Divide(scan);
   scanC->Divide(scan);

   //  CutFlow->DrawCopy();

   myFile->Write();
   return (myFile);
      // if (Cut(ientry) < 0) continue;
}
コード例 #10
0
ファイル: testHZZ4l.C プロジェクト: nucleosynthesis/Bacon
//--------------------------------------------------------------------------------------------------
const TPhoton* recoverFsr(const Lepton              &lep,
                          const vector<Lepton>      &lepvec,
                          const pair<Lepton,Lepton> &zcand,
                          const TClonesArray	    *photonArr)
{
    vector<TLorentzVector> photonMoms;
    vector<const TPhoton*> photonObjs;
    TLorentzVector phovec;

    for(int i=0; i<photonArr->GetEntriesFast(); i++) {
        const TPhoton *photon = (TPhoton*)photonArr->At(i);

        phovec.SetPtEtaPhiM(0,0,0,0);
        if((photon->typeBits & kPFMuonPhoton) || (photon->typeBits & kPFPhoton)) {
            // case of muon FSR where photon object is not reconstructed, but photon energy
            // is included in the ECAL energy of the muon object
            phovec.SetPtEtaPhiM(photon->pfPt, photon->pfEta, photon->pfPhi, 0);

        } else {
            continue;
        }

        if(phovec.Pt()        <= 2)   continue;
        if(fabs(phovec.Eta()) >= 2.4) continue;

        double dR = phovec.DeltaR(lep.p4);

        // veto if close to an electron supercluster
        bool flagEleSC = false;
        for(unsigned int j=0; j<lepvec.size(); j++) {
            if(abs(lepvec[j].pdgId)!=ELECTRON_PDGID) continue;

            double dPhi  = fabs(phovec.DeltaPhi(lepvec[j].p4));
            double dEta  = fabs(phovec.Eta() - lepvec[j].p4.Eta());
            if((dPhi<2. && dEta<0.05) || sqrt(dPhi*dPhi + dEta*dEta)<0.15) {
                flagEleSC = true;
                break;
            }
        }
        if(flagEleSC) continue;

        // check input lepton is the closest lepton to this photon
        bool found_closer_lepton = false;
        for(unsigned int j=0; j<lepvec.size(); j++) {
            if(lep.baconObj == lepvec[j].baconObj) continue;

            double tmp_dR = phovec.DeltaR(lepvec[j].p4);
            if(tmp_dR < dR) {
                found_closer_lepton = true;
                break;
            }
        }
        if(found_closer_lepton) continue;

        // Z mass OK?
        double oldMass = (zcand.first.p4 + zcand.second.p4).M();
        double newMass = (zcand.first.p4 + zcand.second.p4 + phovec).M();
        if( newMass <= 4.   ||
                newMass >= 100. ||
                fabs(newMass - Z_MASS) >= fabs(oldMass - Z_MASS) )
            continue;

        // "keep all photons close to one of the 4L leptons..."
        bool use = false;
        if(dR < 0.07) {
            use = true;
        } else if(dR<0.5 && phovec.Pt()>4 && photon->isoForFsr03<1.0*phovec.Pt()) {  // "need tighter cuts for other photons..."
            use = true;
        }
        if(use) {
            photonMoms.push_back(phovec);
            photonObjs.push_back(photon);
        }
    }

    // choose the best one
    double maxPt  =  0, minDR  = 999;
    int    iMaxPt = -1, iMinDR = -1;
    for(unsigned int i=0; i<photonMoms.size(); i++) {
        if(photonMoms[i].Pt() > maxPt) {
            maxPt  = photonMoms[i].Pt();
            iMaxPt = i;
        }
        double tmp_dR = photonMoms[i].DeltaR(lep.p4);
        if(tmp_dR < minDR) {
            minDR  = tmp_dR;
            iMinDR = i;
        }
    }

    if(maxPt > 4) {
        return photonObjs[iMaxPt];
    } else if(minDR < 999) {
        return photonObjs[iMinDR];
    } else {
        return 0;
    }
}
コード例 #11
0
void placeholder::Loop()
{

	//===================================================================================================
	//      MAKE TREE FOR PLACEHOLDER SIGNAL/BG TYPE AND DECLARE VARIABLES
	//===================================================================================================

	// Update output file
	TFile * file1 = new TFile("placeholder.root","RECREATE");
	// create tree for the signal or background type
	TTree *tree=new TTree("PhysicalVariables","PhysicalVariables");

	//*****************************************************************
	//         MUON AND CALOJET/CALOMET VARIABLES BELOW
	//*****************************************************************

	// Particle Counts
	BRANCH(MuonCount); BRANCH(EleCount); BRANCH(PFJetCount); BRANCH(BpfJetCount);
	BRANCH(GlobalMuonCount); BRANCH(TrackerMuonCount);

	// Leading muon 1
	BRANCH(TrkD0_muon1);     BRANCH(NHits_muon1);   BRANCH(TrkDZ_muon1);   BRANCH(ChiSq_muon1);
	BRANCH(TrkIso_muon1); BRANCH(EcalIso_muon1); BRANCH(HcalIso_muon1); BRANCH(RelIso_muon1);
	BRANCH(Phi_muon1);    BRANCH(Eta_muon1);     BRANCH(Pt_muon1);      BRANCH(Charge_muon1);
	BRANCH(QOverPError_muon1); BRANCH(PhiError_muon1);    BRANCH(EtaError_muon1);     BRANCH(PtError_muon1); 

	// Leading muon 2
	BRANCH(TrkD0_muon2);     BRANCH(NHits_muon2);   BRANCH(TrkDZ_muon2);   BRANCH(ChiSq_muon2);
	BRANCH(TrkIso_muon2); BRANCH(EcalIso_muon2); BRANCH(HcalIso_muon2); BRANCH(RelIso_muon2);
	BRANCH(Phi_muon2);    BRANCH(Eta_muon2);     BRANCH(Pt_muon2);      BRANCH(Charge_muon2);
	BRANCH(QOverPError_muon2); BRANCH(PhiError_muon2);    BRANCH(EtaError_muon2);     BRANCH(PtError_muon2); 


	// PFJet 1
	BRANCH(Phi_pfjet1); BRANCH(Eta_pfjet1); BRANCH(Pt_pfjet1); BRANCH(BDisc_pfjet1);
	BRANCH(PFJetNeutralMultiplicity_pfjet1);         BRANCH(PFJetNeutralHadronEnergyFraction_pfjet1);
	BRANCH(PFJetNeutralEmEnergyFraction_pfjet1);     BRANCH(PFJetChargedMultiplicity_pfjet1);
	BRANCH(PFJetChargedHadronEnergyFraction_pfjet1); BRANCH(PFJetChargedEmEnergyFraction_pfjet1);

	// PFJet 2
	BRANCH(Phi_pfjet2); BRANCH(Eta_pfjet2); BRANCH(Pt_pfjet2); BRANCH(BDisc_pfjet2);
	BRANCH(PFJetNeutralMultiplicity_pfjet2);         BRANCH(PFJetNeutralHadronEnergyFraction_pfjet2);
	BRANCH(PFJetNeutralEmEnergyFraction_pfjet2);     BRANCH(PFJetChargedMultiplicity_pfjet2);
	BRANCH(PFJetChargedHadronEnergyFraction_pfjet2); BRANCH(PFJetChargedEmEnergyFraction_pfjet2);

	// Electron (If any)
	BRANCH(Pt_ele1);

	// Event Information
	BRANCH(run_number); BRANCH(event_number); BRANCH(bx);
	BRANCH(xsection);   BRANCH(weight);
	BRANCH(Events_AfterLJ); BRANCH(Events_Orig);
	BRANCH(N_Vertices);

	// PFMET
	BRANCH(MET_pf); BRANCH(Phi_MET_pf);

	// Delta Phi Variables
	BRANCH(deltaPhi_muon1muon2);  BRANCH(deltaPhi_pfjet1pfjet2);
	BRANCH(deltaPhi_muon1pfMET);  BRANCH(deltaPhi_muon2pfMET);
	BRANCH(deltaPhi_pfjet1pfMET); BRANCH(deltaPhi_pfjet2pfMET);
	BRANCH(deltaPhi_muon1pfjet1); BRANCH(deltaPhi_muon1pfjet2);
	BRANCH(deltaPhi_muon2pfjet1); BRANCH(deltaPhi_muon2pfjet2);

	// Delta R Variables
	BRANCH(deltaR_muon1muon2);  BRANCH(deltaR_pfjet1pfjet2);
	BRANCH(deltaR_muon1pfjet1); BRANCH(deltaR_muon1pfjet2);
	BRANCH(deltaR_muon2pfjet1); BRANCH(deltaR_muon2pfjet2);
	BRANCH(deltaR_muon1closestPFJet);

	// Mass Combinations
	BRANCH(M_muon1muon2);  BRANCH(M_pfjet1pfjet2);
	BRANCH(M_muon1pfjet1); BRANCH(M_muon1pfjet2);
	BRANCH(M_muon2pfjet1); BRANCH(M_muon2pfjet2);
	BRANCH(M_muon1muon2pfjet1pfjet2);
	BRANCH(M_bestmupfjet1_mumu); BRANCH(M_bestmupfjet2_mumu);
	BRANCH(M_bestmupfjet_munu);

	// Transverse Mass Combinations
	BRANCH(MT_muon1pfMET);
	BRANCH(MT_pfjet1pfMET); BRANCH(MT_pfjet2pfMET);
	BRANCH(MT_muon1pfjet1); BRANCH(MT_muon1pfjet2);
	BRANCH(MT_muon2pfjet1); BRANCH(MT_muon2pfjet2);

	// ST Variables
	BRANCH(ST_pf_mumu); BRANCH(ST_pf_munu);

	// Other Variables
	BRANCH(minval_muon1pfMET);
	BRANCH(Pt_Z);  BRANCH(Pt_W);
	BRANCH(Phi_Z); BRANCH(Phi_W);
	BRANCH(N_PileUpInteractions);

	// Generator Level Variables
	BRANCH(Pt_genjet1);     BRANCH(Pt_genjet2);
	BRANCH(Pt_genmuon1);    BRANCH(Pt_genmuon2);
	BRANCH(Phi_genmuon1);   BRANCH(Phi_genmuon2);
	BRANCH(Eta_genmuon1);   BRANCH(Eta_genmuon2);
	BRANCH(Pt_genMET);      BRANCH(Phi_genMET);    BRANCH(Eta_genMET);
	BRANCH(Pt_genneutrino); BRANCH(Phi_genneutrino); BRANCH(Eta_genneutrino);
	BRANCH(genWTM);
	BRANCH(Pt_Z_gen);       BRANCH(Pt_W_gen);
	BRANCH(Phi_Z_gen);      BRANCH(Phi_W_gen);

	// Recoil variables
	BRANCH(U1_Z_gen); BRANCH(U2_Z_gen);
	BRANCH(U1_W_gen); BRANCH(U2_W_gen);
	BRANCH(U1_Z);     BRANCH(U2_Z);
	BRANCH(U1_W);     BRANCH(U2_W);
	BRANCH(UdotMu);   BRANCH(UdotMu_overmu);

	//===================================================================================================
	//===================================================================================================

	//===================================================================================================
	//        SETUP WITH SOME TEMPLATE INPUTS AND THRESHOLDS
	//===================================================================================================

	// "desired_luminosity" is a PlaceHolder that gets replaced from the python template replicator
	Double_t lumi=desired_luminosity;

	// PlaceHolder, values stored in bookkeeping/NTupleInfo.csv
	Events_Orig = Numberofevents;

	// Another placeHolder. Needed because recoil corrections only get applied to W MC.
	bool IsW = IsItWMC;
	bool IsSpring11ZAlpgen = IsItSpring11ZAlpgen;

	xsection = crosssection;	 // Another PlaceHolder for the cross sections in bookkeeping/NTupleInfo.csv

	//===================================================================================================
	//===================================================================================================

	//===================================================================================================
	//           LOOP OVER ENTRIES AND MAKE MAIN CALCULATIONS
	//===================================================================================================

	if (fChain == 0) return;	 //check for correctly assigned chain from h file

	Long64_t nentries = fChain->GetEntriesFast();
	Long64_t nbytes = 0, nb = 0;

	//nentries=10000;  /// TEST>>>>>> COMMENT THIS ALWAYS

	for (Long64_t jentry=0; jentry<nentries;jentry++)
	{

		Long64_t ientry = LoadTree(jentry);
		if (ientry < 0) break;
		nb = fChain->GetEntry(jentry);   nbytes += nb;

		//		if (jentry>1000) break;

		// Important Event Informations
		run_number = run;
		event_number = event;
		bx = bunch;

		weight = lumi*xsection/Events_Orig;

		//========================     Weight Fix for Spring 11 Z Alpgen ===============//
		Double_t rescale = 1.0;
		for(unsigned int ip = 0; ip != GenParticlePdgId->size(); ++ip)
		{
			int pdgId = GenParticlePdgId->at(ip);
			int motherIndex = GenParticleMotherIndex->at(ip);
			if (motherIndex >= 0)
			{
				if (abs(GenParticlePdgId->at(motherIndex) ) == 23)
				{
					int lepton = 999;
					if (abs(pdgId) == 11) lepton = 11;
					if (abs(pdgId) == 13) lepton = 13;
					if (abs(pdgId) == 15) lepton = 15;
					if (IsSpring11ZAlpgen)
					{
						if (lepton == 999) rescale = 1.0;
						if (lepton == 11) rescale = electron_rescalevalue;
						if (lepton == 13) rescale = muon_rescalevalue;
						if (lepton == 15) rescale = tau_rescalevalue;
						weight = weight*rescale;
					}
					if (lepton <999) break;
				}
			}
		}

		//========================     HLT Conditions   ================================//

		//		if (run_number<1000)
		//		{
		//			if ( ((*HLTResults)[60] ==1) ||((*HLTResults)[0] ==1) ) precut_HLT=1.0;
		//			else continue;
		//		}

		//		if ((run_number>1000)&&(run_number<146000))
		//		{
		//			if ((*HLTResults)[60] ==1) precut_HLT=1.0;
		//			else continue;
		//		}

		//		if ((run_number>146000)&&(run_number<147455))
		//		{
		//			if ((*HLTResults)[61] ==1) precut_HLT=1.0;
		//			else continue;
		//		}

		//		if (run_number>=147455)
		//		{
		//			if ((*HLTResults)[66] ==1) precut_HLT=1.0;
		//			else continue;
		//		}

		//========================     JSON   Conditions   ================================//

		if (isData)
		{
			bool KeepEvent = PassFilter(run, ls);
			if (!KeepEvent) continue;
		}
		//========================     Vertex Conditions   ================================//

		if ( isBeamScraping ) continue;

		bool vtxFound = false;
		for(unsigned int ivtx = 0; ivtx != VertexZ->size(); ++ivtx)
		{
			if ( VertexIsFake->at(ivtx) == true ) continue;
			if ( VertexNDF->at(ivtx) <= 4.0 ) continue;
			if ( TMath::Abs(VertexZ->at(ivtx)) > 24.0 ) continue;
			if ( TMath::Abs(VertexRho->at(ivtx)) >= 2.0 ) continue;
			vtxFound = true;
			break;
		}
		if ( !vtxFound ) continue;

		N_Vertices = VertexZ->size();

		if (!isData) N_PileUpInteractions = 1.0*PileUpInteractions;

		//========================     Electron Conditions   ================================//

		vector<int> v_idx_ele_final;
		// check if there are electrons
		int nelectrons = 0;
		for(unsigned int iele = 0; iele < ElectronPt->size(); ++iele)
		{
			//			if ( ElectronPt->at(iele) < 15.0 ) continue;
			if ( (ElectronPassID->at(iele) & 1 << 5 ) && ElectronOverlaps->at(iele) == 0 )
			{
				++nelectrons;

				v_idx_ele_final.push_back(iele);
			}
		}

		//========================      Muon Conditions   ================================//

		vector<int> v_idx_muon_final;
		// container for muons
		vector<TLorentzVector> muons;
		int iMUON = -1;
		// select muons

		bool checkPT = true;	 // Pt requirement only on first muon at this stage

		for(unsigned int imuon = 0; imuon < MuonPt->size(); ++imuon)
		{

			float muonPt = MuonPt->at(imuon);
			float muonEta = MuonEta->at(imuon);

			if (checkPT && (muonPt < 30.0) ) continue;
			if  ( fabs(muonEta) > 2.4 )      continue;

			bool PassVBTFLoose =
				MuonIsGlobal ->at(imuon) == 1 &&
				MuonTrackerkIsoSumPT->at(imuon) < 3.0 &&
				MuonTrkHits ->at(imuon) >= 11   ;

			bool PassVBTFTight =
				MuonIsTracker ->at(imuon) == 1 &&
				fabs(MuonTrkD0 ->at(imuon)) < 0.2  &&
				MuonGlobalChi2 ->at(imuon) < 10.0 &&
				MuonPixelHitCount ->at(imuon) >=1 &&
				MuonSegmentMatches->at(imuon) >=2 &&
				MuonGlobalTrkValidHits->at(imuon)>=1 ;

			if ( ! (PassVBTFLoose && PassVBTFTight) ) continue;
			iMUON = imuon;
			TLorentzVector muon;
			muon.SetPtEtaPhiM( MuonPt -> at(imuon), MuonEta-> at(imuon),    MuonPhi-> at(imuon),    0);

			muons.push_back(muon);
			checkPT=false;

			v_idx_muon_final.push_back(imuon);
		}						 // loop over muons

		MuonCount = 1.0*v_idx_muon_final.size();

		if ( MuonCount < 1 ) continue;
		TLorentzVector muon = muons[0];
		
		// SubRoutine for Muon Counts
		GlobalMuonCount = 0.0;
		TrackerMuonCount = 0.0;

		for(unsigned int imuon = 0; imuon < MuonPt->size(); ++imuon)
		{
			if (MuonIsGlobal  ->at(imuon) == 1) GlobalMuonCount += 1.0;
			if (MuonIsTracker ->at(imuon) == 1) TrackerMuonCount += 1.0;
		}

		//========================     PFJet Conditions   ================================//

		// Get Good Jets in general

		deltaR_muon1closestPFJet = 999.9;
		float deltaR_thisjet = 9999.9;
		vector<TLorentzVector> jets;
		vector<int> v_idx_pfjet_prefinal;
		vector<int> v_idx_pfjet_final_unseparated;
		vector<int> v_idx_pfjet_final;
		BpfJetCount = 0.0;

		// Initial Jet Quality Selection
		for(unsigned int ijet = 0; ijet < PFJetPt->size(); ++ijet)
		{
			double jetPt = PFJetPt -> at(ijet);
			double jetEta = PFJetEta -> at(ijet);

			if ( jetPt < 30.0 ) continue;
			if ( fabs(jetEta) > 3.0 ) continue;

			if (PFJetPassLooseID->at(ijet) != 1) continue;
			//if (PFJetPassTightID->at(ijet) != 1) continue;

			v_idx_pfjet_prefinal.push_back(ijet);
		}

		/// Filter out jets that are actually muons
		TLorentzVector thisjet, thismu;
		vector<int> jetstoremove;

		float thisdeltar = 0.0;
		float mindeltar = 99999;
		int minjet = 0;
		int muindex = 99;
		int jetindex = 99;
		// Get list of jets to throw out
		//		for(unsigned int imu=0; imu<v_idx_muon_final.size(); imu++)
		//		{
		//			mindeltar = 999999;
		//			muindex = v_idx_muon_final[imu];
		//			thismu.SetPtEtaPhiM(MuonPt->at(muindex),MuonEta->at(muindex),MuonPhi->at(muindex),0);

		//			for(unsigned int ijet=0; ijet<v_idx_pfjet_prefinal.size(); ijet++)
		//			{
		//				jetindex = v_idx_pfjet_prefinal[ijet];
		//				thisjet.SetPtEtaPhiM((*PFJetPt)[jetindex],(*PFJetEta)[jetindex],(*PFJetPhi)[jetindex],0);

		//				thisdeltar = thismu.DeltaR(thisjet);

		//				if (thisdeltar < mindeltar)
		//				{
		//					mindeltar = thisdeltar;
		//					minjet = ijet;
		//				}
		//			}

		//			if (mindeltar<0.3) jetstoremove.push_back(minjet)       ;

		//		}

		for(unsigned int ijet=0; ijet<v_idx_pfjet_prefinal.size(); ijet++)
		{
			jetindex = v_idx_pfjet_prefinal[ijet];
			thisjet.SetPtEtaPhiM((*PFJetPt)[jetindex],(*PFJetEta)[jetindex],(*PFJetPhi)[jetindex],0);

			for(unsigned int imu=0; imu<v_idx_muon_final.size(); imu++)
			{
				muindex = v_idx_muon_final[imu];
				thismu.SetPtEtaPhiM(MuonPt->at(muindex),MuonEta->at(muindex),MuonPhi->at(muindex),0);

				thisdeltar = thismu.DeltaR(thisjet);

				if (thisdeltar < 0.3)
				{
					jetstoremove.push_back(jetindex);
				}
			}

		}

		jetindex = 99;
		int remjetindex = 99;
		// Eliminate bad jets from prefinal jet vector, save as final
		for(unsigned int ijet=0; ijet<v_idx_pfjet_prefinal.size(); ijet++)
		{
			int jetgood = 1;
			jetindex = v_idx_pfjet_prefinal[ijet];
			for(unsigned int kjet=0; kjet<jetstoremove.size(); kjet++)
			{
				remjetindex = jetstoremove[kjet];
				if (jetindex == remjetindex) jetgood=0;

			}

			if (jetgood ==1) v_idx_pfjet_final_unseparated.push_back(jetindex);
		}

		// Take filtered jets and eliminate those too close to the muon. save b variables

		jetindex = 99;

		for(unsigned int ijet=0; ijet<v_idx_pfjet_final_unseparated.size(); ijet++)
		{
			jetindex = v_idx_pfjet_final_unseparated[ijet];
			double jetPt = PFJetPt -> at(jetindex);
			double jetEta = PFJetEta -> at(jetindex);

			TLorentzVector newjet;
			newjet.SetPtEtaPhiM(jetPt,  jetEta, PFJetPhi->at(jetindex),     0);
			// require a separation between a muon and a jet

			deltaR_thisjet =  newjet.DeltaR(muon);
			if ( deltaR_thisjet < deltaR_muon1closestPFJet)  deltaR_muon1closestPFJet = deltaR_thisjet ;

			//			if ( deltaR_thisjet < 0.5 ) continue;

			if ( PFJetTrackCountingHighEffBTag->at(jetindex) > 1.7 )
			{
				BpfJetCount = BpfJetCount + 1.0;
			}

			// if we are here, the jet is good
			v_idx_pfjet_final.push_back(jetindex);
		}
		PFJetCount = 1.0*v_idx_pfjet_final.size();

		if (PFJetCount <2) continue;

		//========================     Generator Level Module  ================================//

		float piover2 = 3.1415926/2.0;
		TLorentzVector V_MetAddition;
		V_MetAddition.SetPtEtaPhiM(0.0,0.0,0.0,0.0);

		TLorentzVector UW_gen , BW_gen, v_GenNu, muon1test;

		BW_gen.SetPtEtaPhiM(0,0,0,0); UW_gen.SetPtEtaPhiM(0,0,0,0); v_GenNu.SetPtEtaPhiM(0,0,0,0), muon1test.SetPtEtaPhiM(0,0,0,0) ;

		// Generator Level Variables
		VRESET(Pt_genjet1);     VRESET(Pt_genjet2);
		VRESET(Pt_genmuon1);    VRESET(Pt_genmuon2);
		VRESET(Phi_genmuon1);   VRESET(Phi_genmuon2);
		VRESET(Eta_genmuon1);   VRESET(Eta_genmuon2);
		VRESET(Pt_genMET);      VRESET(Phi_genMET);    VRESET(Eta_genMET);
		VRESET(Pt_genneutrino); VRESET(Phi_genneutrino); VRESET(Eta_genneutrino);
		VRESET(genWTM);
		VRESET(Pt_Z_gen);       VRESET(Pt_W_gen);
		VRESET(Phi_Z_gen);      VRESET(Phi_W_gen);

		// Recoil variables
		VRESET(U1_Z_gen); VRESET(U2_Z_gen);
		VRESET(U1_W_gen); VRESET(U2_W_gen);

		/// Generator Addon
		if (!isData)
		{

			Pt_genjet1 = 0;
			Pt_genjet2 = 0;
			Pt_genmuon1 = 0;
			Pt_genmuon2 = 0;
			Phi_genmuon1 = 0;
			Eta_genmuon1 = 0;
			Phi_genmuon2 = 0;
			Eta_genmuon2 = 0;
			Pt_genMET = 0;
			Pt_genneutrino = 0;
			Eta_genneutrino = 0;
			Phi_genneutrino = 0;
			Phi_genMET = 0;
			Eta_genMET = 0;

			for(unsigned int ijet = 0; ijet < GenJetPt->size(); ++ijet)
			{
				if (ijet ==0) Pt_genjet1 = GenJetPt->at(ijet);
				if (ijet ==1) Pt_genjet2 = GenJetPt->at(ijet);
			}

			for(unsigned int ip = 0; ip != GenParticlePdgId->size(); ++ip)
			{

				int pdgId = GenParticlePdgId->at(ip);
				int motherIndex = GenParticleMotherIndex->at(ip);
								 // ISR
				if ( motherIndex == -1 ) continue;
				int pdgIdMother = GenParticlePdgId->at(motherIndex);

				//muon
								 // && TMath::Abs(pdgIdMother) == 23 ) {
				if ( TMath::Abs(pdgId) == 13 )
				{
					//				std::cout<<GenParticlePt -> at (ip)<<"   "<<GenParticlePhi-> at (ip)<<std::endl;

					if (Pt_genmuon1==0)
					{
						Pt_genmuon1 = GenParticlePt -> at (ip);
						Phi_genmuon1 = GenParticlePhi-> at (ip);
						Eta_genmuon1 = GenParticleEta-> at (ip);
					}

					if (Pt_genmuon1>0)
					{
						Pt_genmuon2 = GenParticlePt -> at (ip);
						Phi_genmuon2 = GenParticlePhi-> at (ip);
						Eta_genmuon2 = GenParticleEta-> at (ip);
					}

				}

								 // Muon Neutrino
				if ( TMath::Abs(pdgId) == 14 )
				{

					if (GenParticlePt->at(ip) > Pt_genneutrino)
					{
						Pt_genneutrino = GenParticlePt -> at (ip);
						Phi_genneutrino = GenParticlePhi-> at (ip);
						Eta_genneutrino = GenParticleEta-> at (ip);
					}
				}

			}

			Pt_genMET = GenMETTrue->at(0);
			Phi_genMET = GenMETPhiTrue->at(0);
			genWTM = 0.0;
			genWTM =  TMass(Pt_genmuon1,Pt_genMET, fabs(Phi_genmuon1 - Phi_genMET) );

			// Set the recoil variables

			U1_Z_gen = 990.0;
			U2_Z_gen = 990.0;
			U1_W_gen = 990.0;
			U2_W_gen = 990.0;

			TLorentzVector v_GenMuon1, v_GenMuon2, v_GenMet;

			v_GenMuon1.SetPtEtaPhiM(Pt_genmuon1,Eta_genmuon1,Phi_genmuon1,0);
			v_GenMuon2.SetPtEtaPhiM(Pt_genmuon2,Eta_genmuon2,Phi_genmuon2,0);
			v_GenNu.SetPtEtaPhiM( Pt_genneutrino ,Eta_genneutrino,Phi_genneutrino ,0);
			v_GenMet.SetPtEtaPhiM ( Pt_genMET, 0, Phi_genMET,0 );

			Pt_Z_gen = (v_GenMuon1 + v_GenMuon2).Pt();
			Phi_Z_gen = (v_GenMuon1 + v_GenMuon2).Phi();

			TLorentzVector UZ_gen = -(v_GenMet + v_GenMuon1 + v_GenMuon2);
			TLorentzVector BZ_gen = (v_GenMuon1+v_GenMuon2 );
			U1_Z_gen = (UZ_gen.Pt()) * (cos(UZ_gen.DeltaPhi(BZ_gen))) ;
			U2_Z_gen = (UZ_gen.Pt()) * (sin(UZ_gen.DeltaPhi(BZ_gen))) ;

			TLorentzVector pfMETtest;
			pfMETtest.SetPtEtaPhiM(PFMET->at(0),0.0,PFMETPhi->at(0),0.0);
			muon1test.SetPtEtaPhiM(MuonPt->at(v_idx_muon_final[0]),MuonEta->at(v_idx_muon_final[0]),MuonPhi->at(v_idx_muon_final[0]),0.0);

			Pt_W_gen = (muon1test + v_GenNu).Pt();
			Phi_W_gen = (muon1test + v_GenNu).Phi();

			UW_gen = -(pfMETtest + muon1test );
			BW_gen = (muon1test +v_GenNu);
			U1_W_gen = (UW_gen.Pt()) * (cos(UW_gen.DeltaPhi(BW_gen))) ;
			U2_W_gen = (UW_gen.Pt()) * (sin(UW_gen.DeltaPhi(BW_gen))) ;

			if (IsW && DoRecoilCorrections)
			{

				float U1Phi = - BW_gen.Phi();
				float U2Phi = BW_gen.Phi() + piover2;

				if ((BW_gen.DeltaPhi(UW_gen)) < 0)   U2Phi = BW_gen.Phi() - piover2;

				float U1Prime = F_U1Prime(Pt_W_gen);
				float U2Prime = F_U2Prime(Pt_W_gen);

				TLorentzVector V_UPrime, V_U1Prime, V_U2Prime, V_MetPrime;

				V_U1Prime.SetPtEtaPhiM(U1Prime,0,U1Phi,0);
				V_U2Prime.SetPtEtaPhiM(U2Prime,0,U2Phi,0);
				V_UPrime = V_U1Prime + V_U2Prime;
				V_MetPrime = -(v_GenMuon1+ V_UPrime);

				V_MetAddition.SetPtEtaPhiM(V_MetPrime.Pt(),0,V_MetPrime.Phi(),0);
				V_MetAddition = V_MetAddition - v_GenMet;

			}
		}

		//========================     Set variables to zero  ================================//

		// Leading muon 1
		VRESET(TrkD0_muon1);     VRESET(NHits_muon1);   VRESET(TrkDZ_muon1);   VRESET(ChiSq_muon1);
		VRESET(TrkIso_muon1); VRESET(EcalIso_muon1); VRESET(HcalIso_muon1); VRESET(RelIso_muon1);
		VRESET(Phi_muon1);    VRESET(Eta_muon1);     VRESET(Pt_muon1);      VRESET(Charge_muon1);
		VRESET(QOverPError_muon1); VRESET(PhiError_muon1);    VRESET(EtaError_muon1);     VRESET(PtError_muon1); 


		// Leading muon 2
		VRESET(TrkD0_muon2);     VRESET(NHits_muon2);   VRESET(TrkDZ_muon2);   VRESET(ChiSq_muon2);
		VRESET(TrkIso_muon2); VRESET(EcalIso_muon2); VRESET(HcalIso_muon2); VRESET(RelIso_muon2);
		VRESET(Phi_muon2);    VRESET(Eta_muon2);     VRESET(Pt_muon2);      VRESET(Charge_muon2);
		VRESET(QOverPError_muon2); VRESET(PhiError_muon2);    VRESET(EtaError_muon2);     VRESET(PtError_muon2); 


		// PFJet 1
		VRESET(Phi_pfjet1); VRESET(Eta_pfjet1); VRESET(Pt_pfjet1); VRESET(BDisc_pfjet1);
		VRESET(PFJetNeutralMultiplicity_pfjet1);         VRESET(PFJetNeutralHadronEnergyFraction_pfjet1);
		VRESET(PFJetNeutralEmEnergyFraction_pfjet1);     VRESET(PFJetChargedMultiplicity_pfjet1);
		VRESET(PFJetChargedHadronEnergyFraction_pfjet1); VRESET(PFJetChargedEmEnergyFraction_pfjet1);

		// PFJet 2
		VRESET(Phi_pfjet2); VRESET(Eta_pfjet2); VRESET(Pt_pfjet2); VRESET(BDisc_pfjet2);
		VRESET(PFJetNeutralMultiplicity_pfjet2);         VRESET(PFJetNeutralHadronEnergyFraction_pfjet2);
		VRESET(PFJetNeutralEmEnergyFraction_pfjet2);     VRESET(PFJetChargedMultiplicity_pfjet2);
		VRESET(PFJetChargedHadronEnergyFraction_pfjet2); VRESET(PFJetChargedEmEnergyFraction_pfjet2);

		// Electron (If any)

		VRESET(Pt_ele1);
		// PFMET
		VRESET(MET_pf); VRESET(Phi_MET_pf);

		// Delta Phi Variables
		VRESET(deltaPhi_muon1muon2);  VRESET(deltaPhi_pfjet1pfjet2);
		VRESET(deltaPhi_muon1pfMET);  VRESET(deltaPhi_muon2pfMET);
		VRESET(deltaPhi_pfjet1pfMET); VRESET(deltaPhi_pfjet2pfMET);
		VRESET(deltaPhi_muon1pfjet1); VRESET(deltaPhi_muon1pfjet2);
		VRESET(deltaPhi_muon2pfjet1); VRESET(deltaPhi_muon2pfjet2);

		// Delta R Variables
		VRESET(deltaR_muon1muon2);  VRESET(deltaR_pfjet1pfjet2);
		VRESET(deltaR_muon1pfjet1); VRESET(deltaR_muon1pfjet2);
		VRESET(deltaR_muon2pfjet1); VRESET(deltaR_muon2pfjet2);
		VRESET(deltaR_muon1closestPFJet);

		// Mass Combinations
		VRESET(M_muon1muon2);  VRESET(M_pfjet1pfjet2);
		VRESET(M_muon1pfjet1); VRESET(M_muon1pfjet2);
		VRESET(M_muon2pfjet1); VRESET(M_muon2pfjet2);
		VRESET(M_muon1muon2pfjet1pfjet2);
		VRESET(M_bestmupfjet1_mumu); VRESET(M_bestmupfjet2_mumu);
		VRESET(M_bestmupfjet_munu);

		// Transverse Mass Combinations
		VRESET(MT_muon1pfMET);
		VRESET(MT_pfjet1pfMET); VRESET(MT_pfjet2pfMET);
		VRESET(MT_muon1pfjet1); VRESET(MT_muon1pfjet2);
		VRESET(MT_muon1pfjet2); VRESET(MT_muon2pfjet2);

		// ST Variables
		VRESET(ST_pf_mumu); VRESET(ST_pf_munu);

		// Other Variables
		VRESET(minval_muon1pfMET);
		VRESET(Pt_Z);  VRESET(Pt_W);
		VRESET(Phi_Z); VRESET(Phi_W);

		// Recoil variables
		VRESET(U1_Z);     VRESET(U2_Z);
		VRESET(U1_W);     VRESET(U2_W);
		VRESET(UdotMu);   VRESET(UdotMu_overmu);

		//===================================================================================================
		//      Run the Calculations of physical variables using selected particles.
		//===================================================================================================

		// 4-Vectors for Particles
		TLorentzVector jet1, jet2, pfjet1, pfjet2, muon1,muon3, caloMET,muon2,pfMET,tcMET;

		//========================     MET Basics  ================================//

		MET_pf = PFMET->at(0);
		pfMET.SetPtEtaPhiM(MET_pf,0.0,PFMETPhi->at(0),0.0);

		//========================     MET Recoil Correction  ================================//

		// Recoil Corrections
		if (IsW && DoRecoilCorrections && true)
		{

			// Very careful calculation of the geometry of the recoil vectors.
			float U1Phi =  BW_gen.Phi() + 2*piover2;
			if (U1Phi> (2*piover2)) U1Phi = U1Phi - 4*piover2;

			float check_phi_u1 = U1Phi; if (check_phi_u1<0) check_phi_u1 = check_phi_u1 + 4*piover2;
			float check_phi_w = BW_gen.Phi(); if (check_phi_w<0) check_phi_w = check_phi_w +  4*piover2;
			float check_phi_u = UW_gen.Phi(); if (check_phi_u<0) check_phi_u = check_phi_u +  4*piover2;

			float check_phi_u2 = 99;
			if ((check_phi_w<2*piover2)&&(check_phi_u>check_phi_w)) check_phi_u2 = check_phi_w + piover2;
			if ((check_phi_w<2*piover2)&&(check_phi_u<check_phi_w)) check_phi_u2 = check_phi_w - piover2;
			if ((check_phi_w>2*piover2)&&(check_phi_u>check_phi_w)) check_phi_u2 = check_phi_w + piover2;
			if ((check_phi_w>2*piover2)&&(check_phi_u<check_phi_w)&&(check_phi_u>(check_phi_w - 2*piover2))) check_phi_u2 = check_phi_w - piover2;
			if ((check_phi_w>2*piover2)&&(check_phi_u<check_phi_w)&&(check_phi_u<(check_phi_w - 2*piover2))) check_phi_u2 = check_phi_w + piover2;
			if (check_phi_u2 > 4*piover2) check_phi_u2 = check_phi_u2 - 4*piover2;

			// Get the new recoil vectors
			float U2Phi = check_phi_u2;
			float reco_Pt_W = (muon1test + v_GenNu).Pt();
			float U1Prime = F_U1Prime(reco_Pt_W);
			float U2Prime = F_U2Prime(reco_Pt_W);

			// Change the MET vector based on the new recoil vectors
			TLorentzVector V_UPrime, V_U1Prime, V_U2Prime, V_MetPrime;

			V_U1Prime.SetPtEtaPhiM(U1Prime,0,U1Phi,0);
			V_U2Prime.SetPtEtaPhiM(U2Prime,0,U2Phi,0);

			V_UPrime = V_U1Prime + V_U2Prime;
			V_MetPrime = -(muon1test+ V_UPrime);

			pfMET.SetPtEtaPhiM(V_MetPrime.Pt(),0,V_MetPrime.Phi(),0);
			MET_pf = pfMET.Pt();

		}

		//========================    Electrons?  ================================//

		if (EleCount>=1)
		{
			Pt_ele1 = ElectronPt->at(v_idx_ele_final[0]);
		}

		//========================   At least 1 muon  ================================//

		if (MuonCount>=1)
		{
			// Quality Variables
			TrkD0_muon1 = MuonTrkD0->at(v_idx_muon_final[0]);
			NHits_muon1 = MuonTrkHits ->at(v_idx_muon_final[0]);
			Charge_muon1 = MuonCharge->at(v_idx_muon_final[0]);
			RelIso_muon1 = MuonRelIso->at(v_idx_muon_final[0]);
			TrkDZ_muon1 = MuonTrkDz->at(v_idx_muon_final[0]);
			TrkIso_muon1 = MuonTrkIso->at(v_idx_muon_final[0]);
			EcalIso_muon1 = MuonEcalIso->at(v_idx_muon_final[0]);
			HcalIso_muon1 = MuonHcalIso->at(v_idx_muon_final[0]);
			ChiSq_muon1 = MuonGlobalChi2->at(v_idx_muon_final[0]);
            QOverPError_muon1 = MuonQOverPError->at(v_idx_muon_final[0]);
            PhiError_muon1  = MuonPhiError->at(v_idx_muon_final[0]);
            EtaError_muon1  = MuonEtaError->at(v_idx_muon_final[0]);
            PtError_muon1 = MuonPtError->at(v_idx_muon_final[0]);



			// muon Pt/Eta/Phi
			Pt_muon1 = MuonPt->at(v_idx_muon_final[0]);
			Phi_muon1 = MuonPhi->at(v_idx_muon_final[0]);
			Eta_muon1 = MuonEta->at(v_idx_muon_final[0]);

			// Other Variables
			muon1.SetPtEtaPhiM(Pt_muon1,Eta_muon1,Phi_muon1,0);

			deltaPhi_muon1pfMET = (pfMET.DeltaPhi(muon1));
			MT_muon1pfMET = TMass(Pt_muon1,MET_pf,deltaPhi_muon1pfMET);

			minval_muon1pfMET = Pt_muon1;
			if (MET_pf < Pt_muon1) minval_muon1pfMET = MET_pf;

			// Recoil Stuff
			Pt_W = (muon1 + pfMET).Pt();
			Phi_W = (muon1 + pfMET).Phi();

			TLorentzVector UW = -(pfMET + muon1);
			TLorentzVector BW = (muon1+pfMET);

			U1_W = (UW.Pt()) * (cos(UW.DeltaPhi(BW))) ;
			U2_W = (UW.Pt()) * (sin(UW.DeltaPhi(BW))) ;

			UdotMu = Pt_muon1*UW.Pt()*cos(UW.DeltaPhi(muon1));
			UdotMu_overmu = UW.Pt()*cos(UW.DeltaPhi(muon1));

		}

		//========================   At least 2 muon  ================================//

		if (MuonCount>=2)
		{
			// Quality Variables
			TrkD0_muon2 = MuonTrkD0->at(v_idx_muon_final[1]);
			NHits_muon2 = MuonTrkHits ->at(v_idx_muon_final[1]);
			Charge_muon2 = MuonCharge->at(v_idx_muon_final[1]);
			RelIso_muon2 = MuonRelIso->at(v_idx_muon_final[1]);
			TrkDZ_muon2 = MuonTrkDz->at(v_idx_muon_final[1]);
			TrkIso_muon2 = MuonTrkIso->at(v_idx_muon_final[1]);
			EcalIso_muon2 = MuonEcalIso->at(v_idx_muon_final[1]);
			HcalIso_muon2 = MuonHcalIso->at(v_idx_muon_final[1]);
			ChiSq_muon2 = MuonGlobalChi2->at(v_idx_muon_final[1]);
            QOverPError_muon2 = MuonQOverPError->at(v_idx_muon_final[1]);
            PhiError_muon2  = MuonPhiError->at(v_idx_muon_final[1]);
            EtaError_muon2  = MuonEtaError->at(v_idx_muon_final[1]);
            PtError_muon2 = MuonPtError->at(v_idx_muon_final[1]);
			
			

			// muon Pt/Eta/Phi
			Pt_muon2 = MuonPt->at(v_idx_muon_final[1]);
			Phi_muon2 = MuonPhi->at(v_idx_muon_final[1]);
			Eta_muon2 = MuonEta->at(v_idx_muon_final[1]);

			// Other Variables
			muon2.SetPtEtaPhiM(Pt_muon2,Eta_muon2,Phi_muon2,0);

			deltaPhi_muon1pfMET = (pfMET.DeltaPhi(muon1));

			deltaPhi_muon1muon2 = (muon1.DeltaPhi(muon2));
			deltaR_muon1muon2 = muon1.DeltaR(muon2);
			M_muon1muon2 = (muon1+muon2).M();

			// Boson PT
			TLorentzVector UZ = -(pfMET + muon1 + muon2);
			TLorentzVector BZ = (muon1+muon2);

			U1_Z = (UZ.Pt()) * (cos(UZ.DeltaPhi(BZ))) ;
			U2_Z = (UZ.Pt()) * (sin(UZ.DeltaPhi(BZ))) ;

			Pt_Z = (muon1 + muon2).Pt();
			Phi_Z = (muon1 + muon2).Phi();

		}

		//========================   At least 1 PFJET  ================================//

		if (PFJetCount>=1)
		{

			// Jet Quality
			PFJetNeutralMultiplicity_pfjet1= PFJetNeutralMultiplicity->at(v_idx_pfjet_final[0]);
			PFJetNeutralHadronEnergyFraction_pfjet1= PFJetNeutralHadronEnergyFraction->at(v_idx_pfjet_final[0]);
			PFJetNeutralEmEnergyFraction_pfjet1= PFJetNeutralEmEnergyFraction->at(v_idx_pfjet_final[0]);
			PFJetChargedMultiplicity_pfjet1= PFJetChargedMultiplicity->at(v_idx_pfjet_final[0]);
			PFJetChargedHadronEnergyFraction_pfjet1= PFJetChargedHadronEnergyFraction->at(v_idx_pfjet_final[0]);
			PFJetChargedEmEnergyFraction_pfjet1= PFJetChargedEmEnergyFraction->at(v_idx_pfjet_final[0]);

			// Pt/Eta/Phi
			Pt_pfjet1 = PFJetPt->at(v_idx_pfjet_final[0]);
			Phi_pfjet1 = PFJetPhi->at(v_idx_pfjet_final[0]);
			Eta_pfjet1 = PFJetEta->at(v_idx_pfjet_final[0]);

			// Other Variables
			pfjet1.SetPtEtaPhiM(Pt_pfjet1,Eta_pfjet1,Phi_pfjet1,0);

			deltaPhi_pfjet1pfMET = (pfMET.DeltaPhi(pfjet1));
			MT_pfjet1pfMET = TMass(Pt_pfjet1,MET_pf,deltaPhi_pfjet1pfMET);
			BDisc_pfjet1 = PFJetTrackCountingHighEffBTag->at(v_idx_pfjet_final[0]);

		}

		//========================   At least 2 PFJET  ================================//

		if (PFJetCount>=2)
		{
			// Pt/Eta/Phi
			Pt_pfjet2 = PFJetPt->at(v_idx_pfjet_final[1]);
			Phi_pfjet2 = PFJetPhi->at(v_idx_pfjet_final[1]);
			Eta_pfjet2 = PFJetEta->at(v_idx_pfjet_final[1]);

			// Jet Quality
			PFJetNeutralMultiplicity_pfjet2= PFJetNeutralMultiplicity->at(v_idx_pfjet_final[1]);
			PFJetNeutralHadronEnergyFraction_pfjet2= PFJetNeutralHadronEnergyFraction->at(v_idx_pfjet_final[1]);
			PFJetNeutralEmEnergyFraction_pfjet2= PFJetNeutralEmEnergyFraction->at(v_idx_pfjet_final[1]);
			PFJetChargedMultiplicity_pfjet2= PFJetChargedMultiplicity->at(v_idx_pfjet_final[1]);
			PFJetChargedHadronEnergyFraction_pfjet2= PFJetChargedHadronEnergyFraction->at(v_idx_pfjet_final[1]);
			PFJetChargedEmEnergyFraction_pfjet2= PFJetChargedEmEnergyFraction->at(v_idx_pfjet_final[1]);

			// Other Variables
			pfjet2.SetPtEtaPhiM(Pt_pfjet2,Eta_pfjet2,Phi_pfjet2,0);

			BDisc_pfjet2 = PFJetTrackCountingHighEffBTag->at(v_idx_pfjet_final[1]);

			deltaPhi_pfjet2pfMET = (pfMET.DeltaPhi(pfjet2));
			MT_pfjet2pfMET = TMass(Pt_pfjet2,MET_pf,deltaPhi_pfjet2pfMET);

			deltaR_pfjet1pfjet2 = pfjet1.DeltaR(pfjet2);
			deltaPhi_pfjet1pfjet2 = (pfjet1.DeltaPhi(pfjet2));
			M_pfjet1pfjet2 = (pfjet1 + pfjet2).M();
		}

		//========================   1 Muon 1 Jet ================================//

		if ((MuonCount>0) && (PFJetCount> 0))
		{
			deltaPhi_muon1pfjet1 = (muon1.DeltaPhi(pfjet1));
			deltaR_muon1pfjet1 = (muon1.DeltaR(pfjet1));
			M_muon1pfjet1 = (pfjet1 + muon1).M();
			MT_muon1pfjet1 = TMass(Pt_pfjet1,Pt_muon1,deltaPhi_muon1pfjet1);
		}

		//========================   1 Muon 2 Jet ================================//

		if ((MuonCount>0) && (PFJetCount> 1))
		{
			deltaPhi_muon1pfjet2 = (muon1.DeltaPhi(pfjet2));
			deltaR_muon1pfjet2 = (muon1.DeltaR(pfjet2));
			M_muon1pfjet2 = (pfjet2 + muon1).M();
			MT_muon1pfjet2 = TMass(Pt_pfjet2,Pt_muon1,deltaPhi_muon1pfjet2);
			ST_pf_munu= Pt_muon1 + MET_pf + Pt_pfjet1 + Pt_pfjet2;

		}

		//========================   2 Muon 1 Jet ================================//

		if ((MuonCount>1) && (PFJetCount> 0))
		{
			deltaPhi_muon2pfjet1 = (muon2.DeltaPhi(pfjet1));
			deltaR_muon2pfjet1 = (muon2.DeltaR(pfjet1));
			M_muon2pfjet1 = (pfjet1+muon2).M();
			MT_muon2pfjet1 = TMass(Pt_pfjet1,Pt_muon2,deltaPhi_muon2pfjet1);
		}

		//========================   2 Muon 2 Jet ================================//

		if ((MuonCount>1) && (PFJetCount> 1))
		{
			deltaPhi_muon2pfjet2 = (muon2.DeltaPhi(pfjet2));
			deltaR_muon2pfjet2 = (muon2.DeltaR(pfjet2));
			ST_pf_mumu= Pt_muon1 + Pt_muon2 + Pt_pfjet1 + Pt_pfjet2;
			M_muon2pfjet2 = (pfjet2 + muon2).M();
			MT_muon2pfjet2 = TMass(Pt_pfjet2,Pt_muon2,deltaPhi_muon2pfjet2);

			M_muon1muon2pfjet1pfjet2 = (muon1+muon2+pfjet1+pfjet2).M();
		}

		//========================   LQ Mass Concepts ================================//

		// DiMuon, minimizing differene between mu-jet masses
		if ((MuonCount>1) && (PFJetCount> 1))
		{
			if (abs(M_muon1pfjet1 - M_muon2pfjet2) < abs(M_muon1pfjet2 - M_muon2pfjet1) )
			{
				M_bestmupfjet1_mumu = M_muon1pfjet1;
				M_bestmupfjet2_mumu = M_muon2pfjet2;
			}

			if (abs(M_muon1pfjet1 - M_muon2pfjet2) > abs(M_muon1pfjet2 - M_muon2pfjet1) )
			{
				M_bestmupfjet1_mumu = M_muon2pfjet1;
				M_bestmupfjet2_mumu = M_muon1pfjet2;
			}
		}

		// Beta - Half production - minimize difference of transverse masses
		if ((MuonCount>0) && (PFJetCount> 1))
		{
			if (abs(MT_muon1pfjet1 - MT_pfjet2pfMET) < abs(MT_muon1pfjet2 - MT_pfjet1pfMET) )
			{
				M_bestmupfjet_munu= M_muon1pfjet1;
			}

			if (abs(MT_muon1pfjet1 - MT_pfjet2pfMET) > abs(MT_muon1pfjet2 - MT_pfjet1pfMET) )
			{
				M_bestmupfjet_munu= M_muon1pfjet2;
			}
		}

		tree->Fill();			 // FILL FINAL TREE

	}

	tree->Write();
	file1->Close();
}
コード例 #12
0
ファイル: AnaSjePy8Mass.C プロジェクト: xcheung/AnaSubjetsMC
int main(int argc, char* argv[])
{
  TApplication theApp(srcName.Data(), &argc, argv);
//=============================================================================

  if (argc<5) return -1;
  TString sPath = argv[1]; if (sPath.IsNull()) return -1;
  TString sFile = argv[2]; if (sFile.IsNull()) return -1;
  TString sJetR = argv[3]; if (sJetR.IsNull()) return -1;
  TString sSjeR = argv[4]; if (sSjeR.IsNull()) return -1;
//=============================================================================

  sPath.ReplaceAll("#", "/");
//=============================================================================

  double dJetR = -1.;
  if (sJetR=="JetR02") dJetR = 0.2;
  if (sJetR=="JetR03") dJetR = 0.3;
  if (sJetR=="JetR04") dJetR = 0.4;
  if (sJetR=="JetR05") dJetR = 0.5;

  if (dJetR<0.) return -1;
  cout << "Jet R = " << dJetR << endl;
//=============================================================================

  double dSjeR = -1.;
  if (sSjeR=="SjeR01") dSjeR = 0.1;
  if (sSjeR=="SjeR02") dSjeR = 0.2;
  if (sSjeR=="SjeR03") dSjeR = 0.3;
  if (sSjeR=="SjeR04") dSjeR = 0.4;

  if (dSjeR<0.) return -1;
  cout << "Sub-jet R = " << dSjeR << endl;
//=============================================================================

  const double dJetsPtMin  = 0.001;
  const double dCutEtaMax  = 1.6;
  const double dJetEtaMax  = 1.;
  const double dJetAreaRef = TMath::Pi() * dJetR * dJetR;

  fastjet::GhostedAreaSpec areaSpc(dCutEtaMax);
  fastjet::JetDefinition   jetsDef(fastjet::antikt_algorithm, dJetR, fastjet::E_scheme, fastjet::Best);
  fastjet::AreaDefinition  areaDef(fastjet::active_area_explicit_ghosts,areaSpc);

  fastjet::Selector selectJet = fastjet::SelectorAbsEtaMax(dJetEtaMax);
  fastjet::JetDefinition subjDef(fastjet::kt_algorithm, dSjeR, fastjet::E_scheme, fastjet::Best);
//=============================================================================

  std::vector<fastjet::PseudoJet> fjInput;

  const Double_t dCut = TMath::TwoPi() / 3.;
  const double dMass  = TDatabasePDG::Instance()->GetParticle(211)->Mass();
//=============================================================================

  enum { kWgt, kLje, kLjr, kLtk, kLtr, kJet, kAje, kMje, k1sz, k1sA, k1sm, k1sr, k2sz, k2sA, k2sm, k2sr, kDsm, kDsr, kVar };

  TFile *file = TFile::Open(Form("%s.root",sFile.Data()), "NEW");
  TNtuple *nt = new TNtuple("nt", "", "fWgt:fLje:fLjr:fLtk:fLtr:fJet:fAje:fMje:f1sj:f1sA:f1sm:f1sr:f2sj:f2sA:f2sm:f2sr:fDsm:fDsr");
//=============================================================================

  HepMC::IO_GenEvent ascii_in(Form("%s/%s.hepmc",sPath.Data(),sFile.Data()), std::ios::in);
  HepMC::GenEvent *evt = ascii_in.read_next_event();

  while (evt) {
    fjInput.resize(0);

    double dLtk = -1.;
    TLorentzVector vPar, vLtk;
    for (HepMC::GenEvent::particle_const_iterator p=evt->particles_begin(); p!=evt->particles_end(); ++p) if ((*p)->status()==1) {
      double dEta = (*p)->momentum().eta(); if (TMath::Abs(dEta)>dCutEtaMax) continue;

      double dTrk = (*p)->momentum().perp();
      double dPhi = (*p)->momentum().phi();
      vPar.SetPtEtaPhiM(dTrk, dEta, dPhi, dMass);
      fjInput.push_back(fastjet::PseudoJet(vPar.Px(), vPar.Py(), vPar.Pz(), vPar.E()));
      if (dTrk>dLtk) { dLtk = dTrk; vLtk.SetPtEtaPhiM(dTrk, dEta, dPhi, dMass); }
    }
//=============================================================================

    fastjet::ClusterSequenceArea clustSeq(fjInput, jetsDef, areaDef);
    std::vector<fastjet::PseudoJet> includJets = clustSeq.inclusive_jets(dJetsPtMin);
    std::vector<fastjet::PseudoJet> selectJets = selectJet(includJets);
//=============================================================================

    if (selectJets.size()>0) {
      std::vector<fastjet::PseudoJet> sortedJets = fastjet::sorted_by_pt(selectJets);
      TLorentzVector vLje; vLje.SetPtEtaPhiM(sortedJets[0].pt(), sortedJets[0].eta(), sortedJets[0].phi(), sortedJets[0].m());

      TLorentzVector vJet;
      int kJrl = -1; double dJrl = -1.;
      int kTrl = -1; double dTrl = -1.;
      for (int j=0; j<sortedJets.size(); j++) {
        double dJet = sortedJets[j].pt();
        sortedJets[j].set_user_index(-1);
        vJet.SetPtEtaPhiM(dJet, sortedJets[j].eta(), sortedJets[j].phi(), sortedJets[j].m());
        if (TMath::Abs(vJet.DeltaPhi(vLje))>dCut) { sortedJets[j].set_user_index(1); if (dJet>dJrl) { dJrl = dJet; kJrl = j; } }
        if (TMath::Abs(vJet.DeltaPhi(vLtk))>dCut) { sortedJets[j].set_user_index(2); if (dJet>dTrl) { dTrl = dJet; kTrl = j; } }
      }
//=============================================================================

      TLorentzVector v1sj, v2sj, vDsj;
      for (int j=0; j<sortedJets.size(); j++) {
        Float_t dVar[kVar]; for (Int_t i=0; i<kVar; i++) dVar[i] = -1.; dVar[kWgt] = 1.;
        vJet.SetPtEtaPhiM(sortedJets[j].pt(), sortedJets[j].eta(), sortedJets[j].phi(), sortedJets[j].m());
//=============================================================================

        dVar[kLje] = vLje.Pt(); if (sortedJets[j].user_index()==1) { dVar[kLjr] = ((kJrl==j) ? 1.5 : 0.5); }
        dVar[kLtk] = vLtk.Pt(); if (sortedJets[j].user_index()==2) { dVar[kLtr] = ((kTrl==j) ? 1.5 : 0.5); }
//=============================================================================

        dVar[kJet] = sortedJets[j].pt();
        dVar[kAje] = sortedJets[j].area();
        dVar[kMje] = sortedJets[j].m();
//=============================================================================

        fastjet::Filter trimmer(subjDef, fastjet::SelectorPtFractionMin(0.));
        fastjet::PseudoJet trimmdJet = trimmer(sortedJets[j]);
        std::vector<fastjet::PseudoJet> trimmdSj = trimmdJet.pieces();

        double d1sj = -1.; int k1sj = -1;
        double d2sj = -1.; int k2sj = -1;
        for (int i=0; i<trimmdSj.size(); i++) {
          double dIsj = trimmdSj[i].pt(); if (dIsj<0.001) continue;

          if (dIsj>d1sj) {
            d2sj = d1sj; k2sj = k1sj;
            d1sj = dIsj; k1sj = i;
          } else if (dIsj>d2sj) {
            d2sj = dIsj; k2sj = i;
          }
        }
//=============================================================================

        if (d1sj>0.) {
          v1sj.SetPtEtaPhiM(d1sj, trimmdSj[k1sj].eta(), trimmdSj[k1sj].phi(), trimmdSj[k1sj].m());
          dVar[k1sz] = d1sj;
          dVar[k1sA] = trimmdSj[k1sj].area();
          dVar[k1sm] = trimmdSj[k1sj].m();
          dVar[k1sr] = v1sj.DeltaR(vJet);
        }

        if (d2sj>0.) {
          v2sj.SetPtEtaPhiM(d2sj, trimmdSj[k2sj].eta(), trimmdSj[k2sj].phi(), trimmdSj[k2sj].m());
          dVar[k2sz] = d2sj;
          dVar[k2sA] = trimmdSj[k2sj].area();
          dVar[k2sm] = trimmdSj[k2sj].m();
          dVar[k2sr] = v2sj.DeltaR(vJet);
        }

        if ((d1sj>0.) && (d2sj>0.)) {
          vDsj = v1sj + v2sj;
          dVar[kDsm] = vDsj.M();
          dVar[kDsr] = v2sj.DeltaR(v1sj);
        }

        nt->Fill(dVar);
      }
    }
//=============================================================================

    delete evt;
    ascii_in >> evt;
  }
//=============================================================================

  file->cd(); nt->Write(); file->Close();
//=============================================================================

  TString sXsec = sFile; sXsec.ReplaceAll("out", "xsecs");
  file = TFile::Open(Form("%s/xsecs/%s.root",sPath.Data(),sXsec.Data()), "READ");
  TH1D *hPtHat        = (TH1D*)file->Get("hPtHat");        hPtHat->SetDirectory(0);
  TH1D *hWeightSum    = (TH1D*)file->Get("hWeightSum");    hWeightSum->SetDirectory(0);
  TProfile *hSigmaGen = (TProfile*)file->Get("hSigmaGen"); hSigmaGen->SetDirectory(0);
  file->Close();
//=============================================================================

  sFile.ReplaceAll("out", "wgt");
  file = TFile::Open(Form("%s.root",sFile.Data()), "NEW");
  hPtHat->Write();
  hWeightSum->Write();
  hSigmaGen->Write();
  file->Close();
//=============================================================================

  cout << "DONE" << endl;
  return 0;
}
コード例 #13
0
ファイル: UEAnalysisUE.C プロジェクト: aashaqshah/cmssw-1
void UEAnalysisUE::ueAnalysisRECO(float weight,std::string tkpt,float etaRegion,float ptThreshold, TClonesArray* Track, TClonesArray* TracksJet, TFile* f, std::string hltBit)
{
  f->cd( hltBit.c_str() );

  // find leading jet in visible phase space
  TLorentzVector* leadingJet;
  Float_t PTLeadingTJ = -10;
  for(int j=0;j<TracksJet->GetSize();++j){
    TLorentzVector *v = (TLorentzVector*)TracksJet->At(j);
    if(fabs(v->Eta())<etaRegion){
      leadingJet = v;
      PTLeadingTJ= v->Pt();
      break;
    }
  }

  // save <pT> vs track multiplicity
  int numTracks( 0 );
  double trackPtSum( 0. );
  double averageTrackPt( 0. );
  for(int i=0;i<Track->GetSize();++i)
    {
      TLorentzVector *v = (TLorentzVector*)Track->At(i);
      if(v->Pt()>ptThreshold) 
	{
	  ++numTracks;
	  trackPtSum += v->Pt();
	}
    }
  if ( numTracks > 0 ) 
    {
      averageTrackPt = trackPtSum/numTracks;
      //std::cout << "[RECO] N(tracks)=" << numTracks << ", <pT>(tracks)=" << averageTrackPt << std::endl;
      h2d_averageTrackPt_vs_numTracks->Fill( numTracks, averageTrackPt, weight );
    }

  // catch events where no charged jet is found in the central region
  if ( PTLeadingTJ == -10 ) return;

  Float_t  PTLeadingCJ = cc->calibrationPt(PTLeadingTJ,tkpt)*PTLeadingTJ;

  for(int i=0;i<Track->GetSize();++i){
    TLorentzVector *v = (TLorentzVector*)Track->At(i);

    if(v->Pt()>ptThreshold){

      fHistPtDistRECO->Fill(v->Pt(),weight);
      fHistEtaDistRECO->Fill(v->Eta(),weight);
      fHistPhiDistRECO->Fill(v->Phi(),weight);
      temp3RECO->Fill(fabs(v->Eta()));
      temp4RECO->Fill(fabs(v->Pt()));
    }

    if(fabs(v->Eta())<etaRegion&&v->Pt()>=ptThreshold){
      
      //if (hltBit=="HLTMinBias") std::cout << "Track: pT=" << v->Pt() << ", eta=" << v->Eta() << ", phi=" << v->Phi() << std::endl;

      // use ROOT method to calculate dphi                                                                                    
      // convert dphi from radiants to degrees                                                                                
      Float_t conv = 180/piG;
      Float_t Dphi_reco = conv * leadingJet->DeltaPhi(*v);
      
      temp1RECO->Fill(Dphi_reco);
      temp2RECO->Fill(Dphi_reco,v->Pt());
    }
  }

  
  for(int i=0;i<100;i++){
    pdN_vs_etaRECO->Fill((i*0.05)+0.025,temp3RECO->GetBinContent(i+1)/0.1,weight);
  }
  for(int i=0;i<1000;i++){
    pdN_vs_ptRECO->Fill((i*0.1)+0.05,temp4RECO->GetBinContent(i+1)/0.1,weight);
  }
  
  temp3RECO->Reset();
  temp4RECO->Reset();
  
  Float_t transN1=0;
  Float_t transN2=0;
  Float_t transP1=0;
  Float_t transP2=0;
  Float_t towardN=0;
  Float_t towardP=0;
  Float_t awayN=0;
  Float_t awayP=0;
  
  for(int i=0;i<100;i++){
    if(i<=14){

      //std::cout << "[RECO] Away (" << i << "): dN=" << temp1RECO->GetBinContent(i+1) << ", dpT=" << temp2RECO->GetBinContent(i+1) << std::endl;

      awayN += temp1RECO->GetBinContent(i+1);
      awayP += temp2RECO->GetBinContent(i+1);
    }
    if(i>14 && i<33 ){

      //std::cout << "[RECO] Trans1 (" << i << "): dN=" << temp1RECO->GetBinContent(i+1) << ", dpT=" << temp2RECO->GetBinContent(i+1) << std::endl;

      transN1 += temp1RECO->GetBinContent(i+1);
      transP1 += temp2RECO->GetBinContent(i+1);
    }
    if(i>=33 && i<=64 ){

      //std::cout << "[RECO] Toward (" << i << "): dN=" << temp1RECO->GetBinContent(i+1) << ", dpT=" << temp2RECO->GetBinContent(i+1) << std::endl;

      towardN += temp1RECO->GetBinContent(i+1);
      towardP += temp2RECO->GetBinContent(i+1);
    }
    if(i>64 && i<83 ){

      //std::cout << "[RECO] Trans2 (" << i << "): dN=" << temp1RECO->GetBinContent(i+1) << ", dpT=" << temp2RECO->GetBinContent(i+1) << std::endl;

      transN2 += temp1RECO->GetBinContent(i+1);
      transP2 += temp2RECO->GetBinContent(i+1);
    }
    if(i>=83){

      //std::cout << "[RECO] Away (" << i << "): dN=" << temp1RECO->GetBinContent(i+1) << ", dpT=" << temp2RECO->GetBinContent(i+1) << std::endl;

      awayN += temp1RECO->GetBinContent(i+1);
      awayP += temp2RECO->GetBinContent(i+1);
    }

    Float_t bincont1_reco=temp1RECO->GetBinContent(i+1);
    pdN_vs_dphiRECO->Fill(-180.+i*3.6+1.8,bincont1_reco/(3.6*2*etaRegion*(piG/180.)),weight);
    
    Float_t bincont2_reco=temp2RECO->GetBinContent(i+1);
    pdPt_vs_dphiRECO->Fill(-180.+i*3.6+1.8,bincont2_reco/(3.6*2*etaRegion*(piG/180.)),weight);
    
  }
  

  //if (hltBit=="HLTMinBias") std::cout << "[RECO] N(transverse)=" << transN1+transN2 << ", pT(transverse)=" << transP1+transP2 << std::endl;

  bool orderedN = false;
  //  bool orderedP = false;
  
  pdN_vs_ptJTowardRECO->Fill(PTLeadingTJ,(towardN)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptJTowardRECO->Fill(PTLeadingTJ,(towardP)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdN_vs_ptJAwayRECO->Fill(PTLeadingTJ,(awayN)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptJAwayRECO->Fill(PTLeadingTJ,(awayP)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdN_vs_ptCJTowardRECO->Fill(PTLeadingCJ,(towardN*cc->correctionNToward(PTLeadingTJ,tkpt))/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptCJTowardRECO->Fill(PTLeadingCJ,(towardP*cc->correctionPtToward(PTLeadingTJ,tkpt))/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdN_vs_ptCJAwayRECO->Fill(PTLeadingCJ,(awayN*cc->correctionNAway(PTLeadingTJ,tkpt))/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptCJAwayRECO->Fill(PTLeadingCJ,(awayP*cc->correctionPtAway(PTLeadingTJ,tkpt))/(120.*(2*etaRegion)*(piG/180.)),weight);

  /*
  pdN_vs_ptCJTowardRECO->Fill(PTLeadingCJ,(towardN)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptCJTowardRECO->Fill(PTLeadingCJ,(towardP)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdN_vs_ptCJAwayRECO->Fill(PTLeadingCJ,(awayN)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptCJAwayRECO->Fill(PTLeadingCJ,(awayP)/(120.*(2*etaRegion)*(piG/180.)),weight);
  */
  
  if( transN1>=transN2 ) orderedN = true;
  //  if( transP1>=transP2 ) orderedP = true;
  
  //if (hltBit=="HLTMinBias") std::cout << "[RECO] dN/dphideta=" << (transN1+transN2)/(120.*(2*etaRegion)*(piG/180.)) << std::endl;
  //if (hltBit=="HLTMinBias") std::cout << "[RECO] dpT/dphideta=" << (transP1+transP2)/(120.*(2*etaRegion)*(piG/180.)) << std::endl;
  h_dN_TransRECO->Fill( (transN1+transN2)/(120.*(2*etaRegion)*(piG/180.)) );
  h_dPt_TransRECO->Fill( (transP1+transP2)/(120.*(2*etaRegion)*(piG/180.)) );

  pdN_vs_ptJTransRECO->Fill(PTLeadingTJ,(transN1+transN2)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptJTransRECO->Fill(PTLeadingTJ,(transP1+transP2)/(120.*(2*etaRegion)*(piG/180.)),weight);

  pdN_vs_ptCJTransRECO->Fill(PTLeadingCJ,((transN1+transN2)*cc->correctionNTrans(PTLeadingTJ,tkpt))/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptCJTransRECO->Fill(PTLeadingCJ,((transP1+transP2)*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(120.*(2*etaRegion)*(piG/180.)),weight);

  /*  
  pdN_vs_ptCJTransRECO->Fill(PTLeadingCJ,((transN1+transN2))/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptCJTransRECO->Fill(PTLeadingCJ,((transP1+transP2))/(120.*(2*etaRegion)*(piG/180.)),weight);
  */

  if(orderedN){

    //dN

    pdN_vs_ptJTransMinRECO->Fill(PTLeadingTJ,transN2/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    pdN_vs_ptJTransMaxRECO->Fill(PTLeadingTJ,transN1/(60.*(2*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transN2*cc->correctionNTrans(PTLeadingTJ,tkpt))/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    pdN_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transN1*cc->correctionNTrans(PTLeadingTJ,tkpt))/(60.*(2*etaRegion)*(piG/180.)),weight);

    /*
    pdN_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transN2)/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    pdN_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transN1)/(60.*(2*etaRegion)*(piG/180.)),weight);
    */

    //dP

    pdPt_vs_ptJTransMinRECO->Fill(PTLeadingTJ,transP2/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptJTransMaxRECO->Fill(PTLeadingTJ,transP1/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdPt_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transP2*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transP1*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);

    /*
    pdPt_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transP2)/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transP1)/(60.*(2.*etaRegion)*(piG/180.)),weight);
    */

  }else{

    //dN

    pdN_vs_ptJTransMinRECO->Fill(PTLeadingTJ,transN1/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptJTransMaxRECO->Fill(PTLeadingTJ,transN2/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transN1*cc->correctionNTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transN2*cc->correctionNTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);

    /*
    pdN_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transN1)/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    pdN_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transN2)/(60.*(2*etaRegion)*(piG/180.)),weight);
    */

    //dP

    pdPt_vs_ptJTransMinRECO->Fill(PTLeadingTJ,transP1/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptJTransMaxRECO->Fill(PTLeadingTJ,transP2/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdPt_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transP1*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transP2*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);

    /*
    pdPt_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transP1)/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transP2)/(60.*(2.*etaRegion)*(piG/180.)),weight);
    */
  }
  
  /*
  if(orderedP){

    //dN

    pdN_vs_ptJTransMinRECO->Fill(PTLeadingTJ,transN2/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    pdN_vs_ptJTransMaxRECO->Fill(PTLeadingTJ,transN1/(60.*(2*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transN2*cc->correctionNTrans(PTLeadingTJ,tkpt))/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    pdN_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transN1*cc->correctionNTrans(PTLeadingTJ,tkpt))/(60.*(2*etaRegion)*(piG/180.)),weight);

    
    //pdN_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transN2)/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    //pdN_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transN1)/(60.*(2*etaRegion)*(piG/180.)),weight);
    

    //dP

    pdPt_vs_ptJTransMinRECO->Fill(PTLeadingTJ,transP2/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptJTransMaxRECO->Fill(PTLeadingTJ,transP1/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdPt_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transP2*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transP1*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);

    
    //pdPt_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transP2)/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    //pdPt_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transP1)/(60.*(2.*etaRegion)*(piG/180.)),weight);
    

  }else{

    //dN

    pdN_vs_ptJTransMinRECO->Fill(PTLeadingTJ,transN1/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptJTransMaxRECO->Fill(PTLeadingTJ,transN2/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transN1*cc->correctionNTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transN2*cc->correctionNTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);

    
    //pdN_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transN1)/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    //pdN_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transN2)/(60.*(2*etaRegion)*(piG/180.)),weight);
    

    //dP

    pdPt_vs_ptJTransMinRECO->Fill(PTLeadingTJ,transP1/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptJTransMaxRECO->Fill(PTLeadingTJ,transP2/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdPt_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transP1*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transP2*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);

    
    //pdPt_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transP1)/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    //pdPt_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transP2)/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
  }
  */
  temp1RECO->Reset();
  temp2RECO->Reset();

}
コード例 #14
0
ファイル: UEAnalysisUE.C プロジェクト: aashaqshah/cmssw-1
void UEAnalysisUE::ueAnalysisMC(float weight,std::string tkpt,float etaRegion, float ptThreshold, 
				TClonesArray* MonteCarlo, TClonesArray* ChargedJet, TFile* f, std::string hltBit)
{
  f->cd( hltBit.c_str() );
  //  std::cout << "UEAnalysisUE::ueAnalysisMC(...), HLT " << hltBit << std::endl;

  TLorentzVector* leadingJet;
  Float_t PTLeadingCJ = -10;
  for(int j=0;j<ChargedJet->GetSize();++j){
    TLorentzVector *v = (TLorentzVector*)ChargedJet->At(j);
    if(fabs(v->Eta())<etaRegion){
      leadingJet = v;
      PTLeadingCJ= v->Pt();
      break;
    }
  }

  // save <pT> vs particle multiplicity
  int numParticles( 0 );
  double particlePtSum( 0. );
  double averageParticlePt( 0. );
  for(int i=0;i<MonteCarlo->GetSize();++i)
    {
      TLorentzVector *v = (TLorentzVector*)MonteCarlo->At(i);
      if(v->Pt()>ptThreshold)
        {
          ++numParticles;
          particlePtSum += v->Pt();
        }
    }
  if ( numParticles > 0 ) 
    {
      averageParticlePt = particlePtSum/numParticles;
      //  std::cout << "[MC] N(chg. part's)=" << numParticles << ", <pT>(chg. part's)=" << averageParticlePt << std::endl;
      h2d_averageParticlePt_vs_numParticles->Fill( numParticles, averageParticlePt, weight );
    }


  //std::cout << "PTLeadingCJ " << PTLeadingCJ << std::endl;

  if ( PTLeadingCJ == -10. )
    {
      //std::cout << "return" << std::endl;
      return;
    }

  h_pTChgGenJet->Fill( PTLeadingCJ, weight );
  //std::cout << "for(int i=0;i<MonteCarlo->GetSize();i++){" << std::endl;

  //   if ( hltBit == "All" )
  //     {
  //       std::cout << "[UEAnalysisUE]" << std::endl;
  //     }
  for(int i=0;i<MonteCarlo->GetSize();i++){
    TLorentzVector *v = (TLorentzVector*)MonteCarlo->At(i);    

    if(v->Pt()>=ptThreshold){
      fHistPtDistMC->Fill(v->Pt(),weight);
      fHistEtaDistMC->Fill(v->Eta(),weight);
      fHistPhiDistMC->Fill(v->Phi(),weight);
      temp3MC->Fill(fabs(v->Eta()));
      temp4MC->Fill(fabs(v->Pt()));
    }

    if(fabs(v->Eta())<etaRegion && v->Pt()>=ptThreshold){

      //if (hltBit=="HLTMinBias") std::cout << "Particle: pT=" << v->Pt() << ", eta=" << v->Eta() << ", phi=" << v->Phi() << std::endl;

      Float_t conv = 180/piG;
      Float_t Dphi_mc = conv * leadingJet->DeltaPhi(*v);

      //       if ( hltBit == "All" )
      //        	{
      //        	  std::cout << "(" << i << ") ";
      //        	  std::cout << "pT, eta, phi, dphi ";
      //        	  std::cout << v->Pt() << ", ";
      //        	  std::cout << v->Eta() << ", ";
      //        	  std::cout << v->Phi() << ", ";
      //        	  std::cout << Dphi_mc << std::endl;
      //        	}
      
      temp1MC->Fill(Dphi_mc);
      temp2MC->Fill(Dphi_mc,v->Pt());
    }
  }
  
  //std::cout << "for(int i=0;i<100;i++){" << std::endl;

  for(int i=0;i<100;i++){
    pdN_vs_etaMC->Fill((i*0.05)+0.025,temp3MC->GetBinContent(i+1)/0.1,weight);
  }
  for(int i=0;i<1000;i++){
    pdN_vs_ptMC->Fill((i*0.1)+0.05,temp4MC->GetBinContent(i+1)/0.1,weight);
  }

  temp3MC->Reset();
  temp4MC->Reset();
    
  Float_t transN1=0;
  Float_t transN2=0;
  Float_t transP1=0;
  Float_t transP2=0;
  Float_t towardN=0;
  Float_t towardP=0;
  Float_t awayN=0;
  Float_t awayP=0;
  
  for(int i=0;i<100;i++){
    if(i<=14){

      //std::cout << "[MC] Away (" << i << "): dN=" << temp1MC->GetBinContent(i+1) << ", dpT=" << temp2MC->GetBinContent(i+1) << std::endl;

      awayN += temp1MC->GetBinContent(i+1);
      awayP += temp2MC->GetBinContent(i+1);
    }
    if(i>14 && i<33 ){

      //std::cout << "[MC] Trans1 (" << i << "): dN=" << temp1MC->GetBinContent(i+1) << ", dpT=" << temp2MC->GetBinContent(i+1) << std::endl;

      transN1 += temp1MC->GetBinContent(i+1);
      transP1 += temp2MC->GetBinContent(i+1);
    }
    if(i>=33 && i<=64 ){

      //std::cout << "[MC] Toward (" << i << "): dN=" << temp1MC->GetBinContent(i+1) << ", dpT=" << temp2MC->GetBinContent(i+1) << std::endl;

      towardN += temp1MC->GetBinContent(i+1);
      towardP += temp2MC->GetBinContent(i+1);
    }
    if(i>64 && i<83 ){

      //std::cout << "[MC] Trans2 (" << i << "): dN=" << temp1MC->GetBinContent(i+1) << ", dpT=" << temp2MC->GetBinContent(i+1) << std::endl;

      transN2 += temp1MC->GetBinContent(i+1);
      transP2 += temp2MC->GetBinContent(i+1);
    }
    if(i>=83){

      //std::cout << "[MC] Away (" << i << "): dN=" << temp1MC->GetBinContent(i+1) << ", dpT=" << temp2MC->GetBinContent(i+1) << std::endl;

      awayN += temp1MC->GetBinContent(i+1);
      awayP += temp2MC->GetBinContent(i+1);
    }

    Float_t bincont1_mc=temp1MC->GetBinContent(i+1);
    pdN_vs_dphiMC->Fill(-180.+i*3.6+1.8,bincont1_mc/(3.6*2*etaRegion*(piG/180.)),weight);

    Float_t bincont2_mc=temp2MC->GetBinContent(i+1);

    //     std::cout << "(" << i << ") ";
    //     std::cout << bincont2_mc/(3.6*2*etaRegion*(piG/180.)) << std::endl;
    
    pdPt_vs_dphiMC->Fill(-180.+i*3.6+1.8,bincont2_mc/(3.6*2*etaRegion*(piG/180.)),weight);
    
  }


  //if (hltBit=="HLTMinBias") std::cout << "[MC] N(transverse)=" << transN1+transN2 << ", pT(transverse)=" << transP1+transP2 << std::endl;
  //std::cout << "bool orderedN = false;" << std::endl;

  bool orderedN = false;
  //  bool orderedP = false;
  
  pdN_vs_ptJTowardMC->Fill(PTLeadingCJ,(towardN)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptJTowardMC->Fill(PTLeadingCJ,(towardP)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdN_vs_ptJAwayMC->Fill(PTLeadingCJ,(awayN)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptJAwayMC->Fill(PTLeadingCJ,(awayP)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  if( transN1>=transN2 ) orderedN = true;
  //  if( transP1>=transP2 ) orderedP = true;

  //if (hltBit=="HLTMinBias") std::cout << "[MC] dN/dphideta=" << (transN1+transN2)/(120.*(2*etaRegion)*(piG/180.)) << std::endl;
  //if (hltBit=="HLTMinBias") std::cout << "[MC] dpT/dphideta=" << (transP1+transP2)/(120.*(2*etaRegion)*(piG/180.)) << std::endl;
  h_dN_TransMC->Fill( (transN1+transN2)/(120.*(2*etaRegion)*(piG/180.)) );
  h_dPt_TransMC->Fill( (transP1+transP2)/(120.*(2*etaRegion)*(piG/180.)) );

  pdN_vs_ptJTransMC->Fill(PTLeadingCJ,(transN1+transN2)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptJTransMC->Fill(PTLeadingCJ,(transP1+transP2)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  if(orderedN){
    //dN
    pdN_vs_ptJTransMinMC->Fill(PTLeadingCJ,transN2/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    pdN_vs_ptJTransMaxMC->Fill(PTLeadingCJ,transN1/(60.*(2*etaRegion)*(piG/180.)),weight);
    //dP
    pdPt_vs_ptJTransMinMC->Fill(PTLeadingCJ,transP2/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptJTransMaxMC->Fill(PTLeadingCJ,transP1/(60.*(2.*etaRegion)*(piG/180.)),weight);
  }else{
    //dN
    pdN_vs_ptJTransMinMC->Fill(PTLeadingCJ,transN1/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptJTransMaxMC->Fill(PTLeadingCJ,transN2/(60.*(2.*etaRegion)*(piG/180.)),weight);
    //dP
    pdPt_vs_ptJTransMinMC->Fill(PTLeadingCJ,transP1/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptJTransMaxMC->Fill(PTLeadingCJ,transP2/(60.*(2.*etaRegion)*(piG/180.)),weight);
  }
  /*
  if(orderedP){
    //dN
    pdN_vs_ptJTransMinMC->Fill(PTLeadingCJ,transN2/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    pdN_vs_ptJTransMaxMC->Fill(PTLeadingCJ,transN1/(60.*(2*etaRegion)*(piG/180.)),weight);
    //dP
    pdPt_vs_ptJTransMinMC->Fill(PTLeadingCJ,transP2/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptJTransMaxMC->Fill(PTLeadingCJ,transP1/(60.*(2.*etaRegion)*(piG/180.)),weight);
  }else{
    //dN
    pdN_vs_ptJTransMinMC->Fill(PTLeadingCJ,transN1/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptJTransMaxMC->Fill(PTLeadingCJ,transN2/(60.*(2.*etaRegion)*(piG/180.)),weight);
    //dP
    pdPt_vs_ptJTransMinMC->Fill(PTLeadingCJ,transP1/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptJTransMaxMC->Fill(PTLeadingCJ,transP2/(60.*(2.*etaRegion)*(piG/180.)),weight);
  }
  */
  temp1MC->Reset();
  temp2MC->Reset();

  //std::cout << "done" << std::endl;

}
コード例 #15
0
ファイル: ADDON3_LAC.C プロジェクト: dertexaner/LQ3
// // //
bool analysisClass::PreSelection(TString Process){
  //
  int TotalN=0;
  int TotalTau=0;
  int TotalMu=0;
  int TotalEl=0;
  int TotalJet=0;
  int TotalBJet=0;
  TotalTau  = TauCounter();
  TotalMu   = MuCounter();
  TotalEl   = ElCounter();
  TotalJet  = JetCounter();
  TotalBJet = BJetCounter();
  TotalN = TotalTau + TotalMu + TotalEl + TotalJet;
  //
  double LeadMuTauDeltaR=0;
  TLorentzVector Mu;
  TLorentzVector Tau;
  Mu.SetPtEtaPhiM(0,0,0,0);
  Tau.SetPtEtaPhiM(0,0,0,0);
  for(unsigned int iTauR=0; iTauR<HPSTauPt->size(); iTauR++){
    if( !tauRisoCheck(iTauR) )continue;
    if( tauPtcorr(iTauR)>Tau.Pt() ){
      Tau.SetPtEtaPhiM(tauPtcorr(iTauR), HPSTauEta->at(iTauR), HPSTauPhi->at(iTauR), 0);
    }
  }
  for(unsigned int iMuR=0; iMuR<MuonPt->size(); iMuR++){
    if( !muRisoCheck(iMuR) )continue;
    if( muPtcorr(iMuR)>Mu.Pt() ){
      Mu.SetPtEtaPhiM(muPtcorr(iMuR), MuonEta->at(iMuR), MuonPhi->at(iMuR), 0);
    }
  }
  if( TotalMu>0 && TotalTau>0 ) LeadMuTauDeltaR=Mu.DeltaR(Tau);
  //
  //
  if( Process != "Neutr" && Process != "Neutr2Jet" && Process != "NeutrNoQCD" && Process != "Neutr2JetNoQCD" && Process != "Neutr2Jet250ST" && Process != "Neutr2Jet250STtuneZ"
      && Process != "Neutr0Btag" && Process != "Neutr0BtagNoQCD" && Process != "Neutr2Jet350STtuneZ" && Process != "Neutr1Jet350STtuneZ"
      && Process != "Neutr1Jet350ST" && Process != "Neutr1Jet300ST" && Process != "Neutr1Jet500ST"
      && Process != "ZToMuMuAnalysis" && Process != "ZToMuTauAnalysis" && Process != "TTBar" && Process != "WJets" && Process != "FakeTaus" && Process != "ControlRegion1"
      && Process != "FakeMuons" && Process != "FakeMuonsV2" && Process != "FakeMuonsV3" && Process != "ZJets" && Process != "QCD" && Process != "LQ3M400" ){ return false; }
  //
  if( Process == "Neutr" ){
    //if( MaxDiLepInvMass()<55    ) return false;
    if( MaxMuMuInvMass()>0 && MaxMuMuInvMass()<50 ) return false;
    //if( isZToMuMu()             ) return false;//required to exclude events in MuTrig Calculation
    if( TotalJet<1              ) return false;
  }
  if( Process == "Neutr2Jet" ){
    if( MaxMuMuInvMass()>0 && MaxMuMuInvMass()<50 ) return false;
    if( TotalJet<2              ) return false;
  }
  if( Process == "Neutr2Jet250ST" ){
    if( MaxMuMuInvMass()>0 && MaxMuMuInvMass()<50 ) return false;
    if( TotalJet<2              ) return false;
    if( ST()<250                ) return false;
  }
  if( Process == "Neutr2Jet250STtuneZ" ){
    if( MaxMuMuInvMass()>0   && MaxMuMuInvMass()<55   ) return false;
    if( MaxMuTauInvMass()>0  && MaxMuTauInvMass()<55  ) return false;
    if( MaxTauTauInvMass()>0 && MaxTauTauInvMass()<55 ) return false;
    if( TotalJet<2              ) return false;
    if( ST()<250                ) return false;
  }
  if( Process == "Neutr2Jet350STtuneZ" ){
    if( MaxMuMuInvMass()>0   && MaxMuMuInvMass()<55   ) return false;
    if( MaxMuTauInvMass()>0  && MaxMuTauInvMass()<55  ) return false;
    if( MaxTauTauInvMass()>0 && MaxTauTauInvMass()<55 ) return false;
    if( TotalJet<2              ) return false;
    if( ST()<350                ) return false;
  }
  if( Process == "Neutr1Jet350STtuneZ" ){
    if( MaxMuMuInvMass()>0   && MaxMuMuInvMass()<55   ) return false;
    if( MaxMuTauInvMass()>0  && MaxMuTauInvMass()<55  ) return false;
    if( MaxTauTauInvMass()>0 && MaxTauTauInvMass()<55 ) return false;
    if( TotalJet<1              ) return false;
    if( ST()<350                ) return false;
  }
  if( Process == "Neutr1Jet350ST" ){
    if( TotalJet<1              ) return false;
    if( ST()<350                ) return false;
  }
  if( Process == "Neutr1Jet500ST" ){
    if( TotalJet<1              ) return false;
    if( ST()<500                ) return false;
  }
  if( Process == "Neutr1Jet300ST" ){
    if( TotalJet<1              ) return false;
    if( ST()<300                ) return false;
  }
  if( Process == "Neutr0Btag"){
    if( MaxMuMuInvMass()>0 && MaxMuMuInvMass()<50 ) return false;
    if( TotalBJet>0             ) return false;
  }
  if( Process == "Neutr0BtagNoQCD"){
    if( MaxMuMuInvMass()>0 && MaxMuMuInvMass()<50 ) return false;
    if( TotalBJet>0             ) return false;
    if( METlepMT("Mu")<75       ) return false;
  }
  if( Process == "NeutrNoQCD" ){
    if( MaxMuMuInvMass()>0 && MaxMuMuInvMass()<50 ) return false;
    if( isZToMuMu()             ) return false;//required to exclude events in MuTrig Calculation
    if( TotalJet<1              ) return false;
    if( METlepMT("Mu")<60       ) return false;
  }
  if( Process == "Neutr2JetNoQCD" ){
    if( MaxMuMuInvMass()>0 && MaxMuMuInvMass()<50 ) return false;
    if( isZToMuMu()             ) return false;//required to exclude events in MuTrig Calculation
    if( TotalJet<2              ) return false;
    if( METlepMT("Mu")<60       ) return false;
  }
  //
  if( Process == "FakeTaus" ){
    if( TotalBJet>0              ) return false;
    if( METlepMT("Mu")<40        ) return false;
    if( TotalJet<1               ) return false;
    //if( RecoSignalType()!=-2110  ) return false;//this is mu,tau opp sign
    if( RecoSignalType()!=+2110  ) return false;//this is mu,tau same sign
    if( MaxMuTauInvMass()<80     ) return false;
    //
    if( !isOneMuonSuperIso()     ) return false;
  }
  if( Process == "ZToMuTauAnalysis" ){
    if( MaxMuTauInvMass()<20     ) return false;
    if( TotalBJet>0              ) return false;
    if( METlepMT("Mu")>40        ) return false;
    if( METlepMT("Tau")>90       ) return false;
    if( TotalJet<1               ) return false;
    if( RecoSignalType()!=-2110  ) return false;//this is mu,tau opp sign
    if( MuTaudeltaPzeta()<-15    ) return false;
    //
    if( !isOneMuonSuperIso()     ) return false;
    //
    if( MaxMuTauInvMass()<45 || MaxMuTauInvMass()>75 ) return false;
  }
  if( Process == "ZToMuMuAnalysis" ){
    double MaxMuMuInvMass_ = MaxMuMuInvMass();
    double LeadingMuPt_ =LeadingMuPt();
    if( LeadingMuPt_<35          ) return false;//LJ filter
    if( MaxMuMuInvMass_<80 || MaxMuMuInvMass_>100 ) return false;
    if( TotalJet<1               ) return false;
    if( ST()<300                 ) return false;
    if( TotalBJet>0              ) return false;
    if( RecoSignalType()!=-2020  ) return false;//this is mu,mu opp sign
  }
  if( Process == "FakeMuons" ){
    double LeadingMuPt_  = LeadingMuPt();
    if( LeadingMuPt_<35          ) return false;//LJ filter
    if( TotalJet<1               ) return false;
    double LeadingJetPt_ = LeadingJetPt();
    if( LeadingJetPt_<50         ) return false;
    if( ST()<400                 ) return false;
    if( METlepMT("Mu")>20        ) return false;
    if( METcorr("Pt")>20  ) return false;
    //if( TotalBJet>0              ) return false;
    if( abs(RecoSignalType())!=1010  ) return false;//this is one mu
  }
  if( Process == "FakeMuonsV2" ){
    ////double LeadingMuPt_  = LeadingMuPt();
    ////if( LeadingMuPt_<35          ) return false;//LJ filter removed
    if( TotalJet<1                   ) return false;
    //double LeadingJetPt_ = LeadingJetPt();
    //if( LeadingJetPt_<50         ) return false;
    //if( !isZToMuMu()             ) return false;
    //if( ST()>350                 ) return false;
    if( METlepMT("Mu")>20            ) return false;
    if( METcorr("Pt")>20      ) return false;
    if( abs(RecoSignalType())!=1010  ) return false;//this is one mu
  }
  if( Process == "FakeMuonsV3" ){
    if( METlepMT("Mu")>10            ) return false;
    if( METcorr("Pt")>10      ) return false;
    if( TotalJet<1                   ) return false;//
    if( abs(RecoSignalType())!=1010  ) return false;//this is one mu
    if( !isAllMuonsHLT()             ) return false;//mu has to match the trigger
    //
    //--------- Veto on 2nd Global Muon ---------------------
    int nGlobalMuons=0;
    for(unsigned int iMuR=0;  iMuR<MuonPt->size();     iMuR++){
      if( muPtcorr(iMuR)>MuonPtCut && fabs(MuonEta->at(iMuR))<2.1 && MuonIsGlobal->at(iMuR)==1 ) nGlobalMuons++;
    }
    if( nGlobalMuons>1               ) return false;
    //
    //--------- Check for back-to-back Jet-Muon -------------
    bool isBackToBackJet=false;
    TLorentzVector Mu;
    TLorentzVector Jet;
    for(unsigned int iMuR=0;  iMuR<MuonPt->size();     iMuR++){
      if( !muRisoCheck(iMuR)     ) continue;
      Mu.SetPtEtaPhiM(muPtcorr(iMuR), MuonEta->at(iMuR), MuonPhi->at(iMuR), 0);
      for(unsigned int iJetR=0;  iJetR<PFJetPt->size();     iJetR++){
	if( !jetRTightCheck(iJetR) ) continue;
	Jet.SetPtEtaPhiM( jetPtcorr(iJetR), PFJetEta->at(iJetR), PFJetPhi->at(iJetR), 0 );
	if( (fabs(fabs(Mu.DeltaPhi(Jet))-TMath::Pi())/TMath::Pi())<0.1 )  isBackToBackJet=true;
      }
    }
    //--------- Check for back-to-back Jet-Muon ------------- 
    if( !isBackToBackJet             ) return false;
  }
  if( Process == "ControlRegion1" ){
    //low in signal contamination, to check tau fakes loose->tight ratio
    if( TotalBJet<1                    ) return false;
    if( TotalJet<2                     ) return false;
    ///ST cut reverted
    ///remove MaxMuTauInvMass CUT:  /*if( MaxMuTauInvMass()<100          ) return false;*/
    if( LeadingTauPt()<50              ) return false;
    if( RecoSignalType()!=2110         ) return false;// SS selection
    if( isZToMuMu()                    ) return false;// required to exclude events in MuTrig Calculation  
    //
    if( ST()>400                       ) return false;// Revert the ST cut
  }
  if( Process == "TTBar" ){
    double ZToMuMuCentral = 90;
    double ZToMuTauCentral = 75;
    if( MaxDiLepInvMass()<65       ) return false;
    if( TotalN<5                 ) return false;
    if( ST()<250           ) return false;
    if( RecoSignalType()>0 ) return false;
    if( TotalJet<3               ) return false;
    if( fabs(MuTauInZpeak("ZToMuMu")-ZToMuMuCentral)<10  ) return false; //exclue 80-100
    if( fabs(MuTauInZpeak("ZToMuTau")-ZToMuTauCentral)<15 ) return false; //exclude 60-90
  }
  if( Process == "WJets" ){
    double ZToMuMuCentral = 90;
    double ZToMuTauCentral = 75;
    if( MaxDiLepInvMass()<65       ) return false;
    if( TotalMu!=1          ) return false;
    if( TotalJet!=0         ) return false;
    if( ST()>250      ) return false;
    if( fabs(MuTauInZpeak("ZToMuMu")-ZToMuMuCentral)<10  ) return false; //exclue 80-100
    if( fabs(MuTauInZpeak("ZToMuTau")-ZToMuTauCentral)<15 ) return false; //exclude 60-90
  }
  if( Process == "ZJets" ){
    if( MaxDiLepInvMass()<65 ) return false;
    if( METlepMT("Mu")>50  ) return false;
    if( TotalMu < 2                ) return false;
    double ZToMuMuCentral  = 90;
    double ZToMuTauCentral = 75;
    bool   dilepZpeak_     = false;
    if( fabs(MuTauInZpeak("ZToMuMu")-ZToMuMuCentral)<10  ) dilepZpeak_=true; //accept 80-100
    if( fabs(MuTauInZpeak("ZToMuTau")-ZToMuTauCentral)<15 ) dilepZpeak_=true; //accept 60-90
    if( !dilepZpeak_               ) return false;
  }
  if( Process == "LQ3M400" ){
    if( MaxDiLepInvMass()<65       ) return false;
    if( LeadMuTauDeltaR>4          ) return false;
    if( TotalN<4                   ) return false;
    if( METcorr("Pt")<30    ) return false;
    if( ST()<400             ) return false;
    if( RecoSignalType()<0   ) return false;
  }
  //
  return true;
  //
}
コード例 #16
0
ファイル: UEAnalysisUE.C プロジェクト: Andrej-CMS/cmssw
void UEAnalysisUE::ueAnalysisRECO(float weight,std::string tkpt,float etaRegion,float ptThreshold, TClonesArray* Track, TClonesArray* TracksJet)
{
  
  TLorentzVector* leadingJet;
  Float_t PTLeadingTJ = -10;
  for(int j=0;j<TracksJet->GetSize();++j){
    TLorentzVector *v = (TLorentzVector*)TracksJet->At(j);
    if(fabs(v->Eta())<etaRegion){
      leadingJet = v;
      PTLeadingTJ= v->Pt();
      break;
    }
  }

  Float_t  PTLeadingCJ = cc->calibrationPt(PTLeadingTJ,tkpt)*PTLeadingTJ;

  for(int i=0;i<Track->GetSize();++i){
    TLorentzVector *v = (TLorentzVector*)Track->At(i);

    if(v->Pt()>ptThreshold){
      fHistPtDistRECO->Fill(v->Pt(),weight);
      fHistEtaDistRECO->Fill(v->Eta(),weight);
      fHistPhiDistRECO->Fill(v->Phi(),weight);
      temp3RECO->Fill(fabs(v->Eta()));
      temp4RECO->Fill(fabs(v->Pt()));
    }

    if(fabs(v->Eta())<etaRegion&&v->Pt()>=ptThreshold){
      
      // use ROOT method to calculate dphi                                                                                    
      // convert dphi from radiants to degrees                                                                                
      Float_t conv = 180/piG;
      Float_t Dphi_reco = conv * leadingJet->DeltaPhi(*v);
      
      temp1RECO->Fill(Dphi_reco);
      temp2RECO->Fill(Dphi_reco,v->Pt());
    }
  }

  
  for(int i=0;i<100;i++){
    pdN_vs_etaRECO->Fill((i*0.05)+0.025,temp3RECO->GetBinContent(i+1)/0.1,weight);
  }
  for(int i=0;i<1000;i++){
    pdN_vs_ptRECO->Fill((i*0.1)+0.05,temp4RECO->GetBinContent(i+1)/0.1,weight);
  }
  
  temp3RECO->Reset();
  temp4RECO->Reset();
  
  Float_t transN1=0;
  Float_t transN2=0;
  Float_t transP1=0;
  Float_t transP2=0;
  Float_t towardN=0;
  Float_t towardP=0;
  Float_t awayN=0;
  Float_t awayP=0;
  
  for(int i=0;i<100;i++){
    if(i<=14){
      awayN += temp1RECO->GetBinContent(i+1);
      awayP += temp2RECO->GetBinContent(i+1);
    }
    if(i>14 && i<33 ){
      transN1 += temp1RECO->GetBinContent(i+1);
      transP1 += temp2RECO->GetBinContent(i+1);
    }
    if(i>=33 && i<=64 ){
      towardN += temp1RECO->GetBinContent(i+1);
      towardP += temp2RECO->GetBinContent(i+1);
    }
    if(i>64 && i<83 ){
      transN2 += temp1RECO->GetBinContent(i+1);
      transP2 += temp2RECO->GetBinContent(i+1);
    }
    if(i>=83){
      awayN += temp1RECO->GetBinContent(i+1);
      awayP += temp2RECO->GetBinContent(i+1);
    }

    Float_t bincont1_reco=temp1RECO->GetBinContent(i+1);
    pdN_vs_dphiRECO->Fill(-180.+i*3.6+1.8,bincont1_reco/(3.6*2*etaRegion*(piG/180.)),weight);
    
    Float_t bincont2_reco=temp2RECO->GetBinContent(i+1);
    pdPt_vs_dphiRECO->Fill(-180.+i*3.6+1.8,bincont2_reco/(3.6*2*etaRegion*(piG/180.)),weight);
    
  }
  
  bool orderedN = false;
  //  bool orderedP = false;
  
  pdN_vs_ptJTowardRECO->Fill(PTLeadingTJ,(towardN)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptJTowardRECO->Fill(PTLeadingTJ,(towardP)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdN_vs_ptJAwayRECO->Fill(PTLeadingTJ,(awayN)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptJAwayRECO->Fill(PTLeadingTJ,(awayP)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdN_vs_ptCJTowardRECO->Fill(PTLeadingCJ,(towardN*cc->correctionNToward(PTLeadingTJ,tkpt))/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptCJTowardRECO->Fill(PTLeadingCJ,(towardP*cc->correctionPtToward(PTLeadingTJ,tkpt))/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdN_vs_ptCJAwayRECO->Fill(PTLeadingCJ,(awayN*cc->correctionNAway(PTLeadingTJ,tkpt))/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptCJAwayRECO->Fill(PTLeadingCJ,(awayP*cc->correctionPtAway(PTLeadingTJ,tkpt))/(120.*(2*etaRegion)*(piG/180.)),weight);

  /*
  pdN_vs_ptCJTowardRECO->Fill(PTLeadingCJ,(towardN)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptCJTowardRECO->Fill(PTLeadingCJ,(towardP)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdN_vs_ptCJAwayRECO->Fill(PTLeadingCJ,(awayN)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptCJAwayRECO->Fill(PTLeadingCJ,(awayP)/(120.*(2*etaRegion)*(piG/180.)),weight);
  */
  
  if( transN1>=transN2 ) orderedN = true;
  //  if( transP1>=transP2 ) orderedP = true;
  
  pdN_vs_ptJTransRECO->Fill(PTLeadingTJ,(transN1+transN2)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptJTransRECO->Fill(PTLeadingTJ,(transP1+transP2)/(120.*(2*etaRegion)*(piG/180.)),weight);

  pdN_vs_ptCJTransRECO->Fill(PTLeadingCJ,((transN1+transN2)*cc->correctionNTrans(PTLeadingTJ,tkpt))/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptCJTransRECO->Fill(PTLeadingCJ,((transP1+transP2)*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(120.*(2*etaRegion)*(piG/180.)),weight);

  /*  
  pdN_vs_ptCJTransRECO->Fill(PTLeadingCJ,((transN1+transN2))/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptCJTransRECO->Fill(PTLeadingCJ,((transP1+transP2))/(120.*(2*etaRegion)*(piG/180.)),weight);
  */

  if(orderedN){

    //dN

    pdN_vs_ptJTransMinRECO->Fill(PTLeadingTJ,transN2/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    pdN_vs_ptJTransMaxRECO->Fill(PTLeadingTJ,transN1/(60.*(2*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transN2*cc->correctionNTrans(PTLeadingTJ,tkpt))/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    pdN_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transN1*cc->correctionNTrans(PTLeadingTJ,tkpt))/(60.*(2*etaRegion)*(piG/180.)),weight);

    /*
    pdN_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transN2)/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    pdN_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transN1)/(60.*(2*etaRegion)*(piG/180.)),weight);
    */

    //dP

    pdPt_vs_ptJTransMinRECO->Fill(PTLeadingTJ,transP2/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptJTransMaxRECO->Fill(PTLeadingTJ,transP1/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdPt_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transP2*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transP1*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);

    /*
    pdPt_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transP2)/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transP1)/(60.*(2.*etaRegion)*(piG/180.)),weight);
    */

  }else{

    //dN

    pdN_vs_ptJTransMinRECO->Fill(PTLeadingTJ,transN1/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptJTransMaxRECO->Fill(PTLeadingTJ,transN2/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transN1*cc->correctionNTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transN2*cc->correctionNTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);

    /*
    pdN_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transN1)/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    pdN_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transN2)/(60.*(2*etaRegion)*(piG/180.)),weight);
    */

    //dP

    pdPt_vs_ptJTransMinRECO->Fill(PTLeadingTJ,transP1/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptJTransMaxRECO->Fill(PTLeadingTJ,transP2/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdPt_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transP1*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transP2*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);

    /*
    pdPt_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transP1)/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transP2)/(60.*(2.*etaRegion)*(piG/180.)),weight);
    */
  }
  
  /*
  if(orderedP){

    //dN

    pdN_vs_ptJTransMinRECO->Fill(PTLeadingTJ,transN2/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    pdN_vs_ptJTransMaxRECO->Fill(PTLeadingTJ,transN1/(60.*(2*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transN2*cc->correctionNTrans(PTLeadingTJ,tkpt))/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    pdN_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transN1*cc->correctionNTrans(PTLeadingTJ,tkpt))/(60.*(2*etaRegion)*(piG/180.)),weight);

    
    //pdN_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transN2)/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    //pdN_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transN1)/(60.*(2*etaRegion)*(piG/180.)),weight);
    

    //dP

    pdPt_vs_ptJTransMinRECO->Fill(PTLeadingTJ,transP2/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptJTransMaxRECO->Fill(PTLeadingTJ,transP1/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdPt_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transP2*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transP1*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);

    
    //pdPt_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transP2)/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    //pdPt_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transP1)/(60.*(2.*etaRegion)*(piG/180.)),weight);
    

  }else{

    //dN

    pdN_vs_ptJTransMinRECO->Fill(PTLeadingTJ,transN1/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptJTransMaxRECO->Fill(PTLeadingTJ,transN2/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transN1*cc->correctionNTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transN2*cc->correctionNTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);

    
    //pdN_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transN1)/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    //pdN_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transN2)/(60.*(2*etaRegion)*(piG/180.)),weight);
    

    //dP

    pdPt_vs_ptJTransMinRECO->Fill(PTLeadingTJ,transP1/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptJTransMaxRECO->Fill(PTLeadingTJ,transP2/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdPt_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transP1*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transP2*cc->correctionPtTrans(PTLeadingTJ,tkpt))/(60.*(2.*etaRegion)*(piG/180.)),weight);

    
    //pdPt_vs_ptCJTransMinRECO->Fill(PTLeadingCJ,(transP1)/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    //pdPt_vs_ptCJTransMaxRECO->Fill(PTLeadingCJ,(transP2)/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
  }
  */
  temp1RECO->Reset();
  temp2RECO->Reset();

}
コード例 #17
0
ファイル: UEAnalysisUE.C プロジェクト: Andrej-CMS/cmssw
void UEAnalysisUE::ueAnalysisMC(float weight,std::string tkpt,float etaRegion, float ptThreshold, TClonesArray* MonteCarlo, TClonesArray* ChargedJet)
{

  //std::cout << "UEAnalysisUE::ueAnalysisMC(...)" << std::endl;

  TLorentzVector* leadingJet;
  Float_t PTLeadingCJ = -10;
  for(int j=0;j<ChargedJet->GetSize();++j){
    TLorentzVector *v = (TLorentzVector*)ChargedJet->At(j);
    if(fabs(v->Eta())<etaRegion){
      leadingJet = v;
      PTLeadingCJ= v->Pt();
      break;
    }
  }


  //std::cout << "PTLeadingCJ " << PTLeadingCJ << std::endl;

  if ( PTLeadingCJ == -10. )
    {
      //std::cout << "return" << std::endl;
      return;
    }

  //std::cout << "for(int i=0;i<MonteCarlo->GetSize();i++){" << std::endl;

  for(int i=0;i<MonteCarlo->GetSize();i++){
    TLorentzVector *v = (TLorentzVector*)MonteCarlo->At(i);    

    if(v->Pt()>=ptThreshold){
      fHistPtDistMC->Fill(v->Pt(),weight);
      fHistEtaDistMC->Fill(v->Eta(),weight);
      fHistPhiDistMC->Fill(v->Phi(),weight);
      temp3MC->Fill(fabs(v->Eta()));
      temp4MC->Fill(fabs(v->Pt()));
    }

    if(fabs(v->Eta())<etaRegion && v->Pt()>=ptThreshold){
      Float_t conv = 180/piG;
      Float_t Dphi_mc = conv * leadingJet->DeltaPhi(*v);
      temp1MC->Fill(Dphi_mc);
      temp2MC->Fill(Dphi_mc,v->Pt());
    }
  }
  
  //std::cout << "for(int i=0;i<100;i++){" << std::endl;

  for(int i=0;i<100;i++){
    pdN_vs_etaMC->Fill((i*0.05)+0.025,temp3MC->GetBinContent(i+1)/0.1,weight);
  }
  for(int i=0;i<1000;i++){
    pdN_vs_ptMC->Fill((i*0.1)+0.05,temp4MC->GetBinContent(i+1)/0.1,weight);
  }

  temp3MC->Reset();
  temp4MC->Reset();
    
  Float_t transN1=0;
  Float_t transN2=0;
  Float_t transP1=0;
  Float_t transP2=0;
  Float_t towardN=0;
  Float_t towardP=0;
  Float_t awayN=0;
  Float_t awayP=0;
  
  for(int i=0;i<100;i++){
    if(i<=14){
      awayN += temp1MC->GetBinContent(i+1);
      awayP += temp2MC->GetBinContent(i+1);
    }
    if(i>14 && i<33 ){
      transN1 += temp1MC->GetBinContent(i+1);
      transP1 += temp2MC->GetBinContent(i+1);
    }
    if(i>=33 && i<=64 ){
      towardN += temp1MC->GetBinContent(i+1);
      towardP += temp2MC->GetBinContent(i+1);
    }
    if(i>64 && i<83 ){
      transN2 += temp1MC->GetBinContent(i+1);
      transP2 += temp2MC->GetBinContent(i+1);
    }
    if(i>=83){
      awayN += temp1MC->GetBinContent(i+1);
      awayP += temp2MC->GetBinContent(i+1);
    }

    Float_t bincont1_mc=temp1MC->GetBinContent(i+1);
    pdN_vs_dphiMC->Fill(-180.+i*3.6+1.8,bincont1_mc/(3.6*2*etaRegion*(piG/180.)),weight);
    
    Float_t bincont2_mc=temp2MC->GetBinContent(i+1);
    pdPt_vs_dphiMC->Fill(-180.+i*3.6+1.8,bincont2_mc/(3.6*2*etaRegion*(piG/180.)),weight);
    
  }
  
  //std::cout << "bool orderedN = false;" << std::endl;

  bool orderedN = false;
  //  bool orderedP = false;
  
  pdN_vs_ptJTowardMC->Fill(PTLeadingCJ,(towardN)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptJTowardMC->Fill(PTLeadingCJ,(towardP)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdN_vs_ptJAwayMC->Fill(PTLeadingCJ,(awayN)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptJAwayMC->Fill(PTLeadingCJ,(awayP)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  if( transN1>=transN2 ) orderedN = true;
  //  if( transP1>=transP2 ) orderedP = true;

  // add histo for ue fluctuation
  h2d_dN_vs_ptJTransMC->Fill(PTLeadingCJ,(transN1+transN2)/(120.*(2*etaRegion)*(piG/180.)),weight);

  pdN_vs_ptJTransMC->Fill(PTLeadingCJ,(transN1+transN2)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  pdPt_vs_ptJTransMC->Fill(PTLeadingCJ,(transP1+transP2)/(120.*(2*etaRegion)*(piG/180.)),weight);
  
  if(orderedN){
    //dN
    pdN_vs_ptJTransMinMC->Fill(PTLeadingCJ,transN2/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    pdN_vs_ptJTransMaxMC->Fill(PTLeadingCJ,transN1/(60.*(2*etaRegion)*(piG/180.)),weight);
    //dP
    pdPt_vs_ptJTransMinMC->Fill(PTLeadingCJ,transP2/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptJTransMaxMC->Fill(PTLeadingCJ,transP1/(60.*(2.*etaRegion)*(piG/180.)),weight);
  }else{
    //dN
    pdN_vs_ptJTransMinMC->Fill(PTLeadingCJ,transN1/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptJTransMaxMC->Fill(PTLeadingCJ,transN2/(60.*(2.*etaRegion)*(piG/180.)),weight);
    //dP
    pdPt_vs_ptJTransMinMC->Fill(PTLeadingCJ,transP1/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptJTransMaxMC->Fill(PTLeadingCJ,transP2/(60.*(2.*etaRegion)*(piG/180.)),weight);
  }
  /*
  if(orderedP){
    //dN
    pdN_vs_ptJTransMinMC->Fill(PTLeadingCJ,transN2/(60.*(2*etaRegion)*(piG/180.)),weight);
    
    pdN_vs_ptJTransMaxMC->Fill(PTLeadingCJ,transN1/(60.*(2*etaRegion)*(piG/180.)),weight);
    //dP
    pdPt_vs_ptJTransMinMC->Fill(PTLeadingCJ,transP2/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptJTransMaxMC->Fill(PTLeadingCJ,transP1/(60.*(2.*etaRegion)*(piG/180.)),weight);
  }else{
    //dN
    pdN_vs_ptJTransMinMC->Fill(PTLeadingCJ,transN1/(60.*(2.*etaRegion)*(piG/180.)),weight);

    pdN_vs_ptJTransMaxMC->Fill(PTLeadingCJ,transN2/(60.*(2.*etaRegion)*(piG/180.)),weight);
    //dP
    pdPt_vs_ptJTransMinMC->Fill(PTLeadingCJ,transP1/(60.*(2.*etaRegion)*(piG/180.)),weight);
    
    pdPt_vs_ptJTransMaxMC->Fill(PTLeadingCJ,transP2/(60.*(2.*etaRegion)*(piG/180.)),weight);
  }
  */
  temp1MC->Reset();
  temp2MC->Reset();

  //std::cout << "done" << std::endl;

}
コード例 #18
0
ファイル: ADDON3_LAC.C プロジェクト: dertexaner/LQ3
// // //
double analysisClass::MuTauInZpeak(TString Pair){
  TLorentzVector mu;
  TLorentzVector mu2;
  TLorentzVector tau;
  TLorentzVector tau2;
  double Zmass = 91.188;
  double MuPt = 0;
  double TauPt = 0;
  double Dilepmass = 9999999;
  bool pairfound_ = false;
  //
  /*
  if( Pair == "ZToMuTau" ){ // MET is redistributed to Mu and Tau.. 
    TLorentzVector MET;
    MET.SetPtEtaPhiM( METcorr("Pt"), 0 , METcorr("Phi") , 0 );
    for(unsigned int iMuR=0; iMuR<MuonPt->size(); iMuR++){
      if(!muRisoCheck(iMuR)){continue;}
      mu.SetPtEtaPhiM( muPtcorr(iMuR), MuonEta->at(iMuR), MuonPhi->at(iMuR), 0);
      MuPt = MET.Pt()*TMath::Cos(mu.DeltaPhi(MET)) + muPtcorr(iMuR); //adding projected MET on transverse plane Muon.
      mu.SetPtEtaPhiM( MuPt , MuonEta->at(iMuR), MuonPhi->at(iMuR), 0);
      for(unsigned int iTauR=0; iTauR<HPSTauPt->size(); iTauR++){
	if(!tauRisoCheck(iTauR)){continue;}
	tau.SetPtEtaPhiM( tauPtcorr(iTauR), HPSTauEta->at(iTauR) , HPSTauPhi->at(iTauR), 0); 
	TauPt = MET.Pt()*TMath::Cos(tau.DeltaPhi(MET)) + tauPtcorr(iTauR); //adding projected MET on transverse plane Tau.
	tau.SetPtEtaPhiM( TauPt, HPSTauEta->at(iTauR), HPSTauPhi->at(iTauR), 0);
	pairfound_=true;
	if( fabs((mu+tau).M()-Zmass) < fabs(Dilepmass-Zmass) ) Dilepmass=(mu+tau).M();
      }
    }
  }
  */
  //
  if( Pair == "ZToMuTau" ){ // MET is added to TauPt..         mu <-- Z --> Tau (Tau_vis, neutrino :: collinear)
    TLorentzVector MET;
    MET.SetPtEtaPhiM( METcorr("Pt"), 0 , METcorr("Phi") , 0 );
    for(unsigned int iMuR=0; iMuR<MuonPt->size(); iMuR++){
      if(!muRisoCheck(iMuR)){continue;}
      mu.SetPtEtaPhiM( muPtcorr(iMuR), MuonEta->at(iMuR), MuonPhi->at(iMuR), 0);
      //MuPt = MET.Pt()*TMath::Cos(mu.DeltaPhi(MET)) + muPtcorr(iMuR); //adding projected MET on transverse plane Muon.
      // mu.SetPtEtaPhiM( MuPt , MuonEta->at(iMuR), MuonPhi->at(iMuR), 0);
      for(unsigned int iTauR=0; iTauR<HPSTauPt->size(); iTauR++){
	if(!tauRisoCheck(iTauR)){continue;}
	tau.SetPtEtaPhiM( tauPtcorr(iTauR), HPSTauEta->at(iTauR) , HPSTauPhi->at(iTauR), 0); 
	//TauPt = MET.Pt()*TMath::Cos(tau.DeltaPhi(MET)) + tauPtcorr(iTauR); //adding projected MET on transverse plane Tau.
	TauPt = MET.Pt()*TMath::Cos(tau.DeltaPhi(MET)) + tauPtcorr(iTauR); //adding MET to TauPt.
	tau.SetPtEtaPhiM( TauPt, HPSTauEta->at(iTauR), HPSTauPhi->at(iTauR), 0);
	pairfound_=true;
	if( fabs((mu+tau).M()-Zmass) < fabs(Dilepmass-Zmass) ) Dilepmass=(mu+tau).M();
      }
    }
  }
  //
  if( Pair == "ZToMuMu" ){
    for(unsigned int iMuR=0; iMuR<MuonPt->size(); iMuR++){
      if(!muRisoCheck(iMuR)){continue;}
      mu.SetPtEtaPhiM( muPtcorr(iMuR), MuonEta->at(iMuR), MuonPhi->at(iMuR), 0);
      for(unsigned int iMuR2=iMuR+1; iMuR2<MuonPt->size(); iMuR2++){
	if(!muRisoCheck(iMuR2)){continue;}
	mu2.SetPtEtaPhiM( muPtcorr(iMuR2), MuonEta->at(iMuR2), MuonPhi->at(iMuR2), 0);
	pairfound_=true;
	if( fabs((mu+mu2).M()-Zmass) < fabs(Dilepmass-Zmass) ) Dilepmass=(mu+mu2).M();
      }
    }
  }
  //
  if( Pair == "ZToTauTau" ){
    for(unsigned int iTauR=0; iTauR<HPSTauPt->size(); iTauR++){
      if(!tauRisoCheck(iTauR)){continue;}
      tau.SetPtEtaPhiM( tauPtcorr(iTauR), HPSTauEta->at(iTauR), HPSTauPhi->at(iTauR), 0);
      for(unsigned int iTauR2=iTauR+1; iTauR2<HPSTauPt->size(); iTauR2++){
	if(!tauRisoCheck(iTauR2)){continue;}
	tau2.SetPtEtaPhiM( tauPtcorr(iTauR2), HPSTauEta->at(iTauR2), HPSTauPhi->at(iTauR2), 0);
	pairfound_=true;
	if( fabs((tau+tau2).M()-Zmass) < fabs(Dilepmass-Zmass) ) Dilepmass=(tau+tau2).M();
      }
    }
  }
  //
  if( pairfound_ ) return Dilepmass;
  else return 0;
}
コード例 #19
0
void treeProducerSusySoftlepton::Loop()
{
   if (fChain == 0) return;

 TFile* myGreatPlots = new TFile("greatPlotsW_Data_SingleMuAB_Test.root","recreate");

 Long64_t nentries = fChain->GetEntries();

TH1D* MuonPt = new TH1D("MuonPt","MuonPt",100,0,150);
TH1D* MetPt = new TH1D("MetPt","MetPt",100,0,150);
TH1D* WPt = new TH1D("WPt","WPt",100,0,150);
TH1D* TransverseMass = new TH1D("TransverseMass","TransverseMass",100,0,120);

 //nentries=100000;
   Long64_t nbytes = 0, nb = 0;
   for (Long64_t jentry=0; jentry<nentries;jentry++) {
   genEventInvalid = false;
      Long64_t ientry = LoadTree(jentry);
      if (ientry < 0) break;
      if(jentry%1000==0) cout << jentry/1000 << " k events" <<endl;
      nb = fChain->GetEntry(jentry);   nbytes += nb;



//RECO

 if(nLepGood==0) continue;
 if(fabs(LepGood_pdgId[0])!=13) continue; // if the first particle is a muon (13) continue
 
 TLorentzVector mu; // declare a four-vector for reconstructed the muon
 mu.SetPtEtaPhiM(LepGood_pt[0],LepGood_eta[0],LepGood_phi[0],0.106);

 TLorentzVector met;
 met.SetPtEtaPhiM(met_pt,0,met_phi,0);

 TLorentzVector jet;       
 jet.SetPtEtaPhiM(Jet_pt[0],Jet_eta[0],Jet_phi[0],80.4);

 float MT = sqrt(2 * met_pt * LepGood_pt[0] * (cos(mu.DeltaPhi(met))));

 float lumi = 19.71;

 //MC_tree_WJets_PtW_50To70
// int NEvents = 47790949;
// float CrossSection = 48.2;

 //MC_tree_WJets_PtW_70To100
 //int NEvents = 22435242;
 //float CrossSection = 42.4;

 //MC_tree_WJets_PtW_100
//int NEvents = 12742360;
 //float CrossSection = 45.1;

 //MC_tree_TTfullyLep
//int NEvents = 12108496;
//float CrossSection = 445.8;



 float weight = 1/* CrossSection/NEvents*lumi*1000*/;

 if (CutReco() == 1){
 //cout << weight << endl;
 MuonPt->Fill(mu.Pt(),weight);
 MetPt->Fill(met.Pt(),weight);
 WPt->Fill((mu+met).Pt(),weight);
 TransverseMass->Fill(MT,weight);
}


  }


   myGreatPlots->Write();
   myGreatPlots->Close();
}