CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
HcalTTPDigiProducer Class Reference

#include <HcalTTPDigiProducer.h>

Inheritance diagram for HcalTTPDigiProducer:
edm::stream::EDProducer<>

Public Member Functions

 HcalTTPDigiProducer (const edm::ParameterSet &ps)
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
 ~HcalTTPDigiProducer () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Member Functions

bool decision (int nP, int nM, int bit)
 
bool isMasked (HcalDetId id)
 

Private Attributes

std::string bit_ [4]
 
int calc_ [4]
 
int fwAlgo_
 
int id_
 
int iEtaMax_
 
int iEtaMin_
 
std::vector< unsigned int > maskedChannels_
 
char mReq_ [4]
 
int nHFm_ [4]
 
int nHFp_ [4]
 
int nHits_ [4]
 
char pmLogic_ [4]
 
char pReq_ [4]
 
int presamples_
 
int samples_
 
int SoI_
 
unsigned int threshold_
 
edm::EDGetTokenT< HFDigiCollectiontok_hf_
 

Static Private Attributes

static const int inputs_ []
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 11 of file HcalTTPDigiProducer.h.

Constructor & Destructor Documentation

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

Definition at line 18 of file HcalTTPDigiProducer.cc.

References bit_, calc_, Exception, fwAlgo_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, id_, iEtaMax_, iEtaMin_, maskedChannels_, mReq_, nHFm_, nHFp_, nHits_, pmLogic_, pReq_, presamples_, samples_, SoI_, AlCaHLTBitMon_QueryRunRegistry::string, threshold_, and tok_hf_.

