CMS 3D CMS Logo

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

#include <CastorTTRecord.h>

Inheritance diagram for CastorTTRecord:
edm::one::EDProducer<> edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 CastorTTRecord (const edm::ParameterSet &ps)
 
void getEnergy_fC (double energy[16][14], edm::Handle< CastorDigiCollection > &CastorDigiColl, edm::Event &e, const edm::EventSetup &c)
 
void getTriggerDecisions (std::vector< bool > &decision, double energy[16][14]) const
 
void getTriggerDecisionsPerOctant (std::vector< bool > tdps[16], double energy[16][14]) const
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
 ~CastorTTRecord () override
 
- Public Member Functions inherited from edm::one::EDProducer<>
 EDProducer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

edm::EDGetTokenT< CastorDigiCollectionCastorDigiColl_
 
unsigned int CastorSignalTS_
 
double reweighted_gain
 
std::vector< std::string > TrigNames_
 
std::vector< double > TrigThresholds_
 
std::vector< unsigned int > ttpBits_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 11 of file CastorTTRecord.h.

Constructor & Destructor Documentation

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

Definition at line 14 of file CastorTTRecord.cc.

References CastorDigiColl_, CastorSignalTS_, edm::ParameterSet::getParameter(), reweighted_gain, TrigNames_, TrigThresholds_, and ttpBits_.

14  {
15  CastorDigiColl_ = consumes<CastorDigiCollection>(ps.getParameter<edm::InputTag>("CastorDigiCollection"));
16  CastorSignalTS_ = ps.getParameter<unsigned int>("CastorSignalTS");
17 
18  ttpBits_ = ps.getParameter<std::vector<unsigned int>>("ttpBits");
19  TrigNames_ = ps.getParameter<std::vector<std::string>>("TriggerBitNames");
20  TrigThresholds_ = ps.getParameter<std::vector<double>>("TriggerThresholds");
21 
22  reweighted_gain = 1.0;
23 
24  produces<L1GtTechnicalTriggerRecord>();
25 }
T getParameter(std::string const &) const
std::vector< unsigned int > ttpBits_
unsigned int CastorSignalTS_
std::vector< std::string > TrigNames_
std::vector< double > TrigThresholds_
edm::EDGetTokenT< CastorDigiCollection > CastorDigiColl_
double reweighted_gain
CastorTTRecord::~CastorTTRecord ( )
override

Definition at line 27 of file CastorTTRecord.cc.

27 {}

Member Function Documentation

void CastorTTRecord::getEnergy_fC ( double  energy[16][14],
edm::Handle< CastorDigiCollection > &  CastorDigiColl,
edm::Event e,
const edm::EventSetup c 
)

Definition at line 64 of file CastorTTRecord.cc.

References CastorCoderDb::adc2fC(), edm::SortedCollection< T, SORT >::begin(), AlignmentProducer_cff::calibrations, CastorSignalTS_, edm::SortedCollection< T, SORT >::end(), CastorCalibrations::gain(), edm::EventSetup::get(), CastorDbService::getCastorCalibrations(), CastorDbService::getCastorCoder(), CastorDbService::getCastorShape(), CastorDataFrame::id(), HcalCastorDetId::module(), CastorCalibrations::pedestal(), reweighted_gain, and HcalCastorDetId::sector().

Referenced by produce().

