CMS 3D CMS Logo

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

#include <L1TriggerOffline/BSCTriggerSimulation/src/BSCTrigger.cc>

Inheritance diagram for BSCTrigger:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 BSCTrigger (const edm::ParameterSet &)
 
 ~BSCTrigger () override
 
- Public Member Functions inherited from edm::global::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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

int getBSCNum (int id, float z) const
 
bool isInner (int id) const
 
bool isZplus (int id) const
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

const std::vector< std::string > names_
 
const double theCoincidence_
 
const edm::EDGetTokenT< CrossingFrame< PSimHit > > theHitsToken_
 
const edm::EDPutTokenT< L1GtTechnicalTriggerRecordthePutToken_
 
const double theResolution_
 
const std::vector< unsigned > ttBits_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 44 of file BSCTrigger.cc.

Constructor & Destructor Documentation

◆ BSCTrigger()

BSCTrigger::BSCTrigger ( const edm::ParameterSet iConfig)
explicit

Definition at line 74 of file BSCTrigger.cc.

References edm::ParameterSet::getParameter().

75  : ttBits_{iConfig.getParameter<std::vector<unsigned>>("bitNumbers")},
76  names_{iConfig.getParameter<std::vector<std::string>>("bitNames")},
77  theCoincidence_{iConfig.getParameter<double>("coincidence")},
78  theResolution_{iConfig.getParameter<double>("resolution")},
79  theHitsToken_{consumes<CrossingFrame<PSimHit>>(iConfig.getParameter<edm::InputTag>("theHits"))},
80  thePutToken_{produces<L1GtTechnicalTriggerRecord>()} {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDPutTokenT< L1GtTechnicalTriggerRecord > thePutToken_
Definition: BSCTrigger.cc:60
const edm::EDGetTokenT< CrossingFrame< PSimHit > > theHitsToken_
Definition: BSCTrigger.cc:59
const double theCoincidence_
Definition: BSCTrigger.cc:57
const double theResolution_
Definition: BSCTrigger.cc:58
const std::vector< unsigned > ttBits_
Definition: BSCTrigger.cc:55
const std::vector< std::string > names_
Definition: BSCTrigger.cc:56

◆ ~BSCTrigger()

BSCTrigger::~BSCTrigger ( )
override

Definition at line 82 of file BSCTrigger.cc.

82  {
83  // do anything here that needs to be done at desctruction time
84  // (e.g. close files, deallocate resources etc.)
85 }

Member Function Documentation

◆ getBSCNum()

int BSCTrigger::getBSCNum ( int  id,
float  z 
) const
private

Definition at line 270 of file BSCTrigger.cc.

References edm::isDebugEnabled(), LogTrace, relativeConstraints::station, z, and ecaldqm::zside().

Referenced by produce().

270  {
271  int zside = 0;
272  if (z > 0)
273  zside = 1;
274  if (edm::isDebugEnabled()) {
275  int det = (id & 24) >> 3;
276  int station = id & 7;
277  LogTrace("BSCTrig") << "id=" << id << " zside=" << zside << " det=" << det << " station=" << station;
278  }
279  int BSCNum;
280  if (id & 16)
281  BSCNum = 32 + (id & 1) + (zside << 1); // small paddles further from IP
282  else
283  BSCNum = (id & 15) + (zside << 4); // the BSC on the HF
284  return BSCNum;
285 }
bool isDebugEnabled()
int zside(DetId const &)
#define LogTrace(id)

◆ isInner()

bool BSCTrigger::isInner ( int  id) const
private

Definition at line 287 of file BSCTrigger.cc.

Referenced by produce().

287 { return ((id & 8) >> 3); }

◆ isZplus()

bool BSCTrigger::isZplus ( int  id) const
private

Definition at line 289 of file BSCTrigger.cc.

Referenced by produce().

289 { return ((id & 16) >> 4); }

◆ produce()

void BSCTrigger::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 92 of file BSCTrigger.cc.

References funct::abs(), triggerObjects_cff::bit, DummyCfis::c, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), getBSCNum(), mps_fire::i, EcalPhiSymFlatTableProducers_cfi::id, iEvent, edm::isDebugEnabled(), isInner(), isZplus(), LogDebug, LogTrace, eostools::move(), names_, convertSQLitetoXML_cfg::output, mathSSE::sqrt(), submitPVValidationJobs::t, theCoincidence_, theHitsToken_, thePutToken_, theResolution_, and ttBits_.

