CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ZHLTMatchFilter.cc
Go to the documentation of this file.
1 /* \class ZHLTFilter
2  *
3  * \author Pasquale Noli, Universita' di Napoli & INFN Napoli
4  *
5  */
15 #include <string>
16 using namespace std;
17 namespace modules {
18  struct ZHLTMatchFilter {
20  cond_(cfg.getParameter<std::string >("condition")),
21  hltPath_(cfg.getParameter<std::string >("hltPath")){ }
22  bool operator()(const reco::Candidate & z) const {
23  assert(z.numberOfDaughters()==2);
24  bool singleTrigFlag0 = false;
25  bool singleTrigFlag1 = false;
26  bool exactlyOneTriggerFlag = false;
27  bool bothTriggerFlag = false;
28  bool atLeastOneTriggerFlag=false;
29  bool FirstTriggerFlag = false;
30  bool globalisTriggerFlag =false;
31  if((((cond_ !="exactlyOneMatched" && cond_!="atLeastOneMatched") && cond_ !="bothMatched") && cond_ != "firstMatched") && cond_ != "globalisMatched")
33  << "Invalid condition type: " << cond_ << ". Valid types are:"
34  << " exactlyOneMatched, atLeastOneMatched, bothMatched, firstMatched,globalisMatched\n";
35  const reco::Candidate* dau0 = z.daughter(0);
36  const reco::Candidate * m0 = &*dau0->masterClone();
37  const pat::Muon * mu0 = dynamic_cast<const pat::Muon*>(m0);//cast in patMuon
38  bool firstismuon = (dau0->isGlobalMuon() ? true : false);
39  bool firstisStandAlone = (dau0->isStandAloneMuon() ? true : false);
40  bool firstisTrackerMuon = (dau0->isTrackerMuon() ? true : false);
41  if(mu0 != 0 && (firstismuon ||firstisStandAlone||firstisTrackerMuon )){
42  // get the vector of trigger objects matched to the muon corresponding to hltPath_
43  const pat::TriggerObjectStandAloneCollection mu0HLTMatches =
44  mu0->triggerObjectMatchesByPath( hltPath_ );
45 
46  int dimTrig0 = mu0HLTMatches.size();
47  if(dimTrig0 !=0 ){
48  singleTrigFlag0 = true;
49  }
50  }
51  const reco::Candidate* dau1 = z.daughter(1);
52  const reco::Candidate * m1 = &*dau1->masterClone();
53  bool secondismuon = (dau1->isGlobalMuon() ? true : false);
54  bool secondisStandAlone = (dau1->isStandAloneMuon() ? true : false);
55  bool secondisTrackerMuon = (dau1->isTrackerMuon() ? true : false);
56  const pat::Muon * mu1 = dynamic_cast<const pat::Muon*>(m1);
57  if(mu1 != 0 && (secondismuon ||secondisStandAlone||secondisTrackerMuon ) ){
58  // get the vector of trigger objects matched to the muon corresponding to hltPath_
59  const pat::TriggerObjectStandAloneCollection mu1HLTMatches =
60  mu1->triggerObjectMatchesByPath( hltPath_ );
61 
62  int dimTrig1 = mu1HLTMatches.size();
63  if(dimTrig1 !=0){
64  singleTrigFlag1 = true;
65  }
66  }
67  if(!singleTrigFlag0 && !singleTrigFlag1)return false;
68  if((singleTrigFlag0 && singleTrigFlag1) && firstismuon && secondismuon ) bothTriggerFlag = true;
69  if(((singleTrigFlag0 && !singleTrigFlag1) && firstismuon && secondismuon) || ((!singleTrigFlag0 && singleTrigFlag1) && firstismuon && secondismuon)) exactlyOneTriggerFlag = true;
70  if((((singleTrigFlag0 && firstismuon) && (secondisStandAlone || secondisTrackerMuon ) ) && !secondismuon ) || (((singleTrigFlag1 && secondismuon) && (firstisStandAlone|| firstisTrackerMuon) ) && !firstismuon))globalisTriggerFlag = true;
71 
72  if((singleTrigFlag0 && !singleTrigFlag1) && !secondismuon) FirstTriggerFlag = true;
73  if((singleTrigFlag0 || singleTrigFlag1) && firstismuon && secondismuon) atLeastOneTriggerFlag=true;
74  if(cond_=="exactlyOneMatched") return exactlyOneTriggerFlag;
75  if(cond_=="atLeastOneMatched") return atLeastOneTriggerFlag;
76  if(cond_=="bothMatched") return bothTriggerFlag;
77  if(cond_=="firstMatched") return FirstTriggerFlag;
78  if(cond_=="globalisMatched") return globalisTriggerFlag;
79 
80  return false;
81  }
82 
83  private:
86 
87  };
88 }
89 
90 typedef SingleObjectSelector<
94 
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
tuple cfg
Definition: looper.py:293
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
ZHLTMatchFilter(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
assert(m_qm.get())
SingleObjectSelector< edm::View< reco::Candidate >, modules::ZHLTMatchFilter > ZHLTMatchFilter
std::vector< TriggerObjectStandAlone > TriggerObjectStandAloneCollection
Collection of TriggerObjectStandAlone.
virtual size_type numberOfDaughters() const =0
number of daughters
virtual bool isStandAloneMuon() const =0
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const std::string &namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true) const
Definition: PATObject.h:610
bool operator()(const reco::Candidate &z) const
virtual bool isTrackerMuon() const =0
Analysis-level muon class.
Definition: Muon.h:49
virtual bool isGlobalMuon() const =0
virtual const CandidateBaseRef & masterClone() const =0