CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

HLTMuonL1Filter Class Reference

#include <HLTMuonL1Filter.h>

Inheritance diagram for HLTMuonL1Filter:
HLTFilter edm::EDFilter edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

virtual bool filter (edm::Event &, const edm::EventSetup &)
 HLTMuonL1Filter (const edm::ParameterSet &)
 ~HLTMuonL1Filter ()

Private Member Functions

bool isSingleSegmentCSC (const l1extra::L1MuonParticleRef &)
 checks if the passed L1MuExtraParticle is a single segment CSC

Private Attributes

edm::InputTag candTag_
 input tag identifying the product containing muons
edm::InputTag csctfTag_
 input tag identifying the product containing CSCTF tracks
edm::Handle< L1CSCTrackCollectioncsctfTracks_
 handle for CSCTFtracks
bool excludeSingleSegmentCSC_
 should we exclude single-segment CSC trigger objects from our counting?
const L1MuTriggerScalesl1MuTriggerScales_
 trigger scales
unsigned long long m_scalesCacheID_
 trigger scales cache ID
double maxEta_
 max Eta cut
int minN_
 required number of passing candidates to pass the filter
double minPt_
 pT threshold
edm::InputTag previousCandTag_
 input tag identifying the product containing refs to muons passing the previous level
int qualityBitMask_
bool saveTag_
 should we save the input collection?

Detailed Description

This class is an HLTFilter (-> EDFilter) implementing a filter on L1 GMT input

Author:
J. Alcaraz

See header file for documentation

Author:
J. Alcaraz

Definition at line 25 of file HLTMuonL1Filter.h.


Constructor & Destructor Documentation

HLTMuonL1Filter::HLTMuonL1Filter ( const edm::ParameterSet iConfig) [explicit]

Definition at line 26 of file HLTMuonL1Filter.cc.

References candTag_, edm::errors::Configuration, csctfTag_, edm::InputTag::encode(), Exception, excludeSingleSegmentCSC_, edm::ParameterSet::getParameter(), i, edm::isDebugEnabled(), LogDebug, maxEta_, minN_, minPt_, previousCandTag_, qualityBitMask_, and saveTag_.

                                                               :
  candTag_( iConfig.getParameter<edm::InputTag>("CandTag") ),
  previousCandTag_( iConfig.getParameter<edm::InputTag>("PreviousCandTag") ),
  maxEta_( iConfig.getParameter<double>("MaxEta") ),
  minPt_( iConfig.getParameter<double>("MinPt") ),
  minN_( iConfig.getParameter<int>("MinN") ),
  excludeSingleSegmentCSC_( iConfig.getParameter<bool>("ExcludeSingleSegmentCSC") ),
  csctfTag_( iConfig.getParameter<edm::InputTag>("CSCTFtag") ),
  l1MuTriggerScales_(0),
  m_scalesCacheID_(0),
  saveTag_( iConfig.getUntrackedParameter<bool>("SaveTag",false) ) 
{
  using namespace std;

  //set the quality bit mask
  qualityBitMask_ = 0;
  vector<int> selectQualities = iConfig.getParameter<vector<int> >("SelectQualities");
  for(size_t i=0; i<selectQualities.size(); i++){
    if(selectQualities[i] > 7){
      throw edm::Exception(edm::errors::Configuration) << "QualityBits must be smaller than 8!";
    }
    qualityBitMask_ |= 1<<selectQualities[i];
  }
 
  // dump parameters for debugging
  if(edm::isDebugEnabled()){
    ostringstream ss;
    ss<<"Constructed with parameters:"<<endl;
    ss<<"    CandTag = "<<candTag_.encode()<<endl;
    ss<<"    PreviousCandTag = "<<previousCandTag_.encode()<<endl;
    ss<<"    MaxEta = "<<maxEta_<<endl;
    ss<<"    MinPt = "<<minPt_<<endl;
    ss<<"    SelectQualities =";
    for(size_t i=0; i<8; i++){
      if((qualityBitMask_>>i) % 2) ss<<" "<<i;
    }
    ss<<endl;
    ss<<"    MinN = "<<minN_<<endl;
    ss<<"    ExcludeSingleSegmentCSC = "<<excludeSingleSegmentCSC_<<endl;
    ss<<"    CSCTFtag = "<<csctfTag_.encode()<<endl;
    ss<<"    SaveTag = "<<saveTag_;
    LogDebug("HLTMuonL1Filter")<<ss.str();
  }

  //register your products
  produces<trigger::TriggerFilterObjectWithRefs>();
}
HLTMuonL1Filter::~HLTMuonL1Filter ( )

