Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-10 02:59:09

0001 // system include files
0002 #include <vector>
0003 
0004 // user include files
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0007 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0008 #include "FWCore/Utilities/interface/EDGetToken.h"
0009 #include "DataFormats/Common/interface/ValidHandle.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 
0015 #include "SimDataFormats/CaloAnalysis/interface/MtdSimLayerCluster.h"
0016 #include "SimDataFormats/CaloAnalysis/interface/MtdSimLayerClusterFwd.h"
0017 
0018 class MtdTruthDumper : public edm::one::EDAnalyzer<> {
0019 public:
0020   explicit MtdTruthDumper(const edm::ParameterSet&);
0021   ~MtdTruthDumper() override {}
0022 
0023   void analyze(const edm::Event&, const edm::EventSetup&) override;
0024   void beginJob() override {}
0025   void endJob() override {}
0026 
0027   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0028 
0029 private:
0030   edm::EDGetTokenT<MtdSimLayerClusterCollection> mtdSimLCToken_;
0031 };
0032 
0033 MtdTruthDumper::MtdTruthDumper(const edm::ParameterSet& iConfig)
0034     : mtdSimLCToken_(
0035           consumes<MtdSimLayerClusterCollection>(iConfig.getParameter<edm::InputTag>("moduleLabelMtdSimLC"))) {}
0036 
0037 //
0038 // member functions
0039 //
0040 
0041 // ------------ method called to produce the data  ------------
0042 void MtdTruthDumper::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0043   auto mtdSimLCcoll = edm::makeValid(iEvent.getHandle(mtdSimLCToken_));
0044 
0045   edm::LogPrint("DumpMtdSimLC") << "\n MtdSimLayerCluster collection dump \n";
0046   edm::LogPrint("DumpMtdSimLC") << " MtdSimLayerCluster in the event = " << (*mtdSimLCcoll).size();
0047   size_t isimLC(0);
0048 
0049   isimLC = 0;
0050   for (const auto& mtdLC : *mtdSimLCcoll) {
0051     edm::LogPrint("DumpMtdSimLC") << "MtdSimLayerCluster " << isimLC << " = " << mtdLC;
0052     size_t ihit(0);
0053     for (const auto& hit : mtdLC.detIds_and_rows()) {
0054       edm::LogPrint("DumpMtdSimLC") << "hit # " << ihit << " DetId " << hit.first << " r/c "
0055                                     << (uint32_t)hit.second.first << " " << (uint32_t)hit.second.second;
0056       ihit++;
0057     }
0058     isimLC++;
0059     edm::LogPrint("DumpMtdSimLC") << "\n";
0060   }
0061 
0062   return;
0063 }
0064 
0065 void MtdTruthDumper::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0066   edm::ParameterSetDescription desc;
0067   desc.add<edm::InputTag>("moduleLabelMtdSimLC", edm::InputTag("mix", "MergedMtdTruthLC"))
0068       ->setComment("Module for input MtdSimLayerCluster collection");
0069   descriptions.add("mtdTruthDumper", desc);
0070 }
0071 
0072 #include "FWCore/Framework/interface/MakerMacros.h"
0073 
0074 //define this as a plug-in
0075 DEFINE_FWK_MODULE(MtdTruthDumper);