Skip to content

Instantly share code, notes, and snippets.

@kratsg
Created July 23, 2015 01:57
Show Gist options
  • Select an option

  • Save kratsg/6193f21b3cc3161b50d2 to your computer and use it in GitHub Desktop.

Select an option

Save kratsg/6193f21b3cc3161b50d2 to your computer and use it in GitHub Desktop.
Index: OverlapRemovalTool.patch
===================================================================
--- OverlapRemovalTool.patch (revision 239645)
+++ OverlapRemovalTool.patch (revision 239687)
@@ -1,50 +0,0 @@
---- OverlapRemovalTool.cxx 2015-06-10 13:24:57.000000001 +0200
-+++ OverlapRemovalTool_patch.cxx 2015-06-10 13:24:08.000000001 +0200
-@@ -227,31 +227,29 @@
- #define numTrk(jet) \
- jet->getAttribute< std::vector<int> >(xAOD::JetAttribute::NumTrkPt500)[0]
-
-- // Remove jets that overlap with muons
-- for(const auto jet : jets){
-- // Only remove low-trk-multiplicity jets
-- if(isSurvivingObject(jet) && numTrk(jet) <= 2){
-- if(objectOverlaps(jet, muons, m_muonJetDR)){
-- ATH_MSG_DEBUG(" Found overlap jet: " << jet->pt()*invGeV);
-- setObjectFail(jet);
-- }
-- }
-- }
- // Remove muons that overlap with jets
- for(const auto muon : muons){
- if(isSurvivingObject(muon)){
-+ double DR = 0.04 + 10000. / muon->pt();
- for(const auto jet : jets){
-- // Only remove from high-trk-multiplicity jets
-- if(isSurvivingObject(jet) && numTrk(jet) > 2){
-- if(objectsOverlap(jet, muon, m_muonJetDR)){
-- ATH_MSG_DEBUG(" Found overlap muon: " << muon->pt()*invGeV);
-- setObjectFail(muon);
-- }
-- }
-+ // remove low-trk-multiplicity jets which overlap with muons
-+ if(isSurvivingObject(jet) && numTrk(jet) <= 2){
-+ if(objectsOverlap(jet, muon, DR)){
-+ ATH_MSG_DEBUG(" Found overlap jet: " << jet->pt()*invGeV);
-+ setObjectFail(jet);
-+ }
-+ }
-+ // remove muons which overlap with high-trk-multiplicity jets
-+ else if(isSurvivingObject(jet) && numTrk(jet) > 2){
-+ if(objectsOverlap(jet, muon, DR)){
-+ ATH_MSG_DEBUG(" Found overlap muon: " << muon->pt()*invGeV);
-+ setObjectFail(muon);
-+ }
-+ }
- }
- }
- }
--
-+
- #undef numTrk
-
- return StatusCode::SUCCESS;
Index: SUSYTools.patch
===================================================================
--- SUSYTools.patch (revision 0)
+++ SUSYTools.patch (revision 239687)
@@ -0,0 +1,24 @@
+--- SUSYObjDef_xAOD.cxx 2015-07-22 16:43:53.000000001 +0200
++++ SUSYObjDef_xAOD_patch.cxx 2015-07-22 16:45:20.000000001 +0200
+@@ -1685,8 +1685,8 @@
+ std::vector<int> nTrkVec;
+ jet->getAttribute(xAOD::JetAttribute::NumTrkPt500, nTrkVec);
+ int jet_nTrk = (this->GetPrimVtx() == 0 || nTrkVec.size() == 0) ? 0 : nTrkVec[this->GetPrimVtx()->index()];
+-
+- if ( xAOD::P4Helpers::deltaR2(*mu, *jet) < dRjetmu * dRjetmu ) {
++ double dRjetmu_rel = 0.04 + 10000. / mu->pt();
++ if ( xAOD::P4Helpers::deltaR2(*mu, *jet) < dRjetmu_rel * dRjetmu_rel ) {
+ if (jet_nTrk < 3) {
+ ATH_MSG_VERBOSE( " Rejecting jet at (pT,eta,phi)=(" << jet->pt() << "," << jet->eta() << "," << jet->phi() << ") with only nTrk=" << jet_nTrk
+ << " due to muon at (pT,eta,phi)=(" << mu->pt() << "," << mu->eta() << "," << mu->phi() << ")" );
+@@ -1841,8 +1841,8 @@
+ std::vector<int> nTrkVec;
+ jet->getAttribute(xAOD::JetAttribute::NumTrkPt500, nTrkVec);
+ int jet_nTrk = (this->GetPrimVtx() == 0 || nTrkVec.size() == 0) ? 0 : nTrkVec[this->GetPrimVtx()->index()];
+-
+- if ( xAOD::P4Helpers::deltaR2(mu, jet) < dRjetmu * dRjetmu ) {
++ double dRjetmu_rel = 0.04 + 10000. / mu->pt();
++ if ( xAOD::P4Helpers::deltaR2(mu, jet) < dRjetmu_rel * dRjetmu_rel ) {
+ if (jet_nTrk < 3) {
+ ATH_MSG_VERBOSE( " Rejecting jet at (pT,eta,phi)=(" << jet->pt() << "," << jet->eta() << "," << jet->phi() << ") with only nTrk=" << jet_nTrk
+ << " due to muon at (pT,eta,phi)=(" << mu->pt() << "," << mu->eta() << "," << mu->phi() << ")" );
Index: Root/TreeMaker.cxx
===================================================================
--- Root/TreeMaker.cxx (revision 239645)
+++ Root/TreeMaker.cxx (revision 239687)
@@ -17,175 +17,213 @@
#include <TSystem.h>
#include "BtaggingTRFandRW/TRFinterface.h"
+
#include<memory>
//_________________________________________________________________________
//
-TreeMaker::TreeMaker(TFile *file, bool do_truth, bool do_rc_jets, bool do_ak10_jets, bool do_TRF)
+TreeMaker::TreeMaker(TFile *file, bool do_truth, bool do_rc_jets, bool do_ak10_jets, bool do_TRF, int TopPtCorrectionMode, bool do_syst, std::vector<ST::SystInfo> sys_list)
{
- m_tree = new TTree ("tree", "tree");
- m_tree->SetDirectory (file);
+
+ TTree* tree_nom = new TTree("nominal", "nominal");
+ m_tree_map.insert( std::pair< string, TTree*> ("nominal" , tree_nom) );
+ m_tree_map["nominal"]->SetDirectory (file);
+
+ if(do_syst) {
+ for(const auto& sys : sys_list) {
+ if(sys.affectsKinematics){
+ const CP::SystematicSet& sysSet = sys.systset;
+ const char* sys_name = sysSet.name().c_str();
+ TTree* tree_sys = new TTree(sys_name, sys_name);
+ m_tree_map.insert( std::pair< string, TTree*> (sys_name , tree_sys) );
+ m_tree_map[sys_name]->SetDirectory (file);
+ }
+ }
+ }
// chiara
const std::string pathToConf = gSystem->Getenv("ROOTCOREBIN");
m_trfint = new TRFinterface(pathToConf+"/data/BtaggingTRFandRW/calibConfig_MV2c20.txt",-0.7682,"AntiKt4EMTopoJets",false, 0);
- m_tree->Branch("event_number", &m_event_number, "event_number/I");
- m_tree->Branch("run_number", &m_run_number, "run_number/I");
- m_tree->Branch("average_interactions_per_crossing", &m_average_interactions_per_crossing, "average_interactions_per_crossing/F");
- m_tree->Branch("actual_interactions_per_crossing", &m_actual_interactions_per_crossing, "actual_interactions_per_crossing/F");
- m_tree->Branch("primary_vertex_z", &m_primary_vertex_z, "primary_vertex_z/F");
- m_tree->Branch("process", &m_process, "process/I");
-
- m_tree->Branch("muons_n",&m_muons_n, "muons_n/I");
- m_tree->Branch("muons_pt",&m_muons_pt);
- m_tree->Branch("muons_phi",&m_muons_phi);
- m_tree->Branch("muons_eta", &m_muons_eta);
- m_tree->Branch("muons_e", &m_muons_e);
- m_tree->Branch("muons_passOR", &m_muons_passOR);
- m_tree->Branch("muons_isSignal", &m_muons_isSignal);
- m_tree->Branch("muons_isCosmic", &m_muons_isCosmic);
- m_tree->Branch("muons_isBad", &m_muons_isBad);
- m_tree->Branch("muons_ptvarcone20", &m_muons_ptvarcone20);
- m_tree->Branch("muons_ptvarcone30", &m_muons_ptvarcone30);
- m_tree->Branch("muons_topoetcone20", &m_muons_topoetcone20);
- m_tree->Branch("muons_d0sig", &m_muons_d0sig);
- m_tree->Branch("muons_z0", &m_muons_z0);
-
- m_tree->Branch("electrons_n",&m_electrons_n, "electrons_n/I");
- m_tree->Branch("electrons_pt",&m_electrons_pt);
- m_tree->Branch("electrons_phi",&m_electrons_phi);
- m_tree->Branch("electrons_eta", &m_electrons_eta);
- m_tree->Branch("electrons_e", &m_electrons_e);
- m_tree->Branch("electrons_passOR", &m_electrons_passOR);
- m_tree->Branch("electrons_isSignal", &m_electrons_isSignal);
- m_tree->Branch("electrons_ptvarcone20", &m_electrons_ptvarcone20);
- m_tree->Branch("electrons_ptvarcone30", &m_electrons_ptvarcone30);
- m_tree->Branch("electrons_topoetcone20", &m_electrons_topoetcone20);
- m_tree->Branch("electrons_d0sig", &m_electrons_d0sig);
- m_tree->Branch("electrons_z0", &m_electrons_z0);
-
- m_tree->Branch("jets_n",&m_jets_n, "jets_n/I");
- m_tree->Branch("jets_pt",&m_jets_pt);
- m_tree->Branch("jets_phi",&m_jets_phi);
- m_tree->Branch("jets_eta", &m_jets_eta);
- m_tree->Branch("jets_e", &m_jets_e);
- m_tree->Branch("jets_passOR", &m_jets_passOR);
- m_tree->Branch("jets_isBad", &m_jets_isBad);
- m_tree->Branch("jets_nTracks", &m_jets_nTracks);
- m_tree->Branch("jets_truthLabel", &m_jets_truthLabel);
- m_tree->Branch("jets_btag_weight", &m_jets_btag_weight);
- m_tree->Branch("jets_isb_60", &m_jets_isb_60);
- m_tree->Branch("jets_isb_70", &m_jets_isb_70);
- m_tree->Branch("jets_isb_85", &m_jets_isb_85);
-
- m_tree->Branch("metcst",&m_metcst,"metcst/F");
- m_tree->Branch("metcst_phi",&m_metcst_phi,"metcst_phi/F");
- m_tree->Branch("mettst",&m_mettst,"mettst/F");
- m_tree->Branch("mettst_phi",&m_mettst_phi,"mettst_phi/F");
-
- m_tree->Branch("meff",&m_meff,"meff/F");
- m_tree->Branch("ht",&m_ht,"ht/F");
- m_tree->Branch("met_sig",&m_met_sig,"met_sig/F");
- m_tree->Branch("mt",&m_mt,"mt/F");
- m_tree->Branch("mt_min_bmet",&m_mt_min_bmet,"mt_min_bmet/F");
- m_tree->Branch("mt_min_bmetW",&m_mt_min_bmetW,"mt_min_bmetW/F");
-
-
- m_tree->Branch("trigger",&m_trigger);
-
- m_tree->Branch("weight_mc",&m_weight_mc,"weight_mc/D");
- m_tree->Branch("weight_pu",&m_weight_pu,"weight_pu/D");
- m_tree->Branch("weight_btag",&m_weight_btag,"weight_btag/D");
- m_tree->Branch("weight_elec",&m_weight_elec,"weight_elec/D");
- m_tree->Branch("weight_muon",&m_weight_muon,"weight_muon/D");
-
- if(do_truth) {
- m_tree->Branch("ttbar_class", &m_ttbar_class, "ttbar_class/I");
- m_tree->Branch("ttbar_class_ext", &m_ttbar_class_ext, "ttbar_class_ext/I");
- m_tree->Branch("ttbar_class_prompt", &m_ttbar_class_prompt, "ttbar_class_prompt/I");
+ for(auto &it : m_tree_map) {
+ it.second->Branch("event_number", &m_event_number, "event_number/I");
+ it.second->Branch("run_number", &m_run_number, "run_number/I");
+ it.second->Branch("average_interactions_per_crossing", &m_average_interactions_per_crossing, "average_interactions_per_crossing/F");
+ it.second->Branch("actual_interactions_per_crossing", &m_actual_interactions_per_crossing, "actual_interactions_per_crossing/F");
+ it.second->Branch("primary_vertex_z", &m_primary_vertex_z, "primary_vertex_z/F");
+ it.second->Branch("process", &m_process, "process/I");
+
+ it.second->Branch("muons_n",&m_muons_n, "muons_n/I");
+ it.second->Branch("muons_pt",&m_muons_pt);
+ it.second->Branch("muons_phi",&m_muons_phi);
+ it.second->Branch("muons_eta", &m_muons_eta);
+ it.second->Branch("muons_e", &m_muons_e);
+ it.second->Branch("muons_passOR", &m_muons_passOR);
+ it.second->Branch("muons_isSignal", &m_muons_isSignal);
+ it.second->Branch("muons_isCosmic", &m_muons_isCosmic);
+ it.second->Branch("muons_isBad", &m_muons_isBad);
+ it.second->Branch("muons_ptvarcone20", &m_muons_ptvarcone20);
+ it.second->Branch("muons_ptvarcone30", &m_muons_ptvarcone30);
+ it.second->Branch("muons_topoetcone20", &m_muons_topoetcone20);
+ it.second->Branch("muons_d0sig", &m_muons_d0sig);
+ it.second->Branch("muons_z0", &m_muons_z0);
+
+ it.second->Branch("electrons_n",&m_electrons_n, "electrons_n/I");
+ it.second->Branch("electrons_pt",&m_electrons_pt);
+ it.second->Branch("electrons_phi",&m_electrons_phi);
+ it.second->Branch("electrons_eta", &m_electrons_eta);
+ it.second->Branch("electrons_e", &m_electrons_e);
+ it.second->Branch("electrons_passOR", &m_electrons_passOR);
+ it.second->Branch("electrons_isSignal", &m_electrons_isSignal);
+ it.second->Branch("electrons_ptvarcone20", &m_electrons_ptvarcone20);
+ it.second->Branch("electrons_ptvarcone30", &m_electrons_ptvarcone30);
+ it.second->Branch("electrons_topoetcone20", &m_electrons_topoetcone20);
+ it.second->Branch("electrons_d0sig", &m_electrons_d0sig);
+ it.second->Branch("electrons_z0", &m_electrons_z0);
+
+ it.second->Branch("jets_n",&m_jets_n, "jets_n/I");
+ it.second->Branch("jets_pt",&m_jets_pt);
+ it.second->Branch("jets_phi",&m_jets_phi);
+ it.second->Branch("jets_eta", &m_jets_eta);
+ it.second->Branch("jets_e", &m_jets_e);
+ it.second->Branch("jets_passOR", &m_jets_passOR);
+ it.second->Branch("jets_isBad", &m_jets_isBad);
+ it.second->Branch("jets_nTracks", &m_jets_nTracks);
+ it.second->Branch("jets_truthLabel", &m_jets_truthLabel);
+ it.second->Branch("jets_btag_weight", &m_jets_btag_weight);
+ it.second->Branch("jets_isb_60", &m_jets_isb_60);
+ it.second->Branch("jets_isb_70", &m_jets_isb_70);
+ it.second->Branch("jets_isb_85", &m_jets_isb_85);
+
+ it.second->Branch("metcst",&m_metcst,"metcst/F");
+ it.second->Branch("metcst_phi",&m_metcst_phi,"metcst_phi/F");
+ it.second->Branch("mettst",&m_mettst,"mettst/F");
+ it.second->Branch("mettst_phi",&m_mettst_phi,"mettst_phi/F");
+
+ it.second->Branch("meff",&m_meff,"meff/F");
+ it.second->Branch("ht",&m_ht,"ht/F");
+ it.second->Branch("met_sig",&m_met_sig,"met_sig/F");
+ it.second->Branch("mt",&m_mt,"mt/F");
+ it.second->Branch("mt_min_bmet",&m_mt_min_bmet,"mt_min_bmet/F");
+ it.second->Branch("mt_min_bmetW",&m_mt_min_bmetW,"mt_min_bmetW/F");
+
+ it.second->Branch("trigger",&m_trigger);
+
+ it.second->Branch("weight_mc",&m_weight_mc,"weight_mc/D");
+ it.second->Branch("weight_pu",&m_weight_pu,"weight_pu/D");
+ it.second->Branch("weight_btag",&m_weight_btag,"weight_btag/D");
+ it.second->Branch("weight_elec",&m_weight_elec,"weight_elec/D");
+ it.second->Branch("weight_muon",&m_weight_muon,"weight_muon/D");
+
+ if(do_truth) {
+ it.second->Branch("ttbar_class", &m_ttbar_class, "ttbar_class/I");
+ it.second->Branch("ttbar_class_ext", &m_ttbar_class_ext, "ttbar_class_ext/I");
+ it.second->Branch("ttbar_class_prompt", &m_ttbar_class_prompt, "ttbar_class_prompt/I");
- m_tree->Branch("mc_n",&m_mc_n, "mc_n/I");
- m_tree->Branch("mc_pt",&m_mc_pt);
- m_tree->Branch("mc_eta",&m_mc_eta);
- m_tree->Branch("mc_phi",&m_mc_phi);
- m_tree->Branch("mc_m",&m_mc_m);
- m_tree->Branch("mc_status",&m_mc_status);
- m_tree->Branch("mc_barcode",&m_mc_barcode);
- m_tree->Branch("mc_pdgId",&m_mc_pdgId);
- m_tree->Branch("mc_index",&m_mc_index);
- m_tree->Branch("mc_parents_index",&m_mc_parents_index);
- m_tree->Branch("mc_children_index",&m_mc_children_index);
+ it.second->Branch("mc_n",&m_mc_n, "mc_n/I");
+ it.second->Branch("mc_pt",&m_mc_pt);
+ it.second->Branch("mc_eta",&m_mc_eta);
+ it.second->Branch("mc_phi",&m_mc_phi);
+ it.second->Branch("mc_m",&m_mc_m);
+ it.second->Branch("mc_status",&m_mc_status);
+ it.second->Branch("mc_barcode",&m_mc_barcode);
+ it.second->Branch("mc_pdgId",&m_mc_pdgId);
+ it.second->Branch("mc_index",&m_mc_index);
+ it.second->Branch("mc_parents_index",&m_mc_parents_index);
+ it.second->Branch("mc_children_index",&m_mc_children_index);
+
+ it.second->Branch("met_truth",&m_met_truth,"met_truth/F");
+ it.second->Branch("met_truth_phi",&m_met_truth_phi,"met_truth_phi/F");
+
+ it.second->Branch("mtt",&m_mtt,"mtt/F");
+
+ if(TopPtCorrectionMode>0){
+ it.second->Branch("weight_topPt",&m_weight_topPt,"weight_topPt/D");
+ if(TopPtCorrectionMode>1){//consider systematic variations
+ std::vector < std::string > vec_sys;
+ vec_sys.push_back("ISRFSR_UP");vec_sys.push_back("ISRFSR_DOWN");
+ vec_sys.push_back("Fragmentation_UP");vec_sys.push_back("Fragmentation_DOWN");
+ vec_sys.push_back("MCGenerator_UP");vec_sys.push_back("MCGenerator_DOWN");
+ vec_sys.push_back("JER_UP");vec_sys.push_back("JER_DOWN");
+ vec_sys.push_back("bJES_UP");vec_sys.push_back("bJES_DOWN");
+ vec_sys.push_back("closebyJES_UP");vec_sys.push_back("closebyJES_DOWN");
+ vec_sys.push_back("etacalibJES_UP");vec_sys.push_back("etacalibJES_DOWN");
+ vec_sys.push_back("effdetset1JES_UP");vec_sys.push_back("effdetset1JES_DOWN");
+ vec_sys.push_back("btageff_UP");vec_sys.push_back("btageff_DOWN");
+ for( const std::string sys : vec_sys ){
+ std::string name = "weight_topPt_"+sys;
+ std::string branchName = name+"/D";
+ m_weight_topPt_systs.insert( std::pair < std::string, double >(name,1.) );
+ it.second->Branch(name.c_str(), &(m_weight_topPt_systs[name]), branchName.c_str());
+ }
+ vec_sys.clear();
+ }
+ }
+ }
- m_tree->Branch("met_truth",&m_met_truth,"met_truth/F");
- m_tree->Branch("met_truth_phi",&m_met_truth_phi,"met_truth_phi/F");
-
- m_tree->Branch("mtt",&m_mtt,"mtt/F");
+ if(do_rc_jets) {
+ it.second->Branch("rc_jets_n",&m_rc_jets_n, "rc_jets_n/I");
+ it.second->Branch("rc_jets_pt",&m_rc_jets_pt);
+ it.second->Branch("rc_jets_phi",&m_rc_jets_phi);
+ it.second->Branch("rc_jets_eta", &m_rc_jets_eta);
+ it.second->Branch("rc_jets_e", &m_rc_jets_e);
+ it.second->Branch("rc_jets_m", &m_rc_jets_m);
+ it.second->Branch("rc_jets_nconst", &m_rc_jets_nconst);
+ it.second->Branch("rc_jets_SPLIT12", &m_rc_jets_SPLIT12);
+ it.second->Branch("rc_jets_SPLIT23", &m_rc_jets_SPLIT23);
+ it.second->Branch("rc_jets_tau21", &m_rc_jets_Tau21);
+ it.second->Branch("rc_jets_tau32", &m_rc_jets_Tau32);
+ it.second->Branch("rc_jets_isTopLoose", &m_rc_jets_isTopLoose);
+ it.second->Branch("rc_jets_isTopMedium", &m_rc_jets_isTopMedium);
+ it.second->Branch("rc_jets_isTopTight", &m_rc_jets_isTopTight);
+
+ }
+
+ if(do_ak10_jets) {
+ it.second->Branch("ak10_jets_n",&m_ak10_jets_n, "ak10_jets_n/I");
+ it.second->Branch("ak10_jets_pt",&m_ak10_jets_pt);
+ it.second->Branch("ak10_jets_phi",&m_ak10_jets_phi);
+ it.second->Branch("ak10_jets_eta", &m_ak10_jets_eta);
+ it.second->Branch("ak10_jets_e", &m_ak10_jets_e);
+ it.second->Branch("ak10_jets_m", &m_ak10_jets_m);
+ it.second->Branch("ak10_jets_SPLIT12", &m_ak10_jets_SPLIT12);
+ it.second->Branch("ak10_jets_SPLIT23", &m_ak10_jets_SPLIT23);
+ it.second->Branch("ak10_jets_tau21", &m_ak10_jets_Tau21);
+ it.second->Branch("ak10_jets_tau32", &m_ak10_jets_Tau32);
+ it.second->Branch("ak10_jets_isTopLoose", &m_ak10_jets_isTopLoose);
+ it.second->Branch("ak10_jets_isTopTight", &m_ak10_jets_isTopTight);
+ it.second->Branch("ak10_jets_isTopSmoothLoose", &m_ak10_jets_isTopSmoothLoose);
+ it.second->Branch("ak10_jets_isTopSmoothTight", &m_ak10_jets_isTopSmoothTight);
+ }
+
+ // chiara
+ if(do_TRF){
+ // it.second->Branch("TRFweight_in", &m_TRFweight_in);
+ // it.second->Branch("TRFweight_ex", &m_TRFweight_ex);
+ // it.second->Branch("TRFPerm_in", &m_TRFPerm_in);
+ // it.second->Branch("TRFPerm_ex", &m_TRFPerm_ex);
+ // it.second->Branch("TRFTagBins_in", &m_TRFTagBins_in);
+ // it.second->Branch("TRFTagBins_ex", &m_TRFTagBins_ex);
+ it.second->Branch("TRFweight_2excl", &m_TRFweight_2excl);
+ it.second->Branch("TRFweight_2incl", &m_TRFweight_2incl);
+ it.second->Branch("TRFweight_3excl", &m_TRFweight_3excl);
+ it.second->Branch("TRFweight_3incl", &m_TRFweight_3incl);
+ it.second->Branch("TRFweight_4incl", &m_TRFweight_4incl);
+ it.second->Branch("jets_isb_85_TRF_2excl" , &m_jets_isb_85_TRF_2excl);
+ it.second->Branch("jets_isb_85_TRF_2incl" , &m_jets_isb_85_TRF_2incl);
+ it.second->Branch("jets_isb_85_TRF_3excl" , &m_jets_isb_85_TRF_3excl);
+ it.second->Branch("jets_isb_85_TRF_3incl" , &m_jets_isb_85_TRF_3incl);
+ it.second->Branch("jets_isb_85_TRF_4incl" , &m_jets_isb_85_TRF_4incl);
+ }
}
-
- if(do_rc_jets) {
- m_tree->Branch("rc_jets_n",&m_rc_jets_n, "rc_jets_n/I");
- m_tree->Branch("rc_jets_pt",&m_rc_jets_pt);
- m_tree->Branch("rc_jets_phi",&m_rc_jets_phi);
- m_tree->Branch("rc_jets_eta", &m_rc_jets_eta);
- m_tree->Branch("rc_jets_e", &m_rc_jets_e);
- m_tree->Branch("rc_jets_m", &m_rc_jets_m);
- m_tree->Branch("rc_jets_nconst", &m_rc_jets_nconst);
- m_tree->Branch("rc_jets_SPLIT12", &m_rc_jets_SPLIT12);
- m_tree->Branch("rc_jets_SPLIT23", &m_rc_jets_SPLIT23);
- m_tree->Branch("rc_jets_tau21", &m_rc_jets_Tau21);
- m_tree->Branch("rc_jets_tau32", &m_rc_jets_Tau32);
- m_tree->Branch("rc_jets_isTopLoose", &m_rc_jets_isTopLoose);
- m_tree->Branch("rc_jets_isTopMedium", &m_rc_jets_isTopMedium);
- m_tree->Branch("rc_jets_isTopTight", &m_rc_jets_isTopTight);
- }
- if(do_ak10_jets) {
- m_tree->Branch("ak10_jets_n",&m_ak10_jets_n, "ak10_jets_n/I");
- m_tree->Branch("ak10_jets_pt",&m_ak10_jets_pt);
- m_tree->Branch("ak10_jets_phi",&m_ak10_jets_phi);
- m_tree->Branch("ak10_jets_eta", &m_ak10_jets_eta);
- m_tree->Branch("ak10_jets_e", &m_ak10_jets_e);
- m_tree->Branch("ak10_jets_m", &m_ak10_jets_m);
- m_tree->Branch("ak10_jets_SPLIT12", &m_ak10_jets_SPLIT12);
- m_tree->Branch("ak10_jets_SPLIT23", &m_ak10_jets_SPLIT23);
- m_tree->Branch("ak10_jets_tau21", &m_ak10_jets_Tau21);
- m_tree->Branch("ak10_jets_tau32", &m_ak10_jets_Tau32);
- m_tree->Branch("ak10_jets_isTopLoose", &m_ak10_jets_isTopLoose);
- m_tree->Branch("ak10_jets_isTopTight", &m_ak10_jets_isTopTight);
- m_tree->Branch("ak10_jets_isTopSmoothLoose", &m_ak10_jets_isTopSmoothLoose);
- m_tree->Branch("ak10_jets_isTopSmoothTight", &m_ak10_jets_isTopSmoothTight);
-
- }
-
- // chiara
- if(do_TRF){
- // m_tree->Branch("TRFweight_in", &m_TRFweight_in);
- // m_tree->Branch("TRFweight_ex", &m_TRFweight_ex);
- // m_tree->Branch("TRFPerm_in", &m_TRFPerm_in);
- // m_tree->Branch("TRFPerm_ex", &m_TRFPerm_ex);
- // m_tree->Branch("TRFTagBins_in", &m_TRFTagBins_in);
- // m_tree->Branch("TRFTagBins_ex", &m_TRFTagBins_ex);
- m_tree->Branch("TRFweight_2excl", &m_TRFweight_2excl);
- m_tree->Branch("TRFweight_2incl", &m_TRFweight_2incl);
- m_tree->Branch("TRFweight_3excl", &m_TRFweight_3excl);
- m_tree->Branch("TRFweight_3incl", &m_TRFweight_3incl);
- m_tree->Branch("TRFweight_4incl", &m_TRFweight_4incl);
- m_tree->Branch("jets_isb_85_TRF_2excl" , &m_jets_isb_85_TRF_2excl);
- m_tree->Branch("jets_isb_85_TRF_2incl" , &m_jets_isb_85_TRF_2incl);
- m_tree->Branch("jets_isb_85_TRF_3excl" , &m_jets_isb_85_TRF_3excl);
- m_tree->Branch("jets_isb_85_TRF_3incl" , &m_jets_isb_85_TRF_3incl);
- m_tree->Branch("jets_isb_85_TRF_4incl" , &m_jets_isb_85_TRF_4incl);
- }
-
-
}
//_________________________________________________________________________
//
TreeMaker::~TreeMaker(){
- delete m_tree;
+
}
//_________________________________________________________________________
@@ -199,6 +237,7 @@
int ttbar_class,
int ttbar_class_ext,
int ttbar_class_prompt,
+ TopTtbarPtReweighting::TopTtbarPtReweightingResult topptrw,
const xAOD::MuonContainer* v_muons,
const xAOD::ElectronContainer* v_electrons,
const xAOD::JetContainer* v_jets,
@@ -225,7 +264,6 @@
m_mettst = v_mettst->met() / MEV;
m_mettst_phi = v_mettst->phi();
-
// default met is mtcst
m_meff = Variables::Meff_incl(v_metcst, v_jets, v_muons, v_electrons);
m_ht = Variables::Ht(v_jets, v_muons, v_electrons);
@@ -240,9 +278,10 @@
m_weight_elec = weight[3];
m_weight_muon = weight[4];
- m_muons_n = v_muons->size();
+ m_muons_n = 0;
for (auto muon : *v_muons) {
if(muon->auxdata<char>("baseline")==0) continue;
+ m_muons_n ++;
m_muons_pt.push_back(muon->pt() / MEV);
m_muons_eta.push_back(muon->eta());
@@ -262,10 +301,11 @@
m_muons_z0.push_back(HelperFunctions::getZ0(muon, primary_vertex_z));
}
- m_electrons_n = v_electrons->size();
+ m_electrons_n = 0;
for (auto electron : *v_electrons) {
if(electron->auxdata<char>("baseline")==0) continue;
-
+ m_electrons_n ++;
+
m_electrons_pt.push_back(electron->pt() / MEV);
m_electrons_eta.push_back(electron->eta());
m_electrons_phi.push_back(electron->phi());
@@ -291,10 +331,12 @@
}
- m_jets_n = v_jets->size();
+ m_jets_n = 0;
for (auto jet : *v_jets) {
if(jet->auxdata<char>("baseline")==0) continue;
+ m_jets_n++;
+
m_jets_pt.push_back(jet->pt() / MEV);
m_jets_eta.push_back(jet->eta());
m_jets_phi.push_back(jet->phi());
@@ -369,7 +411,16 @@
m_TRFweight_3incl = m_TRFweight_in.at(3);
m_TRFweight_4incl = m_TRFweight_in.at(4);
}
-
+
+ m_weight_topPt = topptrw.nominal;
+ if(topptrw.systematics.size()>0){
+ for( const std::pair < std::string, double > syst : topptrw.systematics ){
+ std::string name = "weight_topPt_"+syst.first;
+ m_weight_topPt_systs[name] = syst.second;
+ name.clear();
+ }
+ }
+
for( auto trigger : v_trigger) {
m_trigger.push_back(trigger);
}
@@ -506,16 +557,18 @@
//_________________________________________________________________________
//
-void TreeMaker::Fill()
+void TreeMaker::Fill(std::string sys_name)
{
- m_tree->Fill();
+ m_tree_map[sys_name]->Fill();
}
//_________________________________________________________________________
//
void TreeMaker::Write()
{
- m_tree->Write();
+ for(auto &it : m_tree_map) {
+ it.second->Write();
+ }
}
//_________________________________________________________________________
@@ -645,4 +698,10 @@
m_jets_isb_85_TRF_3incl.clear();
m_jets_isb_85_TRF_4incl.clear();
+ m_weight_topPt = 1.;
+ if(m_weight_topPt_systs.size()>0){
+ for ( std::pair < std::string, double > syst : m_weight_topPt_systs ) {
+ syst.second = -1.;
+ }
+ }
}
Index: Root/JetHelper.cxx
===================================================================
--- Root/JetHelper.cxx (revision 239645)
+++ Root/JetHelper.cxx (revision 239687)
@@ -96,15 +96,16 @@
// Retreive the jet container and apply calibrations
void JetHelper::RetrieveJets(xAOD::JetContainer*& jets,xAOD::ShallowAuxContainer*& jets_aux, bool isNominal)
{
-
- //Take advantage of TStore memory management (if isNominal = true)
- if(!m_susy_tools->GetJets(jets,jets_aux,isNominal,"AntiKt4EMTopoJets").isSuccess()) std::cout << "Could not get the jets" << std::endl;
-
// Store only the nominal calibration
if(isNominal) {
+ //Take advantage of TStore memory management (if isNominal = true)
+ if(!m_susy_tools->GetJets(jets,jets_aux,isNominal,"AntiKt4EMTopoJets").isSuccess()) std::cout << "Could not get the jets" << std::endl;
m_jets_copy = jets;
m_jets_copy_aux = jets_aux;
}
+ else {
+ if(!m_susy_tools->GetJetsSyst(*m_jets_copy,jets,jets_aux,isNominal,"AntiKt4EMTopoJets").isSuccess()) std::cout << "Could not get the jets" << std::endl;
+ }
}
//_________________________________________________________________________
@@ -133,6 +134,8 @@
jet->setAttribute("btag_MV2c20", btag_weight);
+ m_susy_tools->IsBJet( *jet);
+
if(isNominal) {
selected_jets->push_back(jet);
Index: Root/HistFitterInputMaker.cxx
===================================================================
--- Root/HistFitterInputMaker.cxx (revision 239645)
+++ Root/HistFitterInputMaker.cxx (revision 239687)
@@ -43,6 +43,12 @@
it.second->Branch("met",&m_met,"met/F");
it.second->Branch("meff",&m_meff,"meff/F");
+
+ it.second->Branch("weight_mc",&m_weight_mc,"weight_mc/D");
+ it.second->Branch("weight_pu",&m_weight_pu,"weight_pu/D");
+ it.second->Branch("weight_btag",&m_weight_btag,"weight_btag/D");
+ it.second->Branch("weight_elec",&m_weight_elec,"weight_elec/D");
+ it.second->Branch("weight_muon",&m_weight_muon,"weight_muon/D");
}
}
@@ -87,7 +93,13 @@
m_met = met->met() / MEV;
m_meff = Variables::Meff_incl(met, v_jets, v_muons, v_electrons);
-
+
+ m_weight_mc = weight[0];
+ m_weight_pu = weight[1];
+ m_weight_btag = weight[2];
+ m_weight_elec = weight[3];
+ m_weight_muon = weight[4];
+
m_tree_map[sys_name]->Fill();
}
@@ -95,8 +107,7 @@
//
void HistFitterInputMaker::Write()
{
- for(auto &it : m_tree_map) {
-
+ for(auto &it : m_tree_map) {
it.second->Write();
}
}
@@ -111,4 +122,10 @@
m_met = 0;
m_meff = 0;
+
+ m_weight_mc = -1.;
+ m_weight_pu = -1.;
+ m_weight_btag = -1.;
+ m_weight_elec = -1.;
+ m_weight_muon = -1.;
}
Index: Root/MainAnalysis.cxx
===================================================================
--- Root/MainAnalysis.cxx (revision 239645)
+++ Root/MainAnalysis.cxx (revision 239687)
@@ -38,6 +38,9 @@
#include "MultibjetsAnalysis/ClassifyHF.h"
#include "MultibjetsAnalysis/DataMembersHF.h"
+//top pT reweighting tool
+#include "MultibjetsAnalysis/TopTtbarPtReweighting.h"
+
// output tree
#include "MultibjetsAnalysis/TreeMaker.h"
#include "MultibjetsAnalysis/HistFitterInputMaker.h"
@@ -58,10 +61,10 @@
#include "MultibjetsAnalysis/HelperFunctions.h"
-
#include "SubstructureTopTagger/SubstructureTopTaggerHelpers.h"
#include "SubstructureTopTagger/SubstructureTopTagger.h"
+
const double GEV = 1000;
// this is needed to distribute the algorithm to the workers
@@ -191,7 +194,7 @@
//check if file is from a DxAOD
m_isDerived = !MetaData->GetBranch("StreamAOD");
- if(m_isDerived ){
+ if( m_isDerived && m_dataSource!=0 /*don't do it on data*/){
// check for corruption
const xAOD::CutBookkeeperContainer* incompleteCBC = nullptr;
@@ -211,7 +214,7 @@
return EL::StatusCode::FAILURE;
}
- // Find the smallest cycle number, the original first processing step/cycle
+ // Find the smallest cycle number, the original first processing step/cycle
int minCycle = 10000;
for ( auto cbk : *completeCBC ) {
if ( ! cbk->name().empty() && minCycle > cbk->cycle() ){ minCycle = cbk->cycle(); }
@@ -300,6 +303,8 @@
CHECK( m_susy_tools->setProperty("DoJetGSCCalib",m_doJetGSC) );
CHECK( m_susy_tools->setProperty("EleId",m_EleIdSignal) );
CHECK( m_susy_tools->setProperty("EleIdBaseline",m_EleIdBaseline) );
+ CHECK( m_susy_tools->setProperty("BtagCut",m_BtagCut) );
+ CHECK( m_susy_tools->setProperty("BtagCut_OR",m_BtagCut_OR) );
// This should probably be re-enabled at some point
CHECK( m_susy_tools->setProperty("JESNuisanceParameterSet",m_JESNuisanceParameterSet) );
@@ -403,7 +408,7 @@
// output files
TFile *file_tree = wk()->getOutputFile ("output_tree");
- m_tree_maker = new TreeMaker(file_tree, m_doTruth, m_doRcJets, m_doAK10Jets, m_doTRF);
+ m_tree_maker = new TreeMaker(file_tree, m_doTruth, m_doRcJets, m_doAK10Jets, m_doTRF, m_doTopPtCorrection, m_doNTUPSyst, m_syst_info_list);
TFile *file_histfitter = wk()->getOutputFile ("output_histfitter");
m_histfitter_input_maker = new HistFitterInputMaker(file_histfitter, m_syst_info_list);
@@ -471,6 +476,9 @@
}else{
Info(APP_NAME,"TriggerMenuMetaDataTool initialized... " );
}
+ if(m_doTopPtCorrection>0){
+ m_topttbarPtrw = new TopTtbarPtReweighting(m_maindir+"MultibjetsAnalysis/Reweighting_forRun2.root", m_doTopPtCorrection==2);
+ }
if(m_debug) {
CHECK( m_trigger_metadata_tool->setProperty( "OutputLevel", MSG::VERBOSE ) );
@@ -649,10 +657,14 @@
// TruthJetVector truthjets;
const xAOD::JetContainer* truthjets;
TLorentzVector v_met_truth;
+ TopTtbarPtReweighting::TopTtbarPtReweightingResult topptrw;
if(isMC && m_doTruth){
if(m_debug) std::cout << "Doing truth particles now" << std::endl;
+ //
+ // Ttbar + HF classification
+ //
truthparticle_helper.RetrieveTruthParticles();
truthjet_helper.RetrieveTruthJets();
@@ -670,6 +682,15 @@
ClassifyHF classHF;
classHF.classify(&dm_HF,&ttbarHF,&ttbarHF_ext, false, false, &ttbarHF_prompt);
+ //
+ // Top pT correction
+ //
+ if(m_doTopPtCorrection>0){
+ m_topttbarPtrw -> FindTops( v_truthparticles );
+ topptrw = m_topttbarPtrw -> GetEventWeight();
+ m_topttbarPtrw -> Clear();
+ }
+
// get truth MET
const xAOD::MissingETContainer* met_truth(0);
if(!event->retrieve(met_truth,"MET_Truth").isSuccess()) return EL::StatusCode::FAILURE;
@@ -836,34 +857,77 @@
} // end is nominal
}
-
// Fill HistFitter input tree for all events
if(is_nominal || sys_info.affectsKinematics) {
- std::string name_syst = sys.name();
- m_histfitter_input_maker->Fill((name_syst.empty())?"nominal":name_syst,
- muons,
- electrons,
- jets,
- mettst,
- m_weight);
- if(m_debug) std::cout << "after histfitter input tree " << std::endl;
-
-
+
if(m_debug) std::cout << "test for baseline selection" << std::endl;
// keep event if satisfies the selection cuts for at least one systematic variation
if(BaselineSelection::keep(mettst, jets, muons, electrons) || !isMC) {
if(m_debug) std::cout << " passed baseline " << std::endl;
pass_selection = true;
- //break;
+
+ if(m_debug) std::cout << "do histfitter input tree " << std::endl;
+ std::string name_syst = sys.name();
+ m_histfitter_input_maker->Fill((name_syst.empty())?"nominal":name_syst,
+ muons,
+ electrons,
+ jets,
+ mettst,
+ m_weight);
+ if(m_debug) std::cout << "after histfitter input tree " << std::endl;
+
+ if(m_doNTUP && ( is_nominal || m_doNTUPSyst ) ) {
+ if(m_debug) std::cout << "recording ntuples" << std::endl;
+ if(m_debug) std::cout << "start grabbing tree info" << std::endl;
+
+ float average_interactions_per_crossing = eventInfo->averageInteractionsPerCrossing();
+ float actual_interactions_per_crossing = eventInfo->actualInteractionsPerCrossing();
+ const xAOD::Vertex* pv = m_susy_tools->GetPrimVtx();
+ float primary_vertex_z = pv ? pv->z() : 0;
+
+ if(m_debug) std::cout << " before tree fill standard " << std::endl;
+
+ m_tree_maker->Fill_obj(m_event_number,
+ m_run_number,
+ average_interactions_per_crossing,
+ actual_interactions_per_crossing,
+ primary_vertex_z,
+ m_process,
+ ttbarHF,
+ ttbarHF_ext,
+ ttbarHF_prompt,
+ topptrw,
+ muons_nominal,
+ electrons_nominal,
+ jets_nominal,
+ metcst_nominal,
+ mettst_nominal,
+ v_trigger,
+ m_weight,
+ m_doTRF);
+ if(m_debug) std::cout << "after tree fill standard " << std::endl;
+
+ if(isMC && m_doTruth) m_tree_maker->Fill_truth(v_truthparticles, v_met_truth);
+ if(m_debug) std::cout << "after tree fill truth " << std::endl;
+
+ if(m_doRcJets) m_tree_maker->Fill_rc_jets(v_rc_jets);
+ if(m_debug) std::cout << " after tree fill rc" << std::endl;
+
+ if(m_doAK10Jets) m_tree_maker->Fill_ak10_jets(ak10_jets);
+ if(m_debug) std::cout << "after tree fill ak10" << std::endl;
+
+ m_tree_maker->Fill((name_syst.empty())?"nominal":name_syst);
+ if(m_debug) std::cout << "after full tree " << std::endl;
+ }
}
}
-
+
if(sys_info.affectsKinematics) {
delete metcst;
delete metcst_aux;
delete mettst;
delete mettst_aux;
-
+
if(syst_affects_electrons) {
delete electrons;
delete electrons_aux;
@@ -877,95 +941,53 @@
delete jets_aux;
}
}
-
+
} // end loop over systematics
if(m_debug) std::cout << "End loop over systematics" << std::endl;
-
+
// Fill outputs for events which pass the selection
if(pass_selection) {
m_cut_flow[5]++;
- if(m_doNTUP) {
- if(m_debug) std::cout << "recording ntuples" << std::endl;
- if(m_debug) std::cout << "start grabbing tree info" << std::endl;
-
- float average_interactions_per_crossing = eventInfo->averageInteractionsPerCrossing();
- float actual_interactions_per_crossing = eventInfo->actualInteractionsPerCrossing();
- const xAOD::Vertex* pv = m_susy_tools->GetPrimVtx();
- float primary_vertex_z = pv ? pv->z() : 0;
-
- if(m_debug) std::cout << " before tree fill standard " << std::endl;
-
- m_tree_maker->Fill_obj(m_event_number,
- m_run_number,
- average_interactions_per_crossing,
- actual_interactions_per_crossing,
- primary_vertex_z,
- m_process,
- ttbarHF,
- ttbarHF_ext,
- ttbarHF_prompt,
- muons_nominal,
- electrons_nominal,
- jets_nominal,
- metcst_nominal,
- mettst_nominal,
- v_trigger,
- m_weight,
- m_doTRF);
- if(m_debug) std::cout << "after tree fill standard " << std::endl;
-
- if(isMC && m_doTruth) m_tree_maker->Fill_truth(v_truthparticles, v_met_truth);
- if(m_debug) std::cout << "after tree fill truth " << std::endl;
-
- if(m_doRcJets) m_tree_maker->Fill_rc_jets(v_rc_jets);
- if(m_debug) std::cout << " after tree fill rc" << std::endl;
-
- if(m_doAK10Jets) m_tree_maker->Fill_ak10_jets(ak10_jets);
- if(m_debug) std::cout << "after tree fill ak10" << std::endl;
-
- m_tree_maker->Fill();
- if(m_debug) std::cout << "after full tree " << std::endl;
+
+ // make xAOD
+ if(m_doxAOD) {
+ if(m_debug) std::cout << "recording xAOD" << std::endl;
+ muon_helper.MakeDeepCopy();
+ if(m_debug) std::cout << "did muons" << std::endl;
+ electron_helper.MakeDeepCopy();
+ if(m_debug) std::cout << "did electrons" << std::endl;
+ jet_helper.MakeDeepCopy(m_doAK10Jets);
+ if(m_debug) std::cout << "did jets" << std::endl;
+
+ if(isMC){
+ if(m_doTruth){
+ eventInfo->auxdecor < int > ("ttbar_class") = ttbarHF;
+ eventInfo->auxdecor < int > ("ttbar_class_ext") = ttbarHF_ext;
+ truthparticle_helper.MakeDeepCopy();
+ }
}
-
- // make xAOD
- if(m_doxAOD) {
- if(m_debug) std::cout << "recording xAOD" << std::endl;
- muon_helper.MakeDeepCopy();
- if(m_debug) std::cout << "did muons" << std::endl;
- electron_helper.MakeDeepCopy();
- if(m_debug) std::cout << "did electrons" << std::endl;
- jet_helper.MakeDeepCopy(m_doAK10Jets);
- if(m_debug) std::cout << "did jets" << std::endl;
-
- if(isMC){
- if(m_doTruth){
- eventInfo->auxdecor < int > ("ttbar_class") = ttbarHF;
- eventInfo->auxdecor < int > ("ttbar_class_ext") = ttbarHF_ext;
- truthparticle_helper.MakeDeepCopy();
- }
- }
-
- static SG::AuxElement::Decorator<float> weight_mc("weight_mc");
- static SG::AuxElement::Decorator<float> weight_pu("weight_pu");
- static SG::AuxElement::Decorator<float> weight_btag("weight_btag");
-
- weight_mc(*eventInfo) = m_weight[0];
- weight_pu(*eventInfo) = m_weight[1];
- weight_btag(*eventInfo) = m_weight[2];
-
- event->copy("EventInfo");
- // we want trigger decisions in the output
- // make sure metadata is also copied using xAODTrigCnv by initializing tool
- event->copy("xTrigDecision");
- event->copy("TrigConfKeys");
-
- event->fill();
- if(m_debug) std::cout << "done with xAOD" << std::endl;
- }
+
+ static SG::AuxElement::Decorator<float> weight_mc("weight_mc");
+ static SG::AuxElement::Decorator<float> weight_pu("weight_pu");
+ static SG::AuxElement::Decorator<float> weight_btag("weight_btag");
+
+ weight_mc(*eventInfo) = m_weight[0];
+ weight_pu(*eventInfo) = m_weight[1];
+ weight_btag(*eventInfo) = m_weight[2];
+
+ event->copy("EventInfo");
+ // we want trigger decisions in the output
+ // make sure metadata is also copied using xAODTrigCnv by initializing tool
+ event->copy("xTrigDecision");
+ event->copy("TrigConfKeys");
+
+ event->fill();
+ if(m_debug) std::cout << "done with xAOD" << std::endl;
+ }
}
-
+
if(m_debug) std::cout << "end of event!" << std::endl;
-
+
return EL::StatusCode::SUCCESS;
}
@@ -1011,6 +1033,9 @@
delete m_susy_tools;
m_susy_tools = 0;
}
+
+ //Delete top-pt reweighting tool
+ if(m_topttbarPtrw && m_doTopPtCorrection>0) delete m_topttbarPtrw;
// If no metadat, put the initial number of events to the number of events in the file
if(m_nb_events==0){
Index: Root/TopTtbarPtReweighting.cxx
===================================================================
--- Root/TopTtbarPtReweighting.cxx (revision 0)
+++ Root/TopTtbarPtReweighting.cxx (revision 239687)
@@ -0,0 +1,162 @@
+#include "xAODTruth/TruthParticleContainer.h"
+#include "xAODTruth/TruthParticle.h"
+
+#include "TFile.h"
+#include "TH1F.h"
+
+#include "MultibjetsAnalysis/TopTtbarPtReweighting.h"
+
+
+//___________________________________________________
+//
+TopTtbarPtReweighting::TopTtbarPtReweighting( const std::string &fileName, const bool useSysts ):
+m_top(0),
+m_antitop(0),
+m_useSyst(useSysts),
+m_histos(0),
+m_systs(0)
+{
+ TFile *corrFile = new TFile(fileName.c_str(), "read");
+ if(!corrFile){
+ std::cerr << "<!> ERROR in TopTtbarPtReweighting constructor: no rootfile found !!" << std::endl;
+ } else {
+ //Decaring the map of histograms
+ m_histos = new std::map < std::string, TH1F* >;
+ m_systs = new std::vector < std::string >;
+
+ //Getting the nominal histogram
+ TH1F* h_nom = (TH1F*)corrFile -> Get("topPtCorr_NOMINAL");
+ h_nom -> SetDirectory(0);
+ m_histos -> insert ( std::pair < std::string, TH1F* > ("NOMINAL", h_nom));
+
+ //Getting the weight systematics if needed
+ if(m_useSyst){
+ m_systs -> push_back("ISRFSR_UP");
+ m_systs -> push_back("ISRFSR_DOWN");
+ m_systs -> push_back("Fragmentation_UP");
+ m_systs -> push_back("Fragmentation_DOWN");
+ m_systs -> push_back("MCGenerator_UP");
+ m_systs -> push_back("MCGenerator_DOWN");
+ m_systs -> push_back("JER_UP");
+ m_systs -> push_back("JER_DOWN");
+ m_systs -> push_back("bJES_UP");
+ m_systs -> push_back("bJES_DOWN");
+ m_systs -> push_back("closebyJES_UP");
+ m_systs -> push_back("closebyJES_DOWN");
+ m_systs -> push_back("etacalibJES_UP");
+ m_systs -> push_back("etacalibJES_DOWN");
+ m_systs -> push_back("effdetset1JES_UP");
+ m_systs -> push_back("effdetset1JES_DOWN");
+ m_systs -> push_back("btageff_UP");
+ m_systs -> push_back("btageff_DOWN");
+ for ( const std::string syst : *m_systs ){
+ std::string nameHist = "topPtCorr_"+syst;
+ TH1F* h_syst = (TH1F*)corrFile -> Get(nameHist.c_str());
+ h_syst -> SetDirectory(0);
+ if(h_syst){
+ m_histos -> insert ( std::pair < std::string, TH1F* > (syst, h_syst));
+ } else {
+ std::cerr << "<!> ERROR: the histogram \"" << nameHist << "\" is not found in the file " << fileName << std::endl;
+ }
+ }
+ }
+ corrFile -> Close();
+ }
+ delete corrFile;
+}
+
+//___________________________________________________
+//
+TopTtbarPtReweighting::TopTtbarPtReweighting( const TopTtbarPtReweighting &q )
+{
+ m_top = q.m_top;
+ m_antitop = q.m_antitop;
+ m_useSyst = q.m_useSyst;
+ m_histos = q.m_histos;
+ m_systs = q.m_systs;
+}
+
+//___________________________________________________
+//
+TopTtbarPtReweighting::~TopTtbarPtReweighting()
+{
+ m_systs -> clear();
+ delete m_systs;
+ for ( std::pair < std::string, TH1F* > hist : *m_histos ){
+ delete hist.second;
+ }
+ m_histos -> clear();
+ delete m_histos;
+}
+
+//___________________________________________________
+//
+bool TopTtbarPtReweighting::Clear()
+{
+ m_top = 0;
+ m_antitop = 0;
+ return true;
+}
+
+//___________________________________________________
+//
+bool TopTtbarPtReweighting::FindTops( const xAOD::TruthParticleContainer *vec )
+{
+ for ( const xAOD::TruthParticle* part : *vec ){
+ if(part->pdgId()==6 && !m_top){
+ m_top = part;
+ } else if (part->pdgId()==-6 && !m_antitop){
+ m_antitop = part;
+ }
+ if(m_top && m_antitop) break;//no need to go through the whole MC truth
+ }
+ return true;
+}
+
+//___________________________________________________
+//
+TopTtbarPtReweighting::TopTtbarPtReweightingResult TopTtbarPtReweighting::GetEventWeight() const
+{
+ // This function is here in case we need to apply additional
+ // correction, in order to reduce the impact on the user's
+ // code. For now, it only consists in a top pT-based correction.
+ // It calls the needed *private* functions
+ TopTtbarPtReweighting::TopTtbarPtReweightingResult result;
+ result.nominal = GetTopPtEventWeight( m_top -> pt() / 1000, "NOMINAL");
+ if(m_useSyst){
+ for ( const std::string syst : *m_systs ){
+ result.systematics.insert( std::pair < std::string, double > ( syst, GetTopPtEventWeight( m_top -> pt() / 1000, syst ) ) );
+ }
+ }
+ return result;
+
+}
+
+//___________________________________________________
+//
+double TopTtbarPtReweighting::GetTopPtEventWeight( const double pt, const std::string &name ) const
+{
+ //
+ // INTERNAL FUNCTION
+ // Uses the input histograms to derive the appropriate correction
+ //
+
+ std::map < std::string, TH1F* >::const_iterator it_hist = m_histos -> find(name);
+ if(it_hist == m_histos -> end()){
+ std::cerr << "<!> EROOR in TopTtbarPtReweighting::GetTopPtEventWeight(): cannot find correction for type " << name << std::endl;
+ return 1.;
+ }
+
+ if(!it_hist -> second){
+ std::cerr << "<!> ERROR in TopTtbarPtReweighting::GetTopPtEventWeight(): histogram doesn't exist : " << name << std::endl;
+ return 1.;
+ }
+
+ double ptToUse = pt;
+ double maxpT = it_hist -> second -> GetBinLowEdge ( it_hist -> second -> GetNbinsX() );
+ if ( pt > maxpT ) {
+ ptToUse = maxpT;
+ }
+ double rw = it_hist -> second -> GetBinContent( it_hist -> second -> FindBin(ptToUse) );
+ return rw;
+}
Index: MultibjetsAnalysis/TopTtbarPtReweighting.h
===================================================================
--- MultibjetsAnalysis/TopTtbarPtReweighting.h (revision 0)
+++ MultibjetsAnalysis/TopTtbarPtReweighting.h (revision 239687)
@@ -0,0 +1,41 @@
+#ifndef TOPTTBARPTREWEIGHTING_H
+#define TOPTTBARPTREWEIGHTING_H
+
+#include <string>
+#include <map>
+class TH1F;
+
+class TopTtbarPtReweighting {
+
+public:
+
+ struct TopTtbarPtReweightingResult {
+ double nominal;
+ std::map < std::string, double > systematics;
+ };
+
+ //
+ // Standard c++
+ //
+ TopTtbarPtReweighting( const std::string &fileName, const bool useSysts = false );
+ TopTtbarPtReweighting( const TopTtbarPtReweighting & );
+ ~TopTtbarPtReweighting();
+
+
+ //
+ // Specific functions
+ //
+ bool Clear();
+ bool FindTops( const xAOD::TruthParticleContainer * );
+ TopTtbarPtReweightingResult GetEventWeight() const ;
+
+private:
+ double GetTopPtEventWeight( const double, const std::string & ) const;
+ const xAOD::TruthParticle *m_top;
+ const xAOD::TruthParticle *m_antitop;
+ bool m_useSyst;
+ std::map < std::string, TH1F* > *m_histos;
+ std::vector < std::string > *m_systs;
+};
+
+#endif //TOPTTBARPTREWEIGHTING_H
Index: MultibjetsAnalysis/TreeMaker.h
===================================================================
--- MultibjetsAnalysis/TreeMaker.h (revision 239645)
+++ MultibjetsAnalysis/TreeMaker.h (revision 239687)
@@ -6,13 +6,20 @@
#include <TTree.h>
#include <TFile.h>
+#include "PATInterfaces/SystematicSet.h"
+#include "SUSYTools/ISUSYObjDef_xAODTool.h"
+
+
#include "MultibjetsAnalysis/MuonHelper.h"
#include "MultibjetsAnalysis/ElectronHelper.h"
#include "MultibjetsAnalysis/JetHelper.h"
#include "MultibjetsAnalysis/TruthParticleHelper.h"
#include <xAODMissingET/MissingET.h>
-// chiara
+//Top/ttbar pT reweighting
+#include "MultibjetsAnalysis/TopTtbarPtReweighting.h"
+
+//TRF
class TRFinterface;
class TreeMaker
@@ -20,7 +27,7 @@
public:
- TreeMaker(TFile *file, bool do_truth=false, bool do_rc_jets=false, bool do_ak10_jets=false, bool do_TRF=false);
+ TreeMaker(TFile *file, bool do_truth, bool do_rc_jets, bool do_ak10_jets, bool do_TRF, int topPtCorrection, bool do_syst, std::vector<ST::SystInfo> sys_list);
virtual ~TreeMaker();
void Fill_obj(int event_number,
@@ -32,6 +39,7 @@
int ttbar_class,
int ttbar_class_ext,
int ttbar_class_prompt,
+ TopTtbarPtReweighting::TopTtbarPtReweightingResult topptrw,
const xAOD::MuonContainer* v_muons,
const xAOD::ElectronContainer* v_electrons,
const xAOD::JetContainer* v_jets,
@@ -46,15 +54,15 @@
void Fill_rc_jets(FatJetVector v_rc_jets);
void Fill_ak10_jets(const xAOD::JetContainer* v_ak10_jets);
- void Fill();
+ void Fill(std::string sys_name);
void Write();
protected:
void Reset();
-
- TTree *m_tree; //!
+ std::map<std::string, TTree*> m_tree_map; //!
+
// chiara
#ifndef __CINT__
TRFinterface *m_trfint;
@@ -160,6 +168,8 @@
Double_t m_weight_btag; //!
Double_t m_weight_elec; //!
Double_t m_weight_muon; //!
+ Double_t m_weight_topPt; //!
+ std::map < std::string, double > m_weight_topPt_systs;//!
// truth
Int_t m_mc_n; //!
Index: MultibjetsAnalysis/HistFitterInputMaker.h
===================================================================
--- MultibjetsAnalysis/HistFitterInputMaker.h (revision 239645)
+++ MultibjetsAnalysis/HistFitterInputMaker.h (revision 239687)
@@ -44,6 +44,12 @@
Float_t m_met; //!
Float_t m_meff; //!
+
+ Double_t m_weight_mc; //!
+ Double_t m_weight_pu; //!
+ Double_t m_weight_btag; //!
+ Double_t m_weight_elec; //!
+ Double_t m_weight_muon; //!
};
#endif //MultibjetsAnalysis_TreeMaker_h
Index: MultibjetsAnalysis/MainAnalysis.h
===================================================================
--- MultibjetsAnalysis/MainAnalysis.h (revision 239645)
+++ MultibjetsAnalysis/MainAnalysis.h (revision 239687)
@@ -51,6 +51,7 @@
class TruthJetHelper;
class TreeMaker;
class HistFitterInputMaker;
+class TopTtbarPtReweighting;
class SubstructureTopTagger;
@@ -105,6 +106,7 @@
OverlapRemovalTool *m_or_tool; //!
FileMetaDataTool *m_metadata_tool; //!
TriggerMenuMetaDataTool *m_trigger_metadata_tool; //!
+ TopTtbarPtReweighting *m_topttbarPtrw; //!
#endif // not __CINT__
double m_weight[6]; //!
@@ -125,6 +127,7 @@
int m_doTruth;
int m_doTRF;
int m_doNTUP;
+ int m_doNTUPSyst;
int m_doxAOD;
bool m_doJetArea;
bool m_doJetGSC;
@@ -132,9 +135,12 @@
int m_doAK10Jets;
string m_EleIdSignal;
string m_EleIdBaseline;
+ float m_BtagCut;
+ float m_BtagCut_OR;
bool m_isDerived;
int m_JESNuisanceParameterSet;
int m_debug;
+ int m_doTopPtCorrection;
public:
Index: ChangeLog
===================================================================
--- ChangeLog (revision 239645)
+++ ChangeLog (revision 239687)
@@ -1,3 +1,16 @@
+2015-07-22 Antoine Marzin <[email protected]>
+ * Move to SUSYTools-00-06-16
+ * Add patch to add loose OR in SUSYTools
+ * Add possibily to add all shape systematics in the output ntuple (weights for systematics still missing)
+
+2015-07-21 Loic Valery <[email protected]>
+ * Implement top-pT reweighting (nominal+systematics)
+ * Update for GRL (includes period C5)
+ * Avoid CutBookKeeper checks when running on data (based on --dataSource value)
+
+2015-07-18 Antoine Marzin <[email protected]>
+ * Fix jets systematics
+
2015-07-17 Giordon Stark <[email protected]>
* This fixes the `No current directory` errors
* This fixes a lot of missing status code checks
Index: scripts/2015-PreRecomm-13TeV-MC12-CDI_July15-v1.root
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: scripts/2015-PreRecomm-13TeV-MC12-CDI_July15-v1.root
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Index: scripts/Run.py
===================================================================
--- scripts/Run.py (revision 239645)
+++ scripts/Run.py (revision 239687)
@@ -24,14 +24,20 @@
parser.add_option("--doJetArea", help="DoJetArea flag [0/1]", type="int", default=1)
parser.add_option("--doJetGSC", help="DoJetGCS flag [0/1]", type="int", default=1)
parser.add_option("--JESNuisanceParameterSet", help=" 0->14 NP, 1..4->3 NP set 1", type="int", default=1)
+#top correction configuration
+parser.add_option("--doTopPtCorrection", help="Applies top-pT correction [0:no, 1:nom, 2:nom+syst]", type="int", default=1)
+#b-tagging configuration
+parser.add_option("--BtagCut", help="b-tagging cut", type="float", default=-0.7887)
+parser.add_option("--BtagCut_OR", help="b-tagging cut for the OR", type="float", default=-0.7887)
# output configuration
-parser.add_option("--doPileup", help="pileup flag [0/1]", type="int", default=0)
-parser.add_option("--doSyst", help="Do systemtic variations [0/1]", type="int", default=0)
+parser.add_option("--doPileup", help="pileup flag [0/1]", type="int", default=1)
+parser.add_option("--doSyst", help="Do systemtic variations [0/1]", type="int", default=1)
parser.add_option("--doTruth", help="Truth flag [0/1]", type="int", default=0)
parser.add_option("--doNTUP", help="Make flat ntuple output [0/1]", type="int", default=1)
+parser.add_option("--doNTUPSyst", help="Add systematics in the flat ntuple output [0/1]", type="int", default=1)
parser.add_option("--doxAOD", help="Make xAOD output [0/1]", type="int", default=1)
parser.add_option("--doRcJets", help="DoRcJets flag [0/1]", type="int", default=0)
-parser.add_option("--doAK10Jets", help="DoAK10Jets flag [0/1]", type="int", default=0)
+parser.add_option("--doAK10Jets", help="DoAK10Jets flag [0/1]", type="int", default=1)
parser.add_option("--debug", help="Debug mode: print extra stuff [0/1]", type="int", default=0)
parser.add_option("--doTRF", help="TRF flag [0/1]", type="int", default=0)
@@ -62,14 +68,14 @@
else :
search_directories = []
#search_directories = ["/afs/cern.ch/user/c/crizzi/IFAE/storage/SUSY10/"]
- search_directories = ["/share/t3data3/kratsg/xAODs/test/"]
+ #search_directories = ["/share/t3data3/kratsg/xAODs/test/"]
# search_directories = ["/afs/cern.ch/work/l/lvalery/public/mc15_dSUSY1/test/"]
#search_directories = ("/afs/cern.ch/atlas/project/PAT/xAODs/r5787/",)
#search_directories = ["/u/at/swiatlow/nfs/test/rel20/ttbarSUSY1/"]
# search_directories = ["/u/at/swiatlow/nfs/test/susy10/"]
- # search_directories = ["/afs/cern.ch/work/a/amarzin/susy_13TeV/samples/ttbar/"]
+ search_directories = ["/afs/cern.ch/work/a/amarzin/susy_13TeV/samples/ttbar/"]
#search_directories = ["/afs/cern.ch/work/a/amarzin/susy_13TeV/samples/mini_xAOD/"]
-
+ #search_directories = ["/afs/cern.ch/work/l/lvalery/public/mc15_dSUSY1/test/"]
# scan for datasets in the given directories
for directory in search_directories:
ROOT.SH.scanDir(sh_all, directory)
@@ -103,6 +109,7 @@
alg.m_doSyst = options.doSyst
alg.m_doTruth = options.doTruth
alg.m_doNTUP = options.doNTUP
+alg.m_doNTUPSyst = options.doNTUPSyst
alg.m_doxAOD = options.doxAOD
alg.m_doJetArea = options.doJetArea;
alg.m_doJetGSC = options.doJetGSC;
@@ -110,10 +117,13 @@
alg.m_doAK10Jets = options.doAK10Jets;
alg.m_EleIdSignal = options.EleIdSignal;
alg.m_EleIdBaseline = options.EleIdBaseline;
+alg.m_BtagCut = options.BtagCut;
+alg.m_BtagCut_OR = options.BtagCut_OR;
alg.m_JESNuisanceParameterSet = options.JESNuisanceParameterSet;
alg.m_dataSource = options.dataSource;
alg.m_debug = options.debug;
alg.m_doTRF = options.doTRF
+alg.m_doTopPtCorrection = options.doTopPtCorrection
logging.info("adding algorithms")
job.algsAdd(alg)
Index: scripts/submit_ttbar_SUSY10.py
===================================================================
--- scripts/submit_ttbar_SUSY10.py (revision 239645)
+++ scripts/submit_ttbar_SUSY10.py (revision 239687)
@@ -12,7 +12,7 @@
for inds in datasets:
inds += ""
run = "ttbar"#inds[inds.find("13TeV.")+6:inds.find(".Herwigpp")]
- cmd = 'python Run.py --doRcJets 0 --doTruth 1 --doAK10Jets 1 --dataSource 1 --submitDir %s --inputDS %s --driver grid' % (run,inds)
+ cmd = 'python Run.py --doRcJets 0 --doTruth 1 --doAK10Jets 1 --dataSource 1 --doTopPtCorrection 1 --submitDir %s --inputDS %s --driver grid' % (run,inds)
print cmd
os.system(cmd)
clean = 'rm -r %s' % (run)
Index: data/GRL/data15_13TeV.periodAllYear_DetStatus-v63-pro18-01_DQDefects-00-01-02_PHYS_StandardGRL_All_Good.xml
===================================================================
--- data/GRL/data15_13TeV.periodAllYear_DetStatus-v63-pro18-01_DQDefects-00-01-02_PHYS_StandardGRL_All_Good.xml (revision 239645)
+++ data/GRL/data15_13TeV.periodAllYear_DetStatus-v63-pro18-01_DQDefects-00-01-02_PHYS_StandardGRL_All_Good.xml (revision 239687)
@@ -9,7 +9,7 @@
<Metadata Name="ARQEquivalentQuery">find run data15_13TeV.periodAllYear and dq PHYS_StandardGRL_All_Good DEFECTS#DetStatus-v63-pro18-01 g</Metadata>
<Metadata Name="Query">Period: data15_13TeV.AllYear; Defect: PHYS_StandardGRL_All_Good; Defect tag: DetStatus-v63-pro18-01; Ignoring None</Metadata>
<Metadata Name="RQTSVNVersion">DQDefects-00-01-02</Metadata>
-<Metadata Name="RunList">267073,267167,267358,267359,267360,267367,267385,267599,267638,267639,270806,270953,271048,271298,271421</Metadata>
+<Metadata Name="RunList">267073,267167,267358,267359,267360,267367,267385,267599,267638,267639,270806,270953,271048,271298,271421,271516,271595,271744</Metadata>
<LumiBlockCollection>
<Run>267073</Run>
<LBRange Start="368" End="410"/>
@@ -108,20 +108,28 @@
</LumiBlockCollection>
<LumiBlockCollection>
<Run>271421</Run>
-<LBRange Start="64" End="137"/>
-<LBRange Start="139" End="139"/>
-<LBRange Start="141" End="154"/>
-<LBRange Start="168" End="168"/>
-<LBRange Start="175" End="175"/>
-<LBRange Start="177" End="179"/>
-<LBRange Start="189" End="227"/>
+<LBRange Start="64" End="183"/>
+<LBRange Start="189" End="240"/>
<LBRange Start="242" End="248"/>
-<LBRange Start="262" End="277"/>
-<LBRange Start="311" End="311"/>
-<LBRange Start="322" End="323"/>
+<LBRange Start="262" End="334"/>
<LBRange Start="338" End="340"/>
<LBRange Start="342" End="401"/>
<LBRange Start="403" End="409"/>
</LumiBlockCollection>
+<LumiBlockCollection>
+<Run>271516</Run>
+<LBRange Start="181" End="372"/>
+<LBRange Start="374" End="444"/>
+<LBRange Start="446" End="497"/>
+</LumiBlockCollection>
+<LumiBlockCollection>
+<Run>271595</Run>
+<LBRange Start="331" End="428"/>
+<LBRange Start="454" End="582"/>
+</LumiBlockCollection>
+<LumiBlockCollection>
+<Run>271744</Run>
+<LBRange Start="78" End="219"/>
+</LumiBlockCollection>
</NamedLumiRange>
</LumiRangeCollection>
Index: data/2015-PreRecomm-13TeV-MC12-CDI_July15-v1.root
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: data/2015-PreRecomm-13TeV-MC12-CDI_July15-v1.root
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Index: data/Reweighting_forRun2.root
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: data/Reweighting_forRun2.root
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Index: packages.txt
===================================================================
--- packages.txt (revision 239645)
+++ packages.txt (revision 239687)
@@ -1,5 +1,5 @@
# SUSYTools
-#atlasoff/PhysicsAnalysis/SUSYPhys/SUSYTools/tags/SUSYTools-00-06-15
+atlasoff/PhysicsAnalysis/SUSYPhys/SUSYTools/tags/SUSYTools-00-06-16
#atlasoff/PhysicsAnalysis/AnalysisCommon/AssociationUtils/tags/AssociationUtils-01-00-18
atlasoff/Event/xAOD/xAODMetaDataCnv/tags/xAODMetaDataCnv-00-00-01
atlasoff/Event/xAOD/xAODTriggerCnv/tags/xAODTriggerCnv-00-00-16
Index: README
===================================================================
--- README (revision 239645)
+++ README (revision 239687)
@@ -8,20 +8,20 @@
rc checkout MultibjetsAnalysis/packages.txt
not with SUSY release
-#rc checkout_SUSYTools/doc/packages.txt
+#rc checkout SUSYTools/doc/packages.txt
==============
Patches
==============
-#cd AssociationUtils/Root/ && patch -p0 < ../../MultibjetsAnalysis/OverlapRemovalTool.patch
+cd SUSYTools/Root/ && patch -p0 < ../../MultibjetsAnalysis/SUSYTools.patch
cp MultibjetsAnalysis/Makefile.RootCore.xAODMetaDataCnv xAODMetaDataCnv/cmt/Makefile.RootCore
========
compile
========
-rcSetup SUSY,2.3.18b
+rcSetup Base,2.3.20
rc find_packages
rc clean
Property changes on: .
___________________________________________________________________
Modified: svn:mergeinfo
Merged /Physics/SUSY/Analyses/MultiBJets/MultibjetsAnalysis/devbranches/lvalery:r239631-239675
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment