CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes

WZInterestingEventSelector Class Reference

Inheritance diagram for WZInterestingEventSelector:
edm::EDFilter edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Classes

struct  event

Public Member Functions

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

Private Member Functions

bool electronSelection (const GsfElectron *eleRef, math::XYZPoint bspotPosition)
virtual void endJob ()
virtual bool filter (edm::Event &, const edm::EventSetup &)

Private Attributes

float eb_ecalIsoCut_
float eb_hcalIsoCut_
float eb_hoeCut_
float eb_seeCut_
float eb_trIsoCut_
float ee_ecalIsoCut_
float ee_hcalIsoCut_
float ee_hoeCut_
float ee_seeCut_
float ee_trIsoCut_
edm::InputTag electronCollection_
float invMassCut_
float metCut_
int missHitCut_
edm::InputTag offlineBSCollection_
edm::InputTag pfMetCollection_
float ptCut_

Detailed Description

Definition at line 45 of file WZInterestingEventSelector.cc.


Constructor & Destructor Documentation

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

Definition at line 105 of file WZInterestingEventSelector.cc.

References edm::ParameterSet::getParameter(), and edm::ParameterSet::getUntrackedParameter().

{
  ptCut_   = iConfig.getParameter<double>("ptCut");
  missHitCut_ = iConfig.getParameter<int>("missHitsCut");
  
  eb_trIsoCut_   = iConfig.getParameter<double>("eb_trIsoCut");
  eb_ecalIsoCut_   = iConfig.getParameter<double>("eb_ecalIsoCut");
  eb_hcalIsoCut_   = iConfig.getParameter<double>("eb_hcalIsoCut");
  eb_hoeCut_   = iConfig.getParameter<double>("eb_hoeCut");
  eb_seeCut_   = iConfig.getParameter<double>("eb_seeCut");

  ee_trIsoCut_   = iConfig.getParameter<double>("ee_trIsoCut");
  ee_ecalIsoCut_   = iConfig.getParameter<double>("ee_ecalIsoCut");
  ee_hcalIsoCut_   = iConfig.getParameter<double>("ee_hcalIsoCut");
  ee_hoeCut_   = iConfig.getParameter<double>("ee_hoeCut");
  ee_seeCut_   = iConfig.getParameter<double>("ee_seeCut");
  
  metCut_ = iConfig.getParameter<double>("metCut");
  invMassCut_ = iConfig.getParameter<double>("invMassCut");

  electronCollection_ = iConfig.getUntrackedParameter<edm::InputTag>("electronCollection",edm::InputTag("gsfElectrons"));
  pfMetCollection_ = iConfig.getUntrackedParameter<edm::InputTag>("pfMetCollection",edm::InputTag("pfMet"));
  offlineBSCollection_ = iConfig.getUntrackedParameter<edm::InputTag>("offlineBSCollection",edm::InputTag("offlineBeamSpot"));
  
}
WZInterestingEventSelector::~WZInterestingEventSelector ( )

Definition at line 132 of file WZInterestingEventSelector.cc.

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

}

Member Function Documentation

bool WZInterestingEventSelector::electronSelection ( const GsfElectron eleRef,
math::XYZPoint  bspotPosition 
) [private]

Definition at line 182 of file WZInterestingEventSelector.cc.

References reco::GsfElectron::dr03EcalRecHitSumEt(), reco::GsfElectron::dr03HcalTowerSumEt(), reco::GsfElectron::dr03TkSumPt(), reco::GsfElectron::gsfTrack(), reco::GsfElectron::hcalOverEcal(), reco::GsfElectron::isEB(), reco::GsfElectron::isEE(), reco::LeafCandidate::pt(), and reco::GsfElectron::sigmaIetaIeta().

