Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-04-12 23:30:29

0001 #include <memory>
0002 #include <iostream>
0003 #include <vector>
0004 
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 
0011 #include "DataFormats/ForwardDetId/interface/MTDDetId.h"
0012 #include "DataFormats/FTLRecHit/interface/FTLRecHitCollections.h"
0013 
0014 class MTDRecoDump : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0015 public:
0016   explicit MTDRecoDump(const edm::ParameterSet&);
0017   ~MTDRecoDump() override;
0018 
0019   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0020 
0021 private:
0022   void beginJob() override;
0023   void analyze(const edm::Event&, const edm::EventSetup&) override;
0024   void endJob() override;
0025 
0026   // ----------member data ---------------------------
0027 
0028   edm::EDGetTokenT<FTLRecHitCollection> tok_BTL_reco;
0029   edm::EDGetTokenT<FTLRecHitCollection> tok_ETL_reco;
0030 };
0031 
0032 MTDRecoDump::MTDRecoDump(const edm::ParameterSet& iConfig)
0033 
0034 {
0035   tok_BTL_reco = consumes<FTLRecHitCollection>(edm::InputTag("mtdRecHits", "FTLBarrel"));
0036   tok_ETL_reco = consumes<FTLRecHitCollection>(edm::InputTag("mtdRecHits", "FTLEndcap"));
0037 }
0038 
0039 MTDRecoDump::~MTDRecoDump() {}
0040 
0041 //
0042 // member functions
0043 //
0044 
0045 // ------------ method called for each event ------------
0046 void MTDRecoDump::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0047   using namespace std;
0048 
0049   edm::Handle<FTLRecHitCollection> h_BTL_reco;
0050   iEvent.getByToken(tok_BTL_reco, h_BTL_reco);
0051 
0052   edm::Handle<FTLRecHitCollection> h_ETL_reco;
0053   iEvent.getByToken(tok_ETL_reco, h_ETL_reco);
0054 
0055   // --- BTL RECOs:
0056 
0057   if (!h_BTL_reco->empty()) {
0058     std::cout << " ----------------------------------------" << std::endl;
0059     std::cout << " BTL RECO collection:" << std::endl;
0060 
0061     for (const auto& recHit : *h_BTL_reco) {
0062       MTDDetId mtdDetId(recHit.id());
0063 
0064       // --- detector element ID:
0065       std::cout << "   det ID:  det = " << mtdDetId.det() << "  subdet = " << mtdDetId.mtdSubDetector()
0066                 << "  rawID = " << mtdDetId.rawId() << std::endl;
0067 
0068       std::cout << "       energy = " << recHit.energy() << "  time = " << recHit.time()
0069                 << "  time error = " << recHit.timeError() << std::endl;
0070 
0071     }  // recHit loop
0072 
0073   }  // if ( h_BTL_reco->size() > 0 )
0074 
0075   // --- ETL RECOs:
0076 
0077   if (!h_ETL_reco->empty()) {
0078     std::cout << " ----------------------------------------" << std::endl;
0079     std::cout << " ETL RECO collection:" << std::endl;
0080 
0081     for (const auto& recHit : *h_ETL_reco) {
0082       MTDDetId mtdDetId(recHit.id());
0083 
0084       // --- detector element ID:
0085       std::cout << "   det ID:  det = " << mtdDetId.det() << "  subdet = " << mtdDetId.mtdSubDetector()
0086                 << "  rawID = " << mtdDetId.rawId() << std::endl;
0087 
0088       std::cout << "       energy = " << recHit.energy() << "  time = " << recHit.time()
0089                 << "  time error = " << recHit.timeError() << std::endl;
0090 
0091     }  // recHit loop
0092 
0093   }  // if ( h_ETL_reco->size() > 0 )
0094 }
0095 
0096 // ------------ method called once each job just before starting event loop  ------------
0097 void MTDRecoDump::beginJob() {}
0098 
0099 // ------------ method called once each job just after ending the event loop  ------------
0100 void MTDRecoDump::endJob() {}
0101 
0102 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0103 void MTDRecoDump::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0104   //The following says we do not know what parameters are allowed so do no validation
0105   // Please change this to state exactly what you do use, even if it is no parameters
0106   edm::ParameterSetDescription desc;
0107   desc.setUnknown();
0108   descriptions.addDefault(desc);
0109 }
0110 
0111 //define this as a plug-in
0112 DEFINE_FWK_MODULE(MTDRecoDump);