Hi, Axel
Sure, here it is
[code]#define TBW_cxx
#include “TBW.h”
#include “cuts.h”
#include “TMatrixD.h”
#include
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
double dr(double eta1, double phi1, double eta2, double phi2)
{
Double_t M_PI2 = 3.141592653589793238462.;
double deta = fabs(eta1 - eta2);
double dphi = fabs(phi1 - phi2);
if( dphi > M_PI ) dphi = M_PI2 - dphi;
return sqrt(detadeta + dphi*dphi);
}
void TBW::Loop()
{
if (fChain == 0) return;
Float_t myfile = 0.;
Long64_t nentries = fChain->GetEntriesFast();
Long64_t nbytes = 0, nb = 0;
Int_t event_number = 0;
Double_t M_PI2 = 3.14159265358979323846*2.;
Double_t JetPtCorr[100];
Double_t JetEtCorr[100];
// variables for MVA tree
float ETMISS;
float WFM;
float DPHI;
float MTR;
float W;
float MLL;
float Mmumu2_5;
float Mmumu2_6;
float Mmumu2_7;
float Mmumu3_1;
float Mmumu3_2;
float Mmumu3_3;
float Mmumu3_4;
float Mmumu3_5;
float Mmumu3_6;
Int_t nbins = 20;
float PHM;
TLorentzVector VMuP;
TLorentzVector VMuM;
TLorentzVector VMuMu;
TLorentzVector VAMuMu;
TLorentzVector VMuMu_cor;
TLorentzVector VMuMu_sm;
TLorentzVector corr;
TLorentzVector VJP;
TLorentzVector VJM;
TTree *tree = new TTree(“T”,“An example of a ROOT tree”);
TH1F* dimuon_Mass = new TH1F ("dimuon_Mass","", 400, 0., 200.);
TH1F* pt_ll = new TH1F ("pt_ll","", 500, 0., 1000.);
TLorentzVector::Class()->IgnoreTObjectStreamer();
TVector3::Class()->IgnoreTObjectStreamer();
//genparticles block
Int_t n1 = 0;
Int_t n2 = 0;
Int_t n3 = 0;
Int_t n4 = 0;
Int_t n5 = 0;
Int_t n6 = 0;
Int_t n7 = 0;
Int_t n8 = 0;
Double_t dxy ;
Double_t ptm ;
double all_jets50=0;
double all_jets60=0;
double all_jets70=0;
double all_jets80=0;
double fake_jets50=0;
double fake_jets60=0;
double fake_jets70=0;
double fake_jets80=0;
Double_t n01 = 0;
Double_t n02 = 0;
Double_t n03 = 0;
Double_t n04 = 0;
Int_t n05 = 0;
Int_t trig1 = 0;
Int_t trig2 = 0;
Int_t trig3 = 0;
Int_t trig4 = 0;
Int_t trig5 = 0;
Int_t trig6 = 0;
Int_t trig7 = 0;
Double_t btgn1a=0;
Double_t btgn1b=0;
Double_t btgn1c=0;
Double_t btgn1d=0;
Double_t btgn2a=0;
Double_t btgn2b=0;
Double_t btgn2c=0;
Double_t btgn2d=0;
Double_t btgn3a=0;
Double_t btgn3b=0;
Double_t btgn3c=0;
Double_t btgn3d=0;
Double_t btgn4a=0;
Double_t btgn4b=0;
Double_t btgn4c=0;
Double_t btgn4d=0;
Double_t total_events=0;
Double_t btagged_events=0;
Double_t fakerate=0;
Double_t lost=0;
Double_t truetagged = 0;
TLorentzVector *JETS = new TLorentzVector[30];
TLorentzVector VJJ;
TLorentzVector VJJll;
TLorentzVector Vnunu;
TLorentzVector Total;
TLorentzVector VE;
TLorentzVector VNUM;
TLorentzVector VM;
TLorentzVector VNUE;
TLorentzVector VH;
TLorentzVector VZ;
TLorentzVector VZNU;
TLorentzVector TJ;
TLorentzVector TOTJ;
///////////////////////////////////////////////////////////////////////////////////////////////// start job running
//for (Long64_t jentry=0; jentry<30000;jentry++) { //1
for (Long64_t jentry=0; jentry<nentries;jentry++) { //1
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
if(ientry == 0) {cout<<" New file "<<myfile<<endl; myfile++;}
if (event_number%100000==0) cout<<"event number"<<event_number<<"trigs 3, 4: "<<trig3<<" , "<<trig4<<endl;
event_number++;
/////////////////////////////////////////////////////////////////////////////////////////////////
Double_t w=2;
Double_t Nvtx = NvtxEv;
Int_t MuHLT;
MuHLT = HLT_IsoMu24_eta2p1 ;
//w = w_Nvtx2[(int)Nvtx];
Int_t MUMINUS;
Int_t nminus=1;
Int_t MUPLUS;
Int_t nplus=1;
Int_t nZgood = 0;
int eplus=0;
int eminus=0;
int EP;
int EM;
int n_e=0;
int n_mu=0;
int n_enu=0;
int n_munu=0;
double pt_centr = 0;
double Evis=0;
double M0=0;
double M1=0;
double M2=0;
double M3=0;
double M4=0;
double M5=0;
double NM2=0;
double NM3=0;
double NM4=0;
double LM1=0;
double LM2=0;
double LM3=0;
int toptag=0;
Double_t ptm =0;
Double_t ptp =0;
for(Int_t kmu=0; kmu<NumRecoMuons - 1; kmu++ )
{
for(Int_t kmu2 = kmu + 1; kmu2<NumRecoMuons; kmu2++ )
{
if(dr(RecoEtaMuons[kmu], RecoPhiMuons[kmu], RecoEtaMuons[kmu2], RecoPhiMuons[kmu2]) < 0.3)
{
RecoIsoMuonsSumPt[kmu] -= RecoPtMuons[kmu2];
RecoIsoMuonsSumPt[kmu2] -= RecoPtMuons[kmu];
}
}
}
for(Int_t kmu=0; kmu<NumRecoMuons; kmu++ )
{
if((RecoIsoMuonsSumPt[kmu])/(RecoPtMuons[kmu]) > 0.1) continue;
if(RecoChargeMuons[kmu]>0 && fabs(RecoEtaMuons[kmu]) < 2.1 && RecoPtMuons[kmu] > 25) { nplus++;
//if(RecoChargeMuons[kmu]>0 && fabs(RecoEtaMuons[kmu]) < 2.4 ) { nplus++;
if(RecoPtMuons[kmu] > ptm) {MUPLUS = kmu; ptm = RecoPtMuons[kmu];}
}
if(RecoChargeMuons[kmu]<0 && fabs(RecoEtaMuons[kmu]) < 2.1 && RecoPtMuons[kmu] > 25) { nminus++;
//if(RecoChargeMuons[kmu]<0 && fabs(RecoEtaMuons[kmu]) < 2.4) { nminus++;
if(RecoPtMuons[kmu] > ptp) {MUMINUS = kmu; ptp = RecoPtMuons[kmu];}
}
}
if( nminus < 1 || nplus < 1) continue;
Int_t ip = MUPLUS;
Int_t im = MUMINUS;
Int_t ep = EP;
Int_t em = EM;
Double_t theta1 = 2.*atan(exp(-RecoEtaMuons[ip]));
Double_t theta2 = 2.*atan(exp(-RecoEtaMuons[im]));
Double_t Mu1Eta = RecoEtaMuons[ip];
Double_t Mu2Eta = RecoEtaMuons[im];
Double_t Mu1Phi = RecoPhiMuons[ip];
Double_t Mu2Phi = RecoPhiMuons[im];
Double_t Mu1Pt = RecoPtMuons[ip];
Double_t Mu2Pt = RecoPtMuons[im];
Double_t px1 = RecoPtMuons[ip]*cos(RecoPhiMuons[ip]);
Double_t py1 = RecoPtMuons[ip]*sin(RecoPhiMuons[ip]);
Double_t pz1 = RecoPtMuons[ip]/tan(theta1);
Double_t px2 = RecoPtMuons[im]*cos(RecoPhiMuons[im]);
Double_t py2 = RecoPtMuons[im]*sin(RecoPhiMuons[im]);
Double_t pz2 = RecoPtMuons[im]/tan(theta2);
Double_t e1 = sqrt(RecoPtMuons[ip]*RecoPtMuons[ip]+pz1*pz1+0.105*0.105);
Double_t e2 = sqrt(RecoPtMuons[im]*RecoPtMuons[im]+pz2*pz2+0.105*0.105);
Double_t eZ = e1+e2;
Double_t ptZ = sqrt((px1+px2)*(px1+px2)+(py1+py2)*(py1+py2));
Double_t pZZ = pz1+pz2;
Double_t phiZ = acos((px1+px2)/ptZ);
if(py1+py2<0.) phiZ = -1.*phiZ;
Double_t mZ = sqrt(eZ*eZ-ptZ*ptZ-pZZ*pZZ);
Float_t YZ = 0.5*log((eZ + pZZ)/(eZ - pZZ));
VMuP.SetPxPyPzE(px1,py1,pz1,e1);
VMuM.SetPxPyPzE(px2,py2,pz2,e2);
if((VMuP.Pt() < 20) || (VMuM.Pt() < 20)) continue;
VMuMu = VMuP + VMuM;
Float_t M_Z = VMuMu.M();
//cout<<"MZ: "<<M_Z<<endl;
dimuon_Mass->Fill(M_Z,w);
double dphi_mumu = fabs(Mu1Phi - Mu2Phi);
if (dphi_mumu > M_PI)
{
dphi_mumu = M_PI2 - dphi_mumu;
}
pt_ll->Fill(VMuMu.Pt(), w);
/////////////////////////////////////////////////////////////////////////////////////////////////
}// for (Long64_t jentry=0; jentry<nentries;jentry++) {
cout<<“total event number “<<event_number<<endl;
TFile *MyFile = new TFile(”/afs/cern.ch/work/a/astepenn/CMSSW_7_4_7_patch1/src/ZWW/TBW_13TeV.root”,“recreate”);
dimuon_Mass->Write();
pt_ll->Write();
delete tree;
}
[/code]
weight is set in line 191, w=2;
Cheers, Anton