CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
L1TZDCProducer Class Reference
Inheritance diagram for L1TZDCProducer:
edm::stream::EDProducer<>

Public Member Functions

 L1TZDCProducer (const edm::ParameterSet &ps)
 
 ~L1TZDCProducer () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void produce (edm::Event &, const edm::EventSetup &) override
 
int zdcLUTIndexHelper (int iDetPos, int iBXPos)
 

Private Attributes

int bxFirst_
 
int bxLast_
 
edm::ESGetToken< CaloParams, L1TCaloParamsRcdcandidateToken_
 
edm::EDPutTokenT< EtSumBxCollectionetToken_
 
std::unique_ptr< CaloParamsHelperparams_
 
int sampleToCenterBX_
 
int scaleFactor_
 
edm::EDGetTokenT< QIE10DigiCollectionzdcToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 62 of file L1TZDCProducer.cc.

Constructor & Destructor Documentation

◆ L1TZDCProducer()

L1TZDCProducer::L1TZDCProducer ( const edm::ParameterSet ps)
explicit

Definition at line 97 of file L1TZDCProducer.cc.

References edm::ParameterSet::getParameter().

97  {
98  // register what you produce
99  etToken_ = produces<EtSumBxCollection>();
100 
101  // register what you consume and keep token for later access:
102  zdcToken_ = consumes<QIE10DigiCollection>(ps.getParameter<edm::InputTag>("zdcDigis"));
103  candidateToken_ = esConsumes<CaloParams, L1TCaloParamsRcd, edm::Transition::BeginRun>();
104 
105  bxFirst_ = ps.getParameter<int>("bxFirst");
106  bxLast_ = ps.getParameter<int>("bxLast");
107  sampleToCenterBX_ = ps.getParameter<int>("sampleToCenterBX");
108 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< CaloParams, L1TCaloParamsRcd > candidateToken_
edm::EDPutTokenT< EtSumBxCollection > etToken_
edm::EDGetTokenT< QIE10DigiCollection > zdcToken_

◆ ~L1TZDCProducer()

L1TZDCProducer::~L1TZDCProducer ( )
overridedefault

Member Function Documentation

◆ beginRun()

void L1TZDCProducer::beginRun ( edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
overrideprivate

Definition at line 237 of file L1TZDCProducer.cc.

References edm::EventSetup::getHandle(), and edm::ESHandle< T >::product().

237  {
238  edm::ESHandle<CaloParams> candidateHandle = iSetup.getHandle(candidateToken_);
239 
240  params_ = std::make_unique<CaloParamsHelper>(*candidateHandle.product());
241  scaleFactor_ = params_->zdcLUT()->data(0); //First position is the integer scaling factor
242  edm::LogInfo("L1TZDCProducer") << "SCALE FACTOR FOR LUT: " << scaleFactor_ << std::endl;
243 }
edm::ESGetToken< CaloParams, L1TCaloParamsRcd > candidateToken_
T const * product() const
Definition: ESHandle.h:86
Log< level::Info, false > LogInfo
std::unique_ptr< CaloParamsHelper > params_

◆ fillDescriptions()

void L1TZDCProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 249 of file L1TZDCProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

249  {
251  desc.add<edm::InputTag>("zdcDigis", edm::InputTag("hcalDigis", "ZDC"));
252  desc.add<int>("bxFirst", -2);
253  desc.add<int>("bxLast", 2);
254  desc.add<int>("sampleToCenterBX", 4);
255  descriptions.add("l1tZDCProducer", desc);
256 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void L1TZDCProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 111 of file L1TZDCProducer.cc.

References gpuClustering::adc, edm::DataFrameContainer::begin(), HcalZDCDetId::channel(), edm::DataFrameContainer::end(), l1t::CaloTools::etSumP4Demux(), amptDefault_cfi::frame, iEvent, edm::HandleBase::isValid(), L1Analysis::kZDCM, L1Analysis::kZDCP, LogDebug, eostools::move(), PresampleTask_cfi::nSamples, BXVector< T >::push_back(), QIE10DataFrame::samples(), HcalZDCDetId::section(), hgcalPlots::section, l1t::L1Candidate::setHwEta(), l1t::L1Candidate::setHwPhi(), l1t::L1Candidate::setHwPt(), l1t::EtSum::setType(), HcalZDCDetId::zside(), and ecaldqm::zside().

111  {
112  using namespace edm;
113  using namespace l1t;
114 
115  LogDebug("L1TZDCProducer") << "L1TZDCProducer::produce function called..." << std::endl;
116 
117  // reduced collection to be emplaced in output
118  EtSumBxCollection etsumsReduced(0, bxFirst_, bxLast_);
119 
120  //inputs
121  Handle<QIE10DigiCollection> zdcDigiCollection;
122  iEvent.getByToken(zdcToken_, zdcDigiCollection);
123 
124  //Produce ZDC EtSums IF input zdcDigiCollection is valid
125  if (zdcDigiCollection.isValid()) {
126  //In lieu of bxFirst, bxLast, use the number of the timeslice samples
127  const QIE10DataFrame& frametest = (*zdcDigiCollection)[0];
128  int nSamples = frametest.samples();
129 
130  //Check if the sample requested as center bx is valid
131  int sampleToCenterBXChecked = sampleToCenterBX_;
132 
133  if (sampleToCenterBXChecked < 0) {
134  edm::LogWarning("L1TZDCProducer") << "sampleToCenterBX LT 0; Set bx 0 to sample 0 (minimum allowed)" << std::endl;
135  sampleToCenterBXChecked = 0;
136  } else if (sampleToCenterBXChecked >= nSamples) {
137  edm::LogWarning("L1TZDCProducer")
138  << "sampleToCenterBX GE nsamples; Set bx 0 to sample nsamples-1 (maximum allowed)" << std::endl;
139  sampleToCenterBXChecked = nSamples - 1;
140  }
141 
142  //rawadc[detector index][time slices]
143  unsigned short rawadc[18][10];
144 
145  // the loop below loops over all the elements of the QIE10DigiCollection. Each entry corresponds to one channel
146  for (QIE10DigiCollection::const_iterator it = zdcDigiCollection->begin(); it != zdcDigiCollection->end(); it++) {
147  const QIE10DataFrame& frame(*it);
148  HcalZDCDetId cell = frame.id();
149  int zside = cell.zside();
150  int section = cell.section();
151  int channel = cell.channel();
152 
153  if (zside != -1 && zside != 1)
154  continue;
155  if (section != 1 && section != 2)
156  continue;
157  if (section == 1 && (channel < 1 || channel > 5))
158  continue;
159  if (section == 2 && (channel < 1 || channel > 4))
160  continue;
161 
162  int ihitid = (zside == 1 ? 9 : 0) + (section == 2 ? 5 : 0) + (channel - 1);
163  //the loop below iterates over the time slices
164  for (int iTS = 0; iTS < nSamples; iTS++) {
165  unsigned short adc = (unsigned short)frame[iTS].adc();
166  rawadc[ihitid][iTS] = adc;
167  } // end of loop over iTS
168  } //end of loop over channels
169 
170  for (int ibx = 0; ibx < nSamples; ibx++) {
171  double cEMP = 0, cEMM = 0, cHDP = 0, cHDM = 0;
172  double sumcEMP = 0, sumcEMM = 0, sumcHDP = 0, sumcHDM = 0;
173  //idet=0-4 correpond to the EM channels
174  for (int idet = 0; idet < 5; idet++) {
175  unsigned short EMP = rawadc[idet + 9][ibx];
176  unsigned short EMM = rawadc[idet][ibx];
177 
178  int cEMP_LUTIndex = zdcLUTIndexHelper(idet + 9, (int)EMP);
179  int cEMM_LUTIndex = zdcLUTIndexHelper(idet, (int)EMM);
180 
181  cEMP = ((double)params_->zdcLUT()->data(cEMP_LUTIndex)) / ((double)scaleFactor_);
182  cEMM = ((double)params_->zdcLUT()->data(cEMM_LUTIndex)) / ((double)scaleFactor_);
183 
184  sumcEMP = sumcEMP + cEMP;
185  sumcEMM = sumcEMM + cEMM;
186  }
187  //idet=5-8 correspond to HAD channels
188  for (int idet = 5; idet < 9; idet++) {
189  unsigned short HDP = rawadc[idet + 9][ibx];
190  unsigned short HDM = rawadc[idet][ibx];
191 
192  int cHDP_LUTIndex = zdcLUTIndexHelper(idet + 9, (int)HDP);
193  int cHDM_LUTIndex = zdcLUTIndexHelper(idet, (int)HDM);
194 
195  cHDP = ((double)params_->zdcLUT()->data(cHDP_LUTIndex)) / ((double)scaleFactor_);
196  cHDM = ((double)params_->zdcLUT()->data(cHDM_LUTIndex)) / ((double)scaleFactor_);
197 
198  sumcHDP = sumcHDP + cHDP;
199  sumcHDM = sumcHDM + cHDM;
200  }
201  double sumM = sumcEMM + sumcHDM;
202  double sumP = sumcEMP + sumcHDP;
203 
204  if (ibx == 4) {
205  edm::LogInfo("L1TZDCProducer") << ", sumM= " << sumM << std::endl;
206  edm::LogInfo("L1TZDCProducer") << ", sumP= " << sumP << std::endl;
207  }
208  l1t::EtSum tempEtM = l1t::EtSum();
209  tempEtM.setHwPt(sumM);
210  tempEtM.setHwEta(-1.);
211  tempEtM.setHwPhi(0.);
213 
214  l1t::EtSum tempEtP = l1t::EtSum();
215  tempEtP.setHwPt(sumP);
216  tempEtP.setHwEta(1.);
217  tempEtP.setHwPhi(0.);
219 
220  if (ibx >= sampleToCenterBXChecked + bxFirst_ && ibx <= sampleToCenterBXChecked + bxLast_) {
221  etsumsReduced.push_back(ibx - sampleToCenterBXChecked, CaloTools::etSumP4Demux(tempEtP));
222  etsumsReduced.push_back(ibx - sampleToCenterBXChecked, CaloTools::etSumP4Demux(tempEtM));
223  }
224  } // end of loop over bunch crossings
225  } // end if(zdcDigiCollection.isValid())
226  else {
227  // If the collection is not valid issue a warning before putting an empty collection
228  edm::LogWarning("L1TZDCProducer") << "zdcDigis not valid; return empty ZDC Et Sum BXCollection" << std::endl;
229  }
230 
231  // Emplace even if !zdcDigiCollection.isValid()
232  // Output in this case will be an empty collection
233  iEvent.emplace(etToken_, std::move(etsumsReduced));
234 }
delete x;
Definition: CaloConfig.h:22
int zside(DetId const &)
int zdcLUTIndexHelper(int iDetPos, int iBXPos)
void setType(EtSumType type)
Definition: EtSum.cc:11
edm::EDPutTokenT< EtSumBxCollection > etToken_
int iEvent
Definition: GenABIO.cc:224
const_iterator end() const
Log< level::Info, false > LogInfo
std::unique_ptr< CaloParamsHelper > params_
void setHwPhi(int phi)
Definition: L1Candidate.h:30
const_iterator begin() const
The iterator returned can not safely be used across threads.
edm::EDGetTokenT< QIE10DigiCollection > zdcToken_
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
bool isValid() const
Definition: HandleBase.h:70
constexpr Section section() const
get the section
Definition: HcalZDCDetId.h:84
HLT enums.
void setHwPt(int pt)
Definition: L1Candidate.h:28
void setHwEta(int eta)
Definition: L1Candidate.h:29
constexpr int32_t channel() const
get the channel
Definition: HcalZDCDetId.h:104
constexpr int32_t zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:82
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511
constexpr int samples() const
total number of samples in the digi
uint16_t *__restrict__ uint16_t const *__restrict__ adc
#define LogDebug(id)

◆ zdcLUTIndexHelper()

int L1TZDCProducer::zdcLUTIndexHelper ( int  iDetPos,
int  iBXPos 
)
private

Definition at line 246 of file L1TZDCProducer.cc.

246 { return 1 + iDetPos * 256 + iBxPos; }

Member Data Documentation

◆ bxFirst_

int L1TZDCProducer::bxFirst_
private

Definition at line 85 of file L1TZDCProducer.cc.

◆ bxLast_

int L1TZDCProducer::bxLast_
private

Definition at line 86 of file L1TZDCProducer.cc.

◆ candidateToken_

edm::ESGetToken<CaloParams, L1TCaloParamsRcd> L1TZDCProducer::candidateToken_
private

Definition at line 82 of file L1TZDCProducer.cc.

◆ etToken_

edm::EDPutTokenT<EtSumBxCollection> L1TZDCProducer::etToken_
private

Definition at line 90 of file L1TZDCProducer.cc.

◆ params_

std::unique_ptr<CaloParamsHelper> L1TZDCProducer::params_
private

Definition at line 93 of file L1TZDCProducer.cc.

◆ sampleToCenterBX_

int L1TZDCProducer::sampleToCenterBX_
private

Definition at line 87 of file L1TZDCProducer.cc.

◆ scaleFactor_

int L1TZDCProducer::scaleFactor_
private

Definition at line 94 of file L1TZDCProducer.cc.

◆ zdcToken_

edm::EDGetTokenT<QIE10DigiCollection> L1TZDCProducer::zdcToken_
private

Definition at line 81 of file L1TZDCProducer.cc.