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 ()
 
ModuleDescription const & moduleDescription () const
 
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
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

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
 
- 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::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 44 of file BSCTrigger.cc.

Constructor & Destructor Documentation

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

Definition at line 80 of file BSCTrigger.cc.

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

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

Definition at line 92 of file BSCTrigger.cc.

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

Member Function Documentation

void BSCTrigger::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 242 of file BSCTrigger.cc.

243 {
244 }
void BSCTrigger::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 247 of file BSCTrigger.cc.

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

Definition at line 250 of file BSCTrigger.cc.

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

Referenced by produce().

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

Definition at line 264 of file BSCTrigger.cc.

Referenced by produce().

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

Definition at line 268 of file BSCTrigger.cc.

Referenced by produce().

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

Implements edm::EDProducer.

Definition at line 106 of file BSCTrigger.cc.

References funct::abs(), EnergyCorrector::c, 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(), edmStreamStallGrapher::t, theCoincidence_, TheHits_tag_, theResolution_, and ttBits_.

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

Member Data Documentation

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

Definition at line 58 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

unsigned BSCTrigger::nEvt_
private

Definition at line 59 of file BSCTrigger.cc.

int BSCTrigger::nevt_
private

Definition at line 64 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

float BSCTrigger::theCoincidence_
private

Definition at line 60 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

edm::InputTag BSCTrigger::TheHits_tag_
private

Definition at line 65 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

int BSCTrigger::theNinner_
private

Definition at line 62 of file BSCTrigger.cc.

int BSCTrigger::theNouter_
private

Definition at line 63 of file BSCTrigger.cc.

float BSCTrigger::theResolution_
private

Definition at line 61 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

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

Definition at line 57 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().