Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 114 additions & 1 deletion NTupleMaker/bin/SynchNTupleProducer_2017.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down Expand Up @@ -959,7 +960,8 @@ for (Long64_t iEntry=0; iEntry<numberOfEntries; iEntry++) {
lep_eta = analysisTree.tau_eta[leptonIndex];
lep_phi = analysisTree.tau_phi[leptonIndex];
}



bool isSingleLepTrig = false;
bool isDiTauTrig = false;
bool isTauTrig = false;
Expand Down Expand Up @@ -1067,6 +1069,7 @@ for (Long64_t iEntry=0; iEntry<numberOfEntries; iEntry++) {

//all criterua passed, we fill vertices here;
SaveRECOVertices(&analysisTree,otree, isData);
Refitting(&analysisTree, otree, tauIndex, leptonIndex, argv[3]);

//Merijn: save here all gen information for the selected RECO events, gets stored for convenience in the taucheck tree ;-). Note that no selection on gen level is applied..
if (!isData){
Expand Down Expand Up @@ -2126,6 +2129,11 @@ void SaveRECOVertices(const AC1B * analysisTree, Synch17Tree *otree, const bool
otree->RecoVertexX=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){
Expand All @@ -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; i<analysisTree->refitvertex_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; i<analysisTree->refitvertexwithbs_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)
}
31 changes: 31 additions & 0 deletions NTupleMaker/interface/Synch17Tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
30 changes: 30 additions & 0 deletions NTupleMaker/src/Synch17Tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down