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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const 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
 
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 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
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::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

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

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

Definition at line 46 of file BSCTrigger.cc.

Constructor & Destructor Documentation

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

Definition at line 77 of file BSCTrigger.cc.

References edm::ParameterSet::getParameter(), names_, theCoincidence_, theHitsToken_, thePutToken_, and theResolution_.

77  :
78  ttBits_{iConfig.getParameter< std::vector<unsigned> >("bitNumbers")},
79  names_{iConfig.getParameter< std::vector<std::string> >("bitNames")},
80  theCoincidence_{iConfig.getParameter<double>("coincidence")},
81  theResolution_{iConfig.getParameter<double>("resolution")},
82  theHitsToken_{consumes<CrossingFrame<PSimHit>>(iConfig.getParameter<edm::InputTag>("theHits")) },
83  thePutToken_{produces<L1GtTechnicalTriggerRecord>()}
84 {
85 }
T getParameter(std::string const &) const
const edm::EDPutTokenT< L1GtTechnicalTriggerRecord > thePutToken_
Definition: BSCTrigger.cc:62
const edm::EDGetTokenT< CrossingFrame< PSimHit > > theHitsToken_
Definition: BSCTrigger.cc:61
const double theCoincidence_
Definition: BSCTrigger.cc:59
const double theResolution_
Definition: BSCTrigger.cc:60
const std::vector< unsigned > ttBits_
Definition: BSCTrigger.cc:57
const std::vector< std::string > names_
Definition: BSCTrigger.cc:58
BSCTrigger::~BSCTrigger ( )
override

Definition at line 88 of file BSCTrigger.cc.

89 {
90 
91  // do anything here that needs to be done at desctruction time
92  // (e.g. close files, deallocate resources etc.)
93 
94 }

Member Function Documentation

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

Definition at line 235 of file BSCTrigger.cc.

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

Referenced by produce().

235  {
236  int zside = 0;
237  if ( z > 0 ) zside = 1;
238  if ( edm::isDebugEnabled() ) {
239  int det = (id&24)>>3;
240  int station = id&7;
241  LogTrace("BSCTrig")<<"id="<<id<<" zside="<<zside<<" det="<<det<<" station="<<station;
242  }
243  int BSCNum;
244  if (id&16) BSCNum=32+(id&1)+(zside<<1) ; // small paddles further from IP
245  else BSCNum= (id&15)+(zside<<4); // the BSC on the HF
246  return BSCNum;
247 }
bool isDebugEnabled()
int zside(DetId const &)
#define LogTrace(id)
bool BSCTrigger::isInner ( int  id) const
private

Definition at line 249 of file BSCTrigger.cc.

Referenced by produce().

249  {
250  return ( (id&8)>>3 ) ;
251 }
bool BSCTrigger::isZplus ( int  id) const
private

Definition at line 253 of file BSCTrigger.cc.

References DEFINE_FWK_MODULE.

Referenced by produce().

253  {
254  return ( (id&16)>>4 ) ;
255 }
void BSCTrigger::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivate

Definition at line 102 of file BSCTrigger.cc.

References funct::abs(), EnergyCorrector::c, constexpr, edm::Event::emplace(), getBSCNum(), edm::Event::getByToken(), mps_fire::i, triggerObjects_cff::id, edm::isDebugEnabled(), isInner(), isZplus(), LogDebug, LogTrace, eostools::move(), names_, convertSQLitetoXML_cfg::output, L1GtTechnicalTriggerRecord::setGtTechnicalTrigger(), mathSSE::sqrt(), protons_cff::t, theCoincidence_, theHitsToken_, thePutToken_, theResolution_, and ttBits_.

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

Member Data Documentation

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

Definition at line 58 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

const double BSCTrigger::theCoincidence_
private

Definition at line 59 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

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

Definition at line 61 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

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

Definition at line 62 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

const double BSCTrigger::theResolution_
private

Definition at line 60 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

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

Definition at line 57 of file BSCTrigger.cc.

Referenced by produce().