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

MuonSelector.hpp

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 // Updates: 25 Oct. 2005, 
00003 //               - Supriya Jain (sjain@fnal.gov)
00004 //                 Added options: 
00005 //                            JetBranch, MinDeltaR, MaxDeltaR
00006 //
00007 //          20 Dec, 2005
00008 //               - Mark Owen (markowen@fnal.gov)
00009 //                 Added interface to Muon ID standard slection
00010 //                 Added DCA calculation wrt beam spot
00011 //                 Added possibility to correct pT wrt beam spot
00012 //
00013 //          8 Jan, 2006
00014 //               - Mark Owen (markowen@fnal.gov)
00015 //                 Moved pT correction to before function
00016 //             
00017 //
00018 // ---------------------------------------------------------------------------
00019 #ifndef CAFUTIL_MUONSELECTOR_HPP__
00020 #define CAFUTIL_MUONSELECTOR_HPP__
00021 
00022 #include "cafe/Stat.hpp"
00023 #include "caf_util/TRefFinder.hpp"
00024 #include "cafe/Event.hpp"
00025 #include "cafe/SelectUserObjects.hpp"
00026 #include "tmb_tree/TMBMuon.hpp"
00027 
00028 namespace caf_util {
00029   
00107   class MuonSelector : public cafe::SelectUserObjects<TMBMuon>
00108   {
00109   public:
00110     MuonSelector(const char *name);
00111     ~MuonSelector() {}
00112     bool processEvent(cafe::Event &event);
00113     bool selectObject(const TMBMuon &muon);
00114   private:
00115     void before(cafe::Collection<TMBMuon>& from) ;    
00116     void after(cafe::Collection<TMBMuon>& accepted, cafe::Collection<TMBMuon>& rejected);
00117   private:
00118     enum Quality {Loose, Medium, Tight} ;
00119 
00120     cafe::StatPointer _stat ; //< pointer to the statistics collector class
00121 
00122     int _nmuons ; //< minimal number of muons to be selected
00123     int _nmuonsmax ; //< maximal number of muons to be selected
00124     int _nselected ; //< number of selected objects
00125 
00126     Quality _qual ; //< muon quality
00127     int _nseg ; //< minimal number of muon segments
00128     float _pTcut ; //< minimal muon pT
00129     float _eta ; //< the maximal absolute value of the detector eta
00130     float _chisq ; //< Chisquare from global matching (global muon fit) 
00131     float _dcaSignif ; //< maximal DCA significance for the central track
00132     float _dcaSMT; //< maximal DCA for tracks with SMT hits
00133     float _dcaNoSMT; //< maximal DCA for tracks with no SMT hits 
00134     int _nSMT; //< minimal number of SMT hits on the muon track
00135     float _etHalo ; //< maximal value on the calorimeter isolation
00136     float _etHaloMin ; //< minimal value on the calorimeter isolation
00137     float _etHaloScaled ; //< maximal value on the scaled calorimeter isolation
00138     float _etHaloScaledMin ; //< minimal value on the scaled calorimeter isolation
00139     float _etTrkCone ; //< maximal value on the track isolation
00140     float _etTrkConeMin ; //< minimal value on the track isolation
00141     float _etTrkConeScaled ; //< maximal value on the scaled track isolation
00142     float _etTrkConeScaledMin ; //< minimal value on the scaled track isolation
00143     bool _useCentralMatched ; //< use only muons with central track matched
00144     bool _cosmicVeto ; //< use timing cuts to remove cosmic muons
00145     bool _sort; 
00146     bool _use_beam_spot; //< use beam spot to calculate DCA, if false use vertex
00147     bool _reject_no_beam_spot; //< reject runs with no beam spot entry
00148     bool _corr_pT_SMT; //< correct pT with respect to beam spot for tracks with SMT hits
00149     bool _corr_pT_noSMT; //< correct pT with respect to beam spot for tracks with no SMT hits
00150     bool _mc; //< is sample mc - if find it is then don't need beam spot file
00151     bool _excludeHole; //< do you want to exclude muon that are in the bottom hole ?
00152 
00153     // Parameters for DeltaR cuts
00154     cafe::Collection<TMBJet> _jets;
00155     float _MinDeltaR; //< min. delta_R from nearest jet
00156     float _MaxDeltaR; //< max. delta_R from nearest jet
00157     std::string _JetBranch; //< for computing delta_R
00158 
00159     cafe::Event* _event ;
00160     cafe::Variables _jetvars ; // variables for optimize jets reading
00161     TRefFinder _finder ; //< workaround for the TRef problem 
00162 
00163     // Functions to calculate DCA, either from vertex or beamspot
00164     //double CalcDCAwrtVertex(double &ip[2], double &iperr[3], const TMBTrack* mutrk);
00165 
00166     // Additions to use MUID standard cuts
00167     bool _use_muid; //< switch to use standard muon cuts
00168     bool _cuts_set; //< bool to check muon id cuts were set correctly
00169     std::string _muqual_file; //< name of file containing muon quality definions
00170     std::string _muqual_name; //< name of muon quality definition
00171     int _muqual_version; //< muon quality version number
00172     std::string _trkqual_file; //< name of file containing track quality definions
00173     std::string _trkqual_name; //< name of track quality definition
00174     int _trkqual_version; //< track quality version number
00175     std::string _isoqual_file; //< name of file containing isolation quality definions
00176     std::string _isoqual_name; //< name of isolation quality definition
00177     int _isoqual_version; //< isolation quality version number    
00178     std::string _path; //< path of the definitions.
00179 
00180     //Beam spot info
00181     FILE *_beamspot_file; //< file for beam spot info
00182     std::string _beam; //< name of beam spot file
00183     bool _open_beam; //< is beam spot file open?
00184     float _bx, _by, _bsx, _bsy;
00185     int _lastrun;
00186     cafe::Variables _runvar;
00187     bool GetBeamSpot(FILE *fp, int run, float &bx, float &by,  float &bsx, float &bsy);
00188     cafe::Variables _chunkvar;
00189     double DCAfromBeamSpot(const TMBTrack* muon_trk);
00190 
00191     //Get Corrected Pt
00192     double GetCorrectedPt(const TMBMuon& muon, double dca);
00193 
00194     //Function to set up all the cuts based on the standard muIDs
00195     bool SetStdCuts(std::string path, std::string mu_file_name, std::string mu_name, int mu_ver, std::string trk_file_name, std::string trk_name, int trk_ver, std::string iso_file_name, std::string iso_name, int iso_ver);
00196 
00197 
00198     void DisplayMuonQualityCuts();
00199     void DisplayMuonTrackQualityCuts();
00200     void DisplayMuonIsolationQualityCuts();
00201 
00202     //Debug switch for development
00203     int _debuglevel;
00204 
00205     ClassDef(MuonSelector, 0) ;
00206   };
00207   
00208 }
00209 #endif // CAFUTIL_MUONSELECTOR_HPP__

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