Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:40

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