Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-01-15 23:49:37

0001 #include "FastSimulation/ForwardDetectors/plugins/FastSimDataFilter.h"
0002 
0003 #include "FWCore/Framework/interface/Frameworkfwd.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "FWCore/Framework/interface/ESHandle.h"
0010 #include "FWCore/PluginManager/interface/ModuleDef.h"
0011 #include "FWCore/ServiceRegistry/interface/Service.h"
0012 #include "DataFormats/DetId/interface/DetId.h"
0013 #include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
0014 
0015 using namespace std;
0016 namespace cms {
0017 
0018   FastSimDataFilter::FastSimDataFilter(const edm::ParameterSet& conf)
0019       : tokTowers_(consumes<CaloTowerCollection>(edm::InputTag("towerMaker"))),
0020         towercut(conf.getUntrackedParameter<double>("towercut", 1.4)) {}
0021 
0022   void FastSimDataFilter::beginJob() {
0023     ntotal = 0;
0024     npassed = 0;
0025   }
0026   void FastSimDataFilter::endJob() {
0027     edm::LogVerbatim("FastSimDataFilter") << " FastSimDataFilter: accepted " << npassed << "  out of total " << ntotal;
0028   }
0029 
0030   bool FastSimDataFilter::filter(edm::Event& event, const edm::EventSetup& setup) {
0031     ntotal++;
0032     bool result = false;
0033 
0034     const edm::Handle<CaloTowerCollection>& towers = event.getHandle(tokTowers_);
0035     CaloTowerCollection::const_iterator cal;
0036 
0037     int nplusP = 0;
0038     int nminusP = 0;
0039     int nplusR = 0;
0040     int nminusR = 0;
0041 
0042     for (cal = towers->begin(); cal != towers->end(); ++cal) {
0043       //    double eE   = cal->emEnergy();
0044       //    double eH   = cal->hadEnergy();
0045       //    double eHO  = cal->outerEnergy();
0046       //    double phi  = cal->phi();
0047 
0048       double eta = cal->eta();
0049       double en = cal->energy();
0050 
0051       // cylindrical
0052       math::RhoEtaPhiVector mom(cal->et(), cal->eta(), cal->phi());
0053 
0054       /*  
0055     // cell properties    
0056     CaloTowerDetId idT = cal->id();
0057     int ieta = idT.ieta();
0058     if(ieta > 0) ieta -= 1;
0059     int iphi = idT.iphi();
0060     */
0061 
0062       // Towers approx. in the region of BSC Paddles and Rings
0063       if (en > towercut && eta > 3.1 && eta < 3.5)
0064         nplusP++;
0065       if (en > towercut && eta < -3.1 && eta > -3.5)
0066         nminusP++;
0067       if (en > towercut && eta > 3.9 && eta < 4.6)
0068         nplusR++;
0069       if (en > towercut && eta < -3.9 && eta > -4.6)
0070         nminusR++;
0071 
0072     }  // towers cycle
0073 
0074     if ((nplusP * nminusP >= 1) || (nplusR * nminusR >= 1) || (nplusP * nminusR >= 1) || (nplusR * nminusP >= 1)) {
0075       result = true;
0076       npassed++;
0077     }
0078 
0079     return result;
0080   }
0081 }  // namespace cms
0082 
0083 // define this class as a plugin
0084 #include "FWCore/Framework/interface/MakerMacros.h"
0085 using namespace cms;
0086 DEFINE_FWK_MODULE(FastSimDataFilter);