diff --git a/NTupleMaker/bin/SynchNTupleProducer_2017.cpp b/NTupleMaker/bin/SynchNTupleProducer_2017.cpp index eb8ffc3fe01..ced623aef1b 100644 --- a/NTupleMaker/bin/SynchNTupleProducer_2017.cpp +++ b/NTupleMaker/bin/SynchNTupleProducer_2017.cpp @@ -76,6 +76,7 @@ void initializeCPvar(Synch17Tree *otree); void SaveRECOVertices(const AC1B * analysisTree,Synch17Tree *otree, const bool isData); void initializeGenTree(Synch17GenTree *gentree); void FillGenTree(const AC1B * analysisTree, Synch17GenTree *gentree, TString ch); +void Refitting(const AC1B *analysisTree, Synch17Tree *otree, int tauIndex, int leptonIndex, TString ch); //void fillTTbarUncWeights(const AC1B * analysisTree, Synch17Tree *otree, bool isData, bool includeTTbarUncWeights); @@ -959,7 +960,8 @@ for (Long64_t iEntry=0; iEntryRecoVertexX=analysisTree->primvertex_x; otree->RecoVertexY=analysisTree->primvertex_y; otree->RecoVertexZ=analysisTree->primvertex_z; + + otree->RecoVertexX_with_bs=analysisTree->primvertexwithbs_x; + otree->RecoVertexY_with_bs=analysisTree->primvertexwithbs_y; + otree->RecoVertexZ_with_bs=analysisTree->primvertexwithbs_z; + if(!isData){ @@ -2149,3 +2157,108 @@ else{//if it is data, fill with something recognisable nonsensible otree->GenVertexZ=-9999;} } + +void Refitting(const AC1B *analysisTree, Synch17Tree *otree, int tauIndex, int leptonIndex, TString ch) +{ + //Begin of identifying correct refitted vertex (WITHOUT bs) + otree->RefitVertexX = otree->RecoVertexX; + otree->RefitVertexY = otree->RecoVertexY; + otree->RefitVertexZ = otree->RecoVertexZ; + + otree->matched_pair = -1; + + for(unsigned int i=0; irefitvertex_count; i++) + { + if(ch=="mt") + { + if( +((leptonIndex==(analysisTree->refitvertex_muIndex[i][0]))||(leptonIndex==(analysisTree->refitvertex_muIndex[i][1])))&&((tauIndex==(analysisTree->refitvertex_tauIndex[i][0]))||(tauIndex==(analysisTree->refitvertex_tauIndex[i][1]))) + ) + { + otree->RefitVertexX = analysisTree->refitvertex_x[i]; + otree->RefitVertexY = analysisTree->refitvertex_y[i]; + otree->RefitVertexZ = analysisTree->refitvertex_z[i]; + otree->matched_pair = i; + } + } + + if(ch=="et") + { + if( +((leptonIndex==(analysisTree->refitvertex_eleIndex[i][0]))||(leptonIndex==(analysisTree->refitvertex_eleIndex[i][1])))&&((tauIndex==(analysisTree->refitvertex_tauIndex[i][0]))||(tauIndex==(analysisTree->refitvertex_tauIndex[i][1]))) + ) + { + otree->RefitVertexX = analysisTree->refitvertex_x[i]; + otree->RefitVertexY = analysisTree->refitvertex_y[i]; + otree->RefitVertexZ = analysisTree->refitvertex_z[i]; + otree->matched_pair = i; + } + } + + if(ch=="tt") + { + if( +((leptonIndex==(analysisTree->refitvertex_tauIndex[i][0]))||(leptonIndex==(analysisTree->refitvertex_tauIndex[i][1])))&&((tauIndex==(analysisTree->refitvertex_tauIndex[i][0]))||(tauIndex==(analysisTree->refitvertex_tauIndex[i][1]))) + ) + { + otree->RefitVertexX = analysisTree->refitvertex_x[i]; + otree->RefitVertexY = analysisTree->refitvertex_y[i]; + otree->RefitVertexZ = analysisTree->refitvertex_z[i]; + otree->matched_pair = i; + } + } + } + + //End of identifying correct refitted vertex (WITHOUT bs) + + //Begin of identifying correct refitted vertex (WITH bs) + + otree->RefitVertexX_with_bs = otree->RecoVertexX_with_bs; + otree->RefitVertexY_with_bs = otree->RecoVertexY_with_bs; + otree->RefitVertexZ_with_bs = otree->RecoVertexZ_with_bs; + + otree->matched_pair_with_bs = -1; + + for(unsigned int i=0; irefitvertexwithbs_count; i++) + { + if(ch=="mt") + { + if( +((leptonIndex==(analysisTree->refitvertexwithbs_muIndex[i][0]))||(leptonIndex==(analysisTree->refitvertexwithbs_muIndex[i][1])))&&((tauIndex==(analysisTree->refitvertexwithbs_tauIndex[i][0]))||(tauIndex==(analysisTree->refitvertexwithbs_tauIndex[i][1]))) + ) + { + otree->RefitVertexX_with_bs = analysisTree->refitvertexwithbs_x[i]; + otree->RefitVertexY_with_bs = analysisTree->refitvertexwithbs_y[i]; + otree->RefitVertexZ_with_bs = analysisTree->refitvertexwithbs_z[i]; + otree->matched_pair_with_bs = i; + } + } + + if(ch=="et") + { + if( +((leptonIndex==(analysisTree->refitvertexwithbs_eleIndex[i][0]))||(leptonIndex==(analysisTree->refitvertexwithbs_eleIndex[i][1])))&&((tauIndex==(analysisTree->refitvertexwithbs_tauIndex[i][0]))||(tauIndex==(analysisTree->refitvertexwithbs_tauIndex[i][1]))) + ) + { + otree->RefitVertexX_with_bs = analysisTree->refitvertexwithbs_x[i]; + otree->RefitVertexY_with_bs = analysisTree->refitvertexwithbs_y[i]; + otree->RefitVertexZ_with_bs = analysisTree->refitvertexwithbs_z[i]; + otree->matched_pair_with_bs = i; + } + } + + if(ch=="tt") + { + if( +((leptonIndex==(analysisTree->refitvertexwithbs_tauIndex[i][0]))||(leptonIndex==(analysisTree->refitvertexwithbs_tauIndex[i][1])))&&((tauIndex==(analysisTree->refitvertexwithbs_tauIndex[i][0]))||(tauIndex==(analysisTree->refitvertexwithbs_tauIndex[i][1]))) + ) + { + otree->RefitVertexX_with_bs = analysisTree->refitvertexwithbs_x[i]; + otree->RefitVertexY_with_bs = analysisTree->refitvertexwithbs_y[i]; + otree->RefitVertexZ_with_bs = analysisTree->refitvertexwithbs_z[i]; + otree->matched_pair_with_bs = i; + } + } + } + //End of identifying correct refitted vertex (WITH bs) +} diff --git a/NTupleMaker/interface/Synch17Tree.h b/NTupleMaker/interface/Synch17Tree.h index e7bf026fdf9..10ed336071b 100644 --- a/NTupleMaker/interface/Synch17Tree.h +++ b/NTupleMaker/interface/Synch17Tree.h @@ -304,10 +304,26 @@ public : Float_t RecoVertexX; Float_t RecoVertexY; Float_t RecoVertexZ; + + Float_t RecoVertexX_with_bs; + Float_t RecoVertexY_with_bs; + Float_t RecoVertexZ_with_bs; Float_t GenVertexX; Float_t GenVertexY; Float_t GenVertexZ; + + //refit vertices + Float_t RefitVertexX; + Float_t RefitVertexY; + Float_t RefitVertexZ; + Int_t matched_pair; + + Float_t RefitVertexX_with_bs; + Float_t RefitVertexY_with_bs; + Float_t RefitVertexZ_with_bs; + Int_t matched_pair_with_bs; + //Merijn: add the vx of the tau decay products Float_t VxConstitTau1; @@ -606,12 +622,27 @@ public : TBranch *b_RecoVertexX; TBranch *b_RecoVertexY; TBranch *b_RecoVertexZ; + + TBranch *b_RecoVertexX_with_bs; + TBranch *b_RecoVertexY_with_bs; + TBranch *b_RecoVertexZ_with_bs; //gen vertex info is practical to have TBranch *b_GenVertexX; TBranch *b_GenVertexY; TBranch *b_GenVertexZ; + //refit vertex info + TBranch *b_RefitVertexX; + TBranch *b_RefitVertexY; + TBranch *b_RefitVertexZ; + TBranch *b_matched_pair; + + TBranch *b_RefitVertexX_with_bs; + TBranch *b_RefitVertexY_with_bs; + TBranch *b_RefitVertexZ_with_bs; + TBranch *b_matched_pair_with_bs; + TBranch *b_VxConstitTau1; TBranch *b_VyConstitTau1; TBranch *b_VzConstitTau1; diff --git a/NTupleMaker/src/Synch17Tree.cc b/NTupleMaker/src/Synch17Tree.cc index 536b568748c..5615f9a4fb9 100644 --- a/NTupleMaker/src/Synch17Tree.cc +++ b/NTupleMaker/src/Synch17Tree.cc @@ -337,11 +337,26 @@ void Synch17Tree::ReadInit(TTree *tree) fChain->SetBranchAddress("RecoVertexX", &RecoVertexX, &b_RecoVertexX); fChain->SetBranchAddress("RecoVertexY", &RecoVertexY, &b_RecoVertexY); fChain->SetBranchAddress("RecoVertexZ", &RecoVertexZ, &b_RecoVertexZ); + + fChain->SetBranchAddress("RecoVertexX_with_bs", &RecoVertexX_with_bs, &b_RecoVertexX_with_bs); + fChain->SetBranchAddress("RecoVertexY_with_bs", &RecoVertexY_with_bs, &b_RecoVertexY_with_bs); + fChain->SetBranchAddress("RecoVertexZ_with_bs", &RecoVertexZ_with_bs, &b_RecoVertexZ_with_bs); //gen vertex info useful to have fChain->SetBranchAddress("GenVertexX", &GenVertexX, &b_GenVertexX); fChain->SetBranchAddress("GenVertexY", &GenVertexY, &b_GenVertexY); fChain->SetBranchAddress("GenVertexZ", &GenVertexZ, &b_GenVertexZ); + + //refitvertex info + fChain->SetBranchAddress("RefitVertexX", &RefitVertexX, &b_RefitVertexX); + fChain->SetBranchAddress("RefitVertexY", &RefitVertexY, &b_RefitVertexY); + fChain->SetBranchAddress("RefitVertexZ", &RefitVertexZ, &b_RefitVertexZ); + fChain->SetBranchAddress("matched_pair", &matched_pair, &b_matched_pair); + + fChain->SetBranchAddress("RefitVertexX_with_bs", &RefitVertexX_with_bs, &b_RefitVertexX_with_bs); + fChain->SetBranchAddress("RefitVertexY_with_bs", &RefitVertexY_with_bs, &b_RefitVertexY_with_bs); + fChain->SetBranchAddress("RefitVertexZ_with_bs", &RefitVertexZ_with_bs, &b_RefitVertexZ_with_bs); + fChain->SetBranchAddress("matched_pair_with_bs", &matched_pair_with_bs, &b_matched_pair_with_bs); fChain->SetBranchAddress("VxConstitTau1", &VxConstitTau1, &b_VxConstitTau1); fChain->SetBranchAddress("VyConstitTau1", &VyConstitTau1, &b_VyConstitTau1); @@ -703,11 +718,26 @@ void Synch17Tree::WriteInit(TTree *tree) { fChain->Branch("RecoVertexX", &RecoVertexX, "RecoVertexX/F"); fChain->Branch("RecoVertexY", &RecoVertexY, "RecoVertexY/F"); fChain->Branch("RecoVertexZ", &RecoVertexZ, "RecoVertexZ/F"); + + fChain->Branch("RecoVertexX_with_bs", &RecoVertexX_with_bs, "RecoVertexX_with_bs/F"); + fChain->Branch("RecoVertexY_with_bs", &RecoVertexY_with_bs, "RecoVertexY_with_bs/F"); + fChain->Branch("RecoVertexZ_with_bs", &RecoVertexZ_with_bs, "RecoVertexZ_with_bs/F"); fChain->Branch("GenVertexX", &GenVertexX, "GenVertexX/F"); fChain->Branch("GenVertexY", &GenVertexY, "GenVertexY/F"); fChain->Branch("GenVertexZ", &GenVertexZ, "GenVertexZ/F"); + //storing refitvertex info + fChain->Branch("RefitVertexX", &RefitVertexX, "RefitVertexX/F"); + fChain->Branch("RefitVertexY", &RefitVertexY, "RefitVertexY/F"); + fChain->Branch("RefitVertexZ", &RefitVertexZ, "RefitVertexZ/F"); + fChain->Branch("matched_pair", &matched_pair, "matched_pair/I"); + + fChain->Branch("RefitVertexX_with_bs", &RefitVertexX_with_bs, "RefitVertexX_with_bs/F"); + fChain->Branch("RefitVertexY_with_bs", &RefitVertexY_with_bs, "RefitVertexY_with_bs/F"); + fChain->Branch("RefitVertexZ_with_bs", &RefitVertexZ_with_bs, "RefitVertexZ_with_bs/F"); + fChain->Branch("matched_pair_with_bs", &matched_pair_with_bs, "matched_pair_with_bs/I"); + fChain->Branch("VxConstitTau1", &VxConstitTau1, "VxConstitTau1/F"); fChain->Branch("VyConstitTau1", &VyConstitTau1, "VyConstitTau1/F"); fChain->Branch("VzConstitTau1", &VzConstitTau1, "VzConstitTau1/F");