67  {
68  // std::cerr << "**** RUNNING THROUGH CastorTTRecord::getEnergy_fC" <<
69  // std::endl;
70 
71  // Get Conditions
73  eventSetup.get<CastorDbRecord>().get(conditions);
74  const CastorQIEShape *shape = conditions->getCastorShape(); // this one is generic
75 
76  for (int isec = 0; isec < 16; isec++)
77  for (int imod = 0; imod < 14; imod++)
78  energy[isec][imod] = 0;
79 
80  // Loop over digis
82  for (idigi = CastorDigiColl->begin(); idigi != CastorDigiColl->end(); idigi++) {
83  const CastorDataFrame &digi = (*idigi);
84  HcalCastorDetId cell = digi.id();
85 
86  // Get Castor Coder
87  const CastorQIECoder *channelCoder = conditions->getCastorCoder(cell);
88  CastorCoderDb coder(*channelCoder, *shape);
89 
90  // Get Castor Calibration
91  const CastorCalibrations &calibrations = conditions->getCastorCalibrations(cell);
92 
93  // convert adc to fC
94  CaloSamples tool;
95  coder.adc2fC(digi, tool);
96 
97  // pedestal substraction
98  int capid = digi[CastorSignalTS_].capid();
99  double fC = tool[CastorSignalTS_] - calibrations.pedestal(capid);
100 
101  // to correct threshold levels in fC for different gains
102  reweighted_gain = calibrations.gain(capid) / 0.015;
103 
104  energy[digi.id().sector() - 1][digi.id().module() - 1] = fC;
105  }
106 }
int sector() const
get the sector (1-16)
unsigned int CastorSignalTS_
std::vector< T >::const_iterator const_iterator
const CastorCalibrations & getCastorCalibrations(const HcalGenericDetId &fId) const
int module() const
get the module (1-2 for EM, 1-12 for HAD)
const CastorQIEShape * getCastorShape() const
double pedestal(int fCapId) const
get pedestal for capid=0..3
const_iterator end() const
double gain(int fCapId) const
get gain for capid=0..3
const HcalCastorDetId & id() const
double reweighted_gain
const_iterator begin() const
const CastorQIECoder * getCastorCoder(const HcalGenericDetId &fId) const
void CastorTTRecord::getTriggerDecisions ( std::vector< bool > &  decision,
double  energy[16][14] 
) const

Definition at line 108 of file CastorTTRecord.cc.

References getTriggerDecisionsPerOctant().

Referenced by produce().

108  {
109  // std::cerr << "**** RUNNING THROUGH CastorTTRecord::getTriggerDecisions" <<
110  // std::endl;
111 
112  // check if number of bits is at least four
113  if (decision.size() < 4)
114  return;
115 
116  std::vector<bool> tdpo[8]; // TriggerDecisionsPerOctant
118 
119  // preset trigger decisions
120  decision.at(0) = true;
121  decision.at(1) = false;
122  decision.at(2) = false;
123  decision.at(3) = false;
124 
125  // canceld for low pt jet
126  // bool EM_decision = false;
127  // bool HAD_decision = false;
128  // loop over castor octants
129  for (int ioct = 0; ioct < 8; ioct++) {
130  int next_oct = (ioct + 1) % 8;
131  int prev_oct = (ioct + 8 - 1) % 8;
132 
133  // gap Trigger
134  if (!tdpo[ioct].at(0))
135  decision.at(0) = false;
136  if (!tdpo[ioct].at(1))
137  decision.at(0) = false;
138 
139  // jet Trigger
140  if (tdpo[ioct].at(2))
141  decision.at(1) = true;
142 
143  // electron
144  // canceld for low pt jet
145  // if( tdpo[ioct].at(3) ) EM_decision = true;
146  // if( tdpo[ioct].at(4) ) HAD_decision = true;
147 
148  // iso muon
149  if (tdpo[ioct].at(5)) {
150  // was one of the other sectors
151  // in the octant empty ?
152  if (tdpo[ioct].at(0)) {
153  if (tdpo[prev_oct].at(1) && tdpo[next_oct].at(0) && tdpo[next_oct].at(1))
154  decision.at(3) = true;
155  } else if (tdpo[ioct].at(1)) {
156  if (tdpo[prev_oct].at(0) && tdpo[prev_oct].at(1) && tdpo[next_oct].at(0))
157  decision.at(3) = true;
158  }
159  // when not no iso muon
160  }
161 
162  // low pt jet Trigger
163  if (tdpo[ioct].at(6))
164  decision.at(2) = true;
165  }
166 
167  // for EM Trigger whole castor not hadronic and somewhere EM
168  // canceld for low pt jet
169  // decision.at(2) = EM_decision && !HAD_decision;
170 }
void getTriggerDecisionsPerOctant(std::vector< bool > tdps[16], double energy[16][14]) const
void CastorTTRecord::getTriggerDecisionsPerOctant ( std::vector< bool >  tdps[16],
double  energy[16][14] 
) const