Definition at line 74 of file HLTMuonL1Filter.cc.

{
}

Member Function Documentation

bool HLTMuonL1Filter::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements HLTFilter.

Definition at line 83 of file HLTMuonL1Filter.cc.

References accept(), allMuons_cfi::allMuons, edm::eventsetup::EventSetupRecord::cacheIdentifier(), candTag_, csctfTag_, csctfTracks_, excludeSingleSegmentCSC_, spr::find(), edm::EventSetup::get(), edm::Event::getByLabel(), i, edm::isDebugEnabled(), isSingleSegmentCSC(), l1MuTriggerScales_, LogDebug, m_scalesCacheID_, maxEta_, minN_, minPt_, module(), metsig::muon, n, path(), previousCandTag_, edm::ESHandle< T >::product(), edm::Event::put(), qualityBitMask_, saveTag_, and trigger::TriggerL1Mu.

                                                                         {
  using namespace std;
  using namespace edm;
  using namespace trigger;
  using namespace l1extra;

  // All HLT filters must create and fill an HLT filter object,
  // recording any reconstructed physics objects satisfying (or not)
  // this HLT filter, and place it in the Event.

  // The filter object
  auto_ptr<TriggerFilterObjectWithRefs> filterproduct(new TriggerFilterObjectWithRefs(path(), module()));

  // get hold of all muons
  Handle<L1MuonParticleCollection> allMuons;
  iEvent.getByLabel(candTag_, allMuons);

  // get hold of CSCTF raw tracks
  if( excludeSingleSegmentCSC_ ) {
    iEvent.getByLabel(csctfTag_, csctfTracks_);
    // update scales if necessary
    if( iSetup.get<L1MuTriggerScalesRcd>().cacheIdentifier() != m_scalesCacheID_ ){
      LogDebug("HLTMuonL1Filter")<<"Changing trigger scales";
      ESHandle<L1MuTriggerScales> scales;
      iSetup.get<L1MuTriggerScalesRcd>().get(scales);
      l1MuTriggerScales_ = scales.product();
      m_scalesCacheID_  = iSetup.get<L1MuTriggerScalesRcd>().cacheIdentifier();
    }
  }  

  // get hold of muons that fired the previous level
  Handle<TriggerFilterObjectWithRefs> previousLevelCands;
  iEvent.getByLabel(previousCandTag_, previousLevelCands);
  vector<L1MuonParticleRef> prevMuons;
  previousLevelCands->getObjects(TriggerL1Mu, prevMuons);
   
  // look at all muon candidates, check cuts and add to filter object
  int n = 0;
  for(size_t i = 0; i < allMuons->size(); i++){
    L1MuonParticleRef muon(allMuons, i);

    //check if triggered by the previous level
    if(find(prevMuons.begin(), prevMuons.end(), muon) == prevMuons.end()) continue;

    //check maxEta cut
    if(fabs(muon->eta()) > maxEta_) continue;

    //check pT cut
    if(muon->pt() < minPt_) continue;

    //check quality cut
    if(qualityBitMask_){
      int quality = muon->gmtMuonCand().empty() ? 0 : (1 << muon->gmtMuonCand().quality());
      if((quality & qualityBitMask_) == 0) continue;
    }

    // reject single-segment CSC objects if necessary
    if (excludeSingleSegmentCSC_ && isSingleSegmentCSC(muon)) continue;

    //we have a good candidate
    n++;
    filterproduct->addObject(TriggerL1Mu,muon);
  }

  if(saveTag_) filterproduct->addCollectionTag(candTag_);

  // filter decision
  const bool accept(n >= minN_);

  // dump event for debugging
  if(edm::isDebugEnabled()){
    ostringstream ss;
    ss.precision(2);
    ss<<"L1mu#"<<'\t'<<"q*pt"<<'\t'<<'\t'<<"eta"<<'\t'<<"phi"<<'\t'<<"quality"<<'\t'<<"isPrev"<<'\t'<<"isFired"<<'\t'<<"isSingleCSC"<<endl;
    ss<<"--------------------------------------------------------------------------"<<endl;

    vector<L1MuonParticleRef> firedMuons;
    filterproduct->getObjects(TriggerL1Mu, firedMuons);
    for(size_t i=0; i<allMuons->size(); i++){
      L1MuonParticleRef mu(allMuons, i);
      int quality = mu->gmtMuonCand().empty() ? 0 : mu->gmtMuonCand().quality();
      bool isPrev = find(prevMuons.begin(), prevMuons.end(), mu) != prevMuons.end();
      bool isFired = find(firedMuons.begin(), firedMuons.end(), mu) != firedMuons.end();
      bool isSingleCSC = excludeSingleSegmentCSC_ && isSingleSegmentCSC(mu);
      ss<<i<<'\t'<<scientific<<mu->charge()*mu->pt()<<'\t'<<fixed<<mu->eta()<<'\t'<<mu->phi()<<'\t'<<quality<<'\t'<<isPrev<<'\t'<<isFired<<'\t'<<isSingleCSC<<endl;
    }
    ss<<"--------------------------------------------------------------------------"<<endl;
    LogDebug("HLTMuonL1Filter")<<ss.str()<<"Decision of filter is "<<accept<<", number of muons passing = "<<filterproduct->l1muonSize();
  }

  // put filter object into the Event
  iEvent.put(filterproduct);

  return accept;
}
bool HLTMuonL1Filter::isSingleSegmentCSC ( const l1extra::L1MuonParticleRef muon) [private]

