CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 BSCTrigger (const edm::ParameterSet &)
 
 ~BSCTrigger ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
int getBSCNum (int id, float z)
 
bool isInner (int id)
 
bool isZplus (int id)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

std::vector< std::string > names_
 
unsigned nEvt_
 
int nevt_
 
float theCoincidence_
 
edm::InputTag TheHits_tag_
 
int theNinner_
 
int theNouter_
 
float theResolution_
 
std::vector< unsigned > ttBits_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 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 45 of file BSCTrigger.cc.

Constructor & Destructor Documentation

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

Definition at line 81 of file BSCTrigger.cc.

References edm::ParameterSet::getParameter(), names_, nevt_, theCoincidence_, TheHits_tag_, theResolution_, and ttBits_.

82 {
83  ttBits_=iConfig.getParameter< std::vector<unsigned> >("bitNumbers");
84  names_= iConfig.getParameter< std::vector<std::string> >("bitNames");
85  theCoincidence_= iConfig.getParameter<double>("coincidence");
86  theResolution_= iConfig.getParameter<double>("resolution");
87  TheHits_tag_= iConfig.getParameter<edm::InputTag>("theHits");
88  produces<L1GtTechnicalTriggerRecord>();
89  nevt_=0;
90 }
T getParameter(std::string const &) const
float theResolution_
Definition: BSCTrigger.cc:62
std::vector< unsigned > ttBits_
Definition: BSCTrigger.cc:58
std::vector< std::string > names_
Definition: BSCTrigger.cc:59
edm::InputTag TheHits_tag_
Definition: BSCTrigger.cc:66
float theCoincidence_
Definition: BSCTrigger.cc:61
BSCTrigger::~BSCTrigger ( )

Definition at line 93 of file BSCTrigger.cc.

94 {
95 
96  // do anything here that needs to be done at desctruction time
97  // (e.g. close files, deallocate resources etc.)
98 
99 }

Member Function Documentation

void BSCTrigger::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 243 of file BSCTrigger.cc.

244 {
245 }
void BSCTrigger::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 248 of file BSCTrigger.cc.

248  {
249 }
int BSCTrigger::getBSCNum ( int  id,
float  z 
)
private

Definition at line 251 of file BSCTrigger.cc.

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

Referenced by produce().

251  {
252  int zside = 0;
253  if ( z > 0 ) zside = 1;
254  if ( edm::isDebugEnabled() ) {
255  int det = (id&24)>>3;
256  int station = id&7;
257  LogTrace("BSCTrig")<<"id="<<id<<" zside="<<zside<<" det="<<det<<" station="<<station;
258  }
259  int BSCNum;
260  if (id&16) BSCNum=32+(id&1)+(zside<<1) ; // small paddles further from IP
261  else BSCNum= (id&15)+(zside<<4); // the BSC on the HF
262  return BSCNum;
263 }
bool isDebugEnabled()
float float float z
#define LogTrace(id)
bool BSCTrigger::isInner ( int  id)
private

Definition at line 265 of file BSCTrigger.cc.

Referenced by produce().

265  {
266  return ( (id&8)>>3 ) ;
267 }
bool BSCTrigger::isZplus ( int  id)
private

Definition at line 269 of file BSCTrigger.cc.

Referenced by produce().

269  {
270  return ( (id&16)>>4 ) ;
271 }
void BSCTrigger::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 107 of file BSCTrigger.cc.

References abs, MixCollection< T >::begin(), trackerHits::c, MixCollection< T >::end(), edm::HandleBase::failedToGet(), getBSCNum(), edm::Event::getByLabel(), i, edm::isDebugEnabled(), isInner(), isZplus(), LogDebug, LogTrace, names_, nevt_, convertSQLitetoXML_cfg::output, edm::Handle< T >::product(), edm::Event::put(), mathSSE::sqrt(), lumiQTWidget::t, theCoincidence_, TheHits_tag_, theResolution_, and ttBits_.

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

Member Data Documentation

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

Definition at line 59 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

unsigned BSCTrigger::nEvt_
private

Definition at line 60 of file BSCTrigger.cc.

int BSCTrigger::nevt_
private

Definition at line 65 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

float BSCTrigger::theCoincidence_
private

Definition at line 61 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

edm::InputTag BSCTrigger::TheHits_tag_
private

Definition at line 66 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

int BSCTrigger::theNinner_
private

Definition at line 63 of file BSCTrigger.cc.

int BSCTrigger::theNouter_
private

Definition at line 64 of file BSCTrigger.cc.

float BSCTrigger::theResolution_
private

Definition at line 62 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

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

Definition at line 58 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().