92  {
93  std::vector<L1GtTechnicalTrigger> ttVec(ttBits_.size());
94 
96  iEvent.getByToken(theHitsToken_, cf);
97 
98  if (!cf.failedToGet()) {
99  std::vector<float> EnergyBX(32);
100  std::vector<float> EnergyBXMinusDt(32);
101 
102  for (int c = 0; c < 32; ++c) {
103  EnergyBX[c] = 0;
104  EnergyBXMinusDt[c] = 0;
105  }
106  MixCollection<PSimHit> theBSCHitContainer(cf.product());
107  const float dt1 = theCoincidence_ / 2 + theResolution_;
108  const float dt2 = theCoincidence_ / 2 - theResolution_;
109  if (edm::isDebugEnabled())
110  LogDebug("BSCTrig") << " ----------------new event ---with " << theBSCHitContainer.size() << " hits in the BSC";
111 
112  // collect total deposited energy in BSC segments -> EnergyBX[segment id], in GeV units ---------------------------------------------------------------
113  for (auto itHit = theBSCHitContainer.begin(); itHit != theBSCHitContainer.end(); ++itHit) {
114  float zh = itHit->entryPoint().z() / 10;
115  int id = getBSCNum(itHit->detUnitId(), zh);
116  if (id > 31)
117  continue; // the small 2 paddles further from the IP
118  float t = itHit->timeOfFlight();
119 
120  if (edm::isDebugEnabled()) {
121  float rh = sqrt(itHit->entryPoint().x() * itHit->entryPoint().x() +
122  itHit->entryPoint().y() * itHit->entryPoint().y()) /
123  10;
124  LogTrace("BSCTrig") << " BSC Num " << id << " z=" << zh << " isZplus=" << isZplus(id)
125  << " Hit DetId=" << getBSCNum(id, zh) << " r=" << rh << " isInner=" << isInner(id);
126  LogTrace("BSCTrig") << " Hit time=" << t << " accepted range=[" << dt2 << "," << dt1 << "] from a "
127  << abs(itHit->particleType()) << " with energy " << itHit->energyLoss();
128  }
129  if (fabs(t) > dt1 || fabs(t) < dt2)
130  continue;
131  if (t > 0)
132  EnergyBX[id] += itHit->energyLoss();
133  else
134  EnergyBXMinusDt[id] += itHit->energyLoss();
135  }
136 
137  // count number of segments hit in inner/outer and +z, -z ---------------------------------------------------------------------------------------------
138  int ZMinnerBX = 0, ZMouterBX = 0;
139  int ZPinnerBX = 0, ZPouterBX = 0;
140  int ZMinnerBXMinusDt = 0, ZMouterBXMinusDt = 0;
141  int ZPinnerBXMinusDt = 0, ZPouterBXMinusDt = 0;
142 
143  constexpr float MipFraction = 0.5;
144  constexpr float MipEnergy = 0.0027;
145  constexpr float theThreshold = MipFraction * MipEnergy;
146  for (unsigned int ipad = 0; ipad < 32; ipad++) {
147  if (edm::isDebugEnabled())
148  LogTrace("BSCTrig") << " EnergyBX[" << ipad << "]=" << EnergyBX[ipad];
149  // hits after the bunch crossing
150  if (EnergyBX[ipad] > theThreshold) {
151  if (isZplus(ipad)) {
152  if (isInner(ipad))
153  ZPinnerBX++;
154  else
155  ZPouterBX++;
156  } else {
157  if (isInner(ipad))
158  ZMinnerBX++;
159  else
160  ZMouterBX++;
161  }
162  }
163  // hits before the bunch crossing
164  if (EnergyBXMinusDt[ipad] > theThreshold) {
165  if (isZplus(ipad)) {
166  if (isInner(ipad))
167  ZPinnerBXMinusDt++;
168  else
169  ZPouterBXMinusDt++;
170  } else {
171  if (isInner(ipad))
172  ZMinnerBXMinusDt++;
173  else
174  ZMouterBXMinusDt++;
175  }
176  }
177  }
178 
179  if (edm::isDebugEnabled())
180  LogTrace("BSCTrig") << " Zplus I=" << ZPinnerBX << " Zminus I=" << ZMinnerBX << " Zplus O=" << ZPouterBX
181  << " Zminus O=" << ZMouterBX;
182 
183  // minimum bias technical triggers that are also connected to 'external condition' triggers -----------------
184  bool bit32 = false; // min bias inner >=1
185  if (ZPinnerBX >= 1 && ZMinnerBX >= 1)
186  bit32 = true;
187 
188  bool bit33 = false; // min bias inner >=2
189  if (ZPinnerBX >= 2 && ZMinnerBX >= 2)
190  bit33 = true;
191 
192  bool bit34 = false; // min bias OR
193  if (ZPinnerBX + ZMinnerBX + ZPouterBX + ZMouterBX >= 1)
194  bit34 = true;
195 
196  bool bit35 = false; // high multiplicity
197  if (ZPinnerBX == 8 && ZMinnerBX == 8)
198  bit35 = true;
199 
200  // beam halo technical triggers ----------------------------------------------------------------
201  bool bit36 = false; // beam 2 halo inner
202  if (ZPinnerBX >= 1 && ZMinnerBXMinusDt >= 1)
203  bit36 = true;
204 
205  bool bit37 = false; // beam 2 halo outer
206  if (ZPouterBX >= 1 && ZMouterBXMinusDt >= 1)
207  bit37 = true;
208 
209  bool bit38 = false; // beam 1 halo inner
210  if (ZMinnerBX >= 1 && ZPinnerBXMinusDt >= 1)
211  bit38 = true;
212 
213  bool bit39 = false; // beam 1 halo outer
214  if (ZMouterBX >= 1 && ZPouterBXMinusDt >= 1)
215  bit39 = true;
216 
217  // minimum bias technical triggers ---------------------------------------------------------
218  bool bit40 = false; // min bias all >=1
219  if (ZPinnerBX + ZPouterBX >= 1 && ZMinnerBX + ZMouterBX >= 1)
220  bit40 = true;
221 
222  bool bit41 = false; // min bias all >=2
223  if (ZPinnerBX + ZPouterBX >= 2 && ZMinnerBX + ZMouterBX >= 2)
224  bit41 = true;
225 
226  bool bit42 = false; // beam 1 splash (-z)
227  if (ZMinnerBX >= 2)
228  bit42 = true;
229 
230  bool bit43 = false; // beam 2 splash (+z)
231  if (ZPinnerBX >= 2)
232  bit43 = true;
233 
234  for (unsigned i = 0; i < ttBits_.size(); ++i) {
235  bool bit = false;
236  if (names_.at(i) == names_[0])
237  bit = bit32;
238  if (names_.at(i) == names_[1])
239  bit = bit33;
240  if (names_.at(i) == names_[2])
241  bit = bit34;
242  if (names_.at(i) == names_[3])
243  bit = bit35;
244  if (names_.at(i) == names_[4])
245  bit = bit36;
246  if (names_.at(i) == names_[5])
247  bit = bit37;
248  if (names_.at(i) == names_[6])
249  bit = bit38;
250  if (names_.at(i) == names_[7])
251  bit = bit39;
252  if (names_.at(i) == names_[8])
253  bit = bit40;
254  if (names_.at(i) == names_[9])
255  bit = bit41;
256  if (names_.at(i) == names_[10])
257  bit = bit42;
258  if (names_.at(i) == names_[11])
259  bit = bit43;
260  ttVec.at(i) = L1GtTechnicalTrigger(names_.at(i), ttBits_.at(i), 0, bit);
261  if (edm::isDebugEnabled())
262  LogTrace("AnaBsc") << "bit: " << ttBits_[i] << " VALUE:" << bit;
263  }
264  } else
265  ttVec.clear();
267  output.setGtTechnicalTrigger(ttVec);
268  iEvent.emplace(thePutToken_, std::move(output));
269 }
bool isDebugEnabled()
bool isInner(int id) const
Definition: BSCTrigger.cc:287
const edm::EDPutTokenT< L1GtTechnicalTriggerRecord > thePutToken_
Definition: BSCTrigger.cc:60
const edm::EDGetTokenT< CrossingFrame< PSimHit > > theHitsToken_
Definition: BSCTrigger.cc:59
const double theCoincidence_
Definition: BSCTrigger.cc:57
const double theResolution_
Definition: BSCTrigger.cc:58
const std::vector< unsigned > ttBits_
Definition: BSCTrigger.cc:55
#define LogTrace(id)
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:23
int getBSCNum(int id, float z) const
Definition: BSCTrigger.cc:270
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::vector< std::string > names_
Definition: BSCTrigger.cc:56
Definition: output.py:1
bool isZplus(int id) const
Definition: BSCTrigger.cc:289
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

Member Data Documentation

◆ names_

const std::vector<std::string> BSCTrigger::names_
private

Definition at line 56 of file BSCTrigger.cc.

Referenced by produce().

◆ theCoincidence_

const double BSCTrigger::theCoincidence_
private

Definition at line 57 of file BSCTrigger.cc.

Referenced by produce().

◆ theHitsToken_

const edm::EDGetTokenT<CrossingFrame<PSimHit> > BSCTrigger::theHitsToken_
private

Definition at line 59 of file BSCTrigger.cc.

Referenced by produce().

◆ thePutToken_

const edm::EDPutTokenT<L1GtTechnicalTriggerRecord> BSCTrigger::thePutToken_
private

Definition at line 60 of file BSCTrigger.cc.

Referenced by produce().

◆ theResolution_

const double BSCTrigger::theResolution_
private

Definition at line 58 of file BSCTrigger.cc.

Referenced by produce().

◆ ttBits_

const std::vector<unsigned> BSCTrigger::ttBits_
private

Definition at line 55 of file BSCTrigger.cc.

Referenced by produce().