CMS 3D CMS Logo

L1TZDCProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1Trigger/L1TZDC
4 // Class: L1TZDC
5 //
14 //
15 // Modded from L1TZDCProducer by: Chris McGinn
16 // Modifications Made: Wed, 26 Sep 2023
17 // Contact: christopher.mc.ginn@cern.ch or
18 // cfmcginn on github for bugs/issues
19 //
20 #include <memory>
21 #include <iostream>
22 // user include files
23 
36 
40 
44 
50 
52 
53 //
54 // class declaration
55 //
56 
57 using namespace l1t;
58 
60 public:
61  explicit L1TZDCProducer(const edm::ParameterSet& ps);
62  ~L1TZDCProducer() override = default;
63 
64  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
65 
66 private:
67  void produce(edm::Event&, const edm::EventSetup&) override;
68 
69  // ----------member data ---------------------------
70 
71  // input tokens
72  //Add the hcalTP token
74 
75  //input ints
76  int bxFirst_;
77  int bxLast_;
78 
79  // put tokens
81 };
82 
84  : hcalTPSource(consumes<HcalTrigPrimDigiCollection>(ps.getParameter<edm::InputTag>("hcalTPDigis"))) {
85  // register what you produce
86  etToken_ = produces<EtSumBxCollection>();
87 
88  bxFirst_ = ps.getParameter<int>("bxFirst");
89  bxLast_ = ps.getParameter<int>("bxLast");
90 }
91 
92 // ------------ method called to produce the data ------------
94  using namespace edm;
95  using namespace l1t;
96 
97  LogDebug("L1TZDCProducer") << "L1TZDCProducer::produce function called..." << std::endl;
98 
99  // reduced collection to be emplaced in output
100  EtSumBxCollection etsumsReduced(0, bxFirst_, bxLast_);
101 
103  iEvent.getByToken(hcalTPSource, hcalTPs);
104 
105  //Check if the hcal tokens are valid
106  if (hcalTPs.isValid()) {
107  //If valid, process
108  for (const auto& hcalTp : *hcalTPs) {
109  int ieta = hcalTp.id().ieta();
110  uint32_t absIEta = std::abs(ieta);
111 
112  //absIEta position 42 is used for the ZDC; -42 for ZDCM, +42 for ZDCP
113  if (absIEta != 42)
114  continue;
115 
116  int iphi = hcalTp.id().iphi();
117  //iphi position 99 is used for the etSums
118  if (iphi != 99)
119  continue;
120 
121  //Get number of samples and number of presamples; bx 0 is nPresamples
122  int nSamples = hcalTp.size();
123  int nPresamples = hcalTp.presamples();
124 
125  for (int ibx = 0; ibx < nSamples; ibx++) {
126  if (ibx >= nPresamples + bxFirst_ && ibx <= nPresamples + bxLast_) {
127  HcalTriggerPrimitiveSample hcalTpSample = hcalTp.sample(ibx);
128  int ietIn = hcalTpSample.raw();
129 
130  l1t::EtSum tempEt = l1t::EtSum();
131  tempEt.setHwPt(ietIn);
132  tempEt.setHwPhi(0.);
133 
134  //ieta < 0 is ZDCMinus; > 0 is ZDCPlus
135  if (ieta < 0) {
136  tempEt.setHwEta(-1.);
138  } else {
139  tempEt.setHwEta(1.);
141  }
142 
143  //By construction, nPresamples is 0 bx (since presamples span 0 to nPresamples-1)
144  etsumsReduced.push_back(ibx - nPresamples, CaloTools::etSumP4Demux(tempEt));
145  }
146  }
147  }
148  } else {
149  // If the collection is not valid issue a warning before putting an empty collection
150  edm::LogWarning("L1TZDCProducer") << "hcalTps not valid; return empty ZDC Et Sum BXCollection" << std::endl;
151  }
152 
153  // Emplace even if !hcalTps.isValid()
154  // Output in this case will be an empty collection
155  iEvent.emplace(etToken_, std::move(etsumsReduced));
156 }
157 
158 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
161  desc.add<edm::InputTag>("hcalTPDigis", edm::InputTag("simHcalTriggerPrimitiveDigis"));
162  desc.add<int>("bxFirst", -2);
163  desc.add<int>("bxLast", 2);
164  descriptions.add("l1tZDCProducer", desc);
165 }
166 
167 //define this as a plug-in
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void produce(edm::Event &, const edm::EventSetup &) override
delete x;
Definition: CaloConfig.h:22
void setType(EtSumType type)
Definition: EtSum.cc:11
edm::EDPutTokenT< EtSumBxCollection > etToken_
uint16_t raw() const
get the raw word
int iEvent
Definition: GenABIO.cc:224
L1TZDCProducer(const edm::ParameterSet &ps)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void setHwPhi(int phi)
Definition: L1Candidate.h:30
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
void setHwPt(int pt)
Definition: L1Candidate.h:28
void setHwEta(int eta)
Definition: L1Candidate.h:29
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511
void push_back(int bx, T object)
edm::EDGetTokenT< HcalTrigPrimDigiCollection > hcalTPSource
#define LogDebug(id)