CMS 3D CMS Logo

Public Member Functions | Private Attributes

ZToMuMuSelector Class Reference

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

List of all members.

Public Member Functions

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

Private Attributes

double etaCut_
edm::InputTag isoTag_
edm::InputTag isoTrackerTag_
double massZMax_
double massZMin_
int minTrackerHits_
edm::InputTag muonTag_
bool onlyGlobalMuons_
double ptCut_
edm::InputTag trackerTag_

Detailed Description

Definition at line 9 of file ZToMuMuSelector.cc.


Constructor & Destructor Documentation

ZToMuMuSelector::ZToMuMuSelector ( const edm::ParameterSet cfg)

Definition at line 39 of file ZToMuMuSelector.cc.

                                                           :
      muonTag_(cfg.getParameter<edm::InputTag> ("MuonTag")),
      isoTag_(cfg.getParameter<edm::InputTag> ("IsolationTag")),
      ptCut_(cfg.getParameter<double>("PtCut")),
      etaCut_(cfg.getParameter<double>("EtaCut")),
      massZMin_(cfg.getParameter<double>("MassZMin")),
      massZMax_(cfg.getParameter<double>("MassZMax")),

      onlyGlobalMuons_(cfg.getParameter<bool>("OnlyGlobalMuons")),
      trackerTag_(cfg.getUntrackedParameter<edm::InputTag> ("TrackerTag",edm::InputTag("ctfWithMaterialTracks"))),
      isoTrackerTag_(cfg.getUntrackedParameter<edm::InputTag> ("TrackerIsolationTag",edm::InputTag("zMuMuTrackerIsolations"))),
      minTrackerHits_(cfg.getUntrackedParameter<int>("MinTrackerHits",7))
{
}

Member Function Documentation

bool ZToMuMuSelector::filter ( edm::Event ev,
const edm::EventSetup  
) [virtual]

Implements edm::EDFilter.

Definition at line 54 of file ZToMuMuSelector.cc.

