MyHtautauAnalysis/MyHtautauAnalysis/MyHtautauAnalysis.h

00001 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00002 // 06.12.2006, AUTHOR: MANFRED GROH
00003 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00004 
00005 #ifndef MyHtautauAnalysisH
00006 #define MyHtautauAnalysisH
00007 
00008 //:::::::::::::::::::::::::::::
00009 //:: CLASS MyHtautauAnalysis ::
00010 //:::::::::::::::::::::::::::::
00011 
00027 
00028 //::::::::::::::::::
00029 //:: HEADER FILES ::
00030 //::::::::::::::::::
00031 
00032 // ROOT //
00033 #include "TFile.h"
00034 #include "TH1.h"
00035 #include "TH2.h"
00036 #include "TNtuple.h"
00037 #include "TProfile2D.h"
00038 
00039 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,0)
00040     #include "TDirectoryFile.h"
00041 #else
00042     #include "TDirectory.h"
00043 #endif
00044 
00045 // analysis base class //
00046 #include "NtupleReader/MyAnalysis.h"
00047 #include "NtupleReader/MyDatasetInfo.h"
00048 #include "NtupleReader/MyTrigger.h"
00049 #include "NtupleReader/MyTruthParticleManager.h"
00050 #include "NtupleReader/MyCollinearApproximation.h"
00051 #include "NtupleReader/MyParticlePair.h"
00052 #include "NtupleReader/MyTools.h"
00053 #include "NtupleReader/MyTextFileReader.h"
00054 #include "NtupleReader/MyVBFCandidate.h"
00055 
00056 
00057 
00058 class MyHtautauAnalysis : public MyAnalysis {
00059 
00060 public:
00061 // Constructors //
00062     MyHtautauAnalysis(void) {
00063         init();
00064         }
00066 
00067     ~MyHtautauAnalysis(void) {
00068         destruct();
00069         }
00071 
00072 // Methods //
00073     void initialize(void);
00078     void analyse_event(const MyEvent & event);
00080     void end_of_analysis(void);
00083     TString settingsFilename;
00085     TString filename;  // name of ROOT file
00088 
00089 private:
00090     
00091 // The MyDatasetInfo object 
00092     MyDatasetInfo *m_dataset_info;
00093     
00094     TString met_ana_obj;
00095     // name of the met object that should be used in the analysis
00096     // before changing to the new MET design this was realized with overwriting
00097     // the met_final variables
00098     
00099     std::vector<int> evt_nb_passed;
00100 
00101     const MyEvent * m_event;
00102     
00103     // Number of the entry, starting with 1
00104     int entry_nb;
00105     
00106     double weight;
00107 
00108     bool ev_has_fake_taus;
00109 
00110     int nb_e25i_triggers;
00111     int nb_m20i_triggers;
00112     int nb_e25i_not_triggers;
00113     int nb_m20i_not_triggers;
00114     int nb_both_triggers;
00115 
00116     int event_flavour;
00117         // 0 if event isnt triggered
00118         // 1 if the triggered high pt lepton is an electron
00119         // 2 if it is a muon
00120     
00121     std::string generator;
00122     
00123     static const double GeV=1.0;
00124 //    static const double GeV=0.001;
00125     TFile *m_tfile; // ROOT file
00126     
00127     bool switch_truth_lepton_filter;
00128     int truth_lepton_filter_min_nb_leptons;
00129     bool switch_analyse_truth_decay;
00130     bool switch_truth_decay_mode_filter;
00131     bool truth_decay_mode_filter_only_higgs;
00132     bool truth_decay_mode_filter_analyse_ll;
00133     bool truth_decay_mode_filter_analyse_lh;
00134     bool truth_decay_mode_filter_analyse_hh;
00135     
00136     double e_presel_pt_min;
00137     double e_presel_eta_max;
00138     double e_presel_eoverp_min;
00139     double e_presel_eoverp_max;
00140     bool   e_presel_require_isem_0;
00141     bool   e_presel_require_isem_0x3FF;
00142     bool   e_presel_require_isem_mod16_0;
00143     double e_presel_min_NeuralNet;
00144     double e_presel_max_etCone02;
00145     double e_presel_max_etCone02_rel;
00146     bool   e_presel_noisolation_eta14165;
00147     double e_truth_presel_min_pt;
00148     double e_truth_presel_max_eta;
00149     
00150     std::string reco_muons_name;
00151     double mu_presel_pt_min;
00152     double mu_presel_eta_max;
00153     double mu_presel_max_etCone04;
00154     double mu_presel_max_etCone045;
00155     double mu_presel_max_etCone02_rel;
00156     bool   mu_presel_use_combined;
00157     bool   mu_presel_use_standalone;
00158     bool   mu_presel_use_lowpt;
00159     bool   mu_presel_require_hasCombinedMuonTrackParticle;
00160     double mu_presel_min_matchChi2;
00161     double mu_presel_max_matchChi2;
00162     double mu_presel_max_matchChi2OverDoF;
00163     double mu_presel_max_fitChi2OverDoF;
00164     double mu_truth_presel_min_pt;
00165     double mu_truth_presel_max_eta;
00166     
00167     
00168     bool   switch_mu_delete_doubles;
00169     bool   switch_mu_remove_overlap_e;
00170     double dr_mu_remove_overlap_e;
00171 
00172     double taujet_truth_presel_min_pt;
00173     double taujet_truth_presel_max_eta;
00174     
00175     bool    apply_taujet_correction;
00176     double taujet_presel_min_pt;
00177     double taujet_presel_max_eta;
00178     double taujet_presel_min_llh;
00179     bool   taujet_presel_require_charge_1;
00180     bool   taujet_presel_require_nb_tracks_13;
00181     bool   taujet_presel_require_TRTHitRatio;
00182     double taujet_presel_min_e_over_p;
00183     double taujet_presel_e_ethadoveret_min;
00184     
00185     double jet_presel_min_pt;
00186     double jet_presel_max_eta;
00187     
00188     double jet_truth_presel_min_pt;
00189     double jet_truth_presel_max_eta;
00190     
00191     bool switch_taujet_reco_remove_overlap_e;
00192     bool switch_taujet_reco_remove_overlap_mu;
00193     double dr_taujet_reco_remove_overlap_e;
00194     double dr_taujet_reco_remove_overlap_mu;
00195     
00196     bool switch_jet_reco_remove_overlap_e;
00197     double dr_jet_reco_remove_overlap_e;
00198     bool switch_jet_reco_remove_overlap_mu;
00199     double dr_jet_reco_remove_overlap_mu;
00200     bool switch_jet_reco_remove_overlap_taujet;
00201     double dr_jet_reco_remove_overlap_taujet;
00202     
00203     bool switch_jet_truth_remove_overlap_e;
00204     double dr_jet_truth_remove_overlap_e;
00205     bool switch_jet_truth_remove_overlap_mu;
00206     double dr_jet_truth_remove_overlap_mu;
00207     bool switch_jet_truth_remove_overlap_taujet;
00208     double dr_jet_truth_remove_overlap_taujet;
00209     
00210     std::string recalculate_met_muons;
00211     std::string met_option;
00212     std::string met_muon_contribution;
00213     // is set in: add_recalculated_missinget
00214     // according to the given met_option
00215 
00216     bool switch_ana_use_e_truth;
00217     bool switch_ana_use_mu_truth;
00218     bool switch_ana_use_taujet_truth;
00219     bool switch_ana_use_jet_truth;
00220     
00221     bool switch_only_highpt_jetpair;
00222     
00223     int ana_require_trigger_flavour;
00224     
00225     int output_level_cand_ntuple;
00226     
00227     unsigned int ana_e_nb_min;
00228     unsigned int ana_e_nb_max;
00229     unsigned int ana_mu_nb_min;
00230     unsigned int ana_mu_nb_max;
00231     unsigned int ana_emu_nb_min;
00232     unsigned int ana_emu_nb_max;
00233     unsigned int ana_taujet_nb_min;
00234     unsigned int ana_taujet_nb_max;
00235     
00236     
00237     double deltaR_jetmatching_cut;
00238     int cuts_total_nb;
00239     std::string cuts[20];
00240 
00241     Double_t min_etmiss;
00242     Double_t min_e_pt;
00243     Double_t min_mu_pt;
00244     Double_t min_taujet_pt;
00245     
00246     Double_t min_leptons_cosdphi;
00247     Double_t max_leptons_dr;
00248     Double_t min_lept_x;
00249     Double_t min_had_x;
00250     Double_t max_lept_x;
00251     Double_t max_had_x;
00252     Double_t max_x_squaresum;
00253     Double_t max_transverse_mass;
00254     Double_t min_jet1_pt;
00255     Double_t min_jet2_pt;
00256     Double_t min_jets_deta;
00257     Double_t max_jets_dphi;
00258     Double_t min_jets_mass;
00259     Double_t max_bjet_weight;
00260     Double_t min_cj_pt;
00261     Double_t max_cj_eta;
00262     Bool_t   switch_cj_between_fwdjets;
00263     Double_t min_leptons_jets_deta;
00264     Double_t max_pt_balance;
00265     Double_t min_mass_window;
00266     Double_t max_mass_window;
00267 
00268 
00269 #include "HtautauHistos.h"
00270     
00271     std::vector<MyParticle*> v_e_reco_aod;
00272     std::vector<MyParticle*> v_e_reco_presel;
00273     
00274     std::vector<MyParticle*> v_mu_reco_aod;
00275     std::vector<MyParticle*> v_mu_reco_orm;
00276     std::vector<MyParticle*> v_mu_reco_presel;
00277      std::vector<MyParticle*> v_mu_reco_matched;
00278     
00279     std::vector<MyParticle*> v_taujet_reco_aod;
00280     std::vector<MyParticle*> v_garbage;
00281     std::vector<MyParticle*> v_taujet_reco_orm;
00282     std::vector<MyParticle*> v_taujet_reco_presel;
00283     std::vector<MyParticle*> v_taujet_reco_fake;
00284     
00285     
00286     std::vector<MyParticle*> v_jet_reco_aod;
00287     std::vector<MyParticle*> v_jet_reco_orm;
00288     std::vector<MyParticle*> v_jet_reco_presel;
00289     
00290     std::vector<MyParticle*> v_e_truth_aod;
00291     std::vector<MyParticle*> v_e_truth_presel;
00292     
00293     std::vector<MyParticle*> v_mu_truth_aod;
00294     std::vector<MyParticle*> v_mu_truth_presel;
00295      std::vector<MyParticle*> v_mu_truth_matched;
00296     
00297     std::vector<MyParticle*> v_tau_truth_aod;
00298     
00299     std::vector<MyParticle*> v_jet_truth_aod;
00300     std::vector<MyParticle*> v_jet_truth_orm;
00301     std::vector<MyParticle*> v_jet_truth_presel;
00302     
00303     std::vector<MyParticle*> v_taujet_truth;
00304         // the objects in this vector have to be deleted
00305         // after every event !!!
00306     std::vector<MyParticle*> v_taujet_truth_all;
00307     std::vector<MyParticle*> v_taujet_truth_orm;
00308     std::vector<MyParticle*> v_taujet_truth_presel;
00309 
00310 
00311 
00312     // vectors on which the analysis is performed:
00313     std::vector<MyParticle*> v_e_ana;
00314     std::vector<MyParticle*> v_mu_ana;
00315     std::vector<MyParticle*> v_taujet_ana;
00316     std::vector<MyParticle*> v_jet_ana;
00317     MyMissingEtManager missinget_ana;
00318     std::vector<MyVBFCandidate*> v_candidates_ana;
00319     bool has_leptonpair;
00320     bool has_jetpair;
00321 
00322     
00323     // The CollinearApproximationObjects
00324     std::vector<MyCollinearApproximation> v_coll_app;
00325 
00326     // The Tools
00327     MyTools m_tools;
00328     // The Truth Manager //
00329     MyTruthParticleManager m_truth_manager;
00330     // Decay Modes //
00331     int primary_particle_mode;// primary particles (W, Z, H...)
00332                 // Mode -1: unknown
00333                 // Mode 0: H
00334                 // Mode 1: Z
00335                 // Mode 2: W+,W-
00336     int primary_particle_decay_mode;
00337     int tau_0_decay_mode; // Mode numbering scheme according to ATL-PHYS-PUB-2006-008
00338                 // Table 2 on Page 8
00339                 // e-> 1
00340                 // mu-> 2
00341                 // picharged -> 3
00342                 // 1prong -> 3-7
00343                 // 3prong -> 8-10
00344                 // extension to this:
00345                 // less than two taus -> -1
00346     int tau_1_decay_mode; // Michael Heldmann: "An improved Tau-Identification ..."
00347     int higgs_decay_mode; // 1 for ll, 2 for lh, 3 for hh
00348     
00349     TString decay_mode_string;
00350     int decay_mode; // the one that is used for the analysis
00351                 // needed for handling col. app.
00352                 // value is derived from decay_mode_string
00353 
00354 
00355 
00356 // methods //
00357     void init(void); // initialization routine
00358     void clear_event_data(void); // reset variables like:
00359                              // primary_particle_mode
00360                      // tau_0_decay_mode...
00361     void destruct(void); // destruction routine
00362     
00363     void cut_based_anlysis(
00364         const MyMissingEtManager missinget_in);
00365     std::vector<MyVBFCandidate*> 
00366         build_candidates( std::vector<MyParticle*> v_e_cand,
00367                           std::vector<MyParticle*> v_mu_cand,
00368                           std::vector<MyParticle*> v_tau_cand,
00369                           std::vector<MyParticle*> v_jet_cand,
00370                           MyMissingEt missing_et);
00372 
00373     void cut_offline_trigger(MyVBFCandidate* candidate);
00374     void cut_online_trigger(MyVBFCandidate* candidate);
00375     void cut_number_emu(MyVBFCandidate* candidate);
00376     void cut_number_taujets(MyVBFCandidate* candidate);
00377     void cut_number_jets(MyVBFCandidate* candidate);
00378     void cut_etmiss(MyVBFCandidate* candidate);
00379     void cut_lepton_pt(MyVBFCandidate* candidate);
00380     void cut_leptons_charge(MyVBFCandidate* candidate);
00381     void cut_leptons_dphi(MyVBFCandidate* candidate);
00382     void cut_leptons_dr(MyVBFCandidate* candidate);
00383     void cut_collinear_approximation(MyVBFCandidate* candidate);
00384     void cut_transverse_mass(MyVBFCandidate* candidate);
00385     void cut_jets_pt(MyVBFCandidate* candidate);
00386     void cut_jets_hemisphere(MyVBFCandidate* candidate);
00387     void cut_jets_deta(MyVBFCandidate* candidate);
00388     void cut_jets_dphi(MyVBFCandidate* candidate);
00389     void cut_jets_mass(MyVBFCandidate* candidate);
00390     void cut_bjet_veto(MyVBFCandidate* candidate);
00391     void cut_central_jet_veto(MyVBFCandidate* candidate);
00392     void cut_leptons_jets_deta(MyVBFCandidate* candidate);
00393     void cut_pt_balance(MyVBFCandidate* candidate);
00394     void cut_mass_window(MyVBFCandidate* candidate);
00395     MyVBFCandidate* choose_candidate(std::vector<MyVBFCandidate*> v_candidates_tmp);
00396 
00397     void fill_raw_aod_content_histos(void);
00398         // fill histos for the raw AOD content
00399         
00400     std::vector<MyParticle*> preselect_electrons(
00401         const std::vector<MyParticle*> v_particle);
00402         // returns the given vector of particles after
00403         // pt, eta cut (and isolation?)
00404     std::vector<MyParticle*> preselect_truth_electrons(
00405         const std::vector<MyParticle*> v_particle);
00406         // returns the given vector of particles after
00407         // pt, eta cut (and isolation?)
00408     std::vector<MyParticle*> preselect_muons(
00409         const std::vector<MyParticle*> v_particle);
00410         // returns the given vector of particles after
00411         // pt, eta cut (and isolation?)
00412     std::vector<MyParticle*> preselect_truth_muons(
00413         const std::vector<MyParticle*> v_particle);
00414         // returns the given vector of particles after
00415         // pt, eta cut (and isolation?)
00416     std::vector<MyParticle*> preselect_taujets(
00417         const std::vector<MyParticle*> v_particle);
00418         // returns the given vector of particles after
00419         // pt, eta cut (and isolation?)
00420     std::vector<MyParticle*> preselect_truth_taujets(
00421         const std::vector<MyParticle*> v_particle);
00422         // returns the given vector of particles after
00423         // pt, eta cut (and isolation?)
00424     std::vector<MyParticle*> preselect_jets(
00425         const std::vector<MyParticle*> v_particle);
00426         // returns the given vector of particles after
00427         // pt, eta cut (and isolation?)
00428     std::vector<MyParticle*> preselect_truth_jets(
00429         const std::vector<MyParticle*> v_particle);
00430         // returns the given vector of particles after
00431         // pt, eta cut (and isolation?)
00432     MyParticle visible_part_of_decay_products(MyTruthParticle* part_in);
00433         // returns the sum of all visible decay products as a MyParticle
00434     std::vector<MyParticle*> create_truth_taujets(std::vector<MyParticle*> v_particle);
00435         // takes the incoming vector of truth taus and creates for each truth tau
00436         // a new vector that contains one particle for each tau with the sum of
00437         // all visible decay products of the tau
00438     std::vector<MyParticle*> create_corrected_taujets(std::vector<MyParticle*> v_particle);
00439         // takes the incoming vector of tau jets and returns a new vector that contains
00440         // the same tau jets with corrected energy
00441     void delete_truth_taujets(void);
00442         // deletes the objects created by create_truth_taujets
00443     void match_electrons(
00444         std::vector<MyParticle*> v_e_reco, std::vector<MyParticle*> v_e_truth);
00445         // match recornstructed electrons with truth electrons
00446     void match_muons(
00447         std::vector<MyParticle*> v_mu_reco, std::vector<MyParticle*> v_mu_truth);
00448         // match recornstructed muons with truth muons
00449     void match_taujets(
00450         std::vector<MyParticle*> v_taujet_reco, std::vector<MyParticle*> v_taujet_truth);
00451         // match recornstructed taujets with truth taujets
00452     void match_jets(
00453         std::vector<MyParticle*> v_jet_reco, std::vector<MyParticle*> v_jet_truth);
00454         // match recornstructed jets with truth jets
00455     void match_fake_taujets(void);
00456         // match faked tau jets to several kind of things
00457     void add_recalculated_missinget(MyMissingEtManager *orig_missing_et);
00458         // recalculate a missing Et object, add it to the MET-Manager as recalculated
00459     int n_pt_above(const std::vector<MyParticle*> v_particle, const double ptcut);
00460         // return number of particles in vector with pt above ptcut
00461     int tau_decay_mode(MyTruthParticle* truth_tau);
00462     void calculate_decay_mode(void);
00463     void fill_decay_mode_hists(bool print_info);
00464     void fill_lepton_hists(const std::vector<MyVBFCandidate*> v_candidates_tmp, const int cut_number);
00465     void fill_jet_hists(const std::vector<MyVBFCandidate*> v_candidates_tmp, const int cut_number);
00466         // returns the number of truth leptons that pased the lepton filter
00467     int check_truth_lepton_filter(void);
00468     void analyse_truth_decay(void);
00469     void fill_all_ana_histos(const std::vector<MyVBFCandidate*> v_candidates_tmp, const int cut_number);
00470     void fill_candidate_ntuple(const std::vector<MyVBFCandidate*> v_candidates_tmp);
00471 
00472     std::vector<MyParticlePair> 
00473         get_tagjet_pairs(std::vector<MyVBFCandidate*> vec_candidates);
00475 
00476     std::vector<MyParticlePair> 
00477         get_lepton_pairs(std::vector<MyVBFCandidate*> vec_candidates);
00479 
00480     std::vector<MyParticle*> 
00481         get_tagjets(std::vector<MyParticlePair> vec_tagjet_pairs);
00483 
00484     std::vector<MyParticle*> 
00485         get_leptons(std::vector<MyParticlePair> vec_lepton_pairs);
00487     std::vector<MyParticle*>
00488             get_centraljet_candidates(std::vector<MyParticle*> vec_jets_tmp, MyVBFCandidate* candidate);
00490     double get_transverse_mass(MyVBFCandidate* candidate_tmp);
00491     double get_max_btag_weight(MyVBFCandidate* candidate_tmp, std::vector<MyParticle*> vec_jets_tmp);
00492     void   check_bjet_performance(std::vector<MyParticle*> v_jet_reco_presel);
00493     MyTruthParticle* get_next_mother(MyTruthParticle* part);
00494     bool TTbarLeptonFilter();
00495 
00496     TH1F* h_Wplus_Jetcharge;
00497     TH1F* h_Wminus_Jetcharge;
00498     TH1F* h_Wplus_JetpdgIds;
00499     TH1F* h_Wminus_JetpdgIds;
00500     void JetOriginInvest(std::vector<MyParticle*> jets_to_invest);
00501 };
00502 
00503 #endif

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