Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-07 05:50:19

0001 /** \file
0002  *  \author A. Tumanov - Rice
0003  */
0004 
0005 #include "EventFilter/CSCRawToDigi/interface/CSCDigiToRaw.h"
0006 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0007 #include "DataFormats/Common/interface/Handle.h"
0008 #include "FWCore/Framework/interface/Event.h"
0009 #include "FWCore/Framework/interface/ESHandle.h"
0010 #include "FWCore/Utilities/interface/ESGetToken.h"
0011 #include "FWCore/Framework/interface/EventSetup.h"
0012 #include "FWCore/Utilities/interface/InputTag.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0015 #include "CondFormats/DataRecord/interface/CSCChamberMapRcd.h"
0016 
0017 #include "FWCore/Framework/interface/ConsumesCollector.h"
0018 #include "FWCore/Framework/interface/global/EDProducer.h"
0019 #include "FWCore/Utilities/interface/InputTag.h"
0020 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0021 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0022 
0023 #include "FWCore/Framework/interface/MakerMacros.h"
0024 
0025 #include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
0026 #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
0027 #include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h"
0028 #include "DataFormats/CSCDigi/interface/CSCALCTDigiCollection.h"
0029 #include "DataFormats/CSCDigi/interface/CSCCLCTDigiCollection.h"
0030 #include "DataFormats/CSCDigi/interface/CSCCLCTPreTriggerCollection.h"
0031 #include "DataFormats/CSCDigi/interface/CSCCLCTPreTriggerDigiCollection.h"
0032 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
0033 #include "DataFormats/CSCDigi/interface/CSCShowerDigiCollection.h"
0034 #include "DataFormats/GEMDigi/interface/GEMPadDigiClusterCollection.h"
0035 
0036 namespace edm {
0037   class ConfigurationDescriptions;
0038 }
0039 
0040 class CSCDigiToRaw;
0041 
0042 class CSCDigiToRawModule : public edm::global::EDProducer<> {
0043 public:
0044   /// Constructor
0045   CSCDigiToRawModule(const edm::ParameterSet& pset);
0046 
0047   // Operations
0048   void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0049 
0050   // Fill parameters descriptions
0051   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0052 
0053 private:
0054   bool usePreTriggers_;  // Select if to use Pre-Triggers CLCT digis
0055   bool useGEMs_;
0056   bool useCSCShowers_;
0057 
0058   std::unique_ptr<const CSCDigiToRaw> packer_;
0059 
0060   edm::EDGetTokenT<CSCWireDigiCollection> wd_token;
0061   edm::EDGetTokenT<CSCStripDigiCollection> sd_token;
0062   edm::EDGetTokenT<CSCComparatorDigiCollection> cd_token;
0063   edm::EDGetTokenT<CSCALCTDigiCollection> al_token;
0064   edm::EDGetTokenT<CSCCLCTDigiCollection> cl_token;
0065   edm::EDGetTokenT<CSCCLCTPreTriggerCollection> pr_token;
0066   edm::EDGetTokenT<CSCCLCTPreTriggerDigiCollection> prdigi_token;
0067   edm::EDGetTokenT<CSCCorrelatedLCTDigiCollection> co_token;
0068   edm::ESGetToken<CSCChamberMap, CSCChamberMapRcd> cham_token;
0069 
0070   /// Run3 CSC Shower objects collections
0071   edm::EDGetTokenT<CSCShowerDigiCollection> shower_token;
0072   edm::EDGetTokenT<CSCShowerDigiCollection> anode_shower_token;
0073   edm::EDGetTokenT<CSCShowerDigiCollection> cathode_shower_token;
0074   edm::EDGetTokenT<CSCShowerDigiCollection> alct_anode_shower_token;
0075   /// Run3 GEM GE11 trigger objects collection
0076   edm::EDGetTokenT<GEMPadDigiClusterCollection> gem_token;
0077 
0078   edm::EDPutTokenT<FEDRawDataCollection> put_token_;
0079 };
0080 
0081 CSCDigiToRawModule::CSCDigiToRawModule(const edm::ParameterSet& pset) : packer_(std::make_unique<CSCDigiToRaw>(pset)) {
0082   usePreTriggers_ = pset.getParameter<bool>("usePreTriggers");  // disable checking CLCT PreTriggers digis
0083 
0084   useGEMs_ = pset.getParameter<bool>("useGEMs");
0085   useCSCShowers_ = pset.getParameter<bool>("useCSCShowers");
0086   wd_token = consumes<CSCWireDigiCollection>(pset.getParameter<edm::InputTag>("wireDigiTag"));
0087   sd_token = consumes<CSCStripDigiCollection>(pset.getParameter<edm::InputTag>("stripDigiTag"));
0088   cd_token = consumes<CSCComparatorDigiCollection>(pset.getParameter<edm::InputTag>("comparatorDigiTag"));
0089   if (usePreTriggers_) {
0090     pr_token = consumes<CSCCLCTPreTriggerCollection>(pset.getParameter<edm::InputTag>("preTriggerTag"));
0091     prdigi_token = consumes<CSCCLCTPreTriggerDigiCollection>(pset.getParameter<edm::InputTag>("preTriggerDigiTag"));
0092   }
0093   al_token = consumes<CSCALCTDigiCollection>(pset.getParameter<edm::InputTag>("alctDigiTag"));
0094   cl_token = consumes<CSCCLCTDigiCollection>(pset.getParameter<edm::InputTag>("clctDigiTag"));
0095   co_token = consumes<CSCCorrelatedLCTDigiCollection>(pset.getParameter<edm::InputTag>("correlatedLCTDigiTag"));
0096   cham_token = esConsumes<CSCChamberMap, CSCChamberMapRcd>();
0097   if (useGEMs_) {
0098     gem_token = consumes<GEMPadDigiClusterCollection>(pset.getParameter<edm::InputTag>("padDigiClusterTag"));
0099   }
0100   if (useCSCShowers_) {
0101     shower_token = consumes<CSCShowerDigiCollection>(pset.getParameter<edm::InputTag>("showerDigiTag"));
0102     anode_shower_token = consumes<CSCShowerDigiCollection>(pset.getParameter<edm::InputTag>("anodeShowerDigiTag"));
0103     cathode_shower_token = consumes<CSCShowerDigiCollection>(pset.getParameter<edm::InputTag>("cathodeShowerDigiTag"));
0104     alct_anode_shower_token =
0105         consumes<CSCShowerDigiCollection>(pset.getParameter<edm::InputTag>("anodeALCTShowerDigiTag"));
0106   }
0107   put_token_ = produces<FEDRawDataCollection>("CSCRawData");
0108 }
0109 
0110 void CSCDigiToRawModule::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0111   edm::ParameterSetDescription desc;
0112 
0113   desc.add<unsigned int>("formatVersion", 2005)
0114       ->setComment(
0115           "Set to 2005 for pre-LS1 CSC data format, 2013 -  post-LS1 Run2 CSC data format, 2020 - Run3 CSC data "
0116           "format");
0117   desc.add<bool>("usePreTriggers", true)->setComment("Set to false if CSCCLCTPreTrigger digis are not available");
0118   desc.add<bool>("packEverything", false)
0119       ->setComment("Set to true to disable trigger-related constraints on readout data");
0120   desc.add<bool>("packByCFEB", false)->setComment("Pack strip digis using CFEB info");
0121   /// Run3 GEM and CSCShower objects packing
0122   desc.add<bool>("useGEMs", false)->setComment("Pack Run3 GEM trigger data");
0123   desc.add<bool>("useCSCShowers", false)->setComment("Pack Run3 CSC shower trigger data");
0124 
0125   desc.add<edm::InputTag>("wireDigiTag", edm::InputTag("simMuonCSCDigis", "MuonCSCWireDigi"));
0126   desc.add<edm::InputTag>("stripDigiTag", edm::InputTag("simMuonCSCDigis", "MuonCSCStripDigi"));
0127   desc.add<edm::InputTag>("comparatorDigiTag", edm::InputTag("simMuonCSCDigis", "MuonCSCComparatorDigi"));
0128   desc.add<edm::InputTag>("alctDigiTag", edm::InputTag("simCscTriggerPrimitiveDigis"));
0129   desc.add<edm::InputTag>("clctDigiTag", edm::InputTag("simCscTriggerPrimitiveDigis"));
0130   desc.add<edm::InputTag>("preTriggerTag", edm::InputTag("simCscTriggerPrimitiveDigis"));
0131   desc.add<edm::InputTag>("preTriggerDigiTag", edm::InputTag("simCscTriggerPrimitiveDigis"));
0132   desc.add<edm::InputTag>("correlatedLCTDigiTag", edm::InputTag("simCscTriggerPrimitiveDigis", "MPCSORTED"));
0133   desc.add<edm::InputTag>("padDigiClusterTag",
0134                           edm::InputTag("simMuonGEMPadDigiClusters"));  /// "MuonGEMPadDigiCluster" in data
0135   desc.add<edm::InputTag>("showerDigiTag",
0136                           edm::InputTag("simCscTriggerPrimitiveDigis"));  /// "MuonCSCShowerDigi" in data
0137   desc.add<edm::InputTag>("anodeShowerDigiTag",
0138                           edm::InputTag("simCscTriggerPrimitiveDigis"));  /// "MuonCSCShowerDigiAnode" in data
0139   desc.add<edm::InputTag>("cathodeShowerDigiTag",
0140                           edm::InputTag("simCscTriggerPrimitiveDigis"));  /// "MuonCSCShowerDigiCathode" in
0141   desc.add<edm::InputTag>("anodeALCTShowerDigiTag",
0142                           edm::InputTag("simCscTriggerPrimitiveDigis"));  /// "MuonCSCShowerDigiAnodeALCT" in data
0143 
0144   desc.add<int32_t>("alctWindowMin", -3)->setComment("If min parameter = -999 always accept");
0145   desc.add<int32_t>("alctWindowMax", 3);
0146   desc.add<int32_t>("clctWindowMin", -3)->setComment("If min parameter = -999 always accept");
0147   desc.add<int32_t>("clctWindowMax", 3);
0148   desc.add<int32_t>("preTriggerWindowMin", -3)->setComment("If min parameter = -999 always accept");
0149   desc.add<int32_t>("preTriggerWindowMax", 1);
0150 
0151   descriptions.add("cscPackerDef", desc);
0152 }
0153 
0154 void CSCDigiToRawModule::produce(edm::StreamID, edm::Event& e, const edm::EventSetup& c) const {
0155   ///reverse mapping for packer
0156   edm::ESHandle<CSCChamberMap> hcham = c.getHandle(cham_token);
0157   const CSCChamberMap* theMapping = hcham.product();
0158 
0159   FEDRawDataCollection fed_buffers;
0160 
0161   // Take digis from the event
0162   edm::Handle<CSCWireDigiCollection> wireDigis;
0163   edm::Handle<CSCStripDigiCollection> stripDigis;
0164   edm::Handle<CSCComparatorDigiCollection> comparatorDigis;
0165   edm::Handle<CSCALCTDigiCollection> alctDigis;
0166   edm::Handle<CSCCLCTDigiCollection> clctDigis;
0167   edm::Handle<CSCCorrelatedLCTDigiCollection> correlatedLCTDigis;
0168 
0169   // collections that are always packed
0170   e.getByToken(wd_token, wireDigis);
0171   e.getByToken(sd_token, stripDigis);
0172   e.getByToken(cd_token, comparatorDigis);
0173   e.getByToken(al_token, alctDigis);
0174   e.getByToken(cl_token, clctDigis);
0175   e.getByToken(co_token, correlatedLCTDigis);
0176 
0177   // packing with pre-triggers
0178   CSCCLCTPreTriggerCollection const* preTriggersPtr = nullptr;
0179   CSCCLCTPreTriggerDigiCollection const* preTriggerDigisPtr = nullptr;
0180   if (usePreTriggers_) {
0181     preTriggersPtr = &e.get(pr_token);
0182     preTriggerDigisPtr = &e.get(prdigi_token);
0183   }
0184 
0185   // collections that are packed optionally
0186 
0187   // packing of Run3 GEM GE11 hits
0188   const GEMPadDigiClusterCollection* padDigiClustersPtr = nullptr;
0189   if (useGEMs_) {
0190     padDigiClustersPtr = &e.get(gem_token);
0191   }
0192 
0193   // packing of Run3 CSC shower digis
0194   const CSCShowerDigiCollection* cscShowerDigisPtr = nullptr;
0195   const CSCShowerDigiCollection* cscAnodeShowerDigisPtr = nullptr;
0196   const CSCShowerDigiCollection* cscCathodeShowerDigisPtr = nullptr;
0197   const CSCShowerDigiCollection* cscALCTAnodeShowerDigisPtr = nullptr;
0198   if (useCSCShowers_) {
0199     cscShowerDigisPtr = &e.get(shower_token);
0200     cscAnodeShowerDigisPtr = &e.get(anode_shower_token);
0201     cscCathodeShowerDigisPtr = &e.get(cathode_shower_token);
0202     cscALCTAnodeShowerDigisPtr = &e.get(alct_anode_shower_token);
0203   }
0204 
0205   // Create the packed data
0206   packer_->createFedBuffers(*stripDigis,
0207                             *wireDigis,
0208                             *comparatorDigis,
0209                             *alctDigis,
0210                             *clctDigis,
0211                             preTriggersPtr,
0212                             preTriggerDigisPtr,
0213                             *correlatedLCTDigis,
0214                             cscShowerDigisPtr,
0215                             cscAnodeShowerDigisPtr,
0216                             cscCathodeShowerDigisPtr,
0217                             cscALCTAnodeShowerDigisPtr,
0218                             padDigiClustersPtr,
0219                             fed_buffers,
0220                             theMapping,
0221                             e.id());
0222 
0223   // put the raw data to the event
0224   e.emplace(put_token_, std::move(fed_buffers));
0225 }
0226 
0227 DEFINE_FWK_MODULE(CSCDigiToRawModule);