Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-23 03:25:37

0001 #include "FWCore/Framework/interface/Event.h"
0002 #include "FWCore/Framework/interface/EventSetup.h"
0003 #include "FWCore/Framework/interface/MakerMacros.h"
0004 #include "FWCore/Framework/interface/global/EDProducer.h"
0005 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0008 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0009 
0010 #include "SimGeneral/TrackingAnalysis/interface/TrackingParticleNumberOfLayers.h"
0011 
0012 /**
0013  * The purpose of this producer is to create a ValueMap<pair<unsigned int,
0014  * unsigned int>> for the number of pixel and strip stereo tracker layers the
0015  * TrackingParticle has hits on.
0016  */
0017 class TrackingParticleNumberOfLayersProducer : public edm::global::EDProducer<> {
0018 public:
0019   TrackingParticleNumberOfLayersProducer(const edm::ParameterSet &iConfig);
0020 
0021   static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
0022 
0023   void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override;
0024 
0025 private:
0026   edm::EDGetTokenT<TrackingParticleCollection> tpToken_;
0027   std::vector<edm::EDGetTokenT<std::vector<PSimHit>>> simHitTokens_;
0028   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
0029 };
0030 
0031 TrackingParticleNumberOfLayersProducer::TrackingParticleNumberOfLayersProducer(const edm::ParameterSet &iConfig)
0032     : tpToken_(consumes<TrackingParticleCollection>(iConfig.getParameter<edm::InputTag>("trackingParticles"))),
0033       tTopoToken_(esConsumes()) {
0034   for (const auto &tag : iConfig.getParameter<std::vector<edm::InputTag>>("simHits")) {
0035     simHitTokens_.push_back(consumes<std::vector<PSimHit>>(tag));
0036   }
0037 
0038   produces<edm::ValueMap<unsigned int>>("trackerLayers");
0039   produces<edm::ValueMap<unsigned int>>("pixelLayers");
0040   produces<edm::ValueMap<unsigned int>>("stripStereoLayers");
0041 }
0042 
0043 void TrackingParticleNumberOfLayersProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
0044   edm::ParameterSetDescription desc;
0045   desc.add<edm::InputTag>("trackingParticles", edm::InputTag("mix", "MergedTrackTruth"));
0046 
0047   desc.add<std::vector<edm::InputTag>>("simHits",
0048                                        {edm::InputTag("g4SimHits", "TrackerHitsPixelBarrelLowTof"),
0049                                         edm::InputTag("g4SimHits", "TrackerHitsPixelBarrelHighTof"),
0050                                         edm::InputTag("g4SimHits", "TrackerHitsPixelEndcapLowTof"),
0051                                         edm::InputTag("g4SimHits", "TrackerHitsPixelEndcapHighTof"),
0052                                         edm::InputTag("g4SimHits", "TrackerHitsTIBLowTof"),
0053                                         edm::InputTag("g4SimHits", "TrackerHitsTIBHighTof"),
0054                                         edm::InputTag("g4SimHits", "TrackerHitsTIDLowTof"),
0055                                         edm::InputTag("g4SimHits", "TrackerHitsTIDHighTof"),
0056                                         edm::InputTag("g4SimHits", "TrackerHitsTOBLowTof"),
0057                                         edm::InputTag("g4SimHits", "TrackerHitsTOBHighTof"),
0058                                         edm::InputTag("g4SimHits", "TrackerHitsTECLowTof"),
0059                                         edm::InputTag("g4SimHits", "TrackerHitsTECHighTof")});
0060 
0061   descriptions.add("trackingParticleNumberOfLayersProducer", desc);
0062 }
0063 
0064 void TrackingParticleNumberOfLayersProducer::produce(edm::StreamID,
0065                                                      edm::Event &iEvent,
0066                                                      const edm::EventSetup &iSetup) const {
0067   edm::Handle<TrackingParticleCollection> htps;
0068   iEvent.getByToken(tpToken_, htps);
0069 
0070   TrackingParticleNumberOfLayers algo(iEvent, simHitTokens_);
0071   auto ret = algo.calculate(htps, iSetup.getData(tTopoToken_));
0072   iEvent.put(std::move(std::get<TrackingParticleNumberOfLayers::nTrackerLayers>(ret)), "trackerLayers");
0073   iEvent.put(std::move(std::get<TrackingParticleNumberOfLayers::nPixelLayers>(ret)), "pixelLayers");
0074   iEvent.put(std::move(std::get<TrackingParticleNumberOfLayers::nStripMonoAndStereoLayers>(ret)), "stripStereoLayers");
0075 }
0076 
0077 DEFINE_FWK_MODULE(TrackingParticleNumberOfLayersProducer);