Definition at line 172 of file CastorTTRecord.cc.

References reweighted_gain, and TrigThresholds_.

Referenced by getTriggerDecisions().

172  {
173  // std::cerr << "**** RUNNING THROUGH
174  // CastorTTRecord::getTriggerDecisionsPerOctant" << std::endl;
175 
176  // loop over octatants
177  for (int ioct = 0; ioct < 8; ioct++) {
178  // six bits from HTR card
179  // 0. first sector empty
180  // 1. second sector empty
181  // 2. jet any sector
182  // 3. EM any sector
183  // 4. HAD any sector
184  // 5. muon any sector
185  // add instead of EM Trigger (not bit 6 in real)
186  // 6. low pt jet any sector
187  tdpo[ioct].resize(7);
188 
189  for (int ibit = 0; ibit < 7; ibit++)
190  tdpo[ioct].at(ibit) = false;
191 
192  // loop over castor sectors in octant
193  for (int ioctsec = 0; ioctsec < 2; ioctsec++) {
194  // absolute sector number
195  int isec = 2 * ioct + ioctsec;
196 
197  // init module sums for every sector
198  double fCsum_mod = 0;
199  double fCsum_em = 0, fCsum_ha = 0;
200  double fCsum_jet_had = 0;
201  double fCsum_col[3] = {0, 0, 0};
202 
203  // loop over modules
204  for (int imod = 0; imod < 14; imod++) {
205  // total sum
206  fCsum_mod += energy[isec][imod];
207 
208  // EM & HAD sum
209  if (imod < 2)
210  fCsum_em += energy[isec][imod];
211  if (imod > 2 && imod < 12)
212  fCsum_ha += energy[isec][imod];
213 
214  // sum over three sector parts
215  if (imod < 4)
216  fCsum_col[0] += energy[isec][imod];
217  else if (imod < 8)
218  fCsum_col[1] += energy[isec][imod];
219  else if (imod < 12)
220  fCsum_col[2] += energy[isec][imod];
221 
222  // HAD sum for jet trigger v2
223  if (imod > 1 && imod < 5)
224  fCsum_jet_had += energy[isec][imod];
225  }
226 
227  // gap Trigger
228  if (fCsum_mod < TrigThresholds_.at(0)) {
229  if (ioctsec == 0)
230  tdpo[ioct].at(0) = true;
231  else if (ioctsec == 1)
232  tdpo[ioct].at(1) = true;
233  }
234 
235  // jet Trigger
236  // with gain correction
237  /* old version of jet trigger ( deprecated because of saturation )
238  if( fCsum_mod > TrigThresholds_.at(1) / reweighted_gain )
239  tdpo[ioct].at(2) = true;
240  */
241  if (fCsum_jet_had > TrigThresholds_.at(1) / reweighted_gain)
242  // additional high threshold near saturation for EM part
243  if (energy[isec][0] > 26000 / reweighted_gain && energy[isec][1] > 26000 / reweighted_gain)
244  tdpo[ioct].at(2) = true;
245 
246  // low pt jet Trigger
247  if (fCsum_mod > TrigThresholds_.at(5) / reweighted_gain)
248  tdpo[ioct].at(6) = true;
249 
250  // egamma Trigger
251  // with gain correction only in the EM threshold
252  if (fCsum_em > TrigThresholds_.at(2) / reweighted_gain)
253  tdpo[ioct].at(3) = true;
254  if (fCsum_ha > TrigThresholds_.at(3))
255  tdpo[ioct].at(4) = true;
256 
257  // muon Trigger
258  int countColumns = 0;
259  for (int icol = 0; icol < 3; icol++)
260  if (fCsum_col[icol] > TrigThresholds_.at(4))
261  countColumns++;
262  if (countColumns >= 2)
263  tdpo[ioct].at(5) = true;
264  }
265  }
266 }
std::vector< double > TrigThresholds_
double reweighted_gain
void CastorTTRecord::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 29 of file CastorTTRecord.cc.

