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 hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () 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_
 
edm::ESGetToken< HcalTPGCoder, HcalTPGRecordtok_tpgCoder_
 

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 14 of file HcalTTPDigiProducer.h.

Constructor & Destructor Documentation

◆ HcalTTPDigiProducer()

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

Definition at line 16 of file HcalTTPDigiProducer.cc.

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

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_, tok_hf_, and tok_tpgCoder_.

◆ ~HcalTTPDigiProducer()

HcalTTPDigiProducer::~HcalTTPDigiProducer ( )
overridedefault

Member Function Documentation

◆ decision()

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

Definition at line 86 of file HcalTTPDigiProducer.cc.

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

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

Referenced by produce().

◆ isMasked()

bool HcalTTPDigiProducer::isMasked ( HcalDetId  id)
private

Definition at line 79 of file HcalTTPDigiProducer.cc.

79  {
80  for (unsigned int i = 0; i < maskedChannels_.size(); i++)
81  if (id.rawId() == maskedChannels_.at(i))
82  return true;
83  return false;
84 }

References mps_fire::i, and maskedChannels_.

Referenced by produce().

◆ produce()

void HcalTTPDigiProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 114 of file HcalTTPDigiProducer.cc.

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

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

Member Data Documentation

◆ bit_

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

Definition at line 28 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer().

◆ calc_

int HcalTTPDigiProducer::calc_[4]
private

Definition at line 29 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

◆ fwAlgo_

int HcalTTPDigiProducer::fwAlgo_
private

Definition at line 33 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

◆ id_

int HcalTTPDigiProducer::id_
private

Definition at line 32 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

◆ iEtaMax_

int HcalTTPDigiProducer::iEtaMax_
private

Definition at line 34 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

◆ iEtaMin_

int HcalTTPDigiProducer::iEtaMin_
private

Definition at line 34 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

◆ inputs_

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 39 of file HcalTTPDigiProducer.h.

Referenced by produce().

◆ maskedChannels_

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

Definition at line 27 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and isMasked().

◆ mReq_

char HcalTTPDigiProducer::mReq_[4]
private

Definition at line 31 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

◆ nHFm_

int HcalTTPDigiProducer::nHFm_[4]
private

Definition at line 30 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

◆ nHFp_

int HcalTTPDigiProducer::nHFp_[4]
private

Definition at line 30 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

◆ nHits_

int HcalTTPDigiProducer::nHits_[4]
private

Definition at line 30 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

◆ pmLogic_

char HcalTTPDigiProducer::pmLogic_[4]
private

Definition at line 31 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

◆ pReq_

char HcalTTPDigiProducer::pReq_[4]
private

Definition at line 31 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

◆ presamples_

int HcalTTPDigiProducer::presamples_
private

Definition at line 32 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

◆ samples_

int HcalTTPDigiProducer::samples_
private

Definition at line 32 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

◆ SoI_

int HcalTTPDigiProducer::SoI_
private

Definition at line 37 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

◆ threshold_

unsigned int HcalTTPDigiProducer::threshold_
private

Definition at line 35 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

◆ tok_hf_

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

Definition at line 25 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

◆ tok_tpgCoder_

edm::ESGetToken<HcalTPGCoder, HcalTPGRecord> HcalTTPDigiProducer::tok_tpgCoder_
private

Definition at line 26 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

mps_fire.i
i
Definition: mps_fire.py:428
HcalTTPDigiProducer::decision
bool decision(int nP, int nM, int bit)
Definition: HcalTTPDigiProducer.cc:86
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
HcalTTPDigiProducer::SoI_
int SoI_
Definition: HcalTTPDigiProducer.h:37
HcalTTPDigiProducer::nHFm_
int nHFm_[4]
Definition: HcalTTPDigiProducer.h:30
HcalTTPDigiProducer::fwAlgo_
int fwAlgo_
Definition: HcalTTPDigiProducer.h:33
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
HcalTTPDigi
Definition: HcalTTPDigi.h:12
HcalTPGCoder::adc2Linear
virtual void adc2Linear(const HBHEDataFrame &df, IntegerCaloSamples &ics) const =0
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
IntegerCaloSamples
Definition: IntegerCaloSamples.h:16
EgammaValidation_cff.samples
samples
Definition: EgammaValidation_cff.py:19
HcalTTPDigiProducer::id_
int id_
Definition: HcalTTPDigiProducer.h:32
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
HcalTTPDigiProducer::maskedChannels_
std::vector< unsigned int > maskedChannels_
Definition: HcalTTPDigiProducer.h:27
HcalTTPDigiProducer::iEtaMin_
int iEtaMin_
Definition: HcalTTPDigiProducer.h:34
HcalTTPDigiProducer::pmLogic_
char pmLogic_[4]
Definition: HcalTTPDigiProducer.h:31
edm::ESHandle
Definition: DTSurvey.h:22
HcalTTPDigiProducer::presamples_
int presamples_
Definition: HcalTTPDigiProducer.h:32
HcalTTPDigiProducer::iEtaMax_
int iEtaMax_
Definition: HcalTTPDigiProducer.h:34
HcalTTPDigiProducer::pReq_
char pReq_[4]
Definition: HcalTTPDigiProducer.h:31
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalTTPDigiProducer::tok_hf_
edm::EDGetTokenT< HFDigiCollection > tok_hf_
Definition: HcalTTPDigiProducer.h:25
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
HcalDetId
Definition: HcalDetId.h:12
HcalTTPDigiProducer::bit_
std::string bit_[4]
Definition: HcalTTPDigiProducer.h:28
HcalTTPDigiProducer::samples_
int samples_
Definition: HcalTTPDigiProducer.h:32
HcalTTPDigiProducer::tok_tpgCoder_
edm::ESGetToken< HcalTPGCoder, HcalTPGRecord > tok_tpgCoder_
Definition: HcalTTPDigiProducer.h:26
HcalTTPDigiProducer::nHits_
int nHits_[4]
Definition: HcalTTPDigiProducer.h:30
HcalTTPDigiProducer::threshold_
unsigned int threshold_
Definition: HcalTTPDigiProducer.h:35
HcalTTPDigiProducer::isMasked
bool isMasked(HcalDetId id)
Definition: HcalTTPDigiProducer.cc:79
HcalTTPDigiProducer::nHFp_
int nHFp_[4]
Definition: HcalTTPDigiProducer.h:30
HcalTTPDigiProducer::calc_
int calc_[4]
Definition: HcalTTPDigiProducer.h:29
eostools.move
def move(src, dest)
Definition: eostools.py:511
HcalTTPDigiCollection
edm::SortedCollection< HcalTTPDigi > HcalTTPDigiCollection
Definition: HcalDigiCollections.h:30
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
Exception
Definition: hltDiff.cc:246
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
edm::InputTag
Definition: InputTag.h:15
HcalTTPDigiProducer::inputs_
static const int inputs_[]
Definition: HcalTTPDigiProducer.h:39
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
watchdog.group
group
Definition: watchdog.py:82
HcalTTPDigiProducer::mReq_
char mReq_[4]
Definition: HcalTTPDigiProducer.h:31