CMS 3D CMS Logo

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::ProductRegistryHelper

List of all members.

Public Member Functions

 BSCTrigger (const edm::ParameterSet &)
 ~BSCTrigger ()

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_
int nevt_
unsigned nEvt_
float theCoincidence_
edm::InputTag TheHits_tag_
int theNinner_
int theNouter_
float theResolution_
std::vector< unsigned > ttBits_

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_.

{
  ttBits_=iConfig.getParameter< std::vector<unsigned> >("bitNumbers");
  names_= iConfig.getParameter< std::vector<std::string> >("bitNames");
  theCoincidence_= iConfig.getParameter<double>("coincidence");
  theResolution_= iConfig.getParameter<double>("resolution");
  TheHits_tag_= iConfig.getParameter<edm::InputTag>("theHits");
  produces<L1GtTechnicalTriggerRecord>();  
  nevt_=0;
}
BSCTrigger::~BSCTrigger ( )

Definition at line 93 of file BSCTrigger.cc.

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

}

Member Function Documentation

void BSCTrigger::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 243 of file BSCTrigger.cc.

{
}
void BSCTrigger::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 248 of file BSCTrigger.cc.

                        {
}
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().

                                           {
  int zside = 0;
  if ( z > 0 ) zside = 1;
  if ( edm::isDebugEnabled() ) {
    int det    = (id&24)>>3;
    int station = id&7;
    LogTrace("BSCTrig")<<"id="<<id<<" zside="<<zside<<" det="<<det<<" station="<<station;
  }
  int BSCNum;
  if (id&16) BSCNum=32+(id&1)+(zside<<1) ;  // small paddles further from IP
  else BSCNum= (id&15)+(zside<<4);          // the BSC on the HF
  return BSCNum;
}
bool BSCTrigger::isInner ( int  id) [private]

Definition at line 265 of file BSCTrigger.cc.

Referenced by produce().

                                { 
  return ( (id&8)>>3 ) ;
}
bool BSCTrigger::isZplus ( int  id) [private]

Definition at line 269 of file BSCTrigger.cc.

Referenced by produce().

                                { 
  return ( (id&16)>>4 ) ;
}
void BSCTrigger::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

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, ExpressReco_HICollisions_FallBack::id, edm::isDebugEnabled(), isInner(), isZplus(), LogDebug, LogTrace, names_, nevt_, convertSQLitetoXML_cfg::output, edm::Handle< T >::product(), edm::Event::put(), mathSSE::sqrt(), matplotRender::t, theCoincidence_, TheHits_tag_, theResolution_, and ttBits_.

