CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/HLTrigger/special/src/HLTHFAsymmetryFilter.cc

Go to the documentation of this file.
00001 #include "HLTrigger/special/interface/HLTHFAsymmetryFilter.h"
00002 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00003 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 
00006 HLTHFAsymmetryFilter::HLTHFAsymmetryFilter(const edm::ParameterSet& iConfig)
00007 {
00008   HFHits_   = iConfig.getParameter<edm::InputTag>("HFHitCollection");  
00009   eCut_HF_  = iConfig.getParameter<double>("ECut_HF");
00010   os_asym_ = iConfig.getParameter<double>("OS_Asym_max");
00011   ss_asym_ = iConfig.getParameter<double>("SS_Asym_min");
00012 
00013   //register your products
00014 
00015   produces<trigger::TriggerFilterObjectWithRefs>();
00016 }
00017 
00018 
00019 HLTHFAsymmetryFilter::~HLTHFAsymmetryFilter()
00020 {
00021  
00022 
00023 }
00024 
00025 
00026 // ------------ method called to produce the data  ------------
00027 bool
00028 HLTHFAsymmetryFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00029 {
00030   edm::Handle<HFRecHitCollection> HFRecHitsH;
00031   
00032   iEvent.getByLabel(HFHits_,HFRecHitsH);
00033 
00034   double asym_hf_1  = -1;
00035   double asym_hf_2  = -1;
00036 
00037   int n_hf[2]   = {0,0};
00038   double e_hf[2] = {0.,0.};
00039 
00040   //Select interesting HFRecHits
00041   for (HFRecHitCollection::const_iterator it=HFRecHitsH->begin(); it!=HFRecHitsH->end(); it++) {
00042     if (it->energy()>eCut_HF_) 
00043     {
00044       if (it->id().zside() == -1)
00045       {
00046         ++n_hf[0];
00047         e_hf[0] += it->energy();
00048       }
00049       else
00050       {
00051         ++n_hf[1];
00052         e_hf[1] += it->energy();
00053       }
00054     }
00055   }
00056  
00057 
00058   for (int i=0;i<2;++i) 
00059   {
00060     if (n_hf[i])
00061       e_hf[i] /= n_hf[i];
00062   }
00063 
00064   if (e_hf[0]+e_hf[1] != 0)
00065   {
00066     asym_hf_1 = e_hf[0]/(e_hf[0]+e_hf[1]);
00067     asym_hf_2 = e_hf[1]/(e_hf[0]+e_hf[1]);
00068   }
00069   else 
00070   {
00071     return false;
00072   }
00073 
00074   bool pkam_1 = (asym_hf_1 >= ss_asym_ || asym_hf_1 <= os_asym_);
00075   bool pkam_2 = (asym_hf_2 >= ss_asym_ || asym_hf_2 <= os_asym_);
00076 
00077   if (pkam_1 || pkam_2)
00078     return true;
00079 
00080   return false;
00081 }
00082