18  {
19  tok_hf_ = consumes<HFDigiCollection>(ps.getParameter<edm::InputTag>("HFDigiCollection"));
20  maskedChannels_ = ps.getParameter<std::vector<unsigned int> >("maskedChannels");
21  bit_[0] = ps.getParameter<std::string>("defTT8");
22  bit_[1] = ps.getParameter<std::string>("defTT9");
23  bit_[2] = ps.getParameter<std::string>("defTT10");
24  bit_[3] = ps.getParameter<std::string>("defTTLocal");
25 
26  for (int i = 0; i < 4; i++) {
27  nHits_[i] = -1;
28  nHFp_[i] = -1;
29  nHFm_[i] = -1;
30  pReq_[i] = ' ';
31  mReq_[i] = ' ';
32  pmLogic_[i] = ' ';
33  calc_[i] = sscanf(bit_[i].c_str(),
34  "hits>=%d:hfp%c=%d%chfm%c=%d",
35  &(nHits_[i]),
36  &(pReq_[i]),
37  &(nHFp_[i]),
38  &(pmLogic_[i]),
39  &(mReq_[i]),
40  &(nHFm_[i]));
41  if (calc_[i] == 1) {
42  if (nHits_[i] < 0)
43  throw cms::Exception("HcalTTPDigiProducer") << "Unable to read logic for technical trigger";
44  } else if (calc_[i] == 6) {
45  if (nHits_[i] < 0 || nHFp_[i] < 0 || nHFm_[i] < 0)
46  throw cms::Exception("HcalTTPDigiProducer") << "Unable to read logic for technical trigger";
47  if ((pReq_[i] != '>' && pReq_[i] != '<') || (mReq_[i] != '>' && mReq_[i] != '<') ||
48  (pmLogic_[i] != ':' && pmLogic_[i] != '|'))
49  throw cms::Exception("HcalTTPDigiProducer") << "Technical Trigger logic must obey the following format:\n"
50  "\"hits>=[A1]:hfp[B1]=[A2][C]hfm[B2]=[A3]\",\n"
51  "or \"hits>=[A1]\",\n"
52  "with A# >= 0, B# = (</>) and C = (:/|)";
53  } else {
54  throw cms::Exception("HcalTTPDigiProducer") << "Unable to read logic for technical trigger";
55  }
56  }
57 
58  id_ = ps.getUntrackedParameter<int>("id", -1);
59  samples_ = ps.getParameter<int>("samples");
60  presamples_ = ps.getParameter<int>("presamples");
61  iEtaMin_ = ps.getParameter<int>("iEtaMin");
62  iEtaMax_ = ps.getParameter<int>("iEtaMax");
63  threshold_ = ps.getParameter<unsigned int>("threshold");
64  fwAlgo_ = ps.getParameter<int>("fwAlgorithm");
65 
66  SoI_ = ps.getParameter<int>("HFSoI");
67 
68  if (samples_ > 8) {
69  samples_ = 8;
70  edm::LogWarning("HcalTTPDigiProducer") << "Samples forced to maximum value of 8";
71  }
72  if (presamples_ - SoI_ > 0) { // Too many presamples
73  presamples_ = SoI_;
74  edm::LogWarning("HcalTTPDigiProducer") << "Presamples reset to HF SoI value";
75  }
76 
77  produces<HcalTTPDigiCollection>();
78 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< unsigned int > maskedChannels_
edm::EDGetTokenT< HFDigiCollection > tok_hf_
HcalTTPDigiProducer::~HcalTTPDigiProducer ( )
overridedefault

Member Function Documentation

bool HcalTTPDigiProducer::decision ( int  nP,
int  nM,
int  bit 
)
private

Definition at line 87 of file HcalTTPDigiProducer.cc.

References calc_, mReq_, nHFm_, nHFp_, nHits_, pmLogic_, and pReq_.

Referenced by produce().

87  {
88  bool pOK = false;
89  bool mOK = false;
90  if ((nP + nM) < nHits_[bit])
91  return false;
92  if (calc_[bit] == 1)
93  return ((nP + nM) >= nHits_[bit]);
94 
95  if (pReq_[bit] == '>')
96  pOK = (nP >= nHFp_[bit]);
97  else if (pReq_[bit] == '<')
98  pOK = (nP <= nHFp_[bit]);
99 
100  if (mReq_[bit] == '>')
101  mOK = (nM >= nHFm_[bit]);
102  else if (mReq_[bit] == '<')
103  mOK = (nM <= nHFm_[bit]);
104 
105  if (pmLogic_[bit] == ':')
106  return (pOK && mOK);
107  else if (pmLogic_[bit] == '|')
108  return (pOK || mOK);
109 
110  // Should not ever get here...need to create a warning message
111  edm::LogWarning("HcalTTPDigiProducer") << "Trigger logic exhausted. Returning false";
112  return false;
113 }
bool HcalTTPDigiProducer::isMasked ( HcalDetId  id)
private

Definition at line 80 of file HcalTTPDigiProducer.cc.

References mps_fire::i, and maskedChannels_.

Referenced by produce().

80  {
81  for (unsigned int i = 0; i < maskedChannels_.size(); i++)
82  if (id.rawId() == maskedChannels_.at(i))
83  return true;
84  return false;
85 }
std::vector< unsigned int > maskedChannels_
void HcalTTPDigiProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 115 of file HcalTTPDigiProducer.cc.

References HcalTPGCoder::adc2Linear(), edm::SortedCollection< T, SORT >::begin(), decision(), edm::SortedCollection< T, SORT >::end(), fwAlgo_, edm::EventSetup::get(), edm::Event::getByToken(), watchdog::group, mps_fire::i, id_, iEtaMax_, iEtaMin_, inputs_, isMasked(), dqmiolumiharvest::j, eostools::move(), hltrates_dqm_sourceclient-live_cfg::offset, presamples_, edm::Event::put(), EgammaValidation_cff::samples, samples_, HcalTTPDigi::setSample(), edm::shift, SoI_, threshold_, and tok_hf_.

115  {
116  // Step A: Get Inputs
117  edm::Handle<HFDigiCollection> hfDigiCollection;
118  e.getByToken(tok_hf_, hfDigiCollection);
119  edm::ESHandle<HcalTPGCoder> inputCoder;
120  eventSetup.get<HcalTPGRecord>().get(inputCoder);
121 
122  // Step B: Create empty output
123  std::unique_ptr<HcalTTPDigiCollection> ttpResult(new HcalTTPDigiCollection());
124 
125  // Step C: Compute TTP inputs
126  uint16_t trigInputs[40];
127  int nP[8];
128  int nM[8];
129  for (int i = 0; i < 8; i++) {
130  nP[i] = 0;
131  nM[i] = 0;
132  for (int j = 0; j < 5; j++)
133  trigInputs[j * 8 + i] = 0;
134  }
135  for (HFDigiCollection::const_iterator theDigi = hfDigiCollection->begin(); theDigi != hfDigiCollection->end();
136  theDigi++) {
137  HcalDetId id = HcalDetId(theDigi->id());
138  if (isMasked(id))
139  continue;
140  if (id.ietaAbs() < iEtaMin_ || id.ietaAbs() > iEtaMax_)
141  continue;
142 
143  IntegerCaloSamples samples(id, theDigi->size());
144  inputCoder->adc2Linear(*theDigi, samples);
145 
146  for (int relSample = -presamples_; relSample < (samples_ - presamples_); relSample++) {
147  if (samples[SoI_ + relSample] >= threshold_) {
148  int linSample = presamples_ + relSample;
149  int offset = (-1 + id.zside()) / 2;
150  int shift = inputs_[id.iphi() + offset];
151  int group = 0;
152  while (shift >= 16) {
153  shift -= 16;
154  group++;
155  }
156  if (!(trigInputs[(linSample * 8) + group] & (1 << shift)))
157  (id.ieta() > 0) ? (nP[linSample]++) : (nM[linSample]++);
158  trigInputs[(linSample * 8) + group] |= (1 << shift);
159  }
160  }
161  }
162 
163  // Step D: Compute trigger decision and fill TTP digi
164  uint8_t trigOutput[8];
165  uint32_t algoDepBits[8];
166  HcalTTPDigi ttpDigi(id_, samples_, presamples_, 0, fwAlgo_, 0);
167  for (int linSample = 0; linSample < 8; linSample++) {
168  trigOutput[linSample] = 0;
169  algoDepBits[linSample] = 0;
170  if (linSample < samples_) {
171  for (int j = 0; j < 4; j++)
172  trigOutput[linSample] |= (decision(nP[linSample], nM[linSample], j) << j);
173  int nT = nP[linSample] + nM[linSample];
174 
175  // Algorithm Dependent bits for FW flavor = 1
176  // NOTE: this disagrees with the fw var. names that implies (LSB) T,M,P (MSB)
177  if (fwAlgo_ == 1)
178  algoDepBits[linSample] = (nT & 0x7F) | ((nP[linSample] & 0x3F) << 7) | ((nM[linSample] & 0x3F) << 13);
179  ttpDigi.setSample(
180  (linSample - presamples_), &trigInputs[linSample * 8], algoDepBits[linSample], trigOutput[linSample]);
181  }
182  }
183  ttpResult->push_back(ttpDigi);
184 
185  // Step E: Put outputs into event
186  e.put(std::move(ttpResult));
187 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::vector< T >::const_iterator const_iterator
bool isMasked(HcalDetId id)
static const int inputs_[]
bool decision(int nP, int nM, int bit)
const_iterator end() const
virtual void adc2Linear(const HBHEDataFrame &df, IntegerCaloSamples &ics) const =0
edm::SortedCollection< HcalTTPDigi > HcalTTPDigiCollection
edm::EDGetTokenT< HFDigiCollection > tok_hf_
static unsigned int const shift
def move(src, dest)
Definition: eostools.py:511
const_iterator begin() const

Member Data Documentation

std::string HcalTTPDigiProducer::bit_[4]
private

Definition at line 24 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer().

int HcalTTPDigiProducer::calc_[4]
private

Definition at line 25 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

int HcalTTPDigiProducer::fwAlgo_
private

Definition at line 29 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

int HcalTTPDigiProducer::id_
private

Definition at line 28 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

int HcalTTPDigiProducer::iEtaMax_
private

Definition at line 30 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

int HcalTTPDigiProducer::iEtaMin_
private

Definition at line 30 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

const int HcalTTPDigiProducer::inputs_
staticprivate
Initial value:
= {30, 66, 4, 44, 4, 44, 0, 68, 0, 68, 16, 48, 16, 48, 6, 46, 6, 46,
2, 70, 2, 70, 18, 50, 18, 50, 12, 40, 12, 40, 8, 52, 8, 52, 20, 36,
20, 36, 14, 42, 14, 42, 10, 54, 10, 54, 22, 38, 22, 38, 24, 56, 24, 56,
32, 60, 32, 60, 28, 64, 28, 64, 26, 58, 26, 58, 34, 62, 34, 62, 30, 66}

Definition at line 35 of file HcalTTPDigiProducer.h.

Referenced by produce().

std::vector<unsigned int> HcalTTPDigiProducer::maskedChannels_
private

Definition at line 23 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and isMasked().

char HcalTTPDigiProducer::mReq_[4]
private

Definition at line 27 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

int HcalTTPDigiProducer::nHFm_[4]
private

Definition at line 26 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

int HcalTTPDigiProducer::nHFp_[4]
private

Definition at line 26 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

int HcalTTPDigiProducer::nHits_[4]
private

Definition at line 26 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

char HcalTTPDigiProducer::pmLogic_[4]
private

Definition at line 27 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

char HcalTTPDigiProducer::pReq_[4]
private

Definition at line 27 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

int HcalTTPDigiProducer::presamples_
private

Definition at line 28 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

int HcalTTPDigiProducer::samples_
private

Definition at line 28 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

int HcalTTPDigiProducer::SoI_
private

Definition at line 33 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

unsigned int HcalTTPDigiProducer::threshold_
private

Definition at line 31 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

edm::EDGetTokenT<HFDigiCollection> HcalTTPDigiProducer::tok_hf_
private

Definition at line 22 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().