{
  std::vector<L1GtTechnicalTrigger> ttVec(ttBits_.size());
  std::vector<float>EnergyBX(32);
  std::vector<float>EnergyBXMinusDt(32);
  int ZMinnerBX=0, ZMouterBX=0;
  int ZPinnerBX=0, ZPouterBX=0;
  int ZMinnerBXMinusDt=0, ZMouterBXMinusDt=0;
  int ZPinnerBXMinusDt=0, ZPouterBXMinusDt=0;
  ++nevt_;
  std::auto_ptr<L1GtTechnicalTriggerRecord> BscRecord;
  float MipFraction=0.5;
  float MipEnergy=0.0027;
  float theThreshold=MipFraction*MipEnergy;

  edm::Handle<CrossingFrame<PSimHit> > cf;
  iEvent.getByLabel(TheHits_tag_, cf);
   
  if (!cf.failedToGet()) {
    for ( int c=0;c<32;++c){
      EnergyBX[c]=0;
      EnergyBXMinusDt[c]=0;
    }
    std::auto_ptr<MixCollection<PSimHit> > theBSCHitContainer( new MixCollection <PSimHit>(cf.product()));
    MixCollection<PSimHit>::MixItr itHit;
    float dt1,dt2;
    dt1=theCoincidence_/2 + theResolution_;
    dt2=theCoincidence_/2 - theResolution_;
    if ( edm::isDebugEnabled() ) LogDebug("BSCTrig")<<" ----------------new event ---with "<<theBSCHitContainer->size()<<" hits in the BSC";
    
    // collect total deposited energy in BSC segments -> EnergyBX[segment id], in GeV units ---------------------------------------------------------------
    for (itHit = theBSCHitContainer->begin(); itHit != theBSCHitContainer->end(); ++itHit) {
      float zh=itHit->entryPoint().z()/10;    
      int id=getBSCNum(itHit->detUnitId(),zh);
      if ( id > 31 ) continue;   // the small 2 paddles further from the IP
      float t=itHit->timeOfFlight();

      if ( edm::isDebugEnabled() ) {
        float rh=sqrt(itHit->entryPoint().x()*itHit->entryPoint().x()+itHit->entryPoint().y()*itHit->entryPoint().y())/10;    
        LogTrace("BSCTrig")<<" BSC Num "<<id<<" z="<<zh<<" isZplus="<<isZplus(id)<<" Hit DetId="<<getBSCNum(id,zh)<<" r="<<rh<<" isInner="<<isInner(id);
        LogTrace("BSCTrig")<<" Hit time="<<t<<" accepted range=["<<dt2<<","<<dt1<<"] from a "<<abs(itHit->particleType())<<" with energy " <<itHit->energyLoss();
      }
      if (fabs(t)> dt1 || fabs(t) <dt2 ) continue;
      if (t>0) EnergyBX[id]+=itHit->energyLoss();
      else EnergyBXMinusDt[id]+=itHit->energyLoss();    
    }

    // count number of segments hit in inner/outer and +z, -z ---------------------------------------------------------------------------------------------
    for ( unsigned int ipad = 0 ; ipad<32; ipad++) {
      if ( edm::isDebugEnabled() ) LogTrace("BSCTrig")<<" EnergyBX["<<ipad<<"]="<<EnergyBX[ipad];
      // hits after the bunch crossing
      if ( EnergyBX[ipad] > theThreshold ) {
        if ( isZplus(ipad)) {
          if ( isInner(ipad) ) ZPinnerBX++;
          else ZPouterBX++;
        } else {
          if ( isInner(ipad) ) ZMinnerBX++;
          else ZMouterBX++;     
        }
      } 
      // hits before the bunch crossing
      if ( EnergyBXMinusDt[ipad] > theThreshold ) {
        if ( isZplus(ipad)) {
          if ( isInner(ipad) ) ZPinnerBXMinusDt++;
          else ZPouterBXMinusDt++;
        } else {
          if ( isInner(ipad) ) ZMinnerBXMinusDt++;
          else ZMouterBXMinusDt++;      
        }
      } 
    }

    if ( edm::isDebugEnabled() ) LogTrace("BSCTrig")<<" Zplus I="<<ZPinnerBX<<" Zminus I="<<ZMinnerBX<<" Zplus O="<<ZPouterBX<<"  Zminus O="<<ZMouterBX;

    // minimum bias technical triggers that are also connected to 'external condition' triggers -----------------
    bool bit32=false;    // min bias inner >=1
    if(ZPinnerBX >= 1 && ZMinnerBX >= 1) bit32 = true;

    bool bit33=false;    // min bias inner >=2
    if(ZPinnerBX >= 2 && ZMinnerBX >= 2) bit33 = true;

    bool bit34=false;    // min bias OR
    if(ZPinnerBX + ZMinnerBX + ZPouterBX + ZMouterBX >= 1) bit34 = true;

    bool bit35=false;    // high multiplicity
    if(ZPinnerBX == 8 && ZMinnerBX == 8) bit35 = true;

    // beam halo technical triggers ----------------------------------------------------------------
    bool bit36=false;    // beam 2 halo inner
    if(ZPinnerBX >= 1 && ZMinnerBXMinusDt >= 1) bit36 = true;

    bool bit37=false;    // beam 2 halo outer
    if(ZPouterBX >= 1 && ZMouterBXMinusDt >= 1) bit37 = true;

    bool bit38=false;    // beam 1 halo inner
    if(ZMinnerBX >= 1 && ZPinnerBXMinusDt >= 1) bit38 = true;

    bool bit39=false;    // beam 1 halo outer
    if(ZMouterBX >= 1 && ZPouterBXMinusDt >= 1) bit39 = true;

    // minimum bias technical triggers ---------------------------------------------------------
    bool bit40=false;    // min bias all >=1
    if(ZPinnerBX + ZPouterBX >= 1 && ZMinnerBX + ZMouterBX >= 1) bit40 = true;

    bool bit41=false;    // min bias all >=2
    if(ZPinnerBX + ZPouterBX >= 2 && ZMinnerBX + ZMouterBX >= 2) bit41 = true;

    bool bit42=false;    // beam 1 splash (-z)
    if(ZMinnerBX >= 2) bit42 = true;

    bool bit43=false;    // beam 2 splash (+z)
    if(ZPinnerBX >= 2) bit43 = true;

    for ( unsigned i=0; i< ttBits_.size();++i ){
      bool bit = false;
      if ( names_.at(i) == names_[0] ) bit = bit32;
      if ( names_.at(i) == names_[1] ) bit = bit33;
      if ( names_.at(i) == names_[2] ) bit = bit34;
      if ( names_.at(i) == names_[3] ) bit = bit35;
      if ( names_.at(i) == names_[4] ) bit = bit36;
      if ( names_.at(i) == names_[5] ) bit = bit37;
      if ( names_.at(i) == names_[6] ) bit = bit38;
      if ( names_.at(i) == names_[7] ) bit = bit39;
      if ( names_.at(i) == names_[8] ) bit = bit40;
      if ( names_.at(i) == names_[9] ) bit = bit41;
      if ( names_.at(i) == names_[10]) bit = bit42;
      if ( names_.at(i) == names_[11]) bit = bit43;
      ttVec.at(i)=L1GtTechnicalTrigger(names_.at(i), ttBits_.at(i), 0, bit) ;
      if ( edm::isDebugEnabled() ) LogTrace("AnaBsc") << "bit: "<<ttBits_[i] << " VALUE:"<<bit ;
    }
  } else ttVec.clear();
  std::auto_ptr<L1GtTechnicalTriggerRecord> output(new L1GtTechnicalTriggerRecord());
  output->setGtTechnicalTrigger(ttVec);    
  iEvent.put(output);
}

Member Data Documentation

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

Definition at line 59 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

int BSCTrigger::nevt_ [private]

Definition at line 65 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

unsigned BSCTrigger::nEvt_ [private]

Definition at line 60 of file BSCTrigger.cc.

float BSCTrigger::theCoincidence_ [private]

Definition at line 61 of file BSCTrigger.cc.

Referenced by BSCTrigger(), and produce().

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().