References eta(), etaCut_, edm::Event::getByLabel(), i, isoTag_, isoTrackerTag_, edm::HandleBase::isValid(), j, LogTrace, massZMax_, massZMin_, minTrackerHits_, muonTag_, onlyGlobalMuons_, ptCut_, mathSSE::sqrt(), and trackerTag_.

                                                            {

      // Note:    try/catch sequences should disappear in the future
      //          GetByLabel will return a false bool value 
      //          if the collection is not present

      Handle<TrackCollection> muonCollection;

      ev.getByLabel(muonTag_, muonCollection);
      if (!muonCollection.isValid()) {
        LogTrace("") << ">>> Muon collection does not exist !!!";
        return false;
      }

      Handle<edm::ValueMap<bool> > isoMap;
      ev.getByLabel(isoTag_, isoMap);
      if (!isoMap.isValid()) {
        LogTrace("") << ">>> ISO Muon collection does not exist !!!";
        return false;
      }

      Handle<TrackCollection> trackerCollection;
      Handle<edm::ValueMap<bool> > isoTrackerMap;
      if (!onlyGlobalMuons_) {
        ev.getByLabel(trackerTag_, trackerCollection);
        if (!trackerCollection.isValid()) {
          LogTrace("") << ">>> Tracker collection does not exist !!!";
          return false;
        }
        
        ev.getByLabel(isoTrackerTag_, isoTrackerMap);
        if (!isoTrackerMap.isValid()) {
          LogTrace("") << ">>> ISO Tracker collection does not exist !!!";
          return false;
        }
      }

      unsigned int npairs = 0;
      bool globalCombinationFound = false;
      for (unsigned int i=0; i<muonCollection->size(); i++) {
            TrackRef mu(muonCollection,i);
            LogTrace("") << "> Processing muon number " << i << "...";
            double pt = mu->pt();
            LogTrace("") << "\t... pt= " << pt << " GeV";
            if (pt<ptCut_) continue;
            double eta = mu->eta();
            LogTrace("") << "\t... eta= " << eta;
            if (fabs(eta)>etaCut_) continue;
            bool iso = (*isoMap)[mu];
            LogTrace("") << "\t... isolated? " << iso;
            if (!iso) continue;

            for (unsigned int j=i+1; j<muonCollection->size(); j++) {
                  TrackRef mu2(muonCollection,j);
                  LogTrace("") << "> Processing second muon number " << j << "...";
                  double pt2 = mu2->pt();
                  LogTrace("") << "\t... pt2= " << pt2 << " GeV";
                  if (pt2<ptCut_) continue;
                  double eta2 = mu2->eta();
                  LogTrace("") << "\t... eta2= " << eta2;
                  if (fabs(eta2)>etaCut_) continue;
                  bool iso2 = (*isoMap)[mu2];
                  LogTrace("") << "\t... isolated2? " << iso2;
                  if (!iso2) continue;

                  double z_en = mu->p() + mu2->p();
                  double z_px = mu->px() + mu2->px();
                  double z_py = mu->py() + mu2->py();
                  double z_pz = mu->pz() + mu2->pz();
                  double massZ = z_en*z_en - z_px*z_px - z_py*z_py - z_pz*z_pz;
                  massZ = (massZ>0) ? sqrt(massZ) : 0;
                  LogTrace("") << "\t... Z_en, Z_px, Z_py, Z_pz= " << z_en << ", " << z_px << ", " << z_py << ", " << z_pz << " GeV";
                  LogTrace("") << "\t... (GM-GM) Invariant reconstructed mass= " << massZ << " GeV";
                  if (massZ<massZMin_) continue;
                  if (massZ>massZMax_) continue;
                  globalCombinationFound = true;
                  npairs++;
            }

            if (onlyGlobalMuons_ || globalCombinationFound) continue;

            for (unsigned int j=0; j<trackerCollection->size(); j++) {
                  TrackRef mu2(trackerCollection,j);
                  LogTrace("") << "> Processing track number " << j << "...";
                  double pt2 = mu2->pt();
                  LogTrace("") << "\t... pt3= " << pt2 << " GeV";
                  if (pt2<ptCut_) continue;
                  double eta2 = mu2->eta();
                  LogTrace("") << "\t... eta3= " << eta2;
                  if (fabs(eta2)>etaCut_) continue;
                  int nhits2 = mu2->numberOfValidHits();
                  LogTrace("") << "\t... nhits3= " << nhits2;
                  if (nhits2<minTrackerHits_) continue;
                  bool iso2 = (*isoTrackerMap)[mu2];
                  LogTrace("") << "\t... isolated3? " << iso2;
                  if (!iso2) continue;

                  double z_en = mu->p() + mu2->p();
                  double z_px = mu->px() + mu2->px();
                  double z_py = mu->py() + mu2->py();
                  double z_pz = mu->pz() + mu2->pz();
                  double massZ = z_en*z_en - z_px*z_px - z_py*z_py - z_pz*z_pz;
                  massZ = (massZ>0) ? sqrt(massZ) : 0;
                  LogTrace("") << "\t... Z_en, Z_px, Z_py, Z_pz= " << z_en << ", " << z_px << ", " << z_py << ", " << z_pz << " GeV";
                  LogTrace("") << "\t... (GM-TK) Invariant reconstructed mass= " << massZ << " GeV";
                  if (massZ<massZMin_) continue;
                  if (massZ>massZMax_) continue;
                  npairs++;
            }
      }

      LogTrace("") << "> Number of Z pairs found= " << npairs;
      if (npairs<1) {
            LogTrace("") << ">>>> Event REJECTED";
            return false;
      }
      LogTrace("") << ">>>> Event SELECTED!!!";

      return true;

}

Member Data Documentation

double ZToMuMuSelector::etaCut_ [private]

Definition at line 17 of file ZToMuMuSelector.cc.

Referenced by filter().

Definition at line 15 of file ZToMuMuSelector.cc.

Referenced by filter().

Definition at line 23 of file ZToMuMuSelector.cc.

Referenced by filter().

double ZToMuMuSelector::massZMax_ [private]

Definition at line 19 of file ZToMuMuSelector.cc.

Referenced by filter().

double ZToMuMuSelector::massZMin_ [private]

Definition at line 18 of file ZToMuMuSelector.cc.

Referenced by filter().

Definition at line 24 of file ZToMuMuSelector.cc.

Referenced by filter().

Definition at line 14 of file ZToMuMuSelector.cc.

Referenced by filter().

Definition at line 21 of file ZToMuMuSelector.cc.

Referenced by filter().

double ZToMuMuSelector::ptCut_ [private]

Definition at line 16 of file ZToMuMuSelector.cc.

Referenced by filter().

Definition at line 22 of file ZToMuMuSelector.cc.

Referenced by filter().