Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-23 02:49:34

0001 /****************************************************************************
0002  *
0003  * This is a part of CTPPS offline software.
0004  * Authors:
0005  *   Laurent Forthomme (laurent.forthomme@cern.ch)
0006  *   Nicola Minafra (nicola.minafra@cern.ch)
0007  *   Christopher Misan (krzysztof.misan@cern.ch)
0008  *
0009  ****************************************************************************/
0010 
0011 #include <memory>
0012 
0013 #include "FWCore/Framework/interface/Frameworkfwd.h"
0014 #include "FWCore/Framework/interface/stream/EDProducer.h"
0015 #include "FWCore/Framework/interface/Event.h"
0016 #include "FWCore/Framework/interface/MakerMacros.h"
0017 #include "FWCore/Framework/interface/ESHandle.h"
0018 #include "FWCore/Framework/interface/ESWatcher.h"
0019 
0020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0021 #include "FWCore/Utilities/interface/StreamID.h"
0022 #include "FWCore/Utilities/interface/ESGetToken.h"
0023 
0024 #include "DataFormats/Common/interface/DetSetVector.h"
0025 #include "DataFormats/Common/interface/DetSet.h"
0026 
0027 #include "DataFormats/CTPPSDetId/interface/TotemTimingDetId.h"
0028 #include "DataFormats/CTPPSDigi/interface/TotemTimingDigi.h"
0029 #include "DataFormats/CTPPSReco/interface/TotemTimingRecHit.h"
0030 
0031 #include "RecoPPS/Local/interface/TotemTimingRecHitProducerAlgorithm.h"
0032 #include "RecoPPS/Local/interface/TotemTimingConversions.h"
0033 
0034 #include "Geometry/Records/interface/VeryForwardRealGeometryRecord.h"
0035 #include "Geometry/VeryForwardGeometryBuilder/interface/CTPPSGeometry.h"
0036 #include "CondFormats/DataRecord/interface/PPSTimingCalibrationRcd.h"
0037 
0038 /// TOTEM/PPS timing detectors digi-to-rechits conversion module
0039 class TotemTimingRecHitProducer : public edm::stream::EDProducer<> {
0040 public:
0041   explicit TotemTimingRecHitProducer(const edm::ParameterSet&);
0042 
0043   static void fillDescriptions(edm::ConfigurationDescriptions&);
0044 
0045 private:
0046   void produce(edm::Event&, const edm::EventSetup&) override;
0047 
0048   /// Input digi collection
0049   edm::EDGetTokenT<edm::DetSetVector<TotemTimingDigi> > digiToken_;
0050   ///EventSetup Tokens
0051   edm::ESGetToken<PPSTimingCalibration, PPSTimingCalibrationRcd> timingCalibrationToken_;
0052   edm::ESGetToken<CTPPSGeometry, VeryForwardRealGeometryRecord> geometryToken_;
0053   /// Digi-to-rechits transformation algorithm
0054   TotemTimingRecHitProducerAlgorithm algo_;
0055   /// Timing calibration parameters watcher
0056   edm::ESWatcher<PPSTimingCalibrationRcd> calibWatcher_;
0057 };
0058 
0059 TotemTimingRecHitProducer::TotemTimingRecHitProducer(const edm::ParameterSet& iConfig)
0060     : digiToken_(consumes<edm::DetSetVector<TotemTimingDigi> >(iConfig.getParameter<edm::InputTag>("digiTag"))),
0061       timingCalibrationToken_(esConsumes<PPSTimingCalibration, PPSTimingCalibrationRcd>(
0062           edm::ESInputTag(iConfig.getParameter<std::string>("timingCalibrationTag")))),
0063       geometryToken_(esConsumes<CTPPSGeometry, VeryForwardRealGeometryRecord>()),
0064       algo_(iConfig) {
0065   produces<edm::DetSetVector<TotemTimingRecHit> >();
0066 }
0067 
0068 void TotemTimingRecHitProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0069   std::unique_ptr<edm::DetSetVector<TotemTimingRecHit> > pOut(new edm::DetSetVector<TotemTimingRecHit>);
0070 
0071   // get the digi collection
0072   const auto& digis = iEvent.get(digiToken_);
0073 
0074   // do not retrieve the calibration parameters if no digis were found
0075   if (!digis.empty()) {
0076     // check for timing calibration parameters update
0077     if (calibWatcher_.check(iSetup))
0078       algo_.setCalibration(iSetup.getData(timingCalibrationToken_));
0079 
0080     // produce the rechits collection
0081     algo_.build(iSetup.getData(geometryToken_), digis, *pOut);
0082   }
0083 
0084   iEvent.put(std::move(pOut));
0085 }
0086 
0087 void TotemTimingRecHitProducer::fillDescriptions(edm::ConfigurationDescriptions& descr) {
0088   edm::ParameterSetDescription desc;
0089 
0090   desc.add<bool>("applyCalibration", false);
0091   desc.add<double>("timeSliceNs", 0.);
0092   desc.add<edm::InputTag>("digiTag", edm::InputTag("totemTimingRawToDigi", "TotemTiming"))
0093       ->setComment("input digis collection to retrieve");
0094   desc.add<std::string>("timingCalibrationTag", "GlobalTag:TotemTimingCalibration")
0095       ->setComment("input tag for timing calibrations retrieval");
0096   desc.add<int>("baselinePoints", 8)->setComment("number of points to be used for the baseline");
0097   desc.add<double>("saturationLimit", 0.1)
0098       ->setComment(
0099           "all signals with max > saturationLimit will be considered as saturated for UFSD, similarly with "
0100           "min<saturationLimit for a Diamond");
0101   desc.add<double>("cfdFraction", 0.3)->setComment("fraction of the CFD");
0102   desc.add<int>("smoothingPoints", 20)
0103       ->setComment("number of points to be used for the smoothing using sinc (lowpass)");
0104   desc.add<double>("lowPassFrequency", 0.7)
0105       ->setComment("Frequency (in GHz) for CFD smoothing, 0 for disabling the filter");
0106   desc.add<double>("hysteresis", 5.e-3)->setComment("hysteresis of the discriminator");
0107   desc.add<bool>("mergeTimePeaks", true)->setComment("if time peaks schould be merged");
0108   desc.add<double>("sampicOffset", 1.0)->setComment("offset of the flipped sampic signal");
0109   desc.add<double>("sampicSamplingPeriodNs", 1. / 7.695)->setComment("sapic sampling period in ns");
0110   descr.add("totemTimingRecHits", desc);
0111 }
0112 
0113 DEFINE_FWK_MODULE(TotemTimingRecHitProducer);