MyHtautauAnalysis/src/MyHtautauAnalysis.cxx

00001 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00002 // 06.12.2006, AUTHOR: MANFRED GROH
00003 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00004 
00005 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00006 //:: IMPLEMENTATION OF METHODS DEFINED IN THE CLASS MyHtautauAnalysis ::
00007 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00008 
00009 //::::::::::::::::::
00010 //:: HEADER FILES ::
00011 //::::::::::::::::::
00012 
00013 #include "MyHtautauAnalysis/MyHtautauAnalysis.h"
00014 
00015 
00016 //:::::::::::::::::::::::::
00017 //:: NAME SPACE SETTINGS ::
00018 //:::::::::::::::::::::::::
00019 
00020 using namespace std;
00021 
00022 //*****************************************************************************
00023 
00024 //:::::::::::::::::
00025 //:: METHOD init ::
00026 //:::::::::::::::::
00027 
00028 void MyHtautauAnalysis::init(void) {
00029 
00030     filename = "testfile";
00031     clear_event_data();
00032     return;
00033 
00034 }
00035 
00036 //*****************************************************************************
00037 
00038 //:::::::::::::::::
00039 //:: METHOD init ::
00040 //:::::::::::::::::
00041 
00042 void MyHtautauAnalysis::clear_event_data(void) {
00043 
00044     ev_has_fake_taus            = false;
00045 
00046     primary_particle_mode       = -1;
00047     primary_particle_decay_mode = -1;
00048     tau_0_decay_mode            = -1;
00049     tau_1_decay_mode            = -1;
00050     higgs_decay_mode            = -1;
00051 
00052     MVAvar_etmiss = 0;
00053     MVAvar_ll_dr = 0;
00054     MVAvar_ll_dphi = 0;
00055     MVAvar_jj_dphi = 0;
00056     MVAvar_jj_deta = 0;
00057     MVAvar_jj_m = 0;
00058     MVAvar_x1 = 0;
00059     MVAvar_x2 = 0;
00060     MVAvar_m_t = 0;
00061     MVAvar_jl_deta_min = 0;
00062     MVAvar_jl_deta_max = 0;
00063     MVAvar_pt_all =0;
00064     MVAvar_ll_pt1 =0;
00065     MVAvar_ll_pt2 =0;
00066     MVAvar_jj_pt1 =0;
00067     MVAvar_jj_pt2 =0;
00068     MVAvar_H_m = 0;
00069     MVAvar_weight = 0;
00070     MVAvar_Event = 0;
00071     MVAvar_Entry = 0;
00072 
00073     v_taujet_truth.clear();
00074 
00075     return;
00076 
00077 }
00078 
00079 //*****************************************************************************
00080 
00081 //:::::::::::::::::::::
00082 //:: METHOD destruct ::
00083 //:::::::::::::::::::::
00084 
00085 void MyHtautauAnalysis::destruct(void) {
00086 
00087     return;
00088 
00089 }
00090 
00091 //*****************************************************************************
00092 
00093 //:::::::::::::::::::::::
00094 //:: METHOD initialize ::
00095 //:::::::::::::::::::::::
00096 
00097 void MyHtautauAnalysis::initialize(void) {
00098     entry_nb = 0;
00099     events_over_metthr = 0;
00100     nb_e25i_triggers=0;
00101     nb_e25i_not_triggers=0;
00102     nb_m20i_triggers=0;
00103     nb_m20i_not_triggers=0;
00104     nb_both_triggers=0;
00105 
00107     // CREATE THE OUTPUT ROOT FILE //
00109 
00110     //m_tfile = new TFile("tmp.root", "RECREATE");
00111     //m_tfile = new TFile( filename.ReplaceAll(".aan",".selection") , "RECREATE");
00112     //m_tfile = new TFile( filename , "NEW");
00113     m_tfile = new TFile( filename , "RECREATE");
00114     if (!m_tfile->IsOpen()){
00115     cerr<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<endl;
00116     cerr<<"!!!!!!!! Root file exists already !!!!!!!!!!!!"<<endl;
00117     cerr<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<endl;
00118     }
00119    
00120     
00121     
00123     // DatasetInfo stuff //
00125     // m_dataset_info = event.dataset_info();
00126     //  copy treees
00127     m_dataset_info = &MyDatasetInfo::Instance();
00128     TTree *new_aodfilenames_tree = m_dataset_info->get_tree("aod_file_collection")->CloneTree();
00129     TTree *new_aodcontainer_tree = m_dataset_info->get_tree("aod_container_keys")->CloneTree();
00130     new_aodfilenames_tree->GetEntries();
00131     new_aodcontainer_tree->GetEntries();
00132     // generator
00133     generator = m_dataset_info->get_generator();
00134     cout<<"Generator: "<<generator<<endl;
00135     cout<<"Atlfastflag: "<<m_dataset_info->get_AtlFastFlag()<<endl;
00136     
00137     
00138     
00139     //------------------------
00140     //-- BOOK THE HISTOGRAM --
00141     //------------------------
00142     #include "HtautauHistos.cxx"
00143 
00144     h_Wplus_Jetcharge = new TH1F("Wplus_Jetcharge","Wplus_Jetcharge",30,-1.45,1.45);
00145     h_Wminus_Jetcharge = new TH1F("Wminus_Jetcharge","Wminus_Jetcharge",30,-1.45,1.45);
00146     h_Wplus_JetpdgIds = new TH1F("Wplus_JetpdgIds","Wplus_JetpdgIds",13,-6.5,6.5);
00147     h_Wminus_JetpdgIds = new TH1F("Wminus_JetpdgIds","Wminus_JetpdgIds",13,-6.5,6.5);
00148 
00149     
00150     
00151     //----------------------
00152     //-- Text File Reader --
00153     //----------------------
00154     MyTextFileReader m_reader(settingsFilename);
00155     
00156     decay_mode_string = m_reader.retrieve_from_file<TString>("decay_mode_string",settingsFilename);
00157     // auto, ll, lh, hh, ee, em, mm, el, eh, ml, mh
00158     cout<<"decay_mode_string: "<<decay_mode_string<<endl;
00159     
00160     //--------------
00161     //-- Settings --
00162     //--------------
00163     m_reader.fill_cutvalue_map("settings",settingsFilename);
00164     // truth stuff
00165     switch_truth_lepton_filter = (bool)m_reader.get_cutvalue("switch_truth_lepton_filter");
00166     truth_lepton_filter_min_nb_leptons = 
00167         (int)m_reader.get_cutvalue("truth_lepton_filter_min_nb_leptons");
00168     switch_analyse_truth_decay = (bool)m_reader.get_cutvalue("switch_analyse_truth_decay");
00169     switch_truth_decay_mode_filter = (bool)m_reader.get_cutvalue("switch_truth_decay_mode_filter");
00170     truth_decay_mode_filter_only_higgs = 
00171         (bool)m_reader.get_cutvalue("truth_decay_mode_filter_only_higgs");
00172     truth_decay_mode_filter_analyse_ll = 
00173         (bool)m_reader.get_cutvalue("truth_decay_mode_filter_analyse_ll");
00174     truth_decay_mode_filter_analyse_lh = 
00175         (bool)m_reader.get_cutvalue("truth_decay_mode_filter_analyse_lh");
00176     truth_decay_mode_filter_analyse_hh = 
00177         (bool)m_reader.get_cutvalue("truth_decay_mode_filter_analyse_hh");
00178     // e preselection
00179     e_presel_pt_min = (double)m_reader.get_cutvalue("e_presel_pt_min");
00180     e_presel_eta_max = (double)m_reader.get_cutvalue("e_presel_eta_max");
00181     e_presel_eoverp_min = (double)m_reader.get_cutvalue("e_presel_eoverp_min");
00182     e_presel_eoverp_max = (double)m_reader.get_cutvalue("e_presel_eoverp_max");
00183     e_presel_require_isem_0 = (bool)m_reader.get_cutvalue("e_presel_require_isem_0");
00184     e_presel_require_isem_0x3FF = (bool)m_reader.get_cutvalue("e_presel_require_isem_0x3FF");
00185     e_presel_require_isem_mod16_0 = (bool)m_reader.get_cutvalue("e_presel_require_isem_mod16_0");
00186     e_presel_min_NeuralNet = (double)m_reader.get_cutvalue("e_presel_min_NeuralNet");
00187     e_presel_max_etCone02 = (double)m_reader.get_cutvalue("e_presel_max_etCone02");
00188     e_presel_max_etCone02_rel = (double)m_reader.get_cutvalue("e_presel_max_etCone02_rel");
00189     e_presel_noisolation_eta14165 = (bool)m_reader.get_cutvalue("e_presel_noisolation_eta14165");
00190     e_truth_presel_min_pt = (double)m_reader.get_cutvalue("e_truth_presel_min_pt");
00191     e_truth_presel_max_eta = (double)m_reader.get_cutvalue("e_truth_presel_max_eta");
00192     // mu preselection
00193     reco_muons_name = m_reader.retrieve_from_file<TString>("reco_muons_name");
00194     mu_presel_pt_min = (double)m_reader.get_cutvalue("mu_presel_pt_min");
00195     mu_presel_eta_max = (double)m_reader.get_cutvalue("mu_presel_eta_max");
00196     mu_presel_max_etCone04 = (double)m_reader.get_cutvalue("mu_presel_max_etCone04");
00197     mu_presel_max_etCone045 = (double)m_reader.get_cutvalue("mu_presel_max_etCone045");
00198     mu_presel_max_etCone02_rel = (double)m_reader.get_cutvalue("mu_presel_max_etCone02_rel");
00199     mu_presel_use_combined = (bool)m_reader.get_cutvalue("mu_presel_use_combined");
00200     mu_presel_use_standalone = (bool)m_reader.get_cutvalue("mu_presel_use_standalone");
00201     mu_presel_use_lowpt = (bool)m_reader.get_cutvalue("mu_presel_use_lowpt");
00202     mu_presel_require_hasCombinedMuonTrackParticle = (bool)m_reader.get_cutvalue(
00203                                     "mu_presel_require_hasCombinedMuonTrackParticle");
00204     mu_presel_min_matchChi2 = (double)m_reader.get_cutvalue("mu_presel_min_matchChi2");
00205     mu_presel_max_matchChi2 = (double)m_reader.get_cutvalue("mu_presel_max_matchChi2");
00206     mu_presel_max_matchChi2OverDoF = (double)m_reader.get_cutvalue(
00207                                     "mu_presel_max_matchChi2OverDoF");
00208     mu_presel_max_fitChi2OverDoF = (double)m_reader.get_cutvalue("mu_presel_max_fitChi2OverDoF");
00209     mu_truth_presel_min_pt = (double)m_reader.get_cutvalue("mu_truth_presel_min_pt");
00210     mu_truth_presel_max_eta = (double)m_reader.get_cutvalue("mu_truth_presel_max_eta");
00211     
00212     switch_mu_delete_doubles = (bool)m_reader.get_cutvalue("switch_mu_delete_doubles");
00213     switch_mu_remove_overlap_e = (bool)m_reader.get_cutvalue("switch_mu_remove_overlap_e");
00214     dr_mu_remove_overlap_e = (double)m_reader.get_cutvalue("dr_mu_remove_overlap_e");
00215     // taujet preselection
00216     apply_taujet_correction = m_reader.retrieve_from_file<bool>("apply_taujet_correction");
00217     taujet_truth_presel_min_pt = (double)m_reader.get_cutvalue("taujet_truth_presel_min_pt");
00218     taujet_truth_presel_max_eta = (double)m_reader.get_cutvalue("taujet_truth_presel_max_eta");
00219     taujet_presel_min_pt = (double)m_reader.get_cutvalue("taujet_presel_min_pt");
00220     taujet_presel_max_eta = (double)m_reader.get_cutvalue("taujet_presel_max_eta");
00221     taujet_presel_min_llh = (double)m_reader.get_cutvalue("taujet_presel_min_llh");
00222     taujet_presel_require_charge_1 = (bool)m_reader.get_cutvalue(
00223                                                         "taujet_presel_require_charge_1");
00224     taujet_presel_require_nb_tracks_13 = (bool)m_reader.get_cutvalue(
00225             "taujet_presel_require_nb_tracks_13");
00226     taujet_presel_require_TRTHitRatio = (bool)m_reader.get_cutvalue(
00227             "taujet_presel_require_TRTHitRatio");
00228     taujet_presel_min_e_over_p = (double)m_reader.get_cutvalue("taujet_presel_min_e_over_p");
00229     taujet_presel_e_ethadoveret_min = (double)m_reader.get_cutvalue("taujet_presel_e_ethadoveret_min");
00230     switch_taujet_reco_remove_overlap_e = 
00231         (bool)m_reader.get_cutvalue("switch_taujet_reco_remove_overlap_e");
00232     switch_taujet_reco_remove_overlap_mu = 
00233         (bool)m_reader.get_cutvalue("switch_taujet_reco_remove_overlap_mu");
00234     dr_taujet_reco_remove_overlap_e = 
00235         (double)m_reader.get_cutvalue("dr_taujet_reco_remove_overlap_e");
00236     dr_taujet_reco_remove_overlap_mu = 
00237         (double)m_reader.get_cutvalue("dr_taujet_reco_remove_overlap_mu");
00238     // jet preselection
00239     jet_presel_min_pt = (double)m_reader.get_cutvalue("jet_presel_min_pt");
00240     jet_presel_max_eta = (double)m_reader.get_cutvalue("jet_presel_max_eta");
00241     switch_jet_reco_remove_overlap_e = 
00242         (bool)m_reader.get_cutvalue("switch_jet_reco_remove_overlap_e");
00243     dr_jet_reco_remove_overlap_e = (double)m_reader.get_cutvalue("dr_jet_reco_remove_overlap_e");
00244     switch_jet_reco_remove_overlap_mu = 
00245         (bool)m_reader.get_cutvalue("switch_jet_reco_remove_overlap_mu");
00246     dr_jet_reco_remove_overlap_mu = (double)m_reader.get_cutvalue("dr_jet_reco_remove_overlap_mu");
00247     switch_jet_reco_remove_overlap_taujet = 
00248         (bool)m_reader.get_cutvalue("switch_jet_reco_remove_overlap_taujet");
00249     dr_jet_reco_remove_overlap_taujet = 
00250         (double)m_reader.get_cutvalue("dr_jet_reco_remove_overlap_taujet");
00251     jet_truth_presel_min_pt = (double)m_reader.get_cutvalue("jet_truth_presel_min_pt");
00252     jet_truth_presel_max_eta = (double)m_reader.get_cutvalue("jet_truth_presel_max_eta");
00253     switch_jet_truth_remove_overlap_e = 
00254         (bool)m_reader.get_cutvalue("switch_jet_truth_remove_overlap_e");
00255     dr_jet_truth_remove_overlap_e = (double)m_reader.get_cutvalue("dr_jet_truth_remove_overlap_e");
00256     switch_jet_truth_remove_overlap_mu = 
00257         (bool)m_reader.get_cutvalue("switch_jet_truth_remove_overlap_mu");
00258     dr_jet_truth_remove_overlap_mu = 
00259         (double)m_reader.get_cutvalue("dr_jet_truth_remove_overlap_mu");
00260     switch_jet_truth_remove_overlap_taujet = 
00261         (bool)m_reader.get_cutvalue("switch_jet_truth_remove_overlap_taujet");
00262     dr_jet_truth_remove_overlap_taujet = 
00263         (double)m_reader.get_cutvalue("dr_jet_truth_remove_overlap_taujet");
00264 
00265     // analysis related
00266     // reco or truth in analysis
00267     switch_ana_use_e_truth = (bool)m_reader.get_cutvalue("switch_ana_use_e_truth");
00268     switch_ana_use_mu_truth = (bool)m_reader.get_cutvalue("switch_ana_use_mu_truth");
00269     switch_ana_use_taujet_truth = (bool)m_reader.get_cutvalue("switch_ana_use_taujet_truth");
00270     switch_ana_use_jet_truth = (bool)m_reader.get_cutvalue("switch_ana_use_jet_truth");
00271     // trigger flavour
00272     ana_require_trigger_flavour = (int)m_reader.get_cutvalue("ana_require_trigger_flavour");
00273     // -1: no requirement
00274     //  1: e flavour
00275     //  2: mu flavour
00276     
00277     // get switch_only_highpt_jetpair value
00278     switch_only_highpt_jetpair = (bool)m_reader.get_cutvalue("switch_only_highpt_jetpair");
00279     
00280     recalculate_met_muons = m_reader.retrieve_from_file<TString>("recalculate_met_muons");
00281     met_option = m_reader.retrieve_from_file<TString>("met_option");
00282 
00283 
00284     output_level_cand_ntuple = m_reader.retrieve_from_file<int>("output_level_cand_ntuple");
00285 
00286     //-----------------------
00287     //-- read in cut order --
00288     //-----------------------
00289     m_reader.fill_cutvalue_map("cut_order",settingsFilename);
00290     cuts_total_nb=0;
00291 
00292     for(int k=0; k<20; k++){
00293         (cuts[k])="";
00294     }
00295     cuts[(int)(m_reader.get_cutvalue("trigger"))] = "trigger";
00296     cuts[(int)(m_reader.get_cutvalue("number_emu"))] = "number_emu";
00297     cuts[(int)(m_reader.get_cutvalue("number_taujets"))] = "number_taujets";
00298     cuts[(int)(m_reader.get_cutvalue("number_jets"))] = "number_jets";
00299     cuts[(int)(m_reader.get_cutvalue("etmiss"))] = "etmiss";
00300     cuts[(int)(m_reader.get_cutvalue("lepton_pt"))] = "lepton_pt";
00301     cuts[(int)(m_reader.get_cutvalue("leptons_charge"))] = "leptons_charge";
00302     cuts[(int)(m_reader.get_cutvalue("leptons_dphi"))] = "leptons_dphi";
00303     cuts[(int)(m_reader.get_cutvalue("leptons_dr"))] = "leptons_dr";
00304     cuts[(int)(m_reader.get_cutvalue("collinear_approximation"))] = "collinear_approximation";
00305     cuts[(int)(m_reader.get_cutvalue("transverse_mass"))] = "transverse_mass";
00306     cuts[(int)(m_reader.get_cutvalue("jets_pt"))] = "jets_pt";
00307     cuts[(int)(m_reader.get_cutvalue("jets_hemisphere"))] = "jets_hemisphere";
00308     cuts[(int)(m_reader.get_cutvalue("jets_deta"))] = "jets_deta";
00309     cuts[(int)(m_reader.get_cutvalue("jets_dphi"))] = "jets_dphi";
00310     cuts[(int)(m_reader.get_cutvalue("jets_mass"))] = "jets_mass";
00311     cuts[(int)(m_reader.get_cutvalue("bjet_veto"))] = "bjet_veto";
00312     cuts[(int)(m_reader.get_cutvalue("central_jet_veto"))] = "central_jet_veto";
00313     cuts[(int)(m_reader.get_cutvalue("leptons_jets_deta"))] = "leptons_jets_deta";
00314     cuts[(int)(m_reader.get_cutvalue("pt_balance"))] = "pt_balance";
00315     cuts[(int)(m_reader.get_cutvalue("mass_window"))] = "mass_window";
00316 
00317     for(int k=1; k<20; k++){
00318         if((cuts[k])!="")cuts_total_nb++;
00319     if(((cuts[k])!="") && (cuts_total_nb!=k)){
00320         cerr<<"ERROR:  check cut settings!"<<endl;
00321         cuts_total_nb = 0;
00322         exit(1);
00323         break;
00324     }
00325         //cout<<"Cut "<<k<<": "<<cuts[k]<<endl;
00326     }
00327     cout<<"total number of cuts: "<<cuts_total_nb<<endl;
00328     
00329 
00330 
00331     recalculate_met_muons = m_reader.retrieve_from_file<TString>("recalculate_met_muons");
00332 
00333 
00334     
00335     //-----------------
00336     //-- Cut Values ---
00337     //-----------------
00338     {
00339     //decay_mode_string = m_reader.retrieve_from_file<TString>("decay_mode");
00340     m_reader.fill_cutvalue_map("cutvalues_"+decay_mode_string,settingsFilename);
00341     //cout<<"cut_values: "<<"cutvalues_"+decay_mode_string<<endl;
00342     //m_reader.fill_cutvalue_map("cut_values",settingsFilename);
00343     
00344     ana_e_nb_min     = (unsigned int)m_reader.get_cutvalue("ana_e_nb_min");
00345     ana_e_nb_max     = (unsigned int)m_reader.get_cutvalue("ana_e_nb_max");
00346     ana_mu_nb_min     = (unsigned int)m_reader.get_cutvalue("ana_mu_nb_min");
00347     ana_mu_nb_max     = (unsigned int)m_reader.get_cutvalue("ana_mu_nb_max");
00348     ana_emu_nb_min     = (unsigned int)m_reader.get_cutvalue("ana_emu_nb_min");
00349     ana_emu_nb_max    = (unsigned int)m_reader.get_cutvalue("ana_emu_nb_max");
00350     ana_taujet_nb_min = (unsigned int)m_reader.get_cutvalue("ana_taujet_nb_min");
00351     ana_taujet_nb_max = (unsigned int)m_reader.get_cutvalue("ana_taujet_nb_max");
00352     min_etmiss = m_reader.get_cutvalue("min_etmiss");
00353     min_e_pt = m_reader.get_cutvalue("min_e_pt");
00354     min_mu_pt = m_reader.get_cutvalue("min_mu_pt");
00355     min_taujet_pt = m_reader.get_cutvalue("min_taujet_pt");
00356     min_leptons_cosdphi = m_reader.get_cutvalue("min_leptons_cosdphi");
00357     max_leptons_dr = m_reader.get_cutvalue("max_leptons_dr");
00358     min_lept_x = m_reader.get_cutvalue("min_lept_x");
00359     min_had_x = m_reader.get_cutvalue("min_had_x");
00360     max_lept_x = m_reader.get_cutvalue("max_lept_x");
00361     max_had_x = m_reader.get_cutvalue("max_had_x");
00362     max_x_squaresum = m_reader.get_cutvalue("max_x_squaresum");
00363     max_transverse_mass = m_reader.get_cutvalue("max_transverse_mass");
00364     min_jet1_pt = m_reader.get_cutvalue("min_jet1_pt");
00365     min_jet2_pt = m_reader.get_cutvalue("min_jet2_pt");
00366     min_jets_deta = m_reader.get_cutvalue("min_jets_deta");
00367     max_jets_dphi = m_reader.get_cutvalue("max_jets_dphi");
00368     min_jets_mass = m_reader.get_cutvalue("min_jets_mass");
00369     max_bjet_weight = m_reader.get_cutvalue("max_bjet_weight");
00370     min_cj_pt = m_reader.get_cutvalue("min_cj_pt");
00371     max_cj_eta = m_reader.get_cutvalue("max_cj_eta");
00372     switch_cj_between_fwdjets = (Bool_t)m_reader.get_cutvalue("switch_cj_between_fwdjets");
00373     min_leptons_jets_deta = m_reader.get_cutvalue("min_leptons_jets_deta");
00374     max_pt_balance = m_reader.get_cutvalue("max_pt_balance");
00375     min_mass_window = m_reader.get_cutvalue("min_mass_window");
00376     max_mass_window = m_reader.get_cutvalue("max_mass_window");
00377     }
00378 
00379     //-------------------------
00380     //-- write settings tree --
00381     //-------------------------
00382     {
00383     tree_settings->Branch("switch_truth_lepton_filter", &switch_truth_lepton_filter,
00384                           "switch_truth_lepton_filter/O");
00385     tree_settings->Branch("truth_lepton_filter_min_nb_leptons", &truth_lepton_filter_min_nb_leptons,
00386                           "truth_lepton_filter_min_nb_leptons/b");
00387     tree_settings->Branch("switch_analyse_truth_decay", &switch_analyse_truth_decay,
00388                           "switch_analyse_truth_decay/O");
00389     tree_settings->Branch("switch_truth_decay_mode_filter", &switch_truth_decay_mode_filter,
00390                           "switch_truth_decay_mode_filter/O");
00391     tree_settings->Branch("truth_decay_mode_filter_only_higgs", &truth_decay_mode_filter_only_higgs,
00392                           "truth_decay_mode_filter_only_higgs/O");
00393     tree_settings->Branch("truth_decay_mode_filter_analyse_ll", &truth_decay_mode_filter_analyse_ll,
00394                           "truth_decay_mode_filter_analyse_ll/O");
00395     tree_settings->Branch("truth_decay_mode_filter_analyse_lh", &truth_decay_mode_filter_analyse_lh,
00396                           "truth_decay_mode_filter_analyse_lh/O");
00397     tree_settings->Branch("truth_decay_mode_filter_analyse_hh", &truth_decay_mode_filter_analyse_hh,
00398                           "truth_decay_mode_filter_analyse_hh/O");
00399     tree_settings->Branch("e_presel_pt_min", &e_presel_pt_min, "e_presel_pt_min/D");
00400     tree_settings->Branch("e_presel_eta_max", &e_presel_eta_max, "e_presel_eta_max/D");
00401     tree_settings->Branch("e_presel_eoverp_min", &e_presel_eoverp_min, "e_presel_eoverp_min/D");
00402     tree_settings->Branch("e_presel_eoverp_max", &e_presel_eoverp_max, "e_presel_eoverp_max/D");
00403     tree_settings->Branch("e_presel_require_isem_0", &e_presel_require_isem_0,
00404                           "e_presel_require_isem_0/O");
00405     tree_settings->Branch("e_presel_require_isem_0x3FF", &e_presel_require_isem_0x3FF,
00406                           "e_presel_require_isem_0x3FF/O");
00407     tree_settings->Branch("e_presel_require_isem_mod16_0", &e_presel_require_isem_mod16_0,
00408                           "e_presel_require_isem_mod16_0/O");
00409     tree_settings->Branch("e_presel_min_NeuralNet", &e_presel_min_NeuralNet,
00410                           "e_presel_min_NeuralNet/D");
00411     tree_settings->Branch("e_presel_max_etCone02", &e_presel_max_etCone02,
00412                           "e_presel_max_etCone02/D");
00413     tree_settings->Branch("e_presel_max_etCone02_rel", &e_presel_max_etCone02_rel,
00414                           "e_presel_max_etCone02_rel/D");
00415     tree_settings->Branch("e_presel_noisolation_eta14165", &e_presel_noisolation_eta14165,
00416                           "e_presel_noisolation_eta14165/O");
00417     tree_settings->Branch("e_truth_presel_min_pt", &e_truth_presel_min_pt,
00418                           "e_truth_presel_min_pt/D");
00419     tree_settings->Branch("e_truth_presel_max_eta", &e_truth_presel_max_eta,
00420                           "e_truth_presel_max_eta/D");
00421     tree_settings->Branch("mu_presel_pt_min", &mu_presel_pt_min, "mu_presel_pt_min/D");
00422     tree_settings->Branch("mu_presel_eta_max", &mu_presel_eta_max, "mu_presel_eta_max/D");
00423     tree_settings->Branch("mu_presel_max_etCone04", &mu_presel_max_etCone04,
00424                           "mu_presel_max_etCone04/D");
00425     tree_settings->Branch("mu_presel_max_etCone045", &mu_presel_max_etCone045,
00426                           "mu_presel_max_etCone045/D");
00427     tree_settings->Branch("mu_presel_max_etCone02_rel", &mu_presel_max_etCone02_rel,
00428                           "mu_presel_max_etCone02_rel/D");
00429     tree_settings->Branch("mu_presel_use_combined", &mu_presel_use_combined,
00430                           "mu_presel_use_combined/O");
00431     tree_settings->Branch("mu_presel_use_standalone", &mu_presel_use_standalone,
00432                           "mu_presel_use_standalone/O");
00433     tree_settings->Branch("mu_presel_use_lowpt", &mu_presel_use_lowpt,
00434                           "mu_presel_use_lowpt/O");
00435     tree_settings->Branch("mu_presel_require_hasCombinedMuonTrackParticle",
00436                            &mu_presel_require_hasCombinedMuonTrackParticle,
00437                           "mu_presel_require_hasCombinedMuonTrackParticle/O");
00438     tree_settings->Branch("mu_presel_min_matchChi2", &mu_presel_min_matchChi2,
00439                           "mu_presel_min_matchChi2/D");
00440     tree_settings->Branch("mu_presel_max_matchChi2", &mu_presel_max_matchChi2,
00441                           "mu_presel_max_matchChi2/D");
00442     tree_settings->Branch("mu_presel_max_matchChi2OverDoF", &mu_presel_max_matchChi2OverDoF,
00443                           "mu_presel_max_matchChi2OverDoF/D");
00444     tree_settings->Branch("mu_presel_max_fitChi2OverDoF", &mu_presel_max_fitChi2OverDoF,
00445                           "mu_presel_max_fitChi2OverDoF/D");
00446     tree_settings->Branch("mu_truth_presel_min_pt", &mu_truth_presel_min_pt,
00447                           "mu_truth_presel_min_pt/D");
00448     tree_settings->Branch("mu_truth_presel_max_eta", &mu_truth_presel_max_eta,
00449                           "mu_truth_presel_max_eta/D");
00450     tree_settings->Branch("switch_mu_delete_doubles", &switch_mu_delete_doubles,
00451                           "switch_mu_delete_doubles/O");
00452     tree_settings->Branch("switch_mu_remove_overlap_e", &switch_mu_remove_overlap_e,
00453                           "switch_mu_remove_overlap_e/O");
00454     tree_settings->Branch("dr_mu_remove_overlap_e", &dr_mu_remove_overlap_e,
00455                           "dr_mu_remove_overlap_e/D");
00456     tree_settings->Branch("taujet_truth_presel_min_pt", &taujet_truth_presel_min_pt,
00457                           "taujet_truth_presel_min_pt/D");
00458     tree_settings->Branch("taujet_truth_presel_max_eta", &taujet_truth_presel_max_eta,
00459                           "taujet_truth_presel_max_eta/D");
00460     tree_settings->Branch("taujet_presel_min_pt", &taujet_presel_min_pt, "taujet_presel_min_pt/D");
00461     tree_settings->Branch("taujet_presel_max_eta", &taujet_presel_max_eta,
00462                           "taujet_presel_max_eta/D");
00463     tree_settings->Branch("taujet_presel_min_llh", &taujet_presel_min_llh,
00464                           "taujet_presel_min_llh/D");
00465     tree_settings->Branch("taujet_presel_require_charge_1", &taujet_presel_require_charge_1,
00466                           "taujet_presel_require_charge_1/O");
00467     tree_settings->Branch("taujet_presel_require_nb_tracks_13", &taujet_presel_require_nb_tracks_13,
00468                           "taujet_presel_require_nb_tracks_13/O");
00469     tree_settings->Branch("taujet_presel_require_TRTHitRatio", &taujet_presel_require_TRTHitRatio,
00470                           "taujet_presel_require_TRTHitRatio/O");
00471     tree_settings->Branch("taujet_presel_min_e_over_p", &taujet_presel_min_e_over_p,
00472                           "taujet_presel_min_e_over_p/D");
00473     tree_settings->Branch("taujet_presel_e_ethadoveret_min", &taujet_presel_e_ethadoveret_min,
00474                           "taujet_presel_e_ethadoveret_min/D");
00475     tree_settings->Branch("switch_taujet_reco_remove_overlap_e",
00476                           &switch_taujet_reco_remove_overlap_e, 
00477                           "switch_taujet_reco_remove_overlap_e/O");
00478     tree_settings->Branch("switch_taujet_reco_remove_overlap_mu",
00479                           &switch_taujet_reco_remove_overlap_mu,
00480                           "switch_taujet_reco_remove_overlap_mu/O");
00481     tree_settings->Branch("dr_taujet_reco_remove_overlap_e", &dr_taujet_reco_remove_overlap_e,
00482                           "dr_taujet_reco_remove_overlap_e/D");
00483     tree_settings->Branch("dr_taujet_reco_remove_overlap_mu", &dr_taujet_reco_remove_overlap_mu,
00484                           "dr_taujet_reco_remove_overlap_mu/D");
00485     tree_settings->Branch("jet_presel_min_pt", &jet_presel_min_pt,
00486                           "jet_presel_min_pt/D");
00487     tree_settings->Branch("jet_presel_max_eta", &jet_presel_max_eta,
00488                           "jet_presel_max_eta/D");
00489     tree_settings->Branch("switch_jet_reco_remove_overlap_e", &switch_jet_reco_remove_overlap_e,
00490                           "switch_jet_reco_remove_overlap_e/O");
00491     tree_settings->Branch("dr_jet_reco_remove_overlap_e", &dr_jet_reco_remove_overlap_e,
00492                           "dr_jet_reco_remove_overlap_e/D");
00493     tree_settings->Branch("switch_jet_reco_remove_overlap_mu", &switch_jet_reco_remove_overlap_mu,
00494                           "switch_jet_reco_remove_overlap_mu/O");
00495     tree_settings->Branch("dr_jet_reco_remove_overlap_mu", &dr_jet_reco_remove_overlap_mu,
00496                           "dr_jet_reco_remove_overlap_mu/D");
00497     tree_settings->Branch("switch_jet_reco_remove_overlap_taujet",
00498                           &switch_jet_reco_remove_overlap_taujet,
00499                           "switch_jet_reco_remove_overlap_taujet/O");
00500     tree_settings->Branch("dr_jet_reco_remove_overlap_taujet", &dr_jet_reco_remove_overlap_taujet,
00501                           "dr_jet_reco_remove_overlap_taujet/D");
00502     tree_settings->Branch("jet_truth_presel_min_pt", &jet_truth_presel_min_pt,
00503                           "jet_truth_presel_min_pt/D");
00504     tree_settings->Branch("jet_truth_presel_max_eta", &jet_truth_presel_max_eta,
00505                           "jet_truth_presel_max_eta/D");
00506     tree_settings->Branch("switch_jet_truth_remove_overlap_e", &switch_jet_truth_remove_overlap_e,
00507                           "switch_jet_truth_remove_overlap_e/O");
00508     tree_settings->Branch("dr_jet_truth_remove_overlap_e", &dr_jet_truth_remove_overlap_e,
00509                           "dr_jet_truth_remove_overlap_e/D");
00510     tree_settings->Branch("switch_jet_truth_remove_overlap_mu", &switch_jet_truth_remove_overlap_mu,
00511                           "switch_jet_truth_remove_overlap_mu/O");
00512     tree_settings->Branch("dr_jet_truth_remove_overlap_mu", &dr_jet_truth_remove_overlap_mu,
00513                           "dr_jet_truth_remove_overlap_mu/D");
00514     tree_settings->Branch("switch_jet_truth_remove_overlap_taujet",
00515                           &switch_jet_truth_remove_overlap_taujet,
00516                           "switch_jet_truth_remove_overlap_taujet/O");
00517     tree_settings->Branch("dr_jet_truth_remove_overlap_taujet",
00518                           &dr_jet_truth_remove_overlap_taujet,
00519                           "dr_jet_truth_remove_overlap_taujet/D");
00520     tree_settings->Branch("switch_ana_use_e_truth", &switch_ana_use_e_truth,
00521                           "switch_ana_use_e_truth/O");
00522     tree_settings->Branch("switch_ana_use_mu_truth", &switch_ana_use_mu_truth,
00523                           "switch_ana_use_mu_truth/O");
00524     tree_settings->Branch("switch_ana_use_taujet_truth", &switch_ana_use_taujet_truth,
00525                           "switch_ana_use_taujet_truth/O");
00526     tree_settings->Branch("switch_ana_use_jet_truth", &switch_ana_use_jet_truth,
00527                           "switch_ana_use_jet_truth/O");
00528     tree_settings->Branch("ana_require_trigger_flavour", &ana_require_trigger_flavour,
00529                           "ana_require_trigger_flavour/B");
00530     tree_settings->Branch("apply_taujet_correction", &apply_taujet_correction,
00531                           "apply_taujet_correction/B");
00532     tree_settings->Branch("switch_only_highpt_jetpair", &switch_only_highpt_jetpair,
00533                           "switch_only_highpt_jetpair/O");
00534     // string variables
00535     char ca_recalculate_met_muons[50] = "";
00536     strcpy(ca_recalculate_met_muons,recalculate_met_muons.c_str());
00537     tree_settings->Branch("recalculate_met_muons", &ca_recalculate_met_muons,
00538                           "recalculate_met_muons/C");
00539     char ca_met_option[50] = "";
00540     strcpy(ca_met_option,met_option.c_str());
00541     tree_settings->Branch("met_option", &ca_met_option,
00542                           "met_option/C");
00543     char ca_reco_muons_name[50] = "reco_muons_name";
00544     strcpy(ca_reco_muons_name,reco_muons_name.c_str());
00545     tree_settings->Branch("reco_muons_name", &ca_reco_muons_name,
00546                           "reco_muons_name/C");
00547     tree_settings->Branch("output_level_cand_ntuple", &output_level_cand_ntuple,
00548                           "output_level_cand_ntuple/B");
00549     // Fill tree once
00550     tree_settings->Fill();
00551     }
00552     
00553 
00554     //-----------------------------
00555     //-- WRITE THE CUTORDER TREE --
00556     //-----------------------------
00557     string str_helper;
00558     char   char_helper[50] = "";
00559     for(int k=1; k<cuts_total_nb+1; k++){
00560         str_helper=cuts[k];
00561         strcpy(char_helper,str_helper.c_str());
00562         tree_cut_order->Branch(Form("cut_%2.2i",k), &char_helper,
00563             Form("cut_%2.2i/C",k));
00564         tree_cut_order->Fill();
00565     }
00566     tree_cut_order->Branch("nb_cuts", &cuts_total_nb, "nb_cuts/I");
00567     tree_cut_order->Fill();
00568 
00569 
00570 
00571 
00572     //-------------------------------
00573     //-- write the cut values tree --
00574     //-------------------------------
00575     {
00576     tree_cut_values->Branch("min_etmiss", &min_etmiss, "min_etmiss/D");
00577     tree_cut_values->Branch("ana_e_nb_min", &ana_e_nb_min, "ana_e_nb_min/b");
00578     tree_cut_values->Branch("ana_e_nb_max", &ana_e_nb_max, "ana_e_nb_max/b");
00579     tree_cut_values->Branch("ana_mu_nb_min", &ana_mu_nb_min, "ana_mu_nb_min/b");
00580     tree_cut_values->Branch("ana_mu_nb_max", &ana_mu_nb_max, "ana_mu_nb_max/b");
00581     tree_cut_values->Branch("ana_emu_nb_min", &ana_emu_nb_min, "ana_emu_nb_min/b");
00582     tree_cut_values->Branch("ana_emu_nb_max", &ana_emu_nb_max, "ana_emu_nb_max/b");
00583     tree_cut_values->Branch("ana_taujet_nb_min", &ana_taujet_nb_min, "ana_taujet_nb_min/b");
00584     tree_cut_values->Branch("ana_taujet_nb_max", &ana_taujet_nb_max, "ana_taujet_nb_max/b");
00585     tree_cut_values->Branch("min_e_pt", &min_e_pt, "min_e_pt/D");
00586     tree_cut_values->Branch("min_mu_pt", &min_mu_pt, "min_mu_pt/D");
00587     tree_cut_values->Branch("min_taujet_pt", &min_taujet_pt, "min_taujet_pt/D");
00588     tree_cut_values->Branch("min_leptons_cosdphi", &min_leptons_cosdphi, "min_leptons_cosdphi/D");
00589     tree_cut_values->Branch("max_leptons_dr", &max_leptons_dr, "max_leptons_dr/D");
00590     tree_cut_values->Branch("min_lept_x", &min_lept_x, "min_lept_x/D");
00591     tree_cut_values->Branch("min_had_x", &min_had_x, "min_had_x/D");
00592     tree_cut_values->Branch("max_lept_x", &max_lept_x, "max_lept_x/D");
00593     tree_cut_values->Branch("max_had_x", &max_had_x, "max_had_x/D");
00594     tree_cut_values->Branch("max_x_squaresum", &max_x_squaresum, "max_x_squaresum/D");
00595     tree_cut_values->Branch("max_transverse_mass", &max_transverse_mass, "max_transverse_mass/D");
00596     tree_cut_values->Branch("min_jet1_pt", &min_jet1_pt, "min_jet1_pt/D");
00597     tree_cut_values->Branch("min_jet2_pt", &min_jet2_pt, "min_jet2_pt/D");
00598     tree_cut_values->Branch("min_jets_deta", &min_jets_deta, "min_jets_deta/D");
00599     tree_cut_values->Branch("max_jets_dphi", &max_jets_dphi, "max_jets_dphi/D");
00600     tree_cut_values->Branch("min_jets_mass", &min_jets_mass, "min_jets_mass/D");
00601     tree_cut_values->Branch("max_bjet_weight", &max_bjet_weight, "max_bjet_weigth/D");
00602     tree_cut_values->Branch("min_cj_pt", &min_cj_pt, "min_cj_pt/D");
00603     tree_cut_values->Branch("max_cj_eta", &max_cj_eta, "max_cj_eta/D");
00604     tree_cut_values->Branch("switch_cj_between_fwdjets", &switch_cj_between_fwdjets,
00605                             "switch_cj_between_fwdjets/O");
00606     tree_cut_values->Branch("min_leptons_jets_deta", &min_leptons_jets_deta,
00607                             "min_leptons_jets_deta/D");
00608     tree_cut_values->Branch("max_pt_balance", &max_pt_balance,
00609                             "max_pt_balance/D");
00610     tree_cut_values->Branch("min_mass_window", &min_mass_window,
00611                             "min_mass_window/D");
00612     tree_cut_values->Branch("max_mass_window", &max_mass_window,
00613                             "max_mass_window/D");
00614     // Fill tree once    
00615     tree_cut_values->Fill();
00616     }
00617 
00618 
00619     //----------------------------
00620     //-- Tree for MVA variables --
00621     //----------------------------
00622     tree_MVA_variables->Branch("etmiss", &MVAvar_etmiss, "etmiss/F");
00623     tree_MVA_variables->Branch("ll_dr", &MVAvar_ll_dr, "ll_dr/F");
00624     tree_MVA_variables->Branch("ll_dphi", &MVAvar_ll_dphi, "ll_dphi/F");
00625     tree_MVA_variables->Branch("jj_dphi", &MVAvar_jj_dphi, "jj_dphi/F");
00626     tree_MVA_variables->Branch("jj_deta", &MVAvar_jj_deta, "jj_deta/F");
00627     tree_MVA_variables->Branch("jj_m", &MVAvar_jj_m, "jj_m/F");
00628     tree_MVA_variables->Branch("x1", &MVAvar_x1, "x1/F");
00629     tree_MVA_variables->Branch("x2", &MVAvar_x2, "x2/F");
00630     tree_MVA_variables->Branch("jl_deta_min", &MVAvar_jl_deta_min, "jl_deta_min/F");
00631     tree_MVA_variables->Branch("jl_deta_max", &MVAvar_jl_deta_max, "jl_deta_max/F");
00632     tree_MVA_variables->Branch("pt_all", &MVAvar_pt_all, "pt_all/F");
00633     tree_MVA_variables->Branch("ll_pt1", &MVAvar_ll_pt1, "ll_pt1/F");
00634     tree_MVA_variables->Branch("ll_pt2", &MVAvar_ll_pt2, "ll_pt2/F");
00635     tree_MVA_variables->Branch("jj_pt1", &MVAvar_jj_pt1, "jj_pt1/F");
00636     tree_MVA_variables->Branch("jj_pt2", &MVAvar_jj_pt2, "jj_pt2/F");
00637     tree_MVA_variables->Branch("m_t", &MVAvar_m_t, "m_t/F");
00638     tree_MVA_variables->Branch("H_m", &MVAvar_H_m, "H_m/F");
00639     tree_MVA_variables->Branch("weight", &MVAvar_weight, "weight/F");
00640     tree_MVA_variables->Branch("Event", &MVAvar_Event, "Event/F");
00641     tree_MVA_variables->Branch("Entry", &MVAvar_Entry, "Entry/F");
00642 
00643 
00644     //-----------------------------
00645     //-- Tree for candidate data --
00646     //-----------------------------
00647     tree_cand_data->Branch("cand_nb     ", &tcd_cand_nb     , "cand_nb/S");
00648     tree_cand_data->Branch("cand_id     ", &tcd_cand_id     , "cand_id/S");
00649     tree_cand_data->Branch("cut_map     ", &tcd_cut_map     , "cut_map/I");
00650     tree_cand_data->Branch("has_leptons ", &tcd_has_leptons , "has_leptons/O");
00651     tree_cand_data->Branch("has_jets    ", &tcd_has_jets    , "has_jets/O");
00652     tree_cand_data->Branch("ev_e_nb     ", &tcd_ev_e_nb     , "ev_e_nb/S");
00653     tree_cand_data->Branch("ev_mu_nb    ", &tcd_ev_mu_nb    , "ev_mu_nb/S");
00654     tree_cand_data->Branch("ev_tau_nb   ", &tcd_ev_tau_nb   , "ev_tau_nb/S");
00655     tree_cand_data->Branch("ev_jet_nb   ", &tcd_ev_jet_nb   , "ev_jet_nb/S");
00656     tree_cand_data->Branch("bjet_val    ", &tcd_bjet_val    , "bjet_val/F");
00657     tree_cand_data->Branch("etmiss      ", &tcd_etmiss      , "etmiss/F");
00658     tree_cand_data->Branch("etmiss_phi  ", &tcd_etmiss_phi  , "etmiss_phi/F");
00659     tree_cand_data->Branch("ll_dr       ", &tcd_ll_dr       , "ll_dr/F");
00660     tree_cand_data->Branch("ll_dphi     ", &tcd_ll_dphi     , "ll_dphi/F");
00661     tree_cand_data->Branch("ll_dphi_noabs     ", &tcd_ll_dphi_noabs     , "ll_dphi_noabs/F");
00662     tree_cand_data->Branch("ll_deta     ", &tcd_ll_deta     , "ll_deta/F");
00663     tree_cand_data->Branch("ll_dpt      ", &tcd_ll_dpt      , "ll_dpt/F");
00664     tree_cand_data->Branch("jj_dphi     ", &tcd_jj_dphi     , "jj_dphi/F");
00665     tree_cand_data->Branch("jj_dphi_noabs     ", &tcd_jj_dphi_noabs     , "jj_dphi_noabs/F");
00666     tree_cand_data->Branch("jj_deta     ", &tcd_jj_deta     , "jj_deta/F");
00667     tree_cand_data->Branch("jj_dpt      ", &tcd_jj_dpt      , "jj_dpt/F");
00668     tree_cand_data->Branch("jj_m        ", &tcd_jj_m        , "jj_m/F");
00669     tree_cand_data->Branch("btag_weight ", &tcd_btag_weight , "btag_weight/F");
00670     tree_cand_data->Branch("x1          ", &tcd_x1          , "x1/F");
00671     tree_cand_data->Branch("x2          ", &tcd_x2          , "x2/F");
00672     tree_cand_data->Branch("m_t         ", &tcd_m_t         , "m_t/F");
00673     tree_cand_data->Branch("jl_deta_min ", &tcd_jl_deta_min , "jl_deta_min/F");
00674     tree_cand_data->Branch("jl_deta_max ", &tcd_jl_deta_max , "jl_deta_max/F");
00675     tree_cand_data->Branch("pt_all      ", &tcd_pt_all      , "pt_all/F");
00676     tree_cand_data->Branch("l1_pdgId    ", &tcd_l1_pdgId    , "l1_pdgId/S");
00677     tree_cand_data->Branch("l2_pdgId    ", &tcd_l2_pdgId    , "l2_pdgId/S");
00678     tree_cand_data->Branch("l1_pt       ", &tcd_l1_pt       , "l1_pt/F");
00679     tree_cand_data->Branch("l2_pt       ", &tcd_l2_pt       , "l2_pt/F");
00680     tree_cand_data->Branch("l1_eta      ", &tcd_l1_eta      , "l1_eta/F");
00681     tree_cand_data->Branch("l2_eta      ", &tcd_l2_eta      , "l2_eta/F");
00682     tree_cand_data->Branch("l1_phi      ", &tcd_l1_phi      , "l1_phi/F");
00683     tree_cand_data->Branch("l2_phi      ", &tcd_l2_phi      , "l2_phi/F");
00684     tree_cand_data->Branch("j1_pt       ", &tcd_j1_pt       , "j1_pt/F");
00685     tree_cand_data->Branch("j2_pt       ", &tcd_j2_pt       , "j2_pt/F");
00686     tree_cand_data->Branch("j1_eta      ", &tcd_j1_eta      , "j1_eta/F");
00687     tree_cand_data->Branch("j2_eta      ", &tcd_j2_eta      , "j2_eta/F");
00688     tree_cand_data->Branch("j1_phi      ", &tcd_j1_phi      , "j1_phi/F");
00689     tree_cand_data->Branch("j2_phi      ", &tcd_j2_phi      , "j2_phi/F");
00690     tree_cand_data->Branch("cj_nb       ", &tcd_cj_nb       , "cj_nb/S");
00691     tree_cand_data->Branch("cj1_pt      ", &tcd_cj1_pt      , "cj1_pt/F");
00692     tree_cand_data->Branch("cj2_pt      ", &tcd_cj2_pt      , "cj2_pt/F");
00693     tree_cand_data->Branch("cj1_eta     ", &tcd_cj1_eta     , "cj1_eta/F");
00694     tree_cand_data->Branch("cj2_eta     ", &tcd_cj2_eta     , "cj2_eta/F");
00695     tree_cand_data->Branch("cj1_phi     ", &tcd_cj1_phi     , "cj1_phi/F");
00696     tree_cand_data->Branch("cj2_phi     ", &tcd_cj2_phi     , "cj2_phi/F");
00697     tree_cand_data->Branch("H_m         ", &tcd_H_m         , "H_m/F");
00698     tree_cand_data->Branch("H_pt        ", &tcd_H_pt        , "H_pt/F");
00699     tree_cand_data->Branch("H_eta       ", &tcd_H_eta       , "H_eta/F");
00700     tree_cand_data->Branch("H_phi       ", &tcd_H_phi       , "H_phi/F");
00701     tree_cand_data->Branch("weight      ", &tcd_weight      , "weight/F");
00702     tree_cand_data->Branch("Event       ", &tcd_Event       , "Event/I");
00703     tree_cand_data->Branch("Run         ", &tcd_Run         , "Run/I");
00704     tree_cand_data->Branch("Entry       ", &tcd_Entry       , "Entry/I");
00705 
00706 
00707 
00708     return;
00709 }
00710 
00711 
00712 //*****************************************************************************
00713 
00714 // ::::::::::::::::::::::::::
00715 // :: METHOD analyse_event ::
00716 // ::::::::::::::::::::::::::
00717 
00718 void MyHtautauAnalysis::analyse_event(const MyEvent & event) {
00719 
00720     clear_event_data();
00721     m_event = &event;
00722     entry_nb++;
00723 
00724     MVAvar_Event = event.event_number();
00725     MVAvar_Entry = entry_nb;
00726     tcd_Event    = event.event_number();
00727     tcd_Run      = event.run_number();
00728     tcd_Entry    = entry_nb;
00729 
00730     /*
00731     if(event.event_number()!=11357 &&
00732        event.event_number()!=11357
00733        )return; //*/
00734     /*
00735     if(entry_nb!=33086 &&
00736        entry_nb!=33086
00737        )return; //*/
00738     /*
00739     cout<<endl<<"========================================"<<endl;
00740     cout<<"event: "<<event.event_number()<<endl;
00741     cout<<"entry: "<<entry_nb<<endl;//*/
00742 
00743     // create/initialize TruthParticle Manager
00744     //* debug info */ cerr<<"before creating truth particle manager"<<endl;
00745     m_truth_manager = MyTruthParticleManager(event.truth_particles());
00746     m_truth_manager.set_generator(generator);
00747 
00748     weight = event.event_weight();
00749     if(weight==0){
00750         if(generator=="Alpgen" || generator=="Herwig"){
00751             weight=1;
00752         }
00753         else{
00754             cerr<<"weight is 0 and Generator is not Alpgen or Herwig!!!"<<endl;
00755             exit(1);
00756         }
00757     }
00758     // cout<<"Weight: "<<weight<<endl;
00759 
00760     //     TTbarLeptonFilter  //
00761     /*
00762     if(TTbarLeptonFilter()){
00763         // event accepted
00764         h_TTbarLeptonFilter->Fill(1.);
00765         h_TTbarLeptonFilter->Fill(3.,weight);
00766         return;
00767     }
00768     else{
00769         // event NOT accepted
00770         h_TTbarLeptonFilter->Fill(0.);
00771         h_TTbarLeptonFilter->Fill(2.,weight);
00772         //return;
00773     }//*/
00774 
00775 
00776     
00777     // all events
00778     h_cut_evolution->Fill(-2);
00779     h_cut_evolution_candidates->Fill(-2);
00780 
00781 
00782 
00783 // truth lepton filter //
00784     if(switch_truth_lepton_filter){
00785         int n_truth_leptons(0);
00786         n_truth_leptons = check_truth_lepton_filter();
00787         if(n_truth_leptons<truth_lepton_filter_min_nb_leptons) return;
00788     }
00789     // events after truth lepton filter
00790     h_cut_evolution->Fill(-1, weight);
00791     h_cut_evolution_candidates->Fill(-1, weight);
00792 
00793 
00794 // analyse truth decay //
00795     //* debug info */ cerr<<"before analyse_truth_decay"<<endl;
00796     if(switch_analyse_truth_decay)analyse_truth_decay();
00797 
00799 // truth decay mode filter //
00801     if(switch_truth_decay_mode_filter){
00802         if(!switch_analyse_truth_decay){
00803             cerr<<"Set: switch_analyse_truth_decay = True to apply the filter!"<<endl;
00804             exit(1);
00805         }
00806         if(higgs_decay_mode==-1){
00807             cout<<"Could not determine decay mode, skipping event..."<<endl;
00808             return;
00809         }
00810         if(!truth_decay_mode_filter_only_higgs ||
00811              (truth_decay_mode_filter_only_higgs && primary_particle_mode==0)){
00812             if(higgs_decay_mode==1 && !truth_decay_mode_filter_analyse_ll){
00813                 return;
00814             }
00815             if(higgs_decay_mode==2 && !truth_decay_mode_filter_analyse_lh){
00816                 return;
00817             }
00818             if(higgs_decay_mode==3 && !truth_decay_mode_filter_analyse_hh){
00819                 return;
00820             }
00821         }
00822     }
00823 
00824 
00825     //* debug info */ cerr<<"before get particle vectors (raw AOD content)"<<endl;
00826 // get particle vectors (raw AOD content) //
00827     // e
00828     v_e_reco_aod = event.reco_electrons();
00829     //* debug info */ m_tools.PrintVector(v_e_reco_aod);
00830     v_e_truth_aod = m_truth_manager.getParticles_with_ID(11);
00831     v_e_truth_aod = m_truth_manager.remove_multiples(v_e_truth_aod);
00832     // mu
00833     //* debug info */ cout<<"reco_muons_name: "<<reco_muons_name<<endl;
00834     v_mu_reco_aod = event.reco_muons(reco_muons_name);
00835     //* debug info */ m_tools.PrintVector(v_mu_reco_aod,"");
00836     v_mu_truth_aod = m_truth_manager.getParticles_with_ID(13);
00837     v_mu_truth_aod = m_truth_manager.remove_multiples(v_mu_truth_aod);
00838     // tau
00839     v_taujet_reco_aod = event.reco_taujets();
00840     //* debug info */ cout<<"Before tau energy correction"<<endl;
00841     //* debug info */ m_tools.PrintVector(v_taujet_reco_aod,"v");
00842     // tau energy correction
00843     if(apply_taujet_correction){
00844         //* debug info */ cout<<"Do tau energy correction"<<endl;
00845         //m_tools.PrintVector(v_taujet_reco_aod);
00846         v_taujet_reco_aod = create_corrected_taujets(v_taujet_reco_aod);
00847         for(unsigned int m=0; m<v_taujet_reco_aod.size(); m++){
00848         //* debug info */ cout<<"pt      "<<((MyTauJet*)v_taujet_reco_aod[m])->tlv().Pt()<<endl;
00849         //* debug info */ cout<<"pt corr "<<((MyTauJet*)v_taujet_reco_aod[m])->tlv_corr().Pt()<<endl;
00850             (v_taujet_reco_aod[m])->set_tlv(
00851                 ((MyTauJet*)v_taujet_reco_aod[m])->tlv_corr());
00852         }
00853         //* debug info */ cout<<"After tau energy correction"<<endl;
00854         //* debug info */ m_tools.PrintVector(v_taujet_reco_aod);
00855     }
00856     v_taujet_reco_aod = m_tools.sort_particles(v_taujet_reco_aod);
00857     //* debug info */ m_tools.PrintVector(v_taujet_reco_aod);
00858     v_tau_truth_aod = m_truth_manager.getParticles_with_ID(15);
00859     v_tau_truth_aod = m_truth_manager.remove_multiples(v_tau_truth_aod);
00860 
00861     // jet
00862     //* debug info */ cout<<"Before getting jets"<<endl;
00863     v_jet_reco_aod = event.reco_jets();
00864     v_jet_truth_aod = event.truth_jets();
00865     v_jet_reco_aod = m_tools.sort_particles(v_jet_reco_aod);
00866     v_e_reco_aod = m_tools.sort_particles(v_e_reco_aod);
00867 
00868     // sort truth particles
00869     //* debug info */ cout<<"Before sort truth particles"<<endl;
00870     v_e_truth_aod = m_tools.sort_particles(v_e_truth_aod);
00871     v_mu_truth_aod = m_tools.sort_particles(v_mu_truth_aod);
00872     v_tau_truth_aod = m_tools.sort_particles(v_tau_truth_aod);
00873     v_jet_truth_aod = m_tools.sort_particles(v_jet_truth_aod);
00874 
00875     // ensure pt-sorting
00876     //* debug info */ cout<<"Before ensure pt-sorting"<<endl;
00877     m_tools.check_order(v_e_reco_aod);
00878     m_tools.check_order(v_mu_reco_aod);
00879     m_tools.check_order(v_taujet_reco_aod);
00880     m_tools.check_order(v_jet_reco_aod);
00881     
00882     // fill histos    
00883     //* debug info */ cout<<"Before fill_raw_aod_content_histos"<<endl;
00884     fill_raw_aod_content_histos();
00885     // missing Et
00886 //tmp    h_etmiss_aod->Fill(event.met_manager().get_missinget("MET_RefFinal").met()*GeV, weight);
00887     
00888 
00889 // Preselect Particles //
00890 //* debug info */ cerr<<"before preselection"<<endl;
00891 
00892 
00893     // e reco
00894     v_e_reco_presel = preselect_electrons(v_e_reco_aod);
00895 
00896     // e truth
00897     v_e_truth_presel = preselect_truth_electrons(v_e_truth_aod);
00898 
00899     // mu reco
00900     v_mu_reco_orm = v_mu_reco_aod;
00901     // pt eta cuts should not be nescessary, delete doubles takes the
00902     // muon with the higher pt anyway
00903     // v_mu_reco_orm = m_tools.pt_eta_cut(v_mu_reco_orm, 10.0/GeV, 99999999.0, 0.0, 2.5);
00904     // delete doubles should not be nescessary if preselection and reconstruction is ok
00905     // was needed for some 12.0.3 data where there were a lot of fake muons
00906     //* debug info */ m_tools.PrintVector(v_mu_reco_orm);
00907     int mu_nb_before;
00908     int mu_nb_after;
00909     mu_nb_before = v_mu_reco_orm.size();
00910     if(switch_mu_delete_doubles) v_mu_reco_orm = m_tools.delete_doubles(v_mu_reco_orm, 0.1);
00911     //* debug info */ m_tools.PrintVector(v_mu_reco_orm);
00912     mu_nb_after = v_mu_reco_orm.size();
00913     h_remove_double_nb_before->Fill(mu_nb_before, weight);
00914     h_remove_double_nb_doubles->Fill((mu_nb_before-mu_nb_after), weight);
00915     h_remove_double_nb_after->Fill(mu_nb_after, weight);
00916     
00917     
00918     // overlap removal with electrons (if requested)
00919     if(switch_mu_remove_overlap_e){
00920         v_mu_reco_orm = m_tools.remove_overlap(v_mu_reco_orm,v_e_reco_presel, dr_mu_remove_overlap_e);
00921     }
00922     v_mu_reco_presel = preselect_muons(v_mu_reco_orm);
00923     //* debug info */ cout<<"v_mu_reco_presel.size: "<<v_mu_reco_presel.size()<<endl;
00924     //* debug info */ m_tools.PrintVector(v_mu_reco_presel,"");
00925     
00926     // mu truth
00927     v_mu_truth_presel = preselect_truth_muons(v_mu_truth_aod);
00928 
00929 
00930     // taujet reco
00931     v_taujet_reco_orm = v_taujet_reco_aod;
00932     // overlap removal
00933     //* debug info */ cerr<<endl<<"before taujet orm "<<endl;
00934     //* debug info */ m_tools.PrintVector(v_taujet_reco_orm);
00935     if(switch_taujet_reco_remove_overlap_e){
00936         v_taujet_reco_orm = m_tools.remove_overlap(v_taujet_reco_orm,v_e_reco_presel,
00937                                            dr_taujet_reco_remove_overlap_e);
00938     }
00939     //* debug info */ cerr<<endl<<"After taujet orm electrons "<<endl;
00940     //* debug info */ m_tools.PrintVector(v_taujet_reco_orm);
00941     //* debug info */ cerr<<endl<<"Before taujet orm muons "<<endl;
00942     if(switch_taujet_reco_remove_overlap_mu){
00943         v_taujet_reco_orm = m_tools.remove_overlap(v_taujet_reco_orm,v_mu_reco_presel,
00944                                            dr_taujet_reco_remove_overlap_mu);
00945     }
00946     //* debug info */ cerr<<endl<<"After taujet orm muons "<<endl;
00947     //* debug info */ m_tools.PrintVector(v_taujet_reco_orm);
00948     v_taujet_reco_presel = preselect_taujets(v_taujet_reco_orm);
00949     //* debug info */ cerr<<endl<<"After preselect_taujets"<<endl;
00950     
00951     // tau(jet) truth
00952     vector<MyParticle*> v_tau_truth_aod_ptetacut;
00953     // eta cut, some taus with eta>x do not have decay products
00954     v_tau_truth_aod_ptetacut = m_tools.pt_eta_cut(v_tau_truth_aod, 0.0, -1., 0.0, 3.5);
00955     v_taujet_truth_all = create_truth_taujets(v_tau_truth_aod_ptetacut);
00956     v_taujet_truth_presel = preselect_truth_taujets(v_taujet_truth_all);
00957     
00958     
00959     // jet reco
00960     v_jet_reco_orm = v_jet_reco_aod;
00961     if(switch_jet_reco_remove_overlap_e){
00962         v_jet_reco_orm = m_tools.remove_overlap(v_jet_reco_orm,v_e_reco_presel,
00963                                          dr_jet_reco_remove_overlap_e);
00964     }
00965     if(switch_jet_reco_remove_overlap_mu){
00966         v_jet_reco_orm = m_tools.remove_overlap(v_jet_reco_orm,v_mu_reco_presel,
00967                                          dr_jet_reco_remove_overlap_mu);
00968     }
00969     
00971     // Investing the jets for their quark origin...
00973     // JetOriginInvest(v_jet_reco_orm);
00974 
00975     if(switch_jet_reco_remove_overlap_taujet){
00976         v_jet_reco_orm = m_tools.remove_overlap(v_jet_reco_orm,v_taujet_reco_presel,
00977                                          dr_jet_reco_remove_overlap_taujet);
00978     }
00979     // fill jet histos after overlap removal
00980     h_jet_reco_orm_nb->Fill(v_jet_reco_orm.size() , weight);
00981     for (unsigned int k=0; k<v_jet_reco_orm.size(); k++) {
00982         h_jet_reco_orm_pt->Fill((v_jet_reco_orm[k])->tlv().Pt()*GeV , weight);
00983         h_jet_reco_orm_eta->Fill((v_jet_reco_orm[k])->tlv().Eta() , weight);
00984         h_jet_reco_orm_phi->Fill((v_jet_reco_orm[k])->tlv().Phi() , weight);
00985     }
00986      // some other preselection
00987     v_jet_reco_presel = preselect_jets(v_jet_reco_orm);
00988     
00989     // jet truth
00990     v_jet_truth_orm = v_jet_truth_aod;
00991     if(switch_jet_truth_remove_overlap_e){
00992         v_jet_truth_orm = m_tools.remove_overlap(v_jet_truth_orm,v_e_truth_presel,
00993                                          dr_jet_truth_remove_overlap_e);
00994     }
00995     if(switch_jet_truth_remove_overlap_mu){
00996         v_jet_truth_orm = m_tools.remove_overlap(v_jet_truth_orm,v_mu_truth_presel,
00997                                          dr_jet_truth_remove_overlap_mu);
00998     }
00999     if(switch_jet_truth_remove_overlap_taujet){
01000         v_jet_truth_orm = m_tools.remove_overlap(v_jet_truth_orm,v_taujet_truth_presel,
01001                                          dr_jet_truth_remove_overlap_taujet);
01002     }
01003     v_jet_truth_presel = preselect_truth_jets(v_jet_truth_orm);
01004 
01005 
01007 // matching //
01009 
01010 // to be cleaned up, steffens stuff
01011     // set deltaR for matching depending on jet algorithm // 
01012     //if( (TString(m_tfile->GetName())).Contains("Cone") ){
01013     //
01014     //if( (TString(m_tfile->GetName())).Contains("Cone4") ) deltaR_jetmatching_cut = 0.25;
01015     //else                                         deltaR_jetmatching_cut = 0.5;
01016     //}
01017     //else if( (TString(m_tfile->GetName())).Contains("Kt") ){
01018     //
01019     //if( (TString(m_tfile->GetName())).Contains("Kt1") ) deltaR_jetmatching_cut = 0.1;
01020     //if( (TString(m_tfile->GetName())).Contains("Kt3") ) deltaR_jetmatching_cut = 0.2;
01021     //if( (TString(m_tfile->GetName())).Contains("Kt5") ) deltaR_jetmatching_cut = 0.3;
01022     //if( (TString(m_tfile->GetName())).Contains("Kt7") ) deltaR_jetmatching_cut = 0.5;
01023     //else                                       deltaR_jetmatching_cut = 0.7;
01024     //}else{
01025     deltaR_jetmatching_cut = 0.25;
01026     //}
01027 
01028     //* debug info */ cerr<<"before matching"<<endl;
01029     match_electrons(v_e_reco_presel, v_e_truth_presel);
01030     match_muons(v_mu_reco_presel, v_mu_truth_presel);
01031     match_taujets(v_taujet_reco_presel, v_taujet_truth_presel);
01032     match_jets(v_jet_reco_presel, v_jet_truth_presel);
01033     match_fake_taujets();
01034 
01035     // b-jet efficiency/fakerate
01036     check_bjet_performance(v_jet_reco_presel);
01037 
01038     // special muon cuts:
01039     // skip event when there are muons at all
01040     /*
01041     if (v_mu_reco_presel.size()>0){
01042         cout<<"muons inside, skip event..."<<endl;
01043         return;
01044     }
01045     //*/
01046     
01047     // skip event when there are muons in the feet region
01048     /*
01049     for (unsigned int k=0; k<v_mu_reco_presel.size(); k++) {
01050         if (((v_mu_reco_presel[k])->tlv().Phi()>-2.5 &&
01051              (v_mu_reco_presel[k])->tlv().Phi()<-1.5 )
01052             || ((v_mu_reco_presel[k])->tlv().Phi()>-1.5 &&
01053                 (v_mu_reco_presel[k])->tlv().Phi()<-0.5)){
01054                 cout<<"mouns in feet, skip event..."<<endl;
01055             return;
01056             }
01057     }
01058     //*/
01059 
01060 
01061     MyMissingEtManager missinget_in_ana;
01062     missinget_in_ana = event.met_manager();
01063 
01064 
01065     add_recalculated_missinget(&missinget_in_ana);
01066 
01067     // some histos...
01068     if(!m_dataset_info->get_AtlFastFlag()) {
01069         h_etmiss_reco_truth_dpt_vs_muondpt->Fill(
01070                 missinget_in_ana.get_missinget(met_option).met()-
01071                 missinget_in_ana.get_missinget("TruthMET_NonInt").met(),
01072                                                missinget_in_ana.get_missinget("MET_MuonBoy").met()-
01073                                                missinget_in_ana.get_missinget("TruthMET_Muons").met(),
01074                                                weight);
01075     }
01076 
01077 
01078 
01080 // cut based analysis //
01082     //* debug info */ cerr<<"before analysis"<<endl;
01083     cut_based_anlysis(missinget_in_ana);
01084 
01085     delete_truth_taujets();
01086 
01087     return;
01088 
01089 }
01090 
01091 //*****************************************************************************
01092 
01093 //::::::::::::::::::::::::::::::
01094 //:: METHOD cut_based_anlysis ::
01095 //::::::::::::::::::::::::::::::
01096 
01097 void MyHtautauAnalysis::cut_based_anlysis( const MyMissingEtManager missinget_in ){
01098 
01099     // particle vectors for the analysis //
01100     if(switch_ana_use_e_truth) v_e_ana = v_e_truth_presel;
01101     else v_e_ana = v_e_reco_presel;
01102     if(switch_ana_use_mu_truth) v_mu_ana = v_mu_truth_presel;
01103     else v_mu_ana = v_mu_reco_presel;
01104     //else v_mu_ana = v_mu_truth_matched;
01105     if(switch_ana_use_taujet_truth) v_taujet_ana = v_taujet_truth_presel;
01106     else v_taujet_ana = v_taujet_reco_presel;
01107     if(switch_ana_use_jet_truth) v_jet_ana = v_jet_truth_presel;
01108     else v_jet_ana = v_jet_reco_presel;
01109 
01110     missinget_ana = missinget_in;
01111 
01112     // needed to steer the handling of objects
01113     // in the collinear approximation
01114     // how many taujets are there
01115     if(decay_mode_string=="ll")decay_mode=1;
01116     else if(decay_mode_string=="lh")decay_mode=2;
01117     else if(decay_mode_string=="hh")decay_mode=3;
01118     else {
01119         cerr<<"Decay mode: "<<decay_mode_string<<" unknown!"<<endl;
01120         exit(1);
01121     }
01122     //decay_mode = ana_decay_mode;
01123 
01124 
01125 
01126     // print out info
01127     //m_tools.PrintVector(v_mu_ana);
01128 
01129 
01130 
01131     // fake tau filter
01132 //     // Check if fake taus exist, filter events?
01133 //     if(ev_has_fake_taus){
01134 //         //cout<<"Fake tau exists\n";
01135 //         return;
01136 //         //cout<<"NOT exited!!!\n";
01137 //     }
01138 //     else{
01139 //         //cout<<"No Fake tau\n";
01140 //         //return;
01141 //     }
01142     
01143 
01144     // Build candidates
01145     // Prepare vectors
01146     MyMissingEt met_cand;
01147     met_cand = missinget_ana.get_missinget(met_option);
01148 
01149     v_candidates_ana = build_candidates(v_e_ana,
01150                                         v_mu_ana,
01151                                         v_taujet_ana,
01152                                         v_jet_ana,
01153                                         met_cand);
01154 
01155     //* debug info */ cerr<<"Number of candidates: "<<v_candidates_ana.size()<<endl;
01156 
01157 // TODO
01158 //    h_etmiss_reco_truth_dptvsmettruth->Fill((missinget_ana.truth_missinget_NonInt())*GeV,
01159 //                                            (missinget_ana.missinget_AOD_final()
01160 //                                            - missinget_ana.truth_missinget_NonInt())*GeV, weight);
01161     //* debug info */ cerr<<"before fill_all_ana_histos(0);"<<endl;
01162     fill_all_ana_histos(v_candidates_ana, 0);
01163 
01164 
01165     //* debug info */ cerr<<"before loop over cuts"<<endl;
01166     for(int m=1; m<=cuts_total_nb; m++){
01167         //* debug info */ cout << "Apply cut: "<<cuts[m]<<endl;
01168 
01169         //* debug info */ cerr<<"before loop over candidates"<<endl;
01170         for (unsigned int i_cand=0; i_cand<v_candidates_ana.size(); i_cand++){
01171 
01172             // for storing all the event numbers at a given point
01173             //* debug info */     if(return_value>0)evt_nb_passed.push_back(m_event->event_number());
01174 
01175             int return_value;
01176             return_value=0;
01177             if((cuts[m])=="trigger"){
01178             //* debug info */ cout << "Apply trigger cut"<<endl;
01179             // offline or online trigger?
01180                 MyTrigger m_trigger = m_event->trigger();
01181             //* debug info */ cerr<<"number of trigger keys: "<<m_trigger.triggerkey(3).size()<<endl;
01182                 if(m_trigger.triggerkey(3).size() == 0 ) cut_offline_trigger(v_candidates_ana[i_cand]);
01183                 else cut_online_trigger(v_candidates_ana[i_cand]);
01184             }
01185             else if((cuts[m])=="number_emu"){
01186                 //* debug info */ cout << "Apply cut on number of reconstructed e/mu"<<endl;
01187                 cut_number_emu(v_candidates_ana[i_cand]);
01188             }
01189             else if((cuts[m])=="number_taujets"){
01190                 //* debug info */ cout << "Apply cut on number of reconstructed taujets"<<endl;
01191                 cut_number_taujets(v_candidates_ana[i_cand]);
01192             }
01193             else if((cuts[m])=="number_jets"){
01194                 //* debug info */ cout << "Apply cut on number of reconstructed jets"<<endl;
01195                 cut_number_jets(v_candidates_ana[i_cand]);
01196             }
01197             else if((cuts[m])=="etmiss"){
01198                 //* debug info */ cout << "Apply cut on missing Energy"<<endl;
01199                 cut_etmiss(v_candidates_ana[i_cand]);
01200             }
01201             else if((cuts[m])=="lepton_pt"){
01202                 //* debug info */ cout << "Apply cut on lepton pt"<<endl;
01203                 cut_lepton_pt(v_candidates_ana[i_cand]);
01204             }
01205             else if((cuts[m])=="leptons_charge"){
01206                 //* debug info */ cout << "Apply cut on lepton charge"<<endl;
01207                 cut_leptons_charge(v_candidates_ana[i_cand]);
01208             }
01209             else if((cuts[m])=="leptons_dphi"){
01210                 //* debug info */ cout << "Apply cut on lepton delta phi"<<endl;
01211                 cut_leptons_dphi(v_candidates_ana[i_cand]);
01212             }
01213             else if((cuts[m])=="leptons_dr"){
01214                 //* debug info */ cout << "Apply cut on lepton delta R"<<endl;
01215                 cut_leptons_dr(v_candidates_ana[i_cand]);
01216             }
01217             else if((cuts[m])=="collinear_approximation"){
01218                 //* debug info */ cout << "Apply cut on collinear approximation"<<endl;
01219                 cut_collinear_approximation(v_candidates_ana[i_cand]);
01220             }
01221             else if((cuts[m])=="transverse_mass"){
01222                 //* debug info */ cout << "Apply cut on transverse mass"<<endl;
01223                 cut_transverse_mass(v_candidates_ana[i_cand]);
01224             }
01225             else if((cuts[m])=="jets_pt"){
01226                 //* debug info */ cout << "Apply cut on jet pt"<<endl;
01227                  cut_jets_pt(v_candidates_ana[i_cand]);
01228             }
01229             else if((cuts[m])=="jets_hemisphere"){
01230                 //* debug info */ cout << "Apply cut on jet hemisphere"<<endl;
01231                 cut_jets_hemisphere(v_candidates_ana[i_cand]);
01232             }
01233             else if((cuts[m])=="jets_deta"){
01234                 //* debug info */ cout << "Apply cut on jets delta Eta"<<endl;
01235                 cut_jets_deta(v_candidates_ana[i_cand]);
01236             }
01237             else if((cuts[m])=="jets_dphi"){
01238                 //* debug info */ cout << "Apply cut on jet delta phi"<<endl;
01239                 cut_jets_dphi(v_candidates_ana[i_cand]);
01240             }
01241             else if((cuts[m])=="jets_mass"){
01242                 //* debug info */ cout << "Apply cut on jet pair invariant mass"<<endl;
01243                 cut_jets_mass(v_candidates_ana[i_cand]);
01244             }
01245             else if((cuts[m])=="bjet_veto"){
01246                 //* debug info */ cout << "Apply cut on jet pair invariant mass"<<endl;
01247                 cut_bjet_veto(v_candidates_ana[i_cand]);
01248             }
01249             else if((cuts[m])=="central_jet_veto"){
01250                 //* debug info */ cout << "Apply cut on central jet veto"<<endl;
01251                 cut_central_jet_veto(v_candidates_ana[i_cand]);
01252             }
01253             else if((cuts[m])=="leptons_jets_deta"){
01254                 //* debug info */ cout << "Apply cut on lepton - jet topology"<<endl;
01255                 cut_leptons_jets_deta(v_candidates_ana[i_cand]);
01256             }
01257             else if((cuts[m])=="pt_balance"){
01258                 //* debug info */ cout << "Apply cut on reconstructed higgs mass"<<endl;
01259                 cut_pt_balance(v_candidates_ana[i_cand]);
01260             }
01261             else if((cuts[m])=="mass_window"){
01262                 //* debug info */ cout << "Apply cut on reconstructed higgs mass"<<endl;
01263                 cut_mass_window(v_candidates_ana[i_cand]);
01264             }
01265             else {
01266                 cout << "ERROR: Cut "<<cuts[m]<<" unknown!"<<endl;
01267             }
01268         }
01269 
01270         fill_all_ana_histos(v_candidates_ana, m);
01271     }
01272 
01273     //* debug info */ cerr << "before fill_candidate_ntuple"<<endl;
01274     fill_candidate_ntuple(v_candidates_ana);
01275     fill_all_ana_histos(v_candidates_ana, 25);
01276     choose_candidate(v_candidates_ana);
01277 
01278     for (unsigned int j=0; j<v_candidates_ana.size(); j++){
01279         delete v_candidates_ana[j];
01280     }
01281     //delete_truth_taujets();
01282     return;
01283 }
01284 
01285 
01286 //*****************************************************************************
01287 
01288 //::::::::::::::::::::::::
01289 //:: METHOD cut_trigger ::
01290 //::::::::::::::::::::::::
01291 
01292 vector<MyVBFCandidate*> MyHtautauAnalysis::build_candidates( std::vector<MyParticle*> v_e_cand,
01293         std::vector<MyParticle*> v_mu_cand,
01294         std::vector<MyParticle*> v_tau_cand,
01295         std::vector<MyParticle*> v_jet_cand,
01296         MyMissingEt missing_et){
01297 
01298     //init vectors
01299     vector<MyVBFCandidate*> vec_candidates(0);
01300     vector<MyParticle*> v_emu_cand;
01301     v_emu_cand = m_tools.append_vector(v_e_cand, v_mu_cand);
01302     v_emu_cand = m_tools.sort_particles(v_emu_cand);
01303     m_tools.check_order(v_emu_cand);
01304     vector<MyParticlePair> vec_jet_pairs_cand;
01305     vector<MyParticlePair> vec_lepton_pairs_cand;
01306 
01307     //bool has_leptonpair;
01308     //bool has_jetpair;
01309     has_leptonpair = false;
01310     has_jetpair = false;
01311 
01312     if (decay_mode==1){
01313         if (v_emu_cand.size()>1){
01314             has_leptonpair = true;
01315                 // fill pairs
01316             for (unsigned int i=0; i<v_emu_cand.size(); i++){
01317                 for (unsigned int j=i+1; j<v_emu_cand.size(); j++){
01318                     vec_lepton_pairs_cand.push_back( MyParticlePair(v_emu_cand[i],
01319                                                                     v_emu_cand[j]) );
01320                 }
01321             }
01322         }
01323         else {
01324             has_leptonpair = false;
01325             // fill a dummy pair
01326             vec_lepton_pairs_cand.push_back( MyParticlePair());
01327         }
01328     }
01329     if (decay_mode==2){
01330         if (v_emu_cand.size()>0 && v_tau_cand.size()>0){
01331             has_leptonpair = true;
01332                 // fill pairs
01333             for (unsigned int i=0; i<v_emu_cand.size(); i++){
01334                 for (unsigned int j=0; j<v_tau_cand.size(); j++){
01335                     vec_lepton_pairs_cand.push_back( MyParticlePair(v_tau_cand[j],
01336                                                                     v_emu_cand[i]) );
01337                 }
01338             }
01339         }
01340         else {
01341             has_leptonpair = false;
01342             // fill a dummy pair
01343             vec_lepton_pairs_cand.push_back( MyParticlePair());
01344         }
01345     }
01346 
01347 
01348     if (v_jet_cand.size()>1){
01349         has_jetpair = true;
01350 
01351         if(!switch_only_highpt_jetpair){
01352             // if one wants to use all jet pair combinations
01353             for (unsigned int i=0; i<v_jet_cand.size(); i++){
01354                 for (unsigned int j=i+1; j<v_jet_cand.size(); j++){
01355                     vec_jet_pairs_cand.push_back( MyParticlePair(v_jet_cand[i], v_jet_cand[j]) );
01356                 }
01357             }
01358         }
01359         else{
01360             // if one wants to use only highest pt jet pair
01361             vec_jet_pairs_cand.push_back( MyParticlePair(v_jet_cand[0], v_jet_cand[1]) );
01362         }
01363 
01364     }
01365     else{
01366         has_jetpair = false;
01367         // fill a dummy pair
01368         vec_jet_pairs_cand.push_back( MyParticlePair() );
01369     }
01370 
01371 
01372     //build candidates
01373     for (unsigned int i=0; i<vec_jet_pairs_cand.size(); i++){
01374         for (unsigned int j=0; j<vec_lepton_pairs_cand.size(); j++){
01375             vec_candidates.push_back( new MyVBFCandidate( vec_jet_pairs_cand[i],
01376                                       vec_lepton_pairs_cand[j],
01377                                       missing_et) );
01378         }
01379     }
01380 
01381     // set the flags for all candidates
01382     for (unsigned int i=0; i<vec_candidates.size(); i++){
01383         vec_candidates[i]->set_has_tagjet_pair(has_jetpair);
01384         vec_candidates[i]->set_has_lepton_pair(has_leptonpair);
01385     }
01386 
01387     //* debug info */ cerr<<"Number of jetpairs:    "<<vec_jet_pairs_cand.size()<<endl;
01388     //* debug info */ cerr<<"Number of leptonpairs: "<<vec_lepton_pairs_cand.size()<<endl;
01389     //* debug info */ cerr<<"Number of candidates:  "<<vec_candidates.size()<<endl;
01390     return vec_candidates;
01391 
01392 }
01393 
01394 //*****************************************************************************
01395 
01396 //::::::::::::::::::::::::
01397 //:: METHOD cut_trigger ::
01398 //::::::::::::::::::::::::
01399 // cut map: 1, bit 1
01400 void MyHtautauAnalysis::cut_offline_trigger(MyVBFCandidate* candidate){
01401 
01402     bool triggerdecisionsinglemuon;
01403     bool triggerdecisionsingleelectron;
01404     bool triggerdecisiondimuon;
01405     bool triggerdecisiondielectron;
01406     bool triggerdecisionelectronmuon;
01407     bool triggerdecisionfinal;
01408 
01409     // >= 1 muon with pt>20 GeV
01410     triggerdecisionsinglemuon=false;
01411     if ((m_tools.pt_eta_cut(v_mu_ana, 20.0/GeV, -1.0, 0.0, 3.5)).size()>=1){
01412         triggerdecisionsinglemuon=true;
01413     }
01414     // >=2 muons with pt>10 GeV
01415     triggerdecisiondimuon=false;
01416     if ((m_tools.pt_eta_cut(v_mu_ana, 10.0/GeV, -1.0, 0.0, 3.5)).size()>=2){
01417         triggerdecisiondimuon=true;
01418     }
01419     // >= 1 electron with pt>25 GeV
01420     triggerdecisionsingleelectron=false;
01421     if ((m_tools.pt_eta_cut(v_e_ana, 25.0/GeV, -1.0, 0.0, 3.5)).size()>=1){
01422         triggerdecisionsingleelectron=true;
01423     }
01424     // >=2 electrons with pt>15 GeV
01425     triggerdecisiondielectron=false;
01426     if ((m_tools.pt_eta_cut(v_e_ana, 15.0/GeV, -1.0, 0.0, 3.5)).size()>=2){
01427         triggerdecisiondielectron=true;
01428     }
01429     // >= 1 electron with pt>15 GeV and 1 muon with pt>10 GeV
01430     triggerdecisionelectronmuon=false;
01431     if ((m_tools.pt_eta_cut(v_e_ana, 15.0/GeV, -1.0, 0.0, 3.5)).size()>=1
01432          && (m_tools.pt_eta_cut(v_mu_ana, 10.0/GeV, -1.0, 0.0, 3.5)).size()>=1){
01433         triggerdecisionelectronmuon=true;
01434     }
01435 
01436     triggerdecisionfinal =  triggerdecisionsingleelectron
01437                             || triggerdecisionsinglemuon
01438                             // || triggerdecisiondielectron
01439                             // || triggerdecisiondimuon
01440                             // || triggerdecisionelectronmuon
01441                             ;
01442 
01443     if (!triggerdecisionfinal){
01444         candidate->set_cut_map(candidate->get_cut_map() | 1 );
01445     }
01446     return;
01447 }
01448 
01449 //*****************************************************************************
01450 
01451 //:::::::::::::::::::::::::::::::
01452 //:: METHOD cut_online_trigger ::
01453 //:::::::::::::::::::::::::::::::
01454 // cut map: 1, bit 1
01455 void MyHtautauAnalysis::cut_online_trigger(MyVBFCandidate* candidate){
01456 
01457     MyTrigger m_trigger = m_event->trigger();
01458 
01459     event_flavour = 0;
01460     // 0 if event isnt triggered
01461     // 1 if the triggered high pt lepton is an electron
01462     // 2 if it is a muon
01463 
01464     bool triggerdecision_EF_mu20i;
01465     bool triggerdecision_EF_e25i;
01466 
01467     bool triggerdecisionsinglemuon;
01468     bool triggerdecisionsingleelectron;
01469     bool triggerdecisiondimuon;
01470     bool triggerdecisiondielectron;
01471     bool triggerdecisionelectronmuon;
01472     bool triggerdecisionfinal;
01473 
01474     double pt_e(0);
01475     double pt_mu(0);
01476 
01477 
01478     triggerdecision_EF_mu20i = m_trigger.isTriggered("EF_mu20i",3);
01479     triggerdecision_EF_e25i = m_trigger.isTriggered("EF_e25i",3);
01480 
01481 
01482     // >= 1 muon with pt>20 GeV
01483     triggerdecisionsinglemuon=false;
01484     if ((m_tools.pt_eta_cut(v_mu_ana, 20.0/GeV, -1.0, 0.0, 3.5)).size()>=1
01485         // && triggerdecision_EF_mu20i
01486         ){
01487         triggerdecisionsinglemuon=true;
01488         pt_mu = (v_mu_ana[0])->tlv().Pt();
01489     }
01490     // >=2 muons with pt>10 GeV
01491     triggerdecisiondimuon=false;
01492     if ((m_tools.pt_eta_cut(v_mu_ana, 10.0/GeV, -1.0, 0.0, 3.5)).size()>=2){
01493         triggerdecisiondimuon=true;
01494     }
01495     // >= 1 electron with pt>25 GeV
01496     triggerdecisionsingleelectron=false;
01497     if ((m_tools.pt_eta_cut(v_e_ana, 25.0/GeV, -1.0, 0.0, 3.5)).size()>=1
01498         // && triggerdecision_EF_e25i
01499         ){
01500         if(TMath::Abs((v_e_ana[0])->tlv().Et()-(v_e_ana[0])->tlv().Pt())>0.1){
01501             cerr<<"                     ET: "<< (v_e_ana[0])->tlv().Et()<<" pt: "<<(v_e_ana[0])->tlv().Pt()<<endl;
01502             //exit(1);
01503         }
01504         triggerdecisionsingleelectron=true;
01505         pt_e = (v_e_ana[0])->tlv().Pt();
01506     }
01507     // >=2 electrons with pt>15 GeV
01508     triggerdecisiondielectron=false;
01509     if ((m_tools.pt_eta_cut(v_e_ana, 15.0/GeV, -1.0, 0.0, 3.5)).size()>=2){
01510         triggerdecisiondielectron=true;
01511     }
01512     // >= 1 electron with pt>15 GeV and 1 muon with pt>10 GeV
01513     triggerdecisionelectronmuon=false;
01514     if ((m_tools.pt_eta_cut(v_e_ana, 15.0/GeV, -1.0, 0.0, 3.5)).size()>=1
01515         && (m_tools.pt_eta_cut(v_mu_ana, 10.0/GeV, -1.0, 0.0, 3.5)).size()>=1){
01516         triggerdecisionelectronmuon=true;
01517     }
01518 
01519     triggerdecisionfinal =  triggerdecisionsingleelectron
01520                          || triggerdecisionsinglemuon
01521                        //  || triggerdecisiondielectron
01522                        //  || triggerdecisiondimuon
01523                        //  || triggerdecisionelectronmuon
01524                          ;
01525 
01526     if(!triggerdecision_EF_mu20i && !triggerdecision_EF_e25i){
01527         h_trigger_online->Fill(0., weight);
01528         h_trigger_combined->Fill(0., weight);
01529         event_flavour=0;
01530     }
01531     else if(triggerdecision_EF_mu20i && !triggerdecision_EF_e25i){
01532         h_trigger_online->Fill(2., weight);
01533         if(triggerdecisionsinglemuon){
01534             h_trigger_combined->Fill(2., weight);
01535             event_flavour=2;
01536         }
01537         else{
01538             h_trigger_combined->Fill(0., weight);
01539             event_flavour=0;
01540         }
01541     }
01542     else if(!triggerdecision_EF_mu20i && triggerdecision_EF_e25i){
01543         h_trigger_online->Fill(1., weight);
01544         if(triggerdecisionsingleelectron){
01545             h_trigger_combined->Fill(1., weight);
01546             event_flavour=1;
01547         }
01548         else{
01549             h_trigger_combined->Fill(0., weight);
01550             event_flavour=0;
01551         }
01552     }
01553     else if(triggerdecision_EF_mu20i && triggerdecision_EF_e25i){
01554         if(v_mu_ana.size()>0)pt_mu = (v_mu_ana[0])->tlv().Pt();
01555         if(v_e_ana.size()>0)pt_e = (v_e_ana[0])->tlv().Et();
01556         h_trigger_online->Fill(3., weight);
01557 
01558 
01559         // soshis second version: (more reasonable)
01560         if(triggerdecisionsingleelectron && triggerdecisionsinglemuon){
01561             h_trigger_combined->Fill(3., weight);
01562             if(pt_e>pt_mu){
01563                 event_flavour=1;
01564             }
01565             else{
01566                 event_flavour=2;
01567             }
01568         }
01569         else if(triggerdecisionsingleelectron && !triggerdecisionsinglemuon){
01570             h_trigger_combined->Fill(1., weight);
01571             event_flavour=1;
01572         }
01573         else if(!triggerdecisionsingleelectron && triggerdecisionsinglemuon){
01574             h_trigger_combined->Fill(2., weight);
01575             event_flavour=2;
01576         }
01577         else{
01578             h_trigger_combined->Fill(0., weight);
01579             event_flavour=0;
01580         }
01581     // end of soshis second version
01582     }
01583 
01584     //* like soshis first version */         if(pt_mu>pt_e){
01585 //* like soshis first version */             if(triggerdecisionsinglemuon){
01586 //* like soshis first version */                 h_trigger_combined->Fill(3., weight);
01587 //* like soshis first version */                 event_flavour=2;
01588 //* like soshis first version */             }
01589 //* like soshis first version */         }
01590 //* like soshis first version */         else {
01591 //* like soshis first version */             if (triggerdecisionsingleelectron) {
01592 //* like soshis first version */                 h_trigger_combined->Fill(3., weight);
01593 //* like soshis first version */                 event_flavour=1;
01594 //* like soshis first version */             }
01595 //* like soshis first version */           }
01596 
01597 //  else if(triggerdecision_EF_mu20i && triggerdecision_EF_e25i){
01598 //      h_trigger_online->Fill(3., weight);
01599 //      if(triggerdecisionsingleelectron || triggerdecisionsinglemuon){
01600 //      h_trigger_combined->Fill(3., weight);
01601 //      if(pt_e>pt_mu){
01602 //          event_flavour=1;
01603 //      }
01604 //      else{
01605 //          event_flavour=2;
01606 //      }
01607 //  }
01608 //  else{
01609 //      h_trigger_combined->Fill(0., weight);
01610 //      event_flavour=0;
01611 //  }
01612 //}
01613 
01614     else{
01615         cout<<"Error in trigger "<<endl;
01616     }
01617 
01618     //* debug info */ cout<<"event_flavour: "<<event_flavour<<endl;
01619     //* debug info */ cout<<"pt_mu: "<<pt_mu<<endl;
01620     //* debug info */ cout<<"pt_e: "<<pt_e<<endl;
01621     //* debug info */ cout<<"triggerdecision_EF_mu20i: "<<triggerdecision_EF_mu20i<<endl;
01622     //* debug info */ cout<<"triggerdecision_EF_e25i: "<<triggerdecision_EF_e25i<<endl;
01623 
01624     if(ana_require_trigger_flavour!=-1){
01625         if(event_flavour!=ana_require_trigger_flavour){
01626             candidate->set_cut_map(candidate->get_cut_map() | 1 );
01627         }
01628     }
01629     // if(event_flavour!=2) return 0;
01630     if(event_flavour==0){
01631         candidate->set_cut_map(candidate->get_cut_map() | 1 );
01632     }
01633 
01634 
01635     if (!triggerdecisionfinal){
01636         candidate->set_cut_map(candidate->get_cut_map() | 1 );
01637     }
01638     return;
01639     //* debug info */ cerr<<"At end online trigger"<<endl;
01640 }
01641 
01642 //*****************************************************************************
01643 //:::::::::::::::::::::::::::
01644 //:: METHOD cut_number_emu ::
01645 //:::::::::::::::::::::::::::
01646 // cut map: 2, bit 2
01647 
01648 void MyHtautauAnalysis::cut_number_emu(MyVBFCandidate* candidate){
01649 
01650     // check if number of reconstructed e/mu fits
01651     // the requirements
01652     //* debug info */ cout<<"v_mu_ana.size: "<<v_mu_ana.size()<<endl;
01653     if ( ((v_mu_ana.size())<ana_mu_nb_min) ||
01654          ((v_mu_ana.size())>ana_mu_nb_max) ||
01655          ((v_e_ana.size())<ana_e_nb_min) ||
01656          ((v_e_ana.size())>ana_e_nb_max) ||
01657          ((v_mu_ana.size() + v_e_ana.size())<ana_emu_nb_min) ||
01658          ((v_mu_ana.size() + v_e_ana.size())>ana_emu_nb_max) ){
01659         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,1.) );
01660     }
01661 
01662     return;
01663 
01664 }
01665 
01666 //*****************************************************************************
01667 //:::::::::::::::::::::::::::::::
01668 //:: METHOD cut_number_taujets ::
01669 //:::::::::::::::::::::::::::::::
01670 // cut map: 4, bit 3
01671 
01672 void MyHtautauAnalysis::cut_number_taujets(MyVBFCandidate* candidate){
01673 
01674     if( (v_taujet_ana.size()<ana_taujet_nb_min) ||
01675         (v_taujet_ana.size()>ana_taujet_nb_max)){
01676         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,2.) );
01677     }
01678 
01679     return;
01680 
01681 }
01682 
01683 //*****************************************************************************
01684 //::::::::::::::::::::::::::::
01685 //:: METHOD cut_number_jets ::
01686 //::::::::::::::::::::::::::::
01687 // cut map: 8, bit 4
01688 
01689 void MyHtautauAnalysis::cut_number_jets(MyVBFCandidate* candidate){
01690 
01691     if(v_jet_ana.size()<2) {
01692         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,3.) );
01693     }
01694 
01695     return;
01696 
01697 }
01698 
01699 
01700 //*****************************************************************************
01701 //:::::::::::::::::::::::
01702 //:: METHOD cut_etmiss ::
01703 //:::::::::::::::::::::::
01704 // cut map: 16, bit 5
01705 
01706 void MyHtautauAnalysis::cut_etmiss(MyVBFCandidate* candidate){
01707 
01708     if (candidate->get_missinget().met()<min_etmiss){
01709         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,4.) );
01710     }
01711 
01712     return;
01713 
01714 }
01715 
01716 
01717 //*****************************************************************************
01718 //::::::::::::::::::::::::::
01719 //:: METHOD cut_lepton_pt ::
01720 //::::::::::::::::::::::::::
01721 // cut map: 32, bit 6
01722 
01723 void MyHtautauAnalysis::cut_lepton_pt(MyVBFCandidate* candidate){
01724 
01725     // apply a additional pt cuts
01726     v_e_ana=m_tools.pt_eta_cut(v_e_ana, min_e_pt, -1.0, -1.0, -1.0);
01727     v_mu_ana=m_tools.pt_eta_cut(v_mu_ana, min_mu_pt, -1.0, -1.0, -1.0);
01728     cerr<<"Warning! cut_lepton_pt not implemented in new design yet..."<<endl;
01729 //    if(cut_number_emu()==0){
01730 //                candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,5.) );
01731 //                //return 0;
01732 //    }
01733 //  v_taujet_ana=m_tools.pt_eta_cut(v_taujet_ana, min_taujet_pt, -1.0, 0.0, 2.5);
01734 //    if(cut_number_taujets()==0){
01735 //                candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,5.) );
01736 //                //return 0;
01737 //    }
01738     return;
01739 }
01740 
01741 //*****************************************************************************
01742 //:::::::::::::::::::::::::::::::
01743 //:: METHOD cut_leptons_charge ::
01744 //:::::::::::::::::::::::::::::::
01745 // cut map: 64, bit 7
01746 
01747 void MyHtautauAnalysis::cut_leptons_charge(MyVBFCandidate* candidate){
01748     if (!candidate->has_lepton_pair()) return;
01749 
01750     double charge1 = candidate->get_lepton_pair().get_particle1()->charge();
01751     double charge2 = candidate->get_lepton_pair().get_particle2()->charge();
01752 
01753     if((charge1*charge2) >= 0){
01754         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,6.) );
01755     }
01756 
01757     return;
01758 
01759 }
01760 
01761 //*****************************************************************************
01762 //:::::::::::::::::::::::::::::
01763 //:: METHOD cut_leptons_dphi ::
01764 //:::::::::::::::::::::::::::::
01765 // cut map: 128, bit 8
01766 
01767 void MyHtautauAnalysis::cut_leptons_dphi(MyVBFCandidate* candidate){
01768 
01769     if (!candidate->has_lepton_pair()) return;
01770 
01771     double cosdphi = TMath::Cos( candidate->get_lepton_pair().DeltaPhi() );
01772 
01773     if( cosdphi < min_leptons_cosdphi ){
01774         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,7.) );
01775     }
01776 
01777     return;
01778 
01779 }
01780 
01781 //*****************************************************************************
01782 //:::::::::::::::::::::::::::
01783 //:: METHOD cut_leptons_dr ::
01784 //:::::::::::::::::::::::::::
01785 // cut map: 256, bit 9
01786 
01787 void MyHtautauAnalysis::cut_leptons_dr(MyVBFCandidate* candidate){
01788 
01789     if (!candidate->has_lepton_pair()) return;
01790 
01791     if( candidate->get_lepton_pair().DeltaR() > max_leptons_dr ){
01792         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,8.) );
01793     }
01794 
01795     return;
01796 
01797 }
01798 
01799 //*****************************************************************************
01800 //::::::::::::::::::::::::::::::::::::::::
01801 //:: METHOD cut_collinear_approximation ::
01802 //::::::::::::::::::::::::::::::::::::::::
01803 // cut map: 512, bit 10
01804 
01805 void MyHtautauAnalysis::cut_collinear_approximation(MyVBFCandidate* candidate){
01806     if (!candidate->has_lepton_pair()) return;
01807 
01808     double x1 = candidate->get_collinear_approximation().get_x1();
01809     double x2 = candidate->get_collinear_approximation().get_x2();
01810 
01811     if(decay_mode==1 && (x1<min_lept_x || x2<min_lept_x ||
01812                          x1>max_lept_x || x2>max_lept_x ||
01813                        ((x1*x1)+(x2*x2))>max_x_squaresum)){
01814         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,9.) );
01815     }
01816     if(decay_mode==2 && (x1<min_had_x || x2<min_lept_x ||
01817                          x1>max_had_x || x2>max_lept_x ||
01818                        ((x1*x1)+(x2*x2))>max_x_squaresum)){
01819         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,9.) );
01820     }
01821 
01822     return;
01823 
01824 }
01825 
01826 
01827 //*****************************************************************************
01828 //::::::::::::::::::::::::::::::::
01829 //:: METHOD cut_transverse_mass ::
01830 //::::::::::::::::::::::::::::::::
01831 // cut map: 1024, bit 11
01832 
01833 void MyHtautauAnalysis::cut_transverse_mass(MyVBFCandidate* candidate){
01834     if (!candidate->has_lepton_pair()) return;
01835 
01836     h_lmissinget_ana_mt->Fill(get_transverse_mass(candidate)*GeV, weight);
01837     if(get_transverse_mass(candidate)>max_transverse_mass){
01838         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,10.));
01839     }
01840 
01841     return;
01842 
01843 }
01844 
01845 //*****************************************************************************
01846 //::::::::::::::::::::::::
01847 //:: METHOD cut_jets_pt ::
01848 //::::::::::::::::::::::::
01849 // cut map: 2048, bit 12
01850 
01851 void MyHtautauAnalysis::cut_jets_pt(MyVBFCandidate* candidate){
01852     if (!candidate->has_tagjet_pair()) return;
01853 
01854     double pt1, pt2;
01855     pt1 = candidate->get_tagjet_pair().get_particle1()->tlv().Pt();
01856     pt2 = candidate->get_tagjet_pair().get_particle2()->tlv().Pt();
01857 
01858     if( TMath::Max(pt1,pt2)<min_jet1_pt ||
01859         TMath::Min(pt1,pt2)<min_jet2_pt ){
01860         candidate->set_cut_map( candidate->get_cut_map() | (long int)pow(2.,11.) );
01861        }
01862 
01863     return;
01864 
01865 }
01866 
01867 //*****************************************************************************
01868 //::::::::::::::::::::::::::::::::
01869 //:: METHOD cut_jets_hemisphere ::
01870 //::::::::::::::::::::::::::::::::
01871 // cut map: 4096, bit 13
01872 
01873 void MyHtautauAnalysis::cut_jets_hemisphere(MyVBFCandidate* candidate){
01874     if (!candidate->has_tagjet_pair()) return;
01875 
01876     double eta1, eta2;
01877     eta1 = candidate->get_tagjet_pair().get_particle1()->tlv().Eta();
01878     eta2 = candidate->get_tagjet_pair().get_particle2()->tlv().Eta();
01879     if( (eta1 * eta2) >0){
01880         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,12.) );
01881     }
01882 
01883     return;
01884 
01885 }
01886 
01887 //*****************************************************************************
01888 //::::::::::::::::::::::::::
01889 //:: METHOD cut_jets_deta ::
01890 //::::::::::::::::::::::::::
01891 // cut map: 8192, bit 14
01892 
01893 void MyHtautauAnalysis::cut_jets_deta(MyVBFCandidate* candidate){
01894     if (!candidate->has_tagjet_pair()) return;
01895 
01896     if( candidate->get_tagjet_pair().AbsDeltaEta() < min_jets_deta ){
01897         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,13.) );
01898     }
01899 
01900     return;
01901 
01902 }
01903 
01904 //*****************************************************************************
01905 //::::::::::::::::::::::::::
01906 //:: METHOD cut_jets_dphi ::
01907 //::::::::::::::::::::::::::
01908 // cut map: 16384, bit 15
01909 
01910 void MyHtautauAnalysis::cut_jets_dphi(MyVBFCandidate* candidate){
01911     if (!candidate->has_tagjet_pair()) return;
01912 
01913     if( (TMath::Abs(candidate->get_tagjet_pair().DeltaPhi())) > max_jets_dphi ){
01914         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,14.) );
01915     }
01916 
01917     return;
01918 
01919 }
01920 
01921 //*****************************************************************************
01922 //::::::::::::::::::::::::::
01923 //:: METHOD cut_jets_mass ::
01924 //::::::::::::::::::::::::::
01925 // cut map: 32768, bit 16
01926 
01927 void MyHtautauAnalysis::cut_jets_mass(MyVBFCandidate* candidate){
01928     if (!candidate->has_tagjet_pair()) return;
01929 
01930     if( candidate->get_tagjet_pair().M()<min_jets_mass ){
01931         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,15.) );
01932     }
01933 
01934     return;
01935 
01936 }
01937 
01938 //*****************************************************************************
01939 //::::::::::::::::::::::::::
01940 //:: METHOD cut_bjet_veto ::
01941 //::::::::::::::::::::::::::
01942 // cut map: 65536, bit 17
01943 
01944 void MyHtautauAnalysis::cut_bjet_veto(MyVBFCandidate* candidate){
01945     // 7) B-jet veto : veto if either tagged jet has b-tag weight
01946     //                 larger than 1 (jet->weight() > 1.0)
01947     if (!candidate->has_tagjet_pair()) return;
01948 
01949     //cout<<"max_btag_weight "<<get_max_btag_weight(candidate, v_jet_ana)<<endl;
01950     if ( get_max_btag_weight(candidate, v_jet_ana) > max_bjet_weight ){
01951         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,16.) );
01952     }
01953 
01954     return;
01955 
01956 }
01957 
01958 //*****************************************************************************
01959 //:::::::::::::::::::::::::::::::::
01960 //:: METHOD cut_central_jet_veto ::
01961 //:::::::::::::::::::::::::::::::::
01962 // cut map: 131072, bit 18
01963 
01964 void MyHtautauAnalysis::cut_central_jet_veto(MyVBFCandidate* candidate){
01965     if (!candidate->has_tagjet_pair()) return;
01966 
01967     int centraljetcount = 0;
01968     double dr1(1000.);
01969     double dr2(1000.);
01970     bool centraljet         = false;
01971     bool centraljet_at_all  = false;
01972     bool cj_between_fwdjets = false;
01973     TLorentzVector tlv_central_jet;
01974     TLorentzVector tlv_fwd_jet1 = candidate->get_tagjet_pair().get_particle1()->tlv();
01975     TLorentzVector tlv_fwd_jet2 = candidate->get_tagjet_pair().get_particle2()->tlv();
01976     double fwd_jet_eta_min = TMath::Min(tlv_fwd_jet1.Eta(),tlv_fwd_jet2.Eta());
01977     double fwd_jet_eta_max = TMath::Max(tlv_fwd_jet1.Eta(),tlv_fwd_jet2.Eta());
01978     // vector of central jet candidates
01979     vector<MyParticle*> vec_centraljets;
01980     vec_centraljets = get_centraljet_candidates(v_jet_ana, candidate);
01981     vec_centraljets = m_tools.pt_eta_cut( vec_centraljets, min_cj_pt, -1.0, 0.0, max_cj_eta);
01982 
01983 
01984 
01985     for (unsigned int k=0; k<vec_centraljets.size(); k++){
01986         centraljet=false;
01987         cj_between_fwdjets=false;
01988         tlv_central_jet = (vec_centraljets[k])->tlv();
01989 
01990         // is the central jet candidate between the forward jets
01991         if ( (fwd_jet_eta_min < tlv_central_jet.Eta()) &&
01992              (fwd_jet_eta_max > tlv_central_jet.Eta()) ){
01993             cj_between_fwdjets = true;
01994         }
01995 
01996 
01997         // is it considered as a central jet?
01998         if( switch_cj_between_fwdjets && cj_between_fwdjets ){
01999             centraljet = true;
02000         }
02001         else if( !switch_cj_between_fwdjets ){
02002             centraljet = true;
02003         }
02004         else if( switch_cj_between_fwdjets && !cj_between_fwdjets ){
02005             centraljet = false;
02006         }
02007         else {
02008             cerr<<"Something wrong in cut_central_jet_veto"<<endl;
02009         }
02010 
02011 
02012 
02013         // if the central jet candidate is a central jet:
02014         if(centraljet){
02015             centraljet_at_all = true;
02016             centraljetcount++;
02017             h_centraljet_ana_pt->Fill(tlv_central_jet.Pt()*GeV, weight);
02018             h_centraljet_ana_eta->Fill(tlv_central_jet.Eta(), weight);
02019             h_centraljet_ana_phi->Fill(tlv_central_jet.Phi(), weight);
02020                         // zeppenfeld variable
02021             h_centraljet_ana_zeppvar->Fill( tlv_central_jet.Eta()
02022                     - ( tlv_fwd_jet1.Eta()+
02023                     tlv_fwd_jet2.Eta())/2, weight);
02024             dr1 = tlv_central_jet.DeltaR(tlv_fwd_jet1);
02025             dr2 = tlv_central_jet.DeltaR(tlv_fwd_jet2);
02026                 //cout<<"dr1, dr2: "<<dr1<<", "<<dr2<<endl;
02027             h_fwj_cj_dr->Fill(dr1, weight);
02028             h_fwj_cj_dr->Fill(dr2, weight);
02029         }
02030     }
02031 
02032     h_centraljet_ana_nb->Fill(centraljetcount, weight);
02033     if (centraljet_at_all==true){
02034         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,17.) );
02035     }
02036 
02037     return;
02038 
02039 }
02040 
02041 //*****************************************************************************
02042 //::::::::::::::::::::::::::::::::::
02043 //:: METHOD cut_leptons_jets_deta ::
02044 //::::::::::::::::::::::::::::::::::
02045 // cut map: 262144, bit 19
02046 
02047 void MyHtautauAnalysis::cut_leptons_jets_deta(MyVBFCandidate* candidate){
02048     if (!candidate->has_tagjet_pair()) return;
02049     if (!candidate->has_lepton_pair()) return;
02050 
02051     if( ( candidate->get_lj_DeltaEta1() < 0. ) ||
02052         ( candidate->get_lj_DeltaEta2() < 0. ) ||
02053         ( candidate->get_lj_DeltaEtaMin() < min_leptons_jets_deta ) ) {
02054 
02055         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,18.) );
02056     }
02057 
02058     return;
02059 
02060 }
02061 
02062 //*****************************************************************************
02063 //:::::::::::::::::::::::::::
02064 //:: METHOD cut_pt_balance ::
02065 //:::::::::::::::::::::::::::
02066 // cut map: 524288, bit 20
02067 
02068 void MyHtautauAnalysis::cut_pt_balance(MyVBFCandidate* candidate){
02069     if (!candidate->has_tagjet_pair()) return;
02070     if (!candidate->has_lepton_pair()) return;
02071 
02072     if( candidate->get_pt_sum().Pt() > max_pt_balance ){
02073         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,19.) );
02074     }
02075 
02076     return;
02077 
02078 }
02079 
02080 //*****************************************************************************
02081 //::::::::::::::::::::::::::::
02082 //:: METHOD cut_mass_window ::
02083 //::::::::::::::::::::::::::::
02084 // cut map: 524288, bit 21
02085 
02086 void MyHtautauAnalysis::cut_mass_window(MyVBFCandidate* candidate){
02087     if (!candidate->has_lepton_pair()) return;
02088 
02089     double hmass;
02090     hmass = candidate->get_collinear_approximation().get_M_comp_part();
02091 
02092     if( ( hmass<min_mass_window ) || ( hmass>max_mass_window ) ){
02093         candidate->set_cut_map(candidate->get_cut_map() | (long int)pow(2.,20.) );
02094     }
02095 
02096     return;
02097 
02098 }
02099 
02100 //*****************************************************************************
02101 //:::::::::::::::::::::::::::::
02102 //:: METHOD choose_candidate ::
02103 //:::::::::::::::::::::::::::::
02104 MyVBFCandidate* MyHtautauAnalysis::choose_candidate(vector<MyVBFCandidate*> v_candidates_tmp){
02105 
02106     // check if there is a candidate that survived all the cuts up to here
02107     vector<MyVBFCandidate*> v_candidates_survived;
02108     MyVBFCandidate* chosen_candidate;
02109     v_candidates_survived.clear();
02110     chosen_candidate = NULL ;
02111 
02112     for (unsigned int j=0; j<v_candidates_tmp.size(); j++){
02113         if(v_candidates_tmp[j]->get_cut_map()==0){
02114             v_candidates_survived.push_back( v_candidates_tmp[j] );
02115         }
02116     }
02117 
02118     if ( v_candidates_survived.size()>0){
02119         chosen_candidate = v_candidates_survived[0];
02120     }
02121 
02122     if ( v_candidates_survived.size()>1){
02123         cout<<"WARNING: "<<v_candidates_survived.size()<<" candidates survived all the cuts in event "
02124             <<m_event->event_number()<<", entry nb: "<<entry_nb<<endl
02125             <<"Method to choose the best one not yet implemented!"
02126             <<endl;
02127         //m_event->Print();
02128     }
02129 
02130     return chosen_candidate;
02131 
02132 }
02133 
02134 //*****************************************************************************
02135 
02136 //:::::::::::::::::::::::::::::::::
02137 //:: METHOD fill_raw_aod_content ::
02138 //:::::::::::::::::::::::::::::::::
02139 
02140 void
02141 MyHtautauAnalysis::fill_raw_aod_content_histos(void) {
02142     // electrons
02143     h_e_reco_aod_nb->Fill(v_e_reco_aod.size(), weight);
02144     for (unsigned int k=0; k<v_e_reco_aod.size(); k++) {
02145         h_e_reco_aod_pt->Fill( (v_e_reco_aod[k])->tlv().Pt() * GeV, weight);
02146         h_e_reco_aod_eta->Fill((v_e_reco_aod[k])->tlv().Eta(), weight);
02147         h_e_reco_aod_phi->Fill((v_e_reco_aod[k])->tlv().Phi(), weight);
02148         h_e_reco_aod_isolation02->Fill((v_e_reco_aod[k])->tlv().Eta(),
02149             //((((MyElectron*)(v_e_reco_aod[k]))->Et_in_cone(0))/(v_e_reco_aod[k]->tlv().Pt())),
02150             ((MyElectron*)(v_e_reco_aod[k]))->Et_in_cone(0),
02151             weight);
02152     }
02153     h_e_truth_aod_nb->Fill(v_e_truth_aod.size() , weight);
02154     for (unsigned int k=0; k<v_e_truth_aod.size(); k++) {
02155         h_e_truth_aod_pt->Fill( (v_e_truth_aod[k])->tlv().Pt() * GeV, weight);
02156         h_e_truth_aod_eta->Fill((v_e_truth_aod[k])->tlv().Eta(), weight);
02157         h_e_truth_aod_phi->Fill((v_e_truth_aod[k])->tlv().Phi(), weight);
02158     }
02159     // muons
02160     h_mu_reco_aod_nb->Fill(v_mu_reco_aod.size() , weight);
02161     for (unsigned int k=0; k<v_mu_reco_aod.size(); k++) {
02162         h_mu_reco_aod_pt->Fill( (v_mu_reco_aod[k])->tlv().Pt() * GeV, weight);
02163         h_mu_reco_aod_eta->Fill((v_mu_reco_aod[k])->tlv().Eta(), weight);
02164         h_mu_reco_aod_phi->Fill((v_mu_reco_aod[k])->tlv().Phi(), weight);
02165         h_mu_reco_aod_fitChi2OverDoF->Fill(((MyMuon*)(v_mu_reco_aod[k]))->fitChi2OverDoF(), weight);
02166     }
02167     h_mu_truth_aod_nb->Fill(v_mu_truth_aod.size() , weight);
02168     for (unsigned int k=0; k<v_mu_truth_aod.size(); k++) {
02169         h_mu_truth_aod_pt->Fill( (v_mu_truth_aod[k])->tlv().Pt() * GeV, weight);
02170         h_mu_truth_aod_eta->Fill((v_mu_truth_aod[k])->tlv().Eta(), weight);
02171         h_mu_truth_aod_phi->Fill((v_mu_truth_aod[k])->tlv().Phi(), weight);
02172     }
02173 
02174     // taujets
02175     h_taujet_reco_aod_nb->Fill(v_taujet_reco_aod.size() , weight);
02176     for (unsigned int k=0; k<v_taujet_reco_aod.size(); k++) {
02177         h_taujet_reco_aod_pt->Fill( (v_taujet_reco_aod[k])->tlv().Pt() * GeV, weight);
02178         h_taujet_reco_aod_eta->Fill((v_taujet_reco_aod[k])->tlv().Eta(), weight);
02179         h_taujet_reco_aod_phi->Fill((v_taujet_reco_aod[k])->tlv().Phi(), weight);
02180     }
02181     h_tau_truth_aod_nb->Fill(v_tau_truth_aod.size() , weight);
02182     for (unsigned int k=0; k<v_tau_truth_aod.size(); k++) {
02183         h_tau_truth_aod_pt->Fill( (v_tau_truth_aod[k])->tlv().Pt() * GeV, weight);
02184         h_tau_truth_aod_eta->Fill((v_tau_truth_aod[k])->tlv().Eta(), weight);
02185         h_tau_truth_aod_phi->Fill((v_tau_truth_aod[k])->tlv().Phi(), weight);
02186         h_tau_truth_aod_status->Fill(
02187              ((MyTruthParticle*)(v_tau_truth_aod[k]))->status(), weight);
02188     }
02189 
02190     // jets
02191     h_jet_reco_aod_nb->Fill(v_jet_reco_aod.size() , weight);
02192     for (unsigned int k=0; k<v_jet_reco_aod.size(); k++) {
02193         h_jet_reco_aod_pt->Fill( (v_jet_reco_aod[k])->tlv().Pt() * GeV, weight);
02194         h_jet_reco_aod_eta->Fill((v_jet_reco_aod[k])->tlv().Eta(), weight);
02195         h_jet_reco_aod_phi->Fill((v_jet_reco_aod[k])->tlv().Phi(), weight);
02196     }
02197     h_jet_truth_aod_nb->Fill(v_jet_truth_aod.size() , weight);
02198     for (unsigned int k=0; k<v_jet_truth_aod.size(); k++) {
02199         h_jet_truth_aod_pt->Fill( (v_jet_truth_aod[k])->tlv().Pt() * GeV, weight);
02200         h_jet_truth_aod_eta->Fill((v_jet_truth_aod[k])->tlv().Eta(), weight);
02201         h_jet_truth_aod_phi->Fill((v_jet_truth_aod[k])->tlv().Phi(), weight);
02202     }
02203     return;
02204 }
02205 
02206 //*****************************************************************************
02207 
02208 //::::::::::::::::::::::::::::::::
02209 //:: METHOD preselect_electrons ::
02210 //::::::::::::::::::::::::::::::::
02211 vector<MyParticle*>
02212 MyHtautauAnalysis::preselect_electrons(const vector<MyParticle*> v_particle) {
02213     vector<MyParticle*> tmp_v;
02214     vector<MyParticle*> tmp_v_out;
02215     // pt, eta cut
02216     tmp_v = m_tools.pt_eta_cut(v_particle, e_presel_pt_min, -1., 0.0, e_presel_eta_max);
02217 
02218     Double_t  tmp_eta;
02219 
02220     if(!m_dataset_info->get_AtlFastFlag()) {
02221         // if full simulation
02222         for (unsigned int j=0; j<tmp_v.size(); j++){
02223             if ( ((MyElectron*)tmp_v[j])->e_over_p() < e_presel_eoverp_min ) continue;
02224             if ( ((MyElectron*)tmp_v[j])->e_over_p() > e_presel_eoverp_max ) continue;
02225             if ((((int)(((MyElectron*)tmp_v[j])->is_em()))!=0) && e_presel_require_isem_0) continue;
02226             if ((((int)(((MyElectron*)tmp_v[j])->is_em())&0x3FF)!=0) && e_presel_require_isem_0x3FF) continue;
02227             // temporary for loose electrons:
02228             // if ((((int)(((MyElectron*)tmp_v[j])->is_em())&0x7)!=0) && true) continue;
02229             // tmp
02230             if ((((int)(((MyElectron*)tmp_v[j])->is_em())%16)!=0) && e_presel_require_isem_mod16_0) continue;
02231             if ((((MyElectron*)(tmp_v[j]))->NeuralNet()) < e_presel_min_NeuralNet) continue;
02232 
02233             // isolation:
02234             tmp_eta = TMath::Abs(tmp_v[j]->tlv().Eta());
02235             // if eta = 1.4..1.65 and no isolation there required:
02236             if ( e_presel_noisolation_eta14165 && tmp_eta > 1.4 && tmp_eta < 1.65 ){
02237                 // no isolation cut
02238             }
02239             else{
02240                 // aply isoaltion cuts
02241                 if (((((MyElectron*)tmp_v[j])->Et_in_cone(0))/(tmp_v[j]->tlv().Pt()))>e_presel_max_etCone02_rel) continue;
02242                 if ( (((MyElectron*)tmp_v[j])->Et_in_cone(0)) > e_presel_max_etCone02) continue;
02243             }
02244 
02245             // survived all preselection cuts:
02246             tmp_v_out.push_back(tmp_v[j]);
02247         }
02248     }
02249     else{
02250         // if fast simulation take the whole vector
02251         tmp_v_out = tmp_v;
02252     }
02253 
02254     // draw histograms
02255     h_e_reco_presel_nb->Fill(tmp_v_out.size() , weight);
02256     for (unsigned int k=0; k<tmp_v_out.size(); k++) {
02257         h_e_reco_presel_pt->Fill(tmp_v_out[k]->tlv().Pt()*GeV , weight);
02258         h_e_reco_presel_eta->Fill(tmp_v_out[k]->tlv().Eta() , weight);
02259         h_e_reco_presel_phi->Fill(tmp_v_out[k]->tlv().Phi() , weight);
02260         h_e_reco_presel_isem->Fill(((MyElectron*)tmp_v_out[k])->is_em() , weight);
02261     }
02262 
02263     return tmp_v_out;
02264 
02265 }
02266 
02267 //*****************************************************************************
02268 
02269 //::::::::::::::::::::::::::::::::::::::
02270 //:: METHOD preselect_truth_electrons ::
02271 //::::::::::::::::::::::::::::::::::::::
02272 vector<MyParticle*>
02273 MyHtautauAnalysis::preselect_truth_electrons(const vector<MyParticle*> v_particle) {
02274     vector<MyParticle*> tmp_v;
02275     vector<MyParticle*> tmp_v_out;
02276     int absmotherID;
02277     MyTruthParticle* mother;
02278 
02279     // pt, eta cut
02280 
02281     // only pt and eta cut for truth electrons
02282     tmp_v = m_tools.pt_eta_cut(v_particle, e_truth_presel_min_pt, -1.,0.0, e_truth_presel_max_eta);
02283 
02284     for (unsigned int j=0; j<tmp_v.size(); j++){
02285         mother = get_next_mother((MyTruthParticle*)tmp_v[j]);
02286         if(mother==NULL) continue;
02287         //cout<<"found mother: ";
02288         //mother->Print();
02289         //cout<<"for particle: ";
02290         //(tmp_v[j])->Print();
02291         absmotherID = TMath::Abs(mother->pdgId());
02292         if (absmotherID!=15&&absmotherID!=23&&absmotherID!=24&&absmotherID!=25) continue;
02293         // survived all preselection cuts:
02294         tmp_v_out.push_back(tmp_v[j]);
02295     }
02296 
02297     // Fill histos
02298     h_e_truth_presel_nb->Fill(tmp_v.size() , weight);
02299     for (unsigned int k=0; k<tmp_v.size(); k++) {
02300         h_e_truth_presel_pt->Fill( tmp_v[k]->tlv().Pt()*GeV , weight);
02301         h_e_truth_presel_eta->Fill(tmp_v[k]->tlv().Eta() , weight);
02302         h_e_truth_presel_phi->Fill(tmp_v[k]->tlv().Phi() , weight);
02303         h_e_truth_presel_status->Fill(((MyTruthParticle*)(tmp_v[k]))->status() , weight);
02304     }
02305 
02306     return tmp_v;
02307 
02308 }
02309 
02310 //*****************************************************************************
02311 
02312 //::::::::::::::::::::::::::::::::
02313 //:: METHOD preselect_muons ::
02314 //::::::::::::::::::::::::::::::::
02315 vector<MyParticle*>
02316 MyHtautauAnalysis::preselect_muons(const vector<MyParticle*> v_particle) {
02317     vector<MyParticle*> tmp_v;
02318     vector<MyParticle*> tmp_v_out;
02319 
02320     // pt, eta cut
02321     tmp_v = m_tools.pt_eta_cut(v_particle, mu_presel_pt_min, -1., 0.0, mu_presel_eta_max);
02322 
02323     if(!m_dataset_info->get_AtlFastFlag()) {
02324         // if full simulation
02325         for (unsigned int j=0; j<tmp_v.size(); j++){
02326 
02327             // which muons
02328             if ( (((MyMuon*)tmp_v[j])->reconstruction_flag()==1) && !mu_presel_use_combined   ) continue;
02329             if ( (((MyMuon*)tmp_v[j])->reconstruction_flag()==2) && !mu_presel_use_standalone ) continue;
02330             if ( (((MyMuon*)tmp_v[j])->reconstruction_flag()==3) && !mu_presel_use_lowpt      ) continue;
02331             if ( (((MyMuon*)tmp_v[j])->hasCombinedMuonTrackParticle()==false)
02332                  && mu_presel_require_hasCombinedMuonTrackParticle) continue;
02333 
02334             // chi2 cuts
02335             if ( (((MyMuon*)tmp_v[j])->fitChi2OverDoF()) > mu_presel_max_fitChi2OverDoF )     continue;
02336             if ( (((MyMuon*)tmp_v[j])->matchChi2OverDoF()) > mu_presel_max_matchChi2OverDoF ) continue;
02337             if ( (((MyMuon*)tmp_v[j])->matchChi2()) > mu_presel_max_matchChi2 )               continue;
02338             if ( (((MyMuon*)tmp_v[j])->matchChi2()) < mu_presel_min_matchChi2 )               continue;
02339             // isolation
02340 
02341             if ( (((MyMuon*)tmp_v[j])->Et_in_cone(3))  > mu_presel_max_etCone04     ) continue;
02342             if ( (((MyMuon*)tmp_v[j])->Et_in_cone(4))  > mu_presel_max_etCone045    ) continue;
02343             if (((((MyMuon*)tmp_v[j])->Et_in_cone(1))/
02344                     (tmp_v[j]->tlv().Pt())) > mu_presel_max_etCone02_rel ) continue;
02345 
02346             // survived all preselection cuts:
02347             tmp_v_out.push_back(tmp_v[j]);
02348         }
02349     }
02350     else{
02351         // if fast simulation take the whole vector
02352         tmp_v_out = tmp_v;
02353     }
02354 
02355 
02356     // draw histograms
02357     h_mu_reco_presel_nb->Fill(tmp_v_out.size() , weight);
02358     for (unsigned int k=0; k<tmp_v_out.size(); k++) {
02359         h_mu_reco_presel_pt->Fill(tmp_v_out[k]->tlv().Pt()*GeV , weight);
02360         h_mu_reco_presel_eta->Fill(tmp_v_out[k]->tlv().Eta() , weight);
02361         h_mu_reco_presel_phi->Fill(tmp_v_out[k]->tlv().Phi() , weight);
02362         h_mu_reco_presel_fitChi2OverDoF->Fill(((MyMuon*)(tmp_v_out[k]))->fitChi2OverDoF(), weight);
02363         h_mu_reco_presel_fitChi2OverDoFvsphi->Fill(tmp_v_out[k]->tlv().Phi(),
02364                 ((MyMuon*)(tmp_v_out[k]))->fitChi2OverDoF(), weight);
02365 
02366     }
02367 
02368     return tmp_v_out;
02369 
02370 }
02371 
02372 //*****************************************************************************
02373 
02374 //::::::::::::::::::::::::::::::::::
02375 //:: METHOD preselect_truth_muons ::
02376 //::::::::::::::::::::::::::::::::::
02377 
02378 vector<MyParticle*>
02379 MyHtautauAnalysis::preselect_truth_muons(const vector<MyParticle*> v_particle) {
02380     vector<MyParticle*> tmp_v;
02381     vector<MyParticle*> tmp_v_out;
02382     int absmotherID;
02383     MyTruthParticle* mother;
02384 
02385     // pt, eta cut
02386     tmp_v = m_tools.pt_eta_cut(v_particle, mu_truth_presel_min_pt, -1., 0.0,
02387                                mu_truth_presel_max_eta);
02388 
02389     for (unsigned int j=0; j<tmp_v.size(); j++){
02390         mother = get_next_mother((MyTruthParticle*)tmp_v[j]);
02391         if(mother==NULL) continue;
02392         //cout<<"found mother: \n";
02393         //mother->Print();
02394         //cout<<"for particle: \n";
02395         //(tmp_v[j])->Print();
02396         absmotherID = TMath::Abs(mother->pdgId());
02397         if (absmotherID!=15&&absmotherID!=23&&absmotherID!=24&&absmotherID!=25) continue;
02398         // survived all preselection cuts:
02399         tmp_v_out.push_back(tmp_v[j]);
02400     }
02401 
02402     tmp_v = tmp_v_out;
02403     
02404     // Fill histos
02405     h_mu_truth_presel_nb->Fill(tmp_v.size() , weight);
02406     for (unsigned int k=0; k<tmp_v.size(); k++) {
02407         h_mu_truth_presel_pt->Fill( tmp_v[k]->tlv().Pt()*GeV , weight);
02408         h_mu_truth_presel_eta->Fill(tmp_v[k]->tlv().Eta() , weight);
02409         h_mu_truth_presel_phi->Fill(tmp_v[k]->tlv().Phi() , weight);
02410         h_mu_truth_presel_status->Fill(((MyTruthParticle*)tmp_v[k])->status() , weight);
02411     }
02412 
02413     return tmp_v;
02414 
02415 }
02416 
02417 //*****************************************************************************
02418 
02419 //::::::::::::::::::::::::::::::
02420 //:: METHOD preselect_taujets ::
02421 //::::::::::::::::::::::::::::::
02422 
02423 vector<MyParticle*> 
02424 MyHtautauAnalysis::preselect_taujets(const vector<MyParticle*> v_particle) {
02425     vector<MyParticle*> tmp_v;
02426     vector<MyParticle*> tmp_v_out;
02427     MyParticle* matched_em = NULL;
02428     int nb_tracks(0);
02429     double e_over_p(0);
02430     double track_pt_1(0);
02431     double track_pt_2(0);
02432     double track_pt_3(0);
02433     double ethadcalib(0);
02434     double charge(0);
02435     double ethad_over_et(0);
02436 
02437     // pt, eta cut
02438     tmp_v = m_tools.pt_eta_cut(v_particle, taujet_presel_min_pt, -1., 0.0, taujet_presel_max_eta);
02439 
02440 
02441     // cuts for Full AND AtlFast data
02442     for (unsigned int j=0; j<tmp_v.size(); j++){
02443         charge = TMath::Abs((tmp_v[j])->charge());
02444         if ( (charge!=1) && taujet_presel_require_charge_1 ) continue;
02445 
02446         // survived all preselection cuts:
02447         tmp_v_out.push_back(tmp_v[j]);
02448     }
02449 
02450     tmp_v = tmp_v_out;
02451     tmp_v_out.clear();
02452 
02453 
02454     //* debug info */ m_tools.PrintVector(tmp_v);
02455     // cuts for Full data
02456     if(!m_dataset_info->get_AtlFastFlag()) {
02457         // if full simulation
02458         for (unsigned int j=0; j<tmp_v.size(); j++){
02459             nb_tracks = (((MyTauJet*)tmp_v[j])->nb_tracks());
02460             track_pt_1 = GeV*((MyTauJet*)tmp_v[j])->track_1().Pt();
02461             track_pt_2 = GeV*((MyTauJet*)tmp_v[j])->track_2().Pt();
02462             track_pt_3 = GeV*((MyTauJet*)tmp_v[j])->track_3().Pt();
02463             ethadcalib = GeV*((MyTauJet*)tmp_v[j])->ethadcalib();
02464             e_over_p = ethadcalib/(track_pt_1+track_pt_2+track_pt_3);
02465             //* debug info */ cout<<"e_over_p: "<<e_over_p<<endl;
02466             if ( ((MyTauJet*)tmp_v[j])->llh() < taujet_presel_min_llh ) continue;
02467             if ( e_over_p < taujet_presel_min_e_over_p ) continue;
02468             if ( ((nb_tracks!=1 && nb_tracks!=3)) && taujet_presel_require_nb_tracks_13 ) continue;
02469             // survived all cuts:
02470             tmp_v_out.push_back(tmp_v[j]);
02471         }
02472     }
02473     else{
02474         // if fast simulation take the whole vector
02475         tmp_v_out = tmp_v;
02476     }
02477 
02478     //* debug info */ m_tools.PrintVector(tmp_v);
02479 
02480     // some very special tau id stuff, only for Full simulation:
02481     if(!m_dataset_info->get_AtlFastFlag()) {
02482         // reset output vector
02483         tmp_v = tmp_v_out;
02484         tmp_v_out.clear();
02485 
02486         // loop again to find closest em object
02487         for (unsigned int j=0; j<tmp_v.size(); j++){
02488             matched_em = m_tools.find_matching_particle( tmp_v[j], v_e_reco_aod, 0.1, false, false );
02489             if(matched_em==NULL){
02490                 //* debug info */ cerr<<"No em matched for taujet"<<endl;
02491                 ethad_over_et=999999.;
02492             }
02493             else{
02494                 ethad_over_et = (((MyElectron*)matched_em)->ethad1())/(matched_em->tlv().Et());
02495                 //* debug info */ matched_em->Print();
02496             }
02497             if( ethad_over_et > taujet_presel_e_ethadoveret_min){
02498                 tmp_v_out.push_back(tmp_v[j]);
02499             }
02500         }
02501 
02502 
02503         // if required: loop again to check for TRT hits
02504         if( taujet_presel_require_TRTHitRatio ){
02505             // reset output vector
02506             tmp_v = tmp_v_out;
02507             tmp_v_out.clear();
02508 
02509             // loop again to check for TRT hits
02510             for (unsigned int j=0; j<tmp_v.size(); j++){
02511                 bool good_tau;
02512                 good_tau = true;
02513                 nb_tracks = 0;
02514                 double TRT_HT;
02515                 double TRT;
02516                 nb_tracks = ((MyTauJet*)tmp_v[j])->nb_tracks();
02517 
02518                 if(nb_tracks>0){
02519                     TRT_HT=(double)((MyTauJet*)tmp_v[j])->track_TRTHighThresholdHits_1();
02520                     TRT=((MyTauJet*)tmp_v[j])->track_TRTHits_1();
02521                     if(TRT>9){
02522                         if((TRT_HT/TRT)>0.2 && TMath::Abs(tmp_v[j]->tlv().Eta())<1.7){
02523                             good_tau = false;
02524                         }
02525                     }
02526                 }
02527                 if(nb_tracks>1){
02528                     TRT_HT=(double)((MyTauJet*)tmp_v[j])->track_TRTHighThresholdHits_2();
02529                     TRT=((MyTauJet*)tmp_v[j])->track_TRTHits_2();
02530                     if(TRT>9){
02531                         if((TRT_HT/TRT)>0.2 && TMath::Abs(tmp_v[j]->tlv().Eta())<1.7){
02532                             good_tau = false;
02533                         }
02534                     }
02535                 }
02536                 if(nb_tracks>2){
02537                     TRT_HT=(double)((MyTauJet*)tmp_v[j])->track_TRTHighThresholdHits_3();
02538                     TRT=((MyTauJet*)tmp_v[j])->track_TRTHits_3();
02539                     if(TRT>9){
02540                         if((TRT_HT/TRT)>0.2 && TMath::Abs(tmp_v[j]->tlv().Eta())<1.7){
02541                             good_tau = false;
02542                         }
02543                     }
02544                 }
02545                 //* debug info */ cout<<"good tau: "<<good_tau<<endl;
02546                 if(good_tau==true)tmp_v_out.push_back(tmp_v[j]);
02547             }
02548         }
02549     }
02550 
02551     // draw histograms
02552     h_taujet_reco_presel_nb->Fill(tmp_v_out.size() , weight);
02553     for (unsigned int k=0; k<tmp_v_out.size(); k++) {
02554         //* debug info */ cout<<"presel tau llh: "<<((MyTauJet*)tmp_v_out[k])->llh()<<endl;
02555         h_taujet_reco_presel_llh->Fill(((MyTauJet*)tmp_v_out[k])->llh(), weight);
02556         h_taujet_reco_presel_pt->Fill(tmp_v_out[k]->tlv().Pt() *GeV, weight);
02557         h_taujet_reco_presel_eta->Fill(tmp_v_out[k]->tlv().Eta() , weight);
02558         h_taujet_reco_presel_phi->Fill(tmp_v_out[k]->tlv().Phi() , weight);
02559     }
02560 
02561     return tmp_v_out;
02562 
02563 }
02564 
02565 //*****************************************************************************
02566 
02567 //::::::::::::::::::::::::::::::::::::
02568 //:: METHOD preselect_truth_taujets ::
02569 //::::::::::::::::::::::::::::::::::::
02570 vector<MyParticle*> 
02571 MyHtautauAnalysis::preselect_truth_taujets(const vector<MyParticle*> v_particle) {
02572     vector<MyParticle*> tmp_v;
02573 
02574     // pt, eta cut
02575     tmp_v = m_tools.pt_eta_cut(v_particle, taujet_truth_presel_min_pt, -1., 0.0,
02576                                taujet_truth_presel_max_eta);
02577 
02578     // Fill histos
02579     h_taujet_truth_presel_nb->Fill(tmp_v.size() , weight);
02580     for (unsigned int k=0; k<tmp_v.size(); k++) {
02581         h_taujet_truth_presel_pt->Fill( tmp_v[k]->tlv().Pt()*GeV , weight);
02582         h_taujet_truth_presel_eta->Fill(tmp_v[k]->tlv().Eta() , weight);
02583         h_taujet_truth_presel_phi->Fill(tmp_v[k]->tlv().Phi() , weight);
02584     }
02585 
02586     return tmp_v;
02587 
02588 }
02589 
02590 //*****************************************************************************
02591 
02592 //:::::::::::::::::::::::::::
02593 //:: METHOD preselect_jets ::
02594 //:::::::::::::::::::::::::::
02595 vector<MyParticle*> 
02596 MyHtautauAnalysis::preselect_jets(const vector<MyParticle*> v_particle) {
02597     vector<MyParticle*> tmp_v;
02598 
02599     // pt, eta cut
02600     //tmp_v = m_tools.Et_eta_cut(v_particle, jet_presel_min_pt, -1., 0.0, jet_presel_max_eta);
02601     tmp_v = m_tools.pt_eta_cut(v_particle, jet_presel_min_pt, -1., 0.0, jet_presel_max_eta);
02602 
02603     // draw histograms
02604     h_jet_reco_presel_nb->Fill(tmp_v.size() , weight);
02605     for (unsigned int k=0; k<tmp_v.size(); k++) {
02606         h_jet_reco_presel_pt->Fill(tmp_v[k]->tlv().Pt() *GeV , weight);
02607         h_jet_reco_presel_eta->Fill(tmp_v[k]->tlv().Eta() , weight);
02608         h_jet_reco_presel_phi->Fill(tmp_v[k]->tlv().Phi() , weight);
02609     }
02610 
02611     return tmp_v;
02612 
02613 }
02614 
02615 //*****************************************************************************
02616 
02617 //:::::::::::::::::::::::::::::::::
02618 //:: METHOD preselect_truth_jets ::
02619 //:::::::::::::::::::::::::::::::::
02620 vector<MyParticle*> 
02621 MyHtautauAnalysis::preselect_truth_jets(const vector<MyParticle*> v_particle) {
02622     vector<MyParticle*> tmp_v;
02623 
02624     // pt, eta cut
02625     tmp_v = m_tools.pt_eta_cut(v_particle, jet_truth_presel_min_pt, -1., 0.0,
02626                                jet_truth_presel_max_eta);
02627 
02628     // Fill histos
02629     h_jet_truth_presel_nb->Fill(tmp_v.size() , weight);
02630     for (unsigned int k=0; k<tmp_v.size(); k++) {
02631         h_jet_truth_presel_pt->Fill( tmp_v[k]->tlv().Pt()*GeV , weight);
02632         h_jet_truth_presel_eta->Fill(tmp_v[k]->tlv().Eta() , weight);
02633         h_jet_truth_presel_phi->Fill(tmp_v[k]->tlv().Phi() , weight);
02634     }
02635 
02636     return tmp_v;
02637 
02638 }
02639 
02640 //*****************************************************************************
02641 
02642 //:::::::::::::::::::::::::::::::::::::::::::
02643 //:: METHOD visible_part_of_decay_products ::
02644 //:::::::::::::::::::::::::::::::::::::::::::
02645 
02646 MyParticle 
02647 MyHtautauAnalysis::visible_part_of_decay_products(MyTruthParticle* part_in) {
02648     
02649     MyTruthParticle* part_in_li;
02650     vector<MyTruthParticle*> v_children;
02651     int tmp_pdgid;
02652     TLorentzVector tlv_tmp;
02653     double charge_tmp;
02654     MyParticle visible_part;
02655 
02656     charge_tmp = part_in->charge();
02657 
02658     part_in_li = m_truth_manager.get_last_instance(part_in);
02659     v_children  = m_truth_manager.get_children(part_in_li);
02660     //cout<<endl;
02661 //     for (unsigned int l=0; l<v_children.size(); l++){
02662 //         tmp_pdgid = TMath::Abs(v_children[l]->pdgId());
02663 //         //cout<<"tauchild ID: "<<v_children[l]->pdgId()<<endl;
02664 //         if (tmp_pdgid == 12 || tmp_pdgid == 14 ||
02665 //             tmp_pdgid == 16 || tmp_pdgid == 18 ){
02666 //             // neutrino, cut away...
02667 //         }
02668 //         else{
02669 //             // visible energy, add up 4-vector
02670 //         tlv_tmp += v_children[l]->tlv();
02671 //         charge_tmp +=  v_children[l]->charge();
02672 //         }
02673 //     }
02674     tlv_tmp = part_in->tlv();
02675 
02676     for (unsigned int l=0; l<v_children.size(); l++){
02677         tmp_pdgid = TMath::Abs(v_children[l]->pdgId());
02678         //cout<<"tauchild ID: "<<v_children[l]->pdgId()<<endl;
02679         if (tmp_pdgid == 12 || tmp_pdgid == 14 ||
02680             tmp_pdgid == 16 || tmp_pdgid == 18 ){
02681             // neutrino, cut away...
02682         tlv_tmp -= v_children[l]->tlv();
02683         }
02684     }
02685     visible_part = MyParticle(tlv_tmp, 0, charge_tmp, part_in->index(), "truth_taujet_visible");
02686     return visible_part;
02687 }
02688 
02689 //*****************************************************************************
02690 
02691 //:::::::::::::::::::::::::::::::::
02692 //:: METHOD create_truth_taujets ::
02693 //:::::::::::::::::::::::::::::::::
02694 
02695 vector<MyParticle*>
02696 MyHtautauAnalysis::create_truth_taujets(vector<MyParticle*> v_particle) {
02697     
02698     MyParticle mp;
02699     
02700     //delete_truth_taujets();
02701     for (unsigned int i=0; i<v_particle.size(); i++){
02702     //cout<<"taudecaymode: "<<tau_decay_mode((MyTruthParticle*)(v_particle[i]))<<endl;
02703         if(tau_decay_mode((MyTruthParticle*)(v_particle[i]))>2){
02704         mp = visible_part_of_decay_products((MyTruthParticle*)(v_particle[i]));
02705         v_taujet_truth.push_back(
02706             new MyParticle(mp.tlv(), mp.matchingflag(),
02707                  mp.charge(), mp.index(), mp.type())
02708             );
02709         }
02710     }
02711     return v_taujet_truth;
02712 }
02713 
02714 //*****************************************************************************
02715 
02716 //:::::::::::::::::::::::::::::::::::::
02717 //:: METHOD create_corrected_taujets ::
02718 //:::::::::::::::::::::::::::::::::::::
02719 
02720 vector<MyParticle*>
02721 MyHtautauAnalysis::create_corrected_taujets(vector<MyParticle*> v_particle) {
02722     
02723     vector<MyParticle*> new_vec;
02724     
02725     for (unsigned int i=0; i<v_particle.size(); i++){
02726         MyParticle* tau_clone;
02727         tau_clone = ((MyTauJet*)v_particle[i])->Clone();
02728         new_vec.push_back(tau_clone);
02729         v_garbage.push_back(tau_clone);
02730     }
02731     return new_vec;
02732 }
02733 
02734 //*****************************************************************************
02735 
02736 //:::::::::::::::::::::::::::::::::
02737 //:: METHOD delete_truth_taujets ::
02738 //:::::::::::::::::::::::::::::::::
02739 
02740 void
02741 MyHtautauAnalysis::delete_truth_taujets(void) {
02742     
02743     for (unsigned int i=0; i<v_taujet_truth.size(); i++){
02744         delete v_taujet_truth[i];
02745     }
02746     //cout<<"v_garbage.size() "<<v_garbage.size()<<endl;
02747     for (unsigned int i=0; i<v_garbage.size(); i++){
02748         delete v_garbage[i];
02749     }
02750     
02751     v_garbage.clear();
02752 
02753     v_taujet_truth.clear();
02754     return;
02755 }
02756 
02757 //*****************************************************************************
02758 
02759 //::::::::::::::::::::::::::::
02760 //:: METHOD match_electrons ::
02761 //::::::::::::::::::::::::::::
02762 
02763 void 
02764 MyHtautauAnalysis::match_electrons(
02765     vector<MyParticle*> v_e_reco, vector<MyParticle*> v_e_truth) {
02766     
02767     int nb_matched(0);
02768     int nb_notmatched(0);
02769     int nb_fakes(0);
02770     
02771     // loop over truth electrons and search for a matching reconstructed electron
02772     for (unsigned int k=0; k<v_e_truth.size(); k++) {
02773         MyParticle* tmp_electron = NULL; 
02774 
02775         tmp_electron = m_tools.find_matching_particle( v_e_truth[k],
02776                 v_e_reco );
02777         if(tmp_electron!=NULL){
02778             nb_matched++;
02779             h_e_reco_matched_pt->Fill(tmp_electron->tlv().Pt()*GeV , weight);
02780             h_e_reco_matched_eta->Fill(tmp_electron->tlv().Eta() , weight);
02781             h_e_reco_matched_phi->Fill(tmp_electron->tlv().Phi() , weight);
02782             h_e_truth_matched_pt->Fill(v_e_truth[k]->tlv().Pt()*GeV , weight);
02783             h_e_truth_matched_eta->Fill(v_e_truth[k]->tlv().Eta() , weight);
02784             h_e_truth_matched_phi->Fill(v_e_truth[k]->tlv().Phi() , weight);
02785             h_e_reco_matched_isem->Fill(((MyElectron*)tmp_electron)->is_em() , weight);
02786             h_e_reco_matched_NN->Fill(((MyElectron*)tmp_electron)->NeuralNet() , weight);
02787             
02788             h_e_matched_dpt->Fill((tmp_electron->tlv().Pt()-v_e_truth[k]->tlv().Pt())*GeV , weight);
02789             h_e_matched_deta->Fill(tmp_electron->tlv().Eta()-v_e_truth[k]->tlv().Eta() , weight);
02790             h_e_matched_dphi->Fill(tmp_electron->tlv().DeltaPhi(v_e_truth[k]->tlv()), weight);
02791             h_e_matched_dr->Fill(tmp_electron->tlv().DeltaR(v_e_truth[k]->tlv()), weight);
02792             h_e_matched_resolution_pt->Fill(v_e_truth[k]->tlv().Pt()*GeV,
02793                 (tmp_electron->tlv().Pt()-v_e_truth[k]->tlv().Pt())/(v_e_truth[k]->tlv().Pt()),
02794                 weight);
02795             h_e_matched_resolution_eta->Fill(v_e_truth[k]->tlv().Eta(),
02796                 (tmp_electron->tlv().Eta()-v_e_truth[k]->tlv().Eta())/(v_e_truth[k]->tlv().Eta()),
02797                 weight);
02798             h_e_matched_resolution_phi->Fill(v_e_truth[k]->tlv().Phi(),
02799                 (tmp_electron->tlv().DeltaPhi(v_e_truth[k]->tlv()))/(v_e_truth[k]->tlv().Phi()),
02800                 weight);
02801         }
02802         else{ // not matched electron
02803             nb_notmatched++;
02804             h_e_truth_notmatched_pt->Fill(v_e_truth[k]->tlv().Pt() *GeV , weight);
02805             h_e_truth_notmatched_eta->Fill(v_e_truth[k]->tlv().Eta() , weight);
02806             h_e_truth_notmatched_phi->Fill(v_e_truth[k]->tlv().Phi() , weight);
02807         }
02808     }
02809     h_e_reco_matched_nb->Fill(nb_matched, weight);
02810     h_e_truth_notmatched_nb->Fill(nb_notmatched, weight);
02811     
02812     // determine fake electrons
02813     for (unsigned int k=0; k<v_e_reco.size(); k++) {
02814         MyParticle* tmp_electron = NULL;
02815         tmp_electron = m_tools.find_matching_particle(v_e_reco[k],
02816                 v_e_truth);
02817         if (tmp_electron==NULL) { //electron is faked
02818             nb_fakes++;
02819             h_e_reco_fake_pt->Fill(v_e_reco[k]->tlv().Pt()*GeV , weight);
02820             h_e_reco_fake_eta->Fill(v_e_reco[k]->tlv().Eta() , weight);
02821             h_e_reco_fake_phi->Fill(v_e_reco[k]->tlv().Phi() , weight);
02822             h_e_reco_fake_isem->Fill(((MyElectron*)v_e_reco[k])->is_em() , weight);
02823         }
02824     }
02825     h_e_reco_fake_nb->Fill(nb_fakes, weight);
02826     m_tools.clear_vector(v_e_reco);
02827     m_tools.clear_vector(v_e_truth);
02828     return;
02829 }
02830 
02831 //*****************************************************************************
02832 
02833 //::::::::::::::::::::::::
02834 //:: METHOD match_muons ::
02835 //::::::::::::::::::::::::
02836 
02837 void 
02838 MyHtautauAnalysis::match_muons(
02839     vector<MyParticle*> v_mu_reco, vector<MyParticle*> v_mu_truth) {
02840     
02841     v_mu_reco_matched.clear();
02842     v_mu_truth_matched.clear();
02843     int nb_matched(0);
02844     int nb_notmatched(0);
02845     int nb_fakes(0);
02846     
02847     // loop over truth muons and search for a matching reconstructed muon
02848     for (unsigned int k=0; k<v_mu_truth.size(); k++) {
02849         MyParticle* tmp_muon = NULL; 
02850 
02851         tmp_muon = m_tools.find_matching_particle( v_mu_truth[k],
02852                 v_mu_reco );
02853         if(tmp_muon!=NULL){
02854             nb_matched++;
02855             v_mu_reco_matched.push_back(tmp_muon);
02856             v_mu_truth_matched.push_back(v_mu_truth[k]);
02857             
02858             h_mu_reco_matched_pt->Fill(tmp_muon->tlv().Pt() *GeV , weight);
02859             h_mu_reco_matched_eta->Fill(tmp_muon->tlv().Eta() , weight);
02860             h_mu_reco_matched_phi->Fill(tmp_muon->tlv().Phi() , weight);
02861             h_mu_truth_matched_pt->Fill(v_mu_truth[k]->tlv().Pt() *GeV , weight);
02862             h_mu_truth_matched_eta->Fill(v_mu_truth[k]->tlv().Eta() , weight);
02863             h_mu_truth_matched_phi->Fill(v_mu_truth[k]->tlv().Phi() , weight);
02864             h_mu_reco_matched_fitChi2OverDoF->Fill(((MyMuon*)(tmp_muon))->fitChi2OverDoF() , weight);
02865             h_mu_matched_dpt->Fill((tmp_muon->tlv().Pt()-v_mu_truth[k]->tlv().Pt())*GeV , weight);
02866             h_mu_matched_deta->Fill(tmp_muon->tlv().Eta()-v_mu_truth[k]->tlv().Eta() , weight);
02867             h_mu_matched_dphi->Fill(tmp_muon->tlv().DeltaPhi(v_mu_truth[k]->tlv()) , weight);
02868             h_mu_matched_dr->Fill(tmp_muon->tlv().DeltaR(v_mu_truth[k]->tlv()) , weight);
02869             h_mu_matched_resolution_pt->Fill(v_mu_truth[k]->tlv().Pt()*GeV,
02870                (tmp_muon->tlv().Pt()-v_mu_truth[k]->tlv().Pt())/(v_mu_truth[k]->tlv().Pt()),weight);
02871             h_mu_matched_resolution_ptvsphi->Fill(v_mu_truth[k]->tlv().Phi(),
02872                 TMath::Abs(tmp_muon->tlv().Pt()-v_mu_truth[k]->tlv().Pt())*GeV/
02873                            (v_mu_truth[k]->tlv().Pt()) , weight);
02874             h_mu_matched_resolution_ptvseta->Fill(v_mu_truth[k]->tlv().Eta(),
02875                 (tmp_muon->tlv().Pt()-v_mu_truth[k]->tlv().Pt())*GeV/(v_mu_truth[k]->tlv().Pt()),
02876                 weight);
02877             h_mu_matched_resolution_eta->Fill(v_mu_truth[k]->tlv().Eta(),
02878                 (tmp_muon->tlv().Eta()-v_mu_truth[k]->tlv().Eta())/(v_mu_truth[k]->tlv().Eta()) ,
02879                 weight);
02880             h_mu_matched_resolution_phi->Fill(v_mu_truth[k]->tlv().Phi(),
02881                 (tmp_muon->tlv().DeltaPhi(v_mu_truth[k]->tlv()))/(v_mu_truth[k]->tlv().Phi()) ,
02882                 weight);
02883         }
02884         else{ // not matched muon
02885             nb_notmatched++;
02886             h_mu_truth_notmatched_pt->Fill(v_mu_truth[k]->tlv().Pt()*GeV , weight);
02887             h_mu_truth_notmatched_eta->Fill(v_mu_truth[k]->tlv().Eta() , weight);
02888             h_mu_truth_notmatched_phi->Fill(v_mu_truth[k]->tlv().Phi() , weight);
02889         }
02890     }
02891     h_mu_reco_matched_nb->Fill(nb_matched, weight);
02892     h_mu_truth_notmatched_nb->Fill(nb_notmatched, weight);
02893     // determine fake muons
02894     for (unsigned int k=0; k<v_mu_reco.size(); k++) {
02895         MyParticle* tmp_muon = NULL;
02896         tmp_muon = m_tools.find_matching_particle(v_mu_reco[k],
02897                 v_mu_truth);
02898         if (tmp_muon==NULL) { //muon is faked
02899             nb_fakes++;
02900             h_mu_reco_fake_pt->Fill(v_mu_reco[k]->tlv().Pt()*GeV , weight);
02901             h_mu_reco_fake_eta->Fill(v_mu_reco[k]->tlv().Eta() , weight);
02902             h_mu_reco_fake_phi->Fill(v_mu_reco[k]->tlv().Phi() , weight);
02903             h_mu_reco_fake_fitChi2OverDoF->Fill(((MyMuon*)(v_mu_reco[k]))->fitChi2OverDoF(),weight);
02904 
02905         }
02906     }
02907     h_mu_reco_fake_nb->Fill(nb_fakes, weight);
02908     m_tools.clear_vector(v_mu_reco);
02909     m_tools.clear_vector(v_mu_truth);
02910     return;
02911 }
02912 
02913 //*****************************************************************************
02914 
02915 //::::::::::::::::::::::::::
02916 //:: METHOD match_taujets ::
02917 //::::::::::::::::::::::::::
02918 
02919 void 
02920 MyHtautauAnalysis::match_taujets(
02921     vector<MyParticle*> v_taujet_reco, vector<MyParticle*> v_taujet_truth) {
02922     
02923     int nb_matched(0);
02924     int nb_notmatched(0);
02925     int nb_fakes(0);
02926     
02927     // loop over truth taujets and search for a matching reconstructed taujet
02928     for (unsigned int k=0; k<v_taujet_truth.size(); k++) {
02929         MyParticle* tmp_taujet = NULL; 
02930         MyTruthParticle* tmp_truth_part;
02931         tmp_truth_part = ((MyTruthParticle*)(v_taujet_truth[k]));
02932         
02933         tmp_taujet = m_tools.find_matching_particle( v_taujet_truth[k],
02934                 v_taujet_reco );
02935                 
02936         if(tmp_taujet!=NULL){
02937             nb_matched++;
02938 // Test charge
02939 //            if(1){
02940 //                cout<<"charge  reco: "<<tmp_taujet->charge()<<"\n";
02941 //                cout<<"charge truth: "<<v_taujet_truth[k]->charge()<<"\n";
02942 //                if(tmp_taujet->charge()==v_taujet_truth[k]->charge())cout<<"charge equal\n";
02943 //                if(tmp_taujet->charge()!=v_taujet_truth[k]->charge())cout<<"charge different\n";
02944 //            }
02945             h_taujet_reco_matched_pt->Fill(tmp_taujet->tlv().Pt()*GeV , weight);
02946             h_taujet_reco_matched_eta->Fill(tmp_taujet->tlv().Eta() , weight);
02947             h_taujet_reco_matched_phi->Fill(tmp_taujet->tlv().Phi() , weight);
02948             h_taujet_truth_matched_pt->Fill(v_taujet_truth[k]->tlv().Pt()*GeV , weight);
02949             h_taujet_truth_matched_eta->Fill(v_taujet_truth[k]->tlv().Eta() , weight);
02950             h_taujet_truth_matched_phi->Fill(v_taujet_truth[k]->tlv().Phi() , weight);
02951             
02952             h_taujet_matched_dpt->Fill((tmp_taujet->tlv().Pt()-v_taujet_truth[k]->tlv().Pt())*GeV , weight);
02953             h_taujet_matched_deta->Fill(tmp_taujet->tlv().Eta()-v_taujet_truth[k]->tlv().Eta() , weight);
02954             h_taujet_matched_dphi->Fill(tmp_taujet->tlv().DeltaPhi(v_taujet_truth[k]->tlv()) , weight);
02955             h_taujet_matched_dr->Fill(tmp_taujet->tlv().DeltaR(v_taujet_truth[k]->tlv()) , weight);
02956             h_taujet_matched_resolution_pt->Fill(v_taujet_truth[k]->tlv().Pt()*GeV,
02957                 (tmp_taujet->tlv().Pt()-v_taujet_truth[k]->tlv().Pt())/
02958                 (v_taujet_truth[k]->tlv().Pt()) , weight);
02959             h_taujet_matched_resolution_eta->Fill(v_taujet_truth[k]->tlv().Eta(),
02960                 (tmp_taujet->tlv().Eta()-v_taujet_truth[k]->tlv().Eta())/
02961                 (v_taujet_truth[k]->tlv().Eta()) , weight);
02962             h_taujet_matched_resolution_phi->Fill(v_taujet_truth[k]->tlv().Phi(),
02963                 (tmp_taujet->tlv().DeltaPhi(v_taujet_truth[k]->tlv()))/
02964                 (v_taujet_truth[k]->tlv().Phi()) , weight);
02965         }
02966         else{ // not matched taujet
02967             nb_notmatched++;
02968             h_taujet_truth_notmatched_pt->Fill(v_taujet_truth[k]->tlv().Pt()*GeV , weight);
02969             h_taujet_truth_notmatched_eta->Fill(v_taujet_truth[k]->tlv().Eta() , weight);
02970             h_taujet_truth_notmatched_phi->Fill(v_taujet_truth[k]->tlv().Phi() , weight);
02971         }
02972     }
02973     h_taujet_reco_matched_nb->Fill(nb_matched, weight);
02974     h_taujet_truth_notmatched_nb->Fill(nb_notmatched, weight);
02975     
02976     // determine fake taujets
02977     v_taujet_reco_fake.clear();
02978     for (unsigned int k=0; k<v_taujet_reco.size(); k++) {
02979         MyParticle* tmp_taujet = NULL;
02980         tmp_taujet = m_tools.find_matching_particle(v_taujet_reco[k],
02981                 v_taujet_truth);
02982         if (tmp_taujet==NULL) { //taujet is faked
02983             nb_fakes++;
02984             v_taujet_reco_fake.push_back(v_taujet_reco[k]);
02985             h_taujet_reco_fake_pt->Fill(v_taujet_reco[k]->tlv().Pt()*GeV , weight);
02986             h_taujet_reco_fake_eta->Fill(v_taujet_reco[k]->tlv().Eta() , weight);
02987             h_taujet_reco_fake_phi->Fill(v_taujet_reco[k]->tlv().Phi() , weight);
02988         }
02989     }
02990     h_taujet_reco_fake_nb->Fill(nb_fakes, weight);
02991     m_tools.clear_vector(v_taujet_reco);
02992     m_tools.clear_vector(v_taujet_truth);
02993     if(nb_fakes>0) ev_has_fake_taus = true;
02994     return;
02995 }
02996 
02997 //*****************************************************************************
02998 
02999 //:::::::::::::::::::::::
03000 //:: METHOD match_jets ::
03001 //:::::::::::::::::::::::
03002 
03003 void 
03004 MyHtautauAnalysis::match_jets(
03005     vector<MyParticle*> v_jet_reco, vector<MyParticle*> v_jet_truth) {
03006     
03007     int nb_matched(0);
03008     int nb_notmatched(0);
03009     int nb_fakes(0);
03010     
03011     // loop over truth jets and search for a matching reconstructed jet
03012     nb_matched = 0;
03013     nb_notmatched = 0;
03014     for (unsigned int k=0; k<v_jet_truth.size(); k++) {
03015         MyParticle* tmp_jet = NULL; 
03016         MyTruthParticle* tmp_truth_part;
03017         tmp_truth_part = ((MyTruthParticle*)(v_jet_truth[k]));
03018         
03019         tmp_jet = m_tools.find_matching_particle( v_jet_truth[k],
03020                 v_jet_reco, deltaR_jetmatching_cut );
03021         if(tmp_jet!=NULL){
03022             nb_matched++;
03023             h_jet_reco_matched_pt->Fill(tmp_jet->tlv().Pt() *GeV , weight);
03024             h_jet_reco_matched_eta->Fill(tmp_jet->tlv().Eta() , weight);
03025             h_jet_reco_matched_phi->Fill(tmp_jet->tlv().Phi() , weight);
03026             h_jet_truth_matched_pt->Fill(v_jet_truth[k]->tlv().Pt()*GeV , weight);
03027             h_jet_truth_matched_eta->Fill(v_jet_truth[k]->tlv().Eta() , weight);
03028             h_jet_truth_matched_phi->Fill(v_jet_truth[k]->tlv().Phi() , weight);
03029             
03030             h_jet_matched_dpt->Fill((tmp_jet->tlv().Pt()-v_jet_truth[k]->tlv().Pt())*GeV , weight);
03031             h_jet_matched_deta->Fill(tmp_jet->tlv().Eta()-v_jet_truth[k]->tlv().Eta() , weight);
03032             h_jet_matched_dphi->Fill(tmp_jet->tlv().DeltaPhi(v_jet_truth[k]->tlv()) , weight);
03033             h_jet_matched_dr->Fill(tmp_jet->tlv().DeltaR(v_jet_truth[k]->tlv()) , weight);
03034             h_jet_matched_resolution_pt->Fill(v_jet_truth[k]->tlv().Pt()*GeV,
03035                 (tmp_jet->tlv().Pt()-v_jet_truth[k]->tlv().Pt())/(v_jet_truth[k]->tlv().Pt()) ,
03036                 weight);
03037             h_jet_matched_resolution_eta->Fill(v_jet_truth[k]->tlv().Eta(),
03038                 (tmp_jet->tlv().Eta()-v_jet_truth[k]->tlv().Eta())/(v_jet_truth[k]->tlv().Eta()) ,
03039                 weight);
03040             h_jet_matched_resolution_phi->Fill(v_jet_truth[k]->tlv().Phi(),
03041                 (tmp_jet->tlv().DeltaPhi(v_jet_truth[k]->tlv()))/(v_jet_truth[k]->tlv().Phi()) ,
03042                 weight);
03043         }
03044         else{ // not matched jet
03045             nb_notmatched++;
03046             h_jet_truth_notmatched_pt->Fill(v_jet_truth[k]->tlv().Pt()*GeV , weight);
03047             h_jet_truth_notmatched_eta->Fill(v_jet_truth[k]->tlv().Eta() , weight);
03048             h_jet_truth_notmatched_phi->Fill(v_jet_truth[k]->tlv().Phi() , weight);
03049         }
03050     }
03051     h_jet_reco_matched_nb->Fill(nb_matched, weight);
03052     h_jet_truth_notmatched_nb->Fill(nb_notmatched, weight);
03053     
03054     // determine fake jets
03055     nb_fakes = 0;
03056     for (unsigned int k=0; k<v_jet_reco.size(); k++) {
03057         MyParticle* tmp_jet = NULL;
03058         tmp_jet = m_tools.find_matching_particle(v_jet_reco[k],
03059                 v_jet_truth, deltaR_jetmatching_cut);
03060         if (tmp_jet==NULL) { //jet is faked
03061             nb_fakes++;
03062             h_jet_reco_fake_pt->Fill(v_jet_reco[k]->tlv().Pt()*GeV , weight);
03063             h_jet_reco_fake_eta->Fill(v_jet_reco[k]->tlv().Eta() , weight);
03064             h_jet_reco_fake_phi->Fill(v_jet_reco[k]->tlv().Phi() , weight);
03065         }
03066     }
03067     h_jet_reco_fake_nb->Fill(nb_fakes, weight);
03068     m_tools.clear_vector(v_jet_reco);
03069     m_tools.clear_vector(v_jet_truth);
03070     return;
03071 }
03072 
03073 //*****************************************************************************
03074 
03075 //:::::::::::::::::::::::::::::::
03076 //:: METHOD match_fake_taujets ::
03077 //:::::::::::::::::::::::::::::::
03078 
03079 void 
03080 MyHtautauAnalysis::match_fake_taujets(void) {
03081     bool is_e;
03082     bool is_photon;
03083     bool is_mu;
03084     bool is_jet;
03085     
03086     // get the truth photon data
03087     vector<MyParticle*> v_photon_truth_presel = m_truth_manager.getParticles_with_ID(22);
03088     v_photon_truth_presel = m_tools.pt_eta_cut(v_photon_truth_presel,10./GeV,-1,-1,-1);
03089     
03090     
03091     vector<MyParticle*> v_jet_faking_tau;
03092     
03093     MyParticle* tmp_particle1;
03094     MyParticle* tmp_particle2;
03095     MyParticle* tmp_particle3;
03096     MyParticle* tmp_particle4;
03097     
03098 /*        // build truth jets from pdgids:
03099         vector <MyParticle*>tmp_vec;
03100         vector <MyParticle*>partons;
03101         partons.clear();
03102         tmp_vec.clear();
03103         partons = m_truth_manager.getParticles_with_ID(1);
03104         tmp_vec = m_truth_manager.getParticles_with_ID(2);
03105         for(unsigned int i=0; i<tmp_vec.size(); i++)partons.push_back(tmp_vec[i]);
03106         tmp_vec = m_truth_manager.getParticles_with_ID(3);
03107         for(unsigned int i=0; i<tmp_vec.size(); i++)partons.push_back(tmp_vec[i]);
03108         tmp_vec = m_truth_manager.getParticles_with_ID(4);
03109         for(unsigned int i=0; i<tmp_vec.size(); i++)partons.push_back(tmp_vec[i]);
03110         tmp_vec = m_truth_manager.getParticles_with_ID(5);
03111         for(unsigned int i=0; i<tmp_vec.size(); i++)partons.push_back(tmp_vec[i]);
03112         tmp_vec = m_truth_manager.getParticles_with_ID(6);
03113         for(unsigned int i=0; i<tmp_vec.size(); i++)partons.push_back(tmp_vec[i]);
03114         //        partons = m_tools.pt_eta_cut(partons, 10.0/GeV, -1.0, 0.0, 5.);
03115 //         for(unsigned int i=0; i<partons.size(); i++){
03116 //             cout<<"pt parton "<<(partons[i])->tlv().Pt()<<endl;
03117 //         }
03118         v_jet_truth_presel = partons;
03119 //*/
03120 
03121 
03122 
03123     for(unsigned int i=0; i<v_taujet_reco_fake.size(); i++){
03124         is_e = false;
03125         is_photon = false;
03126         is_mu = false;
03127         is_jet = false;
03128         
03129         // check overlap with electrons
03130         tmp_particle1 = m_tools.find_matching_particle(v_taujet_reco_fake[i],
03131                 v_e_truth_presel, 0.1, false, false);
03132         if(tmp_particle1!=NULL){
03133             is_e = true;
03134             h_taujet_fake_match->Fill(1);
03135         }
03136         //check overlap with photons
03137          tmp_particle2 = m_tools.find_matching_particle(v_taujet_reco_fake[i],
03138                  v_photon_truth_presel, 0.1, false, false);
03139 //                cout<<"pt tau reco "<<(v_taujet_reco_fake[i])->tlv().Pt()<<endl;
03140         if(tmp_particle2!=NULL){
03141             is_photon = true;
03142             h_taujet_fake_match->Fill(2);
03143         }
03144         // check overlap with muons
03145         tmp_particle3 = m_tools.find_matching_particle(v_taujet_reco_fake[i],
03146                 v_mu_truth_presel, 0.1, false, false);
03147         if(tmp_particle3!=NULL){
03148             is_mu = true;
03149             h_taujet_fake_match->Fill(3);
03150         }
03151         // check overlap with jets
03152         tmp_particle4 = m_tools.find_matching_particle(v_taujet_reco_fake[i],
03153                 v_jet_truth_presel, 0.1, false, false);
03154         if(tmp_particle4!=NULL){
03155             is_jet = true;
03156             // store this truth_jet as faked tau one
03157             v_jet_faking_tau.push_back(tmp_particle4);
03158             h_taujet_fake_match->Fill(4);
03159         }
03160         
03161         
03162         // evaluate...
03163         if(((int)is_e + (int)is_photon + (int)is_mu + (int)is_jet)<1){
03164             h_taujet_fake_match->Fill(0);
03165         }
03166         if(((int)is_e + (int)is_photon + (int)is_mu + (int)is_jet)>1){
03167 /*            cout<<"Multiple options: "<<endl;
03168             cout<<"is_e "<<is_e <<endl;
03169             cout<<"is_photon "<<is_photon <<endl;
03170             cout<<"is_mu "<<is_mu <<endl;
03171             cout<<"is_jet "<<is_jet <<endl;//*/
03172             h_taujet_fake_match->Fill(9);
03173         }
03174         if(is_photon && is_jet){
03175 /*            
03176             cout<<"pt, eta, phi taujet: "<<(v_taujet_reco_fake[i])->tlv().Pt()<<", "
03177                                          <<(v_taujet_reco_fake[i])->tlv().Eta()<<", "
03178                                          <<(v_taujet_reco_fake[i])->tlv().Phi()<<endl;
03179             cout<<"pt, eta, phi photon: "<<tmp_particle2->tlv().Pt()<<", "
03180                                          <<tmp_particle2->tlv().Eta()<<", "
03181                                          <<tmp_particle2->tlv().Phi()<<endl;
03182             cout<<"photon barcode     : "<<((MyTruthParticle*)tmp_particle2)->barcode()<<endl;
03183             cout<<"pt, eta, phi    jet: "<<tmp_particle4->tlv().Pt()<<", "
03184                                          <<tmp_particle4->tlv().Eta()<<", "
03185                                          <<tmp_particle4->tlv().Phi()<<endl;
03186                                          //*/
03187             
03188         }
03189     }
03190     
03191     
03192     // plot jet faking taujet histos
03193     dir_presel_matching->cd();
03194     h_jet_faking_tau_nb->Fill(v_jet_faking_tau.size(), weight);
03195     for(unsigned int i=0; i<v_jet_faking_tau.size(); i++){
03196         h_jet_faking_tau_pt->Fill((v_jet_faking_tau[i])->tlv().Pt()*GeV, weight);
03197         h_jet_faking_tau_eta->Fill((v_jet_faking_tau[i])->tlv().Eta(), weight);
03198         h_jet_faking_tau_phi->Fill((v_jet_faking_tau[i])->tlv().Phi(), weight);
03199     }
03200 
03201     dir_presel_matching->cd("../");
03202     
03203     return;
03204 }
03205 
03206 //*****************************************************************************
03207 
03208 //::::::::::::::::::::::::::::::::::
03209 //:: METHOD recalculate_missinget ::
03210 //::::::::::::::::::::::::::::::::::
03211 void MyHtautauAnalysis::add_recalculated_missinget(MyMissingEtManager *orig_missing_et) {
03212 
03213         // create muon vectors
03214         // staco muons
03215     std::vector<MyParticle*> v_mu_staco_aod;
03216     std::vector<MyParticle*> v_mu_staco_sel;
03217     std::vector<MyParticle*> v_mu_staco_new;
03218     std::vector<MyParticle*> v_mu_recflag_1;
03219     std::vector<MyParticle*> v_mu_recflag_2;
03220         // MuonBoy (MB) muons
03221     std::vector<MyParticle*> v_mu_MB_aod;
03222     std::vector<MyParticle*> v_mu_MB_sel;
03223     std::vector<MyParticle*> v_mu_MB_new;
03224     if( recalculate_met_muons!="no" ){
03225         // create muon vectors
03226         // staco muons
03227         //std::vector<MyParticle*> v_mu_staco_aod;
03228         //std::vector<MyParticle*> v_mu_staco_sel;
03229         // MuonBoy (MB) muons
03230         //std::vector<MyParticle*> v_mu_MB_aod;
03231         //std::vector<MyParticle*> v_mu_MB_sel;
03232     
03233         //double delta_met_x;
03234         //double delta_met_y;
03235         //double delta_met;
03236     
03237         v_mu_staco_aod = m_event->reco_muons(3);
03238         v_mu_MB_aod = m_event->reco_muons(333);
03239 
03240         if( v_mu_staco_aod.size()!=v_mu_MB_aod.size() ){
03241             cerr<<"Unequal size of muon vectors!"<<endl;
03242             cerr<<"Maybe dataset does not contain extra muons?"<<endl;
03243             exit(1);
03244         }
03245     
03246         for(unsigned int k=0; k<v_mu_staco_aod.size(); k++){
03247             if(((MyMuon*)(v_mu_staco_aod[k]))->reconstruction_flag()==1){
03248                 v_mu_recflag_1.push_back(v_mu_staco_aod[k]);
03249             }
03250             if(((MyMuon*)(v_mu_staco_aod[k]))->reconstruction_flag()==2){
03251                 v_mu_recflag_2.push_back(v_mu_staco_aod[k]);
03252             }
03253             if(0 ||
03254                ((MyMuon*)(v_mu_staco_aod[k]))->reconstruction_flag()==1 ||
03255                //(((MyMuon*)(v_mu_staco_aod[k]))->reconstruction_flag()==8
03256                //&& TMath::Abs((v_mu_staco_aod[k])->tlv().Eta())<2.5) ||
03257             0 ){
03258                 v_mu_staco_sel.push_back(v_mu_staco_aod[k]);
03259                 v_mu_MB_sel.push_back(v_mu_MB_aod[k]);
03260                 //cout<<"pt staco-MB: "<<(v_mu_staco_aod[k])->tlv().Pt()
03261                 //        - (v_mu_MB_aod[k])->tlv().Pt()<<endl;
03262                 MyParticle* tmp_particle;
03263                 tmp_particle = m_tools.find_matching_particle( v_mu_staco_aod[k], v_mu_truth_aod, 0.1,false,false);
03264                 
03265                 if( tmp_particle!=NULL &&
03266                     (((TMath::Abs((v_mu_staco_aod[k])->tlv().Pt() - tmp_particle->tlv().Pt()))>1.) || 1 ||
03267                      ((TMath::Abs((v_mu_MB_aod[k])->tlv().Pt()    - tmp_particle->tlv().Pt()))>1.))){
03268                     h_etmiss_invest_dpt->Fill((v_mu_MB_aod[k])->tlv().Pt()
03269                             - tmp_particle->tlv().Pt(),
03270                             (v_mu_staco_aod[k])->tlv().Pt()
03271                             - tmp_particle->tlv().Pt(),
03272                             weight);
03273                     h_etmiss_MB_dpt->Fill((v_mu_MB_aod[k])->tlv().Pt()
03274                             - tmp_particle->tlv().Pt(),
03275                             weight);
03276                     h_etmiss_staco_dpt->Fill((v_mu_staco_aod[k])->tlv().Pt()
03277                             - tmp_particle->tlv().Pt(),
03278                             weight);
03279                 }
03280                 else{
03281                     //cout<<"No truth muon found"<<endl;
03282                     //(v_mu_staco_aod[k])->Print();
03283                     //m_tools.PrintVector(v_mu_truth_aod);
03284                 }
03285             }
03286         }
03287         //*
03288         // If there were no recflags1 sum up recflag2 with eta>2.5
03289         if(v_mu_staco_sel.size()==0){
03290             for(unsigned int k=0; k<v_mu_staco_aod.size(); k++){
03291                 if(0 ||
03292                    //((MyMuon*)(v_mu_staco_aod[k]))->reconstruction_flag()==99 ||
03293                    (((MyMuon*)(v_mu_staco_aod[k]))->reconstruction_flag()==2
03294                    && TMath::Abs((v_mu_staco_aod[k])->tlv().Eta())>2.5) ||
03295                    0 ){
03296                     v_mu_staco_sel.push_back(v_mu_staco_aod[k]);
03297                     v_mu_MB_sel.push_back(v_mu_MB_aod[k]);
03298                     //cout<<"pt staco-MB: "<<(v_mu_staco_aod[k])->tlv().Pt()
03299                     //        - (v_mu_MB_aod[k])->tlv().Pt()<<endl;
03300                     MyParticle* tmp_particle;
03301                     tmp_particle = m_tools.find_matching_particle( v_mu_staco_aod[k], v_mu_truth_aod, 0.1,false,false);
03302                     
03303                     if( tmp_particle!=NULL &&
03304                         (((TMath::Abs((v_mu_staco_aod[k])->tlv().Pt() - tmp_particle->tlv().Pt()))>5.) ||
03305                         ((TMath::Abs((v_mu_MB_aod[k])->tlv().Pt()    - tmp_particle->tlv().Pt()))>5.))){
03306                         h_etmiss_invest_dpt->Fill((v_mu_MB_aod[k])->tlv().Pt()
03307                                 - tmp_particle->tlv().Pt(),
03308                         (v_mu_staco_aod[k])->tlv().Pt()
03309                                 - tmp_particle->tlv().Pt(),
03310                         weight);
03311                     }
03312                     else{
03313                         //cout<<"No truth muon found"<<endl;
03314                         //(v_mu_staco_aod[k])->Print();
03315                         //m_tools.PrintVector(v_mu_truth_aod);
03316                     }
03317                 }
03318             }
03319         }//*/
03320 
03321         /*
03322         // check wether there is an overlap between recflag 1 and recflag 2 muons
03323         for(unsigned int k=0; k<v_mu_recflag_1.size(); k++){
03324             MyParticle *tmp_part;
03325             tmp_part = m_tools.find_matching_particle( v_mu_recflag_1[k], v_mu_recflag_2, 0.15,false,false);
03326             if( tmp_part!=NULL ){
03327                 if(TMath::Abs((v_mu_recflag_1[k])->tlv().Pt()-tmp_part->tlv().Pt())>10.0){
03328                     cout<<endl<<"recflag 1 and 2 overlap: "<<endl;
03329                     tmp_part->Print();
03330                     (v_mu_recflag_1[k])->Print();
03331                     tmp_part = m_tools.find_matching_particle( v_mu_recflag_1[k], v_mu_truth_aod, 0.15,false,false);
03332                     if( tmp_part!=NULL ){
03333                         cout<<"truth: "<<endl;
03334                         tmp_part->Print();
03335                     }
03336                     //cout<<"vectors: "<<endl;
03337                     //m_tools.PrintVector(v_mu_staco_aod);
03338                     //m_tools.PrintVector(v_mu_truth_aod);
03339                     //m_tools.PrintVector(v_mu_MB_aod);
03340                     string dummy;
03341                     cin>>dummy;
03342                 }
03343             }
03344         }
03345         //*/
03346 
03347         //*
03348         // calculate vectors for new met muon contribution
03349         // first loop: sum up recflag 1
03350         for(unsigned int k=0; k<v_mu_staco_aod.size(); k++){
03351             if(((MyMuon*)(v_mu_staco_aod[k]))->reconstruction_flag()==1){
03352                 //TODO:
03353                 // implement overlap check
03354                 v_mu_staco_new.push_back(v_mu_staco_aod[k]);
03355                 v_mu_MB_new.push_back(v_mu_MB_aod[k]);
03356             }
03357         }
03358         // second loop: sum up recflag 2
03359         for(unsigned int k=0; k<v_mu_staco_aod.size(); k++){
03360             if(((MyMuon*)(v_mu_staco_aod[k]))->reconstruction_flag()==2){
03361                 MyParticle *tmp_part;
03362                 // check if that muon overlaps with a muon with recflag1
03363                 // and which is already in the new vector
03364                 tmp_part = m_tools.find_matching_particle( v_mu_staco_aod[k], v_mu_staco_new, 0.1,false,false);
03365                 if( tmp_part==NULL ){
03366                     // no overlap -> new muon
03367                     v_mu_staco_new.push_back(v_mu_staco_aod[k]);
03368                     v_mu_MB_new.push_back(v_mu_MB_aod[k]);
03369                 }
03370             }
03371 
03372         }
03373 
03374     
03375         //*/
03376 
03377 
03378         
03379     //     // choose which muon vector to use for
03380     //     // comparison
03381     //     std::vector<MyParticle*> v_mu_comp;
03382     //
03383     //     // sum up this vector
03384     //     double mu_reco_sum_x(0);
03385     //     double mu_reco_sum_y(0);
03386     //     double mu_reco_sum_pt(0);
03387     //     // if no recflag 1, summ up all the muon tracks, no matter which recflag
03388     //     /*        if(v_mu_comp.size()==0){
03389     //         //events_over_metthr++;
03390     //         //cout<<"events_over_metthr "<<events_over_metthr<<endl;
03391     //         //m_tools.PrintVector(v_mu_staco_aod);
03392     //     return;
03393     //     v_mu_comp=v_mu_MB_aod;
03394     //     }*/
03395     // 
03396     //     for(unsigned int k=0; k<v_mu_comp.size(); k++){
03397     //         if((v_mu_comp[k])->tlv().Pt()>0.0 && (v_mu_comp[k])->tlv().Eta()<5.0){
03398     //             mu_reco_sum_x -= (v_mu_comp[k])->tlv().Px();
03399     //             mu_reco_sum_y -= (v_mu_comp[k])->tlv().Py();
03400     //         }
03401     //     }
03402     //     mu_reco_sum_pt = sqrt((mu_reco_sum_x*mu_reco_sum_x)+(mu_reco_sum_y*mu_reco_sum_y));
03403     // 
03404     //     // compare with another MET
03405     //     // and inform user
03406     //     string compare_with;
03407     //     compare_with = "TruthMET_Muons";
03408     //     //compare_with = "MET_MuonBoy";
03409     //     delta_met_x = mu_reco_sum_x - missinget_in_ana.get_missinget(compare_with).met_x();
03410     //     delta_met_y = mu_reco_sum_y - missinget_in_ana.get_missinget(compare_with).met_y();
03411     //     delta_met = sqrt((delta_met_x*delta_met_x) + (delta_met_y*delta_met_y));
03412     //     h_etmiss_invest_reco_truth_dpx->Fill(delta_met_x, weight);
03413     //     h_etmiss_invest_reco_truth_dpy->Fill(delta_met_y, weight);
03414     //     h_etmiss_invest_reco_truth_dpt->Fill(delta_met, weight);
03415     // 
03416     // 
03417     //     if( 0 ||
03418     //         //TMath::Abs(delta_met_x)>10 ||
03419     //         //TMath::Abs(delta_met_y)>10 ||
03420     //         TMath::Abs(delta_met)>3 ||
03421     //         0){
03422     //         events_over_metthr++;
03423     //         cout<<endl;
03424     //         cout<<"events_over_metthr "<<events_over_metthr<<endl;
03425     //         /* debug info */ cout<<"MET_Final(x,y,pt):      "<<
03426     //                                     missinget_in_ana.get_missinget("MET_Final").met_x()<<"   \t"<<
03427     //                                     missinget_in_ana.get_missinget("MET_Final").met_y()<<"   \t"<<
03428     //                                     missinget_in_ana.get_missinget("MET_Final").met()<<endl;
03429     //         /* debug info */ cout<<"delta_met(x,y,pt):      "<<
03430     //                                     delta_met_x<<"   \t"<<
03431     //                                     delta_met_y<<"   \t"<<
03432     //                                     delta_met<<endl;
03433     //         /* debug info */ cout<<"MET_MuonBoy(x,y,pt):    "<<
03434     //                                     missinget_in_ana.get_missinget("MET_MuonBoy").met_x()<<"   \t"<<
03435     //                                     missinget_in_ana.get_missinget("MET_MuonBoy").met_y()<<"   \t"<<
03436     //                                     missinget_in_ana.get_missinget("MET_MuonBoy").met()<<endl;
03437     //         /* debug info */ cout<<"reco muons(x,y,pt):     "<<
03438     //                                     mu_reco_sum_x<<"   \t"<<
03439     //                                     mu_reco_sum_y<<"   \t"<<
03440     //                                     mu_reco_sum_pt<<endl;
03441     // 
03442     //         /* debug info */ cout<<"TruthMET_Muons(x,y,pt): "<<
03443     //                                     missinget_in_ana.get_missinget("TruthMET_Muons").met_x()<<"   \t"<<
03444     //                                     missinget_in_ana.get_missinget("TruthMET_Muons").met_y()<<"   \t"<<
03445     //                                     missinget_in_ana.get_missinget("TruthMET_Muons").met()<<endl;
03446     //                             cout<<"Staco"<<endl;
03447     //                             m_tools.PrintVector(v_mu_staco_aod);
03448     //                             cout<<"MuonBoy"<<endl;
03449     //                             m_tools.PrintVector(v_mu_MB_aod);
03450     //                             cout<<"Truth"<<endl;
03451     //                             m_tools.PrintVector(v_mu_truth_aod);
03452     //         }
03453     
03455         // recalculate missing Et //
03457         std::vector<MyParticle*> v_mu_for_met_recalc;
03458         if(recalculate_met_muons == "v_mu_MB_sel"){
03459             v_mu_for_met_recalc = v_mu_MB_sel;
03460         } else if(recalculate_met_muons == "v_mu_MB_aod"){
03461             v_mu_for_met_recalc = v_mu_MB_aod;
03462         } else if(recalculate_met_muons == "v_mu_reco_presel"){
03463             v_mu_for_met_recalc = v_mu_reco_presel;
03464         } else if(recalculate_met_muons == "v_mu_staco_sel"){
03465             v_mu_for_met_recalc = v_mu_staco_sel;
03466         } else if(recalculate_met_muons == "v_mu_staco_new"){
03467             v_mu_for_met_recalc = v_mu_staco_new;
03468         } else if(recalculate_met_muons == "v_mu_MB_new"){
03469             v_mu_for_met_recalc = v_mu_MB_new;
03470         } else if(recalculate_met_muons == "v_mu_staco_aod"){
03471             v_mu_for_met_recalc = v_mu_staco_aod;
03472         } else if(recalculate_met_muons == "v_mu_reco_aod"){
03473             v_mu_for_met_recalc = v_mu_reco_aod;
03474         } else if(recalculate_met_muons == "v_mu_truth_aod"){
03475             v_mu_for_met_recalc = v_mu_truth_aod;
03476         } else{
03477             cerr<<"recalculate_met_muons: "<<recalculate_met_muons<<" unknown!"<<endl;
03478             exit(1);
03479         }
03480         // sum up given muon vector as new MET muon part "MET_MuonRecalculated"
03481         double mu_reco_sum_x(0);
03482         double mu_reco_sum_y(0);
03483         for (unsigned int i=0; i<v_mu_for_met_recalc.size(); i++ ){
03484             mu_reco_sum_x -= (v_mu_for_met_recalc[i])->tlv().Px();
03485             mu_reco_sum_y -= (v_mu_for_met_recalc[i])->tlv().Py();
03486         }
03487         // add calculated variables to the MissingEtManager
03488         MyMissingEt met_mu_reco("MET_MuonRecalculated",
03489                                 mu_reco_sum_x,
03490                                 mu_reco_sum_y,
03491                                 mu_reco_sum_x+mu_reco_sum_y);
03492         orig_missing_et->add_missinget(met_mu_reco);
03493     }
03494     
03495     if( met_option!="MET_Final" &&
03496         met_option!="AtlfastMissingEt" &&
03497         met_option!="ObjMET_Final" &&
03498         met_option!="TruthMET_NonInt" &&
03499         met_option!="MET_RefFinal" &&
03500         met_option!="MET_RefFinal_1mmCorrection"){
03501         // create a new MET Object
03502         double new_met_x(0);
03503         double new_met_y(0);
03504         new_met_x = orig_missing_et->get_missinget("MET_CorrTopo").met_x()
03505                 + orig_missing_et->get_missinget("MET_CryoCone").met_x();
03506         new_met_y = orig_missing_et->get_missinget("MET_CorrTopo").met_y()
03507                 + orig_missing_et->get_missinget("MET_CryoCone").met_y();
03508         if (met_option == "CorrTopo_CryoCone_TruthMuons"){
03509             met_muon_contribution = "TruthMET_Muons";
03510         }
03511         else if (met_option == "CorrTopo_CryoCone_MuonRecalculated"){
03512             met_muon_contribution = "MET_MuonRecalculated";
03513         }
03514         else if (met_option == "CorrTopo_CryoCone_MuonBoy"){
03515             met_muon_contribution = "MET_MuonBoy";
03516         }
03517         else if (met_option == "CorrTopo_CryoCone_Muon"){
03518             met_muon_contribution = "MET_Muon";
03519         }
03520         else if (met_option == "Ref_MuonRecalculated"){
03521             new_met_x = orig_missing_et->get_missinget("MET_CryoCone").met_x()
03522                     + orig_missing_et->get_missinget("MET_CellOut").met_x()
03523                     + orig_missing_et->get_missinget("MET_RefJet").met_x()
03524                     + orig_missing_et->get_missinget("MET_RefEle").met_x();
03525             new_met_y = orig_missing_et->get_missinget("MET_CryoCone").met_y()
03526                     + orig_missing_et->get_missinget("MET_CellOut").met_y()
03527                     + orig_missing_et->get_missinget("MET_RefJet").met_y()
03528                     + orig_missing_et->get_missinget("MET_RefEle").met_y();
03529             met_muon_contribution = "MET_MuonRecalculated";
03530         }
03531         else if (met_option == "Ref_METMuon"){
03532             new_met_x = orig_missing_et->get_missinget("MET_CryoCone").met_x()
03533                     + orig_missing_et->get_missinget("MET_CellOut").met_x()
03534                     + orig_missing_et->get_missinget("MET_RefJet").met_x()
03535                     + orig_missing_et->get_missinget("MET_RefEle").met_x();
03536             new_met_y = orig_missing_et->get_missinget("MET_CryoCone").met_y()
03537                     + orig_missing_et->get_missinget("MET_CellOut").met_y()
03538                     + orig_missing_et->get_missinget("MET_RefJet").met_y()
03539                     + orig_missing_et->get_missinget("MET_RefEle").met_y();
03540             met_muon_contribution = "MET_Muon";
03541         }
03542         else if (met_option == "Ref_METMuonBoy"){
03543             new_met_x = orig_missing_et->get_missinget("MET_CryoCone").met_x()
03544                     + orig_missing_et->get_missinget("MET_CellOut").met_x()
03545                     + orig_missing_et->get_missinget("MET_RefJet").met_x()
03546                     + orig_missing_et->get_missinget("MET_RefEle").met_x();
03547             new_met_y = orig_missing_et->get_missinget("MET_CryoCone").met_y()
03548                     + orig_missing_et->get_missinget("MET_CellOut").met_y()
03549                     + orig_missing_et->get_missinget("MET_RefJet").met_y()
03550                     + orig_missing_et->get_missinget("MET_RefEle").met_y();
03551             met_muon_contribution = "MET_MuonBoy";
03552         }
03553         else if (met_option == "OwnObjMET_MuonRecalculated"){
03554             std::vector<MyParticle*> v_tmp;
03555             v_tmp = m_tools.append_vector(v_jet_reco_presel, v_e_reco_presel);
03556             
03557             for (unsigned int i=0; i<v_tmp.size(); i++ ){
03558                 new_met_x -= (v_tmp[i])->tlv().Px();
03559                 new_met_x -= (v_tmp[i])->tlv().Py();
03560             }
03561             met_muon_contribution = "MET_MuonRecalculated";
03562         }
03563         else{
03564             cerr<<"met_option: "<<met_option<<" unknown!"<<endl;
03565             exit(1);
03566         }
03567         // add muon contribution
03568         new_met_x += orig_missing_et->get_missinget(met_muon_contribution).met_x();
03569         new_met_y += orig_missing_et->get_missinget(met_muon_contribution).met_y();
03570         // add calculated variables to the MissingEtManager
03571         MyMissingEt new_met(met_option,
03572                             new_met_x,
03573                             new_met_y,
03574                             new_met_x+new_met_y);
03575         orig_missing_et->add_missinget(new_met);
03576     }
03577     else if(met_option=="MET_Final"){
03578         met_muon_contribution = "MET_MuonBoy";
03579     }
03580     else if(met_option=="MET_RefFinal_1mmCorrection"){
03581         met_muon_contribution = "MET_MuonBoy";
03582     }
03583     else if(met_option=="MET_RefFinal"){
03584         met_muon_contribution = "MET_MuonBoy";
03585     }
03586     else if(met_option=="Ref_MuonRecalculated"){
03587         met_muon_contribution = "MET_MuonBoy";
03588     }
03589     else if(met_option=="ObjMET_Final"){
03590         met_muon_contribution = "ObjMET_Muon";
03591     }
03592     else if(met_option=="TruthMET_NonInt"){
03593         met_muon_contribution = "TruthMET_Muons";
03594     }
03595     else if(met_option=="AtlfastMissingEt"){
03596         met_muon_contribution = "TruthMET_Muons";
03597     }
03598     else{
03599         cerr<<"met_option: "<<met_option<<" unknown(2)!"<<endl;
03600         exit(1);
03601     }
03602 /*
03603         if(TMath::Abs( orig_missing_et->get_missinget(met_option).met() -  orig_missing_et->get_missinget("MET_RefFinal").met())>.1){
03604         cout<<endl<<"unequal MET_RefFinal: "<<endl;
03605         orig_missing_et->Print();
03606         m_tools.PrintVector(v_mu_staco_aod);
03607         m_tools.PrintVector(v_mu_MB_aod);
03608         }//*/
03609 /*
03610         if(TMath::Abs( orig_missing_et->get_missinget("MET_MuonRecalculated").met() -
03611            orig_missing_et->get_missinget("TruthMET_Muons").met())>10.){
03612             cout<<endl<<endl<<endl<<"unequal MET_Muon: "<<endl;
03613             orig_missing_et->get_missinget("MET_MuonRecalculated").Print();
03614             orig_missing_et->get_missinget("TruthMET_Muons").Print();
03615             cout<<endl<<"v_mu_staco_aod: "<<endl;
03616             m_tools.PrintVector(v_mu_staco_aod);
03617             cout<<endl<<"v_mu_truth_aod: "<<endl;
03618             m_tools.PrintVector(v_mu_truth_aod);
03619             cout<<endl<<"v_mu_MB_aod: "<<endl;
03620             m_tools.PrintVector(v_mu_MB_aod);
03621             string dummy;
03622             cin>>dummy;
03623         }//*/
03624     return;
03625 }
03626 
03627 //*****************************************************************************
03628 
03629 //:::::::::::::::::::::::
03630 //:: METHOD n_pt_above ::
03631 //:::::::::::::::::::::::
03632 
03633 int MyHtautauAnalysis::n_pt_above(const vector<MyParticle*> v_particle, const double ptcut) {
03634     int n_particles_above_ptcut;
03635     n_particles_above_ptcut=0;
03636     for (unsigned int i=0; i<v_particle.size(); i++){
03637         if ((v_particle[i])->tlv().Pt() >= ptcut ){
03638             n_particles_above_ptcut++;
03639         }
03640     }
03641     return n_particles_above_ptcut;
03642 }
03643 
03644 //*****************************************************************************
03645 
03646 //:::::::::::::::::::::::::::
03647 //:: METHOD tau_decay_mode ::
03648 //:::::::::::::::::::::::::::
03649 
03650 int MyHtautauAnalysis::tau_decay_mode(MyTruthParticle* truth_tau) {
03651 
03652     MyTruthParticle* truth_tau_li;
03653 
03654 // decay mode of taus
03655     // leptonic, hadronic?
03656     // unknown -> 0
03657     // e-> 1
03658     // mu-> 2
03659     // picharged -> 3
03660     // 1prong -> 3-7
03661     // 3prong -> 8-10    
03662     
03663     // check wether it is a tau
03664     if(TMath::Abs(truth_tau->pdgId())!=15){
03665         cerr<<"input particle is not a tau"<<endl;
03666         return -1;
03667     }
03668     
03669     vector<MyTruthParticle*> v_truth_children;
03670     int tmp_pdgId(0);
03671     int n_e(0);
03672     int n_nu_e(0);
03673     int n_mu(0);
03674     int n_nu_mu(0);
03675     int n_tau(0);
03676     int n_nu_tau(0);
03677     int n_gamma(0);
03678     int n_pi0(0);
03679     int n_pi_charged(0);
03680     int n_hadron(0);
03681     int n_W(0);
03682     int n_total_decay_particles(0);
03683     
03684     // go to the last instance of the tau:
03685     truth_tau_li = m_truth_manager.get_last_instance(truth_tau);
03686     
03687     v_truth_children = m_truth_manager.get_children(truth_tau_li);
03688     tmp_pdgId=0;
03689     n_e=0;
03690     n_nu_e=0;
03691     n_mu=0;
03692     n_nu_mu=0;
03693     n_tau=0;
03694     n_nu_tau=0;
03695     n_gamma=0;
03696     n_pi0=0;
03697     n_pi_charged=0;
03698     n_hadron=0;
03699     n_W=0;
03700     //cout<<endl;
03701     for(unsigned int i=0; i<v_truth_children.size(); i++ ){
03702         tmp_pdgId=TMath::Abs((v_truth_children[i])->pdgId());
03703         // cout<<"tauID "<<tmp_pdgId<<endl;
03704         
03705         if (tmp_pdgId==11){
03706             n_e++;
03707         }
03708         else if (tmp_pdgId==12){          
03709             n_nu_e++;              
03710         }                      
03711         else if (tmp_pdgId==13){          
03712             n_mu++;               
03713         }                      
03714         else if (tmp_pdgId==14){          
03715             n_nu_mu++;              
03716         }                      
03717         else if (tmp_pdgId==15){          
03718             n_tau++;
03719             cerr<<"ERROR: a tau as a daughter of a tau"<<endl;
03720             return -1;              
03721         }                      
03722         else if (tmp_pdgId==16){          
03723             n_nu_tau++;              
03724         }                      
03725         else if (tmp_pdgId==22){          
03726             n_gamma++;              
03727         }                      
03728         else if (tmp_pdgId==111){          
03729             n_pi0++;              
03730         }                      
03731         else if (tmp_pdgId==211){          
03732             n_pi_charged++;           
03733         }                      
03734         else if (tmp_pdgId>100){          
03735             n_hadron++;              
03736         }                      
03737         else if (tmp_pdgId==24){          
03738             n_W++;              
03739         }                      
03740         else {                      
03741             cerr<<"in tau_decay_mode: unknown ID: "<<tmp_pdgId<<endl;     
03742         }                      
03743     }
03744     
03745     n_total_decay_particles =
03746         n_nu_e+
03747         n_nu_mu+
03748         n_nu_tau+
03749         n_e+
03750         n_mu+
03751         n_tau+
03752         n_gamma+
03753         n_pi0+
03754         n_pi_charged+
03755         n_hadron+
03756         n_W;
03757         
03758     if (n_nu_tau!=1){
03759         cerr<<"WARNING No Tau Neutrino found!!!"<<endl;
03760     }
03761         
03762     if (n_e==1 && n_mu==0 && n_hadron==0 && n_pi_charged==0 && n_pi0==0){
03763         return 1;
03764     }
03765     else if (n_e==0 && n_mu==1 && n_hadron==0 && n_pi_charged==0 && n_pi0==0){
03766         return 2;
03767     }
03768     else if (n_e==0 && n_mu==0 && (n_hadron>=0 || n_pi_charged>=0 || n_pi0>=0)){
03769         return 3;
03770     }
03771     else {
03772         cout<<"unknown tau decay mode"<<endl;
03773     }
03774     return 0;
03775 }            
03776     
03777 //*****************************************************************************
03778 //:::::::::::::::::::::::::::::::::
03779 //:: METHOD calculate_decay_mode ::
03780 //:::::::::::::::::::::::::::::::::
03781 
03782 void MyHtautauAnalysis::calculate_decay_mode(void) {
03783     unsigned int tmp_n_of_decay_chains(0);
03784     tmp_n_of_decay_chains = m_truth_manager.get_n_of_decay_chains();
03785     MyTruthParticle* tmp_truth_particle;
03786     MyTruthParticle* truth_tau_0;
03787     MyTruthParticle* truth_tau_1;
03788     truth_tau_0 = NULL;
03789     truth_tau_1 = NULL;
03790     vector<MyTruthParticle*> v_tmp_truth_particle;
03791     primary_particle_mode = -1;
03792     int tmp_pdgId(0);
03793     int n_e(0);
03794     int n_nu_e(0);
03795     int n_mu(0);
03796     int n_nu_mu(0);
03797     int n_tau(0);
03798     int n_nu_tau(0);
03799     int n_gamma(0);
03800     int n_pi0(0);
03801     int n_pi_charged(0);
03802     int n_hadron(0);
03803     int n_total_taus(0);
03804     
03805     
03806 // primary particles (W, Z, H...)
03807     // Mode -1: unknown
03808     // Mode 0: H
03809     // Mode 1: Z
03810     // Mode 2: W+,W-
03811     if (tmp_n_of_decay_chains==0){
03812         primary_particle_mode=-1;
03813         cout<<"unknown process, no interesting particles found"<<endl;
03814         return;
03815     }
03816     if (tmp_n_of_decay_chains==1){
03817         tmp_truth_particle=m_truth_manager.get_primary_intpart(0);
03818         if (TMath::Abs(tmp_truth_particle->pdgId())==25){
03819  //            cout<<"Higgs"<<endl;
03820             primary_particle_mode=0;
03821         }
03822         else if (TMath::Abs(tmp_truth_particle->pdgId())==23){
03823              //cout<<"Z, status: "<<tmp_truth_particle->status()<<endl;
03824             primary_particle_mode=1;
03825         }
03826         else {
03827             primary_particle_mode=-1;
03828             cout<<"unknown primary particle found, PDG-ID:"
03829                 <<tmp_truth_particle->pdgId()<<endl;
03830         }
03831         
03832     }
03833     
03834     if (tmp_n_of_decay_chains==2){
03835         tmp_truth_particle=m_truth_manager.get_primary_intpart(0);
03836         if (TMath::Abs(m_truth_manager.get_primary_intpart(0)->pdgId())==24 &&
03837             TMath::Abs(m_truth_manager.get_primary_intpart(0)->pdgId())==24){
03838 //             cout<<"W,W"<<endl;
03839             primary_particle_mode=2;
03840         }
03841         else {
03842             primary_particle_mode=-1;
03843             cout<<"unknown primary particles found, PDG-ID/Barcode/status: "
03844                 <<m_truth_manager.get_primary_intpart(0)->pdgId()
03845                 <<"/"
03846                 <<m_truth_manager.get_primary_intpart(0)->barcode()
03847                 <<"/"
03848                 <<m_truth_manager.get_primary_intpart(0)->status()
03849                 <<", "
03850                 <<m_truth_manager.get_primary_intpart(1)->pdgId()
03851                 <<"/"
03852                 <<m_truth_manager.get_primary_intpart(1)->barcode()
03853                 <<"/"
03854                 <<m_truth_manager.get_primary_intpart(1)->status()
03855                 <<endl;
03856         }
03857     }
03858 
03859 
03860 // children of first generation
03861     // children 1st generation (e, mu, tau, gamma?)
03862     // Mode -1: unknown
03863     // Mode 0: tau, tau
03864     // Mode 1: e/mu, tau
03865     // Mode 2: e/mu, e/mu
03866     tmp_pdgId=0;
03867     n_e=0;
03868     n_nu_e=0;
03869     n_mu=0;
03870     n_nu_mu=0;
03871     n_tau=0;
03872     n_nu_tau=0;
03873     n_gamma=0;
03874     n_pi0=0;
03875     n_pi_charged=0;
03876     n_hadron=0;
03877     n_total_taus=0;
03878     
03879     for(unsigned int i=0; i<tmp_n_of_decay_chains; i++ ){
03880         v_tmp_truth_particle = 
03881             m_truth_manager.get_gen1_children_intpart(i);
03882         for(unsigned int j=0; j<v_tmp_truth_particle.size(); j++){
03883             tmp_pdgId=TMath::Abs((v_tmp_truth_particle[j])->pdgId());
03884             if (tmp_pdgId==11){
03885                 n_e++;
03886             }
03887             else if (tmp_pdgId==12){
03888                 n_nu_e++;
03889             }
03890             else if (tmp_pdgId==13){
03891                 n_mu++;
03892             }
03893             else if (tmp_pdgId==14){
03894                 n_nu_mu++;
03895             }
03896             else if (tmp_pdgId==15){
03897                 n_total_taus++;
03898                 n_tau++;
03899                 if (n_total_taus==1){
03900                     truth_tau_0=(v_tmp_truth_particle[j]);
03901                 }
03902                 if (n_total_taus==2){
03903                     truth_tau_1=(v_tmp_truth_particle[j]);
03904                 }
03905                 if (n_total_taus>2){
03906                     cout<<"more than 2 truth taus"
03907                         << endl;
03908                 }
03909                 
03910             }
03911             else if (tmp_pdgId==16){
03912                 n_nu_tau++;
03913             }
03914             else if (tmp_pdgId==22){
03915                 n_gamma++;
03916             }
03917             else if (tmp_pdgId==111){
03918                 n_pi0++;
03919             }
03920             else if (tmp_pdgId==211){
03921                 n_pi_charged++;
03922             }
03923             else if (tmp_pdgId>100){
03924                 n_hadron++;
03925             }
03926             else {
03927                 cerr<<"in calculate_decay_mode: unknown ID"<<endl;
03928             }
03929         }
03930     }
03931     
03932     // inform user about strange particles in 1st generation
03933     if (n_gamma>0){
03934         //cout<<"gamma in 1st generation children"<<endl;
03935     }
03936     if ((n_pi0+n_pi_charged+n_hadron)>0){
03937         cout<<"strange particles in 1st generation children"<<endl
03938             <<"please check..."<<endl;
03939     }
03940 
03941     // define Mode:
03942     if (n_tau==1 && (n_e + n_mu)==1){
03943 //         cout<<"      to e/mu+tau"<<endl;
03944         primary_particle_decay_mode=1;
03945     }
03946     else if (n_tau==2 && n_e==0 && n_mu==0){
03947  //        cout<<"      to tau,tau"<<endl;
03948         primary_particle_decay_mode=0;
03949     }
03950     else if (n_tau==0 && (n_e + n_mu)==2){
03951  //        cout<<"      to e/mu,e/mu"<<endl;
03952         primary_particle_decay_mode=2;
03953     }
03954     else {
03955         cout<<"n_tau: "<<n_tau<<", n_mu: "<<n_mu<<", n_e: "<<n_e<<endl;
03956         cout<<"strange composition in 1st generation"<<endl;
03957         primary_particle_decay_mode=-1;
03958     }
03959     
03960     
03961 // decay mode of taus of 1st generation
03962     // leptonic, hadronic?
03963     // unknown -> 0
03964     // e-> 1
03965     // mu-> 2
03966     // picharged -> 3
03967     // 1prong -> 3-7
03968     // 3prong -> 8-10
03969     
03970     
03971 
03972 // if two taus, mode:
03973     // Mode 1 for ll, 2 for lh, 3 for hh
03974     if (n_total_taus==2){
03975         tau_0_decay_mode = tau_decay_mode(truth_tau_0);
03976         tau_1_decay_mode = tau_decay_mode(truth_tau_1);
03977         if((tau_0_decay_mode==1 || tau_0_decay_mode==2) &&
03978            (tau_1_decay_mode==1 || tau_1_decay_mode==2)){
03979             higgs_decay_mode=1;
03980 //            cout<<"                 leptonic"<<endl;
03981         }
03982         if(((tau_0_decay_mode==1 || tau_0_decay_mode==2) &&
03983             tau_1_decay_mode>2) ||
03984           ((tau_1_decay_mode==1 || tau_1_decay_mode==2) &&
03985             tau_0_decay_mode>2) ){
03986             higgs_decay_mode=2;
03987 //             cout<<"                 semileptonic"<<endl;
03988         }
03989         if( tau_1_decay_mode>2 &&
03990             tau_0_decay_mode>2 ){
03991             higgs_decay_mode=3;
03992 //             cout<<"                 hadronic"<<endl;
03993         }
03994     }
03995     
03996     return;
03997 
03998 }
03999 
04000 //*****************************************************************************
04001 
04002 //::::::::::::::::::::::::::::::::::
04003 //:: METHOD fill_decay_mode_hists ::
04004 //::::::::::::::::::::::::::::::::::
04005 
04006 void MyHtautauAnalysis::fill_decay_mode_hists(bool print_info) {
04007     
04008     string dummy;
04009     dummy = "";
04010 // primary particles (W, Z, H...)
04011     // Mode -1: unknown
04012     // Mode 0: H
04013     // Mode 1: Z
04014     // Mode 2: W+,W-
04015     h_primary_particle_mode->Fill(primary_particle_mode , weight);
04016     if (print_info){
04017         switch (primary_particle_mode){
04018             case 0:
04019                 dummy.append("Higgs ");
04020                 break;
04021             case 1:
04022                 dummy.append("Z ");
04023                 break;
04024             case 2:
04025                 dummy.append("W+,W- ");
04026                 break;
04027             default:
04028                 cout<<"Unknown primary_particle_mode"
04029                     <<endl;
04030         }
04031     }
04032 
04033 
04034 // children of first generation
04035     // children 1st generation (e, mu, tau, gamma?)
04036     // Mode -1: unknown
04037     // Mode 0: tau, tau
04038     // Mode 1: e/mu, tau
04039     // Mode 2: e/mu, e/mu
04040 
04041     h_primary_particle_decay_mode
04042         ->Fill(primary_particle_decay_mode , weight);
04043     if (print_info){
04044         switch (primary_particle_decay_mode){
04045             case 0:
04046                 dummy.append("to tau,tau ");
04047                 break;
04048             case 1:
04049                 dummy.append("to e/mu, tau ");
04050                 break;
04051             case 2:
04052                 dummy.append("to e/mu, e/mu ");
04053                 break;
04054             default:
04055                 cout<<"Unknown primary_particle_decay_mode"
04056                     <<endl;
04057         }
04058     }
04059     
04060 // decay mode of taus of 1st generation
04061     // leptonic, hadronic?
04062     // no tau -> -1
04063     // unknown -> 0
04064     // e-> 1
04065     // mu-> 2
04066     // hadronic -> 3
04067         // not yet:
04068         // picharged -> 3
04069         // 1prong -> 3-7
04070         // 3prong -> 8-10
04071     h_tau_0_decay_mode->Fill(tau_0_decay_mode , weight);
04072     h_tau_1_decay_mode->Fill(tau_1_decay_mode , weight);
04073 
04074 
04075 // if two taus, mode:
04076     // Mode -1 not yet calculated
04077     //       0 unknown
04078     //       1 ll 
04079     //       2 lh
04080     //       3 hh
04081     h_higgs_decay_mode->Fill(higgs_decay_mode , weight);
04082     if (print_info){
04083         switch (higgs_decay_mode){
04084             case 1:
04085                 dummy.append("leptonic");
04086                 break;
04087             case 2:
04088                 dummy.append("semileptonic");
04089                 break;
04090             case 3:
04091                 dummy.append("hadronic");
04092                 break;
04093             default:
04094                 cout<<"Unknown higgs_decay_mode"
04095                     <<endl;
04096         }
04097     }
04098     
04099     if (print_info){
04100         cout<<dummy<<endl;
04101     }
04102     return;
04103 }
04104 
04105 
04106 //*****************************************************************************
04107 
04108 //::::::::::::::::::::::::::::
04109 //:: METHOD end_of_analysis ::
04110 //::::::::::::::::::::::::::::
04111 
04112 void MyHtautauAnalysis::end_of_analysis(void) {
04113 
04114     // print out event numbers of a single cut:    
04115     // cout<<"evt_nb_passed.size(): "<<evt_nb_passed.size()<<endl;
04116     // sort by event number:
04117     vector<int> sorted_vector(0);
04118     unsigned int orig_size = evt_nb_passed.size();
04119     for (unsigned int cycle=0; cycle<orig_size; cycle++){
04120         int    k_max=-1;
04121         double evt_nb_max=-1;
04122         for (unsigned int k=0; k<evt_nb_passed.size(); k++) {
04123             int event_nb = (evt_nb_passed[k]);
04124             if( event_nb > evt_nb_max ){
04125                 k_max = k;
04126                 evt_nb_max = event_nb;
04127             }
04128         }
04129         sorted_vector.push_back( (evt_nb_passed[k_max]) );
04130         evt_nb_passed.erase(evt_nb_passed.begin()+k_max);
04131     }
04132     for(unsigned int k=sorted_vector.size(); k>0; k--){
04133         cout<<"event passed: "<<sorted_vector[k-1]<<endl;
04134     }
04135 
04137     // HISTOGRAMS //
04139     dir_presel_matching->cd();
04140 
04141 
04142     h_jet_faking_tau_rate_pt=(TH1F*)h_jet_faking_tau_pt->Clone("jet_faking_tau_rate_pt");
04143     h_jet_faking_tau_rate_pt->Sumw2();
04144     h_jet_faking_tau_rate_pt->Divide(h_jet_truth_presel_pt);
04145     h_jet_faking_tau_rate_eta=(TH1F*)h_jet_faking_tau_eta->Clone("jet_faking_tau_rate_eta");
04146     h_jet_faking_tau_rate_eta->Sumw2();
04147     h_jet_faking_tau_rate_eta->Divide(h_jet_truth_presel_eta);
04148     h_jet_faking_tau_rate_phi=(TH1F*)h_jet_faking_tau_phi->Clone("jet_faking_tau_rate_phi");
04149     h_jet_faking_tau_rate_phi->Sumw2();
04150     h_jet_faking_tau_rate_phi->Divide(h_jet_truth_presel_phi);
04151 
04152 
04153     // electrons
04154     h_e_reco_efficiency_pt=(TH1F*)h_e_truth_matched_pt->Clone("e_reco_efficiency_pt");
04155     h_e_reco_efficiency_pt->Sumw2();
04156     h_e_reco_efficiency_pt->Divide(h_e_truth_presel_pt);
04157     h_e_reco_efficiency_pt->SetTitle("EFFICIENCY ELECTRON RECONSTRUCTION VS. PT");
04158     h_e_reco_efficiency_eta=(TH1F*)h_e_truth_matched_eta->Clone("e_reco_efficiency_eta");
04159     h_e_reco_efficiency_eta->Sumw2();
04160     h_e_reco_efficiency_eta->Divide(h_e_truth_presel_eta);
04161     h_e_reco_efficiency_eta->SetTitle("EFFICIENCY ELECTRON RECONSTRUCTION VS. ETA");
04162     h_e_reco_efficiency_phi=(TH1F*)h_e_truth_matched_phi->Clone("e_reco_efficiency_phi");
04163     h_e_reco_efficiency_phi->Sumw2();
04164     h_e_reco_efficiency_phi->Divide(h_e_truth_presel_phi);
04165     h_e_reco_efficiency_phi->SetTitle("EFFICIENCY ELECTRON RECONSTRUCTION VS. PHI");
04166 
04167 
04168     h_e_reco_fakerate_pt=(TH1F*)h_e_reco_fake_pt->Clone("e_reco_fakerate_pt");
04169     h_e_reco_fakerate_pt->Sumw2();
04170     h_e_reco_fakerate_pt->Divide(h_e_reco_presel_pt);
04171     h_e_reco_fakerate_pt->SetTitle("FAKERATE ELECTRON RECONSTRUCTION VS. PT");
04172     h_e_reco_fakerate_eta=(TH1F*)h_e_reco_fake_eta->Clone("e_reco_fakerate_eta");
04173     h_e_reco_fakerate_eta->Sumw2();
04174     h_e_reco_fakerate_eta->Divide(h_e_reco_presel_eta);
04175     h_e_reco_fakerate_eta->SetTitle("FAKERATE ELECTRON RECONSTRUCTION VS. ETA");
04176     h_e_reco_fakerate_phi=(TH1F*)h_e_reco_fake_phi->Clone("e_reco_fakerate_phi");
04177     h_e_reco_fakerate_phi->Sumw2();
04178     h_e_reco_fakerate_phi->Divide(h_e_reco_presel_phi);
04179     h_e_reco_fakerate_phi->SetTitle("FAKERATE ELECTRON RECONSTRUCTION VS. PHI");
04180 
04181 
04182     // muons
04183     h_mu_reco_efficiency_pt=(TH1F*)h_mu_truth_matched_pt->Clone("mu_reco_efficiency_pt");
04184     h_mu_reco_efficiency_pt->Sumw2();
04185     h_mu_reco_efficiency_pt->Divide(h_mu_truth_presel_pt);
04186     h_mu_reco_efficiency_pt->SetTitle("EFFICIENCY MUON RECONSTRUCTION VS. PT");
04187     h_mu_reco_efficiency_eta=(TH1F*)h_mu_truth_matched_eta->Clone("mu_reco_efficiency_eta");
04188     h_mu_reco_efficiency_eta->Sumw2();
04189     h_mu_reco_efficiency_eta->Divide(h_mu_truth_presel_eta);
04190     h_mu_reco_efficiency_eta->SetTitle("EFFICIENCY MUON RECONSTRUCTION VS. ETA");
04191     h_mu_reco_efficiency_phi=(TH1F*)h_mu_truth_matched_phi->Clone("mu_reco_efficiency_phi");
04192     h_mu_reco_efficiency_phi->Sumw2();
04193     h_mu_reco_efficiency_phi->Divide(h_mu_truth_presel_phi);
04194     h_mu_reco_efficiency_phi->SetTitle("EFFICIENCY MUON RECONSTRUCTION VS. PHI");
04195 
04196 
04197     h_mu_reco_fakerate_pt=(TH1F*)h_mu_reco_fake_pt->Clone("mu_reco_fakerate_pt");
04198     h_mu_reco_fakerate_pt->Sumw2();
04199     h_mu_reco_fakerate_pt->Divide(h_mu_reco_presel_pt);
04200     h_mu_reco_fakerate_pt->SetTitle("FAKERATE MUON RECONSTRUCTION VS. PT");
04201     h_mu_reco_fakerate_eta=(TH1F*)h_mu_reco_fake_eta->Clone("mu_reco_fakerate_eta");
04202     h_mu_reco_fakerate_eta->Sumw2();
04203     h_mu_reco_fakerate_eta->Divide(h_mu_reco_presel_eta);
04204     h_mu_reco_fakerate_eta->SetTitle("FAKERATE MUON RECONSTRUCTION VS. ETA");
04205     h_mu_reco_fakerate_phi=(TH1F*)h_mu_reco_fake_phi->Clone("mu_reco_fakerate_phi");
04206     h_mu_reco_fakerate_phi->Sumw2();
04207     h_mu_reco_fakerate_phi->Divide(h_mu_reco_presel_phi);
04208     h_mu_reco_fakerate_phi->SetTitle("FAKERATE MUON RECONSTRUCTION VS. PHI");
04209 
04210 
04211     // taujets
04212     h_taujet_reco_efficiency_pt=(TH1F*)h_taujet_truth_matched_pt->Clone(
04213                                  "taujet_reco_efficiency_pt");
04214     h_taujet_reco_efficiency_pt->Sumw2();
04215     h_taujet_reco_efficiency_pt->Divide(h_taujet_truth_presel_pt);
04216     h_taujet_reco_efficiency_pt->SetTitle("EFFICIENCY TAUJET RECONSTRUCTION VS. PT");
04217     h_taujet_reco_efficiency_eta=(TH1F*)h_taujet_truth_matched_eta->Clone(
04218                                   "taujet_reco_efficiency_eta");
04219     h_taujet_reco_efficiency_eta->Sumw2();
04220     h_taujet_reco_efficiency_eta->Divide(h_taujet_truth_presel_eta);
04221     h_taujet_reco_efficiency_eta->SetTitle("EFFICIENCY TAUJET RECONSTRUCTION VS. ETA");
04222     h_taujet_reco_efficiency_phi=(TH1F*)h_taujet_truth_matched_phi->Clone(
04223                                   "taujet_reco_efficiency_phi");
04224     h_taujet_reco_efficiency_phi->Sumw2();
04225     h_taujet_reco_efficiency_phi->Divide(h_taujet_truth_presel_phi);
04226     h_taujet_reco_efficiency_phi->SetTitle("EFFICIENCY TAUJET RECONSTRUCTION VS. PHI");
04227 
04228 
04229     h_taujet_reco_fakerate_pt=(TH1F*)h_taujet_reco_fake_pt->Clone("taujet_reco_fakerate_pt");
04230     h_taujet_reco_fakerate_pt->Sumw2();
04231     h_taujet_reco_fakerate_pt->Divide(h_taujet_reco_presel_pt);
04232     h_taujet_reco_fakerate_pt->SetTitle("FAKERATE TAUJET RECONSTRUCTION VS. PT");
04233     h_taujet_reco_fakerate_eta=(TH1F*)h_taujet_reco_fake_eta->Clone("taujet_reco_fakerate_eta");
04234     h_taujet_reco_fakerate_eta->Sumw2();
04235     h_taujet_reco_fakerate_eta->Divide(h_taujet_reco_presel_eta);
04236     h_taujet_reco_fakerate_eta->SetTitle("FAKERATE TAUJET RECONSTRUCTION VS. ETA");
04237     h_taujet_reco_fakerate_phi=(TH1F*)h_taujet_reco_fake_phi->Clone("taujet_reco_fakerate_phi");
04238     h_taujet_reco_fakerate_phi->Sumw2();
04239     h_taujet_reco_fakerate_phi->Divide(h_taujet_reco_presel_phi);
04240     h_taujet_reco_fakerate_phi->SetTitle("FAKERATE TAUJET RECONSTRUCTION VS. PHI");
04241 
04242 
04243     // bjets
04244     h_bjet_reco_efficiency_pt=(TH1F*)h_bjet_truth_matched_pt->Clone(
04245                                  "bjet_reco_efficiency_pt");
04246     h_bjet_reco_efficiency_pt->Sumw2();
04247     h_bjet_reco_efficiency_pt->Divide(h_bjet_truth_presel_pt);
04248     h_bjet_reco_efficiency_pt->SetTitle("EFFICIENCY TAUJET RECONSTRUCTION VS. PT");
04249     h_bjet_reco_efficiency_eta=(TH1F*)h_bjet_truth_matched_eta->Clone(
04250                                   "bjet_reco_efficiency_eta");
04251     h_bjet_reco_efficiency_eta->Sumw2();
04252     h_bjet_reco_efficiency_eta->Divide(h_bjet_truth_presel_eta);
04253     h_bjet_reco_efficiency_eta->SetTitle("EFFICIENCY TAUJET RECONSTRUCTION VS. ETA");
04254     h_bjet_reco_efficiency_phi=(TH1F*)h_bjet_truth_matched_phi->Clone(
04255                                   "bjet_reco_efficiency_phi");
04256     h_bjet_reco_efficiency_phi->Sumw2();
04257     h_bjet_reco_efficiency_phi->Divide(h_bjet_truth_presel_phi);
04258     h_bjet_reco_efficiency_phi->SetTitle("EFFICIENCY TAUJET RECONSTRUCTION VS. PHI");
04259 
04260 
04261     h_bjet_reco_fakerate_pt=(TH1F*)h_bjet_reco_fake_pt->Clone("bjet_reco_fakerate_pt");
04262     h_bjet_reco_fakerate_pt->Sumw2();
04263     h_bjet_reco_fakerate_pt->Divide(h_bjet_reco_presel_pt);
04264     h_bjet_reco_fakerate_pt->SetTitle("FAKERATE TAUJET RECONSTRUCTION VS. PT");
04265     h_bjet_reco_fakerate_eta=(TH1F*)h_bjet_reco_fake_eta->Clone("bjet_reco_fakerate_eta");
04266     h_bjet_reco_fakerate_eta->Sumw2();
04267     h_bjet_reco_fakerate_eta->Divide(h_bjet_reco_presel_eta);
04268     h_bjet_reco_fakerate_eta->SetTitle("FAKERATE TAUJET RECONSTRUCTION VS. ETA");
04269     h_bjet_reco_fakerate_phi=(TH1F*)h_bjet_reco_fake_phi->Clone("bjet_reco_fakerate_phi");
04270     h_bjet_reco_fakerate_phi->Sumw2();
04271     h_bjet_reco_fakerate_phi->Divide(h_bjet_reco_presel_phi);
04272     h_bjet_reco_fakerate_phi->SetTitle("FAKERATE TAUJET RECONSTRUCTION VS. PHI");
04273 
04274 
04275     // jets
04276     h_jet_reco_efficiency_pt=(TH1F*)h_jet_truth_matched_pt->Clone("jet_reco_efficiency_pt");
04277     h_jet_reco_efficiency_pt->Sumw2();
04278     h_jet_reco_efficiency_pt->Divide(h_jet_truth_presel_pt);
04279     h_jet_reco_efficiency_pt->SetTitle("EFFICIENCY JET RECONSTRUCTION VS. PT");
04280     h_jet_reco_efficiency_eta=(TH1F*)h_jet_truth_matched_eta->Clone("jet_reco_efficiency_eta");
04281     h_jet_reco_efficiency_eta->Sumw2();
04282     h_jet_reco_efficiency_eta->Divide(h_jet_truth_presel_eta);
04283     h_jet_reco_efficiency_eta->SetTitle("EFFICIENCY JET RECONSTRUCTION VS. ETA");
04284     h_jet_reco_efficiency_phi=(TH1F*)h_jet_truth_matched_phi->Clone("jet_reco_efficiency_phi");
04285     h_jet_reco_efficiency_phi->Sumw2();
04286     h_jet_reco_efficiency_phi->Divide(h_jet_truth_presel_phi);
04287     h_jet_reco_efficiency_phi->SetTitle("EFFICIENCY JET RECONSTRUCTION VS. PHI");
04288 
04289 
04290     h_jet_reco_fakerate_pt=(TH1F*)h_jet_reco_fake_pt->Clone("jet_reco_fakerate_pt");
04291     h_jet_reco_fakerate_pt->Sumw2();
04292     h_jet_reco_fakerate_pt->Divide(h_jet_reco_presel_pt);
04293     h_jet_reco_fakerate_pt->SetTitle("FAKERATE JET RECONSTRUCTION VS. PT");
04294     h_jet_reco_fakerate_eta=(TH1F*)h_jet_reco_fake_eta->Clone("jet_reco_fakerate_eta");
04295     h_jet_reco_fakerate_eta->Sumw2();
04296     h_jet_reco_fakerate_eta->Divide(h_jet_reco_presel_eta);
04297     h_jet_reco_fakerate_eta->SetTitle("FAKERATE JET RECONSTRUCTION VS. ETA");
04298     h_jet_reco_fakerate_phi=(TH1F*)h_jet_reco_fake_phi->Clone("jet_reco_fakerate_phi");
04299     h_jet_reco_fakerate_phi->Sumw2();
04300     h_jet_reco_fakerate_phi->Divide(h_jet_reco_presel_phi);
04301     h_jet_reco_fakerate_phi->SetTitle("FAKERATE JET RECONSTRUCTION VS. PHI");
04302     dir_presel_matching->cd("../");
04303 
04304 
04305     // cout<<h_higgs_mass->GetEntries()<<" events passed all the cuts."<<endl;
04306     //h_higgs_mass->GetBin(0)->GetBinContent();
04307 
04308     double nb_init(0);
04309     double nb_before(0);
04310     double nb_current(0);
04311 
04312     cout<<endl<<endl<<"====== Cut evolution ======"<<endl;
04313     cout<<"cut                                        eff   cumeff    events"<<endl;
04314     cout.width(38);
04315     cout<<left<<"All events: ";
04316     cout.width(27);
04317     cout<<right<<h_cut_evolution->GetBinContent(h_cut_evolution->FindBin(0.))<<endl;
04318     nb_init=h_cut_evolution->GetBinContent(h_cut_evolution->FindBin(0.));
04319     nb_before=nb_init;
04320     int rel_eff, cum_eff;
04321     for(int m=1; m<=cuts_total_nb; m++){
04322         nb_current=h_cut_evolution->GetBinContent(h_cut_evolution->FindBin(m));
04323         if(nb_before==0) rel_eff=0;
04324         else rel_eff=(int)(100.*nb_current/nb_before);
04325         if(nb_init==0) cum_eff=0;
04326         else cum_eff=(int)(100.*nb_current/nb_init);
04327 
04328     //  cout<<"rel eff: "<<nb_current/nb_before<<endl;
04329     //  cout<<"cumulated eff: "<<nb_current/nb_init<<endl;
04330         cout<<"cut ";
04331         cout.width(2);
04332         cout<<right<<m;
04333         cout<<": ";
04334         cout.width(25);
04335         cout<<left<<cuts[m];//<<endl;
04336         cout.width(12);cout.precision(3);
04337         cout<<right<<rel_eff<<"%";
04338         cout.width(8);
04339         cout<<right<<cum_eff<<"%";
04340         cout.width(10);
04341         cout<<right<<(int)(nb_current)<<endl;
04342         nb_before=nb_current;
04343     }
04344 
04345 
04346     cout<<endl;
04348     // SAVE THE ROOT FILE //
04350 
04351     m_tfile->Write();
04352     cout<<"root file written"<<endl;
04353 
04354     return;
04355 
04356 }
04357 
04358 //*****************************************************************************
04359 
04360 //::::::::::::::::::::::::::::::
04361 //:: METHOD fill_lepton_hists ::
04362 //::::::::::::::::::::::::::::::
04363 
04364 void MyHtautauAnalysis::fill_lepton_hists(const vector<MyVBFCandidate*> v_candidates_tmp,
04365                                           const int cut_number) {
04366 
04367     int i=cut_number;
04368     //-------------------
04369     //-- Build Vectors --
04370     //-------------------
04371     vector<MyParticlePair> vec_lepton_pairs;
04372     vector<MyParticle*> vec_leptons;
04373 
04374     if ( has_leptonpair ){
04375         vec_lepton_pairs = get_lepton_pairs(v_candidates_tmp);
04376         vec_leptons = get_leptons(vec_lepton_pairs);
04377     }
04378     else{
04379         vec_leptons = m_tools.append_vector(v_e_ana, v_mu_ana);
04380         vec_leptons = m_tools.append_vector(vec_leptons, v_taujet_ana);
04381     }
04382 
04383 
04384     vector<MyParticle*> vec_electrons(0);
04385     vector<MyParticle*> vec_muons(0);
04386     vector<MyParticle*> vec_taujets(0);
04387 
04388     for(unsigned int k=0; k<vec_leptons.size(); k++){
04389         if(TMath::Abs(vec_leptons[k]->pdgId()) == 11){
04390             vec_electrons.push_back(vec_leptons[k]);
04391         }
04392     }
04393 
04394     for(unsigned int k=0; k<vec_leptons.size(); k++){
04395         if(TMath::Abs(vec_leptons[k]->pdgId()) == 13){
04396             vec_muons.push_back(vec_leptons[k]);
04397         }
04398     }
04399 
04400     for(unsigned int k=0; k<vec_leptons.size(); k++){
04401         if(TMath::Abs(vec_leptons[k]->pdgId()) == 15){
04402             vec_taujets.push_back(vec_leptons[k]);
04403         }
04404     }
04405 
04406     // electron hits
04407     //* debug info */ cerr << "Before filling e histos"<<endl;
04408     (v_h_e_ana_nb[i])->Fill(vec_electrons.size(), weight);
04409     for (unsigned int j=0; j<vec_electrons.size(); j++){
04410         (v_h_e_ana_pt[i])->Fill((vec_electrons[j])->tlv().Pt()*GeV, weight);
04411         (v_h_e_ana_eta[i])->Fill((vec_electrons[j])->tlv().Eta(), weight);
04412         (v_h_e_ana_phi[i])->Fill((vec_electrons[j])->tlv().Phi(), weight);
04413 
04414     }
04415 
04416     // muon hists
04417     //* debug info */ cerr << "Before filling mu histos"<<endl;
04418     (v_h_mu_ana_nb[i])->Fill(vec_muons.size(), weight);
04419     for (unsigned int j=0; j<vec_muons.size(); j++){
04420         (v_h_mu_ana_pt[i])->Fill((vec_muons[j])->tlv().Pt()*GeV, weight);
04421         (v_h_mu_ana_eta[i])->Fill((vec_muons[j])->tlv().Eta(), weight);
04422         (v_h_mu_ana_phi[i])->Fill((vec_muons[j])->tlv().Phi(), weight);
04423     }
04424 
04425     // taujet hists
04426     //* debug info */ cerr << "Before filling taujet histos"<<endl;
04427     (v_h_taujet_ana_nb[i])->Fill(vec_taujets.size(), weight);
04428     for (unsigned int j=0; j<vec_taujets.size(); j++){
04429         (v_h_taujet_ana_pt[i])->Fill((vec_taujets[j])->tlv().Pt()*GeV, weight);
04430         (v_h_taujet_ana_eta[i])->Fill((vec_taujets[j])->tlv().Eta(), weight);
04431         (v_h_taujet_ana_phi[i])->Fill((vec_taujets[j])->tlv().Phi(), weight);
04432     }
04433 
04434     // lepton hists
04435     //* debug info */ cerr << "Before filling lepton histos"<<endl;
04436     (v_h_lepton_ana_nb[i])->Fill(vec_leptons.size(), weight);
04437     for (unsigned int j=0; j<vec_leptons.size(); j++){
04438         (v_h_lepton_ana_pt[i])->Fill((vec_leptons[j])->tlv().Pt()*GeV, weight);
04439         (v_h_lepton_ana_eta[i])->Fill((vec_leptons[j])->tlv().Eta(), weight);
04440         (v_h_lepton_ana_phi[i])->Fill((vec_leptons[j])->tlv().Phi(), weight);
04441 
04442     }
04443 
04444     // lepton pair hists
04445     //* debug info */ cerr << "Before filling lepton pair histos"<<endl;
04446     (v_h_2l_ana_nb[i])->Fill(vec_lepton_pairs.size(), weight);
04447     for (unsigned int j=0; j<vec_lepton_pairs.size(); j++){
04448         (v_h_2l_ana_dpt[i])->Fill((vec_lepton_pairs[j]).AbsDeltaPt()*GeV, weight);
04449         (v_h_2l_ana_deta[i])->Fill((vec_lepton_pairs[j]).AbsDeltaEta(), weight);
04450         (v_h_2l_ana_dphi[i])->Fill((vec_lepton_pairs[j]).AbsDeltaPhi(), weight);
04451         (v_h_2l_ana_dr[i])->Fill((vec_lepton_pairs[j]).DeltaR(), weight);
04452         (v_h_2l_ana_m[i])->Fill((vec_lepton_pairs[j]).M()*GeV, weight);
04453         double x1 = v_candidates_tmp[j]->get_collinear_approximation().get_x1();
04454         double x2 = v_candidates_tmp[j]->get_collinear_approximation().get_x2();
04455         (v_h_2l_extau1[i])->Fill(x1, weight);
04456         (v_h_2l_extau2[i])->Fill(x2, weight);
04457         (v_h_2l_extau12[i])->Fill(x1, weight);
04458         (v_h_2l_extau12[i])->Fill(x2, weight);
04459         ((TH2F*)v_h_2l_extau1vs2[i])->Fill(x1,x2, weight);
04460         (v_h_higgs_mass[i])->Fill(v_candidates_tmp[j]->get_collinear_approximation().get_M_comp_part()*GeV, weight);
04461     }
04462 
04463     return;
04464 
04465 }
04466 
04467 //*****************************************************************************
04468 
04469 //:::::::::::::::::::::::::::
04470 //:: METHOD fill_jet_hists ::
04471 //:::::::::::::::::::::::::::
04472 
04473 void MyHtautauAnalysis::fill_jet_hists(const vector<MyVBFCandidate*> v_candidates_tmp,
04474                                        const int cut_number) {
04475 
04476     int i=cut_number;
04477     //-------------------
04478     //-- Build Vectors --
04479     //-------------------
04480     vector<MyParticlePair> vec_tagjet_pairs;
04481     vector<MyParticle*> vec_tagjets;
04482 
04483     if ( has_jetpair ){
04484         vec_tagjet_pairs = get_tagjet_pairs(v_candidates_tmp);
04485         vec_tagjets = get_tagjets(vec_tagjet_pairs);
04486     }
04487     else{
04488         vec_tagjets = v_jet_ana;
04489     }
04490 
04491     // jet hists
04492     //* debug info */ cerr << "Before filling jet histos"<<endl;
04493     (v_h_jet_ana_nb[i])->Fill(vec_tagjets.size(), weight);
04494     for (unsigned int j=0; j<vec_tagjets.size(); j++){
04495         (v_h_jet_ana_pt[i])->Fill((vec_tagjets[j])->tlv().Pt()*GeV, weight);
04496         (v_h_jet_ana_eta[i])->Fill((vec_tagjets[j])->tlv().Eta(), weight);
04497         (v_h_jet_ana_phi[i])->Fill((vec_tagjets[j])->tlv().Phi(), weight);
04498     }
04499 
04500 
04501     // jet pair hists
04502     //* debug info */ cerr << "Before filling jet histos"<<endl;
04503     (v_h_2j_ana_nb[i])->Fill(vec_tagjet_pairs.size(), weight);
04504     for (unsigned int j=0; j<vec_tagjet_pairs.size(); j++){
04505         (v_h_2j_ana_dpt[i])->Fill((vec_tagjet_pairs[j]).AbsDeltaPt()*GeV, weight);
04506         (v_h_2j_ana_deta[i])->Fill((vec_tagjet_pairs[j]).AbsDeltaEta(), weight);
04507         (v_h_2j_ana_dphi[i])->Fill((vec_tagjet_pairs[j]).AbsDeltaPhi(), weight);
04508         (v_h_2j_ana_dr[i])->Fill((vec_tagjet_pairs[j]).DeltaR() , weight);
04509         (v_h_2j_ana_m[i])->Fill((vec_tagjet_pairs[j]).M() *GeV, weight);
04510     }
04511 
04512     return;
04513 
04514 }
04515 
04516 //*****************************************************************************
04517 
04518 //::::::::::::::::::::::::::::::::::::::
04519 //:: METHOD check_truth_lepton_filter ::
04520 //::::::::::::::::::::::::::::::::::::::
04521 
04522 int MyHtautauAnalysis::check_truth_lepton_filter(void) {
04523     // calculate number of leptons that would have passed
04524     // the lepton filter
04525     int e_truht_filter_nb(0);
04526     int mu_truht_filter_nb(0);
04527     vector<MyParticle*> v_truth_tmp;
04528     // get electrons
04529     v_truth_tmp = m_truth_manager.getParticles_with_ID(11);
04530     v_truth_tmp = m_tools.pt_eta_cut(v_truth_tmp, 5.0/GeV, -1.0, 0.0, 2.7);
04531     e_truht_filter_nb = v_truth_tmp.size();
04532     // get muons
04533     v_truth_tmp = m_truth_manager.getParticles_with_ID(13);
04534     v_truth_tmp = m_tools.pt_eta_cut(v_truth_tmp, 5.0/GeV, -1.0, 0.0, 2.7);
04535     mu_truht_filter_nb = v_truth_tmp.size();
04536     h_emu_truth_filter_nb->Fill(e_truht_filter_nb+mu_truht_filter_nb);    
04537     return (e_truht_filter_nb+mu_truht_filter_nb);
04538 }
04539 
04540 //*****************************************************************************
04541 
04542 //::::::::::::::::::::::::::::::::
04543 //:: METHOD analyse_truth_decay ::
04544 //::::::::::::::::::::::::::::::::
04545 
04546 void MyHtautauAnalysis::analyse_truth_decay(void) {
04547 
04548     // vector with pdg-IDs that are interesting to search for
04549     // needed for calling the moethod find_decay_chain_of()
04550     // of the truth particle manager
04551     vector<unsigned int> v_int_id;
04552     v_int_id.clear();
04553     v_int_id.push_back(23);
04554     v_int_id.push_back(24);
04555     v_int_id.push_back(25);
04556     
04557     // search for interesting decays
04558 //* debug info */ cerr<<"before search for interesting decays"<<endl;
04559     int int_decay_chains = m_truth_manager.find_decay_chain_of(v_int_id);
04560 //    cout<<"int_decay_chains: "<<int_decay_chains<<endl;
04561     if (int_decay_chains!=1 && int_decay_chains!=2){
04562         cout<<"Warning! "<<int_decay_chains
04563             <<" interesting decay chains found!"
04564             <<endl;
04565             return;
04566     }
04567     else{
04568 //* debug info */ cout<<"interesting decay chains: "<<int_decay_chains<<endl;
04569     }
04570     // evaluate the found interesting decay chains
04571 //* debug info */ cerr<<"before evaluate the found interesting decay chains"<<endl;
04572     m_truth_manager.process_decay_chains();
04573     calculate_decay_mode();
04574     fill_decay_mode_hists(false);
04575 
04576     // delta R of truth tau and tau decay product
04577     MyTruthParticle* truth_tau;
04578     MyTruthParticle* truth_antitau;
04579     MyTruthParticle* truth_tau_decay_product;
04580     MyTruthParticle* truth_antitau_decay_product;
04581     truth_tau = NULL;
04582     truth_antitau = NULL;
04583     truth_tau_decay_product = NULL;
04584     truth_antitau_decay_product = NULL;
04585 
04586     // get truth taus
04587     vector<MyTruthParticle*> vec1;
04588     vec1 = m_truth_manager.get_gen1_children_intpart(0);
04589     for(unsigned int i=0; i<vec1.size(); i++){
04590         //vec1[i]->Print();
04591         if((vec1[i])->pdgId()==15){
04592             truth_tau = vec1[i];
04593         }
04594         if((vec1[i])->pdgId()==-15){
04595             truth_antitau = vec1[i];
04596         }
04597     }
04598     //cout<<"\nTruth taus: \n";
04599     //truth_tau->Print();
04600     //truth_antitau->Print();
04601 
04602     // get truth tau decay products
04603     vector< vector< MyTruthParticle * > > vecvec2;
04604     vecvec2 = m_truth_manager.get_gen2_children_intpart(0);
04605     for(unsigned int i=0; i<vecvec2.size(); i++){
04606         for(unsigned int j=0; j<vecvec2[i].size(); j++){
04607             if( ((vecvec2[i])[j])->pdgId()==11 || ((vecvec2[i])[j])->pdgId()==13 ){
04608                 truth_tau_decay_product = (vecvec2[i])[j];
04609                 h_truth_taudecay_dr->Fill( truth_tau->tlv().DeltaR((vecvec2[i])[j]->tlv()) );
04610             }
04611             if( ((vecvec2[i])[j])->pdgId()==-12 || ((vecvec2[i])[j])->pdgId()==-14 ){
04612                 h_truth_taudecay_dr->Fill( truth_tau->tlv().DeltaR((vecvec2[i])[j]->tlv()) );
04613             }
04614             if( ((vecvec2[i])[j])->pdgId()==16 ){
04615                 h_truth_taudecay_dr->Fill( truth_tau->tlv().DeltaR((vecvec2[i])[j]->tlv()) );
04616             }
04617             if( ((vecvec2[i])[j])->pdgId()==-11 || ((vecvec2[i])[j])->pdgId()==-13 ){
04618                 truth_antitau_decay_product = (vecvec2[i])[j];
04619                 h_truth_antitaudecay_dr->Fill( truth_antitau->tlv().DeltaR((vecvec2[i])[j]->tlv()) );
04620             }
04621             if( ((vecvec2[i])[j])->pdgId()==12 || ((vecvec2[i])[j])->pdgId()==14 ){
04622                 h_truth_antitaudecay_dr->Fill( truth_antitau->tlv().DeltaR((vecvec2[i])[j]->tlv()) );
04623             }
04624             if( ((vecvec2[i])[j])->pdgId()==-16 ){
04625                 h_truth_antitaudecay_dr->Fill( truth_antitau->tlv().DeltaR((vecvec2[i])[j]->tlv()) );
04626             }
04627         }
04628     }
04629     //cout<<"Truth tau decay products: \n";
04630     //truth_tau_decay_product->Print();
04631     //truth_antitau_decay_product->Print();
04632     //if(truth_tau!=NULL && truth_tau_decay_product!=NULL && truth_antitau!=NULL && truth_antitau_decay_product!=NULL){
04633     //    h_truth_taudecay_dr->Fill( truth_tau->tlv().DeltaR(truth_tau_decay_product->tlv()) );
04634     //    h_truth_antitaudecay_dr->Fill( truth_antitau->tlv().DeltaR(truth_antitau_decay_product->tlv()) );
04635     //}
04636 
04637     
04638     // Some calculations in the rest frame of the Higgs (Truth)
04639 /*
04640     if(1){
04641         if(m_truth_manager.get_primary_intpart(0)!=NULL){
04642             // the lorentz vector of the Higgs
04643             TLorentzVector tlv_H;
04644             // the lorentz vector of the Higgs in its rest frame
04645             TLorentzVector tlv_H_rf;
04646             // the lorentz vector of the two leptons, rest frame
04647             TLorentzVector tlv_l1;
04648             TLorentzVector tlv_l1_rf;
04649             TLorentzVector tlv_l2;
04650             TLorentzVector tlv_l2_rf;
04651             // the Higgs rest frame times -1
04652             // (boost with it and you get the rest frame)
04653             TVector3 b;
04654             
04655             tlv_H = m_truth_manager.get_primary_intpart(0)->tlv();
04656             b = -(tlv_H.BoostVector());
04657             tlv_H_rf = tlv_H;
04658             tlv_H_rf.Boost(b);
04659             
04660             //cout<<"M(H/Z)        "<<tlv_H.M()<<endl;
04661             //cout<<"px, py, pz    "<<tlv_H.Px()<<", "<<tlv_H.Py()<<", "<<tlv_H.Pz()<<endl;
04662             //cout<<"M(H/Z)     rf "<<tlv_H_rf.M()<<endl;
04663             //cout<<"px, py, pz rf "<<tlv_H_rf.Px()<<", "<<tlv_H_rf.Py()<<", "<<tlv_H_rf.Pz()<<endl;
04664             
04665             vector<MyTruthParticle*> vec1;
04666             //vector<MyTruthParticle*> vec1_rf;
04667             vector<TLorentzVector> vec2_rf;
04668             vector<TLorentzVector> vec2;
04669             vector<TLorentzVector> vec_tau1;
04670             TLorentzVector v1;
04671             TLorentzVector tmp_tlv;
04672             vec1 = m_truth_manager.get_gen1_children_intpart(0);
04673             //m_tools.PrintVector(vec1);
04674             for(unsigned int i=0; i<vec1.size(); i++){
04675                 //vec1[i]->Print();
04676                 if((vec1[i])->pdgId()==15){
04677                     vec_tau1.push_back(vec1[i]->tlv());
04678                 }
04679                 tmp_tlv = vec1[i]->tlv();
04680                 tmp_tlv.Boost(b);
04681                 //cout<<"px, py, pz    "<<tmp_tlv.Px()<<", "<<tmp_tlv.Py()<<", "<<tmp_tlv.Pz()<<endl;
04682                 v1 = v1 + tmp_tlv;
04683             }
04684             cout<<"Summ gen 1 "<<v1.M()<<endl;
04685 
04686             vector< vector< MyTruthParticle * > > vecvec2;
04687             vecvec2 = m_truth_manager.get_gen2_children_intpart(0);
04688             for(unsigned int i=0; i<vecvec2.size(); i++){
04689                 for(unsigned int j=0; j<vecvec2[i].size(); j++){
04690                     //((vecvec2[i])[j])->Print();
04691                     if( ((vecvec2[i])[j])->pdgId()==13 ||
04692                           ((vecvec2[i])[j])->pdgId()==-13 ||
04693                           ((vecvec2[i])[j])->pdgId()==11 ||
04694                           ((vecvec2[i])[j])->pdgId()==-11 ){
04695                         vec2_rf.push_back(((vecvec2[i])[j])->tlv());
04696                         //((vecvec2[i])[j])->Print();
04697                     }
04698                     if( ((vecvec2[i])[j])->pdgId()==13 ||
04699                           ((vecvec2[i])[j])->pdgId()==11 ){
04700                         vec2.push_back(((vecvec2[i])[j])->tlv());
04701                         //((vecvec2[i])[j])->Print();
04702                     }
04703                     //tmp_tlv = vec1[i]->tlv();
04704                     //tmp_tlv.Boost(b);
04705                     //cout<<"px, py, pz    "<<tmp_tlv.Px()<<", "<<tmp_tlv.Py()<<", "<<tmp_tlv.Pz()<<endl;
04706                     //v1 = v1 + tmp_tlv;
04707                 }
04708             }
04709             for(unsigned int i=0; i<vec2_rf.size(); i++){
04710                 vec2_rf[i].Boost(b);
04711                 //cout<<"px, py, pz    "<<vec2_rf[i].Px()<<", "<<vec2_rf[i].Py()<<", "<<vec2_rf[i].Pz()<<endl;
04712             }
04713 
04714             if( vec2_rf.size()==2 ){
04715                 cout<<vec2_rf[0].DeltaR(vec2_rf[1])<<endl;
04716                 h_truth_2l_rf_dr->Fill(vec2_rf[0].DeltaR(vec2_rf[1]), 1);
04717             }
04718 
04719             if( vec_tau1.size()==1 ){
04720                 cout<<"neu: "<<vec_tau1[0].DeltaR(tlv_H)<<endl;
04721                 h_truth_2l_rf_dr->Fill(vec_tau1[0].DeltaR(tlv_H), 1);
04722             }
04723             
04724             
04725         }
04726     }//*/
04727     return;
04728 }
04729 
04730 //*****************************************************************************
04731 
04732 //::::::::::::::::::::::::::::::::
04733 //:: METHOD fill_all_ana_histos ::
04734 //::::::::::::::::::::::::::::::::
04735 
04736 void MyHtautauAnalysis::fill_all_ana_histos(const vector<MyVBFCandidate*> v_candidates_tmp,
04737                                             const int cut_number){
04738 
04739     //* debug info */ cerr << "In fill_all_ana_histos, cut "<<cut_number<<endl;
04740     int i = cut_number;
04741     vector<MyVBFCandidate*> v_candidates_survived;
04742     v_candidates_survived.clear();
04743 
04744     // check if there is a candidate that survived all the cuts up to here
04745     bool surviving_cand_exists(false);
04746 
04747     for (unsigned int j=0; j<v_candidates_ana.size(); j++){
04748         //* debug info */ cerr << "cut_map candidate "<<j<<": "<<v_candidates_ana[j]->get_cut_map()<<endl;
04749         if(v_candidates_ana[j]->get_cut_map()==0){
04750             v_candidates_survived.push_back( v_candidates_ana[j] );
04751             h_cut_evolution_candidates->Fill(i, weight);
04752             surviving_cand_exists = true;
04753         }
04754     }
04755 
04756     if(surviving_cand_exists) h_cut_evolution->Fill(i, weight);
04757     //* debug info */ cerr << "Fill in cut_evolution histo: "<<i<<endl;
04758     if(surviving_cand_exists) fill_lepton_hists(v_candidates_survived, cut_number);
04759     if(surviving_cand_exists) fill_jet_hists(v_candidates_survived, cut_number);
04760 
04761     for (unsigned int j=0; j<v_candidates_survived.size(); j++){
04762         if(v_candidates_survived[j]->has_lepton_pair() && v_candidates_survived[j]->has_tagjet_pair()){
04763             (v_h_lj_deta_min[i])->Fill(v_candidates_survived[j]->get_lj_DeltaEtaMin(), weight);
04764             (v_h_lj_deta_max[i])->Fill(v_candidates_survived[j]->get_lj_DeltaEtaMin(), weight);
04765         }
04766     }
04767 
04768 
04769 // MET histos:
04770     //* debug info */ cout << "Before filling MET histos"<<endl;
04771     double rx;
04772     double ry;
04773     double tx;
04774     double ty;
04775     double dx;
04776     double dy;
04777     double dpt_scalar;
04778 
04779     // MET total
04780     rx = missinget_ana.get_missinget(met_option).met_x();
04781     ry = missinget_ana.get_missinget(met_option).met_y();
04782     tx = missinget_ana.get_missinget("TruthMET_NonInt").met_x();
04783     ty = missinget_ana.get_missinget("TruthMET_NonInt").met_y();
04784     dx = rx - tx;
04785     dy = ry - ty;
04786     dpt_scalar=sqrt((rx*rx)+(ry*ry))-sqrt((tx*tx)+(ty*ty));
04787 
04788     // Fill histos
04789     (v_h_etmiss_ana_reco_pt[i]) ->Fill(sqrt((rx*rx)+(ry*ry))*GeV, weight);
04790     (v_h_etmiss_ana_reco_x[i]) ->Fill(rx*GeV, weight);
04791     (v_h_etmiss_ana_reco_y[i]) ->Fill(ry*GeV, weight);
04792     (v_h_etmiss_ana_truth_pt[i])->Fill(sqrt((tx*tx)+(ty*ty))*GeV, weight);
04793     (v_h_etmiss_ana_truth_x[i])->Fill(tx*GeV, weight);
04794     (v_h_etmiss_ana_truth_y[i])->Fill(ty*GeV, weight);
04795     (v_h_etmiss_ana_reco_truth_dpt[i]) ->Fill(sqrt((dx*dx)+(dy*dy))*GeV, weight);
04796     (v_h_etmiss_ana_reco_truth_dpt_scalar[i]) ->Fill(dpt_scalar*GeV, weight);
04797     (v_h_etmiss_ana_reco_truth_dx[i]) ->Fill(dx*GeV, weight);
04798     (v_h_etmiss_ana_reco_truth_dy[i]) ->Fill(dy*GeV, weight);
04799     h_etmiss_reco_truth_dptvscut->Fill(i,sqrt((dx*dx)+(dy*dy))*GeV, weight);
04800 
04801 
04802     // Muon part
04803     rx = missinget_ana.get_missinget(met_muon_contribution).met_x();
04804     ry = missinget_ana.get_missinget(met_muon_contribution).met_y();
04805     tx = missinget_ana.get_missinget("TruthMET_Muons").met_x();
04806     ty = missinget_ana.get_missinget("TruthMET_Muons").met_y();
04807     dx = rx - tx;
04808     dy = ry - ty;
04809     dpt_scalar=sqrt((rx*rx)+(ry*ry))-sqrt((tx*tx)+(ty*ty));
04810     // Fill histos
04811     (v_h_etmiss_muon_ana_reco_pt[i]) ->Fill(sqrt((rx*rx)+(ry*ry))*GeV, weight);
04812     (v_h_etmiss_muon_ana_reco_x[i]) ->Fill(rx*GeV, weight);
04813     (v_h_etmiss_muon_ana_reco_y[i]) ->Fill(ry*GeV, weight);
04814     (v_h_etmiss_muon_ana_truth_pt[i])->Fill(sqrt((tx*tx)+(ty*ty))*GeV, weight);
04815     (v_h_etmiss_muon_ana_truth_x[i])->Fill(tx*GeV, weight);
04816     (v_h_etmiss_muon_ana_truth_y[i])->Fill(ty*GeV, weight);
04817     (v_h_etmiss_muon_ana_reco_truth_dpt_scalar[i]) ->Fill(dpt_scalar*GeV, weight);
04818     (v_h_etmiss_muon_ana_reco_truth_dpt[i]) ->Fill(sqrt((dx*dx)+(dy*dy))*GeV, weight);
04819     (v_h_etmiss_muon_ana_reco_truth_dx[i]) ->Fill(dx*GeV, weight);
04820     (v_h_etmiss_muon_ana_reco_truth_dy[i]) ->Fill(dy*GeV, weight);
04821 
04822     return;
04823 }
04824 
04825 //*****************************************************************************
04826 
04827 //::::::::::::::::::::::::::::::::::
04828 //:: METHOD fill_candidate_ntuple ::
04829 //::::::::::::::::::::::::::::::::::
04830 
04831 void MyHtautauAnalysis::fill_candidate_ntuple(const vector<MyVBFCandidate*> v_candidates_tmp){
04832 
04833     MyVBFCandidate* candidate;
04834 
04835     // Prepare vector of candidates that survived all the cuts
04836     vector<MyVBFCandidate*> v_candidates_survived;
04837     v_candidates_survived.clear();
04838     bool surviving_cand_exists(false);
04839 
04840     for (unsigned int j=0; j<v_candidates_ana.size(); j++){
04841     //for (unsigned int j=0; j<1; j++){
04842         //* debug info */ cerr << "cut_map candidate "<<j<<": "<<v_candidates_ana[j]->get_cut_map()<<endl;
04843         if(v_candidates_tmp[j]->get_cut_map()==0){
04844             v_candidates_survived.push_back( v_candidates_tmp[j] );
04845             surviving_cand_exists = true;
04846         }
04847     }
04848     // write out the MVA ntuple for all surviving candidates
04849     if (surviving_cand_exists && has_jetpair && has_leptonpair){
04850         for (unsigned int j=0; j<v_candidates_survived.size(); j++){
04851             candidate = v_candidates_survived[j];
04852 
04853             MVAvar_etmiss =     candidate->get_missinget().met();
04854             MVAvar_H_m =        candidate->get_collinear_approximation().get_M_comp_part();
04855             MVAvar_x1 =         candidate->get_collinear_approximation().get_x1();
04856             MVAvar_x2 =         candidate->get_collinear_approximation().get_x2();
04857             MVAvar_ll_dr =      candidate->get_lepton_pair().DeltaR();
04858             MVAvar_ll_dphi =    TMath::Cos(
04859                                 candidate->get_lepton_pair().DeltaPhi());
04860             MVAvar_ll_pt1 =     candidate->get_lepton_pair().get_particle1()->tlv().Pt();
04861             MVAvar_ll_pt2 =     candidate->get_lepton_pair().get_particle2()->tlv().Pt();
04862             MVAvar_jj_m =       candidate->get_tagjet_pair().M();
04863             MVAvar_jj_dphi =    candidate->get_tagjet_pair().AbsDeltaPhi();
04864             MVAvar_jj_deta =    candidate->get_tagjet_pair().AbsDeltaEta();
04865             MVAvar_jj_pt1 =     candidate->get_tagjet_pair().get_particle1()->tlv().Pt();
04866             MVAvar_jj_pt2 =     candidate->get_tagjet_pair().get_particle2()->tlv().Pt();
04867             MVAvar_jl_deta_min= candidate->get_lj_DeltaEtaMin();
04868             MVAvar_jl_deta_max= candidate->get_lj_DeltaEtaMax();
04869             MVAvar_pt_all =     candidate->get_pt_sum().Pt();
04870             MVAvar_m_t =        get_transverse_mass(candidate);
04871             MVAvar_weight =     weight;
04872 
04873             // fill the tree
04874             tree_MVA_variables->Fill();
04875         }
04876     }
04877 
04878     // write out the ntuple for all candidates
04879     for (unsigned int j=0; j<v_candidates_tmp.size(); j++){
04880     //for (unsigned int j=0; j<0; j++){
04881         candidate = v_candidates_tmp[j];
04882         // values that are always present:
04883         tcd_cand_nb         = v_candidates_tmp.size();
04884         tcd_cand_id         = j;
04885         tcd_cut_map         = candidate->get_cut_map();
04886         tcd_has_leptons     = candidate->has_lepton_pair();
04887         tcd_has_jets        = candidate->has_tagjet_pair();
04888         tcd_ev_e_nb         = v_e_ana.size();
04889         tcd_ev_mu_nb        = v_mu_ana.size();
04890         tcd_ev_tau_nb       = v_taujet_ana.size();
04891         tcd_ev_jet_nb       = v_jet_ana.size();
04892         tcd_etmiss          = candidate->get_missinget().met();
04893         tcd_etmiss_phi      = candidate->get_missinget().tlv().Phi();
04894         tcd_weight          = weight;
04895         //tcd_Event is set above
04896         //tcd_Run   is set above
04897         //tcd_Entry is set above
04898         if( candidate->has_lepton_pair() ){
04899             tcd_ll_dr           = candidate->get_lepton_pair().DeltaR();
04900             tcd_ll_dphi         = candidate->get_lepton_pair().AbsDeltaPhi();
04901             tcd_ll_dphi_noabs   = candidate->get_lepton_pair().DeltaPhi();
04902             tcd_ll_deta         = candidate->get_lepton_pair().AbsDeltaEta();
04903             tcd_ll_dpt          = candidate->get_lepton_pair().AbsDeltaPt();
04904             tcd_l1_pdgId        = candidate->get_lepton_pair().get_particle1()->pdgId();
04905             tcd_l2_pdgId        = candidate->get_lepton_pair().get_particle2()->pdgId();
04906             tcd_l1_pt           = candidate->get_lepton_pair().get_particle1()->tlv().Pt();
04907             tcd_l2_pt           = candidate->get_lepton_pair().get_particle2()->tlv().Pt();
04908             tcd_l1_eta          = candidate->get_lepton_pair().get_particle1()->tlv().Eta();
04909             tcd_l2_eta          = candidate->get_lepton_pair().get_particle2()->tlv().Eta();
04910             tcd_l1_phi          = candidate->get_lepton_pair().get_particle1()->tlv().Phi();
04911             tcd_l2_phi          = candidate->get_lepton_pair().get_particle2()->tlv().Phi();
04912             tcd_x1              = candidate->get_collinear_approximation().get_x1();
04913             tcd_x2              = candidate->get_collinear_approximation().get_x2();
04914             // truth H_m
04915             //tcd_H_m             = m_truth_manager.get_primary_intpart(0)->tlv().M();
04916             // old style
04917             //tcd_H_m             = candidate->get_collinear_approximation().get_M_comp_part();
04918             // new style
04919             tcd_H_m             = candidate->get_collinear_approximation().get_tlv_comp_part().M();
04920             tcd_H_pt            = candidate->get_collinear_approximation().get_tlv_comp_part().Pt();
04921             tcd_H_eta           = candidate->get_collinear_approximation().get_tlv_comp_part().Eta();
04922             tcd_H_phi           = candidate->get_collinear_approximation().get_tlv_comp_part().Phi();
04923             tcd_m_t             = get_transverse_mass(candidate);
04924         }
04925         else{
04926             tcd_ll_dr           = -99.;
04927             tcd_ll_dphi         = -99.;
04928             tcd_ll_dphi_noabs   = -99.;
04929             tcd_ll_deta         = -99.;
04930             tcd_ll_dpt          = -99.;
04931             tcd_l1_pdgId        = -99;
04932             tcd_l2_pdgId        = -99;
04933             tcd_l1_pt           = -99.;
04934             tcd_l2_pt           = -99.;
04935             tcd_l1_eta          = -99.;
04936             tcd_l2_eta          = -99.;
04937             tcd_l1_phi          = -99.;
04938             tcd_l2_phi          = -99.;
04939             tcd_x1              = -99.;
04940             tcd_x2              = -99.;
04941             tcd_H_m             = -99.;
04942             tcd_H_pt            = -99.;
04943             tcd_H_eta           = -99.;
04944             tcd_H_phi           = -99.;
04945             tcd_m_t             = -99.;
04946         }
04947         vector<MyParticle*> vec_centraljets;
04948         if( candidate->has_tagjet_pair() ){
04949             vec_centraljets = get_centraljet_candidates(v_jet_ana, candidate);
04950             tcd_jj_dphi         = candidate->get_tagjet_pair().AbsDeltaPhi();
04951             tcd_jj_dphi_noabs   = candidate->get_tagjet_pair().DeltaPhi();
04952             tcd_jj_deta         = candidate->get_tagjet_pair().AbsDeltaEta();
04953             tcd_jj_dpt          = candidate->get_tagjet_pair().AbsDeltaPt();
04954             tcd_jj_m            = candidate->get_tagjet_pair().M();
04955             tcd_btag_weight     = get_max_btag_weight(candidate, v_jet_ana);
04956             tcd_j1_pt           = candidate->get_tagjet_pair().get_particle1()->tlv().Pt();
04957             tcd_j2_pt           = candidate->get_tagjet_pair().get_particle2()->tlv().Pt();
04958             tcd_j1_eta          = candidate->get_tagjet_pair().get_particle1()->tlv().Eta();
04959             tcd_j2_eta          = candidate->get_tagjet_pair().get_particle2()->tlv().Eta();
04960             tcd_j1_phi          = candidate->get_tagjet_pair().get_particle1()->tlv().Phi();
04961             tcd_j2_phi          = candidate->get_tagjet_pair().get_particle2()->tlv().Phi();
04962             tcd_cj_nb           = vec_centraljets.size();
04963             if(vec_centraljets.size()>0){
04964                 tcd_cj1_pt          = vec_centraljets[0]->tlv().Pt();
04965                 tcd_cj1_eta         = vec_centraljets[0]->tlv().Eta();
04966                 tcd_cj1_phi         = vec_centraljets[0]->tlv().Phi();
04967             }
04968             else{
04969                 tcd_cj1_pt          = -99.;
04970                 tcd_cj1_eta         = -99.;
04971                 tcd_cj1_phi         = -99.;
04972             }
04973             if(vec_centraljets.size()>1){
04974                 tcd_cj2_pt          = vec_centraljets[1]->tlv().Pt();
04975                 tcd_cj2_eta         = vec_centraljets[1]->tlv().Eta();
04976                 tcd_cj2_phi         = vec_centraljets[1]->tlv().Phi();
04977             }
04978             else{
04979                 tcd_cj2_pt          = -99.;
04980                 tcd_cj2_eta         = -99.;
04981                 tcd_cj2_phi         = -99.;
04982             }
04983             tcd_bjet_val        = 0.0;
04984         }
04985         else{
04986             tcd_jj_dphi         = -99.;
04987             tcd_jj_dphi_noabs   = -99.;
04988             tcd_jj_deta         = -99.;
04989             tcd_jj_dpt          = -99.;
04990             tcd_jj_m            = -99.;
04991             tcd_btag_weight     = -99.;
04992             tcd_j1_pt           = -99.;
04993             tcd_j2_pt           = -99.;
04994             tcd_j1_eta          = -99.;
04995             tcd_j2_eta          = -99.;
04996             tcd_j1_phi          = -99.;
04997             tcd_j2_phi          = -99.;
04998             tcd_cj_nb           =  0;
04999             tcd_cj1_pt          = -99.;
05000             tcd_cj2_pt          = -99.;
05001             tcd_cj1_eta         = -99.;
05002             tcd_cj2_eta         = -99.;
05003             tcd_cj1_phi         = -99.;
05004             tcd_cj2_phi         = -99.;
05005             tcd_bjet_val        = -99.;
05006         }
05007         if( candidate->has_lepton_pair() && candidate->has_tagjet_pair()){
05008             tcd_jl_deta_min     = candidate->get_lj_DeltaEtaMin();
05009             tcd_jl_deta_max     = candidate->get_lj_DeltaEtaMax();
05010             tcd_pt_all          = candidate->get_pt_sum().Pt();
05011         }
05012         else{
05013             tcd_jl_deta_min     = -99.;
05014             tcd_jl_deta_max     = -99.;
05015             tcd_pt_all          = -99.;
05016         }
05017 
05018 
05019         // fill the tree
05020         if( output_level_cand_ntuple==0 ){
05021             tree_cand_data->Fill();
05022         }
05023         else if ( output_level_cand_ntuple==1 ) {
05024             if( candidate->has_lepton_pair() && candidate->has_tagjet_pair() ){
05025                 tree_cand_data->Fill();
05026             }
05027         }
05028         else {
05029             cerr<<"Error: output_level_cand_ntuple = "<<output_level_cand_ntuple
05030                 <<" not known!"<<endl;
05031             exit(1);
05032         }
05033     }
05034 
05035     return;
05036 
05037 }
05038 
05039 //*****************************************************************************
05040 
05041 //:::::::::::::::::::::::::::::
05042 //:: METHOD get_tagjet_pairs ::
05043 //:::::::::::::::::::::::::::::
05044 
05045 vector<MyParticlePair>
05046 MyHtautauAnalysis::get_tagjet_pairs(vector<MyVBFCandidate*> vec_candidates_tmp){
05047 
05048     vector<MyParticlePair> vec_tagjet_pairs(0);
05049 
05050     for(unsigned int iCand=0; iCand<vec_candidates_tmp.size(); iCand++){
05051         bool bool_add_tagjet_pair = true;
05052 
05053         MyParticlePair tagjet_pair
05054                 = vec_candidates_tmp[iCand]->get_tagjet_pair();
05055 
05056         MyParticle* jet1 = tagjet_pair.get_particle1();
05057         MyParticle* jet2 = tagjet_pair.get_particle2();
05058 
05059         for(unsigned int iJP=0; iJP<vec_tagjet_pairs.size(); iJP++){
05060 
05061             if( jet1->index() == vec_tagjet_pairs[iJP].get_particle1()->index() &&
05062                 jet2->index() == vec_tagjet_pairs[iJP].get_particle2()->index() ){
05063 
05064                 bool_add_tagjet_pair = false;
05065                 break;
05066                 }
05067         }
05068 
05069         if(bool_add_tagjet_pair){
05070             vec_tagjet_pairs.push_back( tagjet_pair );
05071         }
05072 
05073     }
05074 
05075     return vec_tagjet_pairs;
05076 
05077 }
05078 
05079 //*****************************************************************************
05080 
05081 //:::::::::::::::::::::::::::::
05082 //:: METHOD get_lepton_pairs ::
05083 //:::::::::::::::::::::::::::::
05084 
05085 vector<MyParticlePair>
05086 MyHtautauAnalysis::get_lepton_pairs(vector<MyVBFCandidate*> vec_candidates_tmp){
05087 
05088     vector<MyParticlePair> vec_lepton_pairs(0);
05089 
05090     for(unsigned int iCand=0; iCand<vec_candidates_tmp.size(); iCand++){
05091 
05092         bool bool_add_lepton_pair = true;
05093 
05094         MyParticlePair lepton_pair
05095                 = vec_candidates_tmp[iCand]->get_lepton_pair();
05096 
05097         MyParticle* lepton1 =  lepton_pair.get_particle1();
05098         MyParticle* lepton2 =  lepton_pair.get_particle2();
05099 
05100         for(unsigned int iLP=0; iLP<vec_lepton_pairs.size(); iLP++){
05101             if( lepton1->pdgId() == vec_lepton_pairs[iLP].get_particle1()->pdgId() &&
05102                 lepton2->pdgId() == vec_lepton_pairs[iLP].get_particle2()->pdgId() &&
05103                 lepton1->index() == vec_lepton_pairs[iLP].get_particle1()->index() &&
05104                 lepton2->index() == vec_lepton_pairs[iLP].get_particle2()->index() ){
05105                 bool_add_lepton_pair = false;
05106                 break;
05107                 }
05108         }
05109 
05110         if(bool_add_lepton_pair){
05111             vec_lepton_pairs.push_back( lepton_pair );
05112         }
05113     }
05114 
05115     return vec_lepton_pairs;
05116 
05117 }
05118 
05119 //*****************************************************************************
05120 
05121 //::::::::::::::::::::::::
05122 //:: METHOD get_tagjets ::
05123 //::::::::::::::::::::::::
05124 
05125 vector<MyParticle*>
05126 MyHtautauAnalysis::get_tagjets(vector<MyParticlePair> vec_tagjet_pairs){
05127 
05128     vector<MyParticle*> vec_tagjets(0);
05129 
05130     for(unsigned int k=0; k<vec_tagjet_pairs.size(); k++){
05131         bool bool_add1 = true;
05132         bool bool_add2 = true;
05133 
05134         MyParticle* jet1 =  vec_tagjet_pairs[k].get_particle1();
05135         MyParticle* jet2 =  vec_tagjet_pairs[k].get_particle2();
05136 
05137         //cout << "jetsize: "<< vec_tagjets.size() << endl;
05138         for(unsigned int iJet=0; iJet<vec_tagjets.size(); iJet++){
05139 
05140             //cout << "iJet: "<< iJet << endl;
05141             if( jet1->index() == vec_tagjets[iJet]->index() ){
05142                 bool_add1 = false;
05143                 break;
05144             }
05145         }
05146         if(bool_add1) vec_tagjets.push_back(jet1);
05147 
05148         for(unsigned int iJet=0; iJet<vec_tagjets.size(); iJet++){
05149 
05150             if( jet2->index() == vec_tagjets[iJet]->index() ){
05151                 bool_add2 = false;
05152                 break;
05153             }
05154         }
05155 
05156         if(bool_add2) vec_tagjets.push_back(jet2);
05157 
05158     }
05159 
05160     return vec_tagjets;
05161 
05162 }
05163 
05164 //*****************************************************************************
05165 
05166 //::::::::::::::::::::::::
05167 //:: METHOD get_leptons ::
05168 //::::::::::::::::::::::::
05169 
05170 vector<MyParticle*>
05171 MyHtautauAnalysis::get_leptons(vector<MyParticlePair> vec_lepton_pairs){
05172 
05173     vector<MyParticle*> vec_leptons(0);
05174 
05175     for(unsigned int k=0; k<vec_lepton_pairs.size(); k++){
05176 
05177         bool bool_add1 = true;
05178         bool bool_add2 = true;
05179 
05180         MyParticle* lepton1 = vec_lepton_pairs[k].get_particle1();
05181         MyParticle* lepton2 = vec_lepton_pairs[k].get_particle2();
05182 
05183         for(unsigned int iLep=0; iLep<vec_leptons.size(); iLep++){
05184 
05185             if( lepton1->pdgId() == vec_leptons[iLep]->pdgId() &&
05186                 lepton1->index() == vec_leptons[iLep]->index() ){
05187 
05188                 bool_add1 = false;
05189                 break;
05190                 }
05191         }
05192 
05193         if(bool_add1) vec_leptons.push_back(lepton1);
05194 
05195         for(unsigned int iLep=0; iLep<vec_leptons.size(); iLep++){
05196 
05197             if( lepton2->pdgId() == vec_leptons[iLep]->pdgId() &&
05198                 lepton2->index() == vec_leptons[iLep]->index() ){
05199 
05200                 bool_add2 = false;
05201                 break;
05202                 }
05203         }
05204 
05205         if(bool_add2) vec_leptons.push_back(lepton2);
05206 
05207     }
05208 
05209     return vec_leptons;
05210 
05211 }
05212 
05213 
05214 //*****************************************************************************
05215 
05216 //::::::::::::::::::::::::::::::::::::::
05217 //:: METHOD get_centraljet_candidates ::
05218 //::::::::::::::::::::::::::::::::::::::
05219 
05220 vector<MyParticle*>
05221 MyHtautauAnalysis::get_centraljet_candidates(vector<MyParticle*> vec_jets_tmp,
05222                                              MyVBFCandidate* candidate){
05223 
05224     vector<MyParticle*> v_out;
05225     if (!candidate->has_tagjet_pair()) return v_out;
05226 
05227     int id_jet3;
05228     int id_jet1 = candidate->get_tagjet_pair().get_particle1()->index();
05229     int id_jet2 = candidate->get_tagjet_pair().get_particle2()->index();
05230 
05231     for (unsigned int k=0; k<vec_jets_tmp.size(); k++){
05232         id_jet3 = (vec_jets_tmp[k])->index();
05233 
05234         // check if the jet is one of the forward jets
05235         if (id_jet3==id_jet1 || id_jet3==id_jet2) continue;
05236         // if not, consider it as a centraljet candidate
05237         v_out.push_back(vec_jets_tmp[k]);
05238     }
05239 
05240     return v_out;
05241 
05242 }
05243 
05244 
05245 //*****************************************************************************
05246 
05247 //::::::::::::::::::::::::::::::::
05248 //:: METHOD get_transverse_mass ::
05249 //::::::::::::::::::::::::::::::::
05250 
05251 double MyHtautauAnalysis::get_transverse_mass(MyVBFCandidate* candidate_tmp){
05252     if ( !candidate_tmp->has_lepton_pair() ){
05253         cerr<<"Error in : MyHtautauAnalysis::get_transverse_mass"<<endl
05254                 <<"You can not call this function "
05255                 <<"if the candidate has no lepton pair!"<<endl;
05256         return -9999.;
05257     }
05258     TLorentzVector tlv_lep_1 = candidate_tmp->get_lepton_pair().get_particle1()->tlv();
05259     TLorentzVector tlv_lep_2 = candidate_tmp->get_lepton_pair().get_particle2()->tlv();
05260     TLorentzVector tlv_lep;
05261     TLorentzVector tlv_met = candidate_tmp->get_missinget().tlv();
05262     double dphi;
05263     double m_transverse;
05264 
05265     tlv_lep = tlv_lep_2;
05266 
05267     // take the higher pt lepton to calculate
05268     // transverse mass in the leptonic case
05269     if(decay_mode==1 && ( tlv_lep_1.Pt() > tlv_lep_2.Pt() ) ) tlv_lep = tlv_lep_1;
05270 
05271     dphi = tlv_met.DeltaPhi(tlv_lep);
05272     m_transverse=sqrt( 2 * tlv_lep.Pt() * tlv_met.Pt() * (1-(cos(dphi))));
05273 
05274     return m_transverse;
05275 
05276 }
05277 
05278 
05279 //*****************************************************************************
05280 
05281 //::::::::::::::::::::::::::::::::
05282 //:: METHOD get_max_btag_weight ::
05283 //::::::::::::::::::::::::::::::::
05284 
05285 double MyHtautauAnalysis::get_max_btag_weight(MyVBFCandidate* candidate_tmp, vector<MyParticle*> vec_jets_tmp){
05286 
05287     if (!candidate_tmp->has_tagjet_pair()) return(-9.);
05288     
05289     vector<MyParticle*> vec_bjet_cands;
05290     // candidates for the bjet veto are only tagjets so far
05291     vec_bjet_cands.push_back(candidate_tmp->get_tagjet_pair().get_particle1());
05292     vec_bjet_cands.push_back(candidate_tmp->get_tagjet_pair().get_particle2());
05293     double bweight;
05294     double max_bweight(-9.);
05295     
05296     for (unsigned int k=0; k<vec_bjet_cands.size(); k++) {
05297         
05298         bweight = ((MyParticleJet*)(vec_bjet_cands[k]))->b_tag_weight();
05299 
05300         if( bweight > max_bweight ){
05301             max_bweight = bweight;
05302         }
05303     }
05304     
05305     return max_bweight;
05306 }
05307 
05308 
05309 //*****************************************************************************
05310 
05311 //:::::::::::::::::::::::::::::::::::
05312 //:: METHOD check_bjet_performance ::
05313 //:::::::::::::::::::::::::::::::::::
05314 void MyHtautauAnalysis::check_bjet_performance(vector<MyParticle*> v_jets_reco){
05315 
05316     //cerr<<"in b jet performance\n";
05317     // create vector of b jets out of jet vector
05318     vector<MyParticle*> tmp_reco_bs;
05319     for (unsigned int k=0; k<v_jets_reco.size(); k++){
05320         if(((MyParticleJet*)(v_jets_reco[k]))->b_tag_weight()>max_bjet_weight){
05321             tmp_reco_bs.push_back(v_jets_reco[k]);
05322     }}
05323     // create vector of true b quarks
05324     vector<MyParticle*> tmp_truth_bs = m_truth_manager.getParticles_with_ID(5);
05325     MyTruthParticle* tmp_truth_part;
05326     vector<MyParticle*> truth_bs;
05327     for (unsigned int k=0; k<tmp_truth_bs.size(); k++){
05328         if ( ((MyTruthParticle*)(tmp_truth_bs.at(k)))->status()!=2) continue;
05329         tmp_truth_part = m_truth_manager.get_mother((MyTruthParticle*)tmp_truth_bs.at(k));
05330         while(tmp_truth_part!=NULL){
05331             if(TMath::Abs(tmp_truth_part->pdgId())==6){
05332                 truth_bs.push_back(tmp_truth_bs.at(k));
05333                 tmp_truth_part=NULL;
05334                 continue;
05335             }
05336             tmp_truth_part = m_truth_manager.get_mother(tmp_truth_part);
05337         }
05338     }
05339     //cout<<"number of reco/true b jets: "<<tmp_reco_bs.size()<<" / "<<truth_bs.size()<<"\n";
05340 
05341 
05342     // efficiency
05343     int nb_matched(0);
05344     int nb_notmatched(0);
05345     int nb_fakes(0);
05346 
05347     for (unsigned int k=0; k<tmp_reco_bs.size(); k++) {
05348         h_bjet_reco_presel_pt->Fill(tmp_reco_bs[k]->tlv().Pt() *GeV, weight);
05349         h_bjet_reco_presel_eta->Fill(tmp_reco_bs[k]->tlv().Eta() , weight);
05350         h_bjet_reco_presel_phi->Fill(tmp_reco_bs[k]->tlv().Phi() , weight);
05351     }
05352     h_bjet_reco_presel_nb->Fill(tmp_reco_bs.size() , weight);
05353     
05354     for (unsigned int k=0; k<truth_bs.size(); k++) {
05355         h_bjet_truth_presel_pt->Fill(truth_bs[k]->tlv().Pt() *GeV, weight);
05356         h_bjet_truth_presel_eta->Fill(truth_bs[k]->tlv().Eta() , weight);
05357         h_bjet_truth_presel_phi->Fill(truth_bs[k]->tlv().Phi() , weight);
05358     }
05359     h_bjet_truth_presel_nb->Fill(truth_bs.size() , weight);
05360     
05361     // loop over truth taujets and search for a matching reconstructed taujet
05362     for (unsigned int k=0; k<truth_bs.size(); k++) {
05363         MyParticle* tmp_taujet = NULL;
05364         MyTruthParticle* tmp_truth_part;
05365         tmp_truth_part = ((MyTruthParticle*)(truth_bs[k]));
05366         
05367         tmp_taujet = m_tools.find_matching_particle( truth_bs[k],
05368                 tmp_reco_bs );
05369                 
05370         if(tmp_taujet!=NULL){
05371             nb_matched++;
05372             h_bjet_reco_matched_pt->Fill(tmp_taujet->tlv().Pt()*GeV , weight);
05373             h_bjet_reco_matched_eta->Fill(tmp_taujet->tlv().Eta() , weight);
05374             h_bjet_reco_matched_phi->Fill(tmp_taujet->tlv().Phi() , weight);
05375             h_bjet_truth_matched_pt->Fill(truth_bs[k]->tlv().Pt()*GeV , weight);
05376             h_bjet_truth_matched_eta->Fill(truth_bs[k]->tlv().Eta() , weight);
05377             h_bjet_truth_matched_phi->Fill(truth_bs[k]->tlv().Phi() , weight);
05378             
05379             h_bjet_matched_dpt->Fill((tmp_taujet->tlv().Pt()-truth_bs[k]->tlv().Pt())*GeV , weight);
05380             h_bjet_matched_deta->Fill(tmp_taujet->tlv().Eta()-truth_bs[k]->tlv().Eta() , weight);
05381             h_bjet_matched_dphi->Fill(tmp_taujet->tlv().DeltaPhi(truth_bs[k]->tlv()) , weight);
05382             h_bjet_matched_dr->Fill(tmp_taujet->tlv().DeltaR(truth_bs[k]->tlv()) , weight);
05383             h_bjet_matched_resolution_pt->Fill(truth_bs[k]->tlv().Pt()*GeV,
05384                     (tmp_taujet->tlv().Pt()-truth_bs[k]->tlv().Pt())/
05385                             (truth_bs[k]->tlv().Pt()) , weight);
05386             h_bjet_matched_resolution_eta->Fill(truth_bs[k]->tlv().Eta(),
05387                     (tmp_taujet->tlv().Eta()-truth_bs[k]->tlv().Eta())/
05388                             (truth_bs[k]->tlv().Eta()) , weight);
05389             h_bjet_matched_resolution_phi->Fill(truth_bs[k]->tlv().Phi(),
05390                     (tmp_taujet->tlv().DeltaPhi(truth_bs[k]->tlv()))/
05391                             (truth_bs[k]->tlv().Phi()) , weight);
05392         }
05393         else{ // not matched taujet
05394             nb_notmatched++;
05395             h_bjet_truth_notmatched_pt->Fill(truth_bs[k]->tlv().Pt()*GeV , weight);
05396             h_bjet_truth_notmatched_eta->Fill(truth_bs[k]->tlv().Eta() , weight);
05397             h_bjet_truth_notmatched_phi->Fill(truth_bs[k]->tlv().Phi() , weight);
05398         }
05399     }
05400     h_bjet_reco_matched_nb->Fill(nb_matched, weight);
05401     h_bjet_truth_notmatched_nb->Fill(nb_notmatched, weight);
05402     
05403     // determine fake taujets
05404     vector<MyParticle*> tmp_reco_bs_fake;
05405     tmp_reco_bs_fake.clear();
05406     for (unsigned int k=0; k<tmp_reco_bs.size(); k++) {
05407         MyParticle* tmp_taujet = NULL;
05408         tmp_taujet = m_tools.find_matching_particle(tmp_reco_bs[k],
05409                 truth_bs);
05410         if (tmp_taujet==NULL) { //taujet is faked
05411             nb_fakes++;
05412             tmp_reco_bs_fake.push_back(tmp_reco_bs[k]);
05413             h_bjet_reco_fake_pt->Fill(tmp_reco_bs[k]->tlv().Pt()*GeV , weight);
05414             h_bjet_reco_fake_eta->Fill(tmp_reco_bs[k]->tlv().Eta() , weight);
05415             h_bjet_reco_fake_phi->Fill(tmp_reco_bs[k]->tlv().Phi() , weight);
05416         }
05417     }
05418     h_bjet_reco_fake_nb->Fill(nb_fakes, weight);
05419     m_tools.clear_vector(tmp_reco_bs);
05420     m_tools.clear_vector(truth_bs);
05421 
05422     return;
05423 }
05424 
05425 
05426 
05427 //*****************************************************************************
05428 
05429 //::::::::::::::::::::::::::::
05430 //:: METHOD get_next_mother ::
05431 //::::::::::::::::::::::::::::
05432 MyTruthParticle* MyHtautauAnalysis::get_next_mother(MyTruthParticle* part){
05433     int partID;
05434     partID = part->pdgId();
05435 
05436     //cout<<"looking for mother of: \n";
05437     //part->Print();
05438     
05439     int mID;
05440     MyTruthParticle* mother;
05441     mother=m_truth_manager.get_mother(part);
05442     if(mother!=NULL){
05443         mID = mother->pdgId();
05444         if (mID!=partID){
05445             return(mother);
05446         }
05447         else{
05448             return(get_next_mother(mother));
05449         }
05450     }
05451     cerr<<"Warning! No mother found in MyHtautauAnalysis::get_next_mother"<<endl;
05452     return NULL;
05453 }
05454 
05455 
05456 
05457 //*****************************************************************************
05458 
05459 //:::::::::::::::::::::::
05460 //:: TTbarLeptonFilter ::
05461 //:::::::::::::::::::::::
05462 bool MyHtautauAnalysis::TTbarLeptonFilter(){
05463     vector<MyParticle*> v_tmp;
05464     vector<MyParticle*> tmp_v_out;
05465     vector<MyParticle*> v_truth_lepton_cand;
05466     int absmotherID;
05467     MyTruthParticle* mother;
05468     v_truth_lepton_cand.clear();
05469     v_tmp.clear();
05470 
05471     // get and add electrons, muons and taus
05472     v_tmp = m_truth_manager.getParticles_with_ID(11);
05473     v_tmp = m_truth_manager.remove_multiples(v_tmp);
05474     v_truth_lepton_cand = m_tools.append_vector(v_truth_lepton_cand,v_tmp);
05475     v_tmp = m_truth_manager.getParticles_with_ID(13);
05476     v_tmp = m_truth_manager.remove_multiples(v_tmp);
05477     v_truth_lepton_cand = m_tools.append_vector(v_truth_lepton_cand,v_tmp);
05478     v_tmp = m_truth_manager.getParticles_with_ID(15);
05479     v_tmp = m_truth_manager.remove_multiples(v_tmp);
05480     v_truth_lepton_cand = m_tools.append_vector(v_truth_lepton_cand,v_tmp);
05481 
05482     
05483     // apply a min pt cut
05484     v_truth_lepton_cand = m_tools.pt_eta_cut(v_truth_lepton_cand, 1., -1., 0.0, 5.0);
05485 
05486     // info
05487     //m_tools.PrintVector(v_truth_lepton_cand);
05488 
05489 
05490     // check if mother of e/mu/tau is from W
05491     tmp_v_out.clear();
05492     for (unsigned int j=0; j<v_truth_lepton_cand.size(); j++){
05493         mother = get_next_mother((MyTruthParticle*)v_truth_lepton_cand[j]);
05494         if(mother==NULL) continue;
05495         //cout<<"found mother: \n";
05496         //mother->Print();
05497         //cout<<"for particle: \n";
05498         //(v_truth_lepton_cand[j])->Print();
05499         absmotherID = TMath::Abs(mother->pdgId());
05500         if (absmotherID!=24) continue;
05501         // survived all preselection cuts:
05502         tmp_v_out.push_back(v_truth_lepton_cand[j]);
05503     }
05504     
05505     if(tmp_v_out.size()>0){
05506         //cout<<"Event ACCEPTED by TTbarLeptonFilter\n";
05507         return true;
05508     }
05509     //cout<<"Event REJECTED by TTbarLeptonFilter\n";
05510     return false;
05511 }
05512 
05513 
05514 void MyHtautauAnalysis::JetOriginInvest(std::vector<MyParticle*> jets_to_invest){
05515 
05516     std::vector<MyParticle*> v_truth_cand;
05517     MyParticle* truth_match;
05518     v_truth_cand = m_tools.append_vector(v_truth_cand , m_truth_manager.getParticles_with_ID(1));
05519     v_truth_cand = m_tools.append_vector(v_truth_cand , m_truth_manager.getParticles_with_ID(2));
05520     v_truth_cand = m_tools.append_vector(v_truth_cand , m_truth_manager.getParticles_with_ID(3));
05521     v_truth_cand = m_tools.append_vector(v_truth_cand , m_truth_manager.getParticles_with_ID(4));
05522     v_truth_cand = m_tools.append_vector(v_truth_cand , m_truth_manager.getParticles_with_ID(5));
05523     v_truth_cand = m_tools.append_vector(v_truth_cand , m_truth_manager.getParticles_with_ID(6));
05524     v_truth_cand = m_tools.pt_eta_cut(v_truth_cand, 1.0, -1., 0.0, 2.5);
05525 
05526     bool Wplus_exists(false);
05527     bool Wminus_exists(false);
05528     std::vector<MyParticle*> v_truth_Ws;
05529     v_truth_Ws = m_truth_manager.getParticles_with_ID(24);
05530     for(unsigned int i=0; i<v_truth_Ws.size(); i++){
05531         if( v_truth_Ws.at(i)->pdgId()==24) {
05532             Wplus_exists=true;
05533             //cout<<"Wplus\n";
05534         }
05535         if( v_truth_Ws.at(i)->pdgId()==-24) {
05536             Wminus_exists=true;
05537             //cout<<"Wminus\n";
05538         }
05539     }
05540 
05541     if(Wplus_exists&&Wminus_exists){
05542         cout<<"Wplus and Wminus found, skipping event!!!\n";
05543         return;
05544     }
05545     if(!Wplus_exists&&!Wminus_exists){
05546         cout<<"No Wplus and Wminus found, skipping event!\n";
05547         return;
05548     }
05549 
05550     
05551     for(unsigned int i=0; i<jets_to_invest.size(); i++){
05552         // cout<<"Jet "<<i<<", nb tracks: "<<((MyParticleJet*)(jets_to_invest.at(i)))->nb_tracks()<<endl;
05553         truth_match = NULL;
05554         truth_match = m_tools.find_matching_particle( jets_to_invest.at(i), v_truth_cand );
05555         if (truth_match != NULL){
05556             //cout<<"pdgId of matching quark: "<<truth_match->pdgId()<<endl;
05557             if(Wplus_exists){
05558                 h_Wplus_JetpdgIds->Fill(truth_match->pdgId());
05559                 h_Wplus_Jetcharge->Fill(truth_match->charge());
05560             }
05561             if(Wminus_exists){
05562                 h_Wminus_JetpdgIds->Fill(truth_match->pdgId());
05563                 h_Wminus_Jetcharge->Fill(truth_match->charge());
05564             }
05565         }
05566     }
05567     return;
05568 }
05569 
05570 

Generated on Tue Oct 21 11:50:44 2008 for NtupleAnalysis by  doxygen 1.5.1