{


//   if (eleRef->trackerDrivenSeed() && !eleRef->ecalDrivenSeed()) 
//     return false;
  
//   if (eleRef->ecalDrivenSeed())
//     {

  if (eleRef->pt()<ptCut_) return false;

  if (eleRef->isEB())
    {
       if (eleRef->dr03TkSumPt()/eleRef->pt()>eb_trIsoCut_) return false;
       if (eleRef->dr03EcalRecHitSumEt()/eleRef->pt()>eb_ecalIsoCut_) return false;
       if (eleRef->dr03HcalTowerSumEt()/eleRef->pt()>eb_hcalIsoCut_) return false;
       if (eleRef->sigmaIetaIeta()>eb_seeCut_) return false;
       if (eleRef->hcalOverEcal()>eb_hoeCut_) return false;
    }
  else if (eleRef->isEE())
    {
      if (eleRef->dr03TkSumPt()/eleRef->pt()>ee_trIsoCut_) return false;
      if (eleRef->dr03EcalRecHitSumEt()/eleRef->pt()>ee_ecalIsoCut_) return false;
      if (eleRef->dr03HcalTowerSumEt()/eleRef->pt()>ee_hcalIsoCut_) return false;
      if (eleRef->sigmaIetaIeta()>ee_seeCut_) return false;
      if (eleRef->hcalOverEcal()>ee_hoeCut_) return false;
    }
  
  if (eleRef->gsfTrack()->trackerExpectedHitsInner().numberOfHits()>missHitCut_) return false;
  
  return true;
}
void WZInterestingEventSelector::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDFilter.

Definition at line 147 of file WZInterestingEventSelector.cc.

                                        { 

//   if (interestingEvents_.size()<1)
//     return;

//   std::ostringstream oss;
//   for (unsigned int iEvent=0;iEvent<interestingEvents_.size();++iEvent)
//     {
//       oss << "==================================" << std::endl;
//       oss << "Run: " << interestingEvents_[iEvent].run << " Event: " <<  interestingEvents_[iEvent].event << " LS: " <<  interestingEvents_[iEvent].ls << std::endl;
//       oss << "nGoodEle: " << interestingEvents_[iEvent].nEle << " maxPt " << interestingEvents_[iEvent].maxPt <<  " maxPtEta " << interestingEvents_[iEvent].maxPtEleEta << " maxPtPhi " << interestingEvents_[iEvent].maxPtElePhi << std::endl;
//       oss << "invMass " << interestingEvents_[iEvent].invMass << " met " << interestingEvents_[iEvent].met << " metPhi " << interestingEvents_[iEvent].metPhi << std::endl;
//     }
//   std::string mailText;
//   mailText = oss.str();

//   std::ofstream outputTxt;
//   outputTxt.open("interestingEvents.txt");
//   outputTxt << mailText;
//   outputTxt.close();

  //Sending email
//   std::ostringstream subject;
//   subject << "Interesting events in Run#" << interestingEvents_[0].run; 

//   std::ostringstream command;
//   command << "cat interestingEvents.txt | mail -s \"" << subject.str() << "\" Paolo.Meridiani@cern.ch";
  
//   std::string commandStr = command.str();
//   char* pch = (char*)malloc( sizeof( char ) *(commandStr.length() +1) );
//   string::traits_type::copy( pch, commandStr.c_str(), commandStr.length() +1 );
//   int i=system(pch);
  
}
bool WZInterestingEventSelector::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDFilter.

Definition at line 217 of file WZInterestingEventSelector.cc.

References reco::LeafCandidate::charge(), DeDxDiscriminatorTools::charge(), eta(), reco::LeafCandidate::eta(), edm::Event::eventAuxiliary(), edm::Event::getByLabel(), edm::Event::getLuminosityBlock(), ALCARECOEcalCalIsolElectron_cff::goodElectrons, gsfElectrons_cfi::gsfElectrons, edm::HandleBase::isValid(), python::pfMET_cfi::pfMET, reco::LeafCandidate::phi(), phi, reco::BeamSpot::position(), edm::Handle< T >::product(), reco::LeafCandidate::pt(), jptDQMConfig_cff::ptMax, and edm::Event::run().

