Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 10:01:55

0001 /****************************************************************************
0002  *
0003  * This is a part of TOTEM offline software.
0004  * Authors:
0005  *   Laurent Forthomme (laurent.forthomme@cern.ch)
0006  *
0007  ****************************************************************************/
0008 
0009 #include <memory>
0010 
0011 #include "FWCore/Framework/interface/Frameworkfwd.h"
0012 #include "FWCore/Framework/interface/stream/EDProducer.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/MakerMacros.h"
0015 
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017 #include "FWCore/Utilities/interface/StreamID.h"
0018 
0019 #include "DataFormats/Common/interface/DetSet.h"
0020 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0021 
0022 #include "DataFormats/CTPPSDetId/interface/TotemT2DetId.h"
0023 #include "DataFormats/TotemReco/interface/TotemT2Digi.h"
0024 #include "DataFormats/TotemReco/interface/TotemT2RecHit.h"
0025 
0026 #include "RecoPPS/Local/interface/TotemT2RecHitProducerAlgorithm.h"
0027 
0028 #include "Geometry/Records/interface/TotemGeometryRcd.h"
0029 #include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h"
0030 
0031 class TotemT2RecHitProducer : public edm::stream::EDProducer<> {
0032 public:
0033   explicit TotemT2RecHitProducer(const edm::ParameterSet&);
0034 
0035   static void fillDescriptions(edm::ConfigurationDescriptions&);
0036 
0037 private:
0038   void produce(edm::Event&, const edm::EventSetup&) override;
0039 
0040   edm::EDGetTokenT<edmNew::DetSetVector<TotemT2Digi> > digiToken_;
0041   edm::ESGetToken<TotemGeometry, TotemGeometryRcd> geometryToken_;
0042   /// A watcher to detect timing calibration changes.
0043 
0044   const bool applyCalib_;  //Diamond calibration not used
0045   TotemT2RecHitProducerAlgorithm algo_;
0046 };
0047 
0048 TotemT2RecHitProducer::TotemT2RecHitProducer(const edm::ParameterSet& iConfig)
0049     : digiToken_(consumes<edmNew::DetSetVector<TotemT2Digi> >(iConfig.getParameter<edm::InputTag>("digiTag"))),
0050       geometryToken_(esConsumes<TotemGeometry, TotemGeometryRcd>()),
0051       applyCalib_(iConfig.getParameter<bool>("applyCalibration")),
0052       algo_(iConfig) {
0053   produces<edmNew::DetSetVector<TotemT2RecHit> >();
0054 }
0055 
0056 void TotemT2RecHitProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0057   auto pOut = std::make_unique<edmNew::DetSetVector<TotemT2RecHit> >();
0058 
0059   // get the digi collection
0060   const auto& digis = iEvent.get(digiToken_);
0061 
0062   if (!digis.empty()) {
0063     // produce the rechits collection
0064     algo_.build(iSetup.getData(geometryToken_), digis, *pOut);
0065   }
0066 
0067   iEvent.put(std::move(pOut));
0068 }
0069 
0070 void TotemT2RecHitProducer::fillDescriptions(edm::ConfigurationDescriptions& descr) {
0071   edm::ParameterSetDescription desc;
0072 
0073   desc.add<edm::InputTag>("digiTag", edm::InputTag("totemT2Digis", "TotemT2"))
0074       ->setComment("input digis collection to retrieve");
0075   desc.add<double>("timeSliceNs", 25.0 / 4.0)
0076       ->setComment("conversion constant between timing bin size and nanoseconds");
0077   desc.add<bool>("applyCalibration", false)->setComment("switch on/off the timing calibration (not in use)");
0078 
0079   descr.add("totemT2RecHits", desc);
0080 }
0081 
0082 DEFINE_FWK_MODULE(TotemT2RecHitProducer);