checks if the passed L1MuExtraParticle is a single segment CSC

Definition at line 179 of file HLTMuonL1Filter.cc.

References csctfTracks_, L1MuScale::getCenter(), L1MuScale::getLowEdge(), L1MuTriggerScales::getPhiScale(), L1MuTriggerScales::getRegionalEtaScale(), l1MuTriggerScales_, and Pi.

Referenced by filter().

                                                                             {
  // is the muon matching a csctf track?
  bool matched   = false;
  // which csctf track mode?
  // -999: no matching
  //  1: bad phi road. Not good extrapolation, but still triggering
  // 11: singles
  // 15: halo
  // 2->10 and 12->14: coincidence trigger with good extrapolation
  int csctfMode = -999;

  // loop over the CSCTF tracks
  for(L1CSCTrackCollection::const_iterator trk=csctfTracks_->begin(); trk<csctfTracks_->end(); trk++){
    
    int trEndcap = (trk->first.endcap()==2 ? trk->first.endcap()-3 : trk->first.endcap());
    int trSector = 6*(trk->first.endcap()-1)+trk->first.sector();

    //... in radians
    // Type 2 is CSC
    float trEtaScale = l1MuTriggerScales_->getRegionalEtaScale(2)->getCenter(trk->first.eta_packed());
    float trPhiScale = l1MuTriggerScales_->getPhiScale()->getLowEdge(trk->first.localPhi());

    double trEta = trEtaScale * trEndcap;
    // there is no L1ExtraParticle below -2.375
    if(trEta<-2.4) trEta=-2.375;

    // CSCTF has 6 sectors 
    // sector 1 starts at 15 degrees
    // trPhiScale is defined inside a sector 
    float trPhi02PI = fmod(trPhiScale + 
                           ((trSector-1)*TMath::Pi()/3) + 
                           (TMath::Pi()/12) , 2*TMath::Pi());

    // L1 information are given from [-Pi,Pi] 
    double trPhi = ( trPhi02PI<TMath::Pi()? trPhi02PI : trPhi02PI - 2*TMath::Pi() );
    /*    
    std::cout << "\ntrEndcap="               << trEndcap                << std::endl;
    std::cout << "trSector="                 << trSector                << std::endl;
    std::cout << "trk->first.eta_packed()="  << trk->first.eta_packed() << std::endl;
    std::cout << "trk->first.localPhi()="    << trk->first.localPhi()   << std::endl;
    std::cout << "trEtaScale=" << trEtaScale << std::endl;
    std::cout << "trPhiScale=" << trPhiScale << std::endl;
    std::cout << "trEta="      << trEta      << std::endl;
    std::cout << "trPhi="      << trPhi      << std::endl;
    */
    if ( fabs (trEta-muon->eta()) < 0.03 && 
         fabs (trPhi-muon->phi()) < 0.001  ) {
      
      matched = true;
      ptadd thePtAddress(trk->first.ptLUTAddress());    
      csctfMode = thePtAddress.track_mode;

      //std::cout << "is matched -> trMode=" << csctfMode << std::endl;
    }
  }

  /*
  std::cout << " ===================================== " << std::endl;
  std::cout << " is matched? " << matched                << std::endl;
  std::cout << " is singles? " << (csctfMode==11 ? 1 :0) << std::endl;
  std::cout << " ===================================== " << std::endl;
  */

  // singles are mode 11 "CSCTF tracks"
  return csctfMode==11;  
}

