MyHtoWWAnalysis/src/MyHtoWWAnalysis.cxx

00001 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00002 // 03/2007, AUTHOR: STEFFEN KAISER
00003 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00004 
00005 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00006 //:: IMPLEMENTATION OF METHODS DEFINED IN THE CLASS MyHtoWWAnalysis ::
00007 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00008 
00009 
00010 //::::::::::::::::::
00011 //:: HEADER FILES ::
00012 //::::::::::::::::::
00013 #include "TObjString.h"
00014 
00015 #include "MyHtoWWAnalysis/MyHtoWWAnalysis.h"
00016 #include "NtupleReader/MyPileUpExtractedEvent.h"
00017 
00018 //:::::::::::::::::::::::::
00019 //:: NAME SPACE SETTINGS ::
00020 //:::::::::::::::::::::::::
00021 
00022 using namespace std;
00023 
00024 //*****************************************************************************
00025 //:::::::::::::::::
00026 //:: METHOD init ::
00027 //:::::::::::::::::
00028 
00029 void MyHtoWWAnalysis::init(void) {
00030   
00031     filename     = "testfile";
00032     outputpath   = ""; 
00033     addon        = "";
00034     m_decay_mode = "";
00035     m_cutfile      = "";  
00036     m_cutstring  = "";
00037     overwrite    = true;
00038     
00039     return;
00040 
00041 }
00042 
00043 //*****************************************************************************
00044 
00045 //:::::::::::::::::::::
00046 //:: METHOD destruct ::
00047 //:::::::::::::::::::::
00048 
00049 void MyHtoWWAnalysis::destruct(void) {
00050         
00051     return;
00052 
00053 }
00054 
00055 //*****************************************************************************
00056 
00057 //:::::::::::::::::::::::
00058 //:: METHOD initialize ::
00059 //:::::::::::::::::::::::
00060 
00061 void MyHtoWWAnalysis::initialize(void) {
00062 
00063     //--------------------------
00064     //-- CREATE THE ROOT FILE --
00065     //--------------------------
00066     
00067     if(m_cutfile==""){
00068         m_cutfile = "cut_values.txt";
00069     }
00070     
00071     cout << "\ncutval file: " << m_cutfile << endl;
00072 
00073     MyTextFileReader m_reader(m_cutfile);
00074 
00075     if(m_decay_mode==""){
00076         TString decay_mode = m_reader.retrieve_from_file<TString>("decay_mode");
00077         m_decay_mode = decay_mode;
00078     }
00079     
00080     cout << "Decay mode: " <<  m_decay_mode << endl;
00081     
00082     if ( m_decay_mode!="ee"  && m_decay_mode!="mumu" && 
00083          m_decay_mode!="emu" && m_decay_mode!="ll" ){
00084         
00085         cerr << "ERROR: Unknown decay mode!" << endl;
00086         exit(1);
00087     }
00088 
00089 
00090     Bool_t truth_ana_flag = m_reader.retrieve_from_file<Bool_t>("truth_ana_flag");
00091     m_truth_ana_flag = truth_ana_flag;
00092 
00093     cout << "Truth ana flag: " << m_truth_ana_flag  << endl;
00094 
00095     TString file_addon = m_reader.retrieve_from_file<TString>("filename_addon");
00096     
00097     if(file_addon!="none"){
00098         if(addon==""){
00099             addon = file_addon;
00100         }
00101         else{
00102             addon = file_addon + "_" + addon;
00103         }
00104     }
00105     
00106     cout << "addon: " << addon << endl;
00107 
00108     TObjArray*  TOarray  = filename.Tokenize("_");
00109     TString filename_cleaned = "";
00110 
00111     for(int k=0; k<TOarray->GetEntries(); k++){
00112         TString string = ((TObjString*)TOarray->At(k))->GetString();
00113         if(!string.Contains("tid")){
00114             if(k!=0){
00115                 filename_cleaned += "_";
00116             }
00117             filename_cleaned += string;
00118         }
00119     }
00120 
00121 
00122     TString output_filename = filename_cleaned.ReplaceAll(".aan",".selection");
00123     //TString output_filename = filename.ReplaceAll(".aan",".selection");
00124 
00125     output_filename = 
00126             output_filename.Insert( output_filename.Index(".root"), "_"+m_decay_mode);
00127     
00128     if(truth_ana_flag){
00129         output_filename = 
00130             output_filename.Insert( output_filename.Index(".root"), "_truthvectors");
00131     }
00132 
00133     if(addon!=""){
00134         output_filename = 
00135             output_filename.Insert( output_filename.Index(".root"), "_"+addon);
00136     }
00137         
00138     if(outputpath!="" && !outputpath.EndsWith("/")){
00139         outputpath += "/";
00140     }
00141 
00142     cout << "outputfile: " << outputpath + output_filename << endl;
00143 
00144     
00145     TString file_openstring = "CREATE";
00146     if(overwrite){
00147         file_openstring = "RE" + file_openstring;
00148     }
00149     
00150     m_tfile =  new TFile( outputpath + output_filename, file_openstring);
00151     // options: CREATE -> only open and write this file if it doesn't exist
00152     //          RECREATE -> overwrite if it exists 
00153     
00154     if (!m_tfile->IsOpen()){
00155         cerr << endl 
00156              << "ERROR: file exists already "                     << endl
00157              << "       (" << outputpath + output_filename << ")" << endl
00158              << endl;
00159         exit(1);
00160     }
00161 
00162     
00163     //-----------------------
00164     //-- DatasetInfo stuff --
00165     //-----------------------
00166     
00167     MyDatasetInfo &m_dataset_info = MyDatasetInfo::Instance();
00168     //cout << "Flag: " <<  m_dataset_info.get_AtlFastFlag() << endl;
00169 
00170     TTree *new_aodfilenames_tree = m_dataset_info.get_tree("aod_file_collection")->CloneTree();
00171     TTree *new_aodcontainer_tree = m_dataset_info.get_tree("aod_container_keys")->CloneTree();
00172    
00173     m_AtlFastFlag = m_dataset_info.get_AtlFastFlag();
00174           
00175     m_1mmFix_flag = false;
00176     TBranch* b_1mmFix_flag = new_aodcontainer_tree->GetBranch("doAODFix1mm");
00177     b_1mmFix_flag->SetAddress(&m_1mmFix_flag);
00178     b_1mmFix_flag->GetEntry(0);
00179 
00180     m_trackjet_flag = m_dataset_info.get_trackjet_flag();
00181   //   TBranch* b_trackjet_flag = new_aodcontainer_tree->GetBranch("doTrackJets");
00182 //     b_trackjet_flag->SetAddress(&m_trackjet_flag);
00183 //     b_trackjet_flag->GetEntry(0);
00184 
00185     cout << "m_AtlFastFlag:   " << m_AtlFastFlag << endl;
00186     cout << "m_1mmFix_flag:   " << m_1mmFix_flag << endl;
00187     cout << "m_trackjet_flag: " << m_trackjet_flag << endl;
00188 
00189     m_generator = m_dataset_info.get_generator();
00190     cout << "\nGenerator: " << m_generator << endl;
00191   
00192     m_release = m_dataset_info.get_release();
00193 
00194     //----------------------
00195     //-- GET THE CUTORDER --
00196     //----------------------
00197 
00198     nb_cuts = 0;
00199     
00200     for(int k=0; k<nb_cuts_max; k++){
00201         cuts[k] = "";
00202     }
00203     
00204     m_reader.fill_cutvalue_map("cut_order");
00205 
00206     cuts[(int)(m_reader.get_cutvalue("trigger"))]           = "trigger";
00207     cuts[(int)(m_reader.get_cutvalue("nb_objects"))]        = "nb_objects";
00208     cuts[(int)(m_reader.get_cutvalue("nb_leptons"))]        = "nb_leptons";
00209     cuts[(int)(m_reader.get_cutvalue("nb_jets"))]           = "nb_jets";
00210     cuts[(int)(m_reader.get_cutvalue("bjet_veto"))]         = "bjet_veto";
00211     cuts[(int)(m_reader.get_cutvalue("tagjet_no_bjet"))]    = "tagjet_no_bjet";
00212     cuts[(int)(m_reader.get_cutvalue("etmiss"))]            = "etmiss";
00213     cuts[(int)(m_reader.get_cutvalue("lepton_pt"))]         = "lepton_pt";
00214     cuts[(int)(m_reader.get_cutvalue("leptons_charge"))]    = "leptons_charge";
00215     cuts[(int)(m_reader.get_cutvalue("leptons_dphi"))]      = "leptons_dphi";
00216     cuts[(int)(m_reader.get_cutvalue("leptons_dr"))]        = "leptons_dr";
00217     cuts[(int)(m_reader.get_cutvalue("leptons_theta"))]     = "leptons_theta";
00218     cuts[(int)(m_reader.get_cutvalue("leptons_mass"))]      = "leptons_mass";
00219     cuts[(int)(m_reader.get_cutvalue("leptons_pt"))]        = "leptons_pt";
00220     cuts[(int)(m_reader.get_cutvalue("tau_veto"))]          = "tau_veto";
00221     cuts[(int)(m_reader.get_cutvalue("jets_pt"))]           = "jets_pt";
00222     cuts[(int)(m_reader.get_cutvalue("jets_hemisphere"))]   = "jets_hemisphere";
00223     cuts[(int)(m_reader.get_cutvalue("jets_deta"))]         = "jets_deta";
00224     cuts[(int)(m_reader.get_cutvalue("jets_dphi"))]         = "jets_dphi";
00225     cuts[(int)(m_reader.get_cutvalue("jets_mass"))]         = "jets_mass";
00226     cuts[(int)(m_reader.get_cutvalue("central_jet_veto"))]  = "central_jet_veto";
00227     cuts[(int)(m_reader.get_cutvalue("leptons_jets_deta"))] = "leptons_jets_deta";
00228     cuts[(int)(m_reader.get_cutvalue("transverse_mass"))]   = "transverse_mass";
00229     cuts[(int)(m_reader.get_cutvalue("pt_balance"))]        = "pt_balance";
00230 
00231     for(int k=1; k<nb_cuts_max; k++){
00232         if((cuts[k])!=""){ 
00233             nb_cuts++;
00234         }
00235         if( ((cuts[k])!="") && (nb_cuts!=k) ){
00236             cerr << "ERROR:  check cut settings!" << endl;
00237             nb_cuts = 0;
00238             exit(1);
00239             break;
00240         }
00241     }
00242     
00243     cout << "total number of cuts: " << nb_cuts <<endl;
00244 
00245 
00246     //-----------------------------
00247     //-- WRITE THE CUTORDER TREE --
00248     //-----------------------------
00249 
00250     m_cut_order_tree = new TTree("cut_order","cut_order");
00251 
00252     string str_helper;
00253     char   char_helper[50] = "";
00254     
00255     for(int k=1; k<nb_cuts+1; k++){
00256         
00257         str_helper=cuts[k];
00258         strcpy(char_helper,str_helper.c_str());
00259         
00260         m_cut_order_tree->Branch(Form("cut_%2.2i",k), &char_helper, Form("cut_%2.2i/C",k));
00261         m_cut_order_tree->Fill();
00262     }
00263 
00264     m_cut_order_tree->Branch("nb_cuts", &nb_cuts, "nb_cuts/I");
00265     m_cut_order_tree->Fill();
00266 
00267 
00268     //-----------------------
00269     //-- GET THE CUTVALUES --
00270     //-----------------------
00271     
00272     //m_reader.fill_cutvalue_map("cutvalues_"+m_decay_mode);
00273     m_reader.fill_cutvalue_map("cutvalues_ll");
00274 
00275     m_cutvalue_etmiss_min           = get_cutvalue("cutvalue_etmiss_min", &m_reader);
00276     m_cutvalue_bjet_weight_max      = get_cutvalue("cutvalue_bjet_weight_max", &m_reader);
00277     m_cutvalue_lepton1_pt_min       = get_cutvalue("cutvalue_lepton1_pt_min", &m_reader);
00278     m_cutvalue_lepton2_pt_min       = get_cutvalue("cutvalue_lepton2_pt_min", &m_reader);
00279     m_cutvalue_lepton_pt_max        = get_cutvalue("cutvalue_lepton_pt_max", &m_reader);
00280     m_cutvalue_leptons_dphi_max     = get_cutvalue("cutvalue_leptons_dphi_max", &m_reader);
00281     m_cutvalue_leptons_dr_max       = get_cutvalue("cutvalue_leptons_dr_max", &m_reader);
00282     m_cutvalue_leptons_costheta_min = get_cutvalue("cutvalue_leptons_costheta_min", &m_reader);
00283     m_cutvalue_leptons_mass_max     = get_cutvalue("cutvalue_leptons_mass_max", &m_reader);
00284     m_cutvalue_leptons_pt_max       = get_cutvalue("cutvalue_leptons_pt_max", &m_reader);
00285   
00286     m_cutvalue_jet_eta_max        = get_cutvalue("cutvalue_jet_eta_max", &m_reader);
00287     m_cutvalue_jet_pt_min         = get_cutvalue("cutvalue_jet_pt_min", &m_reader);
00288     m_cutvalue_jet_pt_max         = get_cutvalue("cutvalue_jet_pt_max", &m_reader);
00289     m_cutvalue_trackjet_pt_min    = get_cutvalue("cutvalue_trackjet_pt_min", &m_reader);
00290     m_cutvalue_trackjet_pt_max    = get_cutvalue("cutvalue_trackjet_pt_max", &m_reader);
00291     m_cutvalue_jet1_pt_min        = get_cutvalue("cutvalue_jet1_pt_min", &m_reader);
00292     m_cutvalue_jet2_pt_min        = get_cutvalue("cutvalue_jet2_pt_min", &m_reader);
00293     m_cutvalue_jets_absdeta_min   = get_cutvalue("cutvalue_jets_absdeta_min", &m_reader);
00294     m_cutvalue_jets_absdphi_max   = get_cutvalue("cutvalue_jets_absdphi_max", &m_reader);
00295     m_cutvalue_jets_mass_min      = get_cutvalue("cutvalue_jets_mass_min", &m_reader);
00296     m_cutvalue_jets_mass_max      = get_cutvalue("cutvalue_jets_mass_max", &m_reader);
00297     m_cutvalue_cjet_eta_max       = get_cutvalue("cutvalue_cjet_eta_max", &m_reader);
00298     m_switch_cjet_between_fwdjets = get_cutvalue("switch_cjet_between_fwdjets", &m_reader);
00299     m_flag_cjv_track_jets         = (int)get_cutvalue("flag_cjv_track_jets", &m_reader);
00300     m_flag_cjv_stdjet_corrpt      = (int)get_cutvalue("flag_cjv_stdjet_corrpt", &m_reader);
00301     m_flag_cjv_trkstdjet_match    = (int)get_cutvalue("flag_cjv_trkstdjet_match", &m_reader);
00302     m_cutvalue_cjv_stdjet_pt_min  = get_cutvalue("cutvalue_cjv_stdjet_pt_min", &m_reader);
00303     m_cutvalue_cjv_trkjet_pt_min  = get_cutvalue("cutvalue_cjv_trkjet_pt_min", &m_reader);
00304     m_cutvalue_cjv_ptratio_min    = get_cutvalue("cutvalue_cjv_ptratio_min", &m_reader);
00305     m_cutvalue_cjv_cmsptratio_min = get_cutvalue("cutvalue_cjv_cmsptratio_min", &m_reader);
00306     m_cutvalue_mtllnu_min         = get_cutvalue("cutvalue_mtllnu_min", &m_reader);
00307     m_cutvalue_pt_balance_max     = get_cutvalue("cutvalue_pt_balance_max", &m_reader);
00308     
00309     m_cutvalue_x1_max             = get_cutvalue("cutvalue_x1_max", &m_reader);
00310     m_cutvalue_x2_max             = get_cutvalue("cutvalue_x2_max", &m_reader);
00311     m_cutvalue_tautau_Z_dm_min    = get_cutvalue("cutvalue_tautau_Z_dm_min", &m_reader);
00312     
00313     m_cutvalue_mt_min         = get_cutvalue("cutvalue_mt_min", &m_reader);
00314     m_cutvalue_mt_max         = get_cutvalue("cutvalue_mt_max", &m_reader);
00315 
00316     m_cutvalue_jet_match_dR = get_cutvalue("cutvalue_jet_match_dR", &m_reader);
00317     
00318     m_cutvalue_nb_vertices_min = (int)get_cutvalue("cutvalue_nb_vertices_min", &m_reader);
00319     m_cutvalue_nb_vertices_max = (int)get_cutvalue("cutvalue_nb_vertices_max", &m_reader);
00320 
00321     
00322 
00323    
00324   //   m_cutvalue_etmiss_min           = m_reader.get_cutvalue("cutvalue_etmiss_min");
00325 //     m_cutvalue_bjet_weight_max      = m_reader.get_cutvalue("cutvalue_bjet_weight_max");
00326 //     m_cutvalue_lepton1_pt_min       = m_reader.get_cutvalue("cutvalue_lepton1_pt_min");
00327 //     m_cutvalue_lepton2_pt_min       = m_reader.get_cutvalue("cutvalue_lepton2_pt_min");
00328 //     m_cutvalue_lepton_pt_max        = m_reader.get_cutvalue("cutvalue_lepton_pt_max");
00329 //     m_cutvalue_leptons_dphi_max     = m_reader.get_cutvalue("cutvalue_leptons_dphi_max");
00330 //     m_cutvalue_leptons_dr_max       = m_reader.get_cutvalue("cutvalue_leptons_dr_max");
00331 //     m_cutvalue_leptons_costheta_min = m_reader.get_cutvalue("cutvalue_leptons_costheta_min");
00332 //     m_cutvalue_leptons_mass_max     = m_reader.get_cutvalue("cutvalue_leptons_mass_max");
00333 //     m_cutvalue_leptons_pt_max       = m_reader.get_cutvalue("cutvalue_leptons_pt_max");
00334 
00335 //     m_cutvalue_jet1_pt_min        = m_reader.get_cutvalue("cutvalue_jet1_pt_min");
00336 //     m_cutvalue_jet2_pt_min        = m_reader.get_cutvalue("cutvalue_jet2_pt_min");
00337 //     m_cutvalue_jets_absdeta_min   = m_reader.get_cutvalue("cutvalue_jets_absdeta_min");
00338 //     m_cutvalue_jets_absdphi_max   = m_reader.get_cutvalue("cutvalue_jets_absdphi_max");
00339 //     m_cutvalue_jets_mass_min      = m_reader.get_cutvalue("cutvalue_jets_mass_min");
00340 //     m_cutvalue_jets_mass_max      = m_reader.get_cutvalue("cutvalue_jets_mass_max");
00341 //     m_cutvalue_cjet_eta_max       = m_reader.get_cutvalue("cutvalue_cjet_eta_max");
00342 //     m_switch_cjet_between_fwdjets = m_reader.get_cutvalue("switch_cjet_between_fwdjets");
00343 //     m_flag_cjv_track_jets         = (int)m_reader.get_cutvalue("flag_cjv_track_jets");
00344 //     m_cutvalue_cjv_stdjet_pt_min  = m_reader.get_cutvalue("cutvalue_cjv_stdjet_pt_min");
00345 //     m_cutvalue_cjv_trkjet_pt_min  = m_reader.get_cutvalue("cutvalue_cjv_trkjet_pt_min");
00346 //     m_cutvalue_mtllnu_min         = m_reader.get_cutvalue("cutvalue_mtllnu_min");
00347 //     m_cutvalue_pt_balance_max     = m_reader.get_cutvalue("cutvalue_pt_balance_max");
00348     
00349 //     m_cutvalue_x1_max             = m_reader.get_cutvalue("cutvalue_x1_max");
00350 //     m_cutvalue_x2_max             = m_reader.get_cutvalue("cutvalue_x2_max");
00351 //     m_cutvalue_tautau_Z_dm_min    = m_reader.get_cutvalue("cutvalue_tautau_Z_dm_min");
00352     
00353 //     m_cutvalue_mt_min         = m_reader.get_cutvalue("cutvalue_mt_min");
00354 //     m_cutvalue_mt_max         = m_reader.get_cutvalue("cutvalue_mt_max");
00355 
00356 
00357     //---------------------------
00358     //-- WRITE THE CONFIG TREE --
00359     //---------------------------
00360     
00361     m_config_tree = new TTree("analysis_config","analysis_config");
00362 
00363     m_config_tree->Branch("cutvalue_etmiss_min", &m_cutvalue_etmiss_min, "cutvalue_etmiss_min/D");
00364     m_config_tree->Branch("cutvalue_bjet_weight_max", &m_cutvalue_bjet_weight_max, "cutvalue_bjet_weight_max/D");
00365  
00366     m_config_tree->Branch("cutvalue_lepton1_pt_min", &m_cutvalue_lepton1_pt_min, "cutvalue_lepton1_pt_min/D");
00367     m_config_tree->Branch("cutvalue_lepton2_pt_min", &m_cutvalue_lepton2_pt_min, "cutvalue_lepton2_pt_min/D");
00368     m_config_tree->Branch("cutvalue_lepton_pt_max", &m_cutvalue_lepton_pt_max, "cutvalue_lepton_pt_max/D");
00369     m_config_tree->Branch("cutvalue_leptons_dphi_max", &m_cutvalue_leptons_dphi_max, "cutvalue_leptons_dphi_max/D");
00370     m_config_tree->Branch("cutvalue_leptons_dr_max", &m_cutvalue_leptons_dr_max, "cutvalue_leptons_dr_max/D");
00371     m_config_tree->Branch("cutvalue_leptons_costheta_min", &m_cutvalue_leptons_costheta_min, "cutvalue_leptons_costheta_min/D");
00372     m_config_tree->Branch("cutvalue_leptons_mass_max", &m_cutvalue_leptons_mass_max, "cutvalue_leptons_mass_max/D");
00373     m_config_tree->Branch("cutvalue_leptons_pt_max", &m_cutvalue_leptons_pt_max, "cutvalue_leptons_pt_max/D");
00374     
00375     m_config_tree->Branch("cutvalue_jet_eta_max", &m_cutvalue_jet_eta_max, "cutvalue_jet_eta_max/D");
00376     m_config_tree->Branch("cutvalue_jet_pt_min", &m_cutvalue_jet_pt_min, "cutvalue_jet_pt_min/D");
00377     m_config_tree->Branch("cutvalue_jet_pt_max", &m_cutvalue_jet_pt_max, "cutvalue_jet_pt_max/D");
00378     m_config_tree->Branch("cutvalue_trackjet_pt_min", &m_cutvalue_trackjet_pt_min, "cutvalue_trackjet_pt_min/D");
00379     m_config_tree->Branch("cutvalue_trackjet_pt_max", &m_cutvalue_trackjet_pt_max, "cutvalue_trackjet_pt_max/D");
00380     
00381     m_config_tree->Branch("cutvalue_jet1_pt_min", &m_cutvalue_jet1_pt_min, "cutvalue_jet1_pt_min/D");
00382     m_config_tree->Branch("cutvalue_jet2_pt_min", &m_cutvalue_jet2_pt_min, "cutvalue_jet2_pt_min/D");
00383 
00384     m_config_tree->Branch("cutvalue_jets_absdeta_min", &m_cutvalue_jets_absdeta_min, "cutvalue_jets_absdeta_min/D");
00385     m_config_tree->Branch("cutvalue_jets_absdphi_max", &m_cutvalue_jets_absdphi_max, "cutvalue_jets_absdphi_max/D");
00386     m_config_tree->Branch("cutvalue_jets_mass_min", &m_cutvalue_jets_mass_min, "cutvalue_jets_mass_min/D");
00387     m_config_tree->Branch("cutvalue_jets_mass_max", &m_cutvalue_jets_mass_max, "cutvalue_jets_mass_max/D");
00388     m_config_tree->Branch("cutvalue_cjet_eta_max", &m_cutvalue_cjet_eta_max, "cutvalue_cjet_eta_max/D");
00389     m_config_tree->Branch("switch_cjet_between_fwdjets", &m_switch_cjet_between_fwdjets, "switch_cjet_between_fwdjets/O");
00390     m_config_tree->Branch("flag_cjv_track_jets", &m_flag_cjv_track_jets, "flag_cjv_track_jets/I");
00391     m_config_tree->Branch("flag_cjv_stdjet_corrpt", &m_flag_cjv_stdjet_corrpt, "flag_cjv_stdjet_corrpt/I");
00392     m_config_tree->Branch("flag_cjv_trkstdjet_match", &m_flag_cjv_trkstdjet_match, "flag_cjv_trkstdjet_match/I");
00393     m_config_tree->Branch("cutvalue_cjv_stdjet_pt_min", &m_cutvalue_cjv_stdjet_pt_min, "cutvalue_cjv_stdjet_pt_min/D");
00394     m_config_tree->Branch("cutvalue_cjv_trkjet_pt_min", &m_cutvalue_cjv_trkjet_pt_min, "cutvalue_cjv_trkjet_pt_min/D");
00395     m_config_tree->Branch("cutvalue_cjv_ptratio_min", &m_cutvalue_cjv_ptratio_min, "cutvalue_cjv_ptratio_min/D");
00396     m_config_tree->Branch("cutvalue_cjv_cmsptratio_min", &m_cutvalue_cjv_cmsptratio_min, "cutvalue_cjv_cmsptratio_min/D");
00397     m_config_tree->Branch("cutvalue_mtllnu_min", &m_cutvalue_mtllnu_min, "cutvalue_mtllnu_min/D");
00398     m_config_tree->Branch("cutvalue_pt_balance_max", &m_cutvalue_pt_balance_max, "cutvalue_pt_balance_max/D");
00399     m_config_tree->Branch("truth_ana_flag", &m_truth_ana_flag, "truth_ana_flag/O");
00400     m_config_tree->Branch("cutvalue_x1_max", &m_cutvalue_x1_max, "cutvalue_x1_max/D");
00401     m_config_tree->Branch("cutvalue_x2_max", &m_cutvalue_x1_max, "cutvalue_x2_max/D");
00402     m_config_tree->Branch("cutvalue_tautau_Z_dm_min", &m_cutvalue_tautau_Z_dm_min, "cutvalue_tautau_Z_dm_min/D");
00403 
00404     m_config_tree->Branch("cutvalue_mt_min", &m_cutvalue_mt_min, "cutvalue_mt_min/D");
00405     m_config_tree->Branch("cutvalue_mt_max", &m_cutvalue_mt_max, "cutvalue_mt_max/D");
00406 
00407     m_config_tree->Branch("cutvalue_jet_match_dR", &m_cutvalue_jet_match_dR, "cutvalue_jet_match_dR/D");
00408 
00409     m_config_tree->Branch("cutvalue_nb_vertices_min", &m_cutvalue_nb_vertices_min, "cutvalue_nb_vertices_min/I");
00410     m_config_tree->Branch("cutvalue_nb_vertices_max", &m_cutvalue_nb_vertices_max, "cutvalue_nb_vertices_max/I");
00411 
00412     
00413     str_helper = m_decay_mode;
00414     strcpy(char_helper,str_helper.c_str());
00415     m_config_tree->Branch("decay_mode", &char_helper, "decay_mode/C");
00416     
00417     
00418     TDatime time;
00419     char   char_helper2[50] = "";
00420     str_helper = string( Form("%i-%i-%i/%i:%i:%i", 
00421                               time.GetDay(), time.GetMonth(), time.GetYear(),
00422                               time.GetHour(), time.GetMinute(), time.GetSecond())
00423                          ); 
00424     
00425     strcpy(char_helper2,str_helper.c_str());
00426     m_config_tree->Branch("date", &char_helper2, "date/C");
00427 
00428     m_config_tree->Fill();
00429     
00430 
00431     //-------------------------
00432     //-- BOOK THE HISTOGRAMS --
00433     //-------------------------
00434     
00435     #include "HtoWWHistos.cxx"
00436 
00437   
00438     //--------------------------
00439     //-- INITIALIZE VARIABLES --
00440     //--------------------------
00441 
00442     for(int k=0; k<nb_cuts_max; k++){
00443         nb_events[k]  = 0;
00444         nb_candidates[k] = 0;
00445     }
00446 
00447 
00448     v_cut_candidates = vector< vector<MyVBFCandidate> >(nb_cuts_max+2);
00449     
00450     for (unsigned int k=0; k<v_cut_candidates.size(); k++) {
00451         v_cut_candidates[k] = vector<MyVBFCandidate>(0);
00452     }
00453     
00454     m_event=0;
00455     m_entry=0;
00456 
00457     return;
00458 
00459 }
00460 
00461 //*****************************************************************************
00462 
00463 //::::::::::::::::::::::::::::
00464 //:: METHOD end_of_analysis ::
00465 //::::::::::::::::::::::::::::
00466 
00467 void MyHtoWWAnalysis::end_of_analysis(void) {
00468         
00469     //----------------
00470     //-- HISTOGRAMS --
00471     //----------------
00472     
00473     // electrons
00474     h_e_reco_efficiency_pt=(TH1F*)h_e_truth_matched_pt->Clone("e_reco_efficiency_pt");
00475     h_e_reco_efficiency_eta=(TH1F*)h_e_truth_matched_eta->Clone("e_reco_efficiency_eta");
00476     h_e_reco_efficiency_phi=(TH1F*)h_e_truth_matched_phi->Clone("e_reco_efficiency_phi");
00477 
00478     h_e_reco_efficiency_pt->Sumw2();
00479     h_e_reco_efficiency_eta->Sumw2();
00480     h_e_reco_efficiency_phi->Sumw2();
00481     
00482     h_e_reco_efficiency_pt->Divide(h_e_truth_matched_pt,h_e_truth_presel_pt,1,1,"b");
00483     h_e_reco_efficiency_eta->Divide(h_e_truth_matched_eta,h_e_truth_presel_eta,1,1,"b");
00484     h_e_reco_efficiency_phi->Divide(h_e_truth_matched_phi,h_e_truth_presel_phi,1,1,"b");
00485     
00486     h_e_reco_efficiency_pt->SetTitle("EFFICIENCY ELECTRON RECONSTRUCTION VS. PT");
00487     h_e_reco_efficiency_eta->SetTitle("EFFICIENCY ELECTRON RECONSTRUCTION VS. ETA");
00488     h_e_reco_efficiency_phi->SetTitle("EFFICIENCY ELECTRON RECONSTRUCTION VS. PHI");
00489  
00490     
00491     h_e_reco_fakerate_pt=(TH1F*)h_e_reco_fake_pt->Clone("e_reco_fakerate_pt");
00492     h_e_reco_fakerate_eta=(TH1F*)h_e_reco_fake_eta->Clone("e_reco_fakerate_eta");
00493     h_e_reco_fakerate_phi=(TH1F*)h_e_reco_fake_phi->Clone("e_reco_fakerate_phi");
00494     
00495     h_e_reco_fakerate_pt->Sumw2();
00496     h_e_reco_fakerate_eta->Sumw2();
00497     h_e_reco_fakerate_phi->Sumw2();
00498     
00499     h_e_reco_fakerate_pt->Divide(h_e_reco_fake_pt,h_e_reco_presel_pt,1,1,"b");
00500     h_e_reco_fakerate_eta->Divide(h_e_reco_fake_eta,h_e_reco_presel_eta,1,1,"b");
00501     h_e_reco_fakerate_phi->Divide(h_e_reco_fake_phi,h_e_reco_presel_phi,1,1,"b");
00502     
00503     h_e_reco_fakerate_pt->SetTitle("FAKERATE ELECTRON RECONSTRUCTION VS. PT");
00504     h_e_reco_fakerate_eta->SetTitle("FAKERATE ELECTRON RECONSTRUCTION VS. ETA");
00505     h_e_reco_fakerate_phi->SetTitle("FAKERATE ELECTRON RECONSTRUCTION VS. PHI");
00506     
00507 
00508     // muons
00509     h_mu_reco_efficiency_pt=(TH1F*)h_mu_truth_matched_pt->Clone("mu_reco_efficiency_pt");
00510     h_mu_reco_efficiency_eta=(TH1F*)h_mu_truth_matched_eta->Clone("mu_reco_efficiency_eta");
00511     h_mu_reco_efficiency_phi=(TH1F*)h_mu_truth_matched_phi->Clone("mu_reco_efficiency_phi");
00512 
00513     h_mu_reco_efficiency_pt->Sumw2();
00514     h_mu_reco_efficiency_eta->Sumw2();
00515     h_mu_reco_efficiency_phi->Sumw2();
00516 
00517     h_mu_reco_efficiency_pt->Divide(h_mu_truth_matched_pt,h_mu_truth_presel_pt,1,1,"b");
00518     h_mu_reco_efficiency_eta->Divide(h_mu_truth_matched_eta,h_mu_truth_presel_eta,1,1,"b");
00519     h_mu_reco_efficiency_phi->Divide(h_mu_truth_matched_phi,h_mu_truth_presel_phi,1,1,"b");
00520 
00521     h_mu_reco_efficiency_pt->SetTitle("EFFICIENCY MUON RECONSTRUCTION VS. PT");
00522     h_mu_reco_efficiency_eta->SetTitle("EFFICIENCY MUON RECONSTRUCTION VS. ETA");
00523     h_mu_reco_efficiency_phi->SetTitle("EFFICIENCY MUON RECONSTRUCTION VS. PHI");
00524 
00525     
00526     h_mu_reco_fakerate_pt=(TH1F*)h_mu_reco_fake_pt->Clone("mu_reco_fakerate_pt");
00527     h_mu_reco_fakerate_eta=(TH1F*)h_mu_reco_fake_eta->Clone("mu_reco_fakerate_eta");
00528     h_mu_reco_fakerate_phi=(TH1F*)h_mu_reco_fake_phi->Clone("mu_reco_fakerate_phi");
00529     
00530     h_mu_reco_fakerate_pt->Sumw2();
00531     h_mu_reco_fakerate_eta->Sumw2();
00532     h_mu_reco_fakerate_phi->Sumw2();
00533 
00534     h_mu_reco_fakerate_pt->Divide(h_mu_reco_fake_pt,h_mu_reco_presel_pt,1,1,"b");
00535     h_mu_reco_fakerate_eta->Divide(h_mu_reco_fake_eta,h_mu_reco_presel_eta,1,1,"b");
00536     h_mu_reco_fakerate_phi->Divide(h_mu_reco_fake_phi,h_mu_reco_presel_phi,1,1,"b");
00537 
00538     h_mu_reco_fakerate_pt->SetTitle("FAKERATE MUON RECONSTRUCTION VS. PT");
00539     h_mu_reco_fakerate_eta->SetTitle("FAKERATE MUON RECONSTRUCTION VS. ETA");
00540     h_mu_reco_fakerate_phi->SetTitle("FAKERATE MUON RECONSTRUCTION VS. PHI");
00541 
00542 
00543     // jets
00544     h_jet_reco_efficiency_pt=(TH1F*)h_jet_truth_matched_pt->Clone("jet_reco_efficiency_pt");
00545     h_jet_reco_efficiency_eta=(TH1F*)h_jet_truth_matched_eta->Clone("jet_reco_efficiency_eta");
00546     h_jet_reco_efficiency_phi=(TH1F*)h_jet_truth_matched_phi->Clone("jet_reco_efficiency_phi");
00547     
00548     h_jet_reco_efficiency_pt->Sumw2();
00549     h_jet_reco_efficiency_eta->Sumw2();
00550     h_jet_reco_efficiency_phi->Sumw2();
00551     
00552     h_jet_reco_efficiency_pt->Divide(h_jet_truth_matched_pt,h_jet_truth_presel_pt,1,1,"b");
00553     h_jet_reco_efficiency_eta->Divide(h_jet_truth_matched_eta,h_jet_truth_presel_eta,1,1,"b");
00554     h_jet_reco_efficiency_phi->Divide(h_jet_truth_matched_phi,h_jet_truth_presel_phi,1,1,"b");
00555     
00556     h_jet_reco_efficiency_pt->SetTitle("EFFICIENCY JET RECONSTRUCTION VS. PT");
00557     h_jet_reco_efficiency_eta->SetTitle("EFFICIENCY JET RECONSTRUCTION VS. ETA");
00558     h_jet_reco_efficiency_phi->SetTitle("EFFICIENCY JET RECONSTRUCTION VS. PHI");
00559     
00560 
00561     h_jet_reco_fakerate_pt=(TH1F*)h_jet_reco_fake_pt->Clone("jet_reco_fakerate_pt");
00562     h_jet_reco_fakerate_eta=(TH1F*)h_jet_reco_fake_eta->Clone("jet_reco_fakerate_eta");
00563     h_jet_reco_fakerate_phi=(TH1F*)h_jet_reco_fake_phi->Clone("jet_reco_fakerate_phi");
00564     
00565     h_jet_reco_fakerate_pt->Sumw2();
00566     h_jet_reco_fakerate_eta->Sumw2();
00567     h_jet_reco_fakerate_phi->Sumw2();
00568     
00569     h_jet_reco_fakerate_pt->Divide(h_jet_reco_fake_pt,h_jet_reco_presel_pt,1,1,"b");
00570     h_jet_reco_fakerate_eta->Divide(h_jet_reco_fake_eta,h_jet_reco_presel_eta,1,1,"b");
00571     h_jet_reco_fakerate_phi->Divide(h_jet_reco_fake_phi,h_jet_reco_presel_phi,1,1,"b");
00572     
00573     h_jet_reco_fakerate_pt->SetTitle("FAKERATE JET RECONSTRUCTION VS. PT");
00574     h_jet_reco_fakerate_eta->SetTitle("FAKERATE JET RECONSTRUCTION VS. ETA");
00575     h_jet_reco_fakerate_phi->SetTitle("FAKERATE JET RECONSTRUCTION VS. PHI");
00576 
00577 
00578     // track jets
00579     h_track_jet_reco_efficiency_pt=(TH1F*)h_track_jet_truth_matched_pt->Clone("track_jet_reco_efficiency_pt");
00580     h_track_jet_reco_efficiency_eta=(TH1F*)h_track_jet_truth_matched_eta->Clone("track_jet_reco_efficiency_eta");
00581     h_track_jet_reco_efficiency_phi=(TH1F*)h_track_jet_truth_matched_phi->Clone("track_jet_reco_efficiency_phi");
00582     
00583     h_track_jet_reco_efficiency_pt->Sumw2();
00584     h_track_jet_reco_efficiency_eta->Sumw2();
00585     h_track_jet_reco_efficiency_phi->Sumw2();
00586     
00587     h_track_jet_reco_efficiency_pt->Divide(h_track_jet_truth_matched_pt,h_track_jet_truth_presel_pt,1,1,"b");
00588     h_track_jet_reco_efficiency_eta->Divide(h_track_jet_truth_matched_eta,h_track_jet_truth_presel_eta,1,1,"b");
00589     h_track_jet_reco_efficiency_phi->Divide(h_track_jet_truth_matched_phi,h_track_jet_truth_presel_phi,1,1,"b");
00590     
00591     h_track_jet_reco_efficiency_pt->SetTitle("EFFICIENCY TRACK_JET RECONSTRUCTION VS. PT");
00592     h_track_jet_reco_efficiency_eta->SetTitle("EFFICIENCY TRACK_JET RECONSTRUCTION VS. ETA");
00593     h_track_jet_reco_efficiency_phi->SetTitle("EFFICIENCY TRACK_JET RECONSTRUCTION VS. PHI");
00594     
00595 
00596     h_track_jet_reco_fakerate_pt=(TH1F*)h_track_jet_reco_fake_pt->Clone("track_jet_reco_fakerate_pt");
00597     h_track_jet_reco_fakerate_eta=(TH1F*)h_track_jet_reco_fake_eta->Clone("track_jet_reco_fakerate_eta");
00598     h_track_jet_reco_fakerate_phi=(TH1F*)h_track_jet_reco_fake_phi->Clone("track_jet_reco_fakerate_phi");
00599     
00600     h_track_jet_reco_fakerate_pt->Sumw2();
00601     h_track_jet_reco_fakerate_eta->Sumw2();
00602     h_track_jet_reco_fakerate_phi->Sumw2();
00603     
00604     h_track_jet_reco_fakerate_pt->Divide(h_track_jet_reco_fake_pt,h_track_jet_reco_presel_pt,1,1,"b");
00605     h_track_jet_reco_fakerate_eta->Divide(h_track_jet_reco_fake_eta,h_track_jet_reco_presel_eta,1,1,"b");
00606     h_track_jet_reco_fakerate_phi->Divide(h_track_jet_reco_fake_phi,h_track_jet_reco_presel_phi,1,1,"b");
00607     
00608     h_track_jet_reco_fakerate_pt->SetTitle("FAKERATE TRACK_JET RECONSTRUCTION VS. PT");
00609     h_track_jet_reco_fakerate_eta->SetTitle("FAKERATE TRACK_JET RECONSTRUCTION VS. ETA");
00610     h_track_jet_reco_fakerate_phi->SetTitle("FAKERATE TRACK_JET RECONSTRUCTION VS. PHI");
00611 
00612 
00613     //track jets the other way around
00614 
00615     h_track_jet_truth_efficiency_pt=(TH1F*)h_track_jet_reco_matched_pt->Clone("track_jet_truth_efficiency_pt");
00616     h_track_jet_truth_efficiency_eta=(TH1F*)h_track_jet_reco_matched_eta->Clone("track_jet_truth_efficiency_eta");
00617     h_track_jet_truth_efficiency_phi=(TH1F*)h_track_jet_reco_matched_phi->Clone("track_jet_truth_efficiency_phi");
00618     
00619     h_track_jet_truth_efficiency_pt->Sumw2();
00620     h_track_jet_truth_efficiency_eta->Sumw2();
00621     h_track_jet_truth_efficiency_phi->Sumw2();
00622     
00623     h_track_jet_truth_efficiency_pt->Divide(h_track_jet_reco_matched_pt,h_track_jet_reco_presel_pt,1,1,"b");
00624     h_track_jet_truth_efficiency_eta->Divide(h_track_jet_reco_matched_eta,h_track_jet_reco_presel_eta,1,1,"b");
00625     h_track_jet_truth_efficiency_phi->Divide(h_track_jet_reco_matched_phi,h_track_jet_reco_presel_phi,1,1,"b");
00626     
00627     h_track_jet_truth_efficiency_pt->SetTitle("EFFICIENCY TRACK_JET RECONSTRUCTION VS. PT");
00628     h_track_jet_truth_efficiency_eta->SetTitle("EFFICIENCY TRACK_JET RECONSTRUCTION VS. ETA");
00629     h_track_jet_truth_efficiency_phi->SetTitle("EFFICIENCY TRACK_JET RECONSTRUCTION VS. PHI");
00630     
00631 
00632     //track jets with standard jets
00633     h_track_std_jet_efficiency_pt  =(TH1F*)h_track_std_jet_matched_pt->Clone("track_std_jet_efficiency_pt");
00634     h_track_std_jet_efficiency_eta =(TH1F*)h_track_std_jet_matched_eta->Clone("track_std_jet_efficiency_eta");
00635     h_track_std_jet_efficiency_phi =(TH1F*)h_track_std_jet_matched_phi->Clone("track_std_jet_efficiency_phi");
00636     
00637     h_track_std_jet_efficiency_pt->Sumw2();
00638     h_track_std_jet_efficiency_eta->Sumw2();
00639     h_track_std_jet_efficiency_phi->Sumw2();
00640     
00641     h_track_std_jet_efficiency_pt->Divide(h_track_std_jet_matched_pt,h_track_jet_reco_presel_pt,1,1,"b");
00642     h_track_std_jet_efficiency_eta->Divide(h_track_std_jet_matched_eta,h_track_jet_reco_presel_eta,1,1,"b");
00643     h_track_std_jet_efficiency_phi->Divide(h_track_std_jet_matched_phi,h_track_jet_reco_presel_phi,1,1,"b");
00644     
00645     h_track_std_jet_efficiency_pt->SetTitle("EFFICIENCY TRACK_STD_JET VS. PT");
00646     h_track_std_jet_efficiency_eta->SetTitle("EFFICIENCY TRACK_STD_JET VS. ETA");
00647     h_track_std_jet_efficiency_phi->SetTitle("EFFICIENCY TRACK_STD_JET VS. PHI");
00648   
00649     
00650     h_std_track_jet_efficiency_pt  =(TH1F*)h_std_track_jet_matched_pt->Clone("std_track_jet_efficiency_pt");
00651     h_std_track_jet_efficiency_eta =(TH1F*)h_std_track_jet_matched_eta->Clone("std_track_jet_efficiency_eta");
00652     h_std_track_jet_efficiency_phi =(TH1F*)h_std_track_jet_matched_phi->Clone("std_track_jet_efficiency_phi");
00653     
00654     h_std_track_jet_efficiency_pt->Sumw2();
00655     h_std_track_jet_efficiency_eta->Sumw2();
00656     h_std_track_jet_efficiency_phi->Sumw2();
00657     
00658     h_std_track_jet_efficiency_pt->Divide(h_std_track_jet_matched_pt,h_jet_reco_central_pt,1,1,"b");
00659     h_std_track_jet_efficiency_eta->Divide(h_std_track_jet_matched_eta,h_jet_reco_central_eta,1,1,"b");
00660     h_std_track_jet_efficiency_phi->Divide(h_std_track_jet_matched_phi,h_jet_reco_central_phi,1,1,"b");
00661     
00662     h_std_track_jet_efficiency_pt->SetTitle("EFFICIENCY STD_TRACK_JET VS. PT");
00663     h_std_track_jet_efficiency_eta->SetTitle("EFFICIENCY STD_TRACK_JET VS. ETA");
00664     h_std_track_jet_efficiency_phi->SetTitle("EFFICIENCY STD_TRACK_JET VS. PHI");
00665   
00666  
00667 
00668     //------------------------
00669     //-- SAVE THE ROOT FILE --
00670     //------------------------
00671    
00672     //TVectorT<double> deltaR_vector(1);
00673     //deltaR_vector[0] = deltaR_jetmatching_cut;
00674     //deltaR_vector.Write("vec_deltaR_jetmatching_cut");
00675 
00676     cout << "writing file: " << m_tfile->GetName() << endl;
00677     m_tfile->Write();
00678 
00679 
00680     //------------------
00681     //-- PRINT OUTPUT --
00682     //------------------
00683         
00684     cout << endl
00685          << "**********************************************" << endl
00686          << "****************    Output    ****************" << endl
00687          << "**********************************************" << endl
00688          << endl;
00689         //<< "jets with multiple matched particles: " << nb_multiple_matchedparticles << endl
00690         // << "jets with overlapping electron:       " << nb_foundoverlaps << endl
00691     
00692 
00693     //TString filename = "cut_flow_"+m_decay_mode+".txt";
00694     //ofstream fout(filename);
00695 
00696     double tot_eff=1;
00697 
00698     cout << "   nb \t cut \t\t nb_events   eff(%)  tot_eff(%)" << endl
00699          << "  _____________________________________________________" << endl;
00700     
00701     for(int k=0; k<nb_cuts+1; k++){
00702         double eff=1;
00703         if(k>0){
00704             eff=(double)(nb_events[k])/(double)(nb_events[k-1]);
00705             //cout << eff << endl;
00706             tot_eff *= eff;
00707             //cout << tot_eff << endl;
00708         }
00709         
00710         cout.width(5);
00711         cout << right << k << "  ";
00712         cout.width(20);
00713         if(k==0){ 
00714             cout << left << "w/o cut"; 
00715         }
00716         else { 
00717             cout << left << cuts[k]; 
00718         }
00719         cout.width(7);
00720         cout << right << nb_events[k];
00721         cout.width(9);
00722         cout << right << Form("%.2f",eff*100);
00723         cout.width(9);
00724         cout << right << Form("%.2f",tot_eff*100) << endl;
00725 
00726     }
00727     cout << endl;
00728     
00729     TDatime time;
00730     
00731     cout << "cut_flow: " << m_decay_mode << ", "
00732          << Form("%i/%i/%i, %i:%i:%i", 
00733                  time.GetDay(), time.GetMonth(), time.GetYear(),
00734                  time.GetHour(), time.GetMinute(), time.GetSecond()) 
00735          << endl;
00736     //cout << fout << endl;
00737     
00738         //ifstream myFile(m_filename);
00739 
00740    //  cout << "Trigger: " << endl
00741 //          << "  1mu:     " << h_offline_trigger->GetBinContent(1) << endl
00742 //          << "  2mu:     " << h_offline_trigger->GetBinContent(2) << endl
00743 //          << "  1e:      " << h_offline_trigger->GetBinContent(3) << endl
00744 //          << "  2e:      " << h_offline_trigger->GetBinContent(4) << endl
00745 //          << "  1e, 1mu: " << h_offline_trigger->GetBinContent(5) << endl
00746 //          << "  all:     " << h_offline_trigger->GetBinContent(6) << endl
00747 //          << endl;
00748     
00749     cout << "**********************************************" << endl
00750          << endl;
00751    
00752     return;
00753 
00754 }
00755 
00756 //*****************************************************************************
00757 
00758 //::::::::::::::::::::::::::
00759 //:: METHOD analyse_event ::
00760 //::::::::::::::::::::::::::
00761 
00762 void MyHtoWWAnalysis::analyse_event(const MyEvent & event) {
00763     
00764     //----------------------
00765     //-- Clear/Init Event --
00766     //----------------------
00767     
00768     //event.Print();
00769 
00770     //clear_event_data();
00771     nb_cuts_applied = 0;
00772 
00773     for(int k=0; k<(nb_cuts_max+2); k++){
00774         flag_evt_selected[k] = false;
00775     }
00776     flag_evt_selected[0]  = true;
00777     
00778     for(unsigned int k=0; k<v_cut_candidates.size(); k++) {
00779         v_cut_candidates[k].clear();
00780     }
00781     
00782     v_track_jet_reco_fake.clear();
00783 
00784     // create/initialize TruthParticle Manager
00785     m_truth_manager = MyTruthParticleManager(event.truth_particles());
00786     m_truth_manager.set_generator(m_generator);
00787     
00788     //get event weight
00789     weight = event.event_weight();
00790     
00791     if(m_release>12){
00792         weight = 1;
00793     }
00794     
00795     m_event = event.event_number();
00796     m_entry++;
00797     
00798  //    if(m_event!=207705){
00799 //         return;
00800 //     }
00801  
00802 //     cout << "==============================" << endl;
00803 //     cout << "-> Event: " << m_event << endl; 
00804 
00805     
00806     h_event_weight->Fill(weight,1.0);
00807 
00808     // all events
00809     h_cut_events->Fill(-2,weight);
00810     
00811     // truth lepton filter
00812     //int n_truth_leptons(0);
00813     //n_truth_leptons = check_truth_lepton_filter();
00814     //if(n_truth_leptons<1) return;
00815 
00816     // all events
00817     h_cut_events->Fill(-1,weight);
00818     
00819 
00820     //-------------------
00821     // Extract pile-up --
00822     //-------------------
00823     
00824     MyPileUpExtractedEvent pu_event(event);
00825     
00826     const MyVertex* vertex       = pu_event.vertex();
00827     const MyVertex* truth_vertex = pu_event.truth_vertex();
00828  
00829     if(m_trackjet_flag && (!vertex || !truth_vertex)){
00830         cout << "Warning: no vertex found in this event: "  << m_event << endl;
00831         return;
00832     }
00833 
00834     if(m_trackjet_flag){
00835         m_primary_vertex_index       = vertex->index();
00836         m_primary_truth_vertex_index = truth_vertex->index();
00837     }
00838     else{
00839         m_primary_vertex_index = -1;
00840         m_primary_truth_vertex_index = -1;
00841     }
00842     //m_primary_vertex_index = 0;
00843 
00844     
00845     //---------------------------
00846     //-- Init Particle Vectors --
00847     //---------------------------
00848 
00849     //double jet_pt_cut(m_cutvalue_jet_pt_min);
00850 
00851     vector<MyParticle*> v_e_reco_aod, v_mu_reco_aod, v_jet_reco_aod;
00852     vector<MyParticle*> v_e_truth_aod, v_mu_truth_aod, v_jet_truth_aod;
00853    
00854     vector<MyParticle*> v_e_reco_presel, v_mu_reco_presel, v_jet_reco_presel;
00855     vector<MyParticle*> v_e_truth_presel, v_mu_truth_presel, v_jet_truth_presel;
00856     
00857     vector<MyParticle*> v_mu_reco_orm, v_jet_reco_orm;
00858     vector<MyParticle*> v_mu_truth_orm, v_jet_truth_orm;
00859     
00860     //vector<MyParticle*> v_track_jet_reco_presel, v_track_jet_truth_presel;
00861     
00862     //v_track_jet_reco_presel = m_tools.pt_eta_cut(track_jet, m_cutvalue_jet_pt_min*GeV, -1, 0.0, 5.0); //track_jet_orm;
00863     //v_track_jet_truth_presel = m_tools.pt_eta_cut(truth_track_jet, m_cutvalue_jet_pt_min*GeV, -1, 0.0, 5.0); //*truth_track_jet;
00864 
00865     //--------------------------
00866     //-- Get Particle Vectors --
00867     //--------------------------
00868 
00869 //     v_e_reco_aod   = event.reco_electrons();
00870 //     v_mu_reco_aod  = event.reco_muons();
00871 //     v_jet_reco_aod = event.reco_jets();
00872     
00873     v_e_reco_aod   = pu_event.reco_electrons();
00874     v_mu_reco_aod  = pu_event.reco_muons();
00875     v_jet_reco_aod = event.reco_jets();
00876  
00877     v_e_truth_aod = m_truth_manager.getParticles_with_ID(11);
00878     v_e_truth_aod = m_truth_manager.remove_multiples(v_e_truth_aod);
00879 
00880     //vector<MyParticle*> v_e_truth_vertex(0);
00881     //vector<MyParticle*> v_e_truth_vertex_tmp = m_tools.particles_from_vertex(v_e_truth_aod,m_primary_truth_vertex_index);
00882     //v_e_truth_vertex = m_tools.pt_eta_cut(v_e_truth_vertex_tmp, 0.*GeV, -1, 0.0, 2.6);
00883        
00884     
00885    //  for(unsigned int k = 0; k<v_e_truth_vertex_tmp.size();k++){
00886     
00887 //         if(((MyTruthParticle*)(v_e_truth_vertex_tmp[k]))->Et_in_cone(1)<8*GeV){
00888 //             v_e_truth_vertex.push_back(v_e_truth_vertex_tmp[k]);
00889 //         }
00890         
00891 //     }
00892 
00893     v_e_truth_aod = m_tools.pt_eta_cut(v_e_truth_aod, 15.*GeV, -1, 0.0, 2.6);
00894     
00895     v_mu_truth_aod = m_truth_manager.getParticles_with_ID(13);
00896     v_mu_truth_aod = m_truth_manager.remove_multiples(v_mu_truth_aod);
00897 
00898    //  vector<MyParticle*> v_mu_truth_vertex(0);
00899 //     vector<MyParticle*> v_mu_truth_vertex_tmp = m_tools.particles_from_vertex(v_mu_truth_aod,m_primary_truth_vertex_index);
00900 //     v_mu_truth_vertex = m_tools.pt_eta_cut(v_mu_truth_vertex_tmp, 0.*GeV, -1, 0.0, 2.6);
00901     
00902     
00903 //     for(unsigned int k = 0; k<v_mu_truth_vertex_tmp.size();k++){
00904     
00905 //          if(((MyTruthParticle*)(v_mu_truth_vertex_tmp[k]))->Et_in_cone(1)<3*GeV){
00906 //             v_mu_truth_vertex.push_back(v_mu_truth_vertex_tmp[k]);
00907 //         }
00908         
00909 //     }
00910 
00911     v_mu_truth_aod = m_tools.pt_eta_cut(v_mu_truth_aod, 15.*GeV, -1, 0.0, 2.6);
00912     
00913     v_jet_truth_aod = event.truth_jets();
00914 
00915     // fill histos
00916     fill_raw_aod_content_histos( v_e_reco_aod, v_mu_reco_aod, v_jet_reco_aod,
00917                                  v_e_truth_aod, v_mu_truth_aod, v_jet_truth_aod);
00918     
00919     if(m_trackjet_flag){
00920         fill_vertex_histos(event.primary_vertices(), event.truth_vertices());
00921     }
00922 
00923     //nb vertex cuts
00924     
00925     if(m_cutvalue_nb_vertices_min>-1){
00926         if((int)event.primary_vertices()->size()<m_cutvalue_nb_vertices_min){
00927             return;
00928         }
00929     }
00930     if(m_cutvalue_nb_vertices_max>-1){
00931         if((int)event.primary_vertices()->size()>m_cutvalue_nb_vertices_max){
00932             return;
00933         }
00934     }
00935 
00936     // missing Et
00937     MyMissingEt missinget;
00938     
00939     if(!m_1mmFix_flag){
00940         missinget = pu_event.met_manager().get_missinget("MET_RefFinal");
00941     }    
00942     else{
00943         missinget = pu_event.met_manager().get_missinget("MET_RefFinal_1mmCorrection");
00944     }
00945     
00946     h_etmiss_aod->Fill(missinget.met()*invGeV,weight);
00947     //event.met_manager().Print("v");
00948 
00949     truth_missinget = pu_event.met_manager().get_missinget("TruthMET_NonInt");
00950       
00951     
00952     //------------------------------
00953     //-- Lepton Isolation Studies --
00954     //------------------------------
00955 
00956     lepton_isolation_study(v_e_reco_aod, &m_truth_manager);
00957     lepton_isolation_study(v_mu_reco_aod, &m_truth_manager);
00958 
00959 
00960     //-------------------------
00961     //-- Preselect Particles --
00962     //-------------------------
00963     
00964     // electrons
00965     v_e_reco_presel  = preselect_electrons(v_e_reco_aod, 15*GeV);
00966     v_e_truth_presel = preselect_truth_electrons(v_e_truth_aod, 15*GeV);
00967     v_e_reco_presel  = m_tools.delete_doubles(v_e_reco_presel);
00968   
00969     vector<MyParticle*> v_e_reco_presel_for_orm  = preselect_electrons_for_orm(v_e_reco_aod, 15*GeV);//15
00970     v_e_reco_presel_for_orm = m_tools.delete_doubles(v_e_reco_presel_for_orm);
00971       
00972     // muons
00973     v_mu_reco_orm = v_mu_reco_aod;
00974     
00975     v_mu_reco_orm = m_tools.pt_eta_cut(v_mu_reco_orm, 15.0*GeV, -1, 0.0, 2.5);
00976     //v_mu_reco_orm = delete_doubles(v_mu_reco_orm);
00977     //v_mu_reco_orm = m_tools.remove_overlap(v_mu_reco_orm,v_e_reco_presel,0.1);
00978     
00979     v_jet_reco_orm = v_jet_reco_aod;
00980     //v_jet_reco_orm = m_tools.pt_eta_cut(v_jet_reco_orm, 15.0*GeV, -1, 0.0, 5.0);
00981     v_jet_reco_orm = m_tools.pt_eta_cut(v_jet_reco_orm, m_cutvalue_jet_pt_min*GeV, m_cutvalue_jet_pt_max*GeV, 0.0, m_cutvalue_jet_eta_max);  
00982     v_jet_reco_orm = m_tools.remove_overlap(v_jet_reco_orm,v_e_reco_presel_for_orm,0.4);
00983 
00984     vector<MyParticle*> v_jet_reco_central = m_tools.pt_eta_cut(v_jet_reco_orm, -1, -1, -1, 2.5);
00985     vector<MyParticle*> v_jet_reco_aod_orm = m_tools.remove_overlap(v_jet_reco_aod,v_e_reco_presel_for_orm,0.4);
00986     //v_jet_reco_aod_orm = m_tools.pt_eta_cut( v_jet_reco_aod_orm, -1, -1, 0.0, 2.5);
00987 
00988     v_mu_reco_presel  = preselect_muons(v_mu_reco_orm, 15*GeV);
00989     vector<MyParticle*> tmp_muons(v_mu_reco_presel);
00990     v_mu_truth_presel = preselect_truth_muons(v_mu_truth_aod, 15*GeV);
00991     //v_mu_reco_presel  = m_tools.remove_overlap(v_mu_reco_presel,v_jet_reco_orm,0.4);
00992     v_mu_reco_presel  = m_tools.delete_doubles(v_mu_reco_presel);
00993 
00994     //reco jets
00995     //v_jet_reco_orm = m_tools.remove_overlap(v_jet_reco_orm,v_mu_reco_presel,0.4);
00996     //v_jet_reco_orm = v_jet_reco_aod;
00997     //v_jet_reco_orm = m_tools.pt_eta_cut(v_jet_reco_orm, 15.0*GeV, -1, 0.0, 5.0);
00998     //v_jet_reco_orm = m_tools.remove_overlap(v_jet_reco_orm,v_e_reco_presel,0.4);
00999     //v_mu_reco_presel= m_tools.remove_overlap(v_mu_reco_presel,v_jet_reco_orm,0.4);
01000 
01001     // taujet overlap removal?
01002     //v_jet_reco_orm = remove_overlap(v_jet_reco_orm,v_taujet_reco_presel,0.1);
01003     //cout << "nb_jets (orm): " << v_jet_reco_orm.size() << endl;
01004     //m_tools.PrintVector(v_jet_reco_orm);
01005 
01006     //test
01007    //  for (unsigned int k=0; k<v_jet_reco_orm.size(); k++) {
01008         
01009 //         MyParticleJet *jet = (MyParticleJet*)(v_jet_reco_orm[k]); 
01010 
01011 //         if(jet->nb_tracks()>0){
01012 //             cout << "vindex: " << jet->tracks_vertex_index(0) << endl;
01013 //         }
01014 
01015 //     }
01016     
01017 
01018 
01019     // fill jet histos after overlap removal
01020     h_jet_reco_orm_nb->Fill(v_jet_reco_orm.size(),weight);
01021     for (unsigned int k=0; k<v_jet_reco_orm.size(); k++) {
01022         h_jet_reco_orm_pt->Fill((v_jet_reco_orm[k])->tlv().Pt()*invGeV,weight);
01023         h_jet_reco_orm_eta->Fill((v_jet_reco_orm[k])->tlv().Eta(),weight);
01024         h_jet_reco_orm_phi->Fill((v_jet_reco_orm[k])->tlv().Phi(),weight);
01025     }
01026     
01027     h_jet_reco_central_nb->Fill(v_jet_reco_central.size(),weight);
01028     for (unsigned int k=0; k<v_jet_reco_central.size(); k++) {
01029         h_jet_reco_central_pt->Fill((v_jet_reco_central[k])->tlv().Pt()*invGeV,weight);
01030         h_jet_reco_central_eta->Fill((v_jet_reco_central[k])->tlv().Eta(),weight);
01031         h_jet_reco_central_phi->Fill((v_jet_reco_central[k])->tlv().Phi(),weight);
01032         h_jet_reco_central_ptratio->Fill( ((MyParticleJet*)(v_jet_reco_central[k]))
01033                                           ->tracks_ptratio(m_primary_vertex_index),weight);
01034         h_jet_reco_central_cmsptratio->Fill( ((MyParticleJet*)(v_jet_reco_central[k]))
01035                                              ->tracks_cmsptratio(m_primary_vertex_index),weight);
01036         h_jet_reco_central_ptcorr->Fill( ((MyParticleJet*)(v_jet_reco_central[k]))
01037                                          ->pt_pucorr(m_primary_vertex_index),weight);
01038     
01039         if(((MyParticleJet*)(v_jet_reco_central[k]))
01040            ->tracks_ptratio(m_primary_vertex_index)>m_cutvalue_cjv_ptratio_min){
01041             h_jet_reco_central_pt_ptratiocut->Fill((v_jet_reco_central[k])->tlv().Pt()*invGeV,weight);
01042         }
01043         if(((MyParticleJet*)(v_jet_reco_central[k]))
01044            ->tracks_cmsptratio(m_primary_vertex_index)>m_cutvalue_cjv_cmsptratio_min){
01045             h_jet_reco_central_pt_cmsptratiocut->Fill((v_jet_reco_central[k])->tlv().Pt()*invGeV,weight);
01046         }
01047     }
01048 
01049 
01050     //v_jet_reco_presel 
01051     //  = m_tools.pt_eta_cut(v_jet_reco_orm, m_cutvalue_jet_pt_min*GeV, -1, 0.0, 5.0);
01052 
01053     v_jet_reco_presel = v_jet_reco_orm;
01054 
01055     //cout << "nb_jets (presel): " << v_jet_reco_presel.size() << endl;
01056     //m_tools.PrintVector(v_jet_reco_presel);
01057 
01058 
01059     // truth jets
01060     v_jet_truth_orm = v_jet_truth_aod;
01061     v_jet_truth_orm = m_tools.remove_overlap(v_jet_truth_orm,v_e_truth_presel,0.4);
01062  
01063     
01064     
01065     //v_jet_truth_orm = m_tools.remove_overlap(v_jet_truth_orm,v_mu_truth_presel,0.4);
01066 
01067     vector<MyParticle*> v_jet_truth_aod_orm = m_tools.remove_overlap(v_jet_truth_aod,v_e_truth_presel,0.4);
01068 
01069     v_jet_truth_presel 
01070         = m_tools.pt_eta_cut(v_jet_truth_orm, m_cutvalue_jet_pt_min*GeV,  m_cutvalue_jet_pt_max*GeV, 0.0, m_cutvalue_jet_eta_max); 
01071 
01072     vector<MyParticle*> v_jet_truth_central = m_tools.pt_eta_cut(v_jet_truth_presel, m_cutvalue_jet_pt_min*GeV, m_cutvalue_jet_pt_max*GeV, 0.0, 2.5);
01073 
01074     //v_mu_truth_presel = m_tools.remove_overlap(v_mu_truth_presel,v_jet_truth_presel,0.4);
01075     // taujet overlap removal?
01076     //v_jet_truth_orm = remove_overlap(v_jet_truth_orm,v_taujet_truth_presel,0.2);
01077    
01078     //v_jet_truth_presel 
01079     //  = m_tools.pt_eta_cut(v_jet_truth_orm, m_cutvalue_jet_pt_min*GeV, -1.0, 0.0, 5.0);
01080    
01081 
01082     // fill preselected jet histos
01083 
01084     if(v_jet_reco_presel.size()>0){
01085         h_jet_reco_presel_pt1->Fill((v_jet_reco_presel[0])->tlv().Pt()*invGeV,weight);
01086         h_jet_reco_presel_eta1->Fill((v_jet_reco_presel[0])->tlv().Eta(),weight);
01087     }
01088     if(v_jet_reco_presel.size()>1){
01089         h_jet_reco_presel_pt2->Fill((v_jet_reco_presel[1])->tlv().Pt()*invGeV,weight);
01090         h_jet_reco_presel_eta2->Fill((v_jet_reco_presel[1])->tlv().Eta(),weight);
01091     }
01092     if(v_jet_reco_presel.size()>2){
01093         h_jet_reco_presel_pt3->Fill((v_jet_reco_presel[2])->tlv().Pt()*invGeV,weight);
01094         h_jet_reco_presel_eta3->Fill((v_jet_reco_presel[2])->tlv().Eta(),weight);
01095     }
01096 
01097     h_jet_reco_presel_nb->Fill(v_jet_reco_presel.size(),weight);
01098     for (unsigned int k=0; k<v_jet_reco_presel.size(); k++) {
01099 
01100         //cout << ((MyParticleJet*)(v_jet_reco_presel[k]))->tracks_ptratio(m_primary_vertex_index) <<  endl;
01101 
01102         h_jet_reco_presel_pt->Fill((v_jet_reco_presel[k])->tlv().Pt()*invGeV,weight);
01103         h_jet_reco_presel_eta->Fill((v_jet_reco_presel[k])->tlv().Eta(),weight);
01104         h_jet_reco_presel_phi->Fill((v_jet_reco_presel[k])->tlv().Phi(),weight);
01105         h_jet_reco_presel_ptratio->Fill( ((MyParticleJet*)(v_jet_reco_presel[k]))
01106                                          ->tracks_ptratio(m_primary_vertex_index),weight);
01107         h_jet_reco_presel_cmsptratio->Fill( ((MyParticleJet*)(v_jet_reco_presel[k]))
01108                                             ->tracks_cmsptratio(m_primary_vertex_index),weight);
01109         h_jet_reco_presel_ptcorr->Fill( ((MyParticleJet*)(v_jet_reco_presel[k]))
01110                                         ->pt_pucorr(m_primary_vertex_index),weight);
01111     }
01112     
01113     h_jet_truth_presel_nb->Fill(v_jet_truth_presel.size(),weight);
01114     for (unsigned int k=0; k<v_jet_truth_presel.size(); k++) {
01115         h_jet_truth_presel_pt->Fill((v_jet_truth_presel[k])->tlv().Pt()*invGeV,weight);
01116         h_jet_truth_presel_eta->Fill((v_jet_truth_presel[k])->tlv().Eta(),weight);
01117         h_jet_truth_presel_phi->Fill((v_jet_truth_presel[k])->tlv().Phi(),weight);
01118     }
01119     
01120     h_jet_truth_central_nb->Fill(v_jet_truth_central.size(),weight);
01121     for (unsigned int k=0; k<v_jet_truth_central.size(); k++) {
01122         h_jet_truth_central_pt->Fill((v_jet_truth_central[k])->tlv().Pt()*invGeV,weight);
01123         h_jet_truth_central_eta->Fill((v_jet_truth_central[k])->tlv().Eta(),weight);
01124         h_jet_truth_central_phi->Fill((v_jet_truth_central[k])->tlv().Phi(),weight);
01125     }
01126  
01127     v_jet_reco_presel  = m_tools.sort_particles(v_jet_reco_presel);
01128     v_jet_truth_presel = m_tools.sort_particles(v_jet_truth_presel);
01129     
01130     m_tools.check_order(v_jet_reco_presel);
01131     m_tools.check_order(v_jet_truth_presel);
01132     
01133     
01134     //---------------------------
01135     // Track Jet Distributions --
01136     //---------------------------
01137     
01138     vector<MyParticle*> v_track_jet_reco_aod(*event.track_jets());
01139     vector<MyParticle*> v_track_jet_truth_aod(*event.truth_track_jets());
01140     
01141     //overlap_removal
01142     //vector<MyParticle*> v_e_reco_presel_tjorm   = preselect_electrons(v_e_reco_aod, 0*GeV);
01143     //vector<MyParticle*> v_e_truth_presel_tjorm  = v_e_truth_vertex;
01144     //vector<MyParticle*> v_mu_reco_presel_tjorm  = preselect_muons(v_mu_reco_aod, 0*GeV);
01145     //vector<MyParticle*> v_mu_truth_presel_tjorm = v_mu_truth_vertex;
01146 
01147     //vector<MyParticle*> v_e_truth_presel_tjorm  = preselect_truth_electrons(v_e_truth_aod, 0*GeV);
01148     //vector<MyParticle*> v_mu_truth_presel_tjorm = preselect_truth_muons(v_mu_truth_aod, 0*GeV);
01149 
01150     //vector<MyParticle*> v_track_jet_reco_orm_e(0);
01151     //vector<MyParticle*> v_track_jet_reco_orm(0);
01152     //vector<MyParticle*> v_track_jet_truth_orm(0);
01153 
01154     //v_track_jet_reco_orm  = m_tools.remove_overlap(v_track_jet_reco_aod,v_e_reco_presel_tjorm,0.1);
01155     //v_track_jet_reco_orm  = m_tools.remove_overlap(v_track_jet_reco_orm,v_mu_reco_presel_tjorm,0.1);
01156     //v_track_jet_truth_orm = m_tools.remove_overlap(v_track_jet_truth_aod,v_e_truth_presel_tjorm,0.1);
01157     //v_track_jet_truth_orm = m_tools.remove_overlap(v_track_jet_truth_orm,v_mu_truth_presel_tjorm,0.1);
01158 
01159     //preselection
01160     vector<MyParticle*> v_track_jet_reco_presel;
01161     vector<MyParticle*> v_track_jet_truth_presel;
01162   
01163     //v_track_jet_reco_presel = m_tools.pt_eta_cut( v_track_jet_reco_aod,0.5*m_cutvalue_jet_pt_min*GeV, -1, 0.0, 5.0);
01164     //v_track_jet_truth_presel = m_tools.pt_eta_cut( v_track_jet_truth_aod,0.5*m_cutvalue_jet_pt_min*GeV, -1, 0.0, 5.0);
01165    
01166     v_track_jet_reco_presel  = m_tools.pt_eta_cut( v_track_jet_reco_aod,  m_cutvalue_trackjet_pt_min*GeV, m_cutvalue_trackjet_pt_max*GeV, 0.0, 2.5);
01167     v_track_jet_truth_presel = m_tools.pt_eta_cut( v_track_jet_truth_aod, m_cutvalue_trackjet_pt_min*GeV, m_cutvalue_trackjet_pt_max*GeV, 0.0, 2.5);
01168     
01169 
01170     //fill histos
01171     h_track_jet_reco_aod_nb->Fill(v_track_jet_reco_aod.size(), weight);
01172     for (unsigned int k=0; k<v_track_jet_reco_aod.size(); k++) {
01173     
01174         h_track_jet_reco_aod_eta->Fill(v_track_jet_reco_aod[k]->tlv().Eta(), weight);
01175         h_track_jet_reco_aod_phi->Fill(v_track_jet_reco_aod[k]->tlv().Phi(), weight);
01176         h_track_jet_reco_aod_pt->Fill(v_track_jet_reco_aod[k]->tlv().Pt(), weight);
01177         h_track_jet_reco_aod_pt_vs_eta->Fill(v_track_jet_reco_aod[k]->tlv().Eta(),
01178                                            v_track_jet_reco_aod[k]->tlv().Pt(), weight);
01179     }
01180     
01181     h_track_jet_truth_aod_nb->Fill(v_track_jet_truth_aod.size(), weight);
01182     for (unsigned int k=0; k<v_track_jet_truth_aod.size(); k++) {
01183     
01184         h_track_jet_truth_aod_eta->Fill(v_track_jet_truth_aod[k]->tlv().Eta(), weight);
01185         h_track_jet_truth_aod_phi->Fill(v_track_jet_truth_aod[k]->tlv().Phi(), weight);
01186         h_track_jet_truth_aod_pt->Fill(v_track_jet_truth_aod[k]->tlv().Pt(), weight);
01187         h_track_jet_truth_aod_pt_vs_eta->Fill(v_track_jet_truth_aod[k]->tlv().Eta(),
01188                                            v_track_jet_truth_aod[k]->tlv().Pt(), weight);
01189     }
01190 
01191     h_track_jet_reco_presel_nb->Fill(v_track_jet_reco_presel.size(), weight);
01192     for (unsigned int k=0; k<v_track_jet_reco_presel.size(); k++) {
01193     
01194         h_track_jet_reco_presel_eta->Fill(v_track_jet_reco_presel[k]->tlv().Eta(), weight);
01195         h_track_jet_reco_presel_phi->Fill(v_track_jet_reco_presel[k]->tlv().Phi(), weight);
01196         h_track_jet_reco_presel_pt->Fill(v_track_jet_reco_presel[k]->tlv().Pt(), weight);
01197         h_track_jet_reco_presel_pt_vs_eta->Fill(v_track_jet_reco_presel[k]->tlv().Eta(),
01198                                            v_track_jet_reco_presel[k]->tlv().Pt(), weight);
01199     }
01200     
01201     h_track_jet_truth_presel_nb->Fill(v_track_jet_truth_presel.size(), weight);
01202     for (unsigned int k=0; k<v_track_jet_truth_presel.size(); k++) {
01203     
01204         h_track_jet_truth_presel_eta->Fill(v_track_jet_truth_presel[k]->tlv().Eta(), weight);
01205         h_track_jet_truth_presel_phi->Fill(v_track_jet_truth_presel[k]->tlv().Phi(), weight);
01206         h_track_jet_truth_presel_pt->Fill(v_track_jet_truth_presel[k]->tlv().Pt(), weight);
01207         h_track_jet_truth_presel_pt_vs_eta->Fill(v_track_jet_truth_presel[k]->tlv().Eta(),
01208                                            v_track_jet_truth_presel[k]->tlv().Pt(), weight);
01209     }
01210 
01211 
01212     vector<MyParticle*> v_track_jet_reco_orm_e(0);
01213     vector<MyParticle*> v_track_jet_reco_orm(0);
01214 
01215     v_track_jet_reco_orm_e = m_tools.remove_overlap(v_track_jet_reco_presel,v_e_reco_presel_for_orm,0.4); 
01216     v_track_jet_reco_orm   = m_tools.remove_overlap(v_track_jet_reco_orm_e,tmp_muons,0.4);
01217     
01218     int nb_e_overlaps  = v_track_jet_reco_aod.size() - v_track_jet_reco_orm_e.size();
01219     int nb_mu_overlaps = v_track_jet_reco_orm_e.size() - v_track_jet_reco_orm.size();
01220 
01221     h_track_jet_reco_orm_nb->Fill(v_track_jet_reco_orm.size(), weight);
01222     for (unsigned int k=0; k<v_track_jet_reco_orm.size(); k++) {
01223         
01224         h_track_jet_reco_orm_eta->Fill(v_track_jet_reco_orm[k]->tlv().Eta(), weight);
01225         h_track_jet_reco_orm_phi->Fill(v_track_jet_reco_orm[k]->tlv().Phi(), weight);     
01226         h_track_jet_reco_orm_pt->Fill(v_track_jet_reco_orm[k]->tlv().Pt(), weight);
01227         h_track_jet_reco_orm_pt_vs_eta->Fill(v_track_jet_reco_orm[k]->tlv().Eta(),
01228                                            v_track_jet_reco_orm[k]->tlv().Pt(), weight);
01229         
01230     }
01231     
01232     h_trj_nb_electron_overlaps->Fill(nb_e_overlaps, weight);
01233     h_trj_nb_muon_overlaps->Fill(nb_mu_overlaps, weight);
01234        
01235 
01236     //-----------------------
01237     //-- Track Jet Ntuples --
01238     //-----------------------
01239 
01240     double dR, Et, eta, phi, truth_Et, truth_eta, truth_phi;
01241     for (unsigned int k=0; k<v_track_jet_reco_aod.size(); k++) {
01242         
01243         dR = -1.0e99;
01244         Et = v_track_jet_reco_aod[k]->tlv().Et();
01245         eta = v_track_jet_reco_aod[k]->tlv().Eta();
01246         phi = v_track_jet_reco_aod[k]->tlv().Phi();
01247         
01248         //find truth_track_jet with the min dR wrt to the track_jet
01249         for (unsigned int l=0; l<v_track_jet_truth_aod.size(); l++) {
01250         
01251             if (v_track_jet_reco_aod[k]
01252                 ->tlv().DeltaR(v_track_jet_truth_aod[l]->tlv())<TMath::Abs(dR)) {
01253                 
01254                 dR = v_track_jet_reco_aod[k]->tlv().DeltaR(v_track_jet_truth_aod[l]->tlv());
01255                 truth_Et = v_track_jet_truth_aod[l]->tlv().Et();
01256                 truth_eta = v_track_jet_truth_aod[l]->tlv().Eta();
01257                 truth_phi = v_track_jet_truth_aod[l]->tlv().Phi();
01258             }
01259         }
01260        
01261         t_trj_ntuple->Fill(weight,
01262                            vertex->numberOfTracks(),
01263                            truth_vertex->numberOfTracks(),
01264                            v_track_jet_reco_aod.size(), v_track_jet_truth_aod.size(),
01265                            Et, eta, phi, dR,
01266                            truth_Et, truth_eta, truth_phi);
01267    }
01268 
01269     //find track jet with the minimum Et
01270     double Et_min(1.0e99);
01271     for (unsigned int l=0; l<v_track_jet_reco_aod.size(); l++) {
01272         
01273         if (v_track_jet_reco_aod[l]->tlv().Et()<Et_min) {
01274             Et_min = v_track_jet_reco_aod[l]->tlv().Et();
01275         }
01276     }
01277     t_trj_ntuple_2->Fill(weight, Et_min, v_track_jet_reco_aod.size());
01278         
01279     for (unsigned int l=0; l<v_track_jet_truth_aod.size(); l++) {
01280     
01281         dR = -1.0e99;
01282         truth_Et = v_track_jet_truth_aod[l]->tlv().Et();
01283         truth_eta = v_track_jet_truth_aod[l]->tlv().Eta();
01284         truth_phi = v_track_jet_truth_aod[l]->tlv().Phi();
01285         
01286         for (unsigned int k=0; k<v_track_jet_reco_aod.size(); k++) {
01287         
01288             if (v_track_jet_reco_aod[k]
01289                 ->tlv().DeltaR(v_track_jet_truth_aod[l]->tlv())<fabs(dR)) {
01290                 
01291                 dR = v_track_jet_reco_aod[k]
01292                     ->tlv().DeltaR(v_track_jet_truth_aod[l]->tlv());
01293                 Et = v_track_jet_reco_aod[k]->tlv().Et();
01294                 eta = v_track_jet_reco_aod[k]->tlv().Eta();
01295                 phi = v_track_jet_reco_aod[k]->tlv().Phi();
01296             }
01297         }
01298 
01299         t_truth_trj_ntuple->Fill(weight,
01300                                  vertex->numberOfTracks(),
01301                                  truth_vertex->numberOfTracks(),
01302                                  v_track_jet_reco_aod.size(), v_track_jet_truth_aod.size(),
01303                                  Et, eta, phi, dR,
01304                                  truth_Et, truth_eta, truth_phi);
01305     
01306     }
01307     int nbstdj(0);
01308     Et_min = 1.0e99;
01309     double Et_mincentral = 1.0e99;
01310     for (unsigned int l=0; l<v_jet_reco_aod_orm.size(); l++) {
01311         if ((v_jet_reco_aod_orm)[l]->tlv().Et()<Et_min) {
01312             Et_min = (v_jet_reco_aod_orm)[l]->tlv().Et();
01313         }
01314         if ((v_jet_reco_aod_orm)[l]->tlv().Et()<Et_mincentral && fabs((v_jet_reco_aod_orm)[l]->tlv().Eta())<2.5) {
01315             Et_mincentral = (v_jet_reco_aod_orm)[l]->tlv().Et();
01316         }
01317     }
01318     for (unsigned int l=0; l<v_jet_reco_aod_orm.size(); l++) {
01319         if (fabs((v_jet_reco_aod_orm)[l]->tlv().Eta())<2.5){
01320             //if (fabs((v_jet_reco_aod_orm)[l]->tlv().Eta())<2.5
01321             //&& (v_jet_reco_aod_orm)[l]->tlv().Et()>Et_min) {
01322             nbstdj++;
01323         }
01324     }
01325     t_std_ntuple_2->Fill(weight, Et_mincentral, nbstdj);
01326     t_std_ntuple_3->Fill(weight, Et_min, v_jet_reco_aod_orm.size());
01327 
01328 
01329     //--------------
01330     //-- Matching --
01331     //--------------
01332 
01333     //-------------------------------------
01334     //only for testing on dijet sample -> change back
01335    //  if(v_jet_reco_presel.size()<2){
01336 //         //cout << "Warning: less then two jets in inner part of detector." << endl;
01337 //         return;
01338 //     }
01339 
01340 //     MyParticle* jet1 =  v_jet_reco_presel.at(0);
01341 //     MyParticle* jet2 =  v_jet_reco_presel.at(1);
01342     
01343 //     double deltaR = TMath::Abs(jet1->tlv().DeltaR(jet2->tlv()));  
01344 
01345 //     h_jets_dr->Fill(deltaR);
01346 //     if(deltaR<0.6){
01347 //         //cout << "Jets to close." << endl;
01348 //         return;
01349 //     }
01350 //     h_jets_dr_cut->Fill(deltaR);
01351 
01352 //     vector<MyParticle*> v_jet_reco_central_tmp(0);
01353 //     if(TMath::Abs(jet1->tlv().Eta())<2.5){
01354 //         v_jet_reco_central_tmp.push_back(jet1);
01355 //     }
01356 //     if(TMath::Abs(jet2->tlv().Eta())<2.5){
01357 //         v_jet_reco_central_tmp.push_back(jet2);
01358 //     }
01359     //-------------------------------------
01360 
01361     //test bweight
01362     //vector<MyParticle*> v_jet_reco_central_tmp(0);
01363 
01364     //for (unsigned int k=0; k<v_jet_reco_central.size(); k++) {
01365     
01366     //  double bweight = ((MyParticleJet*)(v_jet_reco_central[k]))->b_tag_weight();
01367     
01368     //  if( bweight < m_cutvalue_bjet_weight_max ){ 
01369     //      v_jet_reco_central_tmp.push_back(v_jet_reco_central[k]);
01370     //  }
01371     //}
01372 
01373     v_trackjet_forcjvmatch = m_tools.pt_eta_cut( v_track_jet_reco_presel, 
01374                                                  m_cutvalue_cjv_trkjet_pt_min*GeV, -1, 
01375                                                  0.0, 2.5);
01376     
01377     match_electrons(v_e_reco_presel, v_e_truth_presel);
01378     match_muons(v_mu_reco_presel, v_mu_truth_presel);
01379     match_jets(v_jet_reco_presel, v_jet_truth_presel);
01380     
01381     match_track_jets(v_track_jet_reco_presel, v_track_jet_truth_presel);
01382     match_track_with_std_jets(v_track_jet_reco_presel, v_jet_reco_central);
01383     match_truth_track_with_std_jets(v_track_jet_truth_presel, v_jet_truth_central);
01384     
01385 
01386     match_fake_track_jets(v_e_reco_aod, v_mu_reco_aod);
01387     //match_fake_track_jets(v_e_truth_presel, v_mu_truth_presel);
01388 
01389     //---------------------
01390     //-- Btag Efficiency --
01391     //---------------------
01392     
01393     jet_btag_eff(v_jet_reco_presel, &m_truth_manager);
01394 
01395     
01396     //------------------------
01397     //-- Cut Based Analysis --
01398     //------------------------
01399 
01400     //match_central_std_with_track_jets(v_jet_reco_central, v_track_jet_reco_presel)
01401    
01402     
01403 
01404 
01405     //h_cut_events->Fill(0,weight);
01406     
01407     if(!m_truth_ana_flag){
01408         
01409         v_centraljet_ana = build_centraljet_vector(v_jet_reco_aod_orm, v_track_jet_reco_aod);
01410         //v_centraljet_ana = build_centraljet_vector(v_jet_reco_aod_orm, v_track_jet_reco_orm);
01411 
01412         cut_based_analysis( v_e_reco_presel,
01413                             v_mu_reco_presel,
01414                             v_jet_reco_presel,
01415                             v_track_jet_reco_presel,
01416                             missinget,
01417                             event.trigger());
01418     }
01419     else{
01420         
01421         v_centraljet_ana = build_centraljet_vector(v_jet_truth_aod_orm, v_track_jet_truth_aod);
01422         //v_centraljet_ana = build_centraljet_vector(v_jet_truth_aod_orm, v_track_jet_truth_orm);
01423 
01424         cut_based_analysis( v_e_truth_presel,
01425                             v_mu_truth_presel,
01426                             v_jet_truth_presel,
01427                             v_track_jet_truth_presel,
01428                             truth_missinget, 
01429                             event.trigger());
01430     }
01431     
01432  
01433     //---------------------
01434     //-- Fill Histograms --
01435     //---------------------
01436     
01437     flag_evt_selected[nb_cuts_max]   = flag_evt_selected[nb_cuts];
01438     flag_evt_selected[nb_cuts_max+1] = flag_evt_selected[nb_cuts];
01439 
01440     for (unsigned int k=0; k<v_cut_candidates.size(); k++) {
01441         fill_all_ana_histos(k,missinget);
01442     }
01443 
01444 
01445     return;
01446 
01447 }
01448 
01449 
01450 // void
01451 // MyHtoWWAnalysis::match_central_std_with_track_jets( vector<MyParticle*> v_std_jet,
01452 //                                                     vector<MyParticle*> v_track_jet)
01453 // {
01454   
01455 //     for (unsigned int k=0; k<v_std_jet.size(); k++) {
01456         
01457 //         MyParticle* tmp_jet = NULL;
01458 //         tmp_jet = m_tools.find_matching_particle(v_std_jet[k],
01459 //                                                  v_track_jet, 
01460 //                                                  m_cutvalue_jet_match_dR,0,0);
01461         
01462 //         if(tmp_jet != NULL){
01463 //             h_jet_reco_central_ptcorr_trkjetmatch->Fill( ((MyParticleJet*)(v_std_jet[k]))
01464 //                                                          ->pt_pucorr(m_primary_vertex_index),weight);
01465         
01466 //             h_jet_reco_central_ptratio_trkjetmatch->Fill( ((MyParticleJet*)(v_std_jet[k]))
01467 //                                                           ->tracks_ptratio(m_primary_vertex_index),weight );
01468 //             h_jet_reco_central_cmsptratio_trkjetmatch->Fill( ((MyParticleJet*)(v_std_jet[k]))
01469 //                                                              ->tracks_cmsptratio(m_primary_vertex_index),weight );
01470              
01471 //             h_jet_reco_central_trkstdjetptcorrratio_trkjetmatch->Fill( ((MyParticleJet*)(v_std_jet[k]))
01472 //                                                                    ->pt_pucorr(m_primary_vertex_index),
01473 //                                                                    tmp_jet->tlv().Pt()/((MyParticleJet*)(v_std_jet[k]))
01474 //                                                                    ->pt_pucorr(m_primary_vertex_index),weight);
01475 
01476 //             h_jet_reco_central_trkvsstdjetptcorr_trkjetmatch->Fill( ((MyParticleJet*)(v_std_jet[k]))
01477 //                                                                     ->pt_pucorr(m_primary_vertex_index),
01478 //                                                                     tmp_jet->tlv().Pt(),weight);
01479             
01480 
01481 //             h_jet_reco_central_pt_trkjetmatch->Fill( ((MyParticleJet*)(v_std_jet[k]))->tlv().Pt(),weight);
01482             
01483 //             h_jet_reco_central_trkstdjetptratio_trkjetmatch->Fill( (v_std_jet[k])->tlv().Pt(),
01484 //                                                                    tmp_jet->tlv().Pt()/(v_std_jet[k])->tlv().Pt(),weight);
01485 
01486 //             h_jet_reco_central_trkvsstdjetpt_trkjetmatch->Fill( (v_std_jet[k])->tlv().Pt(),
01487 //                                                                 tmp_jet->tlv().Pt(),weight);
01488 
01489 //         }
01490 //     }
01491 
01492 //     m_tools.clear_vector(v_track_jet);
01493 
01494 // }
01495 
01496 
01497 //*****************************************************************************
01498 
01499 //::::::::::::::::::::::::::::::::::::
01500 //:: METHOD build_centraljet_vector ::
01501 //::::::::::::::::::::::::::::::::::::
01502 
01503 vector<MyParticle*>
01504 MyHtoWWAnalysis::build_centraljet_vector(vector<MyParticle*> vec_std_jets,
01505                                          vector<MyParticle*> vec_trk_jets){
01506 
01507     //Flag: 0:std, 1:std(eta<2.5), 2:trk, 3:mix, 4: std(2.5<eta<3.2), 5: all, -1: cutopt
01508     vector<MyParticle*> vec_central_jets(0);
01509         
01510     vec_trk_jets = m_tools.sort_particles(vec_trk_jets);
01511     vec_std_jets = m_tools.sort_particles(vec_std_jets); 
01512     //m_tools.check_order(vec_trk_jets);
01513     //m_tools.check_order(vec_std_jets); 
01514 
01515     if(m_switch_cjet_between_fwdjets){ 
01516         m_cutvalue_cjet_eta_max = 5.0;
01517     }
01518     
01519     if(m_flag_cjv_track_jets==0){
01520         vec_central_jets = m_tools.pt_eta_cut( vec_std_jets, 
01521                                                m_cutvalue_cjv_stdjet_pt_min*GeV, -1,
01522                                                0.0, m_cutvalue_cjet_eta_max);
01523     }
01524     else if(m_flag_cjv_track_jets==1){
01525         vec_central_jets = m_tools.pt_eta_cut( vec_std_jets, 
01526                                                m_cutvalue_cjv_stdjet_pt_min*GeV, -1, 
01527                                                0.0, 2.5);
01528     }
01529     else if(m_flag_cjv_track_jets==2){
01530         vec_central_jets = m_tools.pt_eta_cut( vec_trk_jets, 
01531                                                m_cutvalue_cjv_trkjet_pt_min*GeV, -1, 
01532                                                0.0, 2.5);
01533     }
01534     else if(m_flag_cjv_track_jets==3){
01535         vec_central_jets = m_tools.pt_eta_cut( vec_trk_jets, 
01536                                                m_cutvalue_cjv_trkjet_pt_min*GeV, -1, 
01537                                                0.0, 2.5);
01538         
01539         vector<MyParticle*> 
01540             tmp_std_jets = m_tools.pt_eta_cut( vec_std_jets, 
01541                                                m_cutvalue_cjv_stdjet_pt_min*GeV, -1, 
01542                                                2.5,  m_cutvalue_cjet_eta_max);
01543             
01544         vec_central_jets = m_tools.append_vector(vec_central_jets, tmp_std_jets);
01545     }
01546     else if(m_flag_cjv_track_jets==4){
01547         vec_central_jets = m_tools.pt_eta_cut( vec_std_jets, 
01548                                                m_cutvalue_cjv_stdjet_pt_min*GeV, -1, 
01549                                                2.5,  m_cutvalue_cjet_eta_max);
01550         
01551     }
01552     else if(m_flag_cjv_track_jets==5){
01553         vec_central_jets = m_tools.pt_eta_cut( vec_trk_jets, 
01554                                                m_cutvalue_cjv_trkjet_pt_min*GeV, -1, 
01555                                                0.0, 2.5);
01556         
01557         vector<MyParticle*> 
01558             tmp_std_jets = m_tools.pt_eta_cut( vec_std_jets, 
01559                                                m_cutvalue_cjv_stdjet_pt_min*GeV, -1, 
01560                                                0.0,  m_cutvalue_cjet_eta_max);
01561         
01562         vec_central_jets = m_tools.append_vector(vec_central_jets, tmp_std_jets);
01563         
01564     }
01565     else if(m_flag_cjv_track_jets==-1){
01566         
01567         vec_central_jets = m_tools.pt_eta_cut( vec_trk_jets, -1, -1, 0.0, 2.5);
01568         //vec_central_jets = m_tools.append_vector(vec_central_jets, vec_std_jets);
01569 
01570         vector<MyParticle*> 
01571             tmp_std_jets = m_tools.pt_eta_cut( vec_std_jets, -1, -1, 0.0, 2.5);
01572         
01573         vec_central_jets = m_tools.append_vector(vec_central_jets, tmp_std_jets);
01574     }
01575     else{
01576         cerr << "Error: in build_centraljet_vector()" << endl
01577              << "       wrong option: flag_cjv_track_jets = " 
01578              << m_flag_cjv_track_jets
01579              << endl;
01580     }
01581 
01582     return vec_central_jets;
01583     
01584 }
01585 
01586 
01587 //*****************************************************************************
01588 
01589 //::::::::::::::::::::::::::::::
01590 //:: METHOD cut_based_anlysis ::
01591 //::::::::::::::::::::::::::::::
01592 
01593 void 
01594 MyHtoWWAnalysis::cut_based_analysis( vector<MyParticle*> vec_e_in,
01595                                      vector<MyParticle*> vec_mu_in,
01596                                      vector<MyParticle*> vec_jet_in,
01597                                      vector<MyParticle*> vec_track_jet_in,
01598                                      MyMissingEt missinget_in,
01599                                      MyTrigger trigger) {
01600     
01601     // if(!m_flag_cjv_track_jets){
01602 //         v_centraljet_ana = vec_jet_in;
01603 //     }
01604 //     else{
01605 //         v_centraljet_ana =  vec_track_jet_in;
01606 //     }
01607     nb_events[0]++;
01608 
01609 
01610     //----------------------
01611     //-- build candidates --
01612     //----------------------
01613 
01614     vector<MyParticle*> vec_leptons;
01615 
01616     //comp
01617     vec_leptons = m_tools.append_vector(vec_e_in,vec_mu_in);
01618     vec_leptons = m_tools.sort_particles(vec_leptons);
01619     m_tools.check_order(vec_leptons);
01620     
01621    
01622     if(vec_leptons.size()>2){
01623         vec_leptons.resize(2);
01624     }
01625     
01626     if(vec_leptons.size()>2){
01627         cout << "ERROR: vector vec_leptons to long" << endl;
01628     }
01629     
01630     //my
01631 
01632     // if(m_decay_mode=="ee"){
01633 //         vec_leptons = vec_e_in;
01634 //     }
01635 //     else if(m_decay_mode=="mumu"){
01636 //         vec_leptons = vec_mu_in;
01637 //     }
01638 //     else if(m_decay_mode=="emu" || m_decay_mode=="ll"){
01639 //         vec_leptons = vec_e_in;
01640 //         for (unsigned int k=0; k<vec_mu_in.size(); k++){ 
01641 //             vec_leptons.push_back(vec_mu_in[k]);
01642 //         }
01643 //     }
01644 //     else{
01645 //         cerr << "ERROR: in method cut_based_analysis: "
01646 //              << "unknown decay mode: " << m_decay_mode <<endl;
01647 //         return; 
01648 //     }
01649 
01650 
01651     
01652 
01653     vector<MyVBFCandidate>
01654         vec_candidates = build_candidates(vec_jet_in, vec_leptons, missinget_in);
01655 
01656     
01657     for (unsigned iCand=0; iCand<vec_candidates.size(); iCand++){
01658         v_cut_candidates[0].push_back( vec_candidates[iCand] );
01659     }
01660 
01661 
01662     //----------------------------
01663     //-- apply event based cuts --
01664     //----------------------------
01665 
01666     bool return_value;
01667     
01668     for(int k=1; k<=nb_cuts; k++) {
01669 
01670         return_value=0;
01671 
01672         if((cuts[k])=="trigger"){
01673             //* debug info */ cout << "Apply offline trigger cut"<<endl;
01674             return_value = cut_offline_trigger(vec_e_in, vec_mu_in);
01675             //return_value = cut_online_trigger(vec_e_in, vec_mu_in, trigger);
01676             
01677         }
01678         else if((cuts[k])=="nb_objects"){
01679             //* debug info */ cout << "Apply cut on number of reconstructed objects"<<endl;
01680             return_value = cut_nb_objects(vec_e_in, vec_mu_in, vec_jet_in);
01681         }
01682         else if((cuts[k])=="nb_leptons"){
01683             //* debug info */ cout << "Apply cut on number of reconstructed leptons"<<endl;
01684             return_value = cut_nb_leptons(vec_e_in, vec_mu_in);
01685         }
01686         else if((cuts[k])=="nb_jets"){
01687             //* debug info */ cout << "Apply cut on number of reconstructed jets"<<endl;
01688             return_value = cut_nb_jets(vec_jet_in);
01689         }
01690         else if((cuts[k])=="bjet_veto"){
01691             //* debug info */ cout << "Apply cut: bjet_veto"<<endl;
01692             return_value = cut_bjet_veto(vec_jet_in);
01693         }
01694         //else if((cuts[k])=="etmiss"){
01695             //* debug info */ cout << "Apply cut on missing Energy"<<endl;
01696         //  return_value = cut_etmiss(missinget_in);
01697         //}
01698         else{
01699             continue;
01700         }
01701 
01702         if(return_value==false){
01703              return;
01704         }
01705 
01706        //  if((cuts[k])=="trigger"){
01707 //           static ofstream fout("passed_events.txt");
01708 //            fout << "run: 5322 event: " << m_event << endl;
01709 //            //<< "  entry:  " << m_entry << endl;
01710 //         }
01711         
01712         nb_cuts_applied++;
01713         nb_events[k]++;
01714         flag_evt_selected[k]=true;
01715 
01716         for (unsigned iCand=0; iCand<vec_candidates.size(); iCand++){
01717             v_cut_candidates[k].push_back( vec_candidates[iCand] );
01718         }
01719         
01720     }
01721    
01722     
01723     //-----------------------
01724     //-- select candidates --
01725     //-----------------------
01726 
01727     vector<MyVBFCandidate> selected_candidates;
01728         
01729     for (unsigned int iCand=0; iCand<vec_candidates.size(); iCand++){
01730 
01731         if( !select_candidate(vec_candidates[iCand]) ){
01732             continue;
01733         }
01734     
01735         selected_candidates.push_back(vec_candidates[iCand]);
01736     }
01737 
01738 
01739     //----------------------
01740     //-- choose candidate --
01741     //----------------------
01742 
01743     MyVBFCandidate final_candidate;
01744     
01745     if(selected_candidates.size()<1){
01746         return;
01747     }
01748     else if(selected_candidates.size()==1){
01749         final_candidate = selected_candidates[0];
01750     }
01751     else if(selected_candidates.size()>1){
01752         final_candidate = choose_candidate( selected_candidates );
01753     }
01754     else{
01755         cerr << "ERROR: in method cut_based_analysis" << endl
01756              << "       something got screwed in selected_candidates vector" 
01757              << endl;
01758     }
01759 
01760     v_cut_candidates[nb_cuts_max+1].push_back( final_candidate );
01761 
01762 
01763     //-----------------------
01764     //-- fill final histos --
01765     //-----------------------
01766     
01767     //fill_final_histos( final_candidate );
01768     
01769 
01770     return;
01771   }
01772 
01773 //*****************************************************************************
01774 
01775 //:::::::::::::::::::::::::::::
01776 //:: METHOD choose_candidate ::
01777 //:::::::::::::::::::::::::::::
01778 
01779 MyVBFCandidate
01780 MyHtoWWAnalysis::choose_candidate(vector<MyVBFCandidate> candidates){
01781     
01782     if(candidates.size()<2){
01783         cerr << "ERROR: in method choose_candidate" 
01784              << "       couldn't choose between less than 2 candiddates" << endl;
01785         exit(1); 
01786     }
01787 
01788     MyMissingEt missinget = candidates[0].get_missinget();
01789     
01790 
01791     vector<MyParticlePair> vec_tagjet_pairs = get_tagjet_pairs( candidates );    
01792     vector<MyParticlePair> vec_lepton_pairs = get_lepton_pairs( candidates );
01793     
01794     h_multi_tagjet_pairs_nb->Fill(vec_tagjet_pairs.size(),weight);
01795     h_multi_lepton_pairs_nb->Fill(vec_lepton_pairs.size(),weight);
01796 
01797 
01798     MyParticlePair chosen_tagjet_pair;
01799     MyParticlePair chosen_lepton_pair;
01800 
01801 
01802     // choose tagjet pair
01803 
01804     if(vec_tagjet_pairs.size()==1){
01805         chosen_tagjet_pair = vec_tagjet_pairs[0];
01806     }
01807     else if(vec_tagjet_pairs.size()>1){
01808         
01809         double pt_max = 0;
01810         int    index_max = -1;
01811         
01812         for (unsigned int k=0; k<vec_tagjet_pairs.size(); k++) {
01813             
01814             double pt = TMath::Abs(vec_tagjet_pairs[k].get_particle1()->tlv().Pt())
01815                 + TMath::Abs(vec_tagjet_pairs[k].get_particle2()->tlv().Pt());
01816         
01817             if(k==0){
01818                 index_max = k;
01819                 pt_max    = pt; 
01820             }
01821             else if(pt > pt_max){
01822                 index_max = k;
01823                 pt_max    = pt; 
01824             } 
01825         }
01826         
01827         chosen_tagjet_pair = vec_tagjet_pairs[index_max];
01828     }
01829     else{
01830         cerr << "ERROR: in method choose_candidate" << endl
01831              << "       something got screwed in selected_candidates vector" 
01832              << endl;
01833     }
01834 
01835 
01836     // choose lepton pair
01837 
01838     if(vec_lepton_pairs.size()==1){
01839         chosen_lepton_pair = vec_lepton_pairs[0];
01840     }
01841     else if(vec_lepton_pairs.size()>1){
01842         
01843         double pt_max = 0;
01844         int    index_max = -1;
01845         
01846         for (unsigned int k=0; k<vec_lepton_pairs.size(); k++) {
01847             
01848             double pt = TMath::Abs(vec_lepton_pairs[k].get_particle1()->tlv().Pt())
01849                 + TMath::Abs(vec_lepton_pairs[k].get_particle2()->tlv().Pt());
01850         
01851             if(k==0){
01852                 index_max = k;
01853                 pt_max    = pt; 
01854             }
01855             else if(pt > pt_max){
01856                 index_max = k;
01857                 pt_max    = pt; 
01858             } 
01859         }
01860         
01861         chosen_lepton_pair = vec_lepton_pairs[index_max];
01862     }
01863     else{
01864         cerr << "ERROR: in method choose_candidate" << endl
01865              << "       something got screwed in selected_candidates vector" 
01866              << endl;
01867     }
01868 
01869     MyVBFCandidate chosen_candidate( chosen_tagjet_pair, 
01870                                      chosen_lepton_pair, 
01871                                      missinget );
01872     
01873     return chosen_candidate;
01874     
01875   }
01876 
01877 //*****************************************************************************
01878 
01879 //:::::::::::::::::::::::::::::
01880 //:: METHOD build_candidates ::
01881 //:::::::::::::::::::::::::::::
01882 
01883 vector<MyVBFCandidate>
01884 MyHtoWWAnalysis::build_candidates( vector<MyParticle*> vec_jets,
01885                                    vector<MyParticle*> vec_leptons,                                   
01886                                    MyMissingEt missing_et) {
01887 
01888     //init vectors
01889 
01890     vector<MyVBFCandidate> vec_candidates(0);
01891     
01892     //if(vec_leptons.size()<2){
01893         //cerr << ERROR << endl;
01894     //  return vec_candidates;
01895     //}
01896    
01897     if(vec_leptons.size()!=2){
01898         //cerr << ERROR << endl;
01899         return vec_candidates;
01900     }
01901 
01902     if(vec_jets.size()<2){
01903         return vec_candidates;
01904     }
01905 
01906     vector<MyParticlePair> vec_jet_pairs;
01907     vector<MyParticlePair> vec_lepton_pairs;
01908     
01909     //build jet pairs
01910 
01911     
01912     // comp_ana
01913 
01914     vec_jet_pairs.push_back( MyParticlePair(vec_jets[0], 
01915                                             vec_jets[1]) );
01916 
01917     // my ana
01918 
01919     // for (unsigned int i=0; i<vec_jets.size(); i++){
01920 //         for (unsigned int j=i+1; j<vec_jets.size(); j++){
01921             
01922 //             vec_jet_pairs.push_back( MyParticlePair(vec_jets[i], 
01923 //                                                     vec_jets[j]) );
01924 //         }
01925 //     }
01926 
01927     //build lepton pairs
01928 
01929     for (unsigned int i=0; i<vec_leptons.size(); i++){
01930         for (unsigned int j=i+1; j<vec_leptons.size(); j++){
01931             
01932             if( m_decay_mode=="emu" ){
01933 
01934                 int pdgId_1 = TMath::Abs( vec_leptons[i]->pdgId() );
01935                 int pdgId_2 = TMath::Abs( vec_leptons[j]->pdgId() );
01936                                 
01937                 if(pdgId_1 == pdgId_2){
01938                     continue;
01939                 }
01940                 //if( (vec_leptons[i]->type()) == (vec_leptons[j]->type()) ){
01941                 //  continue;
01942                 //}
01943             }
01944         
01945             vec_lepton_pairs.push_back( MyParticlePair(vec_leptons[i], 
01946                                                        vec_leptons[j]) );
01947         }
01948     }
01949 
01950     
01951     //build candidates
01952 
01953     for (unsigned int i=0; i<vec_jet_pairs.size(); i++){
01954         for (unsigned int j=0; j<vec_lepton_pairs.size(); j++){
01955             
01956             vec_candidates.push_back( MyVBFCandidate( vec_jet_pairs[i],
01957                                                       vec_lepton_pairs[j], 
01958                                                       missing_et) 
01959                                       );
01960         }
01961     }
01962         
01963     return vec_candidates;
01964     
01965   }
01966 
01967 //*****************************************************************************
01968 
01969 //:::::::::::::::::::::::::::::
01970 //:: METHOD select_candidate ::
01971 //:::::::::::::::::::::::::::::
01972 
01973 Bool_t 
01974 MyHtoWWAnalysis::select_candidate(MyVBFCandidate candidate){
01975     
01976     //cout << "select candidate, nb_cuts_applied: " << nb_cuts_applied  <<endl;
01977 
01978     bool return_value;
01979 //     nb_events[0]++; 
01980 
01981     for(int k=nb_cuts_applied+1; k<=nb_cuts; k++) {
01982 
01983         //cout << cuts[k] << endl;
01984 
01985         return_value=true;
01986 
01987         if((cuts[k])=="lepton_pt"){
01988             //* debug info */ cout << "Apply cut on lepton pt"<<endl;
01989             return_value = cut_lepton_pt(candidate);
01990         }
01991         else if((cuts[k])=="etmiss"){
01992             //* debug info */ cout << "Apply cut on missing Energy"<<endl;
01993             return_value = cut_etmiss(candidate);
01994         }
01995         else if((cuts[k])=="leptons_charge"){
01996             //* debug info */ cout << "Apply cut on lepton charge"<<endl;
01997             return_value = cut_leptons_charge(candidate);
01998         }
01999         else if((cuts[k])=="leptons_dphi"){
02000             //* debug info */ cout << "Apply cut on lepton delta phi"<<endl;
02001             return_value = cut_leptons_dphi(candidate);
02002         }
02003         else if((cuts[k])=="leptons_dr"){
02004             //* debug info */ cout << "Apply cut on lepton delta R"<<endl;
02005             return_value = cut_leptons_dr(candidate);
02006         }
02007         else if((cuts[k])=="leptons_theta"){
02008             //* debug info */ cout << "Apply cut on lepton mass"<<endl;
02009             return_value = cut_leptons_theta(candidate);
02010         }
02011         else if((cuts[k])=="leptons_mass"){
02012             //* debug info */ cout << "Apply cut on lepton mass"<<endl;
02013             return_value = cut_leptons_mass(candidate);
02014         }
02015         else if((cuts[k])=="leptons_pt"){
02016             //* debug info */ cout << "Apply cut on lepton mass"<<endl;
02017             return_value = cut_leptons_pt(candidate);
02018         }
02019         else if((cuts[k])=="tau_veto"){
02020             //* debug info */ cout << "Apply tau veto"<<endl;
02021             return_value = cut_tau_veto(candidate);
02022         }
02023         else if((cuts[k])=="tagjet_no_bjet"){
02024             //* debug info */ cout << "Apply cut tagjet_no_bjet"<<endl;
02025             return_value = cut_tagjet_no_bjet(candidate);
02026         }
02027         else if((cuts[k])=="jets_pt"){
02028             //* debug info */ cout << "Apply cut on jet pt"<<endl;
02029              return_value = cut_jets_pt(candidate);
02030         }
02031         else if((cuts[k])=="jets_hemisphere"){
02032             //* debug info */ cout << "Apply cut on jet hemisphere"<<endl;
02033             return_value = cut_jets_hemisphere(candidate);
02034         }
02035         else if((cuts[k])=="jets_deta"){
02036             //* debug info */ cout << "Apply cut on jets delta Eta"<<endl;
02037             return_value = cut_jets_deta(candidate);
02038         }
02039         else if((cuts[k])=="jets_dphi"){
02040             //* debug info */ cout << "Apply cut on jet delta phi"<<endl;
02041             return_value = cut_jets_dphi(candidate);
02042         }
02043         else if((cuts[k])=="jets_mass"){
02044             //* debug info */ cout << "Apply cut on jet pair invariant mass"<<endl;
02045             return_value = cut_jets_mass(candidate);
02046         }
02047         else if((cuts[k])=="central_jet_veto"){
02048              //* debug info */ cout << "Apply cut on central jet veto"<<endl;
02049             return_value = cut_central_jet_veto(candidate);
02050         }
02051         else if((cuts[k])=="leptons_jets_deta"){
02052             //* debug info */ cout << "Apply cut on lepton - jet topology"<<endl;
02053             return_value = cut_leptons_jets_deta(candidate);
02054         }
02055         else if((cuts[k])=="transverse_mass"){
02056             //* debug info */ cout << "Apply cut on transverse mass"<<endl;
02057             return_value = cut_transverse_mass(candidate);
02058         }
02059         else if((cuts[k])=="pt_balance"){
02060              //* debug info */ cout << "Apply cut on pt balance"<<endl;
02061              return_value = cut_pt_balance(candidate);
02062         }
02063         else {
02064             cout << "ERROR: Cut "<< cuts[k] << " unknown!" <<endl;
02065         }
02066 
02067         if(return_value==false){
02068             return false;
02069         }
02070 
02071        //  if((cuts[k])=="jets_hemisphere"){
02072 //             static ofstream fout("passed_events.txt");
02073 //             fout << "run: 5322 event: " << m_event << endl;
02074 //             //<< "  entry:  " << m_entry << endl;
02075 //         }
02076 
02077         nb_candidates[k]++;
02078 
02079         if(!flag_evt_selected[k]){
02080             nb_events[k]++;
02081             flag_evt_selected[k]=true;
02082         }
02083         
02084         v_cut_candidates[k].push_back( candidate );
02085         
02086     } 
02087     
02088     v_cut_candidates[nb_cuts_max].push_back( candidate );
02089     
02090     return true;
02091 }
02092 
02093 
02094 //*****************************************************************************
02095 
02096 //:::::::::::::::::::::::::::::::
02097 //:: METHOD cut_online_trigger ::
02098 //:::::::::::::::::::::::::::::::
02099 
02100 bool 
02101 MyHtoWWAnalysis::cut_online_trigger( std::vector<MyParticle*> vec_e,
02102                                      std::vector<MyParticle*> vec_mu,
02103                                      MyTrigger trigger ){
02104 
02105     int event_flavour(0);
02106     // 0 if event isnt triggered
02107     // 1 if the triggered high pt lepton is an electron
02108     // 2 if it is a muon
02109         
02110     bool triggerdecision_EF_mu20i;
02111     bool triggerdecision_EF_e25i;
02112         
02113     bool triggerdecisionsinglemuon;
02114     bool triggerdecisionsingleelectron;
02115     bool triggerdecisiondimuon;
02116     bool triggerdecisiondielectron;
02117     bool triggerdecisionelectronmuon;
02118     bool triggerdecisionfinal;
02119 
02120     double pt_e(0);
02121     double pt_mu(0);
02122 
02123     triggerdecision_EF_mu20i = trigger.isTriggered("EF_mu20i",3);
02124     triggerdecision_EF_e25i  = trigger.isTriggered("EF_e25i",3);
02125         
02126         
02127         
02128     // >= 1 muon with pt>20 GeV
02129     triggerdecisionsinglemuon=false;
02130     if ((m_tools.pt_eta_cut(vec_mu, 20.0/GeV, -1.0, 0.0, 3.5)).size()>=1
02131         //           && triggerdecision_EF_mu20i
02132         ){
02133         triggerdecisionsinglemuon=true;
02134         pt_mu = (vec_mu[0])->tlv().Pt();
02135     }
02136     // >=2 muons with pt>10 GeV
02137     triggerdecisiondimuon=false;
02138     if ((m_tools.pt_eta_cut(vec_mu, 10.0/GeV, -1.0, 0.0, 3.5)).size()>=2){
02139         triggerdecisiondimuon=true;
02140     }
02141     // >= 1 electron with pt>25 GeV
02142     triggerdecisionsingleelectron=false;
02143     if ((m_tools.pt_eta_cut(vec_e, 25.0/GeV, -1.0, 0.0, 3.5)).size()>=1
02144         //           && triggerdecision_EF_e25i
02145         ){
02146         if(TMath::Abs((vec_e[0])->tlv().Et()-(vec_e[0])->tlv().Pt())>0.1){
02147             cerr<<"                     ET: "<< (vec_e[0])->tlv().Et()<<" pt: "<<(vec_e[0])->tlv().Pt()<<endl;
02148             //exit(1);
02149         }
02150         triggerdecisionsingleelectron=true;
02151         pt_e = (vec_e[0])->tlv().Pt();
02152     }
02153     // >=2 electrons with pt>15 GeV
02154     triggerdecisiondielectron=false;
02155     if ((m_tools.pt_eta_cut(vec_e, 15.0/GeV, -1.0, 0.0, 3.5)).size()>=2){
02156         triggerdecisiondielectron=true;
02157     }
02158     // >= 1 electron with pt>15 GeV and 1 muon with pt>10 GeV
02159     triggerdecisionelectronmuon=false;
02160     if ((m_tools.pt_eta_cut(vec_e, 15.0/GeV, -1.0, 0.0, 3.5)).size()>=1
02161         && (m_tools.pt_eta_cut(vec_mu, 10.0/GeV, -1.0, 0.0, 3.5)).size()>=1){
02162         triggerdecisionelectronmuon=true;
02163     }
02164         
02165     triggerdecisionfinal =  triggerdecisionsingleelectron
02166         || triggerdecisionsinglemuon
02167         //                              || triggerdecisiondielectron
02168         //                              || triggerdecisiondimuon
02169         //                              || triggerdecisionelectronmuon
02170         ;
02171         
02172     if(!triggerdecision_EF_mu20i && !triggerdecision_EF_e25i){
02173         h_trigger_online->Fill(0., weight);
02174         h_trigger_combined->Fill(0., weight);
02175         event_flavour=0;
02176     }
02177     else if(triggerdecision_EF_mu20i && !triggerdecision_EF_e25i){
02178         h_trigger_online->Fill(2., weight);
02179         if(triggerdecisionsinglemuon){
02180             h_trigger_combined->Fill(2., weight);
02181             event_flavour=2;
02182         }
02183         else{
02184             h_trigger_combined->Fill(0., weight);
02185             event_flavour=0;
02186         }
02187     }
02188     else if(!triggerdecision_EF_mu20i && triggerdecision_EF_e25i){
02189         h_trigger_online->Fill(1., weight);
02190         if(triggerdecisionsingleelectron){
02191             h_trigger_combined->Fill(1., weight);
02192             event_flavour=1;
02193         }
02194         else{
02195             h_trigger_combined->Fill(0., weight);
02196             event_flavour=0;
02197         }
02198     }
02199     else if(triggerdecision_EF_mu20i && triggerdecision_EF_e25i){
02200         if(vec_mu.size()>0)pt_mu = (vec_mu[0])->tlv().Pt();
02201         if(vec_e.size()>0)pt_e = (vec_e[0])->tlv().Et();
02202         h_trigger_online->Fill(3., weight);
02203                 
02204                 
02205         // soshis second version: (more reasonable)
02206         if(triggerdecisionsingleelectron && triggerdecisionsinglemuon){
02207             h_trigger_combined->Fill(3., weight);
02208             if(pt_e>pt_mu){
02209                 event_flavour=1;
02210             }
02211             else{
02212                 event_flavour=2;
02213             }
02214         }
02215         else if(triggerdecisionsingleelectron && !triggerdecisionsinglemuon){
02216             h_trigger_combined->Fill(1., weight);
02217             event_flavour=1;
02218         }
02219         else if(!triggerdecisionsingleelectron && triggerdecisionsinglemuon){
02220             h_trigger_combined->Fill(2., weight);
02221             event_flavour=2;
02222         }
02223         else{
02224             h_trigger_combined->Fill(0., weight);
02225             event_flavour=0;
02226         }
02227         
02228     }
02229     //  else if(triggerdecision_EF_mu20i && triggerdecision_EF_e25i){
02230     //          h_trigger_online->Fill(3., weight);
02231     //          if(triggerdecisionsingleelectron || triggerdecisionsinglemuon){
02232     //                  h_trigger_combined->Fill(3., weight);
02233     //                  if(pt_e>pt_mu){
02234     //                          event_flavour=1;
02235     //                  }
02236     //                  else{
02237     //                          event_flavour=2;
02238     //                  }
02239     //          }
02240     //          else{
02241     //                  h_trigger_combined->Fill(0., weight);
02242     //                  event_flavour=0;
02243     //          }
02244     //  }
02245     else{
02246         cout<<"Error in trigger "<<endl;
02247     }
02248         
02249     //* debug info */ cout<<"event_flavour: "<<event_flavour<<endl;
02250     //* debug info */ cout<<"pt_mu: "<<pt_mu<<endl;
02251     //* debug info */ cout<<"pt_e: "<<pt_e<<endl;
02252     //* debug info */ cout<<"triggerdecision_EF_mu20i: "<<triggerdecision_EF_mu20i<<endl;
02253     //* debug info */ cout<<"triggerdecision_EF_e25i: "<<triggerdecision_EF_e25i<<endl;
02254         
02255     //if(ana_require_trigger_flavour!=-1){
02256 
02257     //  if(event_flavour!=ana_require_trigger_flavour){
02258     //      return false;
02259     //  }
02260     //}
02261     //  if(event_flavour!=2) return 0;
02262     if(event_flavour==0){ 
02263         return false;
02264     }
02265 
02266         
02267     if (!triggerdecisionfinal){
02268         return false;
02269     }   
02270  
02271     
02272     return true;
02273   }
02274 
02275 
02276 
02277 
02278 //*****************************************************************************
02279 
02280 //::::::::::::::::::::::::::::::::
02281 //:: METHOD cut_offline_trigger ::
02282 //::::::::::::::::::::::::::::::::
02283 
02284 bool 
02285 MyHtoWWAnalysis::cut_offline_trigger( std::vector<MyParticle*> vec_e,
02286                                       std::vector<MyParticle*> vec_mu){
02287         
02288     bool trigger_singlemuon;
02289     bool trigger_singleelectron;
02290     bool trigger_dimuon;
02291     bool trigger_dielectron;
02292     bool trigger_electronmuon;
02293     bool trigger_final;
02294 
02295     // >= 1 muon with pt>20 GeV
02296     trigger_singlemuon=false;
02297     if ((m_tools.pt_eta_cut(vec_mu, 20.0*GeV, -1, 0.0, 2.5)).size()>=1){
02298         trigger_singlemuon=true;
02299         h_offline_trigger->Fill(0.);
02300     }
02301         
02302     // >=2 muons with pt>10 GeV
02303     trigger_dimuon=false;
02304     if ((m_tools.pt_eta_cut(vec_mu, 10.0*GeV, -1, 0.0, 2.5)).size()>=2){
02305         trigger_dimuon=true;
02306         h_offline_trigger->Fill(1.);
02307     }
02308         
02309     // >= 1 electron with pt>25 GeV
02310     trigger_singleelectron=false;
02311     if ((m_tools.pt_eta_cut(vec_e, 25.0*GeV, -1, 0.0, 2.5)).size()>=1){
02312         trigger_singleelectron=true;
02313         h_offline_trigger->Fill(2.);
02314     }
02315         
02316     // >=2 electrons with pt>15 GeV
02317     trigger_dielectron=false;
02318     if ((m_tools.pt_eta_cut(vec_e, 15.0*GeV, -1, 0.0, 2.5)).size()>=2){
02319         trigger_dielectron=true;
02320         h_offline_trigger->Fill(3.);
02321     }
02322         
02323     // >= 1 electron with pt>15 GeV and 1 muon with pt>10 GeV
02324     trigger_electronmuon=false;
02325     if ((m_tools.pt_eta_cut(vec_e, 15.0*GeV, -1, 0.0, 2.5)).size()>=1
02326         && (m_tools.pt_eta_cut(vec_mu, 10.0*GeV, -1, 0.0, 2.5)).size()>=1){
02327         trigger_electronmuon=true;
02328         h_offline_trigger->Fill(4.);
02329     }
02330         
02331     trigger_final = (trigger_singleelectron || trigger_singlemuon ||
02332                      trigger_dielectron     || trigger_dimuon || 
02333                      trigger_electronmuon
02334                      ); 
02335     
02336     //trigger_final = trigger_dielectron;
02337     
02338     if (!trigger_final){ 
02339         return false;
02340     }
02341     
02342     h_offline_trigger->Fill(5.);  
02343     return true;
02344   }
02345 
02346 
02347 //*****************************************************************************
02348 
02349 //:::::::::::::::::::::::::::
02350 //:: METHOD cut_nb_objects ::
02351 //:::::::::::::::::::::::::::
02352 
02353 bool 
02354 MyHtoWWAnalysis::cut_nb_objects( vector<MyParticle*> vec_e,
02355                                  vector<MyParticle*> vec_mu,
02356                                  vector<MyParticle*> vec_jet){
02357     
02358     if (m_decay_mode=="ee"){
02359         if (vec_e.size()<2) return false;
02360     }
02361     else if (m_decay_mode=="mumu"){
02362         if (vec_mu.size()<2) return false;
02363     }
02364     else if (m_decay_mode=="emu"){
02365         if (vec_e.size()<1 || vec_mu.size()<1) return false;
02366     }
02367     else if (m_decay_mode=="ll"){
02368         //cout << "nb_leptons: " << (vec_e.size() + vec_mu.size()) << endl;
02369         if ((vec_e.size() + vec_mu.size())<2) return false;
02370     }
02371     else {
02372         cerr << "ERROR: in method cut_nb_objects: "
02373              << "unknown decay mode: "<< m_decay_mode <<endl;
02374         return false;
02375     }
02376     
02377     if(vec_jet.size()<2){ 
02378         return false;
02379     }
02380     
02381     return true;
02382   }
02383 
02384 
02385 //*****************************************************************************
02386 
02387 //:::::::::::::::::::::::::::
02388 //:: METHOD cut_nb_leptons ::
02389 //:::::::::::::::::::::::::::
02390 
02391 bool 
02392 MyHtoWWAnalysis::cut_nb_leptons( vector<MyParticle*> vec_e,
02393                                  vector<MyParticle*> vec_mu){
02394     
02395 
02396     //n_ll == 2
02397  //    if (m_decay_mode=="ee"){
02398 //         if (vec_e.size()!=2) return false;
02399 //     }
02400 //     else if (m_decay_mode=="mumu"){
02401 //         if (vec_mu.size()!=2) return false;
02402 //     }
02403 //     else if (m_decay_mode=="emu"){
02404 //         if (vec_e.size()!=1 || vec_mu.size()!=1) return false;
02405 //     }
02406 //     else if (m_decay_mode=="ll"){
02407 //         //cout << "nb_leptons: " << (vec_e.size() + vec_mu.size()) << endl;
02408 //         if ((vec_e.size() + vec_mu.size())!=2) return false;
02409 //     }
02410 
02411     
02412 
02413     //n_ll >=2
02414     // if (m_decay_mode=="ee"){
02415 //         if (vec_e.size()<2) return false;
02416 //     }
02417 //     else if (m_decay_mode=="mumu"){
02418 //         if (vec_mu.size()<2) return false;
02419 //     }
02420 //     else if (m_decay_mode=="emu"){
02421 //         if (vec_e.size()<1 || vec_mu.size()<1) return false;
02422 //     }
02423 //     else if (m_decay_mode=="ll"){
02424 //         //cout << "nb_leptons: " << (vec_e.size() + vec_mu.size()) << endl;
02425 //         if ((vec_e.size() + vec_mu.size())<2) return false;
02426 //     }
02427 //else {
02428     //  cerr << "ERROR: in method cut_nb_leptons: "
02429     //       << "unknown decay mode: "<< m_decay_mode <<endl;
02430     //  return false;
02431     //}
02432 
02433     //leading leptons
02434     vector<MyParticle*> vec_leptons;
02435     vec_leptons=m_tools.append_vector(vec_e,vec_mu);
02436     vec_leptons = m_tools.sort_particles(vec_leptons);
02437     m_tools.check_order(vec_leptons);
02438 
02439     //if(vec_leptons.size()<2){
02440     //   return false;
02441     //}
02442   
02443     if(vec_leptons.size()!=2){
02444         return false;
02445     }
02446 
02447     MyParticlePair leptonpair(vec_leptons[0], vec_leptons[1]);
02448 
02449     if(m_decay_mode!="ll" && m_decay_mode!=leptonpair.get_lepton_flavors()){
02450         return false;
02451     }
02452   
02453     
02454     return true;
02455   }
02456 
02457 //*****************************************************************************
02458 
02459 //::::::::::::::::::::::::
02460 //:: METHOD cut_nb_jets ::
02461 //::::::::::::::::::::::::
02462 
02463 bool 
02464 MyHtoWWAnalysis::cut_nb_jets(vector<MyParticle*> vec_jet){
02465     
02466     if(vec_jet.size()<2){ 
02467         return false;
02468     }
02469     
02470     return true;
02471   }
02472 
02473 //*****************************************************************************
02474 
02475 //:::::::::::::::::::::::::::
02476 //:: METHOD cut_bjet_veto ::
02477 //:::::::::::::::::::::::::::
02478 
02479 bool 
02480 MyHtoWWAnalysis::cut_bjet_veto( vector<MyParticle*> vec_jet ){
02481 
02482     vector<MyParticle*> vec_bjet_cands = 
02483         m_tools.pt_eta_cut(vec_jet, 20.0*GeV, -1, 0.0, 2.5);
02484     
02485     for (unsigned int k=0; k<vec_bjet_cands.size(); k++) {
02486         
02487         double bweight = ((MyParticleJet*)(vec_bjet_cands[k]))->b_tag_weight();
02488 
02489         if( bweight > m_cutvalue_bjet_weight_max ){ 
02490             return false; 
02491         }
02492     }
02493 
02494     
02495     return true;
02496     
02497   }
02498 
02499 //*****************************************************************************
02500 
02501 //:::::::::::::::::::::::
02502 //:: METHOD cut_etmiss ::
02503 //:::::::::::::::::::::::
02504 
02505 bool 
02506 MyHtoWWAnalysis::cut_etmiss(MyMissingEt missing_et){
02507     
02508     if (missing_et.met() < m_cutvalue_etmiss_min){ 
02509         return false;
02510     }
02511     
02512     return true;
02513   }
02514 
02515 bool 
02516 MyHtoWWAnalysis::cut_etmiss(MyVBFCandidate candidate){
02517     
02518     TString type = candidate.get_lepton_pair().get_lepton_flavors();
02519 
02520     if( type!="ee" && type !="mumu" ){
02521         return true;
02522     }
02523 
02524     
02525     if (candidate.get_missinget().met() < m_cutvalue_etmiss_min){ 
02526         return false;
02527     }
02528     
02529     return true;
02530   }
02531 
02532 
02533 //*****************************************************************************
02534 
02535 //::::::::::::::::::::::::::
02536 //:: METHOD cut_lepton_pt ::
02537 //::::::::::::::::::::::::::
02538 
02539 bool
02540 MyHtoWWAnalysis::cut_lepton_pt(MyVBFCandidate candidate){
02541     
02542     double pt1 = candidate.get_lepton_pair().get_particle1()->tlv().Pt();
02543     double pt2 = candidate.get_lepton_pair().get_particle2()->tlv().Pt();
02544     
02545 
02546     if(m_cutvalue_lepton1_pt_min > -1){
02547         if( TMath::Max(pt1,pt2) < m_cutvalue_lepton1_pt_min){
02548             return false;
02549         }
02550     }
02551 
02552     if(m_cutvalue_lepton2_pt_min > -1){
02553         if( TMath::Min(pt1,pt2) < m_cutvalue_lepton2_pt_min){
02554             return false;
02555         }
02556     }
02557   
02558     if(m_cutvalue_lepton_pt_max > -1){
02559         if( pt1 > m_cutvalue_lepton_pt_max ||
02560             pt2 > m_cutvalue_lepton_pt_max ){
02561             
02562             return false;
02563         }
02564     }
02565 
02566     return true;
02567   }
02568 
02569 //*****************************************************************************
02570 
02571 //:::::::::::::::::::::::::::::::
02572 //:: METHOD cut_leptons_charge ::
02573 //:::::::::::::::::::::::::::::::
02574 
02575 bool 
02576 MyHtoWWAnalysis::cut_leptons_charge(MyVBFCandidate candidate){
02577     
02578     double charge1 = candidate.get_lepton_pair().get_particle1()->charge();
02579     double charge2 = candidate.get_lepton_pair().get_particle2()->charge();
02580     
02581     if((charge1*charge2) > 0){
02582         return false;
02583     }
02584     
02585     return true;
02586   }
02587 
02588 
02589 //*****************************************************************************
02590 
02591 //:::::::::::::::::::::::::::::
02592 //:: METHOD cut_leptons_dphi ::
02593 //:::::::::::::::::::::::::::::
02594 
02595 bool 
02596 MyHtoWWAnalysis::cut_leptons_dphi(MyVBFCandidate candidate){
02597     
02598     double dphi = TMath::Abs( candidate.get_lepton_pair().DeltaPhi() );
02599     //TMath::Cos((v_2l_ana[j]).DeltaPhi())
02600     
02601     if( dphi > m_cutvalue_leptons_dphi_max ){   
02602         return false;
02603     }
02604     
02605     return true;
02606   }
02607 
02608 //*****************************************************************************
02609 
02610 //:::::::::::::::::::::::::::
02611 //:: METHOD cut_leptons_dr ::
02612 //:::::::::::::::::::::::::::
02613 
02614 bool
02615 MyHtoWWAnalysis::cut_leptons_dr(MyVBFCandidate candidate){
02616         
02617     double dr = TMath::Abs( candidate.get_lepton_pair().DeltaR() );
02618     
02619     if( dr > m_cutvalue_leptons_dr_max ){
02620         return false;
02621     }
02622     
02623     return true;
02624   }
02625 
02626 //*****************************************************************************
02627 
02628 //::::::::::::::::::::::::::::::
02629 //:: METHOD cut_leptons_theta ::
02630 //::::::::::::::::::::::::::::::
02631 
02632 bool 
02633 MyHtoWWAnalysis::cut_leptons_theta(MyVBFCandidate candidate){
02634     
02635     double costheta = TMath::Abs( candidate.get_lepton_pair().tlv().CosTheta() );
02636     
02637     if( costheta < m_cutvalue_leptons_costheta_min ){   
02638         return false;
02639     }
02640     
02641     return true;
02642   }
02643 
02644 //*****************************************************************************
02645 
02646 //:::::::::::::::::::::::::::
02647 //:: METHOD cut_leptons_mass ::
02648 //:::::::::::::::::::::::::::
02649 
02650 bool 
02651 MyHtoWWAnalysis::cut_leptons_mass(MyVBFCandidate candidate){
02652 
02653     double  mass = candidate.get_lepton_pair().M();
02654     TString type = candidate.get_lepton_pair().get_lepton_flavors();
02655 
02656     double cutvalue = m_cutvalue_leptons_mass_max;
02657     
02658 
02659     if( type=="ee" || type =="mumu" ){
02660         cutvalue = 75.0;
02661     }
02662 
02663     if( mass > cutvalue ){
02664         return false;
02665     }
02666     
02667     return true;
02668   }
02669 
02670 //*****************************************************************************
02671 
02672 //:::::::::::::::::::::::::::
02673 //:: METHOD cut_leptons_pt ::
02674 //:::::::::::::::::::::::::::
02675 
02676 bool 
02677 MyHtoWWAnalysis::cut_leptons_pt(MyVBFCandidate candidate){
02678 
02679     double pt = candidate.get_lepton_pair().tlv().Pt();
02680     
02681     if( pt > m_cutvalue_leptons_pt_max ){
02682         return false;
02683     }
02684     
02685     return true;
02686   }
02687 
02688 //*****************************************************************************
02689 
02690 //:::::::::::::::::::::::::::::::
02691 //:: METHOD cut_tagjet_no_bjet ::
02692 //:::::::::::::::::::::::::::::::
02693 
02694 bool 
02695 MyHtoWWAnalysis::cut_tagjet_no_bjet(MyVBFCandidate candidate){
02696         
02697     double bweight1 = ((MyParticleJet*)(candidate.get_tagjet_pair().get_particle1()))->b_tag_weight();
02698     double bweight2 = ((MyParticleJet*)(candidate.get_tagjet_pair().get_particle2()))->b_tag_weight();
02699     
02700     if( bweight1 > m_cutvalue_bjet_weight_max ||
02701         bweight2 > m_cutvalue_bjet_weight_max ){
02702         
02703         return false;
02704     }
02705     
02706     return true;
02707   }
02708 
02709 //*****************************************************************************
02710 
02711 //::::::::::::::::::::::::
02712 //:: METHOD cut_jets_pt ::
02713 //::::::::::::::::::::::::
02714 
02715 bool 
02716 MyHtoWWAnalysis::cut_jets_pt(MyVBFCandidate candidate){
02717         
02718     double pt1 = candidate.get_tagjet_pair().get_particle1()->tlv().Pt();
02719     double pt2 = candidate.get_tagjet_pair().get_particle2()->tlv().Pt();
02720     
02721     if( TMath::Max(pt1,pt2) < m_cutvalue_jet1_pt_min ||
02722         TMath::Min(pt1,pt2) < m_cutvalue_jet2_pt_min ){
02723         
02724         return false;
02725      }
02726 
02727     return true;
02728   }
02729 
02730 //*****************************************************************************
02731 
02732 //::::::::::::::::::::::::::::::::
02733 //:: METHOD cut_jets_hemisphere ::
02734 //::::::::::::::::::::::::::::::::
02735 
02736 bool 
02737 MyHtoWWAnalysis::cut_jets_hemisphere(MyVBFCandidate candidate){
02738     
02739     double etaprod = candidate.get_tagjet_pair().EtaProd();
02740 
02741     if(etaprod > 0){
02742         return false; 
02743     }
02744    
02745     return true;
02746     
02747   }
02748         
02749 //*****************************************************************************
02750 
02751 //::::::::::::::::::::::::::
02752 //:: METHOD cut_jets_deta ::
02753 //::::::::::::::::::::::::::
02754 
02755 bool
02756 MyHtoWWAnalysis::cut_jets_deta(MyVBFCandidate candidate){
02757     
02758     double deta = candidate.get_tagjet_pair().AbsDeltaEta();
02759     
02760     if(deta < m_cutvalue_jets_absdeta_min){
02761         return false; 
02762     }
02763     
02764     return true;
02765     
02766   }
02767         
02768 //*****************************************************************************
02769 
02770 //::::::::::::::::::::::::::
02771 //:: METHOD cut_jets_dphi ::
02772 //::::::::::::::::::::::::::
02773 
02774 bool 
02775 MyHtoWWAnalysis::cut_jets_dphi(MyVBFCandidate candidate){
02776 
02777     double dphi = TMath::Abs(candidate.get_tagjet_pair().DeltaPhi());
02778 
02779     if(dphi > m_cutvalue_jets_absdphi_max){
02780         return false;   
02781     }
02782 
02783     return true;
02784 
02785   }
02786         
02787 //*****************************************************************************
02788 
02789 //::::::::::::::::::::::::::
02790 //:: METHOD cut_jets_mass ::
02791 //::::::::::::::::::::::::::
02792 
02793 bool 
02794 MyHtoWWAnalysis::cut_jets_mass(MyVBFCandidate candidate){
02795 
02796     double mass = candidate.get_tagjet_pair().M();
02797 
02798     if(m_cutvalue_jets_mass_min > -1){
02799         if(mass < m_cutvalue_jets_mass_min){
02800             return false;   
02801         }
02802     }
02803     
02804     if(m_cutvalue_jets_mass_max > -1){
02805         if(mass > m_cutvalue_jets_mass_max){
02806             return false;   
02807         }
02808     }
02809 
02810     return true;
02811 
02812   }
02813 
02814 
02815 //*****************************************************************************
02816 
02817 //:::::::::::::::::::::::::::::::::
02818 //:: METHOD cut_central_jet_veto ::
02819 //:::::::::::::::::::::::::::::::::
02820 
02821 bool 
02822 MyHtoWWAnalysis::cut_central_jet_veto(MyVBFCandidate candidate){
02823         
02824     int id_jet3;
02825     int centraljetcount = 0;
02826  
02827     double dr1(1000.);
02828     double dr2(1000.);
02829     
02830     bool centraljet         = false;
02831     bool centraljet_at_all  = false;
02832     bool cj_between_fwdjets = false;
02833     
02834     TLorentzVector tlv_central_jet;
02835     
02836     // apply cuts on central jet candidates
02837     
02838     if(m_switch_cjet_between_fwdjets){ 
02839         
02840         m_cutvalue_cjet_eta_max = 5.0;
02841     }
02842 
02843     
02844     vector<MyParticle*> vec_centraljets 
02845         = m_tools.pt_eta_cut( v_centraljet_ana, 5.0*GeV, -1, 
02846                               0.0, m_cutvalue_cjet_eta_max);
02847     
02848     int id_jet1 = candidate.get_tagjet_pair().get_particle1()->index();
02849     int id_jet2 = candidate.get_tagjet_pair().get_particle2()->index();
02850     
02851     TLorentzVector tlv_fwd_jet1 = candidate.get_tagjet_pair().get_particle1()->tlv();
02852     TLorentzVector tlv_fwd_jet2 = candidate.get_tagjet_pair().get_particle2()->tlv();
02853     
02854     double fwd_jet_eta_min = TMath::Min(tlv_fwd_jet1.Eta(),tlv_fwd_jet2.Eta());
02855     double fwd_jet_eta_max = TMath::Max(tlv_fwd_jet1.Eta(),tlv_fwd_jet2.Eta());
02856     
02857     //cout << "jet1: " << id_jet1 << ", " << tlv_fwd_jet1.Eta() << endl;
02858     //cout << "jet2: " << id_jet2 << ", " << tlv_fwd_jet2.Eta() << endl;
02859     
02860     int nb_std_cjet_cands(0);
02861     int nb_trk_cjet_cands(0);
02862 
02863     for (unsigned int k=0; k<vec_centraljets.size(); k++){
02864         
02865         tlv_central_jet = (vec_centraljets[k])->tlv();
02866         dr1 = tlv_central_jet.DeltaR(tlv_fwd_jet1);
02867         dr2 = tlv_central_jet.DeltaR(tlv_fwd_jet2);
02868 
02869         h_fwj_cj_dr_nocut->Fill(dr1);
02870         h_fwj_cj_dr_nocut->Fill(dr2);
02871 
02872        
02873         if ( TString(vec_centraljets[k]->type()).Contains("particle_jet") ){
02874             
02875             id_jet3 = (vec_centraljets[k])->index();   
02876             if (id_jet3==id_jet1 || id_jet3==id_jet2){
02877                 continue;
02878             }
02879             nb_std_cjet_cands++;
02880         }
02881         else if( vec_centraljets[k]->type() == "track_jet" ){
02882             
02883             double dr_match(0.1);
02884             if ( dr1<dr_match || dr2<dr_match ){
02885                 continue;
02886             }
02887             nb_trk_cjet_cands++;
02888         }else{
02889             cerr << "Error: in cut_central_jet_veto" << endl
02890                  << "       object \'" << vec_centraljets[k]->type() 
02891                  << "\' is not a jet" << endl;
02892             exit(1);
02893         }
02894 
02895         
02896         //fill cut opt ntuple
02897         //if ( nb_std_cjet_cands==1 && TString(vec_centraljets[k]->type()).Contains("particle_jet") ){
02898         if ( TString(vec_centraljets[k]->type()).Contains("particle_jet") ){
02899             int n_trks_from_primvert = 0;
02900             MyParticleJet *cjet = (MyParticleJet*)(vec_centraljets[k]);
02901              
02902             for (int itrk=0; itrk<cjet->nb_tracks(); itrk++) {
02903                 
02904                 if(cjet->tracks_vertex_index(itrk) ==  m_primary_vertex_index){
02905                     n_trks_from_primvert++;
02906                 }
02907             }
02908 
02909             t_cutopt_std_jet->Fill( weight,
02910                                     nb_std_cjet_cands,
02911                                     tlv_central_jet.Pt(),
02912                                     tlv_central_jet.Eta(),
02913                                     tlv_central_jet.Phi(),
02914                                     cjet->nb_tracks(),
02915                                     n_trks_from_primvert,
02916                                     cjet->tracks_ptratio(m_primary_vertex_index),
02917                                     cjet->tracks_cmsptratio(m_primary_vertex_index)); 
02918         }
02919         //if ( nb_trk_cjet_cands==1 && vec_centraljets[k]->type() == "track_jet" ){
02920         if ( vec_centraljets[k]->type() == "track_jet" ){
02921             
02922             t_cutopt_trk_jet->Fill(weight,
02923                                    nb_trk_cjet_cands,
02924                                    tlv_central_jet.Pt(),
02925                                    tlv_central_jet.Eta(),
02926                                    tlv_central_jet.Phi()); 
02927         }
02928 
02929         
02930         if( TString(vec_centraljets[k]->type()).Contains("particle_jet") 
02931             && TMath::Abs(vec_centraljets[k]->tlv().Eta())<2.5 ){
02932             
02933             if(m_cutvalue_cjv_ptratio_min>-1){
02934                 
02935                 double tracks_ptratio = ((MyParticleJet*)(vec_centraljets[k]))->tracks_ptratio(m_primary_vertex_index);
02936                 if(tracks_ptratio<m_cutvalue_cjv_ptratio_min){
02937                     continue;
02938                 }
02939             }
02940             
02941             if(m_cutvalue_cjv_cmsptratio_min>-1){
02942                 
02943                 double tracks_cmsptratio = ((MyParticleJet*)(vec_centraljets[k]))->tracks_cmsptratio(m_primary_vertex_index);
02944                 if(tracks_cmsptratio<m_cutvalue_cjv_cmsptratio_min){
02945                     continue;
02946                 }
02947             }
02948             
02949 
02950             if(m_flag_cjv_stdjet_corrpt){
02951               
02952                 double cj_corrpt = ((MyParticleJet*)(vec_centraljets[k]))->pt_pucorr(m_primary_vertex_index);
02953                 if(cj_corrpt<m_cutvalue_cjv_stdjet_pt_min*GeV){
02954                     continue;
02955                 } 
02956             }
02957         
02958             if(m_flag_cjv_trkstdjet_match){
02959                 
02960                 MyParticle* tmp_jet = NULL;
02961                 tmp_jet = m_tools.find_matching_particle(vec_centraljets[k],
02962                                                          v_trackjet_forcjvmatch, 
02963                                                          m_cutvalue_jet_match_dR,0,0);
02964                 
02965                 if(tmp_jet == NULL){
02966                     continue;
02967                 }
02968             }
02969         }
02970         
02971         //if (id_jet3!=id_jet1 && id_jet3!=id_jet2){
02972          
02973 
02974         //fill histos
02975 
02976         h_centraljet_cand_pt->Fill(tlv_central_jet.Pt()*invGeV,weight);
02977         h_centraljet_cand_eta->Fill(tlv_central_jet.Eta(),weight);
02978         h_centraljet_cand_phi->Fill(tlv_central_jet.Phi(),weight);
02979          
02980         if ( TString(vec_centraljets[k]->type()).Contains("particle_jet") ){
02981             h_centraljet_std_cand_pt->Fill(tlv_central_jet.Pt()*invGeV,weight);
02982             h_centraljet_std_cand_eta->Fill(tlv_central_jet.Eta(),weight);
02983             h_centraljet_std_cand_phi->Fill(tlv_central_jet.Phi(),weight);
02984             h_centraljet_std_cand_ntrks->Fill(tlv_central_jet.Phi(),weight);
02985         }
02986         else if( vec_centraljets[k]->type() == "track_jet" ){
02987             h_centraljet_trk_cand_pt->Fill(tlv_central_jet.Pt()*invGeV,weight);
02988             h_centraljet_trk_cand_eta->Fill(tlv_central_jet.Eta(),weight);
02989             h_centraljet_trk_cand_phi->Fill(tlv_central_jet.Phi(),weight);
02990         }
02991 
02992         centraljet         = false;
02993         cj_between_fwdjets = false;
02994                 
02995         //tlv_central_jet = (vec_centraljets[k])->tlv();
02996         //dr1 = tlv_central_jet.DeltaR(tlv_fwd_jet1);
02997         //dr2 = tlv_central_jet.DeltaR(tlv_fwd_jet2);
02998                 
02999         h_fwj_cj_dr->Fill(dr1,weight);
03000         h_fwj_cj_dr->Fill(dr2,weight);
03001                     
03002         // is the central jet candidate between the forward jets
03003         if ( (fwd_jet_eta_min < tlv_central_jet.Eta()) &&
03004              (fwd_jet_eta_max > tlv_central_jet.Eta()) ){
03005                   
03006             cj_between_fwdjets = true;
03007         }
03008                     
03009         // is it considered as a central jet?
03010         if( m_switch_cjet_between_fwdjets && cj_between_fwdjets ){
03011             centraljet = true;
03012         }
03013         else if( !m_switch_cjet_between_fwdjets ){
03014             centraljet = true;
03015         }
03016         else {
03017             centraljet = false;
03018         }
03019                 
03020         // if the central jet candidate is a central jet:
03021         if(centraljet){
03022                     
03023             //cout << "found central jet" << endl;
03024                 
03025             centraljet_at_all = true;
03026             centraljetcount++;
03027                     
03028             h_centraljet_ana_pt->Fill(tlv_central_jet.Pt()*invGeV,weight);
03029             h_centraljet_ana_eta->Fill(tlv_central_jet.Eta(),weight);
03030             h_centraljet_ana_phi->Fill(tlv_central_jet.Phi(),weight);
03031             // zeppenfeld variable
03032             h_centraljet_ana_zeppvar->Fill( tlv_central_jet.Eta()
03033                                             - ( tlv_fwd_jet1.Eta()+
03034                                                 tlv_fwd_jet2.Eta())/2,weight);
03035         
03036             if( ((TString)(vec_centraljets[k]->type())).Contains("particle_jet") ){
03037                 h_centraljet_ana_ntrks->Fill(((MyParticleJet*)(vec_centraljets[k]))->nb_tracks(), weight);
03038             }
03039         
03040         }
03041              
03042     }//for jets
03043   
03044     //if no central jet has been found fill 0 entry in ntuple
03045     if ( nb_std_cjet_cands==0 ){
03046         t_cutopt_std_jet->Fill(0.,0,0.,0.,0.,0,0,0.); 
03047     }
03048     if ( nb_trk_cjet_cands==0 ){
03049         t_cutopt_trk_jet->Fill(0.,0,0.,0.,0.); 
03050     }
03051 
03052     h_centraljet_cand_nb->Fill(nb_std_cjet_cands+nb_trk_cjet_cands,weight);
03053     h_centraljet_std_cand_nb->Fill(nb_std_cjet_cands,weight);
03054     h_centraljet_trk_cand_nb->Fill(nb_trk_cjet_cands,weight);
03055     h_centraljet_ana_nb->Fill(centraljetcount,weight);
03056   
03057 
03058     if (centraljet_at_all==true){
03059         return false;
03060     }
03061     
03062     return true;
03063   }
03064 
03065 
03066 //*****************************************************************************
03067 
03068 //::::::::::::::::::::::::::::::::::
03069 //:: METHOD cut_leptons_jets_deta ::
03070 //::::::::::::::::::::::::::::::::::
03071 
03072 bool
03073 MyHtoWWAnalysis::cut_leptons_jets_deta(MyVBFCandidate candidate){
03074   
03075     double lepton1_eta = candidate.get_lepton_pair().get_particle1()->tlv().Eta();
03076     double lepton2_eta = candidate.get_lepton_pair().get_particle2()->tlv().Eta();
03077 
03078     double jet1_eta = candidate.get_tagjet_pair().get_particle1()->tlv().Eta();
03079     double jet2_eta = candidate.get_tagjet_pair().get_particle2()->tlv().Eta();
03080 
03081     double jet_eta_min = TMath::Min(jet1_eta,jet2_eta);
03082     double jet_eta_max = TMath::Max(jet1_eta,jet2_eta);
03083     
03084     h_jl_mineta->Fill(TMath::Min(lepton1_eta, lepton2_eta)
03085                       - TMath::Min(jet1_eta,jet2_eta),weight);
03086     
03087     h_jl_maxeta->Fill(TMath::Max(jet1_eta,jet2_eta)
03088                       - TMath::Max(lepton1_eta, lepton2_eta),weight);
03089     
03090 
03091     if ( (lepton1_eta < jet_eta_min) ||
03092          (lepton2_eta < jet_eta_min) ||
03093          (lepton1_eta > jet_eta_max) ||
03094          (lepton2_eta > jet_eta_max)
03095          ){
03096         
03097         return false;
03098     }
03099     
03100     return true;
03101     
03102   }
03103 
03104 
03105 //*****************************************************************************
03106 
03107 //::::::::::::::::::::::::::::::::
03108 //:: METHOD cut_transverse_mass ::
03109 //::::::::::::::::::::::::::::::::
03110 
03111 bool
03112 MyHtoWWAnalysis::cut_transverse_mass(MyVBFCandidate candidate){
03113 
03114     MyParticlePair tagjet_pair = candidate.get_tagjet_pair();
03115     MyParticlePair lepton_pair = candidate.get_lepton_pair();
03116 
03117     TLorentzVector met_tlv;
03118     TLorentzVector ll_tlv;
03119     
03120     MyMissingEt missinget = candidate.get_missinget();
03121 
03122     met_tlv = missinget.tlv();
03123     
03124     double pt_miss   = missinget.met();
03125 
03126 
03127     double Et_ll   = lepton_pair.tlv().Et();
03128     double Et_nunu = TMath::Sqrt( pow(pt_miss,2) + lepton_pair.tlv().M2() );
03129     
03130     TVector3 pt_sum_tlv = lepton_pair.tlv().Vect() + met_tlv.Vect();
03131     
03132     double mt = TMath::Sqrt( pow(Et_ll+Et_nunu,2) - pt_sum_tlv.Mag2() ); 
03133     
03134     // mt llnu
03135 
03136     ll_tlv = lepton_pair.tlv();
03137     
03138     double pt_lepton = ll_tlv.Pt();
03139     
03140     double dphi    = met_tlv.DeltaPhi( ll_tlv );
03141     
03142     double mtllnu = TMath::Sqrt(2*pt_lepton*pt_miss
03143                                 * (1-(TMath::Cos(dphi))) );
03144 
03145 
03146     if(m_cutvalue_mtllnu_min>-1){
03147         if( mtllnu < m_cutvalue_mtllnu_min ){
03148             
03149             return false;
03150         }
03151     }
03152     
03153     if(m_cutvalue_mt_min>-1){
03154         
03155         if( mt < m_cutvalue_mt_min ){
03156             return false;
03157         }
03158     }
03159     
03160     if(m_cutvalue_mt_max>-1){
03161         
03162         if( mt > m_cutvalue_mt_max ){
03163             return false;
03164         }
03165     }
03166     
03167     
03168     return true;
03169   }
03170 
03171 
03172 //*****************************************************************************
03173 
03174 //:::::::::::::::::::::::::::
03175 //:: METHOD cut_pt_balance ::
03176 //:::::::::::::::::::::::::::
03177 
03178 bool
03179 MyHtoWWAnalysis::cut_pt_balance(MyVBFCandidate candidate){
03180     
03181     MyMissingEt missinget = candidate.get_missinget();
03182 
03183     TLorentzVector jet1 = candidate.get_tagjet_pair().get_particle1()->tlv();
03184     TLorentzVector jet2 = candidate.get_tagjet_pair().get_particle2()->tlv();
03185         
03186     TLorentzVector lepton1 = candidate.get_lepton_pair().get_particle1()->tlv();
03187     TLorentzVector lepton2 = candidate.get_lepton_pair().get_particle2()->tlv();
03188     
03189     double pt_x = missinget.met_x() 
03190         + jet1.Px() + jet2.Px() + lepton1.Px() + lepton2.Px();
03191     
03192     double pt_y = missinget.met_y() 
03193         + jet1.Py() + jet2.Py() + lepton1.Py() + lepton2.Py();
03194 
03195     double pt_tot = TMath::Sqrt( pt_x*pt_x + pt_y*pt_y );
03196     
03197     
03198     if( pt_tot > m_cutvalue_pt_balance_max){
03199         
03200         return false;
03201     }
03202    
03203     
03204     return true;
03205   }
03206 
03207 //*****************************************************************************
03208 
03209 //:::::::::::::::::::::::::
03210 //:: METHOD cut_tau_veto ::
03211 //:::::::::::::::::::::::::
03212 
03213 bool
03214 MyHtoWWAnalysis::cut_tau_veto(MyVBFCandidate candidate){
03215 
03216     MyCollinearApproximation 
03217         collapp( candidate.get_lepton_pair().get_particle1(),
03218                  candidate.get_lepton_pair().get_particle2(),
03219                  candidate.get_missinget().tlv() );
03220  
03221 
03222     double m_tautau = collapp.get_M_comp_part();
03223     double m_Z = 91.1876*GeV;
03224 
03225     double dm = TMath::Abs(m_tautau - m_Z);
03226 
03227     if( collapp.get_x1() > m_cutvalue_x1_max &&
03228         collapp.get_x2() > m_cutvalue_x2_max &&
03229         dm               < m_cutvalue_tautau_Z_dm_min ){
03230         
03231         return false;
03232     }
03233     
03234     return true;
03235 
03236   }
03237 
03238 //*****************************************************************************
03239 
03240 //::::::::::::::::::::::::::::::::
03241 //:: METHOD preselect_electrons ::
03242 //::::::::::::::::::::::::::::::::
03243 
03244 vector<MyParticle*> 
03245 MyHtoWWAnalysis::preselect_electrons(vector<MyParticle*> vec_particle, double pt_min) {
03246         
03247     //if(vec_particle.size()==0){
03248     //  return vec_particle;
03249     //}
03250     
03251     vector<MyParticle*> vec_tmp1;
03252     vector<MyParticle*> vec_tmp2(0);
03253         
03254     // pt, eta cut
03255     //vec_tmp1 = m_tools.pt_eta_cut(vec_particle, 15.0*GeV, -1.0, 0.0, 2.5);
03256     vec_tmp1 = m_tools.pt_eta_cut(vec_particle, pt_min, -1.0, 0.0, 2.5);
03257     
03258     // isolation
03259     for (unsigned int k=0; k<vec_tmp1.size(); k++){
03260 
03261         if(vec_tmp1[k]->type()!="electron"){
03262             cerr << "ERROR: wrong input particle in method "
03263                  << "preselect_electrons()" << endl;
03264             exit(1);
03265         }
03266 
03267         
03268         //if(!m_AtlFastFlag){
03269         //if (((int)(((MyElectron*)(vec_tmp1[k]))->is_em())%16)!=0){
03270         //if (((MyElectron*)(vec_tmp1[k]))->is_em() != 0){
03271             //if (((int)(((MyElectron*)(vec_tmp1[k]))->is_em())==0){
03272         
03273         if(m_release>12){
03274             if (((MyElectron*)(vec_tmp1[k]))->id_flag()>1){
03275                 continue;
03276             }
03277         }
03278         else{
03279             if ((((MyElectron*)(vec_tmp1[k]))->is_em() & 0x3FF) != 0){
03280                 continue;
03281             }
03282         }
03283         
03284         //if ((((MyElectron*)(vec_tmp1[k]))->is_em() & 0x3FF) != 0){
03285         //  continue;
03286         //}
03287         
03288         //if ( ((MyElectron*)(vec_tmp1[k]))->Et_in_cone(0) > 6.0*GeV ){
03289         //  continue;
03290         //}
03291         if ( ((MyElectron*)(vec_tmp1[k]))->track_Et_in_cone(0) > 5.0*GeV ){
03292             continue;
03293         }
03294         
03295         vec_tmp2.push_back( vec_tmp1[k] );
03296     }
03297 
03298     
03299     // draw histograms
03300     h_e_reco_presel_nb->Fill(vec_tmp2.size(),weight);
03301     
03302     for (unsigned int k=0; k<vec_tmp2.size(); k++) {
03303        
03304         h_e_reco_presel_pt->Fill(vec_tmp2[k]->tlv().Pt()*invGeV,weight);
03305         h_e_reco_presel_eta->Fill(vec_tmp2[k]->tlv().Eta(),weight);
03306         h_e_reco_presel_phi->Fill(vec_tmp2[k]->tlv().Phi(),weight);
03307         h_e_reco_presel_isem->Fill(((MyElectron*)vec_tmp2[k])->is_em(),weight);
03308     }
03309     
03310     return vec_tmp2;
03311 }
03312 
03313 //*****************************************************************************
03314 
03315 //::::::::::::::::::::::::::::::::
03316 //:: METHOD preselect_electrons ::
03317 //::::::::::::::::::::::::::::::::
03318 
03319 vector<MyParticle*> 
03320 MyHtoWWAnalysis::preselect_electrons_for_orm(vector<MyParticle*> vec_particle, double pt_min) {
03321         
03322     vector<MyParticle*> vec_tmp1;
03323     vector<MyParticle*> vec_tmp2(0);
03324         
03325     // pt, eta cut
03326     //vec_tmp1 = m_tools.pt_eta_cut(vec_particle, 15.0*GeV, -1.0, 0.0, 2.5);
03327     vec_tmp1 = m_tools.pt_eta_cut(vec_particle, pt_min, -1.0, 0.0, 2.5);
03328 
03329     // isolation
03330     for (unsigned int k=0; k<vec_tmp1.size(); k++){
03331 
03332         if(vec_tmp1[k]->type()!="electron"){
03333             cerr << "ERROR: wrong input particle in method "
03334                  << "preselect_electrons()" << endl;
03335             exit(1);
03336         }
03337 
03338         if(m_release>12){
03339             if (((MyElectron*)(vec_tmp1[k]))->id_flag() > 0 ){
03340                 continue;
03341             }
03342         }
03343         else{
03344             if ((((MyElectron*)(vec_tmp1[k]))->is_em() & 0x7) != 0){
03345                 continue;
03346             }
03347         }
03348         
03349          //if ((((MyElectron*)(vec_tmp1[k]))->is_em() & 0x7) != 0){
03350          //continue;
03351          //}
03352         if ( ((MyElectron*)(vec_tmp1[k]))->track_Et_in_cone(0) > 5.0*GeV ){
03353             continue;
03354         }
03355         
03356         vec_tmp2.push_back( vec_tmp1[k] );
03357     }
03358   
03359     return vec_tmp2;
03360 }
03361 
03362 //*****************************************************************************
03363 
03364 //::::::::::::::::::::::::::::::::::::::
03365 //:: METHOD preselect_truth_electrons ::
03366 //::::::::::::::::::::::::::::::::::::::
03367 
03368 vector<MyParticle*> 
03369 MyHtoWWAnalysis::preselect_truth_electrons(vector<MyParticle*> vec_particle, double pt_min) {
03370         
03371     //if(vec_particle.size()==0){
03372     //  return vec_particle;
03373     //}
03374 
03375     vector<MyParticle*> vec_tmp;
03376         
03377     // status cut?
03378     
03379     // pt, eta cut
03380     //vec_tmp = m_tools.pt_eta_cut(vec_particle, 15.0*GeV, -1, 0.0, 2.5);
03381     vec_tmp = m_tools.pt_eta_cut(vec_particle, pt_min, -1, 0.0, 2.5);
03382     
03383     // isolation?
03384     
03385     // Fill histos
03386     h_e_truth_presel_nb->Fill(vec_tmp.size(),weight);
03387     
03388     for (unsigned int k=0; k<vec_tmp.size(); k++) {
03389     
03390         if(vec_tmp[k]->type()!="truth_particle"){
03391             cerr << "ERROR: wrong input particle in method "
03392                  << "preselect_truth_electrons()" << endl;
03393             exit(1);
03394         }
03395 
03396         //cout << "et: " << ((MyTruthParticle*)(vec_tmp[k]))->Et_in_cone(3) << endl;
03397 
03398         h_e_truth_presel_pt->Fill( vec_tmp[k]->tlv().Pt()*invGeV,weight);
03399         h_e_truth_presel_eta->Fill(vec_tmp[k]->tlv().Eta(),weight);
03400         h_e_truth_presel_phi->Fill(vec_tmp[k]->tlv().Phi(),weight);
03401         h_e_truth_presel_status
03402             ->Fill( ((MyTruthParticle*)(vec_tmp[k]))->status(),weight);
03403     }
03404     
03405     return vec_tmp;
03406 }
03407 
03408 //*****************************************************************************
03409 
03410 //::::::::::::::::::::::::::::
03411 //:: METHOD preselect_muons ::
03412 //::::::::::::::::::::::::::::
03413 
03414 vector<MyParticle*> 
03415 MyHtoWWAnalysis::preselect_muons(vector<MyParticle*> vec_particle, double pt_min) {
03416 
03417 
03418     //if(vec_particle.size()==0){
03419     //   return vec_particle;
03420     //}
03421 
03422     vector<MyParticle*> vec_tmp1;
03423     vector<MyParticle*> vec_tmp2(0);
03424         
03425     // pt, eta cut
03426     //vec_tmp1 = m_tools.pt_eta_cut(vec_particle, 15.0*GeV, -1, 0.0, 2.5);
03427     vec_tmp1 = m_tools.pt_eta_cut(vec_particle, pt_min, -1, 0.0, 2.5);
03428 
03429     // isolation
03430     for (unsigned int k=0; k<vec_tmp1.size(); k++){
03431 
03432         MyMuon* muon = (MyMuon*)(vec_tmp1[k]);
03433 
03434         if(vec_tmp1[k]->type()!="muon"){
03435             cerr << "ERROR: wrong input particle in method "
03436                  << "preselect_muons()" << endl;
03437             exit(1);
03438         }
03439         
03440         //if ( ((MyMuon*)(vec_tmp1[k]))->Et_in_cone(3) > 9.0*GeV ){
03441         //   continue;
03442         //}
03443         if ( ((MyMuon*)(vec_tmp1[k]))->track_Et_in_cone(1) > 5.0*GeV ){
03444             continue;
03445         }
03446 
03447 
03448       
03449 
03450         if(!m_AtlFastFlag){
03451 
03452             //if(muon->reconstruction_flag() != 1){
03453             //  continue;
03454             //}
03455             //if(muon->hasCombinedMuonTrackParticle()!=true){
03456             //  continue;
03457             //}
03458           //   if(muon->matchChi2()<0  ||
03459 //                muon->matchChi2()>20 ){
03460 //                 continue;
03461 //             }
03462 //             if(muon->fitChi2OverDoF()<0 ||
03463 //                muon->fitChi2OverDoF()>5 ){
03464 //                 continue;
03465 //             }
03466         }
03467     
03468         //muon->Print();
03469         //muon->Printtest();
03470         vec_tmp2.push_back( vec_tmp1[k] );
03471     }
03472 
03473     
03474     // draw histograms
03475     h_mu_reco_presel_nb->Fill(vec_tmp2.size(),weight);
03476 
03477     for (unsigned int k=0; k<vec_tmp2.size(); k++) {
03478       
03479         h_mu_reco_presel_pt->Fill(vec_tmp2[k]->tlv().Pt()*invGeV,weight);
03480         h_mu_reco_presel_eta->Fill(vec_tmp2[k]->tlv().Eta(),weight);
03481         h_mu_reco_presel_phi->Fill(vec_tmp2[k]->tlv().Phi(),weight);
03482         
03483         h_mu_reco_presel_fitChi2OverDoF
03484             ->Fill(((MyMuon*)(vec_tmp2[k]))->fitChi2OverDoF(),weight);
03485         
03486         h_mu_reco_presel_fitChi2OverDoFvsphi
03487             ->Fill( vec_tmp2[k]->tlv().Phi(), 
03488                     ((MyMuon*)(vec_tmp2[k]))->fitChi2OverDoF(),weight);
03489 
03490     }
03491         
03492     return vec_tmp2;
03493 }
03494 
03495 //*****************************************************************************
03496 
03497 //::::::::::::::::::::::::::::::::::
03498 //:: METHOD preselect_truth_muons ::
03499 //::::::::::::::::::::::::::::::::::
03500 
03501 vector<MyParticle*> 
03502 MyHtoWWAnalysis::preselect_truth_muons(vector<MyParticle*> vec_particle, double pt_min) {
03503     
03504     //if(vec_particle.size()==0){
03505     //  return vec_particle;
03506     //}
03507 
03508     vector<MyParticle*> vec_tmp;  
03509     
03510     // status cut?
03511         
03512     // pt, eta cut
03513     //vec_tmp = m_tools.pt_eta_cut(vec_particle, 15.0*GeV, -1, 0.0, 2.5);
03514     vec_tmp = m_tools.pt_eta_cut(vec_particle, pt_min, -1, 0.0, 2.5);
03515 
03516     // isolation?
03517         
03518     // Fill histos
03519     h_mu_truth_presel_nb->Fill(vec_tmp.size(),weight);
03520     
03521     for (unsigned int k=0; k<vec_tmp.size(); k++) {
03522         
03523         if(vec_tmp[k]->type()!="truth_particle"){
03524             cerr << "ERROR: wrong input particle in method "
03525                  << "preselect_truth_muons()" << endl;
03526             exit(1);
03527         }
03528 
03529         h_mu_truth_presel_pt->Fill( vec_tmp[k]->tlv().Pt()*invGeV,weight);
03530         h_mu_truth_presel_eta->Fill(vec_tmp[k]->tlv().Eta(),weight);
03531         h_mu_truth_presel_phi->Fill(vec_tmp[k]->tlv().Phi(),weight);
03532         h_mu_truth_presel_status
03533             ->Fill( ((MyTruthParticle*)(vec_tmp[k]))->status(),weight);
03534     }
03535         
03536     return vec_tmp;
03537 }
03538 
03539 //*****************************************************************************
03540 
03541 //::::::::::::::::::::::::::::
03542 //:: METHOD match_electrons ::
03543 //::::::::::::::::::::::::::::
03544 
03545 void 
03546 MyHtoWWAnalysis::match_electrons( vector<MyParticle*> vec_e_reco, 
03547                                   vector<MyParticle*> vec_e_truth) {
03548         
03549     int nb_matched(0);
03550     int nb_notmatched(0);
03551     int nb_fakes(0);
03552         
03553     // loop over truth electrons and search for a matching reconstructed electron
03554     for (unsigned int k=0; k<vec_e_truth.size(); k++) {
03555        
03556         MyParticle* tmp_electron = NULL; 
03557 
03558         tmp_electron = m_tools.find_matching_particle( vec_e_truth[k],
03559                                                        vec_e_reco, 0.1 );
03560         
03561         if(tmp_electron!=NULL){
03562          
03563             nb_matched++;
03564             h_e_eff->Fill(1.,weight);
03565 
03566             h_e_reco_matched_pt->Fill(tmp_electron->tlv().Pt()*invGeV, weight);
03567             h_e_reco_matched_eta->Fill(tmp_electron->tlv().Eta(), weight);
03568             h_e_reco_matched_phi->Fill(tmp_electron->tlv().Phi(), weight);
03569             
03570             h_e_truth_matched_pt->Fill(vec_e_truth[k]->tlv().Pt()*invGeV, weight);
03571             h_e_truth_matched_eta->Fill(vec_e_truth[k]->tlv().Eta(), weight);
03572             h_e_truth_matched_phi->Fill(vec_e_truth[k]->tlv().Phi(), weight);
03573             
03574             h_e_reco_matched_isem->Fill(((MyElectron*)tmp_electron)->is_em(), weight);
03575             h_e_reco_matched_NN->Fill(((MyElectron*)tmp_electron)->NeuralNet(), weight);
03576                         
03577             h_e_matched_dpt->Fill((tmp_electron->tlv().Pt()-vec_e_truth[k]->tlv().Pt())*invGeV, weight);
03578             h_e_matched_deta->Fill(tmp_electron->tlv().Eta()-vec_e_truth[k]->tlv().Eta(), weight );
03579             h_e_matched_dphi->Fill(tmp_electron->tlv().DeltaPhi(vec_e_truth[k]->tlv()),weight);
03580             h_e_matched_dr->Fill(tmp_electron->tlv().DeltaR(vec_e_truth[k]->tlv()),weight);
03581             
03582             h_e_matched_resolution_pt->Fill(vec_e_truth[k]->tlv().Pt()*invGeV,
03583                                             (tmp_electron->tlv().Pt()-vec_e_truth[k]->tlv().Pt())/
03584                                             (vec_e_truth[k]->tlv().Pt()),weight);
03585             
03586             h_e_matched_resolution_eta->Fill(vec_e_truth[k]->tlv().Eta(),
03587                                              (tmp_electron->tlv().Eta()-vec_e_truth[k]->tlv().Eta())/
03588                                              (vec_e_truth[k]->tlv().Eta()),weight);
03589             
03590             h_e_matched_resolution_phi->Fill(vec_e_truth[k]->tlv().Phi(),
03591                                              (tmp_electron->tlv().DeltaPhi(vec_e_truth[k]->tlv()))/
03592                                              (vec_e_truth[k]->tlv().Phi()),weight);
03593         
03594         }
03595         else{ // not matched electron
03596            
03597             h_e_eff->Fill(0.,weight);
03598             nb_notmatched++;
03599             h_e_truth_notmatched_pt->Fill(vec_e_truth[k]->tlv().Pt()*invGeV, weight);
03600             h_e_truth_notmatched_eta->Fill(vec_e_truth[k]->tlv().Eta(), weight);
03601             h_e_truth_notmatched_phi->Fill(vec_e_truth[k]->tlv().Phi(), weight);
03602         }
03603     }
03604 
03605     h_e_reco_matched_nb->Fill(nb_matched,weight);
03606     h_e_truth_notmatched_nb->Fill(nb_notmatched,weight);
03607         
03608     // determine fake electrons
03609     for (unsigned int k=0; k<vec_e_reco.size(); k++) {
03610        
03611         MyParticle* tmp_electron = NULL;
03612         
03613         tmp_electron = m_tools.find_matching_particle( vec_e_reco[k],
03614                                                        vec_e_truth, 0.1);
03615         
03616         if (tmp_electron==NULL) { //electron is faked
03617         
03618 
03619             nb_fakes++;
03620             h_e_fake->Fill(1.,weight);
03621             
03622             h_e_reco_fake_pt->Fill(vec_e_reco[k]->tlv().Pt()*invGeV, weight);
03623             h_e_reco_fake_eta->Fill(vec_e_reco[k]->tlv().Eta(), weight);
03624             h_e_reco_fake_phi->Fill(vec_e_reco[k]->tlv().Phi(), weight);
03625             h_e_reco_fake_isem->Fill(((MyElectron*)vec_e_reco[k])->is_em(), weight);
03626         }
03627         else{
03628             h_e_fake->Fill(0.,weight);
03629         }
03630     }
03631    
03632     h_e_reco_fake_nb->Fill(nb_fakes,weight);
03633     
03634     return;
03635 }
03636 
03637 //*****************************************************************************
03638 
03639 //::::::::::::::::::::::::
03640 //:: METHOD match_muons ::
03641 //::::::::::::::::::::::::
03642 
03643 void 
03644 MyHtoWWAnalysis::match_muons( vector<MyParticle*> vec_mu_reco, 
03645                               vector<MyParticle*> vec_mu_truth) {
03646         
03647     //v_mu_reco_matched.clear();
03648     //v_mu_truth_matched.clear();
03649     
03650     int nb_matched(0);
03651     int nb_notmatched(0);
03652     int nb_fakes(0);
03653         
03654     // loop over truth muons and search for a matching reconstructed muon
03655     for (unsigned int k=0; k<vec_mu_truth.size(); k++) {
03656         
03657         MyParticle* tmp_muon = NULL; 
03658 
03659         tmp_muon = m_tools.find_matching_particle( vec_mu_truth[k],
03660                                                    vec_mu_reco, 0.1);
03661         
03662         if(tmp_muon!=NULL){
03663      
03664             nb_matched++;
03665             h_mu_eff->Fill(1.,weight);
03666             //v_mu_reco_matched.push_back(tmp_muon);
03667             //v_mu_truth_matched.push_back(vec_mu_truth[k]);
03668             
03669             h_mu_reco_matched_pt->Fill(tmp_muon->tlv().Pt()*invGeV, weight);
03670             h_mu_reco_matched_eta->Fill(tmp_muon->tlv().Eta(), weight);
03671             h_mu_reco_matched_phi->Fill(tmp_muon->tlv().Phi(), weight);
03672            
03673             h_mu_truth_matched_pt->Fill(vec_mu_truth[k]->tlv().Pt()*invGeV, weight);
03674             h_mu_truth_matched_eta->Fill(vec_mu_truth[k]->tlv().Eta(), weight);
03675             h_mu_truth_matched_phi->Fill(vec_mu_truth[k]->tlv().Phi(), weight);
03676                         
03677             h_mu_reco_matched_fitChi2OverDoF
03678                 ->Fill(((MyMuon*)(tmp_muon))->fitChi2OverDoF(),weight);
03679 
03680                         
03681             h_mu_matched_dpt->Fill((tmp_muon->tlv().Pt()-
03682                                     vec_mu_truth[k]->tlv().Pt())*invGeV, weight);
03683             h_mu_matched_deta->Fill(tmp_muon->tlv().Eta()-
03684                                     vec_mu_truth[k]->tlv().Eta(), weight);
03685             h_mu_matched_dphi->Fill(tmp_muon->tlv().DeltaPhi(vec_mu_truth[k]->tlv()),weight);
03686             
03687             h_mu_matched_dr->Fill(tmp_muon->tlv().DeltaR(vec_mu_truth[k]->tlv()),weight);
03688             
03689             h_mu_matched_resolution_pt
03690                 ->Fill(vec_mu_truth[k]->tlv().Pt()*invGeV,
03691                        (tmp_muon->tlv().Pt()-vec_mu_truth[k]->tlv().Pt())/
03692                        (vec_mu_truth[k]->tlv().Pt()),weight);
03693            
03694             h_mu_matched_resolution_ptvsphi
03695                 ->Fill(vec_mu_truth[k]->tlv().Phi(),
03696                        (tmp_muon->tlv().Pt()-vec_mu_truth[k]->tlv().Pt())/
03697                        (vec_mu_truth[k]->tlv().Pt()),weight);
03698             
03699             h_mu_matched_resolution_ptvseta
03700                 ->Fill(vec_mu_truth[k]->tlv().Eta(),
03701                        (tmp_muon->tlv().Pt()-vec_mu_truth[k]->tlv().Pt())/
03702                        (vec_mu_truth[k]->tlv().Pt()),weight);
03703             
03704             h_mu_matched_resolution_eta
03705                 ->Fill(vec_mu_truth[k]->tlv().Eta(),
03706                       (tmp_muon->tlv().Eta()-vec_mu_truth[k]->tlv().Eta())/
03707                       (vec_mu_truth[k]->tlv().Eta()),weight);
03708             
03709             h_mu_matched_resolution_phi
03710                 ->Fill(vec_mu_truth[k]->tlv().Phi(),
03711                        (tmp_muon->tlv().DeltaPhi(vec_mu_truth[k]->tlv()))/
03712                        (vec_mu_truth[k]->tlv().Phi()),weight);
03713         }
03714         else{ // not matched muon
03715             
03716             h_mu_eff->Fill(0.,weight);
03717             nb_notmatched++;
03718             h_mu_truth_notmatched_pt->Fill(vec_mu_truth[k]->tlv().Pt()*invGeV, weight);
03719             h_mu_truth_notmatched_eta->Fill(vec_mu_truth[k]->tlv().Eta(), weight);
03720             h_mu_truth_notmatched_phi->Fill(vec_mu_truth[k]->tlv().Phi(), weight);
03721         }
03722     }
03723     
03724     h_mu_reco_matched_nb->Fill(nb_matched,weight);
03725     h_mu_truth_notmatched_nb->Fill(nb_notmatched,weight);
03726     
03727     // determine fake muons
03728     for (unsigned int k=0; k<vec_mu_reco.size(); k++) {
03729     
03730         MyParticle* tmp_muon = NULL;
03731         
03732         tmp_muon = m_tools.find_matching_particle(vec_mu_reco[k],
03733                                                   vec_mu_truth, 0.1);
03734         if (tmp_muon==NULL) { //muon is faked
03735         
03736             nb_fakes++;
03737             h_mu_fake->Fill(1.,weight);
03738             h_mu_reco_fake_pt->Fill(vec_mu_reco[k]->tlv().Pt()*invGeV, weight);
03739             h_mu_reco_fake_eta->Fill(vec_mu_reco[k]->tlv().Eta(), weight);
03740             h_mu_reco_fake_phi->Fill(vec_mu_reco[k]->tlv().Phi(), weight);
03741             h_mu_reco_fake_fitChi2OverDoF
03742                 ->Fill(((MyMuon*)(vec_mu_reco[k]))->fitChi2OverDoF(),weight);
03743        
03744         }
03745         else{
03746             h_mu_fake->Fill(0.,weight);  
03747         }
03748     }
03749     
03750     h_mu_reco_fake_nb->Fill(nb_fakes,weight);
03751     
03752     return;
03753 }
03754 
03755 
03756 //*****************************************************************************
03757 
03758 //:::::::::::::::::::::::
03759 //:: METHOD match_jets ::
03760 //:::::::::::::::::::::::
03761 
03762 void 
03763 MyHtoWWAnalysis::match_jets( vector<MyParticle*> vec_jet_reco, 
03764                              vector<MyParticle*> vec_jet_truth) {
03765         
03766     int nb_matched(0);
03767     int nb_notmatched(0);
03768     int nb_fakes(0);
03769     
03770     // set deltaR for jet matching depending on jet algorithm // 
03771     
03772     // if( (TString(m_tfile->GetName())).Contains("Cone") ){
03773            
03774 //      if( (TString(m_tfile->GetName())).Contains("Cone4") ) deltaR_jetmatching_cut = 0.25;
03775 //      else                                         deltaR_jetmatching_cut = 0.5;
03776 //     }
03777 //     else if( (TString(m_tfile->GetName())).Contains("Kt") ){
03778            
03779 //      if( (TString(m_tfile->GetName())).Contains("Kt1") ) deltaR_jetmatching_cut = 0.1;
03780 //      if( (TString(m_tfile->GetName())).Contains("Kt3") ) deltaR_jetmatching_cut = 0.2;
03781 //      if( (TString(m_tfile->GetName())).Contains("Kt5") ) deltaR_jetmatching_cut = 0.3;
03782 //      if( (TString(m_tfile->GetName())).Contains("Kt7") ) deltaR_jetmatching_cut = 0.5;
03783 //      else                                       deltaR_jetmatching_cut = 0.7;
03784 //     }else{
03785 //      deltaR_jetmatching_cut = 0.1;
03786 //     }
03787 
03788     double deltaR_jetmatching_cut = m_cutvalue_jet_match_dR;
03789 
03790     // loop over truth jets and search for a matching reconstructed jet
03791     for (unsigned int k=0; k<vec_jet_truth.size(); k++) {
03792     
03793         MyParticle* tmp_jet = NULL; 
03794         
03795         tmp_jet = m_tools.find_matching_particle( vec_jet_truth[k],
03796                                                   vec_jet_reco, deltaR_jetmatching_cut );
03797         if(tmp_jet!=NULL){
03798         
03799             nb_matched++;
03800             h_jet_eff->Fill(1.,weight);
03801 
03802             h_jet_reco_matched_pt->Fill(tmp_jet->tlv().Pt()*invGeV, weight);
03803             h_jet_reco_matched_eta->Fill(tmp_jet->tlv().Eta(), weight);
03804             h_jet_reco_matched_phi->Fill(tmp_jet->tlv().Phi(), weight);
03805             h_jet_reco_matched_E->Fill(tmp_jet->tlv().E()*invGeV, weight);
03806 
03807             h_jet_truth_matched_pt->Fill(vec_jet_truth[k]->tlv().Pt()*invGeV, weight);
03808             h_jet_truth_matched_eta->Fill(vec_jet_truth[k]->tlv().Eta(), weight);
03809             h_jet_truth_matched_phi->Fill(vec_jet_truth[k]->tlv().Phi(), weight);
03810             h_jet_truth_matched_E->Fill(vec_jet_truth[k]->tlv().E()*invGeV, weight);
03811 
03812             h_jet_matched_dpt->Fill((tmp_jet->tlv().Pt()-
03813                                      vec_jet_truth[k]->tlv().Pt())*invGeV,weight);
03814             h_jet_matched_deta->Fill(tmp_jet->tlv().Eta()-
03815                                      vec_jet_truth[k]->tlv().Eta(),weight );
03816             h_jet_matched_dphi->Fill(tmp_jet->tlv().DeltaPhi(vec_jet_truth[k]->tlv()),weight);
03817             h_jet_matched_dr->Fill(tmp_jet->tlv().DeltaR(vec_jet_truth[k]->tlv()),weight);
03818             h_jet_matched_dE->Fill((tmp_jet->tlv().E()-
03819                                      vec_jet_truth[k]->tlv().E())*invGeV,weight);
03820 
03821 
03822             h_jet_matched_ptratio_recoovertruth
03823                 ->Fill(tmp_jet->tlv().Pt()/(vec_jet_truth[k]->tlv().Pt()),weight);
03824             h_jet_matched_ptratio_truthoverreco
03825                 ->Fill((vec_jet_truth[k]->tlv().Pt())/tmp_jet->tlv().Pt(),weight);
03826 
03827             h_jet_matched_ptratio_recoovertruth_corr
03828                 ->Fill(((MyParticleJet*)(tmp_jet))->pt_pucorr(m_primary_vertex_index)/
03829                        (vec_jet_truth[k]->tlv().Pt()),weight);
03830             h_jet_matched_ptratio_truthoverreco_corr
03831                 ->Fill((vec_jet_truth[k]->tlv().Pt())/
03832                        ((MyParticleJet*)(tmp_jet))->pt_pucorr(m_primary_vertex_index),weight);
03833 
03834             double bweight = ((MyParticleJet*)(tmp_jet))->b_tag_weight();
03835             if(bweight < m_cutvalue_bjet_weight_max){
03836                 h_jet_matched_bweightcut_ptratio_recoovertruth
03837                     ->Fill(tmp_jet->tlv().Pt()/(vec_jet_truth[k]->tlv().Pt()),weight);
03838                 h_jet_matched_bweightcut_ptratio_truthoverreco
03839                     ->Fill((vec_jet_truth[k]->tlv().Pt())/tmp_jet->tlv().Pt(),weight);
03840                 
03841                 h_jet_matched_bweightcut_ptratio_recoovertruth_corr
03842                     ->Fill(((MyParticleJet*)(tmp_jet))->pt_pucorr(m_primary_vertex_index)/
03843                            (vec_jet_truth[k]->tlv().Pt()),weight);
03844                 h_jet_matched_bweightcut_ptratio_truthoverreco_corr
03845                     ->Fill((vec_jet_truth[k]->tlv().Pt())/
03846                            ((MyParticleJet*)(tmp_jet))->pt_pucorr(m_primary_vertex_index),weight);
03847             }
03848 
03849 
03850             h_jet_matched_resolution_pt
03851                 ->Fill(vec_jet_truth[k]->tlv().Pt()*invGeV,
03852                        (tmp_jet->tlv().Pt()-vec_jet_truth[k]->tlv().Pt())/
03853                        (vec_jet_truth[k]->tlv().Pt()),weight);
03854 
03855             h_jet_matched_resolution_eta
03856                 ->Fill(vec_jet_truth[k]->tlv().Eta(),
03857                        (tmp_jet->tlv().Eta()-vec_jet_truth[k]->tlv().Eta())/
03858                        (vec_jet_truth[k]->tlv().Eta()),weight);
03859             
03860             h_jet_matched_resolution_phi
03861                 ->Fill(vec_jet_truth[k]->tlv().Phi(),
03862                        (tmp_jet->tlv().DeltaPhi(vec_jet_truth[k]->tlv()))/
03863                        (vec_jet_truth[k]->tlv().Phi()),weight);
03864         
03865             h_jet_matched_Eresolution
03866                 ->Fill( (vec_jet_truth[k]->tlv().E()-tmp_jet->tlv().E())*invGeV,weight );
03867           
03868             h_jet_matched_Eresolution_vs_pt
03869                 ->Fill( vec_jet_truth[k]->tlv().Pt()*invGeV,
03870                         (tmp_jet->tlv().E()-vec_jet_truth[k]->tlv().E())*invGeV,weight );
03871             
03872             h_jet_matched_Eresolution_vs_eta
03873                 ->Fill( vec_jet_truth[k]->tlv().Eta(),
03874                         (tmp_jet->tlv().E()-vec_jet_truth[k]->tlv().E())*invGeV,weight );
03875             
03876             h_jet_matched_Eresolution_vs_phi
03877                 ->Fill( vec_jet_truth[k]->tlv().Phi(),
03878                         (tmp_jet->tlv().E()-vec_jet_truth[k]->tlv().E())*invGeV,weight );
03879             
03880             h_jet_matched_Eresolution_vs_E
03881                 ->Fill( vec_jet_truth[k]->tlv().E()*invGeV,
03882                         (tmp_jet->tlv().E()-vec_jet_truth[k]->tlv().E())*invGeV,weight);
03883             
03884             h_jet_matched_invptresolution->Fill((1/tmp_jet->tlv().Pt()-
03885                                                 1/vec_jet_truth[k]->tlv().Pt())*1/invGeV,weight);
03886             h_jet_matched_relinvptresolution->Fill((1/tmp_jet->tlv().Pt()-
03887                                                     1/vec_jet_truth[k]->tlv().Pt())
03888                                                    *vec_jet_truth[k]->tlv().Pt(),weight);
03889             h_jet_matched_invEresolution->Fill((1./tmp_jet->tlv().E()-
03890                                                 1./vec_jet_truth[k]->tlv().E())*1./invGeV,weight);
03891             h_jet_matched_relinvEresolution->Fill((1./tmp_jet->tlv().E()-
03892                                                    1./vec_jet_truth[k]->tlv().E())
03893                                                    *vec_jet_truth[k]->tlv().E(),weight);
03894 
03895             h_jet_matched_invptresolution_vs_pt->Fill(tmp_jet->tlv().Pt(),
03896                                                       (1/tmp_jet->tlv().Pt()-1/vec_jet_truth[k]->tlv().Pt())
03897                                                       *1/invGeV,weight);
03898             h_jet_matched_relinvptresolution_vs_pt->Fill(tmp_jet->tlv().Pt(),
03899                                                          (1/tmp_jet->tlv().Pt()-1/vec_jet_truth[k]->tlv().Pt())
03900                                                          *vec_jet_truth[k]->tlv().Pt(),weight);
03901             h_jet_matched_invEresolution_vs_E->Fill(tmp_jet->tlv().E(),
03902                                                     (1./tmp_jet->tlv().E()-1./vec_jet_truth[k]->tlv().E())
03903                                                     *1./invGeV,weight);
03904             h_jet_matched_relinvEresolution_vs_E->Fill(tmp_jet->tlv().E(),
03905                                                        (1./tmp_jet->tlv().E()-1./vec_jet_truth[k]->tlv().E())
03906                                                        *vec_jet_truth[k]->tlv().E(),weight);
03907             
03908             h_jet_matched_relEresolution
03909                 ->Fill( (tmp_jet->tlv().E()-vec_jet_truth[k]->tlv().E())/
03910                         vec_jet_truth[k]->tlv().E(),weight );
03911             
03912             h_jet_matched_relEresolution_vs_pt
03913                 ->Fill( vec_jet_truth[k]->tlv().Pt()*invGeV,
03914                         (tmp_jet->tlv().E()-vec_jet_truth[k]->tlv().E())/
03915                         vec_jet_truth[k]->tlv().E(),weight );
03916             
03917             h_jet_matched_relEresolution_vs_eta
03918                 ->Fill( vec_jet_truth[k]->tlv().Eta(),
03919                         (tmp_jet->tlv().E()-vec_jet_truth[k]->tlv().E())/
03920                         vec_jet_truth[k]->tlv().E(),weight );
03921             
03922             h_jet_matched_relEresolution_vs_phi
03923                 ->Fill( vec_jet_truth[k]->tlv().Phi(),
03924                         (tmp_jet->tlv().E()-vec_jet_truth[k]->tlv().E())/
03925                         vec_jet_truth[k]->tlv().E(),weight );
03926             
03927             h_jet_matched_relEresolution_vs_E
03928                 ->Fill( vec_jet_truth[k]->tlv().E()*invGeV,
03929                         (tmp_jet->tlv().E()-vec_jet_truth[k]->tlv().E())/ 
03930                         vec_jet_truth[k]->tlv().E(),weight );
03931             
03932 
03933         }
03934         else{ // not matched jet
03935             
03936             nb_notmatched++;
03937             h_jet_eff->Fill(0.,weight);
03938 
03939             h_jet_truth_notmatched_pt->Fill(vec_jet_truth[k]->tlv().Pt()*invGeV, weight);
03940             h_jet_truth_notmatched_eta->Fill(vec_jet_truth[k]->tlv().Eta(), weight);
03941             h_jet_truth_notmatched_phi->Fill(vec_jet_truth[k]->tlv().Phi(), weight);
03942         }
03943     }
03944   
03945     h_jet_reco_matched_nb->Fill(nb_matched,weight);
03946     h_jet_truth_notmatched_nb->Fill(nb_notmatched,weight);
03947         
03948     // determine fake jets
03949     nb_fakes = 0;
03950     
03951     for (unsigned int k=0; k<vec_jet_reco.size(); k++) {
03952     
03953         MyParticle* tmp_jet = NULL;
03954         
03955         tmp_jet = m_tools.find_matching_particle(vec_jet_reco[k],
03956                                                  vec_jet_truth, deltaR_jetmatching_cut);
03957         
03958         if (tmp_jet==NULL) { //jet is faked
03959         
03960             nb_fakes++;
03961             h_jet_fake->Fill(1.,weight);
03962 
03963             h_jet_reco_fake_pt->Fill(vec_jet_reco[k]->tlv().Pt()*invGeV,weight);
03964             h_jet_reco_fake_eta->Fill(vec_jet_reco[k]->tlv().Eta(),weight);
03965             h_jet_reco_fake_phi->Fill(vec_jet_reco[k]->tlv().Phi(),weight);
03966         }
03967         else{
03968             h_jet_fake->Fill(0.,weight);  
03969         }
03970     }
03971     
03972     h_jet_reco_fake_nb->Fill(nb_fakes,weight);
03973     
03974     m_tools.clear_vector(vec_jet_reco);
03975     m_tools.clear_vector(vec_jet_truth);
03976 
03977     return;
03978 }
03979 
03980 //*****************************************************************************
03981 
03982 //:::::::::::::::::::::::::::::
03983 //:: METHOD match_track_jets ::
03984 //:::::::::::::::::::::::::::::
03985 
03986 void 
03987 MyHtoWWAnalysis::match_track_jets( vector<MyParticle*> vec_track_jet_reco, 
03988                                    vector<MyParticle*> vec_track_jet_truth) {
03989     
03990     int nb_matched(0);
03991     int nb_notmatched(0);
03992     int nb_fakes(0);
03993     
03994     // set deltaR for track_jet matching depending on track_jet algorithm // 
03995     
03996    //  if( (TString(m_tfile->GetName())).Contains("Cone") ){
03997            
03998 //      if( (TString(m_tfile->GetName())).Contains("Cone4") ) deltaR_jetmatching_cut = 0.25;
03999 //      else                                         deltaR_jetmatching_cut = 0.5;
04000 //     }
04001 //     else if( (TString(m_tfile->GetName())).Contains("Kt") ){
04002            
04003 //      if( (TString(m_tfile->GetName())).Contains("Kt1") ) deltaR_jetmatching_cut = 0.1;
04004 //      if( (TString(m_tfile->GetName())).Contains("Kt3") ) deltaR_jetmatching_cut = 0.2;
04005 //      if( (TString(m_tfile->GetName())).Contains("Kt5") ) deltaR_jetmatching_cut = 0.3;
04006 //      if( (TString(m_tfile->GetName())).Contains("Kt7") ) deltaR_jetmatching_cut = 0.5;
04007 //      else                                       deltaR_jetmatching_cut = 0.7;
04008 //     }else{
04009 //      deltaR_jetmatching_cut = 0.1;
04010 //     }
04011 
04012     //deltaR_jetmatching_cut = 0.4;
04013     double deltaR_jetmatching_cut = m_cutvalue_jet_match_dR;
04014 
04015     // loop over truth track_jets and search for a matching reconstructed track_jet
04016     for (unsigned int k=0; k<vec_track_jet_truth.size(); k++) {
04017     
04018         MyParticle* tmp_track_jet = NULL; 
04019         
04020         tmp_track_jet = m_tools.find_matching_particle( vec_track_jet_truth[k],
04021                                                         vec_track_jet_reco, deltaR_jetmatching_cut );
04022         if(tmp_track_jet!=NULL){
04023         
04024             nb_matched++;
04025             h_track_jet_eff->Fill(1.,weight);
04026 
04027         //     h_track_jet_reco_matched_pt->Fill(tmp_track_jet->tlv().Pt()*invGeV, weight);
04028 //             h_track_jet_reco_matched_eta->Fill(tmp_track_jet->tlv().Eta(), weight);
04029 //             h_track_jet_reco_matched_phi->Fill(tmp_track_jet->tlv().Phi(), weight);
04030 //             h_track_jet_reco_matched_E->Fill(tmp_track_jet->tlv().E()*invGeV, weight);
04031 
04032             h_track_jet_truth_matched_pt->Fill(vec_track_jet_truth[k]->tlv().Pt()*invGeV, weight);
04033             h_track_jet_truth_matched_eta->Fill(vec_track_jet_truth[k]->tlv().Eta(), weight);
04034             h_track_jet_truth_matched_phi->Fill(vec_track_jet_truth[k]->tlv().Phi(), weight);
04035             h_track_jet_truth_matched_E->Fill(vec_track_jet_truth[k]->tlv().E()*invGeV, weight);
04036 
04037             h_track_jet_matched_dpt->Fill((tmp_track_jet->tlv().Pt()-
04038                                      vec_track_jet_truth[k]->tlv().Pt())*invGeV,weight);
04039             h_track_jet_matched_deta->Fill(tmp_track_jet->tlv().Eta()-
04040                                      vec_track_jet_truth[k]->tlv().Eta(),weight );
04041             h_track_jet_matched_dphi->Fill(tmp_track_jet->tlv().DeltaPhi(vec_track_jet_truth[k]->tlv()),weight);
04042             h_track_jet_matched_dr->Fill(tmp_track_jet->tlv().DeltaR(vec_track_jet_truth[k]->tlv()),weight);
04043             h_track_jet_matched_dE->Fill((tmp_track_jet->tlv().E()-
04044                                      vec_track_jet_truth[k]->tlv().E())*invGeV,weight);
04045 
04046             h_track_jet_matched_resolution_pt
04047                 ->Fill(vec_track_jet_truth[k]->tlv().Pt()*invGeV,
04048                        (tmp_track_jet->tlv().Pt()-vec_track_jet_truth[k]->tlv().Pt())/
04049                        (vec_track_jet_truth[k]->tlv().Pt()),weight);
04050 
04051             h_track_jet_matched_resolution_eta
04052                 ->Fill(vec_track_jet_truth[k]->tlv().Eta(),
04053                        (tmp_track_jet->tlv().Eta()-vec_track_jet_truth[k]->tlv().Eta())/
04054                        (vec_track_jet_truth[k]->tlv().Eta()),weight);
04055             
04056             h_track_jet_matched_resolution_phi
04057                 ->Fill(vec_track_jet_truth[k]->tlv().Phi(),
04058                        (tmp_track_jet->tlv().DeltaPhi(vec_track_jet_truth[k]->tlv()))/
04059                        (vec_track_jet_truth[k]->tlv().Phi()),weight);
04060         
04061             h_track_jet_matched_invptresolution->Fill((1/tmp_track_jet->tlv().Pt()-
04062                                                        1/vec_track_jet_truth[k]->tlv().Pt())*1/invGeV,weight);
04063             h_track_jet_matched_relinvptresolution->Fill((1/tmp_track_jet->tlv().Pt()-
04064                                                           1/vec_track_jet_truth[k]->tlv().Pt())
04065                                                          *vec_track_jet_truth[k]->tlv().Pt(),weight);
04066             h_track_jet_matched_invEresolution->Fill((1./tmp_track_jet->tlv().E()-
04067                                                       1./vec_track_jet_truth[k]->tlv().E())*1./invGeV,weight);
04068             h_track_jet_matched_relinvEresolution->Fill((1./tmp_track_jet->tlv().E()-
04069                                                          1./vec_track_jet_truth[k]->tlv().E())
04070                                                         *vec_track_jet_truth[k]->tlv().E(),weight);
04071             
04072  
04073             h_track_jet_matched_invptresolution_vs_pt->Fill(tmp_track_jet->tlv().Pt(),
04074                                                             (1/tmp_track_jet->tlv().Pt()-1/vec_track_jet_truth[k]->tlv().Pt())
04075                                                             *1/invGeV,weight);
04076             h_track_jet_matched_relinvptresolution_vs_pt->Fill(tmp_track_jet->tlv().Pt(),
04077                                                                (1/tmp_track_jet->tlv().Pt()-1/vec_track_jet_truth[k]->tlv().Pt())
04078                                                                *vec_track_jet_truth[k]->tlv().Pt(),weight);
04079             h_track_jet_matched_invEresolution_vs_E->Fill(tmp_track_jet->tlv().E(),
04080                                                           (1./tmp_track_jet->tlv().E()-1./vec_track_jet_truth[k]->tlv().E())
04081                                                           *1./invGeV,weight);
04082             h_track_jet_matched_relinvEresolution_vs_E->Fill(tmp_track_jet->tlv().E(),
04083                                                              (1./tmp_track_jet->tlv().E()-1./vec_track_jet_truth[k]->tlv().E())
04084                                                              *vec_track_jet_truth[k]->tlv().E(),weight);
04085       
04086             
04087             h_track_jet_matched_Eresolution
04088                 ->Fill( (vec_track_jet_truth[k]->tlv().E()-tmp_track_jet->tlv().E())*invGeV,weight );
04089           
04090             h_track_jet_matched_Eresolution_vs_pt
04091                 ->Fill( vec_track_jet_truth[k]->tlv().Pt()*invGeV,
04092                         (tmp_track_jet->tlv().E()-vec_track_jet_truth[k]->tlv().E())*invGeV,weight );
04093             
04094             h_track_jet_matched_Eresolution_vs_eta
04095                 ->Fill( vec_track_jet_truth[k]->tlv().Eta(),
04096                         (tmp_track_jet->tlv().E()-vec_track_jet_truth[k]->tlv().E())*invGeV,weight );
04097             
04098             h_track_jet_matched_Eresolution_vs_phi
04099                 ->Fill( vec_track_jet_truth[k]->tlv().Phi(),
04100                         (tmp_track_jet->tlv().E()-vec_track_jet_truth[k]->tlv().E())*invGeV,weight );
04101             
04102             h_track_jet_matched_Eresolution_vs_E
04103                 ->Fill( vec_track_jet_truth[k]->tlv().E()*invGeV,
04104                         (tmp_track_jet->tlv().E()-vec_track_jet_truth[k]->tlv().E())*invGeV,weight);
04105             
04106             
04107             h_track_jet_matched_relEresolution
04108                 ->Fill( (tmp_track_jet->tlv().E()-vec_track_jet_truth[k]->tlv().E())/
04109                         vec_track_jet_truth[k]->tlv().E(),weight );
04110             
04111             h_track_jet_matched_relEresolution_vs_pt
04112                 ->Fill( vec_track_jet_truth[k]->tlv().Pt()*invGeV,
04113                         (tmp_track_jet->tlv().E()-vec_track_jet_truth[k]->tlv().E())/
04114                         vec_track_jet_truth[k]->tlv().E(),weight );
04115             
04116             h_track_jet_matched_relEresolution_vs_eta
04117                 ->Fill( vec_track_jet_truth[k]->tlv().Eta(),
04118                         (tmp_track_jet->tlv().E()-vec_track_jet_truth[k]->tlv().E())/
04119                         vec_track_jet_truth[k]->tlv().E(),weight );
04120             
04121             h_track_jet_matched_relEresolution_vs_phi
04122                 ->Fill( vec_track_jet_truth[k]->tlv().Phi(),
04123                         (tmp_track_jet->tlv().E()-vec_track_jet_truth[k]->tlv().E())/
04124                         vec_track_jet_truth[k]->tlv().E(),weight );
04125             
04126             h_track_jet_matched_relEresolution_vs_E
04127                 ->Fill( vec_track_jet_truth[k]->tlv().E()*invGeV,
04128                         (tmp_track_jet->tlv().E()-vec_track_jet_truth[k]->tlv().E())/ 
04129                         vec_track_jet_truth[k]->tlv().E(),weight );
04130             
04131 
04132         }
04133         else{ // not matched track_jet
04134             
04135             nb_notmatched++;
04136             h_track_jet_eff->Fill(0.,weight);
04137 
04138             h_track_jet_truth_notmatched_pt->Fill(vec_track_jet_truth[k]->tlv().Pt()*invGeV, weight);
04139             h_track_jet_truth_notmatched_eta->Fill(vec_track_jet_truth[k]->tlv().Eta(), weight);
04140             h_track_jet_truth_notmatched_phi->Fill(vec_track_jet_truth[k]->tlv().Phi(), weight);
04141         }
04142     }
04143   
04144     h_track_jet_reco_matched_nb->Fill(nb_matched,weight);
04145     h_track_jet_truth_notmatched_nb->Fill(nb_notmatched,weight);
04146         
04147     
04148 
04149     // determine fake track_jets
04150     nb_fakes = 0;
04151     
04152     for (unsigned int k=0; k<vec_track_jet_reco.size(); k++) {
04153     
04154         MyParticle* tmp_track_jet = NULL;
04155         
04156         tmp_track_jet = m_tools.find_matching_particle(vec_track_jet_reco[k],
04157                                                        vec_track_jet_truth, deltaR_jetmatching_cut);
04158         
04159         if (tmp_track_jet==NULL) { //track_jet is faked
04160         
04161             nb_fakes++;
04162             h_track_jet_fake->Fill(1.,weight);
04163             v_track_jet_reco_fake.push_back(vec_track_jet_reco[k]);
04164 
04165             h_track_jet_reco_fake_pt->Fill(vec_track_jet_reco[k]->tlv().Pt()*invGeV,weight);
04166             h_track_jet_reco_fake_eta->Fill(vec_track_jet_reco[k]->tlv().Eta(),weight);
04167             h_track_jet_reco_fake_phi->Fill(vec_track_jet_reco[k]->tlv().Phi(),weight);
04168      
04169             h_track_jet_reco_fake_vs_pt->Fill(vec_track_jet_reco[k]->tlv().Pt()*invGeV,1.,weight);
04170             h_track_jet_reco_fake_vs_eta->Fill(vec_track_jet_reco[k]->tlv().Eta(),1.,weight);
04171 
04172         }
04173         else{
04174             
04175             h_track_jet_fake->Fill(0.,weight);  
04176             
04177             h_track_jet_reco_fake_vs_pt->Fill(vec_track_jet_reco[k]->tlv().Pt()*invGeV,0.,weight);
04178             h_track_jet_reco_fake_vs_eta->Fill(vec_track_jet_reco[k]->tlv().Eta(),0.,weight);
04179             
04180             h_track_jet_reco_matched_pt->Fill(vec_track_jet_reco[k]->tlv().Pt()*invGeV, weight);
04181             h_track_jet_reco_matched_eta->Fill(vec_track_jet_reco[k]->tlv().Eta(), weight);
04182             h_track_jet_reco_matched_phi->Fill(vec_track_jet_reco[k]->tlv().Phi(), weight);
04183             //h_track_jet_reco_matched_E->Fill(vec_track_jet_reco[k]->tlv().E()*invGeV, weight);
04184 
04185    
04186         }
04187     }
04188     
04189     h_track_jet_reco_fake_nb->Fill(nb_fakes,weight);
04190     
04191     //h_trj_truth_jet_match->Fill(nb_trj_jets_matched/(double)(v_track_jet_reco_presel.size()), weight);
04192 
04193     m_tools.clear_vector(vec_track_jet_reco);
04194     m_tools.clear_vector(vec_track_jet_truth);
04195 
04196     return;
04197 }
04198 
04199 //*****************************************************************************
04200 
04201 //::::::::::::::::::::::::::::::::::
04202 //:: METHOD match_fake_track_jets ::
04203 //::::::::::::::::::::::::::::::::::
04204 
04205 void  
04206 MyHtoWWAnalysis::match_fake_track_jets( std::vector<MyParticle*> vec_e, 
04207                                         std::vector<MyParticle*> vec_mu) {
04208 
04209     bool is_e;
04210     bool is_mu;
04211 
04212     MyParticle* tmp_particle1;
04213     MyParticle* tmp_particle2;
04214     
04215     for(unsigned int k=0; k<v_track_jet_reco_fake.size(); k++){
04216 
04217         is_e = false;
04218         is_mu = false;
04219                 
04220         //cout << "read: " << v_track_jet_reco_fake[k] << endl;
04221         //v_track_jet_reco_fake[k]->Print();
04222         
04223         tmp_particle1 
04224             = m_tools.find_matching_particle(v_track_jet_reco_fake[k],
04225                                              vec_e, 0.4, false, false);
04226         
04227         if(tmp_particle1!=NULL){
04228             is_e = true;
04229             h_track_jet_fake_id->Fill(11);
04230         }
04231         
04232         tmp_particle2 
04233             = m_tools.find_matching_particle(v_track_jet_reco_fake[k],
04234                                              vec_mu, 0.4, false, false);
04235         
04236         if(tmp_particle2!=NULL){
04237             is_mu = true;
04238             h_track_jet_fake_id->Fill(13);
04239         }
04240         
04241         if(is_e || is_mu){
04242             h_track_jet_fake_id->Fill(1);
04243         }
04244         else{
04245             h_track_jet_fake_id->Fill(0);
04246         }
04247         
04248     }
04249 
04250     return;
04251 
04252   }
04253 //*****************************************************************************
04254 
04255 //::::::::::::::::::::::::::::::::::::::
04256 //:: METHOD match_track_with_std_jets ::
04257 //::::::::::::::::::::::::::::::::::::::
04258 
04259 void  
04260 MyHtoWWAnalysis::match_track_with_std_jets( std::vector<MyParticle*> vec_track_jet, 
04261                                             std::vector<MyParticle*> vec_std_jet) {
04262     
04263     
04264 
04265 
04266     double match_window = m_cutvalue_jet_match_dR;
04267 
04268     //loop over track jets
04269     for (unsigned int k=0; k<vec_track_jet.size(); k++) {
04270         
04271         MyParticle* tmp_std_jet = NULL;
04272         tmp_std_jet = m_tools.find_matching_particle( vec_track_jet[k],
04273                                                       vec_std_jet, match_window );
04274         
04275         if(tmp_std_jet!=NULL){
04276             
04277             h_track_std_jet_match->Fill(1.,weight);
04278 
04279             h_track_std_jet_matched_pt->Fill(vec_track_jet[k]->tlv().Pt()*invGeV, weight);
04280             h_track_std_jet_matched_eta->Fill(vec_track_jet[k]->tlv().Eta(), weight);
04281             h_track_std_jet_matched_phi->Fill(vec_track_jet[k]->tlv().Phi(), weight);
04282             h_track_std_jet_matched_E->Fill(vec_track_jet[k]->tlv().E()*invGeV, weight);
04283             
04284             h_track_std_jet_matched_dpt->Fill((tmp_std_jet->tlv().Pt()-
04285                                                vec_track_jet[k]->tlv().Pt())*invGeV,weight);
04286             h_track_std_jet_matched_deta->Fill(tmp_std_jet->tlv().Eta()-
04287                                                vec_track_jet[k]->tlv().Eta(),weight );
04288             h_track_std_jet_matched_dphi->Fill(tmp_std_jet->tlv().DeltaPhi(vec_track_jet[k]->tlv()),weight);
04289             h_track_std_jet_matched_dr->Fill(tmp_std_jet->tlv().DeltaR(vec_track_jet[k]->tlv()),weight);
04290             h_track_std_jet_matched_dE->Fill((tmp_std_jet->tlv().E()-
04291                                               vec_track_jet[k]->tlv().E())*invGeV,weight);
04292             
04293                   
04294             h_track_std_jet_matched_vs_eta
04295                 ->Fill(vec_track_jet[k]->tlv().Eta(), 1., weight);  
04296             h_track_std_jet_matched_vs_pt
04297                 ->Fill(vec_track_jet[k]->tlv().Pt(), 1., weight);  
04298             
04299             
04300             h_track_std_jet_matched_resolution_pt
04301                 ->Fill(vec_track_jet[k]->tlv().Pt()*invGeV,
04302                        (tmp_std_jet->tlv().Pt()-vec_track_jet[k]->tlv().Pt())/
04303                        (vec_track_jet[k]->tlv().Pt()),weight);
04304             
04305             h_track_std_jet_matched_resolution_eta
04306                 ->Fill(vec_track_jet[k]->tlv().Eta(),
04307                        (tmp_std_jet->tlv().Eta()-vec_track_jet[k]->tlv().Eta())/
04308                        (vec_track_jet[k]->tlv().Eta()),weight);
04309             
04310             h_track_std_jet_matched_resolution_phi
04311                 ->Fill(vec_track_jet[k]->tlv().Phi(),
04312                        (tmp_std_jet->tlv().DeltaPhi(vec_track_jet[k]->tlv()))/
04313                        (vec_track_jet[k]->tlv().Phi()),weight);
04314 
04315 
04316             //h_track_std_jet_matched_2Dpt->Fill(vec_track_jet[k]->tlv().Pt(),
04317             //                                 tmp_std_jet->tlv().Pt(),weight);
04318 
04319             
04320             //h_track_std_jet_matched_pt_ratio_vs_pttrk
04321             //  ->Fill(vec_track_jet[k]->tlv().Pt()*invGeV,
04322             //         vec_track_jet[k]->tlv().Pt()/tmp_std_jet->tlv().Pt(),
04323             //         weight);
04324            
04325             //h_track_std_jet_matched_pt_ratio_vs_ptstd
04326             //  ->Fill(tmp_std_jet->tlv().Pt()*invGeV,
04327             //         vec_track_jet[k]->tlv().Pt()/tmp_std_jet->tlv().Pt(),
04328             //         weight);
04329         
04330 
04331             h_track_std_jet_matched_jetptratio->Fill(vec_track_jet[k]->tlv().Pt()/
04332                                                      tmp_std_jet->tlv().Pt(),weight);
04333             
04334             h_track_std_jet_matched_jetptratio_corr->Fill(vec_track_jet[k]->tlv().Pt()/
04335                                                           ((MyParticleJet*)(tmp_std_jet))
04336                                                           ->pt_pucorr(m_primary_vertex_index),weight);
04337 
04338 
04339             h_track_std_jet_matched_pt_vs_jetptratio->Fill( (vec_track_jet[k])->tlv().Pt(),
04340                                                             (vec_track_jet[k])->tlv().Pt()/tmp_std_jet->tlv().Pt(),weight);
04341             
04342             h_track_std_jet_matched_pt_vs_jetptratio_corr
04343                 ->Fill( (vec_track_jet[k])->tlv().Pt(),
04344                         (vec_track_jet[k])->tlv().Pt()/((MyParticleJet*)(tmp_std_jet))
04345                         ->pt_pucorr(m_primary_vertex_index),weight);
04346             
04347             h_track_std_jet_matched_pt_vs_stdjetpt->Fill( (vec_track_jet[k])->tlv().Pt(),
04348                                                           tmp_std_jet->tlv().Pt(),weight);
04349             
04350             h_track_std_jet_matched_pt_vs_stdjetpt_corr->Fill( (vec_track_jet[k])->tlv().Pt(),
04351                                                                ((MyParticleJet*)(tmp_std_jet))
04352                                                                ->pt_pucorr(m_primary_vertex_index),weight);
04353             
04354 
04355         }
04356         else{
04357             h_track_std_jet_match->Fill(0.,weight);
04358             
04359             h_track_std_jet_notmatched_pt->Fill(vec_track_jet[k]->tlv().Pt()*invGeV, weight);
04360             h_track_std_jet_notmatched_eta->Fill(vec_track_jet[k]->tlv().Eta(), weight);
04361             h_track_std_jet_notmatched_phi->Fill(vec_track_jet[k]->tlv().Phi(), weight);
04362             h_track_std_jet_notmatched_E->Fill(vec_track_jet[k]->tlv().E()*invGeV, weight);
04363    
04364 
04365             h_track_std_jet_matched_vs_eta
04366                 ->Fill(vec_track_jet[k]->tlv().Eta(), 0., weight);   
04367             h_track_std_jet_matched_vs_pt
04368                 ->Fill(vec_track_jet[k]->tlv().Pt(), 0., weight);  
04369         }
04370     }
04371     
04372     //loop over std jets
04373     for (unsigned int k=0; k<vec_std_jet.size(); k++) {
04374         
04375         MyParticle* tmp_track_jet = NULL;
04376         tmp_track_jet = m_tools.find_matching_particle( vec_std_jet[k],
04377                                                         vec_track_jet, match_window );
04378         
04379         if(tmp_track_jet!=NULL){
04380               
04381             h_std_track_jet_match->Fill(1.,weight);
04382 
04383             h_std_track_jet_matched_pt->Fill(vec_std_jet[k]->tlv().Pt()*invGeV, weight);
04384             h_std_track_jet_matched_eta->Fill(vec_std_jet[k]->tlv().Eta(), weight);
04385             h_std_track_jet_matched_phi->Fill(vec_std_jet[k]->tlv().Phi(), weight);
04386             h_std_track_jet_matched_E->Fill(vec_std_jet[k]->tlv().E()*invGeV, weight);
04387             
04388             h_std_track_jet_matched_dpt->Fill((tmp_track_jet->tlv().Pt()-
04389                                                vec_std_jet[k]->tlv().Pt())*invGeV,weight);
04390             h_std_track_jet_matched_deta->Fill(tmp_track_jet->tlv().Eta()-
04391                                                vec_std_jet[k]->tlv().Eta(),weight );
04392             h_std_track_jet_matched_dphi->Fill(tmp_track_jet->tlv().DeltaPhi(vec_std_jet[k]->tlv()),weight);
04393             h_std_track_jet_matched_dr->Fill(tmp_track_jet->tlv().DeltaR(vec_std_jet[k]->tlv()),weight);
04394             h_std_track_jet_matched_dE->Fill((tmp_track_jet->tlv().E()-
04395                                               vec_std_jet[k]->tlv().E())*invGeV,weight);
04396             
04397             h_std_track_jet_matched_resolution_pt
04398                 ->Fill(vec_std_jet[k]->tlv().Pt()*invGeV,
04399                        (tmp_track_jet->tlv().Pt()-vec_std_jet[k]->tlv().Pt())/
04400                        (vec_std_jet[k]->tlv().Pt()),weight);
04401             
04402             h_std_track_jet_matched_resolution_eta
04403                 ->Fill(vec_std_jet[k]->tlv().Eta(),
04404                        (tmp_track_jet->tlv().Eta()-vec_std_jet[k]->tlv().Eta())/
04405                        (vec_std_jet[k]->tlv().Eta()),weight);
04406             
04407             h_std_track_jet_matched_resolution_phi
04408                 ->Fill(vec_std_jet[k]->tlv().Phi(),
04409                        (tmp_track_jet->tlv().DeltaPhi(vec_std_jet[k]->tlv()))/
04410                        (vec_std_jet[k]->tlv().Phi()),weight);
04411 
04412                   
04413             h_std_track_jet_matched_vs_eta
04414                 ->Fill(vec_std_jet[k]->tlv().Eta(), 1., weight);  
04415             h_std_track_jet_matched_vs_pt
04416                 ->Fill(vec_std_jet[k]->tlv().Pt(), 1., weight);  
04417             
04418             //new
04419 
04420             h_std_track_jet_matched_pt_corr->Fill( ((MyParticleJet*)(vec_std_jet[k]))
04421                                                   ->pt_pucorr(m_primary_vertex_index),weight);
04422         
04423             h_std_track_jet_matched_trkptratio->Fill( ((MyParticleJet*)(vec_std_jet[k]))
04424                                                       ->tracks_ptratio(m_primary_vertex_index),weight );
04425             
04426             h_std_track_jet_matched_cmstrkptratio->Fill( ((MyParticleJet*)(vec_std_jet[k]))
04427                                                          ->tracks_cmsptratio(m_primary_vertex_index),weight );
04428             
04429             
04430             h_std_track_jet_matched_pt_vs_jetptratio->Fill( (vec_std_jet[k])->tlv().Pt(),
04431                                                             tmp_track_jet->tlv().Pt()/(vec_std_jet[k])->tlv().Pt(),weight);
04432             
04433             h_std_track_jet_matched_pt_vs_jetptratio_corr
04434                 ->Fill( ((MyParticleJet*)(vec_std_jet[k]))->pt_pucorr(m_primary_vertex_index),
04435                         tmp_track_jet->tlv().Pt()/((MyParticleJet*)(vec_std_jet[k]))
04436                         ->pt_pucorr(m_primary_vertex_index),weight);
04437             
04438             h_std_track_jet_matched_pt_vs_trackjetpt->Fill( (vec_std_jet[k])->tlv().Pt(),
04439                                                             tmp_track_jet->tlv().Pt(),weight);
04440             
04441             h_std_track_jet_matched_pt_vs_trackjetpt_corr->Fill( ((MyParticleJet*)(vec_std_jet[k]))
04442                                                                ->pt_pucorr(m_primary_vertex_index),
04443                                                                  tmp_track_jet->tlv().Pt(),weight);
04444            
04445         }
04446         else{
04447 
04448             h_std_track_jet_match->Fill(0.,weight);
04449             
04450             h_std_track_jet_notmatched_pt->Fill(vec_std_jet[k]->tlv().Pt()*invGeV, weight);
04451             h_std_track_jet_notmatched_eta->Fill(vec_std_jet[k]->tlv().Eta(), weight);
04452             h_std_track_jet_notmatched_phi->Fill(vec_std_jet[k]->tlv().Phi(), weight);
04453             h_std_track_jet_notmatched_E->Fill(vec_std_jet[k]->tlv().E()*invGeV, weight);
04454             h_std_track_jet_notmatched_ntrks->Fill(((MyParticleJet*)(vec_std_jet[k]))->nb_tracks(),weight);
04455 
04456             h_std_track_jet_matched_vs_eta
04457                 ->Fill(vec_std_jet[k]->tlv().Eta(), 0., weight);   
04458             h_std_track_jet_matched_vs_pt
04459                 ->Fill(vec_std_jet[k]->tlv().Pt(), 0., weight);  
04460         
04461         }
04462     }
04463     
04464     //h_trj_std_jet_match->Fill(nb_trj_jets_matched/(double)(vec_track_jet.size()), weight);
04465     //h_std_trj_jet_match->Fill(nb_jets_matched/(double)(vec_jet.size()), weight);
04466 
04467     m_tools.clear_vector(vec_std_jet);
04468     m_tools.clear_vector(vec_track_jet);
04469     
04470 
04471   }
04472 
04473 //*****************************************************************************
04474 
04475 //::::::::::::::::::::::::::::::::::::::::::::
04476 //:: METHOD match_truth_track_with_std_jets ::
04477 //::::::::::::::::::::::::::::::::::::::::::::
04478 
04479 void  
04480 MyHtoWWAnalysis::match_truth_track_with_std_jets( std::vector<MyParticle*> vec_truth_track_jet, 
04481                                                   std::vector<MyParticle*> vec_truth_std_jet) {
04482     
04483     
04484 
04485 
04486     double match_window = m_cutvalue_jet_match_dR;
04487 
04488     //loop over track jets
04489     for (unsigned int k=0; k<vec_truth_track_jet.size(); k++) {
04490         
04491         MyParticle* tmp_std_jet = NULL;
04492         tmp_std_jet = m_tools.find_matching_particle( vec_truth_track_jet[k],
04493                                                       vec_truth_std_jet, match_window );
04494         
04495         if(tmp_std_jet!=NULL){
04496             
04497             h_truth_track_std_jet_match->Fill(1.,weight);
04498 
04499             h_truth_track_std_jet_matched_pt->Fill(vec_truth_track_jet[k]->tlv().Pt()*invGeV, weight);
04500             h_truth_track_std_jet_matched_eta->Fill(vec_truth_track_jet[k]->tlv().Eta(), weight);
04501             h_truth_track_std_jet_matched_phi->Fill(vec_truth_track_jet[k]->tlv().Phi(), weight);
04502             h_truth_track_std_jet_matched_E->Fill(vec_truth_track_jet[k]->tlv().E()*invGeV, weight);
04503             
04504             h_truth_track_std_jet_matched_vs_eta
04505                 ->Fill(vec_truth_track_jet[k]->tlv().Eta(), 1., weight);  
04506             h_truth_track_std_jet_matched_vs_pt
04507                 ->Fill(vec_truth_track_jet[k]->tlv().Pt(), 1., weight);  
04508             
04509 
04510             
04511             h_truth_track_std_jet_matched_jetptratio->Fill(vec_truth_track_jet[k]->tlv().Pt()/
04512                                                            tmp_std_jet->tlv().Pt(),weight);
04513             
04514             //h_truth_track_std_jet_matched_2Dpt->Fill(vec_truth_track_jet[k]->tlv().Pt(),
04515             //                               tmp_std_jet->tlv().Pt(),weight);
04516 
04517             //h_truth_track_std_jet_matched_pt_ratio_vs_pttrk
04518             //  ->Fill(vec_truth_track_jet[k]->tlv().Pt()*invGeV,
04519             //         vec_truth_track_jet[k]->tlv().Pt()/tmp_std_jet->tlv().Pt(),
04520             //         weight);
04521 
04522             //h_truth_track_std_jet_matched_pt_ratio_vs_ptstd
04523             //  ->Fill(tmp_std_jet->tlv().Pt()*invGeV,
04524             //         vec_truth_track_jet[k]->tlv().Pt()/tmp_std_jet->tlv().Pt(),
04525             //         weight);
04526 
04527 
04528             
04529             //h_truth_track_std_jet_matched_jetptratio_corr->Fill(vec_truth_track_jet[k]->tlv().Pt()/
04530             //                                                  ((MyParticleJet*)(tmp_std_jet))
04531             //                                                  ->pt_pucorr(m_primary_vertex_index),weight);
04532 
04533 
04534             h_truth_track_std_jet_matched_pt_vs_jetptratio->Fill( (vec_truth_track_jet[k])->tlv().Pt(),
04535                                                                   (vec_truth_track_jet[k])->tlv().Pt()/tmp_std_jet->tlv().Pt(),weight);
04536             
04537             //h_truth_track_std_jet_matched_pt_vs_jetptratio_corr
04538             //  ->Fill( (vec_truth_track_jet[k])->tlv().Pt(),
04539             //          (vec_truth_track_jet[k])->tlv().Pt()/((MyParticleJet*)(tmp_std_jet))
04540             //          ->pt_pucorr(m_primary_vertex_index),weight);
04541             
04542             h_truth_track_std_jet_matched_pt_vs_stdjetpt->Fill( (vec_truth_track_jet[k])->tlv().Pt(),
04543                                                                 tmp_std_jet->tlv().Pt(),weight);
04544             
04545             //h_truth_track_std_jet_matched_pt_vs_stdjetpt_corr->Fill( ((MyParticleJet*)(vec_truth_track_jet[k]))
04546             //                                                       ->pt_pucorr(m_primary_vertex_index),
04547             //                                                       tmp_std_jet->tlv().Pt(),weight);
04548 
04549 
04550         }
04551         else{
04552             h_truth_track_std_jet_match->Fill(0.,weight);
04553             
04554             h_truth_track_std_jet_notmatched_pt->Fill(vec_truth_track_jet[k]->tlv().Pt()*invGeV, weight);
04555             h_truth_track_std_jet_notmatched_eta->Fill(vec_truth_track_jet[k]->tlv().Eta(), weight);
04556             h_truth_track_std_jet_notmatched_phi->Fill(vec_truth_track_jet[k]->tlv().Phi(), weight);
04557             h_truth_track_std_jet_notmatched_E->Fill(vec_truth_track_jet[k]->tlv().E()*invGeV, weight);
04558    
04559 
04560             h_truth_track_std_jet_matched_vs_eta
04561                 ->Fill(vec_truth_track_jet[k]->tlv().Eta(), 0., weight);   
04562             h_truth_track_std_jet_matched_vs_pt
04563                 ->Fill(vec_truth_track_jet[k]->tlv().Pt(), 0., weight);  
04564         }
04565     }
04566     
04567     //loop over std jets
04568     for (unsigned int k=0; k<vec_truth_std_jet.size(); k++) {
04569         
04570         MyParticle* tmp_track_jet = NULL;
04571         tmp_track_jet = m_tools.find_matching_particle( vec_truth_std_jet[k],
04572                                                         vec_truth_track_jet, match_window );
04573         
04574         if(tmp_track_jet!=NULL){
04575               
04576             h_truth_std_track_jet_match->Fill(1.,weight);
04577 
04578             h_truth_std_track_jet_matched_pt->Fill(vec_truth_std_jet[k]->tlv().Pt()*invGeV, weight);
04579             h_truth_std_track_jet_matched_eta->Fill(vec_truth_std_jet[k]->tlv().Eta(), weight);
04580             h_truth_std_track_jet_matched_phi->Fill(vec_truth_std_jet[k]->tlv().Phi(), weight);
04581             h_truth_std_track_jet_matched_E->Fill(vec_truth_std_jet[k]->tlv().E()*invGeV, weight);
04582             
04583             h_truth_std_track_jet_matched_vs_eta
04584                 ->Fill(vec_truth_std_jet[k]->tlv().Eta(), 1., weight);  
04585             h_truth_std_track_jet_matched_vs_pt
04586                 ->Fill(vec_truth_std_jet[k]->tlv().Pt(), 1., weight);  
04587             
04588 
04589          
04590             h_truth_std_track_jet_matched_jetptratio->Fill(tmp_track_jet->tlv().Pt()/
04591                                                            (vec_truth_std_jet[k])->tlv().Pt(),weight);
04592    
04593             h_truth_std_track_jet_matched_pt_vs_jetptratio
04594                 ->Fill( (vec_truth_std_jet[k])->tlv().Pt(),
04595                         tmp_track_jet->tlv().Pt()/(vec_truth_std_jet[k])->tlv().Pt(),weight);
04596             
04597             //h_truth_std_track_jet_matched_pt_vs_jetptratio_corr
04598             //  ->Fill( ((MyParticleJet*)(vec_truth_std_jet[k]))->pt_pucorr(m_primary_vertex_index),
04599             //          tmp_track_jet->tlv().Pt()/((MyParticleJet*)(vec_truth_std_jet[k]))
04600             //          ->pt_pucorr(m_primary_vertex_index),weight);
04601             
04602             h_truth_std_track_jet_matched_pt_vs_trackjetpt->Fill( (vec_truth_std_jet[k])->tlv().Pt(),
04603                                                                 tmp_track_jet->tlv().Pt(),weight);
04604             
04605             //h_truth_std_track_jet_matched_pt_vs_trkjetpt_corr->Fill( ((MyParticleJet*)(vec_truth_std_jet[k]))
04606             //                                                       ->pt_pucorr(m_primary_vertex_index),
04607             //                                                       tmp_track_jet->tlv().Pt(),weight);
04608  
04609 
04610 
04611         }
04612         else{
04613 
04614             h_truth_std_track_jet_match->Fill(0.,weight);
04615             
04616             h_truth_std_track_jet_notmatched_pt->Fill(vec_truth_std_jet[k]->tlv().Pt()*invGeV, weight);
04617             h_truth_std_track_jet_notmatched_eta->Fill(vec_truth_std_jet[k]->tlv().Eta(), weight);
04618             h_truth_std_track_jet_notmatched_phi->Fill(vec_truth_std_jet[k]->tlv().Phi(), weight);
04619             h_truth_std_track_jet_notmatched_E->Fill(vec_truth_std_jet[k]->tlv().E()*invGeV, weight);
04620             //h_truth_std_track_jet_notmatched_ntrks->Fill(((MyParticleJet*)(vec_truth_std_jet[k]))->nb_tracks(),weight);
04621 
04622             h_truth_std_track_jet_matched_vs_eta
04623                 ->Fill(vec_truth_std_jet[k]->tlv().Eta(), 0., weight);   
04624             h_truth_std_track_jet_matched_vs_pt
04625                 ->Fill(vec_truth_std_jet[k]->tlv().Pt(), 0., weight);  
04626         
04627         }
04628     }
04629     
04630     m_tools.clear_vector(vec_truth_std_jet);
04631     m_tools.clear_vector(vec_truth_track_jet);
04632     
04633 
04634   }
04635 //*****************************************************************************
04636 
04637 //:::::::::::::::::::::::::
04638 //:: METHOD jet_btag_eff ::
04639 //:::::::::::::::::::::::::
04640 
04641 void 
04642 MyHtoWWAnalysis::jet_btag_eff( vector<MyParticle*> vec_reco_jets, 
04643                                MyTruthParticleManager *truth_manager) {
04644 
04645     vector<MyParticle*> vec_bjet_cands(0);
04646     vector<MyParticle*> vec_truth_bs_selected(0);
04647 
04648     // select truth b's
04649 
04650     vector<MyParticle*> vec_truth_bs = truth_manager->getParticles_with_ID(5);
04651    
04652     for (unsigned int k=0; k<vec_truth_bs.size(); k++) {
04653         
04654         MyTruthParticle* truthpart = (MyTruthParticle*)vec_truth_bs[k];
04655 
04656         MyTruthParticle* mother = truth_manager->get_mother(truthpart);
04657 
04658         if(mother==NULL){
04659             continue;
04660         }
04661         
04662         int motherId = TMath::Abs(mother->pdgId());
04663         
04664         if( motherId!=6 ){
04665            continue;
04666         }
04667 
04668         h_b_truth_mother_pdgID->Fill(motherId); 
04669         h_b_truth_status->Fill(truthpart->status()); 
04670 
04671         //h_b_truth_mother_pdgID->Fill(motherId); 
04672         //h_b_truth_status->Fill(truthpart->status()); 
04673 
04674         vec_truth_bs_selected.push_back( vec_truth_bs[k] );
04675         
04676     }
04677 
04678 
04679     // select btaged jets
04680     
04681     vector<MyParticle*> vec_jets = 
04682         m_tools.pt_eta_cut(vec_reco_jets, 20.0*GeV, -1, 0.0, 2.5);
04683     
04684   
04685     for (unsigned int k=0; k<vec_jets.size(); k++) {
04686         
04687         double bweight = ((MyParticleJet*)(vec_jets[k]))->b_tag_weight();
04688         
04689         if( bweight > m_cutvalue_bjet_weight_max ){ 
04690            
04691             vec_bjet_cands.push_back( vec_jets[k] );  
04692             h_bjet_ratio->Fill(1.,weight);
04693         }  
04694         else{
04695             h_bjet_ratio->Fill(0.,weight); 
04696         }
04697     }
04698     
04699     h_b_truth_nb->Fill(vec_truth_bs_selected.size(),weight);
04700     
04701 
04702     //btag efficiency
04703 
04704     for (unsigned int k=0; k<vec_truth_bs_selected.size(); k++) {
04705         
04706         h_b_truth_pt->Fill(vec_truth_bs_selected[k]->tlv().Pt()*invGeV,weight); 
04707         
04708         MyParticle* tmp_jet = NULL; 
04709         
04710         tmp_jet = m_tools.find_matching_particle( vec_truth_bs_selected[k],
04711                                                   vec_bjet_cands, 0.3 );
04712         
04713         if(tmp_jet!=NULL){
04714             h_b_eff->Fill(1.,weight);
04715         }
04716         else{
04717             h_b_eff->Fill(0.,weight);
04718         }
04719     }
04720     
04721     
04722     //btag fakerate
04723     
04724     for (unsigned int k=0; k<vec_bjet_cands.size(); k++) {
04725         
04726         MyParticle* tmp_b = NULL; 
04727         
04728         tmp_b = m_tools.find_matching_particle( vec_bjet_cands[k],
04729                                                 vec_truth_bs_selected, 0.3 );
04730         
04731         if(tmp_b!=NULL){
04732             h_b_fake->Fill(0.,weight);
04733         }
04734         else{
04735             h_b_fake->Fill(1.,weight);
04736         }
04737     }
04738     
04739     
04740     //clear matching flags
04741     
04742     m_tools.clear_vector(vec_bjet_cands);
04743     m_tools.clear_vector(vec_truth_bs_selected);
04744 
04745     //for (unsigned int k=0; k<vec_reco_jets.size(); k++) {
04746     //  cout << "mflag: " << vec_reco_jets[k]->matchingflag() << endl;
04747     //}
04748   
04749     return;
04750   }
04751 
04752 //*****************************************************************************
04753 
04754 //:::::::::::::::::::::::::::::::::::
04755 //:: METHOD lepton_isolation_study ::
04756 //:::::::::::::::::::::::::::::::::::
04757 
04758 void 
04759 MyHtoWWAnalysis::lepton_isolation_study( vector<MyParticle*> vec_leptons,
04760                                          MyTruthParticleManager *truth_manager) {
04761 
04762     if(vec_leptons.size()==0){
04763         return;
04764     }
04765 
04766     TString type = TString(vec_leptons[0]->type()); 
04767     int pdgId = TMath::Abs(vec_leptons[0]->pdgId());
04768 
04769     vector<MyParticle*> vec_truth_leptons(0); 
04770     vec_truth_leptons = truth_manager->getParticles_with_ID(pdgId);
04771     //vec_truth_leptons = truth_manager->remove_multiples(vec_truth_leptons);
04772     
04773     
04774     vector<MyParticle*> vec_truth_leptons_isol(0);
04775     vector<MyParticle*> vec_truth_leptons_nonisol(0);
04776 
04777     for (unsigned int k=0; k<vec_truth_leptons.size(); k++) {
04778         
04779         int mother_pdgId(-1);
04780         
04781         MyTruthParticle* mother = truth_manager->get_mother((MyTruthParticle*)vec_truth_leptons[k]);
04782         if (mother!=NULL ) {
04783             mother_pdgId = mother->pdgId();
04784         }
04785 
04786         if( TMath::Abs(mother_pdgId)==pdgId || mother_pdgId==-1 ){
04787             continue;
04788         }
04789 
04790         if(TMath::Abs(mother_pdgId)==24){
04791             vec_truth_leptons_isol.push_back(vec_truth_leptons[k]);
04792             //cout << "pdgId: " << pdgId << ", mother_pdgId: " << mother_pdgId << endl;
04793         }
04794         else{
04795             vec_truth_leptons_nonisol.push_back(vec_truth_leptons[k]);
04796         }
04797     }
04798 
04799     for (unsigned int k=0; k<vec_leptons.size(); k++) {
04800         
04801         MyParticle* tmp_truth_lepton_isol    = NULL; 
04802         
04803         tmp_truth_lepton_isol = m_tools.find_matching_particle( vec_leptons[k],
04804                                                                 vec_truth_leptons_isol, 0.1 );
04805         
04806         if(tmp_truth_lepton_isol!=NULL){
04807             if(type=="electron"){
04808                 t_cutopt_e_isol->Fill( weight, 
04809                                        ((MyElectron*)vec_leptons[k])->track_Et_in_cone(0),
04810                                        ((MyElectron*)vec_leptons[k])->track_Et_in_cone(1),
04811                                        ((MyElectron*)vec_leptons[k])->track_Et_in_cone(2),
04812                                        ((MyElectron*)vec_leptons[k])->track_Et_in_cone(3)
04813                                        );
04814             }
04815             if(type=="muon"){
04816                 t_cutopt_mu_isol->Fill( weight, 
04817                                         ((MyMuon*)vec_leptons[k])->track_Et_in_cone(0),
04818                                         ((MyMuon*)vec_leptons[k])->track_Et_in_cone(1),
04819                                         ((MyMuon*)vec_leptons[k])->track_Et_in_cone(2),
04820                                         ((MyMuon*)vec_leptons[k])->track_Et_in_cone(3),
04821                                         ((MyMuon*)vec_leptons[k])->track_Et_in_cone(4),
04822                                         ((MyMuon*)vec_leptons[k])->track_Et_in_cone(5),
04823                                         ((MyMuon*)vec_leptons[k])->track_Et_in_cone(6),
04824                                         ((MyMuon*)vec_leptons[k])->track_Et_in_cone(7)
04825                                         );
04826             }
04827         }
04828     }
04829 
04830     m_tools.clear_vector(vec_truth_leptons_isol);
04831 
04832 
04833     for (unsigned int k=0; k<vec_leptons.size(); k++) {
04834         
04835         MyParticle* tmp_truth_lepton_nonisol    = NULL; 
04836         
04837         tmp_truth_lepton_nonisol = m_tools.find_matching_particle( vec_leptons[k],
04838                                                                    vec_truth_leptons_nonisol, 0.1 );
04839         
04840         if(tmp_truth_lepton_nonisol!=NULL){
04841             if(type=="electron"){
04842                 t_cutopt_e_nonisol->Fill( weight, 
04843                                           ((MyElectron*)vec_leptons[k])->track_Et_in_cone(0),
04844                                           ((MyElectron*)vec_leptons[k])->track_Et_in_cone(1),
04845                                           ((MyElectron*)vec_leptons[k])->track_Et_in_cone(2),
04846                                           ((MyElectron*)vec_leptons[k])->track_Et_in_cone(3)
04847                                           );
04848             }
04849             if(type=="muon"){
04850                 t_cutopt_mu_nonisol->Fill( weight, 
04851                                            ((MyMuon*)vec_leptons[k])->track_Et_in_cone(0),
04852                                            ((MyMuon*)vec_leptons[k])->track_Et_in_cone(1),
04853                                            ((MyMuon*)vec_leptons[k])->track_Et_in_cone(2),
04854                                            ((MyMuon*)vec_leptons[k])->track_Et_in_cone(3),
04855                                            ((MyMuon*)vec_leptons[k])->track_Et_in_cone(4),
04856                                            ((MyMuon*)vec_leptons[k])->track_Et_in_cone(5),
04857                                            ((MyMuon*)vec_leptons[k])->track_Et_in_cone(6),
04858                                            ((MyMuon*)vec_leptons[k])->track_Et_in_cone(7)
04859                                            );
04860             }
04861         }
04862     }
04863 
04864     m_tools.clear_vector(vec_truth_leptons_nonisol);
04865     
04866     return;
04867  }
04868 
04869 
04870 //*****************************************************************************
04871 
04872 //:::::::::::::::::::::::::::::::::
04873 //:: METHOD fill_raw_aod_content ::
04874 //:::::::::::::::::::::::::::::::::
04875 
04876 void
04877 MyHtoWWAnalysis::fill_vertex_histos(const vector<MyVertex*> *vertices, 
04878                                     const vector<MyVertex*> *truth_vertices){
04879 
04880     // reconstruction //
04881     //const vector<MyVertex*> *vertices(event.primary_vertices());
04882     h_nb_vertices->Fill(vertices->size(), weight);
04883     
04884     int rec_vert_id(0);
04885     TVector3 sel_vert;
04886     
04887     //find vertex with max Et
04888     if (vertices->size()>0) {
04889         
04890         double Et_1((*vertices)[0]->Et());
04891         sel_vert = (*vertices)[0]->position();
04892         
04893         for (unsigned int k=1; k<vertices->size(); k++) {
04894             if (Et_1<(*vertices)[k]->Et()) {
04895                 Et_1 = (*vertices)[k]->Et();
04896                 sel_vert = (*vertices)[k]->position();
04897                 rec_vert_id = k;
04898             }
04899         }
04900 
04901         h_Et_selected_vertex->Fill(Et_1, weight);
04902         
04903         // find vertex with second max Et
04904         if (vertices->size()>1) {
04905             double Et_2(0.0);
04906             
04907             for (unsigned int k=0; k<vertices->size(); k++) {
04908                 if ((*vertices)[k]->Et()<Et_1 &&
04909                     (*vertices)[k]->Et()>Et_2) {
04910                     Et_2 = (*vertices)[k]->Et();
04911                 }
04912             }
04913             
04914             h_Et_v2_vs_Et_v1->Fill(Et_1, Et_2, weight);
04915         }
04916     }
04917     
04918     double min_delta(1.0e99);
04919     
04920     //find vertex closest to the prim vertex
04921     for (unsigned int k=0; k<vertices->size(); k++) {
04922     
04923         if ((*vertices)[k]->position()!=sel_vert) {
04924            
04925             TVector3 delta_vert((*vertices)[k]->position()-sel_vert);
04926         
04927             if (delta_vert.Mag()<min_delta) {
04928                 min_delta = delta_vert.Mag();
04929             }
04930         }
04931     }
04932     
04933     h_delta_vertices->Fill(min_delta, weight);
04934 
04935     //number of tracks at the prim vertex 
04936     h_rec_nb_tracks_from_vertex
04937         ->Fill((*vertices)[rec_vert_id]->numberOfTracks(), weight);
04938 
04939     // truth //
04940     //const vector<MyVertex*> *truth_vertices(event.truth_vertices());
04941     h_nb_truth_vertices->Fill(truth_vertices->size(), weight);
04942     
04943     int truth_vert_id(0);
04944     TVector3 sel_truth_vert;
04945 
04946     //find truth vertex with max Et
04947     if (truth_vertices->size()>0) {
04948 
04949         double Et_1((*truth_vertices)[0]->Et());
04950 
04951         sel_truth_vert=(*truth_vertices)[0]->position();
04952         
04953         for (unsigned int k=1; k<truth_vertices->size(); k++) {
04954             if (Et_1<(*truth_vertices)[k]->Et()) {
04955                 Et_1 = (*truth_vertices)[k]->Et();
04956                 sel_truth_vert=(*truth_vertices)[k]->position();
04957                 truth_vert_id = k;
04958             }
04959         }
04960                 
04961         h_Et_selected_truth_vertex->Fill(Et_1, weight);
04962         
04963         //find truth vertex with second max Et
04964         if (truth_vertices->size()>1) {
04965             double Et_2(0.0);
04966             for (unsigned int k=0; k<truth_vertices->size(); k++) {
04967                 if ((*truth_vertices)[k]->Et()<Et_1 &&
04968                     (*truth_vertices)[k]->Et()>Et_2) {
04969                     Et_2 = (*truth_vertices)[k]->Et();
04970                 }
04971             }
04972             
04973             h_truth_Et_v2_vs_Et_v1->Fill(Et_1, Et_2, weight);
04974         }
04975     }
04976 
04977     //distance reco-truth vertex
04978     h_delta_selected_vertices->Fill(sel_vert.z()-sel_truth_vert.z(), weight);
04979 
04980     //number of tracks at the truth vertex
04981     h_truth_nb_tracks_from_vertex
04982         ->Fill((*truth_vertices)[truth_vert_id]->numberOfTracks(), weight);
04983 
04984     // comparison of reconstruction and truth //
04985     h_vertex_ratio_number_of_tracks
04986         ->Fill((*vertices)[rec_vert_id]->numberOfTracks()/
04987                static_cast<double>((*truth_vertices)[truth_vert_id]->numberOfTracks()),
04988                weight);
04989 
04990     h_vertex_ratio_Et
04991         ->Fill((*vertices)[rec_vert_id]->Et()/(*truth_vertices)[truth_vert_id]->Et(),
04992                weight);
04993 
04994     // ntuple //
04995     t_vertex_ntuple->Fill( weight,
04996                            vertices->size(),
04997                            (*vertices)[rec_vert_id]->chi2(),
04998                            (*vertices)[rec_vert_id]->numberOfTracks(),
04999                            (*vertices)[rec_vert_id]->Et(),
05000                            (*vertices)[rec_vert_id]->position().x(),
05001                            (*vertices)[rec_vert_id]->position().y(),
05002                            (*vertices)[rec_vert_id]->position().z(),
05003                            truth_vertices->size(),
05004                            (*truth_vertices)[truth_vert_id]->numberOfTracks(),
05005                            (*truth_vertices)[truth_vert_id]->Et(),
05006                            (*truth_vertices)[truth_vert_id]->position().x(),
05007                            (*truth_vertices)[truth_vert_id]->position().y(),
05008                            (*truth_vertices)[truth_vert_id]->position().z());
05009 
05010 
05011 
05012 }
05013 
05014 //*****************************************************************************
05015 
05016 //:::::::::::::::::::::::::::::::::
05017 //:: METHOD fill_raw_aod_content ::
05018 //:::::::::::::::::::::::::::::::::
05019 
05020 void
05021 MyHtoWWAnalysis::fill_raw_aod_content_histos( vector<MyParticle*> v_e_reco_aod,
05022                                               vector<MyParticle*> v_mu_reco_aod,
05023                                               vector<MyParticle*> v_jet_reco_aod,
05024                                               vector<MyParticle*> v_e_truth_aod,
05025                                               vector<MyParticle*> v_mu_truth_aod,
05026                                               vector<MyParticle*> v_jet_truth_aod) {
05027  
05028     // electrons
05029     h_e_reco_aod_nb->Fill(v_e_reco_aod.size(), weight);
05030     for (unsigned int k=0; k<v_e_reco_aod.size(); k++) {
05031         h_e_reco_aod_pt->Fill( (v_e_reco_aod[k])->tlv().Pt() * invGeV,weight);
05032         h_e_reco_aod_eta->Fill((v_e_reco_aod[k])->tlv().Eta(),weight);
05033         h_e_reco_aod_phi->Fill((v_e_reco_aod[k])->tlv().Phi(),weight);
05034     }
05035     h_e_truth_aod_nb->Fill(v_e_truth_aod.size(), weight);
05036     for (unsigned int k=0; k<v_e_truth_aod.size(); k++) {
05037         h_e_truth_aod_pt->Fill( (v_e_truth_aod[k])->tlv().Pt() * invGeV,weight);
05038         h_e_truth_aod_eta->Fill((v_e_truth_aod[k])->tlv().Eta(),weight);
05039         h_e_truth_aod_phi->Fill((v_e_truth_aod[k])->tlv().Phi(),weight);
05040     }
05041 
05042     // muons
05043     h_mu_reco_aod_nb->Fill(v_mu_reco_aod.size(), weight);
05044     for (unsigned int k=0; k<v_mu_reco_aod.size(); k++) {
05045         h_mu_reco_aod_pt->Fill( (v_mu_reco_aod[k])->tlv().Pt() * invGeV,weight);
05046         h_mu_reco_aod_eta->Fill((v_mu_reco_aod[k])->tlv().Eta(),weight);
05047         h_mu_reco_aod_phi->Fill((v_mu_reco_aod[k])->tlv().Phi(),weight);
05048         h_mu_reco_aod_fitChi2->Fill(((MyMuon*)(v_mu_reco_aod[k]))->fitChi2(),weight);
05049         h_mu_reco_aod_fitChi2OverDoF->Fill(((MyMuon*)(v_mu_reco_aod[k]))->fitChi2OverDoF(),weight);
05050         h_mu_reco_aod_matchChi2->Fill(((MyMuon*)(v_mu_reco_aod[k]))->matchChi2(),weight);
05051         h_mu_reco_aod_matchChi2OverDoF->Fill(((MyMuon*)(v_mu_reco_aod[k]))->matchChi2OverDoF(),weight);
05052     }
05053     h_mu_truth_aod_nb->Fill(v_mu_truth_aod.size(), weight);
05054     for (unsigned int k=0; k<v_mu_truth_aod.size(); k++) {
05055         h_mu_truth_aod_pt->Fill( (v_mu_truth_aod[k])->tlv().Pt() * invGeV,weight);
05056         h_mu_truth_aod_eta->Fill((v_mu_truth_aod[k])->tlv().Eta(),weight);
05057         h_mu_truth_aod_phi->Fill((v_mu_truth_aod[k])->tlv().Phi(),weight);
05058     }
05059 
05060     
05061     // jets
05062     h_jet_reco_aod_nb->Fill(v_jet_reco_aod.size(), weight);
05063     for (unsigned int k=0; k<v_jet_reco_aod.size(); k++) {
05064         h_jet_reco_aod_pt->Fill( (v_jet_reco_aod[k])->tlv().Pt() * invGeV,weight);
05065         h_jet_reco_aod_eta->Fill((v_jet_reco_aod[k])->tlv().Eta(),weight);
05066         h_jet_reco_aod_phi->Fill((v_jet_reco_aod[k])->tlv().Phi(),weight);
05067     }
05068     h_jet_truth_aod_nb->Fill(v_jet_truth_aod.size(), weight);
05069     for (unsigned int k=0; k<v_jet_truth_aod.size(); k++) {
05070         h_jet_truth_aod_pt->Fill( (v_jet_truth_aod[k])->tlv().Pt() * invGeV,weight);
05071         h_jet_truth_aod_eta->Fill((v_jet_truth_aod[k])->tlv().Eta(),weight);
05072         h_jet_truth_aod_phi->Fill((v_jet_truth_aod[k])->tlv().Phi(),weight);
05073     }
05074 
05075     return;
05076   }
05077 
05078 //*****************************************************************************
05079 
05080 //:::::::::::::::::::::::::::::
05081 //:: METHOD get_tagjet_pairs ::
05082 //:::::::::::::::::::::::::::::
05083 
05084 vector<MyParticlePair>
05085 MyHtoWWAnalysis::get_tagjet_pairs(vector<MyVBFCandidate> vec_candidates){
05086 
05087     vector<MyParticlePair> vec_tagjet_pairs(0);
05088 
05089     for(unsigned int iCand=0; iCand<vec_candidates.size(); iCand++){
05090         
05091         bool bool_add_tagjet_pair = true;
05092         
05093         MyParticlePair tagjet_pair 
05094             = vec_candidates[iCand].get_tagjet_pair();
05095 
05096         MyParticle* jet1 = tagjet_pair.get_particle1();
05097         MyParticle* jet2 = tagjet_pair.get_particle2();
05098         
05099         for(unsigned int iJP=0; iJP<vec_tagjet_pairs.size(); iJP++){
05100             
05101             if( jet1->index() == vec_tagjet_pairs[iJP].get_particle1()->index() &&
05102                 jet2->index() == vec_tagjet_pairs[iJP].get_particle2()->index() ){
05103                 
05104                 bool_add_tagjet_pair = false;
05105                 break;
05106             }
05107         }
05108          
05109         if(bool_add_tagjet_pair){ 
05110             vec_tagjet_pairs.push_back( tagjet_pair );
05111         }
05112     
05113     }
05114 
05115     return vec_tagjet_pairs;
05116 
05117 }
05118 
05119 //*****************************************************************************
05120 
05121 //:::::::::::::::::::::::::::::
05122 //:: METHOD get_lepton_pairs ::
05123 //:::::::::::::::::::::::::::::
05124 
05125 vector<MyParticlePair>
05126 MyHtoWWAnalysis::get_lepton_pairs(vector<MyVBFCandidate> vec_candidates){
05127 
05128     vector<MyParticlePair> vec_lepton_pairs(0);
05129 
05130     for(unsigned int iCand=0; iCand<vec_candidates.size(); iCand++){
05131 
05132         bool bool_add_lepton_pair = true;
05133 
05134         MyParticlePair lepton_pair 
05135             = vec_candidates[iCand].get_lepton_pair();
05136      
05137         MyParticle* lepton1 =  lepton_pair.get_particle1();
05138         MyParticle* lepton2 =  lepton_pair.get_particle2();
05139      
05140         for(unsigned int iLP=0; iLP<vec_lepton_pairs.size(); iLP++){
05141          
05142             // if( lepton1->type()  == vec_lepton_pairs[iLP].get_particle1()->type()  &&
05143 //                 lepton2->type()  == vec_lepton_pairs[iLP].get_particle2()->type()  &&
05144 //                 lepton1->index() == vec_lepton_pairs[iLP].get_particle1()->index() &&
05145 //                 lepton2->index() == vec_lepton_pairs[iLP].get_particle2()->index() ){
05146              
05147             if( lepton1->pdgId() == vec_lepton_pairs[iLP].get_particle1()->pdgId() &&
05148                 lepton2->pdgId() == vec_lepton_pairs[iLP].get_particle2()->pdgId() &&
05149                 lepton1->index() == vec_lepton_pairs[iLP].get_particle1()->index() &&
05150                 lepton2->index() == vec_lepton_pairs[iLP].get_particle2()->index() ){
05151                 
05152                 bool_add_lepton_pair = false;
05153                 break;
05154             }
05155         }
05156      
05157         if(bool_add_lepton_pair){ 
05158             vec_lepton_pairs.push_back( lepton_pair );
05159         }
05160     }
05161 
05162     return vec_lepton_pairs;
05163        
05164   }
05165 
05166 //*****************************************************************************
05167 
05168 //::::::::::::::::::::::::
05169 //:: METHOD get_tagjets ::
05170 //::::::::::::::::::::::::
05171 
05172 vector<MyParticle*> 
05173 MyHtoWWAnalysis::get_tagjets(vector<MyParticlePair> vec_tagjet_pairs){
05174 
05175     vector<MyParticle*> vec_tagjets(0);
05176 
05177     for(unsigned int k=0; k<vec_tagjet_pairs.size(); k++){
05178         
05179         bool bool_add1 = true;
05180         bool bool_add2 = true;
05181 
05182         MyParticle* jet1 =  vec_tagjet_pairs[k].get_particle1();
05183         MyParticle* jet2 =  vec_tagjet_pairs[k].get_particle2();
05184 
05185         //cout << "jetsize: "<< vec_tagjets.size() << endl;
05186         
05187         for(unsigned int iJet=0; iJet<vec_tagjets.size(); iJet++){
05188           
05189             //cout << "iJet: "<< iJet << endl;
05190             if( jet1->index() == vec_tagjets[iJet]->index() ){
05191                 bool_add1 = false;
05192                 break;
05193             }
05194         }
05195         
05196         if(bool_add1) vec_tagjets.push_back(jet1);
05197         
05198         for(unsigned int iJet=0; iJet<vec_tagjets.size(); iJet++){
05199             
05200             if( jet2->index() == vec_tagjets[iJet]->index() ){
05201                 bool_add2 = false;
05202                 break;
05203             }
05204         }
05205 
05206         if(bool_add2) vec_tagjets.push_back(jet2);
05207         
05208     }
05209 
05210     return vec_tagjets;
05211 
05212 }
05213 
05214 //*****************************************************************************
05215 
05216 //::::::::::::::::::::::::
05217 //:: METHOD get_leptons ::
05218 //::::::::::::::::::::::::
05219 
05220 vector<MyParticle*> 
05221 MyHtoWWAnalysis::get_leptons(vector<MyParticlePair> vec_lepton_pairs){
05222 
05223     vector<MyParticle*> vec_leptons(0);
05224 
05225     for(unsigned int k=0; k<vec_lepton_pairs.size(); k++){
05226     
05227         bool bool_add1 = true;
05228         bool bool_add2 = true;
05229 
05230         MyParticle* lepton1 = vec_lepton_pairs[k].get_particle1();
05231         MyParticle* lepton2 = vec_lepton_pairs[k].get_particle2();
05232 
05233         for(unsigned int iLep=0; iLep<vec_leptons.size(); iLep++){
05234           
05235             if( lepton1->pdgId() == vec_leptons[iLep]->pdgId() &&
05236                 lepton1->index() == vec_leptons[iLep]->index() ){
05237                 
05238                 bool_add1 = false;
05239                 break;
05240             }
05241         }
05242 
05243         if(bool_add1) vec_leptons.push_back(lepton1);
05244 
05245         for(unsigned int iLep=0; iLep<vec_leptons.size(); iLep++){
05246           
05247             if( lepton2->pdgId() == vec_leptons[iLep]->pdgId() &&
05248                 lepton2->index() == vec_leptons[iLep]->index() ){
05249                 
05250                 bool_add2 = false;
05251                 break;
05252             }
05253         }
05254 
05255         if(bool_add2) vec_leptons.push_back(lepton2);
05256 
05257     }
05258 
05259     return vec_leptons;
05260 
05261 }
05262 
05263 //*****************************************************************************
05264 
05265 //::::::::::::::::::::::::::::::::
05266 //:: METHOD fill_all_ana_histos ::
05267 //::::::::::::::::::::::::::::::::
05268 
05269 void 
05270 MyHtoWWAnalysis::fill_all_ana_histos(int iCut, MyMissingEt missinget){
05271 
05272     // check if event passed the cut[iCut]
05273     if(!flag_evt_selected[iCut]){
05274         return;
05275     }
05276 
05277     //-------------------
05278     //-- Build Vectors --
05279     //-------------------
05280 
05281     vector<MyParticlePair> 
05282         vec_tagjet_pairs = get_tagjet_pairs(v_cut_candidates[iCut]);
05283     
05284     vector<MyParticlePair> 
05285         vec_lepton_pairs = get_lepton_pairs(v_cut_candidates[iCut]);
05286 
05287     vector<MyParticle*> vec_tagjets = get_tagjets(vec_tagjet_pairs);
05288     vector<MyParticle*> vec_leptons = get_leptons(vec_lepton_pairs);
05289     
05290     
05291     vector<MyParticle*> vec_electrons(0);
05292     vector<MyParticle*> vec_muons(0);
05293     
05294     for(unsigned int k=0; k<vec_leptons.size(); k++){
05295         
05296         if(TMath::Abs(vec_leptons[k]->pdgId()) == 11){
05297             vec_electrons.push_back(vec_leptons[k]);
05298         }
05299     }
05300     
05301     for(unsigned int k=0; k<vec_leptons.size(); k++){
05302         
05303         if(TMath::Abs(vec_leptons[k]->pdgId()) == 13){
05304             vec_muons.push_back(vec_leptons[k]);
05305         }
05306     }
05307     
05308 
05309     //Debug:
05310     
05311     /*//Jets
05312       cout << "Begin: ************************" << endl;
05313       cout << "nb_tagjet_pairs: " << vec_tagjet_pairs.size() << endl;
05314       for(unsigned int k=0; k<vec_tagjet_pairs.size(); k++){
05315       
05316       MyParticle* jet1 =  vec_tagjet_pairs[k].get_particle1();
05317       MyParticle* jet2 =  vec_tagjet_pairs[k].get_particle2();
05318       
05319       cout << "jet1: " << jet1->type() << ", " << jet1->index()
05320       << "; jet2: " << jet2->type() << ", " << jet2->index()
05321       << endl;
05322       }
05323       
05324       cout << "nb_tagjets: " << vec_tagjets.size() << endl;
05325       for(unsigned int k=0; k<vec_tagjets.size(); k++){
05326       
05327       cout << "jet: " << vec_tagjets[k]->type() << ", " 
05328       << vec_tagjets[k]->index()
05329       << endl;
05330       }
05331       cout << "End:   ************************" << endl;
05332     */
05333 
05334     /*//Leptons
05335       cout << "Begin: ************************" << endl;
05336       cout << "nb_lepton_pairs: " << vec_lepton_pairs.size() << endl;
05337       for(unsigned int k=0; k<vec_lepton_pairs.size(); k++){
05338       
05339       MyParticle* lepton1 =  vec_lepton_pairs[k].get_particle1();
05340       MyParticle* lepton2 =  vec_lepton_pairs[k].get_particle2();
05341       
05342       cout << "lepton1: " << lepton1->type() << ", " << lepton1->index() << ", " << lepton1->pdgId()
05343       << "; lepton2: " << lepton2->type() << ", " << lepton2->index() << ", " << lepton2->pdgId()
05344       << endl;
05345       }
05346       
05347       cout << "nb_leptons: " << vec_leptons.size() << endl;
05348       for(unsigned int k=0; k<vec_leptons.size(); k++){
05349       
05350       cout << "lepton: " << vec_leptons[k]->type() << ", " 
05351       << vec_leptons[k]->index() << ", " << vec_leptons[k]->pdgId()
05352       << endl;
05353       }
05354       cout << "End:   ************************" << endl;
05355     */
05356 
05357 
05358     //---------------------
05359     //-- Fill Histograms --
05360     //---------------------
05361 
05362     //all central jet histos
05363 
05364     (v_h_centraljet_all_nb[iCut])->Fill(v_centraljet_ana.size(),weight);
05365     
05366     for (unsigned int k=0; k<v_centraljet_ana.size(); k++){
05367         (v_h_centraljet_all_pt[iCut])->Fill((v_centraljet_ana[k])->tlv().Pt()*invGeV,weight);
05368         (v_h_centraljet_all_eta[iCut])->Fill((v_centraljet_ana[k])->tlv().Eta(),weight);
05369         (v_h_centraljet_all_phi[iCut])->Fill((v_centraljet_ana[k])->tlv().Phi(),weight);
05370     }
05371 
05372     // general histos
05373 
05374     h_cut_events->Fill(iCut,weight);
05375     v_h_candidates_nb[iCut]->Fill( v_cut_candidates[iCut].size(),weight );
05376 
05377     for(unsigned int iCand=0; iCand<v_cut_candidates[iCut].size(); iCand++){
05378         h_cut_candidates->Fill(iCut,weight);
05379     }
05380 
05381     
05382     // jet pair histos 
05383 
05384     (v_h_2j_ana_nb[iCut])->Fill(vec_tagjet_pairs.size(),weight);
05385     
05386     for (unsigned int k=0; k<vec_tagjet_pairs.size(); k++){
05387         
05388         (v_h_2j_ana_eta[iCut])  ->Fill((vec_tagjet_pairs[k]).tlv().Eta(),weight);
05389         (v_h_2j_ana_phi[iCut])  ->Fill((vec_tagjet_pairs[k]).tlv().Phi(),weight);
05390         (v_h_2j_ana_pt[iCut])   ->Fill((vec_tagjet_pairs[k]).tlv().Pt()*invGeV,weight);
05391         (v_h_2j_ana_deta[iCut]) ->Fill((vec_tagjet_pairs[k]).AbsDeltaEta(),weight);
05392         (v_h_2j_ana_dphi[iCut]) ->Fill(TMath::Abs((vec_tagjet_pairs[k]).DeltaPhi()),weight);
05393         (v_h_2j_ana_dpt[iCut])  ->Fill(TMath::Abs((vec_tagjet_pairs[k]).get_particle1()->tlv().Pt()
05394                                                 -(vec_tagjet_pairs[k]).get_particle2()->tlv().Pt())*invGeV,weight);
05395         (v_h_2j_ana_dr[iCut])   ->Fill((vec_tagjet_pairs[k]).DeltaR(),weight);
05396         (v_h_2j_ana_m[iCut])    ->Fill((vec_tagjet_pairs[k]).M()*invGeV,weight);
05397     }
05398     
05399 
05400     // lepton pair histos
05401     
05402     (v_h_2l_ana_nb[iCut])->Fill(vec_lepton_pairs.size(),weight);
05403     
05404 
05405     for (unsigned int k=0; k<vec_lepton_pairs.size(); k++){
05406         
05407         (v_h_2l_ana_eta[iCut])  ->Fill((vec_lepton_pairs[k]).tlv().Eta(),weight);
05408         (v_h_2l_ana_phi[iCut])  ->Fill((vec_lepton_pairs[k]).tlv().Phi(),weight);
05409         (v_h_2l_ana_pt[iCut])   ->Fill((vec_lepton_pairs[k]).tlv().Pt()*invGeV,weight);
05410         (v_h_2l_ana_deta[iCut]) ->Fill((vec_lepton_pairs[k]).AbsDeltaEta(),weight);
05411         (v_h_2l_ana_dphi[iCut]) ->Fill(TMath::Abs((vec_lepton_pairs[k]).DeltaPhi()),weight);
05412         (v_h_2l_ana_dpt[iCut])  ->Fill(TMath::Abs((vec_lepton_pairs[k]).get_particle1()->tlv().Pt()
05413                                              -(vec_lepton_pairs[k]).get_particle2()->tlv().Pt())*invGeV,weight);
05414         (v_h_2l_ana_dr[iCut])   ->Fill((vec_lepton_pairs[k]).DeltaR(),weight);
05415         (v_h_2l_ana_m[iCut])    ->Fill((vec_lepton_pairs[k]).M()*invGeV,weight);
05416         
05417         (v_h_2l_ana_costheta[iCut])->Fill( (vec_lepton_pairs[k]).tlv().CosTheta(),weight);
05418     }
05419 
05420 
05421     // jet histos
05422 
05423     (v_h_jet_ana_nb[iCut])->Fill(vec_tagjets.size(),weight);
05424     
05425     for (unsigned int k=0; k<vec_tagjets.size(); k++){
05426         (v_h_jet_ana_pt[iCut])->Fill((vec_tagjets[k])->tlv().Pt()*invGeV,weight);
05427         (v_h_jet_ana_eta[iCut])->Fill((vec_tagjets[k])->tlv().Eta(),weight);
05428         (v_h_jet_ana_phi[iCut])->Fill((vec_tagjets[k])->tlv().Phi(),weight);
05429         (v_h_jet_ana_bweight[iCut])->Fill(((MyParticleJet*)(vec_tagjets[k]))->b_tag_weight(),weight);
05430     }
05431 
05432 
05433     // lepton histos 
05434 
05435     (v_h_lepton_ana_nb[iCut])->Fill(vec_leptons.size(),weight);
05436         
05437     for (unsigned int k=0; k<vec_leptons.size(); k++){
05438         (v_h_lepton_ana_pt[iCut])->Fill((vec_leptons[k])->tlv().Pt()*invGeV,weight);
05439         (v_h_lepton_ana_eta[iCut])->Fill((vec_leptons[k])->tlv().Eta(),weight);
05440         (v_h_lepton_ana_phi[iCut])->Fill((vec_leptons[k])->tlv().Phi(),weight);
05441     }
05442 
05443 
05444     // electron histos
05445 
05446     (v_h_e_ana_nb[iCut])->Fill(vec_electrons.size(),weight);
05447         
05448     for (unsigned int k=0; k<vec_electrons.size(); k++){
05449         (v_h_e_ana_pt[iCut])->Fill((vec_electrons[k])->tlv().Pt()*invGeV,weight);
05450         (v_h_e_ana_eta[iCut])->Fill((vec_electrons[k])->tlv().Eta(),weight);
05451         (v_h_e_ana_phi[iCut])->Fill((vec_electrons[k])->tlv().Phi(),weight);
05452     }
05453         
05454 
05455     // muon histos
05456     
05457     (v_h_mu_ana_nb[iCut])->Fill(vec_muons.size(),weight);
05458         
05459     for (unsigned int k=0; k<vec_muons.size(); k++){
05460         (v_h_mu_ana_pt[iCut])->Fill((vec_muons[k])->tlv().Pt()*invGeV,weight);
05461         (v_h_mu_ana_eta[iCut])->Fill((vec_muons[k])->tlv().Eta(),weight);
05462         (v_h_mu_ana_phi[iCut])->Fill((vec_muons[k])->tlv().Phi(),weight);
05463     
05464         (v_h_mu_ana_fitChi2[iCut])->Fill(((MyMuon*)(vec_muons[k]))->fitChi2(),weight);
05465         (v_h_mu_ana_fitChi2OverDoF[iCut])->Fill(((MyMuon*)(vec_muons[k]))->fitChi2OverDoF(),weight);
05466         (v_h_mu_ana_matchChi2[iCut])->Fill(((MyMuon*)(vec_muons[k]))->matchChi2(),weight);
05467         (v_h_mu_ana_matchChi2OverDoF[iCut])->Fill(((MyMuon*)(vec_muons[k]))->matchChi2OverDoF(),weight);
05468     
05469     }
05470         
05471     
05472     // candidate histos
05473     //if( v_cut_candidates[iCut].size() < 1 ) return;
05474 
05475     //MyMissingEt missinget = v_cut_candidates[iCut][0].get_missinget();
05476 
05477     
05478     TLorentzVector met_tlv;
05479     met_tlv = missinget.tlv(); 
05480     
05481     
05482 
05483 
05484     for(unsigned int iCand=0; iCand<v_cut_candidates[iCut].size(); iCand++){
05485      
05486         // total pt
05487    
05488         MyParticlePair tagjet_pair 
05489             = v_cut_candidates[iCut][iCand].get_tagjet_pair();
05490 
05491         MyParticlePair lepton_pair 
05492             = v_cut_candidates[iCut][iCand].get_lepton_pair();
05493         
05494         TLorentzVector jet1 = tagjet_pair.get_particle1()->tlv();
05495         TLorentzVector jet2 = tagjet_pair.get_particle2()->tlv();
05496         
05497         TLorentzVector lepton1 = lepton_pair.get_particle1()->tlv();
05498         TLorentzVector lepton2 = lepton_pair.get_particle2()->tlv();
05499 
05500         double pt_x = missinget.met_x() 
05501             + jet1.Px() + jet2.Px() + lepton1.Px() + lepton2.Px();
05502          
05503         double pt_y = missinget.met_y() 
05504             + jet1.Py() + jet2.Py() + lepton1.Py() + lepton2.Py();
05505 
05506 
05507         double pt_tot = TMath::Sqrt( pt_x*pt_x + pt_y*pt_y );
05508 
05509         (v_h_ana_pttot[iCut])->Fill( pt_tot*invGeV,weight );
05510         
05511 
05512         // transverse mass 
05513         
05514         double pt_miss   = missinget.met();
05515 
05516         // -> mt_llnu 
05517 
05518         double pt_lepton = lepton_pair.tlv().Pt();
05519         
05520         double dphi      = met_tlv.DeltaPhi( lepton_pair.tlv() );
05521 
05522         double mt_llnu = TMath::Sqrt(2*pt_lepton*pt_miss
05523                                              * (1-(TMath::Cos(dphi))) );
05524         
05525         (v_h_ana_mt_llnu[iCut])->Fill( mt_llnu*invGeV,weight );
05526 
05527         
05528         // -> mt (only for m_H < 2m_W) 
05529 
05530         double Et_ll   = lepton_pair.tlv().Et();
05531         double Et_nunu = TMath::Sqrt( pow(pt_miss,2) + lepton_pair.tlv().M2() );
05532    
05533         TVector3 pt_sum_tlv = lepton_pair.tlv().Vect() + met_tlv.Vect();
05534 
05535         double mt = TMath::Sqrt( pow(Et_ll+Et_nunu,2) - pt_sum_tlv.Mag2() ); 
05536 
05537         (v_h_ana_mt[iCut])->Fill( mt*invGeV,weight );
05538 
05539 
05540         // tau veto
05541         MyCollinearApproximation 
05542         collapp( v_cut_candidates[iCut][iCand].get_lepton_pair().get_particle1(),
05543                  v_cut_candidates[iCut][iCand].get_lepton_pair().get_particle2(),
05544                  missinget.tlv() );
05545                  //v_cut_candidates[iCut][iCand].get_missinget() );
05546 
05547         (v_h_2l_x_tau1[iCut])->Fill(collapp.get_x1(),weight);
05548         (v_h_2l_x_tau2[iCut])->Fill(collapp.get_x2(),weight);
05549         (v_h_2l_x_tau12[iCut])->Fill(collapp.get_x1(),weight);
05550         (v_h_2l_x_tau12[iCut])->Fill(collapp.get_x2(),weight);
05551         (v_h_2l_x_tau1vs2[iCut])->Fill(collapp.get_x1(),collapp.get_x2(),weight);
05552 
05553         double m_tautau = collapp.get_M_comp_part();
05554         double m_Z = 91.1876*GeV;
05555         
05556         double dm = TMath::Abs(m_tautau - m_Z);
05557 
05558         (v_h_2l_tautau_Z_dm[iCut])->Fill(dm*invGeV,weight);
05559         
05560     }
05561 
05562 
05563     // met histos
05564     (v_h_etmiss_ana[iCut])->Fill(missinget.met()*invGeV,weight);
05565     (v_h_etmiss_x_ana[iCut])->Fill(missinget.met_x()*invGeV,weight);
05566     (v_h_etmiss_y_ana[iCut])->Fill(missinget.met_y()*invGeV,weight);
05567 
05568     (v_h_etmiss_ana_truth[iCut])->Fill(truth_missinget.met()*invGeV,weight);
05569     (v_h_etmiss_ana_reco_truth_dpt[iCut])->Fill((missinget.met() - truth_missinget.met())*invGeV,weight);
05570     (v_h_etmiss_ana_reco_truth_dx[iCut])->Fill((missinget.met_x() - truth_missinget.met_x())*invGeV,weight);
05571     (v_h_etmiss_ana_reco_truth_dy[iCut])->Fill((missinget.met_y() - truth_missinget.met_y())*invGeV,weight);
05572  
05573 
05574     //h_etmiss_reco_truth_dptvscut->Fill(i,(missinget.missinget_AOD_final() - missinget.truth_missinget_NonInt())*invGeV,weight);
05575     
05576     return; 
05577   }
05578 
05579 
05580 
05581 //*****************************************************************************
05582 
05583 //:::::::::::::::::::::::::
05584 //:: METHOD get_cutvalue ::
05585 //:::::::::::::::::::::::::
05586 
05587 Double_t
05588 MyHtoWWAnalysis::get_cutvalue(TString variable, MyTextFileReader *txtfile_reader){
05589 
05590     //only allow cuts which are stored in the map
05591 
05592     Double_t value = txtfile_reader->get_cutvalue(variable);
05593 
05594     if(m_cutstring!=""){
05595         
05596         TString cutstring = m_cutstring.ReplaceAll(" ","");
05597         TObjArray* cuts_array = cutstring.Tokenize(",");
05598 
05599         for(int k=0; k<cuts_array->GetEntries(); k++){
05600 
05601             TString string = ((TObjString*)cuts_array->At(k))->GetString(); 
05602             
05603             if(string.CountChar('=')!=1){
05604                 cout << "Warning: wrong cutstring given \""
05605                      << string << "\"" <<  endl;
05606                 continue;
05607             }
05608 
05609             TObjArray* cutvalue_array = string.Tokenize("=");
05610             
05611             TString cut_variable  = ((TObjString*)cutvalue_array->First())->GetString();
05612 
05613             Double_t dummy = txtfile_reader->get_cutvalue(cut_variable); dummy = dummy +1;
05614             if( variable == cut_variable){
05615                 
05616                 value = ((TObjString*)cutvalue_array->Last())->GetString().Atof();
05617                 
05618             }
05619         }
05620     }
05621     
05622     //if(value==-999.){
05623     //  value = txtfile_reader->get_cutvalue(variable);
05624     //}
05625     
05626     return value;
05627 
05628   }
05629 
05630 
05631 //*****************************************************************************
05632 
05633 //::::::::::::::::::::::::::::::
05634 //:: METHOD fill_final_histos ::
05635 //::::::::::::::::::::::::::::::
05636 
05637 // void 
05638 // MyHtoWWAnalysis::fill_final_histos(MyVBFCandidate candidate){
05639        
05640 //     TLorentzVector met_tlv;
05641 //     met_tlv.SetPxPyPzE( missinget_ana.missinget_x_AOD_final(),
05642 //                         missinget_ana.missinget_y_AOD_final(),
05643 //                         0.0,
05644 //                         missinget_ana.missinget_AOD_final());
05645     
05646 //     double pt_miss   = missinget_ana.missinget_AOD_final();
05647 //     //double pt_lepton = (v_2l_ana[0]).tlv().Pt();
05648 
05649 //     MyParticlePair lepton_pair = candidate.get_lepton_pair();
05650 
05651 //     double Et_ll   = lepton_pair.tlv().Et();
05652 //     double Et_nunu = TMath::Sqrt( pow(pt_miss,2) + lepton_pair.tlv().M2() );
05653         
05654 //     TVector3 pt_sum_tlv = lepton_pair.tlv().Vect() + met_tlv.Vect();
05655         
05656 //     double m_transverse = TMath::Sqrt( pow(Et_ll+Et_nunu,2) - pt_sum_tlv.Mag2() ); 
05657 
05658 //     h_higgs_mass->Fill( m_transverse*invGeV,weight );
05659    
05660 
05661 //     return;
05662 
05663 //   }
05664 
05665 //*****************************************************************************
05666 
05667 
05668   // 2D tranverse mass
05669 
05670    //-----//
05671     
05672 //     TVector2 met2( missinget_ana.missinget_x_AOD_final(),
05673 //                    missinget_ana.missinget_y_AOD_final()
05674 //                    );
05675 
05676 //     //double pt_lepton2 = ll_tlv.EtaPhiVector().Mod();
05677 //     double dphi2      = met2.DeltaPhi( ll_tlv.EtaPhiVector() );
05678     
05679 //     double transverse_mass2 = TMath::Sqrt(2*pt_lepton*pt_miss
05680 //                                          * (1-(TMath::Cos(dphi2))) );
05681     
05682 //     h_lmissinget_ana_mt2->Fill(transverse_mass2*invGeV,weight);
05683 
05684 
05685 
05686 //*****************************************************************************
05687   //Olivers:
05688 
05689 //------------------------------------------------------
05690     // TRACK-JET DISTRIBUTIONS BEFORE ANY EVENT SELECTION --
05691     //------------------------------------------------------
05692     
05693   //   vector<MyParticle*> track_jets(*event.track_jets());
05694 //     vector<MyParticle*> reco_jets(event.reco_jets());
05695 //     vector<MyParticle*> truth_jets(event.truth_jets());
05696 //     vector<MyParticle*> truth_track_jets(*event.truth_track_jets());
05697 
05698 //     reco_jets = m_tools.pt_eta_cut(reco_jets, 20.0*GeV, -1, 0.0, 5.0);
05699 //     truth_jets = m_tools.pt_eta_cut(truth_jets, 20.0*GeV, -1, 0.0, 5.0);
05700 //     track_jets = m_tools.pt_eta_cut(track_jets, 20.0*GeV, -1, 0.0, 5.0);
05701 //     truth_track_jets = m_tools.pt_eta_cut(truth_track_jets, 20.0*GeV, -1, 0.0, 5.0);
05702 
05703 //     // no removal of overlaps with electrons and muons //
05704 //     h_trj_nor_nb_jets->Fill(track_jets.size(), weight);
05705 //     h_stdj_nor_nb_jets->Fill(reco_jets.size(), weight);
05706     
05707 //     for (unsigned int k=0; k<track_jets.size(); k++) {
05708     
05709 //         h_trj_nor_eta->Fill(track_jets[k]->tlv().Eta(), weight);
05710 //         h_trj_nor_phi->Fill(track_jets[k]->tlv().Phi(), weight);
05711 //         h_trj_nor_Et->Fill(track_jets[k]->tlv().Et(), weight);
05712 //         h_trj_nor_Et_vs_eta->Fill(track_jets[k]->tlv().Eta(),
05713 //                                   track_jets[k]->tlv().Et(), weight);
05714 //     }
05715 
05716 //     for (unsigned int k=0; k<reco_jets.size(); k++) {
05717 //         h_stdj_nor_eta->Fill(reco_jets[k]->tlv().Eta(), weight);
05718 //         h_stdj_nor_phi->Fill(reco_jets[k]->tlv().Phi(), weight);
05719 //         h_stdj_nor_Et->Fill(reco_jets[k]->tlv().Et(),  weight);
05720 //     }
05721 
05722     //-> truth //
05723     // h_truth_trj_nor_nb_jets->Fill(truth_track_jets.size(), weight);
05724 //     for (unsigned int k=0; k<truth_track_jets.size(); k++) {
05725 //         h_truth_trj_nor_eta->Fill(truth_track_jets[k]->tlv().Eta(), weight);
05726 //         h_truth_trj_nor_phi->Fill(truth_track_jets[k]->tlv().Phi(), weight);
05727 //         h_truth_trj_nor_Et->Fill(truth_track_jets[k]->tlv().Et(),   weight);
05728 //         h_truth_trj_nor_Et_vs_eta
05729 //             ->Fill( truth_track_jets[k]->tlv().Eta(),
05730 //                     truth_track_jets[k]->tlv().Et(), weight);
05731 //     }
05732 
05733 //     // ntuples //
05734 //     double dR, Et, eta, phi, truth_Et, truth_eta, truth_phi;
05735 //     for (unsigned int k=0; k<track_jets.size(); k++) {
05736         
05737 //         dR = -1.0e99;
05738 //         Et = track_jets[k]->tlv().Et();
05739 //         eta = track_jets[k]->tlv().Eta();
05740 //         phi = track_jets[k]->tlv().Phi();
05741         
05742 //         //find truth_track_jet with the min dR wrt to the track_jet
05743 //         for (unsigned int l=0; l<truth_track_jets.size(); l++) {
05744         
05745 //             if (track_jets[k]
05746 //                 ->tlv().DeltaR(truth_track_jets[l]->tlv())<TMath::Abs(dR)) {
05747                 
05748 //                 dR = track_jets[k]->tlv().DeltaR(truth_track_jets[l]->tlv());
05749 //                 truth_Et = truth_track_jets[l]->tlv().Et();
05750 //                 truth_eta = truth_track_jets[l]->tlv().Eta();
05751 //                 truth_phi = truth_track_jets[l]->tlv().Phi();
05752 //             }
05753 //         }
05754        
05755 //         t_trj_ntuple->Fill(weight,
05756 //                            vertex->numberOfTracks(),
05757 //                            truth_vertex->numberOfTracks(),
05758 //                            track_jets.size(), truth_track_jets.size(),
05759 //                            Et, eta, phi, dR,
05760 //                            truth_Et, truth_eta, truth_phi);
05761 //    }
05762 
05763 //     //find track jet with the minimum Et
05764 //     double Et_min(1.0e99);
05765 //     for (unsigned int l=0; l<track_jets.size(); l++) {
05766         
05767 //         if (track_jets[l]->tlv().Et()<Et_min) {
05768 //             Et_min = track_jets[l]->tlv().Et();
05769 //         }
05770 //     }
05771 //     t_trj_ntuple_2->Fill(weight, Et_min, track_jets.size());
05772         
05773 //     for (unsigned int l=0; l<truth_track_jets.size(); l++) {
05774     
05775 //         dR = -1.0e99;
05776 //         truth_Et = truth_track_jets[l]->tlv().Et();
05777 //         truth_eta = truth_track_jets[l]->tlv().Eta();
05778 //         truth_phi = truth_track_jets[l]->tlv().Phi();
05779         
05780 //         for (unsigned int k=0; k<track_jets.size(); k++) {
05781         
05782 //             if (track_jets[k]
05783 //                 ->tlv().DeltaR(truth_track_jets[l]->tlv())<fabs(dR)) {
05784                 
05785 //                 dR = track_jets[k]
05786 //                     ->tlv().DeltaR(truth_track_jets[l]->tlv());
05787 //                 Et = track_jets[k]->tlv().Et();
05788 //                 eta = track_jets[k]->tlv().Eta();
05789 //                 phi = track_jets[k]->tlv().Phi();
05790 //             }
05791 //         }
05792 
05793 //         t_truth_trj_ntuple->Fill(weight,
05794 //                                  vertex->numberOfTracks(),
05795 //                                  truth_vertex->numberOfTracks(),
05796 //                                  track_jets.size(), truth_track_jets.size(),
05797 //                                  Et, eta, phi, dR,
05798 //                                  truth_Et, truth_eta, truth_phi);
05799     
05800 //    }
05801 
05802     // removal of overlaps with electrons and muons //
05803  //    const vector<MyParticle*> electrons(pu_event.reco_electrons());
05804 //     const vector<MyParticle*> muons(pu_event.reco_muons());
05805     
05806 //     double match_window(0.4);
05807      
05808 //     vector<MyParticle*> track_jets_orm_e(0);
05809 //     vector<MyParticle*> track_jets_orm(0);
05810 //     track_jets_orm_e  =  m_tools.remove_overlap(track_jets,electrons,match_window);
05811 //     track_jets_orm    =  m_tools.remove_overlap(track_jets_orm_e,muons,match_window);
05812  
05813 //     int nb_e_overlaps  = track_jets.size() - track_jets_orm_e.size();
05814 //     int nb_mu_overlaps = track_jets_orm_e.size() - track_jets_orm.size();
05815 
05816 //     for (unsigned int k=0; k<track_jets_orm.size(); k++) {
05817            
05818 //         h_trj_or_Et->Fill(track_jets_orm[k]->tlv().Et(), weight);
05819 //         h_trj_or_Et_vs_eta->Fill(track_jets_orm[k]->tlv().Eta(),
05820 //                                  track_jets_orm[k]->tlv().Et(), weight);
05821 //         h_trj_or_eta->Fill(track_jets_orm[k]->tlv().Eta(), weight);
05822 //         h_trj_or_phi->Fill(track_jets_orm[k]->tlv().Phi(), weight);     
05823 //     }
05824 
05825 //     h_trj_or_nb_jets->Fill(track_jets_orm.size(), weight);
05826 //     h_trj_nb_electron_overlaps->Fill(nb_e_overlaps, weight);
05827 //     h_trj_nb_muon_overlaps->Fill(nb_mu_overlaps, weight);
05828 
05829 //     const vector<MyParticle *> electrons_orig = event.reco_electrons();
05830 //     const vector<MyParticle *> muons_orig = event.reco_muons();
05831 //     nb_e_overlaps = 0;
05832 //     nb_mu_overlaps = 0;
05833 
05834 //     vector<MyParticle*> reco_jets_orm_e(0);
05835 //     vector<MyParticle*> reco_jets_orm(0);
05836 //     reco_jets_orm_e  =  m_tools.remove_overlap(reco_jets,electrons_orig,match_window);
05837 //     reco_jets_orm    =  m_tools.remove_overlap(reco_jets_orm_e,muons_orig,match_window);
05838 
05839 //     for (unsigned int k=0; k<reco_jets_orm.size(); k++) {
05840 //         h_stdj_or_eta->Fill((reco_jets_orm)[k]->tlv().Eta(), weight);
05841 //         h_stdj_or_phi->Fill((reco_jets_orm)[k]->tlv().Phi(), weight);
05842 //         h_stdj_or_Et->Fill((reco_jets_orm)[k]->tlv().Et(), weight);
05843 //     }
05844 
05845 //     nb_e_overlaps  = reco_jets.size() - reco_jets_orm_e.size();
05846 //     nb_mu_overlaps = reco_jets_orm_e.size() - reco_jets_orm.size();
05847     
05848 //     h_stdj_or_nb_jets->Fill(reco_jets_orm.size(), weight);
05849 //     h_stdj_nb_electron_overlaps->Fill(nb_e_overlaps, weight);
05850 //     h_stdj_nb_muon_overlaps->Fill(nb_mu_overlaps, weight);
05851 
05852 //     // ntuples //
05853 //     int nbstdj(0);
05854 
05855 //     //       for (unsigned int k=0; k<21; k++) {
05856 //     Et_min = 1.0e99;
05857 //     for (unsigned int l=0; l<reco_jets.size(); l++) {
05858 //         if ((reco_jets)[l]->tlv().Et()<Et_min) {
05859 //             Et_min = (reco_jets)[l]->tlv().Et();
05860 //         }
05861 //     }
05862 //     for (unsigned int l=0; l<reco_jets.size(); l++) {
05863 //         if (fabs((reco_jets)[l]->tlv().Eta())<2.5
05864 //             && (reco_jets)[l]->tlv().Et()>Et_min) {
05865 //             nbstdj++;
05866 //         }
05867 //     }
05868 //     t_std_ntuple_2->Fill(weight, Et_min, nbstdj);
05869 //     //       }
05870 
05871  //    // matching of track with truth and standard jets //
05872 //     unsigned int nb_trj_jets_matched(0);
05873 //     match_window = 0.4;
05874     
05875 //     for (unsigned int k=0; k<track_jets.size(); k++) {
05876         
05877 //         MyParticle* tmp_truth_jet = NULL;
05878 //         tmp_truth_jet = m_tools.find_matching_particle( track_jets[k],
05879 //                                                         truth_jets, match_window );
05880         
05881 //         if(tmp_truth_jet!=NULL){
05882 //             nb_trj_jets_matched++;
05883 //             h_trj_truth_jet_match_vs_eta
05884 //                 ->Fill(track_jets[k]->tlv().Eta(), 1.0, weight);  
05885 //         }
05886 //         else{
05887 //             h_trj_truth_jet_match_vs_eta
05888 //                 ->Fill(track_jets[k]->tlv().Eta(), 0.0, weight);   
05889 //         }
05890 //     }
05891 
05892    
05893 //     h_trj_truth_jet_match->Fill(nb_trj_jets_matched/(double)(track_jets.size()), weight);
05894 
05895 //     nb_trj_jets_matched = 0;
05896 //     for (unsigned int k=0; k<track_jets.size(); k++) {
05897         
05898 //         MyParticle* tmp_reco_jet = NULL;
05899 //         tmp_reco_jet = m_tools.find_matching_particle( track_jets[k],
05900 //                                                        reco_jets, match_window );
05901         
05902 //         if(tmp_reco_jet!=NULL){
05903 //             nb_trj_jets_matched++;
05904 //             h_trj_std_jet_match_vs_eta
05905 //                 ->Fill(track_jets[k]->tlv().Eta(), 1.0, weight);  
05906 //         }
05907 //         else{
05908 //             h_trj_std_jet_match_vs_eta
05909 //                 ->Fill(track_jets[k]->tlv().Eta(), 0.0, weight);   
05910 //         }
05911 //     }
05912     
05913 //     h_trj_std_jet_match->Fill(nb_trj_jets_matched/(double)(track_jets.size()), weight);
05914     
05915   // matching of track with truth and standard jets //
05916     //    unsigned int nb_trj_jets_matched(0);
05917     //double match_window = 0.4;
05918     
05919     // for (unsigned int k=0; k<v_track_jet_reco_presel.size(); k++) {
05920         
05921 //         MyParticle* tmp_truth_jet = NULL;
05922 //         tmp_truth_jet = m_tools.find_matching_particle( v_track_jet_reco_presel[k],
05923 //                                                         v_track_jet_truth_presel, match_window );
05924         
05925 //         if(tmp_truth_jet!=NULL){
05926             
05927 //             //nb_trj_jets_matched++;
05928 //             h_trj_truth_jet_match->Fill(1.,weight);
05929 //             h_trj_truth_jet_match_vs_eta
05930 //                 ->Fill(v_track_jet_reco_presel[k]->tlv().Eta(), 1.0, weight); 
05931 //             h_trj_truth_jet_match_vs_pt
05932 //                 ->Fill(v_track_jet_reco_presel[k]->tlv().Pt(), 1.0, weight); 
05933 //         }
05934 //         else{
05935 //             h_trj_truth_jet_match->Fill(0.,weight);
05936 //             h_trj_truth_jet_match_vs_eta
05937 //                 ->Fill(v_track_jet_reco_presel[k]->tlv().Eta(), 0.0, weight);   
05938 //             h_trj_truth_jet_match_vs_pt
05939 //                 ->Fill(v_track_jet_reco_presel[k]->tlv().Pt(), 0.0, weight);  
05940 //         }
05941 //     }
05942 //     m_tools.clear_vector(v_track_jet_truth_presel);
05943    
05944     //h_trj_truth_jet_match->Fill(nb_trj_jets_matched/(double)(v_track_jet_reco_presel.size()), weight);
05945     
05946 
05947 
05948 
05949 
05950 
05951    //  nb_trj_jets_matched = 0;
05952 //     for (unsigned int k=0; k<v_track_jet_reco_presel.size(); k++) {
05953         
05954 //         MyParticle* tmp_reco_jet = NULL;
05955 //         tmp_reco_jet = m_tools.find_matching_particle( v_track_jet_reco_presel[k],
05956 //                                                        v_jet_reco_central, 
05957 //                                                        //v_jet_reco_presel,-1,-1,-1,2.5),
05958 //                                                        match_window );
05959         
05960 //         if(tmp_reco_jet!=NULL){
05961             
05962 //             //nb_trj_jets_matched++;
05963 //             h_trj_std_jet_match->Fill(1.,weight);
05964             
05965 //             h_trj_std_jet_match_vs_eta
05966 //                 ->Fill(v_track_jet_reco_presel[k]->tlv().Eta(), 1., weight);  
05967 //             h_trj_std_jet_match_vs_pt
05968 //                 ->Fill(v_track_jet_reco_presel[k]->tlv().Pt(), 1., weight);  
05969 
05970                     
05971 //             h_trj_std_jet_match_pt_ratio->Fill(v_track_jet_reco_presel[k]->tlv().Pt()/
05972 //                                                tmp_reco_jet->tlv().Pt(),weight);
05973             
05974 //             h_trj_std_jet_match_2Dpt->Fill(v_track_jet_reco_presel[k]->tlv().Pt(),
05975 //                                                tmp_reco_jet->tlv().Pt(),weight);
05976 //         }
05977 //         else{
05978 //             h_trj_std_jet_match->Fill(0.,weight);
05979 //             h_trj_std_jet_match_vs_eta
05980 //                 ->Fill(v_track_jet_reco_presel[k]->tlv().Eta(), 0., weight);   
05981 //             h_trj_std_jet_match_vs_pt
05982 //                 ->Fill(v_track_jet_reco_presel[k]->tlv().Pt(), 0., weight);  
05983 //         }
05984 //     }
05985     
05986 //     //h_trj_std_jet_match->Fill(nb_trj_jets_matched/(double)(v_track_jet_reco_presel.size()), weight);
05987 //     m_tools.clear_vector(v_jet_reco_central);
05988 
05989 //     //int nb_jets_matched(0);
05990 //     for (unsigned int k=0; k<v_jet_reco_central.size(); k++) {
05991         
05992 //         MyParticle* tmp_track_jet = NULL;
05993 //         tmp_track_jet = m_tools.find_matching_particle( v_jet_reco_central[k],
05994 //                                                         v_track_jet_reco_presel, match_window );
05995         
05996 //         if(tmp_track_jet!=NULL){
05997 //             //nb_jets_matched++;
05998 //             h_std_trj_jet_match->Fill(1.,weight);
05999 //             h_std_trj_jet_match_vs_eta
06000 //                 ->Fill(v_jet_reco_central[k]->tlv().Eta(), 1., weight);
06001 //             h_std_trj_jet_match_vs_pt
06002 //                 ->Fill(v_jet_reco_central[k]->tlv().Pt(), 1., weight);
06003 //         }
06004 //         else{
06005 //             h_std_trj_jet_match->Fill(0.,weight);
06006 //             h_std_trj_jet_match_vs_eta
06007 //                 ->Fill(v_jet_reco_central[k]->tlv().Eta(), 0., weight);   
06008 //             h_std_trj_jet_match_vs_pt
06009 //                 ->Fill(v_jet_reco_central[k]->tlv().Pt(), 0., weight);                  
06010             
06011 //             h_jet_reco_notmatched_pt->Fill((v_jet_reco_central[k])->tlv().Pt()*invGeV,weight);
06012 //             h_jet_reco_notmatched_eta->Fill((v_jet_reco_central[k])->tlv().Eta(),weight);
06013 //             h_jet_reco_notmatched_phi->Fill((v_jet_reco_central[k])->tlv().Phi(),weight);
06014 //             h_jet_reco_notmatched_ntrks->Fill(((MyParticleJet*)(v_jet_reco_central[k]))->nb_tracks(),weight);
06015 //         }
06016 //     }
06017     
06018     //h_std_trj_jet_match->Fill(nb_jets_matched/(double)(v_jet_reco_central.size()), weight);
06019 
06020     //m_tools.clear_vector(v_jet_reco_central);
06021     //   m_tools.clear_vector(v_track_jet_reco_presel);

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