Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:48

0001 // -*- C++ -*-
0002 //
0003 // Package:    SimMuon/Neutron
0004 // Class:      NeutronHitsCollector
0005 //
0006 /**\class NeutronHitsCollector NeutronHitsCollector.cc SimMuon/Neutron/plugins/NeutronHitsCollector.cc
0007 
0008  Description:
0009  Utility for neutron SimHits produced by CSC/RPC/DTNeutronWriter modules.
0010    * Re-packs neutron simhits in muon detectors into new collections that have a single module label.
0011    * Creates a bunch of empty collections with the same module label to make MixingModule happy
0012 
0013 
0014 */
0015 //
0016 // Original Author:  Vadim Khotilovich
0017 //         Created:  Mon Aug 09 19:11:42 CST 2010
0018 //
0019 //
0020 
0021 #include "FWCore/Framework/interface/Frameworkfwd.h"
0022 #include "FWCore/Framework/interface/stream/EDProducer.h"
0023 #include "FWCore/Framework/interface/ESHandle.h"
0024 
0025 #include "FWCore/Framework/interface/Event.h"
0026 #include "FWCore/Framework/interface/MakerMacros.h"
0027 
0028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0029 
0030 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0031 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
0032 
0033 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0034 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
0035 
0036 class NeutronHitsCollector : public edm::stream::EDProducer<> {
0037 public:
0038   explicit NeutronHitsCollector(const edm::ParameterSet&);
0039   ~NeutronHitsCollector() override = default;
0040 
0041 private:
0042   virtual void beginJob();
0043   void produce(edm::Event&, const edm::EventSetup&) override;
0044   virtual void endJob();
0045 
0046   const std::string neutron_label_csc;
0047   const std::string neutron_label_dt;
0048   const std::string neutron_label_rpc;
0049   const edm::EDGetTokenT<edm::PSimHitContainer> tokenCSC_;
0050   const edm::EDGetTokenT<edm::PSimHitContainer> tokenDT_;
0051   const edm::EDGetTokenT<edm::PSimHitContainer> tokenRPC_;
0052 };
0053 
0054 NeutronHitsCollector::NeutronHitsCollector(const edm::ParameterSet& iConfig)
0055     : neutron_label_csc(iConfig.getUntrackedParameter<std::string>("neutronLabelCSC", "")),
0056       neutron_label_dt(iConfig.getUntrackedParameter<std::string>("neutronLabelDT", "")),
0057       neutron_label_rpc(iConfig.getUntrackedParameter<std::string>("neutronLabelRPC", "")),
0058       tokenCSC_(consumes<edm::PSimHitContainer>(neutron_label_csc)),
0059       tokenDT_(consumes<edm::PSimHitContainer>(neutron_label_dt)),
0060       tokenRPC_(consumes<edm::PSimHitContainer>(neutron_label_rpc)) {
0061   // The following list duplicates
0062   // http://cmslxr.fnal.gov/lxr/source/SimG4Core/Application/plugins/OscarProducer.cc
0063 
0064   produces<edm::PSimHitContainer>("MuonDTHits");
0065   produces<edm::PSimHitContainer>("MuonCSCHits");
0066   produces<edm::PSimHitContainer>("MuonRPCHits");
0067 
0068   produces<edm::SimTrackContainer>().setBranchAlias("SimTracks");
0069   produces<edm::SimVertexContainer>().setBranchAlias("SimVertices");
0070 
0071   produces<edm::PSimHitContainer>("TrackerHitsPixelBarrelLowTof");
0072   produces<edm::PSimHitContainer>("TrackerHitsPixelBarrelHighTof");
0073   produces<edm::PSimHitContainer>("TrackerHitsTIBLowTof");
0074   produces<edm::PSimHitContainer>("TrackerHitsTIBHighTof");
0075   produces<edm::PSimHitContainer>("TrackerHitsTIDLowTof");
0076   produces<edm::PSimHitContainer>("TrackerHitsTIDHighTof");
0077   produces<edm::PSimHitContainer>("TrackerHitsPixelEndcapLowTof");
0078   produces<edm::PSimHitContainer>("TrackerHitsPixelEndcapHighTof");
0079   produces<edm::PSimHitContainer>("TrackerHitsTOBLowTof");
0080   produces<edm::PSimHitContainer>("TrackerHitsTOBHighTof");
0081   produces<edm::PSimHitContainer>("TrackerHitsTECLowTof");
0082   produces<edm::PSimHitContainer>("TrackerHitsTECHighTof");
0083 
0084   produces<edm::PSimHitContainer>("TotemHitsT1");
0085   produces<edm::PSimHitContainer>("TotemHitsT2Gem");
0086   produces<edm::PSimHitContainer>("TotemHitsRP");
0087   produces<edm::PSimHitContainer>("FP420SI");
0088   produces<edm::PSimHitContainer>("BSCHits");
0089 
0090   produces<edm::PCaloHitContainer>("EcalHitsEB");
0091   produces<edm::PCaloHitContainer>("EcalHitsEE");
0092   produces<edm::PCaloHitContainer>("EcalHitsES");
0093   produces<edm::PCaloHitContainer>("HcalHits");
0094   produces<edm::PCaloHitContainer>("CaloHitsTk");
0095   produces<edm::PCaloHitContainer>("CastorPL");
0096   produces<edm::PCaloHitContainer>("CastorFI");
0097   produces<edm::PCaloHitContainer>("CastorBU");
0098   produces<edm::PCaloHitContainer>("CastorTU");
0099   produces<edm::PCaloHitContainer>("EcalTBH4BeamHits");
0100   produces<edm::PCaloHitContainer>("HcalTB06BeamHits");
0101   produces<edm::PCaloHitContainer>("ZDCHITS");
0102   //produces<edm::PCaloHitContainer>("ChamberHits");
0103   //produces<edm::PCaloHitContainer>("FibreHits");
0104   //produces<edm::PCaloHitContainer>("WedgeHits");
0105 }
0106 
0107 void NeutronHitsCollector::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0108   edm::PSimHitContainer::const_iterator hit;
0109 
0110   // ----- MuonCSCHits -----
0111   //
0112   std::unique_ptr<edm::PSimHitContainer> simCSC(new edm::PSimHitContainer);
0113   if (neutron_label_csc.length() > 0) {
0114     const edm::Handle<edm::PSimHitContainer>& MuonCSCHits = iEvent.getHandle(tokenCSC_);
0115     for (hit = MuonCSCHits->begin(); hit != MuonCSCHits->end(); ++hit)
0116       simCSC->push_back(*hit);
0117   }
0118   iEvent.put(std::move(simCSC), "MuonCSCHits");
0119 
0120   // ----- MuonDTHits -----
0121   //
0122   std::unique_ptr<edm::PSimHitContainer> simDT(new edm::PSimHitContainer);
0123   if (neutron_label_dt.length() > 0) {
0124     const edm::Handle<edm::PSimHitContainer>& MuonDTHits = iEvent.getHandle(tokenDT_);
0125     for (hit = MuonDTHits->begin(); hit != MuonDTHits->end(); ++hit)
0126       simDT->push_back(*hit);
0127   }
0128   iEvent.put(std::move(simDT), "MuonDTHits");
0129 
0130   // ----- MuonRPCHits -----
0131   //
0132   std::unique_ptr<edm::PSimHitContainer> simRPC(new edm::PSimHitContainer);
0133   if (neutron_label_rpc.length() > 0) {
0134     const edm::Handle<edm::PSimHitContainer>& MuonRPCHits = iEvent.getHandle(tokenRPC_);
0135     for (hit = MuonRPCHits->begin(); hit != MuonRPCHits->end(); ++hit)
0136       simRPC->push_back(*hit);
0137   }
0138   iEvent.put(std::move(simRPC), "MuonRPCHits");
0139 
0140   // Further, produce a bunch of empty collections
0141 
0142   // ----- calorimetry -----
0143   //
0144   std::unique_ptr<edm::PCaloHitContainer> calout1(new edm::PCaloHitContainer);
0145   iEvent.put(std::move(calout1), "EcalHitsEB");
0146   std::unique_ptr<edm::PCaloHitContainer> calout2(new edm::PCaloHitContainer);
0147   iEvent.put(std::move(calout2), "EcalHitsEE");
0148   std::unique_ptr<edm::PCaloHitContainer> calout3(new edm::PCaloHitContainer);
0149   iEvent.put(std::move(calout3), "EcalHitsES");
0150   std::unique_ptr<edm::PCaloHitContainer> calout4(new edm::PCaloHitContainer);
0151   iEvent.put(std::move(calout4), "HcalHits");
0152   std::unique_ptr<edm::PCaloHitContainer> calout5(new edm::PCaloHitContainer);
0153   iEvent.put(std::move(calout5), "CaloHitsTk");
0154   std::unique_ptr<edm::PCaloHitContainer> calout6(new edm::PCaloHitContainer);
0155   iEvent.put(std::move(calout6), "CastorPL");
0156   std::unique_ptr<edm::PCaloHitContainer> calout7(new edm::PCaloHitContainer);
0157   iEvent.put(std::move(calout7), "CastorFI");
0158   std::unique_ptr<edm::PCaloHitContainer> calout8(new edm::PCaloHitContainer);
0159   iEvent.put(std::move(calout8), "CastorBU");
0160   std::unique_ptr<edm::PCaloHitContainer> calout9(new edm::PCaloHitContainer);
0161   iEvent.put(std::move(calout9), "CastorTU");
0162   std::unique_ptr<edm::PCaloHitContainer> calout10(new edm::PCaloHitContainer);
0163   iEvent.put(std::move(calout10), "EcalTBH4BeamHits");
0164   std::unique_ptr<edm::PCaloHitContainer> calout11(new edm::PCaloHitContainer);
0165   iEvent.put(std::move(calout11), "HcalTB06BeamHits");
0166   std::unique_ptr<edm::PCaloHitContainer> calout12(new edm::PCaloHitContainer);
0167   iEvent.put(std::move(calout12), "ZDCHITS");
0168   //std::unique_ptr<edm::PCaloHitContainer> calout13(new edm::PCaloHitContainer);
0169   //iEvent.put(std::move(calout13), "ChamberHits");
0170   //std::unique_ptr<edm::PCaloHitContainer> calout14(new edm::PCaloHitContainer);
0171   //iEvent.put(std::move(calout14), "FibreHits");
0172   //std::unique_ptr<edm::PCaloHitContainer> calout15(new edm::PCaloHitContainer);
0173   //iEvent.put(std::move(calout15), "WedgeHits");
0174 
0175   // ----- Tracker -----
0176   //
0177   std::unique_ptr<edm::PSimHitContainer> trout1(new edm::PSimHitContainer);
0178   iEvent.put(std::move(trout1), "TrackerHitsPixelBarrelLowTof");
0179   std::unique_ptr<edm::PSimHitContainer> trout2(new edm::PSimHitContainer);
0180   iEvent.put(std::move(trout2), "TrackerHitsPixelBarrelHighTof");
0181   std::unique_ptr<edm::PSimHitContainer> trout3(new edm::PSimHitContainer);
0182   iEvent.put(std::move(trout3), "TrackerHitsTIBLowTof");
0183   std::unique_ptr<edm::PSimHitContainer> trout4(new edm::PSimHitContainer);
0184   iEvent.put(std::move(trout4), "TrackerHitsTIBHighTof");
0185   std::unique_ptr<edm::PSimHitContainer> trout5(new edm::PSimHitContainer);
0186   iEvent.put(std::move(trout5), "TrackerHitsTIDLowTof");
0187   std::unique_ptr<edm::PSimHitContainer> trout6(new edm::PSimHitContainer);
0188   iEvent.put(std::move(trout6), "TrackerHitsTIDHighTof");
0189   std::unique_ptr<edm::PSimHitContainer> trout7(new edm::PSimHitContainer);
0190   iEvent.put(std::move(trout7), "TrackerHitsPixelEndcapLowTof");
0191   std::unique_ptr<edm::PSimHitContainer> trout8(new edm::PSimHitContainer);
0192   iEvent.put(std::move(trout8), "TrackerHitsPixelEndcapHighTof");
0193   std::unique_ptr<edm::PSimHitContainer> trout9(new edm::PSimHitContainer);
0194   iEvent.put(std::move(trout9), "TrackerHitsTOBLowTof");
0195   std::unique_ptr<edm::PSimHitContainer> trout10(new edm::PSimHitContainer);
0196   iEvent.put(std::move(trout10), "TrackerHitsTOBHighTof");
0197   std::unique_ptr<edm::PSimHitContainer> trout11(new edm::PSimHitContainer);
0198   iEvent.put(std::move(trout11), "TrackerHitsTECLowTof");
0199   std::unique_ptr<edm::PSimHitContainer> trout12(new edm::PSimHitContainer);
0200   iEvent.put(std::move(trout12), "TrackerHitsTECHighTof");
0201 
0202   // ----- Forward stuff -----
0203   //
0204   std::unique_ptr<edm::PSimHitContainer> fwout1(new edm::PSimHitContainer);
0205   iEvent.put(std::move(fwout1), "TotemHitsT1");
0206   std::unique_ptr<edm::PSimHitContainer> fwout2(new edm::PSimHitContainer);
0207   iEvent.put(std::move(fwout2), "TotemHitsT2Gem");
0208   std::unique_ptr<edm::PSimHitContainer> fwout3(new edm::PSimHitContainer);
0209   iEvent.put(std::move(fwout3), "TotemHitsRP");
0210   std::unique_ptr<edm::PSimHitContainer> fwout4(new edm::PSimHitContainer);
0211   iEvent.put(std::move(fwout4), "FP420SI");
0212   std::unique_ptr<edm::PSimHitContainer> fwout5(new edm::PSimHitContainer);
0213   iEvent.put(std::move(fwout5), "BSCHits");
0214 
0215   // ----- SimTracks & SimVertices -----
0216   //
0217   std::unique_ptr<edm::SimTrackContainer> simTr(new edm::SimTrackContainer);
0218   iEvent.put(std::move(simTr));
0219   std::unique_ptr<edm::SimVertexContainer> simVe(new edm::SimVertexContainer);
0220   iEvent.put(std::move(simVe));
0221 }
0222 
0223 void NeutronHitsCollector::beginJob() {}
0224 
0225 void NeutronHitsCollector::endJob() {}
0226 
0227 //define this as a plug-in
0228 DEFINE_FWK_MODULE(NeutronHitsCollector);