{
  // using namespace edm;
  edm::Handle<reco::GsfElectronCollection> gsfElectrons;
  iEvent.getByLabel(electronCollection_,gsfElectrons);

//   edm::Handle<reco::CaloMETCollection> caloMET;
//   iEvent.getByLabel(edm::InputTag("met"), caloMET);  

  edm::Handle<reco::PFMETCollection> pfMET;
  iEvent.getByLabel(pfMetCollection_, pfMET);  

  edm::Handle<reco::BeamSpot> pBeamSpot;
  iEvent.getByLabel(offlineBSCollection_, pBeamSpot);

  const reco::BeamSpot *bspot = pBeamSpot.product();
  math::XYZPoint bspotPosition = bspot->position();

  std::vector<const GsfElectron*> goodElectrons;  
  float ptMax=-999.;
  const GsfElectron* ptMaxEle=0;
  for(reco::GsfElectronCollection::const_iterator myEle=gsfElectrons->begin();myEle!=gsfElectrons->end();++myEle)
    {
      //Apply a minimal isolated electron selection
      if (!electronSelection(&(*myEle),bspotPosition)) continue;
      goodElectrons.push_back(&(*myEle));
      if (myEle->pt() > ptMax )
        {
          ptMax =  myEle->pt();
          ptMaxEle = &(*myEle);
        }
    }

  event thisEvent;
  thisEvent.run=iEvent.run();
  thisEvent.event=iEvent.eventAuxiliary().event();
  thisEvent.ls=iEvent.getLuminosityBlock().luminosityBlock();
  thisEvent.nEle=goodElectrons.size();

  if (ptMaxEle)
    {
      thisEvent.maxPt=ptMax;
      thisEvent.maxPtEleEta=ptMaxEle->eta();
      thisEvent.maxPtElePhi=ptMaxEle->phi();

    }

  if (pfMET.isValid())
    {
      thisEvent.met=pfMET->begin()->et();
      thisEvent.metPhi=pfMET->begin()->phi();
    }


  float maxInv=-999.;
  TLorentzVector v1;
  if (ptMaxEle)
    v1.SetPtEtaPhiM(ptMaxEle->pt(),ptMaxEle->eta(),ptMaxEle->phi(),0);
  if (goodElectrons.size()>1)
    {
      for (unsigned int iEle=0; iEle<goodElectrons.size(); ++iEle)
        if (goodElectrons[iEle]!=ptMaxEle && (goodElectrons[iEle]->charge() * ptMaxEle->charge() == -1) )
          {
            TLorentzVector v2;
            v2.SetPtEtaPhiM(goodElectrons[iEle]->pt(),goodElectrons[iEle]->eta(),goodElectrons[iEle]->phi(),0.);
            if ( (v1+v2).M() > maxInv )
              maxInv = (v1+v2).M();
          }
    }

  if (maxInv > invMassCut_)
    thisEvent.invMass = maxInv;

  //Z filt: Retain event if more then 1 good ele and invMass above threshold (zee)
  if (goodElectrons.size()>1 && maxInv > invMassCut_)
    {
      //interestingEvents_.push_back(thisEvent);
      return true;
    }

  //W filt: Retain event also event with at least 1 good ele and some met
  if (goodElectrons.size()>=1 &&  (pfMET->begin()->et()>metCut_))
    {
      //interestingEvents_.push_back(thisEvent);
      return true;
    }
  
  return false;
}

Member Data Documentation

Definition at line 78 of file WZInterestingEventSelector.cc.

Definition at line 79 of file WZInterestingEventSelector.cc.

Definition at line 80 of file WZInterestingEventSelector.cc.

Definition at line 81 of file WZInterestingEventSelector.cc.

Definition at line 77 of file WZInterestingEventSelector.cc.

Definition at line 85 of file WZInterestingEventSelector.cc.

Definition at line 86 of file WZInterestingEventSelector.cc.

Definition at line 87 of file WZInterestingEventSelector.cc.

Definition at line 88 of file WZInterestingEventSelector.cc.

Definition at line 84 of file WZInterestingEventSelector.cc.

Definition at line 96 of file WZInterestingEventSelector.cc.

Definition at line 94 of file WZInterestingEventSelector.cc.

Definition at line 91 of file WZInterestingEventSelector.cc.

Definition at line 74 of file WZInterestingEventSelector.cc.

Definition at line 98 of file WZInterestingEventSelector.cc.

Definition at line 97 of file WZInterestingEventSelector.cc.

Definition at line 73 of file WZInterestingEventSelector.cc.