References CastorDigiColl_, edm::Event::getByToken(), getEnergy_fC(), getTriggerDecisions(), mps_fire::i, eostools::move(), convertSQLitetoXML_cfg::output, edm::Event::put(), TrigNames_, and ttpBits_.

29  {
30  // std::cerr << "**** RUNNING THROUGH CastorTTRecord::produce" << std::endl;
31 
32  std::vector<L1GtTechnicalTrigger> vecTT(ttpBits_.size());
33 
34  // Get Inputs
35  edm::Handle<CastorDigiCollection> CastorDigiColl;
36  e.getByToken(CastorDigiColl_, CastorDigiColl);
37 
38  if (!CastorDigiColl.failedToGet()) {
39  double cas_efC[16][14];
40  getEnergy_fC(cas_efC, CastorDigiColl, e, eventSetup);
41 
42  std::vector<bool> decision(ttpBits_.size());
43 
44  getTriggerDecisions(decision, cas_efC);
45 
46  for (unsigned int i = 0; i < ttpBits_.size(); i++) {
47  // if( decision.at(i) ) std::cerr << "**** Something Triggered" <<
48  // std::endl; std::cout << "Run CastorTTRecord::produce. TriggerBit = " <<
49  // ttpBits_.at(i) << "; TriggerName = " << TrigNames_.at(i) << "; Decision
50  // = " << decision[i] << std::endl;
51  vecTT.at(i) = L1GtTechnicalTrigger(TrigNames_.at(i), ttpBits_.at(i), 0, decision.at(i));
52  }
53 
54  } else {
55  vecTT.clear();
56  }
57 
58  // Put output into event
59  std::unique_ptr<L1GtTechnicalTriggerRecord> output(new L1GtTechnicalTriggerRecord());
60  output->setGtTechnicalTrigger(vecTT);
61  e.put(std::move(output));
62 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
std::vector< unsigned int > ttpBits_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< std::string > TrigNames_
void getTriggerDecisions(std::vector< bool > &decision, double energy[16][14]) const
edm::EDGetTokenT< CastorDigiCollection > CastorDigiColl_
void getEnergy_fC(double energy[16][14], edm::Handle< CastorDigiCollection > &CastorDigiColl, edm::Event &e, const edm::EventSetup &c)
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::EDGetTokenT<CastorDigiCollection> CastorTTRecord::CastorDigiColl_
private

Definition at line 33 of file CastorTTRecord.h.

Referenced by CastorTTRecord(), and produce().

unsigned int CastorTTRecord::CastorSignalTS_
private

Definition at line 34 of file CastorTTRecord.h.

Referenced by CastorTTRecord(), and getEnergy_fC().

double CastorTTRecord::reweighted_gain
private

Definition at line 40 of file CastorTTRecord.h.

Referenced by CastorTTRecord(), getEnergy_fC(), and getTriggerDecisionsPerOctant().

std::vector<std::string> CastorTTRecord::TrigNames_
private

Definition at line 37 of file CastorTTRecord.h.

Referenced by CastorTTRecord(), and produce().

std::vector<double> CastorTTRecord::TrigThresholds_
private

Definition at line 38 of file CastorTTRecord.h.

Referenced by CastorTTRecord(), and getTriggerDecisionsPerOctant().

std::vector<unsigned int> CastorTTRecord::ttpBits_
private

Definition at line 36 of file CastorTTRecord.h.

Referenced by CastorTTRecord(), and produce().