Member Data Documentation

input tag identifying the product containing muons

Definition at line 34 of file HLTMuonL1Filter.h.

Referenced by filter(), and HLTMuonL1Filter().

input tag identifying the product containing CSCTF tracks

Definition at line 75 of file HLTMuonL1Filter.h.

Referenced by filter(), and HLTMuonL1Filter().

handle for CSCTFtracks

Definition at line 78 of file HLTMuonL1Filter.h.

Referenced by filter(), and isSingleSegmentCSC().

should we exclude single-segment CSC trigger objects from our counting?

Definition at line 69 of file HLTMuonL1Filter.h.

Referenced by filter(), and HLTMuonL1Filter().

trigger scales

Definition at line 81 of file HLTMuonL1Filter.h.

Referenced by filter(), and isSingleSegmentCSC().

unsigned long long HLTMuonL1Filter::m_scalesCacheID_ [private]

trigger scales cache ID

Definition at line 84 of file HLTMuonL1Filter.h.

Referenced by filter().

double HLTMuonL1Filter::maxEta_ [private]

max Eta cut

Definition at line 40 of file HLTMuonL1Filter.h.

Referenced by filter(), and HLTMuonL1Filter().

int HLTMuonL1Filter::minN_ [private]

required number of passing candidates to pass the filter

Definition at line 66 of file HLTMuonL1Filter.h.

Referenced by filter(), and HLTMuonL1Filter().

double HLTMuonL1Filter::minPt_ [private]

pT threshold

Definition at line 43 of file HLTMuonL1Filter.h.

Referenced by filter(), and HLTMuonL1Filter().

input tag identifying the product containing refs to muons passing the previous level

Definition at line 37 of file HLTMuonL1Filter.h.

Referenced by filter(), and HLTMuonL1Filter().

Quality codes:

0 .. no muon 1 .. beam halo muon (CSC) 2 .. very low quality level 1 (e.g. ignore in single and di-muon trigger) 3 .. very low quality level 2 (e.g. ignore in single muon trigger use in di-muon trigger) 4 .. very low quality level 3 (e.g. ignore in di-muon trigger, use in single-muon trigger) 5 .. unmatched RPC 6 .. unmatched DT or CSC 7 .. matched DT-RPC or CSC-RPC

attention: try not to rely on quality codes in analysis: they may change again

Quality bit mask:

the eight lowest order or least significant bits correspond to the qulity codes above; if a bit is 1, that code is accepted, otherwise not; example: 11101000 accepts qualities 3, 5, 6, 7

Definition at line 63 of file HLTMuonL1Filter.h.

Referenced by filter(), and HLTMuonL1Filter().

bool HLTMuonL1Filter::saveTag_ [private]

should we save the input collection?

Definition at line 87 of file HLTMuonL1Filter.h.

Referenced by filter(), and HLTMuonL1Filter().