Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-15 23:34:16

0001 // system include files
0002 #include <memory>
0003 
0004 // user include files
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0007 
0008 #include "FWCore/Framework/interface/Event.h"
0009 #include "FWCore/Framework/interface/EventSetup.h"
0010 
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 
0013 #include "Geometry/Records/interface/CaloTopologyRecord.h"
0014 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
0015 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0016 #include "RecoCaloTools/Navigation/interface/EcalBarrelNavigator.h"
0017 #include "RecoCaloTools/Navigation/interface/EcalEndcapNavigator.h"
0018 #include "RecoCaloTools/Navigation/interface/EcalPreshowerNavigator.h"
0019 #include "RecoCaloTools/Navigation/interface/CaloTowerNavigator.h"
0020 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
0021 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0022 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0023 #include "DataFormats/EcalDetId/interface/ESDetId.h"
0024 
0025 #include <iostream>
0026 
0027 class CaloNavigationAnalyzer : public edm::one::EDAnalyzer<> {
0028 public:
0029   explicit CaloNavigationAnalyzer(const edm::ParameterSet&);
0030   ~CaloNavigationAnalyzer() override = default;
0031 
0032   void analyze(edm::Event const&, edm::EventSetup const&) override;
0033 
0034 private:
0035   const edm::ESGetToken<CaloTopology, CaloTopologyRecord> esToken_;
0036   int pass_;
0037 };
0038 
0039 //
0040 // constructors and destructor
0041 //
0042 CaloNavigationAnalyzer::CaloNavigationAnalyzer(const edm::ParameterSet& iConfig) : esToken_(esConsumes()), pass_(0) {}
0043 
0044 //
0045 // member functions
0046 //
0047 
0048 // ------------ method called to produce the data  ------------
0049 void CaloNavigationAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0050   using namespace edm;
0051 
0052   const auto& theCaloTopology = iSetup.getData(esToken_);
0053   if (pass_ == 0) {
0054     {
0055       std::cout << "Testing Ecal Barrel Navigator" << std::endl;
0056       EBDetId startEB(-85, 1);
0057       std::cout << "Starting at : (" << startEB.ieta() << "," << startEB.iphi() << ")" << std::endl;
0058       EcalBarrelNavigator theEBNav(startEB, theCaloTopology.getSubdetectorTopology(DetId::Ecal, EcalBarrel));
0059 
0060       EBDetId next;
0061       int steps = 0;
0062       while (((next = theEBNav.north()) != EBDetId(0) && next != startEB)) {
0063         std::cout << "North " << steps << " : (" << next.ieta() << "," << next.iphi() << ")" << std::endl;
0064         ++steps;
0065       }
0066       theEBNav.home();
0067       steps = 0;
0068       while (((next = theEBNav.south()) != EBDetId(0) && next != startEB)) {
0069         std::cout << "South " << steps << " : (" << next.ieta() << "," << next.iphi() << ")" << std::endl;
0070         ++steps;
0071       }
0072       theEBNav.home();
0073       steps = 0;
0074       while (((next = theEBNav.west()) != EBDetId(0) && next != startEB)) {
0075         std::cout << "West " << steps << " : (" << next.ieta() << "," << next.iphi() << ")" << std::endl;
0076         ++steps;
0077       }
0078       theEBNav.home();
0079       steps = 0;
0080       while (((next = theEBNav.east()) != EBDetId(0) && next != startEB)) {
0081         std::cout << "East " << steps << " : (" << next.ieta() << "," << next.iphi() << ")" << std::endl;
0082         ++steps;
0083       }
0084       theEBNav.home();
0085       std::cout << "Coming back home" << std::endl;
0086     }
0087     {
0088       std::cout << "Testing Ecal Endcap Navigator" << std::endl;
0089       EEDetId startEE(1, 50, 1);
0090       std::cout << "Starting at : (" << startEE.ix() << "," << startEE.iy() << ")" << std::endl;
0091       EcalEndcapNavigator theEENav(startEE, theCaloTopology.getSubdetectorTopology(DetId::Ecal, EcalEndcap));
0092       theEENav.setHome(startEE);
0093 
0094       EEDetId next;
0095       int steps = 0;
0096       while (((next = theEENav.north()) != EEDetId(0) && next != startEE)) {
0097         std::cout << "North " << steps << " : (" << next.ix() << "," << next.iy() << ")" << std::endl;
0098         ++steps;
0099       }
0100       theEENav.home();
0101       steps = 0;
0102       while (((next = theEENav.south()) != EEDetId(0) && next != startEE)) {
0103         std::cout << "South " << steps << " : (" << next.ix() << "," << next.iy() << ")" << std::endl;
0104         ++steps;
0105       }
0106       theEENav.home();
0107       steps = 0;
0108       while (((next = theEENav.west()) != EEDetId(0) && next != startEE)) {
0109         std::cout << "West " << steps << " : (" << next.ix() << "," << next.iy() << ")" << std::endl;
0110         ++steps;
0111       }
0112       theEENav.home();
0113       steps = 0;
0114       while (((next = theEENav.east()) != EEDetId(0) && next != startEE)) {
0115         std::cout << "East " << steps << " : (" << next.ix() << "," << next.iy() << ")" << std::endl;
0116         ++steps;
0117       }
0118       theEENav.home();
0119     }
0120     {
0121       std::cout << "Testing Ecal Preshower Navigator" << std::endl;
0122       ESDetId startES(1, 16, 1, 1, 1);
0123       std::cout << "Starting at : " << startES << std::endl;
0124       EcalPreshowerNavigator theESNav(startES, theCaloTopology.getSubdetectorTopology(DetId::Ecal, EcalPreshower));
0125       theESNav.setHome(startES);
0126 
0127       ESDetId next;
0128       int steps = 0;
0129       while (((next = theESNav.north()) != ESDetId(0) && next != startES)) {
0130         std::cout << "North " << steps << " : " << next << std::endl;
0131         ++steps;
0132       }
0133       theESNav.home();
0134       steps = 0;
0135       while (((next = theESNav.south()) != ESDetId(0) && next != startES)) {
0136         std::cout << "South " << steps << " : " << next << std::endl;
0137         ++steps;
0138       }
0139       theESNav.home();
0140       steps = 0;
0141       while (((next = theESNav.west()) != ESDetId(0) && next != startES)) {
0142         std::cout << "West " << steps << " : " << next << std::endl;
0143         ++steps;
0144       }
0145       theESNav.home();
0146       steps = 0;
0147       while (((next = theESNav.east()) != ESDetId(0) && next != startES)) {
0148         std::cout << "East " << steps << " : " << next << std::endl;
0149         ++steps;
0150       }
0151       theESNav.home();
0152     }
0153   }
0154 
0155   pass_++;
0156 }
0157 
0158 //define this as a plug-in
0159 #include "FWCore/Framework/interface/MakerMacros.h"
0160 DEFINE_FWK_MODULE(CaloNavigationAnalyzer);