CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/SimMuon/Neutron/plugins/NeutronHitsCollector.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    SimMuon/Neutron
00004 // Class:      NeutronHitsCollector
00005 //
00015 //
00016 // Original Author:  Vadim Khotilovich
00017 //         Created:  Mon Aug 09 19:11:42 CST 2010
00018 // $Id: NeutronHitsCollector.cc,v 1.1 2010/08/20 00:28:13 khotilov Exp $
00019 //
00020 //
00021 
00022 #include "FWCore/Framework/interface/Frameworkfwd.h"
00023 #include "FWCore/Framework/interface/EDProducer.h"
00024 #include "FWCore/Framework/interface/ESHandle.h"
00025 
00026 #include "FWCore/Framework/interface/Event.h"
00027 #include "FWCore/Framework/interface/MakerMacros.h"
00028 
00029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00030 
00031 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
00032 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
00033 
00034 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00035 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
00036 
00037 
00038 
00039 class NeutronHitsCollector : public edm::EDProducer
00040 {
00041 public:
00042   explicit NeutronHitsCollector(const edm::ParameterSet&);
00043   ~NeutronHitsCollector() {};
00044 
00045 private:
00046   virtual void beginJob();
00047   virtual void produce(edm::Event&, const edm::EventSetup&);
00048   virtual void endJob();
00049 
00050   std::string neutron_label_csc;
00051   std::string neutron_label_dt;
00052   std::string neutron_label_rpc;
00053 };
00054 
00055 
00056 
00057 NeutronHitsCollector::NeutronHitsCollector(const edm::ParameterSet& iConfig)
00058 {
00059   neutron_label_csc = iConfig.getUntrackedParameter<std::string>("neutronLabelCSC","");
00060   neutron_label_dt  = iConfig.getUntrackedParameter<std::string>("neutronLabelDT","");
00061   neutron_label_rpc = iConfig.getUntrackedParameter<std::string>("neutronLabelRPC","");
00062 
00063   // The following list duplicates
00064   // https://cmslxr.fnal.gov/lxr/source/SimG4Core/Application/plugins/OscarProducer.cc
00065 
00066   produces<edm::PSimHitContainer>("MuonDTHits");
00067   produces<edm::PSimHitContainer>("MuonCSCHits");
00068   produces<edm::PSimHitContainer>("MuonRPCHits");
00069 
00070   produces<edm::SimTrackContainer>().setBranchAlias("SimTracks");
00071   produces<edm::SimVertexContainer>().setBranchAlias("SimVertices");
00072 
00073   produces<edm::PSimHitContainer>("TrackerHitsPixelBarrelLowTof");
00074   produces<edm::PSimHitContainer>("TrackerHitsPixelBarrelHighTof");
00075   produces<edm::PSimHitContainer>("TrackerHitsTIBLowTof");
00076   produces<edm::PSimHitContainer>("TrackerHitsTIBHighTof");
00077   produces<edm::PSimHitContainer>("TrackerHitsTIDLowTof");
00078   produces<edm::PSimHitContainer>("TrackerHitsTIDHighTof");
00079   produces<edm::PSimHitContainer>("TrackerHitsPixelEndcapLowTof");
00080   produces<edm::PSimHitContainer>("TrackerHitsPixelEndcapHighTof");
00081   produces<edm::PSimHitContainer>("TrackerHitsTOBLowTof");
00082   produces<edm::PSimHitContainer>("TrackerHitsTOBHighTof");
00083   produces<edm::PSimHitContainer>("TrackerHitsTECLowTof");
00084   produces<edm::PSimHitContainer>("TrackerHitsTECHighTof");
00085 
00086   produces<edm::PSimHitContainer>("TotemHitsT1");
00087   produces<edm::PSimHitContainer>("TotemHitsT2Gem");
00088   produces<edm::PSimHitContainer>("TotemHitsRP");
00089   produces<edm::PSimHitContainer>("FP420SI");
00090   produces<edm::PSimHitContainer>("BSCHits");
00091 
00092   produces<edm::PCaloHitContainer>("EcalHitsEB");
00093   produces<edm::PCaloHitContainer>("EcalHitsEE");
00094   produces<edm::PCaloHitContainer>("EcalHitsES");
00095   produces<edm::PCaloHitContainer>("HcalHits");
00096   produces<edm::PCaloHitContainer>("CaloHitsTk");
00097   produces<edm::PCaloHitContainer>("CastorPL");
00098   produces<edm::PCaloHitContainer>("CastorFI");
00099   produces<edm::PCaloHitContainer>("CastorBU");
00100   produces<edm::PCaloHitContainer>("CastorTU");
00101   produces<edm::PCaloHitContainer>("EcalTBH4BeamHits");
00102   produces<edm::PCaloHitContainer>("HcalTB06BeamHits");
00103   produces<edm::PCaloHitContainer>("ZDCHITS");
00104   //produces<edm::PCaloHitContainer>("ChamberHits");
00105   //produces<edm::PCaloHitContainer>("FibreHits");
00106   //produces<edm::PCaloHitContainer>("WedgeHits");
00107 
00108 }
00109 
00110 
00111 void NeutronHitsCollector::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00112 {
00113   edm::PSimHitContainer::const_iterator hit;
00114 
00115   // ----- MuonCSCHits -----
00116   //
00117   std::auto_ptr<edm::PSimHitContainer> simCSC(new edm::PSimHitContainer);
00118   if (neutron_label_csc.length()>0)
00119   {
00120     edm::Handle<edm::PSimHitContainer> MuonCSCHits;
00121     iEvent.getByLabel(neutron_label_csc,MuonCSCHits);
00122     for (hit = MuonCSCHits->begin();  hit != MuonCSCHits->end();  ++hit) simCSC->push_back(*hit);
00123   }
00124   iEvent.put(simCSC, "MuonCSCHits");
00125 
00126   // ----- MuonDTHits -----
00127   //
00128   std::auto_ptr<edm::PSimHitContainer> simDT(new edm::PSimHitContainer);
00129   if (neutron_label_dt.length()>0)
00130   {
00131     edm::Handle<edm::PSimHitContainer> MuonDTHits;
00132     iEvent.getByLabel(neutron_label_dt,MuonDTHits);
00133     for (hit = MuonDTHits->begin();  hit != MuonDTHits->end();  ++hit) simDT->push_back(*hit);
00134   }
00135   iEvent.put(simDT, "MuonDTHits");
00136 
00137   // ----- MuonRPCHits -----
00138   //
00139   std::auto_ptr<edm::PSimHitContainer> simRPC(new edm::PSimHitContainer);
00140   if (neutron_label_rpc.length()>0)
00141   {
00142     edm::Handle<edm::PSimHitContainer> MuonRPCHits;
00143     iEvent.getByLabel(neutron_label_rpc,MuonRPCHits);
00144     for (hit = MuonRPCHits->begin();  hit != MuonRPCHits->end();  ++hit) simRPC->push_back(*hit);
00145   }
00146   iEvent.put(simRPC, "MuonRPCHits");
00147 
00148   // Further, produce a bunch of empty collections
00149 
00150   // ----- calorimetry -----
00151   //
00152   std::auto_ptr<edm::PCaloHitContainer> calout1(new edm::PCaloHitContainer);
00153   iEvent.put(calout1, "EcalHitsEB");
00154   std::auto_ptr<edm::PCaloHitContainer> calout2(new edm::PCaloHitContainer);
00155   iEvent.put(calout2, "EcalHitsEE");
00156   std::auto_ptr<edm::PCaloHitContainer> calout3(new edm::PCaloHitContainer);
00157   iEvent.put(calout3, "EcalHitsES");
00158   std::auto_ptr<edm::PCaloHitContainer> calout4(new edm::PCaloHitContainer);
00159   iEvent.put(calout4, "HcalHits");
00160   std::auto_ptr<edm::PCaloHitContainer> calout5(new edm::PCaloHitContainer);
00161   iEvent.put(calout5, "CaloHitsTk");
00162   std::auto_ptr<edm::PCaloHitContainer> calout6(new edm::PCaloHitContainer);
00163   iEvent.put(calout6, "CastorPL");
00164   std::auto_ptr<edm::PCaloHitContainer> calout7(new edm::PCaloHitContainer);
00165   iEvent.put(calout7, "CastorFI");
00166   std::auto_ptr<edm::PCaloHitContainer> calout8(new edm::PCaloHitContainer);
00167   iEvent.put(calout8, "CastorBU");
00168   std::auto_ptr<edm::PCaloHitContainer> calout9(new edm::PCaloHitContainer);
00169   iEvent.put(calout9, "CastorTU");
00170   std::auto_ptr<edm::PCaloHitContainer> calout10(new edm::PCaloHitContainer);
00171   iEvent.put(calout10, "EcalTBH4BeamHits");
00172   std::auto_ptr<edm::PCaloHitContainer> calout11(new edm::PCaloHitContainer);
00173   iEvent.put(calout11, "HcalTB06BeamHits");
00174   std::auto_ptr<edm::PCaloHitContainer> calout12(new edm::PCaloHitContainer);
00175   iEvent.put(calout12, "ZDCHITS");
00176   //std::auto_ptr<edm::PCaloHitContainer> calout13(new edm::PCaloHitContainer);
00177   //iEvent.put(calout13, "ChamberHits");
00178   //std::auto_ptr<edm::PCaloHitContainer> calout14(new edm::PCaloHitContainer);
00179   //iEvent.put(calout14, "FibreHits");
00180   //std::auto_ptr<edm::PCaloHitContainer> calout15(new edm::PCaloHitContainer);
00181   //iEvent.put(calout15, "WedgeHits");
00182 
00183   // ----- Tracker -----
00184   //
00185   std::auto_ptr<edm::PSimHitContainer> trout1(new edm::PSimHitContainer);
00186   iEvent.put(trout1, "TrackerHitsPixelBarrelLowTof");
00187   std::auto_ptr<edm::PSimHitContainer> trout2(new edm::PSimHitContainer);
00188   iEvent.put(trout2, "TrackerHitsPixelBarrelHighTof");
00189   std::auto_ptr<edm::PSimHitContainer> trout3(new edm::PSimHitContainer);
00190   iEvent.put(trout3, "TrackerHitsTIBLowTof");
00191   std::auto_ptr<edm::PSimHitContainer> trout4(new edm::PSimHitContainer);
00192   iEvent.put(trout4, "TrackerHitsTIBHighTof");
00193   std::auto_ptr<edm::PSimHitContainer> trout5(new edm::PSimHitContainer);
00194   iEvent.put(trout5, "TrackerHitsTIDLowTof");
00195   std::auto_ptr<edm::PSimHitContainer> trout6(new edm::PSimHitContainer);
00196   iEvent.put(trout6, "TrackerHitsTIDHighTof");
00197   std::auto_ptr<edm::PSimHitContainer> trout7(new edm::PSimHitContainer);
00198   iEvent.put(trout7, "TrackerHitsPixelEndcapLowTof");
00199   std::auto_ptr<edm::PSimHitContainer> trout8(new edm::PSimHitContainer);
00200   iEvent.put(trout8, "TrackerHitsPixelEndcapHighTof");
00201   std::auto_ptr<edm::PSimHitContainer> trout9(new edm::PSimHitContainer);
00202   iEvent.put(trout9, "TrackerHitsTOBLowTof");
00203   std::auto_ptr<edm::PSimHitContainer> trout10(new edm::PSimHitContainer);
00204   iEvent.put(trout10, "TrackerHitsTOBHighTof");
00205   std::auto_ptr<edm::PSimHitContainer> trout11(new edm::PSimHitContainer);
00206   iEvent.put(trout11, "TrackerHitsTECLowTof");
00207   std::auto_ptr<edm::PSimHitContainer> trout12(new edm::PSimHitContainer);
00208   iEvent.put(trout12, "TrackerHitsTECHighTof");
00209 
00210   // ----- Forward stuff -----
00211   //
00212   std::auto_ptr<edm::PSimHitContainer> fwout1(new edm::PSimHitContainer);
00213   iEvent.put(fwout1, "TotemHitsT1");
00214   std::auto_ptr<edm::PSimHitContainer> fwout2(new edm::PSimHitContainer);
00215   iEvent.put(fwout2, "TotemHitsT2Gem");
00216   std::auto_ptr<edm::PSimHitContainer> fwout3(new edm::PSimHitContainer);
00217   iEvent.put(fwout3, "TotemHitsRP");
00218   std::auto_ptr<edm::PSimHitContainer> fwout4(new edm::PSimHitContainer);
00219   iEvent.put(fwout4, "FP420SI");
00220   std::auto_ptr<edm::PSimHitContainer> fwout5(new edm::PSimHitContainer);
00221   iEvent.put(fwout5, "BSCHits");
00222 
00223   // ----- SimTracks & SimVertices -----
00224   //
00225   std::auto_ptr<edm::SimTrackContainer> simTr(new edm::SimTrackContainer);
00226   iEvent.put(simTr);
00227   std::auto_ptr<edm::SimVertexContainer> simVe(new edm::SimVertexContainer);
00228   iEvent.put(simVe);
00229 
00230 
00231 }
00232 
00233 
00234 void NeutronHitsCollector::beginJob() {}
00235 
00236 
00237 void NeutronHitsCollector::endJob() {}
00238 
00239 
00240 //define this as a plug-in
00241 DEFINE_FWK_MODULE(NeutronHitsCollector);