Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

TauSelector.cpp

Go to the documentation of this file.
00001 /* File TauSelector.cpp
00002  *
00003  * Created       : Wed Oct 12 11:08:04 CDT 2005
00004  * Author        : Mark OWEN, markowen@fnal.gov
00005  * Purpose       : Select Basic Tau Objects
00006  * Last modified : 10-24-05
00007  * Comments      : 
00008  */
00009 
00010 #include "caf_util/TauSelector.hpp"
00011 #include "cafe/Config.hpp"
00012 
00013 #include <string>
00014 #include <sstream>
00015 
00016 using namespace std;
00017 using namespace cafe;
00018 
00019 namespace caf_util {
00020   
00021   // Constructor: 
00022   TauSelector::TauSelector(const char *name) : cafe::SelectUserObjects<TMBTau>(name)
00023   {
00024     // get parameters from the configuration file
00025     cafe::Config config(name);
00026     
00027     //minimal number of taus to be selected per event
00028     _ntaus = config.get("nTaus",1);
00029 
00030     //maximal number of taus to be selected per event
00031     _ntausmax = config.get("nTausMax",-1);
00032     
00033     //Remove charge 0 taus
00034     _remove_q0 = config.get("RemoveQ0",0);
00035 
00036     //Tau detector eta cut
00037     _tau_eta_cut = config.get("EtaCut",-1.0);
00038 
00039     cout << "Tau Eta Cut for " << name << " = " << _tau_eta_cut << endl; 
00040 
00041     //Tau Et cuts
00042     _taut1_ET_cut = config.get("Type1Et",10.0);
00043     _taut2_ET_cut = config.get("Type2Et",5.0);
00044     _taut3_ET_cut = config.get("Type3Et",10.0);
00045     
00046     cout << "Tau Type 1 Et cut for " << name << " = " << _taut1_ET_cut << endl;
00047     cout << "Tau Type 2 Et cut for " << name << " = " << _taut2_ET_cut << endl;
00048     cout << "Tau Type 3 Et cut for " << name << " = " << _taut3_ET_cut << endl;
00049 
00050     //Tau Track pT cuts
00051     _taut1_trkpt_cut = config.get("Type1TrkPt",7.0);
00052     _taut2_trkpt_cut = config.get("Type2TrkPt",5.0);
00053     _taut3_trkpt_cut = config.get("Type3TrkPt",7.0);
00054 
00055     cout << "Tau Type 1 Track Pt cut for " << name << " = " << _taut1_trkpt_cut << endl;
00056     cout << "Tau Type 2 Track Pt cut for " << name << " = " << _taut2_trkpt_cut << endl;
00057     cout << "Tau Type 3 Track Pt cut for " << name << " = " << _taut3_trkpt_cut << endl;
00058 
00059     //Tau NN Output cuts
00060     _taut1_nn_cut = config.get("Type1NNCut",-1.0);
00061     _taut2_nn_cut = config.get("Type2NNCut",-1.0);
00062     _taut3_nn_cut = config.get("Type3NNCut",-1.0);
00063 
00064     if(_taut1_nn_cut>0) cout << "Tau type 1 NN cut for " << name << " = " << _taut1_nn_cut << endl;
00065     if(_taut2_nn_cut>0) cout << "Tau type 2 NN cut for " << name << " = " << _taut2_nn_cut << endl;
00066     if(_taut3_nn_cut>0) cout << "Tau type 3 NN cut for " << name << " = " << _taut3_nn_cut << endl;
00067     
00068     _nselected = 0;
00069     
00070   }
00071   
00072   //destructor
00073   TauSelector::~TauSelector()
00074   {
00075     
00076   }
00077 
00078   bool TauSelector::processEvent(cafe::Event& event)
00079   {
00080     //get pointer to statistics collector
00081     event.get("StatPointer", _stat) ;
00082    
00083     //Open tracks branch in case autoloading does not work
00084     Collection<TMBTrack> tracks = event.getTracks();
00085     
00086     _nselected = 0 ;
00087     SelectUserObjects<TMBTau>::processEvent(event);
00088     
00089     if(_ntaus > 0 && _nselected < 1) return false;
00090     
00091     for(int i = 2; i <= _ntaus; i++) {
00092       if(_nselected < i) return false;
00093       ostringstream st;
00094       st << i << " taus";
00095       _stat.EventSelected(st.str());
00096     }
00097     
00098     if (_ntausmax >= 0) {
00099       if (_nselected > _ntausmax) return false ; 
00100       ostringstream st ;
00101       st << "Number of taus <= " << _ntausmax ;
00102       _stat.EventSelected(st.str()) ;      
00103     }
00104 
00105     return true;
00106   }
00107   
00108   bool TauSelector::selectObject(const TMBTau &tau)
00109   {
00110     int tau_type = tau.type();
00111 
00112     //Reject tau type 0s
00113     if(tau_type<1) return false;
00114     {
00115       ostringstream st;
00116       st << "Remove Tau Type 0";
00117       if(_ntaus>0) _stat.EventSelected(st.str());
00118     }
00119 
00120     //Remove charge 0 taus
00121     if(_remove_q0) {
00122       if(tau.charge()==0) return false;
00123       ostringstream st;
00124       st << "Remove Taus with charge = 0";
00125       if(_ntaus>0) _stat.EventSelected(st.str());
00126     }
00127 
00128     //Tau Eta selection
00129     if(_tau_eta_cut>0) {
00130       if(fabs(tau.etad()) >= _tau_eta_cut) return false;
00131       ostringstream st;
00132       st << "Tau eta < " << _tau_eta_cut ;
00133       if(_ntaus>0) _stat.EventSelected(st.str());
00134     }
00135 
00136     //Et selection
00137     if(tau_type==1 && tau.ET()<_taut1_ET_cut) return false; 
00138     if(tau_type==2 && tau.ET()<_taut2_ET_cut) return false;
00139     if(tau_type==3 && tau.ET()<_taut3_ET_cut) return false;
00140     
00141     {
00142       ostringstream st;
00143       st << "Tau ET cut (type 1 > " << _taut1_ET_cut << ", type 2 > " << _taut2_ET_cut << ", type 3 > " << _taut3_ET_cut << ")";
00144       if(_ntaus>0) _stat.EventSelected(st.str());
00145     }      
00146 
00147     //Track Pt selection
00148     if(tau_type==1 || tau_type==2) {
00149       if(tau.ntrk()>1) {
00150         cerr << "ERROR: Tau type 1 or 2 has more than 1 track, tau will be rejected" << endl;
00151         return false;
00152       }
00153       const TMBTrack *track = tau.GetChargedTrack(0);
00154       if(track==0) {
00155         cerr << "ERROR: No track associated with tau, tau will be rejected" << endl;
00156         return false;
00157       }
00158       if(tau_type==1 && track->Pt()<_taut1_trkpt_cut) return false;
00159       if(tau_type==2 && track->Pt()<_taut2_trkpt_cut) return false;
00160     } //end if type 1 or 2
00161     
00162     if(tau_type==3) {
00163       float sum_pt=0;
00164       for(int itrk=0; itrk<tau.ntrk(); itrk++) {
00165         const TMBTrack *track = tau.GetChargedTrack(itrk);
00166         if(track==0) {
00167         cerr << "ERROR: No track associated with tau, tau will be rejected" << endl;
00168         return false;
00169         }
00170         sum_pt+=track->Pt();
00171       }//end loop over tau tracks       
00172       if(sum_pt<_taut3_trkpt_cut) return false;
00173     } //end if type 3
00174       
00175     {
00176       ostringstream st;
00177       st << "Tau Track Pt cut (type 1 > " << _taut1_trkpt_cut << ", type 2 > " << _taut2_trkpt_cut << ", type 3 > " << _taut3_trkpt_cut << ")";
00178       if(_ntaus>0) _stat.EventSelected(st.str());
00179     }
00180   
00181     //Tau NN output cut
00184     if(tau_type==1&&_taut1_nn_cut>0) if(tau.nnout()<_taut1_nn_cut) return false;
00185     if(tau_type==2&&_taut2_nn_cut>0) if(tau.nnout()<_taut2_nn_cut) return false;
00186     if(tau_type==3&&_taut3_nn_cut>0) if(tau.nnout()<_taut3_nn_cut) return false;
00187 
00188     if( (_taut1_nn_cut>0) || (_taut2_nn_cut>0) || (_taut3_nn_cut>0) ) {
00189       ostringstream st;
00190       st << "Tau NN (type 1 > " << _taut1_nn_cut << ", type 2 > " << _taut2_nn_cut << ", type 3 > " << _taut3_nn_cut << ")";
00191       if(_ntaus>0) _stat.EventSelected(st.str());
00192     }
00193 
00194       
00195     _nselected++;
00196     
00197     return true;
00198     
00199   }
00200    
00201   
00202 }
00203 
00204 
00205 
00206 ClassImp(caf_util::TauSelector);

Generated on Tue Mar 28 10:13:04 2006 for CAF by doxygen 1.3.4